@permaweb/libs 0.0.45 → 0.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +2 -2
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +2 -2
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";var t8=Object.create;var _f=Object.defineProperty;var r8=Object.getOwnPropertyDescriptor;var n8=Object.getOwnPropertyNames;var i8=Object.getPrototypeOf,a8=Object.prototype.hasOwnProperty;var V=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ou=(t,e)=>{for(var r in e)_f(t,r,{get:e[r],enumerable:!0})},o1=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of n8(e))!a8.call(t,i)&&i!==r&&_f(t,i,{get:()=>e[i],enumerable:!(n=r8(e,i))||n.enumerable});return t};var A=(t,e,r)=>(r=t!=null?t8(i8(t)):{},o1(e||!t||!t.__esModule?_f(r,"default",{value:t,enumerable:!0}):r,t)),o8=t=>o1(_f({},"__esModule",{value:!0}),t);var M=V((s_,u1)=>{var gt=u1.exports={},En,_n;function su(){throw new Error("setTimeout has not been defined")}function fu(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?En=setTimeout:En=su}catch{En=su}try{typeof clearTimeout=="function"?_n=clearTimeout:_n=fu}catch{_n=fu}})();function s1(t){if(En===setTimeout)return setTimeout(t,0);if((En===su||!En)&&setTimeout)return En=setTimeout,setTimeout(t,0);try{return En(t,0)}catch{try{return En.call(null,t,0)}catch{return En.call(this,t,0)}}}function s8(t){if(_n===clearTimeout)return clearTimeout(t);if((_n===fu||!_n)&&clearTimeout)return _n=clearTimeout,clearTimeout(t);try{return _n(t)}catch{try{return _n.call(null,t)}catch{return _n.call(this,t)}}}var ai=[],Qa=!1,aa,Bf=-1;function f8(){!Qa||!aa||(Qa=!1,aa.length?ai=aa.concat(ai):Bf=-1,ai.length&&f1())}function f1(){if(!Qa){var t=s1(f8);Qa=!0;for(var e=ai.length;e;){for(aa=ai,ai=[];++Bf<e;)aa&&aa[Bf].run();Bf=-1,e=ai.length}aa=null,Qa=!1,s8(t)}}gt.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];ai.push(new c1(t,e)),ai.length===1&&!Qa&&s1(f1)};function c1(t,e){this.fun=t,this.array=e}c1.prototype.run=function(){this.fun.apply(null,this.array)};gt.title="browser";gt.browser=!0;gt.env={};gt.argv=[];gt.version="";gt.versions={};function oi(){}gt.on=oi;gt.addListener=oi;gt.once=oi;gt.off=oi;gt.removeListener=oi;gt.removeAllListeners=oi;gt.emit=oi;gt.prependListener=oi;gt.prependOnceListener=oi;gt.listeners=function(t){return[]};gt.binding=function(t){throw new Error("process.binding is not supported")};gt.cwd=function(){return"/"};gt.chdir=function(t){throw new Error("process.chdir is not supported")};gt.umask=function(){return 0}});var A1=V(pu=>{"use strict";var C_=A(M());Object.defineProperty(pu,"__esModule",{value:!0});function v8(t){var e=4,r=t.length,n=r%e;if(!n)return t;var i=r,a=e-n,d=r+a,v=Buffer.alloc(d);for(v.write(t);a--;)v.write("=",i++);return v.toString()}pu.default=v8});var M1=V(vu=>{"use strict";var L_=A(M());Object.defineProperty(vu,"__esModule",{value:!0});var x8=A1();function S1(t,e){return e===void 0&&(e="utf8"),Buffer.isBuffer(t)?bu(t.toString("base64")):bu(Buffer.from(t,e).toString("base64"))}function m8(t,e){return e===void 0&&(e="utf8"),Buffer.from(gu(t),"base64").toString(e)}function gu(t){return t=t.toString(),x8.default(t).replace(/\-/g,"+").replace(/_/g,"/")}function bu(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function y8(t){return Buffer.from(gu(t),"base64")}var $a=S1;$a.encode=S1;$a.decode=m8;$a.toBase64=gu;$a.fromBase64=bu;$a.toBuffer=y8;vu.default=$a});var kr=V((R_,Lf)=>{var F_=A(M());Lf.exports=M1().default;Lf.exports.default=Lf.exports});var N1=V(Of=>{"use strict";var X_=A(M());Of.byteLength=N8;Of.toByteArray=U8;Of.fromByteArray=G8;var Ln=[],Nr=[],k8=typeof Uint8Array<"u"?Uint8Array:Array,_u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(ca=0,I1=_u.length;ca<I1;++ca)Ln[ca]=_u[ca],Nr[_u.charCodeAt(ca)]=ca;var ca,I1;Nr[45]=62;Nr[95]=63;function k1(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function N8(t){var e=k1(t),r=e[0],n=e[1];return(r+n)*3/4-n}function J8(t,e,r){return(e+r)*3/4-r}function U8(t){var e,r=k1(t),n=r[0],i=r[1],a=new k8(J8(t,n,i)),d=0,v=i>0?n-4:n,y;for(y=0;y<v;y+=4)e=Nr[t.charCodeAt(y)]<<18|Nr[t.charCodeAt(y+1)]<<12|Nr[t.charCodeAt(y+2)]<<6|Nr[t.charCodeAt(y+3)],a[d++]=e>>16&255,a[d++]=e>>8&255,a[d++]=e&255;return i===2&&(e=Nr[t.charCodeAt(y)]<<2|Nr[t.charCodeAt(y+1)]>>4,a[d++]=e&255),i===1&&(e=Nr[t.charCodeAt(y)]<<10|Nr[t.charCodeAt(y+1)]<<4|Nr[t.charCodeAt(y+2)]>>2,a[d++]=e>>8&255,a[d++]=e&255),a}function H8(t){return Ln[t>>18&63]+Ln[t>>12&63]+Ln[t>>6&63]+Ln[t&63]}function q8(t,e,r){for(var n,i=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(t[a+2]&255),i.push(H8(n));return i.join("")}function G8(t){for(var e,r=t.length,n=r%3,i=[],a=16383,d=0,v=r-n;d<v;d+=a)i.push(q8(t,d,d+a>v?v:d+a));return n===1?(e=t[r-1],i.push(Ln[e>>2]+Ln[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(Ln[e>>10]+Ln[e>>4&63]+Ln[e<<2&63]+"=")),i.join("")}});var pn=V(Jr=>{"use strict";var K_=A(M());Object.defineProperty(Jr,"__esModule",{value:!0});Jr.concatBuffers=X8;Jr.b64UrlToString=z8;Jr.bufferToString=U1;Jr.stringToBuffer=H1;Jr.stringToB64Url=K8;Jr.b64UrlToBuffer=q1;Jr.bufferTob64=G1;Jr.bufferTob64Url=X1;Jr.b64UrlEncode=z1;Jr.b64UrlDecode=K1;var J1=N1();function X8(t){let e=0;for(let i=0;i<t.length;i++)e+=t[i].byteLength;let r=new Uint8Array(e),n=0;r.set(new Uint8Array(t[0]),n),n+=t[0].byteLength;for(let i=1;i<t.length;i++)r.set(new Uint8Array(t[i]),n),n+=t[i].byteLength;return r}function z8(t){let e=q1(t);return U1(e)}function U1(t){return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function H1(t){return new TextEncoder().encode(t)}function K8(t){return X1(H1(t))}function q1(t){return new Uint8Array(J1.toByteArray(K1(t)))}function G1(t){return J1.fromByteArray(new Uint8Array(t))}function X1(t){return z1(G1(t))}function z1(t){try{return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}catch(e){throw new Error("Failed to encode string",{cause:e})}}function K1(t){try{t=t.replace(/\-/g,"+").replace(/\_/g,"/");let e;return t.length%4==0?e=0:e=4-t.length%4,t.concat("=".repeat(e))}catch(e){throw new Error("Failed to decode string",{cause:e})}}});var Pu=V(Cu=>{"use strict";var W_=A(M());Object.defineProperty(Cu,"__esModule",{value:!0});var Pi=pn(),Bu=class{keyLength=4096;publicExponent=65537;hashAlgorithm="sha256";driver;constructor(){if(!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let e=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),r=await this.driver.exportKey("jwk",e.privateKey);return{kty:r.kty,e:r.e,n:r.n,d:r.d,p:r.p,q:r.q,dp:r.dp,dq:r.dq,qi:r.qi}}async sign(e,r,{saltLength:n}={}){let i=await this.driver.sign({name:"RSA-PSS",saltLength:n??32},await this.jwkToCryptoKey(e),r);return new Uint8Array(i)}async hash(e,r="SHA-256"){let n=await this.driver.digest(r,e);return new Uint8Array(n)}async verify(e,r,n){let i={kty:"RSA",e:"AQAB",n:e},a=await this.jwkToPublicCryptoKey(i),d=await this.driver.digest("SHA-256",r),v=await this.driver.verify({name:"RSA-PSS",saltLength:0},a,n,r),y=await this.driver.verify({name:"RSA-PSS",saltLength:32},a,n,r),m=Math.ceil((a.algorithm.modulusLength-1)/8)-d.byteLength-2,B=await this.driver.verify({name:"RSA-PSS",saltLength:m},a,n,r),P=v||y||B;if(!P){let D={algorithm:a.algorithm.name,modulusLength:a.algorithm.modulusLength,keyUsages:a.usages,saltLengthsAttempted:`0, 32, ${m}`};console.warn(`Transaction Verification Failed!
|
|
2
2
|
`,`Details: ${JSON.stringify(D,null,2)}
|
|
3
|
-
`,"N.B. ArweaveJS is only guaranteed to verify txs created using ArweaveJS.")}return P}async jwkToCryptoKey(e){return this.driver.importKey("jwk",e,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(e){return this.driver.importKey("jwk",e,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let e=crypto?.subtle;return e===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(n=>typeof e[n]=="function")}async encrypt(e,r,n){let i=await this.driver.importKey("raw",typeof r=="string"?Pi.stringToBuffer(r):r,{name:"PBKDF2",length:32},!1,["deriveKey"]),a=await this.driver.deriveKey({name:"PBKDF2",salt:n?Pi.stringToBuffer(n):Pi.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},i,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),d=new Uint8Array(16);crypto.getRandomValues(d);let v=await this.driver.encrypt({name:"AES-CBC",iv:d},a,e);return Pi.concatBuffers([d,v])}async decrypt(e,r,n){let i=await this.driver.importKey("raw",typeof r=="string"?Pi.stringToBuffer(r):r,{name:"PBKDF2",length:32},!1,["deriveKey"]),a=await this.driver.deriveKey({name:"PBKDF2",salt:n?Pi.stringToBuffer(n):Pi.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},i,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),d=e.slice(0,16),v=await this.driver.decrypt({name:"AES-CBC",iv:d},a,e.slice(16));return Pi.concatBuffers([v])}};Cu.default=Bu});var Q1=V((j1,If)=>{var Y_=A(M());(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,a="[BigNumber Error] ",d=a+"Number primitive has more than 15 significant digits: ",v=1e14,y=14,m=9007199254740991,B=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],P=1e7,D=1e9;function F(ie){var ee,ce,te,Y=w.prototype={constructor:w,toString:null,valueOf:null},S=new w(1),s=20,u=4,l=-7,f=21,c=-1e7,g=1e7,x=!1,h=1,o=0,p={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},E="0123456789abcdefghijklmnopqrstuvwxyz",b=!0;function w(_,R){var L,O,G,I,J,z,N,U,Q=this;if(!(Q instanceof w))return new w(_,R);if(R==null){if(_&&_._isBigNumber===!0){Q.s=_.s,!_.c||_.e>g?Q.c=Q.e=null:_.e<c?Q.c=[Q.e=0]:(Q.e=_.e,Q.c=_.c.slice());return}if((z=typeof _=="number")&&_*0==0){if(Q.s=1/_<0?(_=-_,-1):1,_===~~_){for(I=0,J=_;J>=10;J/=10,I++);I>g?Q.c=Q.e=null:(Q.e=I,Q.c=[_]);return}U=String(_)}else{if(!r.test(U=String(_)))return te(Q,U,z);Q.s=U.charCodeAt(0)==45?(U=U.slice(1),-1):1}(I=U.indexOf("."))>-1&&(U=U.replace(".","")),(J=U.search(/e/i))>0?(I<0&&(I=J),I+=+U.slice(J+1),U=U.substring(0,J)):I<0&&(I=U.length)}else{if(K(R,2,E.length,"Base"),R==10&&b)return Q=new w(_),X(Q,s+Q.e+1,u);if(U=String(_),z=typeof _=="number"){if(_*0!=0)return te(Q,U,z,R);if(Q.s=1/_<0?(U=U.slice(1),-1):1,w.DEBUG&&U.replace(/^0\.0*|\./,"").length>15)throw Error(d+_)}else Q.s=U.charCodeAt(0)===45?(U=U.slice(1),-1):1;for(L=E.slice(0,R),I=J=0,N=U.length;J<N;J++)if(L.indexOf(O=U.charAt(J))<0){if(O=="."){if(J>I){I=N;continue}}else if(!G&&(U==U.toUpperCase()&&(U=U.toLowerCase())||U==U.toLowerCase()&&(U=U.toUpperCase()))){G=!0,J=-1,I=0;continue}return te(Q,String(_),z,R)}z=!1,U=ce(U,R,10,Q.s),(I=U.indexOf("."))>-1?U=U.replace(".",""):I=U.length}for(J=0;U.charCodeAt(J)===48;J++);for(N=U.length;U.charCodeAt(--N)===48;);if(U=U.slice(J,++N)){if(N-=J,z&&w.DEBUG&&N>15&&(_>m||_!==i(_)))throw Error(d+Q.s*_);if((I=I-J-1)>g)Q.c=Q.e=null;else if(I<c)Q.c=[Q.e=0];else{if(Q.e=I,Q.c=[],J=(I+1)%y,I<0&&(J+=y),J<N){for(J&&Q.c.push(+U.slice(0,J)),N-=y;J<N;)Q.c.push(+U.slice(J,J+=y));J=y-(U=U.slice(J)).length}else J-=N;for(;J--;U+="0");Q.c.push(+U)}}else Q.c=[Q.e=0]}w.clone=F,w.ROUND_UP=0,w.ROUND_DOWN=1,w.ROUND_CEIL=2,w.ROUND_FLOOR=3,w.ROUND_HALF_UP=4,w.ROUND_HALF_DOWN=5,w.ROUND_HALF_EVEN=6,w.ROUND_HALF_CEIL=7,w.ROUND_HALF_FLOOR=8,w.EUCLID=9,w.config=w.set=function(_){var R,L;if(_!=null)if(typeof _=="object"){if(_.hasOwnProperty(R="DECIMAL_PLACES")&&(L=_[R],K(L,0,D,R),s=L),_.hasOwnProperty(R="ROUNDING_MODE")&&(L=_[R],K(L,0,8,R),u=L),_.hasOwnProperty(R="EXPONENTIAL_AT")&&(L=_[R],L&&L.pop?(K(L[0],-D,0,R),K(L[1],0,D,R),l=L[0],f=L[1]):(K(L,-D,D,R),l=-(f=L<0?-L:L))),_.hasOwnProperty(R="RANGE"))if(L=_[R],L&&L.pop)K(L[0],-D,-1,R),K(L[1],1,D,R),c=L[0],g=L[1];else if(K(L,-D,D,R),L)c=-(g=L<0?-L:L);else throw Error(a+R+" cannot be zero: "+L);if(_.hasOwnProperty(R="CRYPTO"))if(L=_[R],L===!!L)if(L)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))x=L;else throw x=!L,Error(a+"crypto unavailable");else x=L;else throw Error(a+R+" not true or false: "+L);if(_.hasOwnProperty(R="MODULO_MODE")&&(L=_[R],K(L,0,9,R),h=L),_.hasOwnProperty(R="POW_PRECISION")&&(L=_[R],K(L,0,D,R),o=L),_.hasOwnProperty(R="FORMAT"))if(L=_[R],typeof L=="object")p=L;else throw Error(a+R+" not an object: "+L);if(_.hasOwnProperty(R="ALPHABET"))if(L=_[R],typeof L=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(L))b=L.slice(0,10)=="0123456789",E=L;else throw Error(a+R+" invalid: "+L)}else throw Error(a+"Object expected: "+_);return{DECIMAL_PLACES:s,ROUNDING_MODE:u,EXPONENTIAL_AT:[l,f],RANGE:[c,g],CRYPTO:x,MODULO_MODE:h,POW_PRECISION:o,FORMAT:p,ALPHABET:E}},w.isBigNumber=function(_){if(!_||_._isBigNumber!==!0)return!1;if(!w.DEBUG)return!0;var R,L,O=_.c,G=_.e,I=_.s;e:if({}.toString.call(O)=="[object Array]"){if((I===1||I===-1)&&G>=-D&&G<=D&&G===i(G)){if(O[0]===0){if(G===0&&O.length===1)return!0;break e}if(R=(G+1)%y,R<1&&(R+=y),String(O[0]).length==R){for(R=0;R<O.length;R++)if(L=O[R],L<0||L>=v||L!==i(L))break e;if(L!==0)return!0}}}else if(O===null&&G===null&&(I===null||I===1||I===-1))return!0;throw Error(a+"Invalid BigNumber: "+_)},w.maximum=w.max=function(){return T(arguments,-1)},w.minimum=w.min=function(){return T(arguments,1)},w.random=function(){var _=9007199254740992,R=Math.random()*_&2097151?function(){return i(Math.random()*_)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(L){var O,G,I,J,z,N=0,U=[],Q=new w(S);if(L==null?L=s:K(L,0,D),J=n(L/y),x)if(crypto.getRandomValues){for(O=crypto.getRandomValues(new Uint32Array(J*=2));N<J;)z=O[N]*131072+(O[N+1]>>>11),z>=9e15?(G=crypto.getRandomValues(new Uint32Array(2)),O[N]=G[0],O[N+1]=G[1]):(U.push(z%1e14),N+=2);N=J/2}else if(crypto.randomBytes){for(O=crypto.randomBytes(J*=7);N<J;)z=(O[N]&31)*281474976710656+O[N+1]*1099511627776+O[N+2]*4294967296+O[N+3]*16777216+(O[N+4]<<16)+(O[N+5]<<8)+O[N+6],z>=9e15?crypto.randomBytes(7).copy(O,N):(U.push(z%1e14),N+=7);N=J/7}else throw x=!1,Error(a+"crypto unavailable");if(!x)for(;N<J;)z=R(),z<9e15&&(U[N++]=z%1e14);for(J=U[--N],L%=y,J&&L&&(z=B[y-L],U[N]=i(J/z)*z);U[N]===0;U.pop(),N--);if(N<0)U=[I=0];else{for(I=-1;U[0]===0;U.splice(0,1),I-=y);for(N=1,z=U[0];z>=10;z/=10,N++);N<y&&(I-=y-N)}return Q.e=I,Q.c=U,Q}}(),w.sum=function(){for(var _=1,R=arguments,L=new w(R[0]);_<R.length;)L=L.plus(R[_++]);return L},ce=function(){var _="0123456789";function R(L,O,G,I){for(var J,z=[0],N,U=0,Q=L.length;U<Q;){for(N=z.length;N--;z[N]*=O);for(z[0]+=I.indexOf(L.charAt(U++)),J=0;J<z.length;J++)z[J]>G-1&&(z[J+1]==null&&(z[J+1]=0),z[J+1]+=z[J]/G|0,z[J]%=G)}return z.reverse()}return function(L,O,G,I,J){var z,N,U,Q,j,re,De,se,le=L.indexOf("."),Ue=s,oe=u;for(le>=0&&(Q=o,o=0,L=L.replace(".",""),se=new w(O),re=se.pow(L.length-le),o=Q,se.c=R(ae(q(re.c),re.e,"0"),10,G,_),se.e=se.c.length),De=R(L,O,G,J?(z=E,_):(z=_,E)),U=Q=De.length;De[--Q]==0;De.pop());if(!De[0])return z.charAt(0);if(le<0?--U:(re.c=De,re.e=U,re.s=I,re=ee(re,se,Ue,oe,G),De=re.c,j=re.r,U=re.e),N=U+Ue+1,le=De[N],Q=G/2,j=j||N<0||De[N+1]!=null,j=oe<4?(le!=null||j)&&(oe==0||oe==(re.s<0?3:2)):le>Q||le==Q&&(oe==4||j||oe==6&&De[N-1]&1||oe==(re.s<0?8:7)),N<1||!De[0])L=j?ae(z.charAt(1),-Ue,z.charAt(0)):z.charAt(0);else{if(De.length=N,j)for(--G;++De[--N]>G;)De[N]=0,N||(++U,De=[1].concat(De));for(Q=De.length;!De[--Q];);for(le=0,L="";le<=Q;L+=z.charAt(De[le++]));L=ae(L,U,z.charAt(0))}return L}}(),ee=function(){function _(O,G,I){var J,z,N,U,Q=0,j=O.length,re=G%P,De=G/P|0;for(O=O.slice();j--;)N=O[j]%P,U=O[j]/P|0,J=De*N+U*re,z=re*N+J%P*P+Q,Q=(z/I|0)+(J/P|0)+De*U,O[j]=z%I;return Q&&(O=[Q].concat(O)),O}function R(O,G,I,J){var z,N;if(I!=J)N=I>J?1:-1;else for(z=N=0;z<I;z++)if(O[z]!=G[z]){N=O[z]>G[z]?1:-1;break}return N}function L(O,G,I,J){for(var z=0;I--;)O[I]-=z,z=O[I]<G[I]?1:0,O[I]=z*J+O[I]-G[I];for(;!O[0]&&O.length>1;O.splice(0,1));}return function(O,G,I,J,z){var N,U,Q,j,re,De,se,le,Ue,oe,fe,Xe,ge,ve,bt,pe,be,Ye=O.s==G.s?1:-1,de=O.c,ue=G.c;if(!de||!de[0]||!ue||!ue[0])return new w(!O.s||!G.s||(de?ue&&de[0]==ue[0]:!ue)?NaN:de&&de[0]==0||!ue?Ye*0:Ye/0);for(le=new w(Ye),Ue=le.c=[],U=O.e-G.e,Ye=I+U+1,z||(z=v,U=C(O.e/y)-C(G.e/y),Ye=Ye/y|0),Q=0;ue[Q]==(de[Q]||0);Q++);if(ue[Q]>(de[Q]||0)&&U--,Ye<0)Ue.push(1),j=!0;else{for(ve=de.length,pe=ue.length,Q=0,Ye+=2,re=i(z/(ue[0]+1)),re>1&&(ue=_(ue,re,z),de=_(de,re,z),pe=ue.length,ve=de.length),ge=pe,oe=de.slice(0,pe),fe=oe.length;fe<pe;oe[fe++]=0);be=ue.slice(),be=[0].concat(be),bt=ue[0],ue[1]>=z/2&&bt++;do{if(re=0,N=R(ue,oe,pe,fe),N<0){if(Xe=oe[0],pe!=fe&&(Xe=Xe*z+(oe[1]||0)),re=i(Xe/bt),re>1)for(re>=z&&(re=z-1),De=_(ue,re,z),se=De.length,fe=oe.length;R(De,oe,se,fe)==1;)re--,L(De,pe<se?be:ue,se,z),se=De.length,N=1;else re==0&&(N=re=1),De=ue.slice(),se=De.length;if(se<fe&&(De=[0].concat(De)),L(oe,De,fe,z),fe=oe.length,N==-1)for(;R(ue,oe,pe,fe)<1;)re++,L(oe,pe<fe?be:ue,fe,z),fe=oe.length}else N===0&&(re++,oe=[0]);Ue[Q++]=re,oe[0]?oe[fe++]=de[ge]||0:(oe=[de[ge]],fe=1)}while((ge++<ve||oe[0]!=null)&&Ye--);j=oe[0]!=null,Ue[0]||Ue.splice(0,1)}if(z==v){for(Q=1,Ye=Ue[0];Ye>=10;Ye/=10,Q++);X(le,I+(le.e=Q+U*y-1)+1,J,j)}else le.e=U,le.r=+j;return le}}();function H(_,R,L,O){var G,I,J,z,N;if(L==null?L=u:K(L,0,8),!_.c)return _.toString();if(G=_.c[0],J=_.e,R==null)N=q(_.c),N=O==1||O==2&&(J<=l||J>=f)?$(N,J):ae(N,J,"0");else if(_=X(new w(_),R,L),I=_.e,N=q(_.c),z=N.length,O==1||O==2&&(R<=I||I<=l)){for(;z<R;N+="0",z++);N=$(N,I)}else if(R-=J,N=ae(N,I,"0"),I+1>z){if(--R>0)for(N+=".";R--;N+="0");}else if(R+=I-z,R>0)for(I+1==z&&(N+=".");R--;N+="0");return _.s<0&&G?"-"+N:N}function T(_,R){for(var L,O,G=1,I=new w(_[0]);G<_.length;G++)O=new w(_[G]),(!O.s||(L=W(I,O))===R||L===0&&I.s===R)&&(I=O);return I}function k(_,R,L){for(var O=1,G=R.length;!R[--G];R.pop());for(G=R[0];G>=10;G/=10,O++);return(L=O+L*y-1)>g?_.c=_.e=null:L<c?_.c=[_.e=0]:(_.e=L,_.c=R),_}te=function(){var _=/^(-?)0([xbo])(?=\w[\w.]*$)/i,R=/^([^.]+)\.$/,L=/^\.([^.]+)$/,O=/^-?(Infinity|NaN)$/,G=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(I,J,z,N){var U,Q=z?J:J.replace(G,"");if(O.test(Q))I.s=isNaN(Q)?null:Q<0?-1:1;else{if(!z&&(Q=Q.replace(_,function(j,re,De){return U=(De=De.toLowerCase())=="x"?16:De=="b"?2:8,!N||N==U?re:j}),N&&(U=N,Q=Q.replace(R,"$1").replace(L,"0.$1")),J!=Q))return new w(Q,U);if(w.DEBUG)throw Error(a+"Not a"+(N?" base "+N:"")+" number: "+J);I.s=null}I.c=I.e=null}}();function X(_,R,L,O){var G,I,J,z,N,U,Q,j=_.c,re=B;if(j){e:{for(G=1,z=j[0];z>=10;z/=10,G++);if(I=R-G,I<0)I+=y,J=R,N=j[U=0],Q=i(N/re[G-J-1]%10);else if(U=n((I+1)/y),U>=j.length)if(O){for(;j.length<=U;j.push(0));N=Q=0,G=1,I%=y,J=I-y+1}else break e;else{for(N=z=j[U],G=1;z>=10;z/=10,G++);I%=y,J=I-y+G,Q=J<0?0:i(N/re[G-J-1]%10)}if(O=O||R<0||j[U+1]!=null||(J<0?N:N%re[G-J-1]),O=L<4?(Q||O)&&(L==0||L==(_.s<0?3:2)):Q>5||Q==5&&(L==4||O||L==6&&(I>0?J>0?N/re[G-J]:0:j[U-1])%10&1||L==(_.s<0?8:7)),R<1||!j[0])return j.length=0,O?(R-=_.e+1,j[0]=re[(y-R%y)%y],_.e=-R||0):j[0]=_.e=0,_;if(I==0?(j.length=U,z=1,U--):(j.length=U+1,z=re[y-I],j[U]=J>0?i(N/re[G-J]%re[J])*z:0),O)for(;;)if(U==0){for(I=1,J=j[0];J>=10;J/=10,I++);for(J=j[0]+=z,z=1;J>=10;J/=10,z++);I!=z&&(_.e++,j[0]==v&&(j[0]=1));break}else{if(j[U]+=z,j[U]!=v)break;j[U--]=0,z=1}for(I=j.length;j[--I]===0;j.pop());}_.e>g?_.c=_.e=null:_.e<c&&(_.c=[_.e=0])}return _}function Z(_){var R,L=_.e;return L===null?_.toString():(R=q(_.c),R=L<=l||L>=f?$(R,L):ae(R,L,"0"),_.s<0?"-"+R:R)}return Y.absoluteValue=Y.abs=function(){var _=new w(this);return _.s<0&&(_.s=1),_},Y.comparedTo=function(_,R){return W(this,new w(_,R))},Y.decimalPlaces=Y.dp=function(_,R){var L,O,G,I=this;if(_!=null)return K(_,0,D),R==null?R=u:K(R,0,8),X(new w(I),_+I.e+1,R);if(!(L=I.c))return null;if(O=((G=L.length-1)-C(this.e/y))*y,G=L[G])for(;G%10==0;G/=10,O--);return O<0&&(O=0),O},Y.dividedBy=Y.div=function(_,R){return ee(this,new w(_,R),s,u)},Y.dividedToIntegerBy=Y.idiv=function(_,R){return ee(this,new w(_,R),0,1)},Y.exponentiatedBy=Y.pow=function(_,R){var L,O,G,I,J,z,N,U,Q,j=this;if(_=new w(_),_.c&&!_.isInteger())throw Error(a+"Exponent not an integer: "+Z(_));if(R!=null&&(R=new w(R)),z=_.e>14,!j.c||!j.c[0]||j.c[0]==1&&!j.e&&j.c.length==1||!_.c||!_.c[0])return Q=new w(Math.pow(+Z(j),z?_.s*(2-ne(_)):+Z(_))),R?Q.mod(R):Q;if(N=_.s<0,R){if(R.c?!R.c[0]:!R.s)return new w(NaN);O=!N&&j.isInteger()&&R.isInteger(),O&&(j=j.mod(R))}else{if(_.e>9&&(j.e>0||j.e<-1||(j.e==0?j.c[0]>1||z&&j.c[1]>=24e7:j.c[0]<8e13||z&&j.c[0]<=9999975e7)))return I=j.s<0&&ne(_)?-0:0,j.e>-1&&(I=1/I),new w(N?1/I:I);o&&(I=n(o/y+2))}for(z?(L=new w(.5),N&&(_.s=1),U=ne(_)):(G=Math.abs(+Z(_)),U=G%2),Q=new w(S);;){if(U){if(Q=Q.times(j),!Q.c)break;I?Q.c.length>I&&(Q.c.length=I):O&&(Q=Q.mod(R))}if(G){if(G=i(G/2),G===0)break;U=G%2}else if(_=_.times(L),X(_,_.e+1,1),_.e>14)U=ne(_);else{if(G=+Z(_),G===0)break;U=G%2}j=j.times(j),I?j.c&&j.c.length>I&&(j.c.length=I):O&&(j=j.mod(R))}return O?Q:(N&&(Q=S.div(Q)),R?Q.mod(R):I?X(Q,o,u,J):Q)},Y.integerValue=function(_){var R=new w(this);return _==null?_=u:K(_,0,8),X(R,R.e+1,_)},Y.isEqualTo=Y.eq=function(_,R){return W(this,new w(_,R))===0},Y.isFinite=function(){return!!this.c},Y.isGreaterThan=Y.gt=function(_,R){return W(this,new w(_,R))>0},Y.isGreaterThanOrEqualTo=Y.gte=function(_,R){return(R=W(this,new w(_,R)))===1||R===0},Y.isInteger=function(){return!!this.c&&C(this.e/y)>this.c.length-2},Y.isLessThan=Y.lt=function(_,R){return W(this,new w(_,R))<0},Y.isLessThanOrEqualTo=Y.lte=function(_,R){return(R=W(this,new w(_,R)))===-1||R===0},Y.isNaN=function(){return!this.s},Y.isNegative=function(){return this.s<0},Y.isPositive=function(){return this.s>0},Y.isZero=function(){return!!this.c&&this.c[0]==0},Y.minus=function(_,R){var L,O,G,I,J=this,z=J.s;if(_=new w(_,R),R=_.s,!z||!R)return new w(NaN);if(z!=R)return _.s=-R,J.plus(_);var N=J.e/y,U=_.e/y,Q=J.c,j=_.c;if(!N||!U){if(!Q||!j)return Q?(_.s=-R,_):new w(j?J:NaN);if(!Q[0]||!j[0])return j[0]?(_.s=-R,_):new w(Q[0]?J:u==3?-0:0)}if(N=C(N),U=C(U),Q=Q.slice(),z=N-U){for((I=z<0)?(z=-z,G=Q):(U=N,G=j),G.reverse(),R=z;R--;G.push(0));G.reverse()}else for(O=(I=(z=Q.length)<(R=j.length))?z:R,z=R=0;R<O;R++)if(Q[R]!=j[R]){I=Q[R]<j[R];break}if(I&&(G=Q,Q=j,j=G,_.s=-_.s),R=(O=j.length)-(L=Q.length),R>0)for(;R--;Q[L++]=0);for(R=v-1;O>z;){if(Q[--O]<j[O]){for(L=O;L&&!Q[--L];Q[L]=R);--Q[L],Q[O]+=v}Q[O]-=j[O]}for(;Q[0]==0;Q.splice(0,1),--U);return Q[0]?k(_,Q,U):(_.s=u==3?-1:1,_.c=[_.e=0],_)},Y.modulo=Y.mod=function(_,R){var L,O,G=this;return _=new w(_,R),!G.c||!_.s||_.c&&!_.c[0]?new w(NaN):!_.c||G.c&&!G.c[0]?new w(G):(h==9?(O=_.s,_.s=1,L=ee(G,_,0,3),_.s=O,L.s*=O):L=ee(G,_,0,h),_=G.minus(L.times(_)),!_.c[0]&&h==1&&(_.s=G.s),_)},Y.multipliedBy=Y.times=function(_,R){var L,O,G,I,J,z,N,U,Q,j,re,De,se,le,Ue,oe=this,fe=oe.c,Xe=(_=new w(_,R)).c;if(!fe||!Xe||!fe[0]||!Xe[0])return!oe.s||!_.s||fe&&!fe[0]&&!Xe||Xe&&!Xe[0]&&!fe?_.c=_.e=_.s=null:(_.s*=oe.s,!fe||!Xe?_.c=_.e=null:(_.c=[0],_.e=0)),_;for(O=C(oe.e/y)+C(_.e/y),_.s*=oe.s,N=fe.length,j=Xe.length,N<j&&(se=fe,fe=Xe,Xe=se,G=N,N=j,j=G),G=N+j,se=[];G--;se.push(0));for(le=v,Ue=P,G=j;--G>=0;){for(L=0,re=Xe[G]%Ue,De=Xe[G]/Ue|0,J=N,I=G+J;I>G;)U=fe[--J]%Ue,Q=fe[J]/Ue|0,z=De*U+Q*re,U=re*U+z%Ue*Ue+se[I]+L,L=(U/le|0)+(z/Ue|0)+De*Q,se[I--]=U%le;se[I]=L}return L?++O:se.splice(0,1),k(_,se,O)},Y.negated=function(){var _=new w(this);return _.s=-_.s||null,_},Y.plus=function(_,R){var L,O=this,G=O.s;if(_=new w(_,R),R=_.s,!G||!R)return new w(NaN);if(G!=R)return _.s=-R,O.minus(_);var I=O.e/y,J=_.e/y,z=O.c,N=_.c;if(!I||!J){if(!z||!N)return new w(G/0);if(!z[0]||!N[0])return N[0]?_:new w(z[0]?O:G*0)}if(I=C(I),J=C(J),z=z.slice(),G=I-J){for(G>0?(J=I,L=N):(G=-G,L=z),L.reverse();G--;L.push(0));L.reverse()}for(G=z.length,R=N.length,G-R<0&&(L=N,N=z,z=L,R=G),G=0;R;)G=(z[--R]=z[R]+N[R]+G)/v|0,z[R]=v===z[R]?0:z[R]%v;return G&&(z=[G].concat(z),++J),k(_,z,J)},Y.precision=Y.sd=function(_,R){var L,O,G,I=this;if(_!=null&&_!==!!_)return K(_,1,D),R==null?R=u:K(R,0,8),X(new w(I),_,R);if(!(L=I.c))return null;if(G=L.length-1,O=G*y+1,G=L[G]){for(;G%10==0;G/=10,O--);for(G=L[0];G>=10;G/=10,O++);}return _&&I.e+1>O&&(O=I.e+1),O},Y.shiftedBy=function(_){return K(_,-m,m),this.times("1e"+_)},Y.squareRoot=Y.sqrt=function(){var _,R,L,O,G,I=this,J=I.c,z=I.s,N=I.e,U=s+4,Q=new w("0.5");if(z!==1||!J||!J[0])return new w(!z||z<0&&(!J||J[0])?NaN:J?I:1/0);if(z=Math.sqrt(+Z(I)),z==0||z==1/0?(R=q(J),(R.length+N)%2==0&&(R+="0"),z=Math.sqrt(+R),N=C((N+1)/2)-(N<0||N%2),z==1/0?R="5e"+N:(R=z.toExponential(),R=R.slice(0,R.indexOf("e")+1)+N),L=new w(R)):L=new w(z+""),L.c[0]){for(N=L.e,z=N+U,z<3&&(z=0);;)if(G=L,L=Q.times(G.plus(ee(I,G,U,1))),q(G.c).slice(0,z)===(R=q(L.c)).slice(0,z))if(L.e<N&&--z,R=R.slice(z-3,z+1),R=="9999"||!O&&R=="4999"){if(!O&&(X(G,G.e+s+2,0),G.times(G).eq(I))){L=G;break}U+=4,z+=4,O=1}else{(!+R||!+R.slice(1)&&R.charAt(0)=="5")&&(X(L,L.e+s+2,1),_=!L.times(L).eq(I));break}}return X(L,L.e+s+1,u,_)},Y.toExponential=function(_,R){return _!=null&&(K(_,0,D),_++),H(this,_,R,1)},Y.toFixed=function(_,R){return _!=null&&(K(_,0,D),_=_+this.e+1),H(this,_,R)},Y.toFormat=function(_,R,L){var O,G=this;if(L==null)_!=null&&R&&typeof R=="object"?(L=R,R=null):_&&typeof _=="object"?(L=_,_=R=null):L=p;else if(typeof L!="object")throw Error(a+"Argument not an object: "+L);if(O=G.toFixed(_,R),G.c){var I,J=O.split("."),z=+L.groupSize,N=+L.secondaryGroupSize,U=L.groupSeparator||"",Q=J[0],j=J[1],re=G.s<0,De=re?Q.slice(1):Q,se=De.length;if(N&&(I=z,z=N,N=I,se-=I),z>0&&se>0){for(I=se%z||z,Q=De.substr(0,I);I<se;I+=z)Q+=U+De.substr(I,z);N>0&&(Q+=U+De.slice(I)),re&&(Q="-"+Q)}O=j?Q+(L.decimalSeparator||"")+((N=+L.fractionGroupSize)?j.replace(new RegExp("\\d{"+N+"}\\B","g"),"$&"+(L.fractionGroupSeparator||"")):j):Q}return(L.prefix||"")+O+(L.suffix||"")},Y.toFraction=function(_){var R,L,O,G,I,J,z,N,U,Q,j,re,De=this,se=De.c;if(_!=null&&(z=new w(_),!z.isInteger()&&(z.c||z.s!==1)||z.lt(S)))throw Error(a+"Argument "+(z.isInteger()?"out of range: ":"not an integer: ")+Z(z));if(!se)return new w(De);for(R=new w(S),U=L=new w(S),O=N=new w(S),re=q(se),I=R.e=re.length-De.e-1,R.c[0]=B[(J=I%y)<0?y+J:J],_=!_||z.comparedTo(R)>0?I>0?R:U:z,J=g,g=1/0,z=new w(re),N.c[0]=0;Q=ee(z,R,0,1),G=L.plus(Q.times(O)),G.comparedTo(_)!=1;)L=O,O=G,U=N.plus(Q.times(G=U)),N=G,R=z.minus(Q.times(G=R)),z=G;return G=ee(_.minus(L),O,0,1),N=N.plus(G.times(U)),L=L.plus(G.times(O)),N.s=U.s=De.s,I=I*2,j=ee(U,O,I,u).minus(De).abs().comparedTo(ee(N,L,I,u).minus(De).abs())<1?[U,O]:[N,L],g=J,j},Y.toNumber=function(){return+Z(this)},Y.toPrecision=function(_,R){return _!=null&&K(_,1,D),H(this,_,R,2)},Y.toString=function(_){var R,L=this,O=L.s,G=L.e;return G===null?O?(R="Infinity",O<0&&(R="-"+R)):R="NaN":(_==null?R=G<=l||G>=f?$(q(L.c),G):ae(q(L.c),G,"0"):_===10&&b?(L=X(new w(L),s+G+1,u),R=ae(q(L.c),L.e,"0")):(K(_,2,E.length,"Base"),R=ce(ae(q(L.c),G,"0"),10,_,O,!0)),O<0&&L.c[0]&&(R="-"+R)),R},Y.valueOf=Y.toJSON=function(){return Z(this)},Y._isBigNumber=!0,ie!=null&&w.set(ie),w}function C(ie){var ee=ie|0;return ie>0||ie===ee?ee:ee-1}function q(ie){for(var ee,ce,te=1,Y=ie.length,S=ie[0]+"";te<Y;){for(ee=ie[te++]+"",ce=y-ee.length;ce--;ee="0"+ee);S+=ee}for(Y=S.length;S.charCodeAt(--Y)===48;);return S.slice(0,Y+1||1)}function W(ie,ee){var ce,te,Y=ie.c,S=ee.c,s=ie.s,u=ee.s,l=ie.e,f=ee.e;if(!s||!u)return null;if(ce=Y&&!Y[0],te=S&&!S[0],ce||te)return ce?te?0:-u:s;if(s!=u)return s;if(ce=s<0,te=l==f,!Y||!S)return te?0:!Y^ce?1:-1;if(!te)return l>f^ce?1:-1;for(u=(l=Y.length)<(f=S.length)?l:f,s=0;s<u;s++)if(Y[s]!=S[s])return Y[s]>S[s]^ce?1:-1;return l==f?0:l>f^ce?1:-1}function K(ie,ee,ce,te){if(ie<ee||ie>ce||ie!==i(ie))throw Error(a+(te||"Argument")+(typeof ie=="number"?ie<ee||ie>ce?" out of range: ":" not an integer: ":" not a primitive number: ")+String(ie))}function ne(ie){var ee=ie.c.length-1;return C(ie.e/y)==ee&&ie.c[ee]%2!=0}function $(ie,ee){return(ie.length>1?ie.charAt(0)+"."+ie.slice(1):ie)+(ee<0?"e":"e+")+ee}function ae(ie,ee,ce){var te,Y;if(ee<0){for(Y=ce+".";++ee;Y+=ce);ie=Y+ie}else if(te=ie.length,++ee>te){for(Y=ce,ee-=te;--ee;Y+=ce);ie+=Y}else ee<te&&(ie=ie.slice(0,ee)+"."+ie.slice(ee));return ie}e=F(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof If<"u"&&If.exports?If.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(j1)});var W1=V(Ru=>{"use strict";var eB=A(M());Object.defineProperty(Ru,"__esModule",{value:!0});var Z8=Q1(),Lu=class{BigNum;constructor(){this.BigNum=(e,r)=>{let n=Z8.BigNumber.clone({DECIMAL_PLACES:r});return new n(e)}}winstonToAr(e,{formatted:r=!1,decimals:n=12,trim:i=!0}={}){let a=this.stringToBigNum(e,n).shiftedBy(-12);return r?a.toFormat(n):a.toFixed(n)}arToWinston(e,{formatted:r=!1}={}){let n=this.stringToBigNum(e).shiftedBy(12);return r?n.toFormat():n.toFixed(0)}compare(e,r){let n=this.stringToBigNum(e),i=this.stringToBigNum(r);return n.comparedTo(i)}isEqual(e,r){return this.compare(e,r)===0}isLessThan(e,r){let n=this.stringToBigNum(e),i=this.stringToBigNum(r);return n.isLessThan(i)}isGreaterThan(e,r){let n=this.stringToBigNum(e),i=this.stringToBigNum(r);return n.isGreaterThan(i)}add(e,r){let n=this.stringToBigNum(e),i=this.stringToBigNum(r);return n.plus(r).toFixed(0)}sub(e,r){let n=this.stringToBigNum(e),i=this.stringToBigNum(r);return n.minus(r).toFixed(0)}stringToBigNum(e,r=12){return this.BigNum(e,r)}};Ru.default=Lu});var Y1=V(Du=>{"use strict";var rB=A(M());Object.defineProperty(Du,"__esModule",{value:!0});var Fu=class{METHOD_GET="GET";METHOD_POST="POST";config;constructor(e){this.applyConfig(e)}applyConfig(e){this.config=this.mergeDefaults(e)}getConfig(){return this.config}mergeDefaults(e){let r=e.protocol||"http",n=e.port||(r==="https"?443:80);return{host:e.host||"127.0.0.1",protocol:r,port:n,timeout:e.timeout||2e4,logging:e.logging||!1,logger:e.logger||console.log,network:e.network}}async get(e,r){return await this.request(e,{...r,method:this.METHOD_GET})}async post(e,r,n){let i=new Headers(n?.headers||{});return i.get("content-type")?.includes("application/json")||i.append("content-type","application/json"),i.append("accept","application/json, text/plain, */*"),await this.request(e,{...n,method:this.METHOD_POST,body:typeof r!="string"?JSON.stringify(r):r,headers:i})}async request(e,r){let n=new Headers(r?.headers||{}),i=`${this.config.protocol}://${this.config.host}:${this.config.port}`,a=r?.responseType;delete r?.responseType,e.startsWith("/")&&(e=e.slice(1)),this.config.network&&n.append("x-network",this.config.network),this.config.logging&&this.config.logger(`Requesting: ${i}/${e}`);let d=await fetch(`${i}/${e}`,{...r||{},headers:n});this.config.logging&&this.config.logger(`Response: ${d.url} - ${d.status}`);let y=d.headers.get("content-type")?.match(/charset=([^()<>@,;:\"/[\]?.=\s]*)/i)?.[1],m=d,B=async()=>{if(y)try{m.data=new TextDecoder(y).decode(await d.arrayBuffer())}catch{m.data=await d.text()}else m.data=await d.text()};if(a==="arraybuffer")m.data=await d.arrayBuffer();else if(a==="text")await B();else if(a==="webstream")m.data=V8(d.body);else try{let P=await d.clone().json();typeof P!="object"?await B():m.data=await d.json(),P=null}catch{await B()}return m}};Du.default=Fu;var V8=t=>{let e=t;return typeof e[Symbol.asyncIterator]>"u"&&(e[Symbol.asyncIterator]=j8(t)),e},j8=function(t){return async function*(){let r=t.getReader();try{for(;;){let{done:n,value:i}=await r.read();if(n)return;yield i}}finally{r.releaseLock()}}}});var $1=V(Iu=>{"use strict";var iB=A(M());Object.defineProperty(Iu,"__esModule",{value:!0});var Ou=class{api;constructor(e){this.api=e}getInfo(){return this.api.get("info").then(e=>e.data)}getPeers(){return this.api.get("peers").then(e=>e.data)}};Iu.default=Ou});var hs=V(kf=>{"use strict";var oB=A(M());Object.defineProperty(kf,"__esModule",{value:!0});kf.getError=Q8;var ku=class extends Error{type;response;constructor(e,r={}){r.message?super(r.message):super(),this.type=e,this.response=r.response}getType(){return this.type}};kf.default=ku;function Q8(t){let e=t.data;if(typeof t.data=="string")try{e=JSON.parse(t.data)}catch{}if(t.data instanceof ArrayBuffer||t.data instanceof Uint8Array)try{e=JSON.parse(e.toString())}catch{}return e?e.error||e:t.statusText||"unknown"}});var Gu=V(ot=>{"use strict";var fB=A(M());Object.defineProperty(ot,"__esModule",{value:!0});ot.arrayCompare=ot.MIN_CHUNK_SIZE=ot.MAX_CHUNK_SIZE=void 0;ot.chunkData=Ju;ot.generateLeaves=Uu;ot.computeRootHash=W8;ot.generateTree=tp;ot.generateTransactionChunks=Y8;ot.buildLayers=Jf;ot.generateProofs=rp;ot.arrayFlatten=Hu;ot.intToBuffer=gs;ot.bufferToInt=qu;ot.validatePath=ps;ot.debug=np;var Nf=vs(),ep=pn();ot.MAX_CHUNK_SIZE=256*1024;ot.MIN_CHUNK_SIZE=32*1024;var bs=32,ro=32;async function Ju(t){let e=[],r=t,n=0;for(;r.byteLength>=ot.MAX_CHUNK_SIZE;){let i=ot.MAX_CHUNK_SIZE,a=r.byteLength-ot.MAX_CHUNK_SIZE;a>0&&a<ot.MIN_CHUNK_SIZE&&(i=Math.ceil(r.byteLength/2));let d=r.slice(0,i),v=await Nf.default.crypto.hash(d);n+=d.byteLength,e.push({dataHash:v,minByteRange:n-d.byteLength,maxByteRange:n}),r=r.slice(i)}return e.push({dataHash:await Nf.default.crypto.hash(r),minByteRange:n,maxByteRange:n+r.byteLength}),e}async function Uu(t){return Promise.all(t.map(async({dataHash:e,minByteRange:r,maxByteRange:n})=>({type:"leaf",id:await Ot(await Promise.all([Ot(e),Ot(gs(n))])),dataHash:e,minByteRange:r,maxByteRange:n})))}async function W8(t){return(await tp(t)).id}async function tp(t){return await Jf(await Uu(await Ju(t)))}async function Y8(t){let e=await Ju(t),r=await Uu(e),n=await Jf(r),i=await rp(n),a=e.slice(-1)[0];return a.maxByteRange-a.minByteRange===0&&(e.splice(e.length-1,1),i.splice(i.length-1,1)),{data_root:n.id,chunks:e,proofs:i}}async function Jf(t,e=0){if(t.length<2)return t[0];let r=[];for(let n=0;n<t.length;n+=2)r.push(await $8(t[n],t[n+1]));return Jf(r,e+1)}function rp(t){let e=Nu(t);return Array.isArray(e)?Hu(e):[e]}function Nu(t,e=new Uint8Array,r=0){if(t.type=="leaf")return{offset:t.maxByteRange-1,proof:(0,ep.concatBuffers)([e,t.dataHash,gs(t.maxByteRange)])};if(t.type=="branch"){let n=(0,ep.concatBuffers)([e,t.leftChild.id,t.rightChild.id,gs(t.byteRange)]);return[Nu(t.leftChild,n,r+1),Nu(t.rightChild,n,r+1)]}throw new Error("Unexpected node type")}function Hu(t){let e=[];return t.forEach(r=>{Array.isArray(r)?e.push(...Hu(r)):e.push(r)}),e}async function $8(t,e){return e?{type:"branch",id:await Ot([await Ot(t.id),await Ot(e.id),await Ot(gs(t.maxByteRange))]),byteRange:t.maxByteRange,maxByteRange:e.maxByteRange,leftChild:t,rightChild:e}:t}async function Ot(t){return Array.isArray(t)&&(t=Nf.default.utils.concatBuffers(t)),new Uint8Array(await Nf.default.crypto.hash(t))}function gs(t){let e=new Uint8Array(bs);for(var r=e.length-1;r>=0;r--){var n=t%256;e[r]=n,t=(t-n)/256}return e}function qu(t){let e=0;for(var r=0;r<t.length;r++)e*=256,e+=t[r];return e}var e6=(t,e)=>t.every((r,n)=>e[n]===r);ot.arrayCompare=e6;async function ps(t,e,r,n,i){if(n<=0)return!1;if(e>=n)return ps(t,0,n-1,n,i);if(e<0)return ps(t,0,0,n,i);if(i.length==ro+bs){let P=i.slice(0,ro),D=i.slice(P.length,P.length+bs),F=await Ot([await Ot(P),await Ot(D)]);return(0,ot.arrayCompare)(t,F)?{offset:n-1,leftBound:r,rightBound:n,chunkSize:n-r}:!1}let a=i.slice(0,ro),d=i.slice(a.length,a.length+ro),v=i.slice(a.length+d.length,a.length+d.length+bs),y=qu(v),m=i.slice(a.length+d.length+v.length),B=await Ot([await Ot(a),await Ot(d),await Ot(v)]);return(0,ot.arrayCompare)(t,B)?e<y?await ps(a,e,r,Math.min(n,y),m):await ps(d,e,Math.max(r,y),n,m):!1}async function np(t,e=""){if(t.byteLength<1)return e;let r=t.slice(0,ro),n=t.slice(r.length,r.length+ro),i=t.slice(r.length+n.length,r.length+n.length+bs),a=qu(i),d=t.slice(r.length+n.length+i.length),v=await Ot([await Ot(r),await Ot(n),await Ot(i)]),y=`${e}
|
|
3
|
+
`,"N.B. ArweaveJS is only guaranteed to verify txs created using ArweaveJS.")}return P}async jwkToCryptoKey(e){return this.driver.importKey("jwk",e,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(e){return this.driver.importKey("jwk",e,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let e=crypto?.subtle;return e===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(n=>typeof e[n]=="function")}async encrypt(e,r,n){let i=await this.driver.importKey("raw",typeof r=="string"?Pi.stringToBuffer(r):r,{name:"PBKDF2",length:32},!1,["deriveKey"]),a=await this.driver.deriveKey({name:"PBKDF2",salt:n?Pi.stringToBuffer(n):Pi.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},i,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),d=new Uint8Array(16);crypto.getRandomValues(d);let v=await this.driver.encrypt({name:"AES-CBC",iv:d},a,e);return Pi.concatBuffers([d,v])}async decrypt(e,r,n){let i=await this.driver.importKey("raw",typeof r=="string"?Pi.stringToBuffer(r):r,{name:"PBKDF2",length:32},!1,["deriveKey"]),a=await this.driver.deriveKey({name:"PBKDF2",salt:n?Pi.stringToBuffer(n):Pi.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},i,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),d=e.slice(0,16),v=await this.driver.decrypt({name:"AES-CBC",iv:d},a,e.slice(16));return Pi.concatBuffers([v])}};Cu.default=Bu});var Q1=V((j1,If)=>{var Y_=A(M());(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,a="[BigNumber Error] ",d=a+"Number primitive has more than 15 significant digits: ",v=1e14,y=14,m=9007199254740991,B=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],P=1e7,D=1e9;function F(ie){var ee,ce,te,Y=w.prototype={constructor:w,toString:null,valueOf:null},S=new w(1),s=20,u=4,l=-7,f=21,c=-1e7,g=1e7,x=!1,h=1,o=0,p={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},E="0123456789abcdefghijklmnopqrstuvwxyz",b=!0;function w(_,R){var L,O,G,I,J,z,N,U,Q=this;if(!(Q instanceof w))return new w(_,R);if(R==null){if(_&&_._isBigNumber===!0){Q.s=_.s,!_.c||_.e>g?Q.c=Q.e=null:_.e<c?Q.c=[Q.e=0]:(Q.e=_.e,Q.c=_.c.slice());return}if((z=typeof _=="number")&&_*0==0){if(Q.s=1/_<0?(_=-_,-1):1,_===~~_){for(I=0,J=_;J>=10;J/=10,I++);I>g?Q.c=Q.e=null:(Q.e=I,Q.c=[_]);return}U=String(_)}else{if(!r.test(U=String(_)))return te(Q,U,z);Q.s=U.charCodeAt(0)==45?(U=U.slice(1),-1):1}(I=U.indexOf("."))>-1&&(U=U.replace(".","")),(J=U.search(/e/i))>0?(I<0&&(I=J),I+=+U.slice(J+1),U=U.substring(0,J)):I<0&&(I=U.length)}else{if(K(R,2,E.length,"Base"),R==10&&b)return Q=new w(_),X(Q,s+Q.e+1,u);if(U=String(_),z=typeof _=="number"){if(_*0!=0)return te(Q,U,z,R);if(Q.s=1/_<0?(U=U.slice(1),-1):1,w.DEBUG&&U.replace(/^0\.0*|\./,"").length>15)throw Error(d+_)}else Q.s=U.charCodeAt(0)===45?(U=U.slice(1),-1):1;for(L=E.slice(0,R),I=J=0,N=U.length;J<N;J++)if(L.indexOf(O=U.charAt(J))<0){if(O=="."){if(J>I){I=N;continue}}else if(!G&&(U==U.toUpperCase()&&(U=U.toLowerCase())||U==U.toLowerCase()&&(U=U.toUpperCase()))){G=!0,J=-1,I=0;continue}return te(Q,String(_),z,R)}z=!1,U=ce(U,R,10,Q.s),(I=U.indexOf("."))>-1?U=U.replace(".",""):I=U.length}for(J=0;U.charCodeAt(J)===48;J++);for(N=U.length;U.charCodeAt(--N)===48;);if(U=U.slice(J,++N)){if(N-=J,z&&w.DEBUG&&N>15&&(_>m||_!==i(_)))throw Error(d+Q.s*_);if((I=I-J-1)>g)Q.c=Q.e=null;else if(I<c)Q.c=[Q.e=0];else{if(Q.e=I,Q.c=[],J=(I+1)%y,I<0&&(J+=y),J<N){for(J&&Q.c.push(+U.slice(0,J)),N-=y;J<N;)Q.c.push(+U.slice(J,J+=y));J=y-(U=U.slice(J)).length}else J-=N;for(;J--;U+="0");Q.c.push(+U)}}else Q.c=[Q.e=0]}w.clone=F,w.ROUND_UP=0,w.ROUND_DOWN=1,w.ROUND_CEIL=2,w.ROUND_FLOOR=3,w.ROUND_HALF_UP=4,w.ROUND_HALF_DOWN=5,w.ROUND_HALF_EVEN=6,w.ROUND_HALF_CEIL=7,w.ROUND_HALF_FLOOR=8,w.EUCLID=9,w.config=w.set=function(_){var R,L;if(_!=null)if(typeof _=="object"){if(_.hasOwnProperty(R="DECIMAL_PLACES")&&(L=_[R],K(L,0,D,R),s=L),_.hasOwnProperty(R="ROUNDING_MODE")&&(L=_[R],K(L,0,8,R),u=L),_.hasOwnProperty(R="EXPONENTIAL_AT")&&(L=_[R],L&&L.pop?(K(L[0],-D,0,R),K(L[1],0,D,R),l=L[0],f=L[1]):(K(L,-D,D,R),l=-(f=L<0?-L:L))),_.hasOwnProperty(R="RANGE"))if(L=_[R],L&&L.pop)K(L[0],-D,-1,R),K(L[1],1,D,R),c=L[0],g=L[1];else if(K(L,-D,D,R),L)c=-(g=L<0?-L:L);else throw Error(a+R+" cannot be zero: "+L);if(_.hasOwnProperty(R="CRYPTO"))if(L=_[R],L===!!L)if(L)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))x=L;else throw x=!L,Error(a+"crypto unavailable");else x=L;else throw Error(a+R+" not true or false: "+L);if(_.hasOwnProperty(R="MODULO_MODE")&&(L=_[R],K(L,0,9,R),h=L),_.hasOwnProperty(R="POW_PRECISION")&&(L=_[R],K(L,0,D,R),o=L),_.hasOwnProperty(R="FORMAT"))if(L=_[R],typeof L=="object")p=L;else throw Error(a+R+" not an object: "+L);if(_.hasOwnProperty(R="ALPHABET"))if(L=_[R],typeof L=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(L))b=L.slice(0,10)=="0123456789",E=L;else throw Error(a+R+" invalid: "+L)}else throw Error(a+"Object expected: "+_);return{DECIMAL_PLACES:s,ROUNDING_MODE:u,EXPONENTIAL_AT:[l,f],RANGE:[c,g],CRYPTO:x,MODULO_MODE:h,POW_PRECISION:o,FORMAT:p,ALPHABET:E}},w.isBigNumber=function(_){if(!_||_._isBigNumber!==!0)return!1;if(!w.DEBUG)return!0;var R,L,O=_.c,G=_.e,I=_.s;e:if({}.toString.call(O)=="[object Array]"){if((I===1||I===-1)&&G>=-D&&G<=D&&G===i(G)){if(O[0]===0){if(G===0&&O.length===1)return!0;break e}if(R=(G+1)%y,R<1&&(R+=y),String(O[0]).length==R){for(R=0;R<O.length;R++)if(L=O[R],L<0||L>=v||L!==i(L))break e;if(L!==0)return!0}}}else if(O===null&&G===null&&(I===null||I===1||I===-1))return!0;throw Error(a+"Invalid BigNumber: "+_)},w.maximum=w.max=function(){return T(arguments,-1)},w.minimum=w.min=function(){return T(arguments,1)},w.random=function(){var _=9007199254740992,R=Math.random()*_&2097151?function(){return i(Math.random()*_)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(L){var O,G,I,J,z,N=0,U=[],Q=new w(S);if(L==null?L=s:K(L,0,D),J=n(L/y),x)if(crypto.getRandomValues){for(O=crypto.getRandomValues(new Uint32Array(J*=2));N<J;)z=O[N]*131072+(O[N+1]>>>11),z>=9e15?(G=crypto.getRandomValues(new Uint32Array(2)),O[N]=G[0],O[N+1]=G[1]):(U.push(z%1e14),N+=2);N=J/2}else if(crypto.randomBytes){for(O=crypto.randomBytes(J*=7);N<J;)z=(O[N]&31)*281474976710656+O[N+1]*1099511627776+O[N+2]*4294967296+O[N+3]*16777216+(O[N+4]<<16)+(O[N+5]<<8)+O[N+6],z>=9e15?crypto.randomBytes(7).copy(O,N):(U.push(z%1e14),N+=7);N=J/7}else throw x=!1,Error(a+"crypto unavailable");if(!x)for(;N<J;)z=R(),z<9e15&&(U[N++]=z%1e14);for(J=U[--N],L%=y,J&&L&&(z=B[y-L],U[N]=i(J/z)*z);U[N]===0;U.pop(),N--);if(N<0)U=[I=0];else{for(I=-1;U[0]===0;U.splice(0,1),I-=y);for(N=1,z=U[0];z>=10;z/=10,N++);N<y&&(I-=y-N)}return Q.e=I,Q.c=U,Q}}(),w.sum=function(){for(var _=1,R=arguments,L=new w(R[0]);_<R.length;)L=L.plus(R[_++]);return L},ce=function(){var _="0123456789";function R(L,O,G,I){for(var J,z=[0],N,U=0,Q=L.length;U<Q;){for(N=z.length;N--;z[N]*=O);for(z[0]+=I.indexOf(L.charAt(U++)),J=0;J<z.length;J++)z[J]>G-1&&(z[J+1]==null&&(z[J+1]=0),z[J+1]+=z[J]/G|0,z[J]%=G)}return z.reverse()}return function(L,O,G,I,J){var z,N,U,Q,j,re,De,se,le=L.indexOf("."),Ue=s,oe=u;for(le>=0&&(Q=o,o=0,L=L.replace(".",""),se=new w(O),re=se.pow(L.length-le),o=Q,se.c=R(ae(q(re.c),re.e,"0"),10,G,_),se.e=se.c.length),De=R(L,O,G,J?(z=E,_):(z=_,E)),U=Q=De.length;De[--Q]==0;De.pop());if(!De[0])return z.charAt(0);if(le<0?--U:(re.c=De,re.e=U,re.s=I,re=ee(re,se,Ue,oe,G),De=re.c,j=re.r,U=re.e),N=U+Ue+1,le=De[N],Q=G/2,j=j||N<0||De[N+1]!=null,j=oe<4?(le!=null||j)&&(oe==0||oe==(re.s<0?3:2)):le>Q||le==Q&&(oe==4||j||oe==6&&De[N-1]&1||oe==(re.s<0?8:7)),N<1||!De[0])L=j?ae(z.charAt(1),-Ue,z.charAt(0)):z.charAt(0);else{if(De.length=N,j)for(--G;++De[--N]>G;)De[N]=0,N||(++U,De=[1].concat(De));for(Q=De.length;!De[--Q];);for(le=0,L="";le<=Q;L+=z.charAt(De[le++]));L=ae(L,U,z.charAt(0))}return L}}(),ee=function(){function _(O,G,I){var J,z,N,U,Q=0,j=O.length,re=G%P,De=G/P|0;for(O=O.slice();j--;)N=O[j]%P,U=O[j]/P|0,J=De*N+U*re,z=re*N+J%P*P+Q,Q=(z/I|0)+(J/P|0)+De*U,O[j]=z%I;return Q&&(O=[Q].concat(O)),O}function R(O,G,I,J){var z,N;if(I!=J)N=I>J?1:-1;else for(z=N=0;z<I;z++)if(O[z]!=G[z]){N=O[z]>G[z]?1:-1;break}return N}function L(O,G,I,J){for(var z=0;I--;)O[I]-=z,z=O[I]<G[I]?1:0,O[I]=z*J+O[I]-G[I];for(;!O[0]&&O.length>1;O.splice(0,1));}return function(O,G,I,J,z){var N,U,Q,j,re,De,se,le,Ue,oe,fe,Xe,ge,ve,bt,pe,be,Ye=O.s==G.s?1:-1,de=O.c,ue=G.c;if(!de||!de[0]||!ue||!ue[0])return new w(!O.s||!G.s||(de?ue&&de[0]==ue[0]:!ue)?NaN:de&&de[0]==0||!ue?Ye*0:Ye/0);for(le=new w(Ye),Ue=le.c=[],U=O.e-G.e,Ye=I+U+1,z||(z=v,U=C(O.e/y)-C(G.e/y),Ye=Ye/y|0),Q=0;ue[Q]==(de[Q]||0);Q++);if(ue[Q]>(de[Q]||0)&&U--,Ye<0)Ue.push(1),j=!0;else{for(ve=de.length,pe=ue.length,Q=0,Ye+=2,re=i(z/(ue[0]+1)),re>1&&(ue=_(ue,re,z),de=_(de,re,z),pe=ue.length,ve=de.length),ge=pe,oe=de.slice(0,pe),fe=oe.length;fe<pe;oe[fe++]=0);be=ue.slice(),be=[0].concat(be),bt=ue[0],ue[1]>=z/2&&bt++;do{if(re=0,N=R(ue,oe,pe,fe),N<0){if(Xe=oe[0],pe!=fe&&(Xe=Xe*z+(oe[1]||0)),re=i(Xe/bt),re>1)for(re>=z&&(re=z-1),De=_(ue,re,z),se=De.length,fe=oe.length;R(De,oe,se,fe)==1;)re--,L(De,pe<se?be:ue,se,z),se=De.length,N=1;else re==0&&(N=re=1),De=ue.slice(),se=De.length;if(se<fe&&(De=[0].concat(De)),L(oe,De,fe,z),fe=oe.length,N==-1)for(;R(ue,oe,pe,fe)<1;)re++,L(oe,pe<fe?be:ue,fe,z),fe=oe.length}else N===0&&(re++,oe=[0]);Ue[Q++]=re,oe[0]?oe[fe++]=de[ge]||0:(oe=[de[ge]],fe=1)}while((ge++<ve||oe[0]!=null)&&Ye--);j=oe[0]!=null,Ue[0]||Ue.splice(0,1)}if(z==v){for(Q=1,Ye=Ue[0];Ye>=10;Ye/=10,Q++);X(le,I+(le.e=Q+U*y-1)+1,J,j)}else le.e=U,le.r=+j;return le}}();function H(_,R,L,O){var G,I,J,z,N;if(L==null?L=u:K(L,0,8),!_.c)return _.toString();if(G=_.c[0],J=_.e,R==null)N=q(_.c),N=O==1||O==2&&(J<=l||J>=f)?$(N,J):ae(N,J,"0");else if(_=X(new w(_),R,L),I=_.e,N=q(_.c),z=N.length,O==1||O==2&&(R<=I||I<=l)){for(;z<R;N+="0",z++);N=$(N,I)}else if(R-=J+(O===2&&I>J),N=ae(N,I,"0"),I+1>z){if(--R>0)for(N+=".";R--;N+="0");}else if(R+=I-z,R>0)for(I+1==z&&(N+=".");R--;N+="0");return _.s<0&&G?"-"+N:N}function T(_,R){for(var L,O,G=1,I=new w(_[0]);G<_.length;G++)O=new w(_[G]),(!O.s||(L=W(I,O))===R||L===0&&I.s===R)&&(I=O);return I}function k(_,R,L){for(var O=1,G=R.length;!R[--G];R.pop());for(G=R[0];G>=10;G/=10,O++);return(L=O+L*y-1)>g?_.c=_.e=null:L<c?_.c=[_.e=0]:(_.e=L,_.c=R),_}te=function(){var _=/^(-?)0([xbo])(?=\w[\w.]*$)/i,R=/^([^.]+)\.$/,L=/^\.([^.]+)$/,O=/^-?(Infinity|NaN)$/,G=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(I,J,z,N){var U,Q=z?J:J.replace(G,"");if(O.test(Q))I.s=isNaN(Q)?null:Q<0?-1:1;else{if(!z&&(Q=Q.replace(_,function(j,re,De){return U=(De=De.toLowerCase())=="x"?16:De=="b"?2:8,!N||N==U?re:j}),N&&(U=N,Q=Q.replace(R,"$1").replace(L,"0.$1")),J!=Q))return new w(Q,U);if(w.DEBUG)throw Error(a+"Not a"+(N?" base "+N:"")+" number: "+J);I.s=null}I.c=I.e=null}}();function X(_,R,L,O){var G,I,J,z,N,U,Q,j=_.c,re=B;if(j){e:{for(G=1,z=j[0];z>=10;z/=10,G++);if(I=R-G,I<0)I+=y,J=R,N=j[U=0],Q=i(N/re[G-J-1]%10);else if(U=n((I+1)/y),U>=j.length)if(O){for(;j.length<=U;j.push(0));N=Q=0,G=1,I%=y,J=I-y+1}else break e;else{for(N=z=j[U],G=1;z>=10;z/=10,G++);I%=y,J=I-y+G,Q=J<0?0:i(N/re[G-J-1]%10)}if(O=O||R<0||j[U+1]!=null||(J<0?N:N%re[G-J-1]),O=L<4?(Q||O)&&(L==0||L==(_.s<0?3:2)):Q>5||Q==5&&(L==4||O||L==6&&(I>0?J>0?N/re[G-J]:0:j[U-1])%10&1||L==(_.s<0?8:7)),R<1||!j[0])return j.length=0,O?(R-=_.e+1,j[0]=re[(y-R%y)%y],_.e=-R||0):j[0]=_.e=0,_;if(I==0?(j.length=U,z=1,U--):(j.length=U+1,z=re[y-I],j[U]=J>0?i(N/re[G-J]%re[J])*z:0),O)for(;;)if(U==0){for(I=1,J=j[0];J>=10;J/=10,I++);for(J=j[0]+=z,z=1;J>=10;J/=10,z++);I!=z&&(_.e++,j[0]==v&&(j[0]=1));break}else{if(j[U]+=z,j[U]!=v)break;j[U--]=0,z=1}for(I=j.length;j[--I]===0;j.pop());}_.e>g?_.c=_.e=null:_.e<c&&(_.c=[_.e=0])}return _}function Z(_){var R,L=_.e;return L===null?_.toString():(R=q(_.c),R=L<=l||L>=f?$(R,L):ae(R,L,"0"),_.s<0?"-"+R:R)}return Y.absoluteValue=Y.abs=function(){var _=new w(this);return _.s<0&&(_.s=1),_},Y.comparedTo=function(_,R){return W(this,new w(_,R))},Y.decimalPlaces=Y.dp=function(_,R){var L,O,G,I=this;if(_!=null)return K(_,0,D),R==null?R=u:K(R,0,8),X(new w(I),_+I.e+1,R);if(!(L=I.c))return null;if(O=((G=L.length-1)-C(this.e/y))*y,G=L[G])for(;G%10==0;G/=10,O--);return O<0&&(O=0),O},Y.dividedBy=Y.div=function(_,R){return ee(this,new w(_,R),s,u)},Y.dividedToIntegerBy=Y.idiv=function(_,R){return ee(this,new w(_,R),0,1)},Y.exponentiatedBy=Y.pow=function(_,R){var L,O,G,I,J,z,N,U,Q,j=this;if(_=new w(_),_.c&&!_.isInteger())throw Error(a+"Exponent not an integer: "+Z(_));if(R!=null&&(R=new w(R)),z=_.e>14,!j.c||!j.c[0]||j.c[0]==1&&!j.e&&j.c.length==1||!_.c||!_.c[0])return Q=new w(Math.pow(+Z(j),z?_.s*(2-ne(_)):+Z(_))),R?Q.mod(R):Q;if(N=_.s<0,R){if(R.c?!R.c[0]:!R.s)return new w(NaN);O=!N&&j.isInteger()&&R.isInteger(),O&&(j=j.mod(R))}else{if(_.e>9&&(j.e>0||j.e<-1||(j.e==0?j.c[0]>1||z&&j.c[1]>=24e7:j.c[0]<8e13||z&&j.c[0]<=9999975e7)))return I=j.s<0&&ne(_)?-0:0,j.e>-1&&(I=1/I),new w(N?1/I:I);o&&(I=n(o/y+2))}for(z?(L=new w(.5),N&&(_.s=1),U=ne(_)):(G=Math.abs(+Z(_)),U=G%2),Q=new w(S);;){if(U){if(Q=Q.times(j),!Q.c)break;I?Q.c.length>I&&(Q.c.length=I):O&&(Q=Q.mod(R))}if(G){if(G=i(G/2),G===0)break;U=G%2}else if(_=_.times(L),X(_,_.e+1,1),_.e>14)U=ne(_);else{if(G=+Z(_),G===0)break;U=G%2}j=j.times(j),I?j.c&&j.c.length>I&&(j.c.length=I):O&&(j=j.mod(R))}return O?Q:(N&&(Q=S.div(Q)),R?Q.mod(R):I?X(Q,o,u,J):Q)},Y.integerValue=function(_){var R=new w(this);return _==null?_=u:K(_,0,8),X(R,R.e+1,_)},Y.isEqualTo=Y.eq=function(_,R){return W(this,new w(_,R))===0},Y.isFinite=function(){return!!this.c},Y.isGreaterThan=Y.gt=function(_,R){return W(this,new w(_,R))>0},Y.isGreaterThanOrEqualTo=Y.gte=function(_,R){return(R=W(this,new w(_,R)))===1||R===0},Y.isInteger=function(){return!!this.c&&C(this.e/y)>this.c.length-2},Y.isLessThan=Y.lt=function(_,R){return W(this,new w(_,R))<0},Y.isLessThanOrEqualTo=Y.lte=function(_,R){return(R=W(this,new w(_,R)))===-1||R===0},Y.isNaN=function(){return!this.s},Y.isNegative=function(){return this.s<0},Y.isPositive=function(){return this.s>0},Y.isZero=function(){return!!this.c&&this.c[0]==0},Y.minus=function(_,R){var L,O,G,I,J=this,z=J.s;if(_=new w(_,R),R=_.s,!z||!R)return new w(NaN);if(z!=R)return _.s=-R,J.plus(_);var N=J.e/y,U=_.e/y,Q=J.c,j=_.c;if(!N||!U){if(!Q||!j)return Q?(_.s=-R,_):new w(j?J:NaN);if(!Q[0]||!j[0])return j[0]?(_.s=-R,_):new w(Q[0]?J:u==3?-0:0)}if(N=C(N),U=C(U),Q=Q.slice(),z=N-U){for((I=z<0)?(z=-z,G=Q):(U=N,G=j),G.reverse(),R=z;R--;G.push(0));G.reverse()}else for(O=(I=(z=Q.length)<(R=j.length))?z:R,z=R=0;R<O;R++)if(Q[R]!=j[R]){I=Q[R]<j[R];break}if(I&&(G=Q,Q=j,j=G,_.s=-_.s),R=(O=j.length)-(L=Q.length),R>0)for(;R--;Q[L++]=0);for(R=v-1;O>z;){if(Q[--O]<j[O]){for(L=O;L&&!Q[--L];Q[L]=R);--Q[L],Q[O]+=v}Q[O]-=j[O]}for(;Q[0]==0;Q.splice(0,1),--U);return Q[0]?k(_,Q,U):(_.s=u==3?-1:1,_.c=[_.e=0],_)},Y.modulo=Y.mod=function(_,R){var L,O,G=this;return _=new w(_,R),!G.c||!_.s||_.c&&!_.c[0]?new w(NaN):!_.c||G.c&&!G.c[0]?new w(G):(h==9?(O=_.s,_.s=1,L=ee(G,_,0,3),_.s=O,L.s*=O):L=ee(G,_,0,h),_=G.minus(L.times(_)),!_.c[0]&&h==1&&(_.s=G.s),_)},Y.multipliedBy=Y.times=function(_,R){var L,O,G,I,J,z,N,U,Q,j,re,De,se,le,Ue,oe=this,fe=oe.c,Xe=(_=new w(_,R)).c;if(!fe||!Xe||!fe[0]||!Xe[0])return!oe.s||!_.s||fe&&!fe[0]&&!Xe||Xe&&!Xe[0]&&!fe?_.c=_.e=_.s=null:(_.s*=oe.s,!fe||!Xe?_.c=_.e=null:(_.c=[0],_.e=0)),_;for(O=C(oe.e/y)+C(_.e/y),_.s*=oe.s,N=fe.length,j=Xe.length,N<j&&(se=fe,fe=Xe,Xe=se,G=N,N=j,j=G),G=N+j,se=[];G--;se.push(0));for(le=v,Ue=P,G=j;--G>=0;){for(L=0,re=Xe[G]%Ue,De=Xe[G]/Ue|0,J=N,I=G+J;I>G;)U=fe[--J]%Ue,Q=fe[J]/Ue|0,z=De*U+Q*re,U=re*U+z%Ue*Ue+se[I]+L,L=(U/le|0)+(z/Ue|0)+De*Q,se[I--]=U%le;se[I]=L}return L?++O:se.splice(0,1),k(_,se,O)},Y.negated=function(){var _=new w(this);return _.s=-_.s||null,_},Y.plus=function(_,R){var L,O=this,G=O.s;if(_=new w(_,R),R=_.s,!G||!R)return new w(NaN);if(G!=R)return _.s=-R,O.minus(_);var I=O.e/y,J=_.e/y,z=O.c,N=_.c;if(!I||!J){if(!z||!N)return new w(G/0);if(!z[0]||!N[0])return N[0]?_:new w(z[0]?O:G*0)}if(I=C(I),J=C(J),z=z.slice(),G=I-J){for(G>0?(J=I,L=N):(G=-G,L=z),L.reverse();G--;L.push(0));L.reverse()}for(G=z.length,R=N.length,G-R<0&&(L=N,N=z,z=L,R=G),G=0;R;)G=(z[--R]=z[R]+N[R]+G)/v|0,z[R]=v===z[R]?0:z[R]%v;return G&&(z=[G].concat(z),++J),k(_,z,J)},Y.precision=Y.sd=function(_,R){var L,O,G,I=this;if(_!=null&&_!==!!_)return K(_,1,D),R==null?R=u:K(R,0,8),X(new w(I),_,R);if(!(L=I.c))return null;if(G=L.length-1,O=G*y+1,G=L[G]){for(;G%10==0;G/=10,O--);for(G=L[0];G>=10;G/=10,O++);}return _&&I.e+1>O&&(O=I.e+1),O},Y.shiftedBy=function(_){return K(_,-m,m),this.times("1e"+_)},Y.squareRoot=Y.sqrt=function(){var _,R,L,O,G,I=this,J=I.c,z=I.s,N=I.e,U=s+4,Q=new w("0.5");if(z!==1||!J||!J[0])return new w(!z||z<0&&(!J||J[0])?NaN:J?I:1/0);if(z=Math.sqrt(+Z(I)),z==0||z==1/0?(R=q(J),(R.length+N)%2==0&&(R+="0"),z=Math.sqrt(+R),N=C((N+1)/2)-(N<0||N%2),z==1/0?R="5e"+N:(R=z.toExponential(),R=R.slice(0,R.indexOf("e")+1)+N),L=new w(R)):L=new w(z+""),L.c[0]){for(N=L.e,z=N+U,z<3&&(z=0);;)if(G=L,L=Q.times(G.plus(ee(I,G,U,1))),q(G.c).slice(0,z)===(R=q(L.c)).slice(0,z))if(L.e<N&&--z,R=R.slice(z-3,z+1),R=="9999"||!O&&R=="4999"){if(!O&&(X(G,G.e+s+2,0),G.times(G).eq(I))){L=G;break}U+=4,z+=4,O=1}else{(!+R||!+R.slice(1)&&R.charAt(0)=="5")&&(X(L,L.e+s+2,1),_=!L.times(L).eq(I));break}}return X(L,L.e+s+1,u,_)},Y.toExponential=function(_,R){return _!=null&&(K(_,0,D),_++),H(this,_,R,1)},Y.toFixed=function(_,R){return _!=null&&(K(_,0,D),_=_+this.e+1),H(this,_,R)},Y.toFormat=function(_,R,L){var O,G=this;if(L==null)_!=null&&R&&typeof R=="object"?(L=R,R=null):_&&typeof _=="object"?(L=_,_=R=null):L=p;else if(typeof L!="object")throw Error(a+"Argument not an object: "+L);if(O=G.toFixed(_,R),G.c){var I,J=O.split("."),z=+L.groupSize,N=+L.secondaryGroupSize,U=L.groupSeparator||"",Q=J[0],j=J[1],re=G.s<0,De=re?Q.slice(1):Q,se=De.length;if(N&&(I=z,z=N,N=I,se-=I),z>0&&se>0){for(I=se%z||z,Q=De.substr(0,I);I<se;I+=z)Q+=U+De.substr(I,z);N>0&&(Q+=U+De.slice(I)),re&&(Q="-"+Q)}O=j?Q+(L.decimalSeparator||"")+((N=+L.fractionGroupSize)?j.replace(new RegExp("\\d{"+N+"}\\B","g"),"$&"+(L.fractionGroupSeparator||"")):j):Q}return(L.prefix||"")+O+(L.suffix||"")},Y.toFraction=function(_){var R,L,O,G,I,J,z,N,U,Q,j,re,De=this,se=De.c;if(_!=null&&(z=new w(_),!z.isInteger()&&(z.c||z.s!==1)||z.lt(S)))throw Error(a+"Argument "+(z.isInteger()?"out of range: ":"not an integer: ")+Z(z));if(!se)return new w(De);for(R=new w(S),U=L=new w(S),O=N=new w(S),re=q(se),I=R.e=re.length-De.e-1,R.c[0]=B[(J=I%y)<0?y+J:J],_=!_||z.comparedTo(R)>0?I>0?R:U:z,J=g,g=1/0,z=new w(re),N.c[0]=0;Q=ee(z,R,0,1),G=L.plus(Q.times(O)),G.comparedTo(_)!=1;)L=O,O=G,U=N.plus(Q.times(G=U)),N=G,R=z.minus(Q.times(G=R)),z=G;return G=ee(_.minus(L),O,0,1),N=N.plus(G.times(U)),L=L.plus(G.times(O)),N.s=U.s=De.s,I=I*2,j=ee(U,O,I,u).minus(De).abs().comparedTo(ee(N,L,I,u).minus(De).abs())<1?[U,O]:[N,L],g=J,j},Y.toNumber=function(){return+Z(this)},Y.toPrecision=function(_,R){return _!=null&&K(_,1,D),H(this,_,R,2)},Y.toString=function(_){var R,L=this,O=L.s,G=L.e;return G===null?O?(R="Infinity",O<0&&(R="-"+R)):R="NaN":(_==null?R=G<=l||G>=f?$(q(L.c),G):ae(q(L.c),G,"0"):_===10&&b?(L=X(new w(L),s+G+1,u),R=ae(q(L.c),L.e,"0")):(K(_,2,E.length,"Base"),R=ce(ae(q(L.c),G,"0"),10,_,O,!0)),O<0&&L.c[0]&&(R="-"+R)),R},Y.valueOf=Y.toJSON=function(){return Z(this)},Y._isBigNumber=!0,ie!=null&&w.set(ie),w}function C(ie){var ee=ie|0;return ie>0||ie===ee?ee:ee-1}function q(ie){for(var ee,ce,te=1,Y=ie.length,S=ie[0]+"";te<Y;){for(ee=ie[te++]+"",ce=y-ee.length;ce--;ee="0"+ee);S+=ee}for(Y=S.length;S.charCodeAt(--Y)===48;);return S.slice(0,Y+1||1)}function W(ie,ee){var ce,te,Y=ie.c,S=ee.c,s=ie.s,u=ee.s,l=ie.e,f=ee.e;if(!s||!u)return null;if(ce=Y&&!Y[0],te=S&&!S[0],ce||te)return ce?te?0:-u:s;if(s!=u)return s;if(ce=s<0,te=l==f,!Y||!S)return te?0:!Y^ce?1:-1;if(!te)return l>f^ce?1:-1;for(u=(l=Y.length)<(f=S.length)?l:f,s=0;s<u;s++)if(Y[s]!=S[s])return Y[s]>S[s]^ce?1:-1;return l==f?0:l>f^ce?1:-1}function K(ie,ee,ce,te){if(ie<ee||ie>ce||ie!==i(ie))throw Error(a+(te||"Argument")+(typeof ie=="number"?ie<ee||ie>ce?" out of range: ":" not an integer: ":" not a primitive number: ")+String(ie))}function ne(ie){var ee=ie.c.length-1;return C(ie.e/y)==ee&&ie.c[ee]%2!=0}function $(ie,ee){return(ie.length>1?ie.charAt(0)+"."+ie.slice(1):ie)+(ee<0?"e":"e+")+ee}function ae(ie,ee,ce){var te,Y;if(ee<0){for(Y=ce+".";++ee;Y+=ce);ie=Y+ie}else if(te=ie.length,++ee>te){for(Y=ce,ee-=te;--ee;Y+=ce);ie+=Y}else ee<te&&(ie=ie.slice(0,ee)+"."+ie.slice(ee));return ie}e=F(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof If<"u"&&If.exports?If.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(j1)});var W1=V(Ru=>{"use strict";var eB=A(M());Object.defineProperty(Ru,"__esModule",{value:!0});var Z8=Q1(),Lu=class{BigNum;constructor(){this.BigNum=(e,r)=>{let n=Z8.BigNumber.clone({DECIMAL_PLACES:r});return new n(e)}}winstonToAr(e,{formatted:r=!1,decimals:n=12,trim:i=!0}={}){let a=this.stringToBigNum(e,n).shiftedBy(-12);return r?a.toFormat(n):a.toFixed(n)}arToWinston(e,{formatted:r=!1}={}){let n=this.stringToBigNum(e).shiftedBy(12);return r?n.toFormat():n.toFixed(0)}compare(e,r){let n=this.stringToBigNum(e),i=this.stringToBigNum(r);return n.comparedTo(i)}isEqual(e,r){return this.compare(e,r)===0}isLessThan(e,r){let n=this.stringToBigNum(e),i=this.stringToBigNum(r);return n.isLessThan(i)}isGreaterThan(e,r){let n=this.stringToBigNum(e),i=this.stringToBigNum(r);return n.isGreaterThan(i)}add(e,r){let n=this.stringToBigNum(e),i=this.stringToBigNum(r);return n.plus(r).toFixed(0)}sub(e,r){let n=this.stringToBigNum(e),i=this.stringToBigNum(r);return n.minus(r).toFixed(0)}stringToBigNum(e,r=12){return this.BigNum(e,r)}};Ru.default=Lu});var Y1=V(Du=>{"use strict";var rB=A(M());Object.defineProperty(Du,"__esModule",{value:!0});var Fu=class{METHOD_GET="GET";METHOD_POST="POST";config;constructor(e){this.applyConfig(e)}applyConfig(e){this.config=this.mergeDefaults(e)}getConfig(){return this.config}mergeDefaults(e){let r=e.protocol||"http",n=e.port||(r==="https"?443:80);return{host:e.host||"127.0.0.1",protocol:r,port:n,timeout:e.timeout||2e4,logging:e.logging||!1,logger:e.logger||console.log,network:e.network}}async get(e,r){return await this.request(e,{...r,method:this.METHOD_GET})}async post(e,r,n){let i=new Headers(n?.headers||{});return i.get("content-type")?.includes("application/json")||i.append("content-type","application/json"),i.append("accept","application/json, text/plain, */*"),await this.request(e,{...n,method:this.METHOD_POST,body:typeof r!="string"?JSON.stringify(r):r,headers:i})}async request(e,r){let n=new Headers(r?.headers||{}),i=`${this.config.protocol}://${this.config.host}:${this.config.port}`,a=r?.responseType;delete r?.responseType,e.startsWith("/")&&(e=e.slice(1)),this.config.network&&n.append("x-network",this.config.network),this.config.logging&&this.config.logger(`Requesting: ${i}/${e}`);let d=await fetch(`${i}/${e}`,{...r||{},headers:n});this.config.logging&&this.config.logger(`Response: ${d.url} - ${d.status}`);let y=d.headers.get("content-type")?.match(/charset=([^()<>@,;:\"/[\]?.=\s]*)/i)?.[1],m=d,B=async()=>{if(y)try{m.data=new TextDecoder(y).decode(await d.arrayBuffer())}catch{m.data=await d.text()}else m.data=await d.text()};if(a==="arraybuffer")m.data=await d.arrayBuffer();else if(a==="text")await B();else if(a==="webstream")m.data=V8(d.body);else try{let P=await d.clone().json();typeof P!="object"?await B():m.data=await d.json(),P=null}catch{await B()}return m}};Du.default=Fu;var V8=t=>{let e=t;return typeof e[Symbol.asyncIterator]>"u"&&(e[Symbol.asyncIterator]=j8(t)),e},j8=function(t){return async function*(){let r=t.getReader();try{for(;;){let{done:n,value:i}=await r.read();if(n)return;yield i}}finally{r.releaseLock()}}}});var $1=V(Iu=>{"use strict";var iB=A(M());Object.defineProperty(Iu,"__esModule",{value:!0});var Ou=class{api;constructor(e){this.api=e}getInfo(){return this.api.get("info").then(e=>e.data)}getPeers(){return this.api.get("peers").then(e=>e.data)}};Iu.default=Ou});var hs=V(kf=>{"use strict";var oB=A(M());Object.defineProperty(kf,"__esModule",{value:!0});kf.getError=Q8;var ku=class extends Error{type;response;constructor(e,r={}){r.message?super(r.message):super(),this.type=e,this.response=r.response}getType(){return this.type}};kf.default=ku;function Q8(t){let e=t.data;if(typeof t.data=="string")try{e=JSON.parse(t.data)}catch{}if(t.data instanceof ArrayBuffer||t.data instanceof Uint8Array)try{e=JSON.parse(e.toString())}catch{}return e?e.error||e:t.statusText||"unknown"}});var Gu=V(ot=>{"use strict";var fB=A(M());Object.defineProperty(ot,"__esModule",{value:!0});ot.arrayCompare=ot.MIN_CHUNK_SIZE=ot.MAX_CHUNK_SIZE=void 0;ot.chunkData=Ju;ot.generateLeaves=Uu;ot.computeRootHash=W8;ot.generateTree=tp;ot.generateTransactionChunks=Y8;ot.buildLayers=Jf;ot.generateProofs=rp;ot.arrayFlatten=Hu;ot.intToBuffer=gs;ot.bufferToInt=qu;ot.validatePath=ps;ot.debug=np;var Nf=vs(),ep=pn();ot.MAX_CHUNK_SIZE=256*1024;ot.MIN_CHUNK_SIZE=32*1024;var bs=32,ro=32;async function Ju(t){let e=[],r=t,n=0;for(;r.byteLength>=ot.MAX_CHUNK_SIZE;){let i=ot.MAX_CHUNK_SIZE,a=r.byteLength-ot.MAX_CHUNK_SIZE;a>0&&a<ot.MIN_CHUNK_SIZE&&(i=Math.ceil(r.byteLength/2));let d=r.slice(0,i),v=await Nf.default.crypto.hash(d);n+=d.byteLength,e.push({dataHash:v,minByteRange:n-d.byteLength,maxByteRange:n}),r=r.slice(i)}return e.push({dataHash:await Nf.default.crypto.hash(r),minByteRange:n,maxByteRange:n+r.byteLength}),e}async function Uu(t){return Promise.all(t.map(async({dataHash:e,minByteRange:r,maxByteRange:n})=>({type:"leaf",id:await Ot(await Promise.all([Ot(e),Ot(gs(n))])),dataHash:e,minByteRange:r,maxByteRange:n})))}async function W8(t){return(await tp(t)).id}async function tp(t){return await Jf(await Uu(await Ju(t)))}async function Y8(t){let e=await Ju(t),r=await Uu(e),n=await Jf(r),i=await rp(n),a=e.slice(-1)[0];return a.maxByteRange-a.minByteRange===0&&(e.splice(e.length-1,1),i.splice(i.length-1,1)),{data_root:n.id,chunks:e,proofs:i}}async function Jf(t,e=0){if(t.length<2)return t[0];let r=[];for(let n=0;n<t.length;n+=2)r.push(await $8(t[n],t[n+1]));return Jf(r,e+1)}function rp(t){let e=Nu(t);return Array.isArray(e)?Hu(e):[e]}function Nu(t,e=new Uint8Array,r=0){if(t.type=="leaf")return{offset:t.maxByteRange-1,proof:(0,ep.concatBuffers)([e,t.dataHash,gs(t.maxByteRange)])};if(t.type=="branch"){let n=(0,ep.concatBuffers)([e,t.leftChild.id,t.rightChild.id,gs(t.byteRange)]);return[Nu(t.leftChild,n,r+1),Nu(t.rightChild,n,r+1)]}throw new Error("Unexpected node type")}function Hu(t){let e=[];return t.forEach(r=>{Array.isArray(r)?e.push(...Hu(r)):e.push(r)}),e}async function $8(t,e){return e?{type:"branch",id:await Ot([await Ot(t.id),await Ot(e.id),await Ot(gs(t.maxByteRange))]),byteRange:t.maxByteRange,maxByteRange:e.maxByteRange,leftChild:t,rightChild:e}:t}async function Ot(t){return Array.isArray(t)&&(t=Nf.default.utils.concatBuffers(t)),new Uint8Array(await Nf.default.crypto.hash(t))}function gs(t){let e=new Uint8Array(bs);for(var r=e.length-1;r>=0;r--){var n=t%256;e[r]=n,t=(t-n)/256}return e}function qu(t){let e=0;for(var r=0;r<t.length;r++)e*=256,e+=t[r];return e}var e6=(t,e)=>t.every((r,n)=>e[n]===r);ot.arrayCompare=e6;async function ps(t,e,r,n,i){if(n<=0)return!1;if(e>=n)return ps(t,0,n-1,n,i);if(e<0)return ps(t,0,0,n,i);if(i.length==ro+bs){let P=i.slice(0,ro),D=i.slice(P.length,P.length+bs),F=await Ot([await Ot(P),await Ot(D)]);return(0,ot.arrayCompare)(t,F)?{offset:n-1,leftBound:r,rightBound:n,chunkSize:n-r}:!1}let a=i.slice(0,ro),d=i.slice(a.length,a.length+ro),v=i.slice(a.length+d.length,a.length+d.length+bs),y=qu(v),m=i.slice(a.length+d.length+v.length),B=await Ot([await Ot(a),await Ot(d),await Ot(v)]);return(0,ot.arrayCompare)(t,B)?e<y?await ps(a,e,r,Math.min(n,y),m):await ps(d,e,Math.max(r,y),n,m):!1}async function np(t,e=""){if(t.byteLength<1)return e;let r=t.slice(0,ro),n=t.slice(r.length,r.length+ro),i=t.slice(r.length+n.length,r.length+n.length+bs),a=qu(i),d=t.slice(r.length+n.length+i.length),v=await Ot([await Ot(r),await Ot(n),await Ot(i)]),y=`${e}
|
|
4
4
|
${JSON.stringify(Buffer.from(r))},${JSON.stringify(Buffer.from(n))},${a} => ${JSON.stringify(v)}`;return np(d,y)}});var sp=V(Uf=>{"use strict";var uB=A(M());Object.defineProperty(Uf,"__esModule",{value:!0});Uf.TransactionUploader=void 0;var ip=xs(),t6=pn(),Xu=hs(),r6=Gu(),ap=1,n6=["invalid_json","chunk_too_big","data_path_too_big","offset_too_big","data_size_too_big","chunk_proof_ratio_not_attractive","invalid_proof"],op=1e3*40,zu=class t{api;chunkIndex=0;txPosted=!1;transaction;lastRequestTimeEnd=0;totalErrors=0;data;lastResponseStatus=0;lastResponseError="";get isComplete(){return this.txPosted&&this.chunkIndex===this.transaction.chunks.chunks.length}get totalChunks(){return this.transaction.chunks.chunks.length}get uploadedChunks(){return this.chunkIndex}get pctComplete(){return Math.trunc(this.uploadedChunks/this.totalChunks*100)}constructor(e,r){if(this.api=e,!r.id)throw new Error("Transaction is not signed");if(!r.chunks)throw new Error("Transaction chunks not prepared");this.data=r.data,this.transaction=new ip.default(Object.assign({},r,{data:new Uint8Array(0)}))}async uploadChunk(e){if(this.isComplete)throw new Error("Upload is already complete");if(this.lastResponseError!==""?this.totalErrors++:this.totalErrors=0,this.totalErrors===100)throw new Error(`Unable to complete upload: ${this.lastResponseStatus}: ${this.lastResponseError}`);let r=this.lastResponseError===""?0:Math.max(this.lastRequestTimeEnd+op-Date.now(),op);if(r>0&&(r=r-r*Math.random()*.3,await new Promise(d=>setTimeout(d,r))),this.lastResponseError="",!this.txPosted){await this.postTransaction();return}e&&(this.chunkIndex=e);let n=this.transaction.getChunk(e||this.chunkIndex,this.data);if(!await(0,r6.validatePath)(this.transaction.chunks.data_root,parseInt(n.offset),0,parseInt(n.data_size),t6.b64UrlToBuffer(n.data_path)))throw new Error(`Unable to validate chunk ${this.chunkIndex}`);let a=await this.api.post("chunk",this.transaction.getChunk(this.chunkIndex,this.data)).catch(d=>(console.error(d.message),{status:-1,data:{error:d.message}}));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=a.status,this.lastResponseStatus==200)this.chunkIndex++;else if(this.lastResponseError=(0,Xu.getError)(a),n6.includes(this.lastResponseError))throw new Error(`Fatal error uploading chunk ${this.chunkIndex}: ${this.lastResponseError}`)}static async fromSerialized(e,r,n){if(!r||typeof r.chunkIndex!="number"||typeof r.transaction!="object")throw new Error("Serialized object does not match expected format.");var i=new ip.default(r.transaction);i.chunks||await i.prepareChunks(n);let a=new t(e,i);if(a.chunkIndex=r.chunkIndex,a.lastRequestTimeEnd=r.lastRequestTimeEnd,a.lastResponseError=r.lastResponseError,a.lastResponseStatus=r.lastResponseStatus,a.txPosted=r.txPosted,a.data=n,a.transaction.data_root!==r.transaction.data_root)throw new Error("Data mismatch: Uploader doesn't match provided data.");return a}static async fromTransactionId(e,r){let n=await e.get(`tx/${r}`);if(n.status!==200)throw new Error(`Tx ${r} not found: ${n.status}`);let i=n.data;return i.data=new Uint8Array(0),{txPosted:!0,chunkIndex:0,lastResponseError:"",lastRequestTimeEnd:0,lastResponseStatus:0,transaction:i}}toJSON(){return{chunkIndex:this.chunkIndex,transaction:this.transaction,lastRequestTimeEnd:this.lastRequestTimeEnd,lastResponseStatus:this.lastResponseStatus,lastResponseError:this.lastResponseError,txPosted:this.txPosted}}async postTransaction(){if(this.totalChunks<=ap){this.transaction.data=this.data;let n=await this.api.post("tx",this.transaction).catch(i=>(console.error(i),{status:-1,data:{error:i.message}}));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=n.status,this.transaction.data=new Uint8Array(0),n.status>=200&&n.status<300){this.txPosted=!0,this.chunkIndex=ap;return}throw this.lastResponseError=(0,Xu.getError)(n),new Error(`Unable to upload transaction: ${n.status}, ${this.lastResponseError}`)}let r=await this.api.post("tx",this.transaction);if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=r.status,!(r.status>=200&&r.status<300))throw this.lastResponseError=(0,Xu.getError)(r),new Error(`Unable to upload transaction: ${r.status}, ${this.lastResponseError}`);this.txPosted=!0}};Uf.TransactionUploader=zu});var Hf=V((lB,fp)=>{var dB=A(M());fp.exports={}});var cp=V(ju=>{"use strict";var pB=A(M());Object.defineProperty(ju,"__esModule",{value:!0});var Ku=hs(),fi=xs(),ms=pn(),Zu=sp();Hf();var Vu=class{api;crypto;chunks;constructor(e,r,n){this.api=e,this.crypto=r,this.chunks=n}async getTransactionAnchor(){let e=await this.api.get("tx_anchor");if(!e.data.match(/^[a-z0-9_-]{43,}/i)||!e.ok)throw new Error(`Could not getTransactionAnchor. Received: ${e.data}. Status: ${e.status}, ${e.statusText}`);return e.data}async getPrice(e,r){let n=r?`price/${e}/${r}`:`price/${e}`,i=await this.api.get(n);if(!/^\d+$/.test(i.data)||!i.ok)throw new Error(`Could not getPrice. Received: ${i.data}. Status: ${i.status}, ${i.statusText}`);return i.data}async get(e){let r=await this.api.get(`tx/${e}`);if(r.status==200){let n=parseInt(r.data.data_size);if(r.data.format>=2&&n>0&&n<=1024*1024*12){let i=await this.getData(e);return new fi.default({...r.data,data:i})}return new fi.default({...r.data,format:r.data.format||1})}throw r.status==404?new Ku.default("TX_NOT_FOUND"):r.status==410?new Ku.default("TX_FAILED"):new Ku.default("TX_INVALID")}fromRaw(e){return new fi.default(e)}async search(e,r){return this.api.post("arql",{op:"equals",expr1:e,expr2:r}).then(n=>n.data?n.data:[])}getStatus(e){return this.api.get(`tx/${e}/status`).then(r=>r.status==200?{status:200,confirmed:r.data}:{status:r.status,confirmed:null})}async getData(e,r){let n;try{n=await this.chunks.downloadChunkedData(e)}catch(i){console.error(`Error while trying to download chunked data for ${e}`),console.error(i)}if(!n){console.warn(`Falling back to gateway cache for ${e}`);try{let{data:i,ok:a,status:d,statusText:v}=await this.api.get(`/${e}`,{responseType:"arraybuffer"});if(!a)throw new Error("Bad http status code",{cause:{status:d,statusText:v}});n=i}catch(i){console.error(`Error while trying to download contiguous data from gateway cache for ${e}`),console.error(i)}}if(!n)throw new Error(`${e} data was not found!`);return r&&r.decode&&!r.string?n:r&&r.decode&&r.string?ms.bufferToString(n):ms.bufferTob64Url(n)}async sign(e,r,n){let a=typeof r=="object"&&(v=>{let y=!0;return["n","e","d","p","q","dp","dq","qi"].map(m=>!(m in v)&&(y=!1)),y})(r),d=typeof arweaveWallet=="object";if(!a&&!d)throw new Error("No valid JWK or external wallet found to sign transaction.");if(a){e.setOwner(r.n);let v=await e.getSignatureData(),y=await this.crypto.sign(r,v,n),m=await this.crypto.hash(y);e.setSignature({id:ms.bufferTob64Url(m),owner:r.n,signature:ms.bufferTob64Url(y)})}else if(d){try{(await arweaveWallet.getPermissions()).includes("SIGN_TRANSACTION")||await arweaveWallet.connect(["SIGN_TRANSACTION"])}catch{}let v=await arweaveWallet.sign(e,n);e.setSignature({id:v.id,owner:v.owner,reward:v.reward,tags:v.tags,signature:v.signature})}else throw new Error("An error occurred while signing. Check wallet is valid")}async verify(e){let r=await e.getSignatureData(),n=e.get("signature",{decode:!0,string:!1}),i=ms.bufferTob64Url(await this.crypto.hash(n));if(e.id!==i)throw new Error("Invalid transaction signature or ID! The transaction ID doesn't match the expected SHA-256 hash of the signature.");return this.crypto.verify(e.owner,r,n)}async post(e){if(typeof e=="string"?e=new fi.default(JSON.parse(e)):typeof e.readInt32BE=="function"?e=new fi.default(JSON.parse(e.toString())):typeof e=="object"&&!(e instanceof fi.default)&&(e=new fi.default(e)),!(e instanceof fi.default))throw new Error("Must be Transaction object");e.chunks||await e.prepareChunks(e.data);let r=await this.getUploader(e,e.data);try{for(;!r.isComplete;)await r.uploadChunk()}catch(n){if(r.lastResponseStatus>0)return{status:r.lastResponseStatus,statusText:r.lastResponseError,data:{error:r.lastResponseError}};throw n}return{status:200,statusText:"OK",data:{}}}async getUploader(e,r){let n;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),e instanceof fi.default){if(r||(r=e.data),!(r instanceof Uint8Array))throw new Error("Data format is invalid");e.chunks||await e.prepareChunks(r),n=new Zu.TransactionUploader(this.api,e),(!n.data||n.data.length===0)&&(n.data=r)}else{if(typeof e=="string"&&(e=await Zu.TransactionUploader.fromTransactionId(this.api,e)),!r||!(r instanceof Uint8Array))throw new Error("Must provide data when resuming upload");n=await Zu.TransactionUploader.fromSerialized(this.api,e,r)}return n}async*upload(e,r){let n=await this.getUploader(e,r);for(;!n.isComplete;)await n.uploadChunk(),yield n;return n}};ju.default=Vu});var lp=V(Wu=>{"use strict";var gB=A(M());Object.defineProperty(Wu,"__esModule",{value:!0});var up=pn();Hf();var Qu=class{api;crypto;constructor(e,r){this.api=e,this.crypto=r}getBalance(e){return this.api.get(`wallet/${e}/balance`).then(r=>r.data)}getLastTransactionID(e){return this.api.get(`wallet/${e}/last_tx`).then(r=>r.data)}generate(){return this.crypto.generateJWK()}async jwkToAddress(e){return!e||e==="use_wallet"?this.getAddress():this.getAddress(e)}async getAddress(e){if(!e||e==="use_wallet"){try{await arweaveWallet.connect(["ACCESS_ADDRESS"])}catch{}return arweaveWallet.getActiveAddress()}else return this.ownerToAddress(e.n)}async ownerToAddress(e){return up.bufferTob64Url(await this.crypto.hash(up.b64UrlToBuffer(e)))}};Wu.default=Qu});var hp=V(ys=>{"use strict";var xB=A(M());Object.defineProperty(ys,"__esModule",{value:!0});ys.SiloResource=void 0;var dp=pn(),Yu=class{api;crypto;transactions;constructor(e,r,n){this.api=e,this.crypto=r,this.transactions=n}async get(e){if(!e)throw new Error("No Silo URI specified");let r=await this.parseUri(e),n=await this.transactions.search("Silo-Name",r.getAccessKey());if(n.length==0)throw new Error(`No data could be found for the Silo URI: ${e}`);let i=await this.transactions.get(n[0]);if(!i)throw new Error(`No data could be found for the Silo URI: ${e}`);let a=i.get("data",{decode:!0,string:!1});return this.crypto.decrypt(a,r.getEncryptionKey())}async readTransactionData(e,r){if(!r)throw new Error("No Silo URI specified");let n=await this.parseUri(r),i=e.get("data",{decode:!0,string:!1});return this.crypto.decrypt(i,n.getEncryptionKey())}async parseUri(e){let r=e.match(/^([a-z0-9-_]+)\.([0-9]+)/i);if(!r)throw new Error("Invalid Silo name, must be a name in the format of [a-z0-9]+.[0-9]+, e.g. 'bubble.7'");let n=r[1],i=Math.pow(2,parseInt(r[2])),a=await this.hash(dp.stringToBuffer(n),i),d=dp.bufferTob64(a.slice(0,15)),v=await this.hash(a.slice(16,31),1);return new qf(e,d,v)}async hash(e,r){let n=await this.crypto.hash(e);for(let i=0;i<r-1;i++)n=await this.crypto.hash(n);return n}};ys.default=Yu;var qf=class{uri;accessKey;encryptionKey;constructor(e,r,n){this.uri=e,this.accessKey=r,this.encryptionKey=n}getUri(){return this.uri}getAccessKey(){return this.accessKey}getEncryptionKey(){return this.encryptionKey}};ys.SiloResource=qf});var bp=V(el=>{"use strict";var yB=A(M());Object.defineProperty(el,"__esModule",{value:!0});var pp=hs(),i6=pn(),$u=class{api;constructor(e){this.api=e}async getTransactionOffset(e){let r=await this.api.get(`tx/${e}/offset`);if(r.status===200)return r.data;throw new Error(`Unable to get transaction offset: ${(0,pp.getError)(r)}`)}async getChunk(e){let r=await this.api.get(`chunk/${e}`);if(r.status===200)return r.data;throw new Error(`Unable to get chunk: ${(0,pp.getError)(r)}`)}async getChunkData(e){let r=await this.getChunk(e);return i6.b64UrlToBuffer(r.chunk)}firstChunkOffset(e){return parseInt(e.offset)-parseInt(e.size)+1}async downloadChunkedData(e){let r=await this.getTransactionOffset(e),n=parseInt(r.size),a=parseInt(r.offset)-n+1,d=new Uint8Array(n),v=0;for(;v<n;){this.api.config.logging&&console.log(`[chunk] ${v}/${n}`);let y;try{y=await this.getChunkData(a+v)}catch{console.error(`[chunk] Failed to fetch chunk at offset ${a+v}`),console.error("[chunk] This could indicate that the chunk wasn't uploaded or hasn't yet seeded properly to a particular gateway/node")}if(y)d.set(y,v),v+=y.length;else throw new Error(`Couldn't complete data download at ${v}/${n}`)}return d}};el.default=$u});var vp=V(rl=>{"use strict";var AB=A(M());Object.defineProperty(rl,"__esModule",{value:!0});var gp=hs();Hf();var tl=class t{api;network;static HASH_ENDPOINT="block/hash/";static HEIGHT_ENDPOINT="block/height/";constructor(e,r){this.api=e,this.network=r}async get(e){let r=await this.api.get(`${t.HASH_ENDPOINT}${e}`);if(r.status===200)return r.data;throw r.status===404?new gp.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${r}`)}async getByHeight(e){let r=await this.api.get(`${t.HEIGHT_ENDPOINT}${e}`);if(r.status===200)return r.data;throw r.status===404?new gp.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${r}`)}async getCurrent(){let{current:e}=await this.network.getInfo();return await this.get(e)}};rl.default=tl});var vs=V(il=>{"use strict";var MB=A(M());Object.defineProperty(il,"__esModule",{value:!0});var a6=W1(),o6=Y1(),s6=Pu(),f6=$1(),c6=cp(),u6=lp(),xp=xs(),ws=pn(),l6=hp(),d6=bp(),h6=vp(),nl=class t{api;wallets;transactions;network;blocks;ar;silo;chunks;static init;static crypto=new s6.default;static utils=ws;constructor(e){this.api=new o6.default(e),this.wallets=new u6.default(this.api,t.crypto),this.chunks=new d6.default(this.api),this.transactions=new c6.default(this.api,t.crypto,this.chunks),this.silo=new l6.default(this.api,this.crypto,this.transactions),this.network=new f6.default(this.api),this.blocks=new h6.default(this.api,this.network),this.ar=new a6.default}get crypto(){return t.crypto}get utils(){return t.utils}getConfig(){return{api:this.api.getConfig(),crypto:null}}async createTransaction(e,r){let n={};if(Object.assign(n,e),!e.data&&!(e.target&&e.quantity))throw new Error("A new Arweave transaction must have a 'data' value, or 'target' and 'quantity' values.");if(e.owner==null&&r&&r!=="use_wallet"&&(n.owner=r.n),e.last_tx==null&&(n.last_tx=await this.transactions.getTransactionAnchor()),typeof e.data=="string"&&(e.data=ws.stringToBuffer(e.data)),e.data instanceof ArrayBuffer&&(e.data=new Uint8Array(e.data)),e.data&&!(e.data instanceof Uint8Array))throw new Error("Expected data to be a string, Uint8Array or ArrayBuffer");if(e.reward==null){let a=e.data?e.data.byteLength:0;n.reward=await this.transactions.getPrice(a,n.target)}n.data_root="",n.data_size=e.data?e.data.byteLength.toString():"0",n.data=e.data||new Uint8Array(0);let i=new xp.default(n);return await i.getSignatureData(),i}async createSiloTransaction(e,r,n){let i={};if(Object.assign(i,e),!e.data)throw new Error("Silo transactions must have a 'data' value");if(!n)throw new Error("No Silo URI specified.");if(e.target||e.quantity)throw new Error("Silo transactions can only be used for storing data, sending AR to other wallets isn't supported.");if(e.owner==null){if(!r||!r.n)throw new Error("A new Arweave transaction must either have an 'owner' attribute, or you must provide the jwk parameter.");i.owner=r.n}e.last_tx==null&&(i.last_tx=await this.transactions.getTransactionAnchor());let a=await this.silo.parseUri(n);if(typeof e.data=="string"){let v=await this.crypto.encrypt(ws.stringToBuffer(e.data),a.getEncryptionKey());i.reward=await this.transactions.getPrice(v.byteLength),i.data=ws.bufferTob64Url(v)}if(e.data instanceof Uint8Array){let v=await this.crypto.encrypt(e.data,a.getEncryptionKey());i.reward=await this.transactions.getPrice(v.byteLength),i.data=ws.bufferTob64Url(v)}let d=new xp.default(i);return d.addTag("Silo-Name",a.getAccessKey()),d.addTag("Silo-Version","0.1.0"),d}arql(e){return this.api.post("/arql",e).then(r=>r.data||[])}};il.default=nl});var wp=V(al=>{"use strict";var EB=A(M());Object.defineProperty(al,"__esModule",{value:!0});al.default=mp;var Cr=vs();async function mp(t){if(Array.isArray(t)){let n=Cr.default.utils.concatBuffers([Cr.default.utils.stringToBuffer("list"),Cr.default.utils.stringToBuffer(t.length.toString())]);return await yp(t,await Cr.default.crypto.hash(n,"SHA-384"))}let e=Cr.default.utils.concatBuffers([Cr.default.utils.stringToBuffer("blob"),Cr.default.utils.stringToBuffer(t.byteLength.toString())]),r=Cr.default.utils.concatBuffers([await Cr.default.crypto.hash(e,"SHA-384"),await Cr.default.crypto.hash(t,"SHA-384")]);return await Cr.default.crypto.hash(r,"SHA-384")}async function yp(t,e){if(t.length<1)return e;let r=Cr.default.utils.concatBuffers([e,await mp(t[0])]),n=await Cr.default.crypto.hash(r,"SHA-384");return await yp(t.slice(1),n)}});var xs=V(Ss=>{"use strict";var BB=A(M());Object.defineProperty(Ss,"__esModule",{value:!0});Ss.Tag=void 0;var Dt=pn(),p6=wp(),b6=Gu(),Gf=class{get(e,r){if(!Object.getOwnPropertyNames(this).includes(e))throw new Error(`Field "${e}" is not a property of the Arweave Transaction class.`);if(this[e]instanceof Uint8Array)return r&&r.decode&&r.string?Dt.bufferToString(this[e]):r&&r.decode&&!r.string?this[e]:Dt.bufferTob64Url(this[e]);if(this[e]instanceof Array){if(r?.decode!==void 0||r?.string!==void 0)throw e==="tags"&&console.warn(`Did you mean to use 'transaction["tags"]' ?`),new Error("Cannot decode or stringify an array.");return this[e]}return r&&r.decode==!0?r&&r.string?Dt.b64UrlToString(this[e]):Dt.b64UrlToBuffer(this[e]):this[e]}},As=class extends Gf{name;value;constructor(e,r,n=!1){super(),this.name=e,this.value=r}};Ss.Tag=As;var ol=class extends Gf{format=2;id="";last_tx="";owner="";tags=[];target="";quantity="0";data_size="0";data=new Uint8Array;data_root="";reward="0";signature="";chunks;constructor(e={}){super(),Object.assign(this,e),typeof this.data=="string"&&(this.data=Dt.b64UrlToBuffer(this.data)),e.tags&&(this.tags=e.tags.map(r=>new As(r.name,r.value)))}addTag(e,r){this.tags.push(new As(Dt.stringToB64Url(e),Dt.stringToB64Url(r)))}toJSON(){return{format:this.format,id:this.id,last_tx:this.last_tx,owner:this.owner,tags:this.tags,target:this.target,quantity:this.quantity,data:Dt.bufferTob64Url(this.data),data_size:this.data_size,data_root:this.data_root,data_tree:this.data_tree,reward:this.reward,signature:this.signature}}setOwner(e){this.owner=e}setSignature({id:e,owner:r,reward:n,tags:i,signature:a}){this.id=e,this.owner=r,n&&(this.reward=n),i&&(this.tags=i),this.signature=a}async prepareChunks(e){!this.chunks&&e.byteLength>0&&(this.chunks=await(0,b6.generateTransactionChunks)(e),this.data_root=Dt.bufferTob64Url(this.chunks.data_root)),!this.chunks&&e.byteLength===0&&(this.chunks={chunks:[],data_root:new Uint8Array,proofs:[]},this.data_root="")}getChunk(e,r){if(!this.chunks)throw new Error("Chunks have not been prepared");let n=this.chunks.proofs[e],i=this.chunks.chunks[e];return{data_root:this.data_root,data_size:this.data_size,data_path:Dt.bufferTob64Url(n.proof),offset:n.offset.toString(),chunk:Dt.bufferTob64Url(r.slice(i.minByteRange,i.maxByteRange))}}async getSignatureData(){switch(this.format){case 1:let e=this.tags.reduce((n,i)=>Dt.concatBuffers([n,i.get("name",{decode:!0,string:!1}),i.get("value",{decode:!0,string:!1})]),new Uint8Array);return Dt.concatBuffers([this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),this.get("data",{decode:!0,string:!1}),Dt.stringToBuffer(this.quantity),Dt.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),e]);case 2:this.data_root||await this.prepareChunks(this.data);let r=this.tags.map(n=>[n.get("name",{decode:!0,string:!1}),n.get("value",{decode:!0,string:!1})]);return await(0,p6.default)([Dt.stringToBuffer(this.format.toString()),this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),Dt.stringToBuffer(this.quantity),Dt.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),r,Dt.stringToBuffer(this.data_size),this.get("data_root",{decode:!0,string:!1})]);default:throw new Error(`Unexpected transaction format: ${this.format}`)}}};Ss.default=ol});var Ap=V(Xf=>{"use strict";var PB=A(M());Object.defineProperty(Xf,"__esModule",{value:!0});Xf.getDefaultConfig=void 0;var g6=(t,e)=>{let r=/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,n=e.split("."),i=n[n.length-1],a=["localhost","[::1]"];return a.includes(e)||t=="file"||a.includes(i)||!!e.match(r)||!!i.match(r)},v6=t=>{let e=t.charAt(0)==="[",r=/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/;return!!t.match(r)||e},x6=(t,e)=>{if(g6(t,e))return{protocol:"https",host:"arweave.net",port:443};if(!v6(e)){let r=e.split(".");if(r.length>=3){r.shift();let n=r.join(".");return{protocol:t,host:n}}}return{protocol:t,host:e}};Xf.getDefaultConfig=x6});var Sp=V(Li=>{"use strict";var RB=A(M()),m6=Li&&Li.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),y6=Li&&Li.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&m6(e,t,r)};Object.defineProperty(Li,"__esModule",{value:!0});var no=vs(),w6=Ap();no.default.init=function(t={}){let e={host:"arweave.net",port:443,protocol:"https"};if(typeof location!="object"||!location.protocol||!location.hostname)return new no.default({...t,...e});let r=location.protocol.replace(":",""),n=location.hostname,i=location.port?parseInt(location.port):r=="https"?443:80,a=(0,w6.getDefaultConfig)(r,n),d=t.protocol||a.protocol,v=t.host||a.host,y=t.port||a.port||i;return new no.default({...t,host:v,protocol:d,port:y})};typeof globalThis=="object"?globalThis.Arweave=no.default:typeof self=="object"&&(self.Arweave=no.default);y6(vs(),Li);Li.default=no.default});var fl=V((_p,sl)=>{var UB=A(M());(function(t,e){"use strict";function r(S,s){if(!S)throw new Error(s||"Assertion failed")}function n(S,s){S.super_=s;var u=function(){};u.prototype=s.prototype,S.prototype=new u,S.prototype.constructor=S}function i(S,s,u){if(i.isBN(S))return S;this.negative=0,this.words=null,this.length=0,this.red=null,S!==null&&((s==="le"||s==="be")&&(u=s,s=10),this._init(S||0,s||10,u||"be"))}typeof t=="object"?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var a;try{typeof window<"u"&&typeof window.Buffer<"u"?a=window.Buffer:a=require("buffer").Buffer}catch{}i.isBN=function(s){return s instanceof i?!0:s!==null&&typeof s=="object"&&s.constructor.wordSize===i.wordSize&&Array.isArray(s.words)},i.max=function(s,u){return s.cmp(u)>0?s:u},i.min=function(s,u){return s.cmp(u)<0?s:u},i.prototype._init=function(s,u,l){if(typeof s=="number")return this._initNumber(s,u,l);if(typeof s=="object")return this._initArray(s,u,l);u==="hex"&&(u=16),r(u===(u|0)&&u>=2&&u<=36),s=s.toString().replace(/\s+/g,"");var f=0;s[0]==="-"&&(f++,this.negative=1),f<s.length&&(u===16?this._parseHex(s,f,l):(this._parseBase(s,u,f),l==="le"&&this._initArray(this.toArray(),u,l)))},i.prototype._initNumber=function(s,u,l){s<0&&(this.negative=1,s=-s),s<67108864?(this.words=[s&67108863],this.length=1):s<4503599627370496?(this.words=[s&67108863,s/67108864&67108863],this.length=2):(r(s<9007199254740992),this.words=[s&67108863,s/67108864&67108863,1],this.length=3),l==="le"&&this._initArray(this.toArray(),u,l)},i.prototype._initArray=function(s,u,l){if(r(typeof s.length=="number"),s.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(s.length/3),this.words=new Array(this.length);for(var f=0;f<this.length;f++)this.words[f]=0;var c,g,x=0;if(l==="be")for(f=s.length-1,c=0;f>=0;f-=3)g=s[f]|s[f-1]<<8|s[f-2]<<16,this.words[c]|=g<<x&67108863,this.words[c+1]=g>>>26-x&67108863,x+=24,x>=26&&(x-=26,c++);else if(l==="le")for(f=0,c=0;f<s.length;f+=3)g=s[f]|s[f+1]<<8|s[f+2]<<16,this.words[c]|=g<<x&67108863,this.words[c+1]=g>>>26-x&67108863,x+=24,x>=26&&(x-=26,c++);return this.strip()};function d(S,s){var u=S.charCodeAt(s);return u>=65&&u<=70?u-55:u>=97&&u<=102?u-87:u-48&15}function v(S,s,u){var l=d(S,u);return u-1>=s&&(l|=d(S,u-1)<<4),l}i.prototype._parseHex=function(s,u,l){this.length=Math.ceil((s.length-u)/6),this.words=new Array(this.length);for(var f=0;f<this.length;f++)this.words[f]=0;var c=0,g=0,x;if(l==="be")for(f=s.length-1;f>=u;f-=2)x=v(s,u,f)<<c,this.words[g]|=x&67108863,c>=18?(c-=18,g+=1,this.words[g]|=x>>>26):c+=8;else{var h=s.length-u;for(f=h%2===0?u+1:u;f<s.length;f+=2)x=v(s,u,f)<<c,this.words[g]|=x&67108863,c>=18?(c-=18,g+=1,this.words[g]|=x>>>26):c+=8}this.strip()};function y(S,s,u,l){for(var f=0,c=Math.min(S.length,u),g=s;g<c;g++){var x=S.charCodeAt(g)-48;f*=l,x>=49?f+=x-49+10:x>=17?f+=x-17+10:f+=x}return f}i.prototype._parseBase=function(s,u,l){this.words=[0],this.length=1;for(var f=0,c=1;c<=67108863;c*=u)f++;f--,c=c/u|0;for(var g=s.length-l,x=g%f,h=Math.min(g,g-x)+l,o=0,p=l;p<h;p+=f)o=y(s,p,p+f,u),this.imuln(c),this.words[0]+o<67108864?this.words[0]+=o:this._iaddn(o);if(x!==0){var E=1;for(o=y(s,p,s.length,u),p=0;p<x;p++)E*=u;this.imuln(E),this.words[0]+o<67108864?this.words[0]+=o:this._iaddn(o)}this.strip()},i.prototype.copy=function(s){s.words=new Array(this.length);for(var u=0;u<this.length;u++)s.words[u]=this.words[u];s.length=this.length,s.negative=this.negative,s.red=this.red},i.prototype.clone=function(){var s=new i(null);return this.copy(s),s},i.prototype._expand=function(s){for(;this.length<s;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var m=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],B=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],P=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(s,u){s=s||10,u=u|0||1;var l;if(s===16||s==="hex"){l="";for(var f=0,c=0,g=0;g<this.length;g++){var x=this.words[g],h=((x<<f|c)&16777215).toString(16);c=x>>>24-f&16777215,f+=2,f>=26&&(f-=26,g--),c!==0||g!==this.length-1?l=m[6-h.length]+h+l:l=h+l}for(c!==0&&(l=c.toString(16)+l);l.length%u!==0;)l="0"+l;return this.negative!==0&&(l="-"+l),l}if(s===(s|0)&&s>=2&&s<=36){var o=B[s],p=P[s];l="";var E=this.clone();for(E.negative=0;!E.isZero();){var b=E.modn(p).toString(s);E=E.idivn(p),E.isZero()?l=b+l:l=m[o-b.length]+b+l}for(this.isZero()&&(l="0"+l);l.length%u!==0;)l="0"+l;return this.negative!==0&&(l="-"+l),l}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var s=this.words[0];return this.length===2?s+=this.words[1]*67108864:this.length===3&&this.words[2]===1?s+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-s:s},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(s,u){return r(typeof a<"u"),this.toArrayLike(a,s,u)},i.prototype.toArray=function(s,u){return this.toArrayLike(Array,s,u)},i.prototype.toArrayLike=function(s,u,l){var f=this.byteLength(),c=l||Math.max(1,f);r(f<=c,"byte array longer than desired length"),r(c>0,"Requested array length <= 0"),this.strip();var g=u==="le",x=new s(c),h,o,p=this.clone();if(g){for(o=0;!p.isZero();o++)h=p.andln(255),p.iushrn(8),x[o]=h;for(;o<c;o++)x[o]=0}else{for(o=0;o<c-f;o++)x[o]=0;for(o=0;!p.isZero();o++)h=p.andln(255),p.iushrn(8),x[c-o-1]=h}return x},Math.clz32?i.prototype._countBits=function(s){return 32-Math.clz32(s)}:i.prototype._countBits=function(s){var u=s,l=0;return u>=4096&&(l+=13,u>>>=13),u>=64&&(l+=7,u>>>=7),u>=8&&(l+=4,u>>>=4),u>=2&&(l+=2,u>>>=2),l+u},i.prototype._zeroBits=function(s){if(s===0)return 26;var u=s,l=0;return u&8191||(l+=13,u>>>=13),u&127||(l+=7,u>>>=7),u&15||(l+=4,u>>>=4),u&3||(l+=2,u>>>=2),u&1||l++,l},i.prototype.bitLength=function(){var s=this.words[this.length-1],u=this._countBits(s);return(this.length-1)*26+u};function D(S){for(var s=new Array(S.bitLength()),u=0;u<s.length;u++){var l=u/26|0,f=u%26;s[u]=(S.words[l]&1<<f)>>>f}return s}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var s=0,u=0;u<this.length;u++){var l=this._zeroBits(this.words[u]);if(s+=l,l!==26)break}return s},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(s){return this.negative!==0?this.abs().inotn(s).iaddn(1):this.clone()},i.prototype.fromTwos=function(s){return this.testn(s-1)?this.notn(s).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(s){for(;this.length<s.length;)this.words[this.length++]=0;for(var u=0;u<s.length;u++)this.words[u]=this.words[u]|s.words[u];return this.strip()},i.prototype.ior=function(s){return r((this.negative|s.negative)===0),this.iuor(s)},i.prototype.or=function(s){return this.length>s.length?this.clone().ior(s):s.clone().ior(this)},i.prototype.uor=function(s){return this.length>s.length?this.clone().iuor(s):s.clone().iuor(this)},i.prototype.iuand=function(s){var u;this.length>s.length?u=s:u=this;for(var l=0;l<u.length;l++)this.words[l]=this.words[l]&s.words[l];return this.length=u.length,this.strip()},i.prototype.iand=function(s){return r((this.negative|s.negative)===0),this.iuand(s)},i.prototype.and=function(s){return this.length>s.length?this.clone().iand(s):s.clone().iand(this)},i.prototype.uand=function(s){return this.length>s.length?this.clone().iuand(s):s.clone().iuand(this)},i.prototype.iuxor=function(s){var u,l;this.length>s.length?(u=this,l=s):(u=s,l=this);for(var f=0;f<l.length;f++)this.words[f]=u.words[f]^l.words[f];if(this!==u)for(;f<u.length;f++)this.words[f]=u.words[f];return this.length=u.length,this.strip()},i.prototype.ixor=function(s){return r((this.negative|s.negative)===0),this.iuxor(s)},i.prototype.xor=function(s){return this.length>s.length?this.clone().ixor(s):s.clone().ixor(this)},i.prototype.uxor=function(s){return this.length>s.length?this.clone().iuxor(s):s.clone().iuxor(this)},i.prototype.inotn=function(s){r(typeof s=="number"&&s>=0);var u=Math.ceil(s/26)|0,l=s%26;this._expand(u),l>0&&u--;for(var f=0;f<u;f++)this.words[f]=~this.words[f]&67108863;return l>0&&(this.words[f]=~this.words[f]&67108863>>26-l),this.strip()},i.prototype.notn=function(s){return this.clone().inotn(s)},i.prototype.setn=function(s,u){r(typeof s=="number"&&s>=0);var l=s/26|0,f=s%26;return this._expand(l+1),u?this.words[l]=this.words[l]|1<<f:this.words[l]=this.words[l]&~(1<<f),this.strip()},i.prototype.iadd=function(s){var u;if(this.negative!==0&&s.negative===0)return this.negative=0,u=this.isub(s),this.negative^=1,this._normSign();if(this.negative===0&&s.negative!==0)return s.negative=0,u=this.isub(s),s.negative=1,u._normSign();var l,f;this.length>s.length?(l=this,f=s):(l=s,f=this);for(var c=0,g=0;g<f.length;g++)u=(l.words[g]|0)+(f.words[g]|0)+c,this.words[g]=u&67108863,c=u>>>26;for(;c!==0&&g<l.length;g++)u=(l.words[g]|0)+c,this.words[g]=u&67108863,c=u>>>26;if(this.length=l.length,c!==0)this.words[this.length]=c,this.length++;else if(l!==this)for(;g<l.length;g++)this.words[g]=l.words[g];return this},i.prototype.add=function(s){var u;return s.negative!==0&&this.negative===0?(s.negative=0,u=this.sub(s),s.negative^=1,u):s.negative===0&&this.negative!==0?(this.negative=0,u=s.sub(this),this.negative=1,u):this.length>s.length?this.clone().iadd(s):s.clone().iadd(this)},i.prototype.isub=function(s){if(s.negative!==0){s.negative=0;var u=this.iadd(s);return s.negative=1,u._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(s),this.negative=1,this._normSign();var l=this.cmp(s);if(l===0)return this.negative=0,this.length=1,this.words[0]=0,this;var f,c;l>0?(f=this,c=s):(f=s,c=this);for(var g=0,x=0;x<c.length;x++)u=(f.words[x]|0)-(c.words[x]|0)+g,g=u>>26,this.words[x]=u&67108863;for(;g!==0&&x<f.length;x++)u=(f.words[x]|0)+g,g=u>>26,this.words[x]=u&67108863;if(g===0&&x<f.length&&f!==this)for(;x<f.length;x++)this.words[x]=f.words[x];return this.length=Math.max(this.length,x),f!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(s){return this.clone().isub(s)};function F(S,s,u){u.negative=s.negative^S.negative;var l=S.length+s.length|0;u.length=l,l=l-1|0;var f=S.words[0]|0,c=s.words[0]|0,g=f*c,x=g&67108863,h=g/67108864|0;u.words[0]=x;for(var o=1;o<l;o++){for(var p=h>>>26,E=h&67108863,b=Math.min(o,s.length-1),w=Math.max(0,o-S.length+1);w<=b;w++){var H=o-w|0;f=S.words[H]|0,c=s.words[w]|0,g=f*c+E,p+=g/67108864|0,E=g&67108863}u.words[o]=E|0,h=p|0}return h!==0?u.words[o]=h|0:u.length--,u.strip()}var C=function(s,u,l){var f=s.words,c=u.words,g=l.words,x=0,h,o,p,E=f[0]|0,b=E&8191,w=E>>>13,H=f[1]|0,T=H&8191,k=H>>>13,X=f[2]|0,Z=X&8191,_=X>>>13,R=f[3]|0,L=R&8191,O=R>>>13,G=f[4]|0,I=G&8191,J=G>>>13,z=f[5]|0,N=z&8191,U=z>>>13,Q=f[6]|0,j=Q&8191,re=Q>>>13,De=f[7]|0,se=De&8191,le=De>>>13,Ue=f[8]|0,oe=Ue&8191,fe=Ue>>>13,Xe=f[9]|0,ge=Xe&8191,ve=Xe>>>13,bt=c[0]|0,pe=bt&8191,be=bt>>>13,Ye=c[1]|0,de=Ye&8191,ue=Ye>>>13,Xt=c[2]|0,xe=Xt&8191,me=Xt>>>13,zt=c[3]|0,ye=zt&8191,we=zt>>>13,Kt=c[4]|0,Ae=Kt&8191,Se=Kt>>>13,Zt=c[5]|0,Me=Zt&8191,Te=Zt>>>13,Vt=c[6]|0,Ee=Vt&8191,_e=Vt>>>13,jt=c[7]|0,Be=jt&8191,Ce=jt>>>13,Qt=c[8]|0,Pe=Qt&8191,Le=Qt>>>13,Wt=c[9]|0,Re=Wt&8191,Fe=Wt>>>13;l.negative=s.negative^u.negative,l.length=19,h=Math.imul(b,pe),o=Math.imul(b,be),o=o+Math.imul(w,pe)|0,p=Math.imul(w,be);var Rt=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,h=Math.imul(T,pe),o=Math.imul(T,be),o=o+Math.imul(k,pe)|0,p=Math.imul(k,be),h=h+Math.imul(b,de)|0,o=o+Math.imul(b,ue)|0,o=o+Math.imul(w,de)|0,p=p+Math.imul(w,ue)|0;var ke=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(ke>>>26)|0,ke&=67108863,h=Math.imul(Z,pe),o=Math.imul(Z,be),o=o+Math.imul(_,pe)|0,p=Math.imul(_,be),h=h+Math.imul(T,de)|0,o=o+Math.imul(T,ue)|0,o=o+Math.imul(k,de)|0,p=p+Math.imul(k,ue)|0,h=h+Math.imul(b,xe)|0,o=o+Math.imul(b,me)|0,o=o+Math.imul(w,xe)|0,p=p+Math.imul(w,me)|0;var Ne=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,h=Math.imul(L,pe),o=Math.imul(L,be),o=o+Math.imul(O,pe)|0,p=Math.imul(O,be),h=h+Math.imul(Z,de)|0,o=o+Math.imul(Z,ue)|0,o=o+Math.imul(_,de)|0,p=p+Math.imul(_,ue)|0,h=h+Math.imul(T,xe)|0,o=o+Math.imul(T,me)|0,o=o+Math.imul(k,xe)|0,p=p+Math.imul(k,me)|0,h=h+Math.imul(b,ye)|0,o=o+Math.imul(b,we)|0,o=o+Math.imul(w,ye)|0,p=p+Math.imul(w,we)|0;var At=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(At>>>26)|0,At&=67108863,h=Math.imul(I,pe),o=Math.imul(I,be),o=o+Math.imul(J,pe)|0,p=Math.imul(J,be),h=h+Math.imul(L,de)|0,o=o+Math.imul(L,ue)|0,o=o+Math.imul(O,de)|0,p=p+Math.imul(O,ue)|0,h=h+Math.imul(Z,xe)|0,o=o+Math.imul(Z,me)|0,o=o+Math.imul(_,xe)|0,p=p+Math.imul(_,me)|0,h=h+Math.imul(T,ye)|0,o=o+Math.imul(T,we)|0,o=o+Math.imul(k,ye)|0,p=p+Math.imul(k,we)|0,h=h+Math.imul(b,Ae)|0,o=o+Math.imul(b,Se)|0,o=o+Math.imul(w,Ae)|0,p=p+Math.imul(w,Se)|0;var St=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(St>>>26)|0,St&=67108863,h=Math.imul(N,pe),o=Math.imul(N,be),o=o+Math.imul(U,pe)|0,p=Math.imul(U,be),h=h+Math.imul(I,de)|0,o=o+Math.imul(I,ue)|0,o=o+Math.imul(J,de)|0,p=p+Math.imul(J,ue)|0,h=h+Math.imul(L,xe)|0,o=o+Math.imul(L,me)|0,o=o+Math.imul(O,xe)|0,p=p+Math.imul(O,me)|0,h=h+Math.imul(Z,ye)|0,o=o+Math.imul(Z,we)|0,o=o+Math.imul(_,ye)|0,p=p+Math.imul(_,we)|0,h=h+Math.imul(T,Ae)|0,o=o+Math.imul(T,Se)|0,o=o+Math.imul(k,Ae)|0,p=p+Math.imul(k,Se)|0,h=h+Math.imul(b,Me)|0,o=o+Math.imul(b,Te)|0,o=o+Math.imul(w,Me)|0,p=p+Math.imul(w,Te)|0;var Mt=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,h=Math.imul(j,pe),o=Math.imul(j,be),o=o+Math.imul(re,pe)|0,p=Math.imul(re,be),h=h+Math.imul(N,de)|0,o=o+Math.imul(N,ue)|0,o=o+Math.imul(U,de)|0,p=p+Math.imul(U,ue)|0,h=h+Math.imul(I,xe)|0,o=o+Math.imul(I,me)|0,o=o+Math.imul(J,xe)|0,p=p+Math.imul(J,me)|0,h=h+Math.imul(L,ye)|0,o=o+Math.imul(L,we)|0,o=o+Math.imul(O,ye)|0,p=p+Math.imul(O,we)|0,h=h+Math.imul(Z,Ae)|0,o=o+Math.imul(Z,Se)|0,o=o+Math.imul(_,Ae)|0,p=p+Math.imul(_,Se)|0,h=h+Math.imul(T,Me)|0,o=o+Math.imul(T,Te)|0,o=o+Math.imul(k,Me)|0,p=p+Math.imul(k,Te)|0,h=h+Math.imul(b,Ee)|0,o=o+Math.imul(b,_e)|0,o=o+Math.imul(w,Ee)|0,p=p+Math.imul(w,_e)|0;var Tt=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,h=Math.imul(se,pe),o=Math.imul(se,be),o=o+Math.imul(le,pe)|0,p=Math.imul(le,be),h=h+Math.imul(j,de)|0,o=o+Math.imul(j,ue)|0,o=o+Math.imul(re,de)|0,p=p+Math.imul(re,ue)|0,h=h+Math.imul(N,xe)|0,o=o+Math.imul(N,me)|0,o=o+Math.imul(U,xe)|0,p=p+Math.imul(U,me)|0,h=h+Math.imul(I,ye)|0,o=o+Math.imul(I,we)|0,o=o+Math.imul(J,ye)|0,p=p+Math.imul(J,we)|0,h=h+Math.imul(L,Ae)|0,o=o+Math.imul(L,Se)|0,o=o+Math.imul(O,Ae)|0,p=p+Math.imul(O,Se)|0,h=h+Math.imul(Z,Me)|0,o=o+Math.imul(Z,Te)|0,o=o+Math.imul(_,Me)|0,p=p+Math.imul(_,Te)|0,h=h+Math.imul(T,Ee)|0,o=o+Math.imul(T,_e)|0,o=o+Math.imul(k,Ee)|0,p=p+Math.imul(k,_e)|0,h=h+Math.imul(b,Be)|0,o=o+Math.imul(b,Ce)|0,o=o+Math.imul(w,Be)|0,p=p+Math.imul(w,Ce)|0;var Et=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(Et>>>26)|0,Et&=67108863,h=Math.imul(oe,pe),o=Math.imul(oe,be),o=o+Math.imul(fe,pe)|0,p=Math.imul(fe,be),h=h+Math.imul(se,de)|0,o=o+Math.imul(se,ue)|0,o=o+Math.imul(le,de)|0,p=p+Math.imul(le,ue)|0,h=h+Math.imul(j,xe)|0,o=o+Math.imul(j,me)|0,o=o+Math.imul(re,xe)|0,p=p+Math.imul(re,me)|0,h=h+Math.imul(N,ye)|0,o=o+Math.imul(N,we)|0,o=o+Math.imul(U,ye)|0,p=p+Math.imul(U,we)|0,h=h+Math.imul(I,Ae)|0,o=o+Math.imul(I,Se)|0,o=o+Math.imul(J,Ae)|0,p=p+Math.imul(J,Se)|0,h=h+Math.imul(L,Me)|0,o=o+Math.imul(L,Te)|0,o=o+Math.imul(O,Me)|0,p=p+Math.imul(O,Te)|0,h=h+Math.imul(Z,Ee)|0,o=o+Math.imul(Z,_e)|0,o=o+Math.imul(_,Ee)|0,p=p+Math.imul(_,_e)|0,h=h+Math.imul(T,Be)|0,o=o+Math.imul(T,Ce)|0,o=o+Math.imul(k,Be)|0,p=p+Math.imul(k,Ce)|0,h=h+Math.imul(b,Pe)|0,o=o+Math.imul(b,Le)|0,o=o+Math.imul(w,Pe)|0,p=p+Math.imul(w,Le)|0;var ur=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(ur>>>26)|0,ur&=67108863,h=Math.imul(ge,pe),o=Math.imul(ge,be),o=o+Math.imul(ve,pe)|0,p=Math.imul(ve,be),h=h+Math.imul(oe,de)|0,o=o+Math.imul(oe,ue)|0,o=o+Math.imul(fe,de)|0,p=p+Math.imul(fe,ue)|0,h=h+Math.imul(se,xe)|0,o=o+Math.imul(se,me)|0,o=o+Math.imul(le,xe)|0,p=p+Math.imul(le,me)|0,h=h+Math.imul(j,ye)|0,o=o+Math.imul(j,we)|0,o=o+Math.imul(re,ye)|0,p=p+Math.imul(re,we)|0,h=h+Math.imul(N,Ae)|0,o=o+Math.imul(N,Se)|0,o=o+Math.imul(U,Ae)|0,p=p+Math.imul(U,Se)|0,h=h+Math.imul(I,Me)|0,o=o+Math.imul(I,Te)|0,o=o+Math.imul(J,Me)|0,p=p+Math.imul(J,Te)|0,h=h+Math.imul(L,Ee)|0,o=o+Math.imul(L,_e)|0,o=o+Math.imul(O,Ee)|0,p=p+Math.imul(O,_e)|0,h=h+Math.imul(Z,Be)|0,o=o+Math.imul(Z,Ce)|0,o=o+Math.imul(_,Be)|0,p=p+Math.imul(_,Ce)|0,h=h+Math.imul(T,Pe)|0,o=o+Math.imul(T,Le)|0,o=o+Math.imul(k,Pe)|0,p=p+Math.imul(k,Le)|0,h=h+Math.imul(b,Re)|0,o=o+Math.imul(b,Fe)|0,o=o+Math.imul(w,Re)|0,p=p+Math.imul(w,Fe)|0;var lr=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(lr>>>26)|0,lr&=67108863,h=Math.imul(ge,de),o=Math.imul(ge,ue),o=o+Math.imul(ve,de)|0,p=Math.imul(ve,ue),h=h+Math.imul(oe,xe)|0,o=o+Math.imul(oe,me)|0,o=o+Math.imul(fe,xe)|0,p=p+Math.imul(fe,me)|0,h=h+Math.imul(se,ye)|0,o=o+Math.imul(se,we)|0,o=o+Math.imul(le,ye)|0,p=p+Math.imul(le,we)|0,h=h+Math.imul(j,Ae)|0,o=o+Math.imul(j,Se)|0,o=o+Math.imul(re,Ae)|0,p=p+Math.imul(re,Se)|0,h=h+Math.imul(N,Me)|0,o=o+Math.imul(N,Te)|0,o=o+Math.imul(U,Me)|0,p=p+Math.imul(U,Te)|0,h=h+Math.imul(I,Ee)|0,o=o+Math.imul(I,_e)|0,o=o+Math.imul(J,Ee)|0,p=p+Math.imul(J,_e)|0,h=h+Math.imul(L,Be)|0,o=o+Math.imul(L,Ce)|0,o=o+Math.imul(O,Be)|0,p=p+Math.imul(O,Ce)|0,h=h+Math.imul(Z,Pe)|0,o=o+Math.imul(Z,Le)|0,o=o+Math.imul(_,Pe)|0,p=p+Math.imul(_,Le)|0,h=h+Math.imul(T,Re)|0,o=o+Math.imul(T,Fe)|0,o=o+Math.imul(k,Re)|0,p=p+Math.imul(k,Fe)|0;var dr=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(dr>>>26)|0,dr&=67108863,h=Math.imul(ge,xe),o=Math.imul(ge,me),o=o+Math.imul(ve,xe)|0,p=Math.imul(ve,me),h=h+Math.imul(oe,ye)|0,o=o+Math.imul(oe,we)|0,o=o+Math.imul(fe,ye)|0,p=p+Math.imul(fe,we)|0,h=h+Math.imul(se,Ae)|0,o=o+Math.imul(se,Se)|0,o=o+Math.imul(le,Ae)|0,p=p+Math.imul(le,Se)|0,h=h+Math.imul(j,Me)|0,o=o+Math.imul(j,Te)|0,o=o+Math.imul(re,Me)|0,p=p+Math.imul(re,Te)|0,h=h+Math.imul(N,Ee)|0,o=o+Math.imul(N,_e)|0,o=o+Math.imul(U,Ee)|0,p=p+Math.imul(U,_e)|0,h=h+Math.imul(I,Be)|0,o=o+Math.imul(I,Ce)|0,o=o+Math.imul(J,Be)|0,p=p+Math.imul(J,Ce)|0,h=h+Math.imul(L,Pe)|0,o=o+Math.imul(L,Le)|0,o=o+Math.imul(O,Pe)|0,p=p+Math.imul(O,Le)|0,h=h+Math.imul(Z,Re)|0,o=o+Math.imul(Z,Fe)|0,o=o+Math.imul(_,Re)|0,p=p+Math.imul(_,Fe)|0;var hr=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(hr>>>26)|0,hr&=67108863,h=Math.imul(ge,ye),o=Math.imul(ge,we),o=o+Math.imul(ve,ye)|0,p=Math.imul(ve,we),h=h+Math.imul(oe,Ae)|0,o=o+Math.imul(oe,Se)|0,o=o+Math.imul(fe,Ae)|0,p=p+Math.imul(fe,Se)|0,h=h+Math.imul(se,Me)|0,o=o+Math.imul(se,Te)|0,o=o+Math.imul(le,Me)|0,p=p+Math.imul(le,Te)|0,h=h+Math.imul(j,Ee)|0,o=o+Math.imul(j,_e)|0,o=o+Math.imul(re,Ee)|0,p=p+Math.imul(re,_e)|0,h=h+Math.imul(N,Be)|0,o=o+Math.imul(N,Ce)|0,o=o+Math.imul(U,Be)|0,p=p+Math.imul(U,Ce)|0,h=h+Math.imul(I,Pe)|0,o=o+Math.imul(I,Le)|0,o=o+Math.imul(J,Pe)|0,p=p+Math.imul(J,Le)|0,h=h+Math.imul(L,Re)|0,o=o+Math.imul(L,Fe)|0,o=o+Math.imul(O,Re)|0,p=p+Math.imul(O,Fe)|0;var pr=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(pr>>>26)|0,pr&=67108863,h=Math.imul(ge,Ae),o=Math.imul(ge,Se),o=o+Math.imul(ve,Ae)|0,p=Math.imul(ve,Se),h=h+Math.imul(oe,Me)|0,o=o+Math.imul(oe,Te)|0,o=o+Math.imul(fe,Me)|0,p=p+Math.imul(fe,Te)|0,h=h+Math.imul(se,Ee)|0,o=o+Math.imul(se,_e)|0,o=o+Math.imul(le,Ee)|0,p=p+Math.imul(le,_e)|0,h=h+Math.imul(j,Be)|0,o=o+Math.imul(j,Ce)|0,o=o+Math.imul(re,Be)|0,p=p+Math.imul(re,Ce)|0,h=h+Math.imul(N,Pe)|0,o=o+Math.imul(N,Le)|0,o=o+Math.imul(U,Pe)|0,p=p+Math.imul(U,Le)|0,h=h+Math.imul(I,Re)|0,o=o+Math.imul(I,Fe)|0,o=o+Math.imul(J,Re)|0,p=p+Math.imul(J,Fe)|0;var br=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(br>>>26)|0,br&=67108863,h=Math.imul(ge,Me),o=Math.imul(ge,Te),o=o+Math.imul(ve,Me)|0,p=Math.imul(ve,Te),h=h+Math.imul(oe,Ee)|0,o=o+Math.imul(oe,_e)|0,o=o+Math.imul(fe,Ee)|0,p=p+Math.imul(fe,_e)|0,h=h+Math.imul(se,Be)|0,o=o+Math.imul(se,Ce)|0,o=o+Math.imul(le,Be)|0,p=p+Math.imul(le,Ce)|0,h=h+Math.imul(j,Pe)|0,o=o+Math.imul(j,Le)|0,o=o+Math.imul(re,Pe)|0,p=p+Math.imul(re,Le)|0,h=h+Math.imul(N,Re)|0,o=o+Math.imul(N,Fe)|0,o=o+Math.imul(U,Re)|0,p=p+Math.imul(U,Fe)|0;var gr=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(gr>>>26)|0,gr&=67108863,h=Math.imul(ge,Ee),o=Math.imul(ge,_e),o=o+Math.imul(ve,Ee)|0,p=Math.imul(ve,_e),h=h+Math.imul(oe,Be)|0,o=o+Math.imul(oe,Ce)|0,o=o+Math.imul(fe,Be)|0,p=p+Math.imul(fe,Ce)|0,h=h+Math.imul(se,Pe)|0,o=o+Math.imul(se,Le)|0,o=o+Math.imul(le,Pe)|0,p=p+Math.imul(le,Le)|0,h=h+Math.imul(j,Re)|0,o=o+Math.imul(j,Fe)|0,o=o+Math.imul(re,Re)|0,p=p+Math.imul(re,Fe)|0;var vr=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(vr>>>26)|0,vr&=67108863,h=Math.imul(ge,Be),o=Math.imul(ge,Ce),o=o+Math.imul(ve,Be)|0,p=Math.imul(ve,Ce),h=h+Math.imul(oe,Pe)|0,o=o+Math.imul(oe,Le)|0,o=o+Math.imul(fe,Pe)|0,p=p+Math.imul(fe,Le)|0,h=h+Math.imul(se,Re)|0,o=o+Math.imul(se,Fe)|0,o=o+Math.imul(le,Re)|0,p=p+Math.imul(le,Fe)|0;var xr=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(xr>>>26)|0,xr&=67108863,h=Math.imul(ge,Pe),o=Math.imul(ge,Le),o=o+Math.imul(ve,Pe)|0,p=Math.imul(ve,Le),h=h+Math.imul(oe,Re)|0,o=o+Math.imul(oe,Fe)|0,o=o+Math.imul(fe,Re)|0,p=p+Math.imul(fe,Fe)|0;var un=(x+h|0)+((o&8191)<<13)|0;x=(p+(o>>>13)|0)+(un>>>26)|0,un&=67108863,h=Math.imul(ge,Re),o=Math.imul(ge,Fe),o=o+Math.imul(ve,Re)|0,p=Math.imul(ve,Fe);var ln=(x+h|0)+((o&8191)<<13)|0;return x=(p+(o>>>13)|0)+(ln>>>26)|0,ln&=67108863,g[0]=Rt,g[1]=ke,g[2]=Ne,g[3]=At,g[4]=St,g[5]=Mt,g[6]=Tt,g[7]=Et,g[8]=ur,g[9]=lr,g[10]=dr,g[11]=hr,g[12]=pr,g[13]=br,g[14]=gr,g[15]=vr,g[16]=xr,g[17]=un,g[18]=ln,x!==0&&(g[19]=x,l.length++),l};Math.imul||(C=F);function q(S,s,u){u.negative=s.negative^S.negative,u.length=S.length+s.length;for(var l=0,f=0,c=0;c<u.length-1;c++){var g=f;f=0;for(var x=l&67108863,h=Math.min(c,s.length-1),o=Math.max(0,c-S.length+1);o<=h;o++){var p=c-o,E=S.words[p]|0,b=s.words[o]|0,w=E*b,H=w&67108863;g=g+(w/67108864|0)|0,H=H+x|0,x=H&67108863,g=g+(H>>>26)|0,f+=g>>>26,g&=67108863}u.words[c]=x,l=g,g=f}return l!==0?u.words[c]=l:u.length--,u.strip()}function W(S,s,u){var l=new K;return l.mulp(S,s,u)}i.prototype.mulTo=function(s,u){var l,f=this.length+s.length;return this.length===10&&s.length===10?l=C(this,s,u):f<63?l=F(this,s,u):f<1024?l=q(this,s,u):l=W(this,s,u),l};function K(S,s){this.x=S,this.y=s}K.prototype.makeRBT=function(s){for(var u=new Array(s),l=i.prototype._countBits(s)-1,f=0;f<s;f++)u[f]=this.revBin(f,l,s);return u},K.prototype.revBin=function(s,u,l){if(s===0||s===l-1)return s;for(var f=0,c=0;c<u;c++)f|=(s&1)<<u-c-1,s>>=1;return f},K.prototype.permute=function(s,u,l,f,c,g){for(var x=0;x<g;x++)f[x]=u[s[x]],c[x]=l[s[x]]},K.prototype.transform=function(s,u,l,f,c,g){this.permute(g,s,u,l,f,c);for(var x=1;x<c;x<<=1)for(var h=x<<1,o=Math.cos(2*Math.PI/h),p=Math.sin(2*Math.PI/h),E=0;E<c;E+=h)for(var b=o,w=p,H=0;H<x;H++){var T=l[E+H],k=f[E+H],X=l[E+H+x],Z=f[E+H+x],_=b*X-w*Z;Z=b*Z+w*X,X=_,l[E+H]=T+X,f[E+H]=k+Z,l[E+H+x]=T-X,f[E+H+x]=k-Z,H!==h&&(_=o*b-p*w,w=o*w+p*b,b=_)}},K.prototype.guessLen13b=function(s,u){var l=Math.max(u,s)|1,f=l&1,c=0;for(l=l/2|0;l;l=l>>>1)c++;return 1<<c+1+f},K.prototype.conjugate=function(s,u,l){if(!(l<=1))for(var f=0;f<l/2;f++){var c=s[f];s[f]=s[l-f-1],s[l-f-1]=c,c=u[f],u[f]=-u[l-f-1],u[l-f-1]=-c}},K.prototype.normalize13b=function(s,u){for(var l=0,f=0;f<u/2;f++){var c=Math.round(s[2*f+1]/u)*8192+Math.round(s[2*f]/u)+l;s[f]=c&67108863,c<67108864?l=0:l=c/67108864|0}return s},K.prototype.convert13b=function(s,u,l,f){for(var c=0,g=0;g<u;g++)c=c+(s[g]|0),l[2*g]=c&8191,c=c>>>13,l[2*g+1]=c&8191,c=c>>>13;for(g=2*u;g<f;++g)l[g]=0;r(c===0),r((c&-8192)===0)},K.prototype.stub=function(s){for(var u=new Array(s),l=0;l<s;l++)u[l]=0;return u},K.prototype.mulp=function(s,u,l){var f=2*this.guessLen13b(s.length,u.length),c=this.makeRBT(f),g=this.stub(f),x=new Array(f),h=new Array(f),o=new Array(f),p=new Array(f),E=new Array(f),b=new Array(f),w=l.words;w.length=f,this.convert13b(s.words,s.length,x,f),this.convert13b(u.words,u.length,p,f),this.transform(x,g,h,o,f,c),this.transform(p,g,E,b,f,c);for(var H=0;H<f;H++){var T=h[H]*E[H]-o[H]*b[H];o[H]=h[H]*b[H]+o[H]*E[H],h[H]=T}return this.conjugate(h,o,f),this.transform(h,o,w,g,f,c),this.conjugate(w,g,f),this.normalize13b(w,f),l.negative=s.negative^u.negative,l.length=s.length+u.length,l.strip()},i.prototype.mul=function(s){var u=new i(null);return u.words=new Array(this.length+s.length),this.mulTo(s,u)},i.prototype.mulf=function(s){var u=new i(null);return u.words=new Array(this.length+s.length),W(this,s,u)},i.prototype.imul=function(s){return this.clone().mulTo(s,this)},i.prototype.imuln=function(s){r(typeof s=="number"),r(s<67108864);for(var u=0,l=0;l<this.length;l++){var f=(this.words[l]|0)*s,c=(f&67108863)+(u&67108863);u>>=26,u+=f/67108864|0,u+=c>>>26,this.words[l]=c&67108863}return u!==0&&(this.words[l]=u,this.length++),this.length=s===0?1:this.length,this},i.prototype.muln=function(s){return this.clone().imuln(s)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(s){var u=D(s);if(u.length===0)return new i(1);for(var l=this,f=0;f<u.length&&u[f]===0;f++,l=l.sqr());if(++f<u.length)for(var c=l.sqr();f<u.length;f++,c=c.sqr())u[f]!==0&&(l=l.mul(c));return l},i.prototype.iushln=function(s){r(typeof s=="number"&&s>=0);var u=s%26,l=(s-u)/26,f=67108863>>>26-u<<26-u,c;if(u!==0){var g=0;for(c=0;c<this.length;c++){var x=this.words[c]&f,h=(this.words[c]|0)-x<<u;this.words[c]=h|g,g=x>>>26-u}g&&(this.words[c]=g,this.length++)}if(l!==0){for(c=this.length-1;c>=0;c--)this.words[c+l]=this.words[c];for(c=0;c<l;c++)this.words[c]=0;this.length+=l}return this.strip()},i.prototype.ishln=function(s){return r(this.negative===0),this.iushln(s)},i.prototype.iushrn=function(s,u,l){r(typeof s=="number"&&s>=0);var f;u?f=(u-u%26)/26:f=0;var c=s%26,g=Math.min((s-c)/26,this.length),x=67108863^67108863>>>c<<c,h=l;if(f-=g,f=Math.max(0,f),h){for(var o=0;o<g;o++)h.words[o]=this.words[o];h.length=g}if(g!==0)if(this.length>g)for(this.length-=g,o=0;o<this.length;o++)this.words[o]=this.words[o+g];else this.words[0]=0,this.length=1;var p=0;for(o=this.length-1;o>=0&&(p!==0||o>=f);o--){var E=this.words[o]|0;this.words[o]=p<<26-c|E>>>c,p=E&x}return h&&p!==0&&(h.words[h.length++]=p),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(s,u,l){return r(this.negative===0),this.iushrn(s,u,l)},i.prototype.shln=function(s){return this.clone().ishln(s)},i.prototype.ushln=function(s){return this.clone().iushln(s)},i.prototype.shrn=function(s){return this.clone().ishrn(s)},i.prototype.ushrn=function(s){return this.clone().iushrn(s)},i.prototype.testn=function(s){r(typeof s=="number"&&s>=0);var u=s%26,l=(s-u)/26,f=1<<u;if(this.length<=l)return!1;var c=this.words[l];return!!(c&f)},i.prototype.imaskn=function(s){r(typeof s=="number"&&s>=0);var u=s%26,l=(s-u)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=l)return this;if(u!==0&&l++,this.length=Math.min(l,this.length),u!==0){var f=67108863^67108863>>>u<<u;this.words[this.length-1]&=f}return this.strip()},i.prototype.maskn=function(s){return this.clone().imaskn(s)},i.prototype.iaddn=function(s){return r(typeof s=="number"),r(s<67108864),s<0?this.isubn(-s):this.negative!==0?this.length===1&&(this.words[0]|0)<s?(this.words[0]=s-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(s),this.negative=1,this):this._iaddn(s)},i.prototype._iaddn=function(s){this.words[0]+=s;for(var u=0;u<this.length&&this.words[u]>=67108864;u++)this.words[u]-=67108864,u===this.length-1?this.words[u+1]=1:this.words[u+1]++;return this.length=Math.max(this.length,u+1),this},i.prototype.isubn=function(s){if(r(typeof s=="number"),r(s<67108864),s<0)return this.iaddn(-s);if(this.negative!==0)return this.negative=0,this.iaddn(s),this.negative=1,this;if(this.words[0]-=s,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var u=0;u<this.length&&this.words[u]<0;u++)this.words[u]+=67108864,this.words[u+1]-=1;return this.strip()},i.prototype.addn=function(s){return this.clone().iaddn(s)},i.prototype.subn=function(s){return this.clone().isubn(s)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(s,u,l){var f=s.length+l,c;this._expand(f);var g,x=0;for(c=0;c<s.length;c++){g=(this.words[c+l]|0)+x;var h=(s.words[c]|0)*u;g-=h&67108863,x=(g>>26)-(h/67108864|0),this.words[c+l]=g&67108863}for(;c<this.length-l;c++)g=(this.words[c+l]|0)+x,x=g>>26,this.words[c+l]=g&67108863;if(x===0)return this.strip();for(r(x===-1),x=0,c=0;c<this.length;c++)g=-(this.words[c]|0)+x,x=g>>26,this.words[c]=g&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(s,u){var l=this.length-s.length,f=this.clone(),c=s,g=c.words[c.length-1]|0,x=this._countBits(g);l=26-x,l!==0&&(c=c.ushln(l),f.iushln(l),g=c.words[c.length-1]|0);var h=f.length-c.length,o;if(u!=="mod"){o=new i(null),o.length=h+1,o.words=new Array(o.length);for(var p=0;p<o.length;p++)o.words[p]=0}var E=f.clone()._ishlnsubmul(c,1,h);E.negative===0&&(f=E,o&&(o.words[h]=1));for(var b=h-1;b>=0;b--){var w=(f.words[c.length+b]|0)*67108864+(f.words[c.length+b-1]|0);for(w=Math.min(w/g|0,67108863),f._ishlnsubmul(c,w,b);f.negative!==0;)w--,f.negative=0,f._ishlnsubmul(c,1,b),f.isZero()||(f.negative^=1);o&&(o.words[b]=w)}return o&&o.strip(),f.strip(),u!=="div"&&l!==0&&f.iushrn(l),{div:o||null,mod:f}},i.prototype.divmod=function(s,u,l){if(r(!s.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var f,c,g;return this.negative!==0&&s.negative===0?(g=this.neg().divmod(s,u),u!=="mod"&&(f=g.div.neg()),u!=="div"&&(c=g.mod.neg(),l&&c.negative!==0&&c.iadd(s)),{div:f,mod:c}):this.negative===0&&s.negative!==0?(g=this.divmod(s.neg(),u),u!=="mod"&&(f=g.div.neg()),{div:f,mod:g.mod}):this.negative&s.negative?(g=this.neg().divmod(s.neg(),u),u!=="div"&&(c=g.mod.neg(),l&&c.negative!==0&&c.isub(s)),{div:g.div,mod:c}):s.length>this.length||this.cmp(s)<0?{div:new i(0),mod:this}:s.length===1?u==="div"?{div:this.divn(s.words[0]),mod:null}:u==="mod"?{div:null,mod:new i(this.modn(s.words[0]))}:{div:this.divn(s.words[0]),mod:new i(this.modn(s.words[0]))}:this._wordDiv(s,u)},i.prototype.div=function(s){return this.divmod(s,"div",!1).div},i.prototype.mod=function(s){return this.divmod(s,"mod",!1).mod},i.prototype.umod=function(s){return this.divmod(s,"mod",!0).mod},i.prototype.divRound=function(s){var u=this.divmod(s);if(u.mod.isZero())return u.div;var l=u.div.negative!==0?u.mod.isub(s):u.mod,f=s.ushrn(1),c=s.andln(1),g=l.cmp(f);return g<0||c===1&&g===0?u.div:u.div.negative!==0?u.div.isubn(1):u.div.iaddn(1)},i.prototype.modn=function(s){r(s<=67108863);for(var u=(1<<26)%s,l=0,f=this.length-1;f>=0;f--)l=(u*l+(this.words[f]|0))%s;return l},i.prototype.idivn=function(s){r(s<=67108863);for(var u=0,l=this.length-1;l>=0;l--){var f=(this.words[l]|0)+u*67108864;this.words[l]=f/s|0,u=f%s}return this.strip()},i.prototype.divn=function(s){return this.clone().idivn(s)},i.prototype.egcd=function(s){r(s.negative===0),r(!s.isZero());var u=this,l=s.clone();u.negative!==0?u=u.umod(s):u=u.clone();for(var f=new i(1),c=new i(0),g=new i(0),x=new i(1),h=0;u.isEven()&&l.isEven();)u.iushrn(1),l.iushrn(1),++h;for(var o=l.clone(),p=u.clone();!u.isZero();){for(var E=0,b=1;!(u.words[0]&b)&&E<26;++E,b<<=1);if(E>0)for(u.iushrn(E);E-- >0;)(f.isOdd()||c.isOdd())&&(f.iadd(o),c.isub(p)),f.iushrn(1),c.iushrn(1);for(var w=0,H=1;!(l.words[0]&H)&&w<26;++w,H<<=1);if(w>0)for(l.iushrn(w);w-- >0;)(g.isOdd()||x.isOdd())&&(g.iadd(o),x.isub(p)),g.iushrn(1),x.iushrn(1);u.cmp(l)>=0?(u.isub(l),f.isub(g),c.isub(x)):(l.isub(u),g.isub(f),x.isub(c))}return{a:g,b:x,gcd:l.iushln(h)}},i.prototype._invmp=function(s){r(s.negative===0),r(!s.isZero());var u=this,l=s.clone();u.negative!==0?u=u.umod(s):u=u.clone();for(var f=new i(1),c=new i(0),g=l.clone();u.cmpn(1)>0&&l.cmpn(1)>0;){for(var x=0,h=1;!(u.words[0]&h)&&x<26;++x,h<<=1);if(x>0)for(u.iushrn(x);x-- >0;)f.isOdd()&&f.iadd(g),f.iushrn(1);for(var o=0,p=1;!(l.words[0]&p)&&o<26;++o,p<<=1);if(o>0)for(l.iushrn(o);o-- >0;)c.isOdd()&&c.iadd(g),c.iushrn(1);u.cmp(l)>=0?(u.isub(l),f.isub(c)):(l.isub(u),c.isub(f))}var E;return u.cmpn(1)===0?E=f:E=c,E.cmpn(0)<0&&E.iadd(s),E},i.prototype.gcd=function(s){if(this.isZero())return s.abs();if(s.isZero())return this.abs();var u=this.clone(),l=s.clone();u.negative=0,l.negative=0;for(var f=0;u.isEven()&&l.isEven();f++)u.iushrn(1),l.iushrn(1);do{for(;u.isEven();)u.iushrn(1);for(;l.isEven();)l.iushrn(1);var c=u.cmp(l);if(c<0){var g=u;u=l,l=g}else if(c===0||l.cmpn(1)===0)break;u.isub(l)}while(!0);return l.iushln(f)},i.prototype.invm=function(s){return this.egcd(s).a.umod(s)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(s){return this.words[0]&s},i.prototype.bincn=function(s){r(typeof s=="number");var u=s%26,l=(s-u)/26,f=1<<u;if(this.length<=l)return this._expand(l+1),this.words[l]|=f,this;for(var c=f,g=l;c!==0&&g<this.length;g++){var x=this.words[g]|0;x+=c,c=x>>>26,x&=67108863,this.words[g]=x}return c!==0&&(this.words[g]=c,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(s){var u=s<0;if(this.negative!==0&&!u)return-1;if(this.negative===0&&u)return 1;this.strip();var l;if(this.length>1)l=1;else{u&&(s=-s),r(s<=67108863,"Number is too big");var f=this.words[0]|0;l=f===s?0:f<s?-1:1}return this.negative!==0?-l|0:l},i.prototype.cmp=function(s){if(this.negative!==0&&s.negative===0)return-1;if(this.negative===0&&s.negative!==0)return 1;var u=this.ucmp(s);return this.negative!==0?-u|0:u},i.prototype.ucmp=function(s){if(this.length>s.length)return 1;if(this.length<s.length)return-1;for(var u=0,l=this.length-1;l>=0;l--){var f=this.words[l]|0,c=s.words[l]|0;if(f!==c){f<c?u=-1:f>c&&(u=1);break}}return u},i.prototype.gtn=function(s){return this.cmpn(s)===1},i.prototype.gt=function(s){return this.cmp(s)===1},i.prototype.gten=function(s){return this.cmpn(s)>=0},i.prototype.gte=function(s){return this.cmp(s)>=0},i.prototype.ltn=function(s){return this.cmpn(s)===-1},i.prototype.lt=function(s){return this.cmp(s)===-1},i.prototype.lten=function(s){return this.cmpn(s)<=0},i.prototype.lte=function(s){return this.cmp(s)<=0},i.prototype.eqn=function(s){return this.cmpn(s)===0},i.prototype.eq=function(s){return this.cmp(s)===0},i.red=function(s){return new te(s)},i.prototype.toRed=function(s){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),s.convertTo(this)._forceRed(s)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(s){return this.red=s,this},i.prototype.forceRed=function(s){return r(!this.red,"Already a number in reduction context"),this._forceRed(s)},i.prototype.redAdd=function(s){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,s)},i.prototype.redIAdd=function(s){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,s)},i.prototype.redSub=function(s){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,s)},i.prototype.redISub=function(s){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,s)},i.prototype.redShl=function(s){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,s)},i.prototype.redMul=function(s){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,s),this.red.mul(this,s)},i.prototype.redIMul=function(s){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,s),this.red.imul(this,s)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(s){return r(this.red&&!s.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,s)};var ne={k256:null,p224:null,p192:null,p25519:null};function $(S,s){this.name=S,this.p=new i(s,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}$.prototype._tmp=function(){var s=new i(null);return s.words=new Array(Math.ceil(this.n/13)),s},$.prototype.ireduce=function(s){var u=s,l;do this.split(u,this.tmp),u=this.imulK(u),u=u.iadd(this.tmp),l=u.bitLength();while(l>this.n);var f=l<this.n?-1:u.ucmp(this.p);return f===0?(u.words[0]=0,u.length=1):f>0?u.isub(this.p):u.strip!==void 0?u.strip():u._strip(),u},$.prototype.split=function(s,u){s.iushrn(this.n,0,u)},$.prototype.imulK=function(s){return s.imul(this.k)};function ae(){$.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(ae,$),ae.prototype.split=function(s,u){for(var l=4194303,f=Math.min(s.length,9),c=0;c<f;c++)u.words[c]=s.words[c];if(u.length=f,s.length<=9){s.words[0]=0,s.length=1;return}var g=s.words[9];for(u.words[u.length++]=g&l,c=10;c<s.length;c++){var x=s.words[c]|0;s.words[c-10]=(x&l)<<4|g>>>22,g=x}g>>>=22,s.words[c-10]=g,g===0&&s.length>10?s.length-=10:s.length-=9},ae.prototype.imulK=function(s){s.words[s.length]=0,s.words[s.length+1]=0,s.length+=2;for(var u=0,l=0;l<s.length;l++){var f=s.words[l]|0;u+=f*977,s.words[l]=u&67108863,u=f*64+(u/67108864|0)}return s.words[s.length-1]===0&&(s.length--,s.words[s.length-1]===0&&s.length--),s};function ie(){$.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(ie,$);function ee(){$.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(ee,$);function ce(){$.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(ce,$),ce.prototype.imulK=function(s){for(var u=0,l=0;l<s.length;l++){var f=(s.words[l]|0)*19+u,c=f&67108863;f>>>=26,s.words[l]=c,u=f}return u!==0&&(s.words[s.length++]=u),s},i._prime=function(s){if(ne[s])return ne[s];var u;if(s==="k256")u=new ae;else if(s==="p224")u=new ie;else if(s==="p192")u=new ee;else if(s==="p25519")u=new ce;else throw new Error("Unknown prime "+s);return ne[s]=u,u};function te(S){if(typeof S=="string"){var s=i._prime(S);this.m=s.p,this.prime=s}else r(S.gtn(1),"modulus must be greater than 1"),this.m=S,this.prime=null}te.prototype._verify1=function(s){r(s.negative===0,"red works only with positives"),r(s.red,"red works only with red numbers")},te.prototype._verify2=function(s,u){r((s.negative|u.negative)===0,"red works only with positives"),r(s.red&&s.red===u.red,"red works only with red numbers")},te.prototype.imod=function(s){return this.prime?this.prime.ireduce(s)._forceRed(this):s.umod(this.m)._forceRed(this)},te.prototype.neg=function(s){return s.isZero()?s.clone():this.m.sub(s)._forceRed(this)},te.prototype.add=function(s,u){this._verify2(s,u);var l=s.add(u);return l.cmp(this.m)>=0&&l.isub(this.m),l._forceRed(this)},te.prototype.iadd=function(s,u){this._verify2(s,u);var l=s.iadd(u);return l.cmp(this.m)>=0&&l.isub(this.m),l},te.prototype.sub=function(s,u){this._verify2(s,u);var l=s.sub(u);return l.cmpn(0)<0&&l.iadd(this.m),l._forceRed(this)},te.prototype.isub=function(s,u){this._verify2(s,u);var l=s.isub(u);return l.cmpn(0)<0&&l.iadd(this.m),l},te.prototype.shl=function(s,u){return this._verify1(s),this.imod(s.ushln(u))},te.prototype.imul=function(s,u){return this._verify2(s,u),this.imod(s.imul(u))},te.prototype.mul=function(s,u){return this._verify2(s,u),this.imod(s.mul(u))},te.prototype.isqr=function(s){return this.imul(s,s.clone())},te.prototype.sqr=function(s){return this.mul(s,s)},te.prototype.sqrt=function(s){if(s.isZero())return s.clone();var u=this.m.andln(3);if(r(u%2===1),u===3){var l=this.m.add(new i(1)).iushrn(2);return this.pow(s,l)}for(var f=this.m.subn(1),c=0;!f.isZero()&&f.andln(1)===0;)c++,f.iushrn(1);r(!f.isZero());var g=new i(1).toRed(this),x=g.redNeg(),h=this.m.subn(1).iushrn(1),o=this.m.bitLength();for(o=new i(2*o*o).toRed(this);this.pow(o,h).cmp(x)!==0;)o.redIAdd(x);for(var p=this.pow(o,f),E=this.pow(s,f.addn(1).iushrn(1)),b=this.pow(s,f),w=c;b.cmp(g)!==0;){for(var H=b,T=0;H.cmp(g)!==0;T++)H=H.redSqr();r(T<w);var k=this.pow(p,new i(1).iushln(w-T-1));E=E.redMul(k),p=k.redSqr(),b=b.redMul(p),w=T}return E},te.prototype.invm=function(s){var u=s._invmp(this.m);return u.negative!==0?(u.negative=0,this.imod(u).redNeg()):this.imod(u)},te.prototype.pow=function(s,u){if(u.isZero())return new i(1).toRed(this);if(u.cmpn(1)===0)return s.clone();var l=4,f=new Array(1<<l);f[0]=new i(1).toRed(this),f[1]=s;for(var c=2;c<f.length;c++)f[c]=this.mul(f[c-1],s);var g=f[0],x=0,h=0,o=u.bitLength()%26;for(o===0&&(o=26),c=u.length-1;c>=0;c--){for(var p=u.words[c],E=o-1;E>=0;E--){var b=p>>E&1;if(g!==f[0]&&(g=this.sqr(g)),b===0&&x===0){h=0;continue}x<<=1,x|=b,h++,!(h!==l&&(c!==0||E!==0))&&(g=this.mul(g,f[x]),h=0,x=0)}o=26}return g},te.prototype.convertTo=function(s){var u=s.umod(this.m);return u===s?u.clone():u},te.prototype.convertFrom=function(s){var u=s.clone();return u.red=null,u},i.mont=function(s){return new Y(s)};function Y(S){te.call(this,S),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(Y,te),Y.prototype.convertTo=function(s){return this.imod(s.ushln(this.shift))},Y.prototype.convertFrom=function(s){var u=this.imod(s.mul(this.rinv));return u.red=null,u},Y.prototype.imul=function(s,u){if(s.isZero()||u.isZero())return s.words[0]=0,s.length=1,s;var l=s.imul(u),f=l.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),c=l.isub(f).iushrn(this.shift),g=c;return c.cmp(this.m)>=0?g=c.isub(this.m):c.cmpn(0)<0&&(g=c.iadd(this.m)),g._forceRed(this)},Y.prototype.mul=function(s,u){if(s.isZero()||u.isZero())return new i(0)._forceRed(this);var l=s.mul(u),f=l.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),c=l.isub(f).iushrn(this.shift),g=c;return c.cmp(this.m)>=0?g=c.isub(this.m):c.cmpn(0)<0&&(g=c.iadd(this.m)),g._forceRed(this)},Y.prototype.invm=function(s){var u=this.imod(s._invmp(this.m).mul(this.r2));return u._forceRed(this)}})(typeof sl>"u"||sl,_p)});var Bp=V((HB,cl)=>{var qB=A(M());typeof Object.create=="function"?cl.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:cl.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}});var $t=V((GB,ll)=>{var XB=A(M());try{if(ul=require("util"),typeof ul.inherits!="function")throw"";ll.exports=ul.inherits}catch{ll.exports=Bp()}var ul});var jf=V((zB,Cp)=>{"use strict";var KB=A(M()),Vf=require("buffer"),io=Vf.Buffer,Ur={},Hr;for(Hr in Vf)Vf.hasOwnProperty(Hr)&&(Hr==="SlowBuffer"||Hr==="Buffer"||(Ur[Hr]=Vf[Hr]));var ao=Ur.Buffer={};for(Hr in io)io.hasOwnProperty(Hr)&&(Hr==="allocUnsafe"||Hr==="allocUnsafeSlow"||(ao[Hr]=io[Hr]));Ur.Buffer.prototype=io.prototype;(!ao.from||ao.from===Uint8Array.from)&&(ao.from=function(t,e,r){if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&typeof t.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return io(t,e,r)});ao.alloc||(ao.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=io(t);return!e||e.length===0?n.fill(0):typeof r=="string"?n.fill(e,r):n.fill(e),n});if(!Ur.kStringMaxLength)try{Ur.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}Ur.constants||(Ur.constants={MAX_LENGTH:Ur.kMaxLength},Ur.kStringMaxLength&&(Ur.constants.MAX_STRING_LENGTH=Ur.kStringMaxLength));Cp.exports=Ur});var Qf=V(Pp=>{"use strict";var VB=A(M()),M6=$t();function qr(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}Pp.Reporter=qr;qr.prototype.isError=function(e){return e instanceof oo};qr.prototype.save=function(){let e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}};qr.prototype.restore=function(e){let r=this._reporterState;r.obj=e.obj,r.path=r.path.slice(0,e.pathLen)};qr.prototype.enterKey=function(e){return this._reporterState.path.push(e)};qr.prototype.exitKey=function(e){let r=this._reporterState;r.path=r.path.slice(0,e-1)};qr.prototype.leaveKey=function(e,r,n){let i=this._reporterState;this.exitKey(e),i.obj!==null&&(i.obj[r]=n)};qr.prototype.path=function(){return this._reporterState.path.join("/")};qr.prototype.enterObject=function(){let e=this._reporterState,r=e.obj;return e.obj={},r};qr.prototype.leaveObject=function(e){let r=this._reporterState,n=r.obj;return r.obj=e,n};qr.prototype.error=function(e){let r,n=this._reporterState,i=e instanceof oo;if(i?r=e:r=new oo(n.path.map(function(a){return"["+JSON.stringify(a)+"]"}).join(""),e.message||e,e.stack),!n.options.partial)throw r;return i||n.errors.push(r),r};qr.prototype.wrapResult=function(e){let r=this._reporterState;return r.options.partial?{result:this.isError(e)?null:e,errors:r.errors}:e};function oo(t,e){this.path=t,this.rethrow(e)}M6(oo,Error);oo.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,oo),!this.stack)try{throw new Error(this.message)}catch(r){this.stack=r.stack}return this}});var co=V(dl=>{"use strict";var QB=A(M()),T6=$t(),Wf=Qf().Reporter,so=jf().Buffer;function Gr(t,e){if(Wf.call(this,e),!so.isBuffer(t)){this.error("Input not Buffer");return}this.base=t,this.offset=0,this.length=t.length}T6(Gr,Wf);dl.DecoderBuffer=Gr;Gr.isDecoderBuffer=function(e){return e instanceof Gr?!0:typeof e=="object"&&so.isBuffer(e.base)&&e.constructor.name==="DecoderBuffer"&&typeof e.offset=="number"&&typeof e.length=="number"&&typeof e.save=="function"&&typeof e.restore=="function"&&typeof e.isEmpty=="function"&&typeof e.readUInt8=="function"&&typeof e.skip=="function"&&typeof e.raw=="function"};Gr.prototype.save=function(){return{offset:this.offset,reporter:Wf.prototype.save.call(this)}};Gr.prototype.restore=function(e){let r=new Gr(this.base);return r.offset=e.offset,r.length=this.offset,this.offset=e.offset,Wf.prototype.restore.call(this,e.reporter),r};Gr.prototype.isEmpty=function(){return this.offset===this.length};Gr.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")};Gr.prototype.skip=function(e,r){if(!(this.offset+e<=this.length))return this.error(r||"DecoderBuffer overrun");let n=new Gr(this.base);return n._reporterState=this._reporterState,n.offset=this.offset,n.length=this.offset+e,this.offset+=e,n};Gr.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)};function fo(t,e){if(Array.isArray(t))this.length=0,this.value=t.map(function(r){return fo.isEncoderBuffer(r)||(r=new fo(r,e)),this.length+=r.length,r},this);else if(typeof t=="number"){if(!(0<=t&&t<=255))return e.error("non-byte EncoderBuffer value");this.value=t,this.length=1}else if(typeof t=="string")this.value=t,this.length=so.byteLength(t);else if(so.isBuffer(t))this.value=t,this.length=t.length;else return e.error("Unsupported type: "+typeof t)}dl.EncoderBuffer=fo;fo.isEncoderBuffer=function(e){return e instanceof fo?!0:typeof e=="object"&&e.constructor.name==="EncoderBuffer"&&typeof e.length=="number"&&typeof e.join=="function"};fo.prototype.join=function(e,r){return e||(e=so.alloc(this.length)),r||(r=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(n){n.join(e,r),r+=n.length}):(typeof this.value=="number"?e[r]=this.value:typeof this.value=="string"?e.write(this.value,r):so.isBuffer(this.value)&&this.value.copy(e,r),r+=this.length)),e}});var ci=V((WB,Rp)=>{var YB=A(M());Rp.exports=Lp;function Lp(t,e){if(!t)throw new Error(e||"Assertion failed")}Lp.equal=function(e,r,n){if(e!=r)throw new Error(n||"Assertion failed: "+e+" != "+r)}});var Yf=V(($B,Dp)=>{"use strict";var eC=A(M()),E6=Qf().Reporter,_6=co().EncoderBuffer,B6=co().DecoderBuffer,yr=ci(),Fp=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],C6=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(Fp),P6=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function et(t,e,r){let n={};this._baseState=n,n.name=r,n.enc=t,n.parent=e||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}Dp.exports=et;var L6=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];et.prototype.clone=function(){let e=this._baseState,r={};L6.forEach(function(i){r[i]=e[i]});let n=new this.constructor(r.parent);return n._baseState=r,n};et.prototype._wrap=function(){let e=this._baseState;C6.forEach(function(r){this[r]=function(){let i=new this.constructor(this);return e.children.push(i),i[r].apply(i,arguments)}},this)};et.prototype._init=function(e){let r=this._baseState;yr(r.parent===null),e.call(this),r.children=r.children.filter(function(n){return n._baseState.parent===this},this),yr.equal(r.children.length,1,"Root node can have only one child")};et.prototype._useArgs=function(e){let r=this._baseState,n=e.filter(function(i){return i instanceof this.constructor},this);e=e.filter(function(i){return!(i instanceof this.constructor)},this),n.length!==0&&(yr(r.children===null),r.children=n,n.forEach(function(i){i._baseState.parent=this},this)),e.length!==0&&(yr(r.args===null),r.args=e,r.reverseArgs=e.map(function(i){if(typeof i!="object"||i.constructor!==Object)return i;let a={};return Object.keys(i).forEach(function(d){d==(d|0)&&(d|=0);let v=i[d];a[v]=d}),a}))};P6.forEach(function(t){et.prototype[t]=function(){let r=this._baseState;throw new Error(t+" not implemented for encoding: "+r.enc)}});Fp.forEach(function(t){et.prototype[t]=function(){let r=this._baseState,n=Array.prototype.slice.call(arguments);return yr(r.tag===null),r.tag=t,this._useArgs(n),this}});et.prototype.use=function(e){yr(e);let r=this._baseState;return yr(r.use===null),r.use=e,this};et.prototype.optional=function(){let e=this._baseState;return e.optional=!0,this};et.prototype.def=function(e){let r=this._baseState;return yr(r.default===null),r.default=e,r.optional=!0,this};et.prototype.explicit=function(e){let r=this._baseState;return yr(r.explicit===null&&r.implicit===null),r.explicit=e,this};et.prototype.implicit=function(e){let r=this._baseState;return yr(r.explicit===null&&r.implicit===null),r.implicit=e,this};et.prototype.obj=function(){let e=this._baseState,r=Array.prototype.slice.call(arguments);return e.obj=!0,r.length!==0&&this._useArgs(r),this};et.prototype.key=function(e){let r=this._baseState;return yr(r.key===null),r.key=e,this};et.prototype.any=function(){let e=this._baseState;return e.any=!0,this};et.prototype.choice=function(e){let r=this._baseState;return yr(r.choice===null),r.choice=e,this._useArgs(Object.keys(e).map(function(n){return e[n]})),this};et.prototype.contains=function(e){let r=this._baseState;return yr(r.use===null),r.contains=e,this};et.prototype._decode=function(e,r){let n=this._baseState;if(n.parent===null)return e.wrapResult(n.children[0]._decode(e,r));let i=n.default,a=!0,d=null;if(n.key!==null&&(d=e.enterKey(n.key)),n.optional){let y=null;if(n.explicit!==null?y=n.explicit:n.implicit!==null?y=n.implicit:n.tag!==null&&(y=n.tag),y===null&&!n.any){let m=e.save();try{n.choice===null?this._decodeGeneric(n.tag,e,r):this._decodeChoice(e,r),a=!0}catch{a=!1}e.restore(m)}else if(a=this._peekTag(e,y,n.any),e.isError(a))return a}let v;if(n.obj&&a&&(v=e.enterObject()),a){if(n.explicit!==null){let m=this._decodeTag(e,n.explicit);if(e.isError(m))return m;e=m}let y=e.offset;if(n.use===null&&n.choice===null){let m;n.any&&(m=e.save());let B=this._decodeTag(e,n.implicit!==null?n.implicit:n.tag,n.any);if(e.isError(B))return B;n.any?i=e.raw(m):e=B}if(r&&r.track&&n.tag!==null&&r.track(e.path(),y,e.length,"tagged"),r&&r.track&&n.tag!==null&&r.track(e.path(),e.offset,e.length,"content"),n.any||(n.choice===null?i=this._decodeGeneric(n.tag,e,r):i=this._decodeChoice(e,r)),e.isError(i))return i;if(!n.any&&n.choice===null&&n.children!==null&&n.children.forEach(function(B){B._decode(e,r)}),n.contains&&(n.tag==="octstr"||n.tag==="bitstr")){let m=new B6(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(m,r)}}return n.obj&&a&&(i=e.leaveObject(v)),n.key!==null&&(i!==null||a===!0)?e.leaveKey(d,n.key,i):d!==null&&e.exitKey(d),i};et.prototype._decodeGeneric=function(e,r,n){let i=this._baseState;return e==="seq"||e==="set"?null:e==="seqof"||e==="setof"?this._decodeList(r,e,i.args[0],n):/str$/.test(e)?this._decodeStr(r,e,n):e==="objid"&&i.args?this._decodeObjid(r,i.args[0],i.args[1],n):e==="objid"?this._decodeObjid(r,null,null,n):e==="gentime"||e==="utctime"?this._decodeTime(r,e,n):e==="null_"?this._decodeNull(r,n):e==="bool"?this._decodeBool(r,n):e==="objDesc"?this._decodeStr(r,e,n):e==="int"||e==="enum"?this._decodeInt(r,i.args&&i.args[0],n):i.use!==null?this._getUse(i.use,r._reporterState.obj)._decode(r,n):r.error("unknown tag: "+e)};et.prototype._getUse=function(e,r){let n=this._baseState;return n.useDecoder=this._use(e,r),yr(n.useDecoder._baseState.parent===null),n.useDecoder=n.useDecoder._baseState.children[0],n.implicit!==n.useDecoder._baseState.implicit&&(n.useDecoder=n.useDecoder.clone(),n.useDecoder._baseState.implicit=n.implicit),n.useDecoder};et.prototype._decodeChoice=function(e,r){let n=this._baseState,i=null,a=!1;return Object.keys(n.choice).some(function(d){let v=e.save(),y=n.choice[d];try{let m=y._decode(e,r);if(e.isError(m))return!1;i={type:d,value:m},a=!0}catch{return e.restore(v),!1}return!0},this),a?i:e.error("Choice not matched")};et.prototype._createEncoderBuffer=function(e){return new _6(e,this.reporter)};et.prototype._encode=function(e,r,n){let i=this._baseState;if(i.default!==null&&i.default===e)return;let a=this._encodeValue(e,r,n);if(a!==void 0&&!this._skipDefault(a,r,n))return a};et.prototype._encodeValue=function(e,r,n){let i=this._baseState;if(i.parent===null)return i.children[0]._encode(e,r||new E6);let a=null;if(this.reporter=r,i.optional&&e===void 0)if(i.default!==null)e=i.default;else return;let d=null,v=!1;if(i.any)a=this._createEncoderBuffer(e);else if(i.choice)a=this._encodeChoice(e,r);else if(i.contains)d=this._getUse(i.contains,n)._encode(e,r),v=!0;else if(i.children)d=i.children.map(function(y){if(y._baseState.tag==="null_")return y._encode(null,r,e);if(y._baseState.key===null)return r.error("Child should have a key");let m=r.enterKey(y._baseState.key);if(typeof e!="object")return r.error("Child expected, but input is not object");let B=y._encode(e[y._baseState.key],r,e);return r.leaveKey(m),B},this).filter(function(y){return y}),d=this._createEncoderBuffer(d);else if(i.tag==="seqof"||i.tag==="setof"){if(!(i.args&&i.args.length===1))return r.error("Too many args for : "+i.tag);if(!Array.isArray(e))return r.error("seqof/setof, but data is not Array");let y=this.clone();y._baseState.implicit=null,d=this._createEncoderBuffer(e.map(function(m){let B=this._baseState;return this._getUse(B.args[0],e)._encode(m,r)},y))}else i.use!==null?a=this._getUse(i.use,n)._encode(e,r):(d=this._encodePrimitive(i.tag,e),v=!0);if(!i.any&&i.choice===null){let y=i.implicit!==null?i.implicit:i.tag,m=i.implicit===null?"universal":"context";y===null?i.use===null&&r.error("Tag could be omitted only for .use()"):i.use===null&&(a=this._encodeComposite(y,v,m,d))}return i.explicit!==null&&(a=this._encodeComposite(i.explicit,!1,"context",a)),a};et.prototype._encodeChoice=function(e,r){let n=this._baseState,i=n.choice[e.type];return i||yr(!1,e.type+" not found in "+JSON.stringify(Object.keys(n.choice))),i._encode(e.value,r)};et.prototype._encodePrimitive=function(e,r){let n=this._baseState;if(/str$/.test(e))return this._encodeStr(r,e);if(e==="objid"&&n.args)return this._encodeObjid(r,n.reverseArgs[0],n.args[1]);if(e==="objid")return this._encodeObjid(r,null,null);if(e==="gentime"||e==="utctime")return this._encodeTime(r,e);if(e==="null_")return this._encodeNull();if(e==="int"||e==="enum")return this._encodeInt(r,n.args&&n.reverseArgs[0]);if(e==="bool")return this._encodeBool(r);if(e==="objDesc")return this._encodeStr(r,e);throw new Error("Unsupported tag: "+e)};et.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)};et.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)}});var $f=V(la=>{"use strict";var rC=A(M());function Op(t){let e={};return Object.keys(t).forEach(function(r){(r|0)==r&&(r=r|0);let n=t[r];e[n]=r}),e}la.tagClass={0:"universal",1:"application",2:"context",3:"private"};la.tagClassByName=Op(la.tagClass);la.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"};la.tagByName=Op(la.tag)});var pl=V((nC,Np)=>{"use strict";var iC=A(M()),R6=$t(),ui=jf().Buffer,Ip=Yf(),hl=$f();function kp(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new bn,this.tree._init(t.body)}Np.exports=kp;kp.prototype.encode=function(e,r){return this.tree._encode(e,r).join()};function bn(t){Ip.call(this,"der",t)}R6(bn,Ip);bn.prototype._encodeComposite=function(e,r,n,i){let a=F6(e,r,n,this.reporter);if(i.length<128){let y=ui.alloc(2);return y[0]=a,y[1]=i.length,this._createEncoderBuffer([y,i])}let d=1;for(let y=i.length;y>=256;y>>=8)d++;let v=ui.alloc(2+d);v[0]=a,v[1]=128|d;for(let y=1+d,m=i.length;m>0;y--,m>>=8)v[y]=m&255;return this._createEncoderBuffer([v,i])};bn.prototype._encodeStr=function(e,r){if(r==="bitstr")return this._createEncoderBuffer([e.unused|0,e.data]);if(r==="bmpstr"){let n=ui.alloc(e.length*2);for(let i=0;i<e.length;i++)n.writeUInt16BE(e.charCodeAt(i),i*2);return this._createEncoderBuffer(n)}else return r==="numstr"?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):r==="printstr"?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(r)?this._createEncoderBuffer(e):r==="objDesc"?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+r+" unsupported")};bn.prototype._encodeObjid=function(e,r,n){if(typeof e=="string"){if(!r)return this.reporter.error("string objid given, but no values map found");if(!r.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=r[e].split(/[\s.]+/g);for(let v=0;v<e.length;v++)e[v]|=0}else if(Array.isArray(e)){e=e.slice();for(let v=0;v<e.length;v++)e[v]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!n){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,e[0]*40+e[1])}let i=0;for(let v=0;v<e.length;v++){let y=e[v];for(i++;y>=128;y>>=7)i++}let a=ui.alloc(i),d=a.length-1;for(let v=e.length-1;v>=0;v--){let y=e[v];for(a[d--]=y&127;(y>>=7)>0;)a[d--]=128|y&127}return this._createEncoderBuffer(a)};function Xr(t){return t<10?"0"+t:t}bn.prototype._encodeTime=function(e,r){let n,i=new Date(e);return r==="gentime"?n=[Xr(i.getUTCFullYear()),Xr(i.getUTCMonth()+1),Xr(i.getUTCDate()),Xr(i.getUTCHours()),Xr(i.getUTCMinutes()),Xr(i.getUTCSeconds()),"Z"].join(""):r==="utctime"?n=[Xr(i.getUTCFullYear()%100),Xr(i.getUTCMonth()+1),Xr(i.getUTCDate()),Xr(i.getUTCHours()),Xr(i.getUTCMinutes()),Xr(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+r+" time is not supported yet"),this._encodeStr(n,"octstr")};bn.prototype._encodeNull=function(){return this._createEncoderBuffer("")};bn.prototype._encodeInt=function(e,r){if(typeof e=="string"){if(!r)return this.reporter.error("String int or enum given, but no values map");if(!r.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=r[e]}if(typeof e!="number"&&!ui.isBuffer(e)){let a=e.toArray();!e.sign&&a[0]&128&&a.unshift(0),e=ui.from(a)}if(ui.isBuffer(e)){let a=e.length;e.length===0&&a++;let d=ui.alloc(a);return e.copy(d),e.length===0&&(d[0]=0),this._createEncoderBuffer(d)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let n=1;for(let a=e;a>=256;a>>=8)n++;let i=new Array(n);for(let a=i.length-1;a>=0;a--)i[a]=e&255,e>>=8;return i[0]&128&&i.unshift(0),this._createEncoderBuffer(ui.from(i))};bn.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)};bn.prototype._use=function(e,r){return typeof e=="function"&&(e=e(r)),e._getEncoder("der").tree};bn.prototype._skipDefault=function(e,r,n){let i=this._baseState,a;if(i.default===null)return!1;let d=e.join();if(i.defaultBuffer===void 0&&(i.defaultBuffer=this._encodeValue(i.default,r,n).join()),d.length!==i.defaultBuffer.length)return!1;for(a=0;a<d.length;a++)if(d[a]!==i.defaultBuffer[a])return!1;return!0};function F6(t,e,r,n){let i;if(t==="seqof"?t="seq":t==="setof"&&(t="set"),hl.tagByName.hasOwnProperty(t))i=hl.tagByName[t];else if(typeof t=="number"&&(t|0)===t)i=t;else return n.error("Unknown tag: "+t);return i>=31?n.error("Multi-octet tag encoding unsupported"):(e||(i|=32),i|=hl.tagClassByName[r||"universal"]<<6,i)}});var Up=V((aC,Jp)=>{"use strict";var oC=A(M()),D6=$t(),bl=pl();function gl(t){bl.call(this,t),this.enc="pem"}D6(gl,bl);Jp.exports=gl;gl.prototype.encode=function(e,r){let i=bl.prototype.encode.call(this,e).toString("base64"),a=["-----BEGIN "+r.label+"-----"];for(let d=0;d<i.length;d+=64)a.push(i.slice(d,d+64));return a.push("-----END "+r.label+"-----"),a.join(`
|
|
5
5
|
`)}});var vl=V(qp=>{"use strict";var fC=A(M()),Hp=qp;Hp.der=pl();Hp.pem=Up()});var ml=V((cC,Vp)=>{"use strict";var uC=A(M()),O6=$t(),I6=fl(),Gp=co().DecoderBuffer,zp=Yf(),Xp=$f();function Kp(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new Pr,this.tree._init(t.body)}Vp.exports=Kp;Kp.prototype.decode=function(e,r){return Gp.isDecoderBuffer(e)||(e=new Gp(e,r)),this.tree._decode(e,r)};function Pr(t){zp.call(this,"der",t)}O6(Pr,zp);Pr.prototype._peekTag=function(e,r,n){if(e.isEmpty())return!1;let i=e.save(),a=xl(e,'Failed to peek tag: "'+r+'"');return e.isError(a)?a:(e.restore(i),a.tag===r||a.tagStr===r||a.tagStr+"of"===r||n)};Pr.prototype._decodeTag=function(e,r,n){let i=xl(e,'Failed to decode tag of "'+r+'"');if(e.isError(i))return i;let a=Zp(e,i.primitive,'Failed to get length of "'+r+'"');if(e.isError(a))return a;if(!n&&i.tag!==r&&i.tagStr!==r&&i.tagStr+"of"!==r)return e.error('Failed to match tag: "'+r+'"');if(i.primitive||a!==null)return e.skip(a,'Failed to match body of: "'+r+'"');let d=e.save(),v=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(v)?v:(a=e.offset-d.offset,e.restore(d),e.skip(a,'Failed to match body of: "'+r+'"'))};Pr.prototype._skipUntilEnd=function(e,r){for(;;){let n=xl(e,r);if(e.isError(n))return n;let i=Zp(e,n.primitive,r);if(e.isError(i))return i;let a;if(n.primitive||i!==null?a=e.skip(i):a=this._skipUntilEnd(e,r),e.isError(a))return a;if(n.tagStr==="end")break}};Pr.prototype._decodeList=function(e,r,n,i){let a=[];for(;!e.isEmpty();){let d=this._peekTag(e,"end");if(e.isError(d))return d;let v=n.decode(e,"der",i);if(e.isError(v)&&d)break;a.push(v)}return a};Pr.prototype._decodeStr=function(e,r){if(r==="bitstr"){let n=e.readUInt8();return e.isError(n)?n:{unused:n,data:e.raw()}}else if(r==="bmpstr"){let n=e.raw();if(n.length%2===1)return e.error("Decoding of string type: bmpstr length mismatch");let i="";for(let a=0;a<n.length/2;a++)i+=String.fromCharCode(n.readUInt16BE(a*2));return i}else if(r==="numstr"){let n=e.raw().toString("ascii");return this._isNumstr(n)?n:e.error("Decoding of string type: numstr unsupported characters")}else{if(r==="octstr")return e.raw();if(r==="objDesc")return e.raw();if(r==="printstr"){let n=e.raw().toString("ascii");return this._isPrintstr(n)?n:e.error("Decoding of string type: printstr unsupported characters")}else return/str$/.test(r)?e.raw().toString():e.error("Decoding of string type: "+r+" unsupported")}};Pr.prototype._decodeObjid=function(e,r,n){let i,a=[],d=0,v=0;for(;!e.isEmpty();)v=e.readUInt8(),d<<=7,d|=v&127,v&128||(a.push(d),d=0);v&128&&a.push(d);let y=a[0]/40|0,m=a[0]%40;if(n?i=a:i=[y,m].concat(a.slice(1)),r){let B=r[i.join(" ")];B===void 0&&(B=r[i.join(".")]),B!==void 0&&(i=B)}return i};Pr.prototype._decodeTime=function(e,r){let n=e.raw().toString(),i,a,d,v,y,m;if(r==="gentime")i=n.slice(0,4)|0,a=n.slice(4,6)|0,d=n.slice(6,8)|0,v=n.slice(8,10)|0,y=n.slice(10,12)|0,m=n.slice(12,14)|0;else if(r==="utctime")i=n.slice(0,2)|0,a=n.slice(2,4)|0,d=n.slice(4,6)|0,v=n.slice(6,8)|0,y=n.slice(8,10)|0,m=n.slice(10,12)|0,i<70?i=2e3+i:i=1900+i;else return e.error("Decoding "+r+" time is not supported yet");return Date.UTC(i,a-1,d,v,y,m,0)};Pr.prototype._decodeNull=function(){return null};Pr.prototype._decodeBool=function(e){let r=e.readUInt8();return e.isError(r)?r:r!==0};Pr.prototype._decodeInt=function(e,r){let n=e.raw(),i=new I6(n);return r&&(i=r[i.toString(10)]||i),i};Pr.prototype._use=function(e,r){return typeof e=="function"&&(e=e(r)),e._getDecoder("der").tree};function xl(t,e){let r=t.readUInt8(e);if(t.isError(r))return r;let n=Xp.tagClass[r>>6],i=(r&32)===0;if((r&31)===31){let d=r;for(r=0;(d&128)===128;){if(d=t.readUInt8(e),t.isError(d))return d;r<<=7,r|=d&127}}else r&=31;let a=Xp.tag[r];return{cls:n,primitive:i,tag:r,tagStr:a}}function Zp(t,e,r){let n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&n===128)return null;if(!(n&128))return n;let i=n&127;if(i>4)return t.error("length octect is too long");n=0;for(let a=0;a<i;a++){n<<=8;let d=t.readUInt8(r);if(t.isError(d))return d;n|=d}return n}});var Qp=V((lC,jp)=>{"use strict";var dC=A(M()),k6=$t(),N6=jf().Buffer,yl=ml();function wl(t){yl.call(this,t),this.enc="pem"}k6(wl,yl);jp.exports=wl;wl.prototype.decode=function(e,r){let n=e.toString().split(/[\r\n]+/g),i=r.label.toUpperCase(),a=/^-----(BEGIN|END) ([^-]+)-----$/,d=-1,v=-1;for(let B=0;B<n.length;B++){let P=n[B].match(a);if(P!==null&&P[2]===i)if(d===-1){if(P[1]!=="BEGIN")break;d=B}else{if(P[1]!=="END")break;v=B;break}}if(d===-1||v===-1)throw new Error("PEM section not found for: "+i);let y=n.slice(d+1,v).join("");y.replace(/[^a-z0-9+/=]+/gi,"");let m=N6.from(y,"base64");return yl.prototype.decode.call(this,m,r)}});var Al=V(Yp=>{"use strict";var pC=A(M()),Wp=Yp;Wp.der=ml();Wp.pem=Qp()});var eb=V($p=>{"use strict";var gC=A(M()),J6=vl(),U6=Al(),H6=$t(),q6=$p;q6.define=function(e,r){return new uo(e,r)};function uo(t,e){this.name=t,this.body=e,this.decoders={},this.encoders={}}uo.prototype._createNamed=function(e){let r=this.name;function n(i){this._initNamed(i,r)}return H6(n,e),n.prototype._initNamed=function(a,d){e.call(this,a,d)},new n(this)};uo.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(U6[e])),this.decoders[e]};uo.prototype.decode=function(e,r,n){return this._getDecoder(r).decode(e,n)};uo.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(J6[e])),this.encoders[e]};uo.prototype.encode=function(e,r,n){return this._getEncoder(r).encode(e,n)}});var rb=V(tb=>{"use strict";var xC=A(M()),e0=tb;e0.Reporter=Qf().Reporter;e0.DecoderBuffer=co().DecoderBuffer;e0.EncoderBuffer=co().EncoderBuffer;e0.Node=Yf()});var ab=V(ib=>{"use strict";var yC=A(M()),nb=ib;nb._reverse=function(e){let r={};return Object.keys(e).forEach(function(n){(n|0)==n&&(n=n|0);let i=e[n];r[i]=n}),r};nb.der=$f()});var sb=V(ob=>{"use strict";var AC=A(M()),lo=ob;lo.bignum=fl();lo.define=eb().define;lo.base=rb();lo.constants=ab();lo.decoders=Al();lo.encoders=vl()});var bb=V(Rn=>{"use strict";var MC=A(M()),G6=Rn&&Rn.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),X6=Rn&&Rn.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),z6=Rn&&Rn.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&G6(e,t,r);return X6(e,t),e};Object.defineProperty(Rn,"__esModule",{value:!0});Rn.pemTojwk=t4;Rn.jwkTopem=r4;var li=z6(sb());function K6(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Sl(t){return K6(Buffer.from(t,"hex").toString("base64"))}var fb=li.define("RSAPublicKey",function(){this.seq().obj(this.key("n").int(),this.key("e").int())}),cb=li.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())}),Z6=li.define("PublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(cb),this.key("publicKey").bitstr())}),ub=li.define("Version",function(){this.int({0:"two-prime",1:"multi"})}),V6=li.define("OtherPrimeInfos",function(){this.seq().obj(this.key("ri").int(),this.key("di").int(),this.key("ti").int())}),lb=li.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").use(ub),this.key("n").int(),this.key("e").int(),this.key("d").int(),this.key("p").int(),this.key("q").int(),this.key("dp").int(),this.key("dq").int(),this.key("qi").int(),this.key("other").optional().use(V6))}),j6=li.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").use(ub),this.key("algorithm").use(cb),this.key("privateKey").bitstr())});function db(t,e){return e=e||{},Object.keys(e).forEach(function(r){t[r]=e[r]}),t}function Ml(t){return t.length%2===1?"0"+t:t}function hb(t,e){var r=fb.decode(t,"der"),n=Ml(r.e.toString(16)),i={kty:"RSA",n:Fi(r.n),e:Sl(n)};return db(i,e)}function pb(t,e){var r=lb.decode(t,"der"),n=Ml(r.e.toString(16)),i={kty:"RSA",n:Fi(r.n),e:Sl(n),d:Fi(r.d),p:Fi(r.p),q:Fi(r.q),dp:Fi(r.dp),dq:Fi(r.dq),qi:Fi(r.qi)};return db(i,e)}function Q6(t,e){var r=Z6.decode(t,"der");return hb(r.publicKey.data,e)}function W6(t,e){var r=j6.decode(t,"der");return pb(r.privateKey.data,e)}function Y6(t){var e=/^-----BEGIN (RSA )?(PUBLIC|PRIVATE) KEY-----$/.exec(t);if(!e)return null;var r=!!e[1],n=e[2]==="PRIVATE";return n?r?pb:W6:r?hb:Q6}function $6(t){return{n:Ri(t.n),e:Ri(t.e),d:t.d&&Ri(t.d),p:t.p&&Ri(t.p),q:t.q&&Ri(t.q),dp:t.dp&&Ri(t.dp),dq:t.dq&&Ri(t.dq),qi:t.qi&&Ri(t.qi)}}function Fi(t){return Sl(Ml(t.toString(16)))}function e4(t){return new li.bignum(Buffer.from(t,"base64"))}function Ri(t){return/^[0-9]+$/.test(t)?new li.bignum(t,10):e4(t)}function t4(t,e){var r=t.toString().split(/(\r\n|\r|\n)+/g);r=r.filter(function(i){return i.trim().length!==0});var n=Y6(r[0]);return r=r.slice(1,-1).join(""),n(Buffer.from(r.replace(/[^\w\d\+\/=]+/g,""),"base64"),e)}function r4(t){var e=$6(t),r=!!e.d,n=r?"PRIVATE":"PUBLIC",i="-----BEGIN RSA "+n+` KEY-----
|
|
6
6
|
`,a=`
|
|
@@ -39,7 +39,7 @@ ${JSON.stringify(Buffer.from(r))},${JSON.stringify(Buffer.from(n))},${a} => ${JS
|
|
|
39
39
|
}
|
|
40
40
|
}`;return t.queryKey&&(q=`${t.queryKey}: ${q}`),q}async function p8(t){try{return await(await fetch(`https://${t.gateway}/graphql`,{method:"POST",headers:{"Content-Type":"application/json"},body:t.query})).json()}catch(e){throw e}}var S_=Sr.goldsky;async function v1(t,e){let r=[{name:"Authority",value:vt.mu}];e.tags&&e.tags.length>0&&e.tags.forEach(n=>r.push(n));try{let n=await t.ao.spawn({module:e.module,scheduler:e.scheduler,signer:t.signer,tags:r,data:e.data});return hn(`Process ID: ${n}`),hn("Sending initial message..."),await Cn(t,{processId:n,action:"Init"}),n}catch(n){throw console.log(n),new Error(n.message??"Error spawning process")}}function x1(t){return async e=>await Cn(t,e)}async function Cn(t,e){try{let r=[{name:"Action",value:e.action}];e.tags&&r.push(...e.tags);let n=e.useRawData?e.data:JSON.stringify(e.data);return await t.ao.message({process:e.processId,signer:t.signer,tags:r,data:n})}catch(r){throw new Error(r)}}function m1(t){return async e=>await oa(t,e)}async function oa(t,e){let n=`${e.node??l1.defaultNode}/${e.processId}~process@1.0/now/${e.path}`;e.serialize&&(n+="/serialize~json@1.0"),console.log("Getting state from HyperBEAM:",n);try{let i=await fetch(n);if(i.ok)return console.log("Returning state from HyperBEAM."),i.json();throw new Error("Error getting state from HyperBEAM.")}catch(i){if(e.fallbackAction){console.log("State not found, dryrunning...");let a=await Pf(t,{processId:e.processId,action:e.fallbackAction});return console.log("Returning state from dryrun."),a}throw i}}function y1(t){return async e=>await Pf(t,e)}async function Pf(t,e){try{let r=[{name:"Action",value:e.action}];e.tags&&r.push(...e.tags);let n;if(typeof e.data=="object")n=JSON.stringify(e.data||{});else if(typeof e.data=="string"){try{JSON.parse(e.data)}catch(a){throw console.error(a),new Error("Invalid JSON data")}n=e.data}let i=await t.ao.dryrun({process:e.processId,tags:r,data:n});if(i.Messages&&i.Messages.length){if(i.Messages[0].Data)return JSON.parse(i.Messages[0].Data);if(i.Messages[0].Tags)return i.Messages[0].Tags.reduce((a,d)=>(a[d.name]=d.value,a),{})}}catch(r){throw new Error(r.message??"Error dryrunning process")}}async function b8(t,e){try{let{Messages:r}=await t.ao.result({message:e.messageId,process:e.processId});if(r&&r.length){let n={};return r.forEach(i=>{let a=Cf(i.Tags,"Action")||e.action,d=null,v=i.Data;if(v)try{d=JSON.parse(v)}catch{d=v}let y=Cf(i.Tags,"Status"),m=Cf(i.Tags,"Message");n[a]={id:e.messageId,status:y,message:m,data:d}}),n}else return null}catch(r){console.error(r)}}async function ss(t,e){let r=null;if(e.evalSrc?r=e.evalSrc:e.evalTxId&&(r=await g8(e.evalTxId)),r)try{let n=await Cn(t,{processId:e.processId,action:"Eval",data:r,tags:e.evalTags||null,useRawData:!0});return hn(`Eval: ${n}`),await b8(t,{processId:e.processId,messageId:n,action:"Eval"})}catch(n){throw new Error(n.message??"Error sending process eval")}return null}function w1(t){return async(e,r)=>{try{let n={module:e.module||vt.module,scheduler:e.scheduler||vt.scheduler};e.data&&(n.data=e.data),e.tags&&(n.tags=e.tags),r&&r("Spawning process...");let i=await v1(t,n);if(e.evalTxId||e.evalSrc){r&&r("Process retrieved!"),r&&r("Sending eval...");try{await ss(t,{processId:i,evalTxId:e.evalTxId||null,evalSrc:e.evalSrc||null,evalTags:e.evalTags})&&r&&r("Eval complete")}catch(a){throw new Error(a.message??"Error creating process")}}return i}catch(n){throw new Error(n.message??"Error creating process")}}}async function sa(t,e,r){try{let n={module:e.module||vt.module,scheduler:e.scheduler||vt.scheduler};e.data&&(n.data=e.data),e.tags&&(n.tags=e.tags),r&&r("Spawning process...");let i=await v1(t,n);if(e.evalTxId||e.evalSrc){r&&r("Process retrieved!"),r&&r("Sending eval...");try{await ss(t,{processId:i,evalTxId:e.evalTxId||null,evalSrc:e.evalSrc||null,evalTags:e.evalTags})&&r&&r("Eval complete")}catch(a){throw new Error(a.message??"Error creating process")}}return i}catch(n){throw new Error(n.message??"Error creating process")}}async function g8(t){try{return await(await fetch(Ya(t))).text()}catch(e){throw new Error(e)}}var eN=A(M(),1);var Zk=A(M(),1);var t1={};ou(t1,{AVSCTap:()=>Mf,AlgorandSigner:()=>bf,AptosSigner:()=>vf,ArconnectSigner:()=>Za,Arweave:()=>Tp.default,ArweaveSigner:()=>da,Bundle:()=>jc,BundleItem:()=>e1,CryptoDriver:()=>Kf,Curve25519:()=>Br,DataItem:()=>Kc,EthereumSigner:()=>Or,HexInjectedSolanaSigner:()=>Ga,HexSolanaSigner:()=>gf,InjectedAptosSigner:()=>Xa,InjectedEthereumSigner:()=>ih,InjectedSolanaSigner:()=>ha,InjectedTypedEthereumSigner:()=>Qh,KyveSigner:()=>yf,MAX_TAG_BYTES:()=>zc,MIN_BINARY_SIZE:()=>Zc,MultiSignatureAptosSigner:()=>za,NearSigner:()=>pf,PolygonSigner:()=>hf,Rsa4096:()=>ua,SIG_CONFIG:()=>Je,SignatureConfig:()=>Oe,Signer:()=>hu,SolanaSigner:()=>wi,Transaction:()=>Mp.default,TypedEthereumSigner:()=>Ka,bundleAndSignData:()=>GE,byteArrayToLong:()=>pt,concatBuffers:()=>$e.concatBuffers,createData:()=>Ef,deepHash:()=>Ci,deserializeTags:()=>ns,exportForTesting:()=>JE,getCryptoDriver:()=>mt,getSignatureAndId:()=>R3,indexToType:()=>wf,keccak256:()=>Zh,longTo16ByteArray:()=>HE,longTo32ByteArray:()=>Xc,longTo8ByteArray:()=>Gc,longToNByteArray:()=>Sf,secp256k1:()=>qa,serializeTags:()=>Yh,shortTo2ByteArray:()=>Wh,sign:()=>Vc,stringToBuffer:()=>$e.stringToBuffer,unbundleData:()=>qE});var Sk=A(M(),1);var FI=A(M(),1);var __=A(M(),1),hu=class{publicKey;signatureType;signatureLength;ownerLength;pem;static verify(e,r,n,i){throw new Error("You must implement verify method on child")}};var EI=A(M(),1);var q_=A(M(),1),O1=A(kr(),1);var O_=A(M(),1),Oe;(function(t){t[t.ARWEAVE=1]="ARWEAVE",t[t.ED25519=2]="ED25519",t[t.ETHEREUM=3]="ETHEREUM",t[t.SOLANA=4]="SOLANA",t[t.INJECTEDAPTOS=5]="INJECTEDAPTOS",t[t.MULTIAPTOS=6]="MULTIAPTOS",t[t.TYPEDETHEREUM=7]="TYPEDETHEREUM",t[t.KYVE=101]="KYVE"})(Oe||(Oe={}));var Je={[Oe.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[Oe.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[Oe.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[Oe.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[Oe.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[Oe.MULTIAPTOS]:{sigLength:64*32+4,pubLength:32*32+1,sigName:"multiAptos"},[Oe.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"},[Oe.KYVE]:{sigLength:65,pubLength:65,sigName:"kyve"}};var N_=A(M(),1),w8=A(require("crypto"),1);var Yt=BigInt(0),ze=BigInt(1),eo=BigInt(2),A8=BigInt(8),T1=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),at=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:T1,n:T1,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")});var L1=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),fs=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),I_=BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),S8=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),M8=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),T8=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),E8=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Ft=class t{constructor(e,r,n,i){this.x=e,this.y=r,this.z=n,this.t=i}static fromAffine(e){if(!(e instanceof xt))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(xt.ZERO)?t.ZERO:new t(e.x,e.y,ze,he(e.x*e.y))}static toAffineBatch(e){let r=C8(e.map(n=>n.z));return e.map((n,i)=>n.toAffine(r[i]))}static normalizeZ(e){return this.toAffineBatch(e).map(this.fromAffine)}equals(e){_1(e);let{x:r,y:n,z:i}=this,{x:a,y:d,z:v}=e,y=he(r*v),m=he(a*i),B=he(n*v),P=he(d*i);return y===m&&B===P}negate(){return new t(he(-this.x),this.y,this.z,he(-this.t))}double(){let{x:e,y:r,z:n}=this,{a:i}=at,a=he,d=a(e*e),v=a(r*r),y=a(eo*a(n*n)),m=a(i*d),B=e+r,P=a(a(B*B)-d-v),D=m+v,F=D-y,C=m-v,q=a(P*F),W=a(D*C),K=a(P*C),ne=a(F*D);return new t(q,W,ne,K)}add(e){let{x:r,y:n,z:i,t:a}=this;_1(e);let{x:d,y:v,z:y,t:m}=e,{a:B,d:P}=at,D=he,F=D(r*d),C=D(n*v),q=D(a*P*m),W=D(i*y),K=D((r+n)*(d+v)-F-C),ne=D(W-q),$=D(W+q),ae=D(C-B*F),ie=D(K*ne),ee=D($*ae),ce=D(K*ae),te=D(ne*$);return new t(ie,ee,te,ce)}subtract(e){return this.add(e.negate())}precomputeWindow(e){let r=1+256/e,n=[],i=this,a=i;for(let d=0;d<r;d++){a=i,n.push(a);for(let v=1;v<2**(e-1);v++)a=a.add(i),n.push(a);i=a.double()}return n}wNAF(e,r){!r&&this.equals(t.BASE)&&(r=xt.BASE);let n=r&&r._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let i=r&&Au.get(r);i||(i=this.precomputeWindow(n),r&&n!==1&&(i=t.normalizeZ(i),Au.set(r,i)));let a=t.ZERO,d=t.BASE,v=1+256/n,y=2**(n-1),m=BigInt(2**n-1),B=2**n,P=BigInt(n);for(let D=0;D<v;D++){let F=D*y,C=Number(e&m);e>>=P,C>y&&(C-=B,e+=ze);let q=F,W=F+Math.abs(C)-1,K=D%2!==0,ne=C<0;C===0?d=d.add(E1(K,i[q])):a=a.add(E1(ne,i[W]))}return t.normalizeZ([a,d])[0]}multiply(e,r){return this.wNAF(Ff(e,at.l),r)}multiplyUnsafe(e){let r=Ff(e,at.l,!1),n=t.BASE,i=t.ZERO;if(r===Yt)return i;if(this.equals(i)||r===ze)return this;if(this.equals(n))return this.wNAF(r);let a=i,d=this;for(;r>Yt;)r&ze&&(a=a.add(d)),d=d.double(),r>>=ze;return a}isSmallOrder(){return this.multiplyUnsafe(at.h).equals(t.ZERO)}isTorsionFree(){let e=this.multiplyUnsafe(at.l/eo).double();return at.l%eo&&(e=e.add(this)),e.equals(t.ZERO)}toAffine(e){let{x:r,y:n,z:i}=this,a=this.equals(t.ZERO);e==null&&(e=a?A8:Df(i));let d=he(r*e),v=he(n*e),y=he(i*e);if(a)return xt.ZERO;if(y!==ze)throw new Error("invZ was invalid");return new xt(d,v)}fromRistrettoBytes(){mu()}toRistrettoBytes(){mu()}fromRistrettoHash(){mu()}};Ft.BASE=new Ft(at.Gx,at.Gy,ze,he(at.Gx*at.Gy));Ft.ZERO=new Ft(Yt,ze,ze,Yt);function E1(t,e){let r=e.negate();return t?r:e}function _1(t){if(!(t instanceof Ft))throw new TypeError("ExtendedPoint expected")}function xu(t){if(!(t instanceof fa))throw new TypeError("RistrettoPoint expected")}function mu(){throw new Error("Legacy method: switch to RistrettoPoint")}var fa=class t{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){let{d:r}=at,n=he(fs*e*e),i=he((n+ze)*T8),a=BigInt(-1),d=he((a-r*n)*he(n+r)),{isValid:v,value:y}=Tu(i,d),m=he(y*e);Ei(m)||(m=he(-m)),v||(y=m),v||(a=n);let B=he(a*(n-ze)*E8-d),P=y*y,D=he((y+y)*d),F=he(B*S8),C=he(ze-P),q=he(ze+P);return new Ft(he(D*q),he(C*F),he(F*q),he(D*C))}static hashToCurve(e){e=_i(e,64);let r=yu(e.slice(0,32)),n=this.calcElligatorRistrettoMap(r),i=yu(e.slice(32,64)),a=this.calcElligatorRistrettoMap(i);return new t(n.add(a))}static fromHex(e){e=_i(e,32);let{a:r,d:n}=at,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=yu(e);if(!L8(us(a),e)||Ei(a))throw new Error(i);let d=he(a*a),v=he(ze+r*d),y=he(ze-r*d),m=he(v*v),B=he(y*y),P=he(r*n*m-B),{isValid:D,value:F}=P1(he(P*B)),C=he(F*y),q=he(F*C*P),W=he((a+a)*C);Ei(W)&&(W=he(-W));let K=he(v*q),ne=he(W*K);if(!D||Ei(ne)||K===Yt)throw new Error(i);return new t(new Ft(W,K,ze,ne))}toRawBytes(){let{x:e,y:r,z:n,t:i}=this.ep,a=he(he(n+r)*he(n-r)),d=he(e*r),v=he(d*d),{value:y}=P1(he(a*v)),m=he(y*a),B=he(y*d),P=he(m*B*i),D;if(Ei(i*P)){let C=he(r*fs),q=he(e*fs);e=C,r=q,D=he(m*M8)}else D=B;Ei(e*P)&&(r=he(-r));let F=he((n-r)*D);return Ei(F)&&(F=he(-F)),us(F)}toHex(){return ls(this.toRawBytes())}toString(){return this.toHex()}equals(e){xu(e);let r=this.ep,n=e.ep,i=he(r.x*n.y)===he(r.y*n.x),a=he(r.y*n.y)===he(r.x*n.x);return i||a}add(e){return xu(e),new t(this.ep.add(e.ep))}subtract(e){return xu(e),new t(this.ep.subtract(e.ep))}multiply(e){return new t(this.ep.multiply(e))}multiplyUnsafe(e){return new t(this.ep.multiplyUnsafe(e))}};fa.BASE=new fa(Ft.BASE);fa.ZERO=new fa(Ft.ZERO);var Au=new WeakMap,xt=class t{constructor(e,r){this.x=e,this.y=r}_setWindowSize(e){this._WINDOW_SIZE=e,Au.delete(this)}static fromHex(e,r=!0){let{d:n,P:i}=at;e=_i(e,32);let a=e.slice();a[31]=e[31]&-129;let d=ds(a);if(r&&d>=i)throw new Error("Expected 0 < hex < P");if(!r&&d>=L1)throw new Error("Expected 0 < hex < 2**256");let v=he(d*d),y=he(v-ze),m=he(n*v+ze),{isValid:B,value:P}=Tu(y,m);if(!B)throw new Error("Point.fromHex: invalid y coordinate");let D=(P&ze)===ze;return(e[31]&128)!==0!==D&&(P=he(-P)),new t(P,d)}static async fromPrivateKey(e){return(await Eu(e)).point}toRawBytes(){let e=us(this.y);return e[31]|=this.x&ze?128:0,e}toHex(){return ls(this.toRawBytes())}toX25519(){let{y:e}=this,r=he((ze+e)*Df(ze-e));return us(r)}isTorsionFree(){return Ft.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new t(he(-this.x),this.y)}add(e){return Ft.fromAffine(this).add(Ft.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Ft.fromAffine(this).multiply(e,this).toAffine()}};xt.BASE=new xt(at.Gx,at.Gy);xt.ZERO=new xt(Yt,ze);var cs=class t{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromHex(e){let r=_i(e,64),n=xt.fromHex(r.slice(0,32),!1),i=ds(r.slice(32,64));return new t(n,i)}assertValidity(){let{r:e,s:r}=this;if(!(e instanceof xt))throw new Error("Expected Point instance");return Ff(r,at.l,!1),this}toRawBytes(){let e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(us(this.s),32),e}toHex(){return ls(this.toRawBytes())}};function R1(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Su(t){if(!R1(t))throw new Error("Uint8Array expected")}function B1(...t){if(t.every(Su),t.length===1)return t[0];let e=t.reduce((n,i)=>n+i.length,0),r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let a=t[n];r.set(a,i),i+=a.length}return r}var _8=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ls(t){Su(t);let e="";for(let r=0;r<t.length;r++)e+=_8[t[r]];return e}var si={_0:48,_9:57,A:65,F:70,a:97,f:102};function C1(t){if(t>=si._0&&t<=si._9)return t-si._0;if(t>=si.A&&t<=si.F)return t-(si.A-10);if(t>=si.a&&t<=si.f)return t-(si.a-10)}function Mu(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,a=0;i<r;i++,a+=2){let d=C1(t.charCodeAt(a)),v=C1(t.charCodeAt(a+1));if(d===void 0||v===void 0){let y=t[a]+t[a+1];throw new Error('hex string expected, got non-hex character "'+y+'" at index '+a)}n[i]=d*16+v}return n}function F1(t){let r=t.toString(16).padStart(64,"0");return Mu(r)}function us(t){return F1(t).reverse()}function Ei(t){return(he(t)&ze)===ze}function ds(t){return Su(t),BigInt("0x"+ls(Uint8Array.from(t).reverse()))}var B8=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function yu(t){return he(ds(t)&B8)}function he(t,e=at.P){let r=t%e;return r>=Yt?r:e+r}function Df(t,e=at.P){if(t===Yt||e<=Yt)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=he(t,e),n=e,i=Yt,a=ze,d=ze,v=Yt;for(;r!==Yt;){let m=n/r,B=n%r,P=i-d*m,D=a-v*m;n=r,r=B,i=d,a=v,d=P,v=D}if(n!==ze)throw new Error("invert: does not exist");return he(i,e)}function C8(t,e=at.P){let r=new Array(t.length),n=t.reduce((a,d,v)=>d===Yt?a:(r[v]=a,he(a*d,e)),ze),i=Df(n,e);return t.reduceRight((a,d,v)=>d===Yt?a:(r[v]=he(a*r[v],e),he(a*d,e)),i),r}function Pn(t,e){let{P:r}=at,n=t;for(;e-- >Yt;)n*=n,n%=r;return n}function P8(t){let{P:e}=at,r=BigInt(5),n=BigInt(10),i=BigInt(20),a=BigInt(40),d=BigInt(80),y=t*t%e*t%e,m=Pn(y,eo)*y%e,B=Pn(m,ze)*t%e,P=Pn(B,r)*B%e,D=Pn(P,n)*P%e,F=Pn(D,i)*D%e,C=Pn(F,a)*F%e,q=Pn(C,d)*C%e,W=Pn(q,d)*C%e,K=Pn(W,n)*P%e;return{pow_p_5_8:Pn(K,eo)*t%e,b2:y}}function Tu(t,e){let r=he(e*e*e),n=he(r*r*e),i=P8(t*n).pow_p_5_8,a=he(t*r*i),d=he(e*a*a),v=a,y=he(a*fs),m=d===t,B=d===he(-t),P=d===he(-t*fs);return m&&(a=v),(B||P)&&(a=y),Ei(a)&&(a=he(-a)),{isValid:m||B,value:a}}function P1(t){return Tu(ze,t)}function Rf(t){return he(ds(t),at.l)}function L8(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function _i(t,e){let r=R1(t)?Uint8Array.from(t):Mu(t);if(typeof e=="number"&&r.length!==e)throw new Error(`Expected ${e} bytes`);return r}function Ff(t,e,r=!0){if(!e)throw new TypeError("Specify max value");if(typeof t=="number"&&Number.isSafeInteger(t)&&(t=BigInt(t)),typeof t=="bigint"&&t<e){if(r){if(Yt<t)return t}else if(Yt<=t)return t}throw new TypeError("Expected valid scalar: 0 < scalar < max")}function R8(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function F8(t){if(t=typeof t=="bigint"||typeof t=="number"?F1(Ff(t,L1)):_i(t),t.length!==32)throw new Error("Expected 32 bytes");return t}function D8(t){let e=R8(t.slice(0,32)),r=t.slice(32,64),n=Rf(e),i=xt.BASE.multiply(n),a=i.toRawBytes();return{head:e,prefix:r,scalar:n,point:i,pointBytes:a}}var wu;async function Eu(t){return D8(await to.sha512(F8(t)))}async function D1(t,e){t=_i(t);let{prefix:r,scalar:n,pointBytes:i}=await Eu(e),a=Rf(await to.sha512(r,t)),d=xt.BASE.multiply(a),v=Rf(await to.sha512(d.toRawBytes(),i,t)),y=he(a+v*n,at.l);return new cs(d,y).toRawBytes()}function O8(t,e,r){e=_i(e),r instanceof xt||(r=xt.fromHex(r,!1));let{r:n,s:i}=t instanceof cs?t.assertValidity():cs.fromHex(t),a=Ft.BASE.multiplyUnsafe(i);return{r:n,s:i,SB:a,pub:r,msg:e}}function I8(t,e,r,n){let i=Rf(n),a=Ft.fromAffine(t).multiplyUnsafe(i);return Ft.fromAffine(e).add(a).subtract(r).multiplyUnsafe(at.h).equals(Ft.ZERO)}async function Bi(t,e,r){let{r:n,SB:i,msg:a,pub:d}=O8(t,e,r),v=await to.sha512(n.toRawBytes(),d.toRawBytes(),a);return I8(d,n,i,v)}xt.BASE._setWindowSize(8);var Ti={node:w8,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},to={bytesToHex:ls,hexToBytes:Mu,concatBytes:B1,getExtendedPublicKey:Eu,mod:he,invert:Df,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar:t=>{if(t=_i(t),t.length<40||t.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return he(ds(t),at.l-ze)+ze},randomBytes:(t=32)=>{if(Ti.web)return Ti.web.getRandomValues(new Uint8Array(t));if(Ti.node){let{randomBytes:e}=Ti.node;return new Uint8Array(e(t).buffer)}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>to.randomBytes(32),sha512:async(...t)=>{let e=B1(...t);if(Ti.web){let r=await Ti.web.subtle.digest("SHA-512",e.buffer);return new Uint8Array(r)}else{if(Ti.node)return Uint8Array.from(Ti.node.createHash("sha512").update(e).digest());throw new Error("The environment doesn't have sha512 function")}},precompute(t=8,e=xt.BASE){let r=e.equals(xt.BASE)?e:new xt(e.x,e.y);return r._setWindowSize(t),r.multiply(eo),r},sha512Sync:void 0};Object.defineProperties(to,{sha512Sync:{configurable:!1,get(){return wu},set(t){wu||(wu=t)}}});var Br=class{_key;pk;ownerLength=Je[2].pubLength;signatureLength=Je[2].sigLength;_publicKey;get publicKey(){return this._publicKey}signatureType=2;constructor(e,r){this._key=e,this.pk=r}get key(){throw new Error("You must implement `key`")}sign(e){return D1(Buffer.from(e),Buffer.from(this.key))}static async verify(e,r,n){let i=e;return typeof e=="string"&&(i=O1.default.toBuffer(e)),Bi(Buffer.from(n),Buffer.from(r),Buffer.from(i))}};var aI=A(M(),1);var BC=A(M(),1);var JB=A(M(),1);var DB=A(M(),1),$e=A(pn(),1);var j_=A(M(),1);var Z1=require("crypto");async function Ci(t){if(typeof t[Symbol.asyncIterator]=="function"){let i=t,a=(0,Z1.createHash)("sha384"),d=0;for await(let m of i)d+=m.byteLength,a.update(m);let v=(0,$e.concatBuffers)([(0,$e.stringToBuffer)("blob"),(0,$e.stringToBuffer)(d.toString())]),y=(0,$e.concatBuffers)([await mt().hash(v,"SHA-384"),a.digest()]);return await mt().hash(y,"SHA-384")}else if(Array.isArray(t)){let i=(0,$e.concatBuffers)([(0,$e.stringToBuffer)("list"),(0,$e.stringToBuffer)(t.length.toString())]);return await V1(t,await mt().hash(i,"SHA-384"))}let e=t,r=(0,$e.concatBuffers)([(0,$e.stringToBuffer)("blob"),(0,$e.stringToBuffer)(e.byteLength.toString())]),n=(0,$e.concatBuffers)([await mt().hash(r,"SHA-384"),await mt().hash(e,"SHA-384")]);return await mt().hash(n,"SHA-384")}async function V1(t,e){if(t.length<1)return e;let r=(0,$e.concatBuffers)([e,await Ci(t[0])]),n=await mt().hash(r,"SHA-384");return await V1(t.slice(1),n)}var zf=A(Pu(),1),Mp=A(xs(),1),Tp=A(Sp(),1),A6=zf.default.default?zf.default.default:zf.default,Kf=class extends A6{getPublicKey(e){throw new Error("Unimplemented")}},S6;function mt(){return S6??=new Kf}var Ep=A(kr(),1);var Zf=require("crypto"),ua=class{_key;pk;signatureType=1;ownerLength=Je[1].pubLength;signatureLength=Je[1].sigLength;_publicKey;get publicKey(){return this._publicKey}constructor(e,r){this._key=e,this.pk=r,r||(this.pk=mt().getPublicKey(JSON.parse(e)))}sign(e){return(0,Zf.createSign)("sha256").update(e).sign({key:this._key,padding:Zf.constants.RSA_PKCS1_PSS_PADDING})}static async verify(e,r,n){return await mt().verify(Buffer.isBuffer(e)?Ep.default.encode(e):e,r,n)}};var gb=A(bb(),1),vb=A(kr(),1);var da=class extends ua{jwk;constructor(e){super((0,gb.jwkTopem)(e),e.n),this.jwk=e}get publicKey(){if(!this.pk)throw new Error("ArweaveSigner - pk is undefined");return vb.default.toBuffer(this.pk)}sign(e){return mt().sign(this.jwk,e)}static async verify(e,r,n){return await mt().verify(e,r,n)}};var RC=A(M(),1),xb=A(kr(),1);var ha=class{_publicKey;ownerLength=Je[2].pubLength;signatureLength=Je[2].sigLength;signatureType=2;pem;provider;constructor(e){if(this.provider=e,!this.provider.publicKey)throw new Error("InjectedSolanaSigner - provider.publicKey is undefined");this._publicKey=this.provider.publicKey.toBuffer()}get publicKey(){return this._publicKey}async sign(e){if(!this.provider.signMessage)throw new Error("Selected Wallet does not support message signing");return await this.provider.signMessage(e)}static async verify(e,r,n){let i=e;return typeof e=="string"&&(i=xb.default.toBuffer(e)),Bi(Buffer.from(n),Buffer.from(r),Buffer.from(i))}};var UF=A(M(),1),bm=A(Ps(),1),gm=A(Ns(),1);var nh=A(rt(),1),vm=A(Us(),1),xm=A(tf(),1),ih=class{signer;publicKey;ownerLength=Je[Oe.ETHEREUM].pubLength;signatureLength=Je[Oe.ETHEREUM].sigLength;signatureType=Oe.ETHEREUM;constructor(e){this.signer=e.getSigner()}async setPublicKey(){let e="sign this message to connect to Bundlr.Network",r=await this.signer.signMessage(e),n=await(0,bm.hashMessage)(e),i=(0,gm.recoverPublicKey)((0,nh.arrayify)(n),r);this.publicKey=Buffer.from((0,nh.arrayify)(i))}async sign(e){this.publicKey||await this.setPublicKey();let r=await this.signer.signMessage(e);return Buffer.from(r.slice(2),"hex")}static verify(e,r,n){let i=(0,vm.computeAddress)(e);return(0,xm.verifyMessage)(r,n)===i}};var VF=A(M(),1);var jo=A(Tm(),1),wi=class extends Br{get publicKey(){return jo.default.decode(this.pk)}get key(){return jo.default.decode(this._key)}constructor(e){let r=jo.default.decode(e);super(jo.default.encode(r.subarray(0,32)),jo.default.encode(r.subarray(32,64)))}};var vO=A(M(),1);var pO=A(M(),1);var lO=A(M(),1),S3=A(kr(),1),Vh=A(gh(),1);var sO=A(M(),1),ia=require("buffer"),g3=A(b3(),1);function Zh(t){return t=v3(t),(0,g3.default)("keccak256").update(t).digest()}function v3(t){if(!ia.Buffer.isBuffer(t))if(Array.isArray(t))t=ia.Buffer.from(t);else if(typeof t=="string")x3(t)?t=ia.Buffer.from(Hc(m3(t)),"hex"):t=ia.Buffer.from(t);else if(typeof t=="number")t=w3(t);else if(typeof t=="bigint")t=NE(t);else if(t==null)t=ia.Buffer.allocUnsafe(0);else throw new Error("invalid type");return t}function x3(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}function Hc(t){if(typeof t!="string")throw new Error(`while padding to even, value must be string, is currently ${typeof t}, while padToEven.`);return t.length%2&&(t=`0${t}`),t}function m3(t){return typeof t!="string"?t:y3(t)?t.slice(2):t}function y3(t){if(typeof t!="string")throw new Error("value must be type 'string', is currently type "+typeof t+", while checking isHexPrefixed.");return t.startsWith("0x")}function w3(t){let e=A3(t);return ia.Buffer.from(Hc(e.slice(2)),"hex")}function A3(t){return`0x${t.toString(16)}`}function NE(t){let e=t.toString(16);return ia.Buffer.from(Hc(e),"hex")}typeof window<"u"&&(window.keccak256=Zh);var df=Zh,JE={intToBuffer:w3,intToHex:A3,isHexPrefixed:y3,stripHexPrefix:m3,padToEven:Hc,isHexString:x3,toBuffer:v3};var qa=class{_key;ownerLength=Je[Oe.ETHEREUM].pubLength;signatureLength=Je[Oe.ETHEREUM].sigLength;signatureType=Oe.ETHEREUM;pk;constructor(e,r){this._key=e,this.pk=r.toString("hex")}get publicKey(){throw new Error("You must implement `publicKey`")}get key(){return Buffer.from(this._key,"hex")}static async verify(e,r,n){let i=e;typeof e=="string"&&(i=S3.default.toBuffer(e));let a=!1;try{a=Vh.default.ecdsaVerify(n,df(Buffer.from(r)),i)}catch{}return a}async sign(e){return Vh.default.ecdsaSign(df(Buffer.from(e)),Buffer.from(this.key)).signature}};var jh=A(gh(),1),M3=A(kr(),1),T3=A(rt(),1),E3=A(tf(),1),_3=A(Ps(),1),Or=class extends qa{get publicKey(){return Buffer.from(this.pk,"hex")}constructor(e){e.startsWith("0x")&&(e=e.slice(2));let r=Buffer.from(e,"hex"),n=jh.default.publicKeyCreate(r,!1);super(e,Buffer.from(n))}async sign(e){return new E3.Wallet(this._key).signMessage(e).then(n=>Buffer.from(n.slice(2),"hex"))}static async verify(e,r,n){return jh.default.ecdsaVerify(n.length===65?n.slice(0,-1):n,(0,T3.arrayify)((0,_3.hashMessage)(r)),typeof e=="string"?M3.default.toBuffer(e):e)}};var hf=class extends Or{};var yO=A(M(),1);var pf=class extends wi{constructor(e){super(e.replace("ed25519:",""))}};var SO=A(M(),1);var bf=class extends Br{get publicKey(){return Buffer.from(this.pk)}get key(){return Buffer.from(this._key)}constructor(e,r){super(e.subarray(0,32),r)}};var EO=A(M(),1);var Ga=class extends ha{signatureType=4;constructor(e){super(e)}async sign(e){return super.sign(Buffer.from(Buffer.from(e).toString("hex")))}static async verify(e,r,n){return super.verify(e,Buffer.from(Buffer.from(r).toString("hex")),n)}};var CO=A(M(),1);var gf=class extends wi{signatureType=4;constructor(e){super(e)}async sign(e){return super.sign(Buffer.from(Buffer.from(e).toString("hex")))}static async verify(e,r,n){return super.verify(e,Buffer.from(Buffer.from(r).toString("hex")),n)}};var RO=A(M(),1);var vf=class extends Br{constructor(e,r){super(e,r)}get publicKey(){return Buffer.from(this.pk.slice(2),"hex")}get key(){return Buffer.from(this._key.slice(2),"hex")}};var IO=A(M(),1);var Xa=class{_publicKey;ownerLength=Je[Oe.INJECTEDAPTOS].pubLength;signatureLength=Je[Oe.INJECTEDAPTOS].sigLength;signatureType=Oe.INJECTEDAPTOS;pem;provider;constructor(e,r){this.provider=e,this._publicKey=r}get publicKey(){return this._publicKey}async sign(e){if(!this.provider.signMessage)throw new Error("Selected Wallet does not support message signing");let n=(await this.provider.signMessage({message:Buffer.from(e).toString("hex"),nonce:"bundlr"})).signature;return typeof n=="string"?Buffer.from(n,"hex"):n.data.toUint8Array()}static async verify(e,r,n){let i=e;return Bi(Buffer.from(n),Buffer.from(`APTOS
|
|
41
41
|
message: ${Buffer.from(r).toString("hex")}
|
|
42
|
-
nonce: bundlr`),Buffer.from(i))}};var UO=A(M(),1);var za=class{_publicKey;ownerLength=Je[Oe.MULTIAPTOS].pubLength;signatureLength=Je[Oe.MULTIAPTOS].sigLength;signatureType=Oe.MULTIAPTOS;collectSignatures;provider;constructor(e,r){this._publicKey=e,this.collectSignatures=r}get publicKey(){return this._publicKey}async sign(e){let{signatures:r,bitmap:n}=await this.collectSignatures(e),i=128,a=new Uint8Array([0,0,0,0]),d=new Set;n.forEach(m=>{if(m>=32)throw new Error(`Invalid bit value ${m}.`);if(d.has(m))throw new Error("Duplicated bits detected.");d.add(m);let B=Math.floor(m/8),P=a[B];P|=i>>m%8,a[B]=P});let v=Buffer.alloc(this.signatureLength),y=0;for(let m=0;m<32;m++)n.includes(m)&&v.set(r[y++],m*64);return v.set(a,this.signatureLength-4),v}static async verify(e,r,n){let a=Je[Oe.MULTIAPTOS].sigLength-4,d=n.slice(0,a),v=n.slice(a),y=!1;for(let m=0;m<32;m++){let B=Math.floor(m/8),P=m-B*8;if((v[B]&128>>P)!==0){let F=d.slice(m*64,(m+1)*64),C=e.slice(m*32,(m+1)*32);await Bi(Buffer.from(F),Buffer.from(r),Buffer.from(C))||(y=!0)}}return!y}};var zO=A(M(),1),qc=A(tf(),1);var Ka=class extends Or{ownerLength=Je[Oe.TYPEDETHEREUM].pubLength;signatureLength=Je[Oe.TYPEDETHEREUM].sigLength;signatureType=Oe.TYPEDETHEREUM;address;signer;constructor(e){super(e),this.address="0x"+df(super.publicKey.slice(1)).slice(-20).toString("hex"),this.signer=new qc.Wallet(e)}get publicKey(){return Buffer.from(this.address)}async sign(e){let r=await this.signer._signTypedData(xf,mf,{address:this.address,"Transaction hash":e});return Buffer.from(r.slice(2),"hex")}static async verify(e,r,n){let i=e.toString(),a=(0,qc.verifyTypedData)(xf,mf,{address:i,"Transaction hash":r},n);return i.toLowerCase()===a.toLowerCase()}},xf={name:"Bundlr",version:"1"},mf={Bundlr:[{name:"Transaction hash",type:"bytes"},{name:"address",type:"address"}]};var jO=A(M(),1);var B3=A(tf(),1);var Qh=class{ownerLength=Je[Oe.TYPEDETHEREUM].pubLength;signatureLength=Je[Oe.TYPEDETHEREUM].sigLength;signatureType=Oe.TYPEDETHEREUM;address;signer;publicKey;constructor(e){this.signer=e.getSigner()}async ready(){this.address=(await this.signer.getAddress()).toString().toLowerCase(),this.publicKey=Buffer.from(this.address)}async sign(e){let r=await this.signer._signTypedData(xf,mf,{address:this.address,"Transaction hash":e});return Buffer.from(r.slice(2),"hex")}static verify(e,r,n){let i=e.toString(),a=(0,B3.verifyTypedData)(xf,mf,{address:i,"Transaction hash":r},n);return i.toLowerCase()===a.toLowerCase()}};var $O=A(M(),1);var C3=A(kr(),1);var Za=class{signer;publicKey;ownerLength=Je[Oe.ARWEAVE].pubLength;signatureLength=Je[Oe.ARWEAVE].sigLength;signatureType=Oe.ARWEAVE;constructor(e){this.signer=e}async setPublicKey(){let e=await this.signer.getActivePublicKey();this.publicKey=C3.default.toBuffer(e)}async sign(e){this.publicKey||await this.setPublicKey();let r={name:"RSA-PSS",saltLength:32},n=await this.signer.signature(e,r);return new Uint8Array(Object.values(n).map(a=>+a))}static async verify(e,r,n){return await mt().verify(e,r,n)}};var nI=A(M(),1);var yf=class extends Or{signatureType=Oe.KYVE};var wf={1:da,2:Br,3:Or,4:Ga,5:Xa,6:za,7:Ka};var BI=A(M(),1);var HI=A(M(),1);async function UE(t){return Ci([(0,$e.stringToBuffer)("dataitem"),(0,$e.stringToBuffer)("1"),(0,$e.stringToBuffer)(t.signatureType.toString()),t.rawOwner,t.rawTarget,t.rawAnchor,t.rawTags,t.rawData])}var Af=UE;var lk=A(M(),1);var GI=A(M(),1);function Sf(t,e){let r=new Uint8Array(t);if(e<0)throw new Error("Array is unsigned, cannot represent -ve numbers");if(e>2**(t*8)-1)throw new Error(`Number ${e} is too large for an array of ${t} bytes`);for(let n=0;n<r.length;n++){let i=e&255;r[n]=i,e=(e-i)/256}return r}function Gc(t){return Sf(8,t)}function Wh(t){return Sf(2,t)}function HE(t){return Sf(16,t)}function Xc(t){return Sf(32,t)}function pt(t){let e=0;for(let r=t.length-1;r>=0;r--)e=e*256+t[r];return e}var ak=A(M(),1),Tf=A(kr(),1);var tk=A(M(),1);var cn=A(kr(),1),is=require("buffer");var KI=A(M(),1);var Mf=class{buf;pos;constructor(e=Buffer.alloc(zc),r=0){this.buf=e,this.pos=r}writeTags(e){if(!Array.isArray(e))throw new Error("input must be array");let r=e.length,n;if(r)for(this.writeLong(r),n=0;n<r;n++){let i=e[n];if(typeof i?.name!="string"||typeof i?.value!="string")throw new Error(`Invalid tag format for ${i}, expected {name:string, value: string}`);this.writeString(i.name),this.writeString(i.value)}this.writeLong(0)}toBuffer(){let e=Buffer.alloc(this.pos);if(this.pos>this.buf.length)throw new Error(`Too many tag bytes (${this.pos} > ${this.buf.length})`);return this.buf.copy(e,0,0,this.pos),e}writeLong(e){let r=this.buf,n,i;if(e>=-1073741824&&e<1073741824){i=e>=0?e<<1:~e<<1|1;do r[this.pos]=i&127,i>>=7;while(i&&(r[this.pos++]|=128))}else{n=e>=0?e*2:-e*2-1;do r[this.pos]=n&127,n/=128;while(n>=1&&(r[this.pos++]|=128))}this.pos++,this.buf=r}writeString(e){let r=Buffer.byteLength(e),n=this.buf;this.writeLong(r);let i=this.pos;if(this.pos+=r,!(this.pos>n.length)){if(r>64)this.buf.write(e,this.pos-r,r,"utf8");else{let a,d,v,y;for(a=0,d=r;a<d;a++)v=e.charCodeAt(a),v<128?n[i++]=v:v<2048?(n[i++]=v>>6|192,n[i++]=v&63|128):(v&64512)===55296&&((y=e.charCodeAt(a+1))&64512)===56320?(v=65536+((v&1023)<<10)+(y&1023),a++,n[i++]=v>>18|240,n[i++]=v>>12&63|128,n[i++]=v>>6&63|128,n[i++]=v&63|128):(n[i++]=v>>12|224,n[i++]=v>>6&63|128,n[i++]=v&63|128)}this.buf=n}}readLong(){let e=0,r=0,n=this.buf,i,a,d,v;do i=n[this.pos++],a=i&128,e|=(i&127)<<r,r+=7;while(a&&r<28);if(a){d=e,v=268435456;do i=n[this.pos++],d+=(i&127)*v,v*=128;while(i&128);return(d%2?-(d+1):d)/2}return e>>1^-(e&1)}skipLong(){let e=this.buf;for(;e[this.pos++]&128;);}readTags(){let e=[],r;for(;r=this.readLong();)for(r<0&&(r=-r,this.skipLong());r--;){let n=this.readString(),i=this.readString();e.push({name:n,value:i})}return e}readString(){let e=this.readLong(),r=this.pos,n=this.buf;if(this.pos+=e,this.pos>n.length)throw new Error("TAP Position out of range");return this.buf.slice(r,r+e).toString()}};function Yh(t){if(t?.length===0)return Buffer.allocUnsafe(0);let e=new Mf;return e.writeTags(t),e.toBuffer()}function ns(t){return new Mf(t).readTags()}var P3=require("crypto"),Zc=80,zc=4096,Kc=class t{binary;_id;constructor(e){this.binary=e}static isDataItem(e){return e.binary!==void 0}get signatureType(){let e=pt(this.binary.subarray(0,2));if(Oe?.[e]!==void 0)return e;throw new Error("Unknown signature type: "+e)}async isValid(){return t.verify(this.binary)}get id(){return cn.default.encode(this.rawId)}set id(e){this._id=cn.default.toBuffer(e)}get rawId(){return(0,P3.createHash)("sha256").update(this.rawSignature).digest()}set rawId(e){this._id=e}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return cn.default.encode(this.rawSignature)}set rawOwner(e){if(e.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${e.byteLength} bytes.`);this.binary.set(e,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return Je[this.signatureType].sigLength}get owner(){return cn.default.encode(this.rawOwner)}get ownerLength(){return Je[this.signatureType].pubLength}get rawTarget(){let e=this.getTargetStart();return this.binary[e]==1?this.binary.subarray(e+1,e+33):is.Buffer.alloc(0)}get target(){return cn.default.encode(this.rawTarget)}get rawAnchor(){let e=this.getAnchorStart();return this.binary[e]==1?this.binary.subarray(e+1,e+33):is.Buffer.alloc(0)}get anchor(){return cn.default.encode(this.rawAnchor)}get rawTags(){let e=this.getTagsStart(),r=pt(this.binary.subarray(e+8,e+16));return this.binary.subarray(e+16,e+16+r)}get tags(){let e=this.getTagsStart();if(pt(this.binary.subarray(e,e+8))==0)return[];let n=pt(this.binary.subarray(e+8,e+16));return ns(is.Buffer.from(this.binary.subarray(e+16,e+16+n)))}get tagsB64Url(){return this.tags.map(r=>({name:cn.default.encode(r.name),value:cn.default.encode(r.value)}))}getStartOfData(){let e=this.getTagsStart(),r=this.binary.subarray(e+8,e+16),n=pt(r);return e+16+n}get rawData(){let e=this.getTagsStart(),r=this.binary.subarray(e+8,e+16),n=pt(r),i=e+16+n;return this.binary.subarray(i,this.binary.length)}get data(){return cn.default.encode(this.rawData)}getRaw(){return this.binary}async sign(e){return this._id=await Vc(this,e),this.rawId}async setSignature(e){this.binary.set(e,2),this._id=is.Buffer.from(await mt().hash(e))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map(e=>({name:cn.default.encode(e.name),value:cn.default.encode(e.value)})),data:this.data}}static async verify(e){if(e.byteLength<Zc)return!1;let r=new t(e),n=r.signatureType,i=r.getTagsStart(),a=pt(e.subarray(i,i+8)),d=e.subarray(i+8,i+16),v=pt(d);if(v>zc)return!1;if(a>0)try{if(ns(is.Buffer.from(e.subarray(i+16,i+16+v))).length!==a)return!1}catch{return!1}let y=wf[n],m=await Af(r);return await y.verify(r.rawOwner,m,r.rawSignature)}async getSignatureData(){return Af(this)}getTagsStart(){let e=this.getTargetStart(),r=this.binary[e]==1,n=e+(r?33:1),i=this.binary[n]==1;return n+=i?33:1,n}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let e=this.getTargetStart()+1,r=this.binary[this.getTargetStart()]==1;return e+=r?32:0,e}},as=Kc;var L3=require("crypto"),ii=32,jc=class{length;items;binary;constructor(e){this.binary=e,this.length=this.getDataItemCount(),this.items=this.getItems()}getRaw(){return this.binary}get(e){if(typeof e=="number"){if(e>=this.length)throw new RangeError("Index out of range");return this.getByIndex(e)}else return this.getById(e)}getSizes(){let e=[];for(let r=ii;r<ii+64*this.length;r+=64)e.push(pt(this.binary.subarray(r,r+32)));return e}getIds(){let e=[];for(let r=ii;r<ii+64*this.length;r+=64){let n=this.binary.subarray(r+32,r+64);if(n.length===0)throw new Error("Invalid bundle, id specified in headers doesn't exist");e.push(Tf.default.encode(n))}return e}getIdBy(e){if(e>this.length-1)throw new RangeError("Index of bundle out of range");let r=64+64*e;return Tf.default.encode(this.binary.subarray(r,r+32))}async toTransaction(e,r,n){let i=await r.createTransaction({data:this.binary,...e},n);return i.addTag("Bundle-Format","binary"),i.addTag("Bundle-Version","2.0.0"),i}async verify(){for(let e of this.items){let r=await e.isValid(),n=(0,Tf.default)((0,L3.createHash)("sha256").update(e.rawSignature).digest());if(!(r&&e.id===n))return!1}return!0}getOffset(e){let r=0;for(let n=ii;n<ii+64*this.length;n+=64){let i=pt(this.binary.subarray(n,n+32));r+=i;let a=this.binary.subarray(n+32,n+64);if(Buffer.compare(a,e)===0)return{startOffset:r,size:i}}return{startOffset:-1,size:-1}}getByIndex(e){let r=0,n=this.getBundleStart(),i=0,a,d;for(let B=ii;B<ii+64*this.length;B+=64){if(a=pt(this.binary.subarray(B,B+32)),i++===e){d=this.binary.subarray(B+32,B+64);break}r+=a}let v=n+r,y=this.binary.subarray(v,v+a),m=new as(y);return m.rawId=d,m}getById(e){let r=Tf.default.toBuffer(e),n=this.getOffset(r);if(n.startOffset===-1)throw new Error("Transaction not found");let a=this.getBundleStart()+n.startOffset;return new as(this.binary.subarray(a,a+n.size))}getDataItemCount(){return pt(this.binary.subarray(0,32))}getBundleStart(){return 32+64*this.length}getItems(){let e=new Array(this.length),r=0,n=this.getBundleStart(),i=0;for(let a=ii;a<ii+64*this.length;a+=64){let d=pt(this.binary.subarray(a,a+32)),v=this.binary.subarray(a+32,a+64);if(v.length===0)throw new Error("Invalid bundle, id specified in headers doesn't exist");let y=n+r,m=this.binary.subarray(y,y+d);r+=d;let B=new as(m);B.rawId=v,e[i]=B,i++}return e}},$h=jc;function qE(t){return new $h(t)}async function GE(t,e){let r=new Uint8Array(64*t.length),n=await Promise.all(t.map(async(a,d)=>{let v=a.isSigned()?a.rawId:await Vc(a,e),y=new Uint8Array(64);return y.set(Xc(a.getRaw().byteLength),0),y.set(v,32),r.set(y,64*d),a.getRaw()})).then(a=>Buffer.concat(a)),i=Buffer.concat([Buffer.from(Xc(t.length)),Buffer.from(r),n]);return new $h(i)}async function R3(t,e){let r=await Af(t),n=await e.sign(r),i=await mt().hash(n);return{signature:Buffer.from(n),id:Buffer.from(i)}}async function Vc(t,e){let{signature:r,id:n}=await R3(t,e);return t.getRaw().set(r,2),n}var gk=A(M(),1),F3=A(kr(),1);function Ef(t,e,r){let n=e.publicKey,i=r?.target?F3.default.toBuffer(r.target):null,a=1+(i?.byteLength??0),d=r?.anchor?Buffer.from(r.anchor):null,v=1+(d?.byteLength??0),y=(r?.tags?.length??0)>0?Yh(r?.tags):null,m=16+(y?y.byteLength:0),B=Buffer.from(t),P=B.byteLength,D=2+e.signatureLength+e.ownerLength+a+v+m+P,F=Buffer.alloc(D);if(F.set(Wh(e.signatureType),0),F.set(new Uint8Array(e.signatureLength).fill(0),2),n.byteLength!==e.ownerLength)throw new Error(`Owner must be ${e.ownerLength} bytes, but was incorrectly ${n.byteLength}`);F.set(n,2+e.signatureLength);let C=2+e.signatureLength+e.ownerLength;if(F[C]=i?1:0,i){if(i.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${i.byteLength}`);F.set(i,C+1)}let q=C+a,W=q+1;if(F[q]=d?1:0,d){if(W+=d.byteLength,d.byteLength!==32)throw new Error("Anchor must be 32 bytes");F.set(d,q+1)}F.set(Gc(r?.tags?.length??0),W);let K=Gc(y?.byteLength??0);F.set(K,W+8),y&&F.set(y,W+16);let ne=W+m;return F.set(B,ne),new as(F)}var vk=A(M(),1);var mk=A(M(),1),e1=class{signatureType;rawSignature;signature;signatureLength;rawOwner;owner;ownerLength;rawTarget;target;rawAnchor;anchor;rawTags;tags;rawData;data;static async verify(...e){throw new Error("You must implement `verify`")}};var wk=A(M(),1);var Ak=A(M(),1);var r1={};ou(r1,{default:()=>zE,processStream:()=>O3,streamExportForTesting:()=>KE,streamSigner:()=>XE});var zk=A(M(),1),Qc=require("stream");var Va=A(kr(),1);var D3=require("crypto");async function O3(t){let e=I3(t),r=(await e.next()).value;r=await Ar(e,r,32);let n=pt(r.subarray(0,32));r=r.subarray(32);let i=64*n;r=await Ar(e,r,i);let a=new Array(n);for(let y=0;y<i;y+=64)a[y/64]=[pt(r.subarray(y,y+32)),(0,Va.default)(Buffer.from(r.subarray(y+32,y+64)))];r=r.subarray(i);let d=32+i,v=[];for(let[y,m]of a){r=await Ar(e,r,Zc),r=await Ar(e,r,2);let B=pt(r.subarray(0,2));r=r.subarray(2);let{sigLength:P,pubLength:D,sigName:F}=Je[B];r=await Ar(e,r,P);let C=r.subarray(0,P);r=r.subarray(P),r=await Ar(e,r,D);let q=r.subarray(0,D);r=r.subarray(D),r=await Ar(e,r,1);let W=r[0]===1;W&&(r=await Ar(e,r,33));let K=W?r.subarray(1,33):Buffer.allocUnsafe(0);r=r.subarray(W?33:1),r=await Ar(e,r,1);let ne=r[0]===1;ne&&(r=await Ar(e,r,33));let $=ne?r.subarray(1,33):Buffer.allocUnsafe(0);r=r.subarray(ne?33:1),r=await Ar(e,r,8);let ae=pt(r.subarray(0,8));r=r.subarray(8),r=await Ar(e,r,8);let ie=pt(r.subarray(0,8));r=r.subarray(8),r=await Ar(e,r,ie);let ee=r.subarray(0,ie),ce=ae!==0&&ie!==0?ns(Buffer.from(ee)):[];if(ce.length!==ae)throw new Error("Tags lengths don't match");r=r.subarray(ie);let te=new Qc.Transform;te._transform=function(l,f,c){this.push(l),c()};let Y=Ci([(0,$e.stringToBuffer)("dataitem"),(0,$e.stringToBuffer)("1"),(0,$e.stringToBuffer)(B.toString()),q,K,$,ee,te]),S=2+P+D+(W?33:1)+(ne?33:1)+16+ie,s=y-S;if(r.byteLength>s)te.write(r.subarray(0,s)),r=r.subarray(s);else{let l=r.byteLength;for(te.write(r);s>l;){if(r=(await e.next()).value,!r)throw new Error(`Not enough data bytes expected: ${s} received: ${l}`);l+=r.byteLength,l>s?te.write(r.subarray(0,r.byteLength-(l-s))):te.write(r)}r=r.subarray(r.byteLength-(l-s))}if(te.end(),m!==(0,Va.default)((0,D3.createHash)("sha256").update(C).digest()))throw new Error("ID doesn't match signature");if(!await wf[B].verify(q,await Y,C))throw new Error("Invalid signature");v.push({id:m,sigName:F,signature:(0,Va.default)(Buffer.from(C)),target:(0,Va.default)(Buffer.from(K)),anchor:(0,Va.default)(Buffer.from($)),owner:(0,Va.default)(Buffer.from(q)),tags:ce,dataOffset:d+S,dataSize:s}),d+=S+s}return v}async function XE(t,e,r,n){let i=Ef("",r,n),a=new Qc.PassThrough,d=[(0,$e.stringToBuffer)("dataitem"),(0,$e.stringToBuffer)("1"),(0,$e.stringToBuffer)(i.signatureType.toString()),i.rawOwner,i.rawTarget,i.rawAnchor,i.rawTags,t],v=await Ci(d),y=Buffer.from(await r.sign(v));return i.setSignature(y),a.write(i.getRaw()),e.pipe(a)}async function Ar(t,e,r){if(e.byteLength>=r)return e;let{done:n,value:i}=await t.next();if(n&&!i)throw new Error("Invalid buffer");return Ar(t,Buffer.concat([Buffer.from(e),Buffer.from(i)]),r)}async function*I3(t){for await(let e of t)yield e}var zE=O3,KE={readBytes:Ar,getReader:I3};var ZE={...t1,stream:r1};globalThis.arbundles??=ZE;function ja(t){return async e=>{if(dn(e))return e;if(!t.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await VE(t,{data:e})}catch(r){throw new Error(r.message??"Error resolving transaction")}}}async function VE(t,e){let r=null,n=null,i=null;if(typeof e.data=="string"&&(r=Buffer.from(p1(e.data),"base64"),n=h1(e.data),i=b1(r)),e.data instanceof File&&(r=new Uint8Array(await e.data.arrayBuffer()),n=e.data.type,i=e.data.size),r&&n&&i)if(i<Number(cu.dispatchUploadSize))try{let a=await t.arweave.createTransaction({data:r},"use_wallet");return a.addTag(We.keys.contentType,n),e.tags&&e.tags.length>0&&e.tags.forEach(v=>a.addTag(v.name,v.value)),(await global.window.arweaveWallet.dispatch(a)).id}catch(a){throw new Error(a.message??"Error dispatching transaction")}else try{let a=await jE(e.data,{tags:[{name:"Content-Type",value:n},{name:"App-Name",value:"@permaweb/libs"}]},{apiUrl:cu.node1,token:"arweave",chunkSize:5242880,batchSize:3});return console.log(a),console.log("Uploaded dataItem ID:",a.id),a.id}catch(a){throw new Error(a.message??"Error uploading transaction")}else throw new Error("Error preparing transaction data")}async function jE(t,e,r){let{apiUrl:n,token:i,chunkSize:a,batchSize:d=3}=r,v=new Za(window.arweaveWallet),y=await v.signer.getActivePublicKey();v.publicKey=Buffer.from(y,"base64");let m=new Uint8Array(await t.arrayBuffer()),B=Ef(m,v,{...e,anchor:e.anchor||(()=>{let S=new Uint8Array(32);return crypto.getRandomValues(S),btoa(String.fromCharCode(...S)).replace(/\+/g,"-").replace(/\//g,"_").slice(0,32)})()});await B.sign(v);let P=B.getRaw(),D=new Blob([P],{type:"application/octet-stream"}),F={"x-chunking-version":"2"},C=await fetch(`${n}/chunks/${i}/-1/-1`,{headers:F});if(!C.ok)throw new Error(`Failed to get upload ID: ${C.status} ${await C.text()}`);let q=await C.json(),W=q.id;if(a<q.min||a>q.max)throw new Error(`Configured chunkSize ${a} is out of allowed range ${q.min}-${q.max}`);let K=D.size,ne=[];for(let S=0;S<K;S+=a)ne.push(S);let $=new Set;(q.chunks??[]).forEach(([S])=>$.add(Number(S)));let ae=ne.filter(S=>S>0&&!$.has(S)),ie=$.has(0)?[]:[0],ee=ae.concat(ie),ce=S=>new Promise(s=>setTimeout(s,S));for(let S=0;S<ee.length;S+=d){let s=ee.slice(S,S+d);await Promise.all(s.map(async u=>{let f=await D.slice(u,u+a).arrayBuffer(),c=null;for(let g=1;g<=3;g++)try{let x=await fetch(`${n}/chunks/${i}/${W}/${u}`,{method:"POST",headers:{"Content-Type":"application/octet-stream",...F},body:f});if(!x.ok){let h=await x.text();throw x.status===402?new Error(`402 payment required: ${h}`):new Error(`Chunk upload error ${x.status}: ${h}`)}return}catch(x){if(c=x,g<3){await ce(1e3*g);continue}}throw c}))}let te={"Content-Type":"application/octet-stream",...F},Y=await fetch(`${n}/chunks/${i}/${W}/-1`,{method:"POST",headers:te});if(!Y.ok){let S=await Y.text();throw new Error(`Finalizing upload failed ${Y.status}: ${S}`)}return Y.json()}var oN=A(M(),1);var k3={},aN=A(M(),1);var XN=A(M(),1);var vN=A(M(),1);function Wc(t){return async(e,r)=>{let n=$E(e);if(n)throw new Error(n);let i=d1[e.contentType]?.serialize(e.data)??e.data,a=YE(e);try{return await sa(t,{tags:a,data:i},r?v=>r(v):void 0)}catch(d){throw new Error(d.message??"Error creating asset")}}}async function n1(t,e,r){try{let n=Bn(await oa(t,{processId:e,path:"asset",fallbackAction:"Info"}));if(r?.useGateway){let i=await Ir({gateway:Sr.goldsky,ids:[e],tags:null,owners:null,cursor:null});return{...i?.data?.[0]?Yc(i.data[0]):{},...n}}return{id:e,...n}}catch(n){throw new Error(n.message||"Error fetching atomic asset")}}function N3(t){return async(e,r)=>await n1(t,e,r)}async function J3(t){try{let e=await Ir({gateway:Sr.arweave,ids:t??null,tags:null,owners:null,cursor:null});return e&&e.data.length?e.data.map(r=>Yc(r)):null}catch(e){throw new Error(e)}}function Yc(t){let e={id:t.node.id,owner:t.node.owner.address};for(let r of t.node.tags){let n=r.name,a=(n.startsWith(`${We.keys.bootloader}-`)?n.slice(`${We.keys.bootloader}-`.length):n).split("-").map((v,y)=>y===0?v.toLowerCase():v.charAt(0).toUpperCase()+v.slice(1).toLowerCase()).join(""),d;try{d=JSON.parse(r.value)}catch{d=r.value.toString()}e[a]=d}return e}function YE(t){let e=[{name:We.keys.onBoot,value:t.src??vt.src.asset},{name:We.keys.creator,value:t.creator},{name:We.keys.assetType,value:t.assetType},{name:We.keys.contentType,value:t.contentType},{name:We.keys.implements,value:"ANS-110"},{name:We.keys.dateCreated,value:new Date().getTime().toString()},mr("Name",t.name),mr("Description",t.description),mr("Topics",JSON.stringify(t.topics)),mr("Ticker","ATOMIC"),mr("Denomination",t.denomination?.toString()??"1"),mr("TotalSupply",t.supply?.toString()??"1"),mr("Transferable",t.transferable?.toString()??"true"),mr("Creator",t.creator)];if(t.metadata)for(let r in t.metadata)e.push(mr(Wa(r),t.metadata[r].toString()));if(t.users)for(let r of t.users)e.push({name:"Auth-User",value:r});return t.tags&&t.tags.forEach(r=>e.push(r)),e}function $E(t){if(typeof t!="object"||t===null)return"The provided arguments are invalid or empty.";let e=["name","description","topics","creator","data","contentType","assetType"];for(let r of e)if(!(r in t))return`Missing field '${r}'`;return typeof t.name!="string"||t.name.trim()===""?"Name is required":typeof t.description!="string"?"The description must be a valid string":!Array.isArray(t.topics)||t.topics.length===0?"Topics are required":typeof t.creator!="string"||t.creator.trim()===""?"Creator is required":t.data===void 0||t.data===null?"Data field is required":typeof t.contentType!="string"||t.contentType.trim()===""?"Content type must be a non-empty string":typeof t.assetType!="string"||t.assetType.trim()===""?"Type must be a non-empty string":"supply"in t&&(typeof t.supply!="number"||t.supply<=0)?"Supply must be a positive number":"denomination"in t&&(typeof t.denomination!="number"||t.denomination<=0)?"Denomination must be a positive number":"transferable"in t&&typeof t.transferable!="boolean"?"Transferable must be a boolean value":"metadata"in t&&typeof t.metadata!="object"?"Metadata must be an object":"tags"in t&&(!Array.isArray(t.tags)||t.tags.some(r=>typeof r!="object"))?"Tags must be an array of objects":"src"in t&&typeof t.src!="string"?"Source must be a valid string":null}var MN=A(M(),1);var e_="eXCtpVbcd_jZ0dmU2PZ8focaKxBGECBQ8wMib7sIVPo",i1="lJovHqM9hwNjHV5JoY9NGWtt0WD-5D4gOqNL2VWW5jk";function U3(t){return async(e,r)=>{if(!t.signer)throw new Error("No signer provided");let n=ja(t),i=new Date().getTime().toString(),a=[{name:We.keys.creator,value:e.creator},{name:We.keys.ans110.title,value:os(e.title)},{name:We.keys.name,value:os(e.title)},{name:We.keys.ans110.description,value:os(e.description)}],d=null,v=null;try{d=e.banner?await n(e.thumbnail):i1,v=e.banner?await n(e.banner):e_,e.thumbnail&&a.push({name:We.keys.thumbnail,value:d}),e.banner&&a.push({name:We.keys.banner,value:v})}catch(B){console.error(B)}let y=await fetch(Ya(vt.src.collection));if(!y.ok)throw new Error("Unable to fetch process src");let m=await y.text();m=m.replace(/'<NAME>'/g,uu(e.title)),m=m.replace(/'<DESCRIPTION>'/g,uu(e.description)),m=m.replace(/<CREATOR>/g,e.creator),m=m.replace(/<THUMBNAIL>/g,d||i1),m=m.replace(/<BANNER>/g,v||i1),m=m.replace(/<DATECREATED>/g,i),m=m.replace(/<LASTUPDATE>/g,i);try{let B=await sa(t,{tags:a},r?P=>r(P):void 0);if(hn("Sending eval message to collection..."),r&&r("Sending eval message to collection..."),await t.ao.message({process:B,signer:t.signer,tags:[{name:"Action",value:"Eval"}],data:m}),!e.skipRegistry){hn("Sending collection to registry..."),r&&r("Sending collection to registry...");let P=[{name:"Action",value:"Add-Collection"},{name:"CollectionId",value:B},{name:"Name",value:os(e.title)},{name:"Creator",value:e.creator},{name:"DateCreated",value:i}];v&&P.push({name:"Banner",value:v}),d&&P.push({name:"Thumbnail",value:d}),await t.ao.message({process:vt.collectionRegistry,signer:t.signer,tags:P})}if(!e.skipActivity){hn("Creating collection activity process..."),r&&r("Creating collection activity process...");let P=[{name:"CollectionId",value:B},{name:"DateCreated",value:i},{name:"UCM-Process",value:"Collection-Activity"},{name:"On-Boot",value:vt.src.collectionActivity}],D=await sa(t,{tags:P},r?F=>r(F):void 0);hn("Adding activity to collection process..."),r&&r("Adding activity to collection process..."),await t.ao.message({process:B,signer:t.signer,tags:[{name:"Action",value:"Eval"}],data:`ActivityProcess = '${D}'`})}return B}catch(B){throw new Error(B.message??"Error creating collection")}}}function H3(t){return async e=>await Cn(t,{processId:e.creator,action:"Run-Action",tags:[{name:"ForwardTo",value:e.collectionId},{name:"ForwardAction",value:"Update-Assets"}],data:{Target:e.collectionId,Action:"Update-Assets",Input:{AssetIds:e.assetIds,UpdateType:e.updateType}}})}function q3(t){return async e=>{let r=await oa(t,{processId:e,path:"collection",fallbackAction:"Info"});return r?Bn(r):null}}function G3(t){return async e=>{let r=e.creator?"Get-Collections-By-User":"Get-Collections",n=await Pf(t,{processId:vt.collectionRegistry,action:r,tags:e.creator?[{name:"Creator",value:e.creator}]:null});return n&&n.Collections&&n.Collections.length?n.Collections.map(a=>({id:a.Id,title:a.Name.replace(/\[|\]/g,""),description:a.Description,creator:a.Creator,dateCreated:a.DateCreated,banner:a.Banner,thumbnail:a.Thumbnail})):null}}var PN=A(M(),1);function X3(t){let e=Wc(t);return async(r,n)=>{let i=r.tags?r.tags:[];i.push({name:"Data-Source",value:r.parentId}),i.push({name:"Root-Source",value:r.rootId??r.parentId});let a={name:`Comment on ${r.parentId}`,description:`Comment on ${r.parentId}`,topics:["comment"],creator:r.creator,data:r.content,contentType:"text/plain",assetType:"comment",tags:i};return e(a,n)}}function z3(t){return async e=>{try{let r=await n1(t,e,{useGateway:!0}),n=r?.dataSource,i=r?.rootSource;if(!n||!i)throw new Error("dataSource and rootSource must be present on a comment");return{content:await Z3(e),parentId:n,rootId:i}}catch(r){throw new Error(r.message??"Error getting comment")}}}function K3(t){return async e=>{if(!e.parentId&&!e.rootId)throw new Error("Must provide either parentId or rootId");let r=[];e.parentId&&r.push({name:"Data-Source",values:[e.parentId??""]}),e.rootId&&r.push({name:"Root-Source",values:[e.rootId??""]});let n=await Ir({gateway:Sr.goldsky,ids:null,tags:r,owners:null,cursor:null}),i=[];n&&n.data.length&&(i=n.data.map(d=>Yc(d)));let a=[];for(let d of i){let v=d?.dataSource,y=d?.rootSource;if(!v||!y)throw new Error("dataSource and rootSource must be present on a comment");a.push({id:d.id,content:await Z3(d.id),parentId:v,rootId:y})}return a}}async function Z3(t){try{return await(await fetch(Ya(t))).text()}catch(e){throw new Error(e.message??"Error getting comment data")}}var GN=A(M(),1);var IN=A(M(),1);function $c(t){return async(e,r)=>{try{let n=[{name:We.keys.onBoot,value:vt.src.zone.id}];return e.tags&&e.tags.length&&e.tags.forEach(a=>n.push(a)),await sa(t,{data:e.data,tags:n},r?a=>r(a):void 0)}catch(n){throw new Error(n.message??"Error creating zone")}}}function eu(t){return async(e,r)=>{try{let n=Object.entries(e).map(([a,d])=>({key:a,value:d}));return await Cn(t,{processId:r,action:"Zone-Update",data:n})}catch(n){throw new Error(n)}}}function V3(t){return async(e,r)=>{try{return await Cn(t,{processId:r,action:"Zone-Append",tags:[{name:"Path",value:e.path}],data:e.data})}catch(n){throw new Error(n)}}}function j3(t){return async(e,r)=>{if(!dn(r))throw new Error("Invalid zone address");let i=[];for(let a of e){if(!dn(a.granteeId))throw new Error("Invalid granteeId address");if(a.type!=="wallet"&&a.type!=="process")throw new Error("Invalid role type");i.push({Id:a.granteeId,Roles:a.roles,Type:a.type,SendInvite:a.sendInvite})}try{return await Cn(t,{processId:r,action:"Role-Set",tags:[],data:i})}catch(a){throw new Error(a)}}}function Q3(t){return async(e,r)=>{if(!(dn(r)&&dn(e.zoneToJoinId)))throw new Error("Invalid zone address");let i=[{name:"ZoneId",value:e.zoneToJoinId}];e.path&&i.push({name:"Path",value:e.path});try{return await Cn(t,{processId:r,action:"Zone-Join",tags:i})}catch(a){throw new Error(a)}}}function tu(t){return async e=>{try{return hn(`Updating zone to version ${vt.src.zone.version} with source ${vt.src.zone.id}`),await ss(t,{processId:e.zoneId,evalTxId:vt.src.zone.id}),await ss(t,{processId:e.zoneId,evalSrc:`Zone.Version = '${vt.src.zone.version}'; SyncState()`})}catch(r){throw new Error(r)}}}function ru(t){return async e=>{try{let r=await oa(t,{processId:e,path:"zone",fallbackAction:"Info"});return Bn(r)}catch(r){throw new Error(r.message??"Error getting zone")}}}function W3(t){let e=$c(t),r=ja(t);return async(n,i)=>{let a=null,d=[{name:We.keys.dataProtocol,value:We.values.zone},{name:We.keys.zoneType,value:We.values.user}],v=async y=>{let m=y.toLowerCase();if(n[m])try{let B=await r(n[m]);d.push(mr(y,B))}catch(B){i?i(`Failed to resolve ${y}: ${B.message}`):console.error(B)}};n.username&&d.push(mr("Username",n.username)),n.displayName&&d.push(mr("DisplayName",n.displayName)),n.description&&d.push(mr("Description",n.description)),await Promise.all([v("Thumbnail"),v("Banner")]);try{a=await e({tags:d},i)}catch(y){throw new Error(y.message??"Error creating profile")}return a}}function Y3(t){let e=eu(t),r=ja(t);return async(n,i,a)=>{if(i){let d={Username:n.username,DisplayName:n.displayName,Description:n.description};if(n.thumbnail)try{d.Thumbnail=await r(n.thumbnail)}catch(v){a&&a(`Failed to resolve thumbnail: ${v.message}`)}if(n.banner)try{d.Banner=await r(n.banner)}catch(v){a&&a(`Failed to resolve banner: ${v.message}`)}try{return await e(d,i)}catch(v){throw new Error(v.message??"Error creating profile")}}else throw new Error("No profile provided")}}function $3(t){let e=tu(t);return async r=>{try{return await e({zoneId:r.profileId})}catch(n){throw new Error(n)}}}function a1(t){let e=ru(t);return async r=>{try{let n=await e(r);if(!n)throw new Error("Error fetching profile - Not found");return{id:r,owner:n.owner,assets:n.assets,roles:n.roles,invites:n.invites,version:n.version,...n.store}}catch(n){throw new Error(n.message??"Error fetching profile")}}}function e8(t){let e=a1(t);return async r=>{try{let n=await Ir({gateway:Sr.goldsky,tags:[{name:We.keys.dataProtocol,values:[We.values.zone]},{name:We.keys.zoneType,values:[We.values.user]}],owners:[r]});return n?.data?.length>0?(n.data.sort((i,a)=>{let d=i.node.block?.timestamp??0;return(a.node.block?.timestamp??0)-d}),await e(n.data[0].node.id)):{id:null}}catch(n){throw new Error(n.message??"Error fetching profile")}}}var r_=vt.src.zone.version;function n_(t){return{createZone:$c(t),updateZone:eu(t),addToZone:V3(t),getZone:ru(t),setZoneRoles:j3(t),joinZone:Q3(t),updateZoneVersion:tu(t),createProfile:W3(t),updateProfile:Y3(t),updateProfileVersion:$3(t),getProfileById:a1(t),getProfileByWalletAddress:e8(t),createAtomicAsset:Wc(t),getAtomicAsset:N3(t),getAtomicAssets:J3,createComment:X3(t),getComment:z3(t),getComments:K3(t),createCollection:U3(t),updateCollectionAssets:H3(t),getCollection:q3(t),getCollections:G3(t),resolveTransaction:ja(t),getGQLData:Ir,getAggregatedGQLData:g1,createProcess:w1(t),readProcess:y1(t),readState:m1(t),sendMessage:x1(t),mapFromProcessCase:Bn,mapToProcessCase:Wa}}var i_={init:n_};0&&(module.exports={CurrentZoneVersion,Types});
|
|
42
|
+
nonce: bundlr`),Buffer.from(i))}};var UO=A(M(),1);var za=class{_publicKey;ownerLength=Je[Oe.MULTIAPTOS].pubLength;signatureLength=Je[Oe.MULTIAPTOS].sigLength;signatureType=Oe.MULTIAPTOS;collectSignatures;provider;constructor(e,r){this._publicKey=e,this.collectSignatures=r}get publicKey(){return this._publicKey}async sign(e){let{signatures:r,bitmap:n}=await this.collectSignatures(e),i=128,a=new Uint8Array([0,0,0,0]),d=new Set;n.forEach(m=>{if(m>=32)throw new Error(`Invalid bit value ${m}.`);if(d.has(m))throw new Error("Duplicated bits detected.");d.add(m);let B=Math.floor(m/8),P=a[B];P|=i>>m%8,a[B]=P});let v=Buffer.alloc(this.signatureLength),y=0;for(let m=0;m<32;m++)n.includes(m)&&v.set(r[y++],m*64);return v.set(a,this.signatureLength-4),v}static async verify(e,r,n){let a=Je[Oe.MULTIAPTOS].sigLength-4,d=n.slice(0,a),v=n.slice(a),y=!1;for(let m=0;m<32;m++){let B=Math.floor(m/8),P=m-B*8;if((v[B]&128>>P)!==0){let F=d.slice(m*64,(m+1)*64),C=e.slice(m*32,(m+1)*32);await Bi(Buffer.from(F),Buffer.from(r),Buffer.from(C))||(y=!0)}}return!y}};var zO=A(M(),1),qc=A(tf(),1);var Ka=class extends Or{ownerLength=Je[Oe.TYPEDETHEREUM].pubLength;signatureLength=Je[Oe.TYPEDETHEREUM].sigLength;signatureType=Oe.TYPEDETHEREUM;address;signer;constructor(e){super(e),this.address="0x"+df(super.publicKey.slice(1)).slice(-20).toString("hex"),this.signer=new qc.Wallet(e)}get publicKey(){return Buffer.from(this.address)}async sign(e){let r=await this.signer._signTypedData(xf,mf,{address:this.address,"Transaction hash":e});return Buffer.from(r.slice(2),"hex")}static async verify(e,r,n){let i=e.toString(),a=(0,qc.verifyTypedData)(xf,mf,{address:i,"Transaction hash":r},n);return i.toLowerCase()===a.toLowerCase()}},xf={name:"Bundlr",version:"1"},mf={Bundlr:[{name:"Transaction hash",type:"bytes"},{name:"address",type:"address"}]};var jO=A(M(),1);var B3=A(tf(),1);var Qh=class{ownerLength=Je[Oe.TYPEDETHEREUM].pubLength;signatureLength=Je[Oe.TYPEDETHEREUM].sigLength;signatureType=Oe.TYPEDETHEREUM;address;signer;publicKey;constructor(e){this.signer=e.getSigner()}async ready(){this.address=(await this.signer.getAddress()).toString().toLowerCase(),this.publicKey=Buffer.from(this.address)}async sign(e){let r=await this.signer._signTypedData(xf,mf,{address:this.address,"Transaction hash":e});return Buffer.from(r.slice(2),"hex")}static verify(e,r,n){let i=e.toString(),a=(0,B3.verifyTypedData)(xf,mf,{address:i,"Transaction hash":r},n);return i.toLowerCase()===a.toLowerCase()}};var $O=A(M(),1);var C3=A(kr(),1);var Za=class{signer;publicKey;ownerLength=Je[Oe.ARWEAVE].pubLength;signatureLength=Je[Oe.ARWEAVE].sigLength;signatureType=Oe.ARWEAVE;constructor(e){this.signer=e}async setPublicKey(){let e=await this.signer.getActivePublicKey();this.publicKey=C3.default.toBuffer(e)}async sign(e){this.publicKey||await this.setPublicKey();let r={name:"RSA-PSS",saltLength:32},n=await this.signer.signature(e,r);return new Uint8Array(Object.values(n).map(a=>+a))}static async verify(e,r,n){return await mt().verify(e,r,n)}};var nI=A(M(),1);var yf=class extends Or{signatureType=Oe.KYVE};var wf={1:da,2:Br,3:Or,4:Ga,5:Xa,6:za,7:Ka};var BI=A(M(),1);var HI=A(M(),1);async function UE(t){return Ci([(0,$e.stringToBuffer)("dataitem"),(0,$e.stringToBuffer)("1"),(0,$e.stringToBuffer)(t.signatureType.toString()),t.rawOwner,t.rawTarget,t.rawAnchor,t.rawTags,t.rawData])}var Af=UE;var lk=A(M(),1);var GI=A(M(),1);function Sf(t,e){let r=new Uint8Array(t);if(e<0)throw new Error("Array is unsigned, cannot represent -ve numbers");if(e>2**(t*8)-1)throw new Error(`Number ${e} is too large for an array of ${t} bytes`);for(let n=0;n<r.length;n++){let i=e&255;r[n]=i,e=(e-i)/256}return r}function Gc(t){return Sf(8,t)}function Wh(t){return Sf(2,t)}function HE(t){return Sf(16,t)}function Xc(t){return Sf(32,t)}function pt(t){let e=0;for(let r=t.length-1;r>=0;r--)e=e*256+t[r];return e}var ak=A(M(),1),Tf=A(kr(),1);var tk=A(M(),1);var cn=A(kr(),1),is=require("buffer");var KI=A(M(),1);var Mf=class{buf;pos;constructor(e=Buffer.alloc(zc),r=0){this.buf=e,this.pos=r}writeTags(e){if(!Array.isArray(e))throw new Error("input must be array");let r=e.length,n;if(r)for(this.writeLong(r),n=0;n<r;n++){let i=e[n];if(typeof i?.name!="string"||typeof i?.value!="string")throw new Error(`Invalid tag format for ${i}, expected {name:string, value: string}`);this.writeString(i.name),this.writeString(i.value)}this.writeLong(0)}toBuffer(){let e=Buffer.alloc(this.pos);if(this.pos>this.buf.length)throw new Error(`Too many tag bytes (${this.pos} > ${this.buf.length})`);return this.buf.copy(e,0,0,this.pos),e}writeLong(e){let r=this.buf,n,i;if(e>=-1073741824&&e<1073741824){i=e>=0?e<<1:~e<<1|1;do r[this.pos]=i&127,i>>=7;while(i&&(r[this.pos++]|=128))}else{n=e>=0?e*2:-e*2-1;do r[this.pos]=n&127,n/=128;while(n>=1&&(r[this.pos++]|=128))}this.pos++,this.buf=r}writeString(e){let r=Buffer.byteLength(e),n=this.buf;this.writeLong(r);let i=this.pos;if(this.pos+=r,!(this.pos>n.length)){if(r>64)this.buf.write(e,this.pos-r,r,"utf8");else{let a,d,v,y;for(a=0,d=r;a<d;a++)v=e.charCodeAt(a),v<128?n[i++]=v:v<2048?(n[i++]=v>>6|192,n[i++]=v&63|128):(v&64512)===55296&&((y=e.charCodeAt(a+1))&64512)===56320?(v=65536+((v&1023)<<10)+(y&1023),a++,n[i++]=v>>18|240,n[i++]=v>>12&63|128,n[i++]=v>>6&63|128,n[i++]=v&63|128):(n[i++]=v>>12|224,n[i++]=v>>6&63|128,n[i++]=v&63|128)}this.buf=n}}readLong(){let e=0,r=0,n=this.buf,i,a,d,v;do i=n[this.pos++],a=i&128,e|=(i&127)<<r,r+=7;while(a&&r<28);if(a){d=e,v=268435456;do i=n[this.pos++],d+=(i&127)*v,v*=128;while(i&128);return(d%2?-(d+1):d)/2}return e>>1^-(e&1)}skipLong(){let e=this.buf;for(;e[this.pos++]&128;);}readTags(){let e=[],r;for(;r=this.readLong();)for(r<0&&(r=-r,this.skipLong());r--;){let n=this.readString(),i=this.readString();e.push({name:n,value:i})}return e}readString(){let e=this.readLong(),r=this.pos,n=this.buf;if(this.pos+=e,this.pos>n.length)throw new Error("TAP Position out of range");return this.buf.slice(r,r+e).toString()}};function Yh(t){if(t?.length===0)return Buffer.allocUnsafe(0);let e=new Mf;return e.writeTags(t),e.toBuffer()}function ns(t){return new Mf(t).readTags()}var P3=require("crypto"),Zc=80,zc=4096,Kc=class t{binary;_id;constructor(e){this.binary=e}static isDataItem(e){return e.binary!==void 0}get signatureType(){let e=pt(this.binary.subarray(0,2));if(Oe?.[e]!==void 0)return e;throw new Error("Unknown signature type: "+e)}async isValid(){return t.verify(this.binary)}get id(){return cn.default.encode(this.rawId)}set id(e){this._id=cn.default.toBuffer(e)}get rawId(){return(0,P3.createHash)("sha256").update(this.rawSignature).digest()}set rawId(e){this._id=e}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return cn.default.encode(this.rawSignature)}set rawOwner(e){if(e.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${e.byteLength} bytes.`);this.binary.set(e,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return Je[this.signatureType].sigLength}get owner(){return cn.default.encode(this.rawOwner)}get ownerLength(){return Je[this.signatureType].pubLength}get rawTarget(){let e=this.getTargetStart();return this.binary[e]==1?this.binary.subarray(e+1,e+33):is.Buffer.alloc(0)}get target(){return cn.default.encode(this.rawTarget)}get rawAnchor(){let e=this.getAnchorStart();return this.binary[e]==1?this.binary.subarray(e+1,e+33):is.Buffer.alloc(0)}get anchor(){return cn.default.encode(this.rawAnchor)}get rawTags(){let e=this.getTagsStart(),r=pt(this.binary.subarray(e+8,e+16));return this.binary.subarray(e+16,e+16+r)}get tags(){let e=this.getTagsStart();if(pt(this.binary.subarray(e,e+8))==0)return[];let n=pt(this.binary.subarray(e+8,e+16));return ns(is.Buffer.from(this.binary.subarray(e+16,e+16+n)))}get tagsB64Url(){return this.tags.map(r=>({name:cn.default.encode(r.name),value:cn.default.encode(r.value)}))}getStartOfData(){let e=this.getTagsStart(),r=this.binary.subarray(e+8,e+16),n=pt(r);return e+16+n}get rawData(){let e=this.getTagsStart(),r=this.binary.subarray(e+8,e+16),n=pt(r),i=e+16+n;return this.binary.subarray(i,this.binary.length)}get data(){return cn.default.encode(this.rawData)}getRaw(){return this.binary}async sign(e){return this._id=await Vc(this,e),this.rawId}async setSignature(e){this.binary.set(e,2),this._id=is.Buffer.from(await mt().hash(e))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map(e=>({name:cn.default.encode(e.name),value:cn.default.encode(e.value)})),data:this.data}}static async verify(e){if(e.byteLength<Zc)return!1;let r=new t(e),n=r.signatureType,i=r.getTagsStart(),a=pt(e.subarray(i,i+8)),d=e.subarray(i+8,i+16),v=pt(d);if(v>zc)return!1;if(a>0)try{if(ns(is.Buffer.from(e.subarray(i+16,i+16+v))).length!==a)return!1}catch{return!1}let y=wf[n],m=await Af(r);return await y.verify(r.rawOwner,m,r.rawSignature)}async getSignatureData(){return Af(this)}getTagsStart(){let e=this.getTargetStart(),r=this.binary[e]==1,n=e+(r?33:1),i=this.binary[n]==1;return n+=i?33:1,n}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let e=this.getTargetStart()+1,r=this.binary[this.getTargetStart()]==1;return e+=r?32:0,e}},as=Kc;var L3=require("crypto"),ii=32,jc=class{length;items;binary;constructor(e){this.binary=e,this.length=this.getDataItemCount(),this.items=this.getItems()}getRaw(){return this.binary}get(e){if(typeof e=="number"){if(e>=this.length)throw new RangeError("Index out of range");return this.getByIndex(e)}else return this.getById(e)}getSizes(){let e=[];for(let r=ii;r<ii+64*this.length;r+=64)e.push(pt(this.binary.subarray(r,r+32)));return e}getIds(){let e=[];for(let r=ii;r<ii+64*this.length;r+=64){let n=this.binary.subarray(r+32,r+64);if(n.length===0)throw new Error("Invalid bundle, id specified in headers doesn't exist");e.push(Tf.default.encode(n))}return e}getIdBy(e){if(e>this.length-1)throw new RangeError("Index of bundle out of range");let r=64+64*e;return Tf.default.encode(this.binary.subarray(r,r+32))}async toTransaction(e,r,n){let i=await r.createTransaction({data:this.binary,...e},n);return i.addTag("Bundle-Format","binary"),i.addTag("Bundle-Version","2.0.0"),i}async verify(){for(let e of this.items){let r=await e.isValid(),n=(0,Tf.default)((0,L3.createHash)("sha256").update(e.rawSignature).digest());if(!(r&&e.id===n))return!1}return!0}getOffset(e){let r=0;for(let n=ii;n<ii+64*this.length;n+=64){let i=pt(this.binary.subarray(n,n+32));r+=i;let a=this.binary.subarray(n+32,n+64);if(Buffer.compare(a,e)===0)return{startOffset:r,size:i}}return{startOffset:-1,size:-1}}getByIndex(e){let r=0,n=this.getBundleStart(),i=0,a,d;for(let B=ii;B<ii+64*this.length;B+=64){if(a=pt(this.binary.subarray(B,B+32)),i++===e){d=this.binary.subarray(B+32,B+64);break}r+=a}let v=n+r,y=this.binary.subarray(v,v+a),m=new as(y);return m.rawId=d,m}getById(e){let r=Tf.default.toBuffer(e),n=this.getOffset(r);if(n.startOffset===-1)throw new Error("Transaction not found");let a=this.getBundleStart()+n.startOffset;return new as(this.binary.subarray(a,a+n.size))}getDataItemCount(){return pt(this.binary.subarray(0,32))}getBundleStart(){return 32+64*this.length}getItems(){let e=new Array(this.length),r=0,n=this.getBundleStart(),i=0;for(let a=ii;a<ii+64*this.length;a+=64){let d=pt(this.binary.subarray(a,a+32)),v=this.binary.subarray(a+32,a+64);if(v.length===0)throw new Error("Invalid bundle, id specified in headers doesn't exist");let y=n+r,m=this.binary.subarray(y,y+d);r+=d;let B=new as(m);B.rawId=v,e[i]=B,i++}return e}},$h=jc;function qE(t){return new $h(t)}async function GE(t,e){let r=new Uint8Array(64*t.length),n=await Promise.all(t.map(async(a,d)=>{let v=a.isSigned()?a.rawId:await Vc(a,e),y=new Uint8Array(64);return y.set(Xc(a.getRaw().byteLength),0),y.set(v,32),r.set(y,64*d),a.getRaw()})).then(a=>Buffer.concat(a)),i=Buffer.concat([Buffer.from(Xc(t.length)),Buffer.from(r),n]);return new $h(i)}async function R3(t,e){let r=await Af(t),n=await e.sign(r),i=await mt().hash(n);return{signature:Buffer.from(n),id:Buffer.from(i)}}async function Vc(t,e){let{signature:r,id:n}=await R3(t,e);return t.getRaw().set(r,2),n}var gk=A(M(),1),F3=A(kr(),1);function Ef(t,e,r){let n=e.publicKey,i=r?.target?F3.default.toBuffer(r.target):null,a=1+(i?.byteLength??0),d=r?.anchor?Buffer.from(r.anchor):null,v=1+(d?.byteLength??0),y=(r?.tags?.length??0)>0?Yh(r?.tags):null,m=16+(y?y.byteLength:0),B=Buffer.from(t),P=B.byteLength,D=2+e.signatureLength+e.ownerLength+a+v+m+P,F=Buffer.alloc(D);if(F.set(Wh(e.signatureType),0),F.set(new Uint8Array(e.signatureLength).fill(0),2),n.byteLength!==e.ownerLength)throw new Error(`Owner must be ${e.ownerLength} bytes, but was incorrectly ${n.byteLength}`);F.set(n,2+e.signatureLength);let C=2+e.signatureLength+e.ownerLength;if(F[C]=i?1:0,i){if(i.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${i.byteLength}`);F.set(i,C+1)}let q=C+a,W=q+1;if(F[q]=d?1:0,d){if(W+=d.byteLength,d.byteLength!==32)throw new Error("Anchor must be 32 bytes");F.set(d,q+1)}F.set(Gc(r?.tags?.length??0),W);let K=Gc(y?.byteLength??0);F.set(K,W+8),y&&F.set(y,W+16);let ne=W+m;return F.set(B,ne),new as(F)}var vk=A(M(),1);var mk=A(M(),1),e1=class{signatureType;rawSignature;signature;signatureLength;rawOwner;owner;ownerLength;rawTarget;target;rawAnchor;anchor;rawTags;tags;rawData;data;static async verify(...e){throw new Error("You must implement `verify`")}};var wk=A(M(),1);var Ak=A(M(),1);var r1={};ou(r1,{default:()=>zE,processStream:()=>O3,streamExportForTesting:()=>KE,streamSigner:()=>XE});var zk=A(M(),1),Qc=require("stream");var Va=A(kr(),1);var D3=require("crypto");async function O3(t){let e=I3(t),r=(await e.next()).value;r=await Ar(e,r,32);let n=pt(r.subarray(0,32));r=r.subarray(32);let i=64*n;r=await Ar(e,r,i);let a=new Array(n);for(let y=0;y<i;y+=64)a[y/64]=[pt(r.subarray(y,y+32)),(0,Va.default)(Buffer.from(r.subarray(y+32,y+64)))];r=r.subarray(i);let d=32+i,v=[];for(let[y,m]of a){r=await Ar(e,r,Zc),r=await Ar(e,r,2);let B=pt(r.subarray(0,2));r=r.subarray(2);let{sigLength:P,pubLength:D,sigName:F}=Je[B];r=await Ar(e,r,P);let C=r.subarray(0,P);r=r.subarray(P),r=await Ar(e,r,D);let q=r.subarray(0,D);r=r.subarray(D),r=await Ar(e,r,1);let W=r[0]===1;W&&(r=await Ar(e,r,33));let K=W?r.subarray(1,33):Buffer.allocUnsafe(0);r=r.subarray(W?33:1),r=await Ar(e,r,1);let ne=r[0]===1;ne&&(r=await Ar(e,r,33));let $=ne?r.subarray(1,33):Buffer.allocUnsafe(0);r=r.subarray(ne?33:1),r=await Ar(e,r,8);let ae=pt(r.subarray(0,8));r=r.subarray(8),r=await Ar(e,r,8);let ie=pt(r.subarray(0,8));r=r.subarray(8),r=await Ar(e,r,ie);let ee=r.subarray(0,ie),ce=ae!==0&&ie!==0?ns(Buffer.from(ee)):[];if(ce.length!==ae)throw new Error("Tags lengths don't match");r=r.subarray(ie);let te=new Qc.Transform;te._transform=function(l,f,c){this.push(l),c()};let Y=Ci([(0,$e.stringToBuffer)("dataitem"),(0,$e.stringToBuffer)("1"),(0,$e.stringToBuffer)(B.toString()),q,K,$,ee,te]),S=2+P+D+(W?33:1)+(ne?33:1)+16+ie,s=y-S;if(r.byteLength>s)te.write(r.subarray(0,s)),r=r.subarray(s);else{let l=r.byteLength;for(te.write(r);s>l;){if(r=(await e.next()).value,!r)throw new Error(`Not enough data bytes expected: ${s} received: ${l}`);l+=r.byteLength,l>s?te.write(r.subarray(0,r.byteLength-(l-s))):te.write(r)}r=r.subarray(r.byteLength-(l-s))}if(te.end(),m!==(0,Va.default)((0,D3.createHash)("sha256").update(C).digest()))throw new Error("ID doesn't match signature");if(!await wf[B].verify(q,await Y,C))throw new Error("Invalid signature");v.push({id:m,sigName:F,signature:(0,Va.default)(Buffer.from(C)),target:(0,Va.default)(Buffer.from(K)),anchor:(0,Va.default)(Buffer.from($)),owner:(0,Va.default)(Buffer.from(q)),tags:ce,dataOffset:d+S,dataSize:s}),d+=S+s}return v}async function XE(t,e,r,n){let i=Ef("",r,n),a=new Qc.PassThrough,d=[(0,$e.stringToBuffer)("dataitem"),(0,$e.stringToBuffer)("1"),(0,$e.stringToBuffer)(i.signatureType.toString()),i.rawOwner,i.rawTarget,i.rawAnchor,i.rawTags,t],v=await Ci(d),y=Buffer.from(await r.sign(v));return i.setSignature(y),a.write(i.getRaw()),e.pipe(a)}async function Ar(t,e,r){if(e.byteLength>=r)return e;let{done:n,value:i}=await t.next();if(n&&!i)throw new Error("Invalid buffer");return Ar(t,Buffer.concat([Buffer.from(e),Buffer.from(i)]),r)}async function*I3(t){for await(let e of t)yield e}var zE=O3,KE={readBytes:Ar,getReader:I3};var ZE={...t1,stream:r1};globalThis.arbundles??=ZE;function ja(t){return async e=>{if(dn(e))return e;if(!t.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await VE(t,{data:e})}catch(r){throw new Error(r.message??"Error resolving transaction")}}}async function VE(t,e){let r=null,n=null,i=null;if(typeof e.data=="string"&&(r=Buffer.from(p1(e.data),"base64"),n=h1(e.data),i=b1(r)),e.data instanceof File&&(r=new Uint8Array(await e.data.arrayBuffer()),n=e.data.type,i=e.data.size),r&&n&&i)if(i<Number(cu.dispatchUploadSize))try{let a=await t.arweave.createTransaction({data:r},"use_wallet");return a.addTag(We.keys.contentType,n),e.tags&&e.tags.length>0&&e.tags.forEach(v=>a.addTag(v.name,v.value)),(await global.window.arweaveWallet.dispatch(a)).id}catch(a){throw new Error(a.message??"Error dispatching transaction")}else try{let a=await jE(e.data,{tags:[{name:"Content-Type",value:n},{name:"App-Name",value:"@permaweb/libs"}]},{apiUrl:cu.node1,token:"arweave",chunkSize:5242880,batchSize:3});return console.log(a),console.log("Uploaded dataItem ID:",a.id),a.id}catch(a){throw new Error(a.message??"Error uploading transaction")}else throw new Error("Error preparing transaction data")}async function jE(t,e,r){let{apiUrl:n,token:i,chunkSize:a,batchSize:d=3}=r,v=new Za(window.arweaveWallet),y=await v.signer.getActivePublicKey();v.publicKey=Buffer.from(y,"base64");let m=new Uint8Array(await t.arrayBuffer()),B=Ef(m,v,{...e,anchor:e.anchor||(()=>{let S=new Uint8Array(32);return crypto.getRandomValues(S),btoa(String.fromCharCode(...S)).replace(/\+/g,"-").replace(/\//g,"_").slice(0,32)})()});await B.sign(v);let P=B.getRaw(),D=new Blob([new Uint8Array(P)],{type:"application/octet-stream"}),F={"x-chunking-version":"2"},C=await fetch(`${n}/chunks/${i}/-1/-1`,{headers:F});if(!C.ok)throw new Error(`Failed to get upload ID: ${C.status} ${await C.text()}`);let q=await C.json(),W=q.id;if(a<q.min||a>q.max)throw new Error(`Configured chunkSize ${a} is out of allowed range ${q.min}-${q.max}`);let K=D.size,ne=[];for(let S=0;S<K;S+=a)ne.push(S);let $=new Set;(q.chunks??[]).forEach(([S])=>$.add(Number(S)));let ae=ne.filter(S=>S>0&&!$.has(S)),ie=$.has(0)?[]:[0],ee=ae.concat(ie),ce=S=>new Promise(s=>setTimeout(s,S));for(let S=0;S<ee.length;S+=d){let s=ee.slice(S,S+d);await Promise.all(s.map(async u=>{let f=await D.slice(u,u+a).arrayBuffer(),c=null;for(let g=1;g<=3;g++)try{let x=await fetch(`${n}/chunks/${i}/${W}/${u}`,{method:"POST",headers:{"Content-Type":"application/octet-stream",...F},body:f});if(!x.ok){let h=await x.text();throw x.status===402?new Error(`402 payment required: ${h}`):new Error(`Chunk upload error ${x.status}: ${h}`)}return}catch(x){if(c=x,g<3){await ce(1e3*g);continue}}throw c}))}let te={"Content-Type":"application/octet-stream",...F},Y=await fetch(`${n}/chunks/${i}/${W}/-1`,{method:"POST",headers:te});if(!Y.ok){let S=await Y.text();throw new Error(`Finalizing upload failed ${Y.status}: ${S}`)}return Y.json()}var oN=A(M(),1);var k3={},aN=A(M(),1);var XN=A(M(),1);var vN=A(M(),1);function Wc(t){return async(e,r)=>{let n=$E(e);if(n)throw new Error(n);let i=d1[e.contentType]?.serialize(e.data)??e.data,a=YE(e);try{return await sa(t,{tags:a,data:i},r?v=>r(v):void 0)}catch(d){throw new Error(d.message??"Error creating asset")}}}async function n1(t,e,r){try{let n=Bn(await oa(t,{processId:e,path:"asset",fallbackAction:"Info"}));if(r?.useGateway){let i=await Ir({gateway:Sr.goldsky,ids:[e],tags:null,owners:null,cursor:null});return{...i?.data?.[0]?Yc(i.data[0]):{},...n}}return{id:e,...n}}catch(n){throw new Error(n.message||"Error fetching atomic asset")}}function N3(t){return async(e,r)=>await n1(t,e,r)}async function J3(t){try{let e=await Ir({gateway:Sr.arweave,ids:t??null,tags:null,owners:null,cursor:null});return e&&e.data.length?e.data.map(r=>Yc(r)):null}catch(e){throw new Error(e)}}function Yc(t){let e={id:t.node.id,owner:t.node.owner.address};for(let r of t.node.tags){let n=r.name,a=(n.startsWith(`${We.keys.bootloader}-`)?n.slice(`${We.keys.bootloader}-`.length):n).split("-").map((v,y)=>y===0?v.toLowerCase():v.charAt(0).toUpperCase()+v.slice(1).toLowerCase()).join(""),d;try{d=JSON.parse(r.value)}catch{d=r.value.toString()}e[a]=d}return e}function YE(t){let e=[{name:We.keys.onBoot,value:t.src??vt.src.asset},{name:We.keys.creator,value:t.creator},{name:We.keys.assetType,value:t.assetType},{name:We.keys.contentType,value:t.contentType},{name:We.keys.implements,value:"ANS-110"},{name:We.keys.dateCreated,value:new Date().getTime().toString()},mr("Name",t.name),mr("Description",t.description),mr("Topics",JSON.stringify(t.topics)),mr("Ticker","ATOMIC"),mr("Denomination",t.denomination?.toString()??"1"),mr("TotalSupply",t.supply?.toString()??"1"),mr("Transferable",t.transferable?.toString()??"true"),mr("Creator",t.creator)];if(t.metadata)for(let r in t.metadata)e.push(mr(Wa(r),t.metadata[r].toString()));if(t.users)for(let r of t.users)e.push({name:"Auth-User",value:r});return t.tags&&t.tags.forEach(r=>e.push(r)),e}function $E(t){if(typeof t!="object"||t===null)return"The provided arguments are invalid or empty.";let e=["name","description","topics","creator","data","contentType","assetType"];for(let r of e)if(!(r in t))return`Missing field '${r}'`;return typeof t.name!="string"||t.name.trim()===""?"Name is required":typeof t.description!="string"?"The description must be a valid string":!Array.isArray(t.topics)||t.topics.length===0?"Topics are required":typeof t.creator!="string"||t.creator.trim()===""?"Creator is required":t.data===void 0||t.data===null?"Data field is required":typeof t.contentType!="string"||t.contentType.trim()===""?"Content type must be a non-empty string":typeof t.assetType!="string"||t.assetType.trim()===""?"Type must be a non-empty string":"supply"in t&&(typeof t.supply!="number"||t.supply<=0)?"Supply must be a positive number":"denomination"in t&&(typeof t.denomination!="number"||t.denomination<=0)?"Denomination must be a positive number":"transferable"in t&&typeof t.transferable!="boolean"?"Transferable must be a boolean value":"metadata"in t&&typeof t.metadata!="object"?"Metadata must be an object":"tags"in t&&(!Array.isArray(t.tags)||t.tags.some(r=>typeof r!="object"))?"Tags must be an array of objects":"src"in t&&typeof t.src!="string"?"Source must be a valid string":null}var MN=A(M(),1);var e_="eXCtpVbcd_jZ0dmU2PZ8focaKxBGECBQ8wMib7sIVPo",i1="lJovHqM9hwNjHV5JoY9NGWtt0WD-5D4gOqNL2VWW5jk";function U3(t){return async(e,r)=>{if(!t.signer)throw new Error("No signer provided");let n=ja(t),i=new Date().getTime().toString(),a=[{name:We.keys.creator,value:e.creator},{name:We.keys.ans110.title,value:os(e.title)},{name:We.keys.name,value:os(e.title)},{name:We.keys.ans110.description,value:os(e.description)}],d=null,v=null;try{d=e.banner?await n(e.thumbnail):i1,v=e.banner?await n(e.banner):e_,e.thumbnail&&a.push({name:We.keys.thumbnail,value:d}),e.banner&&a.push({name:We.keys.banner,value:v})}catch(B){console.error(B)}let y=await fetch(Ya(vt.src.collection));if(!y.ok)throw new Error("Unable to fetch process src");let m=await y.text();m=m.replace(/'<NAME>'/g,uu(e.title)),m=m.replace(/'<DESCRIPTION>'/g,uu(e.description)),m=m.replace(/<CREATOR>/g,e.creator),m=m.replace(/<THUMBNAIL>/g,d||i1),m=m.replace(/<BANNER>/g,v||i1),m=m.replace(/<DATECREATED>/g,i),m=m.replace(/<LASTUPDATE>/g,i);try{let B=await sa(t,{tags:a},r?P=>r(P):void 0);if(hn("Sending eval message to collection..."),r&&r("Sending eval message to collection..."),await t.ao.message({process:B,signer:t.signer,tags:[{name:"Action",value:"Eval"}],data:m}),!e.skipRegistry){hn("Sending collection to registry..."),r&&r("Sending collection to registry...");let P=[{name:"Action",value:"Add-Collection"},{name:"CollectionId",value:B},{name:"Name",value:os(e.title)},{name:"Creator",value:e.creator},{name:"DateCreated",value:i}];v&&P.push({name:"Banner",value:v}),d&&P.push({name:"Thumbnail",value:d}),await t.ao.message({process:vt.collectionRegistry,signer:t.signer,tags:P})}if(!e.skipActivity){hn("Creating collection activity process..."),r&&r("Creating collection activity process...");let P=[{name:"CollectionId",value:B},{name:"DateCreated",value:i},{name:"UCM-Process",value:"Collection-Activity"},{name:"On-Boot",value:vt.src.collectionActivity}],D=await sa(t,{tags:P},r?F=>r(F):void 0);hn("Adding activity to collection process..."),r&&r("Adding activity to collection process..."),await t.ao.message({process:B,signer:t.signer,tags:[{name:"Action",value:"Eval"}],data:`ActivityProcess = '${D}'`})}return B}catch(B){throw new Error(B.message??"Error creating collection")}}}function H3(t){return async e=>await Cn(t,{processId:e.creator,action:"Run-Action",tags:[{name:"ForwardTo",value:e.collectionId},{name:"ForwardAction",value:"Update-Assets"}],data:{Target:e.collectionId,Action:"Update-Assets",Input:{AssetIds:e.assetIds,UpdateType:e.updateType}}})}function q3(t){return async e=>{let r=await oa(t,{processId:e,path:"collection",fallbackAction:"Info"});return r?Bn(r):null}}function G3(t){return async e=>{let r=e.creator?"Get-Collections-By-User":"Get-Collections",n=await Pf(t,{processId:vt.collectionRegistry,action:r,tags:e.creator?[{name:"Creator",value:e.creator}]:null});return n&&n.Collections&&n.Collections.length?n.Collections.map(a=>({id:a.Id,title:a.Name.replace(/\[|\]/g,""),description:a.Description,creator:a.Creator,dateCreated:a.DateCreated,banner:a.Banner,thumbnail:a.Thumbnail})):null}}var PN=A(M(),1);function X3(t){let e=Wc(t);return async(r,n)=>{let i=r.tags?r.tags:[];i.push({name:"Data-Source",value:r.parentId}),i.push({name:"Root-Source",value:r.rootId??r.parentId});let a={name:`Comment on ${r.parentId}`,description:`Comment on ${r.parentId}`,topics:["comment"],creator:r.creator,data:r.content,contentType:"text/plain",assetType:"comment",tags:i};return e(a,n)}}function z3(t){return async e=>{try{let r=await n1(t,e,{useGateway:!0}),n=r?.dataSource,i=r?.rootSource;if(!n||!i)throw new Error("dataSource and rootSource must be present on a comment");return{content:await Z3(e),parentId:n,rootId:i}}catch(r){throw new Error(r.message??"Error getting comment")}}}function K3(t){return async e=>{if(!e.parentId&&!e.rootId)throw new Error("Must provide either parentId or rootId");let r=[];e.parentId&&r.push({name:"Data-Source",values:[e.parentId??""]}),e.rootId&&r.push({name:"Root-Source",values:[e.rootId??""]});let n=await Ir({gateway:Sr.goldsky,ids:null,tags:r,owners:null,cursor:null}),i=[];n&&n.data.length&&(i=n.data.map(d=>Yc(d)));let a=[];for(let d of i){let v=d?.dataSource,y=d?.rootSource;if(!v||!y)throw new Error("dataSource and rootSource must be present on a comment");a.push({id:d.id,content:await Z3(d.id),parentId:v,rootId:y})}return a}}async function Z3(t){try{return await(await fetch(Ya(t))).text()}catch(e){throw new Error(e.message??"Error getting comment data")}}var GN=A(M(),1);var IN=A(M(),1);function $c(t){return async(e,r)=>{try{let n=[{name:We.keys.onBoot,value:vt.src.zone.id}];return e.tags&&e.tags.length&&e.tags.forEach(a=>n.push(a)),await sa(t,{data:e.data,tags:n},r?a=>r(a):void 0)}catch(n){throw new Error(n.message??"Error creating zone")}}}function eu(t){return async(e,r)=>{try{let n=Object.entries(e).map(([a,d])=>({key:a,value:d}));return await Cn(t,{processId:r,action:"Zone-Update",data:n})}catch(n){throw new Error(n)}}}function V3(t){return async(e,r)=>{try{return await Cn(t,{processId:r,action:"Zone-Append",tags:[{name:"Path",value:e.path}],data:e.data})}catch(n){throw new Error(n)}}}function j3(t){return async(e,r)=>{if(!dn(r))throw new Error("Invalid zone address");let i=[];for(let a of e){if(!dn(a.granteeId))throw new Error("Invalid granteeId address");if(a.type!=="wallet"&&a.type!=="process")throw new Error("Invalid role type");i.push({Id:a.granteeId,Roles:a.roles,Type:a.type,SendInvite:a.sendInvite})}try{return await Cn(t,{processId:r,action:"Role-Set",tags:[],data:i})}catch(a){throw new Error(a)}}}function Q3(t){return async(e,r)=>{if(!(dn(r)&&dn(e.zoneToJoinId)))throw new Error("Invalid zone address");let i=[{name:"ZoneId",value:e.zoneToJoinId}];e.path&&i.push({name:"Path",value:e.path});try{return await Cn(t,{processId:r,action:"Zone-Join",tags:i})}catch(a){throw new Error(a)}}}function tu(t){return async e=>{try{return hn(`Updating zone to version ${vt.src.zone.version} with source ${vt.src.zone.id}`),await ss(t,{processId:e.zoneId,evalTxId:vt.src.zone.id}),await ss(t,{processId:e.zoneId,evalSrc:`Zone.Version = '${vt.src.zone.version}'; SyncState()`})}catch(r){throw new Error(r)}}}function ru(t){return async e=>{try{let r=await oa(t,{processId:e,path:"zone",fallbackAction:"Info"});return Bn(r)}catch(r){throw new Error(r.message??"Error getting zone")}}}function W3(t){let e=$c(t),r=ja(t);return async(n,i)=>{let a=null,d=[{name:We.keys.dataProtocol,value:We.values.zone},{name:We.keys.zoneType,value:We.values.user}],v=async y=>{let m=y.toLowerCase();if(n[m])try{let B=await r(n[m]);d.push(mr(y,B))}catch(B){i?i(`Failed to resolve ${y}: ${B.message}`):console.error(B)}};n.username&&d.push(mr("Username",n.username)),n.displayName&&d.push(mr("DisplayName",n.displayName)),n.description&&d.push(mr("Description",n.description)),await Promise.all([v("Thumbnail"),v("Banner")]);try{a=await e({tags:d},i)}catch(y){throw new Error(y.message??"Error creating profile")}return a}}function Y3(t){let e=eu(t),r=ja(t);return async(n,i,a)=>{if(i){let d={Username:n.username,DisplayName:n.displayName,Description:n.description};if(n.thumbnail)try{d.Thumbnail=await r(n.thumbnail)}catch(v){a&&a(`Failed to resolve thumbnail: ${v.message}`)}if(n.banner)try{d.Banner=await r(n.banner)}catch(v){a&&a(`Failed to resolve banner: ${v.message}`)}try{return await e(d,i)}catch(v){throw new Error(v.message??"Error creating profile")}}else throw new Error("No profile provided")}}function $3(t){let e=tu(t);return async r=>{try{return await e({zoneId:r.profileId})}catch(n){throw new Error(n)}}}function a1(t){let e=ru(t);return async r=>{try{let n=await e(r);if(!n)throw new Error("Error fetching profile - Not found");return{id:r,owner:n.owner,assets:n.assets,roles:n.roles,invites:n.invites,version:n.version,...n.store}}catch(n){throw new Error(n.message??"Error fetching profile")}}}function e8(t){let e=a1(t);return async r=>{try{let n=await Ir({gateway:Sr.goldsky,tags:[{name:We.keys.dataProtocol,values:[We.values.zone]},{name:We.keys.zoneType,values:[We.values.user]}],owners:[r]});return n?.data?.length>0?(n.data.sort((i,a)=>{let d=i.node.block?.timestamp??0;return(a.node.block?.timestamp??0)-d}),await e(n.data[0].node.id)):{id:null}}catch(n){throw new Error(n.message??"Error fetching profile")}}}var r_=vt.src.zone.version;function n_(t){return{createZone:$c(t),updateZone:eu(t),addToZone:V3(t),getZone:ru(t),setZoneRoles:j3(t),joinZone:Q3(t),updateZoneVersion:tu(t),createProfile:W3(t),updateProfile:Y3(t),updateProfileVersion:$3(t),getProfileById:a1(t),getProfileByWalletAddress:e8(t),createAtomicAsset:Wc(t),getAtomicAsset:N3(t),getAtomicAssets:J3,createComment:X3(t),getComment:z3(t),getComments:K3(t),createCollection:U3(t),updateCollectionAssets:H3(t),getCollection:q3(t),getCollections:G3(t),resolveTransaction:ja(t),getGQLData:Ir,getAggregatedGQLData:g1,createProcess:w1(t),readProcess:y1(t),readState:m1(t),sendMessage:x1(t),mapFromProcessCase:Bn,mapToProcessCase:Wa}}var i_={init:n_};0&&(module.exports={CurrentZoneVersion,Types});
|
|
43
43
|
/*! Bundled license information:
|
|
44
44
|
|
|
45
45
|
js-sha3/src/sha3.js:
|