@ar.io/sdk 3.5.1-alpha.1 → 3.5.1-alpha.3
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 +1 -1
- package/lib/cjs/common/io.js +42 -22
- package/lib/cjs/utils/ao.js +0 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/io.js +42 -22
- package/lib/esm/utils/ao.js +0 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -186,7 +186,7 @@ nonce: bundlr`),Me.from(i))}};ie();ae();ne();var Q0=class{_publicKey;ownerLength
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
}`,i=wt.object({data:wt.object({transactions:wt.object({edges:wt.array(wt.object({node:wt.record(wt.any())}))})})});return h=>jr(h).chain(Li(c=>t(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:a,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(i.parse).then(ixe(["data","transactions","edges","0","node"])))).toPromise()}var pSe=nI(M5e(),1),fte=(t="@permaweb/aoconnect")=>{let e=(0,pSe.default)(t);return e.child=r=>fte(`${e.namespace}:${r}`),e.tap=(r,...a)=>hxe((...i)=>e(r,...a,...i)),e},ute=({url:t,path:e})=>e?e.startsWith("/")?ute({url:t,path:e.slice(1)}):(t=new URL(t),t.pathname+=e,t.toString()):t;function vSe(t){return F1(x4([]),U1((e,r)=>F1(oxe([],r.name),wI(r.value),$s(r.name,Fh,e))(e),{}),_4(e=>e.length>1?e:e[0]))(t)}function Cs(t,e){return r=>Pee(vMe([NQ(t,"name"),MI(yI(e),NQ(e,"value"),mI)]),r)}function DQ(t){return jee([[Wg(String),k1(t)],[Wg(Array),VMe(t)],[mI,E9e]])}function Ad(t){let e;return Wg(Ls,t)?(e=new Error(mSe(t)),e.stack+=t.stack):Wg(Error,t)?e=t:HMe("message",t)?e=new Error(t.message):Wg(String,t)?e=new Error(t):e=new Error("An error occurred"),e}function mSe(t){return F1(e=>function r(a,i,h){return U1((c,p)=>F1(jee([[k1(Rt.invalid_arguments),()=>r(p.argumentsError,422,"Invalid Arguments")],[k1(Rt.invalid_return_type),()=>r(p.returnTypeError,500,"Invalid Return")],[k1(Rt.invalid_union),()=>BMe(b=>r(b,400,"Invalid Union"),p.unionErrors)],[mI,()=>[{...p,status:i,contextCode:h}]]]),_I(c))(p.code),[],a.issues)}(e,400,""),e=>U1((r,a)=>{let{message:i,path:h,contextCode:c}=a,p=h[1]||h[0],b=c?`${c} `:"";return r.push(`${b}'${p}': ${i}.`),r},[],e),exe(" | "))(t)}var gSe=wt.object({id:wt.string().min(1,{message:"message is required to be a message id"}),processId:wt.string().min(1,{message:"process is required to be a process id"})});function bSe(){return t=>jr(t).map(gSe.parse).map(()=>t)}var k2=wt.object({name:wt.string(),value:wt.string()}),ySe=wt.function().args(wt.object({Id:wt.string(),Target:wt.string(),Owner:wt.string(),Anchor:wt.string().optional(),Data:wt.any().default("1234"),Tags:wt.array(wt.object({name:wt.string(),value:wt.string()}))})).returns(wt.promise(wt.any())),wSe=wt.function().args(wt.object({id:wt.string().min(1,{message:"message id is required"}),processId:wt.string().min(1,{message:"process id is required"})})).returns(wt.promise(wt.any())),_Se=wt.function().args(wt.object({process:wt.string().min(1,{message:"process id is required"}),from:wt.string().optional(),to:wt.string().optional(),sort:wt.enum(["ASC","DESC"]).default("ASC"),limit:wt.number().optional()})).returns(wt.promise(wt.object({edges:wt.array(wt.object({cursor:wt.string(),node:wt.object({Output:wt.any().optional(),Messages:wt.array(wt.any()).optional(),Spawns:wt.array(wt.any()).optional(),Error:wt.any().optional()})}))}))),hte=wt.function().args(wt.object({processId:wt.string(),data:wt.any(),tags:wt.array(k2),anchor:wt.string().optional(),signer:wt.any()})).returns(wt.promise(wt.object({messageId:wt.string()}).passthrough())),MSe=wt.function().args(wt.object({data:wt.any(),tags:wt.array(k2),signer:wt.any()})).returns(wt.promise(wt.object({processId:wt.string()}).passthrough())),xSe=wt.function().args(wt.object({process:wt.string(),message:wt.string(),baseLayer:wt.boolean().optional(),exclude:wt.array(wt.string()).optional()})).returns(wt.promise(wt.object({assignmentId:wt.string()}).passthrough())),cte=hte,cut=wt.function().args(wt.object({suUrl:wt.string().url(),processId:wt.string()})).returns(wt.promise(wt.object({tags:wt.array(k2)}).passthrough())),lut=wt.function().args(wt.string()).returns(wt.promise(wt.object({url:wt.string()}))),SSe=wt.function().args(wt.string()).returns(wt.promise(wt.boolean())),ESe=wt.function().args(wt.string()).returns(wt.promise(wt.object({tags:wt.array(k2)}).passthrough())),S4=wt.function().args(wt.object({data:wt.any(),tags:wt.array(k2),target:wt.string().optional(),anchor:wt.string().optional()})).returns(wt.promise(wt.object({id:wt.string(),raw:wt.any()})));function ASe({loadResult:t}){return t=Li(wSe.implement(t)),e=>jr({id:e.id,processId:e.processId}).chain(t)}function RSe(t){let e=bSe(t),r=ASe(t);return({message:a,process:i})=>jr({id:a,processId:i}).chain(e).chain(r).map(t.logger.tap('readResult result for message "%s": %O',a)).map(h=>h).bimap(Ad,Ed).toPromise()}var TSe=wt.array(wt.object({name:wt.string(),value:wt.string()}));function ISe(){return t=>jr(t.tags).map(x4([])).map(Cs("Data-Protocol","ao")).map(Cs("Variant")).map(Cs("Type")).map(Cs("SDK")).map(_I(Fh,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"},{name:"SDK",value:"aoconnect"}])).map(TSe.parse).map($s("tags",Fh,t))}function kSe({logger:t}){return e=>jr(e).chain(MI(yI(e.data),()=>_d(e),()=>_d(Math.random().toString().slice(-4)).map($s("data",Fh,e)).map(r=>F1(Sd("tags"),Cs("Content-Type"),wI({name:"Content-Type",value:"text/plain"}),$s("tags",Fh,r))(r)).map(t.tap('added pseudo-random string as message "data"'))))}function BSe(t){let e=ISe(t),r=kSe(t),a=hte.implement(t.deployMessage);return i=>jr(i).chain(e).chain(r).chain(Li(({id:h,data:c,tags:p,anchor:b,signer:g})=>a({processId:h,data:c,tags:p,anchor:b,signer:S4.implement(g)}))).map(h=>$s("messageId",h.messageId,i))}function PSe(t){let e=BSe(t);return({process:r,data:a,tags:i,anchor:h,signer:c})=>jr({id:r,data:a,tags:i,anchor:h,signer:c}).chain(e).map(p=>p.messageId).bimap(Ad,Ed).toPromise()}var Dg=(t,e,r)=>a=>e(a[t])?_d(a):xl(`Tag '${t}': ${r}`);function OSe({loadTransactionMeta:t,logger:e}){return t=Li(ESe.implement(t)),r=>jr(r).chain(t).map(Sd("tags")).map(vSe).chain(Dg("Data-Protocol",DQ("ao"),"value 'ao' was not found on module")).chain(Dg("Type",DQ("Module"),"value 'Module' was not found on module")).chain(Dg("Module-Format",IT,"was not found on module")).chain(Dg("Input-Encoding",IT,"was not found on module")).chain(Dg("Output-Encoding",IT,"was not found on module")).bimap(e.tap("Verifying module source failed: %s"),e.tap("Verified module source"))}function NSe({logger:t,validateScheduler:e}){return e=Li(SSe.implement(e)),r=>jr(r).chain(a=>e(a).chain(i=>i?_d(a):xl(`Valid Scheduler-Location owned by ${a} not found`))).bimap(t.tap("Verifying scheduler failed: %s"),t.tap("Verified scheduler"))}function CSe({logger:t}){return e=>jr(e).map(t.tap("Checking for signer")).chain(r=>r?_d(r):xl("signer not found"))}function LSe(t){let e=t.logger.child("verifyInput");t={...t,logger:e};let r=OSe(t),a=NSe(t),i=CSe(t);return h=>jr(h).chain(c=>r(c.module).map(()=>c)).chain(c=>a(c.scheduler)).map(()=>h).chain(c=>i(c.signer).map(()=>c)).bimap(e.tap("Error when verify input: %s"),e.tap("Successfully verified inputs"))}var DSe=wt.array(wt.object({name:wt.string(),value:wt.string()}));function $Se(){return t=>jr(t).map(Sd("tags")).map(x4([])).map(Cs("Data-Protocol","ao")).map(Cs("Variant")).map(Cs("Type")).map(Cs("Module")).map(Cs("Scheduler")).map(Cs("SDK")).map(_I(Fh,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Process"},{name:"Module",value:t.module},{name:"Scheduler",value:t.scheduler},{name:"SDK",value:"aoconnect"}])).map(DSe.parse).map($s("tags",Fh,t))}function qSe({logger:t}){return e=>jr(e).chain(MI(yI(e.data),()=>_d(e),()=>_d(Math.random().toString().slice(-4)).map($s("data",Fh,e)).map(r=>F1(Sd("tags"),Cs("Content-Type"),wI({name:"Content-Type",value:"text/plain"}),$s("tags",Fh,r))(r)).map(t.tap('added pseudo-random string as process "data"'))))}function USe(t){let e=t.logger.child("uploadProcess");t={...t,logger:e};let r=$Se(t),a=qSe(t),i=MSe.implement(t.deployProcess);return h=>jr(h).chain(r).chain(a).chain(Li(({data:c,tags:p,signer:b})=>i({data:c,tags:p,signer:S4.implement(b)}))).map(c=>$s("processId",c.processId,h))}function FSe(t){let e=LSe(t),r=USe(t);return({module:a,scheduler:i,signer:h,tags:c,data:p})=>jr({module:a,scheduler:i,signer:h,tags:c,data:p}).chain(e).chain(r).map(b=>b.processId).bimap(Ad,Ed).toPromise()}function jSe(t){let e=cte.implement(t.deployMonitor);return r=>jr(r).chain(Li(({id:a,signer:i})=>e({processId:a,signer:S4.implement(i),data:Math.random().toString().slice(-4),tags:[]}))).map(a=>$s("monitorId",a.messageId,r))}function zSe(t){let e=jSe(t);return({process:r,signer:a})=>jr({id:r,signer:a}).chain(e).map(i=>i.monitorId).bimap(Ad,Ed).toPromise()}function ZSe(t){let e=cte.implement(t.deployUnmonitor);return r=>jr(r).chain(Li(({id:a,signer:i})=>e({processId:a,signer:S4.implement(i),data:Math.random().toString().slice(-4),tags:[]}))).map(a=>$s("monitorId",a.messageId,r))}function HSe(t){let e=ZSe(t);return({process:r,signer:a})=>jr({id:r,signer:a}).chain(e).map(i=>i.monitorId).bimap(Ad,Ed).toPromise()}var KSe=wt.object({process:wt.string().min(1,{message:"process identifier is required"}),from:wt.string().optional(),to:wt.string().optional(),sort:wt.enum(["ASC","DESC"]).default("ASC"),limit:wt.number().optional()});function WSe(){return t=>jr(t).map(KSe.parse).map(()=>t)}function VSe({queryResults:t}){return t=Li(_Se.implement(t)),e=>jr({process:e.process,from:e.from,to:e.to,sort:e.sort,limit:e.limit}).chain(t)}function GSe(t){let e=WSe(t),r=VSe(t);return({process:a,from:i,to:h,sort:c,limit:p})=>jr({process:a,from:i,to:h,sort:c,limit:p}).chain(e).chain(r).map(t.logger.tap('readResults result for message "%s": %O',a)).map(b=>b).bimap(Ad,Ed).toPromise()}var YSe=wt.object({Id:wt.string(),Target:wt.string(),Owner:wt.string(),Anchor:wt.string().optional(),Data:wt.any().default("1234"),Tags:wt.array(wt.object({name:wt.string(),value:wt.string()}))});function JSe(){return t=>jr(t).map(YSe.parse).map(e=>(e.Tags=e.Tags.concat([{name:"Data-Protocol",value:"ao"},{name:"Type",value:"Message"},{name:"Variant",value:"ao.TN.1"}]),e))}function XSe({dryrunFetch:t}){return Li(ySe.implement(t))}function QSe(t){let e=JSe(t),r=XSe(t);return a=>jr(a).map(eEe).chain(e).chain(r).toPromise()}function eEe({process:t,data:e,tags:r,anchor:a,...i}){return{Id:"1234",Owner:"1234",...i,Target:t,Data:e||"1234",Tags:r||[],Anchor:a||"0"}}function tEe(t){let e=xSe.implement(t.deployAssign);return r=>jr(r).chain(Li(({process:a,message:i,baseLayer:h,exclude:c})=>e({process:a,message:i,baseLayer:h,exclude:c}))).map(a=>$s("assignmentId",a.assignmentId,r))}function rEe(t){let e=tEe(t);return({process:r,message:a,baseLayer:i,exclude:h})=>jr({process:r,message:a,baseLayer:i,exclude:h}).chain(e).map(c=>c.assignmentId).bimap(Ad,Ed).toPromise()}var iEe="https://arweave.net",nEe="https://mu.ao-testnet.xyz",aEe="https://cu.ao-testnet.xyz";function Sl({GRAPHQL_URL:t,GATEWAY_URL:e=iEe,MU_URL:r=nEe,CU_URL:a=aEe}={}){let i=fte();t||(t=ute({url:e,path:"/graphql"}));let{validate:h}=Tee({cacheSize:100,GRAPHQL_URL:t}),c=x9e({MAX_SIZE:25}),p=i.child("result"),b=RSe({loadResult:w9e({fetch,CU_URL:a,logger:p}),logger:p}),g=i.child("message"),y=PSe({loadProcessMeta:AT({fetch,cache:c,logger:g}),deployMessage:p9e({fetch,MU_URL:r,logger:g}),logger:g}),M=i.child("spawn"),x=FSe({loadTransactionMeta:dSe({fetch,GRAPHQL_URL:t,logger:M}),validateScheduler:h,deployProcess:v9e({fetch,MU_URL:r,logger:M}),logger:M}),E=i.child("monitor"),A=zSe({loadProcessMeta:AT({fetch,cache:c,logger:E}),deployMonitor:m9e({fetch,MU_URL:r,logger:E}),logger:E}),I=i.child("unmonitor"),P=HSe({loadProcessMeta:AT({fetch,cache:c,logger:I}),deployUnmonitor:g9e({fetch,MU_URL:r,logger:I}),logger:E}),N=i.child("results"),L=GSe({queryResults:_9e({fetch,CU_URL:a,logger:N}),logger:N}),C=i.child("dryrun"),Y=QSe({dryrunFetch:y9e({fetch,CU_URL:a,logger:C}),logger:C}),G=i.child("assign"),ee=rEe({deployAssign:b9e({fetch,MU_URL:r,logger:G}),logger:g});return{result:b,results:L,message:y,spawn:x,monitor:A,unmonitor:P,dryrun:Y,assign:ee}}var lte={};UQ(lte,{createDataItemSigner:()=>kEe});var dte=nI(E5e(),1),pte={};UQ(pte,{AVSCTap:()=>B2,ArweaveSigner:()=>RI,DataItem:()=>A2,MAX_TAG_BYTES:()=>E4,MIN_BINARY_SIZE:()=>kI,SIG_CONFIG:()=>K1,SignatureConfig:()=>Ns,Signer:()=>bte,createData:()=>Mte,default:()=>REe,deserializeTags:()=>v4,indexToType:()=>TI,serializeTags:()=>II,tagsExceedLimit:()=>_te,warparbundles:()=>TEe});var oEe=Object.create,EI=Object.defineProperty,sEe=Object.getOwnPropertyDescriptor,fEe=Object.getOwnPropertyNames,uEe=Object.getPrototypeOf,hEe=Object.prototype.hasOwnProperty,zh=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),cEe=(t,e)=>{for(var r in e)EI(t,r,{get:e[r],enumerable:!0})},lEe=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fEe(e))!hEe.call(t,i)&&i!==r&&EI(t,i,{get:()=>e[i],enumerable:!(a=sEe(e,i))||a.enumerable});return t},Rd=(t,e,r)=>(r=t!=null?oEe(uEe(t)):{},lEe(e||!t||!t.__esModule?EI(r,"default",{value:t,enumerable:!0}):r,t)),dEe=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});function e(r){var a=4,i=r.length,h=i%a;if(!h)return r;var c=i,p=a-h,b=i+p,g=Me.alloc(b);for(g.write(r);p--;)g.write("=",c++);return g.toString()}t.default=e}),pEe=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=dEe();function r(b,g){return g===void 0&&(g="utf8"),Me.isBuffer(b)?h(b.toString("base64")):h(Me.from(b,g).toString("base64"))}function a(b,g){return g===void 0&&(g="utf8"),Me.from(i(b),"base64").toString(g)}function i(b){return b=b.toString(),e.default(b).replace(/\-/g,"+").replace(/_/g,"/")}function h(b){return b.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function c(b){return Me.from(i(b),"base64")}var p=r;p.encode=r,p.decode=a,p.toBase64=i,p.fromBase64=h,p.toBuffer=c,t.default=p}),AI=zh((t,e)=>{e.exports=pEe().default,e.exports.default=e.exports}),vte=zh(t=>{"use strict";t.byteLength=b,t.toByteArray=y,t.fromByteArray=E;var e=[],r=[],a=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(h=0,c=i.length;h<c;++h)e[h]=i[h],r[i.charCodeAt(h)]=h;var h,c;r[45]=62,r[95]=63;function p(A){var I=A.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var P=A.indexOf("=");P===-1&&(P=I);var N=P===I?0:4-P%4;return[P,N]}function b(A){var I=p(A),P=I[0],N=I[1];return(P+N)*3/4-N}function g(A,I,P){return(I+P)*3/4-P}function y(A){var I,P=p(A),N=P[0],L=P[1],C=new a(g(A,N,L)),Y=0,G=L>0?N-4:N,ee;for(ee=0;ee<G;ee+=4)I=r[A.charCodeAt(ee)]<<18|r[A.charCodeAt(ee+1)]<<12|r[A.charCodeAt(ee+2)]<<6|r[A.charCodeAt(ee+3)],C[Y++]=I>>16&255,C[Y++]=I>>8&255,C[Y++]=I&255;return L===2&&(I=r[A.charCodeAt(ee)]<<2|r[A.charCodeAt(ee+1)]>>4,C[Y++]=I&255),L===1&&(I=r[A.charCodeAt(ee)]<<10|r[A.charCodeAt(ee+1)]<<4|r[A.charCodeAt(ee+2)]>>2,C[Y++]=I>>8&255,C[Y++]=I&255),C}function M(A){return e[A>>18&63]+e[A>>12&63]+e[A>>6&63]+e[A&63]}function x(A,I,P){for(var N,L=[],C=I;C<P;C+=3)N=(A[C]<<16&16711680)+(A[C+1]<<8&65280)+(A[C+2]&255),L.push(M(N));return L.join("")}function E(A){for(var I,P=A.length,N=P%3,L=[],C=16383,Y=0,G=P-N;Y<G;Y+=C)L.push(x(A,Y,Y+C>G?G:Y+C));return N===1?(I=A[P-1],L.push(e[I>>2]+e[I<<4&63]+"==")):N===2&&(I=(A[P-2]<<8)+A[P-1],L.push(e[I>>10]+e[I>>4&63]+e[I<<2&63]+"=")),L.join("")}}),mte=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64UrlDecode=t.b64UrlEncode=t.bufferTob64Url=t.bufferTob64=t.b64UrlToBuffer=t.stringToB64Url=t.stringToBuffer=t.bufferToString=t.b64UrlToString=t.concatBuffers=void 0;var e=vte();function r(x){let E=0;for(let P=0;P<x.length;P++)E+=x[P].byteLength;let A=new Uint8Array(E),I=0;A.set(new Uint8Array(x[0]),I),I+=x[0].byteLength;for(let P=1;P<x.length;P++)A.set(new Uint8Array(x[P]),I),I+=x[P].byteLength;return A}t.concatBuffers=r;function a(x){let E=p(x);return i(E)}t.b64UrlToString=a;function i(x){return new TextDecoder("utf-8",{fatal:!0}).decode(x)}t.bufferToString=i;function h(x){return new TextEncoder().encode(x)}t.stringToBuffer=h;function c(x){return g(h(x))}t.stringToB64Url=c;function p(x){return new Uint8Array(e.toByteArray(M(x)))}t.b64UrlToBuffer=p;function b(x){return e.fromByteArray(new Uint8Array(x))}t.bufferTob64=b;function g(x){return y(b(x))}t.bufferTob64Url=g;function y(x){return x.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}t.b64UrlEncode=y;function M(x){x=x.replace(/\-/g,"+").replace(/\_/g,"/");let E;return x.length%4==0?E=0:E=4-x.length%4,x.concat("=".repeat(E))}t.b64UrlDecode=M}),vEe=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=mte(),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 a=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),i=await this.driver.exportKey("jwk",a.privateKey);return{kty:i.kty,e:i.e,n:i.n,d:i.d,p:i.p,q:i.q,dp:i.dp,dq:i.dq,qi:i.qi}}async sign(a,i,{saltLength:h}={}){let c=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(a),i);return new Uint8Array(c)}async hash(a,i="SHA-256"){let h=await this.driver.digest(i,a);return new Uint8Array(h)}async verify(a,i,h){let c={kty:"RSA",e:"AQAB",n:a},p=await this.jwkToPublicCryptoKey(c),b=await this.driver.digest("SHA-256",i),g=await this.driver.verify({name:"RSA-PSS",saltLength:0},p,h,i),y=await this.driver.verify({name:"RSA-PSS",saltLength:32},p,h,i),M=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((p.algorithm.modulusLength-1)/8)-b.byteLength-2},p,h,i);return g||y||M}async jwkToCryptoKey(a){return this.driver.importKey("jwk",a,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(a){return this.driver.importKey("jwk",a,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let a=crypto?.subtle;return a===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(i=>typeof a[i]=="function")}async encrypt(a,i,h){let c=await this.driver.importKey("raw",typeof i=="string"?e.stringToBuffer(i):i,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:h?e.stringToBuffer(h):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),b=new Uint8Array(16);crypto.getRandomValues(b);let g=await this.driver.encrypt({name:"AES-CBC",iv:b},p,a);return e.concatBuffers([b,g])}async decrypt(a,i,h){let c=await this.driver.importKey("raw",typeof i=="string"?e.stringToBuffer(i):i,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:h?e.stringToBuffer(h):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),b=a.slice(0,16),g=await this.driver.decrypt({name:"AES-CBC",iv:b},p,a.slice(16));return e.concatBuffers([g])}};t.default=r}),mEe=zh(t=>{t.read=function(e,r,a,i,h){var c,p,b=h*8-i-1,g=(1<<b)-1,y=g>>1,M=-7,x=a?h-1:0,E=a?-1:1,A=e[r+x];for(x+=E,c=A&(1<<-M)-1,A>>=-M,M+=b;M>0;c=c*256+e[r+x],x+=E,M-=8);for(p=c&(1<<-M)-1,c>>=-M,M+=i;M>0;p=p*256+e[r+x],x+=E,M-=8);if(c===0)c=1-y;else{if(c===g)return p?NaN:(A?-1:1)*(1/0);p=p+Math.pow(2,i),c=c-y}return(A?-1:1)*p*Math.pow(2,c-i)},t.write=function(e,r,a,i,h,c){var p,b,g,y=c*8-h-1,M=(1<<y)-1,x=M>>1,E=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=i?0:c-1,I=i?1:-1,P=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(b=isNaN(r)?1:0,p=M):(p=Math.floor(Math.log(r)/Math.LN2),r*(g=Math.pow(2,-p))<1&&(p--,g*=2),p+x>=1?r+=E/g:r+=E*Math.pow(2,1-x),r*g>=2&&(p++,g/=2),p+x>=M?(b=0,p=M):p+x>=1?(b=(r*g-1)*Math.pow(2,h),p=p+x):(b=r*Math.pow(2,x-1)*Math.pow(2,h),p=0));h>=8;e[a+A]=b&255,A+=I,b/=256,h-=8);for(p=p<<h|b,y+=h;y>0;e[a+A]=p&255,A+=I,p/=256,y-=8);e[a+A-I]|=P*128}}),tI=zh(t=>{"use strict";var e=vte(),r=mEe(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=p,t.SlowBuffer=L,t.INSPECT_MAX_BYTES=50;var i=2147483647;t.kMaxLength=i,p.TYPED_ARRAY_SUPPORT=h(),!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 h(){try{let T=new Uint8Array(1),k={foo:function(){return 42}};return Object.setPrototypeOf(k,Uint8Array.prototype),Object.setPrototypeOf(T,k),T.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(T){if(T>i)throw new RangeError('The value "'+T+'" is invalid for option "size"');let k=new Uint8Array(T);return Object.setPrototypeOf(k,p.prototype),k}function p(T,k,O){if(typeof T=="number"){if(typeof k=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return M(T)}return b(T,k,O)}p.poolSize=8192;function b(T,k,O){if(typeof T=="string")return x(T,k);if(ArrayBuffer.isView(T))return A(T);if(T==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T);if(ut(T,ArrayBuffer)||T&&ut(T.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ut(T,SharedArrayBuffer)||T&&ut(T.buffer,SharedArrayBuffer)))return I(T,k,O);if(typeof T=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let q=T.valueOf&&T.valueOf();if(q!=null&&q!==T)return p.from(q,k,O);let H=P(T);if(H)return H;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof T[Symbol.toPrimitive]=="function")return p.from(T[Symbol.toPrimitive]("string"),k,O);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T)}p.from=function(T,k,O){return b(T,k,O)},Object.setPrototypeOf(p.prototype,Uint8Array.prototype),Object.setPrototypeOf(p,Uint8Array);function g(T){if(typeof T!="number")throw new TypeError('"size" argument must be of type number');if(T<0)throw new RangeError('The value "'+T+'" is invalid for option "size"')}function y(T,k,O){return g(T),T<=0?c(T):k!==void 0?typeof O=="string"?c(T).fill(k,O):c(T).fill(k):c(T)}p.alloc=function(T,k,O){return y(T,k,O)};function M(T){return g(T),c(T<0?0:N(T)|0)}p.allocUnsafe=function(T){return M(T)},p.allocUnsafeSlow=function(T){return M(T)};function x(T,k){if((typeof k!="string"||k==="")&&(k="utf8"),!p.isEncoding(k))throw new TypeError("Unknown encoding: "+k);let O=C(T,k)|0,q=c(O),H=q.write(T,k);return H!==O&&(q=q.slice(0,H)),q}function E(T){let k=T.length<0?0:N(T.length)|0,O=c(k);for(let q=0;q<k;q+=1)O[q]=T[q]&255;return O}function A(T){if(ut(T,Uint8Array)){let k=new Uint8Array(T);return I(k.buffer,k.byteOffset,k.byteLength)}return E(T)}function I(T,k,O){if(k<0||T.byteLength<k)throw new RangeError('"offset" is outside of buffer bounds');if(T.byteLength<k+(O||0))throw new RangeError('"length" is outside of buffer bounds');let q;return k===void 0&&O===void 0?q=new Uint8Array(T):O===void 0?q=new Uint8Array(T,k):q=new Uint8Array(T,k,O),Object.setPrototypeOf(q,p.prototype),q}function P(T){if(p.isBuffer(T)){let k=N(T.length)|0,O=c(k);return O.length===0||T.copy(O,0,0,k),O}if(T.length!==void 0)return typeof T.length!="number"||Ze(T.length)?c(0):E(T);if(T.type==="Buffer"&&Array.isArray(T.data))return E(T.data)}function N(T){if(T>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return T|0}function L(T){return+T!=T&&(T=0),p.alloc(+T)}p.isBuffer=function(T){return T!=null&&T._isBuffer===!0&&T!==p.prototype},p.compare=function(T,k){if(ut(T,Uint8Array)&&(T=p.from(T,T.offset,T.byteLength)),ut(k,Uint8Array)&&(k=p.from(k,k.offset,k.byteLength)),!p.isBuffer(T)||!p.isBuffer(k))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(T===k)return 0;let O=T.length,q=k.length;for(let H=0,W=Math.min(O,q);H<W;++H)if(T[H]!==k[H]){O=T[H],q=k[H];break}return O<q?-1:q<O?1:0},p.isEncoding=function(T){switch(String(T).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(T,k){if(!Array.isArray(T))throw new TypeError('"list" argument must be an Array of Buffers');if(T.length===0)return p.alloc(0);let O;if(k===void 0)for(k=0,O=0;O<T.length;++O)k+=T[O].length;let q=p.allocUnsafe(k),H=0;for(O=0;O<T.length;++O){let W=T[O];if(ut(W,Uint8Array))H+W.length>q.length?(p.isBuffer(W)||(W=p.from(W)),W.copy(q,H)):Uint8Array.prototype.set.call(q,W,H);else if(p.isBuffer(W))W.copy(q,H);else throw new TypeError('"list" argument must be an Array of Buffers');H+=W.length}return q};function C(T,k){if(p.isBuffer(T))return T.length;if(ArrayBuffer.isView(T)||ut(T,ArrayBuffer))return T.byteLength;if(typeof T!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof T);let O=T.length,q=arguments.length>2&&arguments[2]===!0;if(!q&&O===0)return 0;let H=!1;for(;;)switch(k){case"ascii":case"latin1":case"binary":return O;case"utf8":case"utf-8":return oe(T).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O*2;case"hex":return O>>>1;case"base64":return ge(T).length;default:if(H)return q?-1:oe(T).length;k=(""+k).toLowerCase(),H=!0}}p.byteLength=C;function Y(T,k,O){let q=!1;if((k===void 0||k<0)&&(k=0),k>this.length||((O===void 0||O>this.length)&&(O=this.length),O<=0)||(O>>>=0,k>>>=0,O<=k))return"";for(T||(T="utf8");;)switch(T){case"hex":return o(this,k,O);case"utf8":case"utf-8":return u(this,k,O);case"ascii":return w(this,k,O);case"latin1":case"binary":return d(this,k,O);case"base64":return f(this,k,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,k,O);default:if(q)throw new TypeError("Unknown encoding: "+T);T=(T+"").toLowerCase(),q=!0}}p.prototype._isBuffer=!0;function G(T,k,O){let q=T[k];T[k]=T[O],T[O]=q}p.prototype.swap16=function(){let T=this.length;if(T%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let k=0;k<T;k+=2)G(this,k,k+1);return this},p.prototype.swap32=function(){let T=this.length;if(T%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let k=0;k<T;k+=4)G(this,k,k+3),G(this,k+1,k+2);return this},p.prototype.swap64=function(){let T=this.length;if(T%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let k=0;k<T;k+=8)G(this,k,k+7),G(this,k+1,k+6),G(this,k+2,k+5),G(this,k+3,k+4);return this},p.prototype.toString=function(){let T=this.length;return T===0?"":arguments.length===0?u(this,0,T):Y.apply(this,arguments)},p.prototype.toLocaleString=p.prototype.toString,p.prototype.equals=function(T){if(!p.isBuffer(T))throw new TypeError("Argument must be a Buffer");return this===T?!0:p.compare(this,T)===0},p.prototype.inspect=function(){let T="",k=t.INSPECT_MAX_BYTES;return T=this.toString("hex",0,k).replace(/(.{2})/g,"$1 ").trim(),this.length>k&&(T+=" ... "),"<Buffer "+T+">"},a&&(p.prototype[a]=p.prototype.inspect),p.prototype.compare=function(T,k,O,q,H){if(ut(T,Uint8Array)&&(T=p.from(T,T.offset,T.byteLength)),!p.isBuffer(T))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof T);if(k===void 0&&(k=0),O===void 0&&(O=T?T.length:0),q===void 0&&(q=0),H===void 0&&(H=this.length),k<0||O>T.length||q<0||H>this.length)throw new RangeError("out of range index");if(q>=H&&k>=O)return 0;if(q>=H)return-1;if(k>=O)return 1;if(k>>>=0,O>>>=0,q>>>=0,H>>>=0,this===T)return 0;let W=H-q,fe=O-k,st=Math.min(W,fe),ue=this.slice(q,H),me=T.slice(k,O);for(let pe=0;pe<st;++pe)if(ue[pe]!==me[pe]){W=ue[pe],fe=me[pe];break}return W<fe?-1:fe<W?1:0};function ee(T,k,O,q,H){if(T.length===0)return-1;if(typeof O=="string"?(q=O,O=0):O>2147483647?O=2147483647:O<-2147483648&&(O=-2147483648),O=+O,Ze(O)&&(O=H?0:T.length-1),O<0&&(O=T.length+O),O>=T.length){if(H)return-1;O=T.length-1}else if(O<0)if(H)O=0;else return-1;if(typeof k=="string"&&(k=p.from(k,q)),p.isBuffer(k))return k.length===0?-1:D(T,k,O,q,H);if(typeof k=="number")return k=k&255,typeof Uint8Array.prototype.indexOf=="function"?H?Uint8Array.prototype.indexOf.call(T,k,O):Uint8Array.prototype.lastIndexOf.call(T,k,O):D(T,[k],O,q,H);throw new TypeError("val must be string, number or Buffer")}function D(T,k,O,q,H){let W=1,fe=T.length,st=k.length;if(q!==void 0&&(q=String(q).toLowerCase(),q==="ucs2"||q==="ucs-2"||q==="utf16le"||q==="utf-16le")){if(T.length<2||k.length<2)return-1;W=2,fe/=2,st/=2,O/=2}function ue(pe,be){return W===1?pe[be]:pe.readUInt16BE(be*W)}let me;if(H){let pe=-1;for(me=O;me<fe;me++)if(ue(T,me)===ue(k,pe===-1?0:me-pe)){if(pe===-1&&(pe=me),me-pe+1===st)return pe*W}else pe!==-1&&(me-=me-pe),pe=-1}else for(O+st>fe&&(O=fe-st),me=O;me>=0;me--){let pe=!0;for(let be=0;be<st;be++)if(ue(T,me+be)!==ue(k,be)){pe=!1;break}if(pe)return me}return-1}p.prototype.includes=function(T,k,O){return this.indexOf(T,k,O)!==-1},p.prototype.indexOf=function(T,k,O){return ee(this,T,k,O,!0)},p.prototype.lastIndexOf=function(T,k,O){return ee(this,T,k,O,!1)};function U(T,k,O,q){O=Number(O)||0;let H=T.length-O;q?(q=Number(q),q>H&&(q=H)):q=H;let W=k.length;q>W/2&&(q=W/2);let fe;for(fe=0;fe<q;++fe){let st=parseInt(k.substr(fe*2,2),16);if(Ze(st))return fe;T[O+fe]=st}return fe}function V(T,k,O,q){return Se(oe(k,T.length-O),T,O,q)}function _(T,k,O,q){return Se(le(k),T,O,q)}function n(T,k,O,q){return Se(ge(k),T,O,q)}function s(T,k,O,q){return Se(ot(k,T.length-O),T,O,q)}p.prototype.write=function(T,k,O,q){if(k===void 0)q="utf8",O=this.length,k=0;else if(O===void 0&&typeof k=="string")q=k,O=this.length,k=0;else if(isFinite(k))k=k>>>0,isFinite(O)?(O=O>>>0,q===void 0&&(q="utf8")):(q=O,O=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let H=this.length-k;if((O===void 0||O>H)&&(O=H),T.length>0&&(O<0||k<0)||k>this.length)throw new RangeError("Attempt to write outside buffer bounds");q||(q="utf8");let W=!1;for(;;)switch(q){case"hex":return U(this,T,k,O);case"utf8":case"utf-8":return V(this,T,k,O);case"ascii":case"latin1":case"binary":return _(this,T,k,O);case"base64":return n(this,T,k,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s(this,T,k,O);default:if(W)throw new TypeError("Unknown encoding: "+q);q=(""+q).toLowerCase(),W=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function f(T,k,O){return k===0&&O===T.length?e.fromByteArray(T):e.fromByteArray(T.slice(k,O))}function u(T,k,O){O=Math.min(T.length,O);let q=[],H=k;for(;H<O;){let W=T[H],fe=null,st=W>239?4:W>223?3:W>191?2:1;if(H+st<=O){let ue,me,pe,be;switch(st){case 1:W<128&&(fe=W);break;case 2:ue=T[H+1],(ue&192)===128&&(be=(W&31)<<6|ue&63,be>127&&(fe=be));break;case 3:ue=T[H+1],me=T[H+2],(ue&192)===128&&(me&192)===128&&(be=(W&15)<<12|(ue&63)<<6|me&63,be>2047&&(be<55296||be>57343)&&(fe=be));break;case 4:ue=T[H+1],me=T[H+2],pe=T[H+3],(ue&192)===128&&(me&192)===128&&(pe&192)===128&&(be=(W&15)<<18|(ue&63)<<12|(me&63)<<6|pe&63,be>65535&&be<1114112&&(fe=be))}}fe===null?(fe=65533,st=1):fe>65535&&(fe-=65536,q.push(fe>>>10&1023|55296),fe=56320|fe&1023),q.push(fe),H+=st}return m(q)}var l=4096;function m(T){let k=T.length;if(k<=l)return String.fromCharCode.apply(String,T);let O="",q=0;for(;q<k;)O+=String.fromCharCode.apply(String,T.slice(q,q+=l));return O}function w(T,k,O){let q="";O=Math.min(T.length,O);for(let H=k;H<O;++H)q+=String.fromCharCode(T[H]&127);return q}function d(T,k,O){let q="";O=Math.min(T.length,O);for(let H=k;H<O;++H)q+=String.fromCharCode(T[H]);return q}function o(T,k,O){let q=T.length;(!k||k<0)&&(k=0),(!O||O<0||O>q)&&(O=q);let H="";for(let W=k;W<O;++W)H+=Ge[T[W]];return H}function v(T,k,O){let q=T.slice(k,O),H="";for(let W=0;W<q.length-1;W+=2)H+=String.fromCharCode(q[W]+q[W+1]*256);return H}p.prototype.slice=function(T,k){let O=this.length;T=~~T,k=k===void 0?O:~~k,T<0?(T+=O,T<0&&(T=0)):T>O&&(T=O),k<0?(k+=O,k<0&&(k=0)):k>O&&(k=O),k<T&&(k=T);let q=this.subarray(T,k);return Object.setPrototypeOf(q,p.prototype),q};function R(T,k,O){if(T%1!==0||T<0)throw new RangeError("offset is not uint");if(T+k>O)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=this[T],H=1,W=0;for(;++W<k&&(H*=256);)q+=this[T+W]*H;return q},p.prototype.readUintBE=p.prototype.readUIntBE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=this[T+--k],H=1;for(;k>0&&(H*=256);)q+=this[T+--k]*H;return q},p.prototype.readUint8=p.prototype.readUInt8=function(T,k){return T=T>>>0,k||R(T,1,this.length),this[T]},p.prototype.readUint16LE=p.prototype.readUInt16LE=function(T,k){return T=T>>>0,k||R(T,2,this.length),this[T]|this[T+1]<<8},p.prototype.readUint16BE=p.prototype.readUInt16BE=function(T,k){return T=T>>>0,k||R(T,2,this.length),this[T]<<8|this[T+1]},p.prototype.readUint32LE=p.prototype.readUInt32LE=function(T,k){return T=T>>>0,k||R(T,4,this.length),(this[T]|this[T+1]<<8|this[T+2]<<16)+this[T+3]*16777216},p.prototype.readUint32BE=p.prototype.readUInt32BE=function(T,k){return T=T>>>0,k||R(T,4,this.length),this[T]*16777216+(this[T+1]<<16|this[T+2]<<8|this[T+3])},p.prototype.readBigUInt64LE=ct(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=k+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24,H=this[++T]+this[++T]*2**8+this[++T]*2**16+O*2**24;return BigInt(q)+(BigInt(H)<<BigInt(32))}),p.prototype.readBigUInt64BE=ct(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=k*2**24+this[++T]*2**16+this[++T]*2**8+this[++T],H=this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+O;return(BigInt(q)<<BigInt(32))+BigInt(H)}),p.prototype.readIntLE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=this[T],H=1,W=0;for(;++W<k&&(H*=256);)q+=this[T+W]*H;return H*=128,q>=H&&(q-=Math.pow(2,8*k)),q},p.prototype.readIntBE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=k,H=1,W=this[T+--q];for(;q>0&&(H*=256);)W+=this[T+--q]*H;return H*=128,W>=H&&(W-=Math.pow(2,8*k)),W},p.prototype.readInt8=function(T,k){return T=T>>>0,k||R(T,1,this.length),this[T]&128?(255-this[T]+1)*-1:this[T]},p.prototype.readInt16LE=function(T,k){T=T>>>0,k||R(T,2,this.length);let O=this[T]|this[T+1]<<8;return O&32768?O|4294901760:O},p.prototype.readInt16BE=function(T,k){T=T>>>0,k||R(T,2,this.length);let O=this[T+1]|this[T]<<8;return O&32768?O|4294901760:O},p.prototype.readInt32LE=function(T,k){return T=T>>>0,k||R(T,4,this.length),this[T]|this[T+1]<<8|this[T+2]<<16|this[T+3]<<24},p.prototype.readInt32BE=function(T,k){return T=T>>>0,k||R(T,4,this.length),this[T]<<24|this[T+1]<<16|this[T+2]<<8|this[T+3]},p.prototype.readBigInt64LE=ct(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=this[T+4]+this[T+5]*2**8+this[T+6]*2**16+(O<<24);return(BigInt(q)<<BigInt(32))+BigInt(k+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24)}),p.prototype.readBigInt64BE=ct(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=(k<<24)+this[++T]*2**16+this[++T]*2**8+this[++T];return(BigInt(q)<<BigInt(32))+BigInt(this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+O)}),p.prototype.readFloatLE=function(T,k){return T=T>>>0,k||R(T,4,this.length),r.read(this,T,!0,23,4)},p.prototype.readFloatBE=function(T,k){return T=T>>>0,k||R(T,4,this.length),r.read(this,T,!1,23,4)},p.prototype.readDoubleLE=function(T,k){return T=T>>>0,k||R(T,8,this.length),r.read(this,T,!0,52,8)},p.prototype.readDoubleBE=function(T,k){return T=T>>>0,k||R(T,8,this.length),r.read(this,T,!1,52,8)};function S(T,k,O,q,H,W){if(!p.isBuffer(T))throw new TypeError('"buffer" argument must be a Buffer instance');if(k>H||k<W)throw new RangeError('"value" argument is out of bounds');if(O+q>T.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(T,k,O,q){if(T=+T,k=k>>>0,O=O>>>0,!q){let fe=Math.pow(2,8*O)-1;S(this,T,k,O,fe,0)}let H=1,W=0;for(this[k]=T&255;++W<O&&(H*=256);)this[k+W]=T/H&255;return k+O},p.prototype.writeUintBE=p.prototype.writeUIntBE=function(T,k,O,q){if(T=+T,k=k>>>0,O=O>>>0,!q){let fe=Math.pow(2,8*O)-1;S(this,T,k,O,fe,0)}let H=O-1,W=1;for(this[k+H]=T&255;--H>=0&&(W*=256);)this[k+H]=T/W&255;return k+O},p.prototype.writeUint8=p.prototype.writeUInt8=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,1,255,0),this[k]=T&255,k+1},p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,65535,0),this[k]=T&255,this[k+1]=T>>>8,k+2},p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,65535,0),this[k]=T>>>8,this[k+1]=T&255,k+2},p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,4294967295,0),this[k+3]=T>>>24,this[k+2]=T>>>16,this[k+1]=T>>>8,this[k]=T&255,k+4},p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,4294967295,0),this[k]=T>>>24,this[k+1]=T>>>16,this[k+2]=T>>>8,this[k+3]=T&255,k+4};function B(T,k,O,q,H){j(k,q,H,T,O,7);let W=Number(k&BigInt(4294967295));T[O++]=W,W=W>>8,T[O++]=W,W=W>>8,T[O++]=W,W=W>>8,T[O++]=W;let fe=Number(k>>BigInt(32)&BigInt(4294967295));return T[O++]=fe,fe=fe>>8,T[O++]=fe,fe=fe>>8,T[O++]=fe,fe=fe>>8,T[O++]=fe,O}function F(T,k,O,q,H){j(k,q,H,T,O,7);let W=Number(k&BigInt(4294967295));T[O+7]=W,W=W>>8,T[O+6]=W,W=W>>8,T[O+5]=W,W=W>>8,T[O+4]=W;let fe=Number(k>>BigInt(32)&BigInt(4294967295));return T[O+3]=fe,fe=fe>>8,T[O+2]=fe,fe=fe>>8,T[O+1]=fe,fe=fe>>8,T[O]=fe,O+8}p.prototype.writeBigUInt64LE=ct(function(T,k=0){return B(this,T,k,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeBigUInt64BE=ct(function(T,k=0){return F(this,T,k,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeIntLE=function(T,k,O,q){if(T=+T,k=k>>>0,!q){let st=Math.pow(2,8*O-1);S(this,T,k,O,st-1,-st)}let H=0,W=1,fe=0;for(this[k]=T&255;++H<O&&(W*=256);)T<0&&fe===0&&this[k+H-1]!==0&&(fe=1),this[k+H]=(T/W>>0)-fe&255;return k+O},p.prototype.writeIntBE=function(T,k,O,q){if(T=+T,k=k>>>0,!q){let st=Math.pow(2,8*O-1);S(this,T,k,O,st-1,-st)}let H=O-1,W=1,fe=0;for(this[k+H]=T&255;--H>=0&&(W*=256);)T<0&&fe===0&&this[k+H+1]!==0&&(fe=1),this[k+H]=(T/W>>0)-fe&255;return k+O},p.prototype.writeInt8=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,1,127,-128),T<0&&(T=255+T+1),this[k]=T&255,k+1},p.prototype.writeInt16LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,32767,-32768),this[k]=T&255,this[k+1]=T>>>8,k+2},p.prototype.writeInt16BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,32767,-32768),this[k]=T>>>8,this[k+1]=T&255,k+2},p.prototype.writeInt32LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,2147483647,-2147483648),this[k]=T&255,this[k+1]=T>>>8,this[k+2]=T>>>16,this[k+3]=T>>>24,k+4},p.prototype.writeInt32BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,2147483647,-2147483648),T<0&&(T=4294967295+T+1),this[k]=T>>>24,this[k+1]=T>>>16,this[k+2]=T>>>8,this[k+3]=T&255,k+4},p.prototype.writeBigInt64LE=ct(function(T,k=0){return B(this,T,k,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),p.prototype.writeBigInt64BE=ct(function(T,k=0){return F(this,T,k,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function $(T,k,O,q,H,W){if(O+q>T.length)throw new RangeError("Index out of range");if(O<0)throw new RangeError("Index out of range")}function re(T,k,O,q,H){return k=+k,O=O>>>0,H||$(T,k,O,4,34028234663852886e22,-34028234663852886e22),r.write(T,k,O,q,23,4),O+4}p.prototype.writeFloatLE=function(T,k,O){return re(this,T,k,!0,O)},p.prototype.writeFloatBE=function(T,k,O){return re(this,T,k,!1,O)};function Q(T,k,O,q,H){return k=+k,O=O>>>0,H||$(T,k,O,8,17976931348623157e292,-17976931348623157e292),r.write(T,k,O,q,52,8),O+8}p.prototype.writeDoubleLE=function(T,k,O){return Q(this,T,k,!0,O)},p.prototype.writeDoubleBE=function(T,k,O){return Q(this,T,k,!1,O)},p.prototype.copy=function(T,k,O,q){if(!p.isBuffer(T))throw new TypeError("argument should be a Buffer");if(O||(O=0),!q&&q!==0&&(q=this.length),k>=T.length&&(k=T.length),k||(k=0),q>0&&q<O&&(q=O),q===O||T.length===0||this.length===0)return 0;if(k<0)throw new RangeError("targetStart out of bounds");if(O<0||O>=this.length)throw new RangeError("Index out of range");if(q<0)throw new RangeError("sourceEnd out of bounds");q>this.length&&(q=this.length),T.length-k<q-O&&(q=T.length-k+O);let H=q-O;return this===T&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(k,O,q):Uint8Array.prototype.set.call(T,this.subarray(O,q),k),H},p.prototype.fill=function(T,k,O,q){if(typeof T=="string"){if(typeof k=="string"?(q=k,k=0,O=this.length):typeof O=="string"&&(q=O,O=this.length),q!==void 0&&typeof q!="string")throw new TypeError("encoding must be a string");if(typeof q=="string"&&!p.isEncoding(q))throw new TypeError("Unknown encoding: "+q);if(T.length===1){let W=T.charCodeAt(0);(q==="utf8"&&W<128||q==="latin1")&&(T=W)}}else typeof T=="number"?T=T&255:typeof T=="boolean"&&(T=Number(T));if(k<0||this.length<k||this.length<O)throw new RangeError("Out of range index");if(O<=k)return this;k=k>>>0,O=O===void 0?this.length:O>>>0,T||(T=0);let H;if(typeof T=="number")for(H=k;H<O;++H)this[H]=T;else{let W=p.isBuffer(T)?T:p.from(T,q),fe=W.length;if(fe===0)throw new TypeError('The value "'+T+'" is invalid for argument "value"');for(H=0;H<O-k;++H)this[H+k]=W[H%fe]}return this};var Z={};function K(T,k,O){Z[T]=class extends O{constructor(){super(),Object.defineProperty(this,"message",{value:k.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${T}]`,this.stack,delete this.name}get code(){return T}set code(q){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:q,writable:!0})}toString(){return`${this.name} [${T}]: ${this.message}`}}}K("ERR_BUFFER_OUT_OF_BOUNDS",function(T){return T?`${T} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),K("ERR_INVALID_ARG_TYPE",function(T,k){return`The "${T}" argument must be of type number. Received type ${typeof k}`},TypeError),K("ERR_OUT_OF_RANGE",function(T,k,O){let q=`The value of "${T}" is out of range.`,H=O;return Number.isInteger(O)&&Math.abs(O)>2**32?H=ce(String(O)):typeof O=="bigint"&&(H=String(O),(O>BigInt(2)**BigInt(32)||O<-(BigInt(2)**BigInt(32)))&&(H=ce(H)),H+="n"),q+=` It must be ${k}. Received ${H}`,q},RangeError);function ce(T){let k="",O=T.length,q=T[0]==="-"?1:0;for(;O>=q+4;O-=3)k=`_${T.slice(O-3,O)}${k}`;return`${T.slice(0,O)}${k}`}function te(T,k,O){J(k,"offset"),(T[k]===void 0||T[k+O]===void 0)&&X(k,T.length-(O+1))}function j(T,k,O,q,H,W){if(T>O||T<k){let fe=typeof k=="bigint"?"n":"",st;throw W>3?k===0||k===BigInt(0)?st=`>= 0${fe} and < 2${fe} ** ${(W+1)*8}${fe}`:st=`>= -(2${fe} ** ${(W+1)*8-1}${fe}) and < 2 ** ${(W+1)*8-1}${fe}`:st=`>= ${k}${fe} and <= ${O}${fe}`,new Z.ERR_OUT_OF_RANGE("value",st,T)}te(q,H,W)}function J(T,k){if(typeof T!="number")throw new Z.ERR_INVALID_ARG_TYPE(k,"number",T)}function X(T,k,O){throw Math.floor(T)!==T?(J(T,O),new Z.ERR_OUT_OF_RANGE(O||"offset","an integer",T)):k<0?new Z.ERR_BUFFER_OUT_OF_BOUNDS:new Z.ERR_OUT_OF_RANGE(O||"offset",`>= ${O?1:0} and <= ${k}`,T)}var he=/[^+/0-9A-Za-z-_]/g;function Te(T){if(T=T.split("=")[0],T=T.trim().replace(he,""),T.length<2)return"";for(;T.length%4!==0;)T=T+"=";return T}function oe(T,k){k=k||1/0;let O,q=T.length,H=null,W=[];for(let fe=0;fe<q;++fe){if(O=T.charCodeAt(fe),O>55295&&O<57344){if(!H){if(O>56319){(k-=3)>-1&&W.push(239,191,189);continue}else if(fe+1===q){(k-=3)>-1&&W.push(239,191,189);continue}H=O;continue}if(O<56320){(k-=3)>-1&&W.push(239,191,189),H=O;continue}O=(H-55296<<10|O-56320)+65536}else H&&(k-=3)>-1&&W.push(239,191,189);if(H=null,O<128){if((k-=1)<0)break;W.push(O)}else if(O<2048){if((k-=2)<0)break;W.push(O>>6|192,O&63|128)}else if(O<65536){if((k-=3)<0)break;W.push(O>>12|224,O>>6&63|128,O&63|128)}else if(O<1114112){if((k-=4)<0)break;W.push(O>>18|240,O>>12&63|128,O>>6&63|128,O&63|128)}else throw new Error("Invalid code point")}return W}function le(T){let k=[];for(let O=0;O<T.length;++O)k.push(T.charCodeAt(O)&255);return k}function ot(T,k){let O,q,H,W=[];for(let fe=0;fe<T.length&&!((k-=2)<0);++fe)O=T.charCodeAt(fe),q=O>>8,H=O%256,W.push(H),W.push(q);return W}function ge(T){return e.toByteArray(Te(T))}function Se(T,k,O,q){let H;for(H=0;H<q&&!(H+O>=k.length||H>=T.length);++H)k[H+O]=T[H];return H}function ut(T,k){return T instanceof k||T!=null&&T.constructor!=null&&T.constructor.name!=null&&T.constructor.name===k.name}function Ze(T){return T!==T}var Ge=function(){let T="0123456789abcdef",k=new Array(256);for(let O=0;O<16;++O){let q=O*16;for(let H=0;H<16;++H)k[q+H]=T[O]+T[H]}return k}();function ct(T){return typeof BigInt>"u"?z:T}function z(){throw new Error("BigInt not supported")}}),gEe=zh((t,e)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,e.exports={Buffer:tI().Buffer,Crypto:window.crypto}):e.exports={Buffer:tI().Buffer,Crypto:crypto}}),gte={};cEe(gte,{AVSCTap:()=>B2,ArweaveSigner:()=>RI,DataItem:()=>A2,MAX_TAG_BYTES:()=>E4,MIN_BINARY_SIZE:()=>kI,SIG_CONFIG:()=>K1,SignatureConfig:()=>Ns,Signer:()=>bte,createData:()=>Mte,deserializeTags:()=>v4,indexToType:()=>TI,serializeTags:()=>II,tagsExceedLimit:()=>_te});var bte=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(t,e,r,a){throw new Error("You must implement verify method on child")}},bEe=Rd(AI(),1),kf=Rd(mte(),1);async function yte(t){if(Array.isArray(t)){let i=(0,kf.concatBuffers)([(0,kf.stringToBuffer)("list"),(0,kf.stringToBuffer)(t.length.toString())]);return await wte(t,await qh().hash(i,"SHA-384"))}let e=t,r=(0,kf.concatBuffers)([(0,kf.stringToBuffer)("blob"),(0,kf.stringToBuffer)(e.byteLength.toString())]),a=(0,kf.concatBuffers)([await qh().hash(r,"SHA-384"),await qh().hash(e,"SHA-384")]);return await qh().hash(a,"SHA-384")}async function wte(t,e){if(t.length<1)return e;let r=(0,kf.concatBuffers)([e,await yte(t[0])]),a=await qh().hash(r,"SHA-384");return await wte(t.slice(1),a)}var BT=Rd(vEe(),1),yEe=BT.default.default?BT.default.default:BT.default,wEe=class extends yEe{getPublicKey(t){throw new Error("Unimplemented")}},_Ee;function qh(){return _Ee??=new wEe}var Ns;(function(t){t[t.ARWEAVE=1]="ARWEAVE",t[t.ED25519=2]="ED25519",t[t.ETHEREUM=3]="ETHEREUM",t[t.SOLANA=4]="SOLANA",t[t.INJECTEDAPTOS=5]="INJECTEDAPTOS",t[t.MULTIAPTOS=6]="MULTIAPTOS",t[t.TYPEDETHEREUM=7]="TYPEDETHEREUM"})(Ns||(Ns={}));var K1={[Ns.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[Ns.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[Ns.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[Ns.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[Ns.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[Ns.MULTIAPTOS]:{sigLength:64*32+4,pubLength:32*32+1,sigName:"multiAptos"},[Ns.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},RI=class{signatureType=1;ownerLength=K1[1].pubLength;signatureLength=K1[1].sigLength;jwk;pk;constructor(t){this.pk=t.n,this.jwk=t}get publicKey(){return bEe.default.toBuffer(this.pk)}sign(t){return qh().sign(this.jwk,t)}static async verify(t,e,r){return await qh().verify(t,e,r)}},TI={1:RI},Ou=Rd(AI(),1);async function rI(t){return yte([(0,kf.stringToBuffer)("dataitem"),(0,kf.stringToBuffer)("1"),(0,kf.stringToBuffer)(t.signatureType.toString()),t.rawOwner,t.rawTarget,t.rawAnchor,t.rawTags,t.rawData])}async function MEe(t,e){let r=await rI(t),a=await e.sign(r),i=await qh().hash(a);return{signature:Me.from(a),id:Me.from(i)}}async function xEe(t,e){let{signature:r,id:a}=await MEe(t,e);return t.getRaw().set(r,2),a}var B2=class{buf;pos;constructor(t=Me.alloc(E4),e=0){this.buf=t,this.pos=e}writeTags(t){if(!Array.isArray(t))throw new Error("input must be array");let e=t.length,r;if(e)for(this.writeLong(e),r=0;r<e;r++){let a=t[r];if(a?.name===void 0||a?.value===void 0)throw new Error(`Invalid tag format for ${a}, expected {name:string, value: string}`);this.writeString(a.name),this.writeString(a.value)}this.writeLong(0)}toBuffer(){let t=Me.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(t,0,0,this.pos),t}tagsExceedLimit(){return this.pos>this.buf.length}writeLong(t){let e=this.buf,r,a;if(t>=-1073741824&&t<1073741824){a=t>=0?t<<1:~t<<1|1;do e[this.pos]=a&127,a>>=7;while(a&&(e[this.pos++]|=128))}else{r=t>=0?t*2:-t*2-1;do e[this.pos]=r&127,r/=128;while(r>=1&&(e[this.pos++]|=128))}this.pos++,this.buf=e}writeString(t){let e=Me.byteLength(t),r=this.buf;this.writeLong(e);let a=this.pos;if(this.pos+=e,!(this.pos>r.length)){if(e>64)this.buf.write(t,this.pos-e,e,"utf8");else{let i,h,c,p;for(i=0,h=e;i<h;i++)c=t.charCodeAt(i),c<128?r[a++]=c:c<2048?(r[a++]=c>>6|192,r[a++]=c&63|128):(c&64512)===55296&&((p=t.charCodeAt(i+1))&64512)===56320?(c=65536+((c&1023)<<10)+(p&1023),i++,r[a++]=c>>18|240,r[a++]=c>>12&63|128,r[a++]=c>>6&63|128,r[a++]=c&63|128):(r[a++]=c>>12|224,r[a++]=c>>6&63|128,r[a++]=c&63|128)}this.buf=r}}readLong(){let t=0,e=0,r=this.buf,a,i,h,c;do a=r[this.pos++],i=a&128,t|=(a&127)<<e,e+=7;while(i&&e<28);if(i){h=t,c=268435456;do a=r[this.pos++],h+=(a&127)*c,c*=128;while(a&128);return(h%2?-(h+1):h)/2}return t>>1^-(t&1)}skipLong(){let t=this.buf;for(;t[this.pos++]&128;);}readTags(){let t=[],e;for(;e=this.readLong();)for(e<0&&(e=-e,this.skipLong());e--;){let r=this.readString(),a=this.readString();t.push({name:r,value:a})}return t}readString(){let t=this.readLong(),e=this.pos,r=this.buf;if(this.pos+=t,!(this.pos>r.length))return this.buf.slice(e,e+t).toString()}};function II(t){let e=new B2;return e.writeTags(t),e.toBuffer()}function _te(t){let e=new B2;return e.writeTags(t),e.tagsExceedLimit()}function v4(t){return new B2(t).readTags()}function pl(t){let e=0;for(let r=t.length-1;r>=0;r--)e=e*256+t[r];return e}function SEe(t){if(t>29)throw new Error("Short too long");let e=[0,0];for(let r=0;r<e.length;r++){let a=t&255;e[r]=a,t=(t-a)/256}return Uint8Array.from(e)}function $Q(t){let e=[0,0,0,0,0,0,0,0];for(let r=0;r<e.length;r++){let a=t&255;e[r]=a,t=(t-a)/256}return Uint8Array.from(e)}var EEe=Rd(gEe(),1),A1=Rd(tI(),1),E4=4096,kI=80,A2=class{binary;_id;constructor(t){this.binary=t}static isDataItem(t){return t.binary!==void 0}get signatureType(){let t=pl(this.binary.subarray(0,2));if(Ns?.[t]!==void 0)return t;throw new Error("Unknown signature type: "+t)}async isValid(){return A2.verify(this.binary)}get id(){return(async()=>Ou.default.encode(await this.rawId))()}set id(t){this._id=Ou.default.toBuffer(t)}get rawId(){return(async()=>A1.Buffer.from(await EEe.Crypto.subtle.digest("SHA-256",this.rawSignature)))()}set rawId(t){this._id=t}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return Ou.default.encode(this.rawSignature)}set rawOwner(t){if(t.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${t.byteLength} bytes.`);this.binary.set(t,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return K1[this.signatureType].sigLength}get owner(){return Ou.default.encode(this.rawOwner)}get ownerLength(){return K1[this.signatureType].pubLength}get rawTarget(){let t=this.getTargetStart();return this.binary[t]==1?this.binary.subarray(t+1,t+33):A1.Buffer.alloc(0)}get target(){return Ou.default.encode(this.rawTarget)}get rawAnchor(){let t=this.getAnchorStart();return this.binary[t]==1?this.binary.subarray(t+1,t+33):A1.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let t=this.getTagsStart(),e=pl(this.binary.subarray(t+8,t+16));return this.binary.subarray(t+16,t+16+e)}get tags(){let t=this.getTagsStart();if(pl(this.binary.subarray(t,t+8))==0)return[];let e=pl(this.binary.subarray(t+8,t+16));return v4(A1.Buffer.from(this.binary.subarray(t+16,t+16+e)))}get tagsB64Url(){return this.tags.map(t=>({name:Ou.default.encode(t.name),value:Ou.default.encode(t.value)}))}getStartOfData(){let t=this.getTagsStart(),e=this.binary.subarray(t+8,t+16),r=pl(e);return t+16+r}get rawData(){let t=this.getTagsStart(),e=this.binary.subarray(t+8,t+16),r=pl(e),a=t+16+r;return this.binary.subarray(a,this.binary.length)}get data(){return Ou.default.encode(this.rawData)}getRaw(){return this.binary}async sign(t){return this._id=await xEe(this,t),this.rawId}async setSignature(t){this.binary.set(t,2),this._id=A1.Buffer.from(await qh().hash(t))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map(t=>({name:Ou.default.encode(t.name),value:Ou.default.encode(t.value)})),data:this.data}}static async verify(t){if(t.byteLength<kI)return!1;let e=new A2(t),r=e.signatureType,a=e.getTagsStart(),i=pl(t.subarray(a,a+8)),h=t.subarray(a+8,a+16),c=pl(h);if(c>E4)return!1;if(i>0)try{if(v4(A1.Buffer.from(t.subarray(a+16,a+16+c))).length!==i)return!1}catch{return!1}let p=TI[r],b=await rI(e);return await p.verify(e.rawOwner,b,e.rawSignature)}async getSignatureData(){return rI(this)}getTagsStart(){let t=this.getTargetStart(),e=this.binary[t]==1,r=t+(e?33:1),a=this.binary[r]==1;return r+=a?33:1,r}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let t=this.getTargetStart()+1,e=this.binary[this.getTargetStart()]==1;return t+=e?32:0,t}},AEe=Rd(AI(),1);function Mte(t,e,r){let a=e.publicKey,i=r?.target?AEe.default.toBuffer(r.target):null,h=1+(i?.byteLength??0),c=r?.anchor?Me.from(r.anchor):null,p=1+(c?.byteLength??0),b=(r?.tags?.length??0)>0?II(r.tags):null,g=16+(b?b.byteLength:0),y=Me.from(t),M=y.byteLength,x=2+e.signatureLength+e.ownerLength+h+p+g+M,E=Me.alloc(x);if(E.set(SEe(e.signatureType),0),E.set(new Uint8Array(e.signatureLength).fill(0),2),a.byteLength!==e.ownerLength)throw new Error(`Owner must be ${e.ownerLength} bytes, but was incorrectly ${a.byteLength}`);E.set(a,2+e.signatureLength);let A=2+e.signatureLength+e.ownerLength;if(E[A]=i?1:0,i){if(i.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${i.byteLength}`);E.set(i,A+1)}let I=A+h,P=I+1;if(E[I]=c?1:0,c){if(P+=c.byteLength,c.byteLength!==32)throw new Error("Anchor must be 32 bytes");E.set(c,I+1)}E.set($Q(r?.tags?.length??0),P);let N=$Q(b?.byteLength??0);E.set(N,P+8),b&&E.set(b,P+16);let L=P+g;return E.set(y,L),new A2(E)}var BI={...gte};globalThis.arbundles??=BI;var REe=BI,TEe=BI;globalThis.Buffer||(globalThis.Buffer=dte.Buffer);var{DataItem:IEe}=pte;function kEe(t){return async({data:r,tags:a,target:i,anchor:h,createDataItem:c=p=>new IEe(p)})=>{let p=await t.signDataItem({data:r,tags:a,target:i,anchor:h}),b=c(dte.Buffer.from(p));return{id:await b.id,raw:await b.getRaw()}}}var BEe=globalThis.GATEWAY_URL||void 0,PEe=globalThis.MU_URL||void 0,OEe=globalThis.CU_URL||void 0,NEe=globalThis.GRAPHQL_URL||void 0,{result:dut,results:put,message:vut,spawn:mut,monitor:gut,unmonitor:but,dryrun:yut,assign:wut}=Sl({GATEWAY_URL:BEe,MU_URL:PEe,CU_URL:OEe,GRAPHQL_URL:NEe}),xte=lte.createDataItemSigner;ie();ae();ne();var mre=mi(vre(),1),N4=mre.default.init({host:"arweave.net",port:443,protocol:"https"});ie();ae();ne();ie();ae();ne();var Df=class extends Error{constructor(e){super(e),this.name=this.constructor.name}},gre=class extends Df{},bre=class extends Df{},yre=class extends Df{constructor(e,r){super(`Failed request: ${e}: ${r}`)}},wre=class extends Df{},C4=class extends Df{},_re=class extends Df{constructor(){super("Invalid signer. Please provide a valid signer to interact with the contract.")}},Rl=class extends Df{constructor(){super("Invalid contract configuration")}},Mre=class extends Df{constructor(){super("Invalid process configuration")}},xre=class extends Df{};ie();ae();ne();var Kf=mi(zfe(),1);ie();ae();ne();var jw="3.5.0";var Wu=class t{logger;silent=!1;static default=new t;constructor({level:e="info"}={}){e==="none"&&(this.silent=!0),typeof window<"u"?this.logger=console:this.logger=(0,Kf.createLogger)({level:e,silent:this.silent,defaultMeta:{name:"ar-io-sdk",version:jw},format:Kf.format.combine(Kf.format.timestamp(),Kf.format.json()),transports:[new Kf.transports.Console({format:Kf.format.combine(Kf.format.timestamp(),Kf.format.json())})]})}info(e,...r){this.silent||this.logger.info(e,...r)}warn(e,...r){this.silent||this.logger.warn(e,...r)}error(e,...r){this.silent||this.logger.error(e,...r)}debug(e,...r){this.silent||this.logger.debug(e,...r)}setLogLevel(e){this.silent=e==="none","silent"in this.logger&&(this.logger.silent=e==="none"),"level"in this.logger&&(this.logger.level=e)}};ie();ae();ne();ie();ae();ne();function Pl(t,e){let r=t.safeParse(e);if(!r.success)throw new Error(JSON.stringify(r.error.format(),null,2));return r}var zw=class{static init(e){return e!==void 0&&"signer"in e?new fP(e):new Zw(e)}},Zw=class{process;processId;strict;constructor(e){if(this.strict=e.strict||!1,vv(e))this.process=e.process;else if(mv(e))this.process=new za({processId:e.processId});else throw new Rl;this.processId=this.process.processId}async getState({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"State"}],a=await this.process.read({tags:r});return e&&Pl(MT.passthrough().and(Qt.object({Records:Qt.record(Qt.string(),q8.passthrough())})),a),a}async getInfo({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Info"}],a=await this.process.read({tags:r});return e&&Pl(dQ.passthrough(),a),a}async getLogo(){return(await this.getInfo()).Logo}async getRecord({undername:e},{strict:r}={strict:this.strict}){let a=[{name:"Sub-Domain",value:e},{name:"Action",value:"Record"}],i=await this.process.read({tags:a});return r&&Pl(q8.passthrough(),i),i}async getRecords({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Records"}],a=await this.process.read({tags:r});return e&&Pl(yT,a),a}async getOwner({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Owner}async getControllers({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Controllers"}],a=await this.process.read({tags:r});return e&&Pl(wT,a),a}async getName({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Name}async getTicker({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Ticker}async getBalances({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Balances"}],a=await this.process.read({tags:r});return e&&Pl(_T,a),a}async getBalance({address:e},{strict:r}={strict:this.strict}){let a=[{name:"Action",value:"Balance"},{name:"Recipient",value:e}],i=await this.process.read({tags:a});return r&&Pl(Qt.number(),i),i}async getHandlers(){let e=await this.getInfo();return e.Handlers??e.HandlerNames}},fP=class extends Zw{signer;constructor({signer:e,...r}){super(r),this.signer=pv(e)}async transfer({target:e},r){let a=[...r?.tags??[],{name:"Action",value:"Transfer"},{name:"Recipient",value:e}];return this.process.send({tags:a,signer:this.signer})}async addController({controller:e},r){let a=[...r?.tags??[],{name:"Action",value:"Add-Controller"},{name:"Controller",value:e}];return this.process.send({tags:a,signer:this.signer})}async removeController({controller:e},r){let a=[...r?.tags??[],{name:"Action",value:"Remove-Controller"},{name:"Controller",value:e}];return this.process.send({tags:a,signer:this.signer})}async setRecord({undername:e,transactionId:r,ttlSeconds:a},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:e},{name:"Transaction-Id",value:r},{name:"TTL-Seconds",value:a.toString()}],signer:this.signer})}async setBaseNameRecord({transactionId:e,ttlSeconds:r},a){return this.setRecord({transactionId:e,ttlSeconds:r,undername:"@"},a)}async setUndernameRecord({undername:e,transactionId:r,ttlSeconds:a},i){return this.setRecord({undername:e,transactionId:r,ttlSeconds:a},i)}async removeUndernameRecord({undername:e}){return this.removeRecord({undername:e})}async removeRecord({undername:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:e}],signer:this.signer})}async setTicker({ticker:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:e}],signer:this.signer})}async setName({name:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Name"},{name:"Name",value:e}],signer:this.signer})}async setDescription({description:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Description"},{name:"Description",value:e}],signer:this.signer})}async setKeywords({keywords:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Keywords"},{name:"Keywords",value:JSON.stringify(e)}],signer:this.signer})}async setLogo({txId:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Logo"},{name:"Logo",value:e}],signer:this.signer})}async releaseName({name:e,arioProcessId:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Release-Name"},{name:"Name",value:e},{name:"IO-Process-Id",value:r},{name:"ARIO-Process-Id",value:r}],signer:this.signer})}async reassignName({name:e,arioProcessId:r,antProcessId:a},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Reassign-Name"},{name:"Name",value:e},{name:"IO-Process-Id",value:r},{name:"ARIO-Process-Id",value:r},{name:"Process-Id",value:a}],signer:this.signer})}async approvePrimaryNameRequest({name:e,address:r,arioProcessId:a},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Approve-Primary-Name"},{name:"Name",value:e},{name:"Recipient",value:r},{name:"IO-Process-Id",value:a},{name:"ARIO-Process-Id",value:a}],signer:this.signer})}async removePrimaryNames({names:e,arioProcessId:r,notifyOwners:a=!1},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Remove-Primary-Names"},{name:"Names",value:e.join(",")},{name:"IO-Process-Id",value:r},{name:"ARIO-Process-Id",value:r},{name:"Notify-Owners",value:a.toString()}],signer:this.signer})}};ie();ae();ne();var Eb=class{static init(e){return e!==void 0&&"signer"in e?new uP(e):new Hw(e)}},Hw=class{process;constructor(e){if(e===void 0||Object.keys(e).length===0)this.process=new za({processId:$8});else if(vv(e))this.process=e.process;else if(mv(e))this.process=new za({processId:e.processId});else throw new Rl}async accessControlList({address:e}){return this.process.read({tags:[{name:"Action",value:"Access-Control-List"},{name:"Address",value:e}]})}},uP=class extends Hw{signer;constructor({signer:e,...r}){super(r),this.signer=pv(e)}async register({processId:e}){return this.process.send({tags:[{name:"Action",value:"Register"},{name:"Process-Id",value:e}],signer:this.signer})}};ie();ae();ne();ie();ae();ne();ie();ae();ne();lu();var Zfe="+",Hfe="/",Kfe="-",Wfe="_",Vfe="=";function Qqe(t){let e=t.length%4;return e&&(t+=Vfe.repeat(4-e)),t.replaceAll(Kfe,Zfe).replaceAll(Wfe,Hfe)}function eUe(t){return t.replaceAll(Zfe,Kfe).replaceAll(Hfe,Wfe).replaceAll(Vfe,"")}function Jbt(t){let e=Qqe(t);return Me.from(e,"base64")}function tUe(t){let e=t.toString("base64");return eUe(e)}function Xbt(t){return tUe(df("sha256").update(Uint8Array.from(t)).digest())}function Gfe(t=32){let e=oE(t);return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("").slice(0,t)}ie();ae();ne();ie();ae();ne();function hP(t){try{return JSON.parse(t)}catch{return t}}ie();ae();ne();ie();ae();ne();var lP=mi(Jfe(),1);ie();ae();ne();var nUe=Object.defineProperty,aUe=(t,e,r)=>e in t?nUe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rb=(t,e,r)=>(aUe(t,typeof e!="symbol"?e+"":e,r),r),dP=class{constructor(e){Rb(this,"value"),Rb(this,"next"),this.value=e}},pP=class{constructor(){Rb(this,"head"),Rb(this,"tail"),Rb(this,"_size",0),this.clear()}clear(){this.head=void 0,this.tail=void 0,this._size=0}push(e){let r=new dP(e);return this.head&&this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),this._size++,this._size}pop(){if(!this.head)return;let e=this.head;return this.head=this.head.next,this._size--,e.value}get size(){return this._size}*[Symbol.iterator](){let e=this.head;for(;e;)yield e.value,e=e.next}};function Xfe(t){if(!((Number.isInteger(t)||t===1/0)&&t>0))throw new TypeError("Expected `concurrency` to be a number greater than 1");let e=new pP,r=0,a=()=>{r--,e.size>0&&e.pop()()},i=async(p,b,g)=>{r++;let y=(async()=>p(...g))();b(y);try{await y}catch{}a()},h=(p,b,g)=>{e.push(i.bind(null,p,b,g)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.pop()()))()},c=(p,...b)=>new Promise(g=>{h(p,g,b)});return Object.defineProperties(c,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),c}var Iyt=async({address:t,registry:e=Eb.init()})=>{let r=await e.accessControlList({address:t});return[...new Set([...r.Owned,...r.Controlled])]};function Qfe(t,e){return new Promise((r,a)=>{let i=setTimeout(()=>{a(new Error("Timeout"))},t);e.then(h=>{clearTimeout(i),r(h)}).catch(h=>{clearTimeout(i),a(h)})})}var eue=class extends lP.default{contract;timeoutMs;throttle;logger;strict;antAoClient;constructor({contract:e=Tb.init({processId:Lh}),timeoutMs:r=6e4,concurrency:a=30,logger:i=Wu.default,strict:h=!1,antAoClient:c=Sl()}={}){super(),this.contract=e,this.timeoutMs=r,this.throttle=Xfe(a),this.logger=i,this.strict=h,this.antAoClient=c}async fetchProcessesOwnedByWallet({address:e,pageSize:r,antRegistry:a=Eb.init()}){let i={},h=await a.accessControlList({address:e}),c=new Set([...h.Owned,...h.Controlled]);await Qfe(this.timeoutMs,oUe({contract:this.contract,emitter:this,pageSize:r})).catch(b=>(this.emit("error",`Error getting ArNS records: ${b}`),this.logger.error("Error getting ArNS records",{message:b?.message,stack:b?.stack}),{})).then(b=>{Object.entries(b).forEach(([g,y])=>{c.has(y.processId)&&(i[y.processId]==null&&(i[y.processId]={state:void 0,names:{}}),i[y.processId].names[g]=y)})});let p=Object.keys(i).length;this.emit("progress",0,p),await Promise.all(Object.keys(i).map(async(b,g)=>this.throttle(async()=>{if(i[b].state!==void 0){this.emit("progress",g+1,p);return}let y=zw.init({process:new za({processId:b,ao:this.antAoClient}),strict:this.strict}),M=await Qfe(this.timeoutMs,y.getState()).catch(x=>{this.emit("error",`Error getting state for process ${b}: ${x}`)});(M?.Owner===e||M?.Controllers.includes(e))&&(i[b].state=M,this.emit("process",b,i[b])),this.emit("progress",g+1,p)}))),this.emit("end",i)}},oUe=async({contract:t=Tb.init({processId:Lh}),emitter:e,logger:r=Wu.default,pageSize:a=5e4})=>{let i,h=Date.now(),c={};do{let p=await t.getArNSRecords({cursor:i,limit:a}).catch(b=>{r?.error("Error getting ArNS records",{message:b?.message,stack:b?.stack}),e?.emit("arns:error",`Error getting ArNS records: ${b}`)});if(!p)return{};p.items.forEach(b=>{let{name:g,...y}=b;c[g]=y}),r.debug("Fetched page of ArNS records",{totalRecordCount:p.totalItems,fetchedRecordCount:Object.keys(c).length,cursor:p.nextCursor}),e?.emit("arns:pageLoaded",{totalRecordCount:p.totalItems,fetchedRecordCount:Object.keys(c).length,records:p.items,cursor:p.nextCursor}),i=p.nextCursor}while(i!==void 0);return e?.emit("arns:end",c),r.debug("Fetched all ArNS records",{totalRecordCount:Object.keys(c).length,durationMs:Date.now()-h}),c};ie();ae();ne();var Nyt=t=>{let e=Object.entries(t).sort(([r,a],[i,h])=>r==="@"?-1:i==="@"?1:"priority"in a&&!("priority"in h)?-1:!("priority"in a)&&"priority"in h?1:a.priority!==void 0&&h.priority!==void 0?a.priority===h.priority?r<i?-1:r>i?1:0:a.priority-h.priority:r<i?-1:r>i?1:0);return Object.fromEntries(e.map(([r,a],i)=>[r,{...a,index:i}]))};var za=class{logger;ao;processId;constructor({processId:e,ao:r=Sl(),logger:a=Wu.default}){this.processId=e,this.logger=a,this.ao=r}isMessageDataEmpty(e){return e===void 0||e==="null"||e===""||e===null}async read({tags:e,retries:r=3,fromAddress:a}){let i=0,h;for(;i<r;)try{this.logger.debug("Evaluating read interaction on process",{tags:e,processId:this.processId});let c={process:this.processId,tags:e};a!==void 0&&(c.Owner=a);let p=await this.ao.dryrun(c);this.logger.debug("Read interaction result",{result:p,processId:this.processId});let b=vP(p);if(b!==void 0)throw new Error(b);if(p.Messages===void 0||p.Messages.length===0)throw this.logger.debug(`Process ${this.processId} does not support provided action.`,{result:p,tags:e,processId:this.processId}),new Error(`Process ${this.processId} does not support provided action.`);let g=p.Messages?.[0]?.Data;return this.isMessageDataEmpty(g)?void 0:hP(g)}catch(c){i++,this.logger.debug(`Read attempt ${i} failed`,{error:c?.message,stack:c?.stack,tags:e,processId:this.processId}),h=c,await new Promise(p=>setTimeout(p,2**i*1e3))}throw h}async send({tags:e,data:r,signer:a,retries:i=3}){let h=0,c;for(;h<i;)try{this.logger.debug("Evaluating send interaction on contract",{tags:e,data:r,processId:this.processId});let p=Gfe(32),b=await this.ao.message({process:this.processId,tags:[...e,{name:"AR-IO-SDK",value:jw}],data:r,signer:a,anchor:p});this.logger.debug("Sent message to process",{messageId:b,processId:this.processId,anchor:p});let g=await this.ao.result({message:b,process:this.processId});this.logger.debug("Message result",{output:g,messageId:b,processId:this.processId});let y=vP(g);if(y!==void 0)throw new C4(y);if(g.Messages?.length===0||g.Messages===void 0)return{id:b};if(g.Messages.length===0)throw new Error(`Process ${this.processId} does not support provided action.`);if(this.isMessageDataEmpty(g.Messages[0].Data))return{id:b};let M=hP(g.Messages[0].Data);return this.logger.debug("Message result data",{resultData:M,messageId:b,processId:this.processId}),{id:b,result:M}}catch(p){if(this.logger.error("Error sending message to process",{error:p?.message,stack:p?.stack,processId:this.processId,tags:e}),p.message.includes("500"))this.logger.debug("Retrying send interaction",{attempts:h,retries:i,error:p?.message,processId:this.processId}),await new Promise(b=>setTimeout(b,2**h*2e3)),h++,c=p;else throw p}throw c}};var Tb=class{static init(e){return e!==void 0&&"signer"in e?new mP(e):new Ww(e)}},Ww=class{process;epochSettings;arweave;constructor(e){if(this.arweave=e?.arweave??N4,e===void 0||Object.keys(e).length===0)this.process=new za({processId:Lh});else if(vv(e))this.process=e.process;else if(mv(e))this.process=new za({processId:e.processId});else throw new Rl}async getInfo(){return this.process.read({tags:[{name:"Action",value:"Info"}]})}async getTokenSupply(){return this.process.read({tags:[{name:"Action",value:"Total-Token-Supply"}]})}async computeEpochIndexForTimestamp(e){let r=await this.getEpochSettings(),a=r.epochZeroStartTimestamp,i=r.durationMs;return Math.floor((e-a)/i)}async computeCurrentEpochIndex(){let e=await this.getEpochSettings(),r=e.epochZeroStartTimestamp,a=e.durationMs,i=Date.now();return Math.floor((i-r)/a)}async computeEpochIndex(e){let r=e?.epochIndex;if(r!==void 0)return r.toString();let a=e?.timestamp;if(a!==void 0)return(await this.computeEpochIndexForTimestamp(a)).toString()}async getEpochSettings(){return this.epochSettings??=await this.process.read({tags:[{name:"Action",value:"Epoch-Settings"}]})}async getEpoch(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&+r<a)return await gv({arweave:this.arweave,epochIndex:+r,processId:this.process.processId});let i=[{name:"Action",value:"Epoch"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(i)})}async getArNSRecord({name:e}){return this.process.read({tags:[{name:"Action",value:"Record"},{name:"Name",value:e}]})}async getArNSRecords(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Records"},...Ha(e)]})}async getArNSReservedNames(e){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"},...Ha(e)]})}async getArNSReservedName({name:e}){return this.process.read({tags:[{name:"Action",value:"Reserved-Name"},{name:"Name",value:e}]})}async getBalance({address:e}){return this.process.read({tags:[{name:"Action",value:"Balance"},{name:"Address",value:e}]})}async getBalances(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Balances"},...Ha(e)]})}async getVault({address:e,vaultId:r}){return this.process.read({tags:[{name:"Action",value:"Vault"},{name:"Address",value:e},{name:"Vault-Id",value:r}]})}async getVaults(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Vaults"},...Ha(e)]})}async getGateway({address:e}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:e}]})}async getGatewayDelegates({address:e,...r}){return this.process.read({tags:[{name:"Action",value:"Paginated-Delegates"},{name:"Address",value:e},...Ha(r)]})}async getGatewayDelegateAllowList({address:e,...r}){return this.process.read({tags:[{name:"Action",value:"Paginated-Allowed-Delegates"},{name:"Address",value:e},...Ha(r)]})}async getGateways(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateways"},...Ha(e)]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"}]})}async getPrescribedObservers(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&+r<a)return(await gv({arweave:this.arweave,epochIndex:+r,processId:this.process.processId}))?.prescribedObservers;let i=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(i)})}async getPrescribedNames(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&+r<a)return(await gv({arweave:this.arweave,epochIndex:+r,processId:this.process.processId}))?.prescribedNames;let i=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(i)})}async getObservations(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&+r<a)return(await gv({arweave:this.arweave,epochIndex:+r,processId:this.process.processId}))?.observations;let i=[{name:"Action",value:"Epoch-Observations"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(i)})}async getDistributions(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&+r<a)return(await gv({arweave:this.arweave,epochIndex:+r,processId:this.process.processId}))?.distributions;let i=[{name:"Action",value:"Epoch-Distributions"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(i)})}async getTokenCost({intent:e,type:r,years:a,name:i,quantity:h,fromAddress:c}){let p=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:e},{name:"Name",value:i},{name:"Years",value:a?.toString()},{name:"Quantity",value:h?.toString()},{name:"Purchase-Type",value:r}];return this.process.read({tags:Sn(p),fromAddress:c})}async getCostDetails({intent:e,type:r,years:a,name:i,quantity:h,fromAddress:c,fundFrom:p}){let b=[{name:"Action",value:"Cost-Details"},{name:"Intent",value:e},{name:"Name",value:i},{name:"Years",value:a?.toString()},{name:"Quantity",value:h?.toString()},{name:"Purchase-Type",value:r},{name:"Fund-From",value:p}];return this.process.read({tags:Sn(b),fromAddress:c})}async getRegistrationFees(){return this.process.read({tags:[{name:"Action",value:"Registration-Fees"}]})}async getDemandFactor(){return this.process.read({tags:[{name:"Action",value:"Demand-Factor"}]})}async getDemandFactorSettings(){return this.process.read({tags:[{name:"Action",value:"Demand-Factor-Settings"}]})}async getArNSReturnedNames(e){return this.process.read({tags:[{name:"Action",value:"Returned-Names"},...Ha(e)]})}async getArNSReturnedName({name:e}){let r=[{name:"Action",value:"Returned-Name"},{name:"Name",value:e}];return this.process.read({tags:r})}async getDelegations(e){let r=[{name:"Action",value:"Paginated-Delegations"},{name:"Address",value:e.address},...Ha(e)];return this.process.read({tags:Sn(r)})}async getAllowedDelegates(e){return this.getGatewayDelegateAllowList(e)}async getGatewayVaults(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateway-Vaults"},{name:"Address",value:e.address},...Ha(e)]})}async getPrimaryNameRequest(e){let r=[{name:"Action",value:"Primary-Name-Request"},{name:"Initiator",value:e.initiator}];return this.process.read({tags:r})}async getPrimaryNameRequests(e){return this.process.read({tags:[{name:"Action",value:"Primary-Name-Requests"},...Ha(e)]})}async getPrimaryName(e){let r=[{name:"Action",value:"Primary-Name"},{name:"Address",value:e?.address},{name:"Name",value:e?.name}];return this.process.read({tags:Sn(r)})}async getPrimaryNames(e){return this.process.read({tags:[{name:"Action",value:"Primary-Names"},...Ha(e)]})}async getRedelegationFee(e){return this.process.read({tags:[{name:"Action",value:"Redelegation-Fee"},{name:"Address",value:e.address}]})}async getGatewayRegistrySettings(){return this.process.read({tags:[{name:"Action",value:"Gateway-Registry-Settings"}]})}async getAllDelegates(e){return this.process.read({tags:[{name:"Action",value:"All-Paginated-Delegates"},...Ha(e)]})}async getAllGatewayVaults(e){return this.process.read({tags:[{name:"Action",value:"All-Gateway-Vaults"},...Ha(e)]})}},mP=class extends Ww{signer;constructor({signer:e,...r}){r===void 0?super({process:new za({processId:Lh})}):super(r),this.signer=pv(e)}async transfer({target:e,qty:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Transfer"},{name:"Recipient",value:e},{name:"Quantity",value:r.valueOf().toString()}],signer:this.signer})}async vaultedTransfer({recipient:e,quantity:r,lockLengthMs:a,revokable:i=!1},h){let{tags:c=[]}=h||{};return this.process.send({tags:[...c,{name:"Action",value:"Vaulted-Transfer"},{name:"Recipient",value:e},{name:"Quantity",value:r.toString()},{name:"Lock-Length",value:a.toString()},{name:"Revokable",value:`${i}`}],signer:this.signer})}async revokeVault({vaultId:e,recipient:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Revoke-Vault"},{name:"Vault-Id",value:e},{name:"Recipient",value:r}],signer:this.signer})}async createVault({lockLengthMs:e,quantity:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Create-Vault"},{name:"Lock-Length",value:e.toString()},{name:"Quantity",value:r.toString()}],signer:this.signer})}async extendVault({vaultId:e,extendLengthMs:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Extend-Vault"},{name:"Vault-Id",value:e},{name:"Extend-Length",value:r.toString()}],signer:this.signer})}async increaseVault({vaultId:e,quantity:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Increase-Vault"},{name:"Vault-Id",value:e},{name:"Quantity",value:r.toString()}],signer:this.signer})}async joinNetwork({operatorStake:e,allowDelegatedStaking:r,allowedDelegates:a,delegateRewardShareRatio:i,fqdn:h,label:c,minDelegatedStake:p,note:b,port:g,properties:y,protocol:M,autoStake:x,observerAddress:E},A){let{tags:I=[]}=A||{},P=[...I,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:e.valueOf().toString()},{name:"Allow-Delegated-Staking",value:r?.toString()},{name:"Allowed-Delegates",value:a?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:i?.toString()},{name:"FQDN",value:h},{name:"Label",value:c},{name:"Min-Delegated-Stake",value:p?.valueOf().toString()},{name:"Note",value:b},{name:"Port",value:g?.toString()},{name:"Properties",value:y},{name:"Protocol",value:M},{name:"Auto-Stake",value:x?.toString()},{name:"Observer-Address",value:E}];return this.process.send({signer:this.signer,tags:Sn(P)})}async leaveNetwork(e){let{tags:r=[]}=e||{};return this.process.send({signer:this.signer,tags:[...r,{name:"Action",value:"Leave-Network"}]})}async updateGatewaySettings({allowDelegatedStaking:e,allowedDelegates:r,delegateRewardShareRatio:a,fqdn:i,label:h,minDelegatedStake:c,note:p,port:b,properties:g,protocol:y,autoStake:M,observerAddress:x},E){let{tags:A=[]}=E||{},I=[...A,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:h},{name:"Note",value:p},{name:"FQDN",value:i},{name:"Port",value:b?.toString()},{name:"Properties",value:g},{name:"Protocol",value:y},{name:"Observer-Address",value:x},{name:"Allow-Delegated-Staking",value:e?.toString()},{name:"Allowed-Delegates",value:r?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:a?.toString()},{name:"Min-Delegated-Stake",value:c?.valueOf().toString()},{name:"Auto-Stake",value:M?.toString()}];return this.process.send({signer:this.signer,tags:Sn(I)})}async delegateStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:e.target},{name:"Quantity",value:e.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Decrease-Delegate-Stake"},{name:"Target",value:e.target},{name:"Quantity",value:e.decreaseQty.valueOf().toString()},{name:"Instant",value:`${e.instant||!1}`}]})}async instantWithdrawal(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Instant-Withdrawal"},{name:"Vault-Id",value:e.vaultId},{name:"Address",value:e.gatewayAddress}];return this.process.send({signer:this.signer,tags:Sn(i)})}async increaseOperatorStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:e.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:e.decreaseQty.valueOf().toString()},{name:"Instant",value:`${e.instant||!1}`}]})}async saveObservations(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:e.reportTxId},{name:"Failed-Gateways",value:e.failedGateways.join(",")}]})}async buyRecord(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Buy-Name"},{name:"Name",value:e.name},{name:"Years",value:e.years?.toString()??"1"},{name:"Process-Id",value:e.processId},{name:"Purchase-Type",value:e.type||"lease"},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Sn(i)})}async upgradeRecord(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Upgrade-Name"},{name:"Name",value:e.name},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Sn(i)})}async extendLease(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Extend-Lease"},{name:"Name",value:e.name},{name:"Years",value:e.years.toString()},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Sn(i)})}async increaseUndernameLimit(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Increase-Undername-Limit"},{name:"Name",value:e.name},{name:"Quantity",value:e.increaseCount.toString()},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Sn(i)})}async cancelWithdrawal(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Cancel-Withdrawal"},{name:"Vault-Id",value:e.vaultId},{name:"Address",value:e.gatewayAddress}];return this.process.send({signer:this.signer,tags:Sn(i)})}async requestPrimaryName(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Request-Primary-Name"},{name:"Name",value:e.name}];return this.process.send({signer:this.signer,tags:Sn(i)})}async redelegateStake(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Redelegate-Stake"},{name:"Target",value:e.target},{name:"Source",value:e.source},{name:"Quantity",value:e.stakeQty.valueOf().toString()},{name:"Vault-Id",value:e.vaultId}];return this.process.send({signer:this.signer,tags:Sn(i)})}};async function l3t({signer:t,module:e=oQ,ao:r=Sl(),scheduler:a=uQ,state:i,antRegistryId:h=$8,logger:c=Wu.default,authority:p=fQ}){let b=await r.spawn({module:e,scheduler:a,signer:t,data:i?JSON.stringify(i):void 0,tags:[{name:"Authority",value:p},{name:"ANT-Registry-Id",value:h}]});return c.debug("Spawned ANT",{processId:b,module:e,scheduler:a}),b}async function d3t({signer:t,processId:e,luaCodeTxId:r=sQ,ao:a=Sl(),logger:i=Wu.default,arweave:h=N4}){let c=new za({processId:e,ao:a,logger:i}),{api:{host:p,port:b,protocol:g}}=h.getConfig(),y=await fetch(`${g}://${p}:${b}/${r}`).then(x=>x.text()),{id:M}=await c.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:r}],data:y,signer:t});return i.debug("Evolved ANT",{processId:e,luaCodeTxId:r,evalMsgId:M}),M}function sUe(t){let e=Qt.object({name:Qt.string(),value:Qt.union([Qt.string(),Qt.number()])}),r=Qt.function().args(Qt.object({data:Qt.union([Qt.string(),Qt.instanceof(Me)]),tags:Qt.array(e).optional(),target:Qt.string().optional(),anchor:Qt.string().optional()})).returns(Qt.promise(Qt.object({id:Qt.string(),raw:Qt.instanceof(ArrayBuffer)})));try{return r.parse(t),!0}catch{return!1}}function pv(t){return sUe(t)?t:"publicKey"in t?async({data:r,tags:a,target:i,anchor:h})=>{if(t.publicKey===void 0&&"setPublicKey"in t&&typeof t.setPublicKey=="function"&&await t.setPublicKey(),t instanceof ul){let b=await t.signer.signDataItem({data:r,tags:a,target:i,anchor:h}),g=new v1(Me.from(b));return{id:await g.id,raw:await g.getRaw()}}let c=Rg(r,t,{tags:a,target:i,anchor:h});return c.sign(t).then(async()=>({id:await c.id,raw:await c.getRaw()}))}:xte(t)}var fUe="-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI";function p3t({owner:t,targetId:e,ttlSeconds:r=3600,keywords:a=[],controllers:i=[],description:h="",ticker:c="aos",name:p="ANT"}){return{ticker:c,name:p,description:h,keywords:a,owner:t,controllers:[t,...i],balances:{[t]:1},records:{"@":{transactionId:e??fUe.toString(),ttlSeconds:r}}}}function rue(t){return Qt.object({startTimestamp:Qt.number(),startHeight:Qt.number(),distributions:Qt.any(),endTimestamp:Qt.number(),prescribedObservers:Qt.any(),prescribedNames:Qt.array(Qt.string()),observations:Qt.any(),distributionTimestamp:Qt.number(),epochIndex:Qt.number()}).parse(t)}function vP(t){let r=t.Error??t.Messages?.[0]?.Tags?.find(a=>a.name==="Error")?.value;if(r!==void 0){let a=r.match(/\[string "aos"]:(\d+):\s*(.+)/);if(a){let[,i,h]=a;return`${tue(h).trim()} (line ${i.trim()})`.trim()}return tue(r)}}function tue(t){let e="\x1B";return t.replace(new RegExp(`${e}[\\[\\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]`,"g"),"").trim()}var iue=t=>D8.test(t);function _3t(t){return t!==void 0&&!isNaN(parseInt(t.toString()))}var Sn=t=>t.filter(e=>e.value!==void 0&&e.value!==""),Ha=t=>{let e=[{name:"Cursor",value:t?.cursor?.toString()},{name:"Limit",value:t?.limit?.toString()},{name:"Sort-By",value:t?.sortBy?.toString()},{name:"Sort-Order",value:t?.sortOrder?.toString()}];return Sn(e)},gv=async({arweave:t,epochIndex:e,processId:r=Lh,retries:a=3,gqlUrl:i="https://arweave-search.goldsky.com/graphql"})=>{let h=uUe({epochIndex:e,processId:r});for(let c=0;c<a;c++)try{let p=await fetch(i,{method:"POST",body:h,headers:{"Content-Type":"application/json"}}).then(y=>y.json());if(p?.data?.transactions?.edges?.length===0)return;let b=p.data.transactions.edges[0].node.id,g=await t.api.get(b);return rue(g.data)}catch(p){if(c===a-1)throw p;await new Promise(b=>setTimeout(b,Math.pow(2,c)*1e3))}},uUe=({epochIndex:t,processId:e=Lh,authorities:r=["fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY"]})=>JSON.stringify({query:`
|
|
189
|
+
}`,i=wt.object({data:wt.object({transactions:wt.object({edges:wt.array(wt.object({node:wt.record(wt.any())}))})})});return h=>jr(h).chain(Li(c=>t(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:a,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(i.parse).then(ixe(["data","transactions","edges","0","node"])))).toPromise()}var pSe=nI(M5e(),1),fte=(t="@permaweb/aoconnect")=>{let e=(0,pSe.default)(t);return e.child=r=>fte(`${e.namespace}:${r}`),e.tap=(r,...a)=>hxe((...i)=>e(r,...a,...i)),e},ute=({url:t,path:e})=>e?e.startsWith("/")?ute({url:t,path:e.slice(1)}):(t=new URL(t),t.pathname+=e,t.toString()):t;function vSe(t){return F1(x4([]),U1((e,r)=>F1(oxe([],r.name),wI(r.value),$s(r.name,Fh,e))(e),{}),_4(e=>e.length>1?e:e[0]))(t)}function Cs(t,e){return r=>Pee(vMe([NQ(t,"name"),MI(yI(e),NQ(e,"value"),mI)]),r)}function DQ(t){return jee([[Wg(String),k1(t)],[Wg(Array),VMe(t)],[mI,E9e]])}function Ad(t){let e;return Wg(Ls,t)?(e=new Error(mSe(t)),e.stack+=t.stack):Wg(Error,t)?e=t:HMe("message",t)?e=new Error(t.message):Wg(String,t)?e=new Error(t):e=new Error("An error occurred"),e}function mSe(t){return F1(e=>function r(a,i,h){return U1((c,p)=>F1(jee([[k1(Rt.invalid_arguments),()=>r(p.argumentsError,422,"Invalid Arguments")],[k1(Rt.invalid_return_type),()=>r(p.returnTypeError,500,"Invalid Return")],[k1(Rt.invalid_union),()=>BMe(b=>r(b,400,"Invalid Union"),p.unionErrors)],[mI,()=>[{...p,status:i,contextCode:h}]]]),_I(c))(p.code),[],a.issues)}(e,400,""),e=>U1((r,a)=>{let{message:i,path:h,contextCode:c}=a,p=h[1]||h[0],b=c?`${c} `:"";return r.push(`${b}'${p}': ${i}.`),r},[],e),exe(" | "))(t)}var gSe=wt.object({id:wt.string().min(1,{message:"message is required to be a message id"}),processId:wt.string().min(1,{message:"process is required to be a process id"})});function bSe(){return t=>jr(t).map(gSe.parse).map(()=>t)}var k2=wt.object({name:wt.string(),value:wt.string()}),ySe=wt.function().args(wt.object({Id:wt.string(),Target:wt.string(),Owner:wt.string(),Anchor:wt.string().optional(),Data:wt.any().default("1234"),Tags:wt.array(wt.object({name:wt.string(),value:wt.string()}))})).returns(wt.promise(wt.any())),wSe=wt.function().args(wt.object({id:wt.string().min(1,{message:"message id is required"}),processId:wt.string().min(1,{message:"process id is required"})})).returns(wt.promise(wt.any())),_Se=wt.function().args(wt.object({process:wt.string().min(1,{message:"process id is required"}),from:wt.string().optional(),to:wt.string().optional(),sort:wt.enum(["ASC","DESC"]).default("ASC"),limit:wt.number().optional()})).returns(wt.promise(wt.object({edges:wt.array(wt.object({cursor:wt.string(),node:wt.object({Output:wt.any().optional(),Messages:wt.array(wt.any()).optional(),Spawns:wt.array(wt.any()).optional(),Error:wt.any().optional()})}))}))),hte=wt.function().args(wt.object({processId:wt.string(),data:wt.any(),tags:wt.array(k2),anchor:wt.string().optional(),signer:wt.any()})).returns(wt.promise(wt.object({messageId:wt.string()}).passthrough())),MSe=wt.function().args(wt.object({data:wt.any(),tags:wt.array(k2),signer:wt.any()})).returns(wt.promise(wt.object({processId:wt.string()}).passthrough())),xSe=wt.function().args(wt.object({process:wt.string(),message:wt.string(),baseLayer:wt.boolean().optional(),exclude:wt.array(wt.string()).optional()})).returns(wt.promise(wt.object({assignmentId:wt.string()}).passthrough())),cte=hte,cut=wt.function().args(wt.object({suUrl:wt.string().url(),processId:wt.string()})).returns(wt.promise(wt.object({tags:wt.array(k2)}).passthrough())),lut=wt.function().args(wt.string()).returns(wt.promise(wt.object({url:wt.string()}))),SSe=wt.function().args(wt.string()).returns(wt.promise(wt.boolean())),ESe=wt.function().args(wt.string()).returns(wt.promise(wt.object({tags:wt.array(k2)}).passthrough())),S4=wt.function().args(wt.object({data:wt.any(),tags:wt.array(k2),target:wt.string().optional(),anchor:wt.string().optional()})).returns(wt.promise(wt.object({id:wt.string(),raw:wt.any()})));function ASe({loadResult:t}){return t=Li(wSe.implement(t)),e=>jr({id:e.id,processId:e.processId}).chain(t)}function RSe(t){let e=bSe(t),r=ASe(t);return({message:a,process:i})=>jr({id:a,processId:i}).chain(e).chain(r).map(t.logger.tap('readResult result for message "%s": %O',a)).map(h=>h).bimap(Ad,Ed).toPromise()}var TSe=wt.array(wt.object({name:wt.string(),value:wt.string()}));function ISe(){return t=>jr(t.tags).map(x4([])).map(Cs("Data-Protocol","ao")).map(Cs("Variant")).map(Cs("Type")).map(Cs("SDK")).map(_I(Fh,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"},{name:"SDK",value:"aoconnect"}])).map(TSe.parse).map($s("tags",Fh,t))}function kSe({logger:t}){return e=>jr(e).chain(MI(yI(e.data),()=>_d(e),()=>_d(Math.random().toString().slice(-4)).map($s("data",Fh,e)).map(r=>F1(Sd("tags"),Cs("Content-Type"),wI({name:"Content-Type",value:"text/plain"}),$s("tags",Fh,r))(r)).map(t.tap('added pseudo-random string as message "data"'))))}function BSe(t){let e=ISe(t),r=kSe(t),a=hte.implement(t.deployMessage);return i=>jr(i).chain(e).chain(r).chain(Li(({id:h,data:c,tags:p,anchor:b,signer:g})=>a({processId:h,data:c,tags:p,anchor:b,signer:S4.implement(g)}))).map(h=>$s("messageId",h.messageId,i))}function PSe(t){let e=BSe(t);return({process:r,data:a,tags:i,anchor:h,signer:c})=>jr({id:r,data:a,tags:i,anchor:h,signer:c}).chain(e).map(p=>p.messageId).bimap(Ad,Ed).toPromise()}var Dg=(t,e,r)=>a=>e(a[t])?_d(a):xl(`Tag '${t}': ${r}`);function OSe({loadTransactionMeta:t,logger:e}){return t=Li(ESe.implement(t)),r=>jr(r).chain(t).map(Sd("tags")).map(vSe).chain(Dg("Data-Protocol",DQ("ao"),"value 'ao' was not found on module")).chain(Dg("Type",DQ("Module"),"value 'Module' was not found on module")).chain(Dg("Module-Format",IT,"was not found on module")).chain(Dg("Input-Encoding",IT,"was not found on module")).chain(Dg("Output-Encoding",IT,"was not found on module")).bimap(e.tap("Verifying module source failed: %s"),e.tap("Verified module source"))}function NSe({logger:t,validateScheduler:e}){return e=Li(SSe.implement(e)),r=>jr(r).chain(a=>e(a).chain(i=>i?_d(a):xl(`Valid Scheduler-Location owned by ${a} not found`))).bimap(t.tap("Verifying scheduler failed: %s"),t.tap("Verified scheduler"))}function CSe({logger:t}){return e=>jr(e).map(t.tap("Checking for signer")).chain(r=>r?_d(r):xl("signer not found"))}function LSe(t){let e=t.logger.child("verifyInput");t={...t,logger:e};let r=OSe(t),a=NSe(t),i=CSe(t);return h=>jr(h).chain(c=>r(c.module).map(()=>c)).chain(c=>a(c.scheduler)).map(()=>h).chain(c=>i(c.signer).map(()=>c)).bimap(e.tap("Error when verify input: %s"),e.tap("Successfully verified inputs"))}var DSe=wt.array(wt.object({name:wt.string(),value:wt.string()}));function $Se(){return t=>jr(t).map(Sd("tags")).map(x4([])).map(Cs("Data-Protocol","ao")).map(Cs("Variant")).map(Cs("Type")).map(Cs("Module")).map(Cs("Scheduler")).map(Cs("SDK")).map(_I(Fh,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Process"},{name:"Module",value:t.module},{name:"Scheduler",value:t.scheduler},{name:"SDK",value:"aoconnect"}])).map(DSe.parse).map($s("tags",Fh,t))}function qSe({logger:t}){return e=>jr(e).chain(MI(yI(e.data),()=>_d(e),()=>_d(Math.random().toString().slice(-4)).map($s("data",Fh,e)).map(r=>F1(Sd("tags"),Cs("Content-Type"),wI({name:"Content-Type",value:"text/plain"}),$s("tags",Fh,r))(r)).map(t.tap('added pseudo-random string as process "data"'))))}function USe(t){let e=t.logger.child("uploadProcess");t={...t,logger:e};let r=$Se(t),a=qSe(t),i=MSe.implement(t.deployProcess);return h=>jr(h).chain(r).chain(a).chain(Li(({data:c,tags:p,signer:b})=>i({data:c,tags:p,signer:S4.implement(b)}))).map(c=>$s("processId",c.processId,h))}function FSe(t){let e=LSe(t),r=USe(t);return({module:a,scheduler:i,signer:h,tags:c,data:p})=>jr({module:a,scheduler:i,signer:h,tags:c,data:p}).chain(e).chain(r).map(b=>b.processId).bimap(Ad,Ed).toPromise()}function jSe(t){let e=cte.implement(t.deployMonitor);return r=>jr(r).chain(Li(({id:a,signer:i})=>e({processId:a,signer:S4.implement(i),data:Math.random().toString().slice(-4),tags:[]}))).map(a=>$s("monitorId",a.messageId,r))}function zSe(t){let e=jSe(t);return({process:r,signer:a})=>jr({id:r,signer:a}).chain(e).map(i=>i.monitorId).bimap(Ad,Ed).toPromise()}function ZSe(t){let e=cte.implement(t.deployUnmonitor);return r=>jr(r).chain(Li(({id:a,signer:i})=>e({processId:a,signer:S4.implement(i),data:Math.random().toString().slice(-4),tags:[]}))).map(a=>$s("monitorId",a.messageId,r))}function HSe(t){let e=ZSe(t);return({process:r,signer:a})=>jr({id:r,signer:a}).chain(e).map(i=>i.monitorId).bimap(Ad,Ed).toPromise()}var KSe=wt.object({process:wt.string().min(1,{message:"process identifier is required"}),from:wt.string().optional(),to:wt.string().optional(),sort:wt.enum(["ASC","DESC"]).default("ASC"),limit:wt.number().optional()});function WSe(){return t=>jr(t).map(KSe.parse).map(()=>t)}function VSe({queryResults:t}){return t=Li(_Se.implement(t)),e=>jr({process:e.process,from:e.from,to:e.to,sort:e.sort,limit:e.limit}).chain(t)}function GSe(t){let e=WSe(t),r=VSe(t);return({process:a,from:i,to:h,sort:c,limit:p})=>jr({process:a,from:i,to:h,sort:c,limit:p}).chain(e).chain(r).map(t.logger.tap('readResults result for message "%s": %O',a)).map(b=>b).bimap(Ad,Ed).toPromise()}var YSe=wt.object({Id:wt.string(),Target:wt.string(),Owner:wt.string(),Anchor:wt.string().optional(),Data:wt.any().default("1234"),Tags:wt.array(wt.object({name:wt.string(),value:wt.string()}))});function JSe(){return t=>jr(t).map(YSe.parse).map(e=>(e.Tags=e.Tags.concat([{name:"Data-Protocol",value:"ao"},{name:"Type",value:"Message"},{name:"Variant",value:"ao.TN.1"}]),e))}function XSe({dryrunFetch:t}){return Li(ySe.implement(t))}function QSe(t){let e=JSe(t),r=XSe(t);return a=>jr(a).map(eEe).chain(e).chain(r).toPromise()}function eEe({process:t,data:e,tags:r,anchor:a,...i}){return{Id:"1234",Owner:"1234",...i,Target:t,Data:e||"1234",Tags:r||[],Anchor:a||"0"}}function tEe(t){let e=xSe.implement(t.deployAssign);return r=>jr(r).chain(Li(({process:a,message:i,baseLayer:h,exclude:c})=>e({process:a,message:i,baseLayer:h,exclude:c}))).map(a=>$s("assignmentId",a.assignmentId,r))}function rEe(t){let e=tEe(t);return({process:r,message:a,baseLayer:i,exclude:h})=>jr({process:r,message:a,baseLayer:i,exclude:h}).chain(e).map(c=>c.assignmentId).bimap(Ad,Ed).toPromise()}var iEe="https://arweave.net",nEe="https://mu.ao-testnet.xyz",aEe="https://cu.ao-testnet.xyz";function Sl({GRAPHQL_URL:t,GATEWAY_URL:e=iEe,MU_URL:r=nEe,CU_URL:a=aEe}={}){let i=fte();t||(t=ute({url:e,path:"/graphql"}));let{validate:h}=Tee({cacheSize:100,GRAPHQL_URL:t}),c=x9e({MAX_SIZE:25}),p=i.child("result"),b=RSe({loadResult:w9e({fetch,CU_URL:a,logger:p}),logger:p}),g=i.child("message"),y=PSe({loadProcessMeta:AT({fetch,cache:c,logger:g}),deployMessage:p9e({fetch,MU_URL:r,logger:g}),logger:g}),M=i.child("spawn"),x=FSe({loadTransactionMeta:dSe({fetch,GRAPHQL_URL:t,logger:M}),validateScheduler:h,deployProcess:v9e({fetch,MU_URL:r,logger:M}),logger:M}),E=i.child("monitor"),A=zSe({loadProcessMeta:AT({fetch,cache:c,logger:E}),deployMonitor:m9e({fetch,MU_URL:r,logger:E}),logger:E}),I=i.child("unmonitor"),P=HSe({loadProcessMeta:AT({fetch,cache:c,logger:I}),deployUnmonitor:g9e({fetch,MU_URL:r,logger:I}),logger:E}),N=i.child("results"),L=GSe({queryResults:_9e({fetch,CU_URL:a,logger:N}),logger:N}),C=i.child("dryrun"),Y=QSe({dryrunFetch:y9e({fetch,CU_URL:a,logger:C}),logger:C}),G=i.child("assign"),ee=rEe({deployAssign:b9e({fetch,MU_URL:r,logger:G}),logger:g});return{result:b,results:L,message:y,spawn:x,monitor:A,unmonitor:P,dryrun:Y,assign:ee}}var lte={};UQ(lte,{createDataItemSigner:()=>kEe});var dte=nI(E5e(),1),pte={};UQ(pte,{AVSCTap:()=>B2,ArweaveSigner:()=>RI,DataItem:()=>A2,MAX_TAG_BYTES:()=>E4,MIN_BINARY_SIZE:()=>kI,SIG_CONFIG:()=>K1,SignatureConfig:()=>Ns,Signer:()=>bte,createData:()=>Mte,default:()=>REe,deserializeTags:()=>v4,indexToType:()=>TI,serializeTags:()=>II,tagsExceedLimit:()=>_te,warparbundles:()=>TEe});var oEe=Object.create,EI=Object.defineProperty,sEe=Object.getOwnPropertyDescriptor,fEe=Object.getOwnPropertyNames,uEe=Object.getPrototypeOf,hEe=Object.prototype.hasOwnProperty,zh=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),cEe=(t,e)=>{for(var r in e)EI(t,r,{get:e[r],enumerable:!0})},lEe=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fEe(e))!hEe.call(t,i)&&i!==r&&EI(t,i,{get:()=>e[i],enumerable:!(a=sEe(e,i))||a.enumerable});return t},Rd=(t,e,r)=>(r=t!=null?oEe(uEe(t)):{},lEe(e||!t||!t.__esModule?EI(r,"default",{value:t,enumerable:!0}):r,t)),dEe=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});function e(r){var a=4,i=r.length,h=i%a;if(!h)return r;var c=i,p=a-h,b=i+p,g=Me.alloc(b);for(g.write(r);p--;)g.write("=",c++);return g.toString()}t.default=e}),pEe=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=dEe();function r(b,g){return g===void 0&&(g="utf8"),Me.isBuffer(b)?h(b.toString("base64")):h(Me.from(b,g).toString("base64"))}function a(b,g){return g===void 0&&(g="utf8"),Me.from(i(b),"base64").toString(g)}function i(b){return b=b.toString(),e.default(b).replace(/\-/g,"+").replace(/_/g,"/")}function h(b){return b.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function c(b){return Me.from(i(b),"base64")}var p=r;p.encode=r,p.decode=a,p.toBase64=i,p.fromBase64=h,p.toBuffer=c,t.default=p}),AI=zh((t,e)=>{e.exports=pEe().default,e.exports.default=e.exports}),vte=zh(t=>{"use strict";t.byteLength=b,t.toByteArray=y,t.fromByteArray=E;var e=[],r=[],a=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(h=0,c=i.length;h<c;++h)e[h]=i[h],r[i.charCodeAt(h)]=h;var h,c;r[45]=62,r[95]=63;function p(A){var I=A.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var P=A.indexOf("=");P===-1&&(P=I);var N=P===I?0:4-P%4;return[P,N]}function b(A){var I=p(A),P=I[0],N=I[1];return(P+N)*3/4-N}function g(A,I,P){return(I+P)*3/4-P}function y(A){var I,P=p(A),N=P[0],L=P[1],C=new a(g(A,N,L)),Y=0,G=L>0?N-4:N,ee;for(ee=0;ee<G;ee+=4)I=r[A.charCodeAt(ee)]<<18|r[A.charCodeAt(ee+1)]<<12|r[A.charCodeAt(ee+2)]<<6|r[A.charCodeAt(ee+3)],C[Y++]=I>>16&255,C[Y++]=I>>8&255,C[Y++]=I&255;return L===2&&(I=r[A.charCodeAt(ee)]<<2|r[A.charCodeAt(ee+1)]>>4,C[Y++]=I&255),L===1&&(I=r[A.charCodeAt(ee)]<<10|r[A.charCodeAt(ee+1)]<<4|r[A.charCodeAt(ee+2)]>>2,C[Y++]=I>>8&255,C[Y++]=I&255),C}function M(A){return e[A>>18&63]+e[A>>12&63]+e[A>>6&63]+e[A&63]}function x(A,I,P){for(var N,L=[],C=I;C<P;C+=3)N=(A[C]<<16&16711680)+(A[C+1]<<8&65280)+(A[C+2]&255),L.push(M(N));return L.join("")}function E(A){for(var I,P=A.length,N=P%3,L=[],C=16383,Y=0,G=P-N;Y<G;Y+=C)L.push(x(A,Y,Y+C>G?G:Y+C));return N===1?(I=A[P-1],L.push(e[I>>2]+e[I<<4&63]+"==")):N===2&&(I=(A[P-2]<<8)+A[P-1],L.push(e[I>>10]+e[I>>4&63]+e[I<<2&63]+"=")),L.join("")}}),mte=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64UrlDecode=t.b64UrlEncode=t.bufferTob64Url=t.bufferTob64=t.b64UrlToBuffer=t.stringToB64Url=t.stringToBuffer=t.bufferToString=t.b64UrlToString=t.concatBuffers=void 0;var e=vte();function r(x){let E=0;for(let P=0;P<x.length;P++)E+=x[P].byteLength;let A=new Uint8Array(E),I=0;A.set(new Uint8Array(x[0]),I),I+=x[0].byteLength;for(let P=1;P<x.length;P++)A.set(new Uint8Array(x[P]),I),I+=x[P].byteLength;return A}t.concatBuffers=r;function a(x){let E=p(x);return i(E)}t.b64UrlToString=a;function i(x){return new TextDecoder("utf-8",{fatal:!0}).decode(x)}t.bufferToString=i;function h(x){return new TextEncoder().encode(x)}t.stringToBuffer=h;function c(x){return g(h(x))}t.stringToB64Url=c;function p(x){return new Uint8Array(e.toByteArray(M(x)))}t.b64UrlToBuffer=p;function b(x){return e.fromByteArray(new Uint8Array(x))}t.bufferTob64=b;function g(x){return y(b(x))}t.bufferTob64Url=g;function y(x){return x.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}t.b64UrlEncode=y;function M(x){x=x.replace(/\-/g,"+").replace(/\_/g,"/");let E;return x.length%4==0?E=0:E=4-x.length%4,x.concat("=".repeat(E))}t.b64UrlDecode=M}),vEe=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=mte(),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 a=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),i=await this.driver.exportKey("jwk",a.privateKey);return{kty:i.kty,e:i.e,n:i.n,d:i.d,p:i.p,q:i.q,dp:i.dp,dq:i.dq,qi:i.qi}}async sign(a,i,{saltLength:h}={}){let c=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(a),i);return new Uint8Array(c)}async hash(a,i="SHA-256"){let h=await this.driver.digest(i,a);return new Uint8Array(h)}async verify(a,i,h){let c={kty:"RSA",e:"AQAB",n:a},p=await this.jwkToPublicCryptoKey(c),b=await this.driver.digest("SHA-256",i),g=await this.driver.verify({name:"RSA-PSS",saltLength:0},p,h,i),y=await this.driver.verify({name:"RSA-PSS",saltLength:32},p,h,i),M=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((p.algorithm.modulusLength-1)/8)-b.byteLength-2},p,h,i);return g||y||M}async jwkToCryptoKey(a){return this.driver.importKey("jwk",a,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(a){return this.driver.importKey("jwk",a,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let a=crypto?.subtle;return a===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(i=>typeof a[i]=="function")}async encrypt(a,i,h){let c=await this.driver.importKey("raw",typeof i=="string"?e.stringToBuffer(i):i,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:h?e.stringToBuffer(h):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),b=new Uint8Array(16);crypto.getRandomValues(b);let g=await this.driver.encrypt({name:"AES-CBC",iv:b},p,a);return e.concatBuffers([b,g])}async decrypt(a,i,h){let c=await this.driver.importKey("raw",typeof i=="string"?e.stringToBuffer(i):i,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:h?e.stringToBuffer(h):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),b=a.slice(0,16),g=await this.driver.decrypt({name:"AES-CBC",iv:b},p,a.slice(16));return e.concatBuffers([g])}};t.default=r}),mEe=zh(t=>{t.read=function(e,r,a,i,h){var c,p,b=h*8-i-1,g=(1<<b)-1,y=g>>1,M=-7,x=a?h-1:0,E=a?-1:1,A=e[r+x];for(x+=E,c=A&(1<<-M)-1,A>>=-M,M+=b;M>0;c=c*256+e[r+x],x+=E,M-=8);for(p=c&(1<<-M)-1,c>>=-M,M+=i;M>0;p=p*256+e[r+x],x+=E,M-=8);if(c===0)c=1-y;else{if(c===g)return p?NaN:(A?-1:1)*(1/0);p=p+Math.pow(2,i),c=c-y}return(A?-1:1)*p*Math.pow(2,c-i)},t.write=function(e,r,a,i,h,c){var p,b,g,y=c*8-h-1,M=(1<<y)-1,x=M>>1,E=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=i?0:c-1,I=i?1:-1,P=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(b=isNaN(r)?1:0,p=M):(p=Math.floor(Math.log(r)/Math.LN2),r*(g=Math.pow(2,-p))<1&&(p--,g*=2),p+x>=1?r+=E/g:r+=E*Math.pow(2,1-x),r*g>=2&&(p++,g/=2),p+x>=M?(b=0,p=M):p+x>=1?(b=(r*g-1)*Math.pow(2,h),p=p+x):(b=r*Math.pow(2,x-1)*Math.pow(2,h),p=0));h>=8;e[a+A]=b&255,A+=I,b/=256,h-=8);for(p=p<<h|b,y+=h;y>0;e[a+A]=p&255,A+=I,p/=256,y-=8);e[a+A-I]|=P*128}}),tI=zh(t=>{"use strict";var e=vte(),r=mEe(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=p,t.SlowBuffer=L,t.INSPECT_MAX_BYTES=50;var i=2147483647;t.kMaxLength=i,p.TYPED_ARRAY_SUPPORT=h(),!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 h(){try{let T=new Uint8Array(1),k={foo:function(){return 42}};return Object.setPrototypeOf(k,Uint8Array.prototype),Object.setPrototypeOf(T,k),T.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(T){if(T>i)throw new RangeError('The value "'+T+'" is invalid for option "size"');let k=new Uint8Array(T);return Object.setPrototypeOf(k,p.prototype),k}function p(T,k,O){if(typeof T=="number"){if(typeof k=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return M(T)}return b(T,k,O)}p.poolSize=8192;function b(T,k,O){if(typeof T=="string")return x(T,k);if(ArrayBuffer.isView(T))return A(T);if(T==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T);if(ut(T,ArrayBuffer)||T&&ut(T.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ut(T,SharedArrayBuffer)||T&&ut(T.buffer,SharedArrayBuffer)))return I(T,k,O);if(typeof T=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let q=T.valueOf&&T.valueOf();if(q!=null&&q!==T)return p.from(q,k,O);let H=P(T);if(H)return H;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof T[Symbol.toPrimitive]=="function")return p.from(T[Symbol.toPrimitive]("string"),k,O);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T)}p.from=function(T,k,O){return b(T,k,O)},Object.setPrototypeOf(p.prototype,Uint8Array.prototype),Object.setPrototypeOf(p,Uint8Array);function g(T){if(typeof T!="number")throw new TypeError('"size" argument must be of type number');if(T<0)throw new RangeError('The value "'+T+'" is invalid for option "size"')}function y(T,k,O){return g(T),T<=0?c(T):k!==void 0?typeof O=="string"?c(T).fill(k,O):c(T).fill(k):c(T)}p.alloc=function(T,k,O){return y(T,k,O)};function M(T){return g(T),c(T<0?0:N(T)|0)}p.allocUnsafe=function(T){return M(T)},p.allocUnsafeSlow=function(T){return M(T)};function x(T,k){if((typeof k!="string"||k==="")&&(k="utf8"),!p.isEncoding(k))throw new TypeError("Unknown encoding: "+k);let O=C(T,k)|0,q=c(O),H=q.write(T,k);return H!==O&&(q=q.slice(0,H)),q}function E(T){let k=T.length<0?0:N(T.length)|0,O=c(k);for(let q=0;q<k;q+=1)O[q]=T[q]&255;return O}function A(T){if(ut(T,Uint8Array)){let k=new Uint8Array(T);return I(k.buffer,k.byteOffset,k.byteLength)}return E(T)}function I(T,k,O){if(k<0||T.byteLength<k)throw new RangeError('"offset" is outside of buffer bounds');if(T.byteLength<k+(O||0))throw new RangeError('"length" is outside of buffer bounds');let q;return k===void 0&&O===void 0?q=new Uint8Array(T):O===void 0?q=new Uint8Array(T,k):q=new Uint8Array(T,k,O),Object.setPrototypeOf(q,p.prototype),q}function P(T){if(p.isBuffer(T)){let k=N(T.length)|0,O=c(k);return O.length===0||T.copy(O,0,0,k),O}if(T.length!==void 0)return typeof T.length!="number"||Ze(T.length)?c(0):E(T);if(T.type==="Buffer"&&Array.isArray(T.data))return E(T.data)}function N(T){if(T>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return T|0}function L(T){return+T!=T&&(T=0),p.alloc(+T)}p.isBuffer=function(T){return T!=null&&T._isBuffer===!0&&T!==p.prototype},p.compare=function(T,k){if(ut(T,Uint8Array)&&(T=p.from(T,T.offset,T.byteLength)),ut(k,Uint8Array)&&(k=p.from(k,k.offset,k.byteLength)),!p.isBuffer(T)||!p.isBuffer(k))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(T===k)return 0;let O=T.length,q=k.length;for(let H=0,W=Math.min(O,q);H<W;++H)if(T[H]!==k[H]){O=T[H],q=k[H];break}return O<q?-1:q<O?1:0},p.isEncoding=function(T){switch(String(T).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(T,k){if(!Array.isArray(T))throw new TypeError('"list" argument must be an Array of Buffers');if(T.length===0)return p.alloc(0);let O;if(k===void 0)for(k=0,O=0;O<T.length;++O)k+=T[O].length;let q=p.allocUnsafe(k),H=0;for(O=0;O<T.length;++O){let W=T[O];if(ut(W,Uint8Array))H+W.length>q.length?(p.isBuffer(W)||(W=p.from(W)),W.copy(q,H)):Uint8Array.prototype.set.call(q,W,H);else if(p.isBuffer(W))W.copy(q,H);else throw new TypeError('"list" argument must be an Array of Buffers');H+=W.length}return q};function C(T,k){if(p.isBuffer(T))return T.length;if(ArrayBuffer.isView(T)||ut(T,ArrayBuffer))return T.byteLength;if(typeof T!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof T);let O=T.length,q=arguments.length>2&&arguments[2]===!0;if(!q&&O===0)return 0;let H=!1;for(;;)switch(k){case"ascii":case"latin1":case"binary":return O;case"utf8":case"utf-8":return oe(T).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O*2;case"hex":return O>>>1;case"base64":return ge(T).length;default:if(H)return q?-1:oe(T).length;k=(""+k).toLowerCase(),H=!0}}p.byteLength=C;function Y(T,k,O){let q=!1;if((k===void 0||k<0)&&(k=0),k>this.length||((O===void 0||O>this.length)&&(O=this.length),O<=0)||(O>>>=0,k>>>=0,O<=k))return"";for(T||(T="utf8");;)switch(T){case"hex":return o(this,k,O);case"utf8":case"utf-8":return u(this,k,O);case"ascii":return w(this,k,O);case"latin1":case"binary":return d(this,k,O);case"base64":return f(this,k,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,k,O);default:if(q)throw new TypeError("Unknown encoding: "+T);T=(T+"").toLowerCase(),q=!0}}p.prototype._isBuffer=!0;function G(T,k,O){let q=T[k];T[k]=T[O],T[O]=q}p.prototype.swap16=function(){let T=this.length;if(T%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let k=0;k<T;k+=2)G(this,k,k+1);return this},p.prototype.swap32=function(){let T=this.length;if(T%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let k=0;k<T;k+=4)G(this,k,k+3),G(this,k+1,k+2);return this},p.prototype.swap64=function(){let T=this.length;if(T%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let k=0;k<T;k+=8)G(this,k,k+7),G(this,k+1,k+6),G(this,k+2,k+5),G(this,k+3,k+4);return this},p.prototype.toString=function(){let T=this.length;return T===0?"":arguments.length===0?u(this,0,T):Y.apply(this,arguments)},p.prototype.toLocaleString=p.prototype.toString,p.prototype.equals=function(T){if(!p.isBuffer(T))throw new TypeError("Argument must be a Buffer");return this===T?!0:p.compare(this,T)===0},p.prototype.inspect=function(){let T="",k=t.INSPECT_MAX_BYTES;return T=this.toString("hex",0,k).replace(/(.{2})/g,"$1 ").trim(),this.length>k&&(T+=" ... "),"<Buffer "+T+">"},a&&(p.prototype[a]=p.prototype.inspect),p.prototype.compare=function(T,k,O,q,H){if(ut(T,Uint8Array)&&(T=p.from(T,T.offset,T.byteLength)),!p.isBuffer(T))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof T);if(k===void 0&&(k=0),O===void 0&&(O=T?T.length:0),q===void 0&&(q=0),H===void 0&&(H=this.length),k<0||O>T.length||q<0||H>this.length)throw new RangeError("out of range index");if(q>=H&&k>=O)return 0;if(q>=H)return-1;if(k>=O)return 1;if(k>>>=0,O>>>=0,q>>>=0,H>>>=0,this===T)return 0;let W=H-q,fe=O-k,st=Math.min(W,fe),ue=this.slice(q,H),me=T.slice(k,O);for(let pe=0;pe<st;++pe)if(ue[pe]!==me[pe]){W=ue[pe],fe=me[pe];break}return W<fe?-1:fe<W?1:0};function ee(T,k,O,q,H){if(T.length===0)return-1;if(typeof O=="string"?(q=O,O=0):O>2147483647?O=2147483647:O<-2147483648&&(O=-2147483648),O=+O,Ze(O)&&(O=H?0:T.length-1),O<0&&(O=T.length+O),O>=T.length){if(H)return-1;O=T.length-1}else if(O<0)if(H)O=0;else return-1;if(typeof k=="string"&&(k=p.from(k,q)),p.isBuffer(k))return k.length===0?-1:D(T,k,O,q,H);if(typeof k=="number")return k=k&255,typeof Uint8Array.prototype.indexOf=="function"?H?Uint8Array.prototype.indexOf.call(T,k,O):Uint8Array.prototype.lastIndexOf.call(T,k,O):D(T,[k],O,q,H);throw new TypeError("val must be string, number or Buffer")}function D(T,k,O,q,H){let W=1,fe=T.length,st=k.length;if(q!==void 0&&(q=String(q).toLowerCase(),q==="ucs2"||q==="ucs-2"||q==="utf16le"||q==="utf-16le")){if(T.length<2||k.length<2)return-1;W=2,fe/=2,st/=2,O/=2}function ue(pe,be){return W===1?pe[be]:pe.readUInt16BE(be*W)}let me;if(H){let pe=-1;for(me=O;me<fe;me++)if(ue(T,me)===ue(k,pe===-1?0:me-pe)){if(pe===-1&&(pe=me),me-pe+1===st)return pe*W}else pe!==-1&&(me-=me-pe),pe=-1}else for(O+st>fe&&(O=fe-st),me=O;me>=0;me--){let pe=!0;for(let be=0;be<st;be++)if(ue(T,me+be)!==ue(k,be)){pe=!1;break}if(pe)return me}return-1}p.prototype.includes=function(T,k,O){return this.indexOf(T,k,O)!==-1},p.prototype.indexOf=function(T,k,O){return ee(this,T,k,O,!0)},p.prototype.lastIndexOf=function(T,k,O){return ee(this,T,k,O,!1)};function U(T,k,O,q){O=Number(O)||0;let H=T.length-O;q?(q=Number(q),q>H&&(q=H)):q=H;let W=k.length;q>W/2&&(q=W/2);let fe;for(fe=0;fe<q;++fe){let st=parseInt(k.substr(fe*2,2),16);if(Ze(st))return fe;T[O+fe]=st}return fe}function V(T,k,O,q){return Se(oe(k,T.length-O),T,O,q)}function _(T,k,O,q){return Se(le(k),T,O,q)}function n(T,k,O,q){return Se(ge(k),T,O,q)}function s(T,k,O,q){return Se(ot(k,T.length-O),T,O,q)}p.prototype.write=function(T,k,O,q){if(k===void 0)q="utf8",O=this.length,k=0;else if(O===void 0&&typeof k=="string")q=k,O=this.length,k=0;else if(isFinite(k))k=k>>>0,isFinite(O)?(O=O>>>0,q===void 0&&(q="utf8")):(q=O,O=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let H=this.length-k;if((O===void 0||O>H)&&(O=H),T.length>0&&(O<0||k<0)||k>this.length)throw new RangeError("Attempt to write outside buffer bounds");q||(q="utf8");let W=!1;for(;;)switch(q){case"hex":return U(this,T,k,O);case"utf8":case"utf-8":return V(this,T,k,O);case"ascii":case"latin1":case"binary":return _(this,T,k,O);case"base64":return n(this,T,k,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s(this,T,k,O);default:if(W)throw new TypeError("Unknown encoding: "+q);q=(""+q).toLowerCase(),W=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function f(T,k,O){return k===0&&O===T.length?e.fromByteArray(T):e.fromByteArray(T.slice(k,O))}function u(T,k,O){O=Math.min(T.length,O);let q=[],H=k;for(;H<O;){let W=T[H],fe=null,st=W>239?4:W>223?3:W>191?2:1;if(H+st<=O){let ue,me,pe,be;switch(st){case 1:W<128&&(fe=W);break;case 2:ue=T[H+1],(ue&192)===128&&(be=(W&31)<<6|ue&63,be>127&&(fe=be));break;case 3:ue=T[H+1],me=T[H+2],(ue&192)===128&&(me&192)===128&&(be=(W&15)<<12|(ue&63)<<6|me&63,be>2047&&(be<55296||be>57343)&&(fe=be));break;case 4:ue=T[H+1],me=T[H+2],pe=T[H+3],(ue&192)===128&&(me&192)===128&&(pe&192)===128&&(be=(W&15)<<18|(ue&63)<<12|(me&63)<<6|pe&63,be>65535&&be<1114112&&(fe=be))}}fe===null?(fe=65533,st=1):fe>65535&&(fe-=65536,q.push(fe>>>10&1023|55296),fe=56320|fe&1023),q.push(fe),H+=st}return m(q)}var l=4096;function m(T){let k=T.length;if(k<=l)return String.fromCharCode.apply(String,T);let O="",q=0;for(;q<k;)O+=String.fromCharCode.apply(String,T.slice(q,q+=l));return O}function w(T,k,O){let q="";O=Math.min(T.length,O);for(let H=k;H<O;++H)q+=String.fromCharCode(T[H]&127);return q}function d(T,k,O){let q="";O=Math.min(T.length,O);for(let H=k;H<O;++H)q+=String.fromCharCode(T[H]);return q}function o(T,k,O){let q=T.length;(!k||k<0)&&(k=0),(!O||O<0||O>q)&&(O=q);let H="";for(let W=k;W<O;++W)H+=Ge[T[W]];return H}function v(T,k,O){let q=T.slice(k,O),H="";for(let W=0;W<q.length-1;W+=2)H+=String.fromCharCode(q[W]+q[W+1]*256);return H}p.prototype.slice=function(T,k){let O=this.length;T=~~T,k=k===void 0?O:~~k,T<0?(T+=O,T<0&&(T=0)):T>O&&(T=O),k<0?(k+=O,k<0&&(k=0)):k>O&&(k=O),k<T&&(k=T);let q=this.subarray(T,k);return Object.setPrototypeOf(q,p.prototype),q};function R(T,k,O){if(T%1!==0||T<0)throw new RangeError("offset is not uint");if(T+k>O)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=this[T],H=1,W=0;for(;++W<k&&(H*=256);)q+=this[T+W]*H;return q},p.prototype.readUintBE=p.prototype.readUIntBE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=this[T+--k],H=1;for(;k>0&&(H*=256);)q+=this[T+--k]*H;return q},p.prototype.readUint8=p.prototype.readUInt8=function(T,k){return T=T>>>0,k||R(T,1,this.length),this[T]},p.prototype.readUint16LE=p.prototype.readUInt16LE=function(T,k){return T=T>>>0,k||R(T,2,this.length),this[T]|this[T+1]<<8},p.prototype.readUint16BE=p.prototype.readUInt16BE=function(T,k){return T=T>>>0,k||R(T,2,this.length),this[T]<<8|this[T+1]},p.prototype.readUint32LE=p.prototype.readUInt32LE=function(T,k){return T=T>>>0,k||R(T,4,this.length),(this[T]|this[T+1]<<8|this[T+2]<<16)+this[T+3]*16777216},p.prototype.readUint32BE=p.prototype.readUInt32BE=function(T,k){return T=T>>>0,k||R(T,4,this.length),this[T]*16777216+(this[T+1]<<16|this[T+2]<<8|this[T+3])},p.prototype.readBigUInt64LE=ct(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=k+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24,H=this[++T]+this[++T]*2**8+this[++T]*2**16+O*2**24;return BigInt(q)+(BigInt(H)<<BigInt(32))}),p.prototype.readBigUInt64BE=ct(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=k*2**24+this[++T]*2**16+this[++T]*2**8+this[++T],H=this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+O;return(BigInt(q)<<BigInt(32))+BigInt(H)}),p.prototype.readIntLE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=this[T],H=1,W=0;for(;++W<k&&(H*=256);)q+=this[T+W]*H;return H*=128,q>=H&&(q-=Math.pow(2,8*k)),q},p.prototype.readIntBE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=k,H=1,W=this[T+--q];for(;q>0&&(H*=256);)W+=this[T+--q]*H;return H*=128,W>=H&&(W-=Math.pow(2,8*k)),W},p.prototype.readInt8=function(T,k){return T=T>>>0,k||R(T,1,this.length),this[T]&128?(255-this[T]+1)*-1:this[T]},p.prototype.readInt16LE=function(T,k){T=T>>>0,k||R(T,2,this.length);let O=this[T]|this[T+1]<<8;return O&32768?O|4294901760:O},p.prototype.readInt16BE=function(T,k){T=T>>>0,k||R(T,2,this.length);let O=this[T+1]|this[T]<<8;return O&32768?O|4294901760:O},p.prototype.readInt32LE=function(T,k){return T=T>>>0,k||R(T,4,this.length),this[T]|this[T+1]<<8|this[T+2]<<16|this[T+3]<<24},p.prototype.readInt32BE=function(T,k){return T=T>>>0,k||R(T,4,this.length),this[T]<<24|this[T+1]<<16|this[T+2]<<8|this[T+3]},p.prototype.readBigInt64LE=ct(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=this[T+4]+this[T+5]*2**8+this[T+6]*2**16+(O<<24);return(BigInt(q)<<BigInt(32))+BigInt(k+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24)}),p.prototype.readBigInt64BE=ct(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=(k<<24)+this[++T]*2**16+this[++T]*2**8+this[++T];return(BigInt(q)<<BigInt(32))+BigInt(this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+O)}),p.prototype.readFloatLE=function(T,k){return T=T>>>0,k||R(T,4,this.length),r.read(this,T,!0,23,4)},p.prototype.readFloatBE=function(T,k){return T=T>>>0,k||R(T,4,this.length),r.read(this,T,!1,23,4)},p.prototype.readDoubleLE=function(T,k){return T=T>>>0,k||R(T,8,this.length),r.read(this,T,!0,52,8)},p.prototype.readDoubleBE=function(T,k){return T=T>>>0,k||R(T,8,this.length),r.read(this,T,!1,52,8)};function S(T,k,O,q,H,W){if(!p.isBuffer(T))throw new TypeError('"buffer" argument must be a Buffer instance');if(k>H||k<W)throw new RangeError('"value" argument is out of bounds');if(O+q>T.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(T,k,O,q){if(T=+T,k=k>>>0,O=O>>>0,!q){let fe=Math.pow(2,8*O)-1;S(this,T,k,O,fe,0)}let H=1,W=0;for(this[k]=T&255;++W<O&&(H*=256);)this[k+W]=T/H&255;return k+O},p.prototype.writeUintBE=p.prototype.writeUIntBE=function(T,k,O,q){if(T=+T,k=k>>>0,O=O>>>0,!q){let fe=Math.pow(2,8*O)-1;S(this,T,k,O,fe,0)}let H=O-1,W=1;for(this[k+H]=T&255;--H>=0&&(W*=256);)this[k+H]=T/W&255;return k+O},p.prototype.writeUint8=p.prototype.writeUInt8=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,1,255,0),this[k]=T&255,k+1},p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,65535,0),this[k]=T&255,this[k+1]=T>>>8,k+2},p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,65535,0),this[k]=T>>>8,this[k+1]=T&255,k+2},p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,4294967295,0),this[k+3]=T>>>24,this[k+2]=T>>>16,this[k+1]=T>>>8,this[k]=T&255,k+4},p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,4294967295,0),this[k]=T>>>24,this[k+1]=T>>>16,this[k+2]=T>>>8,this[k+3]=T&255,k+4};function B(T,k,O,q,H){j(k,q,H,T,O,7);let W=Number(k&BigInt(4294967295));T[O++]=W,W=W>>8,T[O++]=W,W=W>>8,T[O++]=W,W=W>>8,T[O++]=W;let fe=Number(k>>BigInt(32)&BigInt(4294967295));return T[O++]=fe,fe=fe>>8,T[O++]=fe,fe=fe>>8,T[O++]=fe,fe=fe>>8,T[O++]=fe,O}function F(T,k,O,q,H){j(k,q,H,T,O,7);let W=Number(k&BigInt(4294967295));T[O+7]=W,W=W>>8,T[O+6]=W,W=W>>8,T[O+5]=W,W=W>>8,T[O+4]=W;let fe=Number(k>>BigInt(32)&BigInt(4294967295));return T[O+3]=fe,fe=fe>>8,T[O+2]=fe,fe=fe>>8,T[O+1]=fe,fe=fe>>8,T[O]=fe,O+8}p.prototype.writeBigUInt64LE=ct(function(T,k=0){return B(this,T,k,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeBigUInt64BE=ct(function(T,k=0){return F(this,T,k,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeIntLE=function(T,k,O,q){if(T=+T,k=k>>>0,!q){let st=Math.pow(2,8*O-1);S(this,T,k,O,st-1,-st)}let H=0,W=1,fe=0;for(this[k]=T&255;++H<O&&(W*=256);)T<0&&fe===0&&this[k+H-1]!==0&&(fe=1),this[k+H]=(T/W>>0)-fe&255;return k+O},p.prototype.writeIntBE=function(T,k,O,q){if(T=+T,k=k>>>0,!q){let st=Math.pow(2,8*O-1);S(this,T,k,O,st-1,-st)}let H=O-1,W=1,fe=0;for(this[k+H]=T&255;--H>=0&&(W*=256);)T<0&&fe===0&&this[k+H+1]!==0&&(fe=1),this[k+H]=(T/W>>0)-fe&255;return k+O},p.prototype.writeInt8=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,1,127,-128),T<0&&(T=255+T+1),this[k]=T&255,k+1},p.prototype.writeInt16LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,32767,-32768),this[k]=T&255,this[k+1]=T>>>8,k+2},p.prototype.writeInt16BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,32767,-32768),this[k]=T>>>8,this[k+1]=T&255,k+2},p.prototype.writeInt32LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,2147483647,-2147483648),this[k]=T&255,this[k+1]=T>>>8,this[k+2]=T>>>16,this[k+3]=T>>>24,k+4},p.prototype.writeInt32BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,2147483647,-2147483648),T<0&&(T=4294967295+T+1),this[k]=T>>>24,this[k+1]=T>>>16,this[k+2]=T>>>8,this[k+3]=T&255,k+4},p.prototype.writeBigInt64LE=ct(function(T,k=0){return B(this,T,k,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),p.prototype.writeBigInt64BE=ct(function(T,k=0){return F(this,T,k,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function $(T,k,O,q,H,W){if(O+q>T.length)throw new RangeError("Index out of range");if(O<0)throw new RangeError("Index out of range")}function re(T,k,O,q,H){return k=+k,O=O>>>0,H||$(T,k,O,4,34028234663852886e22,-34028234663852886e22),r.write(T,k,O,q,23,4),O+4}p.prototype.writeFloatLE=function(T,k,O){return re(this,T,k,!0,O)},p.prototype.writeFloatBE=function(T,k,O){return re(this,T,k,!1,O)};function Q(T,k,O,q,H){return k=+k,O=O>>>0,H||$(T,k,O,8,17976931348623157e292,-17976931348623157e292),r.write(T,k,O,q,52,8),O+8}p.prototype.writeDoubleLE=function(T,k,O){return Q(this,T,k,!0,O)},p.prototype.writeDoubleBE=function(T,k,O){return Q(this,T,k,!1,O)},p.prototype.copy=function(T,k,O,q){if(!p.isBuffer(T))throw new TypeError("argument should be a Buffer");if(O||(O=0),!q&&q!==0&&(q=this.length),k>=T.length&&(k=T.length),k||(k=0),q>0&&q<O&&(q=O),q===O||T.length===0||this.length===0)return 0;if(k<0)throw new RangeError("targetStart out of bounds");if(O<0||O>=this.length)throw new RangeError("Index out of range");if(q<0)throw new RangeError("sourceEnd out of bounds");q>this.length&&(q=this.length),T.length-k<q-O&&(q=T.length-k+O);let H=q-O;return this===T&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(k,O,q):Uint8Array.prototype.set.call(T,this.subarray(O,q),k),H},p.prototype.fill=function(T,k,O,q){if(typeof T=="string"){if(typeof k=="string"?(q=k,k=0,O=this.length):typeof O=="string"&&(q=O,O=this.length),q!==void 0&&typeof q!="string")throw new TypeError("encoding must be a string");if(typeof q=="string"&&!p.isEncoding(q))throw new TypeError("Unknown encoding: "+q);if(T.length===1){let W=T.charCodeAt(0);(q==="utf8"&&W<128||q==="latin1")&&(T=W)}}else typeof T=="number"?T=T&255:typeof T=="boolean"&&(T=Number(T));if(k<0||this.length<k||this.length<O)throw new RangeError("Out of range index");if(O<=k)return this;k=k>>>0,O=O===void 0?this.length:O>>>0,T||(T=0);let H;if(typeof T=="number")for(H=k;H<O;++H)this[H]=T;else{let W=p.isBuffer(T)?T:p.from(T,q),fe=W.length;if(fe===0)throw new TypeError('The value "'+T+'" is invalid for argument "value"');for(H=0;H<O-k;++H)this[H+k]=W[H%fe]}return this};var Z={};function K(T,k,O){Z[T]=class extends O{constructor(){super(),Object.defineProperty(this,"message",{value:k.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${T}]`,this.stack,delete this.name}get code(){return T}set code(q){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:q,writable:!0})}toString(){return`${this.name} [${T}]: ${this.message}`}}}K("ERR_BUFFER_OUT_OF_BOUNDS",function(T){return T?`${T} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),K("ERR_INVALID_ARG_TYPE",function(T,k){return`The "${T}" argument must be of type number. Received type ${typeof k}`},TypeError),K("ERR_OUT_OF_RANGE",function(T,k,O){let q=`The value of "${T}" is out of range.`,H=O;return Number.isInteger(O)&&Math.abs(O)>2**32?H=ce(String(O)):typeof O=="bigint"&&(H=String(O),(O>BigInt(2)**BigInt(32)||O<-(BigInt(2)**BigInt(32)))&&(H=ce(H)),H+="n"),q+=` It must be ${k}. Received ${H}`,q},RangeError);function ce(T){let k="",O=T.length,q=T[0]==="-"?1:0;for(;O>=q+4;O-=3)k=`_${T.slice(O-3,O)}${k}`;return`${T.slice(0,O)}${k}`}function te(T,k,O){J(k,"offset"),(T[k]===void 0||T[k+O]===void 0)&&X(k,T.length-(O+1))}function j(T,k,O,q,H,W){if(T>O||T<k){let fe=typeof k=="bigint"?"n":"",st;throw W>3?k===0||k===BigInt(0)?st=`>= 0${fe} and < 2${fe} ** ${(W+1)*8}${fe}`:st=`>= -(2${fe} ** ${(W+1)*8-1}${fe}) and < 2 ** ${(W+1)*8-1}${fe}`:st=`>= ${k}${fe} and <= ${O}${fe}`,new Z.ERR_OUT_OF_RANGE("value",st,T)}te(q,H,W)}function J(T,k){if(typeof T!="number")throw new Z.ERR_INVALID_ARG_TYPE(k,"number",T)}function X(T,k,O){throw Math.floor(T)!==T?(J(T,O),new Z.ERR_OUT_OF_RANGE(O||"offset","an integer",T)):k<0?new Z.ERR_BUFFER_OUT_OF_BOUNDS:new Z.ERR_OUT_OF_RANGE(O||"offset",`>= ${O?1:0} and <= ${k}`,T)}var he=/[^+/0-9A-Za-z-_]/g;function Te(T){if(T=T.split("=")[0],T=T.trim().replace(he,""),T.length<2)return"";for(;T.length%4!==0;)T=T+"=";return T}function oe(T,k){k=k||1/0;let O,q=T.length,H=null,W=[];for(let fe=0;fe<q;++fe){if(O=T.charCodeAt(fe),O>55295&&O<57344){if(!H){if(O>56319){(k-=3)>-1&&W.push(239,191,189);continue}else if(fe+1===q){(k-=3)>-1&&W.push(239,191,189);continue}H=O;continue}if(O<56320){(k-=3)>-1&&W.push(239,191,189),H=O;continue}O=(H-55296<<10|O-56320)+65536}else H&&(k-=3)>-1&&W.push(239,191,189);if(H=null,O<128){if((k-=1)<0)break;W.push(O)}else if(O<2048){if((k-=2)<0)break;W.push(O>>6|192,O&63|128)}else if(O<65536){if((k-=3)<0)break;W.push(O>>12|224,O>>6&63|128,O&63|128)}else if(O<1114112){if((k-=4)<0)break;W.push(O>>18|240,O>>12&63|128,O>>6&63|128,O&63|128)}else throw new Error("Invalid code point")}return W}function le(T){let k=[];for(let O=0;O<T.length;++O)k.push(T.charCodeAt(O)&255);return k}function ot(T,k){let O,q,H,W=[];for(let fe=0;fe<T.length&&!((k-=2)<0);++fe)O=T.charCodeAt(fe),q=O>>8,H=O%256,W.push(H),W.push(q);return W}function ge(T){return e.toByteArray(Te(T))}function Se(T,k,O,q){let H;for(H=0;H<q&&!(H+O>=k.length||H>=T.length);++H)k[H+O]=T[H];return H}function ut(T,k){return T instanceof k||T!=null&&T.constructor!=null&&T.constructor.name!=null&&T.constructor.name===k.name}function Ze(T){return T!==T}var Ge=function(){let T="0123456789abcdef",k=new Array(256);for(let O=0;O<16;++O){let q=O*16;for(let H=0;H<16;++H)k[q+H]=T[O]+T[H]}return k}();function ct(T){return typeof BigInt>"u"?z:T}function z(){throw new Error("BigInt not supported")}}),gEe=zh((t,e)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,e.exports={Buffer:tI().Buffer,Crypto:window.crypto}):e.exports={Buffer:tI().Buffer,Crypto:crypto}}),gte={};cEe(gte,{AVSCTap:()=>B2,ArweaveSigner:()=>RI,DataItem:()=>A2,MAX_TAG_BYTES:()=>E4,MIN_BINARY_SIZE:()=>kI,SIG_CONFIG:()=>K1,SignatureConfig:()=>Ns,Signer:()=>bte,createData:()=>Mte,deserializeTags:()=>v4,indexToType:()=>TI,serializeTags:()=>II,tagsExceedLimit:()=>_te});var bte=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(t,e,r,a){throw new Error("You must implement verify method on child")}},bEe=Rd(AI(),1),kf=Rd(mte(),1);async function yte(t){if(Array.isArray(t)){let i=(0,kf.concatBuffers)([(0,kf.stringToBuffer)("list"),(0,kf.stringToBuffer)(t.length.toString())]);return await wte(t,await qh().hash(i,"SHA-384"))}let e=t,r=(0,kf.concatBuffers)([(0,kf.stringToBuffer)("blob"),(0,kf.stringToBuffer)(e.byteLength.toString())]),a=(0,kf.concatBuffers)([await qh().hash(r,"SHA-384"),await qh().hash(e,"SHA-384")]);return await qh().hash(a,"SHA-384")}async function wte(t,e){if(t.length<1)return e;let r=(0,kf.concatBuffers)([e,await yte(t[0])]),a=await qh().hash(r,"SHA-384");return await wte(t.slice(1),a)}var BT=Rd(vEe(),1),yEe=BT.default.default?BT.default.default:BT.default,wEe=class extends yEe{getPublicKey(t){throw new Error("Unimplemented")}},_Ee;function qh(){return _Ee??=new wEe}var Ns;(function(t){t[t.ARWEAVE=1]="ARWEAVE",t[t.ED25519=2]="ED25519",t[t.ETHEREUM=3]="ETHEREUM",t[t.SOLANA=4]="SOLANA",t[t.INJECTEDAPTOS=5]="INJECTEDAPTOS",t[t.MULTIAPTOS=6]="MULTIAPTOS",t[t.TYPEDETHEREUM=7]="TYPEDETHEREUM"})(Ns||(Ns={}));var K1={[Ns.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[Ns.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[Ns.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[Ns.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[Ns.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[Ns.MULTIAPTOS]:{sigLength:64*32+4,pubLength:32*32+1,sigName:"multiAptos"},[Ns.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},RI=class{signatureType=1;ownerLength=K1[1].pubLength;signatureLength=K1[1].sigLength;jwk;pk;constructor(t){this.pk=t.n,this.jwk=t}get publicKey(){return bEe.default.toBuffer(this.pk)}sign(t){return qh().sign(this.jwk,t)}static async verify(t,e,r){return await qh().verify(t,e,r)}},TI={1:RI},Ou=Rd(AI(),1);async function rI(t){return yte([(0,kf.stringToBuffer)("dataitem"),(0,kf.stringToBuffer)("1"),(0,kf.stringToBuffer)(t.signatureType.toString()),t.rawOwner,t.rawTarget,t.rawAnchor,t.rawTags,t.rawData])}async function MEe(t,e){let r=await rI(t),a=await e.sign(r),i=await qh().hash(a);return{signature:Me.from(a),id:Me.from(i)}}async function xEe(t,e){let{signature:r,id:a}=await MEe(t,e);return t.getRaw().set(r,2),a}var B2=class{buf;pos;constructor(t=Me.alloc(E4),e=0){this.buf=t,this.pos=e}writeTags(t){if(!Array.isArray(t))throw new Error("input must be array");let e=t.length,r;if(e)for(this.writeLong(e),r=0;r<e;r++){let a=t[r];if(a?.name===void 0||a?.value===void 0)throw new Error(`Invalid tag format for ${a}, expected {name:string, value: string}`);this.writeString(a.name),this.writeString(a.value)}this.writeLong(0)}toBuffer(){let t=Me.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(t,0,0,this.pos),t}tagsExceedLimit(){return this.pos>this.buf.length}writeLong(t){let e=this.buf,r,a;if(t>=-1073741824&&t<1073741824){a=t>=0?t<<1:~t<<1|1;do e[this.pos]=a&127,a>>=7;while(a&&(e[this.pos++]|=128))}else{r=t>=0?t*2:-t*2-1;do e[this.pos]=r&127,r/=128;while(r>=1&&(e[this.pos++]|=128))}this.pos++,this.buf=e}writeString(t){let e=Me.byteLength(t),r=this.buf;this.writeLong(e);let a=this.pos;if(this.pos+=e,!(this.pos>r.length)){if(e>64)this.buf.write(t,this.pos-e,e,"utf8");else{let i,h,c,p;for(i=0,h=e;i<h;i++)c=t.charCodeAt(i),c<128?r[a++]=c:c<2048?(r[a++]=c>>6|192,r[a++]=c&63|128):(c&64512)===55296&&((p=t.charCodeAt(i+1))&64512)===56320?(c=65536+((c&1023)<<10)+(p&1023),i++,r[a++]=c>>18|240,r[a++]=c>>12&63|128,r[a++]=c>>6&63|128,r[a++]=c&63|128):(r[a++]=c>>12|224,r[a++]=c>>6&63|128,r[a++]=c&63|128)}this.buf=r}}readLong(){let t=0,e=0,r=this.buf,a,i,h,c;do a=r[this.pos++],i=a&128,t|=(a&127)<<e,e+=7;while(i&&e<28);if(i){h=t,c=268435456;do a=r[this.pos++],h+=(a&127)*c,c*=128;while(a&128);return(h%2?-(h+1):h)/2}return t>>1^-(t&1)}skipLong(){let t=this.buf;for(;t[this.pos++]&128;);}readTags(){let t=[],e;for(;e=this.readLong();)for(e<0&&(e=-e,this.skipLong());e--;){let r=this.readString(),a=this.readString();t.push({name:r,value:a})}return t}readString(){let t=this.readLong(),e=this.pos,r=this.buf;if(this.pos+=t,!(this.pos>r.length))return this.buf.slice(e,e+t).toString()}};function II(t){let e=new B2;return e.writeTags(t),e.toBuffer()}function _te(t){let e=new B2;return e.writeTags(t),e.tagsExceedLimit()}function v4(t){return new B2(t).readTags()}function pl(t){let e=0;for(let r=t.length-1;r>=0;r--)e=e*256+t[r];return e}function SEe(t){if(t>29)throw new Error("Short too long");let e=[0,0];for(let r=0;r<e.length;r++){let a=t&255;e[r]=a,t=(t-a)/256}return Uint8Array.from(e)}function $Q(t){let e=[0,0,0,0,0,0,0,0];for(let r=0;r<e.length;r++){let a=t&255;e[r]=a,t=(t-a)/256}return Uint8Array.from(e)}var EEe=Rd(gEe(),1),A1=Rd(tI(),1),E4=4096,kI=80,A2=class{binary;_id;constructor(t){this.binary=t}static isDataItem(t){return t.binary!==void 0}get signatureType(){let t=pl(this.binary.subarray(0,2));if(Ns?.[t]!==void 0)return t;throw new Error("Unknown signature type: "+t)}async isValid(){return A2.verify(this.binary)}get id(){return(async()=>Ou.default.encode(await this.rawId))()}set id(t){this._id=Ou.default.toBuffer(t)}get rawId(){return(async()=>A1.Buffer.from(await EEe.Crypto.subtle.digest("SHA-256",this.rawSignature)))()}set rawId(t){this._id=t}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return Ou.default.encode(this.rawSignature)}set rawOwner(t){if(t.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${t.byteLength} bytes.`);this.binary.set(t,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return K1[this.signatureType].sigLength}get owner(){return Ou.default.encode(this.rawOwner)}get ownerLength(){return K1[this.signatureType].pubLength}get rawTarget(){let t=this.getTargetStart();return this.binary[t]==1?this.binary.subarray(t+1,t+33):A1.Buffer.alloc(0)}get target(){return Ou.default.encode(this.rawTarget)}get rawAnchor(){let t=this.getAnchorStart();return this.binary[t]==1?this.binary.subarray(t+1,t+33):A1.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let t=this.getTagsStart(),e=pl(this.binary.subarray(t+8,t+16));return this.binary.subarray(t+16,t+16+e)}get tags(){let t=this.getTagsStart();if(pl(this.binary.subarray(t,t+8))==0)return[];let e=pl(this.binary.subarray(t+8,t+16));return v4(A1.Buffer.from(this.binary.subarray(t+16,t+16+e)))}get tagsB64Url(){return this.tags.map(t=>({name:Ou.default.encode(t.name),value:Ou.default.encode(t.value)}))}getStartOfData(){let t=this.getTagsStart(),e=this.binary.subarray(t+8,t+16),r=pl(e);return t+16+r}get rawData(){let t=this.getTagsStart(),e=this.binary.subarray(t+8,t+16),r=pl(e),a=t+16+r;return this.binary.subarray(a,this.binary.length)}get data(){return Ou.default.encode(this.rawData)}getRaw(){return this.binary}async sign(t){return this._id=await xEe(this,t),this.rawId}async setSignature(t){this.binary.set(t,2),this._id=A1.Buffer.from(await qh().hash(t))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map(t=>({name:Ou.default.encode(t.name),value:Ou.default.encode(t.value)})),data:this.data}}static async verify(t){if(t.byteLength<kI)return!1;let e=new A2(t),r=e.signatureType,a=e.getTagsStart(),i=pl(t.subarray(a,a+8)),h=t.subarray(a+8,a+16),c=pl(h);if(c>E4)return!1;if(i>0)try{if(v4(A1.Buffer.from(t.subarray(a+16,a+16+c))).length!==i)return!1}catch{return!1}let p=TI[r],b=await rI(e);return await p.verify(e.rawOwner,b,e.rawSignature)}async getSignatureData(){return rI(this)}getTagsStart(){let t=this.getTargetStart(),e=this.binary[t]==1,r=t+(e?33:1),a=this.binary[r]==1;return r+=a?33:1,r}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let t=this.getTargetStart()+1,e=this.binary[this.getTargetStart()]==1;return t+=e?32:0,t}},AEe=Rd(AI(),1);function Mte(t,e,r){let a=e.publicKey,i=r?.target?AEe.default.toBuffer(r.target):null,h=1+(i?.byteLength??0),c=r?.anchor?Me.from(r.anchor):null,p=1+(c?.byteLength??0),b=(r?.tags?.length??0)>0?II(r.tags):null,g=16+(b?b.byteLength:0),y=Me.from(t),M=y.byteLength,x=2+e.signatureLength+e.ownerLength+h+p+g+M,E=Me.alloc(x);if(E.set(SEe(e.signatureType),0),E.set(new Uint8Array(e.signatureLength).fill(0),2),a.byteLength!==e.ownerLength)throw new Error(`Owner must be ${e.ownerLength} bytes, but was incorrectly ${a.byteLength}`);E.set(a,2+e.signatureLength);let A=2+e.signatureLength+e.ownerLength;if(E[A]=i?1:0,i){if(i.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${i.byteLength}`);E.set(i,A+1)}let I=A+h,P=I+1;if(E[I]=c?1:0,c){if(P+=c.byteLength,c.byteLength!==32)throw new Error("Anchor must be 32 bytes");E.set(c,I+1)}E.set($Q(r?.tags?.length??0),P);let N=$Q(b?.byteLength??0);E.set(N,P+8),b&&E.set(b,P+16);let L=P+g;return E.set(y,L),new A2(E)}var BI={...gte};globalThis.arbundles??=BI;var REe=BI,TEe=BI;globalThis.Buffer||(globalThis.Buffer=dte.Buffer);var{DataItem:IEe}=pte;function kEe(t){return async({data:r,tags:a,target:i,anchor:h,createDataItem:c=p=>new IEe(p)})=>{let p=await t.signDataItem({data:r,tags:a,target:i,anchor:h}),b=c(dte.Buffer.from(p));return{id:await b.id,raw:await b.getRaw()}}}var BEe=globalThis.GATEWAY_URL||void 0,PEe=globalThis.MU_URL||void 0,OEe=globalThis.CU_URL||void 0,NEe=globalThis.GRAPHQL_URL||void 0,{result:dut,results:put,message:vut,spawn:mut,monitor:gut,unmonitor:but,dryrun:yut,assign:wut}=Sl({GATEWAY_URL:BEe,MU_URL:PEe,CU_URL:OEe,GRAPHQL_URL:NEe}),xte=lte.createDataItemSigner;ie();ae();ne();var mre=mi(vre(),1),N4=mre.default.init({host:"arweave.net",port:443,protocol:"https"});ie();ae();ne();ie();ae();ne();var Df=class extends Error{constructor(e){super(e),this.name=this.constructor.name}},gre=class extends Df{},bre=class extends Df{},yre=class extends Df{constructor(e,r){super(`Failed request: ${e}: ${r}`)}},wre=class extends Df{},C4=class extends Df{},_re=class extends Df{constructor(){super("Invalid signer. Please provide a valid signer to interact with the contract.")}},Rl=class extends Df{constructor(){super("Invalid contract configuration")}},Mre=class extends Df{constructor(){super("Invalid process configuration")}},xre=class extends Df{};ie();ae();ne();var Kf=mi(zfe(),1);ie();ae();ne();var jw="3.5.1-alpha.2";var Wu=class t{logger;silent=!1;static default=new t;constructor({level:e="info"}={}){e==="none"&&(this.silent=!0),typeof window<"u"?this.logger=console:this.logger=(0,Kf.createLogger)({level:e,silent:this.silent,defaultMeta:{name:"ar-io-sdk",version:jw},format:Kf.format.combine(Kf.format.timestamp(),Kf.format.json()),transports:[new Kf.transports.Console({format:Kf.format.combine(Kf.format.timestamp(),Kf.format.json())})]})}info(e,...r){this.silent||this.logger.info(e,...r)}warn(e,...r){this.silent||this.logger.warn(e,...r)}error(e,...r){this.silent||this.logger.error(e,...r)}debug(e,...r){this.silent||this.logger.debug(e,...r)}setLogLevel(e){this.silent=e==="none","silent"in this.logger&&(this.logger.silent=e==="none"),"level"in this.logger&&(this.logger.level=e)}};ie();ae();ne();ie();ae();ne();function Pl(t,e){let r=t.safeParse(e);if(!r.success)throw new Error(JSON.stringify(r.error.format(),null,2));return r}var zw=class{static init(e){return e!==void 0&&"signer"in e?new fP(e):new Zw(e)}},Zw=class{process;processId;strict;constructor(e){if(this.strict=e.strict||!1,vv(e))this.process=e.process;else if(mv(e))this.process=new za({processId:e.processId});else throw new Rl;this.processId=this.process.processId}async getState({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"State"}],a=await this.process.read({tags:r});return e&&Pl(MT.passthrough().and(Qt.object({Records:Qt.record(Qt.string(),q8.passthrough())})),a),a}async getInfo({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Info"}],a=await this.process.read({tags:r});return e&&Pl(dQ.passthrough(),a),a}async getLogo(){return(await this.getInfo()).Logo}async getRecord({undername:e},{strict:r}={strict:this.strict}){let a=[{name:"Sub-Domain",value:e},{name:"Action",value:"Record"}],i=await this.process.read({tags:a});return r&&Pl(q8.passthrough(),i),i}async getRecords({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Records"}],a=await this.process.read({tags:r});return e&&Pl(yT,a),a}async getOwner({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Owner}async getControllers({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Controllers"}],a=await this.process.read({tags:r});return e&&Pl(wT,a),a}async getName({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Name}async getTicker({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Ticker}async getBalances({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Balances"}],a=await this.process.read({tags:r});return e&&Pl(_T,a),a}async getBalance({address:e},{strict:r}={strict:this.strict}){let a=[{name:"Action",value:"Balance"},{name:"Recipient",value:e}],i=await this.process.read({tags:a});return r&&Pl(Qt.number(),i),i}async getHandlers(){let e=await this.getInfo();return e.Handlers??e.HandlerNames}},fP=class extends Zw{signer;constructor({signer:e,...r}){super(r),this.signer=pv(e)}async transfer({target:e},r){let a=[...r?.tags??[],{name:"Action",value:"Transfer"},{name:"Recipient",value:e}];return this.process.send({tags:a,signer:this.signer})}async addController({controller:e},r){let a=[...r?.tags??[],{name:"Action",value:"Add-Controller"},{name:"Controller",value:e}];return this.process.send({tags:a,signer:this.signer})}async removeController({controller:e},r){let a=[...r?.tags??[],{name:"Action",value:"Remove-Controller"},{name:"Controller",value:e}];return this.process.send({tags:a,signer:this.signer})}async setRecord({undername:e,transactionId:r,ttlSeconds:a},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:e},{name:"Transaction-Id",value:r},{name:"TTL-Seconds",value:a.toString()}],signer:this.signer})}async setBaseNameRecord({transactionId:e,ttlSeconds:r},a){return this.setRecord({transactionId:e,ttlSeconds:r,undername:"@"},a)}async setUndernameRecord({undername:e,transactionId:r,ttlSeconds:a},i){return this.setRecord({undername:e,transactionId:r,ttlSeconds:a},i)}async removeUndernameRecord({undername:e}){return this.removeRecord({undername:e})}async removeRecord({undername:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:e}],signer:this.signer})}async setTicker({ticker:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:e}],signer:this.signer})}async setName({name:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Name"},{name:"Name",value:e}],signer:this.signer})}async setDescription({description:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Description"},{name:"Description",value:e}],signer:this.signer})}async setKeywords({keywords:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Keywords"},{name:"Keywords",value:JSON.stringify(e)}],signer:this.signer})}async setLogo({txId:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Logo"},{name:"Logo",value:e}],signer:this.signer})}async releaseName({name:e,arioProcessId:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Release-Name"},{name:"Name",value:e},{name:"IO-Process-Id",value:r},{name:"ARIO-Process-Id",value:r}],signer:this.signer})}async reassignName({name:e,arioProcessId:r,antProcessId:a},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Reassign-Name"},{name:"Name",value:e},{name:"IO-Process-Id",value:r},{name:"ARIO-Process-Id",value:r},{name:"Process-Id",value:a}],signer:this.signer})}async approvePrimaryNameRequest({name:e,address:r,arioProcessId:a},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Approve-Primary-Name"},{name:"Name",value:e},{name:"Recipient",value:r},{name:"IO-Process-Id",value:a},{name:"ARIO-Process-Id",value:a}],signer:this.signer})}async removePrimaryNames({names:e,arioProcessId:r,notifyOwners:a=!1},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Remove-Primary-Names"},{name:"Names",value:e.join(",")},{name:"IO-Process-Id",value:r},{name:"ARIO-Process-Id",value:r},{name:"Notify-Owners",value:a.toString()}],signer:this.signer})}};ie();ae();ne();var Eb=class{static init(e){return e!==void 0&&"signer"in e?new uP(e):new Hw(e)}},Hw=class{process;constructor(e){if(e===void 0||Object.keys(e).length===0)this.process=new za({processId:$8});else if(vv(e))this.process=e.process;else if(mv(e))this.process=new za({processId:e.processId});else throw new Rl}async accessControlList({address:e}){return this.process.read({tags:[{name:"Action",value:"Access-Control-List"},{name:"Address",value:e}]})}},uP=class extends Hw{signer;constructor({signer:e,...r}){super(r),this.signer=pv(e)}async register({processId:e}){return this.process.send({tags:[{name:"Action",value:"Register"},{name:"Process-Id",value:e}],signer:this.signer})}};ie();ae();ne();ie();ae();ne();ie();ae();ne();lu();var Zfe="+",Hfe="/",Kfe="-",Wfe="_",Vfe="=";function Qqe(t){let e=t.length%4;return e&&(t+=Vfe.repeat(4-e)),t.replaceAll(Kfe,Zfe).replaceAll(Wfe,Hfe)}function eUe(t){return t.replaceAll(Zfe,Kfe).replaceAll(Hfe,Wfe).replaceAll(Vfe,"")}function Jbt(t){let e=Qqe(t);return Me.from(e,"base64")}function tUe(t){let e=t.toString("base64");return eUe(e)}function Xbt(t){return tUe(df("sha256").update(Uint8Array.from(t)).digest())}function Gfe(t=32){let e=oE(t);return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("").slice(0,t)}ie();ae();ne();ie();ae();ne();function hP(t){try{return JSON.parse(t)}catch{return t}}ie();ae();ne();ie();ae();ne();var lP=mi(Jfe(),1);ie();ae();ne();var nUe=Object.defineProperty,aUe=(t,e,r)=>e in t?nUe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rb=(t,e,r)=>(aUe(t,typeof e!="symbol"?e+"":e,r),r),dP=class{constructor(e){Rb(this,"value"),Rb(this,"next"),this.value=e}},pP=class{constructor(){Rb(this,"head"),Rb(this,"tail"),Rb(this,"_size",0),this.clear()}clear(){this.head=void 0,this.tail=void 0,this._size=0}push(e){let r=new dP(e);return this.head&&this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),this._size++,this._size}pop(){if(!this.head)return;let e=this.head;return this.head=this.head.next,this._size--,e.value}get size(){return this._size}*[Symbol.iterator](){let e=this.head;for(;e;)yield e.value,e=e.next}};function Xfe(t){if(!((Number.isInteger(t)||t===1/0)&&t>0))throw new TypeError("Expected `concurrency` to be a number greater than 1");let e=new pP,r=0,a=()=>{r--,e.size>0&&e.pop()()},i=async(p,b,g)=>{r++;let y=(async()=>p(...g))();b(y);try{await y}catch{}a()},h=(p,b,g)=>{e.push(i.bind(null,p,b,g)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.pop()()))()},c=(p,...b)=>new Promise(g=>{h(p,g,b)});return Object.defineProperties(c,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),c}var Iyt=async({address:t,registry:e=Eb.init()})=>{let r=await e.accessControlList({address:t});return[...new Set([...r.Owned,...r.Controlled])]};function Qfe(t,e){return new Promise((r,a)=>{let i=setTimeout(()=>{a(new Error("Timeout"))},t);e.then(h=>{clearTimeout(i),r(h)}).catch(h=>{clearTimeout(i),a(h)})})}var eue=class extends lP.default{contract;timeoutMs;throttle;logger;strict;antAoClient;constructor({contract:e=Tb.init({processId:Lh}),timeoutMs:r=6e4,concurrency:a=30,logger:i=Wu.default,strict:h=!1,antAoClient:c=Sl()}={}){super(),this.contract=e,this.timeoutMs=r,this.throttle=Xfe(a),this.logger=i,this.strict=h,this.antAoClient=c}async fetchProcessesOwnedByWallet({address:e,pageSize:r,antRegistry:a=Eb.init()}){let i={},h=await a.accessControlList({address:e}),c=new Set([...h.Owned,...h.Controlled]);await Qfe(this.timeoutMs,oUe({contract:this.contract,emitter:this,pageSize:r})).catch(b=>(this.emit("error",`Error getting ArNS records: ${b}`),this.logger.error("Error getting ArNS records",{message:b?.message,stack:b?.stack}),{})).then(b=>{Object.entries(b).forEach(([g,y])=>{c.has(y.processId)&&(i[y.processId]==null&&(i[y.processId]={state:void 0,names:{}}),i[y.processId].names[g]=y)})});let p=Object.keys(i).length;this.emit("progress",0,p),await Promise.all(Object.keys(i).map(async(b,g)=>this.throttle(async()=>{if(i[b].state!==void 0){this.emit("progress",g+1,p);return}let y=zw.init({process:new za({processId:b,ao:this.antAoClient}),strict:this.strict}),M=await Qfe(this.timeoutMs,y.getState()).catch(x=>{this.emit("error",`Error getting state for process ${b}: ${x}`)});(M?.Owner===e||M?.Controllers.includes(e))&&(i[b].state=M,this.emit("process",b,i[b])),this.emit("progress",g+1,p)}))),this.emit("end",i)}},oUe=async({contract:t=Tb.init({processId:Lh}),emitter:e,logger:r=Wu.default,pageSize:a=5e4})=>{let i,h=Date.now(),c={};do{let p=await t.getArNSRecords({cursor:i,limit:a}).catch(b=>{r?.error("Error getting ArNS records",{message:b?.message,stack:b?.stack}),e?.emit("arns:error",`Error getting ArNS records: ${b}`)});if(!p)return{};p.items.forEach(b=>{let{name:g,...y}=b;c[g]=y}),r.debug("Fetched page of ArNS records",{totalRecordCount:p.totalItems,fetchedRecordCount:Object.keys(c).length,cursor:p.nextCursor}),e?.emit("arns:pageLoaded",{totalRecordCount:p.totalItems,fetchedRecordCount:Object.keys(c).length,records:p.items,cursor:p.nextCursor}),i=p.nextCursor}while(i!==void 0);return e?.emit("arns:end",c),r.debug("Fetched all ArNS records",{totalRecordCount:Object.keys(c).length,durationMs:Date.now()-h}),c};ie();ae();ne();var Nyt=t=>{let e=Object.entries(t).sort(([r,a],[i,h])=>r==="@"?-1:i==="@"?1:"priority"in a&&!("priority"in h)?-1:!("priority"in a)&&"priority"in h?1:a.priority!==void 0&&h.priority!==void 0?a.priority===h.priority?r<i?-1:r>i?1:0:a.priority-h.priority:r<i?-1:r>i?1:0);return Object.fromEntries(e.map(([r,a],i)=>[r,{...a,index:i}]))};var za=class{logger;ao;processId;constructor({processId:e,ao:r=Sl(),logger:a=Wu.default}){this.processId=e,this.logger=a,this.ao=r}isMessageDataEmpty(e){return e===void 0||e==="null"||e===""||e===null}async read({tags:e,retries:r=3,fromAddress:a}){let i=0,h;for(;i<r;)try{this.logger.debug("Evaluating read interaction on process",{tags:e,processId:this.processId});let c={process:this.processId,tags:e};a!==void 0&&(c.Owner=a);let p=await this.ao.dryrun(c);this.logger.debug("Read interaction result",{result:p,processId:this.processId});let b=vP(p);if(b!==void 0)throw new Error(b);if(p.Messages===void 0||p.Messages.length===0)throw this.logger.debug(`Process ${this.processId} does not support provided action.`,{result:p,tags:e,processId:this.processId}),new Error(`Process ${this.processId} does not support provided action.`);let g=p.Messages?.[0]?.Data;return this.isMessageDataEmpty(g)?void 0:hP(g)}catch(c){i++,this.logger.debug(`Read attempt ${i} failed`,{error:c?.message,stack:c?.stack,tags:e,processId:this.processId}),h=c,await new Promise(p=>setTimeout(p,2**i*1e3))}throw h}async send({tags:e,data:r,signer:a,retries:i=3}){let h=0,c;for(;h<i;)try{this.logger.debug("Evaluating send interaction on contract",{tags:e,data:r,processId:this.processId});let p=Gfe(32),b=await this.ao.message({process:this.processId,tags:[...e,{name:"AR-IO-SDK",value:jw}],data:r,signer:a,anchor:p});this.logger.debug("Sent message to process",{messageId:b,processId:this.processId,anchor:p});let g=await this.ao.result({message:b,process:this.processId});this.logger.debug("Message result",{output:g,messageId:b,processId:this.processId});let y=vP(g);if(y!==void 0)throw new C4(y);if(g.Messages?.length===0||g.Messages===void 0)return{id:b};if(g.Messages.length===0)throw new Error(`Process ${this.processId} does not support provided action.`);if(this.isMessageDataEmpty(g.Messages[0].Data))return{id:b};let M=hP(g.Messages[0].Data);return this.logger.debug("Message result data",{resultData:M,messageId:b,processId:this.processId}),{id:b,result:M}}catch(p){if(this.logger.error("Error sending message to process",{error:p?.message,stack:p?.stack,processId:this.processId,tags:e}),p.message.includes("500"))this.logger.debug("Retrying send interaction",{attempts:h,retries:i,error:p?.message,processId:this.processId}),await new Promise(b=>setTimeout(b,2**h*2e3)),h++,c=p;else throw p}throw c}};var Tb=class{static init(e){return e!==void 0&&"signer"in e?new mP(e):new Ww(e)}},Ww=class{process;epochSettings;arweave;constructor(e){if(this.arweave=e?.arweave??N4,e===void 0||Object.keys(e).length===0)this.process=new za({processId:Lh});else if(vv(e))this.process=e.process;else if(mv(e))this.process=new za({processId:e.processId});else throw new Rl}async getInfo(){return this.process.read({tags:[{name:"Action",value:"Info"}]})}async getTokenSupply(){return this.process.read({tags:[{name:"Action",value:"Total-Token-Supply"}]})}async computeEpochIndexForTimestamp(e){let r=await this.getEpochSettings(),a=r.epochZeroStartTimestamp,i=r.durationMs;return Math.floor((e-a)/i)}async computeCurrentEpochIndex(){let e=await this.getEpochSettings(),r=e.epochZeroStartTimestamp,a=e.durationMs,i=Date.now();return Math.floor((i-r)/a)}async computeEpochIndex(e){let r=e?.epochIndex;if(r!==void 0)return r;let a=e?.timestamp;if(a!==void 0)return this.computeEpochIndexForTimestamp(a)}async getEpochSettings(){return this.epochSettings??=await this.process.read({tags:[{name:"Action",value:"Epoch-Settings"}]})}async getEpoch(e){let r=await this.computeCurrentEpochIndex(),a=await this.computeEpochIndex(e);if(a!==void 0&&a<r)return await gv({arweave:this.arweave,epochIndex:a,processId:this.process.processId});let i=[{name:"Action",value:"Epoch"},{name:"Epoch-Index",value:r.toString()}];return this.process.read({tags:Sn(i)})}async getArNSRecord({name:e}){return this.process.read({tags:[{name:"Action",value:"Record"},{name:"Name",value:e}]})}async getArNSRecords(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Records"},...Ha(e)]})}async getArNSReservedNames(e){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"},...Ha(e)]})}async getArNSReservedName({name:e}){return this.process.read({tags:[{name:"Action",value:"Reserved-Name"},{name:"Name",value:e}]})}async getBalance({address:e}){return this.process.read({tags:[{name:"Action",value:"Balance"},{name:"Address",value:e}]})}async getBalances(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Balances"},...Ha(e)]})}async getVault({address:e,vaultId:r}){return this.process.read({tags:[{name:"Action",value:"Vault"},{name:"Address",value:e},{name:"Vault-Id",value:r}]})}async getVaults(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Vaults"},...Ha(e)]})}async getGateway({address:e}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:e}]})}async getGatewayDelegates({address:e,...r}){return this.process.read({tags:[{name:"Action",value:"Paginated-Delegates"},{name:"Address",value:e},...Ha(r)]})}async getGatewayDelegateAllowList({address:e,...r}){return this.process.read({tags:[{name:"Action",value:"Paginated-Allowed-Delegates"},{name:"Address",value:e},...Ha(r)]})}async getGateways(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateways"},...Ha(e)]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"}]})}async getPrescribedObservers(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&r<a)return(await gv({arweave:this.arweave,epochIndex:r,processId:this.process.processId}))?.prescribedObservers;let i=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Epoch-Index",value:a.toString()}];return this.process.read({tags:Sn(i)})}async getPrescribedNames(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&r<a)return(await gv({arweave:this.arweave,epochIndex:r,processId:this.process.processId}))?.prescribedNames;let i=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Epoch-Index",value:a.toString()}];return this.process.read({tags:Sn(i)})}async getObservations(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&r<a)return(await gv({arweave:this.arweave,epochIndex:r,processId:this.process.processId}))?.observations;let i=[{name:"Action",value:"Epoch-Observations"},{name:"Epoch-Index",value:a.toString()}];return this.process.read({tags:Sn(i)})}async getDistributions(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&r<a)return(await gv({arweave:this.arweave,epochIndex:r,processId:this.process.processId}))?.distributions;let i=[{name:"Action",value:"Epoch-Distributions"},{name:"Epoch-Index",value:a.toString()}];return this.process.read({tags:Sn(i)})}async getTokenCost({intent:e,type:r,years:a,name:i,quantity:h,fromAddress:c}){let p=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:e},{name:"Name",value:i},{name:"Years",value:a?.toString()},{name:"Quantity",value:h?.toString()},{name:"Purchase-Type",value:r}];return this.process.read({tags:Sn(p),fromAddress:c})}async getCostDetails({intent:e,type:r,years:a,name:i,quantity:h,fromAddress:c,fundFrom:p}){let b=[{name:"Action",value:"Cost-Details"},{name:"Intent",value:e},{name:"Name",value:i},{name:"Years",value:a?.toString()},{name:"Quantity",value:h?.toString()},{name:"Purchase-Type",value:r},{name:"Fund-From",value:p}];return this.process.read({tags:Sn(b),fromAddress:c})}async getRegistrationFees(){return this.process.read({tags:[{name:"Action",value:"Registration-Fees"}]})}async getDemandFactor(){return this.process.read({tags:[{name:"Action",value:"Demand-Factor"}]})}async getDemandFactorSettings(){return this.process.read({tags:[{name:"Action",value:"Demand-Factor-Settings"}]})}async getArNSReturnedNames(e){return this.process.read({tags:[{name:"Action",value:"Returned-Names"},...Ha(e)]})}async getArNSReturnedName({name:e}){let r=[{name:"Action",value:"Returned-Name"},{name:"Name",value:e}];return this.process.read({tags:r})}async getDelegations(e){let r=[{name:"Action",value:"Paginated-Delegations"},{name:"Address",value:e.address},...Ha(e)];return this.process.read({tags:Sn(r)})}async getAllowedDelegates(e){return this.getGatewayDelegateAllowList(e)}async getGatewayVaults(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateway-Vaults"},{name:"Address",value:e.address},...Ha(e)]})}async getPrimaryNameRequest(e){let r=[{name:"Action",value:"Primary-Name-Request"},{name:"Initiator",value:e.initiator}];return this.process.read({tags:r})}async getPrimaryNameRequests(e){return this.process.read({tags:[{name:"Action",value:"Primary-Name-Requests"},...Ha(e)]})}async getPrimaryName(e){let r=[{name:"Action",value:"Primary-Name"},{name:"Address",value:e?.address},{name:"Name",value:e?.name}];return this.process.read({tags:Sn(r)})}async getPrimaryNames(e){return this.process.read({tags:[{name:"Action",value:"Primary-Names"},...Ha(e)]})}async getRedelegationFee(e){return this.process.read({tags:[{name:"Action",value:"Redelegation-Fee"},{name:"Address",value:e.address}]})}async getGatewayRegistrySettings(){return this.process.read({tags:[{name:"Action",value:"Gateway-Registry-Settings"}]})}async getAllDelegates(e){return this.process.read({tags:[{name:"Action",value:"All-Paginated-Delegates"},...Ha(e)]})}async getAllGatewayVaults(e){return this.process.read({tags:[{name:"Action",value:"All-Gateway-Vaults"},...Ha(e)]})}},mP=class extends Ww{signer;constructor({signer:e,...r}){r===void 0?super({process:new za({processId:Lh})}):super(r),this.signer=pv(e)}async transfer({target:e,qty:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Transfer"},{name:"Recipient",value:e},{name:"Quantity",value:r.valueOf().toString()}],signer:this.signer})}async vaultedTransfer({recipient:e,quantity:r,lockLengthMs:a,revokable:i=!1},h){let{tags:c=[]}=h||{};return this.process.send({tags:[...c,{name:"Action",value:"Vaulted-Transfer"},{name:"Recipient",value:e},{name:"Quantity",value:r.toString()},{name:"Lock-Length",value:a.toString()},{name:"Revokable",value:`${i}`}],signer:this.signer})}async revokeVault({vaultId:e,recipient:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Revoke-Vault"},{name:"Vault-Id",value:e},{name:"Recipient",value:r}],signer:this.signer})}async createVault({lockLengthMs:e,quantity:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Create-Vault"},{name:"Lock-Length",value:e.toString()},{name:"Quantity",value:r.toString()}],signer:this.signer})}async extendVault({vaultId:e,extendLengthMs:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Extend-Vault"},{name:"Vault-Id",value:e},{name:"Extend-Length",value:r.toString()}],signer:this.signer})}async increaseVault({vaultId:e,quantity:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Increase-Vault"},{name:"Vault-Id",value:e},{name:"Quantity",value:r.toString()}],signer:this.signer})}async joinNetwork({operatorStake:e,allowDelegatedStaking:r,allowedDelegates:a,delegateRewardShareRatio:i,fqdn:h,label:c,minDelegatedStake:p,note:b,port:g,properties:y,protocol:M,autoStake:x,observerAddress:E},A){let{tags:I=[]}=A||{},P=[...I,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:e.valueOf().toString()},{name:"Allow-Delegated-Staking",value:r?.toString()},{name:"Allowed-Delegates",value:a?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:i?.toString()},{name:"FQDN",value:h},{name:"Label",value:c},{name:"Min-Delegated-Stake",value:p?.valueOf().toString()},{name:"Note",value:b},{name:"Port",value:g?.toString()},{name:"Properties",value:y},{name:"Protocol",value:M},{name:"Auto-Stake",value:x?.toString()},{name:"Observer-Address",value:E}];return this.process.send({signer:this.signer,tags:Sn(P)})}async leaveNetwork(e){let{tags:r=[]}=e||{};return this.process.send({signer:this.signer,tags:[...r,{name:"Action",value:"Leave-Network"}]})}async updateGatewaySettings({allowDelegatedStaking:e,allowedDelegates:r,delegateRewardShareRatio:a,fqdn:i,label:h,minDelegatedStake:c,note:p,port:b,properties:g,protocol:y,autoStake:M,observerAddress:x},E){let{tags:A=[]}=E||{},I=[...A,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:h},{name:"Note",value:p},{name:"FQDN",value:i},{name:"Port",value:b?.toString()},{name:"Properties",value:g},{name:"Protocol",value:y},{name:"Observer-Address",value:x},{name:"Allow-Delegated-Staking",value:e?.toString()},{name:"Allowed-Delegates",value:r?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:a?.toString()},{name:"Min-Delegated-Stake",value:c?.valueOf().toString()},{name:"Auto-Stake",value:M?.toString()}];return this.process.send({signer:this.signer,tags:Sn(I)})}async delegateStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:e.target},{name:"Quantity",value:e.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Decrease-Delegate-Stake"},{name:"Target",value:e.target},{name:"Quantity",value:e.decreaseQty.valueOf().toString()},{name:"Instant",value:`${e.instant||!1}`}]})}async instantWithdrawal(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Instant-Withdrawal"},{name:"Vault-Id",value:e.vaultId},{name:"Address",value:e.gatewayAddress}];return this.process.send({signer:this.signer,tags:Sn(i)})}async increaseOperatorStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:e.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:e.decreaseQty.valueOf().toString()},{name:"Instant",value:`${e.instant||!1}`}]})}async saveObservations(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:e.reportTxId},{name:"Failed-Gateways",value:e.failedGateways.join(",")}]})}async buyRecord(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Buy-Name"},{name:"Name",value:e.name},{name:"Years",value:e.years?.toString()??"1"},{name:"Process-Id",value:e.processId},{name:"Purchase-Type",value:e.type||"lease"},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Sn(i)})}async upgradeRecord(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Upgrade-Name"},{name:"Name",value:e.name},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Sn(i)})}async extendLease(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Extend-Lease"},{name:"Name",value:e.name},{name:"Years",value:e.years.toString()},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Sn(i)})}async increaseUndernameLimit(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Increase-Undername-Limit"},{name:"Name",value:e.name},{name:"Quantity",value:e.increaseCount.toString()},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Sn(i)})}async cancelWithdrawal(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Cancel-Withdrawal"},{name:"Vault-Id",value:e.vaultId},{name:"Address",value:e.gatewayAddress}];return this.process.send({signer:this.signer,tags:Sn(i)})}async requestPrimaryName(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Request-Primary-Name"},{name:"Name",value:e.name}];return this.process.send({signer:this.signer,tags:Sn(i)})}async redelegateStake(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Redelegate-Stake"},{name:"Target",value:e.target},{name:"Source",value:e.source},{name:"Quantity",value:e.stakeQty.valueOf().toString()},{name:"Vault-Id",value:e.vaultId}];return this.process.send({signer:this.signer,tags:Sn(i)})}};async function l3t({signer:t,module:e=oQ,ao:r=Sl(),scheduler:a=uQ,state:i,antRegistryId:h=$8,logger:c=Wu.default,authority:p=fQ}){let b=await r.spawn({module:e,scheduler:a,signer:t,data:i?JSON.stringify(i):void 0,tags:[{name:"Authority",value:p},{name:"ANT-Registry-Id",value:h}]});return c.debug("Spawned ANT",{processId:b,module:e,scheduler:a}),b}async function d3t({signer:t,processId:e,luaCodeTxId:r=sQ,ao:a=Sl(),logger:i=Wu.default,arweave:h=N4}){let c=new za({processId:e,ao:a,logger:i}),{api:{host:p,port:b,protocol:g}}=h.getConfig(),y=await fetch(`${g}://${p}:${b}/${r}`).then(x=>x.text()),{id:M}=await c.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:r}],data:y,signer:t});return i.debug("Evolved ANT",{processId:e,luaCodeTxId:r,evalMsgId:M}),M}function sUe(t){let e=Qt.object({name:Qt.string(),value:Qt.union([Qt.string(),Qt.number()])}),r=Qt.function().args(Qt.object({data:Qt.union([Qt.string(),Qt.instanceof(Me)]),tags:Qt.array(e).optional(),target:Qt.string().optional(),anchor:Qt.string().optional()})).returns(Qt.promise(Qt.object({id:Qt.string(),raw:Qt.instanceof(ArrayBuffer)})));try{return r.parse(t),!0}catch{return!1}}function pv(t){return sUe(t)?t:"publicKey"in t?async({data:r,tags:a,target:i,anchor:h})=>{if(t.publicKey===void 0&&"setPublicKey"in t&&typeof t.setPublicKey=="function"&&await t.setPublicKey(),t instanceof ul){let b=await t.signer.signDataItem({data:r,tags:a,target:i,anchor:h}),g=new v1(Me.from(b));return{id:await g.id,raw:await g.getRaw()}}let c=Rg(r,t,{tags:a,target:i,anchor:h});return c.sign(t).then(async()=>({id:await c.id,raw:await c.getRaw()}))}:xte(t)}var fUe="-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI";function p3t({owner:t,targetId:e,ttlSeconds:r=3600,keywords:a=[],controllers:i=[],description:h="",ticker:c="aos",name:p="ANT"}){return{ticker:c,name:p,description:h,keywords:a,owner:t,controllers:[t,...i],balances:{[t]:1},records:{"@":{transactionId:e??fUe.toString(),ttlSeconds:r}}}}function rue(t){return Qt.object({startTimestamp:Qt.number(),startHeight:Qt.number(),distributions:Qt.any(),endTimestamp:Qt.number(),prescribedObservers:Qt.any(),prescribedNames:Qt.array(Qt.string()),observations:Qt.any(),epochIndex:Qt.number()}).parse(t)}function vP(t){let r=t.Error??t.Messages?.[0]?.Tags?.find(a=>a.name==="Error")?.value;if(r!==void 0){let a=r.match(/\[string "aos"]:(\d+):\s*(.+)/);if(a){let[,i,h]=a;return`${tue(h).trim()} (line ${i.trim()})`.trim()}return tue(r)}}function tue(t){let e="\x1B";return t.replace(new RegExp(`${e}[\\[\\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]`,"g"),"").trim()}var iue=t=>D8.test(t);function _3t(t){return t!==void 0&&!isNaN(parseInt(t.toString()))}var Sn=t=>t.filter(e=>e.value!==void 0&&e.value!==""),Ha=t=>{let e=[{name:"Cursor",value:t?.cursor?.toString()},{name:"Limit",value:t?.limit?.toString()},{name:"Sort-By",value:t?.sortBy?.toString()},{name:"Sort-Order",value:t?.sortOrder?.toString()}];return Sn(e)},gv=async({arweave:t,epochIndex:e,processId:r=Lh,retries:a=3,gqlUrl:i="https://arweave-search.goldsky.com/graphql"})=>{let h=uUe({epochIndex:e,processId:r});for(let c=0;c<a;c++)try{let p=await fetch(i,{method:"POST",body:h,headers:{"Content-Type":"application/json"}}).then(y=>y.json());if(p?.data?.transactions?.edges?.length===0)return;let b=p.data.transactions.edges[0].node.id,g=await t.api.get(b);return rue(g.data)}catch(p){if(c===a-1)throw p;await new Promise(b=>setTimeout(b,Math.pow(2,c)*1e3))}},uUe=({epochIndex:t,processId:e=Lh,authorities:r=["fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY"]})=>JSON.stringify({query:`
|
|
190
190
|
query {
|
|
191
191
|
transactions(
|
|
192
192
|
tags: [
|
package/lib/cjs/common/io.js
CHANGED
|
@@ -67,11 +67,11 @@ class ARIOReadable {
|
|
|
67
67
|
async computeEpochIndex(params) {
|
|
68
68
|
const epochIndex = params?.epochIndex;
|
|
69
69
|
if (epochIndex !== undefined) {
|
|
70
|
-
return epochIndex
|
|
70
|
+
return epochIndex;
|
|
71
71
|
}
|
|
72
72
|
const timestamp = params?.timestamp;
|
|
73
73
|
if (timestamp !== undefined) {
|
|
74
|
-
return
|
|
74
|
+
return this.computeEpochIndexForTimestamp(timestamp);
|
|
75
75
|
}
|
|
76
76
|
return undefined;
|
|
77
77
|
}
|
|
@@ -81,12 +81,13 @@ class ARIOReadable {
|
|
|
81
81
|
}));
|
|
82
82
|
}
|
|
83
83
|
async getEpoch(epoch) {
|
|
84
|
-
const epochIndex = await this.computeEpochIndex(epoch);
|
|
85
84
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
86
|
-
|
|
85
|
+
const requestedEpochIndex = await this.computeEpochIndex(epoch);
|
|
86
|
+
if (requestedEpochIndex !== undefined &&
|
|
87
|
+
requestedEpochIndex < currentIndex) {
|
|
87
88
|
const epochData = await (0, arweave_js_1.getEpochDataFromGql)({
|
|
88
89
|
arweave: this.arweave,
|
|
89
|
-
epochIndex:
|
|
90
|
+
epochIndex: requestedEpochIndex,
|
|
90
91
|
processId: this.process.processId,
|
|
91
92
|
});
|
|
92
93
|
return epochData;
|
|
@@ -94,7 +95,10 @@ class ARIOReadable {
|
|
|
94
95
|
// go to the process epoch and fetch the epoch data
|
|
95
96
|
const allTags = [
|
|
96
97
|
{ name: 'Action', value: 'Epoch' },
|
|
97
|
-
{
|
|
98
|
+
{
|
|
99
|
+
name: 'Epoch-Index',
|
|
100
|
+
value: currentIndex.toString(),
|
|
101
|
+
},
|
|
98
102
|
];
|
|
99
103
|
return this.process.read({
|
|
100
104
|
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
@@ -205,38 +209,46 @@ class ARIOReadable {
|
|
|
205
209
|
});
|
|
206
210
|
}
|
|
207
211
|
async getPrescribedObservers(epoch) {
|
|
208
|
-
const
|
|
212
|
+
const requestedEpochIndex = await this.computeEpochIndex(epoch);
|
|
209
213
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
210
|
-
if (
|
|
214
|
+
if (requestedEpochIndex !== undefined &&
|
|
215
|
+
requestedEpochIndex < currentIndex) {
|
|
211
216
|
const epochData = await (0, arweave_js_1.getEpochDataFromGql)({
|
|
212
217
|
arweave: this.arweave,
|
|
213
|
-
epochIndex:
|
|
218
|
+
epochIndex: requestedEpochIndex,
|
|
214
219
|
processId: this.process.processId,
|
|
215
220
|
});
|
|
216
221
|
return epochData?.prescribedObservers;
|
|
217
222
|
}
|
|
218
223
|
const allTags = [
|
|
219
224
|
{ name: 'Action', value: 'Epoch-Prescribed-Observers' },
|
|
220
|
-
{
|
|
225
|
+
{
|
|
226
|
+
name: 'Epoch-Index',
|
|
227
|
+
value: currentIndex.toString(),
|
|
228
|
+
},
|
|
221
229
|
];
|
|
222
230
|
return this.process.read({
|
|
223
231
|
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
224
232
|
});
|
|
225
233
|
}
|
|
226
234
|
async getPrescribedNames(epoch) {
|
|
227
|
-
const
|
|
235
|
+
const requestedEpochIndex = await this.computeEpochIndex(epoch);
|
|
228
236
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
229
|
-
if (
|
|
237
|
+
if (requestedEpochIndex !== undefined &&
|
|
238
|
+
requestedEpochIndex < currentIndex) {
|
|
230
239
|
const epochData = await (0, arweave_js_1.getEpochDataFromGql)({
|
|
231
240
|
arweave: this.arweave,
|
|
232
|
-
epochIndex:
|
|
241
|
+
epochIndex: requestedEpochIndex,
|
|
233
242
|
processId: this.process.processId,
|
|
234
243
|
});
|
|
235
244
|
return epochData?.prescribedNames;
|
|
236
245
|
}
|
|
237
246
|
const allTags = [
|
|
238
247
|
{ name: 'Action', value: 'Epoch-Prescribed-Names' },
|
|
239
|
-
{
|
|
248
|
+
{
|
|
249
|
+
name: 'Epoch-Index',
|
|
250
|
+
value: currentIndex.toString(),
|
|
251
|
+
},
|
|
240
252
|
];
|
|
241
253
|
return this.process.read({
|
|
242
254
|
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
@@ -244,12 +256,13 @@ class ARIOReadable {
|
|
|
244
256
|
}
|
|
245
257
|
// we need to find the epoch index for the epoch that is currently being distributed and fetch it from gql
|
|
246
258
|
async getObservations(epoch) {
|
|
247
|
-
const
|
|
259
|
+
const requestedEpochIndex = await this.computeEpochIndex(epoch);
|
|
248
260
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
249
|
-
if (
|
|
261
|
+
if (requestedEpochIndex !== undefined &&
|
|
262
|
+
requestedEpochIndex < currentIndex) {
|
|
250
263
|
const epochData = await (0, arweave_js_1.getEpochDataFromGql)({
|
|
251
264
|
arweave: this.arweave,
|
|
252
|
-
epochIndex:
|
|
265
|
+
epochIndex: requestedEpochIndex,
|
|
253
266
|
processId: this.process.processId,
|
|
254
267
|
});
|
|
255
268
|
return epochData?.observations;
|
|
@@ -257,19 +270,23 @@ class ARIOReadable {
|
|
|
257
270
|
// go to the process epoch and fetch the observations
|
|
258
271
|
const allTags = [
|
|
259
272
|
{ name: 'Action', value: 'Epoch-Observations' },
|
|
260
|
-
{
|
|
273
|
+
{
|
|
274
|
+
name: 'Epoch-Index',
|
|
275
|
+
value: currentIndex.toString(),
|
|
276
|
+
},
|
|
261
277
|
];
|
|
262
278
|
return this.process.read({
|
|
263
279
|
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
264
280
|
});
|
|
265
281
|
}
|
|
266
282
|
async getDistributions(epoch) {
|
|
267
|
-
const
|
|
283
|
+
const requestedEpochIndex = await this.computeEpochIndex(epoch);
|
|
268
284
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
269
|
-
if (
|
|
285
|
+
if (requestedEpochIndex !== undefined &&
|
|
286
|
+
requestedEpochIndex < currentIndex) {
|
|
270
287
|
const epochData = await (0, arweave_js_1.getEpochDataFromGql)({
|
|
271
288
|
arweave: this.arweave,
|
|
272
|
-
epochIndex:
|
|
289
|
+
epochIndex: requestedEpochIndex,
|
|
273
290
|
processId: this.process.processId,
|
|
274
291
|
});
|
|
275
292
|
return epochData?.distributions;
|
|
@@ -277,7 +294,10 @@ class ARIOReadable {
|
|
|
277
294
|
// go to the process epoch and fetch the distributions
|
|
278
295
|
const allTags = [
|
|
279
296
|
{ name: 'Action', value: 'Epoch-Distributions' },
|
|
280
|
-
{
|
|
297
|
+
{
|
|
298
|
+
name: 'Epoch-Index',
|
|
299
|
+
value: currentIndex.toString(),
|
|
300
|
+
},
|
|
281
301
|
];
|
|
282
302
|
return this.process.read({
|
|
283
303
|
tags: (0, arweave_js_1.pruneTags)(allTags),
|
package/lib/cjs/utils/ao.js
CHANGED
|
@@ -171,7 +171,6 @@ function parseAoEpochData(value) {
|
|
|
171
171
|
prescribedObservers: zod_1.z.any(),
|
|
172
172
|
prescribedNames: zod_1.z.array(zod_1.z.string()),
|
|
173
173
|
observations: zod_1.z.any(),
|
|
174
|
-
distributionTimestamp: zod_1.z.number(),
|
|
175
174
|
epochIndex: zod_1.z.number(),
|
|
176
175
|
});
|
|
177
176
|
return epochDataSchema.parse(value);
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/common/io.js
CHANGED
|
@@ -63,11 +63,11 @@ export class ARIOReadable {
|
|
|
63
63
|
async computeEpochIndex(params) {
|
|
64
64
|
const epochIndex = params?.epochIndex;
|
|
65
65
|
if (epochIndex !== undefined) {
|
|
66
|
-
return epochIndex
|
|
66
|
+
return epochIndex;
|
|
67
67
|
}
|
|
68
68
|
const timestamp = params?.timestamp;
|
|
69
69
|
if (timestamp !== undefined) {
|
|
70
|
-
return
|
|
70
|
+
return this.computeEpochIndexForTimestamp(timestamp);
|
|
71
71
|
}
|
|
72
72
|
return undefined;
|
|
73
73
|
}
|
|
@@ -77,12 +77,13 @@ export class ARIOReadable {
|
|
|
77
77
|
}));
|
|
78
78
|
}
|
|
79
79
|
async getEpoch(epoch) {
|
|
80
|
-
const epochIndex = await this.computeEpochIndex(epoch);
|
|
81
80
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
82
|
-
|
|
81
|
+
const requestedEpochIndex = await this.computeEpochIndex(epoch);
|
|
82
|
+
if (requestedEpochIndex !== undefined &&
|
|
83
|
+
requestedEpochIndex < currentIndex) {
|
|
83
84
|
const epochData = await getEpochDataFromGql({
|
|
84
85
|
arweave: this.arweave,
|
|
85
|
-
epochIndex:
|
|
86
|
+
epochIndex: requestedEpochIndex,
|
|
86
87
|
processId: this.process.processId,
|
|
87
88
|
});
|
|
88
89
|
return epochData;
|
|
@@ -90,7 +91,10 @@ export class ARIOReadable {
|
|
|
90
91
|
// go to the process epoch and fetch the epoch data
|
|
91
92
|
const allTags = [
|
|
92
93
|
{ name: 'Action', value: 'Epoch' },
|
|
93
|
-
{
|
|
94
|
+
{
|
|
95
|
+
name: 'Epoch-Index',
|
|
96
|
+
value: currentIndex.toString(),
|
|
97
|
+
},
|
|
94
98
|
];
|
|
95
99
|
return this.process.read({
|
|
96
100
|
tags: pruneTags(allTags),
|
|
@@ -201,38 +205,46 @@ export class ARIOReadable {
|
|
|
201
205
|
});
|
|
202
206
|
}
|
|
203
207
|
async getPrescribedObservers(epoch) {
|
|
204
|
-
const
|
|
208
|
+
const requestedEpochIndex = await this.computeEpochIndex(epoch);
|
|
205
209
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
206
|
-
if (
|
|
210
|
+
if (requestedEpochIndex !== undefined &&
|
|
211
|
+
requestedEpochIndex < currentIndex) {
|
|
207
212
|
const epochData = await getEpochDataFromGql({
|
|
208
213
|
arweave: this.arweave,
|
|
209
|
-
epochIndex:
|
|
214
|
+
epochIndex: requestedEpochIndex,
|
|
210
215
|
processId: this.process.processId,
|
|
211
216
|
});
|
|
212
217
|
return epochData?.prescribedObservers;
|
|
213
218
|
}
|
|
214
219
|
const allTags = [
|
|
215
220
|
{ name: 'Action', value: 'Epoch-Prescribed-Observers' },
|
|
216
|
-
{
|
|
221
|
+
{
|
|
222
|
+
name: 'Epoch-Index',
|
|
223
|
+
value: currentIndex.toString(),
|
|
224
|
+
},
|
|
217
225
|
];
|
|
218
226
|
return this.process.read({
|
|
219
227
|
tags: pruneTags(allTags),
|
|
220
228
|
});
|
|
221
229
|
}
|
|
222
230
|
async getPrescribedNames(epoch) {
|
|
223
|
-
const
|
|
231
|
+
const requestedEpochIndex = await this.computeEpochIndex(epoch);
|
|
224
232
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
225
|
-
if (
|
|
233
|
+
if (requestedEpochIndex !== undefined &&
|
|
234
|
+
requestedEpochIndex < currentIndex) {
|
|
226
235
|
const epochData = await getEpochDataFromGql({
|
|
227
236
|
arweave: this.arweave,
|
|
228
|
-
epochIndex:
|
|
237
|
+
epochIndex: requestedEpochIndex,
|
|
229
238
|
processId: this.process.processId,
|
|
230
239
|
});
|
|
231
240
|
return epochData?.prescribedNames;
|
|
232
241
|
}
|
|
233
242
|
const allTags = [
|
|
234
243
|
{ name: 'Action', value: 'Epoch-Prescribed-Names' },
|
|
235
|
-
{
|
|
244
|
+
{
|
|
245
|
+
name: 'Epoch-Index',
|
|
246
|
+
value: currentIndex.toString(),
|
|
247
|
+
},
|
|
236
248
|
];
|
|
237
249
|
return this.process.read({
|
|
238
250
|
tags: pruneTags(allTags),
|
|
@@ -240,12 +252,13 @@ export class ARIOReadable {
|
|
|
240
252
|
}
|
|
241
253
|
// we need to find the epoch index for the epoch that is currently being distributed and fetch it from gql
|
|
242
254
|
async getObservations(epoch) {
|
|
243
|
-
const
|
|
255
|
+
const requestedEpochIndex = await this.computeEpochIndex(epoch);
|
|
244
256
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
245
|
-
if (
|
|
257
|
+
if (requestedEpochIndex !== undefined &&
|
|
258
|
+
requestedEpochIndex < currentIndex) {
|
|
246
259
|
const epochData = await getEpochDataFromGql({
|
|
247
260
|
arweave: this.arweave,
|
|
248
|
-
epochIndex:
|
|
261
|
+
epochIndex: requestedEpochIndex,
|
|
249
262
|
processId: this.process.processId,
|
|
250
263
|
});
|
|
251
264
|
return epochData?.observations;
|
|
@@ -253,19 +266,23 @@ export class ARIOReadable {
|
|
|
253
266
|
// go to the process epoch and fetch the observations
|
|
254
267
|
const allTags = [
|
|
255
268
|
{ name: 'Action', value: 'Epoch-Observations' },
|
|
256
|
-
{
|
|
269
|
+
{
|
|
270
|
+
name: 'Epoch-Index',
|
|
271
|
+
value: currentIndex.toString(),
|
|
272
|
+
},
|
|
257
273
|
];
|
|
258
274
|
return this.process.read({
|
|
259
275
|
tags: pruneTags(allTags),
|
|
260
276
|
});
|
|
261
277
|
}
|
|
262
278
|
async getDistributions(epoch) {
|
|
263
|
-
const
|
|
279
|
+
const requestedEpochIndex = await this.computeEpochIndex(epoch);
|
|
264
280
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
265
|
-
if (
|
|
281
|
+
if (requestedEpochIndex !== undefined &&
|
|
282
|
+
requestedEpochIndex < currentIndex) {
|
|
266
283
|
const epochData = await getEpochDataFromGql({
|
|
267
284
|
arweave: this.arweave,
|
|
268
|
-
epochIndex:
|
|
285
|
+
epochIndex: requestedEpochIndex,
|
|
269
286
|
processId: this.process.processId,
|
|
270
287
|
});
|
|
271
288
|
return epochData?.distributions;
|
|
@@ -273,7 +290,10 @@ export class ARIOReadable {
|
|
|
273
290
|
// go to the process epoch and fetch the distributions
|
|
274
291
|
const allTags = [
|
|
275
292
|
{ name: 'Action', value: 'Epoch-Distributions' },
|
|
276
|
-
{
|
|
293
|
+
{
|
|
294
|
+
name: 'Epoch-Index',
|
|
295
|
+
value: currentIndex.toString(),
|
|
296
|
+
},
|
|
277
297
|
];
|
|
278
298
|
return this.process.read({
|
|
279
299
|
tags: pruneTags(allTags),
|
package/lib/esm/utils/ao.js
CHANGED
|
@@ -163,7 +163,6 @@ export function parseAoEpochData(value) {
|
|
|
163
163
|
prescribedObservers: z.any(),
|
|
164
164
|
prescribedNames: z.array(z.string()),
|
|
165
165
|
observations: z.any(),
|
|
166
|
-
distributionTimestamp: z.number(),
|
|
167
166
|
epochIndex: z.number(),
|
|
168
167
|
});
|
|
169
168
|
return epochDataSchema.parse(value);
|
package/lib/esm/version.js
CHANGED
package/lib/types/version.d.ts
CHANGED