@signumjs/util
Version:
Useful utilities and tools for building Signum Network applications
1 lines • 50.3 kB
JavaScript
"use strict";var sig$util=(()=>{var Xr=Object.create;var Ge=Object.defineProperty;var Wr=Object.getOwnPropertyDescriptor;var Zr=Object.getOwnPropertyNames;var Yr=Object.getPrototypeOf,Qr=Object.prototype.hasOwnProperty;var jr=(o,i)=>()=>(o&&(i=o(o=0)),i);var je=(o,i)=>()=>(i||o((i={exports:{}}).exports,i),i.exports),mr=(o,i)=>{for(var O in i)Ge(o,O,{get:i[O],enumerable:!0})},Le=(o,i,O,D)=>{if(i&&typeof i=="object"||typeof i=="function")for(let v of Zr(i))!Qr.call(o,v)&&v!==O&&Ge(o,v,{get:()=>i[v],enumerable:!(D=Wr(i,v))||D.enumerable});return o},L=(o,i,O)=>(Le(o,i,"default"),O&&Le(O,i,"default")),qe=(o,i,O)=>(O=o!=null?Xr(Yr(o)):{},Le(i||!o||!o.__esModule?Ge(O,"default",{value:o,enumerable:!0}):O,o)),dr=o=>Le(Ge({},"__esModule",{value:!0}),o);var _r=je((Ar,ze)=>{(function(o){"use strict";var i,O=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,D=Math.ceil,v=Math.floor,M="[BigNumber Error] ",W=M+"Number primitive has more than 15 significant digits: ",z=1e14,P=14,le=9007199254740991,Se=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],oe=1e7,K=1e9;function Be(G){var I,$,r,e=B.prototype={constructor:B,toString:null,valueOf:null},f=new B(1),m=20,l=4,g=-7,E=21,u=-1e7,h=1e7,_=!1,x=1,y=0,R={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},U="0123456789abcdefghijklmnopqrstuvwxyz",H=!0;function B(t,n){var s,A,c,p,w,a,d,N,S=this;if(!(S instanceof B))return new B(t,n);if(n==null){if(t&&t._isBigNumber===!0){S.s=t.s,!t.c||t.e>h?S.c=S.e=null:t.e<u?S.c=[S.e=0]:(S.e=t.e,S.c=t.c.slice());return}if((a=typeof t=="number")&&t*0==0){if(S.s=1/t<0?(t=-t,-1):1,t===~~t){for(p=0,w=t;w>=10;w/=10,p++);p>h?S.c=S.e=null:(S.e=p,S.c=[t]);return}N=String(t)}else{if(!O.test(N=String(t)))return r(S,N,a);S.s=N.charCodeAt(0)==45?(N=N.slice(1),-1):1}(p=N.indexOf("."))>-1&&(N=N.replace(".","")),(w=N.search(/e/i))>0?(p<0&&(p=w),p+=+N.slice(w+1),N=N.substring(0,w)):p<0&&(p=N.length)}else{if(J(n,2,U.length,"Base"),n==10&&H)return S=new B(t),Q(S,m+S.e+1,l);if(N=String(t),a=typeof t=="number"){if(t*0!=0)return r(S,N,a,n);if(S.s=1/t<0?(N=N.slice(1),-1):1,B.DEBUG&&N.replace(/^0\.0*|\./,"").length>15)throw Error(W+t)}else S.s=N.charCodeAt(0)===45?(N=N.slice(1),-1):1;for(s=U.slice(0,n),p=w=0,d=N.length;w<d;w++)if(s.indexOf(A=N.charAt(w))<0){if(A=="."){if(w>p){p=d;continue}}else if(!c&&(N==N.toUpperCase()&&(N=N.toLowerCase())||N==N.toLowerCase()&&(N=N.toUpperCase()))){c=!0,w=-1,p=0;continue}return r(S,String(t),a,n)}a=!1,N=$(N,n,10,S.s),(p=N.indexOf("."))>-1?N=N.replace(".",""):p=N.length}for(w=0;N.charCodeAt(w)===48;w++);for(d=N.length;N.charCodeAt(--d)===48;);if(N=N.slice(w,++d)){if(d-=w,a&&B.DEBUG&&d>15&&(t>le||t!==v(t)))throw Error(W+S.s*t);if((p=p-w-1)>h)S.c=S.e=null;else if(p<u)S.c=[S.e=0];else{if(S.e=p,S.c=[],w=(p+1)%P,p<0&&(w+=P),w<d){for(w&&S.c.push(+N.slice(0,w)),d-=P;w<d;)S.c.push(+N.slice(w,w+=P));w=P-(N=N.slice(w)).length}else w-=d;for(;w--;N+="0");S.c.push(+N)}}else S.c=[S.e=0]}B.clone=Be,B.ROUND_UP=0,B.ROUND_DOWN=1,B.ROUND_CEIL=2,B.ROUND_FLOOR=3,B.ROUND_HALF_UP=4,B.ROUND_HALF_DOWN=5,B.ROUND_HALF_EVEN=6,B.ROUND_HALF_CEIL=7,B.ROUND_HALF_FLOOR=8,B.EUCLID=9,B.config=B.set=function(t){var n,s;if(t!=null)if(typeof t=="object"){if(t.hasOwnProperty(n="DECIMAL_PLACES")&&(s=t[n],J(s,0,K,n),m=s),t.hasOwnProperty(n="ROUNDING_MODE")&&(s=t[n],J(s,0,8,n),l=s),t.hasOwnProperty(n="EXPONENTIAL_AT")&&(s=t[n],s&&s.pop?(J(s[0],-K,0,n),J(s[1],0,K,n),g=s[0],E=s[1]):(J(s,-K,K,n),g=-(E=s<0?-s:s))),t.hasOwnProperty(n="RANGE"))if(s=t[n],s&&s.pop)J(s[0],-K,-1,n),J(s[1],1,K,n),u=s[0],h=s[1];else if(J(s,-K,K,n),s)u=-(h=s<0?-s:s);else throw Error(M+n+" cannot be zero: "+s);if(t.hasOwnProperty(n="CRYPTO"))if(s=t[n],s===!!s)if(s)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))_=s;else throw _=!s,Error(M+"crypto unavailable");else _=s;else throw Error(M+n+" not true or false: "+s);if(t.hasOwnProperty(n="MODULO_MODE")&&(s=t[n],J(s,0,9,n),x=s),t.hasOwnProperty(n="POW_PRECISION")&&(s=t[n],J(s,0,K,n),y=s),t.hasOwnProperty(n="FORMAT"))if(s=t[n],typeof s=="object")R=s;else throw Error(M+n+" not an object: "+s);if(t.hasOwnProperty(n="ALPHABET"))if(s=t[n],typeof s=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(s))H=s.slice(0,10)=="0123456789",U=s;else throw Error(M+n+" invalid: "+s)}else throw Error(M+"Object expected: "+t);return{DECIMAL_PLACES:m,ROUNDING_MODE:l,EXPONENTIAL_AT:[g,E],RANGE:[u,h],CRYPTO:_,MODULO_MODE:x,POW_PRECISION:y,FORMAT:R,ALPHABET:U}},B.isBigNumber=function(t){if(!t||t._isBigNumber!==!0)return!1;if(!B.DEBUG)return!0;var n,s,A=t.c,c=t.e,p=t.s;e:if({}.toString.call(A)=="[object Array]"){if((p===1||p===-1)&&c>=-K&&c<=K&&c===v(c)){if(A[0]===0){if(c===0&&A.length===1)return!0;break e}if(n=(c+1)%P,n<1&&(n+=P),String(A[0]).length==n){for(n=0;n<A.length;n++)if(s=A[n],s<0||s>=z||s!==v(s))break e;if(s!==0)return!0}}}else if(A===null&&c===null&&(p===null||p===1||p===-1))return!0;throw Error(M+"Invalid BigNumber: "+t)},B.maximum=B.max=function(){return V(arguments,-1)},B.minimum=B.min=function(){return V(arguments,1)},B.random=function(){var t=9007199254740992,n=Math.random()*t&2097151?function(){return v(Math.random()*t)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(s){var A,c,p,w,a,d=0,N=[],S=new B(f);if(s==null?s=m:J(s,0,K),w=D(s/P),_)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(w*=2));d<w;)a=A[d]*131072+(A[d+1]>>>11),a>=9e15?(c=crypto.getRandomValues(new Uint32Array(2)),A[d]=c[0],A[d+1]=c[1]):(N.push(a%1e14),d+=2);d=w/2}else if(crypto.randomBytes){for(A=crypto.randomBytes(w*=7);d<w;)a=(A[d]&31)*281474976710656+A[d+1]*1099511627776+A[d+2]*4294967296+A[d+3]*16777216+(A[d+4]<<16)+(A[d+5]<<8)+A[d+6],a>=9e15?crypto.randomBytes(7).copy(A,d):(N.push(a%1e14),d+=7);d=w/7}else throw _=!1,Error(M+"crypto unavailable");if(!_)for(;d<w;)a=n(),a<9e15&&(N[d++]=a%1e14);for(w=N[--d],s%=P,w&&s&&(a=Se[P-s],N[d]=v(w/a)*a);N[d]===0;N.pop(),d--);if(d<0)N=[p=0];else{for(p=-1;N[0]===0;N.splice(0,1),p-=P);for(d=1,a=N[0];a>=10;a/=10,d++);d<P&&(p-=P-d)}return S.e=p,S.c=N,S}}(),B.sum=function(){for(var t=1,n=arguments,s=new B(n[0]);t<n.length;)s=s.plus(n[t++]);return s},$=function(){var t="0123456789";function n(s,A,c,p){for(var w,a=[0],d,N=0,S=s.length;N<S;){for(d=a.length;d--;a[d]*=A);for(a[0]+=p.indexOf(s.charAt(N++)),w=0;w<a.length;w++)a[w]>c-1&&(a[w+1]==null&&(a[w+1]=0),a[w+1]+=a[w]/c|0,a[w]%=c)}return a.reverse()}return function(s,A,c,p,w){var a,d,N,S,T,F,b,Y,te=s.indexOf("."),fe=m,X=l;for(te>=0&&(S=y,y=0,s=s.replace(".",""),Y=new B(A),F=Y.pow(s.length-te),y=S,Y.c=n(we(ce(F.c),F.e,"0"),10,c,t),Y.e=Y.c.length),b=n(s,A,c,w?(a=U,t):(a=t,U)),N=S=b.length;b[--S]==0;b.pop());if(!b[0])return a.charAt(0);if(te<0?--N:(F.c=b,F.e=N,F.s=p,F=I(F,Y,fe,X,c),b=F.c,T=F.r,N=F.e),d=N+fe+1,te=b[d],S=c/2,T=T||d<0||b[d+1]!=null,T=X<4?(te!=null||T)&&(X==0||X==(F.s<0?3:2)):te>S||te==S&&(X==4||T||X==6&&b[d-1]&1||X==(F.s<0?8:7)),d<1||!b[0])s=T?we(a.charAt(1),-fe,a.charAt(0)):a.charAt(0);else{if(b.length=d,T)for(--c;++b[--d]>c;)b[d]=0,d||(++N,b=[1].concat(b));for(S=b.length;!b[--S];);for(te=0,s="";te<=S;s+=a.charAt(b[te++]));s=we(s,N,a.charAt(0))}return s}}(),I=function(){function t(A,c,p){var w,a,d,N,S=0,T=A.length,F=c%oe,b=c/oe|0;for(A=A.slice();T--;)d=A[T]%oe,N=A[T]/oe|0,w=b*d+N*F,a=F*d+w%oe*oe+S,S=(a/p|0)+(w/oe|0)+b*N,A[T]=a%p;return S&&(A=[S].concat(A)),A}function n(A,c,p,w){var a,d;if(p!=w)d=p>w?1:-1;else for(a=d=0;a<p;a++)if(A[a]!=c[a]){d=A[a]>c[a]?1:-1;break}return d}function s(A,c,p,w){for(var a=0;p--;)A[p]-=a,a=A[p]<c[p]?1:0,A[p]=a*w+A[p]-c[p];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,c,p,w,a){var d,N,S,T,F,b,Y,te,fe,X,j,ae,ke,Ye,Qe,Oe,Ie,xe=A.s==c.s?1:-1,pe=A.c,ie=c.c;if(!pe||!pe[0]||!ie||!ie[0])return new B(!A.s||!c.s||(pe?ie&&pe[0]==ie[0]:!ie)?NaN:pe&&pe[0]==0||!ie?xe*0:xe/0);for(te=new B(xe),fe=te.c=[],N=A.e-c.e,xe=p+N+1,a||(a=z,N=ne(A.e/P)-ne(c.e/P),xe=xe/P|0),S=0;ie[S]==(pe[S]||0);S++);if(ie[S]>(pe[S]||0)&&N--,xe<0)fe.push(1),T=!0;else{for(Ye=pe.length,Oe=ie.length,S=0,xe+=2,F=v(a/(ie[0]+1)),F>1&&(ie=t(ie,F,a),pe=t(pe,F,a),Oe=ie.length,Ye=pe.length),ke=Oe,X=pe.slice(0,Oe),j=X.length;j<Oe;X[j++]=0);Ie=ie.slice(),Ie=[0].concat(Ie),Qe=ie[0],ie[1]>=a/2&&Qe++;do{if(F=0,d=n(ie,X,Oe,j),d<0){if(ae=X[0],Oe!=j&&(ae=ae*a+(X[1]||0)),F=v(ae/Qe),F>1)for(F>=a&&(F=a-1),b=t(ie,F,a),Y=b.length,j=X.length;n(b,X,Y,j)==1;)F--,s(b,Oe<Y?Ie:ie,Y,a),Y=b.length,d=1;else F==0&&(d=F=1),b=ie.slice(),Y=b.length;if(Y<j&&(b=[0].concat(b)),s(X,b,j,a),j=X.length,d==-1)for(;n(ie,X,Oe,j)<1;)F++,s(X,Oe<j?Ie:ie,j,a),j=X.length}else d===0&&(F++,X=[0]);fe[S++]=F,X[0]?X[j++]=pe[ke]||0:(X=[pe[ke]],j=1)}while((ke++<Ye||X[0]!=null)&&xe--);T=X[0]!=null,fe[0]||fe.splice(0,1)}if(a==z){for(S=1,xe=fe[0];xe>=10;xe/=10,S++);Q(te,p+(te.e=S+N*P-1)+1,w,T)}else te.e=N,te.r=+T;return te}}();function ee(t,n,s,A){var c,p,w,a,d;if(s==null?s=l:J(s,0,8),!t.c)return t.toString();if(c=t.c[0],w=t.e,n==null)d=ce(t.c),d=A==1||A==2&&(w<=g||w>=E)?Te(d,w):we(d,w,"0");else if(t=Q(new B(t),n,s),p=t.e,d=ce(t.c),a=d.length,A==1||A==2&&(n<=p||p<=g)){for(;a<n;d+="0",a++);d=Te(d,p)}else if(n-=w,d=we(d,p,"0"),p+1>a){if(--n>0)for(d+=".";n--;d+="0");}else if(n+=p-a,n>0)for(p+1==a&&(d+=".");n--;d+="0");return t.s<0&&c?"-"+d:d}function V(t,n){for(var s,A,c=1,p=new B(t[0]);c<t.length;c++)A=new B(t[c]),(!A.s||(s=he(p,A))===n||s===0&&p.s===n)&&(p=A);return p}function Z(t,n,s){for(var A=1,c=n.length;!n[--c];n.pop());for(c=n[0];c>=10;c/=10,A++);return(s=A+s*P-1)>h?t.c=t.e=null:s<u?t.c=[t.e=0]:(t.e=s,t.c=n),t}r=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,n=/^([^.]+)\.$/,s=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,c=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(p,w,a,d){var N,S=a?w:w.replace(c,"");if(A.test(S))p.s=isNaN(S)?null:S<0?-1:1;else{if(!a&&(S=S.replace(t,function(T,F,b){return N=(b=b.toLowerCase())=="x"?16:b=="b"?2:8,!d||d==N?F:T}),d&&(N=d,S=S.replace(n,"$1").replace(s,"0.$1")),w!=S))return new B(S,N);if(B.DEBUG)throw Error(M+"Not a"+(d?" base "+d:"")+" number: "+w);p.s=null}p.c=p.e=null}}();function Q(t,n,s,A){var c,p,w,a,d,N,S,T=t.c,F=Se;if(T){e:{for(c=1,a=T[0];a>=10;a/=10,c++);if(p=n-c,p<0)p+=P,w=n,d=T[N=0],S=v(d/F[c-w-1]%10);else if(N=D((p+1)/P),N>=T.length)if(A){for(;T.length<=N;T.push(0));d=S=0,c=1,p%=P,w=p-P+1}else break e;else{for(d=a=T[N],c=1;a>=10;a/=10,c++);p%=P,w=p-P+c,S=w<0?0:v(d/F[c-w-1]%10)}if(A=A||n<0||T[N+1]!=null||(w<0?d:d%F[c-w-1]),A=s<4?(S||A)&&(s==0||s==(t.s<0?3:2)):S>5||S==5&&(s==4||A||s==6&&(p>0?w>0?d/F[c-w]:0:T[N-1])%10&1||s==(t.s<0?8:7)),n<1||!T[0])return T.length=0,A?(n-=t.e+1,T[0]=F[(P-n%P)%P],t.e=-n||0):T[0]=t.e=0,t;if(p==0?(T.length=N,a=1,N--):(T.length=N+1,a=F[P-p],T[N]=w>0?v(d/F[c-w]%F[w])*a:0),A)for(;;)if(N==0){for(p=1,w=T[0];w>=10;w/=10,p++);for(w=T[0]+=a,a=1;w>=10;w/=10,a++);p!=a&&(t.e++,T[0]==z&&(T[0]=1));break}else{if(T[N]+=a,T[N]!=z)break;T[N--]=0,a=1}for(p=T.length;T[--p]===0;T.pop());}t.e>h?t.c=t.e=null:t.e<u&&(t.c=[t.e=0])}return t}function ge(t){var n,s=t.e;return s===null?t.toString():(n=ce(t.c),n=s<=g||s>=E?Te(n,s):we(n,s,"0"),t.s<0?"-"+n:n)}return e.absoluteValue=e.abs=function(){var t=new B(this);return t.s<0&&(t.s=1),t},e.comparedTo=function(t,n){return he(this,new B(t,n))},e.decimalPlaces=e.dp=function(t,n){var s,A,c,p=this;if(t!=null)return J(t,0,K),n==null?n=l:J(n,0,8),Q(new B(p),t+p.e+1,n);if(!(s=p.c))return null;if(A=((c=s.length-1)-ne(this.e/P))*P,c=s[c])for(;c%10==0;c/=10,A--);return A<0&&(A=0),A},e.dividedBy=e.div=function(t,n){return I(this,new B(t,n),m,l)},e.dividedToIntegerBy=e.idiv=function(t,n){return I(this,new B(t,n),0,1)},e.exponentiatedBy=e.pow=function(t,n){var s,A,c,p,w,a,d,N,S,T=this;if(t=new B(t),t.c&&!t.isInteger())throw Error(M+"Exponent not an integer: "+ge(t));if(n!=null&&(n=new B(n)),a=t.e>14,!T.c||!T.c[0]||T.c[0]==1&&!T.e&&T.c.length==1||!t.c||!t.c[0])return S=new B(Math.pow(+ge(T),a?t.s*(2-C(t)):+ge(t))),n?S.mod(n):S;if(d=t.s<0,n){if(n.c?!n.c[0]:!n.s)return new B(NaN);A=!d&&T.isInteger()&&n.isInteger(),A&&(T=T.mod(n))}else{if(t.e>9&&(T.e>0||T.e<-1||(T.e==0?T.c[0]>1||a&&T.c[1]>=24e7:T.c[0]<8e13||a&&T.c[0]<=9999975e7)))return p=T.s<0&&C(t)?-0:0,T.e>-1&&(p=1/p),new B(d?1/p:p);y&&(p=D(y/P+2))}for(a?(s=new B(.5),d&&(t.s=1),N=C(t)):(c=Math.abs(+ge(t)),N=c%2),S=new B(f);;){if(N){if(S=S.times(T),!S.c)break;p?S.c.length>p&&(S.c.length=p):A&&(S=S.mod(n))}if(c){if(c=v(c/2),c===0)break;N=c%2}else if(t=t.times(s),Q(t,t.e+1,1),t.e>14)N=C(t);else{if(c=+ge(t),c===0)break;N=c%2}T=T.times(T),p?T.c&&T.c.length>p&&(T.c.length=p):A&&(T=T.mod(n))}return A?S:(d&&(S=f.div(S)),n?S.mod(n):p?Q(S,y,l,w):S)},e.integerValue=function(t){var n=new B(this);return t==null?t=l:J(t,0,8),Q(n,n.e+1,t)},e.isEqualTo=e.eq=function(t,n){return he(this,new B(t,n))===0},e.isFinite=function(){return!!this.c},e.isGreaterThan=e.gt=function(t,n){return he(this,new B(t,n))>0},e.isGreaterThanOrEqualTo=e.gte=function(t,n){return(n=he(this,new B(t,n)))===1||n===0},e.isInteger=function(){return!!this.c&&ne(this.e/P)>this.c.length-2},e.isLessThan=e.lt=function(t,n){return he(this,new B(t,n))<0},e.isLessThanOrEqualTo=e.lte=function(t,n){return(n=he(this,new B(t,n)))===-1||n===0},e.isNaN=function(){return!this.s},e.isNegative=function(){return this.s<0},e.isPositive=function(){return this.s>0},e.isZero=function(){return!!this.c&&this.c[0]==0},e.minus=function(t,n){var s,A,c,p,w=this,a=w.s;if(t=new B(t,n),n=t.s,!a||!n)return new B(NaN);if(a!=n)return t.s=-n,w.plus(t);var d=w.e/P,N=t.e/P,S=w.c,T=t.c;if(!d||!N){if(!S||!T)return S?(t.s=-n,t):new B(T?w:NaN);if(!S[0]||!T[0])return T[0]?(t.s=-n,t):new B(S[0]?w:l==3?-0:0)}if(d=ne(d),N=ne(N),S=S.slice(),a=d-N){for((p=a<0)?(a=-a,c=S):(N=d,c=T),c.reverse(),n=a;n--;c.push(0));c.reverse()}else for(A=(p=(a=S.length)<(n=T.length))?a:n,a=n=0;n<A;n++)if(S[n]!=T[n]){p=S[n]<T[n];break}if(p&&(c=S,S=T,T=c,t.s=-t.s),n=(A=T.length)-(s=S.length),n>0)for(;n--;S[s++]=0);for(n=z-1;A>a;){if(S[--A]<T[A]){for(s=A;s&&!S[--s];S[s]=n);--S[s],S[A]+=z}S[A]-=T[A]}for(;S[0]==0;S.splice(0,1),--N);return S[0]?Z(t,S,N):(t.s=l==3?-1:1,t.c=[t.e=0],t)},e.modulo=e.mod=function(t,n){var s,A,c=this;return t=new B(t,n),!c.c||!t.s||t.c&&!t.c[0]?new B(NaN):!t.c||c.c&&!c.c[0]?new B(c):(x==9?(A=t.s,t.s=1,s=I(c,t,0,3),t.s=A,s.s*=A):s=I(c,t,0,x),t=c.minus(s.times(t)),!t.c[0]&&x==1&&(t.s=c.s),t)},e.multipliedBy=e.times=function(t,n){var s,A,c,p,w,a,d,N,S,T,F,b,Y,te,fe,X=this,j=X.c,ae=(t=new B(t,n)).c;if(!j||!ae||!j[0]||!ae[0])return!X.s||!t.s||j&&!j[0]&&!ae||ae&&!ae[0]&&!j?t.c=t.e=t.s=null:(t.s*=X.s,!j||!ae?t.c=t.e=null:(t.c=[0],t.e=0)),t;for(A=ne(X.e/P)+ne(t.e/P),t.s*=X.s,d=j.length,T=ae.length,d<T&&(Y=j,j=ae,ae=Y,c=d,d=T,T=c),c=d+T,Y=[];c--;Y.push(0));for(te=z,fe=oe,c=T;--c>=0;){for(s=0,F=ae[c]%fe,b=ae[c]/fe|0,w=d,p=c+w;p>c;)N=j[--w]%fe,S=j[w]/fe|0,a=b*N+S*F,N=F*N+a%fe*fe+Y[p]+s,s=(N/te|0)+(a/fe|0)+b*S,Y[p--]=N%te;Y[p]=s}return s?++A:Y.splice(0,1),Z(t,Y,A)},e.negated=function(){var t=new B(this);return t.s=-t.s||null,t},e.plus=function(t,n){var s,A=this,c=A.s;if(t=new B(t,n),n=t.s,!c||!n)return new B(NaN);if(c!=n)return t.s=-n,A.minus(t);var p=A.e/P,w=t.e/P,a=A.c,d=t.c;if(!p||!w){if(!a||!d)return new B(c/0);if(!a[0]||!d[0])return d[0]?t:new B(a[0]?A:c*0)}if(p=ne(p),w=ne(w),a=a.slice(),c=p-w){for(c>0?(w=p,s=d):(c=-c,s=a),s.reverse();c--;s.push(0));s.reverse()}for(c=a.length,n=d.length,c-n<0&&(s=d,d=a,a=s,n=c),c=0;n;)c=(a[--n]=a[n]+d[n]+c)/z|0,a[n]=z===a[n]?0:a[n]%z;return c&&(a=[c].concat(a),++w),Z(t,a,w)},e.precision=e.sd=function(t,n){var s,A,c,p=this;if(t!=null&&t!==!!t)return J(t,1,K),n==null?n=l:J(n,0,8),Q(new B(p),t,n);if(!(s=p.c))return null;if(c=s.length-1,A=c*P+1,c=s[c]){for(;c%10==0;c/=10,A--);for(c=s[0];c>=10;c/=10,A++);}return t&&p.e+1>A&&(A=p.e+1),A},e.shiftedBy=function(t){return J(t,-le,le),this.times("1e"+t)},e.squareRoot=e.sqrt=function(){var t,n,s,A,c,p=this,w=p.c,a=p.s,d=p.e,N=m+4,S=new B("0.5");if(a!==1||!w||!w[0])return new B(!a||a<0&&(!w||w[0])?NaN:w?p:1/0);if(a=Math.sqrt(+ge(p)),a==0||a==1/0?(n=ce(w),(n.length+d)%2==0&&(n+="0"),a=Math.sqrt(+n),d=ne((d+1)/2)-(d<0||d%2),a==1/0?n="5e"+d:(n=a.toExponential(),n=n.slice(0,n.indexOf("e")+1)+d),s=new B(n)):s=new B(a+""),s.c[0]){for(d=s.e,a=d+N,a<3&&(a=0);;)if(c=s,s=S.times(c.plus(I(p,c,N,1))),ce(c.c).slice(0,a)===(n=ce(s.c)).slice(0,a))if(s.e<d&&--a,n=n.slice(a-3,a+1),n=="9999"||!A&&n=="4999"){if(!A&&(Q(c,c.e+m+2,0),c.times(c).eq(p))){s=c;break}N+=4,a+=4,A=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(Q(s,s.e+m+2,1),t=!s.times(s).eq(p));break}}return Q(s,s.e+m+1,l,t)},e.toExponential=function(t,n){return t!=null&&(J(t,0,K),t++),ee(this,t,n,1)},e.toFixed=function(t,n){return t!=null&&(J(t,0,K),t=t+this.e+1),ee(this,t,n)},e.toFormat=function(t,n,s){var A,c=this;if(s==null)t!=null&&n&&typeof n=="object"?(s=n,n=null):t&&typeof t=="object"?(s=t,t=n=null):s=R;else if(typeof s!="object")throw Error(M+"Argument not an object: "+s);if(A=c.toFixed(t,n),c.c){var p,w=A.split("."),a=+s.groupSize,d=+s.secondaryGroupSize,N=s.groupSeparator||"",S=w[0],T=w[1],F=c.s<0,b=F?S.slice(1):S,Y=b.length;if(d&&(p=a,a=d,d=p,Y-=p),a>0&&Y>0){for(p=Y%a||a,S=b.substr(0,p);p<Y;p+=a)S+=N+b.substr(p,a);d>0&&(S+=N+b.slice(p)),F&&(S="-"+S)}A=T?S+(s.decimalSeparator||"")+((d=+s.fractionGroupSize)?T.replace(new RegExp("\\d{"+d+"}\\B","g"),"$&"+(s.fractionGroupSeparator||"")):T):S}return(s.prefix||"")+A+(s.suffix||"")},e.toFraction=function(t){var n,s,A,c,p,w,a,d,N,S,T,F,b=this,Y=b.c;if(t!=null&&(a=new B(t),!a.isInteger()&&(a.c||a.s!==1)||a.lt(f)))throw Error(M+"Argument "+(a.isInteger()?"out of range: ":"not an integer: ")+ge(a));if(!Y)return new B(b);for(n=new B(f),N=s=new B(f),A=d=new B(f),F=ce(Y),p=n.e=F.length-b.e-1,n.c[0]=Se[(w=p%P)<0?P+w:w],t=!t||a.comparedTo(n)>0?p>0?n:N:a,w=h,h=1/0,a=new B(F),d.c[0]=0;S=I(a,n,0,1),c=s.plus(S.times(A)),c.comparedTo(t)!=1;)s=A,A=c,N=d.plus(S.times(c=N)),d=c,n=a.minus(S.times(c=n)),a=c;return c=I(t.minus(s),A,0,1),d=d.plus(c.times(N)),s=s.plus(c.times(A)),d.s=N.s=b.s,p=p*2,T=I(N,A,p,l).minus(b).abs().comparedTo(I(d,s,p,l).minus(b).abs())<1?[N,A]:[d,s],h=w,T},e.toNumber=function(){return+ge(this)},e.toPrecision=function(t,n){return t!=null&&J(t,1,K),ee(this,t,n,2)},e.toString=function(t){var n,s=this,A=s.s,c=s.e;return c===null?A?(n="Infinity",A<0&&(n="-"+n)):n="NaN":(t==null?n=c<=g||c>=E?Te(ce(s.c),c):we(ce(s.c),c,"0"):t===10&&H?(s=Q(new B(s),m+c+1,l),n=we(ce(s.c),s.e,"0")):(J(t,2,U.length,"Base"),n=$(we(ce(s.c),c,"0"),10,t,A,!0)),A<0&&s.c[0]&&(n="-"+n)),n},e.valueOf=e.toJSON=function(){return ge(this)},e._isBigNumber=!0,G!=null&&B.set(G),B}function ne(G){var I=G|0;return G>0||G===I?I:I-1}function ce(G){for(var I,$,r=1,e=G.length,f=G[0]+"";r<e;){for(I=G[r++]+"",$=P-I.length;$--;I="0"+I);f+=I}for(e=f.length;f.charCodeAt(--e)===48;);return f.slice(0,e+1||1)}function he(G,I){var $,r,e=G.c,f=I.c,m=G.s,l=I.s,g=G.e,E=I.e;if(!m||!l)return null;if($=e&&!e[0],r=f&&!f[0],$||r)return $?r?0:-l:m;if(m!=l)return m;if($=m<0,r=g==E,!e||!f)return r?0:!e^$?1:-1;if(!r)return g>E^$?1:-1;for(l=(g=e.length)<(E=f.length)?g:E,m=0;m<l;m++)if(e[m]!=f[m])return e[m]>f[m]^$?1:-1;return g==E?0:g>E^$?1:-1}function J(G,I,$,r){if(G<I||G>$||G!==v(G))throw Error(M+(r||"Argument")+(typeof G=="number"?G<I||G>$?" out of range: ":" not an integer: ":" not a primitive number: ")+String(G))}function C(G){var I=G.c.length-1;return ne(G.e/P)==I&&G.c[I]%2!=0}function Te(G,I){return(G.length>1?G.charAt(0)+"."+G.slice(1):G)+(I<0?"e":"e+")+I}function we(G,I,$){var r,e;if(I<0){for(e=$+".";++I;e+=$);G=e+G}else if(r=G.length,++I>r){for(e=$,I-=r;--I;e+=$);G+=e}else I<r&&(G=G.slice(0,I)+"."+G.slice(I));return G}i=Be(),i.default=i.BigNumber=i,typeof define=="function"&&define.amd?define(function(){return i}):typeof ze<"u"&&ze.exports?ze.exports=i:(o||(o=typeof self<"u"&&self?self:window),o.BigNumber=i)})(Ar)});var er=je(ve=>{"use strict";var Jr=ve&&ve.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(ve,"__esModule",{value:!0});ve.ChainValue=ve.ChainValueFormats=void 0;var Fe=Jr(_r());Fe.default.config({EXPONENTIAL_AT:[-9,20],DECIMAL_PLACES:8});var Kr={decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0,suffix:""},et={decimalSeparator:",",groupSeparator:".",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0,suffix:""};ve.ChainValueFormats={DotDecimal:Kr,CommaDecimal:et};function He(o){if(!(o&&/^-?\d*(\.\d+)?$/.test(o)))throw new Error(`Invalid value: ${o}`)}var Ke=class o{_big;_decimals;constructor(i){if(i<0||i>8)throw new Error("Decimals must be between 0 and 8");this._big=new Fe.default(0),this._decimals=i}static create(i){return new o(i)}getDecimals(){return this._decimals}getRaw(){return this._big}getAtomic(){return this._big.dp(0).toString()}setAtomic(i){return typeof i=="number"?this._big=new Fe.default(Math.floor(i)):(He(i),this._big=new Fe.default(i)),this}getCompound(){return this._big.dividedBy(10**this._decimals).dp(this._decimals).toString()}setCompound(i){return typeof i=="string"&&He(i),this._big=new Fe.default(i||0).multipliedBy(10**this._decimals),this}equals(i){return this._big.eq(i._big)}lessOrEqual(i){return this._big.lte(i._big)}less(i){return this._big.lt(i._big)}greaterOrEqual(i){return this._big.gte(i._big)}greater(i){return this._big.gt(i._big)}add(i){return this._big=this._big.plus(i._big),this}subtract(i){return this._big=this._big.minus(i._big),this}multiply(i){let O=i;return typeof i=="string"&&(He(i),O=parseFloat(i)),this._big=this._big.multipliedBy(O),this}divide(i){let O=i;if(typeof i=="string"&&(He(i),O=parseFloat(i)),O===0)throw new Error("Division by zero");return this._big=this._big.div(O),this}toFormat(i,O=ve.ChainValueFormats.DotDecimal){return this._big.dividedBy(10**this._decimals).toFormat({...O,prefix:i})}clone(){let i=new o(this._decimals);return i._big=this._big,i}};ve.ChainValue=Ke});var Sr={};mr(Sr,{CurrencySymbol:()=>Er,FeeQuantPlanck:()=>rt,OneSignaPlanck:()=>tt});var Er,rt,tt,rr=jr(()=>{"use strict";Er="\uA7A8",rt=1e6,tt=1e8});var Ve=je(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.Amount=de.AmountFormats=de.FormatCommaDecimal=de.FormatDotDecimal=void 0;var ir=(rr(),dr(Sr)),it=er();de.FormatDotDecimal={prefix:ir.CurrencySymbol+" ",decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0,suffix:""};de.FormatCommaDecimal={prefix:ir.CurrencySymbol+" ",decimalSeparator:",",groupSeparator:".",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0,suffix:""};de.AmountFormats={DotDecimal:de.FormatDotDecimal,CommaDecimal:de.FormatCommaDecimal};var tr=class o{_value;constructor(i){this._value=new it.ChainValue(8).setAtomic(i)}static CurrencySymbol(){return ir.CurrencySymbol}static Zero(){return new o(0)}static fromPlanck(i){return new o(i)}static fromSigna(i){let O=new o("0");return O.setSigna(typeof i=="number"?i.toString(10):i),O}getRaw(){return this._value.getRaw()}getPlanck(){return this._value.getAtomic()}setPlanck(i){return this._value.setAtomic(i),this}getSigna(){return this._value.getCompound()}setSigna(i){return this._value.setCompound(i),this}equals(i){return this._value.equals(i._value)}lessOrEqual(i){return this._value.lessOrEqual(i._value)}less(i){return this._value.less(i._value)}greaterOrEqual(i){return this._value.greaterOrEqual(i._value)}greater(i){return this._value.greater(i._value)}add(i){return this._value.add(i._value),this}subtract(i){return this._value.subtract(i._value),this}multiply(i){return this._value.multiply(i),this}divide(i){return this._value.divide(i),this}toString(i=de.AmountFormats.DotDecimal){return this._value.toFormat(i.prefix,i)}clone(){return o.fromPlanck(this.getPlanck())}};de.Amount=tr});var k={};mr(k,{ChainTime:()=>Je,CurrencySymbol:()=>Er,FeeQuantPlanck:()=>rt,OneSignaPlanck:()=>tt,asyncRetry:()=>wr,convertAssetPriceToPlanck:()=>yt,convertBase36StringToHexString:()=>ft,convertBase64StringToString:()=>wt,convertByteArrayToHexString:()=>ar,convertByteArrayToString:()=>hr,convertDecStringToHexString:()=>At,convertHexEndianess:()=>_t,convertHexStringToBase36String:()=>Et,convertHexStringToByteArray:()=>pr,convertHexStringToDecString:()=>St,convertHexStringToString:()=>Nt,convertPlanckToAssetPrice:()=>Bt,convertStringToBase64String:()=>Ot,convertStringToByteArray:()=>gr,convertStringToHexString:()=>vt});async function wr(o){let{asyncFn:i,onFailureAsync:O,retryCount:D=1,maxRetrials:v=20}=o;try{return await i()}catch(M){if(D>v)throw M;if(await O(M,D))await wr({asyncFn:i,onFailureAsync:O,retryCount:D+1});else throw M}}var xr=Date.UTC(2014,7,11,2,0,0,0)/1e3,Je=class o{_chainTimestamp;constructor(i){this._chainTimestamp=i}static fromChainTimestamp(i){return new o(i)}static fromDate(i){let O=new o(0);return O.setDate(i),O}getChainTimestamp(){return this._chainTimestamp}setChainTimestamp(i){this._chainTimestamp=i}getEpoch(){return(xr+this._chainTimestamp)*1e3}getDate(){return new Date(this.getEpoch())}setDate(i){this._chainTimestamp=Math.round(i.getTime()/1e3)-xr}equals(i){return this._chainTimestamp===i._chainTimestamp}before(i){return this._chainTimestamp<i._chainTimestamp}after(i){return this._chainTimestamp>i._chainTimestamp}};L(k,qe(er()));L(k,qe(Ve()));rr();var nt=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,nr=Math.ceil,_e=Math.floor,me="[BigNumber Error] ",Nr=me+"Number primitive has more than 15 significant digits: ",Ne=1e14,q=14,or=9007199254740991,fr=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Ce=1e7,se=1e9;function Or(o){var i,O,D,v=C.prototype={constructor:C,toString:null,valueOf:null},M=new C(1),W=20,z=4,P=-7,le=21,Se=-1e7,oe=1e7,K=!1,Be=1,ne=0,ce={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},he="0123456789abcdefghijklmnopqrstuvwxyz",J=!0;function C(r,e){var f,m,l,g,E,u,h,_,x=this;if(!(x instanceof C))return new C(r,e);if(e==null){if(r&&r._isBigNumber===!0){x.s=r.s,!r.c||r.e>oe?x.c=x.e=null:r.e<Se?x.c=[x.e=0]:(x.e=r.e,x.c=r.c.slice());return}if((u=typeof r=="number")&&r*0==0){if(x.s=1/r<0?(r=-r,-1):1,r===~~r){for(g=0,E=r;E>=10;E/=10,g++);g>oe?x.c=x.e=null:(x.e=g,x.c=[r]);return}_=String(r)}else{if(!nt.test(_=String(r)))return D(x,_,u);x.s=_.charCodeAt(0)==45?(_=_.slice(1),-1):1}(g=_.indexOf("."))>-1&&(_=_.replace(".","")),(E=_.search(/e/i))>0?(g<0&&(g=E),g+=+_.slice(E+1),_=_.substring(0,E)):g<0&&(g=_.length)}else{if(re(e,2,he.length,"Base"),e==10&&J)return x=new C(r),I(x,W+x.e+1,z);if(_=String(r),u=typeof r=="number"){if(r*0!=0)return D(x,_,u,e);if(x.s=1/r<0?(_=_.slice(1),-1):1,C.DEBUG&&_.replace(/^0\.0*|\./,"").length>15)throw Error(Nr+r)}else x.s=_.charCodeAt(0)===45?(_=_.slice(1),-1):1;for(f=he.slice(0,e),g=E=0,h=_.length;E<h;E++)if(f.indexOf(m=_.charAt(E))<0){if(m=="."){if(E>g){g=h;continue}}else if(!l&&(_==_.toUpperCase()&&(_=_.toLowerCase())||_==_.toLowerCase()&&(_=_.toUpperCase()))){l=!0,E=-1,g=0;continue}return D(x,String(r),u,e)}u=!1,_=O(_,e,10,x.s),(g=_.indexOf("."))>-1?_=_.replace(".",""):g=_.length}for(E=0;_.charCodeAt(E)===48;E++);for(h=_.length;_.charCodeAt(--h)===48;);if(_=_.slice(E,++h)){if(h-=E,u&&C.DEBUG&&h>15&&(r>or||r!==_e(r)))throw Error(Nr+x.s*r);if((g=g-E-1)>oe)x.c=x.e=null;else if(g<Se)x.c=[x.e=0];else{if(x.e=g,x.c=[],E=(g+1)%q,g<0&&(E+=q),E<h){for(E&&x.c.push(+_.slice(0,E)),h-=q;E<h;)x.c.push(+_.slice(E,E+=q));E=q-(_=_.slice(E)).length}else E-=h;for(;E--;_+="0");x.c.push(+_)}}else x.c=[x.e=0]}C.clone=Or,C.ROUND_UP=0,C.ROUND_DOWN=1,C.ROUND_CEIL=2,C.ROUND_FLOOR=3,C.ROUND_HALF_UP=4,C.ROUND_HALF_DOWN=5,C.ROUND_HALF_EVEN=6,C.ROUND_HALF_CEIL=7,C.ROUND_HALF_FLOOR=8,C.EUCLID=9,C.config=C.set=function(r){var e,f;if(r!=null)if(typeof r=="object"){if(r.hasOwnProperty(e="DECIMAL_PLACES")&&(f=r[e],re(f,0,se,e),W=f),r.hasOwnProperty(e="ROUNDING_MODE")&&(f=r[e],re(f,0,8,e),z=f),r.hasOwnProperty(e="EXPONENTIAL_AT")&&(f=r[e],f&&f.pop?(re(f[0],-se,0,e),re(f[1],0,se,e),P=f[0],le=f[1]):(re(f,-se,se,e),P=-(le=f<0?-f:f))),r.hasOwnProperty(e="RANGE"))if(f=r[e],f&&f.pop)re(f[0],-se,-1,e),re(f[1],1,se,e),Se=f[0],oe=f[1];else if(re(f,-se,se,e),f)Se=-(oe=f<0?-f:f);else throw Error(me+e+" cannot be zero: "+f);if(r.hasOwnProperty(e="CRYPTO"))if(f=r[e],f===!!f)if(f)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))K=f;else throw K=!f,Error(me+"crypto unavailable");else K=f;else throw Error(me+e+" not true or false: "+f);if(r.hasOwnProperty(e="MODULO_MODE")&&(f=r[e],re(f,0,9,e),Be=f),r.hasOwnProperty(e="POW_PRECISION")&&(f=r[e],re(f,0,se,e),ne=f),r.hasOwnProperty(e="FORMAT"))if(f=r[e],typeof f=="object")ce=f;else throw Error(me+e+" not an object: "+f);if(r.hasOwnProperty(e="ALPHABET"))if(f=r[e],typeof f=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(f))J=f.slice(0,10)=="0123456789",he=f;else throw Error(me+e+" invalid: "+f)}else throw Error(me+"Object expected: "+r);return{DECIMAL_PLACES:W,ROUNDING_MODE:z,EXPONENTIAL_AT:[P,le],RANGE:[Se,oe],CRYPTO:K,MODULO_MODE:Be,POW_PRECISION:ne,FORMAT:ce,ALPHABET:he}},C.isBigNumber=function(r){if(!r||r._isBigNumber!==!0)return!1;if(!C.DEBUG)return!0;var e,f,m=r.c,l=r.e,g=r.s;e:if({}.toString.call(m)=="[object Array]"){if((g===1||g===-1)&&l>=-se&&l<=se&&l===_e(l)){if(m[0]===0){if(l===0&&m.length===1)return!0;break e}if(e=(l+1)%q,e<1&&(e+=q),String(m[0]).length==e){for(e=0;e<m.length;e++)if(f=m[e],f<0||f>=Ne||f!==_e(f))break e;if(f!==0)return!0}}}else if(m===null&&l===null&&(g===null||g===1||g===-1))return!0;throw Error(me+"Invalid BigNumber: "+r)},C.maximum=C.max=function(){return we(arguments,-1)},C.minimum=C.min=function(){return we(arguments,1)},C.random=function(){var r=9007199254740992,e=Math.random()*r&2097151?function(){return _e(Math.random()*r)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(f){var m,l,g,E,u,h=0,_=[],x=new C(M);if(f==null?f=W:re(f,0,se),E=nr(f/q),K)if(crypto.getRandomValues){for(m=crypto.getRandomValues(new Uint32Array(E*=2));h<E;)u=m[h]*131072+(m[h+1]>>>11),u>=9e15?(l=crypto.getRandomValues(new Uint32Array(2)),m[h]=l[0],m[h+1]=l[1]):(_.push(u%1e14),h+=2);h=E/2}else if(crypto.randomBytes){for(m=crypto.randomBytes(E*=7);h<E;)u=(m[h]&31)*281474976710656+m[h+1]*1099511627776+m[h+2]*4294967296+m[h+3]*16777216+(m[h+4]<<16)+(m[h+5]<<8)+m[h+6],u>=9e15?crypto.randomBytes(7).copy(m,h):(_.push(u%1e14),h+=7);h=E/7}else throw K=!1,Error(me+"crypto unavailable");if(!K)for(;h<E;)u=e(),u<9e15&&(_[h++]=u%1e14);for(E=_[--h],f%=q,E&&f&&(u=fr[q-f],_[h]=_e(E/u)*u);_[h]===0;_.pop(),h--);if(h<0)_=[g=0];else{for(g=-1;_[0]===0;_.splice(0,1),g-=q);for(h=1,u=_[0];u>=10;u/=10,h++);h<q&&(g-=q-h)}return x.e=g,x.c=_,x}}(),C.sum=function(){for(var r=1,e=arguments,f=new C(e[0]);r<e.length;)f=f.plus(e[r++]);return f},O=function(){var r="0123456789";function e(f,m,l,g){for(var E,u=[0],h,_=0,x=f.length;_<x;){for(h=u.length;h--;u[h]*=m);for(u[0]+=g.indexOf(f.charAt(_++)),E=0;E<u.length;E++)u[E]>l-1&&(u[E+1]==null&&(u[E+1]=0),u[E+1]+=u[E]/l|0,u[E]%=l)}return u.reverse()}return function(f,m,l,g,E){var u,h,_,x,y,R,U,H,B=f.indexOf("."),ee=W,V=z;for(B>=0&&(x=ne,ne=0,f=f.replace(".",""),H=new C(m),R=H.pow(f.length-B),ne=x,H.c=e(ye(Ae(R.c),R.e,"0"),10,l,r),H.e=H.c.length),U=e(f,m,l,E?(u=he,r):(u=r,he)),_=x=U.length;U[--x]==0;U.pop());if(!U[0])return u.charAt(0);if(B<0?--_:(R.c=U,R.e=_,R.s=g,R=i(R,H,ee,V,l),U=R.c,y=R.r,_=R.e),h=_+ee+1,B=U[h],x=l/2,y=y||h<0||U[h+1]!=null,y=V<4?(B!=null||y)&&(V==0||V==(R.s<0?3:2)):B>x||B==x&&(V==4||y||V==6&&U[h-1]&1||V==(R.s<0?8:7)),h<1||!U[0])f=y?ye(u.charAt(1),-ee,u.charAt(0)):u.charAt(0);else{if(U.length=h,y)for(--l;++U[--h]>l;)U[h]=0,h||(++_,U=[1].concat(U));for(x=U.length;!U[--x];);for(B=0,f="";B<=x;f+=u.charAt(U[B++]));f=ye(f,_,u.charAt(0))}return f}}(),i=function(){function r(m,l,g){var E,u,h,_,x=0,y=m.length,R=l%Ce,U=l/Ce|0;for(m=m.slice();y--;)h=m[y]%Ce,_=m[y]/Ce|0,E=U*h+_*R,u=R*h+E%Ce*Ce+x,x=(u/g|0)+(E/Ce|0)+U*_,m[y]=u%g;return x&&(m=[x].concat(m)),m}function e(m,l,g,E){var u,h;if(g!=E)h=g>E?1:-1;else for(u=h=0;u<g;u++)if(m[u]!=l[u]){h=m[u]>l[u]?1:-1;break}return h}function f(m,l,g,E){for(var u=0;g--;)m[g]-=u,u=m[g]<l[g]?1:0,m[g]=u*E+m[g]-l[g];for(;!m[0]&&m.length>1;m.splice(0,1));}return function(m,l,g,E,u){var h,_,x,y,R,U,H,B,ee,V,Z,Q,ge,t,n,s,A,c=m.s==l.s?1:-1,p=m.c,w=l.c;if(!p||!p[0]||!w||!w[0])return new C(!m.s||!l.s||(p?w&&p[0]==w[0]:!w)?NaN:p&&p[0]==0||!w?c*0:c/0);for(B=new C(c),ee=B.c=[],_=m.e-l.e,c=g+_+1,u||(u=Ne,_=Ee(m.e/q)-Ee(l.e/q),c=c/q|0),x=0;w[x]==(p[x]||0);x++);if(w[x]>(p[x]||0)&&_--,c<0)ee.push(1),y=!0;else{for(t=p.length,s=w.length,x=0,c+=2,R=_e(u/(w[0]+1)),R>1&&(w=r(w,R,u),p=r(p,R,u),s=w.length,t=p.length),ge=s,V=p.slice(0,s),Z=V.length;Z<s;V[Z++]=0);A=w.slice(),A=[0].concat(A),n=w[0],w[1]>=u/2&&n++;do{if(R=0,h=e(w,V,s,Z),h<0){if(Q=V[0],s!=Z&&(Q=Q*u+(V[1]||0)),R=_e(Q/n),R>1)for(R>=u&&(R=u-1),U=r(w,R,u),H=U.length,Z=V.length;e(U,V,H,Z)==1;)R--,f(U,s<H?A:w,H,u),H=U.length,h=1;else R==0&&(h=R=1),U=w.slice(),H=U.length;if(H<Z&&(U=[0].concat(U)),f(V,U,Z,u),Z=V.length,h==-1)for(;e(w,V,s,Z)<1;)R++,f(V,s<Z?A:w,Z,u),Z=V.length}else h===0&&(R++,V=[0]);ee[x++]=R,V[0]?V[Z++]=p[ge]||0:(V=[p[ge]],Z=1)}while((ge++<t||V[0]!=null)&&c--);y=V[0]!=null,ee[0]||ee.splice(0,1)}if(u==Ne){for(x=1,c=ee[0];c>=10;c/=10,x++);I(B,g+(B.e=x+_*q-1)+1,E,y)}else B.e=_,B.r=+y;return B}}();function Te(r,e,f,m){var l,g,E,u,h;if(f==null?f=z:re(f,0,8),!r.c)return r.toString();if(l=r.c[0],E=r.e,e==null)h=Ae(r.c),h=m==1||m==2&&(E<=P||E>=le)?Xe(h,E):ye(h,E,"0");else if(r=I(new C(r),e,f),g=r.e,h=Ae(r.c),u=h.length,m==1||m==2&&(e<=g||g<=P)){for(;u<e;h+="0",u++);h=Xe(h,g)}else if(e-=E,h=ye(h,g,"0"),g+1>u){if(--e>0)for(h+=".";e--;h+="0");}else if(e+=g-u,e>0)for(g+1==u&&(h+=".");e--;h+="0");return r.s<0&&l?"-"+h:h}function we(r,e){for(var f,m,l=1,g=new C(r[0]);l<r.length;l++)m=new C(r[l]),(!m.s||(f=Ue(g,m))===e||f===0&&g.s===e)&&(g=m);return g}function G(r,e,f){for(var m=1,l=e.length;!e[--l];e.pop());for(l=e[0];l>=10;l/=10,m++);return(f=m+f*q-1)>oe?r.c=r.e=null:f<Se?r.c=[r.e=0]:(r.e=f,r.c=e),r}D=function(){var r=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,f=/^\.([^.]+)$/,m=/^-?(Infinity|NaN)$/,l=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(g,E,u,h){var _,x=u?E:E.replace(l,"");if(m.test(x))g.s=isNaN(x)?null:x<0?-1:1;else{if(!u&&(x=x.replace(r,function(y,R,U){return _=(U=U.toLowerCase())=="x"?16:U=="b"?2:8,!h||h==_?R:y}),h&&(_=h,x=x.replace(e,"$1").replace(f,"0.$1")),E!=x))return new C(x,_);if(C.DEBUG)throw Error(me+"Not a"+(h?" base "+h:"")+" number: "+E);g.s=null}g.c=g.e=null}}();function I(r,e,f,m){var l,g,E,u,h,_,x,y=r.c,R=fr;if(y){e:{for(l=1,u=y[0];u>=10;u/=10,l++);if(g=e-l,g<0)g+=q,E=e,h=y[_=0],x=_e(h/R[l-E-1]%10);else if(_=nr((g+1)/q),_>=y.length)if(m){for(;y.length<=_;y.push(0));h=x=0,l=1,g%=q,E=g-q+1}else break e;else{for(h=u=y[_],l=1;u>=10;u/=10,l++);g%=q,E=g-q+l,x=E<0?0:_e(h/R[l-E-1]%10)}if(m=m||e<0||y[_+1]!=null||(E<0?h:h%R[l-E-1]),m=f<4?(x||m)&&(f==0||f==(r.s<0?3:2)):x>5||x==5&&(f==4||m||f==6&&(g>0?E>0?h/R[l-E]:0:y[_-1])%10&1||f==(r.s<0?8:7)),e<1||!y[0])return y.length=0,m?(e-=r.e+1,y[0]=R[(q-e%q)%q],r.e=-e||0):y[0]=r.e=0,r;if(g==0?(y.length=_,u=1,_--):(y.length=_+1,u=R[q-g],y[_]=E>0?_e(h/R[l-E]%R[E])*u:0),m)for(;;)if(_==0){for(g=1,E=y[0];E>=10;E/=10,g++);for(E=y[0]+=u,u=1;E>=10;E/=10,u++);g!=u&&(r.e++,y[0]==Ne&&(y[0]=1));break}else{if(y[_]+=u,y[_]!=Ne)break;y[_--]=0,u=1}for(g=y.length;y[--g]===0;y.pop());}r.e>oe?r.c=r.e=null:r.e<Se&&(r.c=[r.e=0])}return r}function $(r){var e,f=r.e;return f===null?r.toString():(e=Ae(r.c),e=f<=P||f>=le?Xe(e,f):ye(e,f,"0"),r.s<0?"-"+e:e)}return v.absoluteValue=v.abs=function(){var r=new C(this);return r.s<0&&(r.s=1),r},v.comparedTo=function(r,e){return Ue(this,new C(r,e))},v.decimalPlaces=v.dp=function(r,e){var f,m,l,g=this;if(r!=null)return re(r,0,se),e==null?e=z:re(e,0,8),I(new C(g),r+g.e+1,e);if(!(f=g.c))return null;if(m=((l=f.length-1)-Ee(this.e/q))*q,l=f[l])for(;l%10==0;l/=10,m--);return m<0&&(m=0),m},v.dividedBy=v.div=function(r,e){return i(this,new C(r,e),W,z)},v.dividedToIntegerBy=v.idiv=function(r,e){return i(this,new C(r,e),0,1)},v.exponentiatedBy=v.pow=function(r,e){var f,m,l,g,E,u,h,_,x,y=this;if(r=new C(r),r.c&&!r.isInteger())throw Error(me+"Exponent not an integer: "+$(r));if(e!=null&&(e=new C(e)),u=r.e>14,!y.c||!y.c[0]||y.c[0]==1&&!y.e&&y.c.length==1||!r.c||!r.c[0])return x=new C(Math.pow(+$(y),u?r.s*(2-$e(r)):+$(r))),e?x.mod(e):x;if(h=r.s<0,e){if(e.c?!e.c[0]:!e.s)return new C(NaN);m=!h&&y.isInteger()&&e.isInteger(),m&&(y=y.mod(e))}else{if(r.e>9&&(y.e>0||y.e<-1||(y.e==0?y.c[0]>1||u&&y.c[1]>=24e7:y.c[0]<8e13||u&&y.c[0]<=9999975e7)))return g=y.s<0&&$e(r)?-0:0,y.e>-1&&(g=1/g),new C(h?1/g:g);ne&&(g=nr(ne/q+2))}for(u?(f=new C(.5),h&&(r.s=1),_=$e(r)):(l=Math.abs(+$(r)),_=l%2),x=new C(M);;){if(_){if(x=x.times(y),!x.c)break;g?x.c.length>g&&(x.c.length=g):m&&(x=x.mod(e))}if(l){if(l=_e(l/2),l===0)break;_=l%2}else if(r=r.times(f),I(r,r.e+1,1),r.e>14)_=$e(r);else{if(l=+$(r),l===0)break;_=l%2}y=y.times(y),g?y.c&&y.c.length>g&&(y.c.length=g):m&&(y=y.mod(e))}return m?x:(h&&(x=M.div(x)),e?x.mod(e):g?I(x,ne,z,E):x)},v.integerValue=function(r){var e=new C(this);return r==null?r=z:re(r,0,8),I(e,e.e+1,r)},v.isEqualTo=v.eq=function(r,e){return Ue(this,new C(r,e))===0},v.isFinite=function(){return!!this.c},v.isGreaterThan=v.gt=function(r,e){return Ue(this,new C(r,e))>0},v.isGreaterThanOrEqualTo=v.gte=function(r,e){return(e=Ue(this,new C(r,e)))===1||e===0},v.isInteger=function(){return!!this.c&&Ee(this.e/q)>this.c.length-2},v.isLessThan=v.lt=function(r,e){return Ue(this,new C(r,e))<0},v.isLessThanOrEqualTo=v.lte=function(r,e){return(e=Ue(this,new C(r,e)))===-1||e===0},v.isNaN=function(){return!this.s},v.isNegative=function(){return this.s<0},v.isPositive=function(){return this.s>0},v.isZero=function(){return!!this.c&&this.c[0]==0},v.minus=function(r,e){var f,m,l,g,E=this,u=E.s;if(r=new C(r,e),e=r.s,!u||!e)return new C(NaN);if(u!=e)return r.s=-e,E.plus(r);var h=E.e/q,_=r.e/q,x=E.c,y=r.c;if(!h||!_){if(!x||!y)return x?(r.s=-e,r):new C(y?E:NaN);if(!x[0]||!y[0])return y[0]?(r.s=-e,r):new C(x[0]?E:z==3?-0:0)}if(h=Ee(h),_=Ee(_),x=x.slice(),u=h-_){for((g=u<0)?(u=-u,l=x):(_=h,l=y),l.reverse(),e=u;e--;l.push(0));l.reverse()}else for(m=(g=(u=x.length)<(e=y.length))?u:e,u=e=0;e<m;e++)if(x[e]!=y[e]){g=x[e]<y[e];break}if(g&&(l=x,x=y,y=l,r.s=-r.s),e=(m=y.length)-(f=x.length),e>0)for(;e--;x[f++]=0);for(e=Ne-1;m>u;){if(x[--m]<y[m]){for(f=m;f&&!x[--f];x[f]=e);--x[f],x[m]+=Ne}x[m]-=y[m]}for(;x[0]==0;x.splice(0,1),--_);return x[0]?G(r,x,_):(r.s=z==3?-1:1,r.c=[r.e=0],r)},v.modulo=v.mod=function(r,e){var f,m,l=this;return r=new C(r,e),!l.c||!r.s||r.c&&!r.c[0]?new C(NaN):!r.c||l.c&&!l.c[0]?new C(l):(Be==9?(m=r.s,r.s=1,f=i(l,r,0,3),r.s=m,f.s*=m):f=i(l,r,0,Be),r=l.minus(f.times(r)),!r.c[0]&&Be==1&&(r.s=l.s),r)},v.multipliedBy=v.times=function(r,e){var f,m,l,g,E,u,h,_,x,y,R,U,H,B,ee,V=this,Z=V.c,Q=(r=new C(r,e)).c;if(!Z||!Q||!Z[0]||!Q[0])return!V.s||!r.s||Z&&!Z[0]&&!Q||Q&&!Q[0]&&!Z?r.c=r.e=r.s=null:(r.s*=V.s,!Z||!Q?r.c=r.e=null:(r.c=[0],r.e=0)),r;for(m=Ee(V.e/q)+Ee(r.e/q),r.s*=V.s,h=Z.length,y=Q.length,h<y&&(H=Z,Z=Q,Q=H,l=h,h=y,y=l),l=h+y,H=[];l--;H.push(0));for(B=Ne,ee=Ce,l=y;--l>=0;){for(f=0,R=Q[l]%ee,U=Q[l]/ee|0,E=h,g=l+E;g>l;)_=Z[--E]%ee,x=Z[E]/ee|0,u=U*_+x*R,_=R*_+u%ee*ee+H[g]+f,f=(_/B|0)+(u/ee|0)+U*x,H[g--]=_%B;H[g]=f}return f?++m:H.splice(0,1),G(r,H,m)},v.negated=function(){var r=new C(this);return r.s=-r.s||null,r},v.plus=function(r,e){var f,m=this,l=m.s;if(r=new C(r,e),e=r.s,!l||!e)return new C(NaN);if(l!=e)return r.s=-e,m.minus(r);var g=m.e/q,E=r.e/q,u=m.c,h=r.c;if(!g||!E){if(!u||!h)return new C(l/0);if(!u[0]||!h[0])return h[0]?r:new C(u[0]?m:l*0)}if(g=Ee(g),E=Ee(E),u=u.slice(),l=g-E){for(l>0?(E=g,f=h):(l=-l,f=u),f.reverse();l--;f.push(0));f.reverse()}for(l=u.length,e=h.length,l-e<0&&(f=h,h=u,u=f,e=l),l=0;e;)l=(u[--e]=u[e]+h[e]+l)/Ne|0,u[e]=Ne===u[e]?0:u[e]%Ne;return l&&(u=[l].concat(u),++E),G(r,u,E)},v.precision=v.sd=function(r,e){var f,m,l,g=this;if(r!=null&&r!==!!r)return re(r,1,se),e==null?e=z:re(e,0,8),I(new C(g),r,e);if(!(f=g.c))return null;if(l=f.length-1,m=l*q+1,l=f[l]){for(;l%10==0;l/=10,m--);for(l=f[0];l>=10;l/=10,m++);}return r&&g.e+1>m&&(m=g.e+1),m},v.shiftedBy=function(r){return re(r,-or,or),this.times("1e"+r)},v.squareRoot=v.sqrt=function(){var r,e,f,m,l,g=this,E=g.c,u=g.s,h=g.e,_=W+4,x=new C("0.5");if(u!==1||!E||!E[0])return new C(!u||u<0&&(!E||E[0])?NaN:E?g:1/0);if(u=Math.sqrt(+$(g)),u==0||u==1/0?(e=Ae(E),(e.length+h)%2==0&&(e+="0"),u=Math.sqrt(+e),h=Ee((h+1)/2)-(h<0||h%2),u==1/0?e="5e"+h:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+h),f=new C(e)):f=new C(u+""),f.c[0]){for(h=f.e,u=h+_,u<3&&(u=0);;)if(l=f,f=x.times(l.plus(i(g,l,_,1))),Ae(l.c).slice(0,u)===(e=Ae(f.c)).slice(0,u))if(f.e<h&&--u,e=e.slice(u-3,u+1),e=="9999"||!m&&e=="4999"){if(!m&&(I(l,l.e+W+2,0),l.times(l).eq(g))){f=l;break}_+=4,u+=4,m=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(I(f,f.e+W+2,1),r=!f.times(f).eq(g));break}}return I(f,f.e+W+1,z,r)},v.toExponential=function(r,e){return r!=null&&(re(r,0,se),r++),Te(this,r,e,1)},v.toFixed=function(r,e){return r!=null&&(re(r,0,se),r=r+this.e+1),Te(this,r,e)},v.toFormat=function(r,e,f){var m,l=this;if(f==null)r!=null&&e&&typeof e=="object"?(f=e,e=null):r&&typeof r=="object"?(f=r,r=e=null):f=ce;else if(typeof f!="object")throw Error(me+"Argument not an object: "+f);if(m=l.toFixed(r,e),l.c){var g,E=m.split("."),u=+f.groupSize,h=+f.secondaryGroupSize,_=f.groupSeparator||"",x=E[0],y=E[1],R=l.s<0,U=R?x.slice(1):x,H=U.length;if(h&&(g=u,u=h,h=g,H-=g),u>0&&H>0){for(g=H%u||u,x=U.substr(0,g);g<H;g+=u)x+=_+U.substr(g,u);h>0&&(x+=_+U.slice(g)),R&&(x="-"+x)}m=y?x+(f.decimalSeparator||"")+((h=+f.fractionGroupSize)?y.replace(new RegExp("\\d{"+h+"}\\B","g"),"$&"+(f.fractionGroupSeparator||"")):y):x}return(f.prefix||"")+m+(f.suffix||"")},v.toFraction=function(r){var e,f,m,l,g,E,u,h,_,x,y,R,U=this,H=U.c;if(r!=null&&(u=new C(r),!u.isInteger()&&(u.c||u.s!==1)||u.lt(M)))throw Error(me+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+$(u));if(!H)return new C(U);for(e=new C(M),_=f=new C(M),m=h=new C(M),R=Ae(H),g=e.e=R.length-U.e-1,e.c[0]=fr[(E=g%q)<0?q+E:E],r=!r||u.comparedTo(e)>0?g>0?e:_:u,E=oe,oe=1/0,u=new C(R),h.c[0]=0;x=i(u,e,0,1),l=f.plus(x.times(m)),l.comparedTo(r)!=1;)f=m,m=l,_=h.plus(x.times(l=_)),h=l,e=u.minus(x.times(l=e)),u=l;return l=i(r.minus(f),m,0,1),h=h.plus(l.times(_)),f=f.plus(l.times(m)),h.s=_.s=U.s,g=g*2,y=i(_,m,g,z).minus(U).abs().comparedTo(i(h,f,g,z).minus(U).abs())<1?[_,m]:[h,f],oe=E,y},v.toNumber=function(){return+$(this)},v.toPrecision=function(r,e){return r!=null&&re(r,1,se),Te(this,r,e,2)},v.toString=function(r){var e,f=this,m=f.s,l=f.e;return l===null?m?(e="Infinity",m<0&&(e="-"+e)):e="NaN":(r==null?e=l<=P||l>=le?Xe(Ae(f.c),l):ye(Ae(f.c),l,"0"):r===10&&J?(f=I(new C(f),W+l+1,z),e=ye(Ae(f.c),f.e,"0")):(re(r,2,he.length,"Base"),e=O(ye(Ae(f.c),l,"0"),10,r,m,!0)),m<0&&f.c[0]&&(e="-"+e)),e},v.valueOf=v.toJSON=function(){return $(this)},v._isBigNumber=!0,v[Symbol.toStringTag]="BigNumber",v[Symbol.for("nodejs.util.inspect.custom")]=v.valueOf,o!=null&&C.set(o),C}function Ee(o){var i=o|0;return o>0||o===i?i:i-1}function Ae(o){for(var i,O,D=1,v=o.length,M=o[0]+"";D<v;){for(i=o[D++]+"",O=q-i.length;O--;i="0"+i);M+=i}for(v=M.length;M.charCodeAt(--v)===48;);return M.slice(0,v+1||1)}function Ue(o,i){var O,D,v=o.c,M=i.c,W=o.s,z=i.s,P=o.e,le=i.e;if(!W||!z)return null;if(O=v&&!v[0],D=M&&!M[0],O||D)return O?D?0:-z:W;if(W!=z)return W;if(O=W<0,D=P==le,!v||!M)return D?0:!v^O?1:-1;if(!D)return P>le^O?1:-1;for(z=(P=v.length)<(le=M.length)?P:le,W=0;W<z;W++)if(v[W]!=M[W])return v[W]>M[W]^O?1:-1;return P==le?0:P>le^O?1:-1}function re(o,i,O,D){if(o<i||o>O||o!==_e(o))throw Error(me+(D||"Argument")+(typeof o=="number"?o<i||o>O?" out of range: ":" not an integer: ":" not a primitive number: ")+String(o))}function $e(o){var i=o.c.length-1;return Ee(o.e/q)==i&&o.c[i]%2!=0}function Xe(o,i){return(o.length>1?o.charAt(0)+"."+o.slice(1):o)+(i<0?"e":"e+")+i}function ye(o,i,O){var D,v;if(i<0){for(v=O+".";++i;v+=O);o=v+o}else if(D=o.length,++i>D){for(v=O,i-=D;--i;v+=O);o+=v}else i<D&&(o=o.slice(0,i)+"."+o.slice(i));return o}var ot=Or(),De=ot;var ft=o=>new De(o,36).toString(16);var Dr="3.7.7",st=Dr,Pe=typeof Buffer=="function",vr=typeof TextDecoder=="function"?new TextDecoder:void 0,yr=typeof TextEncoder=="function"?new TextEncoder:void 0,lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Me=Array.prototype.slice.call(lt),We=(o=>{let i={};return o.forEach((O,D)=>i[O]=D),i})(Me),ut=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,ue=String.fromCharCode.bind(String),Br=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):o=>new Uint8Array(Array.prototype.slice.call(o,0)),Ur=o=>o.replace(/=/g,"").replace(/[+\/]/g,i=>i=="+"?"-":"_"),Rr=o=>o.replace(/[^A-Za-z0-9\+\/]/g,""),Pr=o=>{let i,O,D,v,M="",W=o.length%3;for(let z=0;z<o.length;){if((O=o.charCodeAt(z++))>255||(D=o.charCodeAt(z++))>255||(v=o.charCodeAt(z++))>255)throw new TypeError("invalid character found");i=O<<16|D<<8|v,M+=Me[i>>18&63]+Me[i>>12&63]+Me[i>>6&63]+Me[i&63]}return W?M.slice(0,W-3)+"===".substring(W):M},ur=typeof btoa=="function"?o=>btoa(o):Pe?o=>Buffer.from(o,"binary").toString("base64"):Pr,sr=Pe?o=>Buffer.from(o).toString("base64"):o=>{let O=[];for(let D=0,v=o.length;D<v;D+=4096)O.push(ue.apply(null,o.subarray(D,D+4096)));return ur(O.join(""))},Ze=(o,i=!1)=>i?Ur(sr(o)):sr(o),ct=o=>{if(o.length<2){var i=o.charCodeAt(0);return i<128?o:i<2048?ue(192|i>>>6)+ue(128|i&63):ue(224|i>>>12&15)+ue(128|i>>>6&63)+ue(128|i&63)}else{var i=65536+(o.charCodeAt(0)-55296)*1024+(o.charCodeAt(1)-56320);return ue(240|i>>>18&7)+ue(128|i>>>12&63)+ue(128|i>>>6&63)+ue(128|i&63)}},at=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Ir=o=>o.replace(at,ct),Tr=Pe?o=>Buffer.from(o,"utf8").toString("base64"):yr?o=>sr(yr.encode(o)):o=>ur(Ir(o)),Re=(o,i=!1)=>i?Ur(Tr(o)):Tr(o),Cr=o=>Re(o,!0),ht=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,pt=o=>{switch(o.length){case 4:var i=(7&o.charCodeAt(0))<<18|(63&o.charCodeAt(1))<<12|(63&o.charCodeAt(2))<<6|63&o.charCodeAt(3),O=i-65536;return ue((O>>>10)+55296)+ue((O&1023)+56320);case 3:return ue((15&o.charCodeAt(0))<<12|(63&o.charCodeAt(1))<<6|63&o.charCodeAt(2));default:return ue((31&o.charCodeAt(0))<<6|63&o.charCodeAt(1))}},Fr=o=>o.replace(ht,pt),Mr=o=>{if(o=o.replace(/\s+/g,""),!ut.test(o))throw new TypeError("malformed base64.");o+="==".slice(2-(o.length&3));let i,O="",D,v;for(let M=0;M<o.length;)i=We[o.charAt(M++)]<<18|We[o.charAt(M++)]<<12|(D=We[o.charAt(M++)])<<6|(v=We[o.charAt(M++)]),O+=D===64?ue(i>>16&255):v===64?ue(i>>16&255,i>>8&255):ue(i>>16&255,i>>8&255,i&255);return O},cr=typeof atob=="function"?o=>atob(Rr(o)):Pe?o=>Buffer.from(o,"base64").toString("binary"):Mr,br=Pe?o=>Br(Buffer.from(o,"base64")):o=>Br(cr(o).split("").map(i=>i.charCodeAt(0))),kr=o=>br(Lr(o)),gt=Pe?o=>Buffer.from(o,"base64").toString("utf8"):vr?o=>vr.decode(br(o)):o=>Fr(cr(o)),Lr=o=>Rr(o.replace(/[-_]/g,i=>i=="-"?"+":"/")),lr=o=>gt(Lr(o)),mt=o=>{if(typeof o!="string")return!1;let i=o.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(i)||!/[^\s0-9a-zA-Z\-_]/.test(i)},Gr=o=>({value:o,enumerable:!1,writable:!0,configurable:!0}),qr=function(){let o=(i,O)=>Object.defineProperty(String.prototype,i,Gr(O));o("fromBase64",function(){return lr(this)}),o("toBase64",function(i){return Re(this,i)}),o("toBase64URI",function(){return Re(this,!0)}),o("toBase64URL",function(){return Re(this,!0)}),o("toUint8Array",function(){return kr(this)})},zr=function(){let o=(i,O)=>Object.defineProperty(Uint8Array.prototype,i,Gr(O));o("toBase64",function(i){return Ze(this,i)}),o("toBase64URI",function(){return Ze(this,!0)}),o("toBase64URL",function(){return Ze(this,!0)})},dt=()=>{qr(),zr()},be={version:Dr,VERSION:st,atob:cr,atobPolyfill:Mr,btoa:ur,btoaPolyfill:Pr,fromBase64:lr,toBase64:Re,encode:Re,encodeURI:Cr,encodeURL:Cr,utob:Ir,btou:Fr,decode:lr,isValid:mt,fromUint8Array:Ze,toUint8Array:kr,extendString:qr,extendUint8Array:zr,extendBuiltins:dt};var wt=o=>be.decode(o);var ar=(o,i=!1)=>{let O=[];for(let D of o)O.push((D>>>4).toString(16)),O.push((D&15).toString(16));return i?O.join("").toUpperCase():O.join("")};var hr=(o,i=0,O=null)=>{if(O===0)return"";let D=o;if(i!==0){let M=O===null?o.length-i:O;xt(D,M,i),D=o.slice(i,i+M)}let v=escape(String.fromCharCode.apply(null,Array.from(D)));try{return decodeURIComponent(v)}catch{throw new Error("Error decoding utf-8 data")}};function xt(o,i,O=0){if(O<0)throw new Error("Start index should not be negative");if(o.length<O+i)throw new Error("Need at least "+i+" bytes to convert to an integer");return O}String.prototype.padStart||(String.prototype.padStart=function(i,O){return i=i>>0,O=String(O!==void 0?O:" "),this.length>=i?String(this):(i=i-this.length,i>O.length&&(O+=O.repeat(i/O.length)),O.slice(0,i)+String(this))});var Hr=o=>{let i=o.multipliedBy(-1).toString(2);for(;i.length%8;)i="0"+i;let O=i[0]==="1"&&i.slice(1).indexOf("1")!==-1?"11111111":"";return i=i.split("").map(D=>D==="0"?"1":"0").join(""),new De(O+i,2).plus(1)};var At=(o,i=2)=>{let O=typeof o=="string"?new De(o):o;if(O.isNaN())throw new Error(`Invalid decimal argument: [${o}] - Expected a valid decimal value`);if(i<0)throw new Error(`Invalid padding argument: [${i}] - Expected a positive value`);let D=O.lt(0);D&&(O=Hr(O));let v=O.toString(16),M=Math.ceil(v.length/i);return v.padStart(M*i,D?"f":"0")};var _t=o=>{let i="",O=o;for(let D=O.length-1;D>=0;D-=2)i+=O[D-1]+O[D];return i};var Et=o=>new De(o,16).toString(36);var pr=o=>{if(o.length%2)throw new Error(`Invalid Hex String: ${o}`);let i=new Uint8Array(o.length/2);for(let O=0;O<o.length;O+=2){let D=parseInt(o.substr(O,2),16);if(Number.isNaN(D))throw new Error(`Invalid Hex String: ${o}`);i[O/2]=D}return i};var St=o=>{let i=[0],O,D,v;for(O=0;O<o.length;O+=1){for(v=parseInt(o.charAt(O),16),D=0;D<i.length;D+=1)i[D]=i[D]*16+v,v=i[D]/10|0,i[D]%=10;for(;v>0;)i.push(v%10),v=v/10|0}return i.reverse().join("")};var Nt=o=>hr(pr(o));var Ot=(o,i=!0)=>i?be.encodeURI(o):be.encode(o);var gr=o=>{let i=unescape(encodeURIComponent(o)),O=new Uint8Array(i.length);for(let D=0;D<i.length;++D)O[D]=i.charCodeAt(D);return O};var vt=o=>ar(g