UNPKG

iota-sig-utils

Version:

A collection of signature, secure utilities for crypto networks in IOTA

1 lines 198 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["iota-sig-utils"]=e():t["iota-sig-utils"]=e()}(this,(()=>(()=>{var t={574:(t,e,i)=>{var s;t=i.nmd(t);var n=function(t){"use strict";var e=1e7,i=7,s=9007199254740992,r=m(s),a="0123456789abcdefghijklmnopqrstuvwxyz",h="function"==typeof BigInt;function o(t,e,i,s){return void 0===t?o[0]:void 0===e||10==+e&&!i?V(t):j(t,e,i,s)}function d(t,e){this.value=t,this.sign=e,this.isSmall=!1}function u(t){this.value=t,this.sign=t<0,this.isSmall=!0}function l(t){this.value=t}function w(t){return-s<t&&t<s}function m(t){return t<1e7?[t]:t<1e14?[t%1e7,Math.floor(t/1e7)]:[t%1e7,Math.floor(t/1e7)%1e7,Math.floor(t/1e14)]}function f(t){c(t);var i=t.length;if(i<4&&T(t,r)<0)switch(i){case 0:return 0;case 1:return t[0];case 2:return t[0]+t[1]*e;default:return t[0]+(t[1]+t[2]*e)*e}return t}function c(t){for(var e=t.length;0===t[--e];);t.length=e+1}function p(t){for(var e=new Array(t),i=-1;++i<t;)e[i]=0;return e}function g(t){return t>0?Math.floor(t):Math.ceil(t)}function y(t,i){var s,n,r=t.length,a=i.length,h=new Array(r),o=0,d=e;for(n=0;n<a;n++)o=(s=t[n]+i[n]+o)>=d?1:0,h[n]=s-o*d;for(;n<r;)o=(s=t[n]+o)===d?1:0,h[n++]=s-o*d;return o>0&&h.push(o),h}function b(t,e){return t.length>=e.length?y(t,e):y(e,t)}function v(t,i){var s,n,r=t.length,a=new Array(r),h=e;for(n=0;n<r;n++)s=t[n]-h+i,i=Math.floor(s/h),a[n]=s-i*h,i+=1;for(;i>0;)a[n++]=i%h,i=Math.floor(i/h);return a}function _(t,i){var s,n,r=t.length,a=i.length,h=new Array(r),o=0,d=e;for(s=0;s<a;s++)(n=t[s]-o-i[s])<0?(n+=d,o=1):o=0,h[s]=n;for(s=a;s<r;s++){if(!((n=t[s]-o)<0)){h[s++]=n;break}n+=d,h[s]=n}for(;s<r;s++)h[s]=t[s];return c(h),h}function R(t,i,s){var n,r,a=t.length,h=new Array(a),o=-i,l=e;for(n=0;n<a;n++)r=t[n]+o,o=Math.floor(r/l),r%=l,h[n]=r<0?r+l:r;return"number"==typeof(h=f(h))?(s&&(h=-h),new u(h)):new d(h,s)}function E(t,i){var s,n,r,a,h=t.length,o=i.length,d=p(h+o),u=e;for(r=0;r<h;++r){a=t[r];for(var l=0;l<o;++l)s=a*i[l]+d[r+l],n=Math.floor(s/u),d[r+l]=s-n*u,d[r+l+1]+=n}return c(d),d}function S(t,i){var s,n,r=t.length,a=new Array(r),h=e,o=0;for(n=0;n<r;n++)s=t[n]*i+o,o=Math.floor(s/h),a[n]=s-o*h;for(;o>0;)a[n++]=o%h,o=Math.floor(o/h);return a}function L(t,e){for(var i=[];e-- >0;)i.push(0);return i.concat(t)}function A(t,e){var i=Math.max(t.length,e.length);if(i<=30)return E(t,e);i=Math.ceil(i/2);var s=t.slice(i),n=t.slice(0,i),r=e.slice(i),a=e.slice(0,i),h=A(n,a),o=A(s,r),d=A(b(n,s),b(a,r)),u=b(b(h,L(_(_(d,h),o),i)),L(o,2*i));return c(u),u}function x(t,i,s){return new d(t<e?S(i,t):E(i,m(t)),s)}function k(t){var i,s,n,r,a=t.length,h=p(a+a),o=e;for(n=0;n<a;n++){s=0-(r=t[n])*r;for(var d=n;d<a;d++)i=r*t[d]*2+h[n+d]+s,s=Math.floor(i/o),h[n+d]=i-s*o;h[n+a]=s}return c(h),h}function I(t,i){var s,n,r,a,h=t.length,o=p(h),d=e;for(r=0,s=h-1;s>=0;--s)r=(a=r*d+t[s])-(n=g(a/i))*i,o[s]=0|n;return[o,0|r]}function N(t,i){var s,n=V(i);if(h)return[new l(t.value/n.value),new l(t.value%n.value)];var r,a=t.value,w=n.value;if(0===w)throw new Error("Cannot divide by zero");if(t.isSmall)return n.isSmall?[new u(g(a/w)),new u(a%w)]:[o[0],t];if(n.isSmall){if(1===w)return[t,o[0]];if(-1==w)return[t.negate(),o[0]];var y=Math.abs(w);if(y<e){r=f((s=I(a,y))[0]);var b=s[1];return t.sign&&(b=-b),"number"==typeof r?(t.sign!==n.sign&&(r=-r),[new u(r),new u(b)]):[new d(r,t.sign!==n.sign),new u(b)]}w=m(y)}var v=T(a,w);if(-1===v)return[o[0],t];if(0===v)return[o[t.sign===n.sign?1:-1],o[0]];s=a.length+w.length<=200?function(t,i){var s,n,r,a,h,o,d,u=t.length,l=i.length,w=e,m=p(i.length),c=i[l-1],g=Math.ceil(w/(2*c)),y=S(t,g),b=S(i,g);for(y.length<=u&&y.push(0),b.push(0),c=b[l-1],n=u-l;n>=0;n--){for(s=w-1,y[n+l]!==c&&(s=Math.floor((y[n+l]*w+y[n+l-1])/c)),r=0,a=0,o=b.length,h=0;h<o;h++)r+=s*b[h],d=Math.floor(r/w),a+=y[n+h]-(r-d*w),r=d,a<0?(y[n+h]=a+w,a=-1):(y[n+h]=a,a=0);for(;0!==a;){for(s-=1,r=0,h=0;h<o;h++)(r+=y[n+h]-w+b[h])<0?(y[n+h]=r+w,r=0):(y[n+h]=r,r=1);a+=r}m[n]=s}return y=I(y,g)[0],[f(m),f(y)]}(a,w):function(t,i){for(var s,n,r,a,h,o=t.length,d=i.length,u=[],l=[],w=e;o;)if(l.unshift(t[--o]),c(l),T(l,i)<0)u.push(0);else{r=l[(n=l.length)-1]*w+l[n-2],a=i[d-1]*w+i[d-2],n>d&&(r=(r+1)*w),s=Math.ceil(r/a);do{if(T(h=S(i,s),l)<=0)break;s--}while(s);u.push(s),l=_(l,h)}return u.reverse(),[f(u),f(l)]}(a,w),r=s[0];var R=t.sign!==n.sign,E=s[1],L=t.sign;return"number"==typeof r?(R&&(r=-r),r=new u(r)):r=new d(r,R),"number"==typeof E?(L&&(E=-E),E=new u(E)):E=new d(E,L),[r,E]}function T(t,e){if(t.length!==e.length)return t.length>e.length?1:-1;for(var i=t.length-1;i>=0;i--)if(t[i]!==e[i])return t[i]>e[i]?1:-1;return 0}function M(t){var e=t.abs();return!e.isUnit()&&(!!(e.equals(2)||e.equals(3)||e.equals(5))||!(e.isEven()||e.isDivisibleBy(3)||e.isDivisibleBy(5))&&(!!e.lesser(49)||void 0))}function B(t,e){for(var i,s,r,a=t.prev(),h=a,o=0;h.isEven();)h=h.divide(2),o++;t:for(s=0;s<e.length;s++)if(!t.lesser(e[s])&&!(r=n(e[s]).modPow(h,t)).isUnit()&&!r.equals(a)){for(i=o-1;0!=i;i--){if((r=r.square().mod(t)).isUnit())return!1;if(r.equals(a))continue t}return!1}return!0}d.prototype=Object.create(o.prototype),u.prototype=Object.create(o.prototype),l.prototype=Object.create(o.prototype),d.prototype.add=function(t){var e=V(t);if(this.sign!==e.sign)return this.subtract(e.negate());var i=this.value,s=e.value;return e.isSmall?new d(v(i,Math.abs(s)),this.sign):new d(b(i,s),this.sign)},d.prototype.plus=d.prototype.add,u.prototype.add=function(t){var e=V(t),i=this.value;if(i<0!==e.sign)return this.subtract(e.negate());var s=e.value;if(e.isSmall){if(w(i+s))return new u(i+s);s=m(Math.abs(s))}return new d(v(s,Math.abs(i)),i<0)},u.prototype.plus=u.prototype.add,l.prototype.add=function(t){return new l(this.value+V(t).value)},l.prototype.plus=l.prototype.add,d.prototype.subtract=function(t){var e=V(t);if(this.sign!==e.sign)return this.add(e.negate());var i=this.value,s=e.value;return e.isSmall?R(i,Math.abs(s),this.sign):function(t,e,i){var s;return T(t,e)>=0?s=_(t,e):(s=_(e,t),i=!i),"number"==typeof(s=f(s))?(i&&(s=-s),new u(s)):new d(s,i)}(i,s,this.sign)},d.prototype.minus=d.prototype.subtract,u.prototype.subtract=function(t){var e=V(t),i=this.value;if(i<0!==e.sign)return this.add(e.negate());var s=e.value;return e.isSmall?new u(i-s):R(s,Math.abs(i),i>=0)},u.prototype.minus=u.prototype.subtract,l.prototype.subtract=function(t){return new l(this.value-V(t).value)},l.prototype.minus=l.prototype.subtract,d.prototype.negate=function(){return new d(this.value,!this.sign)},u.prototype.negate=function(){var t=this.sign,e=new u(-this.value);return e.sign=!t,e},l.prototype.negate=function(){return new l(-this.value)},d.prototype.abs=function(){return new d(this.value,!1)},u.prototype.abs=function(){return new u(Math.abs(this.value))},l.prototype.abs=function(){return new l(this.value>=0?this.value:-this.value)},d.prototype.multiply=function(t){var i,s,n,r=V(t),a=this.value,h=r.value,u=this.sign!==r.sign;if(r.isSmall){if(0===h)return o[0];if(1===h)return this;if(-1===h)return this.negate();if((i=Math.abs(h))<e)return new d(S(a,i),u);h=m(i)}return new d(-.012*(s=a.length)-.012*(n=h.length)+15e-6*s*n>0?A(a,h):E(a,h),u)},d.prototype.times=d.prototype.multiply,u.prototype._multiplyBySmall=function(t){return w(t.value*this.value)?new u(t.value*this.value):x(Math.abs(t.value),m(Math.abs(this.value)),this.sign!==t.sign)},d.prototype._multiplyBySmall=function(t){return 0===t.value?o[0]:1===t.value?this:-1===t.value?this.negate():x(Math.abs(t.value),this.value,this.sign!==t.sign)},u.prototype.multiply=function(t){return V(t)._multiplyBySmall(this)},u.prototype.times=u.prototype.multiply,l.prototype.multiply=function(t){return new l(this.value*V(t).value)},l.prototype.times=l.prototype.multiply,d.prototype.square=function(){return new d(k(this.value),!1)},u.prototype.square=function(){var t=this.value*this.value;return w(t)?new u(t):new d(k(m(Math.abs(this.value))),!1)},l.prototype.square=function(t){return new l(this.value*this.value)},d.prototype.divmod=function(t){var e=N(this,t);return{quotient:e[0],remainder:e[1]}},l.prototype.divmod=u.prototype.divmod=d.prototype.divmod,d.prototype.divide=function(t){return N(this,t)[0]},l.prototype.over=l.prototype.divide=function(t){return new l(this.value/V(t).value)},u.prototype.over=u.prototype.divide=d.prototype.over=d.prototype.divide,d.prototype.mod=function(t){return N(this,t)[1]},l.prototype.mod=l.prototype.remainder=function(t){return new l(this.value%V(t).value)},u.prototype.remainder=u.prototype.mod=d.prototype.remainder=d.prototype.mod,d.prototype.pow=function(t){var e,i,s,n=V(t),r=this.value,a=n.value;if(0===a)return o[1];if(0===r)return o[0];if(1===r)return o[1];if(-1===r)return n.isEven()?o[1]:o[-1];if(n.sign)return o[0];if(!n.isSmall)throw new Error("The exponent "+n.toString()+" is too large.");if(this.isSmall&&w(e=Math.pow(r,a)))return new u(g(e));for(i=this,s=o[1];!0&a&&(s=s.times(i),--a),0!==a;)a/=2,i=i.square();return s},u.prototype.pow=d.prototype.pow,l.prototype.pow=function(t){var e=V(t),i=this.value,s=e.value,n=BigInt(0),r=BigInt(1),a=BigInt(2);if(s===n)return o[1];if(i===n)return o[0];if(i===r)return o[1];if(i===BigInt(-1))return e.isEven()?o[1]:o[-1];if(e.isNegative())return new l(n);for(var h=this,d=o[1];(s&r)===r&&(d=d.times(h),--s),s!==n;)s/=a,h=h.square();return d},d.prototype.modPow=function(t,e){if(t=V(t),(e=V(e)).isZero())throw new Error("Cannot take modPow with modulus 0");var i=o[1],s=this.mod(e);for(t.isNegative()&&(t=t.multiply(o[-1]),s=s.modInv(e));t.isPositive();){if(s.isZero())return o[0];t.isOdd()&&(i=i.multiply(s).mod(e)),t=t.divide(2),s=s.square().mod(e)}return i},l.prototype.modPow=u.prototype.modPow=d.prototype.modPow,d.prototype.compareAbs=function(t){var e=V(t),i=this.value,s=e.value;return e.isSmall?1:T(i,s)},u.prototype.compareAbs=function(t){var e=V(t),i=Math.abs(this.value),s=e.value;return e.isSmall?i===(s=Math.abs(s))?0:i>s?1:-1:-1},l.prototype.compareAbs=function(t){var e=this.value,i=V(t).value;return(e=e>=0?e:-e)===(i=i>=0?i:-i)?0:e>i?1:-1},d.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=V(t),i=this.value,s=e.value;return this.sign!==e.sign?e.sign?1:-1:e.isSmall?this.sign?-1:1:T(i,s)*(this.sign?-1:1)},d.prototype.compareTo=d.prototype.compare,u.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=V(t),i=this.value,s=e.value;return e.isSmall?i==s?0:i>s?1:-1:i<0!==e.sign?i<0?-1:1:i<0?1:-1},u.prototype.compareTo=u.prototype.compare,l.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=this.value,i=V(t).value;return e===i?0:e>i?1:-1},l.prototype.compareTo=l.prototype.compare,d.prototype.equals=function(t){return 0===this.compare(t)},l.prototype.eq=l.prototype.equals=u.prototype.eq=u.prototype.equals=d.prototype.eq=d.prototype.equals,d.prototype.notEquals=function(t){return 0!==this.compare(t)},l.prototype.neq=l.prototype.notEquals=u.prototype.neq=u.prototype.notEquals=d.prototype.neq=d.prototype.notEquals,d.prototype.greater=function(t){return this.compare(t)>0},l.prototype.gt=l.prototype.greater=u.prototype.gt=u.prototype.greater=d.prototype.gt=d.prototype.greater,d.prototype.lesser=function(t){return this.compare(t)<0},l.prototype.lt=l.prototype.lesser=u.prototype.lt=u.prototype.lesser=d.prototype.lt=d.prototype.lesser,d.prototype.greaterOrEquals=function(t){return this.compare(t)>=0},l.prototype.geq=l.prototype.greaterOrEquals=u.prototype.geq=u.prototype.greaterOrEquals=d.prototype.geq=d.prototype.greaterOrEquals,d.prototype.lesserOrEquals=function(t){return this.compare(t)<=0},l.prototype.leq=l.prototype.lesserOrEquals=u.prototype.leq=u.prototype.lesserOrEquals=d.prototype.leq=d.prototype.lesserOrEquals,d.prototype.isEven=function(){return 0==(1&this.value[0])},u.prototype.isEven=function(){return 0==(1&this.value)},l.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},d.prototype.isOdd=function(){return 1==(1&this.value[0])},u.prototype.isOdd=function(){return 1==(1&this.value)},l.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},d.prototype.isPositive=function(){return!this.sign},u.prototype.isPositive=function(){return this.value>0},l.prototype.isPositive=u.prototype.isPositive,d.prototype.isNegative=function(){return this.sign},u.prototype.isNegative=function(){return this.value<0},l.prototype.isNegative=u.prototype.isNegative,d.prototype.isUnit=function(){return!1},u.prototype.isUnit=function(){return 1===Math.abs(this.value)},l.prototype.isUnit=function(){return this.abs().value===BigInt(1)},d.prototype.isZero=function(){return!1},u.prototype.isZero=function(){return 0===this.value},l.prototype.isZero=function(){return this.value===BigInt(0)},d.prototype.isDivisibleBy=function(t){var e=V(t);return!e.isZero()&&(!!e.isUnit()||(0===e.compareAbs(2)?this.isEven():this.mod(e).isZero()))},l.prototype.isDivisibleBy=u.prototype.isDivisibleBy=d.prototype.isDivisibleBy,d.prototype.isPrime=function(e){var i=M(this);if(i!==t)return i;var s=this.abs(),r=s.bitLength();if(r<=64)return B(s,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var a=Math.log(2)*r.toJSNumber(),h=Math.ceil(!0===e?2*Math.pow(a,2):a),o=[],d=0;d<h;d++)o.push(n(d+2));return B(s,o)},l.prototype.isPrime=u.prototype.isPrime=d.prototype.isPrime,d.prototype.isProbablePrime=function(e,i){var s=M(this);if(s!==t)return s;for(var r=this.abs(),a=e===t?5:e,h=[],o=0;o<a;o++)h.push(n.randBetween(2,r.minus(2),i));return B(r,h)},l.prototype.isProbablePrime=u.prototype.isProbablePrime=d.prototype.isProbablePrime,d.prototype.modInv=function(t){for(var e,i,s,r=n.zero,a=n.one,h=V(t),o=this.abs();!o.isZero();)e=h.divide(o),i=r,s=h,r=a,h=o,a=i.subtract(e.multiply(a)),o=s.subtract(e.multiply(o));if(!h.isUnit())throw new Error(this.toString()+" and "+t.toString()+" are not co-prime");return-1===r.compare(0)&&(r=r.add(t)),this.isNegative()?r.negate():r},l.prototype.modInv=u.prototype.modInv=d.prototype.modInv,d.prototype.next=function(){var t=this.value;return this.sign?R(t,1,this.sign):new d(v(t,1),this.sign)},u.prototype.next=function(){var t=this.value;return t+1<s?new u(t+1):new d(r,!1)},l.prototype.next=function(){return new l(this.value+BigInt(1))},d.prototype.prev=function(){var t=this.value;return this.sign?new d(v(t,1),!0):R(t,1,this.sign)},u.prototype.prev=function(){var t=this.value;return t-1>-s?new u(t-1):new d(r,!0)},l.prototype.prev=function(){return new l(this.value-BigInt(1))};for(var O=[1];2*O[O.length-1]<=e;)O.push(2*O[O.length-1]);var q=O.length,Z=O[q-1];function P(t){return Math.abs(t)<=e}function U(t,e,i){e=V(e);for(var s=t.isNegative(),r=e.isNegative(),a=s?t.not():t,h=r?e.not():e,o=0,d=0,u=null,l=null,w=[];!a.isZero()||!h.isZero();)o=(u=N(a,Z))[1].toJSNumber(),s&&(o=Z-1-o),d=(l=N(h,Z))[1].toJSNumber(),r&&(d=Z-1-d),a=u[0],h=l[0],w.push(i(o,d));for(var m=0!==i(s?1:0,r?1:0)?n(-1):n(0),f=w.length-1;f>=0;f-=1)m=m.multiply(Z).add(n(w[f]));return m}d.prototype.shiftLeft=function(t){var e=V(t).toJSNumber();if(!P(e))throw new Error(String(e)+" is too large for shifting.");if(e<0)return this.shiftRight(-e);var i=this;if(i.isZero())return i;for(;e>=q;)i=i.multiply(Z),e-=q-1;return i.multiply(O[e])},l.prototype.shiftLeft=u.prototype.shiftLeft=d.prototype.shiftLeft,d.prototype.shiftRight=function(t){var e,i=V(t).toJSNumber();if(!P(i))throw new Error(String(i)+" is too large for shifting.");if(i<0)return this.shiftLeft(-i);for(var s=this;i>=q;){if(s.isZero()||s.isNegative()&&s.isUnit())return s;s=(e=N(s,Z))[1].isNegative()?e[0].prev():e[0],i-=q-1}return(e=N(s,O[i]))[1].isNegative()?e[0].prev():e[0]},l.prototype.shiftRight=u.prototype.shiftRight=d.prototype.shiftRight,d.prototype.not=function(){return this.negate().prev()},l.prototype.not=u.prototype.not=d.prototype.not,d.prototype.and=function(t){return U(this,t,(function(t,e){return t&e}))},l.prototype.and=u.prototype.and=d.prototype.and,d.prototype.or=function(t){return U(this,t,(function(t,e){return t|e}))},l.prototype.or=u.prototype.or=d.prototype.or,d.prototype.xor=function(t){return U(this,t,(function(t,e){return t^e}))},l.prototype.xor=u.prototype.xor=d.prototype.xor;var X=1<<30,K=(e&-e)*(e&-e)|X;function J(t){var i=t.value,s="number"==typeof i?i|X:"bigint"==typeof i?i|BigInt(X):i[0]+i[1]*e|K;return s&-s}function C(t,e){if(e.compareTo(t)<=0){var i=C(t,e.square(e)),s=i.p,r=i.e,a=s.multiply(e);return a.compareTo(t)<=0?{p:a,e:2*r+1}:{p:s,e:2*r}}return{p:n(1),e:0}}function z(t,e){return t=V(t),e=V(e),t.greater(e)?t:e}function H(t,e){return t=V(t),e=V(e),t.lesser(e)?t:e}function Y(t,e){if(t=V(t).abs(),e=V(e).abs(),t.equals(e))return t;if(t.isZero())return e;if(e.isZero())return t;for(var i,s,n=o[1];t.isEven()&&e.isEven();)i=H(J(t),J(e)),t=t.divide(i),e=e.divide(i),n=n.multiply(i);for(;t.isEven();)t=t.divide(J(t));do{for(;e.isEven();)e=e.divide(J(e));t.greater(e)&&(s=e,e=t,t=s),e=e.subtract(t)}while(!e.isZero());return n.isUnit()?t:t.multiply(n)}d.prototype.bitLength=function(){var t=this;return t.compareTo(n(0))<0&&(t=t.negate().subtract(n(1))),0===t.compareTo(n(0))?n(0):n(C(t,n(2)).e).add(n(1))},l.prototype.bitLength=u.prototype.bitLength=d.prototype.bitLength;var j=function(t,e,i,s){i=i||a,t=String(t),s||(t=t.toLowerCase(),i=i.toLowerCase());var n,r=t.length,h=Math.abs(e),o={};for(n=0;n<i.length;n++)o[i[n]]=n;for(n=0;n<r;n++)if("-"!==(l=t[n])&&l in o&&o[l]>=h){if("1"===l&&1===h)continue;throw new Error(l+" is not a valid digit in base "+e+".")}e=V(e);var d=[],u="-"===t[0];for(n=u?1:0;n<t.length;n++){var l;if((l=t[n])in o)d.push(V(o[l]));else{if("<"!==l)throw new Error(l+" is not a valid character");var w=n;do{n++}while(">"!==t[n]&&n<t.length);d.push(V(t.slice(w+1,n)))}}return G(d,e,u)};function G(t,e,i){var s,n=o[0],r=o[1];for(s=t.length-1;s>=0;s--)n=n.add(t[s].times(r)),r=r.times(e);return i?n.negate():n}function D(t,e){if((e=n(e)).isZero()){if(t.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(e.equals(-1)){if(t.isZero())return{value:[0],isNegative:!1};if(t.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-t.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var i=Array.apply(null,Array(t.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return i.unshift([1]),{value:[].concat.apply([],i),isNegative:!1}}var s=!1;if(t.isNegative()&&e.isPositive()&&(s=!0,t=t.abs()),e.isUnit())return t.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(t.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:s};for(var r,a=[],h=t;h.isNegative()||h.compareAbs(e)>=0;){r=h.divmod(e),h=r.quotient;var o=r.remainder;o.isNegative()&&(o=e.minus(o).abs(),h=h.next()),a.push(o.toJSNumber())}return a.push(h.toJSNumber()),{value:a.reverse(),isNegative:s}}function $(t,e,i){var s=D(t,e);return(s.isNegative?"-":"")+s.value.map((function(t){return function(t,e){return t<(e=e||a).length?e[t]:"<"+t+">"}(t,i)})).join("")}function F(t){if(w(+t)){var e=+t;if(e===g(e))return h?new l(BigInt(e)):new u(e);throw new Error("Invalid integer: "+t)}var s="-"===t[0];s&&(t=t.slice(1));var n=t.split(/e/i);if(n.length>2)throw new Error("Invalid integer: "+n.join("e"));if(2===n.length){var r=n[1];if("+"===r[0]&&(r=r.slice(1)),(r=+r)!==g(r)||!w(r))throw new Error("Invalid integer: "+r+" is not a valid exponent.");var a=n[0],o=a.indexOf(".");if(o>=0&&(r-=a.length-o-1,a=a.slice(0,o)+a.slice(o+1)),r<0)throw new Error("Cannot include negative exponent part for integers");t=a+=new Array(r+1).join("0")}if(!/^([0-9][0-9]*)$/.test(t))throw new Error("Invalid integer: "+t);if(h)return new l(BigInt(s?"-"+t:t));for(var m=[],f=t.length,p=i,y=f-p;f>0;)m.push(+t.slice(y,f)),(y-=p)<0&&(y=0),f-=p;return c(m),new d(m,s)}function V(t){return"number"==typeof t?function(t){if(h)return new l(BigInt(t));if(w(t)){if(t!==g(t))throw new Error(t+" is not an integer.");return new u(t)}return F(t.toString())}(t):"string"==typeof t?F(t):"bigint"==typeof t?new l(t):t}d.prototype.toArray=function(t){return D(this,t)},u.prototype.toArray=function(t){return D(this,t)},l.prototype.toArray=function(t){return D(this,t)},d.prototype.toString=function(e,i){if(e===t&&(e=10),10!==e)return $(this,e,i);for(var s,n=this.value,r=n.length,a=String(n[--r]);--r>=0;)s=String(n[r]),a+="0000000".slice(s.length)+s;return(this.sign?"-":"")+a},u.prototype.toString=function(e,i){return e===t&&(e=10),10!=e?$(this,e,i):String(this.value)},l.prototype.toString=u.prototype.toString,l.prototype.toJSON=d.prototype.toJSON=u.prototype.toJSON=function(){return this.toString()},d.prototype.valueOf=function(){return parseInt(this.toString(),10)},d.prototype.toJSNumber=d.prototype.valueOf,u.prototype.valueOf=function(){return this.value},u.prototype.toJSNumber=u.prototype.valueOf,l.prototype.valueOf=l.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};for(var W=0;W<1e3;W++)o[W]=V(W),W>0&&(o[-W]=V(-W));return o.one=o[1],o.zero=o[0],o.minusOne=o[-1],o.max=z,o.min=H,o.gcd=Y,o.lcm=function(t,e){return t=V(t).abs(),e=V(e).abs(),t.divide(Y(t,e)).multiply(e)},o.isInstance=function(t){return t instanceof d||t instanceof u||t instanceof l},o.randBetween=function(t,i,s){t=V(t),i=V(i);var n=s||Math.random,r=H(t,i),a=z(t,i).subtract(r).add(1);if(a.isSmall)return r.add(Math.floor(n()*a));for(var h=D(a,e).value,d=[],u=!0,l=0;l<h.length;l++){var w=u?h[l]+(l+1<h.length?h[l+1]/e:0):e,m=g(n()*w);d.push(m),m<h[l]&&(u=!1)}return r.add(o.fromArray(d,e,!1))},o.fromArray=function(t,e,i){return G(t.map(V),V(e||10),i)},o}();t.hasOwnProperty("exports")&&(t.exports=n),void 0===(s=function(){return n}.call(e,i,e,t))||(t.exports=s)}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var r=e[s]={id:s,loaded:!1,exports:{}};return t[s](r,r.exports,i),r.loaded=!0,r.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var s={};return(()=>{"use strict";i.r(s),i.d(s,{default:()=>F});class t{static encode(e,i){return t.encode5BitArray(e,t.to5Bit(i))}static encode5BitArray(e,i){const s=t.createChecksum(e,i);let n=`${e}${t.SEPARATOR}`;for(let e=0;e<i.length;e++)n+=t.CHARSET.charAt(i[e]);for(let e=0;e<s.length;e++)n+=t.CHARSET.charAt(s[e]);return n}static decode(e){const i=t.decodeTo5BitArray(e);return i?{humanReadablePart:i.humanReadablePart,data:t.from5Bit(i.data)}:void 0}static decodeTo5BitArray(e){const i=(e=e.toLowerCase()).lastIndexOf(t.SEPARATOR);if(-1===i)throw new Error(`There is no separator character ${t.SEPARATOR} in the data`);if(i<1)throw new Error(`The separator position is ${i}, which is too early in the string`);if(i+7>e.length)throw new Error(`The separator position is ${i}, which doesn't leave enough space for data`);const s=new Uint8Array(e.length-i-1);let n=0;for(let r=i+1;r<e.length;r++){if(-1===t.CHARSET.indexOf(e.charAt(r)))throw new Error(`Data contains characters not in the charset ${e.charAt(r)}`);s[n++]=t.CHARSET.indexOf(e.charAt(r))}const r=e.slice(0,i);if(t.verifyChecksum(r,s))return{humanReadablePart:r,data:s.slice(0,-6)}}static to5Bit(e){return t.convertBits(e,8,5,!0)}static from5Bit(e){return t.convertBits(e,5,8,!1)}static matches(e,i){return!!i&&new RegExp(`^${e}1[${t.CHARSET}]{6,}$`).test(i)}static createChecksum(e,i){const s=t.humanReadablePartExpand(e),n=new Uint8Array(s.length+i.length+6);n.set(s,0),n.set(i,s.length),n.set([0,0,0,0,0,0],s.length+i.length);const r=1^t.polymod(n),a=new Uint8Array(6);for(let t=0;t<6;t++)a[t]=r>>5*(5-t)&31;return a}static verifyChecksum(e,i){const s=t.humanReadablePartExpand(e),n=new Uint8Array(s.length+i.length);return n.set(s,0),n.set(i,s.length),1===t.polymod(n)}static polymod(e){let i=1;for(let s=0;s<e.length;s++){const n=i>>25;i=(33554431&i)<<5^e[s];for(let e=0;e<5;++e)n>>e&1&&(i^=t.GENERATOR[e])}return i}static humanReadablePartExpand(t){const e=new Uint8Array(2*t.length+1);let i=0;for(let s=0;s<t.length;s++)e[i++]=t.charCodeAt(s)>>5;e[i++]=0;for(let s=0;s<t.length;s++)e[i++]=31&t.charCodeAt(s);return e}static convertBits(t,e,i,s){let n=0,r=0;const a=(1<<i)-1,h=[];for(let s=0;s<t.length;s++)for(n=n<<e|t[s],r+=e;r>=i;)r-=i,h.push(n>>r&a);if(s)r>0&&h.push(n<<i-r&a);else{if(r>=e)throw new Error("Excess padding");if(n<<i-r&a)throw new Error("Non-zero padding")}return new Uint8Array(h)}}t.CHARSET="qpzry9x8gf2tvdw0s3jn54khce6mua7l",t.SEPARATOR="1",t.GENERATOR=Uint32Array.from([996825010,642813549,513874426,1027748829,705979059]);class e{constructor(t,e){this._v=new Uint32Array(32),this._m=new Uint32Array(32),this._context={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t},this.init(t,e)}static sum256(t,i){const s=new e(e.SIZE_256,i);return s.update(t),s.final()}static sum512(t,i){const s=new e(e.SIZE_512,i);return s.update(t),s.final()}update(t){for(let e=0;e<t.length;e++)128===this._context.c&&(this._context.t+=this._context.c,this.compress(!1),this._context.c=0),this._context.b[this._context.c++]=t[e]}final(){for(this._context.t+=this._context.c;this._context.c<128;)this._context.b[this._context.c++]=0;this.compress(!0);const t=new Uint8Array(this._context.outlen);for(let e=0;e<this._context.outlen;e++)t[e]=this._context.h[e>>2]>>8*(3&e);return t}init(t,i){if(t<=0||t>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(i&&i.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");for(let t=0;t<16;t++)this._context.h[t]=e.BLAKE2B_IV32[t];const s=i?i.length:0;this._context.h[0]^=16842752^s<<8^t,i&&(this.update(i),this._context.c=128)}compress(t){let i=0;for(i=0;i<16;i++)this._v[i]=this._context.h[i],this._v[i+16]=e.BLAKE2B_IV32[i];for(this._v[24]^=this._context.t,this._v[25]^=this._context.t/4294967296,t&&(this._v[28]=~this._v[28],this._v[29]=~this._v[29]),i=0;i<32;i++)this._m[i]=this.b2bGet32(this._context.b,4*i);for(i=0;i<12;i++)this.b2bG(0,8,16,24,e.SIGMA82[16*i+0],e.SIGMA82[16*i+1]),this.b2bG(2,10,18,26,e.SIGMA82[16*i+2],e.SIGMA82[16*i+3]),this.b2bG(4,12,20,28,e.SIGMA82[16*i+4],e.SIGMA82[16*i+5]),this.b2bG(6,14,22,30,e.SIGMA82[16*i+6],e.SIGMA82[16*i+7]),this.b2bG(0,10,20,30,e.SIGMA82[16*i+8],e.SIGMA82[16*i+9]),this.b2bG(2,12,22,24,e.SIGMA82[16*i+10],e.SIGMA82[16*i+11]),this.b2bG(4,14,16,26,e.SIGMA82[16*i+12],e.SIGMA82[16*i+13]),this.b2bG(6,8,18,28,e.SIGMA82[16*i+14],e.SIGMA82[16*i+15]);for(i=0;i<16;i++)this._context.h[i]=this._context.h[i]^this._v[i]^this._v[i+16]}add64AA(t,e,i){const s=t[e]+t[i];let n=t[e+1]+t[i+1];s>=4294967296&&n++,t[e]=s,t[e+1]=n}add64AC(t,e,i,s){let n=t[e]+i;i<0&&(n+=4294967296);let r=t[e+1]+s;n>=4294967296&&r++,t[e]=n,t[e+1]=r}b2bGet32(t,e){return t[e]^t[e+1]<<8^t[e+2]<<16^t[e+3]<<24}b2bG(t,e,i,s,n,r){const a=this._m[n],h=this._m[n+1],o=this._m[r],d=this._m[r+1];this.add64AA(this._v,t,e),this.add64AC(this._v,t,a,h);let u=this._v[s]^this._v[t],l=this._v[s+1]^this._v[t+1];this._v[s]=l,this._v[s+1]=u,this.add64AA(this._v,i,s),u=this._v[e]^this._v[i],l=this._v[e+1]^this._v[i+1],this._v[e]=u>>>24^l<<8,this._v[e+1]=l>>>24^u<<8,this.add64AA(this._v,t,e),this.add64AC(this._v,t,o,d),u=this._v[s]^this._v[t],l=this._v[s+1]^this._v[t+1],this._v[s]=u>>>16^l<<16,this._v[s+1]=l>>>16^u<<16,this.add64AA(this._v,i,s),u=this._v[e]^this._v[i],l=this._v[e+1]^this._v[i+1],this._v[e]=l>>>31^u<<1,this._v[e+1]=u>>>31^l<<1}}e.SIZE_256=32,e.SIZE_512=64,e.BLAKE2B_IV32=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),e.SIGMA8=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],e.SIGMA82=new Uint8Array(e.SIGMA8.map((t=>2*t)));class n{constructor(t=n.NUMBER_OF_ROUNDS){if(27!==t&&81!==t)throw new Error("Illegal number of rounds. Only `27` and `81` rounds are supported.");this._state=new Int8Array(n.STATE_LENGTH),this._rounds=t}static transform(t,e){let i,s=0;for(let r=0;r<e;r++){i=t.slice();for(let e=0;e<n.STATE_LENGTH;e++){const r=i[s];s<365?s+=364:s-=365;const a=i[s]<<2;t[e]=n.TRUTH_TABLE[r+a+5]}}}reset(){this._state=new Int8Array(n.STATE_LENGTH)}rate(t=n.HASH_LENGTH){return this._state.slice(0,t)}absorb(t,e,i){do{const s=i<n.HASH_LENGTH?i:n.HASH_LENGTH;this._state.set(t.subarray(e,e+s)),n.transform(this._state,this._rounds),i-=n.HASH_LENGTH,e+=s}while(i>0)}squeeze(t,e,i){do{const s=i<n.HASH_LENGTH?i:n.HASH_LENGTH;t.set(this._state.subarray(0,s),e),n.transform(this._state,this._rounds),i-=n.HASH_LENGTH,e+=s}while(i>0)}}n.HASH_LENGTH=243,n.STATE_LENGTH=3*n.HASH_LENGTH,n.NUMBER_OF_ROUNDS=81,n.TRUTH_TABLE=[1,0,-1,2,1,-1,0,2,-1,1,0];class r{constructor(){this.blocks=[],this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1732584193,this.h1=4023233417,this.h2=2562383102,this.h3=271733878,this.h4=3285377520,this.block=0,this.start=0,this.bytes=0,this.hBytes=0,this.lastByteIndex=0,this.finalized=!1,this.hashed=!1,this.first=!0}static sum(t){const e=new r;return e.update(t),e.digest()}update(t){if(this.finalized)throw new Error("The hash has already been finalized.");let e,i=0;const s=t.length,n=this.blocks;for(;i<s;){for(this.hashed&&(this.hashed=!1,n[0]=this.block,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=0,n[16]=0),e=this.start;i<s&&e<64;++i)n[e>>2]|=t[i]<<r._SHIFT[3&e++];this.lastByteIndex=e,this.bytes+=e-this.start,e>=64?(this.block=n[16],this.start=e-64,this.hash(),this.hashed=!0):this.start=e}return this.bytes>4294967295&&(this.hBytes+=Math.trunc(this.bytes/4294967296),this.bytes%=4294967296),this}digest(){this.finalize();const t=this.h0,e=this.h1,i=this.h2,s=this.h3,n=this.h4;return Uint8Array.from([t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24&255,i>>16&255,i>>8&255,255&i,s>>24&255,s>>16&255,s>>8&255,255&s,n>>24&255,n>>16&255,n>>8&255,255&n])}finalize(){if(this.finalized)return;this.finalized=!0;const t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=r._EXTRA[3&e],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=0,t[16]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}hash(){let t,e,i,s=this.h0,n=this.h1,r=this.h2,a=this.h3,h=this.h4;const o=this.blocks;for(e=16;e<80;++e)i=o[e-3]^o[e-8]^o[e-14]^o[e-16],o[e]=i<<1|i>>>31;for(e=0;e<20;e+=5)t=n&r|~n&a,i=s<<5|s>>>27,h=Math.trunc(i+t+h+1518500249+o[e]),n=n<<30|n>>>2,t=s&n|~s&r,i=h<<5|h>>>27,a=Math.trunc(i+t+a+1518500249+o[e+1]),s=s<<30|s>>>2,t=h&s|~h&n,i=a<<5|a>>>27,r=Math.trunc(i+t+r+1518500249+o[e+2]),h=h<<30|h>>>2,t=a&h|~a&s,i=r<<5|r>>>27,n=Math.trunc(i+t+n+1518500249+o[e+3]),a=a<<30|a>>>2,t=r&a|~r&h,i=n<<5|n>>>27,s=Math.trunc(i+t+s+1518500249+o[e+4]),r=r<<30|r>>>2;for(;e<40;e+=5)t=n^r^a,i=s<<5|s>>>27,h=Math.trunc(i+t+h+1859775393+o[e]),n=n<<30|n>>>2,t=s^n^r,i=h<<5|h>>>27,a=Math.trunc(i+t+a+1859775393+o[e+1]),s=s<<30|s>>>2,t=h^s^n,i=a<<5|a>>>27,r=Math.trunc(i+t+r+1859775393+o[e+2]),h=h<<30|h>>>2,t=a^h^s,i=r<<5|r>>>27,n=Math.trunc(i+t+n+1859775393+o[e+3]),a=a<<30|a>>>2,t=r^a^h,i=n<<5|n>>>27,s=Math.trunc(i+t+s+1859775393+o[e+4]),r=r<<30|r>>>2;for(;e<60;e+=5)t=n&r|n&a|r&a,i=s<<5|s>>>27,h=Math.trunc(i+t+h-1894007588+o[e]),n=n<<30|n>>>2,t=s&n|s&r|n&r,i=h<<5|h>>>27,a=Math.trunc(i+t+a-1894007588+o[e+1]),s=s<<30|s>>>2,t=h&s|h&n|s&n,i=a<<5|a>>>27,r=Math.trunc(i+t+r-1894007588+o[e+2]),h=h<<30|h>>>2,t=a&h|a&s|h&s,i=r<<5|r>>>27,n=Math.trunc(i+t+n-1894007588+o[e+3]),a=a<<30|a>>>2,t=r&a|r&h|a&h,i=n<<5|n>>>27,s=Math.trunc(i+t+s-1894007588+o[e+4]),r=r<<30|r>>>2;for(;e<80;e+=5)t=n^r^a,i=s<<5|s>>>27,h=Math.trunc(i+t+h-899497514+o[e]),n=n<<30|n>>>2,t=s^n^r,i=h<<5|h>>>27,a=Math.trunc(i+t+a-899497514+o[e+1]),s=s<<30|s>>>2,t=h^s^n,i=a<<5|a>>>27,r=Math.trunc(i+t+r-899497514+o[e+2]),h=h<<30|h>>>2,t=a^h^s,i=r<<5|r>>>27,n=Math.trunc(i+t+n-899497514+o[e+3]),a=a<<30|a>>>2,t=r^a^h,i=n<<5|n>>>27,s=Math.trunc(i+t+s-899497514+o[e+4]),r=r<<30|r>>>2;this.h0=Math.trunc(this.h0+s),this.h1=Math.trunc(this.h1+n),this.h2=Math.trunc(this.h2+r),this.h3=Math.trunc(this.h3+a),this.h4=Math.trunc(this.h4+h)}}r._EXTRA=[-2147483648,8388608,32768,128],r._SHIFT=[24,16,8,0];class a{constructor(t=a.SIZE_256){if(this._blocks=[],t!==a.SIZE_224&&t!==a.SIZE_256)throw new Error("Only 224 or 256 bits are supported");this._blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t===a.SIZE_224?(this._h0=3238371032,this._h1=914150663,this._h2=812702999,this._h3=4144912697,this._h4=4290775857,this._h5=1750603025,this._h6=1694076839,this._h7=3204075428):(this._h0=1779033703,this._h1=3144134277,this._h2=1013904242,this._h3=2773480762,this._h4=1359893119,this._h5=2600822924,this._h6=528734635,this._h7=1541459225),this._bits=t,this._block=0,this._start=0,this._bytes=0,this._hBytes=0,this._lastByteIndex=0,this._finalized=!1,this._hashed=!1,this._first=!0}static sum256(t){const e=new a(a.SIZE_256);return e.update(t),e.digest()}static sum224(t){const e=new a(a.SIZE_224);return e.update(t),e.digest()}update(t){if(this._finalized)throw new Error("The hash has already been finalized.");let e,i=0;const s=t.length,n=this._blocks;for(;i<s;){for(this._hashed&&(this._hashed=!1,n[0]=this._block,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=0,n[16]=0),e=this._start;i<s&&e<64;++i)n[e>>2]|=t[i]<<a.SHIFT[3&e++];this._lastByteIndex=e,this._bytes+=e-this._start,e>=64?(this._block=n[16],this._start=e-64,this.hash(),this._hashed=!0):this._start=e}return this._bytes>4294967295&&(this._hBytes+=Math.trunc(this._bytes/4294967296),this._bytes%=4294967296),this}digest(){this.finalize();const t=this._h0,e=this._h1,i=this._h2,s=this._h3,n=this._h4,r=this._h5,h=this._h6,o=this._h7,d=[t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24&255,i>>16&255,i>>8&255,255&i,s>>24&255,s>>16&255,s>>8&255,255&s,n>>24&255,n>>16&255,n>>8&255,255&n,r>>24&255,r>>16&255,r>>8&255,255&r,h>>24&255,h>>16&255,h>>8&255,255&h];return this._bits===a.SIZE_256&&d.push(o>>24&255,o>>16&255,o>>8&255,255&o),Uint8Array.from(d)}finalize(){if(this._finalized)return;this._finalized=!0;const t=this._blocks,e=this._lastByteIndex;t[16]=this._block,t[e>>2]|=a.EXTRA[3&e],this._block=t[16],e>=56&&(this._hashed||this.hash(),t[0]=this._block,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=0,t[16]=0),t[14]=this._hBytes<<3|this._bytes>>>29,t[15]=this._bytes<<3,this.hash()}hash(){let t=this._h0,e=this._h1,i=this._h2,s=this._h3,n=this._h4,r=this._h5,h=this._h6,o=this._h7;const d=this._blocks;let u,l,w,m,f,c,p,g,y,b,v;for(u=16;u<64;++u)f=d[u-15],l=(f>>>7|f<<25)^(f>>>18|f<<14)^f>>>3,f=d[u-2],w=(f>>>17|f<<15)^(f>>>19|f<<13)^f>>>10,d[u]=d[u-16]+l+d[u-7]+w<<0;for(v=e&i,u=0;u<64;u+=4)this._first?(this._bits===a.SIZE_224?(g=300032,f=d[0]-1413257819,o=f-150054599<<0,s=f+24177077<<0):(g=704751109,f=d[0]-210244248,o=f-1521486534<<0,s=f+143694565<<0),this._first=!1):(l=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),w=(n>>>6|n<<26)^(n>>>11|n<<21)^(n>>>25|n<<7),g=t&e,m=g^t&i^v,p=n&r^~n&h,f=o+w+p+a.K[u]+d[u],c=l+m,o=s+f<<0,s=f+c<<0),l=(s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10),w=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),y=s&t,m=y^s&e^g,p=o&n^~o&r,f=h+w+p+a.K[u+1]+d[u+1],c=l+m,h=i+f<<0,i=f+c<<0,l=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),w=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),b=i&s,m=b^i&t^y,p=h&o^~h&n,f=r+w+p+a.K[u+2]+d[u+2],c=l+m,r=e+f<<0,e=f+c<<0,l=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),w=(r>>>6|r<<26)^(r>>>11|r<<21)^(r>>>25|r<<7),v=e&i,m=v^e&s^b,p=r&h^~r&o,f=n+w+p+a.K[u+3]+d[u+3],c=l+m,n=t+f<<0,t=f+c<<0;this._h0+=Math.trunc(t),this._h1+=Math.trunc(e),this._h2+=Math.trunc(i),this._h3+=Math.trunc(s),this._h4+=Math.trunc(n),this._h5+=Math.trunc(r),this._h6+=Math.trunc(h),this._h7+=Math.trunc(o)}}a.SIZE_256=256,a.SIZE_224=224,a.EXTRA=[-2147483648,8388608,32768,128],a.SHIFT=[24,16,8,0],a.K=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);class h{constructor(t=h.SIZE_512){if(this._blocks=[],t!==h.SIZE_224&&t!==h.SIZE_256&&t!==h.SIZE_384&&t!==h.SIZE_512)throw new Error("Only 224, 256, 384 or 512 bits are supported");this._blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t===h.SIZE_384?(this._h0h=3418070365,this._h0l=3238371032,this._h1h=1654270250,this._h1l=914150663,this._h2h=2438529370,this._h2l=812702999,this._h3h=355462360,this._h3l=4144912697,this._h4h=1731405415,this._h4l=4290775857,this._h5h=2394180231,this._h5l=1750603025,this._h6h=3675008525,this._h6l=1694076839,this._h7h=1203062813,this._h7l=3204075428):t===h.SIZE_256?(this._h0h=573645204,this._h0l=4230739756,this._h1h=2673172387,this._h1l=3360449730,this._h2h=596883563,this._h2l=1867755857,this._h3h=2520282905,this._h3l=1497426621,this._h4h=2519219938,this._h4l=2827943907,this._h5h=3193839141,this._h5l=1401305490,this._h6h=721525244,this._h6l=746961066,this._h7h=246885852,this._h7l=2177182882):t===h.SIZE_224?(this._h0h=2352822216,this._h0l=424955298,this._h1h=1944164710,this._h1l=2312950998,this._h2h=502970286,this._h2l=855612546,this._h3h=1738396948,this._h3l=1479516111,this._h4h=258812777,this._h4l=2077511080,this._h5h=2011393907,this._h5l=79989058,this._h6h=1067287976,this._h6l=1780299464,this._h7h=286451373,this._h7l=2446758561):(this._h0h=1779033703,this._h0l=4089235720,this._h1h=3144134277,this._h1l=2227873595,this._h2h=1013904242,this._h2l=4271175723,this._h3h=2773480762,this._h3l=1595750129,this._h4h=1359893119,this._h4l=2917565137,this._h5h=2600822924,this._h5l=725511199,this._h6h=528734635,this._h6l=4215389547,this._h7h=1541459225,this._h7l=327033209),this._bits=t,this._block=0,this._start=0,this._bytes=0,this._hBytes=0,this._lastByteIndex=0,this._finalized=!1,this._hashed=!1}static sum512(t){const e=new h(h.SIZE_512);return e.update(t),e.digest()}update(t){if(this._finalized)throw new Error("The hash has already been finalized.");let e,i=0;const s=t.length,n=this._blocks;for(;i<s;){for(this._hashed&&(this._hashed=!1,n[0]=this._block,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=0,n[16]=0,n[17]=0,n[18]=0,n[19]=0,n[20]=0,n[21]=0,n[22]=0,n[23]=0,n[24]=0,n[25]=0,n[26]=0,n[27]=0,n[28]=0,n[29]=0,n[30]=0,n[31]=0,n[32]=0),e=this._start;i<s&&e<128;++i)n[e>>2]|=t[i]<<h.SHIFT[3&e++];this._lastByteIndex=e,this._bytes+=e-this._start,e>=128?(this._block=n[32],this._start=e-128,this.hash(),this._hashed=!0):this._start=e}return this._bytes>4294967295&&(this._hBytes+=Math.trunc(this._bytes/4294967296),this._bytes%=4294967296),this}digest(){this.finalize();const t=this._h0h,e=this._h0l,i=this._h1h,s=this._h1l,n=this._h2h,r=this._h2l,a=this._h3h,o=this._h3l,d=this._h4h,u=this._h4l,l=this._h5h,w=this._h5l,m=this._h6h,f=this._h6l,c=this._h7h,p=this._h7l,g=this._bits,y=[t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24&255,i>>16&255,i>>8&255,255&i,s>>24&255,s>>16&255,s>>8&255,255&s,n>>24&255,n>>16&255,n>>8&255,255&n,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a];return g>=h.SIZE_256&&y.push(o>>24&255,o>>16&255,o>>8&255,255&o),g>=h.SIZE_384&&y.push(d>>24&255,d>>16&255,d>>8&255,255&d,u>>24&255,u>>16&255,u>>8&255,255&u,l>>24&255,l>>16&255,l>>8&255,255&l,w>>24&255,w>>16&255,w>>8&255,255&w),g===h.SIZE_512&&y.push(m>>24&255,m>>16&255,m>>8&255,255&m,f>>24&255,f>>16&255,f>>8&255,255&f,c>>24&255,c>>16&255,c>>8&255,255&c,p>>24&255,p>>16&255,p>>8&255,255&p),Uint8Array.from(y)}finalize(){if(this._finalized)return;this._finalized=!0;const t=this._blocks,e=this._lastByteIndex;t[32]=this._block,t[e>>2]|=h.EXTRA[3&e],this._block=t[32],e>=112&&(this._hashed||this.hash(),t[0]=this._block,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=0,t[16]=0,t[17]=0,t[18]=0,t[19]=0,t[20]=0,t[21]=0,t[22]=0,t[23]=0,t[24]=0,t[25]=0,t[26]=0,t[27]=0,t[28]=0,t[29]=0,t[30]=0,t[31]=0,t[32]=0),t[30]=this._hBytes<<3|this._bytes>>>29,t[31]=this._bytes<<3,this.hash()}hash(){const t=this._h0h,e=this._h0l,i=this._h1h,s=this._h1l,n=this._h2h,r=this._h2l,a=this._h3h,o=this._h3l,d=this._h4h,u=this._h4l,l=this._h5h,w=this._h5l,m=this._h6h,f=this._h6l,c=this._h7h,p=this._h7l,g=this._blocks;let y,b,v,_,R,E,S,L,A,x,k,I,N,T,M,B,O,q,Z,P,U,X,K,J,C;for(y=32;y<160;y+=2)P=g[y-30],U=g[y-29],b=(P>>>1|U<<31)^(P>>>8|U<<24)^P>>>7,v=(U>>>1|P<<31)^(U>>>8|P<<24)^(U>>>7|P<<25),P=g[y-4],U=g[y-3],_=(P>>>19|U<<13)^(U>>>29|P<<3)^P>>>6,R=(U>>>19|P<<13)^(P>>>29|U<<3)^(U>>>6|P<<26),P=g[y-32],U=g[y-31],X=g[y-14],K=g[y-13],E=(65535&K)+(65535&U)+(65535&v)+(65535&R),S=(K>>>16)+(U>>>16)+(v>>>16)+(R>>>16)+(E>>>16),L=(65535&X)+(65535&P)+(65535&b)+(65535&_)+(S>>>16),A=(X>>>16)+(P>>>16)+(b>>>16)+(_>>>16)+(L>>>16),g[y]=A<<16|65535&L,g[y+1]=S<<16|65535&E;let z=t,H=e,Y=i,j=s,G=n,D=r,$=a,F=o,V=d,W=u,Q=l,tt=w,et=m,it=f,st=c,nt=p;for(B=Y&G,O=j&D,y=0;y<160;y+=8)b=(z>>>28|H<<4)^(H>>>2|z<<30)^(H>>>7|z<<25),v=(H>>>28|z<<4)^(z>>>2|H<<30)^(z>>>7|H<<25),_=(V>>>14|W<<18)^(V>>>18|W<<14)^(W>>>9|V<<23),R=(W>>>14|V<<18)^(W>>>18|V<<14)^(V>>>9|W<<23),x=z&Y,k=H&j,q=x^z&G^B,Z=k^H&D^O,J=V&Q^~V&et,C=W&tt^~W&it,P=g[y],U=g[y+1],X=h.K[y],K=h.K[y+1],E=(65535&K)+(65535&U)+(65535&C)+(65535&R)+(65535&nt),S=(K>>>16)+(U>>>16)+(C>>>16)+(R>>>16)+(nt>>>16)+(E>>>16),L=(65535&X)+(65535&P)+(65535&J)+(65535&_)+(65535&st)+(S>>>16),A=(X>>>16)+(P>>>16)+(J>>>16)+(_>>>16)+(st>>>16)+(L>>>16),P=A<<16|65535&L,U=S<<16|65535&E,E=(65535&Z)+(65535&v),S=(Z>>>16)+(v>>>16)+(E>>>16),L=(65535&q)+(65535&b)+(S>>>16),A=(q>>>16)+(b>>>16)+(L>>>16),X=A<<16|65535&L,K=S<<16|65535&E,E=(65535&F)+(65535&U),S=(F>>>16)+(U>>>16)+(E>>>16),L=(65535&$)+(65535&P)+(S>>>16),A=($>>>16)+(P>>>16)+(L>>>16),st=A<<16|65535&L,nt=S<<16|65535&E,E=(65535&K)+(65535&U),S=(K>>>16)+(U>>>16)+(E>>>16),L=(65535&X)+(65535&P)+(S>>>16),A=(X>>>16)+(P>>>16)+(L>>>16),$=A<<16|65535&L,F=S<<16|65535&E,b=($>>>28|F<<4)^(F>>>2|$<<30)^(F>>>7|$<<25),v=(F>>>28|$<<4)^($>>>2|F<<30)^($>>>7|F<<25),_=(st>>>14|nt<<18)^(st>>>18|nt<<14)^(nt>>>9|st<<23),R=(nt>>>14|st<<18)^(nt>>>18|st<<14)^(st>>>9|nt<<23),I=$&z,N=F&H,q=I^$&Y^x,Z=N^F&j^k,J=st&V^~st&Q,C=nt&W^~nt&tt,P=g[y+2],U=g[y+3],X=h.K[y+2],K=h.K[y+3],E=(65535&K)+(65535&U)+(65535&C)+(65535&R)+(65535&it),S=(K>>>16)+(U>>>16)+(C>>>16)+(R>>>16)+(it>>>16)+(E>>>16),L=(65535&X)+(65535&P)+(65535&J)+(65535&_)+(65535&et)+(S>>>16),A=(X>>>16)+(P>>>16)+(J>>>16)+(_>>>16)+(et>>>16)+(L>>>16),P=A<<16|65535&L,U=S<<16|65535&E,E=(65535&Z)+(65535&v),S=(Z>>>16)+(v>>>16)+(E>>>16),L=(65535&q)+(65535&b)+(S>>>16),A=(q>>>16)+(b>>>16)+(L>>>16),X=A<<16|65535&L,K=S<<16|65535&E,E=(65535&D)+(65535&U),S=(D>>>16)+(U>>>16)+(E>>>16),L=(65535&G)+(65535&P)+(S>>>16),A=(G>>>16)+(P>>>16)+(L>>>16),et=A<<16|65535&L,it=S<<16|65535&E,E=(65535&K)+(65535&U),S=(K>>>16)+(U>>>16)+(E>>>16),L=(65535&X)+(65535&P)+(S>>>16),A=(X>>>16)+(P>>>16)+(L>>>16),G=A<<16|65535&L,D=S<<16|65535&E,b=(G>>>28|D<<4)^(D>>>2|G<<30)^(D>>>7|G<<25),v=(D>>>28|G<<4)^(G>>>2|D<<30)^(G>>>7|D<<25),_=(et>>>14|it<<18)^(et>>>18|it<<14)^(it>>>9|et<<23),R=(it>>>14|et<<18)^(it>>>18|et<<14)^(et>>>9|it<<23),T=G&$,M=D&F,q=T^G&z^I,Z=M^D&H^N,J=et&st^~et&V,C=it&nt^~it&W,P=g[y+4],U=g[y+5],X=h.K[y+4],K=h.K[y+5],E=(65535&K)+(65535&U)+(65535&C)+(65535&R)+(65535&tt),S=(K>>>16)+(U>>>16)+(C>>>16)+(R>>>16)+(tt>>>16)+(E>>>16),L=(65535&X)+(65535&P)+(65535&J)+(65535&_)+(65535&Q)+(S>>>16),A=(X>>>16)+(P>>>16)+(J>>>16)+(_>>>16)+(Q>>>16)+(L>>>16),P=A<<16|65535&L,U=S<<16|65535&E,E=(65535&Z)+(65535&v),S=(Z>>>16)+(v>>>16)+(E>>>16),L=(65535&q)+(65535&b)+(S>>>16),A=(q>>>16)+(b>>>16)+(L>>>16),X=A<<16|65535&L,K=S<<16|65535&E,E=(65535&j)+(65535&U),S=(j>>>16)+(U>>>16)+(E>>>16),L=(65535&Y)+(65535&P)+(S>>>16),A=(Y>>>16)+(P>>>16)+(L>>>16),Q=A<<16|65535&L,tt=S<<16|65535&E,E=(65535&K)+(65535&U),S=(K>>>16)+(U>>>16)+(E>>>16),L=(65535&X)+(65535&P)+(S>>>16),A=(X>>>16)+(P>>>16)+(L>>>16),Y=A<<16|65535&L,j=S<<16|65535&E,b=(Y>>>28|j<<4)^(j>>>2|Y<<30)^(j>>>7|Y<<25),v=(j>>>28|Y<<4)^(Y>>>2|j<<30)^(Y>>>7|j<<25),_=(Q>>>14|tt<<18)^(Q>>>18|tt<<14)^(tt>>>9|Q<<23),R=(tt>>>14|Q<<18)^(tt>>>18|Q<<14)^(Q>>>9|tt<<23),B=Y&G,O=j&D,q=B^Y&$^T,Z=O^j&F^M,J=Q&et^~Q&st,C=tt&it^~tt&nt,P=g[y+6],U=g[y+7],X=h.K[y+6],K=h.K[y+7],E=(65535&K)+(65535&U)+(65535&C)+(65535&R)+(65535&W),S=(K>>>16)+(U>>>16)+(C>>>16)+(R>>>16)+(W>>>16)+(E>>>16),L=(65535&X)+(65535&P)+(65535&J)+(65535&_)+(65535&V)+(S>>>16),A=(X>>>16)+(P>>>16)+(J>>>16)+(_>>>16)+(V>>>16)+(L>>>16),P=A<<16|65535&L,U=S<<16|65535&E,E=(65535&Z)+(65535&v),S=(Z>>>16)+(v>>>16)+(E>>>16),L=(65535&q)+(65535&b)+(S>>>16),A=(q>>>16)+(b>>>16)+(L>>>16),X=A<<16|65535&L,K=S<<16|65535&E,E=(65535&H)+(65535&U),S=(H>>>16)+(U>>>16)+(E>>>16),L=(65535&z)+(65535&P)+(S>>>16),A=(z>>>16)+(P>>>16)+(L>>>16),V=A<<16|65535&L,W=S<<16|65535&E,E=(65535&K)+(65535&U),S=(K>>>16)+(U>>>16)+(E>>>16),L=(65535&X)+(65535&P)+(S>>>16),A=(X>>>16)+(P>>>16)+(L>>>16),z=A<<16|65535&L,H=S<<16|65535&E;E=(65535&e)+(65535&H),S=(e>>>16)+(H>>>16)+(E>>>16),L=(65535&t)+(65535&z)+(S>>>16),A=(t>>>16)+(z>>>16)+(L>>>16),this._h0h=A<<16|65535&L,this._h0l=S<<16|65535&E,E=(65535&s)+(65535&j),S=(s>>>16)+(j>>>16)+(E>>>16),L=(65535&i)+(65535&Y)+(S>>>16),A=(i>>>16)+(Y>>>16)+(L>>>16),this._h1h=A<<16|65535&L,this._h1l=S<<16|65535&E,E=(65535&r)+(65535&D),S=(r>>>16)+(D>>>16)+(E>>>16),L=(65535&n)+(65535&G)+(S>>>16),A=(n>>>16)+(G>>>16)+(L>>>16),this._h2h=A<<16|65535&L,this._h2l=S<<16|65535&E,E=(65535&o)+(65535&F),S=(o>>>16)+(F>>>16)+(E>>>16),L=(65535&a)+(65535&$)+(S>>>16),A=(a>>>16)+($>>>16)+(L>>>16),this._h3h=A<<16|65535&L,this._h3l=S<<16|65535&E,E=(65535&u)+(65535&W),S=(u>>>16)+(W>>>16)+(E>>>16),L=(65535&d)+(65535&V)+(S>>>16),A=(d>>>16)+(V>>>16)+(L>>>16),this._h4h=A<<16|65535&L,this._h4l=S<<16|65535&E,E=(65535&w)+(65535&tt),S=(w>>>16)+(tt>>>16)+(E>>>16),L=(65535&l)+(65535&Q)+(S>>>16),A=(l>>>16)+(Q>>>16)+(L>>>16),this._h5h=A<<16|65535&L,this._h5l=S<<16|65535&E,E=(65535&f)+(65535&it),S=(f>>>16)+(it>>>16)+(E>>>16),L=(65535&m)+(65535&et)+(S>>>16),A=(m>>>16)+(et>>>16)+(L>>>16),this._h6h=A<<16|65535&L,this._h6l=S<<16|65535&E,E=(65535&p)+(65535&nt),S=(p>>>16)+(nt>>>16)+(E>>>16),L=(65535&c)+(65535&st)+(S>>>16),A=(c>>>16)+(st>>>16)+(L>>>16),this._h7h=A<<16|65535&L,this._h7l=S<<16|65535&E}}h.SIZE_224=224,h.SIZE_256=256,h.SIZE_384=384,h.SIZE_512=512,h.EXTRA=[-2147483648,8388608,32768,128],h.SHIFT=[24,16,8,0],h.K=Uint32Array.from([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);class o{static generate(t){return o.randomPolyfill?o.randomPolyfill(t):new Uint8Array(t)}}o.randomPolyfill||(o.randomPolyfill=t=>{const e=new Uint8Array(t);return window.crypto.getRandomValues(e),e});class d{static decode(t){let e=0,i=0;t=t.replace(/=+$/,"");let s=0;const n=new Uint8Array(Math.trunc(5*t.length/8));for(let r=0;r<t.length;r++){const a=d._ALPHABET.indexOf(t[r]);if(-1===a)throw new Error(`"Invalid character found '${t[r]}'`);i=i<<5|a,e+=5,e>=8&&(n[s++]=i>>>e-8&255,e-=8)}return n}static encode(t){let e=0,i=0,s="";for(let n=0;n<t.byteLength;n++)for(i=i<<8|t[n],e+=8;e>=5;)s+=d._ALPHABET[i>>>e-5&31],e-=5;for(e>0&&(s+=d._ALPHABET[i<<5-e&31]);s.length%8!=0;)s+="=";return s}}d._ALPHABET="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";class u{static decode(t){let e=0;for(let i=0;i<t.length&&"1"===t[i];i++)e+=1;const i=Math.trunc(733*t.length/1e3)+1,s=i<=128?new Uint8Array(128).fill(0):Buffer.alloc(i);let n=0;for(let r=e;r<t.length;r++){const e=t.charCodeAt(r);if(65408&e)throw new Error(`"Invalid character fou