@ar.io/sdk 1.2.0 → 1.2.2
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/bundles/web.bundle.min.js +3 -3
- package/lib/cjs/common/io.js +50 -10
- package/lib/cjs/utils/graphql/processes.js +2 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/io.js +51 -11
- package/lib/esm/utils/graphql/processes.js +3 -3
- package/lib/esm/version.js +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -213,12 +213,12 @@ ${C}`,A.pop(),`[${H}]`}let P=Object.keys(T),N=P.length;if(N===0)return"{}";if(l<
|
|
|
213
213
|
${B}`,W="",J="",F=Math.min(N,c);tO(T)&&(W+=eO(T,q,c),P=P.slice(T.length),F-=T.length,J=q),o&&(P=QB(P)),A.push(T);for(let H=0;H<F;H++){let Y=P[H],E=m(Y,T[Y],A,R,B);E!==void 0&&(W+=`${J}"${ml(Y)}": ${E}`,J=q)}if(N>c){let H=N-c;W+=`${J}"...": "${ad(H)} not stringified"`,J=q}return J!==""&&(W=`
|
|
214
214
|
${B}${W}
|
|
215
215
|
${C}`),A.pop(),`{${W}}`}case"number":return isFinite(T)?String(T):t?t(T):"null";case"boolean":return T===!0?"true":"false";case"undefined":return;case"bigint":if(h)return String(T);default:return t?t(T):void 0}}function y(M,T,A){switch(typeof T){case"string":return`"${ml(T)}"`;case"object":{if(T===null)return"null";if(typeof T.toJSON=="function"){if(T=T.toJSON(M),typeof T!="object")return y(M,T,A);if(T===null)return"null"}if(A.indexOf(T)!==-1)return r;let R="";if(Array.isArray(T)){if(T.length===0)return"[]";if(l<A.length+1)return'"[Array]"';A.push(T);let q=Math.min(T.length,c),W=0;for(;W<q-1;W++){let F=y(W,T[W],A);R+=F!==void 0?F:"null",R+=","}let J=y(W,T[W],A);if(R+=J!==void 0?J:"null",T.length-1>c){let F=T.length-c-1;R+=`,"... ${ad(F)} not stringified"`}return A.pop(),`[${R}]`}let B=Object.keys(T),C=B.length;if(C===0)return"{}";if(l<A.length+1)return'"[Object]"';let P="",N=Math.min(C,c);tO(T)&&(R+=eO(T,",",c),B=B.slice(T.length),N-=T.length,P=","),o&&(B=QB(B)),A.push(T);for(let q=0;q<N;q++){let W=B[q],J=y(W,T[W],A);J!==void 0&&(R+=`${P}"${ml(W)}":${J}`,P=",")}if(C>c){let q=C-c;R+=`${P}"...":"${ad(q)} not stringified"`}return A.pop(),`{${R}}`}case"number":return isFinite(T)?String(T):t?t(T):"null";case"boolean":return T===!0?"true":"false";case"undefined":return;case"bigint":if(h)return String(T);default:return t?t(T):void 0}}function v(M,T,A){if(arguments.length>1){let R="";if(typeof A=="number"?R=" ".repeat(Math.min(A,10)):typeof A=="string"&&(R=A.slice(0,10)),T!=null){if(typeof T=="function")return p("",{"":M},[],T,R,"");if(Array.isArray(T))return w("",M,[],yxt(T),R,"")}if(R.length!==0)return m("",M,[],R,"")}return y("",M,[])}return v}});var oO=De(yl=>{"use strict";Tt();Rt();xt();Object.defineProperty(yl,"__esModule",{value:!0});yl.createInteractionTagsList=yl.createDummyTx=yl.createInteractionTx=void 0;var hd=Vh(),wxt=Vu(),vl=Ep();async function _xt(i,t,r,h,o,l="",c="0",p=!1,w,m){let y={data:Math.random().toString().slice(-4)};l&&l.length&&(y.target=l.toString(),c&&+c>0&&(y.quantity=c.toString())),p&&(y.reward="0",y.last_tx="p7vc1iSP6bvH_fCeUFa9LqoV5qiyW-jdEKouAT0XMoSwrNraB9mgpi29Q10waEpO"),m&&m.length&&(y.reward=m);let v=await i.createTransaction(y);return Cnt(r,h,w,o).forEach(T=>v.addTag(T.name,T.value)),t&&await t(v),v}yl.createInteractionTx=_xt;function Mxt(i,t,r){let o=new wxt.TagsParser().decodeTags(i);return{id:i.id,owner:{address:t,key:""},recipient:i.target,tags:o,fee:{winston:i.reward,ar:""},quantity:{winston:i.quantity,ar:""},block:{id:r.indep_hash,height:r.height,timestamp:r.timestamp,previous:null},dry:!0,anchor:null,signature:null,data:null,parent:null,bundledIn:null}}yl.createDummyTx=Mxt;function Cnt(i,t,r,h){let o=[];if(h&&h.length)for(let l of h)o.push(new vl.Tag(l.name.toString(),l.value.toString()));return o.push(new vl.Tag(hd.SMART_WEAVE_TAGS.APP_NAME,"SmartWeaveAction")),o.push(new vl.Tag(hd.SMART_WEAVE_TAGS.APP_VERSION,"0.3.0")),o.push(new vl.Tag(hd.SMART_WEAVE_TAGS.SDK,"Warp")),o.push(new vl.Tag(hd.SMART_WEAVE_TAGS.CONTRACT_TX_ID,i)),o.push(new vl.Tag(hd.SMART_WEAVE_TAGS.INPUT,JSON.stringify(t))),o.push(new vl.Tag(hd.WARP_TAGS.INPUT_FORMAT,"tag")),r&&o.push(new vl.Tag(hd.WARP_TAGS.WARP_TESTNET,"1.0.0")),o}yl.createInteractionTagsList=Cnt});var aO=De(Rp=>{"use strict";Tt();Rt();xt();Object.defineProperty(Rp,"__esModule",{value:!0});Rp.REGISTER_PROVIDER=Rp.emptyTransfer=void 0;Rp.emptyTransfer={target:"",winstonQty:"0"};Rp.REGISTER_PROVIDER=["node1","node2","arweave"]});var hO=De(rw=>{"use strict";Tt();Rt();xt();Object.defineProperty(rw,"__esModule",{value:!0});rw.InnerWritesEvaluator=void 0;var sO=class{eval(t){let r=[];return Object.keys(t.interactions).forEach(h=>{let o=t.interactions[h];this.evalForeignCalls(t.contractTxId,o,r)}),r}evalForeignCalls(t,r,h){Object.keys(r.interactionInput.foreignContractCalls).forEach(o=>{let l=r.interactionInput.foreignContractCalls[o];l.innerCallType=="write"&&Object.keys(l.interactions).forEach(c=>{let p=l.interactions[c];p.interactionInput.dryWrite&&!h.includes(l.contractTxId)&&t!==l.contractTxId&&h.push(l.contractTxId),this.evalForeignCalls(t,p,h)})})}};rw.InnerWritesEvaluator=sO});var bO={};cs(bO,{AVSCTap:()=>gv,ArweaveSigner:()=>pO,DataItem:()=>pv,MAX_TAG_BYTES:()=>nw,MIN_BINARY_SIZE:()=>vO,SIG_CONFIG:()=>Ip,SignatureConfig:()=>sh,Signer:()=>$nt,createData:()=>jnt,default:()=>Wxt,deserializeTags:()=>iw,indexToType:()=>gO,serializeTags:()=>mO,tagsExceedLimit:()=>Fnt,warparbundles:()=>Kxt});async function Unt(i){if(Array.isArray(i)){let o=(0,Yh.concatBuffers)([(0,Yh.stringToBuffer)("list"),(0,Yh.stringToBuffer)(i.length.toString())]);return await qnt(i,await Xu().hash(o,"SHA-384"))}let t=i,r=(0,Yh.concatBuffers)([(0,Yh.stringToBuffer)("blob"),(0,Yh.stringToBuffer)(t.byteLength.toString())]),h=(0,Yh.concatBuffers)([await Xu().hash(r,"SHA-384"),await Xu().hash(t,"SHA-384")]);return await Xu().hash(h,"SHA-384")}async function qnt(i,t){if(i.length<1)return t;let r=(0,Yh.concatBuffers)([t,await Unt(i[0])]),h=await Xu().hash(r,"SHA-384");return await qnt(i.slice(1),h)}function Xu(){return $xt??=new Dxt}async function cO(i){return Unt([(0,Yh.stringToBuffer)("dataitem"),(0,Yh.stringToBuffer)("1"),(0,Yh.stringToBuffer)(i.signatureType.toString()),i.rawOwner,i.rawTarget,i.rawAnchor,i.rawTags,i.rawData])}async function Uxt(i,t){let r=await cO(i),h=await t.sign(r),o=await Xu().hash(h);return{signature:ge.from(h),id:ge.from(o)}}async function qxt(i,t){let{signature:r,id:h}=await Uxt(i,t);return i.getRaw().set(r,2),h}function mO(i){let t=new gv;return t.writeTags(i),t.toBuffer()}function Fnt(i){let t=new gv;return t.writeTags(i),t.tagsExceedLimit()}function iw(i){return new gv(i).readTags()}function bl(i){let t=0;for(let r=i.length-1;r>=0;r--)t=t*256+i[r];return t}function Fxt(i){if(i>29)throw new Error("Short too long");let t=[0,0];for(let r=0;r<t.length;r++){let h=i&255;t[r]=h,i=(i-h)/256}return Uint8Array.from(t)}function Pnt(i){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let h=i&255;t[r]=h,i=(i-h)/256}return Uint8Array.from(t)}function jnt(i,t,r){let h=t.publicKey,o=r?.target?zxt.default.toBuffer(r.target):null,l=1+(o?.byteLength??0),c=r?.anchor?ge.from(r.anchor):null,p=1+(c?.byteLength??0),w=(r?.tags?.length??0)>0?mO(r.tags):null,m=16+(w?w.byteLength:0),y=ge.from(i),v=y.byteLength,M=2+t.signatureLength+t.ownerLength+l+p+m+v,T=ge.alloc(M);if(T.set(Fxt(t.signatureType),0),T.set(new Uint8Array(t.signatureLength).fill(0),2),h.byteLength!==t.ownerLength)throw new Error(`Owner must be ${t.ownerLength} bytes, but was incorrectly ${h.byteLength}`);T.set(h,2+t.signatureLength);let A=2+t.signatureLength+t.ownerLength;if(T[A]=o?1:0,o){if(o.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${o.byteLength}`);T.set(o,A+1)}let R=A+l,B=R+1;if(T[R]=c?1:0,c){if(B+=c.byteLength,c.byteLength!==32)throw new Error("Anchor must be 32 bytes");T.set(c,R+1)}T.set(Pnt(r?.tags?.length??0),B);let C=Pnt(w?.byteLength??0);T.set(C,B+8),w&&T.set(w,B+16);let P=B+m;return T.set(y,P),new pv(T)}var Sxt,lO,Ext,Axt,Txt,xxt,Yu,Rxt,kxt,fd,Ixt,Bxt,dO,Nnt,Lnt,Oxt,Cxt,uO,Pxt,Dnt,$nt,Nxt,Yh,fO,Lxt,Dxt,$xt,sh,Ip,pO,gO,Hf,gv,jxt,kp,nw,vO,pv,zxt,yO,Wxt,Kxt,wO=Vi(()=>{"use strict";Tt();Rt();xt();Sxt=Object.create,lO=Object.defineProperty,Ext=Object.getOwnPropertyDescriptor,Axt=Object.getOwnPropertyNames,Txt=Object.getPrototypeOf,xxt=Object.prototype.hasOwnProperty,Yu=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),Rxt=(i,t)=>{for(var r in t)lO(i,r,{get:t[r],enumerable:!0})},kxt=(i,t,r,h)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Axt(t))!xxt.call(i,o)&&o!==r&&lO(i,o,{get:()=>t[o],enumerable:!(h=Ext(t,o))||h.enumerable});return i},fd=(i,t,r)=>(r=i!=null?Sxt(Txt(i)):{},kxt(t||!i||!i.__esModule?lO(r,"default",{value:i,enumerable:!0}):r,i)),Ixt=Yu(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});function t(r){var h=4,o=r.length,l=o%h;if(!l)return r;var c=o,p=h-l,w=o+p,m=ge.alloc(w);for(m.write(r);p--;)m.write("=",c++);return m.toString()}i.default=t}),Bxt=Yu(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var t=Ixt();function r(w,m){return m===void 0&&(m="utf8"),ge.isBuffer(w)?l(w.toString("base64")):l(ge.from(w,m).toString("base64"))}function h(w,m){return m===void 0&&(m="utf8"),ge.from(o(w),"base64").toString(m)}function o(w){return w=w.toString(),t.default(w).replace(/\-/g,"+").replace(/_/g,"/")}function l(w){return w.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function c(w){return ge.from(o(w),"base64")}var p=r;p.encode=r,p.decode=h,p.toBase64=o,p.fromBase64=l,p.toBuffer=c,i.default=p}),dO=Yu((i,t)=>{t.exports=Bxt().default,t.exports.default=t.exports}),Nnt=Yu(i=>{"use strict";i.byteLength=w,i.toByteArray=y,i.fromByteArray=T;var t=[],r=[],h=typeof Uint8Array<"u"?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(l=0,c=o.length;l<c;++l)t[l]=o[l],r[o.charCodeAt(l)]=l;var l,c;r[45]=62,r[95]=63;function p(A){var R=A.length;if(R%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=A.indexOf("=");B===-1&&(B=R);var C=B===R?0:4-B%4;return[B,C]}function w(A){var R=p(A),B=R[0],C=R[1];return(B+C)*3/4-C}function m(A,R,B){return(R+B)*3/4-B}function y(A){var R,B=p(A),C=B[0],P=B[1],N=new h(m(A,C,P)),q=0,W=P>0?C-4:C,J;for(J=0;J<W;J+=4)R=r[A.charCodeAt(J)]<<18|r[A.charCodeAt(J+1)]<<12|r[A.charCodeAt(J+2)]<<6|r[A.charCodeAt(J+3)],N[q++]=R>>16&255,N[q++]=R>>8&255,N[q++]=R&255;return P===2&&(R=r[A.charCodeAt(J)]<<2|r[A.charCodeAt(J+1)]>>4,N[q++]=R&255),P===1&&(R=r[A.charCodeAt(J)]<<10|r[A.charCodeAt(J+1)]<<4|r[A.charCodeAt(J+2)]>>2,N[q++]=R>>8&255,N[q++]=R&255),N}function v(A){return t[A>>18&63]+t[A>>12&63]+t[A>>6&63]+t[A&63]}function M(A,R,B){for(var C,P=[],N=R;N<B;N+=3)C=(A[N]<<16&16711680)+(A[N+1]<<8&65280)+(A[N+2]&255),P.push(v(C));return P.join("")}function T(A){for(var R,B=A.length,C=B%3,P=[],N=16383,q=0,W=B-C;q<W;q+=N)P.push(M(A,q,q+N>W?W:q+N));return C===1?(R=A[B-1],P.push(t[R>>2]+t[R<<4&63]+"==")):C===2&&(R=(A[B-2]<<8)+A[B-1],P.push(t[R>>10]+t[R>>4&63]+t[R<<2&63]+"=")),P.join("")}}),Lnt=Yu(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.b64UrlDecode=i.b64UrlEncode=i.bufferTob64Url=i.bufferTob64=i.b64UrlToBuffer=i.stringToB64Url=i.stringToBuffer=i.bufferToString=i.b64UrlToString=i.concatBuffers=void 0;var t=Nnt();function r(M){let T=0;for(let B=0;B<M.length;B++)T+=M[B].byteLength;let A=new Uint8Array(T),R=0;A.set(new Uint8Array(M[0]),R),R+=M[0].byteLength;for(let B=1;B<M.length;B++)A.set(new Uint8Array(M[B]),R),R+=M[B].byteLength;return A}i.concatBuffers=r;function h(M){let T=p(M);return o(T)}i.b64UrlToString=h;function o(M){return new TextDecoder("utf-8",{fatal:!0}).decode(M)}i.bufferToString=o;function l(M){return new TextEncoder().encode(M)}i.stringToBuffer=l;function c(M){return m(l(M))}i.stringToB64Url=c;function p(M){return new Uint8Array(t.toByteArray(v(M)))}i.b64UrlToBuffer=p;function w(M){return t.fromByteArray(new Uint8Array(M))}i.bufferTob64=w;function m(M){return y(w(M))}i.bufferTob64Url=m;function y(M){return M.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}i.b64UrlEncode=y;function v(M){M=M.replace(/\-/g,"+").replace(/\_/g,"/");let T;return M.length%4==0?T=0:T=4-M.length%4,M.concat("=".repeat(T))}i.b64UrlDecode=v}),Oxt=Yu(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var t=Lnt(),r=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 h=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),o=await this.driver.exportKey("jwk",h.privateKey);return{kty:o.kty,e:o.e,n:o.n,d:o.d,p:o.p,q:o.q,dp:o.dp,dq:o.dq,qi:o.qi}}async sign(h,o,{saltLength:l}={}){let c=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(h),o);return new Uint8Array(c)}async hash(h,o="SHA-256"){let l=await this.driver.digest(o,h);return new Uint8Array(l)}async verify(h,o,l){let c={kty:"RSA",e:"AQAB",n:h},p=await this.jwkToPublicCryptoKey(c),w=await this.driver.digest("SHA-256",o),m=await this.driver.verify({name:"RSA-PSS",saltLength:0},p,l,o),y=await this.driver.verify({name:"RSA-PSS",saltLength:32},p,l,o),v=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((p.algorithm.modulusLength-1)/8)-w.byteLength-2},p,l,o);return m||y||v}async jwkToCryptoKey(h){return this.driver.importKey("jwk",h,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(h){return this.driver.importKey("jwk",h,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let h=crypto?.subtle;return h===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(o=>typeof h[o]=="function")}async encrypt(h,o,l){let c=await this.driver.importKey("raw",typeof o=="string"?t.stringToBuffer(o):o,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:l?t.stringToBuffer(l):t.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),w=new Uint8Array(16);crypto.getRandomValues(w);let m=await this.driver.encrypt({name:"AES-CBC",iv:w},p,h);return t.concatBuffers([w,m])}async decrypt(h,o,l){let c=await this.driver.importKey("raw",typeof o=="string"?t.stringToBuffer(o):o,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:l?t.stringToBuffer(l):t.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),w=h.slice(0,16),m=await this.driver.decrypt({name:"AES-CBC",iv:w},p,h.slice(16));return t.concatBuffers([m])}};i.default=r}),Cxt=Yu(i=>{i.read=function(t,r,h,o,l){var c,p,w=l*8-o-1,m=(1<<w)-1,y=m>>1,v=-7,M=h?l-1:0,T=h?-1:1,A=t[r+M];for(M+=T,c=A&(1<<-v)-1,A>>=-v,v+=w;v>0;c=c*256+t[r+M],M+=T,v-=8);for(p=c&(1<<-v)-1,c>>=-v,v+=o;v>0;p=p*256+t[r+M],M+=T,v-=8);if(c===0)c=1-y;else{if(c===m)return p?NaN:(A?-1:1)*(1/0);p=p+Math.pow(2,o),c=c-y}return(A?-1:1)*p*Math.pow(2,c-o)},i.write=function(t,r,h,o,l,c){var p,w,m,y=c*8-l-1,v=(1<<y)-1,M=v>>1,T=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=o?0:c-1,R=o?1:-1,B=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(w=isNaN(r)?1:0,p=v):(p=Math.floor(Math.log(r)/Math.LN2),r*(m=Math.pow(2,-p))<1&&(p--,m*=2),p+M>=1?r+=T/m:r+=T*Math.pow(2,1-M),r*m>=2&&(p++,m/=2),p+M>=v?(w=0,p=v):p+M>=1?(w=(r*m-1)*Math.pow(2,l),p=p+M):(w=r*Math.pow(2,M-1)*Math.pow(2,l),p=0));l>=8;t[h+A]=w&255,A+=R,w/=256,l-=8);for(p=p<<l|w,y+=l;y>0;t[h+A]=p&255,A+=R,p/=256,y-=8);t[h+A-R]|=B*128}}),uO=Yu(i=>{"use strict";var t=Nnt(),r=Cxt(),h=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=p,i.SlowBuffer=P,i.INSPECT_MAX_BYTES=50;var o=2147483647;i.kMaxLength=o,p.TYPED_ARRAY_SUPPORT=l(),!p.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{let I=new Uint8Array(1),O={foo:function(){return 42}};return Object.setPrototypeOf(O,Uint8Array.prototype),Object.setPrototypeOf(I,O),I.foo()===42}catch{return!1}}Object.defineProperty(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}}),Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}});function c(I){if(I>o)throw new RangeError('The value "'+I+'" is invalid for option "size"');let O=new Uint8Array(I);return Object.setPrototypeOf(O,p.prototype),O}function p(I,O,L){if(typeof I=="number"){if(typeof O=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(I)}return w(I,O,L)}p.poolSize=8192;function w(I,O,L){if(typeof I=="string")return M(I,O);if(ArrayBuffer.isView(I))return A(I);if(I==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof I);if(mt(I,ArrayBuffer)||I&&mt(I.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(I,SharedArrayBuffer)||I&&mt(I.buffer,SharedArrayBuffer)))return R(I,O,L);if(typeof I=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let V=I.valueOf&&I.valueOf();if(V!=null&&V!==I)return p.from(V,O,L);let st=B(I);if(st)return st;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof I[Symbol.toPrimitive]=="function")return p.from(I[Symbol.toPrimitive]("string"),O,L);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof I)}p.from=function(I,O,L){return w(I,O,L)},Object.setPrototypeOf(p.prototype,Uint8Array.prototype),Object.setPrototypeOf(p,Uint8Array);function m(I){if(typeof I!="number")throw new TypeError('"size" argument must be of type number');if(I<0)throw new RangeError('The value "'+I+'" is invalid for option "size"')}function y(I,O,L){return m(I),I<=0?c(I):O!==void 0?typeof L=="string"?c(I).fill(O,L):c(I).fill(O):c(I)}p.alloc=function(I,O,L){return y(I,O,L)};function v(I){return m(I),c(I<0?0:C(I)|0)}p.allocUnsafe=function(I){return v(I)},p.allocUnsafeSlow=function(I){return v(I)};function M(I,O){if((typeof O!="string"||O==="")&&(O="utf8"),!p.isEncoding(O))throw new TypeError("Unknown encoding: "+O);let L=N(I,O)|0,V=c(L),st=V.write(I,O);return st!==L&&(V=V.slice(0,st)),V}function T(I){let O=I.length<0?0:C(I.length)|0,L=c(O);for(let V=0;V<O;V+=1)L[V]=I[V]&255;return L}function A(I){if(mt(I,Uint8Array)){let O=new Uint8Array(I);return R(O.buffer,O.byteOffset,O.byteLength)}return T(I)}function R(I,O,L){if(O<0||I.byteLength<O)throw new RangeError('"offset" is outside of buffer bounds');if(I.byteLength<O+(L||0))throw new RangeError('"length" is outside of buffer bounds');let V;return O===void 0&&L===void 0?V=new Uint8Array(I):L===void 0?V=new Uint8Array(I,O):V=new Uint8Array(I,O,L),Object.setPrototypeOf(V,p.prototype),V}function B(I){if(p.isBuffer(I)){let O=C(I.length)|0,L=c(O);return L.length===0||I.copy(L,0,0,O),L}if(I.length!==void 0)return typeof I.length!="number"||wt(I.length)?c(0):T(I);if(I.type==="Buffer"&&Array.isArray(I.data))return T(I.data)}function C(I){if(I>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return I|0}function P(I){return+I!=I&&(I=0),p.alloc(+I)}p.isBuffer=function(I){return I!=null&&I._isBuffer===!0&&I!==p.prototype},p.compare=function(I,O){if(mt(I,Uint8Array)&&(I=p.from(I,I.offset,I.byteLength)),mt(O,Uint8Array)&&(O=p.from(O,O.offset,O.byteLength)),!p.isBuffer(I)||!p.isBuffer(O))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(I===O)return 0;let L=I.length,V=O.length;for(let st=0,ft=Math.min(L,V);st<ft;++st)if(I[st]!==O[st]){L=I[st],V=O[st];break}return L<V?-1:V<L?1:0},p.isEncoding=function(I){switch(String(I).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},p.concat=function(I,O){if(!Array.isArray(I))throw new TypeError('"list" argument must be an Array of Buffers');if(I.length===0)return p.alloc(0);let L;if(O===void 0)for(O=0,L=0;L<I.length;++L)O+=I[L].length;let V=p.allocUnsafe(O),st=0;for(L=0;L<I.length;++L){let ft=I[L];if(mt(ft,Uint8Array))st+ft.length>V.length?(p.isBuffer(ft)||(ft=p.from(ft)),ft.copy(V,st)):Uint8Array.prototype.set.call(V,ft,st);else if(p.isBuffer(ft))ft.copy(V,st);else throw new TypeError('"list" argument must be an Array of Buffers');st+=ft.length}return V};function N(I,O){if(p.isBuffer(I))return I.length;if(ArrayBuffer.isView(I)||mt(I,ArrayBuffer))return I.byteLength;if(typeof I!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof I);let L=I.length,V=arguments.length>2&&arguments[2]===!0;if(!V&&L===0)return 0;let st=!1;for(;;)switch(O){case"ascii":case"latin1":case"binary":return L;case"utf8":case"utf-8":return ut(I).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L*2;case"hex":return L>>>1;case"base64":return bt(I).length;default:if(st)return V?-1:ut(I).length;O=(""+O).toLowerCase(),st=!0}}p.byteLength=N;function q(I,O,L){let V=!1;if((O===void 0||O<0)&&(O=0),O>this.length||((L===void 0||L>this.length)&&(L=this.length),L<=0)||(L>>>=0,O>>>=0,L<=O))return"";for(I||(I="utf8");;)switch(I){case"hex":return e(this,O,L);case"utf8":case"utf-8":return d(this,O,L);case"ascii":return x(this,O,L);case"latin1":case"binary":return a(this,O,L);case"base64":return f(this,O,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u(this,O,L);default:if(V)throw new TypeError("Unknown encoding: "+I);I=(I+"").toLowerCase(),V=!0}}p.prototype._isBuffer=!0;function W(I,O,L){let V=I[O];I[O]=I[L],I[L]=V}p.prototype.swap16=function(){let I=this.length;if(I%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let O=0;O<I;O+=2)W(this,O,O+1);return this},p.prototype.swap32=function(){let I=this.length;if(I%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let O=0;O<I;O+=4)W(this,O,O+3),W(this,O+1,O+2);return this},p.prototype.swap64=function(){let I=this.length;if(I%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let O=0;O<I;O+=8)W(this,O,O+7),W(this,O+1,O+6),W(this,O+2,O+5),W(this,O+3,O+4);return this},p.prototype.toString=function(){let I=this.length;return I===0?"":arguments.length===0?d(this,0,I):q.apply(this,arguments)},p.prototype.toLocaleString=p.prototype.toString,p.prototype.equals=function(I){if(!p.isBuffer(I))throw new TypeError("Argument must be a Buffer");return this===I?!0:p.compare(this,I)===0},p.prototype.inspect=function(){let I="",O=i.INSPECT_MAX_BYTES;return I=this.toString("hex",0,O).replace(/(.{2})/g,"$1 ").trim(),this.length>O&&(I+=" ... "),"<Buffer "+I+">"},h&&(p.prototype[h]=p.prototype.inspect),p.prototype.compare=function(I,O,L,V,st){if(mt(I,Uint8Array)&&(I=p.from(I,I.offset,I.byteLength)),!p.isBuffer(I))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof I);if(O===void 0&&(O=0),L===void 0&&(L=I?I.length:0),V===void 0&&(V=0),st===void 0&&(st=this.length),O<0||L>I.length||V<0||st>this.length)throw new RangeError("out of range index");if(V>=st&&O>=L)return 0;if(V>=st)return-1;if(O>=L)return 1;if(O>>>=0,L>>>=0,V>>>=0,st>>>=0,this===I)return 0;let ft=st-V,ht=L-O,Et=Math.min(ft,ht),_t=this.slice(V,st),vt=I.slice(O,L);for(let Qt=0;Qt<Et;++Qt)if(_t[Qt]!==vt[Qt]){ft=_t[Qt],ht=vt[Qt];break}return ft<ht?-1:ht<ft?1:0};function J(I,O,L,V,st){if(I.length===0)return-1;if(typeof L=="string"?(V=L,L=0):L>2147483647?L=2147483647:L<-2147483648&&(L=-2147483648),L=+L,wt(L)&&(L=st?0:I.length-1),L<0&&(L=I.length+L),L>=I.length){if(st)return-1;L=I.length-1}else if(L<0)if(st)L=0;else return-1;if(typeof O=="string"&&(O=p.from(O,V)),p.isBuffer(O))return O.length===0?-1:F(I,O,L,V,st);if(typeof O=="number")return O=O&255,typeof Uint8Array.prototype.indexOf=="function"?st?Uint8Array.prototype.indexOf.call(I,O,L):Uint8Array.prototype.lastIndexOf.call(I,O,L):F(I,[O],L,V,st);throw new TypeError("val must be string, number or Buffer")}function F(I,O,L,V,st){let ft=1,ht=I.length,Et=O.length;if(V!==void 0&&(V=String(V).toLowerCase(),V==="ucs2"||V==="ucs-2"||V==="utf16le"||V==="utf-16le")){if(I.length<2||O.length<2)return-1;ft=2,ht/=2,Et/=2,L/=2}function _t(Qt,It){return ft===1?Qt[It]:Qt.readUInt16BE(It*ft)}let vt;if(st){let Qt=-1;for(vt=L;vt<ht;vt++)if(_t(I,vt)===_t(O,Qt===-1?0:vt-Qt)){if(Qt===-1&&(Qt=vt),vt-Qt+1===Et)return Qt*ft}else Qt!==-1&&(vt-=vt-Qt),Qt=-1}else for(L+Et>ht&&(L=ht-Et),vt=L;vt>=0;vt--){let Qt=!0;for(let It=0;It<Et;It++)if(_t(I,vt+It)!==_t(O,It)){Qt=!1;break}if(Qt)return vt}return-1}p.prototype.includes=function(I,O,L){return this.indexOf(I,O,L)!==-1},p.prototype.indexOf=function(I,O,L){return J(this,I,O,L,!0)},p.prototype.lastIndexOf=function(I,O,L){return J(this,I,O,L,!1)};function H(I,O,L,V){L=Number(L)||0;let st=I.length-L;V?(V=Number(V),V>st&&(V=st)):V=st;let ft=O.length;V>ft/2&&(V=ft/2);let ht;for(ht=0;ht<V;++ht){let Et=parseInt(O.substr(ht*2,2),16);if(wt(Et))return ht;I[L+ht]=Et}return ht}function Y(I,O,L,V){return lt(ut(O,I.length-L),I,L,V)}function E(I,O,L,V){return lt(pt(O),I,L,V)}function n(I,O,L,V){return lt(bt(O),I,L,V)}function s(I,O,L,V){return lt(St(O,I.length-L),I,L,V)}p.prototype.write=function(I,O,L,V){if(O===void 0)V="utf8",L=this.length,O=0;else if(L===void 0&&typeof O=="string")V=O,L=this.length,O=0;else if(isFinite(O))O=O>>>0,isFinite(L)?(L=L>>>0,V===void 0&&(V="utf8")):(V=L,L=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let st=this.length-O;if((L===void 0||L>st)&&(L=st),I.length>0&&(L<0||O<0)||O>this.length)throw new RangeError("Attempt to write outside buffer bounds");V||(V="utf8");let ft=!1;for(;;)switch(V){case"hex":return H(this,I,O,L);case"utf8":case"utf-8":return Y(this,I,O,L);case"ascii":case"latin1":case"binary":return E(this,I,O,L);case"base64":return n(this,I,O,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s(this,I,O,L);default:if(ft)throw new TypeError("Unknown encoding: "+V);V=(""+V).toLowerCase(),ft=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function f(I,O,L){return O===0&&L===I.length?t.fromByteArray(I):t.fromByteArray(I.slice(O,L))}function d(I,O,L){L=Math.min(I.length,L);let V=[],st=O;for(;st<L;){let ft=I[st],ht=null,Et=ft>239?4:ft>223?3:ft>191?2:1;if(st+Et<=L){let _t,vt,Qt,It;switch(Et){case 1:ft<128&&(ht=ft);break;case 2:_t=I[st+1],(_t&192)===128&&(It=(ft&31)<<6|_t&63,It>127&&(ht=It));break;case 3:_t=I[st+1],vt=I[st+2],(_t&192)===128&&(vt&192)===128&&(It=(ft&15)<<12|(_t&63)<<6|vt&63,It>2047&&(It<55296||It>57343)&&(ht=It));break;case 4:_t=I[st+1],vt=I[st+2],Qt=I[st+3],(_t&192)===128&&(vt&192)===128&&(Qt&192)===128&&(It=(ft&15)<<18|(_t&63)<<12|(vt&63)<<6|Qt&63,It>65535&&It<1114112&&(ht=It))}}ht===null?(ht=65533,Et=1):ht>65535&&(ht-=65536,V.push(ht>>>10&1023|55296),ht=56320|ht&1023),V.push(ht),st+=Et}return S(V)}var g=4096;function S(I){let O=I.length;if(O<=g)return String.fromCharCode.apply(String,I);let L="",V=0;for(;V<O;)L+=String.fromCharCode.apply(String,I.slice(V,V+=g));return L}function x(I,O,L){let V="";L=Math.min(I.length,L);for(let st=O;st<L;++st)V+=String.fromCharCode(I[st]&127);return V}function a(I,O,L){let V="";L=Math.min(I.length,L);for(let st=O;st<L;++st)V+=String.fromCharCode(I[st]);return V}function e(I,O,L){let V=I.length;(!O||O<0)&&(O=0),(!L||L<0||L>V)&&(L=V);let st="";for(let ft=O;ft<L;++ft)st+=Mt[I[ft]];return st}function u(I,O,L){let V=I.slice(O,L),st="";for(let ft=0;ft<V.length-1;ft+=2)st+=String.fromCharCode(V[ft]+V[ft+1]*256);return st}p.prototype.slice=function(I,O){let L=this.length;I=~~I,O=O===void 0?L:~~O,I<0?(I+=L,I<0&&(I=0)):I>L&&(I=L),O<0?(O+=L,O<0&&(O=0)):O>L&&(O=L),O<I&&(O=I);let V=this.subarray(I,O);return Object.setPrototypeOf(V,p.prototype),V};function b(I,O,L){if(I%1!==0||I<0)throw new RangeError("offset is not uint");if(I+O>L)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I],st=1,ft=0;for(;++ft<O&&(st*=256);)V+=this[I+ft]*st;return V},p.prototype.readUintBE=p.prototype.readUIntBE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I+--O],st=1;for(;O>0&&(st*=256);)V+=this[I+--O]*st;return V},p.prototype.readUint8=p.prototype.readUInt8=function(I,O){return I=I>>>0,O||b(I,1,this.length),this[I]},p.prototype.readUint16LE=p.prototype.readUInt16LE=function(I,O){return I=I>>>0,O||b(I,2,this.length),this[I]|this[I+1]<<8},p.prototype.readUint16BE=p.prototype.readUInt16BE=function(I,O){return I=I>>>0,O||b(I,2,this.length),this[I]<<8|this[I+1]},p.prototype.readUint32LE=p.prototype.readUInt32LE=function(I,O){return I=I>>>0,O||b(I,4,this.length),(this[I]|this[I+1]<<8|this[I+2]<<16)+this[I+3]*16777216},p.prototype.readUint32BE=p.prototype.readUInt32BE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]*16777216+(this[I+1]<<16|this[I+2]<<8|this[I+3])},p.prototype.readBigUInt64LE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=O+this[++I]*2**8+this[++I]*2**16+this[++I]*2**24,st=this[++I]+this[++I]*2**8+this[++I]*2**16+L*2**24;return BigInt(V)+(BigInt(st)<<BigInt(32))}),p.prototype.readBigUInt64BE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=O*2**24+this[++I]*2**16+this[++I]*2**8+this[++I],st=this[++I]*2**24+this[++I]*2**16+this[++I]*2**8+L;return(BigInt(V)<<BigInt(32))+BigInt(st)}),p.prototype.readIntLE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I],st=1,ft=0;for(;++ft<O&&(st*=256);)V+=this[I+ft]*st;return st*=128,V>=st&&(V-=Math.pow(2,8*O)),V},p.prototype.readIntBE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=O,st=1,ft=this[I+--V];for(;V>0&&(st*=256);)ft+=this[I+--V]*st;return st*=128,ft>=st&&(ft-=Math.pow(2,8*O)),ft},p.prototype.readInt8=function(I,O){return I=I>>>0,O||b(I,1,this.length),this[I]&128?(255-this[I]+1)*-1:this[I]},p.prototype.readInt16LE=function(I,O){I=I>>>0,O||b(I,2,this.length);let L=this[I]|this[I+1]<<8;return L&32768?L|4294901760:L},p.prototype.readInt16BE=function(I,O){I=I>>>0,O||b(I,2,this.length);let L=this[I+1]|this[I]<<8;return L&32768?L|4294901760:L},p.prototype.readInt32LE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]|this[I+1]<<8|this[I+2]<<16|this[I+3]<<24},p.prototype.readInt32BE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]<<24|this[I+1]<<16|this[I+2]<<8|this[I+3]},p.prototype.readBigInt64LE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=this[I+4]+this[I+5]*2**8+this[I+6]*2**16+(L<<24);return(BigInt(V)<<BigInt(32))+BigInt(O+this[++I]*2**8+this[++I]*2**16+this[++I]*2**24)}),p.prototype.readBigInt64BE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=(O<<24)+this[++I]*2**16+this[++I]*2**8+this[++I];return(BigInt(V)<<BigInt(32))+BigInt(this[++I]*2**24+this[++I]*2**16+this[++I]*2**8+L)}),p.prototype.readFloatLE=function(I,O){return I=I>>>0,O||b(I,4,this.length),r.read(this,I,!0,23,4)},p.prototype.readFloatBE=function(I,O){return I=I>>>0,O||b(I,4,this.length),r.read(this,I,!1,23,4)},p.prototype.readDoubleLE=function(I,O){return I=I>>>0,O||b(I,8,this.length),r.read(this,I,!0,52,8)},p.prototype.readDoubleBE=function(I,O){return I=I>>>0,O||b(I,8,this.length),r.read(this,I,!1,52,8)};function _(I,O,L,V,st,ft){if(!p.isBuffer(I))throw new TypeError('"buffer" argument must be a Buffer instance');if(O>st||O<ft)throw new RangeError('"value" argument is out of bounds');if(L+V>I.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(I,O,L,V){if(I=+I,O=O>>>0,L=L>>>0,!V){let ht=Math.pow(2,8*L)-1;_(this,I,O,L,ht,0)}let st=1,ft=0;for(this[O]=I&255;++ft<L&&(st*=256);)this[O+ft]=I/st&255;return O+L},p.prototype.writeUintBE=p.prototype.writeUIntBE=function(I,O,L,V){if(I=+I,O=O>>>0,L=L>>>0,!V){let ht=Math.pow(2,8*L)-1;_(this,I,O,L,ht,0)}let st=L-1,ft=1;for(this[O+st]=I&255;--st>=0&&(ft*=256);)this[O+st]=I/ft&255;return O+L},p.prototype.writeUint8=p.prototype.writeUInt8=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,1,255,0),this[O]=I&255,O+1},p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,65535,0),this[O]=I&255,this[O+1]=I>>>8,O+2},p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,65535,0),this[O]=I>>>8,this[O+1]=I&255,O+2},p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,4294967295,0),this[O+3]=I>>>24,this[O+2]=I>>>16,this[O+1]=I>>>8,this[O]=I&255,O+4},p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,4294967295,0),this[O]=I>>>24,this[O+1]=I>>>16,this[O+2]=I>>>8,this[O+3]=I&255,O+4};function k(I,O,L,V,st){U(O,V,st,I,L,7);let ft=Number(O&BigInt(4294967295));I[L++]=ft,ft=ft>>8,I[L++]=ft,ft=ft>>8,I[L++]=ft,ft=ft>>8,I[L++]=ft;let ht=Number(O>>BigInt(32)&BigInt(4294967295));return I[L++]=ht,ht=ht>>8,I[L++]=ht,ht=ht>>8,I[L++]=ht,ht=ht>>8,I[L++]=ht,L}function $(I,O,L,V,st){U(O,V,st,I,L,7);let ft=Number(O&BigInt(4294967295));I[L+7]=ft,ft=ft>>8,I[L+6]=ft,ft=ft>>8,I[L+5]=ft,ft=ft>>8,I[L+4]=ft;let ht=Number(O>>BigInt(32)&BigInt(4294967295));return I[L+3]=ht,ht=ht>>8,I[L+2]=ht,ht=ht>>8,I[L+1]=ht,ht=ht>>8,I[L]=ht,L+8}p.prototype.writeBigUInt64LE=ne(function(I,O=0){return k(this,I,O,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeBigUInt64BE=ne(function(I,O=0){return $(this,I,O,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeIntLE=function(I,O,L,V){if(I=+I,O=O>>>0,!V){let Et=Math.pow(2,8*L-1);_(this,I,O,L,Et-1,-Et)}let st=0,ft=1,ht=0;for(this[O]=I&255;++st<L&&(ft*=256);)I<0&&ht===0&&this[O+st-1]!==0&&(ht=1),this[O+st]=(I/ft>>0)-ht&255;return O+L},p.prototype.writeIntBE=function(I,O,L,V){if(I=+I,O=O>>>0,!V){let Et=Math.pow(2,8*L-1);_(this,I,O,L,Et-1,-Et)}let st=L-1,ft=1,ht=0;for(this[O+st]=I&255;--st>=0&&(ft*=256);)I<0&&ht===0&&this[O+st+1]!==0&&(ht=1),this[O+st]=(I/ft>>0)-ht&255;return O+L},p.prototype.writeInt8=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,1,127,-128),I<0&&(I=255+I+1),this[O]=I&255,O+1},p.prototype.writeInt16LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,32767,-32768),this[O]=I&255,this[O+1]=I>>>8,O+2},p.prototype.writeInt16BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,32767,-32768),this[O]=I>>>8,this[O+1]=I&255,O+2},p.prototype.writeInt32LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,2147483647,-2147483648),this[O]=I&255,this[O+1]=I>>>8,this[O+2]=I>>>16,this[O+3]=I>>>24,O+4},p.prototype.writeInt32BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,2147483647,-2147483648),I<0&&(I=4294967295+I+1),this[O]=I>>>24,this[O+1]=I>>>16,this[O+2]=I>>>8,this[O+3]=I&255,O+4},p.prototype.writeBigInt64LE=ne(function(I,O=0){return k(this,I,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),p.prototype.writeBigInt64BE=ne(function(I,O=0){return $(this,I,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function it(I,O,L,V,st,ft){if(L+V>I.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("Index out of range")}function Z(I,O,L,V,st){return O=+O,L=L>>>0,st||it(I,O,L,4,34028234663852886e22,-34028234663852886e22),r.write(I,O,L,V,23,4),L+4}p.prototype.writeFloatLE=function(I,O,L){return Z(this,I,O,!0,L)},p.prototype.writeFloatBE=function(I,O,L){return Z(this,I,O,!1,L)};function et(I,O,L,V,st){return O=+O,L=L>>>0,st||it(I,O,L,8,17976931348623157e292,-17976931348623157e292),r.write(I,O,L,V,52,8),L+8}p.prototype.writeDoubleLE=function(I,O,L){return et(this,I,O,!0,L)},p.prototype.writeDoubleBE=function(I,O,L){return et(this,I,O,!1,L)},p.prototype.copy=function(I,O,L,V){if(!p.isBuffer(I))throw new TypeError("argument should be a Buffer");if(L||(L=0),!V&&V!==0&&(V=this.length),O>=I.length&&(O=I.length),O||(O=0),V>0&&V<L&&(V=L),V===L||I.length===0||this.length===0)return 0;if(O<0)throw new RangeError("targetStart out of bounds");if(L<0||L>=this.length)throw new RangeError("Index out of range");if(V<0)throw new RangeError("sourceEnd out of bounds");V>this.length&&(V=this.length),I.length-O<V-L&&(V=I.length-O+L);let st=V-L;return this===I&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(O,L,V):Uint8Array.prototype.set.call(I,this.subarray(L,V),O),st},p.prototype.fill=function(I,O,L,V){if(typeof I=="string"){if(typeof O=="string"?(V=O,O=0,L=this.length):typeof L=="string"&&(V=L,L=this.length),V!==void 0&&typeof V!="string")throw new TypeError("encoding must be a string");if(typeof V=="string"&&!p.isEncoding(V))throw new TypeError("Unknown encoding: "+V);if(I.length===1){let ft=I.charCodeAt(0);(V==="utf8"&&ft<128||V==="latin1")&&(I=ft)}}else typeof I=="number"?I=I&255:typeof I=="boolean"&&(I=Number(I));if(O<0||this.length<O||this.length<L)throw new RangeError("Out of range index");if(L<=O)return this;O=O>>>0,L=L===void 0?this.length:L>>>0,I||(I=0);let st;if(typeof I=="number")for(st=O;st<L;++st)this[st]=I;else{let ft=p.isBuffer(I)?I:p.from(I,V),ht=ft.length;if(ht===0)throw new TypeError('The value "'+I+'" is invalid for argument "value"');for(st=0;st<L-O;++st)this[st+O]=ft[st%ht]}return this};var Q={};function z(I,O,L){Q[I]=class extends L{constructor(){super(),Object.defineProperty(this,"message",{value:O.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${I}]`,this.stack,delete this.name}get code(){return I}set code(V){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:V,writable:!0})}toString(){return`${this.name} [${I}]: ${this.message}`}}}z("ERR_BUFFER_OUT_OF_BOUNDS",function(I){return I?`${I} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),z("ERR_INVALID_ARG_TYPE",function(I,O){return`The "${I}" argument must be of type number. Received type ${typeof O}`},TypeError),z("ERR_OUT_OF_RANGE",function(I,O,L){let V=`The value of "${I}" is out of range.`,st=L;return Number.isInteger(L)&&Math.abs(L)>2**32?st=tt(String(L)):typeof L=="bigint"&&(st=String(L),(L>BigInt(2)**BigInt(32)||L<-(BigInt(2)**BigInt(32)))&&(st=tt(st)),st+="n"),V+=` It must be ${O}. Received ${st}`,V},RangeError);function tt(I){let O="",L=I.length,V=I[0]==="-"?1:0;for(;L>=V+4;L-=3)O=`_${I.slice(L-3,L)}${O}`;return`${I.slice(0,L)}${O}`}function X(I,O,L){j(O,"offset"),(I[O]===void 0||I[O+L]===void 0)&&rt(O,I.length-(L+1))}function U(I,O,L,V,st,ft){if(I>L||I<O){let ht=typeof O=="bigint"?"n":"",Et;throw ft>3?O===0||O===BigInt(0)?Et=`>= 0${ht} and < 2${ht} ** ${(ft+1)*8}${ht}`:Et=`>= -(2${ht} ** ${(ft+1)*8-1}${ht}) and < 2 ** ${(ft+1)*8-1}${ht}`:Et=`>= ${O}${ht} and <= ${L}${ht}`,new Q.ERR_OUT_OF_RANGE("value",Et,I)}X(V,st,ft)}function j(I,O){if(typeof I!="number")throw new Q.ERR_INVALID_ARG_TYPE(O,"number",I)}function rt(I,O,L){throw Math.floor(I)!==I?(j(I,L),new Q.ERR_OUT_OF_RANGE(L||"offset","an integer",I)):O<0?new Q.ERR_BUFFER_OUT_OF_BOUNDS:new Q.ERR_OUT_OF_RANGE(L||"offset",`>= ${L?1:0} and <= ${O}`,I)}var ot=/[^+/0-9A-Za-z-_]/g;function ct(I){if(I=I.split("=")[0],I=I.trim().replace(ot,""),I.length<2)return"";for(;I.length%4!==0;)I=I+"=";return I}function ut(I,O){O=O||1/0;let L,V=I.length,st=null,ft=[];for(let ht=0;ht<V;++ht){if(L=I.charCodeAt(ht),L>55295&&L<57344){if(!st){if(L>56319){(O-=3)>-1&&ft.push(239,191,189);continue}else if(ht+1===V){(O-=3)>-1&&ft.push(239,191,189);continue}st=L;continue}if(L<56320){(O-=3)>-1&&ft.push(239,191,189),st=L;continue}L=(st-55296<<10|L-56320)+65536}else st&&(O-=3)>-1&&ft.push(239,191,189);if(st=null,L<128){if((O-=1)<0)break;ft.push(L)}else if(L<2048){if((O-=2)<0)break;ft.push(L>>6|192,L&63|128)}else if(L<65536){if((O-=3)<0)break;ft.push(L>>12|224,L>>6&63|128,L&63|128)}else if(L<1114112){if((O-=4)<0)break;ft.push(L>>18|240,L>>12&63|128,L>>6&63|128,L&63|128)}else throw new Error("Invalid code point")}return ft}function pt(I){let O=[];for(let L=0;L<I.length;++L)O.push(I.charCodeAt(L)&255);return O}function St(I,O){let L,V,st,ft=[];for(let ht=0;ht<I.length&&!((O-=2)<0);++ht)L=I.charCodeAt(ht),V=L>>8,st=L%256,ft.push(st),ft.push(V);return ft}function bt(I){return t.toByteArray(ct(I))}function lt(I,O,L,V){let st;for(st=0;st<V&&!(st+L>=O.length||st>=I.length);++st)O[st+L]=I[st];return st}function mt(I,O){return I instanceof O||I!=null&&I.constructor!=null&&I.constructor.name!=null&&I.constructor.name===O.name}function wt(I){return I!==I}var Mt=function(){let I="0123456789abcdef",O=new Array(256);for(let L=0;L<16;++L){let V=L*16;for(let st=0;st<16;++st)O[V+st]=I[L]+I[st]}return O}();function ne(I){return typeof BigInt>"u"?nt:I}function nt(){throw new Error("BigInt not supported")}}),Pxt=Yu((i,t)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,t.exports={Buffer:uO().Buffer,Crypto:window.crypto}):t.exports={Buffer:uO().Buffer,Crypto:crypto}}),Dnt={};Rxt(Dnt,{AVSCTap:()=>gv,ArweaveSigner:()=>pO,DataItem:()=>pv,MAX_TAG_BYTES:()=>nw,MIN_BINARY_SIZE:()=>vO,SIG_CONFIG:()=>Ip,SignatureConfig:()=>sh,Signer:()=>$nt,createData:()=>jnt,deserializeTags:()=>iw,indexToType:()=>gO,serializeTags:()=>mO,tagsExceedLimit:()=>Fnt});$nt=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(i,t,r,h){throw new Error("You must implement verify method on child")}},Nxt=fd(dO(),1),Yh=fd(Lnt(),1);fO=fd(Oxt(),1),Lxt=fO.default.default?fO.default.default:fO.default,Dxt=class extends Lxt{getPublicKey(i){throw new Error("Unimplemented")}};(function(i){i[i.ARWEAVE=1]="ARWEAVE",i[i.ED25519=2]="ED25519",i[i.ETHEREUM=3]="ETHEREUM",i[i.SOLANA=4]="SOLANA",i[i.INJECTEDAPTOS=5]="INJECTEDAPTOS",i[i.MULTIAPTOS=6]="MULTIAPTOS",i[i.TYPEDETHEREUM=7]="TYPEDETHEREUM"})(sh||(sh={}));Ip={[sh.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[sh.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[sh.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[sh.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[sh.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[sh.MULTIAPTOS]:{sigLength:64*32+4,pubLength:32*32+1,sigName:"multiAptos"},[sh.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},pO=class{signatureType=1;ownerLength=Ip[1].pubLength;signatureLength=Ip[1].sigLength;jwk;pk;constructor(i){this.pk=i.n,this.jwk=i}get publicKey(){return Nxt.default.toBuffer(this.pk)}sign(i){return Xu().sign(this.jwk,i)}static async verify(i,t,r){return await Xu().verify(i,t,r)}},gO={1:pO},Hf=fd(dO(),1);gv=class{buf;pos;constructor(i=ge.alloc(nw),t=0){this.buf=i,this.pos=t}writeTags(i){if(!Array.isArray(i))throw new Error("input must be array");let t=i.length,r;if(t)for(this.writeLong(t),r=0;r<t;r++){let h=i[r];if(h?.name===void 0||h?.value===void 0)throw new Error(`Invalid tag format for ${h}, expected {name:string, value: string}`);this.writeString(h.name),this.writeString(h.value)}this.writeLong(0)}toBuffer(){let i=ge.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(i,0,0,this.pos),i}tagsExceedLimit(){return this.pos>this.buf.length}writeLong(i){let t=this.buf,r,h;if(i>=-1073741824&&i<1073741824){h=i>=0?i<<1:~i<<1|1;do t[this.pos]=h&127,h>>=7;while(h&&(t[this.pos++]|=128))}else{r=i>=0?i*2:-i*2-1;do t[this.pos]=r&127,r/=128;while(r>=1&&(t[this.pos++]|=128))}this.pos++,this.buf=t}writeString(i){let t=ge.byteLength(i),r=this.buf;this.writeLong(t);let h=this.pos;if(this.pos+=t,!(this.pos>r.length)){if(t>64)this.buf.write(i,this.pos-t,t,"utf8");else{let o,l,c,p;for(o=0,l=t;o<l;o++)c=i.charCodeAt(o),c<128?r[h++]=c:c<2048?(r[h++]=c>>6|192,r[h++]=c&63|128):(c&64512)===55296&&((p=i.charCodeAt(o+1))&64512)===56320?(c=65536+((c&1023)<<10)+(p&1023),o++,r[h++]=c>>18|240,r[h++]=c>>12&63|128,r[h++]=c>>6&63|128,r[h++]=c&63|128):(r[h++]=c>>12|224,r[h++]=c>>6&63|128,r[h++]=c&63|128)}this.buf=r}}readLong(){let i=0,t=0,r=this.buf,h,o,l,c;do h=r[this.pos++],o=h&128,i|=(h&127)<<t,t+=7;while(o&&t<28);if(o){l=i,c=268435456;do h=r[this.pos++],l+=(h&127)*c,c*=128;while(h&128);return(l%2?-(l+1):l)/2}return i>>1^-(i&1)}skipLong(){let i=this.buf;for(;i[this.pos++]&128;);}readTags(){let i=[],t;for(;t=this.readLong();)for(t<0&&(t=-t,this.skipLong());t--;){let r=this.readString(),h=this.readString();i.push({name:r,value:h})}return i}readString(){let i=this.readLong(),t=this.pos,r=this.buf;if(this.pos+=i,!(this.pos>r.length))return this.buf.slice(t,t+i).toString()}};jxt=fd(Pxt(),1),kp=fd(uO(),1),nw=4096,vO=80,pv=class{binary;_id;constructor(i){this.binary=i}static isDataItem(i){return i.binary!==void 0}get signatureType(){let i=bl(this.binary.subarray(0,2));if(sh?.[i]!==void 0)return i;throw new Error("Unknown signature type: "+i)}async isValid(){return pv.verify(this.binary)}get id(){return(async()=>Hf.default.encode(await this.rawId))()}set id(i){this._id=Hf.default.toBuffer(i)}get rawId(){return(async()=>kp.Buffer.from(await jxt.Crypto.subtle.digest("SHA-256",this.rawSignature)))()}set rawId(i){this._id=i}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return Hf.default.encode(this.rawSignature)}set rawOwner(i){if(i.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${i.byteLength} bytes.`);this.binary.set(i,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return Ip[this.signatureType].sigLength}get owner(){return Hf.default.encode(this.rawOwner)}get ownerLength(){return Ip[this.signatureType].pubLength}get rawTarget(){let i=this.getTargetStart();return this.binary[i]==1?this.binary.subarray(i+1,i+33):kp.Buffer.alloc(0)}get target(){return Hf.default.encode(this.rawTarget)}get rawAnchor(){let i=this.getAnchorStart();return this.binary[i]==1?this.binary.subarray(i+1,i+33):kp.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let i=this.getTagsStart(),t=bl(this.binary.subarray(i+8,i+16));return this.binary.subarray(i+16,i+16+t)}get tags(){let i=this.getTagsStart();if(bl(this.binary.subarray(i,i+8))==0)return[];let t=bl(this.binary.subarray(i+8,i+16));return iw(kp.Buffer.from(this.binary.subarray(i+16,i+16+t)))}get tagsB64Url(){return this.tags.map(i=>({name:Hf.default.encode(i.name),value:Hf.default.encode(i.value)}))}getStartOfData(){let i=this.getTagsStart(),t=this.binary.subarray(i+8,i+16),r=bl(t);return i+16+r}get rawData(){let i=this.getTagsStart(),t=this.binary.subarray(i+8,i+16),r=bl(t),h=i+16+r;return this.binary.subarray(h,this.binary.length)}get data(){return Hf.default.encode(this.rawData)}getRaw(){return this.binary}async sign(i){return this._id=await qxt(this,i),this.rawId}async setSignature(i){this.binary.set(i,2),this._id=kp.Buffer.from(await Xu().hash(i))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map(i=>({name:Hf.default.encode(i.name),value:Hf.default.encode(i.value)})),data:this.data}}static async verify(i){if(i.byteLength<vO)return!1;let t=new pv(i),r=t.signatureType,h=t.getTagsStart(),o=bl(i.subarray(h,h+8)),l=i.subarray(h+8,h+16),c=bl(l);if(c>nw)return!1;if(o>0)try{if(iw(kp.Buffer.from(i.subarray(h+16,h+16+c))).length!==o)return!1}catch{return!1}let p=gO[r],w=await cO(t);return await p.verify(t.rawOwner,w,t.rawSignature)}async getSignatureData(){return cO(this)}getTagsStart(){let i=this.getTargetStart(),t=this.binary[i]==1,r=i+(t?33:1),h=this.binary[r]==1;return r+=h?33:1,r}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let i=this.getTargetStart()+1,t=this.binary[this.getTargetStart()]==1;return i+=t?32:0,i}},zxt=fd(dO(),1);yO={...Dnt};globalThis.arbundles??=yO;Wxt=yO,Kxt=yO;});var MO=De(ow=>{"use strict";Tt();Rt();xt();Object.defineProperty(ow,"__esModule",{value:!0});ow.Signature=void 0;var Hxt=(wO(),Dn(bO)),_O=class{constructor(t,r){this.warp=t,this.isCustomSignature(r)?(this.assertEnvForCustomSigner(r.type),this.signer=r.signer,this.type=r.type,this.signatureProviderType="CustomSignature"):this.isValidBundlerSignature(r)?(this.signatureProviderType="BundlerSigner",this.type=Gxt(r.signatureType),this.bundlerSigner=r):(this.assignArweaveSigner(r),this.bundlerSigner=typeof r=="string"?null:new Hxt.ArweaveSigner(r),this.signatureProviderType="ArWallet",this.type="arweave"),this.wallet=r}async getAddress(){if(this.cachedAddress)return this.cachedAddress;switch(this.signatureProviderType){case"CustomSignature":return this.wallet.getAddress?this.cachedAddress=await this.wallet.getAddress():this.cachedAddress=await this.deduceSignerBySigning(),this.cachedAddress;case"ArWallet":return this.cachedAddress=await this.deduceSignerBySigning(),this.cachedAddress;case"BundlerSigner":return this.cachedAddress=await this.deduceSignerBySigning(),this.cachedAddress;default:throw Error("Unknown Signature::signatureProvider : "+this.signatureProviderType)}}async deduceSignerBySigning(){let{arweave:t}=this.warp;if(this.signatureProviderType=="BundlerSigner")try{return await this.bundlerSigner.getAddress()}catch{throw new Error("Could not get address from the signer. Is the 'getAddress' implementation correct?'")}else if(this.signatureProviderType=="ArWallet"||this.signatureProviderType=="CustomSignature"){let r=await t.createTransaction({data:Math.random().toString().slice(-4),reward:"72600854",last_tx:"p7vc1iSP6bvH_fCeUFa9LqoV5qiyW-jdEKouAT0XMoSwrNraB9mgpi29Q10waEpO"});return await this.signer(r),t.wallets.ownerToAddress(r.owner)}else throw Error("Unknown Signature::type")}checkNonArweaveSigningAvailability(t){if(this.type!=="arweave"&&!t)throw new Error(`Unable to use signing function of type: ${this.type} when bundling is disabled.`)}checkBundlerSignerAvailability(t){if((!t||this.warp.environment=="local")&&this.signatureProviderType=="BundlerSigner")throw new Error("Only wallet of type 'ArWallet' or 'CustomSignature' is allowed when bundling is disabled or in local environment.")}assignArweaveSigner(t){this.signer=async r=>{await this.warp.arweave.transactions.sign(r,t)}}assertEnvForCustomSigner(t){if(this.warp.interactionsLoader.type()==="warp")throw new Error("Unable to use signing function when bundling is enabled.");if(t=="ethereum")throw new Error(`Unable to use signing function with signature of type: ${t}.`)}isCustomSignature(t){return t.signer!==void 0&&t.type!==void 0}isValidBundlerSignature(t){let r=t,h=!!r.signatureType&&!!r.ownerLength&&!!r.signatureLength;if(h&&!r.publicKey)throw new Error("It seems that you are using BundlerSigner, but publicKey is not set! Maybe try calling await bundlerSigner.setPublicKey() before using it.");return h}};ow.Signature=_O;function Gxt(i){if(i===3)return"ethereum";if(i===1)return"arweave";throw Error(`Not supported arbundle SignatureType : ${i}`)}});var EO=De(aw=>{"use strict";Tt();Rt();xt();Object.defineProperty(aw,"__esModule",{value:!0});aw.EvaluationOptionsEvaluator=void 0;var Vxt=ko(),SO=class{constructor(t,r){if(this.saferEvaluationOptions={internalWrites:h=>{if(h.internalWrites===void 0||this.rootOptions.internalWrites==h.internalWrites)return this.rootOptions.internalWrites;if(this.rootOptions.internalWrites&&!h.internalWrites||!this.rootOptions.internalWrites&&h.internalWrites)return h.internalWrites;throw new Error('Could not determine "internalWrites" value ')},throwOnInternalWriteError:h=>h.throwOnInternalWriteError===void 0?this.rootOptions.throwOnInternalWriteError:h.throwOnInternalWriteError,unsafeClient:h=>{if(h.unsafeClient===void 0||this.rootOptions.unsafeClient==h.unsafeClient)return this.rootOptions.unsafeClient;if(this.rootOptions.unsafeClient==="throw"||this.rootOptions.unsafeClient==="skip")return this.rootOptions.unsafeClient;if(this.rootOptions.unsafeClient==="allow")return h.unsafeClient==="throw"?"skip":h.unsafeClient;throw new Error('Could not determine "unsafeClient" value')},ignoreExceptions:h=>{if(h.ignoreExceptions===void 0||this.rootOptions.ignoreExceptions==h.ignoreExceptions)return this.rootOptions.ignoreExceptions;if(this.rootOptions.ignoreExceptions&&!h.ignoreExceptions)return this.rootOptions.ignoreExceptions;if(!this.rootOptions.ignoreExceptions&&h.ignoreExceptions)return this.rootOptions.ignoreExceptions;throw new Error('Could not determine "ignoreExceptions" value')},waitForConfirmation:()=>this.rootOptions.waitForConfirmation,updateCacheForEachInteraction:()=>this.rootOptions.updateCacheForEachInteraction,maxCallDepth:()=>this.rootOptions.maxCallDepth,maxInteractionEvaluationTimeSeconds:()=>this.rootOptions.maxInteractionEvaluationTimeSeconds,stackTrace:()=>this.rootOptions.stackTrace,sourceType:()=>this.rootOptions.sourceType,sequencerUrl:()=>this.rootOptions.sequencerUrl,gasLimit:()=>this.rootOptions.gasLimit,allowBigInt:()=>this.rootOptions.allowBigInt,walletBalanceUrl:()=>this.rootOptions.walletBalanceUrl,mineArLocalBlocks:()=>this.rootOptions.mineArLocalBlocks,cacheEveryNInteractions:()=>this.rootOptions.cacheEveryNInteractions,remoteStateSyncEnabled:()=>this.rootOptions.remoteStateSyncEnabled,remoteStateSyncSource:()=>this.rootOptions.remoteStateSyncSource,useKVStorage:h=>h.useKVStorage,useConstructor:h=>h.useConstructor,whitelistSources:()=>this.rootOptions.whitelistSources,transactionsPagesPerBatch:()=>this.rootOptions.transactionsPagesPerBatch,strictSortKey:()=>this.rootOptions.strictSortKey,strictEvolve:()=>this.rootOptions.strictEvolve},this.notConflictingEvaluationOptions=["useKVStorage","sourceType","useConstructor","transactionsPagesPerBatch","strictSortKey"],r){let h=[];for(let o in r){if(!t.hasOwnProperty(o))throw new Error("Unknown option set in contract's manifest. You probably need to update the Warp SDK version.");let l=o,c=r[o],p=t[o];if(!this.notConflictingEvaluationOptions.includes(l))if(l==="internalWrites"){if(p===!1&&c===!0)throw new Error("Cannot proceed with contract evaluation. User is blocking internal writes, while contract requires them.")}else if(l==="unsafeClient"){if(p==="throw"&&c!=="throw"||p==="skip"&&c==="allow")throw new Error(`Cannot proceed with contract evaluation. User requires to ${p} on any unsafeClient usage, while contract uses ${c} option.`)}else t[o]!==r[o]&&h.push(`Option {${o}} differs. EvaluationOptions: [${t[o]}], manifest: [${r[o]}]. Use contract.setEvaluationOptions({${o}: ${r[o]}}) to evaluate contract state.`)}if(h.length)throw new Error(h.join(`
|
|
216
|
-
`))}this.rootOptions=Object.freeze(Object.assign({},t,r||{}))}forForeignContract(t){let r=(0,Vxt.deepCopy)(this.rootOptions);if(t)for(let h in t)r[h]=this.saferEvaluationOptions[h](t);return Object.freeze(r)}};aw.EvaluationOptionsEvaluator=SO});var mv={};cs(mv,{__addDisposableResource:()=>fot,__assign:()=>sw,__asyncDelegator:()=>eot,__asyncGenerator:()=>tot,__asyncValues:()=>rot,__await:()=>Bp,__awaiter:()=>Vnt,__classPrivateFieldGet:()=>aot,__classPrivateFieldIn:()=>hot,__classPrivateFieldSet:()=>sot,__createBinding:()=>fw,__decorate:()=>Knt,__disposeResources:()=>uot,__esDecorate:()=>Zxt,__exportStar:()=>Jnt,__extends:()=>znt,__generator:()=>Znt,__importDefault:()=>oot,__importStar:()=>not,__makeTemplateObject:()=>iot,__metadata:()=>Gnt,__param:()=>Hnt,__propKey:()=>Xxt,__read:()=>TO,__rest:()=>Wnt,__runInitializers:()=>Jxt,__setFunctionName:()=>Yxt,__spread:()=>Xnt,__spreadArray:()=>Qnt,__spreadArrays:()=>Ynt,__values:()=>hw,default:()=>eRt});function znt(i,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");AO(i,t);function r(){this.constructor=i}i.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Wnt(i,t){var r={};for(var h in i)Object.prototype.hasOwnProperty.call(i,h)&&t.indexOf(h)<0&&(r[h]=i[h]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,h=Object.getOwnPropertySymbols(i);o<h.length;o++)t.indexOf(h[o])<0&&Object.prototype.propertyIsEnumerable.call(i,h[o])&&(r[h[o]]=i[h[o]]);return r}function Knt(i,t,r,h){var o=arguments.length,l=o<3?t:h===null?h=Object.getOwnPropertyDescriptor(t,r):h,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(i,t,r,h);else for(var p=i.length-1;p>=0;p--)(c=i[p])&&(l=(o<3?c(l):o>3?c(t,r,l):c(t,r))||l);return o>3&&l&&Object.defineProperty(t,r,l),l}function Hnt(i,t){return function(r,h){t(r,h,i)}}function Zxt(i,t,r,h,o,l){function c(C){if(C!==void 0&&typeof C!="function")throw new TypeError("Function expected");return C}for(var p=h.kind,w=p==="getter"?"get":p==="setter"?"set":"value",m=!t&&i?h.static?i:i.prototype:null,y=t||(m?Object.getOwnPropertyDescriptor(m,h.name):{}),v,M=!1,T=r.length-1;T>=0;T--){var A={};for(var R in h)A[R]=R==="access"?{}:h[R];for(var R in h.access)A.access[R]=h.access[R];A.addInitializer=function(C){if(M)throw new TypeError("Cannot add initializers after decoration has completed");l.push(c(C||null))};var B=(0,r[T])(p==="accessor"?{get:y.get,set:y.set}:y[w],A);if(p==="accessor"){if(B===void 0)continue;if(B===null||typeof B!="object")throw new TypeError("Object expected");(v=c(B.get))&&(y.get=v),(v=c(B.set))&&(y.set=v),(v=c(B.init))&&o.unshift(v)}else(v=c(B))&&(p==="field"?o.unshift(v):y[w]=v)}m&&Object.defineProperty(m,h.name,y),M=!0}function Jxt(i,t,r){for(var h=arguments.length>2,o=0;o<t.length;o++)r=h?t[o].call(i,r):t[o].call(i);return h?r:void 0}function Xxt(i){return typeof i=="symbol"?i:"".concat(i)}function Yxt(i,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(i,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function Gnt(i,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,t)}function Vnt(i,t,r,h){function o(l){return l instanceof r?l:new r(function(c){c(l)})}return new(r||(r=Promise))(function(l,c){function p(y){try{m(h.next(y))}catch(v){c(v)}}function w(y){try{m(h.throw(y))}catch(v){c(v)}}function m(y){y.done?l(y.value):o(y.value).then(p,w)}m((h=h.apply(i,t||[])).next())})}function Znt(i,t){var r={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},h,o,l,c;return c={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function p(m){return function(y){return w([m,y])}}function w(m){if(h)throw new TypeError("Generator is already executing.");for(;c&&(c=0,m[0]&&(r=0)),r;)try{if(h=1,o&&(l=m[0]&2?o.return:m[0]?o.throw||((l=o.return)&&l.call(o),0):o.next)&&!(l=l.call(o,m[1])).done)return l;switch(o=0,l&&(m=[m[0]&2,l.value]),m[0]){case 0:case 1:l=m;break;case 4:return r.label++,{value:m[1],done:!1};case 5:r.label++,o=m[1],m=[0];continue;case 7:m=r.ops.pop(),r.trys.pop();continue;default:if(l=r.trys,!(l=l.length>0&&l[l.length-1])&&(m[0]===6||m[0]===2)){r=0;continue}if(m[0]===3&&(!l||m[1]>l[0]&&m[1]<l[3])){r.label=m[1];break}if(m[0]===6&&r.label<l[1]){r.label=l[1],l=m;break}if(l&&r.label<l[2]){r.label=l[2],r.ops.push(m);break}l[2]&&r.ops.pop(),r.trys.pop();continue}m=t.call(i,r)}catch(y){m=[6,y],o=0}finally{h=l=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}}function Jnt(i,t){for(var r in i)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&fw(t,i,r)}function hw(i){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&i[t],h=0;if(r)return r.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&h>=i.length&&(i=void 0),{value:i&&i[h++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function TO(i,t){var r=typeof Symbol=="function"&&i[Symbol.iterator];if(!r)return i;var h=r.call(i),o,l=[],c;try{for(;(t===void 0||t-- >0)&&!(o=h.next()).done;)l.push(o.value)}catch(p){c={error:p}}finally{try{o&&!o.done&&(r=h.return)&&r.call(h)}finally{if(c)throw c.error}}return l}function Xnt(){for(var i=[],t=0;t<arguments.length;t++)i=i.concat(TO(arguments[t]));return i}function Ynt(){for(var i=0,t=0,r=arguments.length;t<r;t++)i+=arguments[t].length;for(var h=Array(i),o=0,t=0;t<r;t++)for(var l=arguments[t],c=0,p=l.length;c<p;c++,o++)h[o]=l[c];return h}function Qnt(i,t,r){if(r||arguments.length===2)for(var h=0,o=t.length,l;h<o;h++)(l||!(h in t))&&(l||(l=Array.prototype.slice.call(t,0,h)),l[h]=t[h]);return i.concat(l||Array.prototype.slice.call(t))}function Bp(i){return this instanceof Bp?(this.v=i,this):new Bp(i)}function tot(i,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var h=r.apply(i,t||[]),o,l=[];return o={},p("next"),p("throw"),p("return",c),o[Symbol.asyncIterator]=function(){return this},o;function c(T){return function(A){return Promise.resolve(A).then(T,v)}}function p(T,A){h[T]&&(o[T]=function(R){return new Promise(function(B,C){l.push([T,R,B,C])>1||w(T,R)})},A&&(o[T]=A(o[T])))}function w(T,A){try{m(h[T](A))}catch(R){M(l[0][3],R)}}function m(T){T.value instanceof Bp?Promise.resolve(T.value.v).then(y,v):M(l[0][2],T)}function y(T){w("next",T)}function v(T){w("throw",T)}function M(T,A){T(A),l.shift(),l.length&&w(l[0][0],l[0][1])}}function eot(i){var t,r;return t={},h("next"),h("throw",function(o){throw o}),h("return"),t[Symbol.iterator]=function(){return this},t;function h(o,l){t[o]=i[o]?function(c){return(r=!r)?{value:Bp(i[o](c)),done:!1}:l?l(c):c}:l}}function rot(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],r;return t?t.call(i):(i=typeof hw=="function"?hw(i):i[Symbol.iterator](),r={},h("next"),h("throw"),h("return"),r[Symbol.asyncIterator]=function(){return this},r);function h(l){r[l]=i[l]&&function(c){return new Promise(function(p,w){c=i[l](c),o(p,w,c.done,c.value)})}}function o(l,c,p,w){Promise.resolve(w).then(function(m){l({value:m,done:p})},c)}}function iot(i,t){return Object.defineProperty?Object.defineProperty(i,"raw",{value:t}):i.raw=t,i}function not(i){if(i&&i.__esModule)return i;var t={};if(i!=null)for(var r in i)r!=="default"&&Object.prototype.hasOwnProperty.call(i,r)&&fw(t,i,r);return Qxt(t,i),t}function oot(i){return i&&i.__esModule?i:{default:i}}function aot(i,t,r,h){if(r==="a"&&!h)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!h:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?h:r==="a"?h.call(i):h?h.value:t.get(i)}function sot(i,t,r,h,o){if(h==="m")throw new TypeError("Private method is not writable");if(h==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!o:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return h==="a"?o.call(i,r):o?o.value=r:t.set(i,r),r}function hot(i,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof i=="function"?t===i:i.has(t)}function fot(i,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var h,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");h=t[Symbol.asyncDispose]}if(h===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");h=t[Symbol.dispose],r&&(o=h)}if(typeof h!="function")throw new TypeError("Object not disposable.");o&&(h=function(){try{o.call(this)}catch(l){return Promise.reject(l)}}),i.stack.push({value:t,dispose:h,async:r})}else r&&i.stack.push({async:!0});return t}function uot(i){function t(h){i.error=i.hasError?new tRt(h,i.error,"An error was suppressed during disposal."):h,i.hasError=!0}function r(){for(;i.stack.length;){var h=i.stack.pop();try{var o=h.dispose&&h.dispose.call(h.value);if(h.async)return Promise.resolve(o).then(r,function(l){return t(l),r()})}catch(l){t(l)}}if(i.hasError)throw i.error}return r()}var AO,sw,fw,Qxt,tRt,eRt,vv=Vi(()=>{"use strict";Tt();Rt();xt();AO=function(i,t){return AO=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,h){r.__proto__=h}||function(r,h){for(var o in h)Object.prototype.hasOwnProperty.call(h,o)&&(r[o]=h[o])},AO(i,t)};sw=function(){return sw=Object.assign||function(t){for(var r,h=1,o=arguments.length;h<o;h++){r=arguments[h];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(t[l]=r[l])}return t},sw.apply(this,arguments)};fw=Object.create?function(i,t,r,h){h===void 0&&(h=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(i,h,o)}:function(i,t,r,h){h===void 0&&(h=r),i[h]=t[r]};Qxt=Object.create?function(i,t){Object.defineProperty(i,"default",{enumerable:!0,value:t})}:function(i,t){i.default=t};tRt=typeof SuppressedError=="function"?SuppressedError:function(i,t,r){var h=new Error(r);return h.name="SuppressedError",h.error=i,h.suppressed=t,h};eRt={__extends:znt,__assign:sw,__rest:Wnt,__decorate:Knt,__param:Hnt,__metadata:Gnt,__awaiter:Vnt,__generator:Znt,__createBinding:fw,__exportStar:Jnt,__values:hw,__read:TO,__spread:Xnt,__spreadArrays:Ynt,__spreadArray:Qnt,__await:Bp,__asyncGenerator:tot,__asyncDelegator:eot,__asyncValues:rot,__makeTemplateObject:iot,__importStar:not,__importDefault:oot,__classPrivateFieldGet:aot,__classPrivateFieldSet:sot,__classPrivateFieldIn:hot,__addDisposableResource:fot,__disposeResources:uot}});var yv=De(wl=>{"use strict";Tt();Rt();xt();Object.defineProperty(wl,"__esModule",{value:!0});wl.E_CANCELED=wl.E_ALREADY_LOCKED=wl.E_TIMEOUT=void 0;wl.E_TIMEOUT=new Error("timeout while waiting for mutex to become available");wl.E_ALREADY_LOCKED=new Error("mutex already locked");wl.E_CANCELED=new Error("request for lock canceled")});var RO=De(xO=>{"use strict";Tt();Rt();xt();Object.defineProperty(xO,"__esModule",{value:!0});var cot=(vv(),Dn(mv)),rRt=yv(),iRt=function(){function i(t,r){r===void 0&&(r=rRt.E_CANCELED),this._value=t,this._cancelError=r,this._weightedQueues=[],this._weightedWaiters=[]}return i.prototype.acquire=function(t){var r=this;if(t===void 0&&(t=1),t<=0)throw new Error("invalid weight ".concat(t,": must be positive"));return new Promise(function(h,o){r._weightedQueues[t-1]||(r._weightedQueues[t-1]=[]),r._weightedQueues[t-1].push({resolve:h,reject:o}),r._dispatch()})},i.prototype.runExclusive=function(t,r){return r===void 0&&(r=1),cot.__awaiter(this,void 0,void 0,function(){var h,o,l;return cot.__generator(this,function(c){switch(c.label){case 0:return[4,this.acquire(r)];case 1:h=c.sent(),o=h[0],l=h[1],c.label=2;case 2:return c.trys.push([2,,4,5]),[4,t(o)];case 3:return[2,c.sent()];case 4:return l(),[7];case 5:return[2]}})})},i.prototype.waitForUnlock=function(t){var r=this;if(t===void 0&&(t=1),t<=0)throw new Error("invalid weight ".concat(t,": must be positive"));return new Promise(function(h){r._weightedWaiters[t-1]||(r._weightedWaiters[t-1]=[]),r._weightedWaiters[t-1].push(h),r._dispatch()})},i.prototype.isLocked=function(){return this._value<=0},i.prototype.getValue=function(){return this._value},i.prototype.setValue=function(t){this._value=t,this._dispatch()},i.prototype.release=function(t){if(t===void 0&&(t=1),t<=0)throw new Error("invalid weight ".concat(t,": must be positive"));this._value+=t,this._dispatch()},i.prototype.cancel=function(){var t=this;this._weightedQueues.forEach(function(r){return r.forEach(function(h){return h.reject(t._cancelError)})}),this._weightedQueues=[]},i.prototype._dispatch=function(){for(var t,r=this._value;r>0;r--){var h=(t=this._weightedQueues[r-1])===null||t===void 0?void 0:t.shift();if(h){var o=this._value,l=r;this._value-=r,r=this._value+1,h.resolve([o,this._newReleaser(l)])}}this._drainUnlockWaiters()},i.prototype._newReleaser=function(t){var r=this,h=!1;return function(){h||(h=!0,r.release(t))}},i.prototype._drainUnlockWaiters=function(){for(var t=this._value;t>0;t--)this._weightedWaiters[t-1]&&(this._weightedWaiters[t-1].forEach(function(r){return r()}),this._weightedWaiters[t-1]=[])},i}();xO.default=iRt});var dot=De(kO=>{"use strict";Tt();Rt();xt();Object.defineProperty(kO,"__esModule",{value:!0});var lot=(vv(),Dn(mv)),nRt=RO(),oRt=function(){function i(t){this._semaphore=new nRt.default(1,t)}return i.prototype.acquire=function(){return lot.__awaiter(this,void 0,void 0,function(){var t,r;return lot.__generator(this,function(h){switch(h.label){case 0:return[4,this._semaphore.acquire()];case 1:return t=h.sent(),r=t[1],[2,r]}})})},i.prototype.runExclusive=function(t){return this._semaphore.runExclusive(function(){return t()})},i.prototype.isLocked=function(){return this._semaphore.isLocked()},i.prototype.waitForUnlock=function(){return this._semaphore.waitForUnlock()},i.prototype.release=function(){this._semaphore.isLocked()&&this._semaphore.release()},i.prototype.cancel=function(){return this._semaphore.cancel()},i}();kO.default=oRt});var IO=De(cw=>{"use strict";Tt();Rt();xt();Object.defineProperty(cw,"__esModule",{value:!0});cw.withTimeout=void 0;var uw=(vv(),Dn(mv)),aRt=yv();function sRt(i,t,r){var h=this;return r===void 0&&(r=aRt.E_TIMEOUT),{acquire:function(o){if(o!==void 0&&o<=0)throw new Error("invalid weight ".concat(o,": must be positive"));return new Promise(function(l,c){return uw.__awaiter(h,void 0,void 0,function(){var p,w,m,y,v;return uw.__generator(this,function(M){switch(M.label){case 0:p=!1,w=setTimeout(function(){p=!0,c(r)},t),M.label=1;case 1:return M.trys.push([1,3,,4]),[4,i.acquire(o)];case 2:return m=M.sent(),p?(y=Array.isArray(m)?m[1]:m,y()):(clearTimeout(w),l(m)),[3,4];case 3:return v=M.sent(),p||(clearTimeout(w),c(v)),[3,4];case 4:return[2]}})})})},runExclusive:function(o,l){return uw.__awaiter(this,void 0,void 0,function(){var c,p;return uw.__generator(this,function(w){switch(w.label){case 0:c=function(){},w.label=1;case 1:return w.trys.push([1,,7,8]),[4,this.acquire(l)];case 2:return p=w.sent(),Array.isArray(p)?(c=p[1],[4,o(p[0])]):[3,4];case 3:return[2,w.sent()];case 4:return c=p,[4,o()];case 5:return[2,w.sent()];case 6:return[3,8];case 7:return c(),[7];case 8:return[2]}})})},release:function(o){i.release(o)},cancel:function(){return i.cancel()},waitForUnlock:function(o){if(o!==void 0&&o<=0)throw new Error("invalid weight ".concat(o,": must be positive"));return new Promise(function(l,c){var p=setTimeout(function(){return c(r)},t);i.waitForUnlock(o).then(function(){clearTimeout(p),l()})})},isLocked:function(){return i.isLocked()},getValue:function(){return i.getValue()},setValue:function(o){return i.setValue(o)}}}cw.withTimeout=sRt});var pot=De(lw=>{"use strict";Tt();Rt();xt();Object.defineProperty(lw,"__esModule",{value:!0});lw.tryAcquire=void 0;var hRt=yv(),fRt=IO();function uRt(i,t){return t===void 0&&(t=hRt.E_ALREADY_LOCKED),(0,fRt.withTimeout)(i,0,t)}lw.tryAcquire=uRt});var got=De(Qh=>{"use strict";Tt();Rt();xt();Object.defineProperty(Qh,"__esModule",{value:!0});Qh.tryAcquire=Qh.withTimeout=Qh.Semaphore=Qh.Mutex=void 0;var cRt=(vv(),Dn(mv)),lRt=dot();Object.defineProperty(Qh,"Mutex",{enumerable:!0,get:function(){return lRt.default}});var dRt=RO();Object.defineProperty(Qh,"Semaphore",{enumerable:!0,get:function(){return dRt.default}});var pRt=IO();Object.defineProperty(Qh,"withTimeout",{enumerable:!0,get:function(){return pRt.withTimeout}});var gRt=pot();Object.defineProperty(Qh,"tryAcquire",{enumerable:!0,get:function(){return gRt.tryAcquire}});cRt.__exportStar(yv(),Qh)});var mot=De(dw=>{"use strict";Tt();Rt();xt();Object.defineProperty(dw,"__esModule",{value:!0});dw.SimpleLRUCache=void 0;var BO=class{constructor(t){this.cache=new Map,this.capacity=t||10}has(t){return this.cache.has(t)}size(){return this.cache.size}get(t){if(!this.cache.has(t))return null;let r=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,r),r}set(t,r){this.cache.delete(t),this.cache.size===this.capacity?(this.cache.delete(this.cache.keys().next().value),this.cache.set(t,r)):this.cache.set(t,r)}keys(){return Array.from(this.cache.keys())}};dw.SimpleLRUCache=BO});var CO=De(pw=>{"use strict";Tt();Rt();xt();Object.defineProperty(pw,"__esModule",{value:!0});pw.ContractInteractionState=void 0;var mRt=$u(),vRt=mot(),OO=class{constructor(t){this._warp=t,this._json=new Map,this._initialJson=new Map,this._kv=new Map}has(t,r){var h;return((h=this._json.get(t))===null||h===void 0?void 0:h.has(r))||!1}get(t,r){var h;return((h=this._json.get(t))===null||h===void 0?void 0:h.get(r))||null}getLessOrEqual(t,r){let h=this._json.get(t);if(h!=null&&h.size()>0){let o=h.keys();r&&(o=o.filter(c=>c.localeCompare(r)<=0)),o=o.sort((c,p)=>c.localeCompare(p));let l=o[o.length-1];if(h.get(l))return new mRt.SortKeyCacheResult(l,h.get(l))}return null}async getKV(t,r){var h;return this._kv.has(t)&&((h=await this._kv.get(t).get(r))===null||h===void 0?void 0:h.cachedValue)||null}async delKV(t,r){this._kv.has(t)&&await this._kv.get(t).del(r)}getKvKeys(t,r,h){return this._warp.kvStorageFactory(t).keys(r,h)}getKvRange(t,r,h){return this._warp.kvStorageFactory(t).kvMap(r,h)}async commit(t,r=!1){if(t.dry)return await this.rollbackKVs(),this.reset();try{let h=new Map;this._json.forEach((o,l)=>{let c=this.getLessOrEqual(l,t.sortKey);c!=null&&h.set(l,c.cachedValue)}),await this.doStoreJson(h,t,r),await this.commitKVs()}finally{this.reset()}}async commitKV(){await this.commitKVs(),this._kv.clear()}async rollback(t,r){try{await this.doStoreJson(this._initialJson,t,r),await this.rollbackKVs()}finally{this.reset()}}setInitial(t,r,h){this._initialJson.set(t,r),this.update(t,r,h)}update(t,r,h){if(!this._json.has(t)){let o=new vRt.SimpleLRUCache(10);this._json.set(t,o)}this._json.get(t).set(h,r)}async updateKV(t,r,h){await(await this.getOrInitKvStorage(t)).put(r,h)}async getOrInitKvStorage(t){if(this._kv.has(t))return this._kv.get(t);let r=this._warp.kvStorageFactory(t);return this._kv.set(t,r),await r.open(),r}reset(){this._json.clear(),this._initialJson.clear(),this._kv.clear()}async doStoreJson(t,r,h=!1){if(t.size>1||h)for(let[o,l]of t)await this._warp.stateEvaluator.putInCache(o,r,l)}async rollbackKVs(){for(let t of this._kv.values())try{await t.rollback()}finally{await t.close()}}async commitKVs(){for(let t of this._kv.values())try{await t.commit()}finally{await t.close()}}};pw.ContractInteractionState=OO});var vw=De(Np=>{"use strict";Tt();Rt();xt();var yRt=Np&&Np.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Np,"__esModule",{value:!0});Np.HandlerBasedContract=void 0;var bRt=yRt(Ont()),bv=$u(),PO=GB(),NO=qf(),LO=ed(),vot=Ym(),Op=Vh(),gw=oO(),Cp=Qs(),yot=bn(),bot=YB(),wRt=gl(),_l=ko(),Pp=aO(),_Rt=hO(),MRt=MO(),SRt=EO(),ERt=Jm(),ARt=got(),mw=Ep(),wot=CO(),DO=Gu(),_ot=(wO(),Dn(bO)),$O=class{constructor(t,r,h=null,o=null){var l,c;if(this._contractTxId=t,this.warp=r,this._parentContract=h,this._innerCallData=o,this.logger=yot.LoggerFactory.INST.create("HandlerBasedContract"),this.ecLogger=yot.LoggerFactory.INST.create("ExecutionContext"),this._innerWritesEvaluator=new _Rt.InnerWritesEvaluator,this._mutex=new ARt.Mutex,this._benchmarkStats=null,this._children=[],this._dreStates=new Map,this.waitForConfirmation=this.waitForConfirmation.bind(this),this._arweaveWrapper=new wRt.ArweaveWrapper(r),this._sorter=new LO.LexicographicalInteractionsSorter(r.arweave),h!=null){this._evaluationOptions=this.getRoot().evaluationOptions(),this._callDepth=h.callDepth()+1;let p=h.getCallStack().getInteraction(o.callingInteraction.id);if(this._callDepth>this._evaluationOptions.maxCallDepth)throw new Error(`Max call depth of ${this._evaluationOptions.maxCallDepth} has been exceeded for interaction ${JSON.stringify(p.interactionInput)}`);if(this.logger.debug("Calling interaction",{id:o.callingInteraction.id,sortKey:o.callingInteraction.sortKey,type:o.callType}),((c=(l=p.interactionInput)===null||l===void 0?void 0:l.foreignContractCalls[t])===null||c===void 0?void 0:c.innerCallType)==="write"&&o.callType==="read")throw new Error("Calling a readContractState after performing an inner write is wrong - instead use a state from the result of an internal write.");let w=new PO.ContractCallRecord(t,this._callDepth,o?.callType);p.interactionInput.foreignContractCalls[t]=w,this._callStack=w,this._rootSortKey=h.rootSortKey,h._children.push(this)}else this._callDepth=0,this._callStack=new PO.ContractCallRecord(t,0),this._rootSortKey=null,this._evaluationOptions=new vot.DefaultEvaluationOptions,this._children=[],this._interactionState=new wot.ContractInteractionState(r);this.getCallStack=this.getCallStack.bind(this),this._warpFetchWrapper=new ERt.WarpFetchWrapper(this.warp)}async readState(t,r,h,o){var l,c,p;if(this.logger.info("Read state for",{contractTxId:this._contractTxId,sortKeyOrBlockHeight:t}),!this.isRoot()&&t==null)throw new Error("SortKey MUST be always set for non-root contract calls");let{stateEvaluator:w}=this.warp,m=typeof t=="number"?this._sorter.generateLastSortKey(t):t;if(m&&!this.isRoot()&&this.interactionState().has(this.txId(),m)){let v=this.interactionState().get(this.txId(),m);return new bv.SortKeyCacheResult(m,v)}let y=await this._mutex.acquire();try{let v=Cp.Benchmark.measure();this.maybeResetRootContract();let M=await this.createExecutionContext(this._contractTxId,m,!1,r,h,o);this.logger.info("Execution Context",{srcTxId:(l=M.contractDefinition)===null||l===void 0?void 0:l.srcTxId,missingInteractions:(c=M.sortedInteractions)===null||c===void 0?void 0:c.length,cachedSortKey:(p=M.cachedState)===null||p===void 0?void 0:p.sortKey}),v.stop();let T=Cp.Benchmark.measure(),A=await w.eval(M);T.stop();let R=v.elapsed(!0)+T.elapsed(!0);return this._benchmarkStats={gatewayCommunication:v.elapsed(!0),stateEvaluation:T.elapsed(!0),total:R},this.logger.info("Benchmark",{"Gateway communication ":v.elapsed(),"Contract evaluation ":T.elapsed(),"Total: ":`${R.toFixed(0)}ms`}),m&&!this.isRoot()&&this.interactionState().update(this.txId(),A.cachedValue,m),A}finally{y()}}async readStateFor(t,r,h,o){return this.readState(t,r,h,o)}async readStateBatch(t=1,r,h){if(!this.isRoot())throw new Error("readStateBatch is only allowed for root contract calls");if(t<1)throw new Error("At least one page per batch is required");if(h?.aborted)throw new NO.AbortError("readStateBatch aborted");let o=this._contractTxId,{interactionsLoader:l,stateEvaluator:c}=this.warp,p=await c.latestAvailableState(o),w={...this._evaluationOptions,transactionsPagesPerBatch:t},m,y=0;do{let v=Cp.Benchmark.measure();if(this.logger.debug(`Loading ${y+1} batch`,w),m=await l.load(o,p?.sortKey,r,w),h?.aborted)throw new NO.AbortError("readStateBatch aborted");if(m.length==0&&y>0)break;if(this.logger.debug(`Evaluating ${m.length} in ${y+1} batch`),p=await this.readStateFor(p?.sortKey||LO.genesisSortKey,m,h),h?.aborted)throw new NO.AbortError("readStateBatch aborted");this.logger.debug(`Batch ${y+1} evaluated in ${v.elapsed()} at sortKey ${p.sortKey}`),y++}while(m.length>0);return p}async viewState(t,r=[],h=Pp.emptyTransfer,o,l,c){return this.logger.info("View state for",this._contractTxId),await this.callContract(t,"view",o,c,r,h,!1,!1,!0,l)}async viewStateForTx(t,r,h){return this.logger.info(`View state for ${this._contractTxId}`),await this.doApplyInputOnTx(t,r,"view",h)}async dryWrite(t,r,h,o,l,c){return this.logger.info("Dry-write for",this._contractTxId),await this.callContract(t,"write",r,c,h,o,void 0,l)}async applyInput(t,r,h){return this.logger.info(`Apply-input from transaction ${r.id} for ${this._contractTxId}`),await this.doApplyInputOnTx(t,r,"write",h)}async writeInteraction(t,r){if(this.logger.info("Write interaction",{input:t,options:r}),!this._signature)throw new Error("Wallet not connected. Use 'connect' method first.");let{arweave:h,interactionsLoader:o,environment:l}=this.warp;await this.warp.definitionLoader.load(this._contractTxId);let c=r?.tags||[],p=r?.transfer||Pp.emptyTransfer,w=r?.strict===!0,m=r?.vrf===!0,y=r?.disableBundling===!0,v=r?.reward,M=r?.manifestData,T=r?.inputFormatAsData,A=o.type()=="warp"&&!y;if(this._signature.checkNonArweaveSigningAvailability(A),this._signature.checkBundlerSignerAvailability(A),A&&p.target!=Pp.emptyTransfer.target&&p.winstonQty!=Pp.emptyTransfer.winstonQty)throw new Error("Ar Transfers are not allowed for bundled interactions");if(m&&!A&&l==="mainnet")throw new Error("Vrf generation is only available for bundle interaction");if(!t)throw new Error(`Input should be a truthy value: ${JSON.stringify(t)}`);if(A)return await this.bundleInteraction(t,{tags:c,strict:w,vrf:m,manifestData:M,inputFormatAsData:T});{let R=await this.createInteraction(t,c,p,w,!1,m&&l!=="mainnet",v),B=await h.transactions.post(R);if(B.status!==200)return this.logger.error("Error while posting transaction",B),null;if(this._evaluationOptions.waitForConfirmation){this.logger.info("Waiting for confirmation of",R.id);let C=Cp.Benchmark.measure();await this.waitForConfirmation(R.id),this.logger.info("Transaction confirmed after",C.elapsed())}return this.warp.environment=="local"&&this._evaluationOptions.mineArLocalBlocks&&await this.warp.testing.mineBlock(),{originalTxId:R.id,interactionTx:R}}}async bundleInteraction(t,r){if(this.logger.info("Bundle interaction input: {}, tag: {}",t,r.tags),!this.maxInteractionDataItemSizeBytes){let c=fetch(`${(0,_l.stripTrailingSlash)(this.warp.gwUrl())}`);this.maxInteractionDataItemSizeBytes=(await(0,_l.getJsonResponse)(c)).maxInteractionDataItemSizeBytes}let h=await this.createInteractionDataItem(t,r.tags,Pp.emptyTransfer,r.strict,r.vrf,r.manifestData,r.inputFormatAsData),o=this._warpFetchWrapper.fetch(`${(0,_l.stripTrailingSlash)(this._evaluationOptions.sequencerUrl)}/gateway/v2/sequencer/register`,{method:"POST",headers:{"Content-Type":"application/octet-stream",Accept:"application/json"},body:h.getRaw()}),l=await h.id;return{bundlrResponse:await(0,_l.getJsonResponse)(o),originalTxId:l,interactionTx:h}}async createInteractionDataItem(t,r,h,o,l=!1,c,p){var w;this._evaluationOptions.internalWrites&&await this.discoverInternalWrites(t,r,h,o,l),l&&r.push(new mw.Tag(Op.WARP_TAGS.REQUEST_VRF,"true"));let m=(0,gw.createInteractionTagsList)(this._contractTxId,t,this.warp.environment==="testnet",r),y;((0,_ot.tagsExceedLimit)(m)||p)&&(m=[...m.filter(T=>T.name!=Op.SMART_WEAVE_TAGS.INPUT&&T.name!=Op.WARP_TAGS.INPUT_FORMAT),new mw.Tag(Op.WARP_TAGS.INPUT_FORMAT,"data")],y={input:t}),c&&(y={...y,manifest:this.createManifest(c)}),y=y?JSON.stringify(y):Math.random().toString().slice(-4);let v=this._signature.bundlerSigner;if(!v)throw new Error("Signer not set correctly. If you connect wallet through 'use_wallet', please remember that it only works when bundling is disabled.");let M;if((0,_l.isBrowser)()&&(!((w=v.signer)===null||w===void 0)&&w.signDataItem)?M=await v.signDataItem(y,m):(M=(0,_ot.createData)(y,v,{tags:m}),await M.sign(v)),M.getRaw().length>this.maxInteractionDataItemSizeBytes)throw new Error(`Interaction data item size: ${M.getRaw().length} exceeds maximum interactions size limit: ${this.maxInteractionDataItemSizeBytes}.`);return!this._evaluationOptions.internalWrites&&o&&await this.checkInteractionInStrictMode(M.owner,t,r,h,o,l),M}async createInteraction(t,r,h,o,l=!1,c=!1,p){this._evaluationOptions.internalWrites&&await this.discoverInternalWrites(t,r,h,o,c),c&&r.push(new mw.Tag(Op.WARP_TAGS.REQUEST_VRF,"true"));let w=await(0,gw.createInteractionTx)(this.warp.arweave,this._signature.signer,this._contractTxId,t,r,h.target,h.winstonQty,l,this.warp.environment==="testnet",p);return!this._evaluationOptions.internalWrites&&o&&await this.checkInteractionInStrictMode(w.owner,t,r,h,o,c),w}async checkInteractionInStrictMode(t,r,h,o,l,c){let{arweave:p}=this.warp,w=this._signature.type=="arweave"?await p.wallets.ownerToAddress(t):await this._signature.getAddress(),m=await this.callContract(r,"write",w,void 0,h,o,l,c);if(m.type!=="ok")throw Error("Cannot create interaction: "+JSON.stringify(m.error||m.errorMessage))}txId(){return this._contractTxId}getCallStack(){return this._callStack}connect(t){return this._signature=new MRt.Signature(this.warp,t),this}setEvaluationOptions(t){if(!this.isRoot())throw new Error("Evaluation options can be set only for the root contract");return this._evaluationOptions={...this._evaluationOptions,...t},this}async waitForConfirmation(t){let{arweave:r}=this.warp,h=await r.transactions.getStatus(t);return h.confirmed===null?(this.logger.info(`Transaction ${t} not yet confirmed. Waiting another 20 seconds before next check.`),await(0,_l.sleep)(2e4),this.waitForConfirmation(t)):(this.logger.info(`Transaction ${t} confirmed`,h),h)}async createExecutionContext(t,r,h=!1,o,l,c){var p,w,m,y,v;let{definitionLoader:M,interactionsLoader:T,stateEvaluator:A}=this.warp,R,B=Cp.Benchmark.measure();if(this.isRoot()||(R=this.interactionState().getLessOrEqual(this.txId(),r)),R=c||R||await A.latestAvailableState(t,r),r&&this.evaluationOptions().strictSortKey&&R?.sortKey!=r)throw new Error(`State not cached at the exact required ${r} sortKey`);this.logger.debug("cache lookup",B.elapsed()),B.reset();let C=bot.Evolve.evolvedSrcTxId((p=R?.cachedValue)===null||p===void 0?void 0:p.state),P,N,q,W,J=o||[];if(this.logger.debug("Cached state",R,r),R&&R.sortKey==r||r==LO.genesisSortKey&&o?.length)this.logger.debug("State fully cached, not loading interactions."),(h||C||o?.length)&&(N=await M.load(t,C),q=this.resolveEvaluationOptions((w=N.manifest)===null||w===void 0?void 0:w.evaluationOptions),this.warp.executorFactory.checkWhiteListContractSources(N,q),o?.length&&(J=await this.getSortedInteractions(o)));else{if(o?.length)throw new Error(`Cannot apply requested interactions at ${r}`);if(N=await M.load(t,C),q=this.resolveEvaluationOptions((m=N.manifest)===null||m===void 0?void 0:m.evaluationOptions),q.remoteStateSyncEnabled&&!q.useKVStorage){W=await this.getRemoteContractState(t),R=await this.maybeSyncStateWithRemoteSource(W,r,R);let F=bot.Evolve.evolvedSrcTxId((y=R?.cachedValue)===null||y===void 0?void 0:y.state);F&&F!==N.srcTxId&&(N=await M.load(t,F))}this.warp.executorFactory.checkWhiteListContractSources(N,q),!W&&J.length==0&&(J=await T.load(t,R?.sortKey,this.getToSortKey(r),q)),R?.sortKey&&(J=J.filter(F=>F.sortKey.localeCompare(R?.sortKey)>0)),r&&(J=J.filter(F=>F.sortKey.localeCompare(r)<=0)),this.logger.debug("contract and interactions load",B.elapsed()),this.isRoot()&&J.length&&(this._rootSortKey=J[J.length-1].sortKey)}return N&&(q||(q=this.resolveEvaluationOptions((v=N.manifest)===null||v===void 0?void 0:v.evaluationOptions)),this.ecLogger.debug(`Evaluation options ${t}:`,q),P=await this.warp.executorFactory.create(N,q,this.warp,this.interactionState())),{warp:this.warp,contract:this,contractDefinition:N,sortedInteractions:J,evaluationOptions:q||this.evaluationOptions(),handler:P,cachedState:R,requestedSortKey:r,signal:l}}async getSortedInteractions(t){return(await this._sorter.sort(t.map(r=>({node:r,cursor:null})))).map(r=>r.node)}resolveEvaluationOptions(t){return this.isRoot()?(this._eoEvaluator=new SRt.EvaluationOptionsEvaluator(this.evaluationOptions(),t),this._eoEvaluator.rootOptions):this.getRootEoEvaluator().forForeignContract(t)}async getRemoteContractState(t){if(this.hasDreState(t))return this.getDreState(t);{let r=await this.fetchRemoteContractState(t);return r!=null?this.setDREState(t,r):null}}async fetchRemoteContractState(t){return(0,_l.getJsonResponse)(this._warpFetchWrapper.fetch(`${this._evaluationOptions.remoteStateSyncSource}?id=${t}&events=false`))}getToSortKey(t){var r;return!((r=this._parentContract)===null||r===void 0)&&r.rootSortKey?t?this._parentContract.rootSortKey.localeCompare(t)>0?this._parentContract.rootSortKey:t:this._parentContract.rootSortKey:t}async createExecutionContextFromTx(t,r,h){let o=r.owner.address,l=r.sortKey;return{...await this.createExecutionContext(t,l,!0,void 0,h),caller:o}}maybeResetRootContract(){this.isRoot()&&(this.logger.debug("Clearing call stack for the root contract"),this._callStack=new PO.ContractCallRecord(this.txId(),0),this._rootSortKey=null,this.warp.interactionsLoader.clearCache(),this._children=[],this._interactionState=new wot.ContractInteractionState(this.warp),this._dreStates=new Map)}async callContract(t,r,h,o,l=[],c=Pp.emptyTransfer,p=!1,w=!1,m=!0,y){var v;this.logger.info("Call contract input",t),this.maybeResetRootContract(),this._signature||this.logger.warn("Wallet not set.");let{arweave:M,stateEvaluator:T}=this.warp,A=await this.createExecutionContext(this._contractTxId,o,!0,void 0,y),R=o?await this._sorter.extractBlockHeight(o):void 0,B;this.warp.environment=="mainnet"&&this.warp.interactionsLoader.type()!=="arweave"?B=await this._arweaveWrapper.warpGwBlock():R?B=await M.blocks.getByHeight(R):B=await M.blocks.getCurrent();let C;h?C=h:this._signature?C=await this._signature.getAddress():C="",this.logger.info("effectiveCaller",C),A={...A,caller:C};let P=await T.eval(A);this.logger.info("Current state",P.cachedValue.state);let N={input:t,caller:A.caller,interactionType:r};this.logger.debug("interaction",N);let q=await(0,gw.createInteractionTx)(M,m?(v=this._signature)===null||v===void 0?void 0:v.signer:void 0,this._contractTxId,t,l,c.target,c.winstonQty,!0,this.warp.environment==="testnet"),W=(0,gw.createDummyTx)(q,A.caller,B);if(this.logger.debug("Creating sortKey for",{blockId:W.block.id,id:W.id,height:W.block.height}),W.sortKey=await this._sorter.createSortKey(W.block.id,W.id,W.block.height,!0),W.strict=p,w){let F=this.warp.maybeLoadPlugin("vrf");F?W.vrf=F.process().generateMockVrf(W.sortKey):this.logger.warn('Cannot generate mock vrf for interaction - no "warp-contracts-plugin-vrf" attached!')}let J=await this.evalInteraction({interaction:N,interactionTx:W},A,P.cachedValue);return J.type!=="ok"&&this.logger.fatal("Error while interacting with contract",{type:J.type,error:J.errorMessage}),J}async doApplyInputOnTx(t,r,h,o){this.maybeResetRootContract();let l,c=await this.createExecutionContextFromTx(this._contractTxId,r,o);!this.isRoot()&&this.interactionState().has(this.txId(),r.sortKey)?l=new bv.SortKeyCacheResult(r.sortKey,this.interactionState().get(this.txId(),r.sortKey)):(l=await this.warp.stateEvaluator.eval(c),this.interactionState().update(this.txId(),l.cachedValue,r.sortKey)),this.logger.debug("callContractForTx - evalStateResult",{result:l.cachedValue.state,txId:this._contractTxId});let w={interaction:{input:t,caller:this._parentContract.txId(),interactionType:h},interactionTx:r},m=await this.evalInteraction(w,c,l.cachedValue);return m.originalValidity=l.cachedValue.validity,m.originalErrorMessages=l.cachedValue.errorMessages,m}async evalInteraction(t,r,h){let o=this.getCallStack().addInteractionData(t),l=Cp.Benchmark.measure();await r.handler.initState(h.state);let c=await r.handler.handle(r,h,t);return o.update({cacheHit:!1,outputState:this._evaluationOptions.stackTrace.saveState?c.state:void 0,executionTime:l.elapsed(!0),valid:c.type==="ok",errorMessage:c.errorMessage,gasUsed:c.gasUsed}),c}parent(){return this._parentContract}callDepth(){return this._callDepth}evaluationOptions(){return this._evaluationOptions}lastReadStateStats(){return this._benchmarkStats}async stateHash(t){let r=(0,bRt.default)(t),h=await DO.Crypto.subtle.digest("SHA-256",DO.Buffer.from(r,"utf-8"));return DO.Buffer.from(h).toString("hex")}async syncState(t,r){let{stateEvaluator:h}=this.warp,o=await this._warpFetchWrapper.fetch(`${t}?${new URLSearchParams({id:this._contractTxId,...r})}`).then(l=>l.ok?l.json():Promise.reject(l)).catch(l=>{var c,p;throw!((c=l.body)===null||c===void 0)&&c.message&&this.logger.error(l.body.message),new Error(`Unable to retrieve state. ${l.status}: ${(p=l.body)===null||p===void 0?void 0:p.message}`)});return await h.syncState(this._contractTxId,o.sortKey,o.state,o.validity),this}async evolve(t,r){return await this.writeInteraction({function:"evolve",value:t},r)}get rootSortKey(){return this._rootSortKey}getRootEoEvaluator(){return this.getRoot()._eoEvaluator}isRoot(){return this._parentContract==null}async getStorageValues(t){let r=await this.warp.stateEvaluator.getCache().getLast(this.txId());if(r==null)return new bv.SortKeyCacheResult(null,new Map);let h=this.warp.kvStorageFactory(this.txId()),o=new Map;try{await h.open();for(let l of t){let c=await h.getLessOrEqual(l,r.sortKey);o.set(l,c==null?null:c.cachedValue)}return new bv.SortKeyCacheResult(r.sortKey,o)}finally{await h.close()}}interactionState(){return this.getRoot()._interactionState}getRoot(){let t=this;for(;!t.isRoot();)t=t.parent();return t}async maybeSyncStateWithRemoteSource(t,r,h){let{stateEvaluator:o}=this.warp;return this.isStateHigherThanAndUpTo(t,h?.sortKey,r)?await o.syncState(this._contractTxId,t.sortKey,t.cachedValue.state,t.cachedValue.validity):h}isStateHigherThanAndUpTo(t,r,h){return t&&(!h||h>=t.sortKey)&&(!r||t.sortKey>r)}setDREState(t,r){let h=new bv.SortKeyCacheResult(r.sortKey,new vot.EvalStateResult(r.state,{},r.errorMessages));return this.getRoot()._dreStates.set(t,h),h}getDreState(t){return this.getRoot()._dreStates.get(t)}hasDreState(t){return this.getRoot()._dreStates.has(t)}async discoverInternalWrites(t,r,h,o,l){let c=await this.callContract(t,"write",void 0,void 0,r,h,o,l,!1);if(o&&c.type!=="ok")throw Error("Cannot create interaction: "+JSON.stringify(c.error||c.errorMessage));let p=this.getCallStack(),w=this._innerWritesEvaluator.eval(p);this.logger.debug("Input",t),this.logger.debug("Callstack",p.print()),w.forEach(m=>{r.push(new mw.Tag(Op.WARP_TAGS.INTERACT_WRITE,m))}),this.logger.debug("Tags with inner calls",r)}clearChildren(){for(let t of this._children)t.clearChildren();this._children=[]}createManifest(t){let r={};return Object.keys(t).forEach(h=>{let o=t[h];if(typeof h!="string")throw new Error("Incorrect manifest data. Manifest key should be of type 'string'");if(typeof o!="string")throw new Error("Incorrect manifest data. Manifest value should be of type 'string'");if(!(0,_l.isTxIdValid)(o))throw new Error(`Incorrect manifest data. Transaction id: ${o} is not valid.`);r[h]=t[h]}),r}};Np.HandlerBasedContract=$O});var qO=De(yw=>{"use strict";Tt();Rt();xt();Object.defineProperty(yw,"__esModule",{value:!0});yw.PstContractImpl=void 0;var TRt=vw(),UO=class extends TRt.HandlerBasedContract{async currentBalance(t){let r=await this.viewState({function:"balance",target:t});if(r.type!=="ok")throw Error(r.errorMessage);return r.result}async currentState(){return(await super.readState()).cachedValue.state}async transfer(t,r){return await this.writeInteraction({function:"transfer",...t},r)}};yw.PstContractImpl=UO});var Mot=De(bw=>{"use strict";Tt();Rt();xt();Object.defineProperty(bw,"__esModule",{value:!0});bw.Testing=void 0;var FO=class{constructor(t){this.arweave=t}async mineBlock(){this.validateEnv(),await this.arweave.api.get("mine")}async addFunds(t){let r=await this.arweave.wallets.getAddress(t);await this.arweave.api.get(`/mint/${r}/1000000000000000`)}async isArlocal(){return(await fetch(`${this.arweave.api.config.protocol}://${this.arweave.api.config.host}:${this.arweave.api.config.port}/info`).then(r=>r.ok?r.json():Promise.reject()).catch(r=>{throw new Error(`Unable to get network info: ${r.message}`)})).network.includes("arlocal")}async validateEnv(){if(!await this.isArlocal())throw new Error("Testing features are not available in a non testing environment")}};bw.Testing=FO});var Sot=De(ww=>{"use strict";Tt();Rt();xt();Object.defineProperty(ww,"__esModule",{value:!0});ww.DebuggableExecutorFactory=void 0;var jO=class{constructor(t,r){this.baseImplementation=t,this.sourceCode=r}async create(t,r,h,o){return Object.prototype.hasOwnProperty.call(this.sourceCode,t.txId)&&(t={...t,src:this.sourceCode[t.txId]}),await this.baseImplementation.create(t,r,h,o)}checkWhiteListContractSources(t,r){return this.baseImplementation.checkWhiteListContractSources(t,r)}};ww.DebuggableExecutorFactory=jO});var xot=De(_w=>{"use strict";Tt();Rt();xt();Object.defineProperty(_w,"__esModule",{value:!0});_w.CacheableContractDefinitionLoader=void 0;var xRt=Gu(),Eot=Qm(),RRt=Qs(),kRt=bn(),Aot=$u(),Tot=Hm(),zO=class{constructor(t,r,h){this.contractDefinitionLoader=t,this.env=r,this.rLogger=kRt.LoggerFactory.INST.create("CacheableContractDefinitionLoader"),this.definitionCache=new Tot.LevelDbCache({...h,dbLocation:`${h.dbLocation}/contracts`}),this.srcCache=new Tot.LevelDbCache({...h,dbLocation:`${h.dbLocation}/source`})}async load(t,r){let h=await this.getFromCache(t,r);if(h)return this.rLogger.debug("Hit from cache!",t,r),h.contractType=="wasm"&&h.srcBinary.data&&(h.srcBinary=xRt.Buffer.from(h.srcBinary.data)),this.verifyEnv(h),h;let o=RRt.Benchmark.measure(),l=await this.contractDefinitionLoader.load(t,r);return this.rLogger.info(`Contract definition loaded in: ${o.elapsed()}`),this.verifyEnv(l),await this.putToCache(t,l,r),l}async loadContractSource(t){return await this.contractDefinitionLoader.loadContractSource(t)}type(){return this.contractDefinitionLoader.type()}setCache(t){this.definitionCache=t}setSrcCache(t){this.srcCache=t}getCache(){return this.definitionCache}getSrcCache(){return this.srcCache}verifyEnv(t){if(t.testnet&&this.env!=="testnet")throw new Error('Trying to use testnet contract in a non-testnet env. Use the "forTestnet" factory method.');if(!t.testnet&&this.env==="testnet")throw new Error("Trying to use non-testnet contract in a testnet env.")}async getFromCache(t,r){let h=await this.definitionCache.get(new Aot.CacheKey(t,"cd"));if(!h)return null;let o=r||h.cachedValue.srcTxId,l=await this.srcCache.get(new Aot.CacheKey(o,"src"));return l?{...h.cachedValue,...l.cachedValue,srcTxId:o}:null}async putToCache(t,r,h){let o=new Eot.SrcCache(r),l=new Eot.ContractCache(r);await this.definitionCache.put({key:t,sortKey:"cd"},l),await this.srcCache.put({key:h||l.srcTxId,sortKey:"src"},o)}set warp(t){this.contractDefinitionLoader.warp=t}};_w.CacheableContractDefinitionLoader=zO});var KO=De(Mw=>{"use strict";Tt();Rt();xt();Object.defineProperty(Mw,"__esModule",{value:!0});Mw.WarpBuilder=void 0;var IRt=Sot(),BRt=DB(),Rot=UB(),ORt=z4(),CRt=OB(),PRt=Xm(),NRt=Sw(),kot=xot(),WO=class{constructor(t,r,h="custom"){this._arweave=t,this._stateCache=r,this._environment=h}setDefinitionLoader(t){return this._definitionLoader=t,this}setInteractionsLoader(t){return this._interactionsLoader=t,this}setExecutorFactory(t){return this._executorFactory=t,this}setStateEvaluator(t){return this._stateEvaluator=t,this}overwriteSource(t){if(this._executorFactory==null)throw new Error("Set base ExecutorFactory first");return this._executorFactory=new IRt.DebuggableExecutorFactory(this._executorFactory,t),this.build()}useWarpGateway(t,r){return this._interactionsLoader=new Rot.CacheableInteractionsLoader(new PRt.WarpGatewayInteractionsLoader(t.confirmationStatus,t.source)),this._definitionLoader=new kot.CacheableContractDefinitionLoader(new CRt.WarpGatewayContractDefinitionLoader(this._arweave,this._environment),this._environment,r),this}useArweaveGateway(t){return this._interactionsLoader=new Rot.CacheableInteractionsLoader(new BRt.ArweaveGatewayInteractionsLoader(this._arweave,this._environment)),this._definitionLoader=new kot.CacheableContractDefinitionLoader(new ORt.ArweaveContractDefinitionLoader(this._arweave,this._environment),this._environment,t),this}build(){let t=new NRt.Warp(this._arweave,this._definitionLoader,this._interactionsLoader,this._executorFactory,this._stateEvaluator,this._environment);return this._definitionLoader.warp=t,this._interactionsLoader.warp=t,t}};Mw.WarpBuilder=WO});var HO=De(Lp=>{"use strict";Tt();Rt();xt();Object.defineProperty(Lp,"__esModule",{value:!0});Lp.knownWarpPlugins=Lp.knownWarpPluginsPartial=void 0;Lp.knownWarpPluginsPartial=["^smartweave-extension-"];Lp.knownWarpPlugins=["evm-signature-verification","subscription","ivm-handler-api","evaluation-progress","fetch-options","deploy","contract-blacklist","vm2","vrf","quickjs"]});var Sw=De(Ew=>{"use strict";Tt();Rt();xt();Object.defineProperty(Ew,"__esModule",{value:!0});Ew.Warp=void 0;var LRt=vw(),DRt=qO(),$Rt=Mot(),URt=KO(),Iot=HO(),Bot=VO(),qRt=Hm(),GO=class{get createContract(){if(!this._createContract)if(this.plugins.has("deploy")){let t=this.loadPlugin("deploy");this._createContract=t.process(this)}else throw new Error("In order to use CreateContract methods please attach DeployPlugin.");return this._createContract}constructor(t,r,h,o,l,c="custom"){this.arweave=t,this.definitionLoader=r,this.interactionsLoader=h,this.executorFactory=o,this.stateEvaluator=l,this.environment=c,this._gwUrl=Bot.WARP_GW_URL,this.plugins=new Map,this.testing=new $Rt.Testing(t),this.kvStorageFactory=p=>new qRt.LevelDbCache({inMemory:!1,dbLocation:`${Bot.DEFAULT_LEVEL_DB_LOCATION}/kv/ldb/${p}`}),this.eventTarget=new EventTarget}static builder(t,r,h){return new URt.WarpBuilder(t,r,h)}contract(t,r,h){return new LRt.HandlerBasedContract(t,this,r,h)}async deploy(t,r){return await this.createContract.deploy(t,r)}async deployFromSourceTx(t,r){return await this.createContract.deployFromSourceTx(t,r)}async deployBundled(t){return await this.createContract.deployBundled(t)}async register(t,r){return await this.createContract.register(t,r)}async createSource(t,r,h=!1){return await this.createContract.createSource(t,r,h)}async saveSource(t,r){return await this.createContract.saveSource(t,r)}pst(t){return new DRt.PstContractImpl(t,this)}useStateCache(t){return this.stateEvaluator.setCache(t),this}useContractCache(t,r){return this.definitionLoader.setSrcCache(r),this.definitionLoader.setCache(t),this}use(t){let r=t.type();if(!this.isPluginType(r))throw new Error(`Unknown plugin type ${r}.`);return this.plugins.set(r,t),this}hasPlugin(t){return this.plugins.has(t)}matchPlugins(t){return[...this.plugins.keys()].filter(h=>h.match(t))}loadPlugin(t){if(!this.hasPlugin(t))throw new Error(`Plugin ${t} not registered.`);return this.plugins.get(t)}maybeLoadPlugin(t){return this.hasPlugin(t)?this.plugins.get(t):null}async close(){return Promise.all([this.definitionLoader.getSrcCache().close(),this.definitionLoader.getCache().close(),this.stateEvaluator.getCache().close()]).then()}async generateWallet(){let t=await this.arweave.wallets.generate();return await this.testing.isArlocal()&&await this.testing.addFunds(t),{jwk:t,address:await this.arweave.wallets.jwkToAddress(t)}}isPluginType(t){return Iot.knownWarpPlugins.includes(t)||Iot.knownWarpPluginsPartial.some(r=>t.match(r))}useKVStorageFactory(t){return this.kvStorageFactory=t,this}useGwUrl(t){return this._gwUrl=t,this}gwUrl(){return this._gwUrl}};Ew.Warp=GO});var VO=De(Sn=>{"use strict";Tt();Rt();xt();var FRt=Sn&&Sn.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Sn,"__esModule",{value:!0});Sn.WarpFactory=Sn.defaultCacheOptions=Sn.DEFAULT_LEVEL_DB_LOCATION=Sn.WARP_GW_URL=Sn.defaultWarpGwOptions=void 0;var ZO=FRt($4()),jRt=Hm(),zRt=YB(),WRt=WB(),KRt=qf(),HRt=Xm(),GRt=Sw();Sn.defaultWarpGwOptions={confirmationStatus:{notCorrupted:!0},source:HRt.SourceType.BOTH};Sn.WARP_GW_URL="https://gw.warp.cc";Sn.DEFAULT_LEVEL_DB_LOCATION="./cache/warp";Sn.defaultCacheOptions={inMemory:!1,dbLocation:Sn.DEFAULT_LEVEL_DB_LOCATION};var JO=class{static forLocal(t=1984,r=ZO.default.init({host:"localhost",port:t,protocol:"http"}),h={...Sn.defaultCacheOptions,inMemory:!0}){return this.customArweaveGw(r,h,"local")}static forTestnet(t=Sn.defaultCacheOptions,r=!1,h=ZO.default.init({host:"arweave.net",port:443,protocol:"https"})){return r?this.customArweaveGw(h,t,"testnet"):this.customWarpGw(h,Sn.defaultWarpGwOptions,t,"testnet")}static forMainnet(t=Sn.defaultCacheOptions,r=!1,h=ZO.default.init({host:"arweave.net",port:443,protocol:"https"})){return r?this.customArweaveGw(h,t,"mainnet"):this.customWarpGw(h,Sn.defaultWarpGwOptions,t,"mainnet")}static custom(t,r,h){let o=new jRt.LevelDbCache({...r,dbLocation:`${r.dbLocation}/state`}),l=new KRt.HandlerExecutorFactory(t),c=new WRt.CacheableStateEvaluator(t,o,[new zRt.Evolve]);return GRt.Warp.builder(t,o,h).setExecutorFactory(l).setStateEvaluator(c)}static customArweaveGw(t,r=Sn.defaultCacheOptions,h){return this.custom(t,r,h).useArweaveGateway(r).build()}static customWarpGw(t,r=Sn.defaultWarpGwOptions,h=Sn.defaultCacheOptions,o){return this.custom(t,h,o).useWarpGateway(r,h).build()}};Sn.WarpFactory=JO});var Cot=De(Oot=>{"use strict";Tt();Rt();xt();Object.defineProperty(Oot,"__esModule",{value:!0})});var Not=De(Pot=>{"use strict";Tt();Rt();xt();Object.defineProperty(Pot,"__esModule",{value:!0})});var Dot=De(Lot=>{"use strict";Tt();Rt();xt();Object.defineProperty(Lot,"__esModule",{value:!0})});var Uot=De($ot=>{"use strict";Tt();Rt();xt();Object.defineProperty($ot,"__esModule",{value:!0})});var Fot=De(qot=>{"use strict";Tt();Rt();xt();Object.defineProperty(qot,"__esModule",{value:!0})});var jot=De(Aw=>{"use strict";Tt();Rt();xt();Object.defineProperty(Aw,"__esModule",{value:!0});Aw.matchMutClosureDtor=void 0;function VRt(i){let t=/(const|var) ret = makeMutClosure\(arg0, arg1, (\d+?), __wbg_adapter/;return i.match(t)[2]}Aw.matchMutClosureDtor=VRt});var Wot=De(Dp=>{"use strict";Tt();Rt();xt();var ZRt=Dp&&Dp.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Dp,"__esModule",{value:!0});Dp.ArweaveGatewayBundledContractDefinitionLoader=void 0;var JRt=Qm(),Qa=Vh(),zot=Qs(),XRt=bn(),YRt=gl(),QRt=H4(),tkt=dv(),ekt=ZRt($4());function ts(i,t,r=void 0){let h=i.find(({name:o})=>o===t);return h?h.value:r}var XO=class i{constructor(t){this.env=t,this.logger=XRt.LoggerFactory.INST.create(i.name)}async load(t,r){let h=zot.Benchmark.measure(),o=await this.fetchContractTx(t);this.logger.debug("Contract tx fetch time",h.elapsed());let l=o.owner.address,c=r||ts(o.tags,Qa.SMART_WEAVE_TAGS.CONTRACT_SRC_TX_ID),p=ts(o.tags,Qa.WARP_TAGS.WARP_TESTNET)||null;if(p&&this.env!=="testnet")throw new Error('Trying to use testnet contract in a non-testnet env. Use the "forTestnet" factory method.');if(!p&&this.env==="testnet")throw new Error("Trying to use non-testnet contract in a testnet env.");let w=ts(o.tags,Qa.SMART_WEAVE_TAGS.MIN_FEE),m=ts(o.tags,Qa.WARP_TAGS.MANIFEST)?JSON.parse(ts(o.tags,Qa.WARP_TAGS.MANIFEST)):null;this.logger.debug("Tags decoding",h.elapsed());let y=await this.evalInitialState(o);this.logger.debug("init state",y);let v=JSON.parse(y);this.logger.debug("Parsing src and init state",h.elapsed());let{src:M,srcBinary:T,srcWasmLang:A,contractType:R,metadata:B,srcTx:C}=await this.loadContractSource(c),P={txId:t,srcTxId:c,src:M,srcBinary:T,srcWasmLang:A,initState:v,minFee:w,owner:l,contractType:R,metadata:B,manifest:m,contractTx:await this.convertToWarpCompatibleContractTx(o),srcTx:await this.convertToWarpCompatibleContractTx(C),testnet:p};return this.logger.info(`Contract definition loaded in: ${h.elapsed()}`),P}async fetchContractTx(t){let r=await this.arweaveTransactions.transaction(t);return r??await this.arweaveTransactions.transactionUsingUploaderTag(t)}async convertToWarpCompatibleContractTx(t){return{tags:t.tags.map(({name:h,value:o})=>({name:ge.from(h).toString("base64url"),value:ge.from(o).toString("base64url")})),owner:t.owner.key,target:t.recipient,signature:t.signature,data:(await this.arweaveWrapper.txData(t.id)).toString("base64url")}}async loadContractSource(t){let r=zot.Benchmark.measure(),h=await this.fetchContractTx(t),o=ts(h.tags,Qa.SMART_WEAVE_TAGS.CONTENT_TYPE);if(!JRt.SUPPORTED_SRC_CONTENT_TYPES.includes(o))throw new Error(`Contract source content type ${o} not supported`);let l=o==="application/javascript"?"js":"wasm",c=await this.contractSource(h,l),p,w,m;if(l=="wasm"){if(w=new tkt.WasmSrc(c),p=ts(h.tags,Qa.WARP_TAGS.WASM_LANG),!p)throw new Error(`Wasm lang not set for wasm contract src ${h.id}`);m=JSON.parse(ts(h.tags,Qa.WARP_TAGS.WASM_META))}return this.logger.debug("Contract src tx load",r.elapsed()),r.reset(),{src:l=="js"?c:null,srcBinary:l=="wasm"?w.wasmBinary():null,srcWasmLang:p,contractType:l,metadata:m,srcTx:h}}async contractSource(t,r){if(ts(t.tags,Qa.WARP_TAGS.UPLOADER_TX_ID)!=null){let o=await this.arweaveWrapper.txDataString(t.id);if(r==="wasm")throw new Error("WASM contracts in legacy format are not supported using AR GW");return ekt.default.utils.b64UrlToString(JSON.parse(o).data)}return r==="js"?await this.arweaveWrapper.txDataString(t.id):await this.arweaveWrapper.txData(t.id)}async evalInitialState(t){if(ts(t.tags,Qa.WARP_TAGS.INIT_STATE))return ts(t.tags,Qa.WARP_TAGS.INIT_STATE);if(ts(t.tags,Qa.WARP_TAGS.INIT_STATE_TX)){let r=ts(t.tags,Qa.WARP_TAGS.INIT_STATE_TX);return this.arweaveWrapper.txDataString(r)}else return this.arweaveWrapper.txDataString(t.id)}setCache(){throw new Error("Method not implemented.")}setSrcCache(){throw new Error("Method not implemented.")}getCache(){throw new Error("Method not implemented.")}getSrcCache(){throw new Error("Method not implemented.")}type(){return"arweave"}set warp(t){this.arweaveWrapper=new YRt.ArweaveWrapper(t),this.arweaveTransactions=new QRt.ArweaveGQLTxsFetcher(t)}};Dp.ArweaveGatewayBundledContractDefinitionLoader=XO});var Vot=De(Tw=>{"use strict";Tt();Rt();xt();Object.defineProperty(Tw,"__esModule",{value:!0});Tw.ArweaveGatewayBundledInteractionLoader=void 0;var es=Vh(),rkt=Qs(),ikt=bn(),nkt=gl(),Kot=ed(),okt=H4(),YO=ko(),akt=Vu(),Hot=100,skt=100,Got=1057409,QO=class i{constructor(t,r){this.arweave=t,this.environment=r,this.logger=ikt.LoggerFactory.INST.create(i.name),this.tagsParser=new akt.TagsParser,this.sorter=new Kot.LexicographicalInteractionsSorter(t)}async load(t,r,h,o,l){if(this.logger.debug("Loading interactions for",{contractId:t,fromSortKey:r,toSortKey:h}),o?.transactionsPagesPerBatch)throw new Error(`Loading in batches not yet implemented for ${i.name}`);let c=this.sorter.extractBlockHeight(r)||0,p=this.sorter.extractBlockHeight(h)||await this.currentBlockHeight(),w={tags:[{name:es.SMART_WEAVE_TAGS.APP_NAME,values:["SmartWeaveAction"]},{name:es.SMART_WEAVE_TAGS.CONTRACT_TX_ID,values:[t]},{name:es.WARP_TAGS.SEQUENCER,values:["RedStone"]}],blockFilter:{min:c,max:p+skt},first:Hot},m=rkt.Benchmark.measure(),y=await this.arweaveFetcher.transactions(w,Number.MAX_SAFE_INTEGER,l);o.internalWrites&&(y=await this.appendInternalWriteInteractions(t,c,p,y,l)),m.stop(),this.logger.debug("All loaded interactions:",{from:r,to:h,loaded:y.length,time:m.elapsed()}),y.forEach(A=>{var R,B,C,P;A.node.sortKey=(R=A.node.sortKey)!==null&&R!==void 0?R:(P=(C=(B=A.node)===null||B===void 0?void 0:B.tags)===null||C===void 0?void 0:C.find(N=>N.name===es.WARP_TAGS.SEQUENCER_SORT_KEY))===null||P===void 0?void 0:P.value});let v=await this.sorter.sort(y),M=this.environment==="local"||this.environment==="testnet",T=this._warp.maybeLoadPlugin("vrf");return v.filter(A=>this.isNewerThenSortKeyBlockHeight(A)).filter(A=>this.isSortKeyInBounds(r,h,A)).map(A=>this.attachSequencerDataToInteraction(A)).map(A=>this.maybeAddMockVrf(M,A,T)).map((A,R,B)=>this.verifySortKeyIntegrity(A,R,B)).map(({node:A})=>A)}verifySortKeyIntegrity(t,r,h){var o;if(r!==0){let l=h[r-1],c=h[r];if(this.logger.debug(`prev: ${l.node.id} | current: ${c.node.id}`),c.node.block.height<=Got||((o=c.node.lastSortKey)===null||o===void 0?void 0:o.split(",")[1])===Kot.defaultArweaveMs)return t;l.node.source==="redstone-sequencer"&&l.node.sortKey!==c.node.lastSortKey&&this.logger.warn(`Interaction loading error: interaction ${c.node.id} lastSortKey is not pointing on prev interaction ${l.node.id}`)}return t}isSortKeyInBounds(t,r,h){return t&&r?h.node.sortKey.localeCompare(t)>0&&h.node.sortKey.localeCompare(r)<=0:t&&!r?h.node.sortKey.localeCompare(t)>0:!t&&r?h.node.sortKey.localeCompare(r)<=0:!0}attachSequencerDataToInteraction(t){let r=v=>{var M;return(M=t.node.tags.find(T=>T.name===v))===null||M===void 0?void 0:M.value},h=r(es.WARP_TAGS.SEQUENCER_TX_ID),o=r(es.WARP_TAGS.SEQUENCER_OWNER),l=r(es.WARP_TAGS.SEQUENCER_BLOCK_ID),c=r(es.WARP_TAGS.SEQUENCER_BLOCK_HEIGHT),p=r(es.WARP_TAGS.SEQUENCER_PREV_SORT_KEY)||r(es.WARP_TAGS.SEQUENCER_LAST_SORT_KEY),w=r(es.WARP_TAGS.SEQUENCER_SORT_KEY),m=r(es.WARP_TAGS.SEQUENCER_BLOCK_TIMESTAMP),y=(0,YO.safeParseInt)(c);if(!o||!l||!c||!p&&y>Got||!h||!w)throw Error(`Interaction ${t.node.id} is not sequenced by sequencer aborting. Only Sequenced transactions are supported by loader ${i.name}`);return{...t,node:{...t.node,owner:{address:o,key:null},block:{...t.node.block,height:(0,YO.safeParseInt)(c),id:l,timestamp:m?(0,YO.safeParseInt)(m):t.node.block.timestamp},sortKey:w,lastSortKey:p,id:h,source:"redstone-sequencer"}}}async appendInternalWriteInteractions(t,r,h,o,l){let c={tags:[{name:es.WARP_TAGS.INTERACT_WRITE,values:[t]}],blockFilter:{min:r,max:h},first:Hot},p=await this.arweaveFetcher.transactions(c,Number.MAX_SAFE_INTEGER,l);return this.logger.debug("Inner writes interactions length:",p.length),o=o.concat(p),o}maybeAddMockVrf(t,r,h){return t&&this.tagsParser.hasVrfTag(r.node)&&(h?r.node.vrf=h.process().generateMockVrf(r.node.sortKey):this.logger.warn('Cannot generate mock vrf for interaction - no "warp-contracts-plugin-vrf" attached!')),r}isNewerThenSortKeyBlockHeight(t){if(t.node.sortKey){let r=t.node.sortKey.split(",")[0],h=Number.parseInt(r);return Number(t.node.block.height)-h>=0}return!0}async currentBlockHeight(){return(await this.arweaveWrapper.info()).height}type(){return"arweave"}clearCache(){}set warp(t){this.arweaveWrapper=new nkt.ArweaveWrapper(t),this.arweaveFetcher=new okt.ArweaveGQLTxsFetcher(t),this._warp=t}};Tw.ArweaveGatewayBundledInteractionLoader=QO});var Zot=De(Mr=>{"use strict";Tt();Rt();xt();var hkt=Mr&&Mr.__createBinding||(Object.create?function(i,t,r,h){h===void 0&&(h=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(i,h,o)}:function(i,t,r,h){h===void 0&&(h=r),i[h]=t[r]}),Ar=Mr&&Mr.__exportStar||function(i,t){for(var r in i)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&hkt(t,i,r)};Object.defineProperty(Mr,"__esModule",{value:!0});Ar(lk(),Mr);Ar(pk(),Mr);Ar(Uet(),Mr);Ar(bn(),Mr);Ar(uk(),Mr);Ar(Qs(),Mr);Ar(Fet(),Mr);Ar($u(),Mr);Ar(zet(),Mr);Ar(Hm(),Mr);Ar(eit(),Mr);Ar(iit(),Mr);Ar(oit(),Mr);Ar(sit(),Mr);Ar(fit(),Mr);Ar(Ym(),Mr);Ar(z4(),Mr);Ar(OB(),Mr);Ar(DB(),Mr);Ar(Xm(),Mr);Ar(UB(),Mr);Ar(jB(),Mr);Ar(WB(),Mr);Ar(qf(),Mr);Ar(ed(),Mr);Ar(Vu(),Mr);Ar(xI(),Mr);Ar(S4(),Mr);Ar(wp(),Mr);Ar(TI(),Mr);Ar(Snt(),Mr);Ar(Vh(),Mr);Ar(Ant(),Mr);Ar(Qm(),Mr);Ar(GB(),Mr);Ar(VO(),Mr);Ar(Sw(),Mr);Ar(KO(),Mr);Ar(HO(),Mr);Ar(Jm(),Mr);Ar(Cot(),Mr);Ar(vw(),Mr);Ar(Not(),Mr);Ar(qO(),Mr);Ar(hO(),Mr);Ar(MO(),Mr);Ar(EO(),Mr);Ar(Dot(),Mr);Ar(aO(),Mr);Ar(CO(),Mr);Ar(Uot(),Mr);Ar(Fot(),Mr);Ar(b4(),Mr);Ar(ZB(),Mr);Ar(BI(),Mr);Ar(oO(),Mr);Ar(ko(),Mr);Ar(gl(),Mr);Ar(Ep(),Mr);Ar(dv(),Mr);Ar(MI(),Mr);Ar(jot(),Mr);Ar(Wot(),Mr);Ar(Vot(),Mr)});Tt();Rt();xt();var iat=sc(z5(),1);Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();var Ist=["gateway","gateways","prescribedObservers","record","auction","balance","epoch","priceForInteraction"],Bst=["delegateStake","decreaseDelegateStake","joinNetwork","increaseOperatorStake","decreaseOperatorStake","updateGatewaySettings","saveObservations","extendRecord","buyRecord","increaseUndernameCount","transfer"],$kt=[...Ist,...Bst],ho={GATEWAY:"gateway",GATEWAYS:"gateways",PRESCRIBED_OBSERVERS:"prescribedObservers",DELEGATE_STAKE:"delegateStake",DECREASE_DELEGATE_STAKE:"decreaseDelegateStake",JOIN_NETWORK:"joinNetwork",INCREASE_OPERATOR_STAKE:"increaseOperatorStake",DECREASE_OPERATOR_STAKE:"decreaseOperatorStake",UPDATE_GATEWAY_SETTINGS:"updateGatewaySettings",SAVE_OBSERVATIONS:"saveObservations",EXTEND_RECORD:"extendRecord",INCREASE_UNDERNAME_COUNT:"increaseUndernameCount",RECORD:"record",AUCTION:"auction",TRANSFER:"transfer",BALANCE:"balance",PRICE_FOR_INTERACTION:"priceForInteraction",EPOCH:"epoch",BUY_RECORD:"buyRecord"},AL=(r=>(r.IO="IO",r.MIO="mIO",r))(AL||{}),cc={TRANSFER:"transfer",SET_CONTROLLER:"setController",REMOVE_CONTROLLER:"removeController",SET_NAME:"setName",SET_TICKER:"setTicker",SET_RECORD:"setRecord",REMOVE_RECORD:"removeRecord",BALANCE:"balance",EVOLVE:"evolve"};Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();var TL=new RegExp("^[a-zA-Z0-9_-]{43}$"),Hkt=new RegExp("^(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{1,63}$"),xL=new RegExp("^[0-9]{12},[0-9]{13},[a-fA-F0-9]{64}$"),Sy=me.env.ARNS_REGISTRY_TX??"bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U",Gkt="_NctcA2sRy1-J4OmIQZbYFPM17piNcbdBPH2ncX2RL8",Ost="GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc",Od=Ost,Vkt="agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA",W5=1e6,RL="cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk",kL="3OlGzE5mrsN2GsxCYM0Tae1KzWepGOr5a94deOWmApM",IL="_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA";var K5=class i{constructor(t){this.positiveFiniteInteger=t;if(!Number.isFinite(this.positiveFiniteInteger)||!Number.isInteger(this.positiveFiniteInteger)||this.positiveFiniteInteger<0)throw new Error(`Number must be a non-negative integer value! ${t}`)}[Symbol.toPrimitive](t){return t==="string"&&this.toString(),this.positiveFiniteInteger}plus(t){return new i(this.positiveFiniteInteger+t.positiveFiniteInteger)}minus(t){return new i(this.positiveFiniteInteger-t.positiveFiniteInteger)}isGreaterThan(t){return this.positiveFiniteInteger>t.positiveFiniteInteger}isGreaterThanOrEqualTo(t){return this.positiveFiniteInteger>=t.positiveFiniteInteger}isLessThan(t){return this.positiveFiniteInteger<t.positiveFiniteInteger}isLessThanOrEqualTo(t){return this.positiveFiniteInteger<=t.positiveFiniteInteger}toString(){return`${this.positiveFiniteInteger}`}valueOf(){return this.positiveFiniteInteger}toJSON(){return this.positiveFiniteInteger}equals(t){return this.positiveFiniteInteger===t.positiveFiniteInteger}},r2=class{value;constructor(t){if(!Number.isFinite(t)||t<0)throw new Error("IOToken must be a non-negative finite number");this.value=+t.toFixed(6)}valueOf(){return this.value}toMIO(){return new H5(Math.floor(this.value*W5))}toString(){return`${this.value}`}},H5=class i extends K5{constructor(t){super(t)}multiply(t){let r=Math.floor(this.valueOf()*t.valueOf());return new i(r)}divide(t){if(t.valueOf()===0)throw new Error("Cannot divide by zero");let r=Math.floor(this.valueOf()/t.valueOf());return new i(r)}plus(t){let r=super.plus(t);return new i(r.valueOf())}minus(t){let r=super.minus(t);return new i(r.valueOf())}toIO(){return new r2(this.valueOf()/W5)}};Tt();Rt();xt();Tt();Rt();xt();var Ey=i=>TL.test(i);function oIt(i){return i!==void 0&&!isNaN(parseInt(i.toString()))}var aIt=i=>["id","owner","tags","signature"].every(r=>r in i);function BL(i){return i.reduce((t,r)=>{let h=r.get("name",{decode:!0,string:!0}),o=r.get("value",{decode:!0,string:!0});return t[h]=o,t},{})}function Rl(i){return"process"in i}function kl(i){return"processId"in i&&typeof i.processId=="string"&&Ey(i.processId)===!0}function lIt(i){return i.type==="lease"&&i.endTimestamp!==void 0}Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();function RIt(i){return G5.validate(i)}var G5=class i{_sortKey;constructor(t){if(!i.validate(t))throw new Error(`Invalid sort key: ${t}`);this._sortKey=t}static validate(t){return xL.test(t)}toString(){return this._sortKey}parts(){return this._sortKey.split(",")}blockHeight(){return parseInt(this.parts()[0])}timestamp(){return parseInt(this.parts()[1])}hash(){return this.parts()[2]}};async function OL({arweave:i,contractTxId:t}){let{tags:r}=await i.transactions.get(t).catch(()=>({tags:[]})),o=BL(r)["Contract-Manifest"]??"{}";return JSON.parse(o)}function Yf(i){return"contract"in i}function Qf(i){return"contractTxId"in i&&typeof i.contractTxId=="string"&&Ey(i.contractTxId)===!0}Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();function i2(i,t){return function(){return i.apply(t,arguments)}}var{toString:Cst}=Object.prototype,{getPrototypeOf:J5}=Object,Ty=(i=>t=>{let r=Cst.call(t);return i[r]||(i[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),gh=i=>(i=i.toLowerCase(),t=>Ty(t)===i),xy=i=>t=>typeof t===i,{isArray:Cd}=Array,n2=xy("undefined");function Pst(i){return i!==null&&!n2(i)&&i.constructor!==null&&!n2(i.constructor)&&ls(i.constructor.isBuffer)&&i.constructor.isBuffer(i)}var NL=gh("ArrayBuffer");function Nst(i){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(i):t=i&&i.buffer&&NL(i.buffer),t}var Lst=xy("string"),ls=xy("function"),LL=xy("number"),Ry=i=>i!==null&&typeof i=="object",Dst=i=>i===!0||i===!1,Ay=i=>{if(Ty(i)!=="object")return!1;let t=J5(i);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in i)&&!(Symbol.iterator in i)},$st=gh("Date"),Ust=gh("File"),qst=gh("Blob"),Fst=gh("FileList"),jst=i=>Ry(i)&&ls(i.pipe),zst=i=>{let t;return i&&(typeof FormData=="function"&&i instanceof FormData||ls(i.append)&&((t=Ty(i))==="formdata"||t==="object"&&ls(i.toString)&&i.toString()==="[object FormData]"))},Wst=gh("URLSearchParams"),[Kst,Hst,Gst,Vst]=["ReadableStream","Request","Response","Headers"].map(gh),Zst=i=>i.trim?i.trim():i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function o2(i,t,{allOwnKeys:r=!1}={}){if(i===null||typeof i>"u")return;let h,o;if(typeof i!="object"&&(i=[i]),Cd(i))for(h=0,o=i.length;h<o;h++)t.call(null,i[h],h,i);else{let l=r?Object.getOwnPropertyNames(i):Object.keys(i),c=l.length,p;for(h=0;h<c;h++)p=l[h],t.call(null,i[p],p,i)}}function DL(i,t){t=t.toLowerCase();let r=Object.keys(i),h=r.length,o;for(;h-- >0;)if(o=r[h],t===o.toLowerCase())return o;return null}var $L=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,UL=i=>!n2(i)&&i!==$L;function Z5(){let{caseless:i}=UL(this)&&this||{},t={},r=(h,o)=>{let l=i&&DL(t,o)||o;Ay(t[l])&&Ay(h)?t[l]=Z5(t[l],h):Ay(h)?t[l]=Z5({},h):Cd(h)?t[l]=h.slice():t[l]=h};for(let h=0,o=arguments.length;h<o;h++)arguments[h]&&o2(arguments[h],r);return t}var Jst=(i,t,r,{allOwnKeys:h}={})=>(o2(t,(o,l)=>{r&&ls(o)?i[l]=i2(o,r):i[l]=o},{allOwnKeys:h}),i),Xst=i=>(i.charCodeAt(0)===65279&&(i=i.slice(1)),i),Yst=(i,t,r,h)=>{i.prototype=Object.create(t.prototype,h),i.prototype.constructor=i,Object.defineProperty(i,"super",{value:t.prototype}),r&&Object.assign(i.prototype,r)},Qst=(i,t,r,h)=>{let o,l,c,p={};if(t=t||{},i==null)return t;do{for(o=Object.getOwnPropertyNames(i),l=o.length;l-- >0;)c=o[l],(!h||h(c,i,t))&&!p[c]&&(t[c]=i[c],p[c]=!0);i=r!==!1&&J5(i)}while(i&&(!r||r(i,t))&&i!==Object.prototype);return t},tht=(i,t,r)=>{i=String(i),(r===void 0||r>i.length)&&(r=i.length),r-=t.length;let h=i.indexOf(t,r);return h!==-1&&h===r},eht=i=>{if(!i)return null;if(Cd(i))return i;let t=i.length;if(!LL(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=i[t];return r},rht=(i=>t=>i&&t instanceof i)(typeof Uint8Array<"u"&&J5(Uint8Array)),iht=(i,t)=>{let h=(i&&i[Symbol.iterator]).call(i),o;for(;(o=h.next())&&!o.done;){let l=o.value;t.call(i,l[0],l[1])}},nht=(i,t)=>{let r,h=[];for(;(r=i.exec(t))!==null;)h.push(r);return h},oht=gh("HTMLFormElement"),aht=i=>i.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,h,o){return h.toUpperCase()+o}),CL=(({hasOwnProperty:i})=>(t,r)=>i.call(t,r))(Object.prototype),sht=gh("RegExp"),qL=(i,t)=>{let r=Object.getOwnPropertyDescriptors(i),h={};o2(r,(o,l)=>{let c;(c=t(o,l,i))!==!1&&(h[l]=c||o)}),Object.defineProperties(i,h)},hht=i=>{qL(i,(t,r)=>{if(ls(i)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let h=i[r];if(ls(h)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},fht=(i,t)=>{let r={},h=o=>{o.forEach(l=>{r[l]=!0})};return Cd(i)?h(i):h(String(i).split(t)),r},uht=()=>{},cht=(i,t)=>i!=null&&Number.isFinite(i=+i)?i:t,V5="abcdefghijklmnopqrstuvwxyz",PL="0123456789",FL={DIGIT:PL,ALPHA:V5,ALPHA_DIGIT:V5+V5.toUpperCase()+PL},lht=(i=16,t=FL.ALPHA_DIGIT)=>{let r="",{length:h}=t;for(;i--;)r+=t[Math.random()*h|0];return r};function dht(i){return!!(i&&ls(i.append)&&i[Symbol.toStringTag]==="FormData"&&i[Symbol.iterator])}var pht=i=>{let t=new Array(10),r=(h,o)=>{if(Ry(h)){if(t.indexOf(h)>=0)return;if(!("toJSON"in h)){t[o]=h;let l=Cd(h)?[]:{};return o2(h,(c,p)=>{let w=r(c,o+1);!n2(w)&&(l[p]=w)}),t[o]=void 0,l}}return h};return r(i,0)},ght=gh("AsyncFunction"),mht=i=>i&&(Ry(i)||ls(i))&&ls(i.then)&&ls(i.catch),Ke={isArray:Cd,isArrayBuffer:NL,isBuffer:Pst,isFormData:zst,isArrayBufferView:Nst,isString:Lst,isNumber:LL,isBoolean:Dst,isObject:Ry,isPlainObject:Ay,isReadableStream:Kst,isRequest:Hst,isResponse:Gst,isHeaders:Vst,isUndefined:n2,isDate:$st,isFile:Ust,isBlob:qst,isRegExp:sht,isFunction:ls,isStream:jst,isURLSearchParams:Wst,isTypedArray:rht,isFileList:Fst,forEach:o2,merge:Z5,extend:Jst,trim:Zst,stripBOM:Xst,inherits:Yst,toFlatObject:Qst,kindOf:Ty,kindOfTest:gh,endsWith:tht,toArray:eht,forEachEntry:iht,matchAll:nht,isHTMLForm:oht,hasOwnProperty:CL,hasOwnProp:CL,reduceDescriptors:qL,freezeMethods:hht,toObjectSet:fht,toCamelCase:aht,noop:uht,toFiniteNumber:cht,findKey:DL,global:$L,isContextDefined:UL,ALPHABET:FL,generateString:lht,isSpecCompliantForm:dht,toJSONObject:pht,isAsyncFn:ght,isThenable:mht};Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();function Pd(i,t,r,h,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=i,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),h&&(this.request=h),o&&(this.response=o)}Ke.inherits(Pd,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ke.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var jL=Pd.prototype,zL={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(i=>{zL[i]={value:i}});Object.defineProperties(Pd,zL);Object.defineProperty(jL,"isAxiosError",{value:!0});Pd.from=(i,t,r,h,o,l)=>{let c=Object.create(jL);return Ke.toFlatObject(i,c,function(w){return w!==Error.prototype},p=>p!=="isAxiosError"),Pd.call(c,i.message,t,r,h,o),c.cause=i,c.name=i.name,l&&Object.assign(c,l),c};var Nr=Pd;Tt();Rt();xt();var ky=null;function X5(i){return Ke.isPlainObject(i)||Ke.isArray(i)}function KL(i){return Ke.endsWith(i,"[]")?i.slice(0,-2):i}function WL(i,t,r){return i?i.concat(t).map(function(o,l){return o=KL(o),!r&&l?"["+o+"]":o}).join(r?".":""):t}function vht(i){return Ke.isArray(i)&&!i.some(X5)}var yht=Ke.toFlatObject(Ke,{},null,function(t){return/^is[A-Z]/.test(t)});function bht(i,t,r){if(!Ke.isObject(i))throw new TypeError("target must be an object");t=t||new(ky||FormData),r=Ke.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(R,B){return!Ke.isUndefined(B[R])});let h=r.metaTokens,o=r.visitor||y,l=r.dots,c=r.indexes,w=(r.Blob||typeof Blob<"u"&&Blob)&&Ke.isSpecCompliantForm(t);if(!Ke.isFunction(o))throw new TypeError("visitor must be a function");function m(A){if(A===null)return"";if(Ke.isDate(A))return A.toISOString();if(!w&&Ke.isBlob(A))throw new Nr("Blob is not supported. Use a Buffer instead.");return Ke.isArrayBuffer(A)||Ke.isTypedArray(A)?w&&typeof Blob=="function"?new Blob([A]):ge.from(A):A}function y(A,R,B){let C=A;if(A&&!B&&typeof A=="object"){if(Ke.endsWith(R,"{}"))R=h?R:R.slice(0,-2),A=JSON.stringify(A);else if(Ke.isArray(A)&&vht(A)||(Ke.isFileList(A)||Ke.endsWith(R,"[]"))&&(C=Ke.toArray(A)))return R=KL(R),C.forEach(function(N,q){!(Ke.isUndefined(N)||N===null)&&t.append(c===!0?WL([R],q,l):c===null?R:R+"[]",m(N))}),!1}return X5(A)?!0:(t.append(WL(B,R,l),m(A)),!1)}let v=[],M=Object.assign(yht,{defaultVisitor:y,convertValue:m,isVisitable:X5});function T(A,R){if(!Ke.isUndefined(A)){if(v.indexOf(A)!==-1)throw Error("Circular reference detected in "+R.join("."));v.push(A),Ke.forEach(A,function(C,P){(!(Ke.isUndefined(C)||C===null)&&o.call(t,C,Ke.isString(P)?P.trim():P,R,M))===!0&&T(C,R?R.concat(P):[P])}),v.pop()}}if(!Ke.isObject(i))throw new TypeError("data must be an object");return T(i),t}var lc=bht;function HL(i){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(i).replace(/[!'()~]|%20|%00/g,function(h){return t[h]})}function GL(i,t){this._pairs=[],i&&lc(i,this,t)}var VL=GL.prototype;VL.append=function(t,r){this._pairs.push([t,r])};VL.toString=function(t){let r=t?function(h){return t.call(this,h,HL)}:HL;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};var Iy=GL;function wht(i){return encodeURIComponent(i).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function a2(i,t,r){if(!t)return i;let h=r&&r.encode||wht,o=r&&r.serialize,l;if(o?l=o(t,r):l=Ke.isURLSearchParams(t)?t.toString():new Iy(t,r).toString(h),l){let c=i.indexOf("#");c!==-1&&(i=i.slice(0,c)),i+=(i.indexOf("?")===-1?"?":"&")+l}return i}Tt();Rt();xt();var Y5=class{constructor(){this.handlers=[]}use(t,r,h){return this.handlers.push({fulfilled:t,rejected:r,synchronous:h?h.synchronous:!1,runWhen:h?h.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Ke.forEach(this.handlers,function(h){h!==null&&t(h)})}},Q5=Y5;Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();var By={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();var ZL=typeof URLSearchParams<"u"?URLSearchParams:Iy;Tt();Rt();xt();var JL=typeof FormData<"u"?FormData:null;Tt();Rt();xt();var XL=typeof Blob<"u"?Blob:null;var YL={isBrowser:!0,classes:{URLSearchParams:ZL,FormData:JL,Blob:XL},protocols:["http","https","file","blob","url","data"]};var e7={};cs(e7,{hasBrowserEnv:()=>t7,hasStandardBrowserEnv:()=>_ht,hasStandardBrowserWebWorkerEnv:()=>Mht,origin:()=>Sht});Tt();Rt();xt();var t7=typeof window<"u"&&typeof document<"u",_ht=(i=>t7&&["ReactNative","NativeScript","NS"].indexOf(i)<0)(typeof navigator<"u"&&navigator.product),Mht=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Sht=t7&&window.location.href||"http://localhost";var fo={...e7,...YL};function r7(i,t){return lc(i,new fo.classes.URLSearchParams,Object.assign({visitor:function(r,h,o,l){return fo.isNode&&Ke.isBuffer(r)?(this.append(h,r.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)}},t))}Tt();Rt();xt();function Eht(i){return Ke.matchAll(/\w+|\[(\w*)]/g,i).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Aht(i){let t={},r=Object.keys(i),h,o=r.length,l;for(h=0;h<o;h++)l=r[h],t[l]=i[l];return t}function Tht(i){function t(r,h,o,l){let c=r[l++];if(c==="__proto__")return!0;let p=Number.isFinite(+c),w=l>=r.length;return c=!c&&Ke.isArray(o)?o.length:c,w?(Ke.hasOwnProp(o,c)?o[c]=[o[c],h]:o[c]=h,!p):((!o[c]||!Ke.isObject(o[c]))&&(o[c]=[]),t(r,h,o[c],l)&&Ke.isArray(o[c])&&(o[c]=Aht(o[c])),!p)}if(Ke.isFormData(i)&&Ke.isFunction(i.entries)){let r={};return Ke.forEachEntry(i,(h,o)=>{t(Eht(h),o,r,0)}),r}return null}var Oy=Tht;function xht(i,t,r){if(Ke.isString(i))try{return(t||JSON.parse)(i),Ke.trim(i)}catch(h){if(h.name!=="SyntaxError")throw h}return(r||JSON.stringify)(i)}var i7={transitional:By,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let h=r.getContentType()||"",o=h.indexOf("application/json")>-1,l=Ke.isObject(t);if(l&&Ke.isHTMLForm(t)&&(t=new FormData(t)),Ke.isFormData(t))return o?JSON.stringify(Oy(t)):t;if(Ke.isArrayBuffer(t)||Ke.isBuffer(t)||Ke.isStream(t)||Ke.isFile(t)||Ke.isBlob(t)||Ke.isReadableStream(t))return t;if(Ke.isArrayBufferView(t))return t.buffer;if(Ke.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let p;if(l){if(h.indexOf("application/x-www-form-urlencoded")>-1)return r7(t,this.formSerializer).toString();if((p=Ke.isFileList(t))||h.indexOf("multipart/form-data")>-1){let w=this.env&&this.env.FormData;return lc(p?{"files[]":t}:t,w&&new w,this.formSerializer)}}return l||o?(r.setContentType("application/json",!1),xht(t)):t}],transformResponse:[function(t){let r=this.transitional||i7.transitional,h=r&&r.forcedJSONParsing,o=this.responseType==="json";if(Ke.isResponse(t)||Ke.isReadableStream(t))return t;if(t&&Ke.isString(t)&&(h&&!this.responseType||o)){let c=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(p){if(c)throw p.name==="SyntaxError"?Nr.from(p,Nr.ERR_BAD_RESPONSE,this,null,this.response):p}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:fo.classes.FormData,Blob:fo.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ke.forEach(["delete","get","head","post","put","patch"],i=>{i7.headers[i]={}});var Nd=i7;Tt();Rt();xt();Tt();Rt();xt();var Rht=Ke.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),QL=i=>{let t={},r,h,o;return i&&i.split(`
|
|
216
|
+
`))}this.rootOptions=Object.freeze(Object.assign({},t,r||{}))}forForeignContract(t){let r=(0,Vxt.deepCopy)(this.rootOptions);if(t)for(let h in t)r[h]=this.saferEvaluationOptions[h](t);return Object.freeze(r)}};aw.EvaluationOptionsEvaluator=SO});var mv={};cs(mv,{__addDisposableResource:()=>fot,__assign:()=>sw,__asyncDelegator:()=>eot,__asyncGenerator:()=>tot,__asyncValues:()=>rot,__await:()=>Bp,__awaiter:()=>Vnt,__classPrivateFieldGet:()=>aot,__classPrivateFieldIn:()=>hot,__classPrivateFieldSet:()=>sot,__createBinding:()=>fw,__decorate:()=>Knt,__disposeResources:()=>uot,__esDecorate:()=>Zxt,__exportStar:()=>Jnt,__extends:()=>znt,__generator:()=>Znt,__importDefault:()=>oot,__importStar:()=>not,__makeTemplateObject:()=>iot,__metadata:()=>Gnt,__param:()=>Hnt,__propKey:()=>Xxt,__read:()=>TO,__rest:()=>Wnt,__runInitializers:()=>Jxt,__setFunctionName:()=>Yxt,__spread:()=>Xnt,__spreadArray:()=>Qnt,__spreadArrays:()=>Ynt,__values:()=>hw,default:()=>eRt});function znt(i,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");AO(i,t);function r(){this.constructor=i}i.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Wnt(i,t){var r={};for(var h in i)Object.prototype.hasOwnProperty.call(i,h)&&t.indexOf(h)<0&&(r[h]=i[h]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,h=Object.getOwnPropertySymbols(i);o<h.length;o++)t.indexOf(h[o])<0&&Object.prototype.propertyIsEnumerable.call(i,h[o])&&(r[h[o]]=i[h[o]]);return r}function Knt(i,t,r,h){var o=arguments.length,l=o<3?t:h===null?h=Object.getOwnPropertyDescriptor(t,r):h,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(i,t,r,h);else for(var p=i.length-1;p>=0;p--)(c=i[p])&&(l=(o<3?c(l):o>3?c(t,r,l):c(t,r))||l);return o>3&&l&&Object.defineProperty(t,r,l),l}function Hnt(i,t){return function(r,h){t(r,h,i)}}function Zxt(i,t,r,h,o,l){function c(C){if(C!==void 0&&typeof C!="function")throw new TypeError("Function expected");return C}for(var p=h.kind,w=p==="getter"?"get":p==="setter"?"set":"value",m=!t&&i?h.static?i:i.prototype:null,y=t||(m?Object.getOwnPropertyDescriptor(m,h.name):{}),v,M=!1,T=r.length-1;T>=0;T--){var A={};for(var R in h)A[R]=R==="access"?{}:h[R];for(var R in h.access)A.access[R]=h.access[R];A.addInitializer=function(C){if(M)throw new TypeError("Cannot add initializers after decoration has completed");l.push(c(C||null))};var B=(0,r[T])(p==="accessor"?{get:y.get,set:y.set}:y[w],A);if(p==="accessor"){if(B===void 0)continue;if(B===null||typeof B!="object")throw new TypeError("Object expected");(v=c(B.get))&&(y.get=v),(v=c(B.set))&&(y.set=v),(v=c(B.init))&&o.unshift(v)}else(v=c(B))&&(p==="field"?o.unshift(v):y[w]=v)}m&&Object.defineProperty(m,h.name,y),M=!0}function Jxt(i,t,r){for(var h=arguments.length>2,o=0;o<t.length;o++)r=h?t[o].call(i,r):t[o].call(i);return h?r:void 0}function Xxt(i){return typeof i=="symbol"?i:"".concat(i)}function Yxt(i,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(i,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function Gnt(i,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,t)}function Vnt(i,t,r,h){function o(l){return l instanceof r?l:new r(function(c){c(l)})}return new(r||(r=Promise))(function(l,c){function p(y){try{m(h.next(y))}catch(v){c(v)}}function w(y){try{m(h.throw(y))}catch(v){c(v)}}function m(y){y.done?l(y.value):o(y.value).then(p,w)}m((h=h.apply(i,t||[])).next())})}function Znt(i,t){var r={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},h,o,l,c;return c={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function p(m){return function(y){return w([m,y])}}function w(m){if(h)throw new TypeError("Generator is already executing.");for(;c&&(c=0,m[0]&&(r=0)),r;)try{if(h=1,o&&(l=m[0]&2?o.return:m[0]?o.throw||((l=o.return)&&l.call(o),0):o.next)&&!(l=l.call(o,m[1])).done)return l;switch(o=0,l&&(m=[m[0]&2,l.value]),m[0]){case 0:case 1:l=m;break;case 4:return r.label++,{value:m[1],done:!1};case 5:r.label++,o=m[1],m=[0];continue;case 7:m=r.ops.pop(),r.trys.pop();continue;default:if(l=r.trys,!(l=l.length>0&&l[l.length-1])&&(m[0]===6||m[0]===2)){r=0;continue}if(m[0]===3&&(!l||m[1]>l[0]&&m[1]<l[3])){r.label=m[1];break}if(m[0]===6&&r.label<l[1]){r.label=l[1],l=m;break}if(l&&r.label<l[2]){r.label=l[2],r.ops.push(m);break}l[2]&&r.ops.pop(),r.trys.pop();continue}m=t.call(i,r)}catch(y){m=[6,y],o=0}finally{h=l=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}}function Jnt(i,t){for(var r in i)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&fw(t,i,r)}function hw(i){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&i[t],h=0;if(r)return r.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&h>=i.length&&(i=void 0),{value:i&&i[h++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function TO(i,t){var r=typeof Symbol=="function"&&i[Symbol.iterator];if(!r)return i;var h=r.call(i),o,l=[],c;try{for(;(t===void 0||t-- >0)&&!(o=h.next()).done;)l.push(o.value)}catch(p){c={error:p}}finally{try{o&&!o.done&&(r=h.return)&&r.call(h)}finally{if(c)throw c.error}}return l}function Xnt(){for(var i=[],t=0;t<arguments.length;t++)i=i.concat(TO(arguments[t]));return i}function Ynt(){for(var i=0,t=0,r=arguments.length;t<r;t++)i+=arguments[t].length;for(var h=Array(i),o=0,t=0;t<r;t++)for(var l=arguments[t],c=0,p=l.length;c<p;c++,o++)h[o]=l[c];return h}function Qnt(i,t,r){if(r||arguments.length===2)for(var h=0,o=t.length,l;h<o;h++)(l||!(h in t))&&(l||(l=Array.prototype.slice.call(t,0,h)),l[h]=t[h]);return i.concat(l||Array.prototype.slice.call(t))}function Bp(i){return this instanceof Bp?(this.v=i,this):new Bp(i)}function tot(i,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var h=r.apply(i,t||[]),o,l=[];return o={},p("next"),p("throw"),p("return",c),o[Symbol.asyncIterator]=function(){return this},o;function c(T){return function(A){return Promise.resolve(A).then(T,v)}}function p(T,A){h[T]&&(o[T]=function(R){return new Promise(function(B,C){l.push([T,R,B,C])>1||w(T,R)})},A&&(o[T]=A(o[T])))}function w(T,A){try{m(h[T](A))}catch(R){M(l[0][3],R)}}function m(T){T.value instanceof Bp?Promise.resolve(T.value.v).then(y,v):M(l[0][2],T)}function y(T){w("next",T)}function v(T){w("throw",T)}function M(T,A){T(A),l.shift(),l.length&&w(l[0][0],l[0][1])}}function eot(i){var t,r;return t={},h("next"),h("throw",function(o){throw o}),h("return"),t[Symbol.iterator]=function(){return this},t;function h(o,l){t[o]=i[o]?function(c){return(r=!r)?{value:Bp(i[o](c)),done:!1}:l?l(c):c}:l}}function rot(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],r;return t?t.call(i):(i=typeof hw=="function"?hw(i):i[Symbol.iterator](),r={},h("next"),h("throw"),h("return"),r[Symbol.asyncIterator]=function(){return this},r);function h(l){r[l]=i[l]&&function(c){return new Promise(function(p,w){c=i[l](c),o(p,w,c.done,c.value)})}}function o(l,c,p,w){Promise.resolve(w).then(function(m){l({value:m,done:p})},c)}}function iot(i,t){return Object.defineProperty?Object.defineProperty(i,"raw",{value:t}):i.raw=t,i}function not(i){if(i&&i.__esModule)return i;var t={};if(i!=null)for(var r in i)r!=="default"&&Object.prototype.hasOwnProperty.call(i,r)&&fw(t,i,r);return Qxt(t,i),t}function oot(i){return i&&i.__esModule?i:{default:i}}function aot(i,t,r,h){if(r==="a"&&!h)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!h:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?h:r==="a"?h.call(i):h?h.value:t.get(i)}function sot(i,t,r,h,o){if(h==="m")throw new TypeError("Private method is not writable");if(h==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!o:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return h==="a"?o.call(i,r):o?o.value=r:t.set(i,r),r}function hot(i,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof i=="function"?t===i:i.has(t)}function fot(i,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var h,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");h=t[Symbol.asyncDispose]}if(h===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");h=t[Symbol.dispose],r&&(o=h)}if(typeof h!="function")throw new TypeError("Object not disposable.");o&&(h=function(){try{o.call(this)}catch(l){return Promise.reject(l)}}),i.stack.push({value:t,dispose:h,async:r})}else r&&i.stack.push({async:!0});return t}function uot(i){function t(h){i.error=i.hasError?new tRt(h,i.error,"An error was suppressed during disposal."):h,i.hasError=!0}function r(){for(;i.stack.length;){var h=i.stack.pop();try{var o=h.dispose&&h.dispose.call(h.value);if(h.async)return Promise.resolve(o).then(r,function(l){return t(l),r()})}catch(l){t(l)}}if(i.hasError)throw i.error}return r()}var AO,sw,fw,Qxt,tRt,eRt,vv=Vi(()=>{"use strict";Tt();Rt();xt();AO=function(i,t){return AO=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,h){r.__proto__=h}||function(r,h){for(var o in h)Object.prototype.hasOwnProperty.call(h,o)&&(r[o]=h[o])},AO(i,t)};sw=function(){return sw=Object.assign||function(t){for(var r,h=1,o=arguments.length;h<o;h++){r=arguments[h];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(t[l]=r[l])}return t},sw.apply(this,arguments)};fw=Object.create?function(i,t,r,h){h===void 0&&(h=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(i,h,o)}:function(i,t,r,h){h===void 0&&(h=r),i[h]=t[r]};Qxt=Object.create?function(i,t){Object.defineProperty(i,"default",{enumerable:!0,value:t})}:function(i,t){i.default=t};tRt=typeof SuppressedError=="function"?SuppressedError:function(i,t,r){var h=new Error(r);return h.name="SuppressedError",h.error=i,h.suppressed=t,h};eRt={__extends:znt,__assign:sw,__rest:Wnt,__decorate:Knt,__param:Hnt,__metadata:Gnt,__awaiter:Vnt,__generator:Znt,__createBinding:fw,__exportStar:Jnt,__values:hw,__read:TO,__spread:Xnt,__spreadArrays:Ynt,__spreadArray:Qnt,__await:Bp,__asyncGenerator:tot,__asyncDelegator:eot,__asyncValues:rot,__makeTemplateObject:iot,__importStar:not,__importDefault:oot,__classPrivateFieldGet:aot,__classPrivateFieldSet:sot,__classPrivateFieldIn:hot,__addDisposableResource:fot,__disposeResources:uot}});var yv=De(wl=>{"use strict";Tt();Rt();xt();Object.defineProperty(wl,"__esModule",{value:!0});wl.E_CANCELED=wl.E_ALREADY_LOCKED=wl.E_TIMEOUT=void 0;wl.E_TIMEOUT=new Error("timeout while waiting for mutex to become available");wl.E_ALREADY_LOCKED=new Error("mutex already locked");wl.E_CANCELED=new Error("request for lock canceled")});var RO=De(xO=>{"use strict";Tt();Rt();xt();Object.defineProperty(xO,"__esModule",{value:!0});var cot=(vv(),Dn(mv)),rRt=yv(),iRt=function(){function i(t,r){r===void 0&&(r=rRt.E_CANCELED),this._value=t,this._cancelError=r,this._weightedQueues=[],this._weightedWaiters=[]}return i.prototype.acquire=function(t){var r=this;if(t===void 0&&(t=1),t<=0)throw new Error("invalid weight ".concat(t,": must be positive"));return new Promise(function(h,o){r._weightedQueues[t-1]||(r._weightedQueues[t-1]=[]),r._weightedQueues[t-1].push({resolve:h,reject:o}),r._dispatch()})},i.prototype.runExclusive=function(t,r){return r===void 0&&(r=1),cot.__awaiter(this,void 0,void 0,function(){var h,o,l;return cot.__generator(this,function(c){switch(c.label){case 0:return[4,this.acquire(r)];case 1:h=c.sent(),o=h[0],l=h[1],c.label=2;case 2:return c.trys.push([2,,4,5]),[4,t(o)];case 3:return[2,c.sent()];case 4:return l(),[7];case 5:return[2]}})})},i.prototype.waitForUnlock=function(t){var r=this;if(t===void 0&&(t=1),t<=0)throw new Error("invalid weight ".concat(t,": must be positive"));return new Promise(function(h){r._weightedWaiters[t-1]||(r._weightedWaiters[t-1]=[]),r._weightedWaiters[t-1].push(h),r._dispatch()})},i.prototype.isLocked=function(){return this._value<=0},i.prototype.getValue=function(){return this._value},i.prototype.setValue=function(t){this._value=t,this._dispatch()},i.prototype.release=function(t){if(t===void 0&&(t=1),t<=0)throw new Error("invalid weight ".concat(t,": must be positive"));this._value+=t,this._dispatch()},i.prototype.cancel=function(){var t=this;this._weightedQueues.forEach(function(r){return r.forEach(function(h){return h.reject(t._cancelError)})}),this._weightedQueues=[]},i.prototype._dispatch=function(){for(var t,r=this._value;r>0;r--){var h=(t=this._weightedQueues[r-1])===null||t===void 0?void 0:t.shift();if(h){var o=this._value,l=r;this._value-=r,r=this._value+1,h.resolve([o,this._newReleaser(l)])}}this._drainUnlockWaiters()},i.prototype._newReleaser=function(t){var r=this,h=!1;return function(){h||(h=!0,r.release(t))}},i.prototype._drainUnlockWaiters=function(){for(var t=this._value;t>0;t--)this._weightedWaiters[t-1]&&(this._weightedWaiters[t-1].forEach(function(r){return r()}),this._weightedWaiters[t-1]=[])},i}();xO.default=iRt});var dot=De(kO=>{"use strict";Tt();Rt();xt();Object.defineProperty(kO,"__esModule",{value:!0});var lot=(vv(),Dn(mv)),nRt=RO(),oRt=function(){function i(t){this._semaphore=new nRt.default(1,t)}return i.prototype.acquire=function(){return lot.__awaiter(this,void 0,void 0,function(){var t,r;return lot.__generator(this,function(h){switch(h.label){case 0:return[4,this._semaphore.acquire()];case 1:return t=h.sent(),r=t[1],[2,r]}})})},i.prototype.runExclusive=function(t){return this._semaphore.runExclusive(function(){return t()})},i.prototype.isLocked=function(){return this._semaphore.isLocked()},i.prototype.waitForUnlock=function(){return this._semaphore.waitForUnlock()},i.prototype.release=function(){this._semaphore.isLocked()&&this._semaphore.release()},i.prototype.cancel=function(){return this._semaphore.cancel()},i}();kO.default=oRt});var IO=De(cw=>{"use strict";Tt();Rt();xt();Object.defineProperty(cw,"__esModule",{value:!0});cw.withTimeout=void 0;var uw=(vv(),Dn(mv)),aRt=yv();function sRt(i,t,r){var h=this;return r===void 0&&(r=aRt.E_TIMEOUT),{acquire:function(o){if(o!==void 0&&o<=0)throw new Error("invalid weight ".concat(o,": must be positive"));return new Promise(function(l,c){return uw.__awaiter(h,void 0,void 0,function(){var p,w,m,y,v;return uw.__generator(this,function(M){switch(M.label){case 0:p=!1,w=setTimeout(function(){p=!0,c(r)},t),M.label=1;case 1:return M.trys.push([1,3,,4]),[4,i.acquire(o)];case 2:return m=M.sent(),p?(y=Array.isArray(m)?m[1]:m,y()):(clearTimeout(w),l(m)),[3,4];case 3:return v=M.sent(),p||(clearTimeout(w),c(v)),[3,4];case 4:return[2]}})})})},runExclusive:function(o,l){return uw.__awaiter(this,void 0,void 0,function(){var c,p;return uw.__generator(this,function(w){switch(w.label){case 0:c=function(){},w.label=1;case 1:return w.trys.push([1,,7,8]),[4,this.acquire(l)];case 2:return p=w.sent(),Array.isArray(p)?(c=p[1],[4,o(p[0])]):[3,4];case 3:return[2,w.sent()];case 4:return c=p,[4,o()];case 5:return[2,w.sent()];case 6:return[3,8];case 7:return c(),[7];case 8:return[2]}})})},release:function(o){i.release(o)},cancel:function(){return i.cancel()},waitForUnlock:function(o){if(o!==void 0&&o<=0)throw new Error("invalid weight ".concat(o,": must be positive"));return new Promise(function(l,c){var p=setTimeout(function(){return c(r)},t);i.waitForUnlock(o).then(function(){clearTimeout(p),l()})})},isLocked:function(){return i.isLocked()},getValue:function(){return i.getValue()},setValue:function(o){return i.setValue(o)}}}cw.withTimeout=sRt});var pot=De(lw=>{"use strict";Tt();Rt();xt();Object.defineProperty(lw,"__esModule",{value:!0});lw.tryAcquire=void 0;var hRt=yv(),fRt=IO();function uRt(i,t){return t===void 0&&(t=hRt.E_ALREADY_LOCKED),(0,fRt.withTimeout)(i,0,t)}lw.tryAcquire=uRt});var got=De(Qh=>{"use strict";Tt();Rt();xt();Object.defineProperty(Qh,"__esModule",{value:!0});Qh.tryAcquire=Qh.withTimeout=Qh.Semaphore=Qh.Mutex=void 0;var cRt=(vv(),Dn(mv)),lRt=dot();Object.defineProperty(Qh,"Mutex",{enumerable:!0,get:function(){return lRt.default}});var dRt=RO();Object.defineProperty(Qh,"Semaphore",{enumerable:!0,get:function(){return dRt.default}});var pRt=IO();Object.defineProperty(Qh,"withTimeout",{enumerable:!0,get:function(){return pRt.withTimeout}});var gRt=pot();Object.defineProperty(Qh,"tryAcquire",{enumerable:!0,get:function(){return gRt.tryAcquire}});cRt.__exportStar(yv(),Qh)});var mot=De(dw=>{"use strict";Tt();Rt();xt();Object.defineProperty(dw,"__esModule",{value:!0});dw.SimpleLRUCache=void 0;var BO=class{constructor(t){this.cache=new Map,this.capacity=t||10}has(t){return this.cache.has(t)}size(){return this.cache.size}get(t){if(!this.cache.has(t))return null;let r=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,r),r}set(t,r){this.cache.delete(t),this.cache.size===this.capacity?(this.cache.delete(this.cache.keys().next().value),this.cache.set(t,r)):this.cache.set(t,r)}keys(){return Array.from(this.cache.keys())}};dw.SimpleLRUCache=BO});var CO=De(pw=>{"use strict";Tt();Rt();xt();Object.defineProperty(pw,"__esModule",{value:!0});pw.ContractInteractionState=void 0;var mRt=$u(),vRt=mot(),OO=class{constructor(t){this._warp=t,this._json=new Map,this._initialJson=new Map,this._kv=new Map}has(t,r){var h;return((h=this._json.get(t))===null||h===void 0?void 0:h.has(r))||!1}get(t,r){var h;return((h=this._json.get(t))===null||h===void 0?void 0:h.get(r))||null}getLessOrEqual(t,r){let h=this._json.get(t);if(h!=null&&h.size()>0){let o=h.keys();r&&(o=o.filter(c=>c.localeCompare(r)<=0)),o=o.sort((c,p)=>c.localeCompare(p));let l=o[o.length-1];if(h.get(l))return new mRt.SortKeyCacheResult(l,h.get(l))}return null}async getKV(t,r){var h;return this._kv.has(t)&&((h=await this._kv.get(t).get(r))===null||h===void 0?void 0:h.cachedValue)||null}async delKV(t,r){this._kv.has(t)&&await this._kv.get(t).del(r)}getKvKeys(t,r,h){return this._warp.kvStorageFactory(t).keys(r,h)}getKvRange(t,r,h){return this._warp.kvStorageFactory(t).kvMap(r,h)}async commit(t,r=!1){if(t.dry)return await this.rollbackKVs(),this.reset();try{let h=new Map;this._json.forEach((o,l)=>{let c=this.getLessOrEqual(l,t.sortKey);c!=null&&h.set(l,c.cachedValue)}),await this.doStoreJson(h,t,r),await this.commitKVs()}finally{this.reset()}}async commitKV(){await this.commitKVs(),this._kv.clear()}async rollback(t,r){try{await this.doStoreJson(this._initialJson,t,r),await this.rollbackKVs()}finally{this.reset()}}setInitial(t,r,h){this._initialJson.set(t,r),this.update(t,r,h)}update(t,r,h){if(!this._json.has(t)){let o=new vRt.SimpleLRUCache(10);this._json.set(t,o)}this._json.get(t).set(h,r)}async updateKV(t,r,h){await(await this.getOrInitKvStorage(t)).put(r,h)}async getOrInitKvStorage(t){if(this._kv.has(t))return this._kv.get(t);let r=this._warp.kvStorageFactory(t);return this._kv.set(t,r),await r.open(),r}reset(){this._json.clear(),this._initialJson.clear(),this._kv.clear()}async doStoreJson(t,r,h=!1){if(t.size>1||h)for(let[o,l]of t)await this._warp.stateEvaluator.putInCache(o,r,l)}async rollbackKVs(){for(let t of this._kv.values())try{await t.rollback()}finally{await t.close()}}async commitKVs(){for(let t of this._kv.values())try{await t.commit()}finally{await t.close()}}};pw.ContractInteractionState=OO});var vw=De(Np=>{"use strict";Tt();Rt();xt();var yRt=Np&&Np.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Np,"__esModule",{value:!0});Np.HandlerBasedContract=void 0;var bRt=yRt(Ont()),bv=$u(),PO=GB(),NO=qf(),LO=ed(),vot=Ym(),Op=Vh(),gw=oO(),Cp=Qs(),yot=bn(),bot=YB(),wRt=gl(),_l=ko(),Pp=aO(),_Rt=hO(),MRt=MO(),SRt=EO(),ERt=Jm(),ARt=got(),mw=Ep(),wot=CO(),DO=Gu(),_ot=(wO(),Dn(bO)),$O=class{constructor(t,r,h=null,o=null){var l,c;if(this._contractTxId=t,this.warp=r,this._parentContract=h,this._innerCallData=o,this.logger=yot.LoggerFactory.INST.create("HandlerBasedContract"),this.ecLogger=yot.LoggerFactory.INST.create("ExecutionContext"),this._innerWritesEvaluator=new _Rt.InnerWritesEvaluator,this._mutex=new ARt.Mutex,this._benchmarkStats=null,this._children=[],this._dreStates=new Map,this.waitForConfirmation=this.waitForConfirmation.bind(this),this._arweaveWrapper=new wRt.ArweaveWrapper(r),this._sorter=new LO.LexicographicalInteractionsSorter(r.arweave),h!=null){this._evaluationOptions=this.getRoot().evaluationOptions(),this._callDepth=h.callDepth()+1;let p=h.getCallStack().getInteraction(o.callingInteraction.id);if(this._callDepth>this._evaluationOptions.maxCallDepth)throw new Error(`Max call depth of ${this._evaluationOptions.maxCallDepth} has been exceeded for interaction ${JSON.stringify(p.interactionInput)}`);if(this.logger.debug("Calling interaction",{id:o.callingInteraction.id,sortKey:o.callingInteraction.sortKey,type:o.callType}),((c=(l=p.interactionInput)===null||l===void 0?void 0:l.foreignContractCalls[t])===null||c===void 0?void 0:c.innerCallType)==="write"&&o.callType==="read")throw new Error("Calling a readContractState after performing an inner write is wrong - instead use a state from the result of an internal write.");let w=new PO.ContractCallRecord(t,this._callDepth,o?.callType);p.interactionInput.foreignContractCalls[t]=w,this._callStack=w,this._rootSortKey=h.rootSortKey,h._children.push(this)}else this._callDepth=0,this._callStack=new PO.ContractCallRecord(t,0),this._rootSortKey=null,this._evaluationOptions=new vot.DefaultEvaluationOptions,this._children=[],this._interactionState=new wot.ContractInteractionState(r);this.getCallStack=this.getCallStack.bind(this),this._warpFetchWrapper=new ERt.WarpFetchWrapper(this.warp)}async readState(t,r,h,o){var l,c,p;if(this.logger.info("Read state for",{contractTxId:this._contractTxId,sortKeyOrBlockHeight:t}),!this.isRoot()&&t==null)throw new Error("SortKey MUST be always set for non-root contract calls");let{stateEvaluator:w}=this.warp,m=typeof t=="number"?this._sorter.generateLastSortKey(t):t;if(m&&!this.isRoot()&&this.interactionState().has(this.txId(),m)){let v=this.interactionState().get(this.txId(),m);return new bv.SortKeyCacheResult(m,v)}let y=await this._mutex.acquire();try{let v=Cp.Benchmark.measure();this.maybeResetRootContract();let M=await this.createExecutionContext(this._contractTxId,m,!1,r,h,o);this.logger.info("Execution Context",{srcTxId:(l=M.contractDefinition)===null||l===void 0?void 0:l.srcTxId,missingInteractions:(c=M.sortedInteractions)===null||c===void 0?void 0:c.length,cachedSortKey:(p=M.cachedState)===null||p===void 0?void 0:p.sortKey}),v.stop();let T=Cp.Benchmark.measure(),A=await w.eval(M);T.stop();let R=v.elapsed(!0)+T.elapsed(!0);return this._benchmarkStats={gatewayCommunication:v.elapsed(!0),stateEvaluation:T.elapsed(!0),total:R},this.logger.info("Benchmark",{"Gateway communication ":v.elapsed(),"Contract evaluation ":T.elapsed(),"Total: ":`${R.toFixed(0)}ms`}),m&&!this.isRoot()&&this.interactionState().update(this.txId(),A.cachedValue,m),A}finally{y()}}async readStateFor(t,r,h,o){return this.readState(t,r,h,o)}async readStateBatch(t=1,r,h){if(!this.isRoot())throw new Error("readStateBatch is only allowed for root contract calls");if(t<1)throw new Error("At least one page per batch is required");if(h?.aborted)throw new NO.AbortError("readStateBatch aborted");let o=this._contractTxId,{interactionsLoader:l,stateEvaluator:c}=this.warp,p=await c.latestAvailableState(o),w={...this._evaluationOptions,transactionsPagesPerBatch:t},m,y=0;do{let v=Cp.Benchmark.measure();if(this.logger.debug(`Loading ${y+1} batch`,w),m=await l.load(o,p?.sortKey,r,w),h?.aborted)throw new NO.AbortError("readStateBatch aborted");if(m.length==0&&y>0)break;if(this.logger.debug(`Evaluating ${m.length} in ${y+1} batch`),p=await this.readStateFor(p?.sortKey||LO.genesisSortKey,m,h),h?.aborted)throw new NO.AbortError("readStateBatch aborted");this.logger.debug(`Batch ${y+1} evaluated in ${v.elapsed()} at sortKey ${p.sortKey}`),y++}while(m.length>0);return p}async viewState(t,r=[],h=Pp.emptyTransfer,o,l,c){return this.logger.info("View state for",this._contractTxId),await this.callContract(t,"view",o,c,r,h,!1,!1,!0,l)}async viewStateForTx(t,r,h){return this.logger.info(`View state for ${this._contractTxId}`),await this.doApplyInputOnTx(t,r,"view",h)}async dryWrite(t,r,h,o,l,c){return this.logger.info("Dry-write for",this._contractTxId),await this.callContract(t,"write",r,c,h,o,void 0,l)}async applyInput(t,r,h){return this.logger.info(`Apply-input from transaction ${r.id} for ${this._contractTxId}`),await this.doApplyInputOnTx(t,r,"write",h)}async writeInteraction(t,r){if(this.logger.info("Write interaction",{input:t,options:r}),!this._signature)throw new Error("Wallet not connected. Use 'connect' method first.");let{arweave:h,interactionsLoader:o,environment:l}=this.warp;await this.warp.definitionLoader.load(this._contractTxId);let c=r?.tags||[],p=r?.transfer||Pp.emptyTransfer,w=r?.strict===!0,m=r?.vrf===!0,y=r?.disableBundling===!0,v=r?.reward,M=r?.manifestData,T=r?.inputFormatAsData,A=o.type()=="warp"&&!y;if(this._signature.checkNonArweaveSigningAvailability(A),this._signature.checkBundlerSignerAvailability(A),A&&p.target!=Pp.emptyTransfer.target&&p.winstonQty!=Pp.emptyTransfer.winstonQty)throw new Error("Ar Transfers are not allowed for bundled interactions");if(m&&!A&&l==="mainnet")throw new Error("Vrf generation is only available for bundle interaction");if(!t)throw new Error(`Input should be a truthy value: ${JSON.stringify(t)}`);if(A)return await this.bundleInteraction(t,{tags:c,strict:w,vrf:m,manifestData:M,inputFormatAsData:T});{let R=await this.createInteraction(t,c,p,w,!1,m&&l!=="mainnet",v),B=await h.transactions.post(R);if(B.status!==200)return this.logger.error("Error while posting transaction",B),null;if(this._evaluationOptions.waitForConfirmation){this.logger.info("Waiting for confirmation of",R.id);let C=Cp.Benchmark.measure();await this.waitForConfirmation(R.id),this.logger.info("Transaction confirmed after",C.elapsed())}return this.warp.environment=="local"&&this._evaluationOptions.mineArLocalBlocks&&await this.warp.testing.mineBlock(),{originalTxId:R.id,interactionTx:R}}}async bundleInteraction(t,r){if(this.logger.info("Bundle interaction input: {}, tag: {}",t,r.tags),!this.maxInteractionDataItemSizeBytes){let c=fetch(`${(0,_l.stripTrailingSlash)(this.warp.gwUrl())}`);this.maxInteractionDataItemSizeBytes=(await(0,_l.getJsonResponse)(c)).maxInteractionDataItemSizeBytes}let h=await this.createInteractionDataItem(t,r.tags,Pp.emptyTransfer,r.strict,r.vrf,r.manifestData,r.inputFormatAsData),o=this._warpFetchWrapper.fetch(`${(0,_l.stripTrailingSlash)(this._evaluationOptions.sequencerUrl)}/gateway/v2/sequencer/register`,{method:"POST",headers:{"Content-Type":"application/octet-stream",Accept:"application/json"},body:h.getRaw()}),l=await h.id;return{bundlrResponse:await(0,_l.getJsonResponse)(o),originalTxId:l,interactionTx:h}}async createInteractionDataItem(t,r,h,o,l=!1,c,p){var w;this._evaluationOptions.internalWrites&&await this.discoverInternalWrites(t,r,h,o,l),l&&r.push(new mw.Tag(Op.WARP_TAGS.REQUEST_VRF,"true"));let m=(0,gw.createInteractionTagsList)(this._contractTxId,t,this.warp.environment==="testnet",r),y;((0,_ot.tagsExceedLimit)(m)||p)&&(m=[...m.filter(T=>T.name!=Op.SMART_WEAVE_TAGS.INPUT&&T.name!=Op.WARP_TAGS.INPUT_FORMAT),new mw.Tag(Op.WARP_TAGS.INPUT_FORMAT,"data")],y={input:t}),c&&(y={...y,manifest:this.createManifest(c)}),y=y?JSON.stringify(y):Math.random().toString().slice(-4);let v=this._signature.bundlerSigner;if(!v)throw new Error("Signer not set correctly. If you connect wallet through 'use_wallet', please remember that it only works when bundling is disabled.");let M;if((0,_l.isBrowser)()&&(!((w=v.signer)===null||w===void 0)&&w.signDataItem)?M=await v.signDataItem(y,m):(M=(0,_ot.createData)(y,v,{tags:m}),await M.sign(v)),M.getRaw().length>this.maxInteractionDataItemSizeBytes)throw new Error(`Interaction data item size: ${M.getRaw().length} exceeds maximum interactions size limit: ${this.maxInteractionDataItemSizeBytes}.`);return!this._evaluationOptions.internalWrites&&o&&await this.checkInteractionInStrictMode(M.owner,t,r,h,o,l),M}async createInteraction(t,r,h,o,l=!1,c=!1,p){this._evaluationOptions.internalWrites&&await this.discoverInternalWrites(t,r,h,o,c),c&&r.push(new mw.Tag(Op.WARP_TAGS.REQUEST_VRF,"true"));let w=await(0,gw.createInteractionTx)(this.warp.arweave,this._signature.signer,this._contractTxId,t,r,h.target,h.winstonQty,l,this.warp.environment==="testnet",p);return!this._evaluationOptions.internalWrites&&o&&await this.checkInteractionInStrictMode(w.owner,t,r,h,o,c),w}async checkInteractionInStrictMode(t,r,h,o,l,c){let{arweave:p}=this.warp,w=this._signature.type=="arweave"?await p.wallets.ownerToAddress(t):await this._signature.getAddress(),m=await this.callContract(r,"write",w,void 0,h,o,l,c);if(m.type!=="ok")throw Error("Cannot create interaction: "+JSON.stringify(m.error||m.errorMessage))}txId(){return this._contractTxId}getCallStack(){return this._callStack}connect(t){return this._signature=new MRt.Signature(this.warp,t),this}setEvaluationOptions(t){if(!this.isRoot())throw new Error("Evaluation options can be set only for the root contract");return this._evaluationOptions={...this._evaluationOptions,...t},this}async waitForConfirmation(t){let{arweave:r}=this.warp,h=await r.transactions.getStatus(t);return h.confirmed===null?(this.logger.info(`Transaction ${t} not yet confirmed. Waiting another 20 seconds before next check.`),await(0,_l.sleep)(2e4),this.waitForConfirmation(t)):(this.logger.info(`Transaction ${t} confirmed`,h),h)}async createExecutionContext(t,r,h=!1,o,l,c){var p,w,m,y,v;let{definitionLoader:M,interactionsLoader:T,stateEvaluator:A}=this.warp,R,B=Cp.Benchmark.measure();if(this.isRoot()||(R=this.interactionState().getLessOrEqual(this.txId(),r)),R=c||R||await A.latestAvailableState(t,r),r&&this.evaluationOptions().strictSortKey&&R?.sortKey!=r)throw new Error(`State not cached at the exact required ${r} sortKey`);this.logger.debug("cache lookup",B.elapsed()),B.reset();let C=bot.Evolve.evolvedSrcTxId((p=R?.cachedValue)===null||p===void 0?void 0:p.state),P,N,q,W,J=o||[];if(this.logger.debug("Cached state",R,r),R&&R.sortKey==r||r==LO.genesisSortKey&&o?.length)this.logger.debug("State fully cached, not loading interactions."),(h||C||o?.length)&&(N=await M.load(t,C),q=this.resolveEvaluationOptions((w=N.manifest)===null||w===void 0?void 0:w.evaluationOptions),this.warp.executorFactory.checkWhiteListContractSources(N,q),o?.length&&(J=await this.getSortedInteractions(o)));else{if(o?.length)throw new Error(`Cannot apply requested interactions at ${r}`);if(N=await M.load(t,C),q=this.resolveEvaluationOptions((m=N.manifest)===null||m===void 0?void 0:m.evaluationOptions),q.remoteStateSyncEnabled&&!q.useKVStorage){W=await this.getRemoteContractState(t),R=await this.maybeSyncStateWithRemoteSource(W,r,R);let F=bot.Evolve.evolvedSrcTxId((y=R?.cachedValue)===null||y===void 0?void 0:y.state);F&&F!==N.srcTxId&&(N=await M.load(t,F))}this.warp.executorFactory.checkWhiteListContractSources(N,q),!W&&J.length==0&&(J=await T.load(t,R?.sortKey,this.getToSortKey(r),q)),R?.sortKey&&(J=J.filter(F=>F.sortKey.localeCompare(R?.sortKey)>0)),r&&(J=J.filter(F=>F.sortKey.localeCompare(r)<=0)),this.logger.debug("contract and interactions load",B.elapsed()),this.isRoot()&&J.length&&(this._rootSortKey=J[J.length-1].sortKey)}return N&&(q||(q=this.resolveEvaluationOptions((v=N.manifest)===null||v===void 0?void 0:v.evaluationOptions)),this.ecLogger.debug(`Evaluation options ${t}:`,q),P=await this.warp.executorFactory.create(N,q,this.warp,this.interactionState())),{warp:this.warp,contract:this,contractDefinition:N,sortedInteractions:J,evaluationOptions:q||this.evaluationOptions(),handler:P,cachedState:R,requestedSortKey:r,signal:l}}async getSortedInteractions(t){return(await this._sorter.sort(t.map(r=>({node:r,cursor:null})))).map(r=>r.node)}resolveEvaluationOptions(t){return this.isRoot()?(this._eoEvaluator=new SRt.EvaluationOptionsEvaluator(this.evaluationOptions(),t),this._eoEvaluator.rootOptions):this.getRootEoEvaluator().forForeignContract(t)}async getRemoteContractState(t){if(this.hasDreState(t))return this.getDreState(t);{let r=await this.fetchRemoteContractState(t);return r!=null?this.setDREState(t,r):null}}async fetchRemoteContractState(t){return(0,_l.getJsonResponse)(this._warpFetchWrapper.fetch(`${this._evaluationOptions.remoteStateSyncSource}?id=${t}&events=false`))}getToSortKey(t){var r;return!((r=this._parentContract)===null||r===void 0)&&r.rootSortKey?t?this._parentContract.rootSortKey.localeCompare(t)>0?this._parentContract.rootSortKey:t:this._parentContract.rootSortKey:t}async createExecutionContextFromTx(t,r,h){let o=r.owner.address,l=r.sortKey;return{...await this.createExecutionContext(t,l,!0,void 0,h),caller:o}}maybeResetRootContract(){this.isRoot()&&(this.logger.debug("Clearing call stack for the root contract"),this._callStack=new PO.ContractCallRecord(this.txId(),0),this._rootSortKey=null,this.warp.interactionsLoader.clearCache(),this._children=[],this._interactionState=new wot.ContractInteractionState(this.warp),this._dreStates=new Map)}async callContract(t,r,h,o,l=[],c=Pp.emptyTransfer,p=!1,w=!1,m=!0,y){var v;this.logger.info("Call contract input",t),this.maybeResetRootContract(),this._signature||this.logger.warn("Wallet not set.");let{arweave:M,stateEvaluator:T}=this.warp,A=await this.createExecutionContext(this._contractTxId,o,!0,void 0,y),R=o?await this._sorter.extractBlockHeight(o):void 0,B;this.warp.environment=="mainnet"&&this.warp.interactionsLoader.type()!=="arweave"?B=await this._arweaveWrapper.warpGwBlock():R?B=await M.blocks.getByHeight(R):B=await M.blocks.getCurrent();let C;h?C=h:this._signature?C=await this._signature.getAddress():C="",this.logger.info("effectiveCaller",C),A={...A,caller:C};let P=await T.eval(A);this.logger.info("Current state",P.cachedValue.state);let N={input:t,caller:A.caller,interactionType:r};this.logger.debug("interaction",N);let q=await(0,gw.createInteractionTx)(M,m?(v=this._signature)===null||v===void 0?void 0:v.signer:void 0,this._contractTxId,t,l,c.target,c.winstonQty,!0,this.warp.environment==="testnet"),W=(0,gw.createDummyTx)(q,A.caller,B);if(this.logger.debug("Creating sortKey for",{blockId:W.block.id,id:W.id,height:W.block.height}),W.sortKey=await this._sorter.createSortKey(W.block.id,W.id,W.block.height,!0),W.strict=p,w){let F=this.warp.maybeLoadPlugin("vrf");F?W.vrf=F.process().generateMockVrf(W.sortKey):this.logger.warn('Cannot generate mock vrf for interaction - no "warp-contracts-plugin-vrf" attached!')}let J=await this.evalInteraction({interaction:N,interactionTx:W},A,P.cachedValue);return J.type!=="ok"&&this.logger.fatal("Error while interacting with contract",{type:J.type,error:J.errorMessage}),J}async doApplyInputOnTx(t,r,h,o){this.maybeResetRootContract();let l,c=await this.createExecutionContextFromTx(this._contractTxId,r,o);!this.isRoot()&&this.interactionState().has(this.txId(),r.sortKey)?l=new bv.SortKeyCacheResult(r.sortKey,this.interactionState().get(this.txId(),r.sortKey)):(l=await this.warp.stateEvaluator.eval(c),this.interactionState().update(this.txId(),l.cachedValue,r.sortKey)),this.logger.debug("callContractForTx - evalStateResult",{result:l.cachedValue.state,txId:this._contractTxId});let w={interaction:{input:t,caller:this._parentContract.txId(),interactionType:h},interactionTx:r},m=await this.evalInteraction(w,c,l.cachedValue);return m.originalValidity=l.cachedValue.validity,m.originalErrorMessages=l.cachedValue.errorMessages,m}async evalInteraction(t,r,h){let o=this.getCallStack().addInteractionData(t),l=Cp.Benchmark.measure();await r.handler.initState(h.state);let c=await r.handler.handle(r,h,t);return o.update({cacheHit:!1,outputState:this._evaluationOptions.stackTrace.saveState?c.state:void 0,executionTime:l.elapsed(!0),valid:c.type==="ok",errorMessage:c.errorMessage,gasUsed:c.gasUsed}),c}parent(){return this._parentContract}callDepth(){return this._callDepth}evaluationOptions(){return this._evaluationOptions}lastReadStateStats(){return this._benchmarkStats}async stateHash(t){let r=(0,bRt.default)(t),h=await DO.Crypto.subtle.digest("SHA-256",DO.Buffer.from(r,"utf-8"));return DO.Buffer.from(h).toString("hex")}async syncState(t,r){let{stateEvaluator:h}=this.warp,o=await this._warpFetchWrapper.fetch(`${t}?${new URLSearchParams({id:this._contractTxId,...r})}`).then(l=>l.ok?l.json():Promise.reject(l)).catch(l=>{var c,p;throw!((c=l.body)===null||c===void 0)&&c.message&&this.logger.error(l.body.message),new Error(`Unable to retrieve state. ${l.status}: ${(p=l.body)===null||p===void 0?void 0:p.message}`)});return await h.syncState(this._contractTxId,o.sortKey,o.state,o.validity),this}async evolve(t,r){return await this.writeInteraction({function:"evolve",value:t},r)}get rootSortKey(){return this._rootSortKey}getRootEoEvaluator(){return this.getRoot()._eoEvaluator}isRoot(){return this._parentContract==null}async getStorageValues(t){let r=await this.warp.stateEvaluator.getCache().getLast(this.txId());if(r==null)return new bv.SortKeyCacheResult(null,new Map);let h=this.warp.kvStorageFactory(this.txId()),o=new Map;try{await h.open();for(let l of t){let c=await h.getLessOrEqual(l,r.sortKey);o.set(l,c==null?null:c.cachedValue)}return new bv.SortKeyCacheResult(r.sortKey,o)}finally{await h.close()}}interactionState(){return this.getRoot()._interactionState}getRoot(){let t=this;for(;!t.isRoot();)t=t.parent();return t}async maybeSyncStateWithRemoteSource(t,r,h){let{stateEvaluator:o}=this.warp;return this.isStateHigherThanAndUpTo(t,h?.sortKey,r)?await o.syncState(this._contractTxId,t.sortKey,t.cachedValue.state,t.cachedValue.validity):h}isStateHigherThanAndUpTo(t,r,h){return t&&(!h||h>=t.sortKey)&&(!r||t.sortKey>r)}setDREState(t,r){let h=new bv.SortKeyCacheResult(r.sortKey,new vot.EvalStateResult(r.state,{},r.errorMessages));return this.getRoot()._dreStates.set(t,h),h}getDreState(t){return this.getRoot()._dreStates.get(t)}hasDreState(t){return this.getRoot()._dreStates.has(t)}async discoverInternalWrites(t,r,h,o,l){let c=await this.callContract(t,"write",void 0,void 0,r,h,o,l,!1);if(o&&c.type!=="ok")throw Error("Cannot create interaction: "+JSON.stringify(c.error||c.errorMessage));let p=this.getCallStack(),w=this._innerWritesEvaluator.eval(p);this.logger.debug("Input",t),this.logger.debug("Callstack",p.print()),w.forEach(m=>{r.push(new mw.Tag(Op.WARP_TAGS.INTERACT_WRITE,m))}),this.logger.debug("Tags with inner calls",r)}clearChildren(){for(let t of this._children)t.clearChildren();this._children=[]}createManifest(t){let r={};return Object.keys(t).forEach(h=>{let o=t[h];if(typeof h!="string")throw new Error("Incorrect manifest data. Manifest key should be of type 'string'");if(typeof o!="string")throw new Error("Incorrect manifest data. Manifest value should be of type 'string'");if(!(0,_l.isTxIdValid)(o))throw new Error(`Incorrect manifest data. Transaction id: ${o} is not valid.`);r[h]=t[h]}),r}};Np.HandlerBasedContract=$O});var qO=De(yw=>{"use strict";Tt();Rt();xt();Object.defineProperty(yw,"__esModule",{value:!0});yw.PstContractImpl=void 0;var TRt=vw(),UO=class extends TRt.HandlerBasedContract{async currentBalance(t){let r=await this.viewState({function:"balance",target:t});if(r.type!=="ok")throw Error(r.errorMessage);return r.result}async currentState(){return(await super.readState()).cachedValue.state}async transfer(t,r){return await this.writeInteraction({function:"transfer",...t},r)}};yw.PstContractImpl=UO});var Mot=De(bw=>{"use strict";Tt();Rt();xt();Object.defineProperty(bw,"__esModule",{value:!0});bw.Testing=void 0;var FO=class{constructor(t){this.arweave=t}async mineBlock(){this.validateEnv(),await this.arweave.api.get("mine")}async addFunds(t){let r=await this.arweave.wallets.getAddress(t);await this.arweave.api.get(`/mint/${r}/1000000000000000`)}async isArlocal(){return(await fetch(`${this.arweave.api.config.protocol}://${this.arweave.api.config.host}:${this.arweave.api.config.port}/info`).then(r=>r.ok?r.json():Promise.reject()).catch(r=>{throw new Error(`Unable to get network info: ${r.message}`)})).network.includes("arlocal")}async validateEnv(){if(!await this.isArlocal())throw new Error("Testing features are not available in a non testing environment")}};bw.Testing=FO});var Sot=De(ww=>{"use strict";Tt();Rt();xt();Object.defineProperty(ww,"__esModule",{value:!0});ww.DebuggableExecutorFactory=void 0;var jO=class{constructor(t,r){this.baseImplementation=t,this.sourceCode=r}async create(t,r,h,o){return Object.prototype.hasOwnProperty.call(this.sourceCode,t.txId)&&(t={...t,src:this.sourceCode[t.txId]}),await this.baseImplementation.create(t,r,h,o)}checkWhiteListContractSources(t,r){return this.baseImplementation.checkWhiteListContractSources(t,r)}};ww.DebuggableExecutorFactory=jO});var xot=De(_w=>{"use strict";Tt();Rt();xt();Object.defineProperty(_w,"__esModule",{value:!0});_w.CacheableContractDefinitionLoader=void 0;var xRt=Gu(),Eot=Qm(),RRt=Qs(),kRt=bn(),Aot=$u(),Tot=Hm(),zO=class{constructor(t,r,h){this.contractDefinitionLoader=t,this.env=r,this.rLogger=kRt.LoggerFactory.INST.create("CacheableContractDefinitionLoader"),this.definitionCache=new Tot.LevelDbCache({...h,dbLocation:`${h.dbLocation}/contracts`}),this.srcCache=new Tot.LevelDbCache({...h,dbLocation:`${h.dbLocation}/source`})}async load(t,r){let h=await this.getFromCache(t,r);if(h)return this.rLogger.debug("Hit from cache!",t,r),h.contractType=="wasm"&&h.srcBinary.data&&(h.srcBinary=xRt.Buffer.from(h.srcBinary.data)),this.verifyEnv(h),h;let o=RRt.Benchmark.measure(),l=await this.contractDefinitionLoader.load(t,r);return this.rLogger.info(`Contract definition loaded in: ${o.elapsed()}`),this.verifyEnv(l),await this.putToCache(t,l,r),l}async loadContractSource(t){return await this.contractDefinitionLoader.loadContractSource(t)}type(){return this.contractDefinitionLoader.type()}setCache(t){this.definitionCache=t}setSrcCache(t){this.srcCache=t}getCache(){return this.definitionCache}getSrcCache(){return this.srcCache}verifyEnv(t){if(t.testnet&&this.env!=="testnet")throw new Error('Trying to use testnet contract in a non-testnet env. Use the "forTestnet" factory method.');if(!t.testnet&&this.env==="testnet")throw new Error("Trying to use non-testnet contract in a testnet env.")}async getFromCache(t,r){let h=await this.definitionCache.get(new Aot.CacheKey(t,"cd"));if(!h)return null;let o=r||h.cachedValue.srcTxId,l=await this.srcCache.get(new Aot.CacheKey(o,"src"));return l?{...h.cachedValue,...l.cachedValue,srcTxId:o}:null}async putToCache(t,r,h){let o=new Eot.SrcCache(r),l=new Eot.ContractCache(r);await this.definitionCache.put({key:t,sortKey:"cd"},l),await this.srcCache.put({key:h||l.srcTxId,sortKey:"src"},o)}set warp(t){this.contractDefinitionLoader.warp=t}};_w.CacheableContractDefinitionLoader=zO});var KO=De(Mw=>{"use strict";Tt();Rt();xt();Object.defineProperty(Mw,"__esModule",{value:!0});Mw.WarpBuilder=void 0;var IRt=Sot(),BRt=DB(),Rot=UB(),ORt=z4(),CRt=OB(),PRt=Xm(),NRt=Sw(),kot=xot(),WO=class{constructor(t,r,h="custom"){this._arweave=t,this._stateCache=r,this._environment=h}setDefinitionLoader(t){return this._definitionLoader=t,this}setInteractionsLoader(t){return this._interactionsLoader=t,this}setExecutorFactory(t){return this._executorFactory=t,this}setStateEvaluator(t){return this._stateEvaluator=t,this}overwriteSource(t){if(this._executorFactory==null)throw new Error("Set base ExecutorFactory first");return this._executorFactory=new IRt.DebuggableExecutorFactory(this._executorFactory,t),this.build()}useWarpGateway(t,r){return this._interactionsLoader=new Rot.CacheableInteractionsLoader(new PRt.WarpGatewayInteractionsLoader(t.confirmationStatus,t.source)),this._definitionLoader=new kot.CacheableContractDefinitionLoader(new CRt.WarpGatewayContractDefinitionLoader(this._arweave,this._environment),this._environment,r),this}useArweaveGateway(t){return this._interactionsLoader=new Rot.CacheableInteractionsLoader(new BRt.ArweaveGatewayInteractionsLoader(this._arweave,this._environment)),this._definitionLoader=new kot.CacheableContractDefinitionLoader(new ORt.ArweaveContractDefinitionLoader(this._arweave,this._environment),this._environment,t),this}build(){let t=new NRt.Warp(this._arweave,this._definitionLoader,this._interactionsLoader,this._executorFactory,this._stateEvaluator,this._environment);return this._definitionLoader.warp=t,this._interactionsLoader.warp=t,t}};Mw.WarpBuilder=WO});var HO=De(Lp=>{"use strict";Tt();Rt();xt();Object.defineProperty(Lp,"__esModule",{value:!0});Lp.knownWarpPlugins=Lp.knownWarpPluginsPartial=void 0;Lp.knownWarpPluginsPartial=["^smartweave-extension-"];Lp.knownWarpPlugins=["evm-signature-verification","subscription","ivm-handler-api","evaluation-progress","fetch-options","deploy","contract-blacklist","vm2","vrf","quickjs"]});var Sw=De(Ew=>{"use strict";Tt();Rt();xt();Object.defineProperty(Ew,"__esModule",{value:!0});Ew.Warp=void 0;var LRt=vw(),DRt=qO(),$Rt=Mot(),URt=KO(),Iot=HO(),Bot=VO(),qRt=Hm(),GO=class{get createContract(){if(!this._createContract)if(this.plugins.has("deploy")){let t=this.loadPlugin("deploy");this._createContract=t.process(this)}else throw new Error("In order to use CreateContract methods please attach DeployPlugin.");return this._createContract}constructor(t,r,h,o,l,c="custom"){this.arweave=t,this.definitionLoader=r,this.interactionsLoader=h,this.executorFactory=o,this.stateEvaluator=l,this.environment=c,this._gwUrl=Bot.WARP_GW_URL,this.plugins=new Map,this.testing=new $Rt.Testing(t),this.kvStorageFactory=p=>new qRt.LevelDbCache({inMemory:!1,dbLocation:`${Bot.DEFAULT_LEVEL_DB_LOCATION}/kv/ldb/${p}`}),this.eventTarget=new EventTarget}static builder(t,r,h){return new URt.WarpBuilder(t,r,h)}contract(t,r,h){return new LRt.HandlerBasedContract(t,this,r,h)}async deploy(t,r){return await this.createContract.deploy(t,r)}async deployFromSourceTx(t,r){return await this.createContract.deployFromSourceTx(t,r)}async deployBundled(t){return await this.createContract.deployBundled(t)}async register(t,r){return await this.createContract.register(t,r)}async createSource(t,r,h=!1){return await this.createContract.createSource(t,r,h)}async saveSource(t,r){return await this.createContract.saveSource(t,r)}pst(t){return new DRt.PstContractImpl(t,this)}useStateCache(t){return this.stateEvaluator.setCache(t),this}useContractCache(t,r){return this.definitionLoader.setSrcCache(r),this.definitionLoader.setCache(t),this}use(t){let r=t.type();if(!this.isPluginType(r))throw new Error(`Unknown plugin type ${r}.`);return this.plugins.set(r,t),this}hasPlugin(t){return this.plugins.has(t)}matchPlugins(t){return[...this.plugins.keys()].filter(h=>h.match(t))}loadPlugin(t){if(!this.hasPlugin(t))throw new Error(`Plugin ${t} not registered.`);return this.plugins.get(t)}maybeLoadPlugin(t){return this.hasPlugin(t)?this.plugins.get(t):null}async close(){return Promise.all([this.definitionLoader.getSrcCache().close(),this.definitionLoader.getCache().close(),this.stateEvaluator.getCache().close()]).then()}async generateWallet(){let t=await this.arweave.wallets.generate();return await this.testing.isArlocal()&&await this.testing.addFunds(t),{jwk:t,address:await this.arweave.wallets.jwkToAddress(t)}}isPluginType(t){return Iot.knownWarpPlugins.includes(t)||Iot.knownWarpPluginsPartial.some(r=>t.match(r))}useKVStorageFactory(t){return this.kvStorageFactory=t,this}useGwUrl(t){return this._gwUrl=t,this}gwUrl(){return this._gwUrl}};Ew.Warp=GO});var VO=De(Sn=>{"use strict";Tt();Rt();xt();var FRt=Sn&&Sn.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Sn,"__esModule",{value:!0});Sn.WarpFactory=Sn.defaultCacheOptions=Sn.DEFAULT_LEVEL_DB_LOCATION=Sn.WARP_GW_URL=Sn.defaultWarpGwOptions=void 0;var ZO=FRt($4()),jRt=Hm(),zRt=YB(),WRt=WB(),KRt=qf(),HRt=Xm(),GRt=Sw();Sn.defaultWarpGwOptions={confirmationStatus:{notCorrupted:!0},source:HRt.SourceType.BOTH};Sn.WARP_GW_URL="https://gw.warp.cc";Sn.DEFAULT_LEVEL_DB_LOCATION="./cache/warp";Sn.defaultCacheOptions={inMemory:!1,dbLocation:Sn.DEFAULT_LEVEL_DB_LOCATION};var JO=class{static forLocal(t=1984,r=ZO.default.init({host:"localhost",port:t,protocol:"http"}),h={...Sn.defaultCacheOptions,inMemory:!0}){return this.customArweaveGw(r,h,"local")}static forTestnet(t=Sn.defaultCacheOptions,r=!1,h=ZO.default.init({host:"arweave.net",port:443,protocol:"https"})){return r?this.customArweaveGw(h,t,"testnet"):this.customWarpGw(h,Sn.defaultWarpGwOptions,t,"testnet")}static forMainnet(t=Sn.defaultCacheOptions,r=!1,h=ZO.default.init({host:"arweave.net",port:443,protocol:"https"})){return r?this.customArweaveGw(h,t,"mainnet"):this.customWarpGw(h,Sn.defaultWarpGwOptions,t,"mainnet")}static custom(t,r,h){let o=new jRt.LevelDbCache({...r,dbLocation:`${r.dbLocation}/state`}),l=new KRt.HandlerExecutorFactory(t),c=new WRt.CacheableStateEvaluator(t,o,[new zRt.Evolve]);return GRt.Warp.builder(t,o,h).setExecutorFactory(l).setStateEvaluator(c)}static customArweaveGw(t,r=Sn.defaultCacheOptions,h){return this.custom(t,r,h).useArweaveGateway(r).build()}static customWarpGw(t,r=Sn.defaultWarpGwOptions,h=Sn.defaultCacheOptions,o){return this.custom(t,h,o).useWarpGateway(r,h).build()}};Sn.WarpFactory=JO});var Cot=De(Oot=>{"use strict";Tt();Rt();xt();Object.defineProperty(Oot,"__esModule",{value:!0})});var Not=De(Pot=>{"use strict";Tt();Rt();xt();Object.defineProperty(Pot,"__esModule",{value:!0})});var Dot=De(Lot=>{"use strict";Tt();Rt();xt();Object.defineProperty(Lot,"__esModule",{value:!0})});var Uot=De($ot=>{"use strict";Tt();Rt();xt();Object.defineProperty($ot,"__esModule",{value:!0})});var Fot=De(qot=>{"use strict";Tt();Rt();xt();Object.defineProperty(qot,"__esModule",{value:!0})});var jot=De(Aw=>{"use strict";Tt();Rt();xt();Object.defineProperty(Aw,"__esModule",{value:!0});Aw.matchMutClosureDtor=void 0;function VRt(i){let t=/(const|var) ret = makeMutClosure\(arg0, arg1, (\d+?), __wbg_adapter/;return i.match(t)[2]}Aw.matchMutClosureDtor=VRt});var Wot=De(Dp=>{"use strict";Tt();Rt();xt();var ZRt=Dp&&Dp.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Dp,"__esModule",{value:!0});Dp.ArweaveGatewayBundledContractDefinitionLoader=void 0;var JRt=Qm(),Qa=Vh(),zot=Qs(),XRt=bn(),YRt=gl(),QRt=H4(),tkt=dv(),ekt=ZRt($4());function ts(i,t,r=void 0){let h=i.find(({name:o})=>o===t);return h?h.value:r}var XO=class i{constructor(t){this.env=t,this.logger=XRt.LoggerFactory.INST.create(i.name)}async load(t,r){let h=zot.Benchmark.measure(),o=await this.fetchContractTx(t);this.logger.debug("Contract tx fetch time",h.elapsed());let l=o.owner.address,c=r||ts(o.tags,Qa.SMART_WEAVE_TAGS.CONTRACT_SRC_TX_ID),p=ts(o.tags,Qa.WARP_TAGS.WARP_TESTNET)||null;if(p&&this.env!=="testnet")throw new Error('Trying to use testnet contract in a non-testnet env. Use the "forTestnet" factory method.');if(!p&&this.env==="testnet")throw new Error("Trying to use non-testnet contract in a testnet env.");let w=ts(o.tags,Qa.SMART_WEAVE_TAGS.MIN_FEE),m=ts(o.tags,Qa.WARP_TAGS.MANIFEST)?JSON.parse(ts(o.tags,Qa.WARP_TAGS.MANIFEST)):null;this.logger.debug("Tags decoding",h.elapsed());let y=await this.evalInitialState(o);this.logger.debug("init state",y);let v=JSON.parse(y);this.logger.debug("Parsing src and init state",h.elapsed());let{src:M,srcBinary:T,srcWasmLang:A,contractType:R,metadata:B,srcTx:C}=await this.loadContractSource(c),P={txId:t,srcTxId:c,src:M,srcBinary:T,srcWasmLang:A,initState:v,minFee:w,owner:l,contractType:R,metadata:B,manifest:m,contractTx:await this.convertToWarpCompatibleContractTx(o),srcTx:await this.convertToWarpCompatibleContractTx(C),testnet:p};return this.logger.info(`Contract definition loaded in: ${h.elapsed()}`),P}async fetchContractTx(t){let r=await this.arweaveTransactions.transaction(t);return r??await this.arweaveTransactions.transactionUsingUploaderTag(t)}async convertToWarpCompatibleContractTx(t){return{tags:t.tags.map(({name:h,value:o})=>({name:ge.from(h).toString("base64url"),value:ge.from(o).toString("base64url")})),owner:t.owner.key,target:t.recipient,signature:t.signature,data:(await this.arweaveWrapper.txData(t.id)).toString("base64url")}}async loadContractSource(t){let r=zot.Benchmark.measure(),h=await this.fetchContractTx(t),o=ts(h.tags,Qa.SMART_WEAVE_TAGS.CONTENT_TYPE);if(!JRt.SUPPORTED_SRC_CONTENT_TYPES.includes(o))throw new Error(`Contract source content type ${o} not supported`);let l=o==="application/javascript"?"js":"wasm",c=await this.contractSource(h,l),p,w,m;if(l=="wasm"){if(w=new tkt.WasmSrc(c),p=ts(h.tags,Qa.WARP_TAGS.WASM_LANG),!p)throw new Error(`Wasm lang not set for wasm contract src ${h.id}`);m=JSON.parse(ts(h.tags,Qa.WARP_TAGS.WASM_META))}return this.logger.debug("Contract src tx load",r.elapsed()),r.reset(),{src:l=="js"?c:null,srcBinary:l=="wasm"?w.wasmBinary():null,srcWasmLang:p,contractType:l,metadata:m,srcTx:h}}async contractSource(t,r){if(ts(t.tags,Qa.WARP_TAGS.UPLOADER_TX_ID)!=null){let o=await this.arweaveWrapper.txDataString(t.id);if(r==="wasm")throw new Error("WASM contracts in legacy format are not supported using AR GW");return ekt.default.utils.b64UrlToString(JSON.parse(o).data)}return r==="js"?await this.arweaveWrapper.txDataString(t.id):await this.arweaveWrapper.txData(t.id)}async evalInitialState(t){if(ts(t.tags,Qa.WARP_TAGS.INIT_STATE))return ts(t.tags,Qa.WARP_TAGS.INIT_STATE);if(ts(t.tags,Qa.WARP_TAGS.INIT_STATE_TX)){let r=ts(t.tags,Qa.WARP_TAGS.INIT_STATE_TX);return this.arweaveWrapper.txDataString(r)}else return this.arweaveWrapper.txDataString(t.id)}setCache(){throw new Error("Method not implemented.")}setSrcCache(){throw new Error("Method not implemented.")}getCache(){throw new Error("Method not implemented.")}getSrcCache(){throw new Error("Method not implemented.")}type(){return"arweave"}set warp(t){this.arweaveWrapper=new YRt.ArweaveWrapper(t),this.arweaveTransactions=new QRt.ArweaveGQLTxsFetcher(t)}};Dp.ArweaveGatewayBundledContractDefinitionLoader=XO});var Vot=De(Tw=>{"use strict";Tt();Rt();xt();Object.defineProperty(Tw,"__esModule",{value:!0});Tw.ArweaveGatewayBundledInteractionLoader=void 0;var es=Vh(),rkt=Qs(),ikt=bn(),nkt=gl(),Kot=ed(),okt=H4(),YO=ko(),akt=Vu(),Hot=100,skt=100,Got=1057409,QO=class i{constructor(t,r){this.arweave=t,this.environment=r,this.logger=ikt.LoggerFactory.INST.create(i.name),this.tagsParser=new akt.TagsParser,this.sorter=new Kot.LexicographicalInteractionsSorter(t)}async load(t,r,h,o,l){if(this.logger.debug("Loading interactions for",{contractId:t,fromSortKey:r,toSortKey:h}),o?.transactionsPagesPerBatch)throw new Error(`Loading in batches not yet implemented for ${i.name}`);let c=this.sorter.extractBlockHeight(r)||0,p=this.sorter.extractBlockHeight(h)||await this.currentBlockHeight(),w={tags:[{name:es.SMART_WEAVE_TAGS.APP_NAME,values:["SmartWeaveAction"]},{name:es.SMART_WEAVE_TAGS.CONTRACT_TX_ID,values:[t]},{name:es.WARP_TAGS.SEQUENCER,values:["RedStone"]}],blockFilter:{min:c,max:p+skt},first:Hot},m=rkt.Benchmark.measure(),y=await this.arweaveFetcher.transactions(w,Number.MAX_SAFE_INTEGER,l);o.internalWrites&&(y=await this.appendInternalWriteInteractions(t,c,p,y,l)),m.stop(),this.logger.debug("All loaded interactions:",{from:r,to:h,loaded:y.length,time:m.elapsed()}),y.forEach(A=>{var R,B,C,P;A.node.sortKey=(R=A.node.sortKey)!==null&&R!==void 0?R:(P=(C=(B=A.node)===null||B===void 0?void 0:B.tags)===null||C===void 0?void 0:C.find(N=>N.name===es.WARP_TAGS.SEQUENCER_SORT_KEY))===null||P===void 0?void 0:P.value});let v=await this.sorter.sort(y),M=this.environment==="local"||this.environment==="testnet",T=this._warp.maybeLoadPlugin("vrf");return v.filter(A=>this.isNewerThenSortKeyBlockHeight(A)).filter(A=>this.isSortKeyInBounds(r,h,A)).map(A=>this.attachSequencerDataToInteraction(A)).map(A=>this.maybeAddMockVrf(M,A,T)).map((A,R,B)=>this.verifySortKeyIntegrity(A,R,B)).map(({node:A})=>A)}verifySortKeyIntegrity(t,r,h){var o;if(r!==0){let l=h[r-1],c=h[r];if(this.logger.debug(`prev: ${l.node.id} | current: ${c.node.id}`),c.node.block.height<=Got||((o=c.node.lastSortKey)===null||o===void 0?void 0:o.split(",")[1])===Kot.defaultArweaveMs)return t;l.node.source==="redstone-sequencer"&&l.node.sortKey!==c.node.lastSortKey&&this.logger.warn(`Interaction loading error: interaction ${c.node.id} lastSortKey is not pointing on prev interaction ${l.node.id}`)}return t}isSortKeyInBounds(t,r,h){return t&&r?h.node.sortKey.localeCompare(t)>0&&h.node.sortKey.localeCompare(r)<=0:t&&!r?h.node.sortKey.localeCompare(t)>0:!t&&r?h.node.sortKey.localeCompare(r)<=0:!0}attachSequencerDataToInteraction(t){let r=v=>{var M;return(M=t.node.tags.find(T=>T.name===v))===null||M===void 0?void 0:M.value},h=r(es.WARP_TAGS.SEQUENCER_TX_ID),o=r(es.WARP_TAGS.SEQUENCER_OWNER),l=r(es.WARP_TAGS.SEQUENCER_BLOCK_ID),c=r(es.WARP_TAGS.SEQUENCER_BLOCK_HEIGHT),p=r(es.WARP_TAGS.SEQUENCER_PREV_SORT_KEY)||r(es.WARP_TAGS.SEQUENCER_LAST_SORT_KEY),w=r(es.WARP_TAGS.SEQUENCER_SORT_KEY),m=r(es.WARP_TAGS.SEQUENCER_BLOCK_TIMESTAMP),y=(0,YO.safeParseInt)(c);if(!o||!l||!c||!p&&y>Got||!h||!w)throw Error(`Interaction ${t.node.id} is not sequenced by sequencer aborting. Only Sequenced transactions are supported by loader ${i.name}`);return{...t,node:{...t.node,owner:{address:o,key:null},block:{...t.node.block,height:(0,YO.safeParseInt)(c),id:l,timestamp:m?(0,YO.safeParseInt)(m):t.node.block.timestamp},sortKey:w,lastSortKey:p,id:h,source:"redstone-sequencer"}}}async appendInternalWriteInteractions(t,r,h,o,l){let c={tags:[{name:es.WARP_TAGS.INTERACT_WRITE,values:[t]}],blockFilter:{min:r,max:h},first:Hot},p=await this.arweaveFetcher.transactions(c,Number.MAX_SAFE_INTEGER,l);return this.logger.debug("Inner writes interactions length:",p.length),o=o.concat(p),o}maybeAddMockVrf(t,r,h){return t&&this.tagsParser.hasVrfTag(r.node)&&(h?r.node.vrf=h.process().generateMockVrf(r.node.sortKey):this.logger.warn('Cannot generate mock vrf for interaction - no "warp-contracts-plugin-vrf" attached!')),r}isNewerThenSortKeyBlockHeight(t){if(t.node.sortKey){let r=t.node.sortKey.split(",")[0],h=Number.parseInt(r);return Number(t.node.block.height)-h>=0}return!0}async currentBlockHeight(){return(await this.arweaveWrapper.info()).height}type(){return"arweave"}clearCache(){}set warp(t){this.arweaveWrapper=new nkt.ArweaveWrapper(t),this.arweaveFetcher=new okt.ArweaveGQLTxsFetcher(t),this._warp=t}};Tw.ArweaveGatewayBundledInteractionLoader=QO});var Zot=De(Mr=>{"use strict";Tt();Rt();xt();var hkt=Mr&&Mr.__createBinding||(Object.create?function(i,t,r,h){h===void 0&&(h=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(i,h,o)}:function(i,t,r,h){h===void 0&&(h=r),i[h]=t[r]}),Ar=Mr&&Mr.__exportStar||function(i,t){for(var r in i)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&hkt(t,i,r)};Object.defineProperty(Mr,"__esModule",{value:!0});Ar(lk(),Mr);Ar(pk(),Mr);Ar(Uet(),Mr);Ar(bn(),Mr);Ar(uk(),Mr);Ar(Qs(),Mr);Ar(Fet(),Mr);Ar($u(),Mr);Ar(zet(),Mr);Ar(Hm(),Mr);Ar(eit(),Mr);Ar(iit(),Mr);Ar(oit(),Mr);Ar(sit(),Mr);Ar(fit(),Mr);Ar(Ym(),Mr);Ar(z4(),Mr);Ar(OB(),Mr);Ar(DB(),Mr);Ar(Xm(),Mr);Ar(UB(),Mr);Ar(jB(),Mr);Ar(WB(),Mr);Ar(qf(),Mr);Ar(ed(),Mr);Ar(Vu(),Mr);Ar(xI(),Mr);Ar(S4(),Mr);Ar(wp(),Mr);Ar(TI(),Mr);Ar(Snt(),Mr);Ar(Vh(),Mr);Ar(Ant(),Mr);Ar(Qm(),Mr);Ar(GB(),Mr);Ar(VO(),Mr);Ar(Sw(),Mr);Ar(KO(),Mr);Ar(HO(),Mr);Ar(Jm(),Mr);Ar(Cot(),Mr);Ar(vw(),Mr);Ar(Not(),Mr);Ar(qO(),Mr);Ar(hO(),Mr);Ar(MO(),Mr);Ar(EO(),Mr);Ar(Dot(),Mr);Ar(aO(),Mr);Ar(CO(),Mr);Ar(Uot(),Mr);Ar(Fot(),Mr);Ar(b4(),Mr);Ar(ZB(),Mr);Ar(BI(),Mr);Ar(oO(),Mr);Ar(ko(),Mr);Ar(gl(),Mr);Ar(Ep(),Mr);Ar(dv(),Mr);Ar(MI(),Mr);Ar(jot(),Mr);Ar(Wot(),Mr);Ar(Vot(),Mr)});Tt();Rt();xt();var iat=sc(z5(),1);Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();var Ist=["gateway","gateways","prescribedObservers","record","auction","balance","epoch","priceForInteraction"],Bst=["delegateStake","decreaseDelegateStake","joinNetwork","increaseOperatorStake","decreaseOperatorStake","updateGatewaySettings","saveObservations","extendRecord","buyRecord","increaseUndernameCount","transfer"],$kt=[...Ist,...Bst],ho={GATEWAY:"gateway",GATEWAYS:"gateways",PRESCRIBED_OBSERVERS:"prescribedObservers",DELEGATE_STAKE:"delegateStake",DECREASE_DELEGATE_STAKE:"decreaseDelegateStake",JOIN_NETWORK:"joinNetwork",INCREASE_OPERATOR_STAKE:"increaseOperatorStake",DECREASE_OPERATOR_STAKE:"decreaseOperatorStake",UPDATE_GATEWAY_SETTINGS:"updateGatewaySettings",SAVE_OBSERVATIONS:"saveObservations",EXTEND_RECORD:"extendRecord",INCREASE_UNDERNAME_COUNT:"increaseUndernameCount",RECORD:"record",AUCTION:"auction",TRANSFER:"transfer",BALANCE:"balance",PRICE_FOR_INTERACTION:"priceForInteraction",EPOCH:"epoch",BUY_RECORD:"buyRecord"},AL=(r=>(r.IO="IO",r.MIO="mIO",r))(AL||{}),cc={TRANSFER:"transfer",SET_CONTROLLER:"setController",REMOVE_CONTROLLER:"removeController",SET_NAME:"setName",SET_TICKER:"setTicker",SET_RECORD:"setRecord",REMOVE_RECORD:"removeRecord",BALANCE:"balance",EVOLVE:"evolve"};Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();var TL=new RegExp("^[a-zA-Z0-9_-]{43}$"),Hkt=new RegExp("^(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{1,63}$"),xL=new RegExp("^[0-9]{12},[0-9]{13},[a-fA-F0-9]{64}$"),Sy=me.env.ARNS_REGISTRY_TX??"bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U",Gkt="_NctcA2sRy1-J4OmIQZbYFPM17piNcbdBPH2ncX2RL8",Ost="GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc",Vkt=Ost,Od="agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA",W5=1e6,RL="cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk",kL="3OlGzE5mrsN2GsxCYM0Tae1KzWepGOr5a94deOWmApM",IL="_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA";var K5=class i{constructor(t){this.positiveFiniteInteger=t;if(!Number.isFinite(this.positiveFiniteInteger)||!Number.isInteger(this.positiveFiniteInteger)||this.positiveFiniteInteger<0)throw new Error(`Number must be a non-negative integer value! ${t}`)}[Symbol.toPrimitive](t){return t==="string"&&this.toString(),this.positiveFiniteInteger}plus(t){return new i(this.positiveFiniteInteger+t.positiveFiniteInteger)}minus(t){return new i(this.positiveFiniteInteger-t.positiveFiniteInteger)}isGreaterThan(t){return this.positiveFiniteInteger>t.positiveFiniteInteger}isGreaterThanOrEqualTo(t){return this.positiveFiniteInteger>=t.positiveFiniteInteger}isLessThan(t){return this.positiveFiniteInteger<t.positiveFiniteInteger}isLessThanOrEqualTo(t){return this.positiveFiniteInteger<=t.positiveFiniteInteger}toString(){return`${this.positiveFiniteInteger}`}valueOf(){return this.positiveFiniteInteger}toJSON(){return this.positiveFiniteInteger}equals(t){return this.positiveFiniteInteger===t.positiveFiniteInteger}},r2=class{value;constructor(t){if(!Number.isFinite(t)||t<0)throw new Error("IOToken must be a non-negative finite number");this.value=+t.toFixed(6)}valueOf(){return this.value}toMIO(){return new H5(Math.floor(this.value*W5))}toString(){return`${this.value}`}},H5=class i extends K5{constructor(t){super(t)}multiply(t){let r=Math.floor(this.valueOf()*t.valueOf());return new i(r)}divide(t){if(t.valueOf()===0)throw new Error("Cannot divide by zero");let r=Math.floor(this.valueOf()/t.valueOf());return new i(r)}plus(t){let r=super.plus(t);return new i(r.valueOf())}minus(t){let r=super.minus(t);return new i(r.valueOf())}toIO(){return new r2(this.valueOf()/W5)}};Tt();Rt();xt();Tt();Rt();xt();var Ey=i=>TL.test(i);function oIt(i){return i!==void 0&&!isNaN(parseInt(i.toString()))}var aIt=i=>["id","owner","tags","signature"].every(r=>r in i);function BL(i){return i.reduce((t,r)=>{let h=r.get("name",{decode:!0,string:!0}),o=r.get("value",{decode:!0,string:!0});return t[h]=o,t},{})}function Rl(i){return"process"in i}function kl(i){return"processId"in i&&typeof i.processId=="string"&&Ey(i.processId)===!0}function lIt(i){return i.type==="lease"&&i.endTimestamp!==void 0}Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();function RIt(i){return G5.validate(i)}var G5=class i{_sortKey;constructor(t){if(!i.validate(t))throw new Error(`Invalid sort key: ${t}`);this._sortKey=t}static validate(t){return xL.test(t)}toString(){return this._sortKey}parts(){return this._sortKey.split(",")}blockHeight(){return parseInt(this.parts()[0])}timestamp(){return parseInt(this.parts()[1])}hash(){return this.parts()[2]}};async function OL({arweave:i,contractTxId:t}){let{tags:r}=await i.transactions.get(t).catch(()=>({tags:[]})),o=BL(r)["Contract-Manifest"]??"{}";return JSON.parse(o)}function Yf(i){return"contract"in i}function Qf(i){return"contractTxId"in i&&typeof i.contractTxId=="string"&&Ey(i.contractTxId)===!0}Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();function i2(i,t){return function(){return i.apply(t,arguments)}}var{toString:Cst}=Object.prototype,{getPrototypeOf:J5}=Object,Ty=(i=>t=>{let r=Cst.call(t);return i[r]||(i[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),gh=i=>(i=i.toLowerCase(),t=>Ty(t)===i),xy=i=>t=>typeof t===i,{isArray:Cd}=Array,n2=xy("undefined");function Pst(i){return i!==null&&!n2(i)&&i.constructor!==null&&!n2(i.constructor)&&ls(i.constructor.isBuffer)&&i.constructor.isBuffer(i)}var NL=gh("ArrayBuffer");function Nst(i){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(i):t=i&&i.buffer&&NL(i.buffer),t}var Lst=xy("string"),ls=xy("function"),LL=xy("number"),Ry=i=>i!==null&&typeof i=="object",Dst=i=>i===!0||i===!1,Ay=i=>{if(Ty(i)!=="object")return!1;let t=J5(i);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in i)&&!(Symbol.iterator in i)},$st=gh("Date"),Ust=gh("File"),qst=gh("Blob"),Fst=gh("FileList"),jst=i=>Ry(i)&&ls(i.pipe),zst=i=>{let t;return i&&(typeof FormData=="function"&&i instanceof FormData||ls(i.append)&&((t=Ty(i))==="formdata"||t==="object"&&ls(i.toString)&&i.toString()==="[object FormData]"))},Wst=gh("URLSearchParams"),[Kst,Hst,Gst,Vst]=["ReadableStream","Request","Response","Headers"].map(gh),Zst=i=>i.trim?i.trim():i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function o2(i,t,{allOwnKeys:r=!1}={}){if(i===null||typeof i>"u")return;let h,o;if(typeof i!="object"&&(i=[i]),Cd(i))for(h=0,o=i.length;h<o;h++)t.call(null,i[h],h,i);else{let l=r?Object.getOwnPropertyNames(i):Object.keys(i),c=l.length,p;for(h=0;h<c;h++)p=l[h],t.call(null,i[p],p,i)}}function DL(i,t){t=t.toLowerCase();let r=Object.keys(i),h=r.length,o;for(;h-- >0;)if(o=r[h],t===o.toLowerCase())return o;return null}var $L=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,UL=i=>!n2(i)&&i!==$L;function Z5(){let{caseless:i}=UL(this)&&this||{},t={},r=(h,o)=>{let l=i&&DL(t,o)||o;Ay(t[l])&&Ay(h)?t[l]=Z5(t[l],h):Ay(h)?t[l]=Z5({},h):Cd(h)?t[l]=h.slice():t[l]=h};for(let h=0,o=arguments.length;h<o;h++)arguments[h]&&o2(arguments[h],r);return t}var Jst=(i,t,r,{allOwnKeys:h}={})=>(o2(t,(o,l)=>{r&&ls(o)?i[l]=i2(o,r):i[l]=o},{allOwnKeys:h}),i),Xst=i=>(i.charCodeAt(0)===65279&&(i=i.slice(1)),i),Yst=(i,t,r,h)=>{i.prototype=Object.create(t.prototype,h),i.prototype.constructor=i,Object.defineProperty(i,"super",{value:t.prototype}),r&&Object.assign(i.prototype,r)},Qst=(i,t,r,h)=>{let o,l,c,p={};if(t=t||{},i==null)return t;do{for(o=Object.getOwnPropertyNames(i),l=o.length;l-- >0;)c=o[l],(!h||h(c,i,t))&&!p[c]&&(t[c]=i[c],p[c]=!0);i=r!==!1&&J5(i)}while(i&&(!r||r(i,t))&&i!==Object.prototype);return t},tht=(i,t,r)=>{i=String(i),(r===void 0||r>i.length)&&(r=i.length),r-=t.length;let h=i.indexOf(t,r);return h!==-1&&h===r},eht=i=>{if(!i)return null;if(Cd(i))return i;let t=i.length;if(!LL(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=i[t];return r},rht=(i=>t=>i&&t instanceof i)(typeof Uint8Array<"u"&&J5(Uint8Array)),iht=(i,t)=>{let h=(i&&i[Symbol.iterator]).call(i),o;for(;(o=h.next())&&!o.done;){let l=o.value;t.call(i,l[0],l[1])}},nht=(i,t)=>{let r,h=[];for(;(r=i.exec(t))!==null;)h.push(r);return h},oht=gh("HTMLFormElement"),aht=i=>i.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,h,o){return h.toUpperCase()+o}),CL=(({hasOwnProperty:i})=>(t,r)=>i.call(t,r))(Object.prototype),sht=gh("RegExp"),qL=(i,t)=>{let r=Object.getOwnPropertyDescriptors(i),h={};o2(r,(o,l)=>{let c;(c=t(o,l,i))!==!1&&(h[l]=c||o)}),Object.defineProperties(i,h)},hht=i=>{qL(i,(t,r)=>{if(ls(i)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let h=i[r];if(ls(h)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},fht=(i,t)=>{let r={},h=o=>{o.forEach(l=>{r[l]=!0})};return Cd(i)?h(i):h(String(i).split(t)),r},uht=()=>{},cht=(i,t)=>i!=null&&Number.isFinite(i=+i)?i:t,V5="abcdefghijklmnopqrstuvwxyz",PL="0123456789",FL={DIGIT:PL,ALPHA:V5,ALPHA_DIGIT:V5+V5.toUpperCase()+PL},lht=(i=16,t=FL.ALPHA_DIGIT)=>{let r="",{length:h}=t;for(;i--;)r+=t[Math.random()*h|0];return r};function dht(i){return!!(i&&ls(i.append)&&i[Symbol.toStringTag]==="FormData"&&i[Symbol.iterator])}var pht=i=>{let t=new Array(10),r=(h,o)=>{if(Ry(h)){if(t.indexOf(h)>=0)return;if(!("toJSON"in h)){t[o]=h;let l=Cd(h)?[]:{};return o2(h,(c,p)=>{let w=r(c,o+1);!n2(w)&&(l[p]=w)}),t[o]=void 0,l}}return h};return r(i,0)},ght=gh("AsyncFunction"),mht=i=>i&&(Ry(i)||ls(i))&&ls(i.then)&&ls(i.catch),Ke={isArray:Cd,isArrayBuffer:NL,isBuffer:Pst,isFormData:zst,isArrayBufferView:Nst,isString:Lst,isNumber:LL,isBoolean:Dst,isObject:Ry,isPlainObject:Ay,isReadableStream:Kst,isRequest:Hst,isResponse:Gst,isHeaders:Vst,isUndefined:n2,isDate:$st,isFile:Ust,isBlob:qst,isRegExp:sht,isFunction:ls,isStream:jst,isURLSearchParams:Wst,isTypedArray:rht,isFileList:Fst,forEach:o2,merge:Z5,extend:Jst,trim:Zst,stripBOM:Xst,inherits:Yst,toFlatObject:Qst,kindOf:Ty,kindOfTest:gh,endsWith:tht,toArray:eht,forEachEntry:iht,matchAll:nht,isHTMLForm:oht,hasOwnProperty:CL,hasOwnProp:CL,reduceDescriptors:qL,freezeMethods:hht,toObjectSet:fht,toCamelCase:aht,noop:uht,toFiniteNumber:cht,findKey:DL,global:$L,isContextDefined:UL,ALPHABET:FL,generateString:lht,isSpecCompliantForm:dht,toJSONObject:pht,isAsyncFn:ght,isThenable:mht};Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();function Pd(i,t,r,h,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=i,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),h&&(this.request=h),o&&(this.response=o)}Ke.inherits(Pd,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ke.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var jL=Pd.prototype,zL={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(i=>{zL[i]={value:i}});Object.defineProperties(Pd,zL);Object.defineProperty(jL,"isAxiosError",{value:!0});Pd.from=(i,t,r,h,o,l)=>{let c=Object.create(jL);return Ke.toFlatObject(i,c,function(w){return w!==Error.prototype},p=>p!=="isAxiosError"),Pd.call(c,i.message,t,r,h,o),c.cause=i,c.name=i.name,l&&Object.assign(c,l),c};var Nr=Pd;Tt();Rt();xt();var ky=null;function X5(i){return Ke.isPlainObject(i)||Ke.isArray(i)}function KL(i){return Ke.endsWith(i,"[]")?i.slice(0,-2):i}function WL(i,t,r){return i?i.concat(t).map(function(o,l){return o=KL(o),!r&&l?"["+o+"]":o}).join(r?".":""):t}function vht(i){return Ke.isArray(i)&&!i.some(X5)}var yht=Ke.toFlatObject(Ke,{},null,function(t){return/^is[A-Z]/.test(t)});function bht(i,t,r){if(!Ke.isObject(i))throw new TypeError("target must be an object");t=t||new(ky||FormData),r=Ke.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(R,B){return!Ke.isUndefined(B[R])});let h=r.metaTokens,o=r.visitor||y,l=r.dots,c=r.indexes,w=(r.Blob||typeof Blob<"u"&&Blob)&&Ke.isSpecCompliantForm(t);if(!Ke.isFunction(o))throw new TypeError("visitor must be a function");function m(A){if(A===null)return"";if(Ke.isDate(A))return A.toISOString();if(!w&&Ke.isBlob(A))throw new Nr("Blob is not supported. Use a Buffer instead.");return Ke.isArrayBuffer(A)||Ke.isTypedArray(A)?w&&typeof Blob=="function"?new Blob([A]):ge.from(A):A}function y(A,R,B){let C=A;if(A&&!B&&typeof A=="object"){if(Ke.endsWith(R,"{}"))R=h?R:R.slice(0,-2),A=JSON.stringify(A);else if(Ke.isArray(A)&&vht(A)||(Ke.isFileList(A)||Ke.endsWith(R,"[]"))&&(C=Ke.toArray(A)))return R=KL(R),C.forEach(function(N,q){!(Ke.isUndefined(N)||N===null)&&t.append(c===!0?WL([R],q,l):c===null?R:R+"[]",m(N))}),!1}return X5(A)?!0:(t.append(WL(B,R,l),m(A)),!1)}let v=[],M=Object.assign(yht,{defaultVisitor:y,convertValue:m,isVisitable:X5});function T(A,R){if(!Ke.isUndefined(A)){if(v.indexOf(A)!==-1)throw Error("Circular reference detected in "+R.join("."));v.push(A),Ke.forEach(A,function(C,P){(!(Ke.isUndefined(C)||C===null)&&o.call(t,C,Ke.isString(P)?P.trim():P,R,M))===!0&&T(C,R?R.concat(P):[P])}),v.pop()}}if(!Ke.isObject(i))throw new TypeError("data must be an object");return T(i),t}var lc=bht;function HL(i){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(i).replace(/[!'()~]|%20|%00/g,function(h){return t[h]})}function GL(i,t){this._pairs=[],i&&lc(i,this,t)}var VL=GL.prototype;VL.append=function(t,r){this._pairs.push([t,r])};VL.toString=function(t){let r=t?function(h){return t.call(this,h,HL)}:HL;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};var Iy=GL;function wht(i){return encodeURIComponent(i).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function a2(i,t,r){if(!t)return i;let h=r&&r.encode||wht,o=r&&r.serialize,l;if(o?l=o(t,r):l=Ke.isURLSearchParams(t)?t.toString():new Iy(t,r).toString(h),l){let c=i.indexOf("#");c!==-1&&(i=i.slice(0,c)),i+=(i.indexOf("?")===-1?"?":"&")+l}return i}Tt();Rt();xt();var Y5=class{constructor(){this.handlers=[]}use(t,r,h){return this.handlers.push({fulfilled:t,rejected:r,synchronous:h?h.synchronous:!1,runWhen:h?h.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Ke.forEach(this.handlers,function(h){h!==null&&t(h)})}},Q5=Y5;Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();var By={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();var ZL=typeof URLSearchParams<"u"?URLSearchParams:Iy;Tt();Rt();xt();var JL=typeof FormData<"u"?FormData:null;Tt();Rt();xt();var XL=typeof Blob<"u"?Blob:null;var YL={isBrowser:!0,classes:{URLSearchParams:ZL,FormData:JL,Blob:XL},protocols:["http","https","file","blob","url","data"]};var e7={};cs(e7,{hasBrowserEnv:()=>t7,hasStandardBrowserEnv:()=>_ht,hasStandardBrowserWebWorkerEnv:()=>Mht,origin:()=>Sht});Tt();Rt();xt();var t7=typeof window<"u"&&typeof document<"u",_ht=(i=>t7&&["ReactNative","NativeScript","NS"].indexOf(i)<0)(typeof navigator<"u"&&navigator.product),Mht=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Sht=t7&&window.location.href||"http://localhost";var fo={...e7,...YL};function r7(i,t){return lc(i,new fo.classes.URLSearchParams,Object.assign({visitor:function(r,h,o,l){return fo.isNode&&Ke.isBuffer(r)?(this.append(h,r.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)}},t))}Tt();Rt();xt();function Eht(i){return Ke.matchAll(/\w+|\[(\w*)]/g,i).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Aht(i){let t={},r=Object.keys(i),h,o=r.length,l;for(h=0;h<o;h++)l=r[h],t[l]=i[l];return t}function Tht(i){function t(r,h,o,l){let c=r[l++];if(c==="__proto__")return!0;let p=Number.isFinite(+c),w=l>=r.length;return c=!c&&Ke.isArray(o)?o.length:c,w?(Ke.hasOwnProp(o,c)?o[c]=[o[c],h]:o[c]=h,!p):((!o[c]||!Ke.isObject(o[c]))&&(o[c]=[]),t(r,h,o[c],l)&&Ke.isArray(o[c])&&(o[c]=Aht(o[c])),!p)}if(Ke.isFormData(i)&&Ke.isFunction(i.entries)){let r={};return Ke.forEachEntry(i,(h,o)=>{t(Eht(h),o,r,0)}),r}return null}var Oy=Tht;function xht(i,t,r){if(Ke.isString(i))try{return(t||JSON.parse)(i),Ke.trim(i)}catch(h){if(h.name!=="SyntaxError")throw h}return(r||JSON.stringify)(i)}var i7={transitional:By,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let h=r.getContentType()||"",o=h.indexOf("application/json")>-1,l=Ke.isObject(t);if(l&&Ke.isHTMLForm(t)&&(t=new FormData(t)),Ke.isFormData(t))return o?JSON.stringify(Oy(t)):t;if(Ke.isArrayBuffer(t)||Ke.isBuffer(t)||Ke.isStream(t)||Ke.isFile(t)||Ke.isBlob(t)||Ke.isReadableStream(t))return t;if(Ke.isArrayBufferView(t))return t.buffer;if(Ke.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let p;if(l){if(h.indexOf("application/x-www-form-urlencoded")>-1)return r7(t,this.formSerializer).toString();if((p=Ke.isFileList(t))||h.indexOf("multipart/form-data")>-1){let w=this.env&&this.env.FormData;return lc(p?{"files[]":t}:t,w&&new w,this.formSerializer)}}return l||o?(r.setContentType("application/json",!1),xht(t)):t}],transformResponse:[function(t){let r=this.transitional||i7.transitional,h=r&&r.forcedJSONParsing,o=this.responseType==="json";if(Ke.isResponse(t)||Ke.isReadableStream(t))return t;if(t&&Ke.isString(t)&&(h&&!this.responseType||o)){let c=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(p){if(c)throw p.name==="SyntaxError"?Nr.from(p,Nr.ERR_BAD_RESPONSE,this,null,this.response):p}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:fo.classes.FormData,Blob:fo.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ke.forEach(["delete","get","head","post","put","patch"],i=>{i7.headers[i]={}});var Nd=i7;Tt();Rt();xt();Tt();Rt();xt();var Rht=Ke.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),QL=i=>{let t={},r,h,o;return i&&i.split(`
|
|
217
217
|
`).forEach(function(c){o=c.indexOf(":"),r=c.substring(0,o).trim().toLowerCase(),h=c.substring(o+1).trim(),!(!r||t[r]&&Rht[r])&&(r==="set-cookie"?t[r]?t[r].push(h):t[r]=[h]:t[r]=t[r]?t[r]+", "+h:h)}),t};var tD=Symbol("internals");function s2(i){return i&&String(i).trim().toLowerCase()}function Cy(i){return i===!1||i==null?i:Ke.isArray(i)?i.map(Cy):String(i)}function kht(i){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,h;for(;h=r.exec(i);)t[h[1]]=h[2];return t}var Iht=i=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(i.trim());function n7(i,t,r,h,o){if(Ke.isFunction(h))return h.call(this,t,r);if(o&&(t=r),!!Ke.isString(t)){if(Ke.isString(h))return t.indexOf(h)!==-1;if(Ke.isRegExp(h))return h.test(t)}}function Bht(i){return i.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,h)=>r.toUpperCase()+h)}function Oht(i,t){let r=Ke.toCamelCase(" "+t);["get","set","has"].forEach(h=>{Object.defineProperty(i,h+r,{value:function(o,l,c){return this[h].call(this,t,o,l,c)},configurable:!0})})}var Ld=class{constructor(t){t&&this.set(t)}set(t,r,h){let o=this;function l(p,w,m){let y=s2(w);if(!y)throw new Error("header name must be a non-empty string");let v=Ke.findKey(o,y);(!v||o[v]===void 0||m===!0||m===void 0&&o[v]!==!1)&&(o[v||w]=Cy(p))}let c=(p,w)=>Ke.forEach(p,(m,y)=>l(m,y,w));if(Ke.isPlainObject(t)||t instanceof this.constructor)c(t,r);else if(Ke.isString(t)&&(t=t.trim())&&!Iht(t))c(QL(t),r);else if(Ke.isHeaders(t))for(let[p,w]of t.entries())l(w,p,h);else t!=null&&l(r,t,h);return this}get(t,r){if(t=s2(t),t){let h=Ke.findKey(this,t);if(h){let o=this[h];if(!r)return o;if(r===!0)return kht(o);if(Ke.isFunction(r))return r.call(this,o,h);if(Ke.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=s2(t),t){let h=Ke.findKey(this,t);return!!(h&&this[h]!==void 0&&(!r||n7(this,this[h],h,r)))}return!1}delete(t,r){let h=this,o=!1;function l(c){if(c=s2(c),c){let p=Ke.findKey(h,c);p&&(!r||n7(h,h[p],p,r))&&(delete h[p],o=!0)}}return Ke.isArray(t)?t.forEach(l):l(t),o}clear(t){let r=Object.keys(this),h=r.length,o=!1;for(;h--;){let l=r[h];(!t||n7(this,this[l],l,t,!0))&&(delete this[l],o=!0)}return o}normalize(t){let r=this,h={};return Ke.forEach(this,(o,l)=>{let c=Ke.findKey(h,l);if(c){r[c]=Cy(o),delete r[l];return}let p=t?Bht(l):String(l).trim();p!==l&&delete r[l],r[p]=Cy(o),h[p]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Ke.forEach(this,(h,o)=>{h!=null&&h!==!1&&(r[o]=t&&Ke.isArray(h)?h.join(", "):h)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
218
218
|
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let h=new this(t);return r.forEach(o=>h.set(o)),h}static accessor(t){let h=(this[tD]=this[tD]={accessors:{}}).accessors,o=this.prototype;function l(c){let p=s2(c);h[p]||(Oht(o,c),h[p]=!0)}return Ke.isArray(t)?t.forEach(l):l(t),this}};Ld.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Ke.reduceDescriptors(Ld.prototype,({value:i},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>i,set(h){this[r]=h}}});Ke.freezeMethods(Ld);var Zn=Ld;function h2(i,t){let r=this||Nd,h=t||r,o=Zn.from(h.headers),l=h.data;return Ke.forEach(i,function(p){l=p.call(r,l,o.normalize(),t?t.status:void 0)}),o.normalize(),l}Tt();Rt();xt();function f2(i){return!!(i&&i.__CANCEL__)}Tt();Rt();xt();function eD(i,t,r){Nr.call(this,i??"canceled",Nr.ERR_CANCELED,t,r),this.name="CanceledError"}Ke.inherits(eD,Nr,{__CANCEL__:!0});var sf=eD;Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();function u2(i,t,r){let h=r.config.validateStatus;!r.status||!h||h(r.status)?i(r):t(new Nr("Request failed with status code "+r.status,[Nr.ERR_BAD_REQUEST,Nr.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}Tt();Rt();xt();function o7(i){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(i);return t&&t[1]||""}Tt();Rt();xt();Tt();Rt();xt();function Cht(i,t){i=i||10;let r=new Array(i),h=new Array(i),o=0,l=0,c;return t=t!==void 0?t:1e3,function(w){let m=Date.now(),y=h[l];c||(c=m),r[o]=w,h[o]=m;let v=l,M=0;for(;v!==o;)M+=r[v++],v=v%i;if(o=(o+1)%i,o===l&&(l=(l+1)%i),m-c<t)return;let T=y&&m-y;return T?Math.round(M*1e3/T):void 0}}var rD=Cht;Tt();Rt();xt();function Pht(i,t){let r=0,h=1e3/t,o=null;return function(){let c=this===!0,p=Date.now();if(c||p-r>h)return o&&(clearTimeout(o),o=null),r=p,i.apply(null,arguments);o||(o=setTimeout(()=>(o=null,r=Date.now(),i.apply(null,arguments)),h-(p-r)))}}var iD=Pht;var Dd=(i,t,r=3)=>{let h=0,o=rD(50,250);return iD(l=>{let c=l.loaded,p=l.lengthComputable?l.total:void 0,w=c-h,m=o(w),y=c<=p;h=c;let v={loaded:c,total:p,progress:p?c/p:void 0,bytes:w,rate:m||void 0,estimated:m&&p&&y?(p-c)/m:void 0,event:l,lengthComputable:p!=null};v[t?"download":"upload"]=!0,i(v)},r)};Tt();Rt();xt();Tt();Rt();xt();var nD=fo.hasStandardBrowserEnv?function(){let t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),h;function o(l){let c=l;return t&&(r.setAttribute("href",c),c=r.href),r.setAttribute("href",c),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return h=o(window.location.href),function(c){let p=Ke.isString(c)?o(c):c;return p.protocol===h.protocol&&p.host===h.host}}():function(){return function(){return!0}}();Tt();Rt();xt();var oD=fo.hasStandardBrowserEnv?{write(i,t,r,h,o,l){let c=[i+"="+encodeURIComponent(t)];Ke.isNumber(r)&&c.push("expires="+new Date(r).toGMTString()),Ke.isString(h)&&c.push("path="+h),Ke.isString(o)&&c.push("domain="+o),l===!0&&c.push("secure"),document.cookie=c.join("; ")},read(i){let t=document.cookie.match(new RegExp("(^|;\\s*)("+i+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(i){this.write(i,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};Tt();Rt();xt();Tt();Rt();xt();function a7(i){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(i)}Tt();Rt();xt();function s7(i,t){return t?i.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):i}function c2(i,t){return i&&!a7(t)?s7(i,t):t}Tt();Rt();xt();var aD=i=>i instanceof Zn?{...i}:i;function mh(i,t){t=t||{};let r={};function h(m,y,v){return Ke.isPlainObject(m)&&Ke.isPlainObject(y)?Ke.merge.call({caseless:v},m,y):Ke.isPlainObject(y)?Ke.merge({},y):Ke.isArray(y)?y.slice():y}function o(m,y,v){if(Ke.isUndefined(y)){if(!Ke.isUndefined(m))return h(void 0,m,v)}else return h(m,y,v)}function l(m,y){if(!Ke.isUndefined(y))return h(void 0,y)}function c(m,y){if(Ke.isUndefined(y)){if(!Ke.isUndefined(m))return h(void 0,m)}else return h(void 0,y)}function p(m,y,v){if(v in t)return h(m,y);if(v in i)return h(void 0,m)}let w={url:l,method:l,data:l,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutMessage:c,withCredentials:c,withXSRFToken:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,beforeRedirect:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,responseEncoding:c,validateStatus:p,headers:(m,y)=>o(aD(m),aD(y),!0)};return Ke.forEach(Object.keys(Object.assign({},i,t)),function(y){let v=w[y]||o,M=v(i[y],t[y],y);Ke.isUndefined(M)&&v!==p||(r[y]=M)}),r}var Py=i=>{let t=mh({},i),{data:r,withXSRFToken:h,xsrfHeaderName:o,xsrfCookieName:l,headers:c,auth:p}=t;t.headers=c=Zn.from(c),t.url=a2(c2(t.baseURL,t.url),i.params,i.paramsSerializer),p&&c.set("Authorization","Basic "+btoa((p.username||"")+":"+(p.password?unescape(encodeURIComponent(p.password)):"")));let w;if(Ke.isFormData(r)){if(fo.hasStandardBrowserEnv||fo.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if((w=c.getContentType())!==!1){let[m,...y]=w?w.split(";").map(v=>v.trim()).filter(Boolean):[];c.setContentType([m||"multipart/form-data",...y].join("; "))}}if(fo.hasStandardBrowserEnv&&(h&&Ke.isFunction(h)&&(h=h(t)),h||h!==!1&&nD(t.url))){let m=o&&l&&oD.read(l);m&&c.set(o,m)}return t};var Nht=typeof XMLHttpRequest<"u",sD=Nht&&function(i){return new Promise(function(r,h){let o=Py(i),l=o.data,c=Zn.from(o.headers).normalize(),{responseType:p}=o,w;function m(){o.cancelToken&&o.cancelToken.unsubscribe(w),o.signal&&o.signal.removeEventListener("abort",w)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function v(){if(!y)return;let T=Zn.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),R={data:!p||p==="text"||p==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:T,config:i,request:y};u2(function(C){r(C),m()},function(C){h(C),m()},R),y=null}"onloadend"in y?y.onloadend=v:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(v)},y.onabort=function(){y&&(h(new Nr("Request aborted",Nr.ECONNABORTED,o,y)),y=null)},y.onerror=function(){h(new Nr("Network Error",Nr.ERR_NETWORK,o,y)),y=null},y.ontimeout=function(){let A=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",R=o.transitional||By;o.timeoutErrorMessage&&(A=o.timeoutErrorMessage),h(new Nr(A,R.clarifyTimeoutError?Nr.ETIMEDOUT:Nr.ECONNABORTED,o,y)),y=null},l===void 0&&c.setContentType(null),"setRequestHeader"in y&&Ke.forEach(c.toJSON(),function(A,R){y.setRequestHeader(R,A)}),Ke.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),p&&p!=="json"&&(y.responseType=o.responseType),typeof o.onDownloadProgress=="function"&&y.addEventListener("progress",Dd(o.onDownloadProgress,!0)),typeof o.onUploadProgress=="function"&&y.upload&&y.upload.addEventListener("progress",Dd(o.onUploadProgress)),(o.cancelToken||o.signal)&&(w=T=>{y&&(h(!T||T.type?new sf(null,i,y):T),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(w),o.signal&&(o.signal.aborted?w():o.signal.addEventListener("abort",w)));let M=o7(o.url);if(M&&fo.protocols.indexOf(M)===-1){h(new Nr("Unsupported protocol "+M+":",Nr.ERR_BAD_REQUEST,i));return}y.send(l||null)})};Tt();Rt();xt();Tt();Rt();xt();var Lht=(i,t)=>{let r=new AbortController,h,o=function(w){if(!h){h=!0,c();let m=w instanceof Error?w:this.reason;r.abort(m instanceof Nr?m:new sf(m instanceof Error?m.message:m))}},l=t&&setTimeout(()=>{o(new Nr(`timeout ${t} of ms exceeded`,Nr.ETIMEDOUT))},t),c=()=>{i&&(l&&clearTimeout(l),l=null,i.forEach(w=>{w&&(w.removeEventListener?w.removeEventListener("abort",o):w.unsubscribe(o))}),i=null)};i.forEach(w=>w&&w.addEventListener&&w.addEventListener("abort",o));let{signal:p}=r;return p.unsubscribe=c,[p,()=>{l&&clearTimeout(l),l=null}]},hD=Lht;Tt();Rt();xt();var Dht=function*(i,t){let r=i.byteLength;if(!t||r<t){yield i;return}let h=0,o;for(;h<r;)o=h+t,yield i.slice(h,o),h=o},$ht=async function*(i,t,r){for await(let h of i)yield*Dht(ArrayBuffer.isView(h)?h:await r(String(h)),t)},h7=(i,t,r,h,o)=>{let l=$ht(i,t,o),c=0;return new ReadableStream({type:"bytes",async pull(p){let{done:w,value:m}=await l.next();if(w){p.close(),h();return}let y=m.byteLength;r&&r(c+=y),p.enqueue(new Uint8Array(m))},cancel(p){return h(p),l.return()}},{highWaterMark:2})};var fD=(i,t)=>{let r=i!=null;return h=>setTimeout(()=>t({lengthComputable:r,total:i,loaded:h}))},Ly=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",cD=Ly&&typeof ReadableStream=="function",f7=Ly&&(typeof TextEncoder=="function"?(i=>t=>i.encode(t))(new TextEncoder):async i=>new Uint8Array(await new Response(i).arrayBuffer())),Uht=cD&&(()=>{let i=!1,t=new Request(fo.origin,{body:new ReadableStream,method:"POST",get duplex(){return i=!0,"half"}}).headers.has("Content-Type");return i&&!t})(),uD=64*1024,u7=cD&&!!(()=>{try{return Ke.isReadableStream(new Response("").body)}catch{}})(),Ny={stream:u7&&(i=>i.body)};Ly&&(i=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Ny[t]&&(Ny[t]=Ke.isFunction(i[t])?r=>r[t]():(r,h)=>{throw new Nr(`Response type '${t}' is not supported`,Nr.ERR_NOT_SUPPORT,h)})})})(new Response);var qht=async i=>{if(i==null)return 0;if(Ke.isBlob(i))return i.size;if(Ke.isSpecCompliantForm(i))return(await new Request(i).arrayBuffer()).byteLength;if(Ke.isArrayBufferView(i))return i.byteLength;if(Ke.isURLSearchParams(i)&&(i=i+""),Ke.isString(i))return(await f7(i)).byteLength},Fht=async(i,t)=>{let r=Ke.toFiniteNumber(i.getContentLength());return r??qht(t)},lD=Ly&&(async i=>{let{url:t,method:r,data:h,signal:o,cancelToken:l,timeout:c,onDownloadProgress:p,onUploadProgress:w,responseType:m,headers:y,withCredentials:v="same-origin",fetchOptions:M}=Py(i);m=m?(m+"").toLowerCase():"text";let[T,A]=o||l||c?hD([o,l],c):[],R,B,C=()=>{!R&&setTimeout(()=>{T&&T.unsubscribe()}),R=!0},P;try{if(w&&Uht&&r!=="get"&&r!=="head"&&(P=await Fht(y,h))!==0){let J=new Request(t,{method:"POST",body:h,duplex:"half"}),F;Ke.isFormData(h)&&(F=J.headers.get("content-type"))&&y.setContentType(F),J.body&&(h=h7(J.body,uD,fD(P,Dd(w)),null,f7))}Ke.isString(v)||(v=v?"cors":"omit"),B=new Request(t,{...M,signal:T,method:r.toUpperCase(),headers:y.normalize().toJSON(),body:h,duplex:"half",withCredentials:v});let N=await fetch(B),q=u7&&(m==="stream"||m==="response");if(u7&&(p||q)){let J={};["status","statusText","headers"].forEach(H=>{J[H]=N[H]});let F=Ke.toFiniteNumber(N.headers.get("content-length"));N=new Response(h7(N.body,uD,p&&fD(F,Dd(p,!0)),q&&C,f7),J)}m=m||"text";let W=await Ny[Ke.findKey(Ny,m)||"text"](N,i);return!q&&C(),A&&A(),await new Promise((J,F)=>{u2(J,F,{data:W,headers:Zn.from(N.headers),status:N.status,statusText:N.statusText,config:i,request:B})})}catch(N){throw C(),N&&N.name==="TypeError"&&/fetch/i.test(N.message)?Object.assign(new Nr("Network Error",Nr.ERR_NETWORK,i,B),{cause:N.cause||N}):Nr.from(N,N&&N.code,i,B)}});var c7={http:ky,xhr:sD,fetch:lD};Ke.forEach(c7,(i,t)=>{if(i){try{Object.defineProperty(i,"name",{value:t})}catch{}Object.defineProperty(i,"adapterName",{value:t})}});var dD=i=>`- ${i}`,jht=i=>Ke.isFunction(i)||i===null||i===!1,Dy={getAdapter:i=>{i=Ke.isArray(i)?i:[i];let{length:t}=i,r,h,o={};for(let l=0;l<t;l++){r=i[l];let c;if(h=r,!jht(r)&&(h=c7[(c=String(r)).toLowerCase()],h===void 0))throw new Nr(`Unknown adapter '${c}'`);if(h)break;o[c||"#"+l]=h}if(!h){let l=Object.entries(o).map(([p,w])=>`adapter ${p} `+(w===!1?"is not supported by the environment":"is not available in the build")),c=t?l.length>1?`since :
|
|
219
219
|
`+l.map(dD).join(`
|
|
220
220
|
`):" "+dD(l[0]):"as no adapter specified";throw new Nr("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return h},adapters:c7};function l7(i){if(i.cancelToken&&i.cancelToken.throwIfRequested(),i.signal&&i.signal.aborted)throw new sf(null,i)}function $y(i){return l7(i),i.headers=Zn.from(i.headers),i.data=h2.call(i,i.transformRequest),["post","put","patch"].indexOf(i.method)!==-1&&i.headers.setContentType("application/x-www-form-urlencoded",!1),Dy.getAdapter(i.adapter||Nd.adapter)(i).then(function(h){return l7(i),h.data=h2.call(i,i.transformResponse,h),h.headers=Zn.from(h.headers),h},function(h){return f2(h)||(l7(i),h&&h.response&&(h.response.data=h2.call(i,i.transformResponse,h.response),h.response.headers=Zn.from(h.response.headers))),Promise.reject(h)})}Tt();Rt();xt();Tt();Rt();xt();var Uy="1.7.2";var d7={};["object","boolean","number","function","string","symbol"].forEach((i,t)=>{d7[i]=function(h){return typeof h===i||"a"+(t<1?"n ":" ")+i}});var pD={};d7.transitional=function(t,r,h){function o(l,c){return"[Axios v"+Uy+"] Transitional option '"+l+"'"+c+(h?". "+h:"")}return(l,c,p)=>{if(t===!1)throw new Nr(o(c," has been removed"+(r?" in "+r:"")),Nr.ERR_DEPRECATED);return r&&!pD[c]&&(pD[c]=!0,console.warn(o(c," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(l,c,p):!0}};function zht(i,t,r){if(typeof i!="object")throw new Nr("options must be an object",Nr.ERR_BAD_OPTION_VALUE);let h=Object.keys(i),o=h.length;for(;o-- >0;){let l=h[o],c=t[l];if(c){let p=i[l],w=p===void 0||c(p,l,i);if(w!==!0)throw new Nr("option "+l+" must be "+w,Nr.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Nr("Unknown option "+l,Nr.ERR_BAD_OPTION)}}var qy={assertOptions:zht,validators:d7};var dc=qy.validators,$d=class{constructor(t){this.defaults=t,this.interceptors={request:new Q5,response:new Q5}}async request(t,r){try{return await this._request(t,r)}catch(h){if(h instanceof Error){let o;Error.captureStackTrace?Error.captureStackTrace(o={}):o=new Error;let l=o.stack?o.stack.replace(/^.+\n/,""):"";try{h.stack?l&&!String(h.stack).endsWith(l.replace(/^.+\n.+\n/,""))&&(h.stack+=`
|
|
221
|
-
`+l):h.stack=l}catch{}}throw h}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=mh(this.defaults,r);let{transitional:h,paramsSerializer:o,headers:l}=r;h!==void 0&&qy.assertOptions(h,{silentJSONParsing:dc.transitional(dc.boolean),forcedJSONParsing:dc.transitional(dc.boolean),clarifyTimeoutError:dc.transitional(dc.boolean)},!1),o!=null&&(Ke.isFunction(o)?r.paramsSerializer={serialize:o}:qy.assertOptions(o,{encode:dc.function,serialize:dc.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let c=l&&Ke.merge(l.common,l[r.method]);l&&Ke.forEach(["delete","get","head","post","put","patch","common"],A=>{delete l[A]}),r.headers=Zn.concat(c,l);let p=[],w=!0;this.interceptors.request.forEach(function(R){typeof R.runWhen=="function"&&R.runWhen(r)===!1||(w=w&&R.synchronous,p.unshift(R.fulfilled,R.rejected))});let m=[];this.interceptors.response.forEach(function(R){m.push(R.fulfilled,R.rejected)});let y,v=0,M;if(!w){let A=[$y.bind(this),void 0];for(A.unshift.apply(A,p),A.push.apply(A,m),M=A.length,y=Promise.resolve(r);v<M;)y=y.then(A[v++],A[v++]);return y}M=p.length;let T=r;for(v=0;v<M;){let A=p[v++],R=p[v++];try{T=A(T)}catch(B){R.call(this,B);break}}try{y=$y.call(this,T)}catch(A){return Promise.reject(A)}for(v=0,M=m.length;v<M;)y=y.then(m[v++],m[v++]);return y}getUri(t){t=mh(this.defaults,t);let r=c2(t.baseURL,t.url);return a2(r,t.params,t.paramsSerializer)}};Ke.forEach(["delete","get","head","options"],function(t){$d.prototype[t]=function(r,h){return this.request(mh(h||{},{method:t,url:r,data:(h||{}).data}))}});Ke.forEach(["post","put","patch"],function(t){function r(h){return function(l,c,p){return this.request(mh(p||{},{method:t,headers:h?{"Content-Type":"multipart/form-data"}:{},url:l,data:c}))}}$d.prototype[t]=r(),$d.prototype[t+"Form"]=r(!0)});var l2=$d;Tt();Rt();xt();var p7=class i{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(l){r=l});let h=this;this.promise.then(o=>{if(!h._listeners)return;let l=h._listeners.length;for(;l-- >0;)h._listeners[l](o);h._listeners=null}),this.promise.then=o=>{let l,c=new Promise(p=>{h.subscribe(p),l=p}).then(o);return c.cancel=function(){h.unsubscribe(l)},c},t(function(l,c,p){h.reason||(h.reason=new sf(l,c,p),r(h.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new i(function(o){t=o}),cancel:t}}},gD=p7;Tt();Rt();xt();function g7(i){return function(r){return i.apply(null,r)}}Tt();Rt();xt();function m7(i){return Ke.isObject(i)&&i.isAxiosError===!0}Tt();Rt();xt();var v7={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(v7).forEach(([i,t])=>{v7[t]=i});var mD=v7;function vD(i){let t=new l2(i),r=i2(l2.prototype.request,t);return Ke.extend(r,l2.prototype,t,{allOwnKeys:!0}),Ke.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return vD(mh(i,o))},r}var Wn=vD(Nd);Wn.Axios=l2;Wn.CanceledError=sf;Wn.CancelToken=gD;Wn.isCancel=f2;Wn.VERSION=Uy;Wn.toFormData=lc;Wn.AxiosError=Nr;Wn.Cancel=Wn.CanceledError;Wn.all=function(t){return Promise.all(t)};Wn.spread=g7;Wn.isAxiosError=m7;Wn.mergeConfig=mh;Wn.AxiosHeaders=Zn;Wn.formToJSON=i=>Oy(Ke.isHTMLForm(i)?new FormData(i):i);Wn.getAdapter=Dy.getAdapter;Wn.HttpStatusCode=mD;Wn.default=Wn;var Fy=Wn;var{Axios:yLt,AxiosError:bLt,CanceledError:wLt,isCancel:_Lt,CancelToken:MLt,VERSION:SLt,all:ELt,Cancel:ALt,isAxiosError:TLt,spread:xLt,toFormData:RLt,AxiosHeaders:kLt,HttpStatusCode:ILt,formToJSON:BLt,getAdapter:OLt,mergeConfig:CLt}=Fy;Tt();Rt();xt();var _D=sc(bD(),1),y7="axios-retry";function MD(i){let t=["ERR_CANCELED","ECONNABORTED"];return i.response||!i.code||t.includes(i.code)?!1:(0,_D.default)(i)}var SD=["get","head","options"],Kht=SD.concat(["put","delete"]);function b7(i){return i.code!=="ECONNABORTED"&&(!i.response||i.response.status===429||i.response.status>=500&&i.response.status<=599)}function Hht(i){return i.config?.method?b7(i)&&SD.indexOf(i.config.method)!==-1:!1}function ED(i){return i.config?.method?b7(i)&&Kht.indexOf(i.config.method)!==-1:!1}function AD(i){return MD(i)||ED(i)}function TD(i=void 0){let t=i?.response?.headers["retry-after"];if(!t)return 0;let r=(Number(t)||0)*1e3;return r===0&&(r=(new Date(t).valueOf()||0)-Date.now()),Math.max(0,r)}function Ght(i=0,t=void 0){return Math.max(0,TD(t))}function Vht(i=0,t=void 0,r=100){let h=2**i*r,o=Math.max(h,TD(t)),l=o*.2*Math.random();return o+l}var Zht={retries:3,retryCondition:AD,retryDelay:Ght,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function Jht(i,t){return{...Zht,...t,...i[y7]}}function wD(i,t){let r=Jht(i,t||{});return r.retryCount=r.retryCount||0,r.lastRequestTime=r.lastRequestTime||Date.now(),i[y7]=r,r}function Xht(i,t){i.defaults.agent===t.agent&&delete t.agent,i.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,i.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}async function Yht(i,t){let{retries:r,retryCondition:h}=i,o=(i.retryCount||0)<r&&h(t);if(typeof o=="object")try{return await o!==!1}catch{return!1}return o}async function Qht(i,t,r,h){t.retryCount+=1;let{retryDelay:o,shouldResetTimeout:l,onRetry:c}=t,p=o(t.retryCount,r);if(Xht(i,h),!l&&h.timeout&&t.lastRequestTime){let w=Date.now()-t.lastRequestTime,m=h.timeout-w-p;if(m<=0)return Promise.reject(r);h.timeout=m}return h.transformRequest=[w=>w],await c(t.retryCount,r,h),new Promise(w=>{setTimeout(()=>w(i(h)),p)})}async function tft(i,t){i.retryCount>=i.retries&&await i.onMaxRetryTimesExceeded(t,i.retryCount)}var Il=(i,t)=>{let r=i.interceptors.request.use(o=>(wD(o,t),o[y7]?.validateResponse&&(o.validateStatus=()=>!1),o)),h=i.interceptors.response.use(null,async o=>{let{config:l}=o;if(!l)return Promise.reject(o);let c=wD(l,t);return o.response&&c.validateResponse?.(o.response)?o.response:await Yht(c,o)?Qht(i,c,o,l):(await tft(c,o),Promise.reject(o))});return{requestInterceptorId:r,responseInterceptorId:h}};Il.isNetworkError=MD;Il.isSafeRequestError=Hht;Il.isIdempotentRequestError=ED;Il.isNetworkOrIdempotentRequestError=AD;Il.exponentialDelay=Vht;Il.isRetryableError=b7;var jy=Il;Tt();Rt();xt();var G9=sc(oF(),1);Tt();Rt();xt();var o1="1.2.
|
|
221
|
+
`+l):h.stack=l}catch{}}throw h}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=mh(this.defaults,r);let{transitional:h,paramsSerializer:o,headers:l}=r;h!==void 0&&qy.assertOptions(h,{silentJSONParsing:dc.transitional(dc.boolean),forcedJSONParsing:dc.transitional(dc.boolean),clarifyTimeoutError:dc.transitional(dc.boolean)},!1),o!=null&&(Ke.isFunction(o)?r.paramsSerializer={serialize:o}:qy.assertOptions(o,{encode:dc.function,serialize:dc.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let c=l&&Ke.merge(l.common,l[r.method]);l&&Ke.forEach(["delete","get","head","post","put","patch","common"],A=>{delete l[A]}),r.headers=Zn.concat(c,l);let p=[],w=!0;this.interceptors.request.forEach(function(R){typeof R.runWhen=="function"&&R.runWhen(r)===!1||(w=w&&R.synchronous,p.unshift(R.fulfilled,R.rejected))});let m=[];this.interceptors.response.forEach(function(R){m.push(R.fulfilled,R.rejected)});let y,v=0,M;if(!w){let A=[$y.bind(this),void 0];for(A.unshift.apply(A,p),A.push.apply(A,m),M=A.length,y=Promise.resolve(r);v<M;)y=y.then(A[v++],A[v++]);return y}M=p.length;let T=r;for(v=0;v<M;){let A=p[v++],R=p[v++];try{T=A(T)}catch(B){R.call(this,B);break}}try{y=$y.call(this,T)}catch(A){return Promise.reject(A)}for(v=0,M=m.length;v<M;)y=y.then(m[v++],m[v++]);return y}getUri(t){t=mh(this.defaults,t);let r=c2(t.baseURL,t.url);return a2(r,t.params,t.paramsSerializer)}};Ke.forEach(["delete","get","head","options"],function(t){$d.prototype[t]=function(r,h){return this.request(mh(h||{},{method:t,url:r,data:(h||{}).data}))}});Ke.forEach(["post","put","patch"],function(t){function r(h){return function(l,c,p){return this.request(mh(p||{},{method:t,headers:h?{"Content-Type":"multipart/form-data"}:{},url:l,data:c}))}}$d.prototype[t]=r(),$d.prototype[t+"Form"]=r(!0)});var l2=$d;Tt();Rt();xt();var p7=class i{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(l){r=l});let h=this;this.promise.then(o=>{if(!h._listeners)return;let l=h._listeners.length;for(;l-- >0;)h._listeners[l](o);h._listeners=null}),this.promise.then=o=>{let l,c=new Promise(p=>{h.subscribe(p),l=p}).then(o);return c.cancel=function(){h.unsubscribe(l)},c},t(function(l,c,p){h.reason||(h.reason=new sf(l,c,p),r(h.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new i(function(o){t=o}),cancel:t}}},gD=p7;Tt();Rt();xt();function g7(i){return function(r){return i.apply(null,r)}}Tt();Rt();xt();function m7(i){return Ke.isObject(i)&&i.isAxiosError===!0}Tt();Rt();xt();var v7={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(v7).forEach(([i,t])=>{v7[t]=i});var mD=v7;function vD(i){let t=new l2(i),r=i2(l2.prototype.request,t);return Ke.extend(r,l2.prototype,t,{allOwnKeys:!0}),Ke.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return vD(mh(i,o))},r}var Wn=vD(Nd);Wn.Axios=l2;Wn.CanceledError=sf;Wn.CancelToken=gD;Wn.isCancel=f2;Wn.VERSION=Uy;Wn.toFormData=lc;Wn.AxiosError=Nr;Wn.Cancel=Wn.CanceledError;Wn.all=function(t){return Promise.all(t)};Wn.spread=g7;Wn.isAxiosError=m7;Wn.mergeConfig=mh;Wn.AxiosHeaders=Zn;Wn.formToJSON=i=>Oy(Ke.isHTMLForm(i)?new FormData(i):i);Wn.getAdapter=Dy.getAdapter;Wn.HttpStatusCode=mD;Wn.default=Wn;var Fy=Wn;var{Axios:yLt,AxiosError:bLt,CanceledError:wLt,isCancel:_Lt,CancelToken:MLt,VERSION:SLt,all:ELt,Cancel:ALt,isAxiosError:TLt,spread:xLt,toFormData:RLt,AxiosHeaders:kLt,HttpStatusCode:ILt,formToJSON:BLt,getAdapter:OLt,mergeConfig:CLt}=Fy;Tt();Rt();xt();var _D=sc(bD(),1),y7="axios-retry";function MD(i){let t=["ERR_CANCELED","ECONNABORTED"];return i.response||!i.code||t.includes(i.code)?!1:(0,_D.default)(i)}var SD=["get","head","options"],Kht=SD.concat(["put","delete"]);function b7(i){return i.code!=="ECONNABORTED"&&(!i.response||i.response.status===429||i.response.status>=500&&i.response.status<=599)}function Hht(i){return i.config?.method?b7(i)&&SD.indexOf(i.config.method)!==-1:!1}function ED(i){return i.config?.method?b7(i)&&Kht.indexOf(i.config.method)!==-1:!1}function AD(i){return MD(i)||ED(i)}function TD(i=void 0){let t=i?.response?.headers["retry-after"];if(!t)return 0;let r=(Number(t)||0)*1e3;return r===0&&(r=(new Date(t).valueOf()||0)-Date.now()),Math.max(0,r)}function Ght(i=0,t=void 0){return Math.max(0,TD(t))}function Vht(i=0,t=void 0,r=100){let h=2**i*r,o=Math.max(h,TD(t)),l=o*.2*Math.random();return o+l}var Zht={retries:3,retryCondition:AD,retryDelay:Ght,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function Jht(i,t){return{...Zht,...t,...i[y7]}}function wD(i,t){let r=Jht(i,t||{});return r.retryCount=r.retryCount||0,r.lastRequestTime=r.lastRequestTime||Date.now(),i[y7]=r,r}function Xht(i,t){i.defaults.agent===t.agent&&delete t.agent,i.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,i.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}async function Yht(i,t){let{retries:r,retryCondition:h}=i,o=(i.retryCount||0)<r&&h(t);if(typeof o=="object")try{return await o!==!1}catch{return!1}return o}async function Qht(i,t,r,h){t.retryCount+=1;let{retryDelay:o,shouldResetTimeout:l,onRetry:c}=t,p=o(t.retryCount,r);if(Xht(i,h),!l&&h.timeout&&t.lastRequestTime){let w=Date.now()-t.lastRequestTime,m=h.timeout-w-p;if(m<=0)return Promise.reject(r);h.timeout=m}return h.transformRequest=[w=>w],await c(t.retryCount,r,h),new Promise(w=>{setTimeout(()=>w(i(h)),p)})}async function tft(i,t){i.retryCount>=i.retries&&await i.onMaxRetryTimesExceeded(t,i.retryCount)}var Il=(i,t)=>{let r=i.interceptors.request.use(o=>(wD(o,t),o[y7]?.validateResponse&&(o.validateStatus=()=>!1),o)),h=i.interceptors.response.use(null,async o=>{let{config:l}=o;if(!l)return Promise.reject(o);let c=wD(l,t);return o.response&&c.validateResponse?.(o.response)?o.response:await Yht(c,o)?Qht(i,c,o,l):(await tft(c,o),Promise.reject(o))});return{requestInterceptorId:r,responseInterceptorId:h}};Il.isNetworkError=MD;Il.isSafeRequestError=Hht;Il.isIdempotentRequestError=ED;Il.isNetworkOrIdempotentRequestError=AD;Il.exponentialDelay=Vht;Il.isRetryableError=b7;var jy=Il;Tt();Rt();xt();var G9=sc(oF(),1);Tt();Rt();xt();var o1="1.2.1";var pa=class{logger;silent=!1;constructor({level:t="info"}={}){if(t==="none"){this.silent=!0;return}this.logger=G9.default.createLogger({level:t,name:"ar-io-sdk",version:o1,serializers:G9.default.stdSerializers})}info(t,...r){this.silent||this.logger.info(...r,t)}warn(t,...r){this.silent||this.logger.warn(...r,t)}error(t,...r){this.silent||this.logger.error(...r,t)}debug(t,...r){this.silent||this.logger.debug(...r,t)}setLogLevel(t){if(t==="none"){this.silent=!0;return}this.logger.level(t)}};var aF=({axiosConfig:i={},logger:t=new pa,retryConfig:r={retries:5,retryDelay:jy.exponentialDelay,retryCondition:h=>jy.isRetryableError(h),onRetry(h,o,l){t.error(`Retrying request ${l.url} attempt ${h}`,o)}}}={})=>{let h=Fy.create({...i,maxRedirects:0,headers:{...i.headers,"x-source-version":`${o1}`,"x-source-identifier":"ar-io-sdk"},validateStatus:()=>!0});return jy(h,r),h};Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();var wh=class extends Error{constructor(t){super(t),this.name=this.constructor.name}},O6=class extends wh{},sF=class extends wh{},Hl=class extends wh{constructor(t,r){super(`Failed request: ${t}: ${r}`)}},C6=class extends wh{},a1=class extends wh{},hF=class extends wh{constructor(){super("Invalid signer. Please provide a valid signer to interact with the contract.")}},No=class extends wh{constructor(){super("Invalid contract configuration")}},fF=class extends wh{constructor(){super("Invalid process configuration")}},s1=class extends wh{};var h1=100;async function Fqt({address:i,arweave:t,signal:r=AbortSignal.timeout(1e4)}){let h=!1,o,l=new Set;do{let c={query:`
|
|
222
222
|
{
|
|
223
223
|
transactions (
|
|
224
224
|
owners:["${i}"]
|
|
@@ -376,7 +376,7 @@ ${C}`),A.pop(),`{${W}}`}case"number":return isFinite(T)?String(T):t?t(T):"null";
|
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
|
-
}`,o=Xe.object({data:Xe.object({transactions:Xe.object({edges:Xe.array(Xe.object({node:Xe.record(Xe.any())}))})})});return l=>ci(l).chain(rn(c=>i(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:h,variables:{transactionIds:[c]}})}).then(async p=>{if(p.ok)return p.json();throw r('Error Encountered when querying gateway for transaction "%s"',c),new Error(`${p.status}: ${await p.text()}`)}).then(o.parse).then(w9t(["data","transactions","edges","0","node"])))).toPromise()}var x_t=UR(j4t(),1),get=(i="@permaweb/aoconnect")=>{let t=(0,x_t.default)(i);return t.child=r=>get(`${t.namespace}:${r}`),t.tap=(r,...h)=>x9t((...o)=>t(r,...h,...o)),t},met=({url:i,path:t})=>t?t.startsWith("/")?met({url:i,path:t.slice(1)}):(i=new URL(i),i.pathname+=t,i.toString()):i;function R_t(i){return ep(b8([]),tp((t,r)=>ep(S9t([],r.name),JR(r.value),Js(r.name,Nu,t))(t),{}),v8(t=>t.length>1?t:t[0]))(i)}function Vs(i,t){return r=>Ftt(B7t([utt(i,"name"),YR(ZR(t),utt(t,"value"),HR)]),r)}function dtt(i){return Xtt([[rm(String),V1(i)],[rm(Array),u9t(i)],[HR,q5t]])}function $0(i){let t;return rm(Zs,i)?(t=new Error(k_t(i)),t.stack+=i.stack):rm(Error,i)?t=i:s9t("message",i)?t=new Error(i.message):rm(String,i)?t=new Error(i):t=new Error("An error occurred"),t}function k_t(i){return ep(t=>function r(h,o,l){return tp((c,p)=>ep(Xtt([[V1(vr.invalid_arguments),()=>r(p.argumentsError,422,"Invalid Arguments")],[V1(vr.invalid_return_type),()=>r(p.returnTypeError,500,"Invalid Return")],[V1(vr.invalid_union),()=>G7t(w=>r(w,400,"Invalid Union"),p.unionErrors)],[HR,()=>[{...p,status:o,contextCode:l}]]]),XR(c))(p.code),[],h.issues)}(t,400,""),t=>tp((r,h)=>{let{message:o,path:l,contextCode:c}=h,p=l[1]||l[0],w=c?`${c} `:"";return r.push(`${w}'${p}': ${o}.`),r},[],t),m9t(" | "))(i)}var I_t=Xe.object({id:Xe.string().min(1,{message:"message is required to be a message id"}),processId:Xe.string().min(1,{message:"process is required to be a process id"})});function B_t(){return i=>ci(i).map(I_t.parse).map(()=>i)}var Mm=Xe.object({name:Xe.string(),value:Xe.string()}),O_t=Xe.function().args(Xe.object({Id:Xe.string(),Target:Xe.string(),Owner:Xe.string(),Anchor:Xe.string().optional(),Data:Xe.any().default("1234"),Tags:Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}))})).returns(Xe.promise(Xe.any())),C_t=Xe.function().args(Xe.object({id:Xe.string().min(1,{message:"message id is required"}),processId:Xe.string().min(1,{message:"process id is required"})})).returns(Xe.promise(Xe.any())),P_t=Xe.function().args(Xe.object({process:Xe.string().min(1,{message:"process id is required"}),from:Xe.string().optional(),to:Xe.string().optional(),sort:Xe.enum(["ASC","DESC"]).default("ASC"),limit:Xe.number().optional()})).returns(Xe.promise(Xe.object({edges:Xe.array(Xe.object({cursor:Xe.string(),node:Xe.object({Output:Xe.any().optional(),Messages:Xe.array(Xe.any()).optional(),Spawns:Xe.array(Xe.any()).optional(),Error:Xe.any().optional()})}))}))),vet=Xe.function().args(Xe.object({processId:Xe.string(),data:Xe.any(),tags:Xe.array(Mm),anchor:Xe.string().optional(),signer:Xe.any()})).returns(Xe.promise(Xe.object({messageId:Xe.string()}).passthrough())),N_t=Xe.function().args(Xe.object({data:Xe.any(),tags:Xe.array(Mm),signer:Xe.any()})).returns(Xe.promise(Xe.object({processId:Xe.string()}).passthrough())),L_t=Xe.function().args(Xe.object({process:Xe.string(),message:Xe.string(),baseLayer:Xe.boolean().optional(),exclude:Xe.array(Xe.string()).optional()})).returns(Xe.promise(Xe.object({assignmentId:Xe.string()}).passthrough())),yet=vet,qWt=Xe.function().args(Xe.object({suUrl:Xe.string().url(),processId:Xe.string()})).returns(Xe.promise(Xe.object({tags:Xe.array(Mm)}).passthrough())),FWt=Xe.function().args(Xe.string()).returns(Xe.promise(Xe.object({url:Xe.string()}))),D_t=Xe.function().args(Xe.string()).returns(Xe.promise(Xe.boolean())),$_t=Xe.function().args(Xe.string()).returns(Xe.promise(Xe.object({tags:Xe.array(Mm)}).passthrough())),w8=Xe.function().args(Xe.object({data:Xe.any(),tags:Xe.array(Mm),target:Xe.string().optional(),anchor:Xe.string().optional()})).returns(Xe.promise(Xe.object({id:Xe.string(),raw:Xe.any()})));function U_t({loadResult:i}){return i=rn(C_t.implement(i)),t=>ci({id:t.id,processId:t.processId}).chain(i)}function q_t(i){let t=B_t(i),r=U_t(i);return({message:h,process:o})=>ci({id:h,processId:o}).chain(t).chain(r).map(i.logger.tap('readResult result for message "%s": %O',h)).map(l=>l).bimap($0,D0).toPromise()}var F_t=Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}));function j_t(){return i=>ci(i.tags).map(b8([])).map(Vs("Data-Protocol","ao")).map(Vs("Variant")).map(Vs("Type")).map(Vs("SDK")).map(XR(Nu,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"},{name:"SDK",value:"aoconnect"}])).map(F_t.parse).map(Js("tags",Nu,i))}function z_t({logger:i}){return t=>ci(t).chain(YR(ZR(t.data),()=>O0(t),()=>O0(Math.random().toString().slice(-4)).map(Js("data",Nu,t)).map(r=>ep(L0("tags"),Vs("Content-Type"),JR({name:"Content-Type",value:"text/plain"}),Js("tags",Nu,r))(r)).map(i.tap('added pseudo-random string as message "data"'))))}function W_t(i){let t=j_t(i),r=z_t(i),h=vet.implement(i.deployMessage);return o=>ci(o).chain(t).chain(r).chain(rn(({id:l,data:c,tags:p,anchor:w,signer:m})=>h({processId:l,data:c,tags:p,anchor:w,signer:w8.implement(m)}))).map(l=>Js("messageId",l.messageId,o))}function K_t(i){let t=W_t(i);return({process:r,data:h,tags:o,anchor:l,signer:c})=>ci({id:r,data:h,tags:o,anchor:l,signer:c}).chain(t).map(p=>p.messageId).bimap($0,D0).toPromise()}var Xg=(i,t,r)=>h=>t(h[i])?O0(h):tl(`Tag '${i}': ${r}`);function H_t({loadTransactionMeta:i,logger:t}){return i=rn($_t.implement(i)),r=>ci(r).chain(i).map(L0("tags")).map(R_t).chain(Xg("Data-Protocol",dtt("ao"),"value 'ao' was not found on module")).chain(Xg("Type",dtt("Module"),"value 'Module' was not found on module")).chain(Xg("Module-Format",bR,"was not found on module")).chain(Xg("Input-Encoding",bR,"was not found on module")).chain(Xg("Output-Encoding",bR,"was not found on module")).bimap(t.tap("Verifying module source failed: %s"),t.tap("Verified module source"))}function G_t({logger:i,validateScheduler:t}){return t=rn(D_t.implement(t)),r=>ci(r).chain(h=>t(h).chain(o=>o?O0(h):tl(`Valid Scheduler-Location owned by ${h} not found`))).bimap(i.tap("Verifying scheduler failed: %s"),i.tap("Verified scheduler"))}function V_t({logger:i}){return t=>ci(t).map(i.tap("Checking for signer")).chain(r=>r?O0(r):tl("signer not found"))}function Z_t(i){let t=i.logger.child("verifyInput");i={...i,logger:t};let r=H_t(i),h=G_t(i),o=V_t(i);return l=>ci(l).chain(c=>r(c.module).map(()=>c)).chain(c=>h(c.scheduler)).map(()=>l).chain(c=>o(c.signer).map(()=>c)).bimap(t.tap("Error when verify input: %s"),t.tap("Successfully verified inputs"))}var J_t=Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}));function X_t(){return i=>ci(i).map(L0("tags")).map(b8([])).map(Vs("Data-Protocol","ao")).map(Vs("Variant")).map(Vs("Type")).map(Vs("Module")).map(Vs("Scheduler")).map(Vs("SDK")).map(XR(Nu,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Process"},{name:"Module",value:i.module},{name:"Scheduler",value:i.scheduler},{name:"SDK",value:"aoconnect"}])).map(J_t.parse).map(Js("tags",Nu,i))}function Y_t({logger:i}){return t=>ci(t).chain(YR(ZR(t.data),()=>O0(t),()=>O0(Math.random().toString().slice(-4)).map(Js("data",Nu,t)).map(r=>ep(L0("tags"),Vs("Content-Type"),JR({name:"Content-Type",value:"text/plain"}),Js("tags",Nu,r))(r)).map(i.tap('added pseudo-random string as process "data"'))))}function Q_t(i){let t=i.logger.child("uploadProcess");i={...i,logger:t};let r=X_t(i),h=Y_t(i),o=N_t.implement(i.deployProcess);return l=>ci(l).chain(r).chain(h).chain(rn(({data:c,tags:p,signer:w})=>o({data:c,tags:p,signer:w8.implement(w)}))).map(c=>Js("processId",c.processId,l))}function tMt(i){let t=Z_t(i),r=Q_t(i);return({module:h,scheduler:o,signer:l,tags:c,data:p})=>ci({module:h,scheduler:o,signer:l,tags:c,data:p}).chain(t).chain(r).map(w=>w.processId).bimap($0,D0).toPromise()}function eMt(i){let t=yet.implement(i.deployMonitor);return r=>ci(r).chain(rn(({id:h,signer:o})=>t({processId:h,signer:w8.implement(o),data:Math.random().toString().slice(-4),tags:[]}))).map(h=>Js("monitorId",h.messageId,r))}function rMt(i){let t=eMt(i);return({process:r,signer:h})=>ci({id:r,signer:h}).chain(t).map(o=>o.monitorId).bimap($0,D0).toPromise()}function iMt(i){let t=yet.implement(i.deployUnmonitor);return r=>ci(r).chain(rn(({id:h,signer:o})=>t({processId:h,signer:w8.implement(o),data:Math.random().toString().slice(-4),tags:[]}))).map(h=>Js("monitorId",h.messageId,r))}function nMt(i){let t=iMt(i);return({process:r,signer:h})=>ci({id:r,signer:h}).chain(t).map(o=>o.monitorId).bimap($0,D0).toPromise()}var oMt=Xe.object({process:Xe.string().min(1,{message:"process identifier is required"}),from:Xe.string().optional(),to:Xe.string().optional(),sort:Xe.enum(["ASC","DESC"]).default("ASC"),limit:Xe.number().optional()});function aMt(){return i=>ci(i).map(oMt.parse).map(()=>i)}function sMt({queryResults:i}){return i=rn(P_t.implement(i)),t=>ci({process:t.process,from:t.from,to:t.to,sort:t.sort,limit:t.limit}).chain(i)}function hMt(i){let t=aMt(i),r=sMt(i);return({process:h,from:o,to:l,sort:c,limit:p})=>ci({process:h,from:o,to:l,sort:c,limit:p}).chain(t).chain(r).map(i.logger.tap('readResults result for message "%s": %O',h)).map(w=>w).bimap($0,D0).toPromise()}var fMt=Xe.object({Id:Xe.string(),Target:Xe.string(),Owner:Xe.string(),Anchor:Xe.string().optional(),Data:Xe.any().default("1234"),Tags:Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}))});function uMt(){return i=>ci(i).map(fMt.parse).map(t=>(t.Tags=t.Tags.concat([{name:"Data-Protocol",value:"ao"},{name:"Type",value:"Message"},{name:"Variant",value:"ao.TN.1"}]),t))}function cMt({dryrunFetch:i}){return rn(O_t.implement(i))}function lMt(i){let t=uMt(i),r=cMt(i);return h=>ci(h).map(dMt).chain(t).chain(r).toPromise()}function dMt({process:i,data:t,tags:r,anchor:h,...o}){return{Id:"1234",Owner:"1234",...o,Target:i,Data:t||"1234",Tags:r||[],Anchor:h||"0"}}function pMt(i){let t=L_t.implement(i.deployAssign);return r=>ci(r).chain(rn(({process:h,message:o,baseLayer:l,exclude:c})=>t({process:h,message:o,baseLayer:l,exclude:c}))).map(h=>Js("assignmentId",h.assignmentId,r))}function gMt(i){let t=pMt(i);return({process:r,message:h,baseLayer:o,exclude:l})=>ci({process:r,message:h,baseLayer:o,exclude:l}).chain(t).map(c=>c.assignmentId).bimap($0,D0).toPromise()}var mMt="https://arweave.net",vMt="https://mu.ao-testnet.xyz",yMt="https://cu.ao-testnet.xyz";function Sm({GRAPHQL_URL:i,GATEWAY_URL:t=mMt,MU_URL:r=vMt,CU_URL:h=yMt}={}){let o=get();i||(i=met({url:t,path:"/graphql"}));let{validate:l}=Dtt({cacheSize:100,GRAPHQL_URL:i}),c=$5t({MAX_SIZE:25}),p=o.child("result"),w=q_t({loadResult:N5t({fetch,CU_URL:h,logger:p}),logger:p}),m=o.child("message"),y=K_t({loadProcessMeta:mR({fetch,cache:c,logger:m}),deployMessage:k5t({fetch,MU_URL:r,logger:m}),logger:m}),v=o.child("spawn"),M=tMt({loadTransactionMeta:T_t({fetch,GRAPHQL_URL:i,logger:v}),validateScheduler:l,deployProcess:I5t({fetch,MU_URL:r,logger:v}),logger:v}),T=o.child("monitor"),A=rMt({loadProcessMeta:mR({fetch,cache:c,logger:T}),deployMonitor:B5t({fetch,MU_URL:r,logger:T}),logger:T}),R=o.child("unmonitor"),B=nMt({loadProcessMeta:mR({fetch,cache:c,logger:R}),deployUnmonitor:O5t({fetch,MU_URL:r,logger:R}),logger:T}),C=o.child("results"),P=hMt({queryResults:L5t({fetch,CU_URL:h,logger:C}),logger:C}),N=o.child("dryrun"),q=lMt({dryrunFetch:P5t({fetch,CU_URL:h,logger:N}),logger:N}),W=o.child("assign"),J=gMt({deployAssign:C5t({fetch,MU_URL:r,logger:W}),logger:m});return{result:w,results:P,message:y,spawn:M,monitor:A,unmonitor:B,dryrun:q,assign:J}}var bet={};mtt(bet,{createDataItemSigner:()=>zMt});var wet=UR(K4t(),1),_et={};mtt(_et,{AVSCTap:()=>Em,ArweaveSigner:()=>rk,DataItem:()=>ym,MAX_TAG_BYTES:()=>_8,MIN_BINARY_SIZE:()=>ok,SIG_CONFIG:()=>op,SignatureConfig:()=>Gs,Signer:()=>Tet,createData:()=>Iet,default:()=>qMt,deserializeTags:()=>l8,indexToType:()=>ik,serializeTags:()=>nk,tagsExceedLimit:()=>ket,warparbundles:()=>FMt});var bMt=Object.create,tk=Object.defineProperty,wMt=Object.getOwnPropertyDescriptor,_Mt=Object.getOwnPropertyNames,MMt=Object.getPrototypeOf,SMt=Object.prototype.hasOwnProperty,Du=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),EMt=(i,t)=>{for(var r in t)tk(i,r,{get:t[r],enumerable:!0})},AMt=(i,t,r,h)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _Mt(t))!SMt.call(i,o)&&o!==r&&tk(i,o,{get:()=>t[o],enumerable:!(h=wMt(t,o))||h.enumerable});return i},U0=(i,t,r)=>(r=i!=null?bMt(MMt(i)):{},AMt(t||!i||!i.__esModule?tk(r,"default",{value:i,enumerable:!0}):r,i)),TMt=Du(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});function t(r){var h=4,o=r.length,l=o%h;if(!l)return r;var c=o,p=h-l,w=o+p,m=ge.alloc(w);for(m.write(r);p--;)m.write("=",c++);return m.toString()}i.default=t}),xMt=Du(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var t=TMt();function r(w,m){return m===void 0&&(m="utf8"),ge.isBuffer(w)?l(w.toString("base64")):l(ge.from(w,m).toString("base64"))}function h(w,m){return m===void 0&&(m="utf8"),ge.from(o(w),"base64").toString(m)}function o(w){return w=w.toString(),t.default(w).replace(/\-/g,"+").replace(/_/g,"/")}function l(w){return w.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function c(w){return ge.from(o(w),"base64")}var p=r;p.encode=r,p.decode=h,p.toBase64=o,p.fromBase64=l,p.toBuffer=c,i.default=p}),ek=Du((i,t)=>{t.exports=xMt().default,t.exports.default=t.exports}),Met=Du(i=>{"use strict";i.byteLength=w,i.toByteArray=y,i.fromByteArray=T;var t=[],r=[],h=typeof Uint8Array<"u"?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(l=0,c=o.length;l<c;++l)t[l]=o[l],r[o.charCodeAt(l)]=l;var l,c;r[45]=62,r[95]=63;function p(A){var R=A.length;if(R%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=A.indexOf("=");B===-1&&(B=R);var C=B===R?0:4-B%4;return[B,C]}function w(A){var R=p(A),B=R[0],C=R[1];return(B+C)*3/4-C}function m(A,R,B){return(R+B)*3/4-B}function y(A){var R,B=p(A),C=B[0],P=B[1],N=new h(m(A,C,P)),q=0,W=P>0?C-4:C,J;for(J=0;J<W;J+=4)R=r[A.charCodeAt(J)]<<18|r[A.charCodeAt(J+1)]<<12|r[A.charCodeAt(J+2)]<<6|r[A.charCodeAt(J+3)],N[q++]=R>>16&255,N[q++]=R>>8&255,N[q++]=R&255;return P===2&&(R=r[A.charCodeAt(J)]<<2|r[A.charCodeAt(J+1)]>>4,N[q++]=R&255),P===1&&(R=r[A.charCodeAt(J)]<<10|r[A.charCodeAt(J+1)]<<4|r[A.charCodeAt(J+2)]>>2,N[q++]=R>>8&255,N[q++]=R&255),N}function v(A){return t[A>>18&63]+t[A>>12&63]+t[A>>6&63]+t[A&63]}function M(A,R,B){for(var C,P=[],N=R;N<B;N+=3)C=(A[N]<<16&16711680)+(A[N+1]<<8&65280)+(A[N+2]&255),P.push(v(C));return P.join("")}function T(A){for(var R,B=A.length,C=B%3,P=[],N=16383,q=0,W=B-C;q<W;q+=N)P.push(M(A,q,q+N>W?W:q+N));return C===1?(R=A[B-1],P.push(t[R>>2]+t[R<<4&63]+"==")):C===2&&(R=(A[B-2]<<8)+A[B-1],P.push(t[R>>10]+t[R>>4&63]+t[R<<2&63]+"=")),P.join("")}}),Eet=Du(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.b64UrlDecode=i.b64UrlEncode=i.bufferTob64Url=i.bufferTob64=i.b64UrlToBuffer=i.stringToB64Url=i.stringToBuffer=i.bufferToString=i.b64UrlToString=i.concatBuffers=void 0;var t=Met();function r(M){let T=0;for(let B=0;B<M.length;B++)T+=M[B].byteLength;let A=new Uint8Array(T),R=0;A.set(new Uint8Array(M[0]),R),R+=M[0].byteLength;for(let B=1;B<M.length;B++)A.set(new Uint8Array(M[B]),R),R+=M[B].byteLength;return A}i.concatBuffers=r;function h(M){let T=p(M);return o(T)}i.b64UrlToString=h;function o(M){return new TextDecoder("utf-8",{fatal:!0}).decode(M)}i.bufferToString=o;function l(M){return new TextEncoder().encode(M)}i.stringToBuffer=l;function c(M){return m(l(M))}i.stringToB64Url=c;function p(M){return new Uint8Array(t.toByteArray(v(M)))}i.b64UrlToBuffer=p;function w(M){return t.fromByteArray(new Uint8Array(M))}i.bufferTob64=w;function m(M){return y(w(M))}i.bufferTob64Url=m;function y(M){return M.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}i.b64UrlEncode=y;function v(M){M=M.replace(/\-/g,"+").replace(/\_/g,"/");let T;return M.length%4==0?T=0:T=4-M.length%4,M.concat("=".repeat(T))}i.b64UrlDecode=v}),RMt=Du(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var t=Eet(),r=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 h=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),o=await this.driver.exportKey("jwk",h.privateKey);return{kty:o.kty,e:o.e,n:o.n,d:o.d,p:o.p,q:o.q,dp:o.dp,dq:o.dq,qi:o.qi}}async sign(h,o,{saltLength:l}={}){let c=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(h),o);return new Uint8Array(c)}async hash(h,o="SHA-256"){let l=await this.driver.digest(o,h);return new Uint8Array(l)}async verify(h,o,l){let c={kty:"RSA",e:"AQAB",n:h},p=await this.jwkToPublicCryptoKey(c),w=await this.driver.digest("SHA-256",o),m=await this.driver.verify({name:"RSA-PSS",saltLength:0},p,l,o),y=await this.driver.verify({name:"RSA-PSS",saltLength:32},p,l,o),v=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((p.algorithm.modulusLength-1)/8)-w.byteLength-2},p,l,o);return m||y||v}async jwkToCryptoKey(h){return this.driver.importKey("jwk",h,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(h){return this.driver.importKey("jwk",h,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let h=crypto?.subtle;return h===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(o=>typeof h[o]=="function")}async encrypt(h,o,l){let c=await this.driver.importKey("raw",typeof o=="string"?t.stringToBuffer(o):o,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:l?t.stringToBuffer(l):t.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),w=new Uint8Array(16);crypto.getRandomValues(w);let m=await this.driver.encrypt({name:"AES-CBC",iv:w},p,h);return t.concatBuffers([w,m])}async decrypt(h,o,l){let c=await this.driver.importKey("raw",typeof o=="string"?t.stringToBuffer(o):o,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:l?t.stringToBuffer(l):t.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),w=h.slice(0,16),m=await this.driver.decrypt({name:"AES-CBC",iv:w},p,h.slice(16));return t.concatBuffers([m])}};i.default=r}),kMt=Du(i=>{i.read=function(t,r,h,o,l){var c,p,w=l*8-o-1,m=(1<<w)-1,y=m>>1,v=-7,M=h?l-1:0,T=h?-1:1,A=t[r+M];for(M+=T,c=A&(1<<-v)-1,A>>=-v,v+=w;v>0;c=c*256+t[r+M],M+=T,v-=8);for(p=c&(1<<-v)-1,c>>=-v,v+=o;v>0;p=p*256+t[r+M],M+=T,v-=8);if(c===0)c=1-y;else{if(c===m)return p?NaN:(A?-1:1)*(1/0);p=p+Math.pow(2,o),c=c-y}return(A?-1:1)*p*Math.pow(2,c-o)},i.write=function(t,r,h,o,l,c){var p,w,m,y=c*8-l-1,v=(1<<y)-1,M=v>>1,T=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=o?0:c-1,R=o?1:-1,B=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(w=isNaN(r)?1:0,p=v):(p=Math.floor(Math.log(r)/Math.LN2),r*(m=Math.pow(2,-p))<1&&(p--,m*=2),p+M>=1?r+=T/m:r+=T*Math.pow(2,1-M),r*m>=2&&(p++,m/=2),p+M>=v?(w=0,p=v):p+M>=1?(w=(r*m-1)*Math.pow(2,l),p=p+M):(w=r*Math.pow(2,M-1)*Math.pow(2,l),p=0));l>=8;t[h+A]=w&255,A+=R,w/=256,l-=8);for(p=p<<l|w,y+=l;y>0;t[h+A]=p&255,A+=R,p/=256,y-=8);t[h+A-R]|=B*128}}),LR=Du(i=>{"use strict";var t=Met(),r=kMt(),h=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=p,i.SlowBuffer=P,i.INSPECT_MAX_BYTES=50;var o=2147483647;i.kMaxLength=o,p.TYPED_ARRAY_SUPPORT=l(),!p.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{let I=new Uint8Array(1),O={foo:function(){return 42}};return Object.setPrototypeOf(O,Uint8Array.prototype),Object.setPrototypeOf(I,O),I.foo()===42}catch{return!1}}Object.defineProperty(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}}),Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}});function c(I){if(I>o)throw new RangeError('The value "'+I+'" is invalid for option "size"');let O=new Uint8Array(I);return Object.setPrototypeOf(O,p.prototype),O}function p(I,O,L){if(typeof I=="number"){if(typeof O=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(I)}return w(I,O,L)}p.poolSize=8192;function w(I,O,L){if(typeof I=="string")return M(I,O);if(ArrayBuffer.isView(I))return A(I);if(I==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof I);if(mt(I,ArrayBuffer)||I&&mt(I.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(I,SharedArrayBuffer)||I&&mt(I.buffer,SharedArrayBuffer)))return R(I,O,L);if(typeof I=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let V=I.valueOf&&I.valueOf();if(V!=null&&V!==I)return p.from(V,O,L);let st=B(I);if(st)return st;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof I[Symbol.toPrimitive]=="function")return p.from(I[Symbol.toPrimitive]("string"),O,L);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof I)}p.from=function(I,O,L){return w(I,O,L)},Object.setPrototypeOf(p.prototype,Uint8Array.prototype),Object.setPrototypeOf(p,Uint8Array);function m(I){if(typeof I!="number")throw new TypeError('"size" argument must be of type number');if(I<0)throw new RangeError('The value "'+I+'" is invalid for option "size"')}function y(I,O,L){return m(I),I<=0?c(I):O!==void 0?typeof L=="string"?c(I).fill(O,L):c(I).fill(O):c(I)}p.alloc=function(I,O,L){return y(I,O,L)};function v(I){return m(I),c(I<0?0:C(I)|0)}p.allocUnsafe=function(I){return v(I)},p.allocUnsafeSlow=function(I){return v(I)};function M(I,O){if((typeof O!="string"||O==="")&&(O="utf8"),!p.isEncoding(O))throw new TypeError("Unknown encoding: "+O);let L=N(I,O)|0,V=c(L),st=V.write(I,O);return st!==L&&(V=V.slice(0,st)),V}function T(I){let O=I.length<0?0:C(I.length)|0,L=c(O);for(let V=0;V<O;V+=1)L[V]=I[V]&255;return L}function A(I){if(mt(I,Uint8Array)){let O=new Uint8Array(I);return R(O.buffer,O.byteOffset,O.byteLength)}return T(I)}function R(I,O,L){if(O<0||I.byteLength<O)throw new RangeError('"offset" is outside of buffer bounds');if(I.byteLength<O+(L||0))throw new RangeError('"length" is outside of buffer bounds');let V;return O===void 0&&L===void 0?V=new Uint8Array(I):L===void 0?V=new Uint8Array(I,O):V=new Uint8Array(I,O,L),Object.setPrototypeOf(V,p.prototype),V}function B(I){if(p.isBuffer(I)){let O=C(I.length)|0,L=c(O);return L.length===0||I.copy(L,0,0,O),L}if(I.length!==void 0)return typeof I.length!="number"||wt(I.length)?c(0):T(I);if(I.type==="Buffer"&&Array.isArray(I.data))return T(I.data)}function C(I){if(I>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return I|0}function P(I){return+I!=I&&(I=0),p.alloc(+I)}p.isBuffer=function(I){return I!=null&&I._isBuffer===!0&&I!==p.prototype},p.compare=function(I,O){if(mt(I,Uint8Array)&&(I=p.from(I,I.offset,I.byteLength)),mt(O,Uint8Array)&&(O=p.from(O,O.offset,O.byteLength)),!p.isBuffer(I)||!p.isBuffer(O))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(I===O)return 0;let L=I.length,V=O.length;for(let st=0,ft=Math.min(L,V);st<ft;++st)if(I[st]!==O[st]){L=I[st],V=O[st];break}return L<V?-1:V<L?1:0},p.isEncoding=function(I){switch(String(I).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},p.concat=function(I,O){if(!Array.isArray(I))throw new TypeError('"list" argument must be an Array of Buffers');if(I.length===0)return p.alloc(0);let L;if(O===void 0)for(O=0,L=0;L<I.length;++L)O+=I[L].length;let V=p.allocUnsafe(O),st=0;for(L=0;L<I.length;++L){let ft=I[L];if(mt(ft,Uint8Array))st+ft.length>V.length?(p.isBuffer(ft)||(ft=p.from(ft)),ft.copy(V,st)):Uint8Array.prototype.set.call(V,ft,st);else if(p.isBuffer(ft))ft.copy(V,st);else throw new TypeError('"list" argument must be an Array of Buffers');st+=ft.length}return V};function N(I,O){if(p.isBuffer(I))return I.length;if(ArrayBuffer.isView(I)||mt(I,ArrayBuffer))return I.byteLength;if(typeof I!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof I);let L=I.length,V=arguments.length>2&&arguments[2]===!0;if(!V&&L===0)return 0;let st=!1;for(;;)switch(O){case"ascii":case"latin1":case"binary":return L;case"utf8":case"utf-8":return ut(I).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L*2;case"hex":return L>>>1;case"base64":return bt(I).length;default:if(st)return V?-1:ut(I).length;O=(""+O).toLowerCase(),st=!0}}p.byteLength=N;function q(I,O,L){let V=!1;if((O===void 0||O<0)&&(O=0),O>this.length||((L===void 0||L>this.length)&&(L=this.length),L<=0)||(L>>>=0,O>>>=0,L<=O))return"";for(I||(I="utf8");;)switch(I){case"hex":return e(this,O,L);case"utf8":case"utf-8":return d(this,O,L);case"ascii":return x(this,O,L);case"latin1":case"binary":return a(this,O,L);case"base64":return f(this,O,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u(this,O,L);default:if(V)throw new TypeError("Unknown encoding: "+I);I=(I+"").toLowerCase(),V=!0}}p.prototype._isBuffer=!0;function W(I,O,L){let V=I[O];I[O]=I[L],I[L]=V}p.prototype.swap16=function(){let I=this.length;if(I%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let O=0;O<I;O+=2)W(this,O,O+1);return this},p.prototype.swap32=function(){let I=this.length;if(I%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let O=0;O<I;O+=4)W(this,O,O+3),W(this,O+1,O+2);return this},p.prototype.swap64=function(){let I=this.length;if(I%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let O=0;O<I;O+=8)W(this,O,O+7),W(this,O+1,O+6),W(this,O+2,O+5),W(this,O+3,O+4);return this},p.prototype.toString=function(){let I=this.length;return I===0?"":arguments.length===0?d(this,0,I):q.apply(this,arguments)},p.prototype.toLocaleString=p.prototype.toString,p.prototype.equals=function(I){if(!p.isBuffer(I))throw new TypeError("Argument must be a Buffer");return this===I?!0:p.compare(this,I)===0},p.prototype.inspect=function(){let I="",O=i.INSPECT_MAX_BYTES;return I=this.toString("hex",0,O).replace(/(.{2})/g,"$1 ").trim(),this.length>O&&(I+=" ... "),"<Buffer "+I+">"},h&&(p.prototype[h]=p.prototype.inspect),p.prototype.compare=function(I,O,L,V,st){if(mt(I,Uint8Array)&&(I=p.from(I,I.offset,I.byteLength)),!p.isBuffer(I))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof I);if(O===void 0&&(O=0),L===void 0&&(L=I?I.length:0),V===void 0&&(V=0),st===void 0&&(st=this.length),O<0||L>I.length||V<0||st>this.length)throw new RangeError("out of range index");if(V>=st&&O>=L)return 0;if(V>=st)return-1;if(O>=L)return 1;if(O>>>=0,L>>>=0,V>>>=0,st>>>=0,this===I)return 0;let ft=st-V,ht=L-O,Et=Math.min(ft,ht),_t=this.slice(V,st),vt=I.slice(O,L);for(let Qt=0;Qt<Et;++Qt)if(_t[Qt]!==vt[Qt]){ft=_t[Qt],ht=vt[Qt];break}return ft<ht?-1:ht<ft?1:0};function J(I,O,L,V,st){if(I.length===0)return-1;if(typeof L=="string"?(V=L,L=0):L>2147483647?L=2147483647:L<-2147483648&&(L=-2147483648),L=+L,wt(L)&&(L=st?0:I.length-1),L<0&&(L=I.length+L),L>=I.length){if(st)return-1;L=I.length-1}else if(L<0)if(st)L=0;else return-1;if(typeof O=="string"&&(O=p.from(O,V)),p.isBuffer(O))return O.length===0?-1:F(I,O,L,V,st);if(typeof O=="number")return O=O&255,typeof Uint8Array.prototype.indexOf=="function"?st?Uint8Array.prototype.indexOf.call(I,O,L):Uint8Array.prototype.lastIndexOf.call(I,O,L):F(I,[O],L,V,st);throw new TypeError("val must be string, number or Buffer")}function F(I,O,L,V,st){let ft=1,ht=I.length,Et=O.length;if(V!==void 0&&(V=String(V).toLowerCase(),V==="ucs2"||V==="ucs-2"||V==="utf16le"||V==="utf-16le")){if(I.length<2||O.length<2)return-1;ft=2,ht/=2,Et/=2,L/=2}function _t(Qt,It){return ft===1?Qt[It]:Qt.readUInt16BE(It*ft)}let vt;if(st){let Qt=-1;for(vt=L;vt<ht;vt++)if(_t(I,vt)===_t(O,Qt===-1?0:vt-Qt)){if(Qt===-1&&(Qt=vt),vt-Qt+1===Et)return Qt*ft}else Qt!==-1&&(vt-=vt-Qt),Qt=-1}else for(L+Et>ht&&(L=ht-Et),vt=L;vt>=0;vt--){let Qt=!0;for(let It=0;It<Et;It++)if(_t(I,vt+It)!==_t(O,It)){Qt=!1;break}if(Qt)return vt}return-1}p.prototype.includes=function(I,O,L){return this.indexOf(I,O,L)!==-1},p.prototype.indexOf=function(I,O,L){return J(this,I,O,L,!0)},p.prototype.lastIndexOf=function(I,O,L){return J(this,I,O,L,!1)};function H(I,O,L,V){L=Number(L)||0;let st=I.length-L;V?(V=Number(V),V>st&&(V=st)):V=st;let ft=O.length;V>ft/2&&(V=ft/2);let ht;for(ht=0;ht<V;++ht){let Et=parseInt(O.substr(ht*2,2),16);if(wt(Et))return ht;I[L+ht]=Et}return ht}function Y(I,O,L,V){return lt(ut(O,I.length-L),I,L,V)}function E(I,O,L,V){return lt(pt(O),I,L,V)}function n(I,O,L,V){return lt(bt(O),I,L,V)}function s(I,O,L,V){return lt(St(O,I.length-L),I,L,V)}p.prototype.write=function(I,O,L,V){if(O===void 0)V="utf8",L=this.length,O=0;else if(L===void 0&&typeof O=="string")V=O,L=this.length,O=0;else if(isFinite(O))O=O>>>0,isFinite(L)?(L=L>>>0,V===void 0&&(V="utf8")):(V=L,L=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let st=this.length-O;if((L===void 0||L>st)&&(L=st),I.length>0&&(L<0||O<0)||O>this.length)throw new RangeError("Attempt to write outside buffer bounds");V||(V="utf8");let ft=!1;for(;;)switch(V){case"hex":return H(this,I,O,L);case"utf8":case"utf-8":return Y(this,I,O,L);case"ascii":case"latin1":case"binary":return E(this,I,O,L);case"base64":return n(this,I,O,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s(this,I,O,L);default:if(ft)throw new TypeError("Unknown encoding: "+V);V=(""+V).toLowerCase(),ft=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function f(I,O,L){return O===0&&L===I.length?t.fromByteArray(I):t.fromByteArray(I.slice(O,L))}function d(I,O,L){L=Math.min(I.length,L);let V=[],st=O;for(;st<L;){let ft=I[st],ht=null,Et=ft>239?4:ft>223?3:ft>191?2:1;if(st+Et<=L){let _t,vt,Qt,It;switch(Et){case 1:ft<128&&(ht=ft);break;case 2:_t=I[st+1],(_t&192)===128&&(It=(ft&31)<<6|_t&63,It>127&&(ht=It));break;case 3:_t=I[st+1],vt=I[st+2],(_t&192)===128&&(vt&192)===128&&(It=(ft&15)<<12|(_t&63)<<6|vt&63,It>2047&&(It<55296||It>57343)&&(ht=It));break;case 4:_t=I[st+1],vt=I[st+2],Qt=I[st+3],(_t&192)===128&&(vt&192)===128&&(Qt&192)===128&&(It=(ft&15)<<18|(_t&63)<<12|(vt&63)<<6|Qt&63,It>65535&&It<1114112&&(ht=It))}}ht===null?(ht=65533,Et=1):ht>65535&&(ht-=65536,V.push(ht>>>10&1023|55296),ht=56320|ht&1023),V.push(ht),st+=Et}return S(V)}var g=4096;function S(I){let O=I.length;if(O<=g)return String.fromCharCode.apply(String,I);let L="",V=0;for(;V<O;)L+=String.fromCharCode.apply(String,I.slice(V,V+=g));return L}function x(I,O,L){let V="";L=Math.min(I.length,L);for(let st=O;st<L;++st)V+=String.fromCharCode(I[st]&127);return V}function a(I,O,L){let V="";L=Math.min(I.length,L);for(let st=O;st<L;++st)V+=String.fromCharCode(I[st]);return V}function e(I,O,L){let V=I.length;(!O||O<0)&&(O=0),(!L||L<0||L>V)&&(L=V);let st="";for(let ft=O;ft<L;++ft)st+=Mt[I[ft]];return st}function u(I,O,L){let V=I.slice(O,L),st="";for(let ft=0;ft<V.length-1;ft+=2)st+=String.fromCharCode(V[ft]+V[ft+1]*256);return st}p.prototype.slice=function(I,O){let L=this.length;I=~~I,O=O===void 0?L:~~O,I<0?(I+=L,I<0&&(I=0)):I>L&&(I=L),O<0?(O+=L,O<0&&(O=0)):O>L&&(O=L),O<I&&(O=I);let V=this.subarray(I,O);return Object.setPrototypeOf(V,p.prototype),V};function b(I,O,L){if(I%1!==0||I<0)throw new RangeError("offset is not uint");if(I+O>L)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I],st=1,ft=0;for(;++ft<O&&(st*=256);)V+=this[I+ft]*st;return V},p.prototype.readUintBE=p.prototype.readUIntBE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I+--O],st=1;for(;O>0&&(st*=256);)V+=this[I+--O]*st;return V},p.prototype.readUint8=p.prototype.readUInt8=function(I,O){return I=I>>>0,O||b(I,1,this.length),this[I]},p.prototype.readUint16LE=p.prototype.readUInt16LE=function(I,O){return I=I>>>0,O||b(I,2,this.length),this[I]|this[I+1]<<8},p.prototype.readUint16BE=p.prototype.readUInt16BE=function(I,O){return I=I>>>0,O||b(I,2,this.length),this[I]<<8|this[I+1]},p.prototype.readUint32LE=p.prototype.readUInt32LE=function(I,O){return I=I>>>0,O||b(I,4,this.length),(this[I]|this[I+1]<<8|this[I+2]<<16)+this[I+3]*16777216},p.prototype.readUint32BE=p.prototype.readUInt32BE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]*16777216+(this[I+1]<<16|this[I+2]<<8|this[I+3])},p.prototype.readBigUInt64LE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=O+this[++I]*2**8+this[++I]*2**16+this[++I]*2**24,st=this[++I]+this[++I]*2**8+this[++I]*2**16+L*2**24;return BigInt(V)+(BigInt(st)<<BigInt(32))}),p.prototype.readBigUInt64BE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=O*2**24+this[++I]*2**16+this[++I]*2**8+this[++I],st=this[++I]*2**24+this[++I]*2**16+this[++I]*2**8+L;return(BigInt(V)<<BigInt(32))+BigInt(st)}),p.prototype.readIntLE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I],st=1,ft=0;for(;++ft<O&&(st*=256);)V+=this[I+ft]*st;return st*=128,V>=st&&(V-=Math.pow(2,8*O)),V},p.prototype.readIntBE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=O,st=1,ft=this[I+--V];for(;V>0&&(st*=256);)ft+=this[I+--V]*st;return st*=128,ft>=st&&(ft-=Math.pow(2,8*O)),ft},p.prototype.readInt8=function(I,O){return I=I>>>0,O||b(I,1,this.length),this[I]&128?(255-this[I]+1)*-1:this[I]},p.prototype.readInt16LE=function(I,O){I=I>>>0,O||b(I,2,this.length);let L=this[I]|this[I+1]<<8;return L&32768?L|4294901760:L},p.prototype.readInt16BE=function(I,O){I=I>>>0,O||b(I,2,this.length);let L=this[I+1]|this[I]<<8;return L&32768?L|4294901760:L},p.prototype.readInt32LE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]|this[I+1]<<8|this[I+2]<<16|this[I+3]<<24},p.prototype.readInt32BE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]<<24|this[I+1]<<16|this[I+2]<<8|this[I+3]},p.prototype.readBigInt64LE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=this[I+4]+this[I+5]*2**8+this[I+6]*2**16+(L<<24);return(BigInt(V)<<BigInt(32))+BigInt(O+this[++I]*2**8+this[++I]*2**16+this[++I]*2**24)}),p.prototype.readBigInt64BE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=(O<<24)+this[++I]*2**16+this[++I]*2**8+this[++I];return(BigInt(V)<<BigInt(32))+BigInt(this[++I]*2**24+this[++I]*2**16+this[++I]*2**8+L)}),p.prototype.readFloatLE=function(I,O){return I=I>>>0,O||b(I,4,this.length),r.read(this,I,!0,23,4)},p.prototype.readFloatBE=function(I,O){return I=I>>>0,O||b(I,4,this.length),r.read(this,I,!1,23,4)},p.prototype.readDoubleLE=function(I,O){return I=I>>>0,O||b(I,8,this.length),r.read(this,I,!0,52,8)},p.prototype.readDoubleBE=function(I,O){return I=I>>>0,O||b(I,8,this.length),r.read(this,I,!1,52,8)};function _(I,O,L,V,st,ft){if(!p.isBuffer(I))throw new TypeError('"buffer" argument must be a Buffer instance');if(O>st||O<ft)throw new RangeError('"value" argument is out of bounds');if(L+V>I.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(I,O,L,V){if(I=+I,O=O>>>0,L=L>>>0,!V){let ht=Math.pow(2,8*L)-1;_(this,I,O,L,ht,0)}let st=1,ft=0;for(this[O]=I&255;++ft<L&&(st*=256);)this[O+ft]=I/st&255;return O+L},p.prototype.writeUintBE=p.prototype.writeUIntBE=function(I,O,L,V){if(I=+I,O=O>>>0,L=L>>>0,!V){let ht=Math.pow(2,8*L)-1;_(this,I,O,L,ht,0)}let st=L-1,ft=1;for(this[O+st]=I&255;--st>=0&&(ft*=256);)this[O+st]=I/ft&255;return O+L},p.prototype.writeUint8=p.prototype.writeUInt8=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,1,255,0),this[O]=I&255,O+1},p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,65535,0),this[O]=I&255,this[O+1]=I>>>8,O+2},p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,65535,0),this[O]=I>>>8,this[O+1]=I&255,O+2},p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,4294967295,0),this[O+3]=I>>>24,this[O+2]=I>>>16,this[O+1]=I>>>8,this[O]=I&255,O+4},p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,4294967295,0),this[O]=I>>>24,this[O+1]=I>>>16,this[O+2]=I>>>8,this[O+3]=I&255,O+4};function k(I,O,L,V,st){U(O,V,st,I,L,7);let ft=Number(O&BigInt(4294967295));I[L++]=ft,ft=ft>>8,I[L++]=ft,ft=ft>>8,I[L++]=ft,ft=ft>>8,I[L++]=ft;let ht=Number(O>>BigInt(32)&BigInt(4294967295));return I[L++]=ht,ht=ht>>8,I[L++]=ht,ht=ht>>8,I[L++]=ht,ht=ht>>8,I[L++]=ht,L}function $(I,O,L,V,st){U(O,V,st,I,L,7);let ft=Number(O&BigInt(4294967295));I[L+7]=ft,ft=ft>>8,I[L+6]=ft,ft=ft>>8,I[L+5]=ft,ft=ft>>8,I[L+4]=ft;let ht=Number(O>>BigInt(32)&BigInt(4294967295));return I[L+3]=ht,ht=ht>>8,I[L+2]=ht,ht=ht>>8,I[L+1]=ht,ht=ht>>8,I[L]=ht,L+8}p.prototype.writeBigUInt64LE=ne(function(I,O=0){return k(this,I,O,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeBigUInt64BE=ne(function(I,O=0){return $(this,I,O,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeIntLE=function(I,O,L,V){if(I=+I,O=O>>>0,!V){let Et=Math.pow(2,8*L-1);_(this,I,O,L,Et-1,-Et)}let st=0,ft=1,ht=0;for(this[O]=I&255;++st<L&&(ft*=256);)I<0&&ht===0&&this[O+st-1]!==0&&(ht=1),this[O+st]=(I/ft>>0)-ht&255;return O+L},p.prototype.writeIntBE=function(I,O,L,V){if(I=+I,O=O>>>0,!V){let Et=Math.pow(2,8*L-1);_(this,I,O,L,Et-1,-Et)}let st=L-1,ft=1,ht=0;for(this[O+st]=I&255;--st>=0&&(ft*=256);)I<0&&ht===0&&this[O+st+1]!==0&&(ht=1),this[O+st]=(I/ft>>0)-ht&255;return O+L},p.prototype.writeInt8=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,1,127,-128),I<0&&(I=255+I+1),this[O]=I&255,O+1},p.prototype.writeInt16LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,32767,-32768),this[O]=I&255,this[O+1]=I>>>8,O+2},p.prototype.writeInt16BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,32767,-32768),this[O]=I>>>8,this[O+1]=I&255,O+2},p.prototype.writeInt32LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,2147483647,-2147483648),this[O]=I&255,this[O+1]=I>>>8,this[O+2]=I>>>16,this[O+3]=I>>>24,O+4},p.prototype.writeInt32BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,2147483647,-2147483648),I<0&&(I=4294967295+I+1),this[O]=I>>>24,this[O+1]=I>>>16,this[O+2]=I>>>8,this[O+3]=I&255,O+4},p.prototype.writeBigInt64LE=ne(function(I,O=0){return k(this,I,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),p.prototype.writeBigInt64BE=ne(function(I,O=0){return $(this,I,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function it(I,O,L,V,st,ft){if(L+V>I.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("Index out of range")}function Z(I,O,L,V,st){return O=+O,L=L>>>0,st||it(I,O,L,4,34028234663852886e22,-34028234663852886e22),r.write(I,O,L,V,23,4),L+4}p.prototype.writeFloatLE=function(I,O,L){return Z(this,I,O,!0,L)},p.prototype.writeFloatBE=function(I,O,L){return Z(this,I,O,!1,L)};function et(I,O,L,V,st){return O=+O,L=L>>>0,st||it(I,O,L,8,17976931348623157e292,-17976931348623157e292),r.write(I,O,L,V,52,8),L+8}p.prototype.writeDoubleLE=function(I,O,L){return et(this,I,O,!0,L)},p.prototype.writeDoubleBE=function(I,O,L){return et(this,I,O,!1,L)},p.prototype.copy=function(I,O,L,V){if(!p.isBuffer(I))throw new TypeError("argument should be a Buffer");if(L||(L=0),!V&&V!==0&&(V=this.length),O>=I.length&&(O=I.length),O||(O=0),V>0&&V<L&&(V=L),V===L||I.length===0||this.length===0)return 0;if(O<0)throw new RangeError("targetStart out of bounds");if(L<0||L>=this.length)throw new RangeError("Index out of range");if(V<0)throw new RangeError("sourceEnd out of bounds");V>this.length&&(V=this.length),I.length-O<V-L&&(V=I.length-O+L);let st=V-L;return this===I&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(O,L,V):Uint8Array.prototype.set.call(I,this.subarray(L,V),O),st},p.prototype.fill=function(I,O,L,V){if(typeof I=="string"){if(typeof O=="string"?(V=O,O=0,L=this.length):typeof L=="string"&&(V=L,L=this.length),V!==void 0&&typeof V!="string")throw new TypeError("encoding must be a string");if(typeof V=="string"&&!p.isEncoding(V))throw new TypeError("Unknown encoding: "+V);if(I.length===1){let ft=I.charCodeAt(0);(V==="utf8"&&ft<128||V==="latin1")&&(I=ft)}}else typeof I=="number"?I=I&255:typeof I=="boolean"&&(I=Number(I));if(O<0||this.length<O||this.length<L)throw new RangeError("Out of range index");if(L<=O)return this;O=O>>>0,L=L===void 0?this.length:L>>>0,I||(I=0);let st;if(typeof I=="number")for(st=O;st<L;++st)this[st]=I;else{let ft=p.isBuffer(I)?I:p.from(I,V),ht=ft.length;if(ht===0)throw new TypeError('The value "'+I+'" is invalid for argument "value"');for(st=0;st<L-O;++st)this[st+O]=ft[st%ht]}return this};var Q={};function z(I,O,L){Q[I]=class extends L{constructor(){super(),Object.defineProperty(this,"message",{value:O.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${I}]`,this.stack,delete this.name}get code(){return I}set code(V){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:V,writable:!0})}toString(){return`${this.name} [${I}]: ${this.message}`}}}z("ERR_BUFFER_OUT_OF_BOUNDS",function(I){return I?`${I} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),z("ERR_INVALID_ARG_TYPE",function(I,O){return`The "${I}" argument must be of type number. Received type ${typeof O}`},TypeError),z("ERR_OUT_OF_RANGE",function(I,O,L){let V=`The value of "${I}" is out of range.`,st=L;return Number.isInteger(L)&&Math.abs(L)>2**32?st=tt(String(L)):typeof L=="bigint"&&(st=String(L),(L>BigInt(2)**BigInt(32)||L<-(BigInt(2)**BigInt(32)))&&(st=tt(st)),st+="n"),V+=` It must be ${O}. Received ${st}`,V},RangeError);function tt(I){let O="",L=I.length,V=I[0]==="-"?1:0;for(;L>=V+4;L-=3)O=`_${I.slice(L-3,L)}${O}`;return`${I.slice(0,L)}${O}`}function X(I,O,L){j(O,"offset"),(I[O]===void 0||I[O+L]===void 0)&&rt(O,I.length-(L+1))}function U(I,O,L,V,st,ft){if(I>L||I<O){let ht=typeof O=="bigint"?"n":"",Et;throw ft>3?O===0||O===BigInt(0)?Et=`>= 0${ht} and < 2${ht} ** ${(ft+1)*8}${ht}`:Et=`>= -(2${ht} ** ${(ft+1)*8-1}${ht}) and < 2 ** ${(ft+1)*8-1}${ht}`:Et=`>= ${O}${ht} and <= ${L}${ht}`,new Q.ERR_OUT_OF_RANGE("value",Et,I)}X(V,st,ft)}function j(I,O){if(typeof I!="number")throw new Q.ERR_INVALID_ARG_TYPE(O,"number",I)}function rt(I,O,L){throw Math.floor(I)!==I?(j(I,L),new Q.ERR_OUT_OF_RANGE(L||"offset","an integer",I)):O<0?new Q.ERR_BUFFER_OUT_OF_BOUNDS:new Q.ERR_OUT_OF_RANGE(L||"offset",`>= ${L?1:0} and <= ${O}`,I)}var ot=/[^+/0-9A-Za-z-_]/g;function ct(I){if(I=I.split("=")[0],I=I.trim().replace(ot,""),I.length<2)return"";for(;I.length%4!==0;)I=I+"=";return I}function ut(I,O){O=O||1/0;let L,V=I.length,st=null,ft=[];for(let ht=0;ht<V;++ht){if(L=I.charCodeAt(ht),L>55295&&L<57344){if(!st){if(L>56319){(O-=3)>-1&&ft.push(239,191,189);continue}else if(ht+1===V){(O-=3)>-1&&ft.push(239,191,189);continue}st=L;continue}if(L<56320){(O-=3)>-1&&ft.push(239,191,189),st=L;continue}L=(st-55296<<10|L-56320)+65536}else st&&(O-=3)>-1&&ft.push(239,191,189);if(st=null,L<128){if((O-=1)<0)break;ft.push(L)}else if(L<2048){if((O-=2)<0)break;ft.push(L>>6|192,L&63|128)}else if(L<65536){if((O-=3)<0)break;ft.push(L>>12|224,L>>6&63|128,L&63|128)}else if(L<1114112){if((O-=4)<0)break;ft.push(L>>18|240,L>>12&63|128,L>>6&63|128,L&63|128)}else throw new Error("Invalid code point")}return ft}function pt(I){let O=[];for(let L=0;L<I.length;++L)O.push(I.charCodeAt(L)&255);return O}function St(I,O){let L,V,st,ft=[];for(let ht=0;ht<I.length&&!((O-=2)<0);++ht)L=I.charCodeAt(ht),V=L>>8,st=L%256,ft.push(st),ft.push(V);return ft}function bt(I){return t.toByteArray(ct(I))}function lt(I,O,L,V){let st;for(st=0;st<V&&!(st+L>=O.length||st>=I.length);++st)O[st+L]=I[st];return st}function mt(I,O){return I instanceof O||I!=null&&I.constructor!=null&&I.constructor.name!=null&&I.constructor.name===O.name}function wt(I){return I!==I}var Mt=function(){let I="0123456789abcdef",O=new Array(256);for(let L=0;L<16;++L){let V=L*16;for(let st=0;st<16;++st)O[V+st]=I[L]+I[st]}return O}();function ne(I){return typeof BigInt>"u"?nt:I}function nt(){throw new Error("BigInt not supported")}}),IMt=Du((i,t)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,t.exports={Buffer:LR().Buffer,Crypto:window.crypto}):t.exports={Buffer:LR().Buffer,Crypto:crypto}}),Aet={};EMt(Aet,{AVSCTap:()=>Em,ArweaveSigner:()=>rk,DataItem:()=>ym,MAX_TAG_BYTES:()=>_8,MIN_BINARY_SIZE:()=>ok,SIG_CONFIG:()=>op,SignatureConfig:()=>Gs,Signer:()=>Tet,createData:()=>Iet,deserializeTags:()=>l8,indexToType:()=>ik,serializeTags:()=>nk,tagsExceedLimit:()=>ket});var Tet=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(i,t,r,h){throw new Error("You must implement verify method on child")}},BMt=U0(ek(),1),Wh=U0(Eet(),1);async function xet(i){if(Array.isArray(i)){let o=(0,Wh.concatBuffers)([(0,Wh.stringToBuffer)("list"),(0,Wh.stringToBuffer)(i.length.toString())]);return await Ret(i,await Cu().hash(o,"SHA-384"))}let t=i,r=(0,Wh.concatBuffers)([(0,Wh.stringToBuffer)("blob"),(0,Wh.stringToBuffer)(t.byteLength.toString())]),h=(0,Wh.concatBuffers)([await Cu().hash(r,"SHA-384"),await Cu().hash(t,"SHA-384")]);return await Cu().hash(h,"SHA-384")}async function Ret(i,t){if(i.length<1)return t;let r=(0,Wh.concatBuffers)([t,await xet(i[0])]),h=await Cu().hash(r,"SHA-384");return await Ret(i.slice(1),h)}var _R=U0(RMt(),1),OMt=_R.default.default?_R.default.default:_R.default,CMt=class extends OMt{getPublicKey(i){throw new Error("Unimplemented")}},PMt;function Cu(){return PMt??=new CMt}var Gs;(function(i){i[i.ARWEAVE=1]="ARWEAVE",i[i.ED25519=2]="ED25519",i[i.ETHEREUM=3]="ETHEREUM",i[i.SOLANA=4]="SOLANA",i[i.INJECTEDAPTOS=5]="INJECTEDAPTOS",i[i.MULTIAPTOS=6]="MULTIAPTOS",i[i.TYPEDETHEREUM=7]="TYPEDETHEREUM"})(Gs||(Gs={}));var op={[Gs.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[Gs.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[Gs.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[Gs.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[Gs.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[Gs.MULTIAPTOS]:{sigLength:64*32+4,pubLength:32*32+1,sigName:"multiAptos"},[Gs.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},rk=class{signatureType=1;ownerLength=op[1].pubLength;signatureLength=op[1].sigLength;jwk;pk;constructor(i){this.pk=i.n,this.jwk=i}get publicKey(){return BMt.default.toBuffer(this.pk)}sign(i){return Cu().sign(this.jwk,i)}static async verify(i,t,r){return await Cu().verify(i,t,r)}},ik={1:rk},Of=U0(ek(),1);async function DR(i){return xet([(0,Wh.stringToBuffer)("dataitem"),(0,Wh.stringToBuffer)("1"),(0,Wh.stringToBuffer)(i.signatureType.toString()),i.rawOwner,i.rawTarget,i.rawAnchor,i.rawTags,i.rawData])}async function NMt(i,t){let r=await DR(i),h=await t.sign(r),o=await Cu().hash(h);return{signature:ge.from(h),id:ge.from(o)}}async function LMt(i,t){let{signature:r,id:h}=await NMt(i,t);return i.getRaw().set(r,2),h}var Em=class{buf;pos;constructor(i=ge.alloc(_8),t=0){this.buf=i,this.pos=t}writeTags(i){if(!Array.isArray(i))throw new Error("input must be array");let t=i.length,r;if(t)for(this.writeLong(t),r=0;r<t;r++){let h=i[r];if(h?.name===void 0||h?.value===void 0)throw new Error(`Invalid tag format for ${h}, expected {name:string, value: string}`);this.writeString(h.name),this.writeString(h.value)}this.writeLong(0)}toBuffer(){let i=ge.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(i,0,0,this.pos),i}tagsExceedLimit(){return this.pos>this.buf.length}writeLong(i){let t=this.buf,r,h;if(i>=-1073741824&&i<1073741824){h=i>=0?i<<1:~i<<1|1;do t[this.pos]=h&127,h>>=7;while(h&&(t[this.pos++]|=128))}else{r=i>=0?i*2:-i*2-1;do t[this.pos]=r&127,r/=128;while(r>=1&&(t[this.pos++]|=128))}this.pos++,this.buf=t}writeString(i){let t=ge.byteLength(i),r=this.buf;this.writeLong(t);let h=this.pos;if(this.pos+=t,!(this.pos>r.length)){if(t>64)this.buf.write(i,this.pos-t,t,"utf8");else{let o,l,c,p;for(o=0,l=t;o<l;o++)c=i.charCodeAt(o),c<128?r[h++]=c:c<2048?(r[h++]=c>>6|192,r[h++]=c&63|128):(c&64512)===55296&&((p=i.charCodeAt(o+1))&64512)===56320?(c=65536+((c&1023)<<10)+(p&1023),o++,r[h++]=c>>18|240,r[h++]=c>>12&63|128,r[h++]=c>>6&63|128,r[h++]=c&63|128):(r[h++]=c>>12|224,r[h++]=c>>6&63|128,r[h++]=c&63|128)}this.buf=r}}readLong(){let i=0,t=0,r=this.buf,h,o,l,c;do h=r[this.pos++],o=h&128,i|=(h&127)<<t,t+=7;while(o&&t<28);if(o){l=i,c=268435456;do h=r[this.pos++],l+=(h&127)*c,c*=128;while(h&128);return(l%2?-(l+1):l)/2}return i>>1^-(i&1)}skipLong(){let i=this.buf;for(;i[this.pos++]&128;);}readTags(){let i=[],t;for(;t=this.readLong();)for(t<0&&(t=-t,this.skipLong());t--;){let r=this.readString(),h=this.readString();i.push({name:r,value:h})}return i}readString(){let i=this.readLong(),t=this.pos,r=this.buf;if(this.pos+=i,!(this.pos>r.length))return this.buf.slice(t,t+i).toString()}};function nk(i){let t=new Em;return t.writeTags(i),t.toBuffer()}function ket(i){let t=new Em;return t.writeTags(i),t.tagsExceedLimit()}function l8(i){return new Em(i).readTags()}function Jc(i){let t=0;for(let r=i.length-1;r>=0;r--)t=t*256+i[r];return t}function DMt(i){if(i>29)throw new Error("Short too long");let t=[0,0];for(let r=0;r<t.length;r++){let h=i&255;t[r]=h,i=(i-h)/256}return Uint8Array.from(t)}function ptt(i){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let h=i&255;t[r]=h,i=(i-h)/256}return Uint8Array.from(t)}var $Mt=U0(IMt(),1),H1=U0(LR(),1),_8=4096,ok=80,ym=class{binary;_id;constructor(i){this.binary=i}static isDataItem(i){return i.binary!==void 0}get signatureType(){let i=Jc(this.binary.subarray(0,2));if(Gs?.[i]!==void 0)return i;throw new Error("Unknown signature type: "+i)}async isValid(){return ym.verify(this.binary)}get id(){return(async()=>Of.default.encode(await this.rawId))()}set id(i){this._id=Of.default.toBuffer(i)}get rawId(){return(async()=>H1.Buffer.from(await $Mt.Crypto.subtle.digest("SHA-256",this.rawSignature)))()}set rawId(i){this._id=i}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return Of.default.encode(this.rawSignature)}set rawOwner(i){if(i.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${i.byteLength} bytes.`);this.binary.set(i,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return op[this.signatureType].sigLength}get owner(){return Of.default.encode(this.rawOwner)}get ownerLength(){return op[this.signatureType].pubLength}get rawTarget(){let i=this.getTargetStart();return this.binary[i]==1?this.binary.subarray(i+1,i+33):H1.Buffer.alloc(0)}get target(){return Of.default.encode(this.rawTarget)}get rawAnchor(){let i=this.getAnchorStart();return this.binary[i]==1?this.binary.subarray(i+1,i+33):H1.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let i=this.getTagsStart(),t=Jc(this.binary.subarray(i+8,i+16));return this.binary.subarray(i+16,i+16+t)}get tags(){let i=this.getTagsStart();if(Jc(this.binary.subarray(i,i+8))==0)return[];let t=Jc(this.binary.subarray(i+8,i+16));return l8(H1.Buffer.from(this.binary.subarray(i+16,i+16+t)))}get tagsB64Url(){return this.tags.map(i=>({name:Of.default.encode(i.name),value:Of.default.encode(i.value)}))}getStartOfData(){let i=this.getTagsStart(),t=this.binary.subarray(i+8,i+16),r=Jc(t);return i+16+r}get rawData(){let i=this.getTagsStart(),t=this.binary.subarray(i+8,i+16),r=Jc(t),h=i+16+r;return this.binary.subarray(h,this.binary.length)}get data(){return Of.default.encode(this.rawData)}getRaw(){return this.binary}async sign(i){return this._id=await LMt(this,i),this.rawId}async setSignature(i){this.binary.set(i,2),this._id=H1.Buffer.from(await Cu().hash(i))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map(i=>({name:Of.default.encode(i.name),value:Of.default.encode(i.value)})),data:this.data}}static async verify(i){if(i.byteLength<ok)return!1;let t=new ym(i),r=t.signatureType,h=t.getTagsStart(),o=Jc(i.subarray(h,h+8)),l=i.subarray(h+8,h+16),c=Jc(l);if(c>_8)return!1;if(o>0)try{if(l8(H1.Buffer.from(i.subarray(h+16,h+16+c))).length!==o)return!1}catch{return!1}let p=ik[r],w=await DR(t);return await p.verify(t.rawOwner,w,t.rawSignature)}async getSignatureData(){return DR(this)}getTagsStart(){let i=this.getTargetStart(),t=this.binary[i]==1,r=i+(t?33:1),h=this.binary[r]==1;return r+=h?33:1,r}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let i=this.getTargetStart()+1,t=this.binary[this.getTargetStart()]==1;return i+=t?32:0,i}},UMt=U0(ek(),1);function Iet(i,t,r){let h=t.publicKey,o=r?.target?UMt.default.toBuffer(r.target):null,l=1+(o?.byteLength??0),c=r?.anchor?ge.from(r.anchor):null,p=1+(c?.byteLength??0),w=(r?.tags?.length??0)>0?nk(r.tags):null,m=16+(w?w.byteLength:0),y=ge.from(i),v=y.byteLength,M=2+t.signatureLength+t.ownerLength+l+p+m+v,T=ge.alloc(M);if(T.set(DMt(t.signatureType),0),T.set(new Uint8Array(t.signatureLength).fill(0),2),h.byteLength!==t.ownerLength)throw new Error(`Owner must be ${t.ownerLength} bytes, but was incorrectly ${h.byteLength}`);T.set(h,2+t.signatureLength);let A=2+t.signatureLength+t.ownerLength;if(T[A]=o?1:0,o){if(o.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${o.byteLength}`);T.set(o,A+1)}let R=A+l,B=R+1;if(T[R]=c?1:0,c){if(B+=c.byteLength,c.byteLength!==32)throw new Error("Anchor must be 32 bytes");T.set(c,R+1)}T.set(ptt(r?.tags?.length??0),B);let C=ptt(w?.byteLength??0);T.set(C,B+8),w&&T.set(w,B+16);let P=B+m;return T.set(y,P),new ym(T)}var ak={...Aet};globalThis.arbundles??=ak;var qMt=ak,FMt=ak;globalThis.Buffer||(globalThis.Buffer=wet.Buffer);var{DataItem:jMt}=_et;function zMt(i){return async({data:r,tags:h,target:o,anchor:l,createDataItem:c=p=>new jMt(p)})=>{let p=await i.signDataItem({data:r,tags:h,target:o,anchor:l}),w=c(wet.Buffer.from(p));return{id:await w.id,raw:await w.getRaw()}}}var WMt=globalThis.GATEWAY_URL||void 0,KMt=globalThis.MU_URL||void 0,HMt=globalThis.CU_URL||void 0,GMt=globalThis.GRAPHQL_URL||void 0,{result:jWt,results:zWt,message:WWt,spawn:KWt,monitor:HWt,unmonitor:GWt,dryrun:VWt,assign:ZWt}=Sm({GATEWAY_URL:WMt,MU_URL:KMt,CU_URL:HMt,GRAPHQL_URL:GMt}),JWt=bet.createDataItemSigner;var Bet=sc(z5(),1);Tt();Rt();xt();function sk(i){try{return JSON.parse(i)}catch{return i}}var Ys=class i{logger;processId;ao;constructor({processId:t,ao:r=Sm(),logger:h=new pa({level:"info"})}){this.processId=t,this.logger=h,this.ao=r}static async createAoSigner(t){return t.publicKey===void 0&&"setPublicKey"in t&&await t.setPublicKey(),async({data:h,tags:o,target:l,anchor:c})=>{let p=(0,Bet.createData)(h,t,{tags:o,target:l,anchor:c});return p.sign(t).then(async()=>({id:await p.id,raw:await p.getRaw()}))}}async read({tags:t,retries:r=3}){let h=0,o;for(;h<r;)try{this.logger.debug("Evaluating read interaction on contract",{tags:t});let l=await this.ao.dryrun({process:this.processId,tags:t});if(l.Messages.length===0)throw new Error(`Process ${this.processId} does not support provided action.`);let p=l.Messages[0].Tags.find(m=>m.name==="Error");if(p)throw new Error(`${p.Value}: ${l.Messages[0].Data}`);return this.logger.debug("Read interaction result",{result:l.Messages[0].Data}),l.Messages[0].Data===void 0?{}:sk(l.Messages[0].Data)}catch(l){h++,this.logger.debug(`Read attempt ${h} failed`,{error:l,tags:t}),o=l,await new Promise(c=>setTimeout(c,2**h*1e3))}throw o}async send({tags:t,data:r,signer:h,retries:o=3}){let l=0,c;for(;l<o;)try{this.logger.debug("Evaluating send interaction on contract",{tags:t,data:r,processId:this.processId});let p=await this.ao.message({process:this.processId,tags:[...t,{name:"AR-IO-SDK",value:o1}],data:typeof r!="string"?JSON.stringify(r):r,signer:await i.createAoSigner(h)});this.logger.debug("Sent message to process",{messageId:p,processId:this.processId});let w=await this.ao.result({message:p,process:this.processId});if(this.logger.debug("Message result",{output:w,messageId:p,processId:this.processId}),w.Messages?.length===0||w.Messages===void 0)return{id:p};let y=w.Messages[0].Tags.find(M=>M.name==="Error");if(y){let M=w.Messages[0].Data;throw new a1(`${y.Value}: ${M}`)}if(w.Messages.length===0)throw new Error(`Process ${this.processId} does not support provided action.`);if(w.Messages[0].Data===void 0)return{id:p};let v=sk(w.Messages[0].Data);return this.logger.debug("Message result data",{resultData:v,messageId:p,processId:this.processId}),{id:p,result:v}}catch(p){if(this.logger.error("Error sending message to process",{error:p.message,processId:this.processId,tags:t}),p.message.includes("500"))this.logger.debug("Retrying send interaction",{attempts:l,retries:o,error:p.message,processId:this.processId}),await new Promise(w=>setTimeout(w,2**l*2e3)),l++,c=p;else throw p}throw c}};var Am=class{static init(t){if(t&&t.signer){let{signer:r,...h}=t;return new hk({...h,signer:r})}return new M8(t)}},M8=class{process;arweave;constructor(t,r=Oet.default.init({})){if(!t)this.process=new Ys({processId:Od});else if(Rl(t))this.process=t.process;else if(kl(t))this.process=new Ys({processId:t.processId,logger:new pa({level:"info"})});else throw new No;this.arweave=r}async getInfo(){return this.process.read({tags:[{name:"Action",value:"Info"}]})}async getEpochSettings(t){let h=[{name:"Action",value:"Epoch-Settings"},{name:"Timestamp",value:t?.timestamp?.toString()??(await this.arweave.blocks.getCurrent().catch(()=>({timestamp:Date.now()}))).timestamp.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return this.process.read({tags:h})}async getEpoch(t){let h=[{name:"Action",value:"Epoch"},{name:"Timestamp",value:t?.timestamp?.toString()??(await this.arweave.blocks.getCurrent().catch(()=>({timestamp:Date.now()}))).timestamp.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return this.process.read({tags:h})}async getArNSRecord({name:t}){return this.process.read({tags:[{name:"Action",value:"Record"},{name:"Name",value:t}]})}async getArNSRecords(){return this.process.read({tags:[{name:"Action",value:"Records"}]})}async getArNSReservedNames(){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"}]})}async getArNSReservedName({name:t}){return this.process.read({tags:[{name:"Action",value:"Reserved-Name"},{name:"Name",value:t}]})}async getBalance({address:t}){return this.process.read({tags:[{name:"Action",value:"Balance"},{name:"Address",value:t}]})}async getBalances(){return this.process.read({tags:[{name:"Action",value:"Balances"}]})}async getGateway({address:t}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:t}]})}async getGateways(){return this.process.read({tags:[{name:"Action",value:"Gateways"}]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"},{name:"Timestamp",value:(await this.arweave.blocks.getCurrent().catch(()=>({timestamp:Date.now()}))).timestamp.toString()}]})}async getPrescribedObservers(t){let h=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Timestamp",value:t?.timestamp?.toString()??(await this.arweave.blocks.getCurrent().catch(()=>({timestamp:Date.now()}))).timestamp.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return this.process.read({tags:h})}async getPrescribedNames(t){let h=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Timestamp",value:t?.timestamp?.toString()??(await this.arweave.blocks.getCurrent().catch(()=>({timestamp:Date.now()}))).timestamp.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return this.process.read({tags:h})}async getObservations(t){let h=[{name:"Action",value:"Epoch-Observations"},{name:"Timestamp",value:t?.timestamp?.toString()??(await this.arweave.blocks.getCurrent().catch(()=>({timestamp:`${Date.now()}`}))).timestamp.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return this.process.read({tags:h})}async getDistributions(t){let h=[{name:"Action",value:"Epoch-Distributions"},{name:"Timestamp",value:t?.timestamp?.toString()??(await this.arweave.blocks.getCurrent().catch(()=>({timestamp:Date.now()}))).timestamp.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return this.process.read({tags:h})}async getTokenCost({intent:t,purchaseType:r,years:h,name:o,quantity:l}){let p=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:t},{name:"Name",value:o},{name:"Years",value:h?.toString()},{name:"Quantity",value:l?.toString()},{name:"Purchase-Type",value:r},{name:"Timestamp",value:(await this.arweave.blocks.getCurrent().catch(()=>({timestamp:Date.now()}))).timestamp.toString()}].filter(w=>w.value!==void 0);return this.process.read({tags:p})}},hk=class extends M8{signer;constructor({signer:t,...r}){if(Object.keys(r).length===0)super({process:new Ys({processId:Od})}),this.signer=t;else if(Rl(r))super({process:r.process}),this.signer=t;else if(kl(r))super({process:new Ys({processId:r.processId})}),this.signer=t;else throw new No}async transfer({target:t,qty:r},h){let{tags:o=[]}=h||{};return this.process.send({tags:[...o,{name:"Action",value:"Transfer"},{name:"Recipient",value:t},{name:"Quantity",value:r.valueOf().toString()}],signer:this.signer})}async joinNetwork({operatorStake:t,allowDelegatedStaking:r,delegateRewardShareRatio:h,fqdn:o,label:l,minDelegatedStake:c,note:p,port:w,properties:m,protocol:y,autoStake:v,observerAddress:M},T){let{tags:A=[]}=T||{},B=[...A,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:t.valueOf().toString()},{name:"Allow-Delegated-Staking",value:r.toString()},{name:"Delegate-Reward-Share-Ratio",value:h.toString()},{name:"FQDN",value:o},{name:"Label",value:l},{name:"Min-Delegated-Stake",value:c.valueOf().toString()},{name:"Note",value:p},{name:"Port",value:w.toString()},{name:"Properties",value:m},{name:"Protocol",value:y},{name:"Auto-Stake",value:v.toString()},{name:"Observer-Address",value:M}].filter(C=>C.value!==void 0);return this.process.send({signer:this.signer,tags:B})}async updateGatewaySettings({allowDelegatedStaking:t,delegateRewardShareRatio:r,fqdn:h,label:o,minDelegatedStake:l,note:c,port:p,properties:w,protocol:m,autoStake:y,observerAddress:v},M){let{tags:T=[]}=M||{},R=[...T,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:o},{name:"Note",value:c},{name:"FQDN",value:h},{name:"Port",value:p?.toString()},{name:"Properties",value:w},{name:"Protocol",value:m},{name:"Observer-Address",value:v},{name:"Allow-Delegated-Staking",value:t?.toString()},{name:"Delegate-Reward-Share-Ratio",value:r?.toString()},{name:"Min-Delegated-Stake",value:l?.valueOf().toString()},{name:"Auto-Stake",value:y?.toString()}].filter(B=>B.value!==void 0);return this.process.send({signer:this.signer,tags:R})}async delegateStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:t.target},{name:"Quantity",value:t.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Decrease-Delegate-Stake"},{name:"Target",value:t.target},{name:"Quantity",value:t.decreaseQty.valueOf().toString()}]})}async increaseOperatorStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:t.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:t.decreaseQty.valueOf().toString()}]})}async saveObservations(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:t.reportTxId},{name:"Failed-Gateways",value:t.failedGateways.join(",")}],data:{reportTxId:t.reportTxId,failedGateways:t.failedGateways}})}async buyRecord(t,r){let{tags:h=[]}=r||{},l=[...h,{name:"Action",value:"Buy-Record"},{name:"Name",value:t.name},{name:"Years",value:t.years?.toString()??"1"},{name:"Process-Id",value:t.processId},{name:"Purchase-Type",value:t.type||"lease"}].filter(c=>c.value!==void 0);return this.process.send({signer:this.signer,tags:l})}async extendLease(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Extend-Lease"},{name:"Name",value:t.name},{name:"Years",value:t.years.toString()}]})}async increaseUndernameLimit(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Increase-Undername-Limit"},{name:"Name",value:t.name},{name:"Quantity",value:t.increaseCount.toString()}]})}};var wHt=async({address:i,contract:t=Am.init({processId:Od})})=>{let r=Y9(50),h=await t.getArNSRecords().then(l=>Object.values(l).filter(c=>c.processId!==void 0).map(c=>c.processId)),o=await Promise.all(h.map(async l=>r(async()=>{let c=j2.init({processId:l}),{Owner:p,Controllers:w}=await c.getState();if(p===i||w.includes(i))return l})));return o.length===0?[]:[...new Set(o)]};function Cet(i,t){return new Promise((r,h)=>{let o=setTimeout(()=>{h(new Error("Timeout"))},i);t.then(l=>{clearTimeout(o),r(l)}).catch(l=>{clearTimeout(o),h(l)})})}var Pet=class extends Z9.default{contract;timeoutMs;throttle;constructor({contract:t=Am.init({processId:Od}),timeoutMs:r=6e4,concurrency:h=30}){super(),this.contract=t,this.timeoutMs=r,this.throttle=Y9(h)}async fetchProcessesOwnedByWallet({address:t}){let r={};await Cet(this.timeoutMs,this.contract.getArNSRecords().catch(o=>(this.emit("error",`Error getting ArNS records: ${o}`),{}))).then(o=>{o&&Object.entries(o).forEach(([l,c])=>{c.processId!==void 0&&(r[c.processId]===void 0&&(r[c.processId]={state:void 0,names:{}}),r[c.processId].names[l]=c)})});let h=Object.keys(r).length;this.emit("progress",0,h),await Promise.all(Object.keys(r).map(async(o,l)=>this.throttle(async()=>{if(r[o].state!==void 0){this.emit("progress",l+1,h);return}let c=j2.init({processId:o}),p=await Cet(this.timeoutMs,c.getState()).catch(w=>{this.emit("error",`Error getting state for process ${o}: ${w}`)});(p?.Owner===t||p?.Controllers.includes(t))&&(r[o].state=p,this.emit("process",o,r[o])),this.emit("progress",l+1,h)}))),this.emit("end",r)}};Tt();Rt();xt();Tt();Rt();xt();var Net=sc(dR(),1),S8=Net.default.init({host:"arweave.net",port:443,protocol:"https"});async function UHt({signer:i,module:t=RL,luaCodeTxId:r=kL,ao:h=Sm(),scheduler:o=IL,state:l,stateContractTxId:c}){let p=await S8.transactions.getData(r,{decode:!0,string:!0}),w=await h.spawn({module:t,scheduler:o,signer:await Ys.createAoSigner(i)}),m=new Ys({processId:w,ao:h});return await m.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:r}],data:p,signer:i}),l&&await m.send({tags:[{name:"Action",value:"Initialize-State"},...c!==void 0?[{name:"State-Contract-TX-ID",value:c}]:[]],data:JSON.stringify(l),signer:i}),w}var E8=class{axios;logger;constructor({url:t,logger:r=new pa}){this.logger=r,this.axios=aF({axiosConfig:{baseURL:t},logger:this.logger})}async get({endpoint:t,signal:r,allowedStatuses:h=[200,202],headers:o,params:l}){this.logger.debug(`Get request to endpoint: ${t} with params ${JSON.stringify(l,void 0,2)}`);let{status:c,statusText:p,data:w}=await this.axios.get(t,{headers:o,signal:r,params:l});if(this.logger.debug(`Response status: ${c} ${p}`),!h.includes(c))switch(c){case 404:throw new O6(p);case 400:throw new Hl(c,p);default:throw new C6(p)}return w}};var Gl=class{logger;http;contractTxId;cacheUrl;constructor({cacheUrl:t="https://api.arns.app",contractTxId:r,logger:h=new pa}){this.cacheUrl=t,this.contractTxId=r,this.logger=h,this.http=new E8({url:`${t}/v1/contract/${r}`})}configuration(){return{contractTxId:this.contractTxId,cacheUrl:this.cacheUrl}}async getState({evaluationOptions:t}={}){this.logger.debug("Fetching contract state",{contractTxId:this.contractTxId,evaluationOptions:t});let{state:r}=await this.http.get({endpoint:"",params:{...t?.evalTo}});return r}async readInteraction({functionName:t,inputs:r,evaluationOptions:h}){this.logger.debug("Evaluating read interaction on contract",{functionName:t,inputs:r,evaluationOptions:h});let{result:o}=await this.http.get({endpoint:`/read/${t}`,params:{...h?.evalTo,...r}});return o}};var Let=class{static createWriteableContract(t){if(!t||Object.keys(t).length===0)return new ga({contractTxId:Sy});if(Yf(t))return t.contract instanceof ga?t.contract:new ga(t.contract.configuration());if(Qf(t))return new ga({contractTxId:t.contractTxId});throw new No}static init(t){if(t&&t.signer!==void 0){let{signer:r,...h}=t,o=this.createWriteableContract(h);return new fk({signer:r,contract:o})}else return new A8(t)}},A8=class{contract;constructor(t){if(!t||t===void 0)this.contract=new Gl({contractTxId:Sy});else if(Yf(t))this.contract=t.contract;else if(Qf(t))this.contract=new Gl({contractTxId:t.contractTxId});else throw new No}async getState(t={}){return await this.contract.getState(t)}async getArNSRecord({domain:t,evaluationOptions:r}){return(await this.getArNSRecords({evaluationOptions:r}))[t]}async getArNSRecords({evaluationOptions:t}={}){return(await this.contract.getState({evaluationOptions:t})).records}async getArNSReservedNames({evaluationOptions:t}={}){return(await this.contract.getState({evaluationOptions:t})).reserved}async getArNSReservedName({domain:t,evaluationOptions:r}){return(await this.getArNSReservedNames({evaluationOptions:r}))[t]}async getBalance({address:t,evaluationOptions:r}){return(await this.getBalances({evaluationOptions:r}))[t]||0}async getBalances({evaluationOptions:t}={}){return(await this.contract.getState({evaluationOptions:t})).balances}async getGateway({address:t,evaluationOptions:r}){return this.contract.readInteraction({functionName:ho.GATEWAY,inputs:{target:t},evaluationOptions:r}).catch(()=>{})}async getGateways({evaluationOptions:t}={}){return this.contract.readInteraction({functionName:ho.GATEWAYS,evaluationOptions:t})}async getCurrentEpoch({evaluationOptions:t}={}){return this.contract.readInteraction({functionName:ho.EPOCH,evaluationOptions:t})}async getEpoch({blockHeight:t,evaluationOptions:r}){return this.contract.readInteraction({functionName:ho.EPOCH,inputs:{height:t},evaluationOptions:r})}async getPrescribedObservers({evaluationOptions:t}={}){return this.contract.readInteraction({functionName:ho.PRESCRIBED_OBSERVERS,evaluationOptions:t})}async getObservations({evaluationOptions:t}={}){let{observations:r}=await this.contract.getState({evaluationOptions:t});return r}async getDistributions({evaluationOptions:t}={}){let{distributions:r}=await this.contract.getState({evaluationOptions:t});return r}async getAuction({domain:t,type:r,evaluationOptions:h}){return this.contract.readInteraction({functionName:ho.AUCTION,inputs:{name:t,type:r},evaluationOptions:h})}async getAuctions({evaluationOptions:t}={}){let{auctions:r}=await this.contract.getState({evaluationOptions:t});return r}async getPriceForInteraction({interactionName:t,payload:r,evaluationOptions:h}){let{price:o}=await this.contract.readInteraction({functionName:ho.PRICE_FOR_INTERACTION,inputs:{interactionName:t,...r},evaluationOptions:h});return o}},fk=class extends A8{signer;constructor({signer:t,...r}){if(Object.keys(r).length===0)super({contract:new ga({contractTxId:Sy})}),this.signer=t;else if(Yf(r))super({contract:r.contract}),this.signer=t;else if(Qf(r))super({contract:new ga({contractTxId:r.contractTxId})}),this.signer=t;else throw new No}async transfer({target:t,qty:r,denomination:h="IO"},o){let l=r;return h==="IO"&&typeof r=="number"&&(l=new r2(r).toMIO()),this.contract.writeInteraction({functionName:ho.TRANSFER,inputs:{target:t,qty:l.valueOf()},signer:this.signer},o)}async joinNetwork({qty:t,allowDelegatedStaking:r,delegateRewardShareRatio:h,fqdn:o,label:l,minDelegatedStake:c,note:p,port:w,properties:m,protocol:y,autoStake:v,observerWallet:M},T){return this.contract.writeInteraction({functionName:ho.JOIN_NETWORK,inputs:{qty:t.valueOf(),allowDelegatedStaking:r,delegateRewardShareRatio:h,fqdn:o,label:l,minDelegatedStake:c.valueOf(),note:p,port:w,properties:m,protocol:y,autoStake:v,observerWallet:M},signer:this.signer},T)}async updateGatewaySettings({allowDelegatedStaking:t,delegateRewardShareRatio:r,fqdn:h,label:o,minDelegatedStake:l,note:c,port:p,properties:w,protocol:m,autoStake:y,observerWallet:v},M){return this.contract.writeInteraction({functionName:ho.UPDATE_GATEWAY_SETTINGS,inputs:{allowDelegatedStaking:t,delegateRewardShareRatio:r,fqdn:h,label:o,minDelegatedStake:l?.valueOf(),note:c,port:p,properties:w,protocol:m,autoStake:y,observerWallet:v},signer:this.signer},M)}async increaseDelegateStake(t,r){return this.contract.writeInteraction({functionName:ho.DELEGATE_STAKE,inputs:{target:t.target,qty:t.qty.valueOf()},signer:this.signer},r)}async decreaseDelegateStake(t,r){return this.contract.writeInteraction({functionName:ho.DECREASE_DELEGATE_STAKE,inputs:{target:t.target,qty:t.qty.valueOf()},signer:this.signer},r)}async increaseOperatorStake(t,r){return this.contract.writeInteraction({functionName:ho.INCREASE_OPERATOR_STAKE,inputs:{qty:t.qty.valueOf()},signer:this.signer},r)}async decreaseOperatorStake(t,r){return this.contract.writeInteraction({functionName:ho.DECREASE_OPERATOR_STAKE,inputs:{qty:t.qty.valueOf()},signer:this.signer},r)}async saveObservations(t,r){return this.contract.writeInteraction({functionName:ho.SAVE_OBSERVATIONS,inputs:{observerReportTxId:t.reportTxId,failedGateways:t.failedGateways},signer:this.signer},r)}async extendLease(t,r){return this.contract.writeInteraction({functionName:ho.EXTEND_RECORD,inputs:{name:t.domain,years:t.years},signer:this.signer},r)}async increaseUndernameLimit(t,r){return this.contract.writeInteraction({functionName:ho.INCREASE_UNDERNAME_COUNT,inputs:{name:t.domain,qty:t.qty},signer:this.signer},r)}};Tt();Rt();xt();Tt();Rt();xt();var or=sc(Zot(),1);var Fie=or.default.AbortError,jie=or.default.AbstractContractHandler,zie=or.default.ArweaveContractDefinitionLoader,Wie=or.default.ArweaveGatewayBundledContractDefinitionLoader,Kie=or.default.ArweaveGatewayBundledInteractionLoader,Hie=or.default.ArweaveGatewayInteractionsLoader,Gie=or.default.ArweaveWrapper,Vie=or.default.Benchmark,Zie=or.default.CacheKey,Jie=or.default.CacheableInteractionsLoader,Xie=or.default.CacheableStateEvaluator,Yie=or.default.ConsoleLogger,Qie=or.default.ConsoleLoggerFactory,tne=or.default.ContractCache,ene=or.default.ContractCallRecord,rne=or.default.ContractError,ine=or.default.ContractInteractionState,nne=or.default.ContractMetadata,one=or.default.CustomEvent,ane=or.default.DEFAULT_LEVEL_DB_LOCATION,sne=or.default.DefaultEvaluationOptions,hne=or.default.DefaultStateEvaluator,fne=or.default.EvalStateResult,une=or.default.EvaluationOptionsEvaluator,cne=or.default.HandlerBasedContract,lne=or.default.HandlerExecutorFactory,dne=or.default.InnerWritesEvaluator,pne=or.default.InteractionCall,gne=or.default.InteractionCompleteEvent,mne=or.default.InteractionInput,vne=or.default.InteractionOutput,yne=or.default.JsHandlerApi,bne=or.default.KV,wne=or.default.KnownErrors,_ne=or.default.LevelDbCache,Mne=or.default.LexicographicalInteractionsSorter,Sne=or.default.LogLevelOrder,Jot=or.default.LoggerFactory,Ene=or.default.MemCache,Ane=or.default.NetworkCommunicationError,Tne=or.default.NonWhitelistedSourceError,xne=or.default.PstContractImpl,Rne=or.default.REGISTER_PROVIDER,kne=or.default.SMART_WEAVE_TAGS,Ine=or.default.SUPPORTED_SRC_CONTENT_TYPES,Bne=or.default.SWBlock,One=or.default.SWTransaction,Cne=or.default.SWVrf,Xot=or.default.Signature,Pne=or.default.SmartWeaveError,Nne=or.default.SmartWeaveErrorType,Lne=or.default.SmartWeaveGlobal,Dne=or.default.SortKeyCacheResult,$ne=or.default.SourceType,Une=or.default.SrcCache,Yot=or.default.Tag,qne=or.default.TagsParser,Fne=or.default.Transaction,jne=or.default.WARP_GW_URL,zne=or.default.WARP_TAGS,Wne=or.default.Warp,Kne=or.default.WarpBuilder,Qot=or.default.WarpFactory,Hne=or.default.WarpFetchWrapper,Gne=or.default.WarpGatewayContractDefinitionLoader,Vne=or.default.WarpGatewayInteractionsLoader,Zne=or.default.WasmHandlerApi,Jne=or.default.WasmSrc,Xne=or.default.arrayToHex,Yne=or.default.asc,Qne=or.default.ascS,toe=or.default.bufToBn,eoe=or.default.bundledTxsFilter,roe=or.default.checkJsSrc,ioe=or.default.createDummyTx,noe=or.default.createInteractionTagsList,ooe=or.default.createInteractionTx,aoe=or.default.deepCopy,soe=or.default.defaultArweaveMs,tat=or.default.defaultCacheOptions,hoe=or.default.defaultWarpGwOptions,foe=or.default.desc,uoe=or.default.descS,coe=or.default.emptyTransfer,loe=or.default.genesisSortKey,doe=or.default.getJsonResponse,poe=or.default.indent,goe=or.default.isBrowser,moe=or.default.isTxIdValid,voe=or.default.knownWarpPlugins,yoe=or.default.knownWarpPluginsPartial,boe=or.default.lastPossibleSortKey,woe=or.default.lvlToOrder,_oe=or.default.mapReplacer,Moe=or.default.mapReviver,Soe=or.default.matchMutClosureDtor,Eoe=or.default.normalizeContractSource,Aoe=or.default.rustWasmImports,Toe=or.default.safeGet,xoe=or.default.safeParseInt,Roe=or.default.sleep,koe=or.default.sortingFirst,Ioe=or.default.sortingLast,Boe=or.default.stripTrailingSlash,Ooe=or.default.timeout;Tt();Rt();xt();Fx();var fkt="+",ukt="/",ckt="-",lkt="_",dkt="=";function pkt(i){return i.replaceAll(fkt,ckt).replaceAll(ukt,lkt).replaceAll(dkt,"")}function wv(i){let t=i.toString("base64");return pkt(t)}function eat(i){return wv(qx("sha256").update(i).digest())}Tt();Rt();xt();var rat=Qot.forMainnet({...tat,inMemory:!0},!0,S8);Jot.INST.logLevel("error");var ga=class{contract;contractTxId;cacheUrl;logger;warp;constructor({contractTxId:t,cacheUrl:r="https://api.arns.app",warp:h=rat,logger:o=new pa({level:"info"})}){this.contractTxId=t,this.contract=h.contract(t),this.cacheUrl=r,this.warp=h,this.logger=o}configuration(){return{contractTxId:this.contractTxId,cacheUrl:this.cacheUrl}}async createWarpSigner(t){return t.publicKey===void 0&&"setPublicKey"in t&&await t.setPublicKey(),new Xot(this.warp,{signer:async h=>{h.setOwner(wv(t.publicKey));let o=await h.getSignatureData(),l=await t.sign(o),c=ge.from(l),p=eat(c);h.setSignature({id:p,owner:wv(t.publicKey),signature:wv(c)})},type:"arweave"})}async getState({evaluationOptions:t={}}){await this.ensureContractInit();let r=t?.evalTo,h;r&&"sortKey"in r?h=r.sortKey:r&&"blockHeight"in r&&(h=r.blockHeight);let o=await this.contract.readState(h);if(!o.cachedValue.state)throw new Hl(502,"Failed to evaluate contract state");return o.cachedValue.state}async ensureContractInit({signer:t}={}){this.logger.debug("Checking contract initialized",{contractTxId:this.contractTxId}),this.logger.debug("Fetching contract manifest",{contractTxId:this.contractTxId});let{evaluationOptions:r={}}=await OL({arweave:this.warp.arweave,contractTxId:this.contractTxId});this.contract.setEvaluationOptions(r),t&&this.contract.connect(await this.createWarpSigner(t)),this.cacheUrl!==void 0&&(this.logger.debug("Syncing contract state",{contractTxId:this.contractTxId,remoteCacheUrl:this.cacheUrl}),await this.contract.syncState(`${this.cacheUrl}/v1/contract/${this.contractTxId}`,{validity:!0}))}async readInteraction({functionName:t,inputs:r}){await this.ensureContractInit(),this.logger.debug(`Read interaction: ${t}`,{contractTxId:this.contractTxId,inputs:r});let h=await this.contract.viewState({function:t,...r});if(h.result===void 0)throw new Hl(502,"Failed to evaluate contract read interaction: "+JSON.stringify({error:h.errorMessage,functionName:t,inputs:r},null,2));return this.logger.debug("Successfully evaluated contract read interaction",{contractTxId:this.contractTxId,result:h.result}),h.result}async writeInteraction({functionName:t,inputs:r,signer:h},o){try{this.logger.debug(`Write interaction: ${t}`,{contractTxId:this.contractTxId}),await this.ensureContractInit({signer:h});let l=await this.contract.dryWrite({function:t,...r});if(l.type!=="ok")throw new Error(`Failed to dry write contract interaction ${t}: ${l.errorMessage}`);let c=await this.contract.writeInteraction({function:t,...r},{disableBundling:!0,tags:o?.tags?.map(p=>new Yot(p.name,p.value))});if(!c?.interactionTx)throw new Error(`Failed to write contract interaction: ${t}`);return this.logger.debug("Successfully wrote contract interaction",{contractTxId:this.contractTxId,interactionTxId:c.originalTxId}),c.interactionTx}catch(l){throw this.logger.error(`Failed to write contract interaction: ${l.message}`,{contractTxId:this.contractTxId}),new a1(l)}}};Tt();Rt();xt();var z2=class{process;constructor(t){if(Rl(t))this.process=t.process;else if(kl(t))this.process=new Ys({processId:t.processId});else throw new No}async getState(){let t=[{name:"Action",value:"State"}];return await this.process.read({tags:t})}async getInfo(){let t=[{name:"Action",value:"Info"}];return await this.process.read({tags:t})}async getRecord({undername:t}){let r=[{name:"Sub-Domain",value:t},{name:"Action",value:"Record"}];return await this.process.read({tags:r})}async getRecords(){let t=[{name:"Action",value:"Records"}];return await this.process.read({tags:t})}async getOwner(){return(await this.getInfo()).Owner}async getControllers(){let t=[{name:"Action",value:"Controllers"}];return await this.process.read({tags:t})}async getName(){return(await this.getInfo()).Name}async getTicker(){return(await this.getInfo()).Ticker}async getBalances(){let t=[{name:"Action",value:"Balances"}];return await this.process.read({tags:t})}async getBalance({address:t}){let r=[{name:"Action",value:"Balance"},{name:"Recipient",value:t}];return await this.process.read({tags:r})}},L6=class extends z2{signer;constructor({signer:t,...r}){super(r),this.signer=t}async transfer({target:t}){let r=[{name:"Action",value:"Transfer"},{name:"Recipient",value:t}];return this.process.send({tags:r,data:{},signer:this.signer})}async addController({controller:t}){let r=[{name:"Action",value:"Add-Controller"},{name:"Controller",value:t}];return this.process.send({tags:r,data:{},signer:this.signer})}async removeController({controller:t}){let r=[{name:"Action",value:"Remove-Controller"},{name:"Controller",value:t}];return this.process.send({tags:r,data:{},signer:this.signer})}async setRecord({undername:t,transactionId:r,ttlSeconds:h}){return this.process.send({tags:[{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:t},{name:"Transaction-Id",value:r},{name:"TTL-Seconds",value:h.toString()}],data:{transactionId:r,ttlSeconds:h},signer:this.signer})}async removeRecord({undername:t}){return this.process.send({tags:[{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:t}],data:{undername:t},signer:this.signer})}async setTicker({ticker:t}){return this.process.send({tags:[{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:t}],data:{ticker:t},signer:this.signer})}async setName({name:t}){return this.process.send({tags:[{name:"Action",value:"Set-Name"},{name:"Name",value:t}],data:{name:t},signer:this.signer})}};var export_ArconnectSigner=iat.ArconnectSigner;var export_ArweaveSigner=iat.ArweaveSigner;export{j2 as ANT,N6 as ANTReadable,Q9 as ANTWritable,cc as ANT_CONTRACT_FUNCTIONS,kL as ANT_LUA_ID,Ys as AOProcess,RL as AOS_MODULE_ID,Gkt as ARNS_DEVNET_REGISTRY_TX,Sy as ARNS_TESTNET_REGISTRY_TX,TL as ARWEAVE_TX_REGEX,ho as AR_IO_CONTRACT_FUNCTIONS,s1 as AbortError,z2 as AoANTReadable,L6 as AoANTWriteable,Let as ArIO,A8 as ArIOReadable,fk as ArIOWritable,Pet as ArNSEventEmitter,export_ArconnectSigner as ArconnectSigner,export_ArweaveSigner as ArweaveSigner,sF as BadRequest,wh as BaseError,IL as DEFAULT_SCHEDULER_ID,AL as DENOMINATIONS,pa as DefaultLogger,Hkt as FQDN_REGEX,Hl as FailedRequestError,Am as IO,M8 as IOReadable,r2 as IOToken,hk as IOWriteable,Ost as IO_DEVNET_PROCESS_ID,Vkt as IO_TESTNET_PROCESS_ID,No as InvalidContractConfigurationError,fF as InvalidProcessConfigurationError,hF as InvalidSignerError,h1 as MAX_REQUEST_SIZE,W5 as MIO_PER_IO,O6 as NotFound,Gl as RemoteContract,xL as SORT_KEY_REGEX,G5 as SmartWeaveSortKey,C6 as UnknownError,ga as WarpContract,a1 as WriteInteractionError,aF as createAxiosInstance,wHt as getANTProcessesOwnedByWallet,OL as getContractManifest,zqt as getContractsTransferredToOrControlledByWallet,Fqt as getSmartweaveContractsFromGQL,jqt as getSmartweaveTransactionsFromGQL,$kt as ioContractInteractions,Ist as ioContractReadInteractions,Bst as ioContractWriteInteractions,Od as ioDevnetProcessId,oIt as isBlockHeight,Yf as isContractConfiguration,Qf as isContractTxIdConfiguration,lIt as isLeasedArNSRecord,Rl as isProcessConfiguration,kl as isProcessIdConfiguration,RIt as isSortKey,aIt as isTransaction,H5 as mIOToken,sk as safeDecode,UHt as spawnANT,BL as tagsToObject,Ey as validateArweaveId};
|
|
379
|
+
}`,o=Xe.object({data:Xe.object({transactions:Xe.object({edges:Xe.array(Xe.object({node:Xe.record(Xe.any())}))})})});return l=>ci(l).chain(rn(c=>i(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:h,variables:{transactionIds:[c]}})}).then(async p=>{if(p.ok)return p.json();throw r('Error Encountered when querying gateway for transaction "%s"',c),new Error(`${p.status}: ${await p.text()}`)}).then(o.parse).then(w9t(["data","transactions","edges","0","node"])))).toPromise()}var x_t=UR(j4t(),1),get=(i="@permaweb/aoconnect")=>{let t=(0,x_t.default)(i);return t.child=r=>get(`${t.namespace}:${r}`),t.tap=(r,...h)=>x9t((...o)=>t(r,...h,...o)),t},met=({url:i,path:t})=>t?t.startsWith("/")?met({url:i,path:t.slice(1)}):(i=new URL(i),i.pathname+=t,i.toString()):i;function R_t(i){return ep(b8([]),tp((t,r)=>ep(S9t([],r.name),JR(r.value),Js(r.name,Nu,t))(t),{}),v8(t=>t.length>1?t:t[0]))(i)}function Vs(i,t){return r=>Ftt(B7t([utt(i,"name"),YR(ZR(t),utt(t,"value"),HR)]),r)}function dtt(i){return Xtt([[rm(String),V1(i)],[rm(Array),u9t(i)],[HR,q5t]])}function $0(i){let t;return rm(Zs,i)?(t=new Error(k_t(i)),t.stack+=i.stack):rm(Error,i)?t=i:s9t("message",i)?t=new Error(i.message):rm(String,i)?t=new Error(i):t=new Error("An error occurred"),t}function k_t(i){return ep(t=>function r(h,o,l){return tp((c,p)=>ep(Xtt([[V1(vr.invalid_arguments),()=>r(p.argumentsError,422,"Invalid Arguments")],[V1(vr.invalid_return_type),()=>r(p.returnTypeError,500,"Invalid Return")],[V1(vr.invalid_union),()=>G7t(w=>r(w,400,"Invalid Union"),p.unionErrors)],[HR,()=>[{...p,status:o,contextCode:l}]]]),XR(c))(p.code),[],h.issues)}(t,400,""),t=>tp((r,h)=>{let{message:o,path:l,contextCode:c}=h,p=l[1]||l[0],w=c?`${c} `:"";return r.push(`${w}'${p}': ${o}.`),r},[],t),m9t(" | "))(i)}var I_t=Xe.object({id:Xe.string().min(1,{message:"message is required to be a message id"}),processId:Xe.string().min(1,{message:"process is required to be a process id"})});function B_t(){return i=>ci(i).map(I_t.parse).map(()=>i)}var Mm=Xe.object({name:Xe.string(),value:Xe.string()}),O_t=Xe.function().args(Xe.object({Id:Xe.string(),Target:Xe.string(),Owner:Xe.string(),Anchor:Xe.string().optional(),Data:Xe.any().default("1234"),Tags:Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}))})).returns(Xe.promise(Xe.any())),C_t=Xe.function().args(Xe.object({id:Xe.string().min(1,{message:"message id is required"}),processId:Xe.string().min(1,{message:"process id is required"})})).returns(Xe.promise(Xe.any())),P_t=Xe.function().args(Xe.object({process:Xe.string().min(1,{message:"process id is required"}),from:Xe.string().optional(),to:Xe.string().optional(),sort:Xe.enum(["ASC","DESC"]).default("ASC"),limit:Xe.number().optional()})).returns(Xe.promise(Xe.object({edges:Xe.array(Xe.object({cursor:Xe.string(),node:Xe.object({Output:Xe.any().optional(),Messages:Xe.array(Xe.any()).optional(),Spawns:Xe.array(Xe.any()).optional(),Error:Xe.any().optional()})}))}))),vet=Xe.function().args(Xe.object({processId:Xe.string(),data:Xe.any(),tags:Xe.array(Mm),anchor:Xe.string().optional(),signer:Xe.any()})).returns(Xe.promise(Xe.object({messageId:Xe.string()}).passthrough())),N_t=Xe.function().args(Xe.object({data:Xe.any(),tags:Xe.array(Mm),signer:Xe.any()})).returns(Xe.promise(Xe.object({processId:Xe.string()}).passthrough())),L_t=Xe.function().args(Xe.object({process:Xe.string(),message:Xe.string(),baseLayer:Xe.boolean().optional(),exclude:Xe.array(Xe.string()).optional()})).returns(Xe.promise(Xe.object({assignmentId:Xe.string()}).passthrough())),yet=vet,qWt=Xe.function().args(Xe.object({suUrl:Xe.string().url(),processId:Xe.string()})).returns(Xe.promise(Xe.object({tags:Xe.array(Mm)}).passthrough())),FWt=Xe.function().args(Xe.string()).returns(Xe.promise(Xe.object({url:Xe.string()}))),D_t=Xe.function().args(Xe.string()).returns(Xe.promise(Xe.boolean())),$_t=Xe.function().args(Xe.string()).returns(Xe.promise(Xe.object({tags:Xe.array(Mm)}).passthrough())),w8=Xe.function().args(Xe.object({data:Xe.any(),tags:Xe.array(Mm),target:Xe.string().optional(),anchor:Xe.string().optional()})).returns(Xe.promise(Xe.object({id:Xe.string(),raw:Xe.any()})));function U_t({loadResult:i}){return i=rn(C_t.implement(i)),t=>ci({id:t.id,processId:t.processId}).chain(i)}function q_t(i){let t=B_t(i),r=U_t(i);return({message:h,process:o})=>ci({id:h,processId:o}).chain(t).chain(r).map(i.logger.tap('readResult result for message "%s": %O',h)).map(l=>l).bimap($0,D0).toPromise()}var F_t=Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}));function j_t(){return i=>ci(i.tags).map(b8([])).map(Vs("Data-Protocol","ao")).map(Vs("Variant")).map(Vs("Type")).map(Vs("SDK")).map(XR(Nu,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"},{name:"SDK",value:"aoconnect"}])).map(F_t.parse).map(Js("tags",Nu,i))}function z_t({logger:i}){return t=>ci(t).chain(YR(ZR(t.data),()=>O0(t),()=>O0(Math.random().toString().slice(-4)).map(Js("data",Nu,t)).map(r=>ep(L0("tags"),Vs("Content-Type"),JR({name:"Content-Type",value:"text/plain"}),Js("tags",Nu,r))(r)).map(i.tap('added pseudo-random string as message "data"'))))}function W_t(i){let t=j_t(i),r=z_t(i),h=vet.implement(i.deployMessage);return o=>ci(o).chain(t).chain(r).chain(rn(({id:l,data:c,tags:p,anchor:w,signer:m})=>h({processId:l,data:c,tags:p,anchor:w,signer:w8.implement(m)}))).map(l=>Js("messageId",l.messageId,o))}function K_t(i){let t=W_t(i);return({process:r,data:h,tags:o,anchor:l,signer:c})=>ci({id:r,data:h,tags:o,anchor:l,signer:c}).chain(t).map(p=>p.messageId).bimap($0,D0).toPromise()}var Xg=(i,t,r)=>h=>t(h[i])?O0(h):tl(`Tag '${i}': ${r}`);function H_t({loadTransactionMeta:i,logger:t}){return i=rn($_t.implement(i)),r=>ci(r).chain(i).map(L0("tags")).map(R_t).chain(Xg("Data-Protocol",dtt("ao"),"value 'ao' was not found on module")).chain(Xg("Type",dtt("Module"),"value 'Module' was not found on module")).chain(Xg("Module-Format",bR,"was not found on module")).chain(Xg("Input-Encoding",bR,"was not found on module")).chain(Xg("Output-Encoding",bR,"was not found on module")).bimap(t.tap("Verifying module source failed: %s"),t.tap("Verified module source"))}function G_t({logger:i,validateScheduler:t}){return t=rn(D_t.implement(t)),r=>ci(r).chain(h=>t(h).chain(o=>o?O0(h):tl(`Valid Scheduler-Location owned by ${h} not found`))).bimap(i.tap("Verifying scheduler failed: %s"),i.tap("Verified scheduler"))}function V_t({logger:i}){return t=>ci(t).map(i.tap("Checking for signer")).chain(r=>r?O0(r):tl("signer not found"))}function Z_t(i){let t=i.logger.child("verifyInput");i={...i,logger:t};let r=H_t(i),h=G_t(i),o=V_t(i);return l=>ci(l).chain(c=>r(c.module).map(()=>c)).chain(c=>h(c.scheduler)).map(()=>l).chain(c=>o(c.signer).map(()=>c)).bimap(t.tap("Error when verify input: %s"),t.tap("Successfully verified inputs"))}var J_t=Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}));function X_t(){return i=>ci(i).map(L0("tags")).map(b8([])).map(Vs("Data-Protocol","ao")).map(Vs("Variant")).map(Vs("Type")).map(Vs("Module")).map(Vs("Scheduler")).map(Vs("SDK")).map(XR(Nu,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Process"},{name:"Module",value:i.module},{name:"Scheduler",value:i.scheduler},{name:"SDK",value:"aoconnect"}])).map(J_t.parse).map(Js("tags",Nu,i))}function Y_t({logger:i}){return t=>ci(t).chain(YR(ZR(t.data),()=>O0(t),()=>O0(Math.random().toString().slice(-4)).map(Js("data",Nu,t)).map(r=>ep(L0("tags"),Vs("Content-Type"),JR({name:"Content-Type",value:"text/plain"}),Js("tags",Nu,r))(r)).map(i.tap('added pseudo-random string as process "data"'))))}function Q_t(i){let t=i.logger.child("uploadProcess");i={...i,logger:t};let r=X_t(i),h=Y_t(i),o=N_t.implement(i.deployProcess);return l=>ci(l).chain(r).chain(h).chain(rn(({data:c,tags:p,signer:w})=>o({data:c,tags:p,signer:w8.implement(w)}))).map(c=>Js("processId",c.processId,l))}function tMt(i){let t=Z_t(i),r=Q_t(i);return({module:h,scheduler:o,signer:l,tags:c,data:p})=>ci({module:h,scheduler:o,signer:l,tags:c,data:p}).chain(t).chain(r).map(w=>w.processId).bimap($0,D0).toPromise()}function eMt(i){let t=yet.implement(i.deployMonitor);return r=>ci(r).chain(rn(({id:h,signer:o})=>t({processId:h,signer:w8.implement(o),data:Math.random().toString().slice(-4),tags:[]}))).map(h=>Js("monitorId",h.messageId,r))}function rMt(i){let t=eMt(i);return({process:r,signer:h})=>ci({id:r,signer:h}).chain(t).map(o=>o.monitorId).bimap($0,D0).toPromise()}function iMt(i){let t=yet.implement(i.deployUnmonitor);return r=>ci(r).chain(rn(({id:h,signer:o})=>t({processId:h,signer:w8.implement(o),data:Math.random().toString().slice(-4),tags:[]}))).map(h=>Js("monitorId",h.messageId,r))}function nMt(i){let t=iMt(i);return({process:r,signer:h})=>ci({id:r,signer:h}).chain(t).map(o=>o.monitorId).bimap($0,D0).toPromise()}var oMt=Xe.object({process:Xe.string().min(1,{message:"process identifier is required"}),from:Xe.string().optional(),to:Xe.string().optional(),sort:Xe.enum(["ASC","DESC"]).default("ASC"),limit:Xe.number().optional()});function aMt(){return i=>ci(i).map(oMt.parse).map(()=>i)}function sMt({queryResults:i}){return i=rn(P_t.implement(i)),t=>ci({process:t.process,from:t.from,to:t.to,sort:t.sort,limit:t.limit}).chain(i)}function hMt(i){let t=aMt(i),r=sMt(i);return({process:h,from:o,to:l,sort:c,limit:p})=>ci({process:h,from:o,to:l,sort:c,limit:p}).chain(t).chain(r).map(i.logger.tap('readResults result for message "%s": %O',h)).map(w=>w).bimap($0,D0).toPromise()}var fMt=Xe.object({Id:Xe.string(),Target:Xe.string(),Owner:Xe.string(),Anchor:Xe.string().optional(),Data:Xe.any().default("1234"),Tags:Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}))});function uMt(){return i=>ci(i).map(fMt.parse).map(t=>(t.Tags=t.Tags.concat([{name:"Data-Protocol",value:"ao"},{name:"Type",value:"Message"},{name:"Variant",value:"ao.TN.1"}]),t))}function cMt({dryrunFetch:i}){return rn(O_t.implement(i))}function lMt(i){let t=uMt(i),r=cMt(i);return h=>ci(h).map(dMt).chain(t).chain(r).toPromise()}function dMt({process:i,data:t,tags:r,anchor:h,...o}){return{Id:"1234",Owner:"1234",...o,Target:i,Data:t||"1234",Tags:r||[],Anchor:h||"0"}}function pMt(i){let t=L_t.implement(i.deployAssign);return r=>ci(r).chain(rn(({process:h,message:o,baseLayer:l,exclude:c})=>t({process:h,message:o,baseLayer:l,exclude:c}))).map(h=>Js("assignmentId",h.assignmentId,r))}function gMt(i){let t=pMt(i);return({process:r,message:h,baseLayer:o,exclude:l})=>ci({process:r,message:h,baseLayer:o,exclude:l}).chain(t).map(c=>c.assignmentId).bimap($0,D0).toPromise()}var mMt="https://arweave.net",vMt="https://mu.ao-testnet.xyz",yMt="https://cu.ao-testnet.xyz";function Sm({GRAPHQL_URL:i,GATEWAY_URL:t=mMt,MU_URL:r=vMt,CU_URL:h=yMt}={}){let o=get();i||(i=met({url:t,path:"/graphql"}));let{validate:l}=Dtt({cacheSize:100,GRAPHQL_URL:i}),c=$5t({MAX_SIZE:25}),p=o.child("result"),w=q_t({loadResult:N5t({fetch,CU_URL:h,logger:p}),logger:p}),m=o.child("message"),y=K_t({loadProcessMeta:mR({fetch,cache:c,logger:m}),deployMessage:k5t({fetch,MU_URL:r,logger:m}),logger:m}),v=o.child("spawn"),M=tMt({loadTransactionMeta:T_t({fetch,GRAPHQL_URL:i,logger:v}),validateScheduler:l,deployProcess:I5t({fetch,MU_URL:r,logger:v}),logger:v}),T=o.child("monitor"),A=rMt({loadProcessMeta:mR({fetch,cache:c,logger:T}),deployMonitor:B5t({fetch,MU_URL:r,logger:T}),logger:T}),R=o.child("unmonitor"),B=nMt({loadProcessMeta:mR({fetch,cache:c,logger:R}),deployUnmonitor:O5t({fetch,MU_URL:r,logger:R}),logger:T}),C=o.child("results"),P=hMt({queryResults:L5t({fetch,CU_URL:h,logger:C}),logger:C}),N=o.child("dryrun"),q=lMt({dryrunFetch:P5t({fetch,CU_URL:h,logger:N}),logger:N}),W=o.child("assign"),J=gMt({deployAssign:C5t({fetch,MU_URL:r,logger:W}),logger:m});return{result:w,results:P,message:y,spawn:M,monitor:A,unmonitor:B,dryrun:q,assign:J}}var bet={};mtt(bet,{createDataItemSigner:()=>zMt});var wet=UR(K4t(),1),_et={};mtt(_et,{AVSCTap:()=>Em,ArweaveSigner:()=>rk,DataItem:()=>ym,MAX_TAG_BYTES:()=>_8,MIN_BINARY_SIZE:()=>ok,SIG_CONFIG:()=>op,SignatureConfig:()=>Gs,Signer:()=>Tet,createData:()=>Iet,default:()=>qMt,deserializeTags:()=>l8,indexToType:()=>ik,serializeTags:()=>nk,tagsExceedLimit:()=>ket,warparbundles:()=>FMt});var bMt=Object.create,tk=Object.defineProperty,wMt=Object.getOwnPropertyDescriptor,_Mt=Object.getOwnPropertyNames,MMt=Object.getPrototypeOf,SMt=Object.prototype.hasOwnProperty,Du=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),EMt=(i,t)=>{for(var r in t)tk(i,r,{get:t[r],enumerable:!0})},AMt=(i,t,r,h)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _Mt(t))!SMt.call(i,o)&&o!==r&&tk(i,o,{get:()=>t[o],enumerable:!(h=wMt(t,o))||h.enumerable});return i},U0=(i,t,r)=>(r=i!=null?bMt(MMt(i)):{},AMt(t||!i||!i.__esModule?tk(r,"default",{value:i,enumerable:!0}):r,i)),TMt=Du(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});function t(r){var h=4,o=r.length,l=o%h;if(!l)return r;var c=o,p=h-l,w=o+p,m=ge.alloc(w);for(m.write(r);p--;)m.write("=",c++);return m.toString()}i.default=t}),xMt=Du(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var t=TMt();function r(w,m){return m===void 0&&(m="utf8"),ge.isBuffer(w)?l(w.toString("base64")):l(ge.from(w,m).toString("base64"))}function h(w,m){return m===void 0&&(m="utf8"),ge.from(o(w),"base64").toString(m)}function o(w){return w=w.toString(),t.default(w).replace(/\-/g,"+").replace(/_/g,"/")}function l(w){return w.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function c(w){return ge.from(o(w),"base64")}var p=r;p.encode=r,p.decode=h,p.toBase64=o,p.fromBase64=l,p.toBuffer=c,i.default=p}),ek=Du((i,t)=>{t.exports=xMt().default,t.exports.default=t.exports}),Met=Du(i=>{"use strict";i.byteLength=w,i.toByteArray=y,i.fromByteArray=T;var t=[],r=[],h=typeof Uint8Array<"u"?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(l=0,c=o.length;l<c;++l)t[l]=o[l],r[o.charCodeAt(l)]=l;var l,c;r[45]=62,r[95]=63;function p(A){var R=A.length;if(R%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=A.indexOf("=");B===-1&&(B=R);var C=B===R?0:4-B%4;return[B,C]}function w(A){var R=p(A),B=R[0],C=R[1];return(B+C)*3/4-C}function m(A,R,B){return(R+B)*3/4-B}function y(A){var R,B=p(A),C=B[0],P=B[1],N=new h(m(A,C,P)),q=0,W=P>0?C-4:C,J;for(J=0;J<W;J+=4)R=r[A.charCodeAt(J)]<<18|r[A.charCodeAt(J+1)]<<12|r[A.charCodeAt(J+2)]<<6|r[A.charCodeAt(J+3)],N[q++]=R>>16&255,N[q++]=R>>8&255,N[q++]=R&255;return P===2&&(R=r[A.charCodeAt(J)]<<2|r[A.charCodeAt(J+1)]>>4,N[q++]=R&255),P===1&&(R=r[A.charCodeAt(J)]<<10|r[A.charCodeAt(J+1)]<<4|r[A.charCodeAt(J+2)]>>2,N[q++]=R>>8&255,N[q++]=R&255),N}function v(A){return t[A>>18&63]+t[A>>12&63]+t[A>>6&63]+t[A&63]}function M(A,R,B){for(var C,P=[],N=R;N<B;N+=3)C=(A[N]<<16&16711680)+(A[N+1]<<8&65280)+(A[N+2]&255),P.push(v(C));return P.join("")}function T(A){for(var R,B=A.length,C=B%3,P=[],N=16383,q=0,W=B-C;q<W;q+=N)P.push(M(A,q,q+N>W?W:q+N));return C===1?(R=A[B-1],P.push(t[R>>2]+t[R<<4&63]+"==")):C===2&&(R=(A[B-2]<<8)+A[B-1],P.push(t[R>>10]+t[R>>4&63]+t[R<<2&63]+"=")),P.join("")}}),Eet=Du(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.b64UrlDecode=i.b64UrlEncode=i.bufferTob64Url=i.bufferTob64=i.b64UrlToBuffer=i.stringToB64Url=i.stringToBuffer=i.bufferToString=i.b64UrlToString=i.concatBuffers=void 0;var t=Met();function r(M){let T=0;for(let B=0;B<M.length;B++)T+=M[B].byteLength;let A=new Uint8Array(T),R=0;A.set(new Uint8Array(M[0]),R),R+=M[0].byteLength;for(let B=1;B<M.length;B++)A.set(new Uint8Array(M[B]),R),R+=M[B].byteLength;return A}i.concatBuffers=r;function h(M){let T=p(M);return o(T)}i.b64UrlToString=h;function o(M){return new TextDecoder("utf-8",{fatal:!0}).decode(M)}i.bufferToString=o;function l(M){return new TextEncoder().encode(M)}i.stringToBuffer=l;function c(M){return m(l(M))}i.stringToB64Url=c;function p(M){return new Uint8Array(t.toByteArray(v(M)))}i.b64UrlToBuffer=p;function w(M){return t.fromByteArray(new Uint8Array(M))}i.bufferTob64=w;function m(M){return y(w(M))}i.bufferTob64Url=m;function y(M){return M.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}i.b64UrlEncode=y;function v(M){M=M.replace(/\-/g,"+").replace(/\_/g,"/");let T;return M.length%4==0?T=0:T=4-M.length%4,M.concat("=".repeat(T))}i.b64UrlDecode=v}),RMt=Du(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var t=Eet(),r=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 h=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),o=await this.driver.exportKey("jwk",h.privateKey);return{kty:o.kty,e:o.e,n:o.n,d:o.d,p:o.p,q:o.q,dp:o.dp,dq:o.dq,qi:o.qi}}async sign(h,o,{saltLength:l}={}){let c=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(h),o);return new Uint8Array(c)}async hash(h,o="SHA-256"){let l=await this.driver.digest(o,h);return new Uint8Array(l)}async verify(h,o,l){let c={kty:"RSA",e:"AQAB",n:h},p=await this.jwkToPublicCryptoKey(c),w=await this.driver.digest("SHA-256",o),m=await this.driver.verify({name:"RSA-PSS",saltLength:0},p,l,o),y=await this.driver.verify({name:"RSA-PSS",saltLength:32},p,l,o),v=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((p.algorithm.modulusLength-1)/8)-w.byteLength-2},p,l,o);return m||y||v}async jwkToCryptoKey(h){return this.driver.importKey("jwk",h,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(h){return this.driver.importKey("jwk",h,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let h=crypto?.subtle;return h===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(o=>typeof h[o]=="function")}async encrypt(h,o,l){let c=await this.driver.importKey("raw",typeof o=="string"?t.stringToBuffer(o):o,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:l?t.stringToBuffer(l):t.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),w=new Uint8Array(16);crypto.getRandomValues(w);let m=await this.driver.encrypt({name:"AES-CBC",iv:w},p,h);return t.concatBuffers([w,m])}async decrypt(h,o,l){let c=await this.driver.importKey("raw",typeof o=="string"?t.stringToBuffer(o):o,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:l?t.stringToBuffer(l):t.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),w=h.slice(0,16),m=await this.driver.decrypt({name:"AES-CBC",iv:w},p,h.slice(16));return t.concatBuffers([m])}};i.default=r}),kMt=Du(i=>{i.read=function(t,r,h,o,l){var c,p,w=l*8-o-1,m=(1<<w)-1,y=m>>1,v=-7,M=h?l-1:0,T=h?-1:1,A=t[r+M];for(M+=T,c=A&(1<<-v)-1,A>>=-v,v+=w;v>0;c=c*256+t[r+M],M+=T,v-=8);for(p=c&(1<<-v)-1,c>>=-v,v+=o;v>0;p=p*256+t[r+M],M+=T,v-=8);if(c===0)c=1-y;else{if(c===m)return p?NaN:(A?-1:1)*(1/0);p=p+Math.pow(2,o),c=c-y}return(A?-1:1)*p*Math.pow(2,c-o)},i.write=function(t,r,h,o,l,c){var p,w,m,y=c*8-l-1,v=(1<<y)-1,M=v>>1,T=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=o?0:c-1,R=o?1:-1,B=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(w=isNaN(r)?1:0,p=v):(p=Math.floor(Math.log(r)/Math.LN2),r*(m=Math.pow(2,-p))<1&&(p--,m*=2),p+M>=1?r+=T/m:r+=T*Math.pow(2,1-M),r*m>=2&&(p++,m/=2),p+M>=v?(w=0,p=v):p+M>=1?(w=(r*m-1)*Math.pow(2,l),p=p+M):(w=r*Math.pow(2,M-1)*Math.pow(2,l),p=0));l>=8;t[h+A]=w&255,A+=R,w/=256,l-=8);for(p=p<<l|w,y+=l;y>0;t[h+A]=p&255,A+=R,p/=256,y-=8);t[h+A-R]|=B*128}}),LR=Du(i=>{"use strict";var t=Met(),r=kMt(),h=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=p,i.SlowBuffer=P,i.INSPECT_MAX_BYTES=50;var o=2147483647;i.kMaxLength=o,p.TYPED_ARRAY_SUPPORT=l(),!p.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{let I=new Uint8Array(1),O={foo:function(){return 42}};return Object.setPrototypeOf(O,Uint8Array.prototype),Object.setPrototypeOf(I,O),I.foo()===42}catch{return!1}}Object.defineProperty(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}}),Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}});function c(I){if(I>o)throw new RangeError('The value "'+I+'" is invalid for option "size"');let O=new Uint8Array(I);return Object.setPrototypeOf(O,p.prototype),O}function p(I,O,L){if(typeof I=="number"){if(typeof O=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(I)}return w(I,O,L)}p.poolSize=8192;function w(I,O,L){if(typeof I=="string")return M(I,O);if(ArrayBuffer.isView(I))return A(I);if(I==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof I);if(mt(I,ArrayBuffer)||I&&mt(I.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(I,SharedArrayBuffer)||I&&mt(I.buffer,SharedArrayBuffer)))return R(I,O,L);if(typeof I=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let V=I.valueOf&&I.valueOf();if(V!=null&&V!==I)return p.from(V,O,L);let st=B(I);if(st)return st;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof I[Symbol.toPrimitive]=="function")return p.from(I[Symbol.toPrimitive]("string"),O,L);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof I)}p.from=function(I,O,L){return w(I,O,L)},Object.setPrototypeOf(p.prototype,Uint8Array.prototype),Object.setPrototypeOf(p,Uint8Array);function m(I){if(typeof I!="number")throw new TypeError('"size" argument must be of type number');if(I<0)throw new RangeError('The value "'+I+'" is invalid for option "size"')}function y(I,O,L){return m(I),I<=0?c(I):O!==void 0?typeof L=="string"?c(I).fill(O,L):c(I).fill(O):c(I)}p.alloc=function(I,O,L){return y(I,O,L)};function v(I){return m(I),c(I<0?0:C(I)|0)}p.allocUnsafe=function(I){return v(I)},p.allocUnsafeSlow=function(I){return v(I)};function M(I,O){if((typeof O!="string"||O==="")&&(O="utf8"),!p.isEncoding(O))throw new TypeError("Unknown encoding: "+O);let L=N(I,O)|0,V=c(L),st=V.write(I,O);return st!==L&&(V=V.slice(0,st)),V}function T(I){let O=I.length<0?0:C(I.length)|0,L=c(O);for(let V=0;V<O;V+=1)L[V]=I[V]&255;return L}function A(I){if(mt(I,Uint8Array)){let O=new Uint8Array(I);return R(O.buffer,O.byteOffset,O.byteLength)}return T(I)}function R(I,O,L){if(O<0||I.byteLength<O)throw new RangeError('"offset" is outside of buffer bounds');if(I.byteLength<O+(L||0))throw new RangeError('"length" is outside of buffer bounds');let V;return O===void 0&&L===void 0?V=new Uint8Array(I):L===void 0?V=new Uint8Array(I,O):V=new Uint8Array(I,O,L),Object.setPrototypeOf(V,p.prototype),V}function B(I){if(p.isBuffer(I)){let O=C(I.length)|0,L=c(O);return L.length===0||I.copy(L,0,0,O),L}if(I.length!==void 0)return typeof I.length!="number"||wt(I.length)?c(0):T(I);if(I.type==="Buffer"&&Array.isArray(I.data))return T(I.data)}function C(I){if(I>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return I|0}function P(I){return+I!=I&&(I=0),p.alloc(+I)}p.isBuffer=function(I){return I!=null&&I._isBuffer===!0&&I!==p.prototype},p.compare=function(I,O){if(mt(I,Uint8Array)&&(I=p.from(I,I.offset,I.byteLength)),mt(O,Uint8Array)&&(O=p.from(O,O.offset,O.byteLength)),!p.isBuffer(I)||!p.isBuffer(O))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(I===O)return 0;let L=I.length,V=O.length;for(let st=0,ft=Math.min(L,V);st<ft;++st)if(I[st]!==O[st]){L=I[st],V=O[st];break}return L<V?-1:V<L?1:0},p.isEncoding=function(I){switch(String(I).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},p.concat=function(I,O){if(!Array.isArray(I))throw new TypeError('"list" argument must be an Array of Buffers');if(I.length===0)return p.alloc(0);let L;if(O===void 0)for(O=0,L=0;L<I.length;++L)O+=I[L].length;let V=p.allocUnsafe(O),st=0;for(L=0;L<I.length;++L){let ft=I[L];if(mt(ft,Uint8Array))st+ft.length>V.length?(p.isBuffer(ft)||(ft=p.from(ft)),ft.copy(V,st)):Uint8Array.prototype.set.call(V,ft,st);else if(p.isBuffer(ft))ft.copy(V,st);else throw new TypeError('"list" argument must be an Array of Buffers');st+=ft.length}return V};function N(I,O){if(p.isBuffer(I))return I.length;if(ArrayBuffer.isView(I)||mt(I,ArrayBuffer))return I.byteLength;if(typeof I!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof I);let L=I.length,V=arguments.length>2&&arguments[2]===!0;if(!V&&L===0)return 0;let st=!1;for(;;)switch(O){case"ascii":case"latin1":case"binary":return L;case"utf8":case"utf-8":return ut(I).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L*2;case"hex":return L>>>1;case"base64":return bt(I).length;default:if(st)return V?-1:ut(I).length;O=(""+O).toLowerCase(),st=!0}}p.byteLength=N;function q(I,O,L){let V=!1;if((O===void 0||O<0)&&(O=0),O>this.length||((L===void 0||L>this.length)&&(L=this.length),L<=0)||(L>>>=0,O>>>=0,L<=O))return"";for(I||(I="utf8");;)switch(I){case"hex":return e(this,O,L);case"utf8":case"utf-8":return d(this,O,L);case"ascii":return x(this,O,L);case"latin1":case"binary":return a(this,O,L);case"base64":return f(this,O,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u(this,O,L);default:if(V)throw new TypeError("Unknown encoding: "+I);I=(I+"").toLowerCase(),V=!0}}p.prototype._isBuffer=!0;function W(I,O,L){let V=I[O];I[O]=I[L],I[L]=V}p.prototype.swap16=function(){let I=this.length;if(I%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let O=0;O<I;O+=2)W(this,O,O+1);return this},p.prototype.swap32=function(){let I=this.length;if(I%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let O=0;O<I;O+=4)W(this,O,O+3),W(this,O+1,O+2);return this},p.prototype.swap64=function(){let I=this.length;if(I%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let O=0;O<I;O+=8)W(this,O,O+7),W(this,O+1,O+6),W(this,O+2,O+5),W(this,O+3,O+4);return this},p.prototype.toString=function(){let I=this.length;return I===0?"":arguments.length===0?d(this,0,I):q.apply(this,arguments)},p.prototype.toLocaleString=p.prototype.toString,p.prototype.equals=function(I){if(!p.isBuffer(I))throw new TypeError("Argument must be a Buffer");return this===I?!0:p.compare(this,I)===0},p.prototype.inspect=function(){let I="",O=i.INSPECT_MAX_BYTES;return I=this.toString("hex",0,O).replace(/(.{2})/g,"$1 ").trim(),this.length>O&&(I+=" ... "),"<Buffer "+I+">"},h&&(p.prototype[h]=p.prototype.inspect),p.prototype.compare=function(I,O,L,V,st){if(mt(I,Uint8Array)&&(I=p.from(I,I.offset,I.byteLength)),!p.isBuffer(I))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof I);if(O===void 0&&(O=0),L===void 0&&(L=I?I.length:0),V===void 0&&(V=0),st===void 0&&(st=this.length),O<0||L>I.length||V<0||st>this.length)throw new RangeError("out of range index");if(V>=st&&O>=L)return 0;if(V>=st)return-1;if(O>=L)return 1;if(O>>>=0,L>>>=0,V>>>=0,st>>>=0,this===I)return 0;let ft=st-V,ht=L-O,Et=Math.min(ft,ht),_t=this.slice(V,st),vt=I.slice(O,L);for(let Qt=0;Qt<Et;++Qt)if(_t[Qt]!==vt[Qt]){ft=_t[Qt],ht=vt[Qt];break}return ft<ht?-1:ht<ft?1:0};function J(I,O,L,V,st){if(I.length===0)return-1;if(typeof L=="string"?(V=L,L=0):L>2147483647?L=2147483647:L<-2147483648&&(L=-2147483648),L=+L,wt(L)&&(L=st?0:I.length-1),L<0&&(L=I.length+L),L>=I.length){if(st)return-1;L=I.length-1}else if(L<0)if(st)L=0;else return-1;if(typeof O=="string"&&(O=p.from(O,V)),p.isBuffer(O))return O.length===0?-1:F(I,O,L,V,st);if(typeof O=="number")return O=O&255,typeof Uint8Array.prototype.indexOf=="function"?st?Uint8Array.prototype.indexOf.call(I,O,L):Uint8Array.prototype.lastIndexOf.call(I,O,L):F(I,[O],L,V,st);throw new TypeError("val must be string, number or Buffer")}function F(I,O,L,V,st){let ft=1,ht=I.length,Et=O.length;if(V!==void 0&&(V=String(V).toLowerCase(),V==="ucs2"||V==="ucs-2"||V==="utf16le"||V==="utf-16le")){if(I.length<2||O.length<2)return-1;ft=2,ht/=2,Et/=2,L/=2}function _t(Qt,It){return ft===1?Qt[It]:Qt.readUInt16BE(It*ft)}let vt;if(st){let Qt=-1;for(vt=L;vt<ht;vt++)if(_t(I,vt)===_t(O,Qt===-1?0:vt-Qt)){if(Qt===-1&&(Qt=vt),vt-Qt+1===Et)return Qt*ft}else Qt!==-1&&(vt-=vt-Qt),Qt=-1}else for(L+Et>ht&&(L=ht-Et),vt=L;vt>=0;vt--){let Qt=!0;for(let It=0;It<Et;It++)if(_t(I,vt+It)!==_t(O,It)){Qt=!1;break}if(Qt)return vt}return-1}p.prototype.includes=function(I,O,L){return this.indexOf(I,O,L)!==-1},p.prototype.indexOf=function(I,O,L){return J(this,I,O,L,!0)},p.prototype.lastIndexOf=function(I,O,L){return J(this,I,O,L,!1)};function H(I,O,L,V){L=Number(L)||0;let st=I.length-L;V?(V=Number(V),V>st&&(V=st)):V=st;let ft=O.length;V>ft/2&&(V=ft/2);let ht;for(ht=0;ht<V;++ht){let Et=parseInt(O.substr(ht*2,2),16);if(wt(Et))return ht;I[L+ht]=Et}return ht}function Y(I,O,L,V){return lt(ut(O,I.length-L),I,L,V)}function E(I,O,L,V){return lt(pt(O),I,L,V)}function n(I,O,L,V){return lt(bt(O),I,L,V)}function s(I,O,L,V){return lt(St(O,I.length-L),I,L,V)}p.prototype.write=function(I,O,L,V){if(O===void 0)V="utf8",L=this.length,O=0;else if(L===void 0&&typeof O=="string")V=O,L=this.length,O=0;else if(isFinite(O))O=O>>>0,isFinite(L)?(L=L>>>0,V===void 0&&(V="utf8")):(V=L,L=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let st=this.length-O;if((L===void 0||L>st)&&(L=st),I.length>0&&(L<0||O<0)||O>this.length)throw new RangeError("Attempt to write outside buffer bounds");V||(V="utf8");let ft=!1;for(;;)switch(V){case"hex":return H(this,I,O,L);case"utf8":case"utf-8":return Y(this,I,O,L);case"ascii":case"latin1":case"binary":return E(this,I,O,L);case"base64":return n(this,I,O,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s(this,I,O,L);default:if(ft)throw new TypeError("Unknown encoding: "+V);V=(""+V).toLowerCase(),ft=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function f(I,O,L){return O===0&&L===I.length?t.fromByteArray(I):t.fromByteArray(I.slice(O,L))}function d(I,O,L){L=Math.min(I.length,L);let V=[],st=O;for(;st<L;){let ft=I[st],ht=null,Et=ft>239?4:ft>223?3:ft>191?2:1;if(st+Et<=L){let _t,vt,Qt,It;switch(Et){case 1:ft<128&&(ht=ft);break;case 2:_t=I[st+1],(_t&192)===128&&(It=(ft&31)<<6|_t&63,It>127&&(ht=It));break;case 3:_t=I[st+1],vt=I[st+2],(_t&192)===128&&(vt&192)===128&&(It=(ft&15)<<12|(_t&63)<<6|vt&63,It>2047&&(It<55296||It>57343)&&(ht=It));break;case 4:_t=I[st+1],vt=I[st+2],Qt=I[st+3],(_t&192)===128&&(vt&192)===128&&(Qt&192)===128&&(It=(ft&15)<<18|(_t&63)<<12|(vt&63)<<6|Qt&63,It>65535&&It<1114112&&(ht=It))}}ht===null?(ht=65533,Et=1):ht>65535&&(ht-=65536,V.push(ht>>>10&1023|55296),ht=56320|ht&1023),V.push(ht),st+=Et}return S(V)}var g=4096;function S(I){let O=I.length;if(O<=g)return String.fromCharCode.apply(String,I);let L="",V=0;for(;V<O;)L+=String.fromCharCode.apply(String,I.slice(V,V+=g));return L}function x(I,O,L){let V="";L=Math.min(I.length,L);for(let st=O;st<L;++st)V+=String.fromCharCode(I[st]&127);return V}function a(I,O,L){let V="";L=Math.min(I.length,L);for(let st=O;st<L;++st)V+=String.fromCharCode(I[st]);return V}function e(I,O,L){let V=I.length;(!O||O<0)&&(O=0),(!L||L<0||L>V)&&(L=V);let st="";for(let ft=O;ft<L;++ft)st+=Mt[I[ft]];return st}function u(I,O,L){let V=I.slice(O,L),st="";for(let ft=0;ft<V.length-1;ft+=2)st+=String.fromCharCode(V[ft]+V[ft+1]*256);return st}p.prototype.slice=function(I,O){let L=this.length;I=~~I,O=O===void 0?L:~~O,I<0?(I+=L,I<0&&(I=0)):I>L&&(I=L),O<0?(O+=L,O<0&&(O=0)):O>L&&(O=L),O<I&&(O=I);let V=this.subarray(I,O);return Object.setPrototypeOf(V,p.prototype),V};function b(I,O,L){if(I%1!==0||I<0)throw new RangeError("offset is not uint");if(I+O>L)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I],st=1,ft=0;for(;++ft<O&&(st*=256);)V+=this[I+ft]*st;return V},p.prototype.readUintBE=p.prototype.readUIntBE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I+--O],st=1;for(;O>0&&(st*=256);)V+=this[I+--O]*st;return V},p.prototype.readUint8=p.prototype.readUInt8=function(I,O){return I=I>>>0,O||b(I,1,this.length),this[I]},p.prototype.readUint16LE=p.prototype.readUInt16LE=function(I,O){return I=I>>>0,O||b(I,2,this.length),this[I]|this[I+1]<<8},p.prototype.readUint16BE=p.prototype.readUInt16BE=function(I,O){return I=I>>>0,O||b(I,2,this.length),this[I]<<8|this[I+1]},p.prototype.readUint32LE=p.prototype.readUInt32LE=function(I,O){return I=I>>>0,O||b(I,4,this.length),(this[I]|this[I+1]<<8|this[I+2]<<16)+this[I+3]*16777216},p.prototype.readUint32BE=p.prototype.readUInt32BE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]*16777216+(this[I+1]<<16|this[I+2]<<8|this[I+3])},p.prototype.readBigUInt64LE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=O+this[++I]*2**8+this[++I]*2**16+this[++I]*2**24,st=this[++I]+this[++I]*2**8+this[++I]*2**16+L*2**24;return BigInt(V)+(BigInt(st)<<BigInt(32))}),p.prototype.readBigUInt64BE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=O*2**24+this[++I]*2**16+this[++I]*2**8+this[++I],st=this[++I]*2**24+this[++I]*2**16+this[++I]*2**8+L;return(BigInt(V)<<BigInt(32))+BigInt(st)}),p.prototype.readIntLE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I],st=1,ft=0;for(;++ft<O&&(st*=256);)V+=this[I+ft]*st;return st*=128,V>=st&&(V-=Math.pow(2,8*O)),V},p.prototype.readIntBE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=O,st=1,ft=this[I+--V];for(;V>0&&(st*=256);)ft+=this[I+--V]*st;return st*=128,ft>=st&&(ft-=Math.pow(2,8*O)),ft},p.prototype.readInt8=function(I,O){return I=I>>>0,O||b(I,1,this.length),this[I]&128?(255-this[I]+1)*-1:this[I]},p.prototype.readInt16LE=function(I,O){I=I>>>0,O||b(I,2,this.length);let L=this[I]|this[I+1]<<8;return L&32768?L|4294901760:L},p.prototype.readInt16BE=function(I,O){I=I>>>0,O||b(I,2,this.length);let L=this[I+1]|this[I]<<8;return L&32768?L|4294901760:L},p.prototype.readInt32LE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]|this[I+1]<<8|this[I+2]<<16|this[I+3]<<24},p.prototype.readInt32BE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]<<24|this[I+1]<<16|this[I+2]<<8|this[I+3]},p.prototype.readBigInt64LE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=this[I+4]+this[I+5]*2**8+this[I+6]*2**16+(L<<24);return(BigInt(V)<<BigInt(32))+BigInt(O+this[++I]*2**8+this[++I]*2**16+this[++I]*2**24)}),p.prototype.readBigInt64BE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=(O<<24)+this[++I]*2**16+this[++I]*2**8+this[++I];return(BigInt(V)<<BigInt(32))+BigInt(this[++I]*2**24+this[++I]*2**16+this[++I]*2**8+L)}),p.prototype.readFloatLE=function(I,O){return I=I>>>0,O||b(I,4,this.length),r.read(this,I,!0,23,4)},p.prototype.readFloatBE=function(I,O){return I=I>>>0,O||b(I,4,this.length),r.read(this,I,!1,23,4)},p.prototype.readDoubleLE=function(I,O){return I=I>>>0,O||b(I,8,this.length),r.read(this,I,!0,52,8)},p.prototype.readDoubleBE=function(I,O){return I=I>>>0,O||b(I,8,this.length),r.read(this,I,!1,52,8)};function _(I,O,L,V,st,ft){if(!p.isBuffer(I))throw new TypeError('"buffer" argument must be a Buffer instance');if(O>st||O<ft)throw new RangeError('"value" argument is out of bounds');if(L+V>I.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(I,O,L,V){if(I=+I,O=O>>>0,L=L>>>0,!V){let ht=Math.pow(2,8*L)-1;_(this,I,O,L,ht,0)}let st=1,ft=0;for(this[O]=I&255;++ft<L&&(st*=256);)this[O+ft]=I/st&255;return O+L},p.prototype.writeUintBE=p.prototype.writeUIntBE=function(I,O,L,V){if(I=+I,O=O>>>0,L=L>>>0,!V){let ht=Math.pow(2,8*L)-1;_(this,I,O,L,ht,0)}let st=L-1,ft=1;for(this[O+st]=I&255;--st>=0&&(ft*=256);)this[O+st]=I/ft&255;return O+L},p.prototype.writeUint8=p.prototype.writeUInt8=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,1,255,0),this[O]=I&255,O+1},p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,65535,0),this[O]=I&255,this[O+1]=I>>>8,O+2},p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,65535,0),this[O]=I>>>8,this[O+1]=I&255,O+2},p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,4294967295,0),this[O+3]=I>>>24,this[O+2]=I>>>16,this[O+1]=I>>>8,this[O]=I&255,O+4},p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,4294967295,0),this[O]=I>>>24,this[O+1]=I>>>16,this[O+2]=I>>>8,this[O+3]=I&255,O+4};function k(I,O,L,V,st){U(O,V,st,I,L,7);let ft=Number(O&BigInt(4294967295));I[L++]=ft,ft=ft>>8,I[L++]=ft,ft=ft>>8,I[L++]=ft,ft=ft>>8,I[L++]=ft;let ht=Number(O>>BigInt(32)&BigInt(4294967295));return I[L++]=ht,ht=ht>>8,I[L++]=ht,ht=ht>>8,I[L++]=ht,ht=ht>>8,I[L++]=ht,L}function $(I,O,L,V,st){U(O,V,st,I,L,7);let ft=Number(O&BigInt(4294967295));I[L+7]=ft,ft=ft>>8,I[L+6]=ft,ft=ft>>8,I[L+5]=ft,ft=ft>>8,I[L+4]=ft;let ht=Number(O>>BigInt(32)&BigInt(4294967295));return I[L+3]=ht,ht=ht>>8,I[L+2]=ht,ht=ht>>8,I[L+1]=ht,ht=ht>>8,I[L]=ht,L+8}p.prototype.writeBigUInt64LE=ne(function(I,O=0){return k(this,I,O,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeBigUInt64BE=ne(function(I,O=0){return $(this,I,O,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeIntLE=function(I,O,L,V){if(I=+I,O=O>>>0,!V){let Et=Math.pow(2,8*L-1);_(this,I,O,L,Et-1,-Et)}let st=0,ft=1,ht=0;for(this[O]=I&255;++st<L&&(ft*=256);)I<0&&ht===0&&this[O+st-1]!==0&&(ht=1),this[O+st]=(I/ft>>0)-ht&255;return O+L},p.prototype.writeIntBE=function(I,O,L,V){if(I=+I,O=O>>>0,!V){let Et=Math.pow(2,8*L-1);_(this,I,O,L,Et-1,-Et)}let st=L-1,ft=1,ht=0;for(this[O+st]=I&255;--st>=0&&(ft*=256);)I<0&&ht===0&&this[O+st+1]!==0&&(ht=1),this[O+st]=(I/ft>>0)-ht&255;return O+L},p.prototype.writeInt8=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,1,127,-128),I<0&&(I=255+I+1),this[O]=I&255,O+1},p.prototype.writeInt16LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,32767,-32768),this[O]=I&255,this[O+1]=I>>>8,O+2},p.prototype.writeInt16BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,32767,-32768),this[O]=I>>>8,this[O+1]=I&255,O+2},p.prototype.writeInt32LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,2147483647,-2147483648),this[O]=I&255,this[O+1]=I>>>8,this[O+2]=I>>>16,this[O+3]=I>>>24,O+4},p.prototype.writeInt32BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,2147483647,-2147483648),I<0&&(I=4294967295+I+1),this[O]=I>>>24,this[O+1]=I>>>16,this[O+2]=I>>>8,this[O+3]=I&255,O+4},p.prototype.writeBigInt64LE=ne(function(I,O=0){return k(this,I,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),p.prototype.writeBigInt64BE=ne(function(I,O=0){return $(this,I,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function it(I,O,L,V,st,ft){if(L+V>I.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("Index out of range")}function Z(I,O,L,V,st){return O=+O,L=L>>>0,st||it(I,O,L,4,34028234663852886e22,-34028234663852886e22),r.write(I,O,L,V,23,4),L+4}p.prototype.writeFloatLE=function(I,O,L){return Z(this,I,O,!0,L)},p.prototype.writeFloatBE=function(I,O,L){return Z(this,I,O,!1,L)};function et(I,O,L,V,st){return O=+O,L=L>>>0,st||it(I,O,L,8,17976931348623157e292,-17976931348623157e292),r.write(I,O,L,V,52,8),L+8}p.prototype.writeDoubleLE=function(I,O,L){return et(this,I,O,!0,L)},p.prototype.writeDoubleBE=function(I,O,L){return et(this,I,O,!1,L)},p.prototype.copy=function(I,O,L,V){if(!p.isBuffer(I))throw new TypeError("argument should be a Buffer");if(L||(L=0),!V&&V!==0&&(V=this.length),O>=I.length&&(O=I.length),O||(O=0),V>0&&V<L&&(V=L),V===L||I.length===0||this.length===0)return 0;if(O<0)throw new RangeError("targetStart out of bounds");if(L<0||L>=this.length)throw new RangeError("Index out of range");if(V<0)throw new RangeError("sourceEnd out of bounds");V>this.length&&(V=this.length),I.length-O<V-L&&(V=I.length-O+L);let st=V-L;return this===I&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(O,L,V):Uint8Array.prototype.set.call(I,this.subarray(L,V),O),st},p.prototype.fill=function(I,O,L,V){if(typeof I=="string"){if(typeof O=="string"?(V=O,O=0,L=this.length):typeof L=="string"&&(V=L,L=this.length),V!==void 0&&typeof V!="string")throw new TypeError("encoding must be a string");if(typeof V=="string"&&!p.isEncoding(V))throw new TypeError("Unknown encoding: "+V);if(I.length===1){let ft=I.charCodeAt(0);(V==="utf8"&&ft<128||V==="latin1")&&(I=ft)}}else typeof I=="number"?I=I&255:typeof I=="boolean"&&(I=Number(I));if(O<0||this.length<O||this.length<L)throw new RangeError("Out of range index");if(L<=O)return this;O=O>>>0,L=L===void 0?this.length:L>>>0,I||(I=0);let st;if(typeof I=="number")for(st=O;st<L;++st)this[st]=I;else{let ft=p.isBuffer(I)?I:p.from(I,V),ht=ft.length;if(ht===0)throw new TypeError('The value "'+I+'" is invalid for argument "value"');for(st=0;st<L-O;++st)this[st+O]=ft[st%ht]}return this};var Q={};function z(I,O,L){Q[I]=class extends L{constructor(){super(),Object.defineProperty(this,"message",{value:O.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${I}]`,this.stack,delete this.name}get code(){return I}set code(V){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:V,writable:!0})}toString(){return`${this.name} [${I}]: ${this.message}`}}}z("ERR_BUFFER_OUT_OF_BOUNDS",function(I){return I?`${I} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),z("ERR_INVALID_ARG_TYPE",function(I,O){return`The "${I}" argument must be of type number. Received type ${typeof O}`},TypeError),z("ERR_OUT_OF_RANGE",function(I,O,L){let V=`The value of "${I}" is out of range.`,st=L;return Number.isInteger(L)&&Math.abs(L)>2**32?st=tt(String(L)):typeof L=="bigint"&&(st=String(L),(L>BigInt(2)**BigInt(32)||L<-(BigInt(2)**BigInt(32)))&&(st=tt(st)),st+="n"),V+=` It must be ${O}. Received ${st}`,V},RangeError);function tt(I){let O="",L=I.length,V=I[0]==="-"?1:0;for(;L>=V+4;L-=3)O=`_${I.slice(L-3,L)}${O}`;return`${I.slice(0,L)}${O}`}function X(I,O,L){j(O,"offset"),(I[O]===void 0||I[O+L]===void 0)&&rt(O,I.length-(L+1))}function U(I,O,L,V,st,ft){if(I>L||I<O){let ht=typeof O=="bigint"?"n":"",Et;throw ft>3?O===0||O===BigInt(0)?Et=`>= 0${ht} and < 2${ht} ** ${(ft+1)*8}${ht}`:Et=`>= -(2${ht} ** ${(ft+1)*8-1}${ht}) and < 2 ** ${(ft+1)*8-1}${ht}`:Et=`>= ${O}${ht} and <= ${L}${ht}`,new Q.ERR_OUT_OF_RANGE("value",Et,I)}X(V,st,ft)}function j(I,O){if(typeof I!="number")throw new Q.ERR_INVALID_ARG_TYPE(O,"number",I)}function rt(I,O,L){throw Math.floor(I)!==I?(j(I,L),new Q.ERR_OUT_OF_RANGE(L||"offset","an integer",I)):O<0?new Q.ERR_BUFFER_OUT_OF_BOUNDS:new Q.ERR_OUT_OF_RANGE(L||"offset",`>= ${L?1:0} and <= ${O}`,I)}var ot=/[^+/0-9A-Za-z-_]/g;function ct(I){if(I=I.split("=")[0],I=I.trim().replace(ot,""),I.length<2)return"";for(;I.length%4!==0;)I=I+"=";return I}function ut(I,O){O=O||1/0;let L,V=I.length,st=null,ft=[];for(let ht=0;ht<V;++ht){if(L=I.charCodeAt(ht),L>55295&&L<57344){if(!st){if(L>56319){(O-=3)>-1&&ft.push(239,191,189);continue}else if(ht+1===V){(O-=3)>-1&&ft.push(239,191,189);continue}st=L;continue}if(L<56320){(O-=3)>-1&&ft.push(239,191,189),st=L;continue}L=(st-55296<<10|L-56320)+65536}else st&&(O-=3)>-1&&ft.push(239,191,189);if(st=null,L<128){if((O-=1)<0)break;ft.push(L)}else if(L<2048){if((O-=2)<0)break;ft.push(L>>6|192,L&63|128)}else if(L<65536){if((O-=3)<0)break;ft.push(L>>12|224,L>>6&63|128,L&63|128)}else if(L<1114112){if((O-=4)<0)break;ft.push(L>>18|240,L>>12&63|128,L>>6&63|128,L&63|128)}else throw new Error("Invalid code point")}return ft}function pt(I){let O=[];for(let L=0;L<I.length;++L)O.push(I.charCodeAt(L)&255);return O}function St(I,O){let L,V,st,ft=[];for(let ht=0;ht<I.length&&!((O-=2)<0);++ht)L=I.charCodeAt(ht),V=L>>8,st=L%256,ft.push(st),ft.push(V);return ft}function bt(I){return t.toByteArray(ct(I))}function lt(I,O,L,V){let st;for(st=0;st<V&&!(st+L>=O.length||st>=I.length);++st)O[st+L]=I[st];return st}function mt(I,O){return I instanceof O||I!=null&&I.constructor!=null&&I.constructor.name!=null&&I.constructor.name===O.name}function wt(I){return I!==I}var Mt=function(){let I="0123456789abcdef",O=new Array(256);for(let L=0;L<16;++L){let V=L*16;for(let st=0;st<16;++st)O[V+st]=I[L]+I[st]}return O}();function ne(I){return typeof BigInt>"u"?nt:I}function nt(){throw new Error("BigInt not supported")}}),IMt=Du((i,t)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,t.exports={Buffer:LR().Buffer,Crypto:window.crypto}):t.exports={Buffer:LR().Buffer,Crypto:crypto}}),Aet={};EMt(Aet,{AVSCTap:()=>Em,ArweaveSigner:()=>rk,DataItem:()=>ym,MAX_TAG_BYTES:()=>_8,MIN_BINARY_SIZE:()=>ok,SIG_CONFIG:()=>op,SignatureConfig:()=>Gs,Signer:()=>Tet,createData:()=>Iet,deserializeTags:()=>l8,indexToType:()=>ik,serializeTags:()=>nk,tagsExceedLimit:()=>ket});var Tet=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(i,t,r,h){throw new Error("You must implement verify method on child")}},BMt=U0(ek(),1),Wh=U0(Eet(),1);async function xet(i){if(Array.isArray(i)){let o=(0,Wh.concatBuffers)([(0,Wh.stringToBuffer)("list"),(0,Wh.stringToBuffer)(i.length.toString())]);return await Ret(i,await Cu().hash(o,"SHA-384"))}let t=i,r=(0,Wh.concatBuffers)([(0,Wh.stringToBuffer)("blob"),(0,Wh.stringToBuffer)(t.byteLength.toString())]),h=(0,Wh.concatBuffers)([await Cu().hash(r,"SHA-384"),await Cu().hash(t,"SHA-384")]);return await Cu().hash(h,"SHA-384")}async function Ret(i,t){if(i.length<1)return t;let r=(0,Wh.concatBuffers)([t,await xet(i[0])]),h=await Cu().hash(r,"SHA-384");return await Ret(i.slice(1),h)}var _R=U0(RMt(),1),OMt=_R.default.default?_R.default.default:_R.default,CMt=class extends OMt{getPublicKey(i){throw new Error("Unimplemented")}},PMt;function Cu(){return PMt??=new CMt}var Gs;(function(i){i[i.ARWEAVE=1]="ARWEAVE",i[i.ED25519=2]="ED25519",i[i.ETHEREUM=3]="ETHEREUM",i[i.SOLANA=4]="SOLANA",i[i.INJECTEDAPTOS=5]="INJECTEDAPTOS",i[i.MULTIAPTOS=6]="MULTIAPTOS",i[i.TYPEDETHEREUM=7]="TYPEDETHEREUM"})(Gs||(Gs={}));var op={[Gs.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[Gs.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[Gs.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[Gs.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[Gs.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[Gs.MULTIAPTOS]:{sigLength:64*32+4,pubLength:32*32+1,sigName:"multiAptos"},[Gs.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},rk=class{signatureType=1;ownerLength=op[1].pubLength;signatureLength=op[1].sigLength;jwk;pk;constructor(i){this.pk=i.n,this.jwk=i}get publicKey(){return BMt.default.toBuffer(this.pk)}sign(i){return Cu().sign(this.jwk,i)}static async verify(i,t,r){return await Cu().verify(i,t,r)}},ik={1:rk},Of=U0(ek(),1);async function DR(i){return xet([(0,Wh.stringToBuffer)("dataitem"),(0,Wh.stringToBuffer)("1"),(0,Wh.stringToBuffer)(i.signatureType.toString()),i.rawOwner,i.rawTarget,i.rawAnchor,i.rawTags,i.rawData])}async function NMt(i,t){let r=await DR(i),h=await t.sign(r),o=await Cu().hash(h);return{signature:ge.from(h),id:ge.from(o)}}async function LMt(i,t){let{signature:r,id:h}=await NMt(i,t);return i.getRaw().set(r,2),h}var Em=class{buf;pos;constructor(i=ge.alloc(_8),t=0){this.buf=i,this.pos=t}writeTags(i){if(!Array.isArray(i))throw new Error("input must be array");let t=i.length,r;if(t)for(this.writeLong(t),r=0;r<t;r++){let h=i[r];if(h?.name===void 0||h?.value===void 0)throw new Error(`Invalid tag format for ${h}, expected {name:string, value: string}`);this.writeString(h.name),this.writeString(h.value)}this.writeLong(0)}toBuffer(){let i=ge.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(i,0,0,this.pos),i}tagsExceedLimit(){return this.pos>this.buf.length}writeLong(i){let t=this.buf,r,h;if(i>=-1073741824&&i<1073741824){h=i>=0?i<<1:~i<<1|1;do t[this.pos]=h&127,h>>=7;while(h&&(t[this.pos++]|=128))}else{r=i>=0?i*2:-i*2-1;do t[this.pos]=r&127,r/=128;while(r>=1&&(t[this.pos++]|=128))}this.pos++,this.buf=t}writeString(i){let t=ge.byteLength(i),r=this.buf;this.writeLong(t);let h=this.pos;if(this.pos+=t,!(this.pos>r.length)){if(t>64)this.buf.write(i,this.pos-t,t,"utf8");else{let o,l,c,p;for(o=0,l=t;o<l;o++)c=i.charCodeAt(o),c<128?r[h++]=c:c<2048?(r[h++]=c>>6|192,r[h++]=c&63|128):(c&64512)===55296&&((p=i.charCodeAt(o+1))&64512)===56320?(c=65536+((c&1023)<<10)+(p&1023),o++,r[h++]=c>>18|240,r[h++]=c>>12&63|128,r[h++]=c>>6&63|128,r[h++]=c&63|128):(r[h++]=c>>12|224,r[h++]=c>>6&63|128,r[h++]=c&63|128)}this.buf=r}}readLong(){let i=0,t=0,r=this.buf,h,o,l,c;do h=r[this.pos++],o=h&128,i|=(h&127)<<t,t+=7;while(o&&t<28);if(o){l=i,c=268435456;do h=r[this.pos++],l+=(h&127)*c,c*=128;while(h&128);return(l%2?-(l+1):l)/2}return i>>1^-(i&1)}skipLong(){let i=this.buf;for(;i[this.pos++]&128;);}readTags(){let i=[],t;for(;t=this.readLong();)for(t<0&&(t=-t,this.skipLong());t--;){let r=this.readString(),h=this.readString();i.push({name:r,value:h})}return i}readString(){let i=this.readLong(),t=this.pos,r=this.buf;if(this.pos+=i,!(this.pos>r.length))return this.buf.slice(t,t+i).toString()}};function nk(i){let t=new Em;return t.writeTags(i),t.toBuffer()}function ket(i){let t=new Em;return t.writeTags(i),t.tagsExceedLimit()}function l8(i){return new Em(i).readTags()}function Jc(i){let t=0;for(let r=i.length-1;r>=0;r--)t=t*256+i[r];return t}function DMt(i){if(i>29)throw new Error("Short too long");let t=[0,0];for(let r=0;r<t.length;r++){let h=i&255;t[r]=h,i=(i-h)/256}return Uint8Array.from(t)}function ptt(i){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let h=i&255;t[r]=h,i=(i-h)/256}return Uint8Array.from(t)}var $Mt=U0(IMt(),1),H1=U0(LR(),1),_8=4096,ok=80,ym=class{binary;_id;constructor(i){this.binary=i}static isDataItem(i){return i.binary!==void 0}get signatureType(){let i=Jc(this.binary.subarray(0,2));if(Gs?.[i]!==void 0)return i;throw new Error("Unknown signature type: "+i)}async isValid(){return ym.verify(this.binary)}get id(){return(async()=>Of.default.encode(await this.rawId))()}set id(i){this._id=Of.default.toBuffer(i)}get rawId(){return(async()=>H1.Buffer.from(await $Mt.Crypto.subtle.digest("SHA-256",this.rawSignature)))()}set rawId(i){this._id=i}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return Of.default.encode(this.rawSignature)}set rawOwner(i){if(i.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${i.byteLength} bytes.`);this.binary.set(i,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return op[this.signatureType].sigLength}get owner(){return Of.default.encode(this.rawOwner)}get ownerLength(){return op[this.signatureType].pubLength}get rawTarget(){let i=this.getTargetStart();return this.binary[i]==1?this.binary.subarray(i+1,i+33):H1.Buffer.alloc(0)}get target(){return Of.default.encode(this.rawTarget)}get rawAnchor(){let i=this.getAnchorStart();return this.binary[i]==1?this.binary.subarray(i+1,i+33):H1.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let i=this.getTagsStart(),t=Jc(this.binary.subarray(i+8,i+16));return this.binary.subarray(i+16,i+16+t)}get tags(){let i=this.getTagsStart();if(Jc(this.binary.subarray(i,i+8))==0)return[];let t=Jc(this.binary.subarray(i+8,i+16));return l8(H1.Buffer.from(this.binary.subarray(i+16,i+16+t)))}get tagsB64Url(){return this.tags.map(i=>({name:Of.default.encode(i.name),value:Of.default.encode(i.value)}))}getStartOfData(){let i=this.getTagsStart(),t=this.binary.subarray(i+8,i+16),r=Jc(t);return i+16+r}get rawData(){let i=this.getTagsStart(),t=this.binary.subarray(i+8,i+16),r=Jc(t),h=i+16+r;return this.binary.subarray(h,this.binary.length)}get data(){return Of.default.encode(this.rawData)}getRaw(){return this.binary}async sign(i){return this._id=await LMt(this,i),this.rawId}async setSignature(i){this.binary.set(i,2),this._id=H1.Buffer.from(await Cu().hash(i))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map(i=>({name:Of.default.encode(i.name),value:Of.default.encode(i.value)})),data:this.data}}static async verify(i){if(i.byteLength<ok)return!1;let t=new ym(i),r=t.signatureType,h=t.getTagsStart(),o=Jc(i.subarray(h,h+8)),l=i.subarray(h+8,h+16),c=Jc(l);if(c>_8)return!1;if(o>0)try{if(l8(H1.Buffer.from(i.subarray(h+16,h+16+c))).length!==o)return!1}catch{return!1}let p=ik[r],w=await DR(t);return await p.verify(t.rawOwner,w,t.rawSignature)}async getSignatureData(){return DR(this)}getTagsStart(){let i=this.getTargetStart(),t=this.binary[i]==1,r=i+(t?33:1),h=this.binary[r]==1;return r+=h?33:1,r}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let i=this.getTargetStart()+1,t=this.binary[this.getTargetStart()]==1;return i+=t?32:0,i}},UMt=U0(ek(),1);function Iet(i,t,r){let h=t.publicKey,o=r?.target?UMt.default.toBuffer(r.target):null,l=1+(o?.byteLength??0),c=r?.anchor?ge.from(r.anchor):null,p=1+(c?.byteLength??0),w=(r?.tags?.length??0)>0?nk(r.tags):null,m=16+(w?w.byteLength:0),y=ge.from(i),v=y.byteLength,M=2+t.signatureLength+t.ownerLength+l+p+m+v,T=ge.alloc(M);if(T.set(DMt(t.signatureType),0),T.set(new Uint8Array(t.signatureLength).fill(0),2),h.byteLength!==t.ownerLength)throw new Error(`Owner must be ${t.ownerLength} bytes, but was incorrectly ${h.byteLength}`);T.set(h,2+t.signatureLength);let A=2+t.signatureLength+t.ownerLength;if(T[A]=o?1:0,o){if(o.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${o.byteLength}`);T.set(o,A+1)}let R=A+l,B=R+1;if(T[R]=c?1:0,c){if(B+=c.byteLength,c.byteLength!==32)throw new Error("Anchor must be 32 bytes");T.set(c,R+1)}T.set(ptt(r?.tags?.length??0),B);let C=ptt(w?.byteLength??0);T.set(C,B+8),w&&T.set(w,B+16);let P=B+m;return T.set(y,P),new ym(T)}var ak={...Aet};globalThis.arbundles??=ak;var qMt=ak,FMt=ak;globalThis.Buffer||(globalThis.Buffer=wet.Buffer);var{DataItem:jMt}=_et;function zMt(i){return async({data:r,tags:h,target:o,anchor:l,createDataItem:c=p=>new jMt(p)})=>{let p=await i.signDataItem({data:r,tags:h,target:o,anchor:l}),w=c(wet.Buffer.from(p));return{id:await w.id,raw:await w.getRaw()}}}var WMt=globalThis.GATEWAY_URL||void 0,KMt=globalThis.MU_URL||void 0,HMt=globalThis.CU_URL||void 0,GMt=globalThis.GRAPHQL_URL||void 0,{result:jWt,results:zWt,message:WWt,spawn:KWt,monitor:HWt,unmonitor:GWt,dryrun:VWt,assign:ZWt}=Sm({GATEWAY_URL:WMt,MU_URL:KMt,CU_URL:HMt,GRAPHQL_URL:GMt}),JWt=bet.createDataItemSigner;var Bet=sc(z5(),1);Tt();Rt();xt();function sk(i){try{return JSON.parse(i)}catch{return i}}var Ys=class i{logger;processId;ao;constructor({processId:t,ao:r=Sm(),logger:h=new pa({level:"info"})}){this.processId=t,this.logger=h,this.ao=r}static async createAoSigner(t){return t.publicKey===void 0&&"setPublicKey"in t&&await t.setPublicKey(),async({data:h,tags:o,target:l,anchor:c})=>{let p=(0,Bet.createData)(h,t,{tags:o,target:l,anchor:c});return p.sign(t).then(async()=>({id:await p.id,raw:await p.getRaw()}))}}async read({tags:t,retries:r=3}){let h=0,o;for(;h<r;)try{this.logger.debug("Evaluating read interaction on contract",{tags:t});let l=await this.ao.dryrun({process:this.processId,tags:t});if(l.Messages.length===0)throw new Error(`Process ${this.processId} does not support provided action.`);let p=l.Messages[0].Tags.find(m=>m.name==="Error");if(p)throw new Error(`${p.Value}: ${l.Messages[0].Data}`);return this.logger.debug("Read interaction result",{result:l.Messages[0].Data}),l.Messages[0].Data===void 0?{}:sk(l.Messages[0].Data)}catch(l){h++,this.logger.debug(`Read attempt ${h} failed`,{error:l,tags:t}),o=l,await new Promise(c=>setTimeout(c,2**h*1e3))}throw o}async send({tags:t,data:r,signer:h,retries:o=3}){let l=0,c;for(;l<o;)try{this.logger.debug("Evaluating send interaction on contract",{tags:t,data:r,processId:this.processId});let p=await this.ao.message({process:this.processId,tags:[...t,{name:"AR-IO-SDK",value:o1}],data:typeof r!="string"?JSON.stringify(r):r,signer:await i.createAoSigner(h)});this.logger.debug("Sent message to process",{messageId:p,processId:this.processId});let w=await this.ao.result({message:p,process:this.processId});if(this.logger.debug("Message result",{output:w,messageId:p,processId:this.processId}),w.Messages?.length===0||w.Messages===void 0)return{id:p};let y=w.Messages[0].Tags.find(M=>M.name==="Error");if(y){let M=w.Messages[0].Data;throw new a1(`${y.Value}: ${M}`)}if(w.Messages.length===0)throw new Error(`Process ${this.processId} does not support provided action.`);if(w.Messages[0].Data===void 0)return{id:p};let v=sk(w.Messages[0].Data);return this.logger.debug("Message result data",{resultData:v,messageId:p,processId:this.processId}),{id:p,result:v}}catch(p){if(this.logger.error("Error sending message to process",{error:p.message,processId:this.processId,tags:t}),p.message.includes("500"))this.logger.debug("Retrying send interaction",{attempts:l,retries:o,error:p.message,processId:this.processId}),await new Promise(w=>setTimeout(w,2**l*2e3)),l++,c=p;else throw p}throw c}};var Am=class{static init(t){if(t&&t.signer){let{signer:r,...h}=t;return new hk({...h,signer:r})}return new M8(t)}},M8=class{process;arweave;constructor(t,r=Oet.default.init({})){if(!t)this.process=new Ys({processId:Od});else if(Rl(t))this.process=t.process;else if(kl(t))this.process=new Ys({processId:t.processId,logger:new pa({level:"info"})});else throw new No;this.arweave=r}async getInfo(){return this.process.read({tags:[{name:"Action",value:"Info"}]})}async getEpochSettings(t){let h=[{name:"Action",value:"Epoch-Settings"},{name:"Timestamp",value:t?.timestamp?.toString()??(await this.arweave.blocks.getCurrent().then(o=>({timestamp:o.timestamp*1e3})).catch(()=>({timestamp:Date.now()}))).timestamp.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return this.process.read({tags:h})}async getEpoch(t){let h=[{name:"Action",value:"Epoch"},{name:"Timestamp",value:t?.timestamp?.toString()??(await this.arweave.blocks.getCurrent().then(o=>({timestamp:o.timestamp*1e3})).catch(()=>({timestamp:Date.now()}))).timestamp.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return this.process.read({tags:h})}async getArNSRecord({name:t}){return this.process.read({tags:[{name:"Action",value:"Record"},{name:"Name",value:t}]})}async getArNSRecords(){return this.process.read({tags:[{name:"Action",value:"Records"}]})}async getArNSReservedNames(){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"}]})}async getArNSReservedName({name:t}){return this.process.read({tags:[{name:"Action",value:"Reserved-Name"},{name:"Name",value:t}]})}async getBalance({address:t}){return this.process.read({tags:[{name:"Action",value:"Balance"},{name:"Address",value:t}]})}async getBalances(){return this.process.read({tags:[{name:"Action",value:"Balances"}]})}async getGateway({address:t}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:t}]})}async getGateways(){return this.process.read({tags:[{name:"Action",value:"Gateways"}]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"},{name:"Timestamp",value:(await this.arweave.blocks.getCurrent().then(t=>({timestamp:t.timestamp*1e3})).catch(()=>({timestamp:Date.now()}))).timestamp.toString()}]})}async getPrescribedObservers(t){let h=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Timestamp",value:t?.timestamp?.toString()??(await this.arweave.blocks.getCurrent().then(o=>({timestamp:o.timestamp*1e3})).catch(()=>({timestamp:Date.now()}))).timestamp.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return this.process.read({tags:h})}async getPrescribedNames(t){let h=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Timestamp",value:t?.timestamp?.toString()??(await this.arweave.blocks.getCurrent().then(o=>({timestamp:o.timestamp*1e3})).catch(()=>({timestamp:Date.now()}))).timestamp.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return this.process.read({tags:h})}async getObservations(t){let h=[{name:"Action",value:"Epoch-Observations"},{name:"Timestamp",value:t?.timestamp?.toString()??(await this.arweave.blocks.getCurrent().then(o=>({timestamp:o.timestamp*1e3})).catch(()=>({timestamp:`${Date.now()}`}))).timestamp.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return this.process.read({tags:h})}async getDistributions(t){let h=[{name:"Action",value:"Epoch-Distributions"},{name:"Timestamp",value:t?.timestamp?.toString()??(await this.arweave.blocks.getCurrent().then(o=>({timestamp:o.timestamp*1e3})).catch(()=>({timestamp:Date.now()}))).timestamp.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return this.process.read({tags:h})}async getTokenCost({intent:t,purchaseType:r,years:h,name:o,quantity:l}){let p=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:t},{name:"Name",value:o},{name:"Years",value:h?.toString()},{name:"Quantity",value:l?.toString()},{name:"Purchase-Type",value:r},{name:"Timestamp",value:(await this.arweave.blocks.getCurrent().then(w=>({timestamp:w.timestamp*1e3})).catch(()=>({timestamp:Date.now()}))).timestamp.toString()}].filter(w=>w.value!==void 0);return this.process.read({tags:p})}},hk=class extends M8{signer;constructor({signer:t,...r}){if(Object.keys(r).length===0)super({process:new Ys({processId:Od})}),this.signer=t;else if(Rl(r))super({process:r.process}),this.signer=t;else if(kl(r))super({process:new Ys({processId:r.processId})}),this.signer=t;else throw new No}async transfer({target:t,qty:r},h){let{tags:o=[]}=h||{};return this.process.send({tags:[...o,{name:"Action",value:"Transfer"},{name:"Recipient",value:t},{name:"Quantity",value:r.valueOf().toString()}],signer:this.signer})}async joinNetwork({operatorStake:t,allowDelegatedStaking:r,delegateRewardShareRatio:h,fqdn:o,label:l,minDelegatedStake:c,note:p,port:w,properties:m,protocol:y,autoStake:v,observerAddress:M},T){let{tags:A=[]}=T||{},B=[...A,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:t.valueOf().toString()},{name:"Allow-Delegated-Staking",value:r.toString()},{name:"Delegate-Reward-Share-Ratio",value:h.toString()},{name:"FQDN",value:o},{name:"Label",value:l},{name:"Min-Delegated-Stake",value:c.valueOf().toString()},{name:"Note",value:p},{name:"Port",value:w.toString()},{name:"Properties",value:m},{name:"Protocol",value:y},{name:"Auto-Stake",value:v.toString()},{name:"Observer-Address",value:M}].filter(C=>C.value!==void 0);return this.process.send({signer:this.signer,tags:B})}async updateGatewaySettings({allowDelegatedStaking:t,delegateRewardShareRatio:r,fqdn:h,label:o,minDelegatedStake:l,note:c,port:p,properties:w,protocol:m,autoStake:y,observerAddress:v},M){let{tags:T=[]}=M||{},R=[...T,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:o},{name:"Note",value:c},{name:"FQDN",value:h},{name:"Port",value:p?.toString()},{name:"Properties",value:w},{name:"Protocol",value:m},{name:"Observer-Address",value:v},{name:"Allow-Delegated-Staking",value:t?.toString()},{name:"Delegate-Reward-Share-Ratio",value:r?.toString()},{name:"Min-Delegated-Stake",value:l?.valueOf().toString()},{name:"Auto-Stake",value:y?.toString()}].filter(B=>B.value!==void 0);return this.process.send({signer:this.signer,tags:R})}async delegateStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:t.target},{name:"Quantity",value:t.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Decrease-Delegate-Stake"},{name:"Target",value:t.target},{name:"Quantity",value:t.decreaseQty.valueOf().toString()}]})}async increaseOperatorStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:t.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:t.decreaseQty.valueOf().toString()}]})}async saveObservations(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:t.reportTxId},{name:"Failed-Gateways",value:t.failedGateways.join(",")}],data:{reportTxId:t.reportTxId,failedGateways:t.failedGateways}})}async buyRecord(t,r){let{tags:h=[]}=r||{},l=[...h,{name:"Action",value:"Buy-Record"},{name:"Name",value:t.name},{name:"Years",value:t.years?.toString()??"1"},{name:"Process-Id",value:t.processId},{name:"Purchase-Type",value:t.type||"lease"}].filter(c=>c.value!==void 0);return this.process.send({signer:this.signer,tags:l})}async extendLease(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Extend-Lease"},{name:"Name",value:t.name},{name:"Years",value:t.years.toString()}]})}async increaseUndernameLimit(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Increase-Undername-Limit"},{name:"Name",value:t.name},{name:"Quantity",value:t.increaseCount.toString()}]})}};var wHt=async({address:i,contract:t=Am.init({processId:Od})})=>{let r=Y9(50),h=await t.getArNSRecords().then(l=>Object.values(l).filter(c=>c.processId!==void 0).map(c=>c.processId)),o=await Promise.all(h.map(async l=>r(async()=>{let c=j2.init({processId:l}),{Owner:p,Controllers:w}=await c.getState();if(p===i||w.includes(i))return l})));return o.length===0?[]:[...new Set(o)]};function Cet(i,t){return new Promise((r,h)=>{let o=setTimeout(()=>{h(new Error("Timeout"))},i);t.then(l=>{clearTimeout(o),r(l)}).catch(l=>{clearTimeout(o),h(l)})})}var Pet=class extends Z9.default{contract;timeoutMs;throttle;constructor({contract:t=Am.init({processId:Od}),timeoutMs:r=6e4,concurrency:h=30}){super(),this.contract=t,this.timeoutMs=r,this.throttle=Y9(h)}async fetchProcessesOwnedByWallet({address:t}){let r={};await Cet(this.timeoutMs,this.contract.getArNSRecords().catch(o=>(this.emit("error",`Error getting ArNS records: ${o}`),{}))).then(o=>{o&&Object.entries(o).forEach(([l,c])=>{c.processId!==void 0&&(r[c.processId]===void 0&&(r[c.processId]={state:void 0,names:{}}),r[c.processId].names[l]=c)})});let h=Object.keys(r).length;this.emit("progress",0,h),await Promise.all(Object.keys(r).map(async(o,l)=>this.throttle(async()=>{if(r[o].state!==void 0){this.emit("progress",l+1,h);return}let c=j2.init({processId:o}),p=await Cet(this.timeoutMs,c.getState()).catch(w=>{this.emit("error",`Error getting state for process ${o}: ${w}`)});(p?.Owner===t||p?.Controllers.includes(t))&&(r[o].state=p,this.emit("process",o,r[o])),this.emit("progress",l+1,h)}))),this.emit("end",r)}};Tt();Rt();xt();Tt();Rt();xt();var Net=sc(dR(),1),S8=Net.default.init({host:"arweave.net",port:443,protocol:"https"});async function UHt({signer:i,module:t=RL,luaCodeTxId:r=kL,ao:h=Sm(),scheduler:o=IL,state:l,stateContractTxId:c}){let p=await S8.transactions.getData(r,{decode:!0,string:!0}),w=await h.spawn({module:t,scheduler:o,signer:await Ys.createAoSigner(i)}),m=new Ys({processId:w,ao:h});return await m.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:r}],data:p,signer:i}),l&&await m.send({tags:[{name:"Action",value:"Initialize-State"},...c!==void 0?[{name:"State-Contract-TX-ID",value:c}]:[]],data:JSON.stringify(l),signer:i}),w}var E8=class{axios;logger;constructor({url:t,logger:r=new pa}){this.logger=r,this.axios=aF({axiosConfig:{baseURL:t},logger:this.logger})}async get({endpoint:t,signal:r,allowedStatuses:h=[200,202],headers:o,params:l}){this.logger.debug(`Get request to endpoint: ${t} with params ${JSON.stringify(l,void 0,2)}`);let{status:c,statusText:p,data:w}=await this.axios.get(t,{headers:o,signal:r,params:l});if(this.logger.debug(`Response status: ${c} ${p}`),!h.includes(c))switch(c){case 404:throw new O6(p);case 400:throw new Hl(c,p);default:throw new C6(p)}return w}};var Gl=class{logger;http;contractTxId;cacheUrl;constructor({cacheUrl:t="https://api.arns.app",contractTxId:r,logger:h=new pa}){this.cacheUrl=t,this.contractTxId=r,this.logger=h,this.http=new E8({url:`${t}/v1/contract/${r}`})}configuration(){return{contractTxId:this.contractTxId,cacheUrl:this.cacheUrl}}async getState({evaluationOptions:t}={}){this.logger.debug("Fetching contract state",{contractTxId:this.contractTxId,evaluationOptions:t});let{state:r}=await this.http.get({endpoint:"",params:{...t?.evalTo}});return r}async readInteraction({functionName:t,inputs:r,evaluationOptions:h}){this.logger.debug("Evaluating read interaction on contract",{functionName:t,inputs:r,evaluationOptions:h});let{result:o}=await this.http.get({endpoint:`/read/${t}`,params:{...h?.evalTo,...r}});return o}};var Let=class{static createWriteableContract(t){if(!t||Object.keys(t).length===0)return new ga({contractTxId:Sy});if(Yf(t))return t.contract instanceof ga?t.contract:new ga(t.contract.configuration());if(Qf(t))return new ga({contractTxId:t.contractTxId});throw new No}static init(t){if(t&&t.signer!==void 0){let{signer:r,...h}=t,o=this.createWriteableContract(h);return new fk({signer:r,contract:o})}else return new A8(t)}},A8=class{contract;constructor(t){if(!t||t===void 0)this.contract=new Gl({contractTxId:Sy});else if(Yf(t))this.contract=t.contract;else if(Qf(t))this.contract=new Gl({contractTxId:t.contractTxId});else throw new No}async getState(t={}){return await this.contract.getState(t)}async getArNSRecord({domain:t,evaluationOptions:r}){return(await this.getArNSRecords({evaluationOptions:r}))[t]}async getArNSRecords({evaluationOptions:t}={}){return(await this.contract.getState({evaluationOptions:t})).records}async getArNSReservedNames({evaluationOptions:t}={}){return(await this.contract.getState({evaluationOptions:t})).reserved}async getArNSReservedName({domain:t,evaluationOptions:r}){return(await this.getArNSReservedNames({evaluationOptions:r}))[t]}async getBalance({address:t,evaluationOptions:r}){return(await this.getBalances({evaluationOptions:r}))[t]||0}async getBalances({evaluationOptions:t}={}){return(await this.contract.getState({evaluationOptions:t})).balances}async getGateway({address:t,evaluationOptions:r}){return this.contract.readInteraction({functionName:ho.GATEWAY,inputs:{target:t},evaluationOptions:r}).catch(()=>{})}async getGateways({evaluationOptions:t}={}){return this.contract.readInteraction({functionName:ho.GATEWAYS,evaluationOptions:t})}async getCurrentEpoch({evaluationOptions:t}={}){return this.contract.readInteraction({functionName:ho.EPOCH,evaluationOptions:t})}async getEpoch({blockHeight:t,evaluationOptions:r}){return this.contract.readInteraction({functionName:ho.EPOCH,inputs:{height:t},evaluationOptions:r})}async getPrescribedObservers({evaluationOptions:t}={}){return this.contract.readInteraction({functionName:ho.PRESCRIBED_OBSERVERS,evaluationOptions:t})}async getObservations({evaluationOptions:t}={}){let{observations:r}=await this.contract.getState({evaluationOptions:t});return r}async getDistributions({evaluationOptions:t}={}){let{distributions:r}=await this.contract.getState({evaluationOptions:t});return r}async getAuction({domain:t,type:r,evaluationOptions:h}){return this.contract.readInteraction({functionName:ho.AUCTION,inputs:{name:t,type:r},evaluationOptions:h})}async getAuctions({evaluationOptions:t}={}){let{auctions:r}=await this.contract.getState({evaluationOptions:t});return r}async getPriceForInteraction({interactionName:t,payload:r,evaluationOptions:h}){let{price:o}=await this.contract.readInteraction({functionName:ho.PRICE_FOR_INTERACTION,inputs:{interactionName:t,...r},evaluationOptions:h});return o}},fk=class extends A8{signer;constructor({signer:t,...r}){if(Object.keys(r).length===0)super({contract:new ga({contractTxId:Sy})}),this.signer=t;else if(Yf(r))super({contract:r.contract}),this.signer=t;else if(Qf(r))super({contract:new ga({contractTxId:r.contractTxId})}),this.signer=t;else throw new No}async transfer({target:t,qty:r,denomination:h="IO"},o){let l=r;return h==="IO"&&typeof r=="number"&&(l=new r2(r).toMIO()),this.contract.writeInteraction({functionName:ho.TRANSFER,inputs:{target:t,qty:l.valueOf()},signer:this.signer},o)}async joinNetwork({qty:t,allowDelegatedStaking:r,delegateRewardShareRatio:h,fqdn:o,label:l,minDelegatedStake:c,note:p,port:w,properties:m,protocol:y,autoStake:v,observerWallet:M},T){return this.contract.writeInteraction({functionName:ho.JOIN_NETWORK,inputs:{qty:t.valueOf(),allowDelegatedStaking:r,delegateRewardShareRatio:h,fqdn:o,label:l,minDelegatedStake:c.valueOf(),note:p,port:w,properties:m,protocol:y,autoStake:v,observerWallet:M},signer:this.signer},T)}async updateGatewaySettings({allowDelegatedStaking:t,delegateRewardShareRatio:r,fqdn:h,label:o,minDelegatedStake:l,note:c,port:p,properties:w,protocol:m,autoStake:y,observerWallet:v},M){return this.contract.writeInteraction({functionName:ho.UPDATE_GATEWAY_SETTINGS,inputs:{allowDelegatedStaking:t,delegateRewardShareRatio:r,fqdn:h,label:o,minDelegatedStake:l?.valueOf(),note:c,port:p,properties:w,protocol:m,autoStake:y,observerWallet:v},signer:this.signer},M)}async increaseDelegateStake(t,r){return this.contract.writeInteraction({functionName:ho.DELEGATE_STAKE,inputs:{target:t.target,qty:t.qty.valueOf()},signer:this.signer},r)}async decreaseDelegateStake(t,r){return this.contract.writeInteraction({functionName:ho.DECREASE_DELEGATE_STAKE,inputs:{target:t.target,qty:t.qty.valueOf()},signer:this.signer},r)}async increaseOperatorStake(t,r){return this.contract.writeInteraction({functionName:ho.INCREASE_OPERATOR_STAKE,inputs:{qty:t.qty.valueOf()},signer:this.signer},r)}async decreaseOperatorStake(t,r){return this.contract.writeInteraction({functionName:ho.DECREASE_OPERATOR_STAKE,inputs:{qty:t.qty.valueOf()},signer:this.signer},r)}async saveObservations(t,r){return this.contract.writeInteraction({functionName:ho.SAVE_OBSERVATIONS,inputs:{observerReportTxId:t.reportTxId,failedGateways:t.failedGateways},signer:this.signer},r)}async extendLease(t,r){return this.contract.writeInteraction({functionName:ho.EXTEND_RECORD,inputs:{name:t.domain,years:t.years},signer:this.signer},r)}async increaseUndernameLimit(t,r){return this.contract.writeInteraction({functionName:ho.INCREASE_UNDERNAME_COUNT,inputs:{name:t.domain,qty:t.qty},signer:this.signer},r)}};Tt();Rt();xt();Tt();Rt();xt();var or=sc(Zot(),1);var Fie=or.default.AbortError,jie=or.default.AbstractContractHandler,zie=or.default.ArweaveContractDefinitionLoader,Wie=or.default.ArweaveGatewayBundledContractDefinitionLoader,Kie=or.default.ArweaveGatewayBundledInteractionLoader,Hie=or.default.ArweaveGatewayInteractionsLoader,Gie=or.default.ArweaveWrapper,Vie=or.default.Benchmark,Zie=or.default.CacheKey,Jie=or.default.CacheableInteractionsLoader,Xie=or.default.CacheableStateEvaluator,Yie=or.default.ConsoleLogger,Qie=or.default.ConsoleLoggerFactory,tne=or.default.ContractCache,ene=or.default.ContractCallRecord,rne=or.default.ContractError,ine=or.default.ContractInteractionState,nne=or.default.ContractMetadata,one=or.default.CustomEvent,ane=or.default.DEFAULT_LEVEL_DB_LOCATION,sne=or.default.DefaultEvaluationOptions,hne=or.default.DefaultStateEvaluator,fne=or.default.EvalStateResult,une=or.default.EvaluationOptionsEvaluator,cne=or.default.HandlerBasedContract,lne=or.default.HandlerExecutorFactory,dne=or.default.InnerWritesEvaluator,pne=or.default.InteractionCall,gne=or.default.InteractionCompleteEvent,mne=or.default.InteractionInput,vne=or.default.InteractionOutput,yne=or.default.JsHandlerApi,bne=or.default.KV,wne=or.default.KnownErrors,_ne=or.default.LevelDbCache,Mne=or.default.LexicographicalInteractionsSorter,Sne=or.default.LogLevelOrder,Jot=or.default.LoggerFactory,Ene=or.default.MemCache,Ane=or.default.NetworkCommunicationError,Tne=or.default.NonWhitelistedSourceError,xne=or.default.PstContractImpl,Rne=or.default.REGISTER_PROVIDER,kne=or.default.SMART_WEAVE_TAGS,Ine=or.default.SUPPORTED_SRC_CONTENT_TYPES,Bne=or.default.SWBlock,One=or.default.SWTransaction,Cne=or.default.SWVrf,Xot=or.default.Signature,Pne=or.default.SmartWeaveError,Nne=or.default.SmartWeaveErrorType,Lne=or.default.SmartWeaveGlobal,Dne=or.default.SortKeyCacheResult,$ne=or.default.SourceType,Une=or.default.SrcCache,Yot=or.default.Tag,qne=or.default.TagsParser,Fne=or.default.Transaction,jne=or.default.WARP_GW_URL,zne=or.default.WARP_TAGS,Wne=or.default.Warp,Kne=or.default.WarpBuilder,Qot=or.default.WarpFactory,Hne=or.default.WarpFetchWrapper,Gne=or.default.WarpGatewayContractDefinitionLoader,Vne=or.default.WarpGatewayInteractionsLoader,Zne=or.default.WasmHandlerApi,Jne=or.default.WasmSrc,Xne=or.default.arrayToHex,Yne=or.default.asc,Qne=or.default.ascS,toe=or.default.bufToBn,eoe=or.default.bundledTxsFilter,roe=or.default.checkJsSrc,ioe=or.default.createDummyTx,noe=or.default.createInteractionTagsList,ooe=or.default.createInteractionTx,aoe=or.default.deepCopy,soe=or.default.defaultArweaveMs,tat=or.default.defaultCacheOptions,hoe=or.default.defaultWarpGwOptions,foe=or.default.desc,uoe=or.default.descS,coe=or.default.emptyTransfer,loe=or.default.genesisSortKey,doe=or.default.getJsonResponse,poe=or.default.indent,goe=or.default.isBrowser,moe=or.default.isTxIdValid,voe=or.default.knownWarpPlugins,yoe=or.default.knownWarpPluginsPartial,boe=or.default.lastPossibleSortKey,woe=or.default.lvlToOrder,_oe=or.default.mapReplacer,Moe=or.default.mapReviver,Soe=or.default.matchMutClosureDtor,Eoe=or.default.normalizeContractSource,Aoe=or.default.rustWasmImports,Toe=or.default.safeGet,xoe=or.default.safeParseInt,Roe=or.default.sleep,koe=or.default.sortingFirst,Ioe=or.default.sortingLast,Boe=or.default.stripTrailingSlash,Ooe=or.default.timeout;Tt();Rt();xt();Fx();var fkt="+",ukt="/",ckt="-",lkt="_",dkt="=";function pkt(i){return i.replaceAll(fkt,ckt).replaceAll(ukt,lkt).replaceAll(dkt,"")}function wv(i){let t=i.toString("base64");return pkt(t)}function eat(i){return wv(qx("sha256").update(i).digest())}Tt();Rt();xt();var rat=Qot.forMainnet({...tat,inMemory:!0},!0,S8);Jot.INST.logLevel("error");var ga=class{contract;contractTxId;cacheUrl;logger;warp;constructor({contractTxId:t,cacheUrl:r="https://api.arns.app",warp:h=rat,logger:o=new pa({level:"info"})}){this.contractTxId=t,this.contract=h.contract(t),this.cacheUrl=r,this.warp=h,this.logger=o}configuration(){return{contractTxId:this.contractTxId,cacheUrl:this.cacheUrl}}async createWarpSigner(t){return t.publicKey===void 0&&"setPublicKey"in t&&await t.setPublicKey(),new Xot(this.warp,{signer:async h=>{h.setOwner(wv(t.publicKey));let o=await h.getSignatureData(),l=await t.sign(o),c=ge.from(l),p=eat(c);h.setSignature({id:p,owner:wv(t.publicKey),signature:wv(c)})},type:"arweave"})}async getState({evaluationOptions:t={}}){await this.ensureContractInit();let r=t?.evalTo,h;r&&"sortKey"in r?h=r.sortKey:r&&"blockHeight"in r&&(h=r.blockHeight);let o=await this.contract.readState(h);if(!o.cachedValue.state)throw new Hl(502,"Failed to evaluate contract state");return o.cachedValue.state}async ensureContractInit({signer:t}={}){this.logger.debug("Checking contract initialized",{contractTxId:this.contractTxId}),this.logger.debug("Fetching contract manifest",{contractTxId:this.contractTxId});let{evaluationOptions:r={}}=await OL({arweave:this.warp.arweave,contractTxId:this.contractTxId});this.contract.setEvaluationOptions(r),t&&this.contract.connect(await this.createWarpSigner(t)),this.cacheUrl!==void 0&&(this.logger.debug("Syncing contract state",{contractTxId:this.contractTxId,remoteCacheUrl:this.cacheUrl}),await this.contract.syncState(`${this.cacheUrl}/v1/contract/${this.contractTxId}`,{validity:!0}))}async readInteraction({functionName:t,inputs:r}){await this.ensureContractInit(),this.logger.debug(`Read interaction: ${t}`,{contractTxId:this.contractTxId,inputs:r});let h=await this.contract.viewState({function:t,...r});if(h.result===void 0)throw new Hl(502,"Failed to evaluate contract read interaction: "+JSON.stringify({error:h.errorMessage,functionName:t,inputs:r},null,2));return this.logger.debug("Successfully evaluated contract read interaction",{contractTxId:this.contractTxId,result:h.result}),h.result}async writeInteraction({functionName:t,inputs:r,signer:h},o){try{this.logger.debug(`Write interaction: ${t}`,{contractTxId:this.contractTxId}),await this.ensureContractInit({signer:h});let l=await this.contract.dryWrite({function:t,...r});if(l.type!=="ok")throw new Error(`Failed to dry write contract interaction ${t}: ${l.errorMessage}`);let c=await this.contract.writeInteraction({function:t,...r},{disableBundling:!0,tags:o?.tags?.map(p=>new Yot(p.name,p.value))});if(!c?.interactionTx)throw new Error(`Failed to write contract interaction: ${t}`);return this.logger.debug("Successfully wrote contract interaction",{contractTxId:this.contractTxId,interactionTxId:c.originalTxId}),c.interactionTx}catch(l){throw this.logger.error(`Failed to write contract interaction: ${l.message}`,{contractTxId:this.contractTxId}),new a1(l)}}};Tt();Rt();xt();var z2=class{process;constructor(t){if(Rl(t))this.process=t.process;else if(kl(t))this.process=new Ys({processId:t.processId});else throw new No}async getState(){let t=[{name:"Action",value:"State"}];return await this.process.read({tags:t})}async getInfo(){let t=[{name:"Action",value:"Info"}];return await this.process.read({tags:t})}async getRecord({undername:t}){let r=[{name:"Sub-Domain",value:t},{name:"Action",value:"Record"}];return await this.process.read({tags:r})}async getRecords(){let t=[{name:"Action",value:"Records"}];return await this.process.read({tags:t})}async getOwner(){return(await this.getInfo()).Owner}async getControllers(){let t=[{name:"Action",value:"Controllers"}];return await this.process.read({tags:t})}async getName(){return(await this.getInfo()).Name}async getTicker(){return(await this.getInfo()).Ticker}async getBalances(){let t=[{name:"Action",value:"Balances"}];return await this.process.read({tags:t})}async getBalance({address:t}){let r=[{name:"Action",value:"Balance"},{name:"Recipient",value:t}];return await this.process.read({tags:r})}},L6=class extends z2{signer;constructor({signer:t,...r}){super(r),this.signer=t}async transfer({target:t}){let r=[{name:"Action",value:"Transfer"},{name:"Recipient",value:t}];return this.process.send({tags:r,data:{},signer:this.signer})}async addController({controller:t}){let r=[{name:"Action",value:"Add-Controller"},{name:"Controller",value:t}];return this.process.send({tags:r,data:{},signer:this.signer})}async removeController({controller:t}){let r=[{name:"Action",value:"Remove-Controller"},{name:"Controller",value:t}];return this.process.send({tags:r,data:{},signer:this.signer})}async setRecord({undername:t,transactionId:r,ttlSeconds:h}){return this.process.send({tags:[{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:t},{name:"Transaction-Id",value:r},{name:"TTL-Seconds",value:h.toString()}],data:{transactionId:r,ttlSeconds:h},signer:this.signer})}async removeRecord({undername:t}){return this.process.send({tags:[{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:t}],data:{undername:t},signer:this.signer})}async setTicker({ticker:t}){return this.process.send({tags:[{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:t}],data:{ticker:t},signer:this.signer})}async setName({name:t}){return this.process.send({tags:[{name:"Action",value:"Set-Name"},{name:"Name",value:t}],data:{name:t},signer:this.signer})}};var export_ArconnectSigner=iat.ArconnectSigner;var export_ArweaveSigner=iat.ArweaveSigner;export{j2 as ANT,N6 as ANTReadable,Q9 as ANTWritable,cc as ANT_CONTRACT_FUNCTIONS,kL as ANT_LUA_ID,Ys as AOProcess,RL as AOS_MODULE_ID,Gkt as ARNS_DEVNET_REGISTRY_TX,Sy as ARNS_TESTNET_REGISTRY_TX,TL as ARWEAVE_TX_REGEX,ho as AR_IO_CONTRACT_FUNCTIONS,s1 as AbortError,z2 as AoANTReadable,L6 as AoANTWriteable,Let as ArIO,A8 as ArIOReadable,fk as ArIOWritable,Pet as ArNSEventEmitter,export_ArconnectSigner as ArconnectSigner,export_ArweaveSigner as ArweaveSigner,sF as BadRequest,wh as BaseError,IL as DEFAULT_SCHEDULER_ID,AL as DENOMINATIONS,pa as DefaultLogger,Hkt as FQDN_REGEX,Hl as FailedRequestError,Am as IO,M8 as IOReadable,r2 as IOToken,hk as IOWriteable,Ost as IO_DEVNET_PROCESS_ID,Od as IO_TESTNET_PROCESS_ID,No as InvalidContractConfigurationError,fF as InvalidProcessConfigurationError,hF as InvalidSignerError,h1 as MAX_REQUEST_SIZE,W5 as MIO_PER_IO,O6 as NotFound,Gl as RemoteContract,xL as SORT_KEY_REGEX,G5 as SmartWeaveSortKey,C6 as UnknownError,ga as WarpContract,a1 as WriteInteractionError,aF as createAxiosInstance,wHt as getANTProcessesOwnedByWallet,OL as getContractManifest,zqt as getContractsTransferredToOrControlledByWallet,Fqt as getSmartweaveContractsFromGQL,jqt as getSmartweaveTransactionsFromGQL,$kt as ioContractInteractions,Ist as ioContractReadInteractions,Bst as ioContractWriteInteractions,Vkt as ioDevnetProcessId,oIt as isBlockHeight,Yf as isContractConfiguration,Qf as isContractTxIdConfiguration,lIt as isLeasedArNSRecord,Rl as isProcessConfiguration,kl as isProcessIdConfiguration,RIt as isSortKey,aIt as isTransaction,H5 as mIOToken,sk as safeDecode,UHt as spawnANT,BL as tagsToObject,Ey as validateArweaveId};
|
|
380
380
|
/*! Bundled license information:
|
|
381
381
|
|
|
382
382
|
@jspm/core/nodelibs/browser/buffer.js:
|