@ar.io/sdk 1.2.0-alpha.13 → 1.2.0-alpha.14
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 +2 -2
- package/lib/cjs/common/io.js +4 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/io.js +4 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -218,7 +218,7 @@ ${C}`),A.pop(),`{${W}}`}case"number":return isFinite(T)?String(T):t?t(T):"null";
|
|
|
218
218
|
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let h=new this(t);return r.forEach(o=>h.set(o)),h}static accessor(t){let h=(this[HL]=this[HL]={accessors:{}}).accessors,o=this.prototype;function l(c){let p=o2(c);h[p]||(wht(o,c),h[p]=!0)}return Ke.isArray(t)?t.forEach(l):l(t),this}};Cd.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Ke.reduceDescriptors(Cd.prototype,({value:i},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>i,set(h){this[r]=h}}});Ke.freezeMethods(Cd);var Zn=Cd;function a2(i,t){let r=this||Od,h=t||r,o=Zn.from(h.headers),l=h.data;return Ke.forEach(i,function(p){l=p.call(r,l,o.normalize(),t?t.status:void 0)}),o.normalize(),l}Tt();Rt();xt();function s2(i){return!!(i&&i.__CANCEL__)}Tt();Rt();xt();function GL(i,t,r){Nr.call(this,i??"canceled",Nr.ERR_CANCELED,t,r),this.name="CanceledError"}Ke.inherits(GL,Nr,{__CANCEL__:!0});var of=GL;Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();function h2(i,t,r){let h=r.config.validateStatus;!r.status||!h||h(r.status)?i(r):t(new Nr("Request failed with status code "+r.status,[Nr.ERR_BAD_REQUEST,Nr.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}Tt();Rt();xt();function e7(i){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(i);return t&&t[1]||""}Tt();Rt();xt();Tt();Rt();xt();function _ht(i,t){i=i||10;let r=new Array(i),h=new Array(i),o=0,l=0,c;return t=t!==void 0?t:1e3,function(w){let m=Date.now(),y=h[l];c||(c=m),r[o]=w,h[o]=m;let v=l,M=0;for(;v!==o;)M+=r[v++],v=v%i;if(o=(o+1)%i,o===l&&(l=(l+1)%i),m-c<t)return;let T=y&&m-y;return T?Math.round(M*1e3/T):void 0}}var VL=_ht;Tt();Rt();xt();function Mht(i,t){let r=0,h=1e3/t,o=null;return function(){let c=this===!0,p=Date.now();if(c||p-r>h)return o&&(clearTimeout(o),o=null),r=p,i.apply(null,arguments);o||(o=setTimeout(()=>(o=null,r=Date.now(),i.apply(null,arguments)),h-(p-r)))}}var ZL=Mht;var Pd=(i,t,r=3)=>{let h=0,o=VL(50,250);return ZL(l=>{let c=l.loaded,p=l.lengthComputable?l.total:void 0,w=c-h,m=o(w),y=c<=p;h=c;let v={loaded:c,total:p,progress:p?c/p:void 0,bytes:w,rate:m||void 0,estimated:m&&p&&y?(p-c)/m:void 0,event:l,lengthComputable:p!=null};v[t?"download":"upload"]=!0,i(v)},r)};Tt();Rt();xt();Tt();Rt();xt();var JL=fo.hasStandardBrowserEnv?function(){let t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),h;function o(l){let c=l;return t&&(r.setAttribute("href",c),c=r.href),r.setAttribute("href",c),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return h=o(window.location.href),function(c){let p=Ke.isString(c)?o(c):c;return p.protocol===h.protocol&&p.host===h.host}}():function(){return function(){return!0}}();Tt();Rt();xt();var XL=fo.hasStandardBrowserEnv?{write(i,t,r,h,o,l){let c=[i+"="+encodeURIComponent(t)];Ke.isNumber(r)&&c.push("expires="+new Date(r).toGMTString()),Ke.isString(h)&&c.push("path="+h),Ke.isString(o)&&c.push("domain="+o),l===!0&&c.push("secure"),document.cookie=c.join("; ")},read(i){let t=document.cookie.match(new RegExp("(^|;\\s*)("+i+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(i){this.write(i,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};Tt();Rt();xt();Tt();Rt();xt();function r7(i){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(i)}Tt();Rt();xt();function i7(i,t){return t?i.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):i}function f2(i,t){return i&&!r7(t)?i7(i,t):t}Tt();Rt();xt();var YL=i=>i instanceof Zn?{...i}:i;function ph(i,t){t=t||{};let r={};function h(m,y,v){return Ke.isPlainObject(m)&&Ke.isPlainObject(y)?Ke.merge.call({caseless:v},m,y):Ke.isPlainObject(y)?Ke.merge({},y):Ke.isArray(y)?y.slice():y}function o(m,y,v){if(Ke.isUndefined(y)){if(!Ke.isUndefined(m))return h(void 0,m,v)}else return h(m,y,v)}function l(m,y){if(!Ke.isUndefined(y))return h(void 0,y)}function c(m,y){if(Ke.isUndefined(y)){if(!Ke.isUndefined(m))return h(void 0,m)}else return h(void 0,y)}function p(m,y,v){if(v in t)return h(m,y);if(v in i)return h(void 0,m)}let w={url:l,method:l,data:l,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutMessage:c,withCredentials:c,withXSRFToken:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,beforeRedirect:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,responseEncoding:c,validateStatus:p,headers:(m,y)=>o(YL(m),YL(y),!0)};return Ke.forEach(Object.keys(Object.assign({},i,t)),function(y){let v=w[y]||o,M=v(i[y],t[y],y);Ke.isUndefined(M)&&v!==p||(r[y]=M)}),r}var k6=i=>{let t=ph({},i),{data:r,withXSRFToken:h,xsrfHeaderName:o,xsrfCookieName:l,headers:c,auth:p}=t;t.headers=c=Zn.from(c),t.url=n2(f2(t.baseURL,t.url),i.params,i.paramsSerializer),p&&c.set("Authorization","Basic "+btoa((p.username||"")+":"+(p.password?unescape(encodeURIComponent(p.password)):"")));let w;if(Ke.isFormData(r)){if(fo.hasStandardBrowserEnv||fo.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if((w=c.getContentType())!==!1){let[m,...y]=w?w.split(";").map(v=>v.trim()).filter(Boolean):[];c.setContentType([m||"multipart/form-data",...y].join("; "))}}if(fo.hasStandardBrowserEnv&&(h&&Ke.isFunction(h)&&(h=h(t)),h||h!==!1&&JL(t.url))){let m=o&&l&&XL.read(l);m&&c.set(o,m)}return t};var Sht=typeof XMLHttpRequest<"u",QL=Sht&&function(i){return new Promise(function(r,h){let o=k6(i),l=o.data,c=Zn.from(o.headers).normalize(),{responseType:p}=o,w;function m(){o.cancelToken&&o.cancelToken.unsubscribe(w),o.signal&&o.signal.removeEventListener("abort",w)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function v(){if(!y)return;let T=Zn.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),R={data:!p||p==="text"||p==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:T,config:i,request:y};h2(function(C){r(C),m()},function(C){h(C),m()},R),y=null}"onloadend"in y?y.onloadend=v:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(v)},y.onabort=function(){y&&(h(new Nr("Request aborted",Nr.ECONNABORTED,o,y)),y=null)},y.onerror=function(){h(new Nr("Network Error",Nr.ERR_NETWORK,o,y)),y=null},y.ontimeout=function(){let A=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",R=o.transitional||T6;o.timeoutErrorMessage&&(A=o.timeoutErrorMessage),h(new Nr(A,R.clarifyTimeoutError?Nr.ETIMEDOUT:Nr.ECONNABORTED,o,y)),y=null},l===void 0&&c.setContentType(null),"setRequestHeader"in y&&Ke.forEach(c.toJSON(),function(A,R){y.setRequestHeader(R,A)}),Ke.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),p&&p!=="json"&&(y.responseType=o.responseType),typeof o.onDownloadProgress=="function"&&y.addEventListener("progress",Pd(o.onDownloadProgress,!0)),typeof o.onUploadProgress=="function"&&y.upload&&y.upload.addEventListener("progress",Pd(o.onUploadProgress)),(o.cancelToken||o.signal)&&(w=T=>{y&&(h(!T||T.type?new of(null,i,y):T),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(w),o.signal&&(o.signal.aborted?w():o.signal.addEventListener("abort",w)));let M=e7(o.url);if(M&&fo.protocols.indexOf(M)===-1){h(new Nr("Unsupported protocol "+M+":",Nr.ERR_BAD_REQUEST,i));return}y.send(l||null)})};Tt();Rt();xt();Tt();Rt();xt();var Eht=(i,t)=>{let r=new AbortController,h,o=function(w){if(!h){h=!0,c();let m=w instanceof Error?w:this.reason;r.abort(m instanceof Nr?m:new of(m instanceof Error?m.message:m))}},l=t&&setTimeout(()=>{o(new Nr(`timeout ${t} of ms exceeded`,Nr.ETIMEDOUT))},t),c=()=>{i&&(l&&clearTimeout(l),l=null,i.forEach(w=>{w&&(w.removeEventListener?w.removeEventListener("abort",o):w.unsubscribe(o))}),i=null)};i.forEach(w=>w&&w.addEventListener&&w.addEventListener("abort",o));let{signal:p}=r;return p.unsubscribe=c,[p,()=>{l&&clearTimeout(l),l=null}]},tD=Eht;Tt();Rt();xt();var Aht=function*(i,t){let r=i.byteLength;if(!t||r<t){yield i;return}let h=0,o;for(;h<r;)o=h+t,yield i.slice(h,o),h=o},Tht=async function*(i,t,r){for await(let h of i)yield*Aht(ArrayBuffer.isView(h)?h:await r(String(h)),t)},n7=(i,t,r,h,o)=>{let l=Tht(i,t,o),c=0;return new ReadableStream({type:"bytes",async pull(p){let{done:w,value:m}=await l.next();if(w){p.close(),h();return}let y=m.byteLength;r&&r(c+=y),p.enqueue(new Uint8Array(m))},cancel(p){return h(p),l.return()}},{highWaterMark:2})};var eD=(i,t)=>{let r=i!=null;return h=>setTimeout(()=>t({lengthComputable:r,total:i,loaded:h}))},B6=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",iD=B6&&typeof ReadableStream=="function",o7=B6&&(typeof TextEncoder=="function"?(i=>t=>i.encode(t))(new TextEncoder):async i=>new Uint8Array(await new Response(i).arrayBuffer())),xht=iD&&(()=>{let i=!1,t=new Request(fo.origin,{body:new ReadableStream,method:"POST",get duplex(){return i=!0,"half"}}).headers.has("Content-Type");return i&&!t})(),rD=64*1024,a7=iD&&!!(()=>{try{return Ke.isReadableStream(new Response("").body)}catch{}})(),I6={stream:a7&&(i=>i.body)};B6&&(i=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!I6[t]&&(I6[t]=Ke.isFunction(i[t])?r=>r[t]():(r,h)=>{throw new Nr(`Response type '${t}' is not supported`,Nr.ERR_NOT_SUPPORT,h)})})})(new Response);var Rht=async i=>{if(i==null)return 0;if(Ke.isBlob(i))return i.size;if(Ke.isSpecCompliantForm(i))return(await new Request(i).arrayBuffer()).byteLength;if(Ke.isArrayBufferView(i))return i.byteLength;if(Ke.isURLSearchParams(i)&&(i=i+""),Ke.isString(i))return(await o7(i)).byteLength},kht=async(i,t)=>{let r=Ke.toFiniteNumber(i.getContentLength());return r??Rht(t)},nD=B6&&(async i=>{let{url:t,method:r,data:h,signal:o,cancelToken:l,timeout:c,onDownloadProgress:p,onUploadProgress:w,responseType:m,headers:y,withCredentials:v="same-origin",fetchOptions:M}=k6(i);m=m?(m+"").toLowerCase():"text";let[T,A]=o||l||c?tD([o,l],c):[],R,B,C=()=>{!R&&setTimeout(()=>{T&&T.unsubscribe()}),R=!0},P;try{if(w&&xht&&r!=="get"&&r!=="head"&&(P=await kht(y,h))!==0){let J=new Request(t,{method:"POST",body:h,duplex:"half"}),F;Ke.isFormData(h)&&(F=J.headers.get("content-type"))&&y.setContentType(F),J.body&&(h=n7(J.body,rD,eD(P,Pd(w)),null,o7))}Ke.isString(v)||(v=v?"cors":"omit"),B=new Request(t,{...M,signal:T,method:r.toUpperCase(),headers:y.normalize().toJSON(),body:h,duplex:"half",withCredentials:v});let N=await fetch(B),q=a7&&(m==="stream"||m==="response");if(a7&&(p||q)){let J={};["status","statusText","headers"].forEach(H=>{J[H]=N[H]});let F=Ke.toFiniteNumber(N.headers.get("content-length"));N=new Response(n7(N.body,rD,p&&eD(F,Pd(p,!0)),q&&C,o7),J)}m=m||"text";let W=await I6[Ke.findKey(I6,m)||"text"](N,i);return!q&&C(),A&&A(),await new Promise((J,F)=>{h2(J,F,{data:W,headers:Zn.from(N.headers),status:N.status,statusText:N.statusText,config:i,request:B})})}catch(N){throw C(),N&&N.name==="TypeError"&&/fetch/i.test(N.message)?Object.assign(new Nr("Network Error",Nr.ERR_NETWORK,i,B),{cause:N.cause||N}):Nr.from(N,N&&N.code,i,B)}});var s7={http:E6,xhr:QL,fetch:nD};Ke.forEach(s7,(i,t)=>{if(i){try{Object.defineProperty(i,"name",{value:t})}catch{}Object.defineProperty(i,"adapterName",{value:t})}});var oD=i=>`- ${i}`,Iht=i=>Ke.isFunction(i)||i===null||i===!1,O6={getAdapter:i=>{i=Ke.isArray(i)?i:[i];let{length:t}=i,r,h,o={};for(let l=0;l<t;l++){r=i[l];let c;if(h=r,!Iht(r)&&(h=s7[(c=String(r)).toLowerCase()],h===void 0))throw new Nr(`Unknown adapter '${c}'`);if(h)break;o[c||"#"+l]=h}if(!h){let l=Object.entries(o).map(([p,w])=>`adapter ${p} `+(w===!1?"is not supported by the environment":"is not available in the build")),c=t?l.length>1?`since :
|
|
219
219
|
`+l.map(oD).join(`
|
|
220
220
|
`):" "+oD(l[0]):"as no adapter specified";throw new Nr("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return h},adapters:s7};function h7(i){if(i.cancelToken&&i.cancelToken.throwIfRequested(),i.signal&&i.signal.aborted)throw new of(null,i)}function C6(i){return h7(i),i.headers=Zn.from(i.headers),i.data=a2.call(i,i.transformRequest),["post","put","patch"].indexOf(i.method)!==-1&&i.headers.setContentType("application/x-www-form-urlencoded",!1),O6.getAdapter(i.adapter||Od.adapter)(i).then(function(h){return h7(i),h.data=a2.call(i,i.transformResponse,h),h.headers=Zn.from(h.headers),h},function(h){return s2(h)||(h7(i),h&&h.response&&(h.response.data=a2.call(i,i.transformResponse,h.response),h.response.headers=Zn.from(h.response.headers))),Promise.reject(h)})}Tt();Rt();xt();Tt();Rt();xt();var P6="1.7.2";var f7={};["object","boolean","number","function","string","symbol"].forEach((i,t)=>{f7[i]=function(h){return typeof h===i||"a"+(t<1?"n ":" ")+i}});var aD={};f7.transitional=function(t,r,h){function o(l,c){return"[Axios v"+P6+"] Transitional option '"+l+"'"+c+(h?". "+h:"")}return(l,c,p)=>{if(t===!1)throw new Nr(o(c," has been removed"+(r?" in "+r:"")),Nr.ERR_DEPRECATED);return r&&!aD[c]&&(aD[c]=!0,console.warn(o(c," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(l,c,p):!0}};function Bht(i,t,r){if(typeof i!="object")throw new Nr("options must be an object",Nr.ERR_BAD_OPTION_VALUE);let h=Object.keys(i),o=h.length;for(;o-- >0;){let l=h[o],c=t[l];if(c){let p=i[l],w=p===void 0||c(p,l,i);if(w!==!0)throw new Nr("option "+l+" must be "+w,Nr.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Nr("Unknown option "+l,Nr.ERR_BAD_OPTION)}}var N6={assertOptions:Bht,validators:f7};var uc=N6.validators,Nd=class{constructor(t){this.defaults=t,this.interceptors={request:new Z5,response:new Z5}}async request(t,r){try{return await this._request(t,r)}catch(h){if(h instanceof Error){let o;Error.captureStackTrace?Error.captureStackTrace(o={}):o=new Error;let l=o.stack?o.stack.replace(/^.+\n/,""):"";try{h.stack?l&&!String(h.stack).endsWith(l.replace(/^.+\n.+\n/,""))&&(h.stack+=`
|
|
221
|
-
`+l):h.stack=l}catch{}}throw h}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ph(this.defaults,r);let{transitional:h,paramsSerializer:o,headers:l}=r;h!==void 0&&N6.assertOptions(h,{silentJSONParsing:uc.transitional(uc.boolean),forcedJSONParsing:uc.transitional(uc.boolean),clarifyTimeoutError:uc.transitional(uc.boolean)},!1),o!=null&&(Ke.isFunction(o)?r.paramsSerializer={serialize:o}:N6.assertOptions(o,{encode:uc.function,serialize:uc.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let c=l&&Ke.merge(l.common,l[r.method]);l&&Ke.forEach(["delete","get","head","post","put","patch","common"],A=>{delete l[A]}),r.headers=Zn.concat(c,l);let p=[],w=!0;this.interceptors.request.forEach(function(R){typeof R.runWhen=="function"&&R.runWhen(r)===!1||(w=w&&R.synchronous,p.unshift(R.fulfilled,R.rejected))});let m=[];this.interceptors.response.forEach(function(R){m.push(R.fulfilled,R.rejected)});let y,v=0,M;if(!w){let A=[C6.bind(this),void 0];for(A.unshift.apply(A,p),A.push.apply(A,m),M=A.length,y=Promise.resolve(r);v<M;)y=y.then(A[v++],A[v++]);return y}M=p.length;let T=r;for(v=0;v<M;){let A=p[v++],R=p[v++];try{T=A(T)}catch(B){R.call(this,B);break}}try{y=C6.call(this,T)}catch(A){return Promise.reject(A)}for(v=0,M=m.length;v<M;)y=y.then(m[v++],m[v++]);return y}getUri(t){t=ph(this.defaults,t);let r=f2(t.baseURL,t.url);return n2(r,t.params,t.paramsSerializer)}};Ke.forEach(["delete","get","head","options"],function(t){Nd.prototype[t]=function(r,h){return this.request(ph(h||{},{method:t,url:r,data:(h||{}).data}))}});Ke.forEach(["post","put","patch"],function(t){function r(h){return function(l,c,p){return this.request(ph(p||{},{method:t,headers:h?{"Content-Type":"multipart/form-data"}:{},url:l,data:c}))}}Nd.prototype[t]=r(),Nd.prototype[t+"Form"]=r(!0)});var u2=Nd;Tt();Rt();xt();var u7=class i{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(l){r=l});let h=this;this.promise.then(o=>{if(!h._listeners)return;let l=h._listeners.length;for(;l-- >0;)h._listeners[l](o);h._listeners=null}),this.promise.then=o=>{let l,c=new Promise(p=>{h.subscribe(p),l=p}).then(o);return c.cancel=function(){h.unsubscribe(l)},c},t(function(l,c,p){h.reason||(h.reason=new of(l,c,p),r(h.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new i(function(o){t=o}),cancel:t}}},sD=u7;Tt();Rt();xt();function c7(i){return function(r){return i.apply(null,r)}}Tt();Rt();xt();function l7(i){return Ke.isObject(i)&&i.isAxiosError===!0}Tt();Rt();xt();var d7={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(d7).forEach(([i,t])=>{d7[t]=i});var hD=d7;function fD(i){let t=new u2(i),r=e2(u2.prototype.request,t);return Ke.extend(r,u2.prototype,t,{allOwnKeys:!0}),Ke.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return fD(ph(i,o))},r}var Wn=fD(Od);Wn.Axios=u2;Wn.CanceledError=of;Wn.CancelToken=sD;Wn.isCancel=s2;Wn.VERSION=P6;Wn.toFormData=fc;Wn.AxiosError=Nr;Wn.Cancel=Wn.CanceledError;Wn.all=function(t){return Promise.all(t)};Wn.spread=c7;Wn.isAxiosError=l7;Wn.mergeConfig=ph;Wn.AxiosHeaders=Zn;Wn.formToJSON=i=>x6(Ke.isHTMLForm(i)?new FormData(i):i);Wn.getAdapter=O6.getAdapter;Wn.HttpStatusCode=hD;Wn.default=Wn;var L6=Wn;var{Axios:nLt,AxiosError:oLt,CanceledError:aLt,isCancel:sLt,CancelToken:hLt,VERSION:fLt,all:uLt,Cancel:cLt,isAxiosError:lLt,spread:dLt,toFormData:pLt,AxiosHeaders:gLt,HttpStatusCode:mLt,formToJSON:vLt,getAdapter:yLt,mergeConfig:bLt}=L6;Tt();Rt();xt();var dD=Sl(cD(),1),p7="axios-retry";function pD(i){let t=["ERR_CANCELED","ECONNABORTED"];return i.response||!i.code||t.includes(i.code)?!1:(0,dD.default)(i)}var gD=["get","head","options"],Cht=gD.concat(["put","delete"]);function g7(i){return i.code!=="ECONNABORTED"&&(!i.response||i.response.status===429||i.response.status>=500&&i.response.status<=599)}function Pht(i){return i.config?.method?g7(i)&&gD.indexOf(i.config.method)!==-1:!1}function mD(i){return i.config?.method?g7(i)&&Cht.indexOf(i.config.method)!==-1:!1}function vD(i){return pD(i)||mD(i)}function yD(i=void 0){let t=i?.response?.headers["retry-after"];if(!t)return 0;let r=(Number(t)||0)*1e3;return r===0&&(r=(new Date(t).valueOf()||0)-Date.now()),Math.max(0,r)}function Nht(i=0,t=void 0){return Math.max(0,yD(t))}function Lht(i=0,t=void 0,r=100){let h=2**i*r,o=Math.max(h,yD(t)),l=o*.2*Math.random();return o+l}var Dht={retries:3,retryCondition:vD,retryDelay:Nht,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function $ht(i,t){return{...Dht,...t,...i[p7]}}function lD(i,t){let r=$ht(i,t||{});return r.retryCount=r.retryCount||0,r.lastRequestTime=r.lastRequestTime||Date.now(),i[p7]=r,r}function Uht(i,t){i.defaults.agent===t.agent&&delete t.agent,i.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,i.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}async function qht(i,t){let{retries:r,retryCondition:h}=i,o=(i.retryCount||0)<r&&h(t);if(typeof o=="object")try{return await o!==!1}catch{return!1}return o}async function Fht(i,t,r,h){t.retryCount+=1;let{retryDelay:o,shouldResetTimeout:l,onRetry:c}=t,p=o(t.retryCount,r);if(Uht(i,h),!l&&h.timeout&&t.lastRequestTime){let w=Date.now()-t.lastRequestTime,m=h.timeout-w-p;if(m<=0)return Promise.reject(r);h.timeout=m}return h.transformRequest=[w=>w],await c(t.retryCount,r,h),new Promise(w=>{setTimeout(()=>w(i(h)),p)})}async function jht(i,t){i.retryCount>=i.retries&&await i.onMaxRetryTimesExceeded(t,i.retryCount)}var Rl=(i,t)=>{let r=i.interceptors.request.use(o=>(lD(o,t),o[p7]?.validateResponse&&(o.validateStatus=()=>!1),o)),h=i.interceptors.response.use(null,async o=>{let{config:l}=o;if(!l)return Promise.reject(o);let c=lD(l,t);return o.response&&c.validateResponse?.(o.response)?o.response:await qht(c,o)?Fht(i,c,o,l):(await jht(c,o),Promise.reject(o))});return{requestInterceptorId:r,responseInterceptorId:h}};Rl.isNetworkError=pD;Rl.isSafeRequestError=Pht;Rl.isIdempotentRequestError=mD;Rl.isNetworkOrIdempotentRequestError=vD;Rl.exponentialDelay=Lht;Rl.isRetryableError=g7;var D6=Rl;Tt();Rt();xt();var z9=Sl(Xq(),1);Tt();Rt();xt();var r1="1.2.0-alpha.
|
|
221
|
+
`+l):h.stack=l}catch{}}throw h}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ph(this.defaults,r);let{transitional:h,paramsSerializer:o,headers:l}=r;h!==void 0&&N6.assertOptions(h,{silentJSONParsing:uc.transitional(uc.boolean),forcedJSONParsing:uc.transitional(uc.boolean),clarifyTimeoutError:uc.transitional(uc.boolean)},!1),o!=null&&(Ke.isFunction(o)?r.paramsSerializer={serialize:o}:N6.assertOptions(o,{encode:uc.function,serialize:uc.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let c=l&&Ke.merge(l.common,l[r.method]);l&&Ke.forEach(["delete","get","head","post","put","patch","common"],A=>{delete l[A]}),r.headers=Zn.concat(c,l);let p=[],w=!0;this.interceptors.request.forEach(function(R){typeof R.runWhen=="function"&&R.runWhen(r)===!1||(w=w&&R.synchronous,p.unshift(R.fulfilled,R.rejected))});let m=[];this.interceptors.response.forEach(function(R){m.push(R.fulfilled,R.rejected)});let y,v=0,M;if(!w){let A=[C6.bind(this),void 0];for(A.unshift.apply(A,p),A.push.apply(A,m),M=A.length,y=Promise.resolve(r);v<M;)y=y.then(A[v++],A[v++]);return y}M=p.length;let T=r;for(v=0;v<M;){let A=p[v++],R=p[v++];try{T=A(T)}catch(B){R.call(this,B);break}}try{y=C6.call(this,T)}catch(A){return Promise.reject(A)}for(v=0,M=m.length;v<M;)y=y.then(m[v++],m[v++]);return y}getUri(t){t=ph(this.defaults,t);let r=f2(t.baseURL,t.url);return n2(r,t.params,t.paramsSerializer)}};Ke.forEach(["delete","get","head","options"],function(t){Nd.prototype[t]=function(r,h){return this.request(ph(h||{},{method:t,url:r,data:(h||{}).data}))}});Ke.forEach(["post","put","patch"],function(t){function r(h){return function(l,c,p){return this.request(ph(p||{},{method:t,headers:h?{"Content-Type":"multipart/form-data"}:{},url:l,data:c}))}}Nd.prototype[t]=r(),Nd.prototype[t+"Form"]=r(!0)});var u2=Nd;Tt();Rt();xt();var u7=class i{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(l){r=l});let h=this;this.promise.then(o=>{if(!h._listeners)return;let l=h._listeners.length;for(;l-- >0;)h._listeners[l](o);h._listeners=null}),this.promise.then=o=>{let l,c=new Promise(p=>{h.subscribe(p),l=p}).then(o);return c.cancel=function(){h.unsubscribe(l)},c},t(function(l,c,p){h.reason||(h.reason=new of(l,c,p),r(h.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new i(function(o){t=o}),cancel:t}}},sD=u7;Tt();Rt();xt();function c7(i){return function(r){return i.apply(null,r)}}Tt();Rt();xt();function l7(i){return Ke.isObject(i)&&i.isAxiosError===!0}Tt();Rt();xt();var d7={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(d7).forEach(([i,t])=>{d7[t]=i});var hD=d7;function fD(i){let t=new u2(i),r=e2(u2.prototype.request,t);return Ke.extend(r,u2.prototype,t,{allOwnKeys:!0}),Ke.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return fD(ph(i,o))},r}var Wn=fD(Od);Wn.Axios=u2;Wn.CanceledError=of;Wn.CancelToken=sD;Wn.isCancel=s2;Wn.VERSION=P6;Wn.toFormData=fc;Wn.AxiosError=Nr;Wn.Cancel=Wn.CanceledError;Wn.all=function(t){return Promise.all(t)};Wn.spread=c7;Wn.isAxiosError=l7;Wn.mergeConfig=ph;Wn.AxiosHeaders=Zn;Wn.formToJSON=i=>x6(Ke.isHTMLForm(i)?new FormData(i):i);Wn.getAdapter=O6.getAdapter;Wn.HttpStatusCode=hD;Wn.default=Wn;var L6=Wn;var{Axios:nLt,AxiosError:oLt,CanceledError:aLt,isCancel:sLt,CancelToken:hLt,VERSION:fLt,all:uLt,Cancel:cLt,isAxiosError:lLt,spread:dLt,toFormData:pLt,AxiosHeaders:gLt,HttpStatusCode:mLt,formToJSON:vLt,getAdapter:yLt,mergeConfig:bLt}=L6;Tt();Rt();xt();var dD=Sl(cD(),1),p7="axios-retry";function pD(i){let t=["ERR_CANCELED","ECONNABORTED"];return i.response||!i.code||t.includes(i.code)?!1:(0,dD.default)(i)}var gD=["get","head","options"],Cht=gD.concat(["put","delete"]);function g7(i){return i.code!=="ECONNABORTED"&&(!i.response||i.response.status===429||i.response.status>=500&&i.response.status<=599)}function Pht(i){return i.config?.method?g7(i)&&gD.indexOf(i.config.method)!==-1:!1}function mD(i){return i.config?.method?g7(i)&&Cht.indexOf(i.config.method)!==-1:!1}function vD(i){return pD(i)||mD(i)}function yD(i=void 0){let t=i?.response?.headers["retry-after"];if(!t)return 0;let r=(Number(t)||0)*1e3;return r===0&&(r=(new Date(t).valueOf()||0)-Date.now()),Math.max(0,r)}function Nht(i=0,t=void 0){return Math.max(0,yD(t))}function Lht(i=0,t=void 0,r=100){let h=2**i*r,o=Math.max(h,yD(t)),l=o*.2*Math.random();return o+l}var Dht={retries:3,retryCondition:vD,retryDelay:Nht,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function $ht(i,t){return{...Dht,...t,...i[p7]}}function lD(i,t){let r=$ht(i,t||{});return r.retryCount=r.retryCount||0,r.lastRequestTime=r.lastRequestTime||Date.now(),i[p7]=r,r}function Uht(i,t){i.defaults.agent===t.agent&&delete t.agent,i.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,i.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}async function qht(i,t){let{retries:r,retryCondition:h}=i,o=(i.retryCount||0)<r&&h(t);if(typeof o=="object")try{return await o!==!1}catch{return!1}return o}async function Fht(i,t,r,h){t.retryCount+=1;let{retryDelay:o,shouldResetTimeout:l,onRetry:c}=t,p=o(t.retryCount,r);if(Uht(i,h),!l&&h.timeout&&t.lastRequestTime){let w=Date.now()-t.lastRequestTime,m=h.timeout-w-p;if(m<=0)return Promise.reject(r);h.timeout=m}return h.transformRequest=[w=>w],await c(t.retryCount,r,h),new Promise(w=>{setTimeout(()=>w(i(h)),p)})}async function jht(i,t){i.retryCount>=i.retries&&await i.onMaxRetryTimesExceeded(t,i.retryCount)}var Rl=(i,t)=>{let r=i.interceptors.request.use(o=>(lD(o,t),o[p7]?.validateResponse&&(o.validateStatus=()=>!1),o)),h=i.interceptors.response.use(null,async o=>{let{config:l}=o;if(!l)return Promise.reject(o);let c=lD(l,t);return o.response&&c.validateResponse?.(o.response)?o.response:await qht(c,o)?Fht(i,c,o,l):(await jht(c,o),Promise.reject(o))});return{requestInterceptorId:r,responseInterceptorId:h}};Rl.isNetworkError=pD;Rl.isSafeRequestError=Pht;Rl.isIdempotentRequestError=mD;Rl.isNetworkOrIdempotentRequestError=vD;Rl.exponentialDelay=Lht;Rl.isRetryableError=g7;var D6=Rl;Tt();Rt();xt();var z9=Sl(Xq(),1);Tt();Rt();xt();var r1="1.2.0-alpha.13";var la=class{logger;silent=!1;constructor({level:t="info"}={}){if(t==="none"){this.silent=!0;return}this.logger=z9.default.createLogger({level:t,name:"ar-io-sdk",version:r1,serializers:z9.default.stdSerializers})}info(t,...r){this.silent||this.logger.info(...r,t)}warn(t,...r){this.silent||this.logger.warn(...r,t)}error(t,...r){this.silent||this.logger.error(...r,t)}debug(t,...r){this.silent||this.logger.debug(...r,t)}setLogLevel(t){if(t==="none"){this.silent=!0;return}this.logger.level(t)}};var Yq=({axiosConfig:i={},logger:t=new la,retryConfig:r={retries:5,retryDelay:D6.exponentialDelay,retryCondition:h=>D6.isRetryableError(h),onRetry(h,o,l){t.error(`Retrying request ${l.url} attempt ${h}`,o)}}}={})=>{let h=L6.create({...i,maxRedirects:0,headers:{...i.headers,"x-source-version":`${r1}`,"x-source-identifier":"ar-io-sdk"},validateStatus:()=>!0});return D6(h,r),h};Tt();Rt();xt();Tt();Rt();xt();Tt();Rt();xt();var yh=class extends Error{constructor(t){super(t),this.name=this.constructor.name}},xy=class extends yh{},Qq=class extends yh{},Wl=class extends yh{constructor(t,r){super(`Failed request: ${t}: ${r}`)}},Ry=class extends yh{},i1=class extends yh{},tF=class extends yh{constructor(){super("Invalid signer. Please provide a valid signer to interact with the contract.")}},No=class extends yh{constructor(){super("Invalid contract configuration")}},eF=class extends yh{constructor(){super("Invalid process configuration")}},n1=class extends yh{};var o1=100;async function xqt({address:i,arweave:t,signal:r=AbortSignal.timeout(1e4)}){let h=!1,o,l=new Set;do{let c={query:`
|
|
222
222
|
{
|
|
223
223
|
transactions (
|
|
224
224
|
owners:["${i}"]
|
|
@@ -376,7 +376,7 @@ ${C}`),A.pop(),`{${W}}`}case"number":return isFinite(T)?String(T):t?t(T):"null";
|
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
|
-
}`,o=Xe.object({data:Xe.object({transactions:Xe.object({edges:Xe.array(Xe.object({node:Xe.record(Xe.any())}))})})});return l=>ci(l).chain(rn(c=>i(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:h,variables:{transactionIds:[c]}})}).then(async p=>{if(p.ok)return p.json();throw r('Error Encountered when querying gateway for transaction "%s"',c),new Error(`${p.status}: ${await p.text()}`)}).then(o.parse).then(a9t(["data","transactions","edges","0","node"])))).toPromise()}var d_t=OR(R4t(),1),oet=(i="@permaweb/aoconnect")=>{let t=(0,d_t.default)(i);return t.child=r=>oet(`${t.namespace}:${r}`),t.tap=(r,...h)=>d9t((...o)=>t(r,...h,...o)),t},aet=({url:i,path:t})=>t?t.startsWith("/")?aet({url:i,path:t.slice(1)}):(i=new URL(i),i.pathname+=t,i.toString()):i;function p_t(i){return Y1(p8([]),X1((t,r)=>Y1(f9t([],r.name),zR(r.value),Vs(r.name,Cu,t))(t),{}),l8(t=>t.length>1?t:t[0]))(i)}function Hs(i,t){return r=>Ott(v7t([ett(i,"name"),KR(jR(t),ett(t,"value"),UR)]),r)}function ntt(i){return jtt([[Yg(String),K1(i)],[Yg(Array),J7t(i)],[UR,T5t]])}function L0(i){let t;return Yg(Gs,i)?(t=new Error(g_t(i)),t.stack+=i.stack):Yg(Error,i)?t=i:G7t("message",i)?t=new Error(i.message):Yg(String,i)?t=new Error(i):t=new Error("An error occurred"),t}function g_t(i){return Y1(t=>function r(h,o,l){return X1((c,p)=>Y1(jtt([[K1(vr.invalid_arguments),()=>r(p.argumentsError,422,"Invalid Arguments")],[K1(vr.invalid_return_type),()=>r(p.returnTypeError,500,"Invalid Return")],[K1(vr.invalid_union),()=>C7t(w=>r(w,400,"Invalid Union"),p.unionErrors)],[UR,()=>[{...p,status:o,contextCode:l}]]]),WR(c))(p.code),[],h.issues)}(t,400,""),t=>X1((r,h)=>{let{message:o,path:l,contextCode:c}=h,p=l[1]||l[0],w=c?`${c} `:"";return r.push(`${w}'${p}': ${o}.`),r},[],t),r9t(" | "))(i)}var m_t=Xe.object({id:Xe.string().min(1,{message:"message is required to be a message id"}),processId:Xe.string().min(1,{message:"process is required to be a process id"})});function v_t(){return i=>ci(i).map(m_t.parse).map(()=>i)}var ym=Xe.object({name:Xe.string(),value:Xe.string()}),y_t=Xe.function().args(Xe.object({Id:Xe.string(),Target:Xe.string(),Owner:Xe.string(),Anchor:Xe.string().optional(),Data:Xe.any().default("1234"),Tags:Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}))})).returns(Xe.promise(Xe.any())),b_t=Xe.function().args(Xe.object({id:Xe.string().min(1,{message:"message id is required"}),processId:Xe.string().min(1,{message:"process id is required"})})).returns(Xe.promise(Xe.any())),w_t=Xe.function().args(Xe.object({process:Xe.string().min(1,{message:"process id is required"}),from:Xe.string().optional(),to:Xe.string().optional(),sort:Xe.enum(["ASC","DESC"]).default("ASC"),limit:Xe.number().optional()})).returns(Xe.promise(Xe.object({edges:Xe.array(Xe.object({cursor:Xe.string(),node:Xe.object({Output:Xe.any().optional(),Messages:Xe.array(Xe.any()).optional(),Spawns:Xe.array(Xe.any()).optional(),Error:Xe.any().optional()})}))}))),set=Xe.function().args(Xe.object({processId:Xe.string(),data:Xe.any(),tags:Xe.array(ym),anchor:Xe.string().optional(),signer:Xe.any()})).returns(Xe.promise(Xe.object({messageId:Xe.string()}).passthrough())),__t=Xe.function().args(Xe.object({data:Xe.any(),tags:Xe.array(ym),signer:Xe.any()})).returns(Xe.promise(Xe.object({processId:Xe.string()}).passthrough())),M_t=Xe.function().args(Xe.object({process:Xe.string(),message:Xe.string(),baseLayer:Xe.boolean().optional(),exclude:Xe.array(Xe.string()).optional()})).returns(Xe.promise(Xe.object({assignmentId:Xe.string()}).passthrough())),het=set,yWt=Xe.function().args(Xe.object({suUrl:Xe.string().url(),processId:Xe.string()})).returns(Xe.promise(Xe.object({tags:Xe.array(ym)}).passthrough())),bWt=Xe.function().args(Xe.string()).returns(Xe.promise(Xe.object({url:Xe.string()}))),S_t=Xe.function().args(Xe.string()).returns(Xe.promise(Xe.boolean())),E_t=Xe.function().args(Xe.string()).returns(Xe.promise(Xe.object({tags:Xe.array(ym)}).passthrough())),g8=Xe.function().args(Xe.object({data:Xe.any(),tags:Xe.array(ym),target:Xe.string().optional(),anchor:Xe.string().optional()})).returns(Xe.promise(Xe.object({id:Xe.string(),raw:Xe.any()})));function A_t({loadResult:i}){return i=rn(b_t.implement(i)),t=>ci({id:t.id,processId:t.processId}).chain(i)}function T_t(i){let t=v_t(i),r=A_t(i);return({message:h,process:o})=>ci({id:h,processId:o}).chain(t).chain(r).map(i.logger.tap('readResult result for message "%s": %O',h)).map(l=>l).bimap(L0,N0).toPromise()}var x_t=Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}));function R_t(){return i=>ci(i.tags).map(p8([])).map(Hs("Data-Protocol","ao")).map(Hs("Variant")).map(Hs("Type")).map(Hs("SDK")).map(WR(Cu,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"},{name:"SDK",value:"aoconnect"}])).map(x_t.parse).map(Vs("tags",Cu,i))}function k_t({logger:i}){return t=>ci(t).chain(KR(jR(t.data),()=>I0(t),()=>I0(Math.random().toString().slice(-4)).map(Vs("data",Cu,t)).map(r=>Y1(P0("tags"),Hs("Content-Type"),zR({name:"Content-Type",value:"text/plain"}),Vs("tags",Cu,r))(r)).map(i.tap('added pseudo-random string as message "data"'))))}function I_t(i){let t=R_t(i),r=k_t(i),h=set.implement(i.deployMessage);return o=>ci(o).chain(t).chain(r).chain(rn(({id:l,data:c,tags:p,anchor:w,signer:m})=>h({processId:l,data:c,tags:p,anchor:w,signer:g8.implement(m)}))).map(l=>Vs("messageId",l.messageId,o))}function B_t(i){let t=I_t(i);return({process:r,data:h,tags:o,anchor:l,signer:c})=>ci({id:r,data:h,tags:o,anchor:l,signer:c}).chain(t).map(p=>p.messageId).bimap(L0,N0).toPromise()}var Gg=(i,t,r)=>h=>t(h[i])?I0(h):Xc(`Tag '${i}': ${r}`);function O_t({loadTransactionMeta:i,logger:t}){return i=rn(E_t.implement(i)),r=>ci(r).chain(i).map(P0("tags")).map(p_t).chain(Gg("Data-Protocol",ntt("ao"),"value 'ao' was not found on module")).chain(Gg("Type",ntt("Module"),"value 'Module' was not found on module")).chain(Gg("Module-Format",lR,"was not found on module")).chain(Gg("Input-Encoding",lR,"was not found on module")).chain(Gg("Output-Encoding",lR,"was not found on module")).bimap(t.tap("Verifying module source failed: %s"),t.tap("Verified module source"))}function C_t({logger:i,validateScheduler:t}){return t=rn(S_t.implement(t)),r=>ci(r).chain(h=>t(h).chain(o=>o?I0(h):Xc(`Valid Scheduler-Location owned by ${h} not found`))).bimap(i.tap("Verifying scheduler failed: %s"),i.tap("Verified scheduler"))}function P_t({logger:i}){return t=>ci(t).map(i.tap("Checking for signer")).chain(r=>r?I0(r):Xc("signer not found"))}function N_t(i){let t=i.logger.child("verifyInput");i={...i,logger:t};let r=O_t(i),h=C_t(i),o=P_t(i);return l=>ci(l).chain(c=>r(c.module).map(()=>c)).chain(c=>h(c.scheduler)).map(()=>l).chain(c=>o(c.signer).map(()=>c)).bimap(t.tap("Error when verify input: %s"),t.tap("Successfully verified inputs"))}var L_t=Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}));function D_t(){return i=>ci(i).map(P0("tags")).map(p8([])).map(Hs("Data-Protocol","ao")).map(Hs("Variant")).map(Hs("Type")).map(Hs("Module")).map(Hs("Scheduler")).map(Hs("SDK")).map(WR(Cu,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Process"},{name:"Module",value:i.module},{name:"Scheduler",value:i.scheduler},{name:"SDK",value:"aoconnect"}])).map(L_t.parse).map(Vs("tags",Cu,i))}function $_t({logger:i}){return t=>ci(t).chain(KR(jR(t.data),()=>I0(t),()=>I0(Math.random().toString().slice(-4)).map(Vs("data",Cu,t)).map(r=>Y1(P0("tags"),Hs("Content-Type"),zR({name:"Content-Type",value:"text/plain"}),Vs("tags",Cu,r))(r)).map(i.tap('added pseudo-random string as process "data"'))))}function U_t(i){let t=i.logger.child("uploadProcess");i={...i,logger:t};let r=D_t(i),h=$_t(i),o=__t.implement(i.deployProcess);return l=>ci(l).chain(r).chain(h).chain(rn(({data:c,tags:p,signer:w})=>o({data:c,tags:p,signer:g8.implement(w)}))).map(c=>Vs("processId",c.processId,l))}function q_t(i){let t=N_t(i),r=U_t(i);return({module:h,scheduler:o,signer:l,tags:c,data:p})=>ci({module:h,scheduler:o,signer:l,tags:c,data:p}).chain(t).chain(r).map(w=>w.processId).bimap(L0,N0).toPromise()}function F_t(i){let t=het.implement(i.deployMonitor);return r=>ci(r).chain(rn(({id:h,signer:o})=>t({processId:h,signer:g8.implement(o),data:Math.random().toString().slice(-4),tags:[]}))).map(h=>Vs("monitorId",h.messageId,r))}function j_t(i){let t=F_t(i);return({process:r,signer:h})=>ci({id:r,signer:h}).chain(t).map(o=>o.monitorId).bimap(L0,N0).toPromise()}function z_t(i){let t=het.implement(i.deployUnmonitor);return r=>ci(r).chain(rn(({id:h,signer:o})=>t({processId:h,signer:g8.implement(o),data:Math.random().toString().slice(-4),tags:[]}))).map(h=>Vs("monitorId",h.messageId,r))}function W_t(i){let t=z_t(i);return({process:r,signer:h})=>ci({id:r,signer:h}).chain(t).map(o=>o.monitorId).bimap(L0,N0).toPromise()}var K_t=Xe.object({process:Xe.string().min(1,{message:"process identifier is required"}),from:Xe.string().optional(),to:Xe.string().optional(),sort:Xe.enum(["ASC","DESC"]).default("ASC"),limit:Xe.number().optional()});function H_t(){return i=>ci(i).map(K_t.parse).map(()=>i)}function G_t({queryResults:i}){return i=rn(w_t.implement(i)),t=>ci({process:t.process,from:t.from,to:t.to,sort:t.sort,limit:t.limit}).chain(i)}function V_t(i){let t=H_t(i),r=G_t(i);return({process:h,from:o,to:l,sort:c,limit:p})=>ci({process:h,from:o,to:l,sort:c,limit:p}).chain(t).chain(r).map(i.logger.tap('readResults result for message "%s": %O',h)).map(w=>w).bimap(L0,N0).toPromise()}var Z_t=Xe.object({Id:Xe.string(),Target:Xe.string(),Owner:Xe.string(),Anchor:Xe.string().optional(),Data:Xe.any().default("1234"),Tags:Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}))});function J_t(){return i=>ci(i).map(Z_t.parse).map(t=>(t.Tags=t.Tags.concat([{name:"Data-Protocol",value:"ao"},{name:"Type",value:"Message"},{name:"Variant",value:"ao.TN.1"}]),t))}function X_t({dryrunFetch:i}){return rn(y_t.implement(i))}function Y_t(i){let t=J_t(i),r=X_t(i);return h=>ci(h).map(Q_t).chain(t).chain(r).toPromise()}function Q_t({process:i,data:t,tags:r,anchor:h,...o}){return{Id:"1234",Owner:"1234",...o,Target:i,Data:t||"1234",Tags:r||[],Anchor:h||"0"}}function tMt(i){let t=M_t.implement(i.deployAssign);return r=>ci(r).chain(rn(({process:h,message:o,baseLayer:l,exclude:c})=>t({process:h,message:o,baseLayer:l,exclude:c}))).map(h=>Vs("assignmentId",h.assignmentId,r))}function eMt(i){let t=tMt(i);return({process:r,message:h,baseLayer:o,exclude:l})=>ci({process:r,message:h,baseLayer:o,exclude:l}).chain(t).map(c=>c.assignmentId).bimap(L0,N0).toPromise()}var rMt="https://arweave.net",iMt="https://mu.ao-testnet.xyz",nMt="https://cu.ao-testnet.xyz";function bm({GRAPHQL_URL:i,GATEWAY_URL:t=rMt,MU_URL:r=iMt,CU_URL:h=nMt}={}){let o=oet();i||(i=aet({url:t,path:"/graphql"}));let{validate:l}=Rtt({cacheSize:100,GRAPHQL_URL:i}),c=E5t({MAX_SIZE:25}),p=o.child("result"),w=T_t({loadResult:_5t({fetch,CU_URL:h,logger:p}),logger:p}),m=o.child("message"),y=B_t({loadProcessMeta:fR({fetch,cache:c,logger:m}),deployMessage:g5t({fetch,MU_URL:r,logger:m}),logger:m}),v=o.child("spawn"),M=q_t({loadTransactionMeta:l_t({fetch,GRAPHQL_URL:i,logger:v}),validateScheduler:l,deployProcess:m5t({fetch,MU_URL:r,logger:v}),logger:v}),T=o.child("monitor"),A=j_t({loadProcessMeta:fR({fetch,cache:c,logger:T}),deployMonitor:v5t({fetch,MU_URL:r,logger:T}),logger:T}),R=o.child("unmonitor"),B=W_t({loadProcessMeta:fR({fetch,cache:c,logger:R}),deployUnmonitor:y5t({fetch,MU_URL:r,logger:R}),logger:T}),C=o.child("results"),P=V_t({queryResults:M5t({fetch,CU_URL:h,logger:C}),logger:C}),N=o.child("dryrun"),q=Y_t({dryrunFetch:w5t({fetch,CU_URL:h,logger:N}),logger:N}),W=o.child("assign"),J=eMt({deployAssign:b5t({fetch,MU_URL:r,logger:W}),logger:m});return{result:w,results:P,message:y,spawn:M,monitor:A,unmonitor:B,dryrun:q,assign:J}}var fet={};stt(fet,{createDataItemSigner:()=>kMt});var uet=OR(B4t(),1),cet={};stt(cet,{AVSCTap:()=>wm,ArweaveSigner:()=>ZR,DataItem:()=>pm,MAX_TAG_BYTES:()=>m8,MIN_BINARY_SIZE:()=>YR,SIG_CONFIG:()=>rp,SignatureConfig:()=>Ks,Signer:()=>met,createData:()=>wet,default:()=>TMt,deserializeTags:()=>s8,indexToType:()=>JR,serializeTags:()=>XR,tagsExceedLimit:()=>bet,warparbundles:()=>xMt});var oMt=Object.create,GR=Object.defineProperty,aMt=Object.getOwnPropertyDescriptor,sMt=Object.getOwnPropertyNames,hMt=Object.getPrototypeOf,fMt=Object.prototype.hasOwnProperty,Nu=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),uMt=(i,t)=>{for(var r in t)GR(i,r,{get:t[r],enumerable:!0})},cMt=(i,t,r,h)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sMt(t))!fMt.call(i,o)&&o!==r&&GR(i,o,{get:()=>t[o],enumerable:!(h=aMt(t,o))||h.enumerable});return i},D0=(i,t,r)=>(r=i!=null?oMt(hMt(i)):{},cMt(t||!i||!i.__esModule?GR(r,"default",{value:i,enumerable:!0}):r,i)),lMt=Nu(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});function t(r){var h=4,o=r.length,l=o%h;if(!l)return r;var c=o,p=h-l,w=o+p,m=ge.alloc(w);for(m.write(r);p--;)m.write("=",c++);return m.toString()}i.default=t}),dMt=Nu(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var t=lMt();function r(w,m){return m===void 0&&(m="utf8"),ge.isBuffer(w)?l(w.toString("base64")):l(ge.from(w,m).toString("base64"))}function h(w,m){return m===void 0&&(m="utf8"),ge.from(o(w),"base64").toString(m)}function o(w){return w=w.toString(),t.default(w).replace(/\-/g,"+").replace(/_/g,"/")}function l(w){return w.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function c(w){return ge.from(o(w),"base64")}var p=r;p.encode=r,p.decode=h,p.toBase64=o,p.fromBase64=l,p.toBuffer=c,i.default=p}),VR=Nu((i,t)=>{t.exports=dMt().default,t.exports.default=t.exports}),det=Nu(i=>{"use strict";i.byteLength=w,i.toByteArray=y,i.fromByteArray=T;var t=[],r=[],h=typeof Uint8Array<"u"?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(l=0,c=o.length;l<c;++l)t[l]=o[l],r[o.charCodeAt(l)]=l;var l,c;r[45]=62,r[95]=63;function p(A){var R=A.length;if(R%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=A.indexOf("=");B===-1&&(B=R);var C=B===R?0:4-B%4;return[B,C]}function w(A){var R=p(A),B=R[0],C=R[1];return(B+C)*3/4-C}function m(A,R,B){return(R+B)*3/4-B}function y(A){var R,B=p(A),C=B[0],P=B[1],N=new h(m(A,C,P)),q=0,W=P>0?C-4:C,J;for(J=0;J<W;J+=4)R=r[A.charCodeAt(J)]<<18|r[A.charCodeAt(J+1)]<<12|r[A.charCodeAt(J+2)]<<6|r[A.charCodeAt(J+3)],N[q++]=R>>16&255,N[q++]=R>>8&255,N[q++]=R&255;return P===2&&(R=r[A.charCodeAt(J)]<<2|r[A.charCodeAt(J+1)]>>4,N[q++]=R&255),P===1&&(R=r[A.charCodeAt(J)]<<10|r[A.charCodeAt(J+1)]<<4|r[A.charCodeAt(J+2)]>>2,N[q++]=R>>8&255,N[q++]=R&255),N}function v(A){return t[A>>18&63]+t[A>>12&63]+t[A>>6&63]+t[A&63]}function M(A,R,B){for(var C,P=[],N=R;N<B;N+=3)C=(A[N]<<16&16711680)+(A[N+1]<<8&65280)+(A[N+2]&255),P.push(v(C));return P.join("")}function T(A){for(var R,B=A.length,C=B%3,P=[],N=16383,q=0,W=B-C;q<W;q+=N)P.push(M(A,q,q+N>W?W:q+N));return C===1?(R=A[B-1],P.push(t[R>>2]+t[R<<4&63]+"==")):C===2&&(R=(A[B-2]<<8)+A[B-1],P.push(t[R>>10]+t[R>>4&63]+t[R<<2&63]+"=")),P.join("")}}),pet=Nu(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.b64UrlDecode=i.b64UrlEncode=i.bufferTob64Url=i.bufferTob64=i.b64UrlToBuffer=i.stringToB64Url=i.stringToBuffer=i.bufferToString=i.b64UrlToString=i.concatBuffers=void 0;var t=det();function r(M){let T=0;for(let B=0;B<M.length;B++)T+=M[B].byteLength;let A=new Uint8Array(T),R=0;A.set(new Uint8Array(M[0]),R),R+=M[0].byteLength;for(let B=1;B<M.length;B++)A.set(new Uint8Array(M[B]),R),R+=M[B].byteLength;return A}i.concatBuffers=r;function h(M){let T=p(M);return o(T)}i.b64UrlToString=h;function o(M){return new TextDecoder("utf-8",{fatal:!0}).decode(M)}i.bufferToString=o;function l(M){return new TextEncoder().encode(M)}i.stringToBuffer=l;function c(M){return m(l(M))}i.stringToB64Url=c;function p(M){return new Uint8Array(t.toByteArray(v(M)))}i.b64UrlToBuffer=p;function w(M){return t.fromByteArray(new Uint8Array(M))}i.bufferTob64=w;function m(M){return y(w(M))}i.bufferTob64Url=m;function y(M){return M.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}i.b64UrlEncode=y;function v(M){M=M.replace(/\-/g,"+").replace(/\_/g,"/");let T;return M.length%4==0?T=0:T=4-M.length%4,M.concat("=".repeat(T))}i.b64UrlDecode=v}),pMt=Nu(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var t=pet(),r=class{keyLength=4096;publicExponent=65537;hashAlgorithm="sha256";driver;constructor(){if(!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let h=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),o=await this.driver.exportKey("jwk",h.privateKey);return{kty:o.kty,e:o.e,n:o.n,d:o.d,p:o.p,q:o.q,dp:o.dp,dq:o.dq,qi:o.qi}}async sign(h,o,{saltLength:l}={}){let c=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(h),o);return new Uint8Array(c)}async hash(h,o="SHA-256"){let l=await this.driver.digest(o,h);return new Uint8Array(l)}async verify(h,o,l){let c={kty:"RSA",e:"AQAB",n:h},p=await this.jwkToPublicCryptoKey(c),w=await this.driver.digest("SHA-256",o),m=await this.driver.verify({name:"RSA-PSS",saltLength:0},p,l,o),y=await this.driver.verify({name:"RSA-PSS",saltLength:32},p,l,o),v=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((p.algorithm.modulusLength-1)/8)-w.byteLength-2},p,l,o);return m||y||v}async jwkToCryptoKey(h){return this.driver.importKey("jwk",h,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(h){return this.driver.importKey("jwk",h,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let h=crypto?.subtle;return h===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(o=>typeof h[o]=="function")}async encrypt(h,o,l){let c=await this.driver.importKey("raw",typeof o=="string"?t.stringToBuffer(o):o,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:l?t.stringToBuffer(l):t.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),w=new Uint8Array(16);crypto.getRandomValues(w);let m=await this.driver.encrypt({name:"AES-CBC",iv:w},p,h);return t.concatBuffers([w,m])}async decrypt(h,o,l){let c=await this.driver.importKey("raw",typeof o=="string"?t.stringToBuffer(o):o,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:l?t.stringToBuffer(l):t.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),w=h.slice(0,16),m=await this.driver.decrypt({name:"AES-CBC",iv:w},p,h.slice(16));return t.concatBuffers([m])}};i.default=r}),gMt=Nu(i=>{i.read=function(t,r,h,o,l){var c,p,w=l*8-o-1,m=(1<<w)-1,y=m>>1,v=-7,M=h?l-1:0,T=h?-1:1,A=t[r+M];for(M+=T,c=A&(1<<-v)-1,A>>=-v,v+=w;v>0;c=c*256+t[r+M],M+=T,v-=8);for(p=c&(1<<-v)-1,c>>=-v,v+=o;v>0;p=p*256+t[r+M],M+=T,v-=8);if(c===0)c=1-y;else{if(c===m)return p?NaN:(A?-1:1)*(1/0);p=p+Math.pow(2,o),c=c-y}return(A?-1:1)*p*Math.pow(2,c-o)},i.write=function(t,r,h,o,l,c){var p,w,m,y=c*8-l-1,v=(1<<y)-1,M=v>>1,T=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=o?0:c-1,R=o?1:-1,B=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(w=isNaN(r)?1:0,p=v):(p=Math.floor(Math.log(r)/Math.LN2),r*(m=Math.pow(2,-p))<1&&(p--,m*=2),p+M>=1?r+=T/m:r+=T*Math.pow(2,1-M),r*m>=2&&(p++,m/=2),p+M>=v?(w=0,p=v):p+M>=1?(w=(r*m-1)*Math.pow(2,l),p=p+M):(w=r*Math.pow(2,M-1)*Math.pow(2,l),p=0));l>=8;t[h+A]=w&255,A+=R,w/=256,l-=8);for(p=p<<l|w,y+=l;y>0;t[h+A]=p&255,A+=R,p/=256,y-=8);t[h+A-R]|=B*128}}),kR=Nu(i=>{"use strict";var t=det(),r=gMt(),h=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=p,i.SlowBuffer=P,i.INSPECT_MAX_BYTES=50;var o=2147483647;i.kMaxLength=o,p.TYPED_ARRAY_SUPPORT=l(),!p.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{let I=new Uint8Array(1),O={foo:function(){return 42}};return Object.setPrototypeOf(O,Uint8Array.prototype),Object.setPrototypeOf(I,O),I.foo()===42}catch{return!1}}Object.defineProperty(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}}),Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}});function c(I){if(I>o)throw new RangeError('The value "'+I+'" is invalid for option "size"');let O=new Uint8Array(I);return Object.setPrototypeOf(O,p.prototype),O}function p(I,O,L){if(typeof I=="number"){if(typeof O=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(I)}return w(I,O,L)}p.poolSize=8192;function w(I,O,L){if(typeof I=="string")return M(I,O);if(ArrayBuffer.isView(I))return A(I);if(I==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof I);if(mt(I,ArrayBuffer)||I&&mt(I.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(I,SharedArrayBuffer)||I&&mt(I.buffer,SharedArrayBuffer)))return R(I,O,L);if(typeof I=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let V=I.valueOf&&I.valueOf();if(V!=null&&V!==I)return p.from(V,O,L);let st=B(I);if(st)return st;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof I[Symbol.toPrimitive]=="function")return p.from(I[Symbol.toPrimitive]("string"),O,L);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof I)}p.from=function(I,O,L){return w(I,O,L)},Object.setPrototypeOf(p.prototype,Uint8Array.prototype),Object.setPrototypeOf(p,Uint8Array);function m(I){if(typeof I!="number")throw new TypeError('"size" argument must be of type number');if(I<0)throw new RangeError('The value "'+I+'" is invalid for option "size"')}function y(I,O,L){return m(I),I<=0?c(I):O!==void 0?typeof L=="string"?c(I).fill(O,L):c(I).fill(O):c(I)}p.alloc=function(I,O,L){return y(I,O,L)};function v(I){return m(I),c(I<0?0:C(I)|0)}p.allocUnsafe=function(I){return v(I)},p.allocUnsafeSlow=function(I){return v(I)};function M(I,O){if((typeof O!="string"||O==="")&&(O="utf8"),!p.isEncoding(O))throw new TypeError("Unknown encoding: "+O);let L=N(I,O)|0,V=c(L),st=V.write(I,O);return st!==L&&(V=V.slice(0,st)),V}function T(I){let O=I.length<0?0:C(I.length)|0,L=c(O);for(let V=0;V<O;V+=1)L[V]=I[V]&255;return L}function A(I){if(mt(I,Uint8Array)){let O=new Uint8Array(I);return R(O.buffer,O.byteOffset,O.byteLength)}return T(I)}function R(I,O,L){if(O<0||I.byteLength<O)throw new RangeError('"offset" is outside of buffer bounds');if(I.byteLength<O+(L||0))throw new RangeError('"length" is outside of buffer bounds');let V;return O===void 0&&L===void 0?V=new Uint8Array(I):L===void 0?V=new Uint8Array(I,O):V=new Uint8Array(I,O,L),Object.setPrototypeOf(V,p.prototype),V}function B(I){if(p.isBuffer(I)){let O=C(I.length)|0,L=c(O);return L.length===0||I.copy(L,0,0,O),L}if(I.length!==void 0)return typeof I.length!="number"||wt(I.length)?c(0):T(I);if(I.type==="Buffer"&&Array.isArray(I.data))return T(I.data)}function C(I){if(I>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return I|0}function P(I){return+I!=I&&(I=0),p.alloc(+I)}p.isBuffer=function(I){return I!=null&&I._isBuffer===!0&&I!==p.prototype},p.compare=function(I,O){if(mt(I,Uint8Array)&&(I=p.from(I,I.offset,I.byteLength)),mt(O,Uint8Array)&&(O=p.from(O,O.offset,O.byteLength)),!p.isBuffer(I)||!p.isBuffer(O))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(I===O)return 0;let L=I.length,V=O.length;for(let st=0,ft=Math.min(L,V);st<ft;++st)if(I[st]!==O[st]){L=I[st],V=O[st];break}return L<V?-1:V<L?1:0},p.isEncoding=function(I){switch(String(I).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},p.concat=function(I,O){if(!Array.isArray(I))throw new TypeError('"list" argument must be an Array of Buffers');if(I.length===0)return p.alloc(0);let L;if(O===void 0)for(O=0,L=0;L<I.length;++L)O+=I[L].length;let V=p.allocUnsafe(O),st=0;for(L=0;L<I.length;++L){let ft=I[L];if(mt(ft,Uint8Array))st+ft.length>V.length?(p.isBuffer(ft)||(ft=p.from(ft)),ft.copy(V,st)):Uint8Array.prototype.set.call(V,ft,st);else if(p.isBuffer(ft))ft.copy(V,st);else throw new TypeError('"list" argument must be an Array of Buffers');st+=ft.length}return V};function N(I,O){if(p.isBuffer(I))return I.length;if(ArrayBuffer.isView(I)||mt(I,ArrayBuffer))return I.byteLength;if(typeof I!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof I);let L=I.length,V=arguments.length>2&&arguments[2]===!0;if(!V&&L===0)return 0;let st=!1;for(;;)switch(O){case"ascii":case"latin1":case"binary":return L;case"utf8":case"utf-8":return ut(I).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L*2;case"hex":return L>>>1;case"base64":return bt(I).length;default:if(st)return V?-1:ut(I).length;O=(""+O).toLowerCase(),st=!0}}p.byteLength=N;function q(I,O,L){let V=!1;if((O===void 0||O<0)&&(O=0),O>this.length||((L===void 0||L>this.length)&&(L=this.length),L<=0)||(L>>>=0,O>>>=0,L<=O))return"";for(I||(I="utf8");;)switch(I){case"hex":return e(this,O,L);case"utf8":case"utf-8":return d(this,O,L);case"ascii":return x(this,O,L);case"latin1":case"binary":return a(this,O,L);case"base64":return f(this,O,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u(this,O,L);default:if(V)throw new TypeError("Unknown encoding: "+I);I=(I+"").toLowerCase(),V=!0}}p.prototype._isBuffer=!0;function W(I,O,L){let V=I[O];I[O]=I[L],I[L]=V}p.prototype.swap16=function(){let I=this.length;if(I%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let O=0;O<I;O+=2)W(this,O,O+1);return this},p.prototype.swap32=function(){let I=this.length;if(I%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let O=0;O<I;O+=4)W(this,O,O+3),W(this,O+1,O+2);return this},p.prototype.swap64=function(){let I=this.length;if(I%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let O=0;O<I;O+=8)W(this,O,O+7),W(this,O+1,O+6),W(this,O+2,O+5),W(this,O+3,O+4);return this},p.prototype.toString=function(){let I=this.length;return I===0?"":arguments.length===0?d(this,0,I):q.apply(this,arguments)},p.prototype.toLocaleString=p.prototype.toString,p.prototype.equals=function(I){if(!p.isBuffer(I))throw new TypeError("Argument must be a Buffer");return this===I?!0:p.compare(this,I)===0},p.prototype.inspect=function(){let I="",O=i.INSPECT_MAX_BYTES;return I=this.toString("hex",0,O).replace(/(.{2})/g,"$1 ").trim(),this.length>O&&(I+=" ... "),"<Buffer "+I+">"},h&&(p.prototype[h]=p.prototype.inspect),p.prototype.compare=function(I,O,L,V,st){if(mt(I,Uint8Array)&&(I=p.from(I,I.offset,I.byteLength)),!p.isBuffer(I))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof I);if(O===void 0&&(O=0),L===void 0&&(L=I?I.length:0),V===void 0&&(V=0),st===void 0&&(st=this.length),O<0||L>I.length||V<0||st>this.length)throw new RangeError("out of range index");if(V>=st&&O>=L)return 0;if(V>=st)return-1;if(O>=L)return 1;if(O>>>=0,L>>>=0,V>>>=0,st>>>=0,this===I)return 0;let ft=st-V,ht=L-O,Et=Math.min(ft,ht),_t=this.slice(V,st),vt=I.slice(O,L);for(let Qt=0;Qt<Et;++Qt)if(_t[Qt]!==vt[Qt]){ft=_t[Qt],ht=vt[Qt];break}return ft<ht?-1:ht<ft?1:0};function J(I,O,L,V,st){if(I.length===0)return-1;if(typeof L=="string"?(V=L,L=0):L>2147483647?L=2147483647:L<-2147483648&&(L=-2147483648),L=+L,wt(L)&&(L=st?0:I.length-1),L<0&&(L=I.length+L),L>=I.length){if(st)return-1;L=I.length-1}else if(L<0)if(st)L=0;else return-1;if(typeof O=="string"&&(O=p.from(O,V)),p.isBuffer(O))return O.length===0?-1:F(I,O,L,V,st);if(typeof O=="number")return O=O&255,typeof Uint8Array.prototype.indexOf=="function"?st?Uint8Array.prototype.indexOf.call(I,O,L):Uint8Array.prototype.lastIndexOf.call(I,O,L):F(I,[O],L,V,st);throw new TypeError("val must be string, number or Buffer")}function F(I,O,L,V,st){let ft=1,ht=I.length,Et=O.length;if(V!==void 0&&(V=String(V).toLowerCase(),V==="ucs2"||V==="ucs-2"||V==="utf16le"||V==="utf-16le")){if(I.length<2||O.length<2)return-1;ft=2,ht/=2,Et/=2,L/=2}function _t(Qt,It){return ft===1?Qt[It]:Qt.readUInt16BE(It*ft)}let vt;if(st){let Qt=-1;for(vt=L;vt<ht;vt++)if(_t(I,vt)===_t(O,Qt===-1?0:vt-Qt)){if(Qt===-1&&(Qt=vt),vt-Qt+1===Et)return Qt*ft}else Qt!==-1&&(vt-=vt-Qt),Qt=-1}else for(L+Et>ht&&(L=ht-Et),vt=L;vt>=0;vt--){let Qt=!0;for(let It=0;It<Et;It++)if(_t(I,vt+It)!==_t(O,It)){Qt=!1;break}if(Qt)return vt}return-1}p.prototype.includes=function(I,O,L){return this.indexOf(I,O,L)!==-1},p.prototype.indexOf=function(I,O,L){return J(this,I,O,L,!0)},p.prototype.lastIndexOf=function(I,O,L){return J(this,I,O,L,!1)};function H(I,O,L,V){L=Number(L)||0;let st=I.length-L;V?(V=Number(V),V>st&&(V=st)):V=st;let ft=O.length;V>ft/2&&(V=ft/2);let ht;for(ht=0;ht<V;++ht){let Et=parseInt(O.substr(ht*2,2),16);if(wt(Et))return ht;I[L+ht]=Et}return ht}function Y(I,O,L,V){return lt(ut(O,I.length-L),I,L,V)}function E(I,O,L,V){return lt(pt(O),I,L,V)}function n(I,O,L,V){return lt(bt(O),I,L,V)}function s(I,O,L,V){return lt(St(O,I.length-L),I,L,V)}p.prototype.write=function(I,O,L,V){if(O===void 0)V="utf8",L=this.length,O=0;else if(L===void 0&&typeof O=="string")V=O,L=this.length,O=0;else if(isFinite(O))O=O>>>0,isFinite(L)?(L=L>>>0,V===void 0&&(V="utf8")):(V=L,L=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let st=this.length-O;if((L===void 0||L>st)&&(L=st),I.length>0&&(L<0||O<0)||O>this.length)throw new RangeError("Attempt to write outside buffer bounds");V||(V="utf8");let ft=!1;for(;;)switch(V){case"hex":return H(this,I,O,L);case"utf8":case"utf-8":return Y(this,I,O,L);case"ascii":case"latin1":case"binary":return E(this,I,O,L);case"base64":return n(this,I,O,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s(this,I,O,L);default:if(ft)throw new TypeError("Unknown encoding: "+V);V=(""+V).toLowerCase(),ft=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function f(I,O,L){return O===0&&L===I.length?t.fromByteArray(I):t.fromByteArray(I.slice(O,L))}function d(I,O,L){L=Math.min(I.length,L);let V=[],st=O;for(;st<L;){let ft=I[st],ht=null,Et=ft>239?4:ft>223?3:ft>191?2:1;if(st+Et<=L){let _t,vt,Qt,It;switch(Et){case 1:ft<128&&(ht=ft);break;case 2:_t=I[st+1],(_t&192)===128&&(It=(ft&31)<<6|_t&63,It>127&&(ht=It));break;case 3:_t=I[st+1],vt=I[st+2],(_t&192)===128&&(vt&192)===128&&(It=(ft&15)<<12|(_t&63)<<6|vt&63,It>2047&&(It<55296||It>57343)&&(ht=It));break;case 4:_t=I[st+1],vt=I[st+2],Qt=I[st+3],(_t&192)===128&&(vt&192)===128&&(Qt&192)===128&&(It=(ft&15)<<18|(_t&63)<<12|(vt&63)<<6|Qt&63,It>65535&&It<1114112&&(ht=It))}}ht===null?(ht=65533,Et=1):ht>65535&&(ht-=65536,V.push(ht>>>10&1023|55296),ht=56320|ht&1023),V.push(ht),st+=Et}return S(V)}var g=4096;function S(I){let O=I.length;if(O<=g)return String.fromCharCode.apply(String,I);let L="",V=0;for(;V<O;)L+=String.fromCharCode.apply(String,I.slice(V,V+=g));return L}function x(I,O,L){let V="";L=Math.min(I.length,L);for(let st=O;st<L;++st)V+=String.fromCharCode(I[st]&127);return V}function a(I,O,L){let V="";L=Math.min(I.length,L);for(let st=O;st<L;++st)V+=String.fromCharCode(I[st]);return V}function e(I,O,L){let V=I.length;(!O||O<0)&&(O=0),(!L||L<0||L>V)&&(L=V);let st="";for(let ft=O;ft<L;++ft)st+=Mt[I[ft]];return st}function u(I,O,L){let V=I.slice(O,L),st="";for(let ft=0;ft<V.length-1;ft+=2)st+=String.fromCharCode(V[ft]+V[ft+1]*256);return st}p.prototype.slice=function(I,O){let L=this.length;I=~~I,O=O===void 0?L:~~O,I<0?(I+=L,I<0&&(I=0)):I>L&&(I=L),O<0?(O+=L,O<0&&(O=0)):O>L&&(O=L),O<I&&(O=I);let V=this.subarray(I,O);return Object.setPrototypeOf(V,p.prototype),V};function b(I,O,L){if(I%1!==0||I<0)throw new RangeError("offset is not uint");if(I+O>L)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I],st=1,ft=0;for(;++ft<O&&(st*=256);)V+=this[I+ft]*st;return V},p.prototype.readUintBE=p.prototype.readUIntBE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I+--O],st=1;for(;O>0&&(st*=256);)V+=this[I+--O]*st;return V},p.prototype.readUint8=p.prototype.readUInt8=function(I,O){return I=I>>>0,O||b(I,1,this.length),this[I]},p.prototype.readUint16LE=p.prototype.readUInt16LE=function(I,O){return I=I>>>0,O||b(I,2,this.length),this[I]|this[I+1]<<8},p.prototype.readUint16BE=p.prototype.readUInt16BE=function(I,O){return I=I>>>0,O||b(I,2,this.length),this[I]<<8|this[I+1]},p.prototype.readUint32LE=p.prototype.readUInt32LE=function(I,O){return I=I>>>0,O||b(I,4,this.length),(this[I]|this[I+1]<<8|this[I+2]<<16)+this[I+3]*16777216},p.prototype.readUint32BE=p.prototype.readUInt32BE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]*16777216+(this[I+1]<<16|this[I+2]<<8|this[I+3])},p.prototype.readBigUInt64LE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=O+this[++I]*2**8+this[++I]*2**16+this[++I]*2**24,st=this[++I]+this[++I]*2**8+this[++I]*2**16+L*2**24;return BigInt(V)+(BigInt(st)<<BigInt(32))}),p.prototype.readBigUInt64BE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=O*2**24+this[++I]*2**16+this[++I]*2**8+this[++I],st=this[++I]*2**24+this[++I]*2**16+this[++I]*2**8+L;return(BigInt(V)<<BigInt(32))+BigInt(st)}),p.prototype.readIntLE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I],st=1,ft=0;for(;++ft<O&&(st*=256);)V+=this[I+ft]*st;return st*=128,V>=st&&(V-=Math.pow(2,8*O)),V},p.prototype.readIntBE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=O,st=1,ft=this[I+--V];for(;V>0&&(st*=256);)ft+=this[I+--V]*st;return st*=128,ft>=st&&(ft-=Math.pow(2,8*O)),ft},p.prototype.readInt8=function(I,O){return I=I>>>0,O||b(I,1,this.length),this[I]&128?(255-this[I]+1)*-1:this[I]},p.prototype.readInt16LE=function(I,O){I=I>>>0,O||b(I,2,this.length);let L=this[I]|this[I+1]<<8;return L&32768?L|4294901760:L},p.prototype.readInt16BE=function(I,O){I=I>>>0,O||b(I,2,this.length);let L=this[I+1]|this[I]<<8;return L&32768?L|4294901760:L},p.prototype.readInt32LE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]|this[I+1]<<8|this[I+2]<<16|this[I+3]<<24},p.prototype.readInt32BE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]<<24|this[I+1]<<16|this[I+2]<<8|this[I+3]},p.prototype.readBigInt64LE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=this[I+4]+this[I+5]*2**8+this[I+6]*2**16+(L<<24);return(BigInt(V)<<BigInt(32))+BigInt(O+this[++I]*2**8+this[++I]*2**16+this[++I]*2**24)}),p.prototype.readBigInt64BE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=(O<<24)+this[++I]*2**16+this[++I]*2**8+this[++I];return(BigInt(V)<<BigInt(32))+BigInt(this[++I]*2**24+this[++I]*2**16+this[++I]*2**8+L)}),p.prototype.readFloatLE=function(I,O){return I=I>>>0,O||b(I,4,this.length),r.read(this,I,!0,23,4)},p.prototype.readFloatBE=function(I,O){return I=I>>>0,O||b(I,4,this.length),r.read(this,I,!1,23,4)},p.prototype.readDoubleLE=function(I,O){return I=I>>>0,O||b(I,8,this.length),r.read(this,I,!0,52,8)},p.prototype.readDoubleBE=function(I,O){return I=I>>>0,O||b(I,8,this.length),r.read(this,I,!1,52,8)};function _(I,O,L,V,st,ft){if(!p.isBuffer(I))throw new TypeError('"buffer" argument must be a Buffer instance');if(O>st||O<ft)throw new RangeError('"value" argument is out of bounds');if(L+V>I.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(I,O,L,V){if(I=+I,O=O>>>0,L=L>>>0,!V){let ht=Math.pow(2,8*L)-1;_(this,I,O,L,ht,0)}let st=1,ft=0;for(this[O]=I&255;++ft<L&&(st*=256);)this[O+ft]=I/st&255;return O+L},p.prototype.writeUintBE=p.prototype.writeUIntBE=function(I,O,L,V){if(I=+I,O=O>>>0,L=L>>>0,!V){let ht=Math.pow(2,8*L)-1;_(this,I,O,L,ht,0)}let st=L-1,ft=1;for(this[O+st]=I&255;--st>=0&&(ft*=256);)this[O+st]=I/ft&255;return O+L},p.prototype.writeUint8=p.prototype.writeUInt8=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,1,255,0),this[O]=I&255,O+1},p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,65535,0),this[O]=I&255,this[O+1]=I>>>8,O+2},p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,65535,0),this[O]=I>>>8,this[O+1]=I&255,O+2},p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,4294967295,0),this[O+3]=I>>>24,this[O+2]=I>>>16,this[O+1]=I>>>8,this[O]=I&255,O+4},p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,4294967295,0),this[O]=I>>>24,this[O+1]=I>>>16,this[O+2]=I>>>8,this[O+3]=I&255,O+4};function k(I,O,L,V,st){U(O,V,st,I,L,7);let ft=Number(O&BigInt(4294967295));I[L++]=ft,ft=ft>>8,I[L++]=ft,ft=ft>>8,I[L++]=ft,ft=ft>>8,I[L++]=ft;let ht=Number(O>>BigInt(32)&BigInt(4294967295));return I[L++]=ht,ht=ht>>8,I[L++]=ht,ht=ht>>8,I[L++]=ht,ht=ht>>8,I[L++]=ht,L}function $(I,O,L,V,st){U(O,V,st,I,L,7);let ft=Number(O&BigInt(4294967295));I[L+7]=ft,ft=ft>>8,I[L+6]=ft,ft=ft>>8,I[L+5]=ft,ft=ft>>8,I[L+4]=ft;let ht=Number(O>>BigInt(32)&BigInt(4294967295));return I[L+3]=ht,ht=ht>>8,I[L+2]=ht,ht=ht>>8,I[L+1]=ht,ht=ht>>8,I[L]=ht,L+8}p.prototype.writeBigUInt64LE=ne(function(I,O=0){return k(this,I,O,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeBigUInt64BE=ne(function(I,O=0){return $(this,I,O,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeIntLE=function(I,O,L,V){if(I=+I,O=O>>>0,!V){let Et=Math.pow(2,8*L-1);_(this,I,O,L,Et-1,-Et)}let st=0,ft=1,ht=0;for(this[O]=I&255;++st<L&&(ft*=256);)I<0&&ht===0&&this[O+st-1]!==0&&(ht=1),this[O+st]=(I/ft>>0)-ht&255;return O+L},p.prototype.writeIntBE=function(I,O,L,V){if(I=+I,O=O>>>0,!V){let Et=Math.pow(2,8*L-1);_(this,I,O,L,Et-1,-Et)}let st=L-1,ft=1,ht=0;for(this[O+st]=I&255;--st>=0&&(ft*=256);)I<0&&ht===0&&this[O+st+1]!==0&&(ht=1),this[O+st]=(I/ft>>0)-ht&255;return O+L},p.prototype.writeInt8=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,1,127,-128),I<0&&(I=255+I+1),this[O]=I&255,O+1},p.prototype.writeInt16LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,32767,-32768),this[O]=I&255,this[O+1]=I>>>8,O+2},p.prototype.writeInt16BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,32767,-32768),this[O]=I>>>8,this[O+1]=I&255,O+2},p.prototype.writeInt32LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,2147483647,-2147483648),this[O]=I&255,this[O+1]=I>>>8,this[O+2]=I>>>16,this[O+3]=I>>>24,O+4},p.prototype.writeInt32BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,2147483647,-2147483648),I<0&&(I=4294967295+I+1),this[O]=I>>>24,this[O+1]=I>>>16,this[O+2]=I>>>8,this[O+3]=I&255,O+4},p.prototype.writeBigInt64LE=ne(function(I,O=0){return k(this,I,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),p.prototype.writeBigInt64BE=ne(function(I,O=0){return $(this,I,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function it(I,O,L,V,st,ft){if(L+V>I.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("Index out of range")}function Z(I,O,L,V,st){return O=+O,L=L>>>0,st||it(I,O,L,4,34028234663852886e22,-34028234663852886e22),r.write(I,O,L,V,23,4),L+4}p.prototype.writeFloatLE=function(I,O,L){return Z(this,I,O,!0,L)},p.prototype.writeFloatBE=function(I,O,L){return Z(this,I,O,!1,L)};function et(I,O,L,V,st){return O=+O,L=L>>>0,st||it(I,O,L,8,17976931348623157e292,-17976931348623157e292),r.write(I,O,L,V,52,8),L+8}p.prototype.writeDoubleLE=function(I,O,L){return et(this,I,O,!0,L)},p.prototype.writeDoubleBE=function(I,O,L){return et(this,I,O,!1,L)},p.prototype.copy=function(I,O,L,V){if(!p.isBuffer(I))throw new TypeError("argument should be a Buffer");if(L||(L=0),!V&&V!==0&&(V=this.length),O>=I.length&&(O=I.length),O||(O=0),V>0&&V<L&&(V=L),V===L||I.length===0||this.length===0)return 0;if(O<0)throw new RangeError("targetStart out of bounds");if(L<0||L>=this.length)throw new RangeError("Index out of range");if(V<0)throw new RangeError("sourceEnd out of bounds");V>this.length&&(V=this.length),I.length-O<V-L&&(V=I.length-O+L);let st=V-L;return this===I&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(O,L,V):Uint8Array.prototype.set.call(I,this.subarray(L,V),O),st},p.prototype.fill=function(I,O,L,V){if(typeof I=="string"){if(typeof O=="string"?(V=O,O=0,L=this.length):typeof L=="string"&&(V=L,L=this.length),V!==void 0&&typeof V!="string")throw new TypeError("encoding must be a string");if(typeof V=="string"&&!p.isEncoding(V))throw new TypeError("Unknown encoding: "+V);if(I.length===1){let ft=I.charCodeAt(0);(V==="utf8"&&ft<128||V==="latin1")&&(I=ft)}}else typeof I=="number"?I=I&255:typeof I=="boolean"&&(I=Number(I));if(O<0||this.length<O||this.length<L)throw new RangeError("Out of range index");if(L<=O)return this;O=O>>>0,L=L===void 0?this.length:L>>>0,I||(I=0);let st;if(typeof I=="number")for(st=O;st<L;++st)this[st]=I;else{let ft=p.isBuffer(I)?I:p.from(I,V),ht=ft.length;if(ht===0)throw new TypeError('The value "'+I+'" is invalid for argument "value"');for(st=0;st<L-O;++st)this[st+O]=ft[st%ht]}return this};var Q={};function z(I,O,L){Q[I]=class extends L{constructor(){super(),Object.defineProperty(this,"message",{value:O.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${I}]`,this.stack,delete this.name}get code(){return I}set code(V){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:V,writable:!0})}toString(){return`${this.name} [${I}]: ${this.message}`}}}z("ERR_BUFFER_OUT_OF_BOUNDS",function(I){return I?`${I} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),z("ERR_INVALID_ARG_TYPE",function(I,O){return`The "${I}" argument must be of type number. Received type ${typeof O}`},TypeError),z("ERR_OUT_OF_RANGE",function(I,O,L){let V=`The value of "${I}" is out of range.`,st=L;return Number.isInteger(L)&&Math.abs(L)>2**32?st=tt(String(L)):typeof L=="bigint"&&(st=String(L),(L>BigInt(2)**BigInt(32)||L<-(BigInt(2)**BigInt(32)))&&(st=tt(st)),st+="n"),V+=` It must be ${O}. Received ${st}`,V},RangeError);function tt(I){let O="",L=I.length,V=I[0]==="-"?1:0;for(;L>=V+4;L-=3)O=`_${I.slice(L-3,L)}${O}`;return`${I.slice(0,L)}${O}`}function X(I,O,L){j(O,"offset"),(I[O]===void 0||I[O+L]===void 0)&&rt(O,I.length-(L+1))}function U(I,O,L,V,st,ft){if(I>L||I<O){let ht=typeof O=="bigint"?"n":"",Et;throw ft>3?O===0||O===BigInt(0)?Et=`>= 0${ht} and < 2${ht} ** ${(ft+1)*8}${ht}`:Et=`>= -(2${ht} ** ${(ft+1)*8-1}${ht}) and < 2 ** ${(ft+1)*8-1}${ht}`:Et=`>= ${O}${ht} and <= ${L}${ht}`,new Q.ERR_OUT_OF_RANGE("value",Et,I)}X(V,st,ft)}function j(I,O){if(typeof I!="number")throw new Q.ERR_INVALID_ARG_TYPE(O,"number",I)}function rt(I,O,L){throw Math.floor(I)!==I?(j(I,L),new Q.ERR_OUT_OF_RANGE(L||"offset","an integer",I)):O<0?new Q.ERR_BUFFER_OUT_OF_BOUNDS:new Q.ERR_OUT_OF_RANGE(L||"offset",`>= ${L?1:0} and <= ${O}`,I)}var ot=/[^+/0-9A-Za-z-_]/g;function ct(I){if(I=I.split("=")[0],I=I.trim().replace(ot,""),I.length<2)return"";for(;I.length%4!==0;)I=I+"=";return I}function ut(I,O){O=O||1/0;let L,V=I.length,st=null,ft=[];for(let ht=0;ht<V;++ht){if(L=I.charCodeAt(ht),L>55295&&L<57344){if(!st){if(L>56319){(O-=3)>-1&&ft.push(239,191,189);continue}else if(ht+1===V){(O-=3)>-1&&ft.push(239,191,189);continue}st=L;continue}if(L<56320){(O-=3)>-1&&ft.push(239,191,189),st=L;continue}L=(st-55296<<10|L-56320)+65536}else st&&(O-=3)>-1&&ft.push(239,191,189);if(st=null,L<128){if((O-=1)<0)break;ft.push(L)}else if(L<2048){if((O-=2)<0)break;ft.push(L>>6|192,L&63|128)}else if(L<65536){if((O-=3)<0)break;ft.push(L>>12|224,L>>6&63|128,L&63|128)}else if(L<1114112){if((O-=4)<0)break;ft.push(L>>18|240,L>>12&63|128,L>>6&63|128,L&63|128)}else throw new Error("Invalid code point")}return ft}function pt(I){let O=[];for(let L=0;L<I.length;++L)O.push(I.charCodeAt(L)&255);return O}function St(I,O){let L,V,st,ft=[];for(let ht=0;ht<I.length&&!((O-=2)<0);++ht)L=I.charCodeAt(ht),V=L>>8,st=L%256,ft.push(st),ft.push(V);return ft}function bt(I){return t.toByteArray(ct(I))}function lt(I,O,L,V){let st;for(st=0;st<V&&!(st+L>=O.length||st>=I.length);++st)O[st+L]=I[st];return st}function mt(I,O){return I instanceof O||I!=null&&I.constructor!=null&&I.constructor.name!=null&&I.constructor.name===O.name}function wt(I){return I!==I}var Mt=function(){let I="0123456789abcdef",O=new Array(256);for(let L=0;L<16;++L){let V=L*16;for(let st=0;st<16;++st)O[V+st]=I[L]+I[st]}return O}();function ne(I){return typeof BigInt>"u"?nt:I}function nt(){throw new Error("BigInt not supported")}}),mMt=Nu((i,t)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,t.exports={Buffer:kR().Buffer,Crypto:window.crypto}):t.exports={Buffer:kR().Buffer,Crypto:crypto}}),get={};uMt(get,{AVSCTap:()=>wm,ArweaveSigner:()=>ZR,DataItem:()=>pm,MAX_TAG_BYTES:()=>m8,MIN_BINARY_SIZE:()=>YR,SIG_CONFIG:()=>rp,SignatureConfig:()=>Ks,Signer:()=>met,createData:()=>wet,deserializeTags:()=>s8,indexToType:()=>JR,serializeTags:()=>XR,tagsExceedLimit:()=>bet});var met=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(i,t,r,h){throw new Error("You must implement verify method on child")}},vMt=D0(VR(),1),jh=D0(pet(),1);async function vet(i){if(Array.isArray(i)){let o=(0,jh.concatBuffers)([(0,jh.stringToBuffer)("list"),(0,jh.stringToBuffer)(i.length.toString())]);return await yet(i,await Bu().hash(o,"SHA-384"))}let t=i,r=(0,jh.concatBuffers)([(0,jh.stringToBuffer)("blob"),(0,jh.stringToBuffer)(t.byteLength.toString())]),h=(0,jh.concatBuffers)([await Bu().hash(r,"SHA-384"),await Bu().hash(t,"SHA-384")]);return await Bu().hash(h,"SHA-384")}async function yet(i,t){if(i.length<1)return t;let r=(0,jh.concatBuffers)([t,await vet(i[0])]),h=await Bu().hash(r,"SHA-384");return await yet(i.slice(1),h)}var pR=D0(pMt(),1),yMt=pR.default.default?pR.default.default:pR.default,bMt=class extends yMt{getPublicKey(i){throw new Error("Unimplemented")}},wMt;function Bu(){return wMt??=new bMt}var Ks;(function(i){i[i.ARWEAVE=1]="ARWEAVE",i[i.ED25519=2]="ED25519",i[i.ETHEREUM=3]="ETHEREUM",i[i.SOLANA=4]="SOLANA",i[i.INJECTEDAPTOS=5]="INJECTEDAPTOS",i[i.MULTIAPTOS=6]="MULTIAPTOS",i[i.TYPEDETHEREUM=7]="TYPEDETHEREUM"})(Ks||(Ks={}));var rp={[Ks.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[Ks.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[Ks.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[Ks.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[Ks.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[Ks.MULTIAPTOS]:{sigLength:64*32+4,pubLength:32*32+1,sigName:"multiAptos"},[Ks.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},ZR=class{signatureType=1;ownerLength=rp[1].pubLength;signatureLength=rp[1].sigLength;jwk;pk;constructor(i){this.pk=i.n,this.jwk=i}get publicKey(){return vMt.default.toBuffer(this.pk)}sign(i){return Bu().sign(this.jwk,i)}static async verify(i,t,r){return await Bu().verify(i,t,r)}},JR={1:ZR},If=D0(VR(),1);async function IR(i){return vet([(0,jh.stringToBuffer)("dataitem"),(0,jh.stringToBuffer)("1"),(0,jh.stringToBuffer)(i.signatureType.toString()),i.rawOwner,i.rawTarget,i.rawAnchor,i.rawTags,i.rawData])}async function _Mt(i,t){let r=await IR(i),h=await t.sign(r),o=await Bu().hash(h);return{signature:ge.from(h),id:ge.from(o)}}async function MMt(i,t){let{signature:r,id:h}=await _Mt(i,t);return i.getRaw().set(r,2),h}var wm=class{buf;pos;constructor(i=ge.alloc(m8),t=0){this.buf=i,this.pos=t}writeTags(i){if(!Array.isArray(i))throw new Error("input must be array");let t=i.length,r;if(t)for(this.writeLong(t),r=0;r<t;r++){let h=i[r];if(h?.name===void 0||h?.value===void 0)throw new Error(`Invalid tag format for ${h}, expected {name:string, value: string}`);this.writeString(h.name),this.writeString(h.value)}this.writeLong(0)}toBuffer(){let i=ge.alloc(this.pos);if(this.pos>this.buf.length)throw new Error(`Too many tag bytes (${this.pos} > ${this.buf.length})`);return this.buf.copy(i,0,0,this.pos),i}tagsExceedLimit(){return this.pos>this.buf.length}writeLong(i){let t=this.buf,r,h;if(i>=-1073741824&&i<1073741824){h=i>=0?i<<1:~i<<1|1;do t[this.pos]=h&127,h>>=7;while(h&&(t[this.pos++]|=128))}else{r=i>=0?i*2:-i*2-1;do t[this.pos]=r&127,r/=128;while(r>=1&&(t[this.pos++]|=128))}this.pos++,this.buf=t}writeString(i){let t=ge.byteLength(i),r=this.buf;this.writeLong(t);let h=this.pos;if(this.pos+=t,!(this.pos>r.length)){if(t>64)this.buf.write(i,this.pos-t,t,"utf8");else{let o,l,c,p;for(o=0,l=t;o<l;o++)c=i.charCodeAt(o),c<128?r[h++]=c:c<2048?(r[h++]=c>>6|192,r[h++]=c&63|128):(c&64512)===55296&&((p=i.charCodeAt(o+1))&64512)===56320?(c=65536+((c&1023)<<10)+(p&1023),o++,r[h++]=c>>18|240,r[h++]=c>>12&63|128,r[h++]=c>>6&63|128,r[h++]=c&63|128):(r[h++]=c>>12|224,r[h++]=c>>6&63|128,r[h++]=c&63|128)}this.buf=r}}readLong(){let i=0,t=0,r=this.buf,h,o,l,c;do h=r[this.pos++],o=h&128,i|=(h&127)<<t,t+=7;while(o&&t<28);if(o){l=i,c=268435456;do h=r[this.pos++],l+=(h&127)*c,c*=128;while(h&128);return(l%2?-(l+1):l)/2}return i>>1^-(i&1)}skipLong(){let i=this.buf;for(;i[this.pos++]&128;);}readTags(){let i=[],t;for(;t=this.readLong();)for(t<0&&(t=-t,this.skipLong());t--;){let r=this.readString(),h=this.readString();i.push({name:r,value:h})}return i}readString(){let i=this.readLong(),t=this.pos,r=this.buf;if(this.pos+=i,!(this.pos>r.length))return this.buf.slice(t,t+i).toString()}};function XR(i){let t=new wm;return t.writeTags(i),t.toBuffer()}function bet(i){let t=new wm;return t.writeTags(i),t.tagsExceedLimit()}function s8(i){return new wm(i).readTags()}function Gc(i){let t=0;for(let r=i.length-1;r>=0;r--)t=t*256+i[r];return t}function SMt(i){if(i>29)throw new Error("Short too long");let t=[0,0];for(let r=0;r<t.length;r++){let h=i&255;t[r]=h,i=(i-h)/256}return Uint8Array.from(t)}function ott(i){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let h=i&255;t[r]=h,i=(i-h)/256}return Uint8Array.from(t)}var EMt=D0(mMt(),1),z1=D0(kR(),1),m8=4096,YR=80,pm=class{binary;_id;constructor(i){this.binary=i}static isDataItem(i){return i.binary!==void 0}get signatureType(){let i=Gc(this.binary.subarray(0,2));if(Ks?.[i]!==void 0)return i;throw new Error("Unknown signature type: "+i)}async isValid(){return pm.verify(this.binary)}get id(){return(async()=>If.default.encode(await this.rawId))()}set id(i){this._id=If.default.toBuffer(i)}get rawId(){return(async()=>z1.Buffer.from(await EMt.Crypto.subtle.digest("SHA-256",this.rawSignature)))()}set rawId(i){this._id=i}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return If.default.encode(this.rawSignature)}set rawOwner(i){if(i.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${i.byteLength} bytes.`);this.binary.set(i,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return rp[this.signatureType].sigLength}get owner(){return If.default.encode(this.rawOwner)}get ownerLength(){return rp[this.signatureType].pubLength}get rawTarget(){let i=this.getTargetStart();return this.binary[i]==1?this.binary.subarray(i+1,i+33):z1.Buffer.alloc(0)}get target(){return If.default.encode(this.rawTarget)}get rawAnchor(){let i=this.getAnchorStart();return this.binary[i]==1?this.binary.subarray(i+1,i+33):z1.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let i=this.getTagsStart(),t=Gc(this.binary.subarray(i+8,i+16));return this.binary.subarray(i+16,i+16+t)}get tags(){let i=this.getTagsStart();if(Gc(this.binary.subarray(i,i+8))==0)return[];let t=Gc(this.binary.subarray(i+8,i+16));return s8(z1.Buffer.from(this.binary.subarray(i+16,i+16+t)))}get tagsB64Url(){return this.tags.map(i=>({name:If.default.encode(i.name),value:If.default.encode(i.value)}))}getStartOfData(){let i=this.getTagsStart(),t=this.binary.subarray(i+8,i+16),r=Gc(t);return i+16+r}get rawData(){let i=this.getTagsStart(),t=this.binary.subarray(i+8,i+16),r=Gc(t),h=i+16+r;return this.binary.subarray(h,this.binary.length)}get data(){return If.default.encode(this.rawData)}getRaw(){return this.binary}async sign(i){return this._id=await MMt(this,i),this.rawId}async setSignature(i){this.binary.set(i,2),this._id=z1.Buffer.from(await Bu().hash(i))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map(i=>({name:If.default.encode(i.name),value:If.default.encode(i.value)})),data:this.data}}static async verify(i){if(i.byteLength<YR)return!1;let t=new pm(i),r=t.signatureType,h=t.getTagsStart(),o=Gc(i.subarray(h,h+8)),l=i.subarray(h+8,h+16),c=Gc(l);if(c>m8)return!1;if(o>0)try{if(s8(z1.Buffer.from(i.subarray(h+16,h+16+c))).length!==o)return!1}catch{return!1}let p=JR[r],w=await IR(t);return await p.verify(t.rawOwner,w,t.rawSignature)}async getSignatureData(){return IR(this)}getTagsStart(){let i=this.getTargetStart(),t=this.binary[i]==1,r=i+(t?33:1),h=this.binary[r]==1;return r+=h?33:1,r}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let i=this.getTargetStart()+1,t=this.binary[this.getTargetStart()]==1;return i+=t?32:0,i}},AMt=D0(VR(),1);function wet(i,t,r){let h=t.publicKey,o=r?.target?AMt.default.toBuffer(r.target):null,l=1+(o?.byteLength??0),c=r?.anchor?ge.from(r.anchor):null,p=1+(c?.byteLength??0),w=(r?.tags?.length??0)>0?XR(r.tags):null,m=16+(w?w.byteLength:0),y=ge.from(i),v=y.byteLength,M=2+t.signatureLength+t.ownerLength+l+p+m+v,T=ge.alloc(M);if(T.set(SMt(t.signatureType),0),T.set(new Uint8Array(t.signatureLength).fill(0),2),h.byteLength!==t.ownerLength)throw new Error(`Owner must be ${t.ownerLength} bytes, but was incorrectly ${h.byteLength}`);T.set(h,2+t.signatureLength);let A=2+t.signatureLength+t.ownerLength;if(T[A]=o?1:0,o){if(o.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${o.byteLength}`);T.set(o,A+1)}let R=A+l,B=R+1;if(T[R]=c?1:0,c){if(B+=c.byteLength,c.byteLength!==32)throw new Error("Anchor must be 32 bytes");T.set(c,R+1)}T.set(ott(r?.tags?.length??0),B);let C=ott(w?.byteLength??0);T.set(C,B+8),w&&T.set(w,B+16);let P=B+m;return T.set(y,P),new pm(T)}var QR={...get};globalThis.arbundles??=QR;var TMt=QR,xMt=QR;globalThis.Buffer||(globalThis.Buffer=uet.Buffer);var{DataItem:RMt}=cet;function kMt(i){return async({data:r,tags:h,target:o,anchor:l,createDataItem:c=p=>new RMt(p)})=>{let p=await i.signDataItem({data:r,tags:h,target:o,anchor:l}),w=c(uet.Buffer.from(p));return{id:await w.id,raw:await w.getRaw()}}}var IMt=globalThis.GATEWAY_URL||void 0,BMt=globalThis.MU_URL||void 0,OMt=globalThis.CU_URL||void 0,CMt=globalThis.GRAPHQL_URL||void 0,{result:wWt,results:_Wt,message:MWt,spawn:SWt,monitor:EWt,unmonitor:AWt,dryrun:TWt,assign:xWt}=bm({GATEWAY_URL:IMt,MU_URL:BMt,CU_URL:OMt,GRAPHQL_URL:CMt}),RWt=fet.createDataItemSigner;var _et=Sl(U5(),1);var Js=class i{logger;processId;ao;constructor({processId:t,ao:r=bm(),logger:h=new la({level:"info"})}){this.processId=t,this.logger=h,this.ao=r}static async createAoSigner(t){return t.publicKey===void 0&&"setPublicKey"in t&&await t.setPublicKey(),async({data:h,tags:o,target:l,anchor:c})=>{let p=(0,_et.createData)(h,t,{tags:o,target:l,anchor:c});return p.sign(t).then(async()=>({id:await p.id,raw:await p.getRaw()}))}}async read({tags:t,retries:r=3}){let h=0,o;for(;h<r;)try{this.logger.debug("Evaluating read interaction on contract",{tags:t});let l=await this.ao.dryrun({process:this.processId,tags:t});if(l.Messages.length===0)throw new Error(`Process ${this.processId} does not support provided action.`);let p=l.Messages[0].Tags.find(m=>m.name==="Error");if(p)throw new Error(`${p.Value}: ${l.Messages[0].Data}`);return this.logger.debug("Read interaction result",{result:l.Messages[0]?.Data}),JSON.parse(l.Messages[0]?.Data)}catch(l){h++,this.logger.debug(`Read attempt ${h} failed`,{error:l,tags:t}),o=l,await new Promise(c=>setTimeout(c,2**h*1e3))}throw o}async send({tags:t,data:r,signer:h,retries:o=3}){let l=0,c;for(;l<o;)try{this.logger.debug("Evaluating send interaction on contract",{tags:t,data:r,processId:this.processId});let p=await this.ao.message({process:this.processId,tags:[...t,{name:"AR-IO-SDK",value:r1}],data:typeof r!="string"?JSON.stringify(r):r,signer:await i.createAoSigner(h)});this.logger.debug("Sent message to process",{messageId:p,processId:this.processId});let w=await this.ao.result({message:p,process:this.processId});if(this.logger.debug("Message result",{output:w,messageId:p,processId:this.processId}),w.Messages?.length===0||w.Messages===void 0)return{id:p};let y=w.Messages[0].Tags.find(M=>M.name==="Error");if(y){let M=w.Messages[0].Data;throw new i1(`${y.Value}: ${M}`)}let v=JSON.parse(w.Messages[0].Data);return this.logger.debug("Message result data",{resultData:v,messageId:p,processId:this.processId}),{id:p,result:v}}catch(p){if(this.logger.error("Error sending message to process",{error:p.message,processId:this.processId,tags:t}),p.message.includes("500"))this.logger.debug("Retrying send interaction",{attempts:l,retries:o,error:p.message,processId:this.processId}),await new Promise(w=>setTimeout(w,2**l*2e3)),l++,c=p;else throw p}throw c}};var v8=class{static init(t){if(t&&t.signer){let{signer:r,...h}=t;return new tk({...h,signer:r})}return new y8(t)}},y8=class{process;arweave;constructor(t,r=Met.default.init({})){if(!t)this.process=new Js({processId:Qp});else if(Tl(t))this.process=t.process;else if(xl(t))this.process=new Js({processId:t.processId,logger:new la({level:"info"})});else throw new No;this.arweave=r}async getEpoch(t){let h=[{name:"Action",value:"Epoch"},{name:"Timestamp",value:t.timestamp?.toString()??""},{name:"Block-Height",value:t?.blockHeight?.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return h.length===1&&h.push({name:"Timestamp",value:(await this.arweave.blocks.getCurrent()).timestamp.toString()}),this.process.read({tags:h})}async getArNSRecord({name:t}){return this.process.read({tags:[{name:"Action",value:"Record"},{name:"Name",value:t}]})}async getArNSRecords(){return this.process.read({tags:[{name:"Action",value:"Records"}]})}async getArNSReservedNames(){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"}]})}async getArNSReservedName({name:t}){return this.process.read({tags:[{name:"Action",value:"Reserved-Name"},{name:"Name",value:t}]})}async getBalance({address:t}){return this.process.read({tags:[{name:"Action",value:"Balance"},{name:"Address",value:t}]})}async getBalances(){return this.process.read({tags:[{name:"Action",value:"Balances"}]})}async getGateway({address:t}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:t}]})}async getGateways(){return this.process.read({tags:[{name:"Action",value:"Gateways"}]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"},{name:"Timestamp",value:`${Date.now()}`}]})}async getPrescribedObservers(t){let h=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Timestamp",value:t.timestamp?.toString()},{name:"Block-Height",value:t?.blockHeight?.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return h.length===1&&h.push({name:"Timestamp",value:`${Date.now()}`}),this.process.read({tags:h})}async getPrescribedNames(t){let h=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Timestamp",value:t.timestamp?.toString()},{name:"Block-Height",value:t?.blockHeight?.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return h.length===1&&h.push({name:"Timestamp",value:`${Date.now()}`}),this.process.read({tags:h})}async getObservations(t){let h=[{name:"Action",value:"Epoch-Observations"},{name:"Timestamp",value:t.timestamp?.toString()},{name:"Block-Height",value:t?.blockHeight?.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return h.length===1&&h.push({name:"Timestamp",value:(await this.arweave.blocks.getCurrent()).timestamp.toString()}),this.process.read({tags:h})}async getDistributions(t){let h=[{name:"Action",value:"Epoch-Distributions"},{name:"Timestamp",value:t.timestamp?.toString()??""},{name:"Block-Height",value:t?.blockHeight?.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return h.length===1&&h.push({name:"Timestamp",value:(await this.arweave.blocks.getCurrent()).timestamp.toString()}),this.process.read({tags:h})}async getTokenCost({intent:t,purchaseType:r,years:h,name:o,quantity:l}){let p=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:t},{name:"Name",value:o},{name:"Years",value:h?.toString()},{name:"Quantity",value:l?.toString()},{name:"Purchase-Type",value:r}].filter(w=>w.value!==void 0);return this.process.read({tags:p})}},tk=class extends y8{signer;constructor({signer:t,...r}){if(Object.keys(r).length===0)super({process:new Js({processId:Qp})}),this.signer=t;else if(Tl(r))super({process:r.process}),this.signer=t;else if(xl(r))super({process:new Js({processId:r.processId})}),this.signer=t;else throw new No}async transfer({target:t,qty:r},h){let{tags:o=[]}=h||{};return this.process.send({tags:[...o,{name:"Action",value:"Transfer"},{name:"Recipient",value:t},{name:"Quantity",value:r.valueOf().toString()}],signer:this.signer})}async joinNetwork({operatorStake:t,allowDelegatedStaking:r,delegateRewardShareRatio:h,fqdn:o,label:l,minDelegatedStake:c,note:p,port:w,properties:m,protocol:y,autoStake:v,observerAddress:M},T){let{tags:A=[]}=T||{},B=[...A,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:t.valueOf().toString()},{name:"Allow-Delegated-Staking",value:r.toString()},{name:"Delegate-Reward-Share-Ratio",value:h.toString()},{name:"FQDN",value:o},{name:"Label",value:l},{name:"Min-Delegated-Stake",value:c.valueOf().toString()},{name:"Note",value:p},{name:"Port",value:w.toString()},{name:"Properties",value:m},{name:"Protocol",value:y},{name:"Auto-Stake",value:v.toString()},{name:"Observer-Address",value:M}].filter(C=>C.value!==void 0);return this.process.send({signer:this.signer,tags:B})}async updateGatewaySettings({allowDelegatedStaking:t,delegateRewardShareRatio:r,fqdn:h,label:o,minDelegatedStake:l,note:c,port:p,properties:w,protocol:m,autoStake:y,observerAddress:v},M){let{tags:T=[]}=M||{},R=[...T,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:o},{name:"Note",value:c},{name:"FQDN",value:h},{name:"Port",value:p?.toString()},{name:"Properties",value:w},{name:"Protocol",value:m},{name:"Observer-Address",value:v},{name:"Allow-Delegated-Staking",value:t?.toString()},{name:"Delegate-Reward-Share-Ratio",value:r?.toString()},{name:"Min-Delegated-Stake",value:l?.valueOf().toString()},{name:"Auto-Stake",value:y?.toString()}].filter(B=>B.value!==void 0);return this.process.send({signer:this.signer,tags:R})}async delegateStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:t.target},{name:"Quantity",value:t.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Decrease-Delegate-Stake"},{name:"Target",value:t.target},{name:"Quantity",value:t.decreaseQty.valueOf().toString()}]})}async increaseOperatorStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:t.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:t.decreaseQty.valueOf().toString()}]})}async saveObservations(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:t.reportTxId},{name:"Failed-Gateways",value:t.failedGateways.join(",")}],data:{reportTxId:t.reportTxId,failedGateways:t.failedGateways}})}async buyRecord(t,r){let{tags:h=[]}=r||{},l=[...h,{name:"Action",value:"Buy-Record"},{name:"Name",value:t.name},{name:"Years",value:t.years?.toString()??"1"},{name:"Process-Id",value:t.processId},{name:"Purchase-Type",value:t.type||"lease"}].filter(c=>c.value!==void 0);return this.process.send({signer:this.signer,tags:l})}async extendLease(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Extend-Lease"},{name:"Name",value:t.name},{name:"Years",value:t.years.toString()}]})}async increaseUndernameLimit(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Increase-Undername-Limit"},{name:"Name",value:t.name},{name:"Quantity",value:t.increaseCount.toString()}]})}};var PMt=rF(50),KKt=async({address:i,contract:t=v8.init({processId:Qp})})=>{let r=await t.getArNSRecords().then(o=>Object.values(o).filter(l=>l.processId!==void 0).map(l=>l.processId)),h=await Promise.all(r.filter(async o=>PMt(async()=>{let l=ky.init({processId:o}),c=await l.getOwner(),p=await l.getControllers();return c===i||p.includes(i)})));return[...new Set(h)]};Tt();Rt();xt();Tt();Rt();xt();var Eet=Sl(aR(),1),b8=Eet.default.init({host:"arweave.net",port:443,protocol:"https"});async function uHt({signer:i,module:t=wL,luaCodeTxId:r=_L,ao:h=bm(),scheduler:o=ML,state:l,stateContractTxId:c}){let p=await b8.transactions.getData(r,{decode:!0,string:!0}),w=await h.spawn({module:t,scheduler:o,signer:await Js.createAoSigner(i)}),m=new Js({processId:w,ao:h});return await m.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:r}],data:p,signer:i}),l&&await m.send({tags:[{name:"Action",value:"Initialize-State"},...c!==void 0?[{name:"State-Contract-TX-ID",value:c}]:[]],data:JSON.stringify(l),signer:i}),w}var w8=class{axios;logger;constructor({url:t,logger:r=new la}){this.logger=r,this.axios=Yq({axiosConfig:{baseURL:t},logger:this.logger})}async get({endpoint:t,signal:r,allowedStatuses:h=[200,202],headers:o,params:l}){this.logger.debug(`Get request to endpoint: ${t} with params ${JSON.stringify(l,void 0,2)}`);let{status:c,statusText:p,data:w}=await this.axios.get(t,{headers:o,signal:r,params:l});if(this.logger.debug(`Response status: ${c} ${p}`),!h.includes(c))switch(c){case 404:throw new xy(p);case 400:throw new Wl(c,p);default:throw new Ry(p)}return w}};var Kl=class{logger;http;contractTxId;cacheUrl;constructor({cacheUrl:t="https://api.arns.app",contractTxId:r,logger:h=new la}){this.cacheUrl=t,this.contractTxId=r,this.logger=h,this.http=new w8({url:`${t}/v1/contract/${r}`})}configuration(){return{contractTxId:this.contractTxId,cacheUrl:this.cacheUrl}}async getState({evaluationOptions:t}={}){this.logger.debug("Fetching contract state",{contractTxId:this.contractTxId,evaluationOptions:t});let{state:r}=await this.http.get({endpoint:"",params:{...t?.evalTo}});return r}async readInteraction({functionName:t,inputs:r,evaluationOptions:h}){this.logger.debug("Evaluating read interaction on contract",{functionName:t,inputs:r,evaluationOptions:h});let{result:o}=await this.http.get({endpoint:`/read/${t}`,params:{...h?.evalTo,...r}});return o}};var Aet=class{static createWriteableContract(t){if(!t||Object.keys(t).length===0)return new da({contractTxId:y6});if(Jf(t))return t.contract instanceof da?t.contract:new da(t.contract.configuration());if(Xf(t))return new da({contractTxId:t.contractTxId});throw new No}static init(t){if(t&&t.signer!==void 0){let{signer:r,...h}=t,o=this.createWriteableContract(h);return new ek({signer:r,contract:o})}else return new _8(t)}},_8=class{contract;constructor(t){if(!t||t===void 0)this.contract=new Kl({contractTxId:y6});else if(Jf(t))this.contract=t.contract;else if(Xf(t))this.contract=new Kl({contractTxId:t.contractTxId});else throw new No}async getState(t={}){return await this.contract.getState(t)}async getArNSRecord({domain:t,evaluationOptions:r}){return(await this.getArNSRecords({evaluationOptions:r}))[t]}async getArNSRecords({evaluationOptions:t}={}){return(await this.contract.getState({evaluationOptions:t})).records}async getArNSReservedNames({evaluationOptions:t}={}){return(await this.contract.getState({evaluationOptions:t})).reserved}async getArNSReservedName({domain:t,evaluationOptions:r}){return(await this.getArNSReservedNames({evaluationOptions:r}))[t]}async getBalance({address:t,evaluationOptions:r}){return(await this.getBalances({evaluationOptions:r}))[t]||0}async getBalances({evaluationOptions:t}={}){return(await this.contract.getState({evaluationOptions:t})).balances}async getGateway({address:t,evaluationOptions:r}){return this.contract.readInteraction({functionName:ho.GATEWAY,inputs:{target:t},evaluationOptions:r}).catch(()=>{})}async getGateways({evaluationOptions:t}={}){return this.contract.readInteraction({functionName:ho.GATEWAYS,evaluationOptions:t})}async getCurrentEpoch({evaluationOptions:t}={}){return this.contract.readInteraction({functionName:ho.EPOCH,evaluationOptions:t})}async getEpoch({blockHeight:t,evaluationOptions:r}){return this.contract.readInteraction({functionName:ho.EPOCH,inputs:{height:t},evaluationOptions:r})}async getPrescribedObservers({evaluationOptions:t}={}){return this.contract.readInteraction({functionName:ho.PRESCRIBED_OBSERVERS,evaluationOptions:t})}async getObservations({evaluationOptions:t}={}){let{observations:r}=await this.contract.getState({evaluationOptions:t});return r}async getDistributions({evaluationOptions:t}={}){let{distributions:r}=await this.contract.getState({evaluationOptions:t});return r}async getAuction({domain:t,type:r,evaluationOptions:h}){return this.contract.readInteraction({functionName:ho.AUCTION,inputs:{name:t,type:r},evaluationOptions:h})}async getAuctions({evaluationOptions:t}={}){let{auctions:r}=await this.contract.getState({evaluationOptions:t});return r}async getPriceForInteraction({interactionName:t,payload:r,evaluationOptions:h}){let{price:o}=await this.contract.readInteraction({functionName:ho.PRICE_FOR_INTERACTION,inputs:{interactionName:t,...r},evaluationOptions:h});return o}},ek=class extends _8{signer;constructor({signer:t,...r}){if(Object.keys(r).length===0)super({contract:new da({contractTxId:y6})}),this.signer=t;else if(Jf(r))super({contract:r.contract}),this.signer=t;else if(Xf(r))super({contract:new da({contractTxId:r.contractTxId})}),this.signer=t;else throw new No}async transfer({target:t,qty:r,denomination:h="IO"},o){let l=r;return h==="IO"&&typeof r=="number"&&(l=new t2(r).toMIO()),this.contract.writeInteraction({functionName:ho.TRANSFER,inputs:{target:t,qty:l.valueOf()},signer:this.signer},o)}async joinNetwork({qty:t,allowDelegatedStaking:r,delegateRewardShareRatio:h,fqdn:o,label:l,minDelegatedStake:c,note:p,port:w,properties:m,protocol:y,autoStake:v,observerWallet:M},T){return this.contract.writeInteraction({functionName:ho.JOIN_NETWORK,inputs:{qty:t.valueOf(),allowDelegatedStaking:r,delegateRewardShareRatio:h,fqdn:o,label:l,minDelegatedStake:c.valueOf(),note:p,port:w,properties:m,protocol:y,autoStake:v,observerWallet:M},signer:this.signer},T)}async updateGatewaySettings({allowDelegatedStaking:t,delegateRewardShareRatio:r,fqdn:h,label:o,minDelegatedStake:l,note:c,port:p,properties:w,protocol:m,autoStake:y,observerWallet:v},M){return this.contract.writeInteraction({functionName:ho.UPDATE_GATEWAY_SETTINGS,inputs:{allowDelegatedStaking:t,delegateRewardShareRatio:r,fqdn:h,label:o,minDelegatedStake:l?.valueOf(),note:c,port:p,properties:w,protocol:m,autoStake:y,observerWallet:v},signer:this.signer},M)}async increaseDelegateStake(t,r){return this.contract.writeInteraction({functionName:ho.DELEGATE_STAKE,inputs:{target:t.target,qty:t.qty.valueOf()},signer:this.signer},r)}async decreaseDelegateStake(t,r){return this.contract.writeInteraction({functionName:ho.DECREASE_DELEGATE_STAKE,inputs:{target:t.target,qty:t.qty.valueOf()},signer:this.signer},r)}async increaseOperatorStake(t,r){return this.contract.writeInteraction({functionName:ho.INCREASE_OPERATOR_STAKE,inputs:{qty:t.qty.valueOf()},signer:this.signer},r)}async decreaseOperatorStake(t,r){return this.contract.writeInteraction({functionName:ho.DECREASE_OPERATOR_STAKE,inputs:{qty:t.qty.valueOf()},signer:this.signer},r)}async saveObservations(t,r){return this.contract.writeInteraction({functionName:ho.SAVE_OBSERVATIONS,inputs:{observerReportTxId:t.reportTxId,failedGateways:t.failedGateways},signer:this.signer},r)}async extendLease(t,r){return this.contract.writeInteraction({functionName:ho.EXTEND_RECORD,inputs:{name:t.domain,years:t.years},signer:this.signer},r)}async increaseUndernameLimit(t,r){return this.contract.writeInteraction({functionName:ho.INCREASE_UNDERNAME_COUNT,inputs:{name:t.domain,qty:t.qty},signer:this.signer},r)}};Tt();Rt();xt();Tt();Rt();xt();var or=Sl($ot(),1);var cie=or.default.AbortError,lie=or.default.AbstractContractHandler,die=or.default.ArweaveContractDefinitionLoader,pie=or.default.ArweaveGatewayBundledContractDefinitionLoader,gie=or.default.ArweaveGatewayBundledInteractionLoader,mie=or.default.ArweaveGatewayInteractionsLoader,vie=or.default.ArweaveWrapper,yie=or.default.Benchmark,bie=or.default.CacheKey,wie=or.default.CacheableInteractionsLoader,_ie=or.default.CacheableStateEvaluator,Mie=or.default.ConsoleLogger,Sie=or.default.ConsoleLoggerFactory,Eie=or.default.ContractCache,Aie=or.default.ContractCallRecord,Tie=or.default.ContractError,xie=or.default.ContractInteractionState,Rie=or.default.ContractMetadata,kie=or.default.CustomEvent,Iie=or.default.DEFAULT_LEVEL_DB_LOCATION,Bie=or.default.DefaultEvaluationOptions,Oie=or.default.DefaultStateEvaluator,Cie=or.default.EvalStateResult,Pie=or.default.EvaluationOptionsEvaluator,Nie=or.default.HandlerBasedContract,Lie=or.default.HandlerExecutorFactory,Die=or.default.InnerWritesEvaluator,$ie=or.default.InteractionCall,Uie=or.default.InteractionCompleteEvent,qie=or.default.InteractionInput,Fie=or.default.InteractionOutput,jie=or.default.JsHandlerApi,zie=or.default.KV,Wie=or.default.KnownErrors,Kie=or.default.LevelDbCache,Hie=or.default.LexicographicalInteractionsSorter,Gie=or.default.LogLevelOrder,Uot=or.default.LoggerFactory,Vie=or.default.MemCache,Zie=or.default.NetworkCommunicationError,Jie=or.default.NonWhitelistedSourceError,Xie=or.default.PstContractImpl,Yie=or.default.REGISTER_PROVIDER,Qie=or.default.SMART_WEAVE_TAGS,tne=or.default.SUPPORTED_SRC_CONTENT_TYPES,ene=or.default.SWBlock,rne=or.default.SWTransaction,ine=or.default.SWVrf,qot=or.default.Signature,nne=or.default.SmartWeaveError,one=or.default.SmartWeaveErrorType,ane=or.default.SmartWeaveGlobal,sne=or.default.SortKeyCacheResult,hne=or.default.SourceType,fne=or.default.SrcCache,Fot=or.default.Tag,une=or.default.TagsParser,cne=or.default.Transaction,lne=or.default.WARP_GW_URL,dne=or.default.WARP_TAGS,pne=or.default.Warp,gne=or.default.WarpBuilder,jot=or.default.WarpFactory,mne=or.default.WarpFetchWrapper,vne=or.default.WarpGatewayContractDefinitionLoader,yne=or.default.WarpGatewayInteractionsLoader,bne=or.default.WasmHandlerApi,wne=or.default.WasmSrc,_ne=or.default.arrayToHex,Mne=or.default.asc,Sne=or.default.ascS,Ene=or.default.bufToBn,Ane=or.default.bundledTxsFilter,Tne=or.default.checkJsSrc,xne=or.default.createDummyTx,Rne=or.default.createInteractionTagsList,kne=or.default.createInteractionTx,Ine=or.default.deepCopy,Bne=or.default.defaultArweaveMs,zot=or.default.defaultCacheOptions,One=or.default.defaultWarpGwOptions,Cne=or.default.desc,Pne=or.default.descS,Nne=or.default.emptyTransfer,Lne=or.default.genesisSortKey,Dne=or.default.getJsonResponse,$ne=or.default.indent,Une=or.default.isBrowser,qne=or.default.isTxIdValid,Fne=or.default.knownWarpPlugins,jne=or.default.knownWarpPluginsPartial,zne=or.default.lastPossibleSortKey,Wne=or.default.lvlToOrder,Kne=or.default.mapReplacer,Hne=or.default.mapReviver,Gne=or.default.matchMutClosureDtor,Vne=or.default.normalizeContractSource,Zne=or.default.rustWasmImports,Jne=or.default.safeGet,Xne=or.default.safeParseInt,Yne=or.default.sleep,Qne=or.default.sortingFirst,toe=or.default.sortingLast,eoe=or.default.stripTrailingSlash,roe=or.default.timeout;Tt();Rt();xt();Px();var JRt="+",XRt="/",YRt="-",QRt="_",tkt="=";function ekt(i){return i.replaceAll(JRt,YRt).replaceAll(XRt,QRt).replaceAll(tkt,"")}function gv(i){let t=i.toString("base64");return ekt(t)}function Wot(i){return gv(Cx("sha256").update(i).digest())}Tt();Rt();xt();var Kot=jot.forMainnet({...zot,inMemory:!0},!0,b8);Uot.INST.logLevel("error");var da=class{contract;contractTxId;cacheUrl;logger;warp;constructor({contractTxId:t,cacheUrl:r="https://api.arns.app",warp:h=Kot,logger:o=new la({level:"info"})}){this.contractTxId=t,this.contract=h.contract(t),this.cacheUrl=r,this.warp=h,this.logger=o}configuration(){return{contractTxId:this.contractTxId,cacheUrl:this.cacheUrl}}async createWarpSigner(t){return t.publicKey===void 0&&"setPublicKey"in t&&await t.setPublicKey(),new qot(this.warp,{signer:async h=>{h.setOwner(gv(t.publicKey));let o=await h.getSignatureData(),l=await t.sign(o),c=ge.from(l),p=Wot(c);h.setSignature({id:p,owner:gv(t.publicKey),signature:gv(c)})},type:"arweave"})}async getState({evaluationOptions:t={}}){await this.ensureContractInit();let r=t?.evalTo,h;r&&"sortKey"in r?h=r.sortKey:r&&"blockHeight"in r&&(h=r.blockHeight);let o=await this.contract.readState(h);if(!o.cachedValue.state)throw new Wl(502,"Failed to evaluate contract state");return o.cachedValue.state}async ensureContractInit({signer:t}={}){this.logger.debug("Checking contract initialized",{contractTxId:this.contractTxId}),this.logger.debug("Fetching contract manifest",{contractTxId:this.contractTxId});let{evaluationOptions:r={}}=await EL({arweave:this.warp.arweave,contractTxId:this.contractTxId});this.contract.setEvaluationOptions(r),t&&this.contract.connect(await this.createWarpSigner(t)),this.cacheUrl!==void 0&&(this.logger.debug("Syncing contract state",{contractTxId:this.contractTxId,remoteCacheUrl:this.cacheUrl}),await this.contract.syncState(`${this.cacheUrl}/v1/contract/${this.contractTxId}`,{validity:!0}))}async readInteraction({functionName:t,inputs:r}){await this.ensureContractInit(),this.logger.debug(`Read interaction: ${t}`,{contractTxId:this.contractTxId,inputs:r});let h=await this.contract.viewState({function:t,...r});if(h.result===void 0)throw new Wl(502,"Failed to evaluate contract read interaction: "+JSON.stringify({error:h.errorMessage,functionName:t,inputs:r},null,2));return this.logger.debug("Successfully evaluated contract read interaction",{contractTxId:this.contractTxId,result:h.result}),h.result}async writeInteraction({functionName:t,inputs:r,signer:h},o){try{this.logger.debug(`Write interaction: ${t}`,{contractTxId:this.contractTxId}),await this.ensureContractInit({signer:h});let l=await this.contract.dryWrite({function:t,...r});if(l.type!=="ok")throw new Error(`Failed to dry write contract interaction ${t}: ${l.errorMessage}`);let c=await this.contract.writeInteraction({function:t,...r},{disableBundling:!0,tags:o?.tags?.map(p=>new Fot(p.name,p.value))});if(!c?.interactionTx)throw new Error(`Failed to write contract interaction: ${t}`);return this.logger.debug("Successfully wrote contract interaction",{contractTxId:this.contractTxId,interactionTxId:c.originalTxId}),c.interactionTx}catch(l){throw this.logger.error(`Failed to write contract interaction: ${l.message}`,{contractTxId:this.contractTxId}),new i1(l)}}};Tt();Rt();xt();var U2=class{process;constructor(t){if(Tl(t))this.process=t.process;else if(xl(t))this.process=new Js({processId:t.processId});else throw new No}async getState(){let t=[{name:"Action",value:"State"}];return await this.process.read({tags:t})}async getInfo(){let t=[{name:"Action",value:"Info"}];return await this.process.read({tags:t})}async getRecord({undername:t}){let r=[{name:"Sub-Domain",value:t},{name:"Action",value:"Record"}];return await this.process.read({tags:r})}async getRecords(){let t=[{name:"Action",value:"Records"}];return await this.process.read({tags:t})}async getOwner(){return(await this.getInfo()).Owner}async getControllers(){let t=[{name:"Action",value:"Controllers"}];return await this.process.read({tags:t})}async getName(){return(await this.getInfo()).Name}async getTicker(){return(await this.getInfo()).Ticker}async getBalances(){let t=[{name:"Action",value:"Balances"}];return await this.process.read({tags:t})}async getBalance({address:t}){let r=[{name:"Action",value:"Balance"},{name:"Recipient",value:t}];return await this.process.read({tags:r})}},By=class extends U2{signer;constructor({signer:t,...r}){super(r),this.signer=t}async transfer({target:t}){let r=[{name:"Action",value:"Transfer"},{name:"Recipient",value:t}];return this.process.send({tags:r,data:{},signer:this.signer})}async addController({controller:t}){let r=[{name:"Action",value:"Add-Controller"},{name:"Controller",value:t}];return this.process.send({tags:r,data:{},signer:this.signer})}async removeController({controller:t}){let r=[{name:"Action",value:"Remove-Controller"},{name:"Controller",value:t}];return this.process.send({tags:r,data:{},signer:this.signer})}async setRecord({undername:t,transactionId:r,ttlSeconds:h}){return this.process.send({tags:[{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:t},{name:"Transaction-Id",value:r},{name:"TTL-Seconds",value:h.toString()}],data:{transactionId:r,ttlSeconds:h},signer:this.signer})}async removeRecord({undername:t}){return this.process.send({tags:[{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:t}],data:{undername:t},signer:this.signer})}async setTicker({ticker:t}){return this.process.send({tags:[{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:t}],data:{ticker:t},signer:this.signer})}async setName({name:t}){return this.process.send({tags:[{name:"Action",value:"Set-Name"},{name:"Name",value:t}],data:{name:t},signer:this.signer})}};var export_ArconnectSigner=Hot.ArconnectSigner;var export_ArweaveSigner=Hot.ArweaveSigner;export{ky as ANT,Iy as ANTReadable,H9 as ANTWritable,hc as ANT_CONTRACT_FUNCTIONS,_L as ANT_LUA_ID,Js as AOProcess,wL as AOS_MODULE_ID,Pkt as ARNS_DEVNET_REGISTRY_TX,y6 as ARNS_TESTNET_REGISTRY_TX,yL as ARWEAVE_TX_REGEX,ho as AR_IO_CONTRACT_FUNCTIONS,n1 as AbortError,U2 as AoANTReadable,By as AoANTWriteable,Aet as ArIO,_8 as ArIOReadable,ek as ArIOWritable,export_ArconnectSigner as ArconnectSigner,export_ArweaveSigner as ArweaveSigner,Qq as BadRequest,yh as BaseError,ML as DEFAULT_SCHEDULER_ID,vL as DENOMINATIONS,la as DefaultLogger,Ckt as FQDN_REGEX,Wl as FailedRequestError,v8 as IO,y8 as IOReadable,t2 as IOToken,tk as IOWriteable,No as InvalidContractConfigurationError,eF as InvalidProcessConfigurationError,tF as InvalidSignerError,o1 as MAX_REQUEST_SIZE,q5 as MIO_PER_IO,xy as NotFound,Kl as RemoteContract,bL as SORT_KEY_REGEX,z5 as SmartWeaveSortKey,Ry as UnknownError,da as WarpContract,i1 as WriteInteractionError,Yq as createAxiosInstance,KKt as getANTProcessesOwnedByWallet,EL as getContractManifest,kqt as getContractsTransferredToOrControlledByWallet,xqt as getSmartweaveContractsFromGQL,Rqt as getSmartweaveTransactionsFromGQL,Akt as ioContractInteractions,bst as ioContractReadInteractions,wst as ioContractWriteInteractions,Qp as ioDevnetProcessId,Kkt as isBlockHeight,Jf as isContractConfiguration,Xf as isContractTxIdConfiguration,Ykt as isLeasedArNSRecord,Tl as isProcessConfiguration,xl as isProcessIdConfiguration,pIt as isSortKey,Hkt as isTransaction,j5 as mIOToken,uHt as spawnANT,SL as tagsToObject,b6 as validateArweaveId};
|
|
379
|
+
}`,o=Xe.object({data:Xe.object({transactions:Xe.object({edges:Xe.array(Xe.object({node:Xe.record(Xe.any())}))})})});return l=>ci(l).chain(rn(c=>i(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:h,variables:{transactionIds:[c]}})}).then(async p=>{if(p.ok)return p.json();throw r('Error Encountered when querying gateway for transaction "%s"',c),new Error(`${p.status}: ${await p.text()}`)}).then(o.parse).then(a9t(["data","transactions","edges","0","node"])))).toPromise()}var d_t=OR(R4t(),1),oet=(i="@permaweb/aoconnect")=>{let t=(0,d_t.default)(i);return t.child=r=>oet(`${t.namespace}:${r}`),t.tap=(r,...h)=>d9t((...o)=>t(r,...h,...o)),t},aet=({url:i,path:t})=>t?t.startsWith("/")?aet({url:i,path:t.slice(1)}):(i=new URL(i),i.pathname+=t,i.toString()):i;function p_t(i){return Y1(p8([]),X1((t,r)=>Y1(f9t([],r.name),zR(r.value),Vs(r.name,Cu,t))(t),{}),l8(t=>t.length>1?t:t[0]))(i)}function Hs(i,t){return r=>Ott(v7t([ett(i,"name"),KR(jR(t),ett(t,"value"),UR)]),r)}function ntt(i){return jtt([[Yg(String),K1(i)],[Yg(Array),J7t(i)],[UR,T5t]])}function L0(i){let t;return Yg(Gs,i)?(t=new Error(g_t(i)),t.stack+=i.stack):Yg(Error,i)?t=i:G7t("message",i)?t=new Error(i.message):Yg(String,i)?t=new Error(i):t=new Error("An error occurred"),t}function g_t(i){return Y1(t=>function r(h,o,l){return X1((c,p)=>Y1(jtt([[K1(vr.invalid_arguments),()=>r(p.argumentsError,422,"Invalid Arguments")],[K1(vr.invalid_return_type),()=>r(p.returnTypeError,500,"Invalid Return")],[K1(vr.invalid_union),()=>C7t(w=>r(w,400,"Invalid Union"),p.unionErrors)],[UR,()=>[{...p,status:o,contextCode:l}]]]),WR(c))(p.code),[],h.issues)}(t,400,""),t=>X1((r,h)=>{let{message:o,path:l,contextCode:c}=h,p=l[1]||l[0],w=c?`${c} `:"";return r.push(`${w}'${p}': ${o}.`),r},[],t),r9t(" | "))(i)}var m_t=Xe.object({id:Xe.string().min(1,{message:"message is required to be a message id"}),processId:Xe.string().min(1,{message:"process is required to be a process id"})});function v_t(){return i=>ci(i).map(m_t.parse).map(()=>i)}var ym=Xe.object({name:Xe.string(),value:Xe.string()}),y_t=Xe.function().args(Xe.object({Id:Xe.string(),Target:Xe.string(),Owner:Xe.string(),Anchor:Xe.string().optional(),Data:Xe.any().default("1234"),Tags:Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}))})).returns(Xe.promise(Xe.any())),b_t=Xe.function().args(Xe.object({id:Xe.string().min(1,{message:"message id is required"}),processId:Xe.string().min(1,{message:"process id is required"})})).returns(Xe.promise(Xe.any())),w_t=Xe.function().args(Xe.object({process:Xe.string().min(1,{message:"process id is required"}),from:Xe.string().optional(),to:Xe.string().optional(),sort:Xe.enum(["ASC","DESC"]).default("ASC"),limit:Xe.number().optional()})).returns(Xe.promise(Xe.object({edges:Xe.array(Xe.object({cursor:Xe.string(),node:Xe.object({Output:Xe.any().optional(),Messages:Xe.array(Xe.any()).optional(),Spawns:Xe.array(Xe.any()).optional(),Error:Xe.any().optional()})}))}))),set=Xe.function().args(Xe.object({processId:Xe.string(),data:Xe.any(),tags:Xe.array(ym),anchor:Xe.string().optional(),signer:Xe.any()})).returns(Xe.promise(Xe.object({messageId:Xe.string()}).passthrough())),__t=Xe.function().args(Xe.object({data:Xe.any(),tags:Xe.array(ym),signer:Xe.any()})).returns(Xe.promise(Xe.object({processId:Xe.string()}).passthrough())),M_t=Xe.function().args(Xe.object({process:Xe.string(),message:Xe.string(),baseLayer:Xe.boolean().optional(),exclude:Xe.array(Xe.string()).optional()})).returns(Xe.promise(Xe.object({assignmentId:Xe.string()}).passthrough())),het=set,yWt=Xe.function().args(Xe.object({suUrl:Xe.string().url(),processId:Xe.string()})).returns(Xe.promise(Xe.object({tags:Xe.array(ym)}).passthrough())),bWt=Xe.function().args(Xe.string()).returns(Xe.promise(Xe.object({url:Xe.string()}))),S_t=Xe.function().args(Xe.string()).returns(Xe.promise(Xe.boolean())),E_t=Xe.function().args(Xe.string()).returns(Xe.promise(Xe.object({tags:Xe.array(ym)}).passthrough())),g8=Xe.function().args(Xe.object({data:Xe.any(),tags:Xe.array(ym),target:Xe.string().optional(),anchor:Xe.string().optional()})).returns(Xe.promise(Xe.object({id:Xe.string(),raw:Xe.any()})));function A_t({loadResult:i}){return i=rn(b_t.implement(i)),t=>ci({id:t.id,processId:t.processId}).chain(i)}function T_t(i){let t=v_t(i),r=A_t(i);return({message:h,process:o})=>ci({id:h,processId:o}).chain(t).chain(r).map(i.logger.tap('readResult result for message "%s": %O',h)).map(l=>l).bimap(L0,N0).toPromise()}var x_t=Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}));function R_t(){return i=>ci(i.tags).map(p8([])).map(Hs("Data-Protocol","ao")).map(Hs("Variant")).map(Hs("Type")).map(Hs("SDK")).map(WR(Cu,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"},{name:"SDK",value:"aoconnect"}])).map(x_t.parse).map(Vs("tags",Cu,i))}function k_t({logger:i}){return t=>ci(t).chain(KR(jR(t.data),()=>I0(t),()=>I0(Math.random().toString().slice(-4)).map(Vs("data",Cu,t)).map(r=>Y1(P0("tags"),Hs("Content-Type"),zR({name:"Content-Type",value:"text/plain"}),Vs("tags",Cu,r))(r)).map(i.tap('added pseudo-random string as message "data"'))))}function I_t(i){let t=R_t(i),r=k_t(i),h=set.implement(i.deployMessage);return o=>ci(o).chain(t).chain(r).chain(rn(({id:l,data:c,tags:p,anchor:w,signer:m})=>h({processId:l,data:c,tags:p,anchor:w,signer:g8.implement(m)}))).map(l=>Vs("messageId",l.messageId,o))}function B_t(i){let t=I_t(i);return({process:r,data:h,tags:o,anchor:l,signer:c})=>ci({id:r,data:h,tags:o,anchor:l,signer:c}).chain(t).map(p=>p.messageId).bimap(L0,N0).toPromise()}var Gg=(i,t,r)=>h=>t(h[i])?I0(h):Xc(`Tag '${i}': ${r}`);function O_t({loadTransactionMeta:i,logger:t}){return i=rn(E_t.implement(i)),r=>ci(r).chain(i).map(P0("tags")).map(p_t).chain(Gg("Data-Protocol",ntt("ao"),"value 'ao' was not found on module")).chain(Gg("Type",ntt("Module"),"value 'Module' was not found on module")).chain(Gg("Module-Format",lR,"was not found on module")).chain(Gg("Input-Encoding",lR,"was not found on module")).chain(Gg("Output-Encoding",lR,"was not found on module")).bimap(t.tap("Verifying module source failed: %s"),t.tap("Verified module source"))}function C_t({logger:i,validateScheduler:t}){return t=rn(S_t.implement(t)),r=>ci(r).chain(h=>t(h).chain(o=>o?I0(h):Xc(`Valid Scheduler-Location owned by ${h} not found`))).bimap(i.tap("Verifying scheduler failed: %s"),i.tap("Verified scheduler"))}function P_t({logger:i}){return t=>ci(t).map(i.tap("Checking for signer")).chain(r=>r?I0(r):Xc("signer not found"))}function N_t(i){let t=i.logger.child("verifyInput");i={...i,logger:t};let r=O_t(i),h=C_t(i),o=P_t(i);return l=>ci(l).chain(c=>r(c.module).map(()=>c)).chain(c=>h(c.scheduler)).map(()=>l).chain(c=>o(c.signer).map(()=>c)).bimap(t.tap("Error when verify input: %s"),t.tap("Successfully verified inputs"))}var L_t=Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}));function D_t(){return i=>ci(i).map(P0("tags")).map(p8([])).map(Hs("Data-Protocol","ao")).map(Hs("Variant")).map(Hs("Type")).map(Hs("Module")).map(Hs("Scheduler")).map(Hs("SDK")).map(WR(Cu,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Process"},{name:"Module",value:i.module},{name:"Scheduler",value:i.scheduler},{name:"SDK",value:"aoconnect"}])).map(L_t.parse).map(Vs("tags",Cu,i))}function $_t({logger:i}){return t=>ci(t).chain(KR(jR(t.data),()=>I0(t),()=>I0(Math.random().toString().slice(-4)).map(Vs("data",Cu,t)).map(r=>Y1(P0("tags"),Hs("Content-Type"),zR({name:"Content-Type",value:"text/plain"}),Vs("tags",Cu,r))(r)).map(i.tap('added pseudo-random string as process "data"'))))}function U_t(i){let t=i.logger.child("uploadProcess");i={...i,logger:t};let r=D_t(i),h=$_t(i),o=__t.implement(i.deployProcess);return l=>ci(l).chain(r).chain(h).chain(rn(({data:c,tags:p,signer:w})=>o({data:c,tags:p,signer:g8.implement(w)}))).map(c=>Vs("processId",c.processId,l))}function q_t(i){let t=N_t(i),r=U_t(i);return({module:h,scheduler:o,signer:l,tags:c,data:p})=>ci({module:h,scheduler:o,signer:l,tags:c,data:p}).chain(t).chain(r).map(w=>w.processId).bimap(L0,N0).toPromise()}function F_t(i){let t=het.implement(i.deployMonitor);return r=>ci(r).chain(rn(({id:h,signer:o})=>t({processId:h,signer:g8.implement(o),data:Math.random().toString().slice(-4),tags:[]}))).map(h=>Vs("monitorId",h.messageId,r))}function j_t(i){let t=F_t(i);return({process:r,signer:h})=>ci({id:r,signer:h}).chain(t).map(o=>o.monitorId).bimap(L0,N0).toPromise()}function z_t(i){let t=het.implement(i.deployUnmonitor);return r=>ci(r).chain(rn(({id:h,signer:o})=>t({processId:h,signer:g8.implement(o),data:Math.random().toString().slice(-4),tags:[]}))).map(h=>Vs("monitorId",h.messageId,r))}function W_t(i){let t=z_t(i);return({process:r,signer:h})=>ci({id:r,signer:h}).chain(t).map(o=>o.monitorId).bimap(L0,N0).toPromise()}var K_t=Xe.object({process:Xe.string().min(1,{message:"process identifier is required"}),from:Xe.string().optional(),to:Xe.string().optional(),sort:Xe.enum(["ASC","DESC"]).default("ASC"),limit:Xe.number().optional()});function H_t(){return i=>ci(i).map(K_t.parse).map(()=>i)}function G_t({queryResults:i}){return i=rn(w_t.implement(i)),t=>ci({process:t.process,from:t.from,to:t.to,sort:t.sort,limit:t.limit}).chain(i)}function V_t(i){let t=H_t(i),r=G_t(i);return({process:h,from:o,to:l,sort:c,limit:p})=>ci({process:h,from:o,to:l,sort:c,limit:p}).chain(t).chain(r).map(i.logger.tap('readResults result for message "%s": %O',h)).map(w=>w).bimap(L0,N0).toPromise()}var Z_t=Xe.object({Id:Xe.string(),Target:Xe.string(),Owner:Xe.string(),Anchor:Xe.string().optional(),Data:Xe.any().default("1234"),Tags:Xe.array(Xe.object({name:Xe.string(),value:Xe.string()}))});function J_t(){return i=>ci(i).map(Z_t.parse).map(t=>(t.Tags=t.Tags.concat([{name:"Data-Protocol",value:"ao"},{name:"Type",value:"Message"},{name:"Variant",value:"ao.TN.1"}]),t))}function X_t({dryrunFetch:i}){return rn(y_t.implement(i))}function Y_t(i){let t=J_t(i),r=X_t(i);return h=>ci(h).map(Q_t).chain(t).chain(r).toPromise()}function Q_t({process:i,data:t,tags:r,anchor:h,...o}){return{Id:"1234",Owner:"1234",...o,Target:i,Data:t||"1234",Tags:r||[],Anchor:h||"0"}}function tMt(i){let t=M_t.implement(i.deployAssign);return r=>ci(r).chain(rn(({process:h,message:o,baseLayer:l,exclude:c})=>t({process:h,message:o,baseLayer:l,exclude:c}))).map(h=>Vs("assignmentId",h.assignmentId,r))}function eMt(i){let t=tMt(i);return({process:r,message:h,baseLayer:o,exclude:l})=>ci({process:r,message:h,baseLayer:o,exclude:l}).chain(t).map(c=>c.assignmentId).bimap(L0,N0).toPromise()}var rMt="https://arweave.net",iMt="https://mu.ao-testnet.xyz",nMt="https://cu.ao-testnet.xyz";function bm({GRAPHQL_URL:i,GATEWAY_URL:t=rMt,MU_URL:r=iMt,CU_URL:h=nMt}={}){let o=oet();i||(i=aet({url:t,path:"/graphql"}));let{validate:l}=Rtt({cacheSize:100,GRAPHQL_URL:i}),c=E5t({MAX_SIZE:25}),p=o.child("result"),w=T_t({loadResult:_5t({fetch,CU_URL:h,logger:p}),logger:p}),m=o.child("message"),y=B_t({loadProcessMeta:fR({fetch,cache:c,logger:m}),deployMessage:g5t({fetch,MU_URL:r,logger:m}),logger:m}),v=o.child("spawn"),M=q_t({loadTransactionMeta:l_t({fetch,GRAPHQL_URL:i,logger:v}),validateScheduler:l,deployProcess:m5t({fetch,MU_URL:r,logger:v}),logger:v}),T=o.child("monitor"),A=j_t({loadProcessMeta:fR({fetch,cache:c,logger:T}),deployMonitor:v5t({fetch,MU_URL:r,logger:T}),logger:T}),R=o.child("unmonitor"),B=W_t({loadProcessMeta:fR({fetch,cache:c,logger:R}),deployUnmonitor:y5t({fetch,MU_URL:r,logger:R}),logger:T}),C=o.child("results"),P=V_t({queryResults:M5t({fetch,CU_URL:h,logger:C}),logger:C}),N=o.child("dryrun"),q=Y_t({dryrunFetch:w5t({fetch,CU_URL:h,logger:N}),logger:N}),W=o.child("assign"),J=eMt({deployAssign:b5t({fetch,MU_URL:r,logger:W}),logger:m});return{result:w,results:P,message:y,spawn:M,monitor:A,unmonitor:B,dryrun:q,assign:J}}var fet={};stt(fet,{createDataItemSigner:()=>kMt});var uet=OR(B4t(),1),cet={};stt(cet,{AVSCTap:()=>wm,ArweaveSigner:()=>ZR,DataItem:()=>pm,MAX_TAG_BYTES:()=>m8,MIN_BINARY_SIZE:()=>YR,SIG_CONFIG:()=>rp,SignatureConfig:()=>Ks,Signer:()=>met,createData:()=>wet,default:()=>TMt,deserializeTags:()=>s8,indexToType:()=>JR,serializeTags:()=>XR,tagsExceedLimit:()=>bet,warparbundles:()=>xMt});var oMt=Object.create,GR=Object.defineProperty,aMt=Object.getOwnPropertyDescriptor,sMt=Object.getOwnPropertyNames,hMt=Object.getPrototypeOf,fMt=Object.prototype.hasOwnProperty,Nu=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),uMt=(i,t)=>{for(var r in t)GR(i,r,{get:t[r],enumerable:!0})},cMt=(i,t,r,h)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sMt(t))!fMt.call(i,o)&&o!==r&&GR(i,o,{get:()=>t[o],enumerable:!(h=aMt(t,o))||h.enumerable});return i},D0=(i,t,r)=>(r=i!=null?oMt(hMt(i)):{},cMt(t||!i||!i.__esModule?GR(r,"default",{value:i,enumerable:!0}):r,i)),lMt=Nu(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});function t(r){var h=4,o=r.length,l=o%h;if(!l)return r;var c=o,p=h-l,w=o+p,m=ge.alloc(w);for(m.write(r);p--;)m.write("=",c++);return m.toString()}i.default=t}),dMt=Nu(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var t=lMt();function r(w,m){return m===void 0&&(m="utf8"),ge.isBuffer(w)?l(w.toString("base64")):l(ge.from(w,m).toString("base64"))}function h(w,m){return m===void 0&&(m="utf8"),ge.from(o(w),"base64").toString(m)}function o(w){return w=w.toString(),t.default(w).replace(/\-/g,"+").replace(/_/g,"/")}function l(w){return w.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function c(w){return ge.from(o(w),"base64")}var p=r;p.encode=r,p.decode=h,p.toBase64=o,p.fromBase64=l,p.toBuffer=c,i.default=p}),VR=Nu((i,t)=>{t.exports=dMt().default,t.exports.default=t.exports}),det=Nu(i=>{"use strict";i.byteLength=w,i.toByteArray=y,i.fromByteArray=T;var t=[],r=[],h=typeof Uint8Array<"u"?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(l=0,c=o.length;l<c;++l)t[l]=o[l],r[o.charCodeAt(l)]=l;var l,c;r[45]=62,r[95]=63;function p(A){var R=A.length;if(R%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=A.indexOf("=");B===-1&&(B=R);var C=B===R?0:4-B%4;return[B,C]}function w(A){var R=p(A),B=R[0],C=R[1];return(B+C)*3/4-C}function m(A,R,B){return(R+B)*3/4-B}function y(A){var R,B=p(A),C=B[0],P=B[1],N=new h(m(A,C,P)),q=0,W=P>0?C-4:C,J;for(J=0;J<W;J+=4)R=r[A.charCodeAt(J)]<<18|r[A.charCodeAt(J+1)]<<12|r[A.charCodeAt(J+2)]<<6|r[A.charCodeAt(J+3)],N[q++]=R>>16&255,N[q++]=R>>8&255,N[q++]=R&255;return P===2&&(R=r[A.charCodeAt(J)]<<2|r[A.charCodeAt(J+1)]>>4,N[q++]=R&255),P===1&&(R=r[A.charCodeAt(J)]<<10|r[A.charCodeAt(J+1)]<<4|r[A.charCodeAt(J+2)]>>2,N[q++]=R>>8&255,N[q++]=R&255),N}function v(A){return t[A>>18&63]+t[A>>12&63]+t[A>>6&63]+t[A&63]}function M(A,R,B){for(var C,P=[],N=R;N<B;N+=3)C=(A[N]<<16&16711680)+(A[N+1]<<8&65280)+(A[N+2]&255),P.push(v(C));return P.join("")}function T(A){for(var R,B=A.length,C=B%3,P=[],N=16383,q=0,W=B-C;q<W;q+=N)P.push(M(A,q,q+N>W?W:q+N));return C===1?(R=A[B-1],P.push(t[R>>2]+t[R<<4&63]+"==")):C===2&&(R=(A[B-2]<<8)+A[B-1],P.push(t[R>>10]+t[R>>4&63]+t[R<<2&63]+"=")),P.join("")}}),pet=Nu(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.b64UrlDecode=i.b64UrlEncode=i.bufferTob64Url=i.bufferTob64=i.b64UrlToBuffer=i.stringToB64Url=i.stringToBuffer=i.bufferToString=i.b64UrlToString=i.concatBuffers=void 0;var t=det();function r(M){let T=0;for(let B=0;B<M.length;B++)T+=M[B].byteLength;let A=new Uint8Array(T),R=0;A.set(new Uint8Array(M[0]),R),R+=M[0].byteLength;for(let B=1;B<M.length;B++)A.set(new Uint8Array(M[B]),R),R+=M[B].byteLength;return A}i.concatBuffers=r;function h(M){let T=p(M);return o(T)}i.b64UrlToString=h;function o(M){return new TextDecoder("utf-8",{fatal:!0}).decode(M)}i.bufferToString=o;function l(M){return new TextEncoder().encode(M)}i.stringToBuffer=l;function c(M){return m(l(M))}i.stringToB64Url=c;function p(M){return new Uint8Array(t.toByteArray(v(M)))}i.b64UrlToBuffer=p;function w(M){return t.fromByteArray(new Uint8Array(M))}i.bufferTob64=w;function m(M){return y(w(M))}i.bufferTob64Url=m;function y(M){return M.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}i.b64UrlEncode=y;function v(M){M=M.replace(/\-/g,"+").replace(/\_/g,"/");let T;return M.length%4==0?T=0:T=4-M.length%4,M.concat("=".repeat(T))}i.b64UrlDecode=v}),pMt=Nu(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var t=pet(),r=class{keyLength=4096;publicExponent=65537;hashAlgorithm="sha256";driver;constructor(){if(!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let h=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),o=await this.driver.exportKey("jwk",h.privateKey);return{kty:o.kty,e:o.e,n:o.n,d:o.d,p:o.p,q:o.q,dp:o.dp,dq:o.dq,qi:o.qi}}async sign(h,o,{saltLength:l}={}){let c=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(h),o);return new Uint8Array(c)}async hash(h,o="SHA-256"){let l=await this.driver.digest(o,h);return new Uint8Array(l)}async verify(h,o,l){let c={kty:"RSA",e:"AQAB",n:h},p=await this.jwkToPublicCryptoKey(c),w=await this.driver.digest("SHA-256",o),m=await this.driver.verify({name:"RSA-PSS",saltLength:0},p,l,o),y=await this.driver.verify({name:"RSA-PSS",saltLength:32},p,l,o),v=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((p.algorithm.modulusLength-1)/8)-w.byteLength-2},p,l,o);return m||y||v}async jwkToCryptoKey(h){return this.driver.importKey("jwk",h,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(h){return this.driver.importKey("jwk",h,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let h=crypto?.subtle;return h===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(o=>typeof h[o]=="function")}async encrypt(h,o,l){let c=await this.driver.importKey("raw",typeof o=="string"?t.stringToBuffer(o):o,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:l?t.stringToBuffer(l):t.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),w=new Uint8Array(16);crypto.getRandomValues(w);let m=await this.driver.encrypt({name:"AES-CBC",iv:w},p,h);return t.concatBuffers([w,m])}async decrypt(h,o,l){let c=await this.driver.importKey("raw",typeof o=="string"?t.stringToBuffer(o):o,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:l?t.stringToBuffer(l):t.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),w=h.slice(0,16),m=await this.driver.decrypt({name:"AES-CBC",iv:w},p,h.slice(16));return t.concatBuffers([m])}};i.default=r}),gMt=Nu(i=>{i.read=function(t,r,h,o,l){var c,p,w=l*8-o-1,m=(1<<w)-1,y=m>>1,v=-7,M=h?l-1:0,T=h?-1:1,A=t[r+M];for(M+=T,c=A&(1<<-v)-1,A>>=-v,v+=w;v>0;c=c*256+t[r+M],M+=T,v-=8);for(p=c&(1<<-v)-1,c>>=-v,v+=o;v>0;p=p*256+t[r+M],M+=T,v-=8);if(c===0)c=1-y;else{if(c===m)return p?NaN:(A?-1:1)*(1/0);p=p+Math.pow(2,o),c=c-y}return(A?-1:1)*p*Math.pow(2,c-o)},i.write=function(t,r,h,o,l,c){var p,w,m,y=c*8-l-1,v=(1<<y)-1,M=v>>1,T=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=o?0:c-1,R=o?1:-1,B=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(w=isNaN(r)?1:0,p=v):(p=Math.floor(Math.log(r)/Math.LN2),r*(m=Math.pow(2,-p))<1&&(p--,m*=2),p+M>=1?r+=T/m:r+=T*Math.pow(2,1-M),r*m>=2&&(p++,m/=2),p+M>=v?(w=0,p=v):p+M>=1?(w=(r*m-1)*Math.pow(2,l),p=p+M):(w=r*Math.pow(2,M-1)*Math.pow(2,l),p=0));l>=8;t[h+A]=w&255,A+=R,w/=256,l-=8);for(p=p<<l|w,y+=l;y>0;t[h+A]=p&255,A+=R,p/=256,y-=8);t[h+A-R]|=B*128}}),kR=Nu(i=>{"use strict";var t=det(),r=gMt(),h=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=p,i.SlowBuffer=P,i.INSPECT_MAX_BYTES=50;var o=2147483647;i.kMaxLength=o,p.TYPED_ARRAY_SUPPORT=l(),!p.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{let I=new Uint8Array(1),O={foo:function(){return 42}};return Object.setPrototypeOf(O,Uint8Array.prototype),Object.setPrototypeOf(I,O),I.foo()===42}catch{return!1}}Object.defineProperty(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}}),Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}});function c(I){if(I>o)throw new RangeError('The value "'+I+'" is invalid for option "size"');let O=new Uint8Array(I);return Object.setPrototypeOf(O,p.prototype),O}function p(I,O,L){if(typeof I=="number"){if(typeof O=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(I)}return w(I,O,L)}p.poolSize=8192;function w(I,O,L){if(typeof I=="string")return M(I,O);if(ArrayBuffer.isView(I))return A(I);if(I==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof I);if(mt(I,ArrayBuffer)||I&&mt(I.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(I,SharedArrayBuffer)||I&&mt(I.buffer,SharedArrayBuffer)))return R(I,O,L);if(typeof I=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let V=I.valueOf&&I.valueOf();if(V!=null&&V!==I)return p.from(V,O,L);let st=B(I);if(st)return st;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof I[Symbol.toPrimitive]=="function")return p.from(I[Symbol.toPrimitive]("string"),O,L);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof I)}p.from=function(I,O,L){return w(I,O,L)},Object.setPrototypeOf(p.prototype,Uint8Array.prototype),Object.setPrototypeOf(p,Uint8Array);function m(I){if(typeof I!="number")throw new TypeError('"size" argument must be of type number');if(I<0)throw new RangeError('The value "'+I+'" is invalid for option "size"')}function y(I,O,L){return m(I),I<=0?c(I):O!==void 0?typeof L=="string"?c(I).fill(O,L):c(I).fill(O):c(I)}p.alloc=function(I,O,L){return y(I,O,L)};function v(I){return m(I),c(I<0?0:C(I)|0)}p.allocUnsafe=function(I){return v(I)},p.allocUnsafeSlow=function(I){return v(I)};function M(I,O){if((typeof O!="string"||O==="")&&(O="utf8"),!p.isEncoding(O))throw new TypeError("Unknown encoding: "+O);let L=N(I,O)|0,V=c(L),st=V.write(I,O);return st!==L&&(V=V.slice(0,st)),V}function T(I){let O=I.length<0?0:C(I.length)|0,L=c(O);for(let V=0;V<O;V+=1)L[V]=I[V]&255;return L}function A(I){if(mt(I,Uint8Array)){let O=new Uint8Array(I);return R(O.buffer,O.byteOffset,O.byteLength)}return T(I)}function R(I,O,L){if(O<0||I.byteLength<O)throw new RangeError('"offset" is outside of buffer bounds');if(I.byteLength<O+(L||0))throw new RangeError('"length" is outside of buffer bounds');let V;return O===void 0&&L===void 0?V=new Uint8Array(I):L===void 0?V=new Uint8Array(I,O):V=new Uint8Array(I,O,L),Object.setPrototypeOf(V,p.prototype),V}function B(I){if(p.isBuffer(I)){let O=C(I.length)|0,L=c(O);return L.length===0||I.copy(L,0,0,O),L}if(I.length!==void 0)return typeof I.length!="number"||wt(I.length)?c(0):T(I);if(I.type==="Buffer"&&Array.isArray(I.data))return T(I.data)}function C(I){if(I>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return I|0}function P(I){return+I!=I&&(I=0),p.alloc(+I)}p.isBuffer=function(I){return I!=null&&I._isBuffer===!0&&I!==p.prototype},p.compare=function(I,O){if(mt(I,Uint8Array)&&(I=p.from(I,I.offset,I.byteLength)),mt(O,Uint8Array)&&(O=p.from(O,O.offset,O.byteLength)),!p.isBuffer(I)||!p.isBuffer(O))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(I===O)return 0;let L=I.length,V=O.length;for(let st=0,ft=Math.min(L,V);st<ft;++st)if(I[st]!==O[st]){L=I[st],V=O[st];break}return L<V?-1:V<L?1:0},p.isEncoding=function(I){switch(String(I).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},p.concat=function(I,O){if(!Array.isArray(I))throw new TypeError('"list" argument must be an Array of Buffers');if(I.length===0)return p.alloc(0);let L;if(O===void 0)for(O=0,L=0;L<I.length;++L)O+=I[L].length;let V=p.allocUnsafe(O),st=0;for(L=0;L<I.length;++L){let ft=I[L];if(mt(ft,Uint8Array))st+ft.length>V.length?(p.isBuffer(ft)||(ft=p.from(ft)),ft.copy(V,st)):Uint8Array.prototype.set.call(V,ft,st);else if(p.isBuffer(ft))ft.copy(V,st);else throw new TypeError('"list" argument must be an Array of Buffers');st+=ft.length}return V};function N(I,O){if(p.isBuffer(I))return I.length;if(ArrayBuffer.isView(I)||mt(I,ArrayBuffer))return I.byteLength;if(typeof I!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof I);let L=I.length,V=arguments.length>2&&arguments[2]===!0;if(!V&&L===0)return 0;let st=!1;for(;;)switch(O){case"ascii":case"latin1":case"binary":return L;case"utf8":case"utf-8":return ut(I).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L*2;case"hex":return L>>>1;case"base64":return bt(I).length;default:if(st)return V?-1:ut(I).length;O=(""+O).toLowerCase(),st=!0}}p.byteLength=N;function q(I,O,L){let V=!1;if((O===void 0||O<0)&&(O=0),O>this.length||((L===void 0||L>this.length)&&(L=this.length),L<=0)||(L>>>=0,O>>>=0,L<=O))return"";for(I||(I="utf8");;)switch(I){case"hex":return e(this,O,L);case"utf8":case"utf-8":return d(this,O,L);case"ascii":return x(this,O,L);case"latin1":case"binary":return a(this,O,L);case"base64":return f(this,O,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u(this,O,L);default:if(V)throw new TypeError("Unknown encoding: "+I);I=(I+"").toLowerCase(),V=!0}}p.prototype._isBuffer=!0;function W(I,O,L){let V=I[O];I[O]=I[L],I[L]=V}p.prototype.swap16=function(){let I=this.length;if(I%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let O=0;O<I;O+=2)W(this,O,O+1);return this},p.prototype.swap32=function(){let I=this.length;if(I%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let O=0;O<I;O+=4)W(this,O,O+3),W(this,O+1,O+2);return this},p.prototype.swap64=function(){let I=this.length;if(I%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let O=0;O<I;O+=8)W(this,O,O+7),W(this,O+1,O+6),W(this,O+2,O+5),W(this,O+3,O+4);return this},p.prototype.toString=function(){let I=this.length;return I===0?"":arguments.length===0?d(this,0,I):q.apply(this,arguments)},p.prototype.toLocaleString=p.prototype.toString,p.prototype.equals=function(I){if(!p.isBuffer(I))throw new TypeError("Argument must be a Buffer");return this===I?!0:p.compare(this,I)===0},p.prototype.inspect=function(){let I="",O=i.INSPECT_MAX_BYTES;return I=this.toString("hex",0,O).replace(/(.{2})/g,"$1 ").trim(),this.length>O&&(I+=" ... "),"<Buffer "+I+">"},h&&(p.prototype[h]=p.prototype.inspect),p.prototype.compare=function(I,O,L,V,st){if(mt(I,Uint8Array)&&(I=p.from(I,I.offset,I.byteLength)),!p.isBuffer(I))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof I);if(O===void 0&&(O=0),L===void 0&&(L=I?I.length:0),V===void 0&&(V=0),st===void 0&&(st=this.length),O<0||L>I.length||V<0||st>this.length)throw new RangeError("out of range index");if(V>=st&&O>=L)return 0;if(V>=st)return-1;if(O>=L)return 1;if(O>>>=0,L>>>=0,V>>>=0,st>>>=0,this===I)return 0;let ft=st-V,ht=L-O,Et=Math.min(ft,ht),_t=this.slice(V,st),vt=I.slice(O,L);for(let Qt=0;Qt<Et;++Qt)if(_t[Qt]!==vt[Qt]){ft=_t[Qt],ht=vt[Qt];break}return ft<ht?-1:ht<ft?1:0};function J(I,O,L,V,st){if(I.length===0)return-1;if(typeof L=="string"?(V=L,L=0):L>2147483647?L=2147483647:L<-2147483648&&(L=-2147483648),L=+L,wt(L)&&(L=st?0:I.length-1),L<0&&(L=I.length+L),L>=I.length){if(st)return-1;L=I.length-1}else if(L<0)if(st)L=0;else return-1;if(typeof O=="string"&&(O=p.from(O,V)),p.isBuffer(O))return O.length===0?-1:F(I,O,L,V,st);if(typeof O=="number")return O=O&255,typeof Uint8Array.prototype.indexOf=="function"?st?Uint8Array.prototype.indexOf.call(I,O,L):Uint8Array.prototype.lastIndexOf.call(I,O,L):F(I,[O],L,V,st);throw new TypeError("val must be string, number or Buffer")}function F(I,O,L,V,st){let ft=1,ht=I.length,Et=O.length;if(V!==void 0&&(V=String(V).toLowerCase(),V==="ucs2"||V==="ucs-2"||V==="utf16le"||V==="utf-16le")){if(I.length<2||O.length<2)return-1;ft=2,ht/=2,Et/=2,L/=2}function _t(Qt,It){return ft===1?Qt[It]:Qt.readUInt16BE(It*ft)}let vt;if(st){let Qt=-1;for(vt=L;vt<ht;vt++)if(_t(I,vt)===_t(O,Qt===-1?0:vt-Qt)){if(Qt===-1&&(Qt=vt),vt-Qt+1===Et)return Qt*ft}else Qt!==-1&&(vt-=vt-Qt),Qt=-1}else for(L+Et>ht&&(L=ht-Et),vt=L;vt>=0;vt--){let Qt=!0;for(let It=0;It<Et;It++)if(_t(I,vt+It)!==_t(O,It)){Qt=!1;break}if(Qt)return vt}return-1}p.prototype.includes=function(I,O,L){return this.indexOf(I,O,L)!==-1},p.prototype.indexOf=function(I,O,L){return J(this,I,O,L,!0)},p.prototype.lastIndexOf=function(I,O,L){return J(this,I,O,L,!1)};function H(I,O,L,V){L=Number(L)||0;let st=I.length-L;V?(V=Number(V),V>st&&(V=st)):V=st;let ft=O.length;V>ft/2&&(V=ft/2);let ht;for(ht=0;ht<V;++ht){let Et=parseInt(O.substr(ht*2,2),16);if(wt(Et))return ht;I[L+ht]=Et}return ht}function Y(I,O,L,V){return lt(ut(O,I.length-L),I,L,V)}function E(I,O,L,V){return lt(pt(O),I,L,V)}function n(I,O,L,V){return lt(bt(O),I,L,V)}function s(I,O,L,V){return lt(St(O,I.length-L),I,L,V)}p.prototype.write=function(I,O,L,V){if(O===void 0)V="utf8",L=this.length,O=0;else if(L===void 0&&typeof O=="string")V=O,L=this.length,O=0;else if(isFinite(O))O=O>>>0,isFinite(L)?(L=L>>>0,V===void 0&&(V="utf8")):(V=L,L=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let st=this.length-O;if((L===void 0||L>st)&&(L=st),I.length>0&&(L<0||O<0)||O>this.length)throw new RangeError("Attempt to write outside buffer bounds");V||(V="utf8");let ft=!1;for(;;)switch(V){case"hex":return H(this,I,O,L);case"utf8":case"utf-8":return Y(this,I,O,L);case"ascii":case"latin1":case"binary":return E(this,I,O,L);case"base64":return n(this,I,O,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s(this,I,O,L);default:if(ft)throw new TypeError("Unknown encoding: "+V);V=(""+V).toLowerCase(),ft=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function f(I,O,L){return O===0&&L===I.length?t.fromByteArray(I):t.fromByteArray(I.slice(O,L))}function d(I,O,L){L=Math.min(I.length,L);let V=[],st=O;for(;st<L;){let ft=I[st],ht=null,Et=ft>239?4:ft>223?3:ft>191?2:1;if(st+Et<=L){let _t,vt,Qt,It;switch(Et){case 1:ft<128&&(ht=ft);break;case 2:_t=I[st+1],(_t&192)===128&&(It=(ft&31)<<6|_t&63,It>127&&(ht=It));break;case 3:_t=I[st+1],vt=I[st+2],(_t&192)===128&&(vt&192)===128&&(It=(ft&15)<<12|(_t&63)<<6|vt&63,It>2047&&(It<55296||It>57343)&&(ht=It));break;case 4:_t=I[st+1],vt=I[st+2],Qt=I[st+3],(_t&192)===128&&(vt&192)===128&&(Qt&192)===128&&(It=(ft&15)<<18|(_t&63)<<12|(vt&63)<<6|Qt&63,It>65535&&It<1114112&&(ht=It))}}ht===null?(ht=65533,Et=1):ht>65535&&(ht-=65536,V.push(ht>>>10&1023|55296),ht=56320|ht&1023),V.push(ht),st+=Et}return S(V)}var g=4096;function S(I){let O=I.length;if(O<=g)return String.fromCharCode.apply(String,I);let L="",V=0;for(;V<O;)L+=String.fromCharCode.apply(String,I.slice(V,V+=g));return L}function x(I,O,L){let V="";L=Math.min(I.length,L);for(let st=O;st<L;++st)V+=String.fromCharCode(I[st]&127);return V}function a(I,O,L){let V="";L=Math.min(I.length,L);for(let st=O;st<L;++st)V+=String.fromCharCode(I[st]);return V}function e(I,O,L){let V=I.length;(!O||O<0)&&(O=0),(!L||L<0||L>V)&&(L=V);let st="";for(let ft=O;ft<L;++ft)st+=Mt[I[ft]];return st}function u(I,O,L){let V=I.slice(O,L),st="";for(let ft=0;ft<V.length-1;ft+=2)st+=String.fromCharCode(V[ft]+V[ft+1]*256);return st}p.prototype.slice=function(I,O){let L=this.length;I=~~I,O=O===void 0?L:~~O,I<0?(I+=L,I<0&&(I=0)):I>L&&(I=L),O<0?(O+=L,O<0&&(O=0)):O>L&&(O=L),O<I&&(O=I);let V=this.subarray(I,O);return Object.setPrototypeOf(V,p.prototype),V};function b(I,O,L){if(I%1!==0||I<0)throw new RangeError("offset is not uint");if(I+O>L)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I],st=1,ft=0;for(;++ft<O&&(st*=256);)V+=this[I+ft]*st;return V},p.prototype.readUintBE=p.prototype.readUIntBE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I+--O],st=1;for(;O>0&&(st*=256);)V+=this[I+--O]*st;return V},p.prototype.readUint8=p.prototype.readUInt8=function(I,O){return I=I>>>0,O||b(I,1,this.length),this[I]},p.prototype.readUint16LE=p.prototype.readUInt16LE=function(I,O){return I=I>>>0,O||b(I,2,this.length),this[I]|this[I+1]<<8},p.prototype.readUint16BE=p.prototype.readUInt16BE=function(I,O){return I=I>>>0,O||b(I,2,this.length),this[I]<<8|this[I+1]},p.prototype.readUint32LE=p.prototype.readUInt32LE=function(I,O){return I=I>>>0,O||b(I,4,this.length),(this[I]|this[I+1]<<8|this[I+2]<<16)+this[I+3]*16777216},p.prototype.readUint32BE=p.prototype.readUInt32BE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]*16777216+(this[I+1]<<16|this[I+2]<<8|this[I+3])},p.prototype.readBigUInt64LE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=O+this[++I]*2**8+this[++I]*2**16+this[++I]*2**24,st=this[++I]+this[++I]*2**8+this[++I]*2**16+L*2**24;return BigInt(V)+(BigInt(st)<<BigInt(32))}),p.prototype.readBigUInt64BE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=O*2**24+this[++I]*2**16+this[++I]*2**8+this[++I],st=this[++I]*2**24+this[++I]*2**16+this[++I]*2**8+L;return(BigInt(V)<<BigInt(32))+BigInt(st)}),p.prototype.readIntLE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=this[I],st=1,ft=0;for(;++ft<O&&(st*=256);)V+=this[I+ft]*st;return st*=128,V>=st&&(V-=Math.pow(2,8*O)),V},p.prototype.readIntBE=function(I,O,L){I=I>>>0,O=O>>>0,L||b(I,O,this.length);let V=O,st=1,ft=this[I+--V];for(;V>0&&(st*=256);)ft+=this[I+--V]*st;return st*=128,ft>=st&&(ft-=Math.pow(2,8*O)),ft},p.prototype.readInt8=function(I,O){return I=I>>>0,O||b(I,1,this.length),this[I]&128?(255-this[I]+1)*-1:this[I]},p.prototype.readInt16LE=function(I,O){I=I>>>0,O||b(I,2,this.length);let L=this[I]|this[I+1]<<8;return L&32768?L|4294901760:L},p.prototype.readInt16BE=function(I,O){I=I>>>0,O||b(I,2,this.length);let L=this[I+1]|this[I]<<8;return L&32768?L|4294901760:L},p.prototype.readInt32LE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]|this[I+1]<<8|this[I+2]<<16|this[I+3]<<24},p.prototype.readInt32BE=function(I,O){return I=I>>>0,O||b(I,4,this.length),this[I]<<24|this[I+1]<<16|this[I+2]<<8|this[I+3]},p.prototype.readBigInt64LE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=this[I+4]+this[I+5]*2**8+this[I+6]*2**16+(L<<24);return(BigInt(V)<<BigInt(32))+BigInt(O+this[++I]*2**8+this[++I]*2**16+this[++I]*2**24)}),p.prototype.readBigInt64BE=ne(function(I){I=I>>>0,j(I,"offset");let O=this[I],L=this[I+7];(O===void 0||L===void 0)&&rt(I,this.length-8);let V=(O<<24)+this[++I]*2**16+this[++I]*2**8+this[++I];return(BigInt(V)<<BigInt(32))+BigInt(this[++I]*2**24+this[++I]*2**16+this[++I]*2**8+L)}),p.prototype.readFloatLE=function(I,O){return I=I>>>0,O||b(I,4,this.length),r.read(this,I,!0,23,4)},p.prototype.readFloatBE=function(I,O){return I=I>>>0,O||b(I,4,this.length),r.read(this,I,!1,23,4)},p.prototype.readDoubleLE=function(I,O){return I=I>>>0,O||b(I,8,this.length),r.read(this,I,!0,52,8)},p.prototype.readDoubleBE=function(I,O){return I=I>>>0,O||b(I,8,this.length),r.read(this,I,!1,52,8)};function _(I,O,L,V,st,ft){if(!p.isBuffer(I))throw new TypeError('"buffer" argument must be a Buffer instance');if(O>st||O<ft)throw new RangeError('"value" argument is out of bounds');if(L+V>I.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(I,O,L,V){if(I=+I,O=O>>>0,L=L>>>0,!V){let ht=Math.pow(2,8*L)-1;_(this,I,O,L,ht,0)}let st=1,ft=0;for(this[O]=I&255;++ft<L&&(st*=256);)this[O+ft]=I/st&255;return O+L},p.prototype.writeUintBE=p.prototype.writeUIntBE=function(I,O,L,V){if(I=+I,O=O>>>0,L=L>>>0,!V){let ht=Math.pow(2,8*L)-1;_(this,I,O,L,ht,0)}let st=L-1,ft=1;for(this[O+st]=I&255;--st>=0&&(ft*=256);)this[O+st]=I/ft&255;return O+L},p.prototype.writeUint8=p.prototype.writeUInt8=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,1,255,0),this[O]=I&255,O+1},p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,65535,0),this[O]=I&255,this[O+1]=I>>>8,O+2},p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,65535,0),this[O]=I>>>8,this[O+1]=I&255,O+2},p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,4294967295,0),this[O+3]=I>>>24,this[O+2]=I>>>16,this[O+1]=I>>>8,this[O]=I&255,O+4},p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,4294967295,0),this[O]=I>>>24,this[O+1]=I>>>16,this[O+2]=I>>>8,this[O+3]=I&255,O+4};function k(I,O,L,V,st){U(O,V,st,I,L,7);let ft=Number(O&BigInt(4294967295));I[L++]=ft,ft=ft>>8,I[L++]=ft,ft=ft>>8,I[L++]=ft,ft=ft>>8,I[L++]=ft;let ht=Number(O>>BigInt(32)&BigInt(4294967295));return I[L++]=ht,ht=ht>>8,I[L++]=ht,ht=ht>>8,I[L++]=ht,ht=ht>>8,I[L++]=ht,L}function $(I,O,L,V,st){U(O,V,st,I,L,7);let ft=Number(O&BigInt(4294967295));I[L+7]=ft,ft=ft>>8,I[L+6]=ft,ft=ft>>8,I[L+5]=ft,ft=ft>>8,I[L+4]=ft;let ht=Number(O>>BigInt(32)&BigInt(4294967295));return I[L+3]=ht,ht=ht>>8,I[L+2]=ht,ht=ht>>8,I[L+1]=ht,ht=ht>>8,I[L]=ht,L+8}p.prototype.writeBigUInt64LE=ne(function(I,O=0){return k(this,I,O,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeBigUInt64BE=ne(function(I,O=0){return $(this,I,O,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeIntLE=function(I,O,L,V){if(I=+I,O=O>>>0,!V){let Et=Math.pow(2,8*L-1);_(this,I,O,L,Et-1,-Et)}let st=0,ft=1,ht=0;for(this[O]=I&255;++st<L&&(ft*=256);)I<0&&ht===0&&this[O+st-1]!==0&&(ht=1),this[O+st]=(I/ft>>0)-ht&255;return O+L},p.prototype.writeIntBE=function(I,O,L,V){if(I=+I,O=O>>>0,!V){let Et=Math.pow(2,8*L-1);_(this,I,O,L,Et-1,-Et)}let st=L-1,ft=1,ht=0;for(this[O+st]=I&255;--st>=0&&(ft*=256);)I<0&&ht===0&&this[O+st+1]!==0&&(ht=1),this[O+st]=(I/ft>>0)-ht&255;return O+L},p.prototype.writeInt8=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,1,127,-128),I<0&&(I=255+I+1),this[O]=I&255,O+1},p.prototype.writeInt16LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,32767,-32768),this[O]=I&255,this[O+1]=I>>>8,O+2},p.prototype.writeInt16BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,2,32767,-32768),this[O]=I>>>8,this[O+1]=I&255,O+2},p.prototype.writeInt32LE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,2147483647,-2147483648),this[O]=I&255,this[O+1]=I>>>8,this[O+2]=I>>>16,this[O+3]=I>>>24,O+4},p.prototype.writeInt32BE=function(I,O,L){return I=+I,O=O>>>0,L||_(this,I,O,4,2147483647,-2147483648),I<0&&(I=4294967295+I+1),this[O]=I>>>24,this[O+1]=I>>>16,this[O+2]=I>>>8,this[O+3]=I&255,O+4},p.prototype.writeBigInt64LE=ne(function(I,O=0){return k(this,I,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),p.prototype.writeBigInt64BE=ne(function(I,O=0){return $(this,I,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function it(I,O,L,V,st,ft){if(L+V>I.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("Index out of range")}function Z(I,O,L,V,st){return O=+O,L=L>>>0,st||it(I,O,L,4,34028234663852886e22,-34028234663852886e22),r.write(I,O,L,V,23,4),L+4}p.prototype.writeFloatLE=function(I,O,L){return Z(this,I,O,!0,L)},p.prototype.writeFloatBE=function(I,O,L){return Z(this,I,O,!1,L)};function et(I,O,L,V,st){return O=+O,L=L>>>0,st||it(I,O,L,8,17976931348623157e292,-17976931348623157e292),r.write(I,O,L,V,52,8),L+8}p.prototype.writeDoubleLE=function(I,O,L){return et(this,I,O,!0,L)},p.prototype.writeDoubleBE=function(I,O,L){return et(this,I,O,!1,L)},p.prototype.copy=function(I,O,L,V){if(!p.isBuffer(I))throw new TypeError("argument should be a Buffer");if(L||(L=0),!V&&V!==0&&(V=this.length),O>=I.length&&(O=I.length),O||(O=0),V>0&&V<L&&(V=L),V===L||I.length===0||this.length===0)return 0;if(O<0)throw new RangeError("targetStart out of bounds");if(L<0||L>=this.length)throw new RangeError("Index out of range");if(V<0)throw new RangeError("sourceEnd out of bounds");V>this.length&&(V=this.length),I.length-O<V-L&&(V=I.length-O+L);let st=V-L;return this===I&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(O,L,V):Uint8Array.prototype.set.call(I,this.subarray(L,V),O),st},p.prototype.fill=function(I,O,L,V){if(typeof I=="string"){if(typeof O=="string"?(V=O,O=0,L=this.length):typeof L=="string"&&(V=L,L=this.length),V!==void 0&&typeof V!="string")throw new TypeError("encoding must be a string");if(typeof V=="string"&&!p.isEncoding(V))throw new TypeError("Unknown encoding: "+V);if(I.length===1){let ft=I.charCodeAt(0);(V==="utf8"&&ft<128||V==="latin1")&&(I=ft)}}else typeof I=="number"?I=I&255:typeof I=="boolean"&&(I=Number(I));if(O<0||this.length<O||this.length<L)throw new RangeError("Out of range index");if(L<=O)return this;O=O>>>0,L=L===void 0?this.length:L>>>0,I||(I=0);let st;if(typeof I=="number")for(st=O;st<L;++st)this[st]=I;else{let ft=p.isBuffer(I)?I:p.from(I,V),ht=ft.length;if(ht===0)throw new TypeError('The value "'+I+'" is invalid for argument "value"');for(st=0;st<L-O;++st)this[st+O]=ft[st%ht]}return this};var Q={};function z(I,O,L){Q[I]=class extends L{constructor(){super(),Object.defineProperty(this,"message",{value:O.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${I}]`,this.stack,delete this.name}get code(){return I}set code(V){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:V,writable:!0})}toString(){return`${this.name} [${I}]: ${this.message}`}}}z("ERR_BUFFER_OUT_OF_BOUNDS",function(I){return I?`${I} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),z("ERR_INVALID_ARG_TYPE",function(I,O){return`The "${I}" argument must be of type number. Received type ${typeof O}`},TypeError),z("ERR_OUT_OF_RANGE",function(I,O,L){let V=`The value of "${I}" is out of range.`,st=L;return Number.isInteger(L)&&Math.abs(L)>2**32?st=tt(String(L)):typeof L=="bigint"&&(st=String(L),(L>BigInt(2)**BigInt(32)||L<-(BigInt(2)**BigInt(32)))&&(st=tt(st)),st+="n"),V+=` It must be ${O}. Received ${st}`,V},RangeError);function tt(I){let O="",L=I.length,V=I[0]==="-"?1:0;for(;L>=V+4;L-=3)O=`_${I.slice(L-3,L)}${O}`;return`${I.slice(0,L)}${O}`}function X(I,O,L){j(O,"offset"),(I[O]===void 0||I[O+L]===void 0)&&rt(O,I.length-(L+1))}function U(I,O,L,V,st,ft){if(I>L||I<O){let ht=typeof O=="bigint"?"n":"",Et;throw ft>3?O===0||O===BigInt(0)?Et=`>= 0${ht} and < 2${ht} ** ${(ft+1)*8}${ht}`:Et=`>= -(2${ht} ** ${(ft+1)*8-1}${ht}) and < 2 ** ${(ft+1)*8-1}${ht}`:Et=`>= ${O}${ht} and <= ${L}${ht}`,new Q.ERR_OUT_OF_RANGE("value",Et,I)}X(V,st,ft)}function j(I,O){if(typeof I!="number")throw new Q.ERR_INVALID_ARG_TYPE(O,"number",I)}function rt(I,O,L){throw Math.floor(I)!==I?(j(I,L),new Q.ERR_OUT_OF_RANGE(L||"offset","an integer",I)):O<0?new Q.ERR_BUFFER_OUT_OF_BOUNDS:new Q.ERR_OUT_OF_RANGE(L||"offset",`>= ${L?1:0} and <= ${O}`,I)}var ot=/[^+/0-9A-Za-z-_]/g;function ct(I){if(I=I.split("=")[0],I=I.trim().replace(ot,""),I.length<2)return"";for(;I.length%4!==0;)I=I+"=";return I}function ut(I,O){O=O||1/0;let L,V=I.length,st=null,ft=[];for(let ht=0;ht<V;++ht){if(L=I.charCodeAt(ht),L>55295&&L<57344){if(!st){if(L>56319){(O-=3)>-1&&ft.push(239,191,189);continue}else if(ht+1===V){(O-=3)>-1&&ft.push(239,191,189);continue}st=L;continue}if(L<56320){(O-=3)>-1&&ft.push(239,191,189),st=L;continue}L=(st-55296<<10|L-56320)+65536}else st&&(O-=3)>-1&&ft.push(239,191,189);if(st=null,L<128){if((O-=1)<0)break;ft.push(L)}else if(L<2048){if((O-=2)<0)break;ft.push(L>>6|192,L&63|128)}else if(L<65536){if((O-=3)<0)break;ft.push(L>>12|224,L>>6&63|128,L&63|128)}else if(L<1114112){if((O-=4)<0)break;ft.push(L>>18|240,L>>12&63|128,L>>6&63|128,L&63|128)}else throw new Error("Invalid code point")}return ft}function pt(I){let O=[];for(let L=0;L<I.length;++L)O.push(I.charCodeAt(L)&255);return O}function St(I,O){let L,V,st,ft=[];for(let ht=0;ht<I.length&&!((O-=2)<0);++ht)L=I.charCodeAt(ht),V=L>>8,st=L%256,ft.push(st),ft.push(V);return ft}function bt(I){return t.toByteArray(ct(I))}function lt(I,O,L,V){let st;for(st=0;st<V&&!(st+L>=O.length||st>=I.length);++st)O[st+L]=I[st];return st}function mt(I,O){return I instanceof O||I!=null&&I.constructor!=null&&I.constructor.name!=null&&I.constructor.name===O.name}function wt(I){return I!==I}var Mt=function(){let I="0123456789abcdef",O=new Array(256);for(let L=0;L<16;++L){let V=L*16;for(let st=0;st<16;++st)O[V+st]=I[L]+I[st]}return O}();function ne(I){return typeof BigInt>"u"?nt:I}function nt(){throw new Error("BigInt not supported")}}),mMt=Nu((i,t)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,t.exports={Buffer:kR().Buffer,Crypto:window.crypto}):t.exports={Buffer:kR().Buffer,Crypto:crypto}}),get={};uMt(get,{AVSCTap:()=>wm,ArweaveSigner:()=>ZR,DataItem:()=>pm,MAX_TAG_BYTES:()=>m8,MIN_BINARY_SIZE:()=>YR,SIG_CONFIG:()=>rp,SignatureConfig:()=>Ks,Signer:()=>met,createData:()=>wet,deserializeTags:()=>s8,indexToType:()=>JR,serializeTags:()=>XR,tagsExceedLimit:()=>bet});var met=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(i,t,r,h){throw new Error("You must implement verify method on child")}},vMt=D0(VR(),1),jh=D0(pet(),1);async function vet(i){if(Array.isArray(i)){let o=(0,jh.concatBuffers)([(0,jh.stringToBuffer)("list"),(0,jh.stringToBuffer)(i.length.toString())]);return await yet(i,await Bu().hash(o,"SHA-384"))}let t=i,r=(0,jh.concatBuffers)([(0,jh.stringToBuffer)("blob"),(0,jh.stringToBuffer)(t.byteLength.toString())]),h=(0,jh.concatBuffers)([await Bu().hash(r,"SHA-384"),await Bu().hash(t,"SHA-384")]);return await Bu().hash(h,"SHA-384")}async function yet(i,t){if(i.length<1)return t;let r=(0,jh.concatBuffers)([t,await vet(i[0])]),h=await Bu().hash(r,"SHA-384");return await yet(i.slice(1),h)}var pR=D0(pMt(),1),yMt=pR.default.default?pR.default.default:pR.default,bMt=class extends yMt{getPublicKey(i){throw new Error("Unimplemented")}},wMt;function Bu(){return wMt??=new bMt}var Ks;(function(i){i[i.ARWEAVE=1]="ARWEAVE",i[i.ED25519=2]="ED25519",i[i.ETHEREUM=3]="ETHEREUM",i[i.SOLANA=4]="SOLANA",i[i.INJECTEDAPTOS=5]="INJECTEDAPTOS",i[i.MULTIAPTOS=6]="MULTIAPTOS",i[i.TYPEDETHEREUM=7]="TYPEDETHEREUM"})(Ks||(Ks={}));var rp={[Ks.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[Ks.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[Ks.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[Ks.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[Ks.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[Ks.MULTIAPTOS]:{sigLength:64*32+4,pubLength:32*32+1,sigName:"multiAptos"},[Ks.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},ZR=class{signatureType=1;ownerLength=rp[1].pubLength;signatureLength=rp[1].sigLength;jwk;pk;constructor(i){this.pk=i.n,this.jwk=i}get publicKey(){return vMt.default.toBuffer(this.pk)}sign(i){return Bu().sign(this.jwk,i)}static async verify(i,t,r){return await Bu().verify(i,t,r)}},JR={1:ZR},If=D0(VR(),1);async function IR(i){return vet([(0,jh.stringToBuffer)("dataitem"),(0,jh.stringToBuffer)("1"),(0,jh.stringToBuffer)(i.signatureType.toString()),i.rawOwner,i.rawTarget,i.rawAnchor,i.rawTags,i.rawData])}async function _Mt(i,t){let r=await IR(i),h=await t.sign(r),o=await Bu().hash(h);return{signature:ge.from(h),id:ge.from(o)}}async function MMt(i,t){let{signature:r,id:h}=await _Mt(i,t);return i.getRaw().set(r,2),h}var wm=class{buf;pos;constructor(i=ge.alloc(m8),t=0){this.buf=i,this.pos=t}writeTags(i){if(!Array.isArray(i))throw new Error("input must be array");let t=i.length,r;if(t)for(this.writeLong(t),r=0;r<t;r++){let h=i[r];if(h?.name===void 0||h?.value===void 0)throw new Error(`Invalid tag format for ${h}, expected {name:string, value: string}`);this.writeString(h.name),this.writeString(h.value)}this.writeLong(0)}toBuffer(){let i=ge.alloc(this.pos);if(this.pos>this.buf.length)throw new Error(`Too many tag bytes (${this.pos} > ${this.buf.length})`);return this.buf.copy(i,0,0,this.pos),i}tagsExceedLimit(){return this.pos>this.buf.length}writeLong(i){let t=this.buf,r,h;if(i>=-1073741824&&i<1073741824){h=i>=0?i<<1:~i<<1|1;do t[this.pos]=h&127,h>>=7;while(h&&(t[this.pos++]|=128))}else{r=i>=0?i*2:-i*2-1;do t[this.pos]=r&127,r/=128;while(r>=1&&(t[this.pos++]|=128))}this.pos++,this.buf=t}writeString(i){let t=ge.byteLength(i),r=this.buf;this.writeLong(t);let h=this.pos;if(this.pos+=t,!(this.pos>r.length)){if(t>64)this.buf.write(i,this.pos-t,t,"utf8");else{let o,l,c,p;for(o=0,l=t;o<l;o++)c=i.charCodeAt(o),c<128?r[h++]=c:c<2048?(r[h++]=c>>6|192,r[h++]=c&63|128):(c&64512)===55296&&((p=i.charCodeAt(o+1))&64512)===56320?(c=65536+((c&1023)<<10)+(p&1023),o++,r[h++]=c>>18|240,r[h++]=c>>12&63|128,r[h++]=c>>6&63|128,r[h++]=c&63|128):(r[h++]=c>>12|224,r[h++]=c>>6&63|128,r[h++]=c&63|128)}this.buf=r}}readLong(){let i=0,t=0,r=this.buf,h,o,l,c;do h=r[this.pos++],o=h&128,i|=(h&127)<<t,t+=7;while(o&&t<28);if(o){l=i,c=268435456;do h=r[this.pos++],l+=(h&127)*c,c*=128;while(h&128);return(l%2?-(l+1):l)/2}return i>>1^-(i&1)}skipLong(){let i=this.buf;for(;i[this.pos++]&128;);}readTags(){let i=[],t;for(;t=this.readLong();)for(t<0&&(t=-t,this.skipLong());t--;){let r=this.readString(),h=this.readString();i.push({name:r,value:h})}return i}readString(){let i=this.readLong(),t=this.pos,r=this.buf;if(this.pos+=i,!(this.pos>r.length))return this.buf.slice(t,t+i).toString()}};function XR(i){let t=new wm;return t.writeTags(i),t.toBuffer()}function bet(i){let t=new wm;return t.writeTags(i),t.tagsExceedLimit()}function s8(i){return new wm(i).readTags()}function Gc(i){let t=0;for(let r=i.length-1;r>=0;r--)t=t*256+i[r];return t}function SMt(i){if(i>29)throw new Error("Short too long");let t=[0,0];for(let r=0;r<t.length;r++){let h=i&255;t[r]=h,i=(i-h)/256}return Uint8Array.from(t)}function ott(i){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let h=i&255;t[r]=h,i=(i-h)/256}return Uint8Array.from(t)}var EMt=D0(mMt(),1),z1=D0(kR(),1),m8=4096,YR=80,pm=class{binary;_id;constructor(i){this.binary=i}static isDataItem(i){return i.binary!==void 0}get signatureType(){let i=Gc(this.binary.subarray(0,2));if(Ks?.[i]!==void 0)return i;throw new Error("Unknown signature type: "+i)}async isValid(){return pm.verify(this.binary)}get id(){return(async()=>If.default.encode(await this.rawId))()}set id(i){this._id=If.default.toBuffer(i)}get rawId(){return(async()=>z1.Buffer.from(await EMt.Crypto.subtle.digest("SHA-256",this.rawSignature)))()}set rawId(i){this._id=i}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return If.default.encode(this.rawSignature)}set rawOwner(i){if(i.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${i.byteLength} bytes.`);this.binary.set(i,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return rp[this.signatureType].sigLength}get owner(){return If.default.encode(this.rawOwner)}get ownerLength(){return rp[this.signatureType].pubLength}get rawTarget(){let i=this.getTargetStart();return this.binary[i]==1?this.binary.subarray(i+1,i+33):z1.Buffer.alloc(0)}get target(){return If.default.encode(this.rawTarget)}get rawAnchor(){let i=this.getAnchorStart();return this.binary[i]==1?this.binary.subarray(i+1,i+33):z1.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let i=this.getTagsStart(),t=Gc(this.binary.subarray(i+8,i+16));return this.binary.subarray(i+16,i+16+t)}get tags(){let i=this.getTagsStart();if(Gc(this.binary.subarray(i,i+8))==0)return[];let t=Gc(this.binary.subarray(i+8,i+16));return s8(z1.Buffer.from(this.binary.subarray(i+16,i+16+t)))}get tagsB64Url(){return this.tags.map(i=>({name:If.default.encode(i.name),value:If.default.encode(i.value)}))}getStartOfData(){let i=this.getTagsStart(),t=this.binary.subarray(i+8,i+16),r=Gc(t);return i+16+r}get rawData(){let i=this.getTagsStart(),t=this.binary.subarray(i+8,i+16),r=Gc(t),h=i+16+r;return this.binary.subarray(h,this.binary.length)}get data(){return If.default.encode(this.rawData)}getRaw(){return this.binary}async sign(i){return this._id=await MMt(this,i),this.rawId}async setSignature(i){this.binary.set(i,2),this._id=z1.Buffer.from(await Bu().hash(i))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map(i=>({name:If.default.encode(i.name),value:If.default.encode(i.value)})),data:this.data}}static async verify(i){if(i.byteLength<YR)return!1;let t=new pm(i),r=t.signatureType,h=t.getTagsStart(),o=Gc(i.subarray(h,h+8)),l=i.subarray(h+8,h+16),c=Gc(l);if(c>m8)return!1;if(o>0)try{if(s8(z1.Buffer.from(i.subarray(h+16,h+16+c))).length!==o)return!1}catch{return!1}let p=JR[r],w=await IR(t);return await p.verify(t.rawOwner,w,t.rawSignature)}async getSignatureData(){return IR(this)}getTagsStart(){let i=this.getTargetStart(),t=this.binary[i]==1,r=i+(t?33:1),h=this.binary[r]==1;return r+=h?33:1,r}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let i=this.getTargetStart()+1,t=this.binary[this.getTargetStart()]==1;return i+=t?32:0,i}},AMt=D0(VR(),1);function wet(i,t,r){let h=t.publicKey,o=r?.target?AMt.default.toBuffer(r.target):null,l=1+(o?.byteLength??0),c=r?.anchor?ge.from(r.anchor):null,p=1+(c?.byteLength??0),w=(r?.tags?.length??0)>0?XR(r.tags):null,m=16+(w?w.byteLength:0),y=ge.from(i),v=y.byteLength,M=2+t.signatureLength+t.ownerLength+l+p+m+v,T=ge.alloc(M);if(T.set(SMt(t.signatureType),0),T.set(new Uint8Array(t.signatureLength).fill(0),2),h.byteLength!==t.ownerLength)throw new Error(`Owner must be ${t.ownerLength} bytes, but was incorrectly ${h.byteLength}`);T.set(h,2+t.signatureLength);let A=2+t.signatureLength+t.ownerLength;if(T[A]=o?1:0,o){if(o.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${o.byteLength}`);T.set(o,A+1)}let R=A+l,B=R+1;if(T[R]=c?1:0,c){if(B+=c.byteLength,c.byteLength!==32)throw new Error("Anchor must be 32 bytes");T.set(c,R+1)}T.set(ott(r?.tags?.length??0),B);let C=ott(w?.byteLength??0);T.set(C,B+8),w&&T.set(w,B+16);let P=B+m;return T.set(y,P),new pm(T)}var QR={...get};globalThis.arbundles??=QR;var TMt=QR,xMt=QR;globalThis.Buffer||(globalThis.Buffer=uet.Buffer);var{DataItem:RMt}=cet;function kMt(i){return async({data:r,tags:h,target:o,anchor:l,createDataItem:c=p=>new RMt(p)})=>{let p=await i.signDataItem({data:r,tags:h,target:o,anchor:l}),w=c(uet.Buffer.from(p));return{id:await w.id,raw:await w.getRaw()}}}var IMt=globalThis.GATEWAY_URL||void 0,BMt=globalThis.MU_URL||void 0,OMt=globalThis.CU_URL||void 0,CMt=globalThis.GRAPHQL_URL||void 0,{result:wWt,results:_Wt,message:MWt,spawn:SWt,monitor:EWt,unmonitor:AWt,dryrun:TWt,assign:xWt}=bm({GATEWAY_URL:IMt,MU_URL:BMt,CU_URL:OMt,GRAPHQL_URL:CMt}),RWt=fet.createDataItemSigner;var _et=Sl(U5(),1);var Js=class i{logger;processId;ao;constructor({processId:t,ao:r=bm(),logger:h=new la({level:"info"})}){this.processId=t,this.logger=h,this.ao=r}static async createAoSigner(t){return t.publicKey===void 0&&"setPublicKey"in t&&await t.setPublicKey(),async({data:h,tags:o,target:l,anchor:c})=>{let p=(0,_et.createData)(h,t,{tags:o,target:l,anchor:c});return p.sign(t).then(async()=>({id:await p.id,raw:await p.getRaw()}))}}async read({tags:t,retries:r=3}){let h=0,o;for(;h<r;)try{this.logger.debug("Evaluating read interaction on contract",{tags:t});let l=await this.ao.dryrun({process:this.processId,tags:t});if(l.Messages.length===0)throw new Error(`Process ${this.processId} does not support provided action.`);let p=l.Messages[0].Tags.find(m=>m.name==="Error");if(p)throw new Error(`${p.Value}: ${l.Messages[0].Data}`);return this.logger.debug("Read interaction result",{result:l.Messages[0]?.Data}),JSON.parse(l.Messages[0]?.Data)}catch(l){h++,this.logger.debug(`Read attempt ${h} failed`,{error:l,tags:t}),o=l,await new Promise(c=>setTimeout(c,2**h*1e3))}throw o}async send({tags:t,data:r,signer:h,retries:o=3}){let l=0,c;for(;l<o;)try{this.logger.debug("Evaluating send interaction on contract",{tags:t,data:r,processId:this.processId});let p=await this.ao.message({process:this.processId,tags:[...t,{name:"AR-IO-SDK",value:r1}],data:typeof r!="string"?JSON.stringify(r):r,signer:await i.createAoSigner(h)});this.logger.debug("Sent message to process",{messageId:p,processId:this.processId});let w=await this.ao.result({message:p,process:this.processId});if(this.logger.debug("Message result",{output:w,messageId:p,processId:this.processId}),w.Messages?.length===0||w.Messages===void 0)return{id:p};let y=w.Messages[0].Tags.find(M=>M.name==="Error");if(y){let M=w.Messages[0].Data;throw new i1(`${y.Value}: ${M}`)}let v=JSON.parse(w.Messages[0].Data);return this.logger.debug("Message result data",{resultData:v,messageId:p,processId:this.processId}),{id:p,result:v}}catch(p){if(this.logger.error("Error sending message to process",{error:p.message,processId:this.processId,tags:t}),p.message.includes("500"))this.logger.debug("Retrying send interaction",{attempts:l,retries:o,error:p.message,processId:this.processId}),await new Promise(w=>setTimeout(w,2**l*2e3)),l++,c=p;else throw p}throw c}};var v8=class{static init(t){if(t&&t.signer){let{signer:r,...h}=t;return new tk({...h,signer:r})}return new y8(t)}},y8=class{process;arweave;constructor(t,r=Met.default.init({})){if(!t)this.process=new Js({processId:Qp});else if(Tl(t))this.process=t.process;else if(xl(t))this.process=new Js({processId:t.processId,logger:new la({level:"info"})});else throw new No;this.arweave=r}async getEpoch(t){let h=[{name:"Action",value:"Epoch"},{name:"Timestamp",value:t.timestamp?.toString()??""},{name:"Block-Height",value:t?.blockHeight?.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return h.length===1&&h.push({name:"Timestamp",value:(await this.arweave.blocks.getCurrent()).timestamp.toString()}),this.process.read({tags:h})}async getArNSRecord({name:t}){return this.process.read({tags:[{name:"Action",value:"Record"},{name:"Name",value:t}]})}async getArNSRecords(){return this.process.read({tags:[{name:"Action",value:"Records"}]})}async getArNSReservedNames(){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"}]})}async getArNSReservedName({name:t}){return this.process.read({tags:[{name:"Action",value:"Reserved-Name"},{name:"Name",value:t}]})}async getBalance({address:t}){return this.process.read({tags:[{name:"Action",value:"Balance"},{name:"Address",value:t}]})}async getBalances(){return this.process.read({tags:[{name:"Action",value:"Balances"}]})}async getGateway({address:t}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:t}]})}async getGateways(){return this.process.read({tags:[{name:"Action",value:"Gateways"}]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"},{name:"Timestamp",value:`${Date.now()}`}]})}async getPrescribedObservers(t){let h=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Timestamp",value:t.timestamp?.toString()},{name:"Block-Height",value:t?.blockHeight?.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return h.length===1&&h.push({name:"Timestamp",value:`${Date.now()}`}),this.process.read({tags:h})}async getPrescribedNames(t){let h=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Timestamp",value:t.timestamp?.toString()},{name:"Block-Height",value:t?.blockHeight?.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return h.length===1&&h.push({name:"Timestamp",value:`${Date.now()}`}),this.process.read({tags:h})}async getObservations(t){let h=[{name:"Action",value:"Epoch-Observations"},{name:"Timestamp",value:t.timestamp?.toString()},{name:"Block-Height",value:t?.blockHeight?.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return h.length===1&&h.push({name:"Timestamp",value:(await this.arweave.blocks.getCurrent()).timestamp.toString()}),this.process.read({tags:h})}async getDistributions(t){let h=[{name:"Action",value:"Epoch-Distributions"},{name:"Timestamp",value:t.timestamp?.toString()??""},{name:"Block-Height",value:t?.blockHeight?.toString()},{name:"Epoch-Index",value:t?.epochIndex?.toString()}].filter(o=>o.value!==void 0);return h.length===1&&h.push({name:"Timestamp",value:(await this.arweave.blocks.getCurrent()).timestamp.toString()}),this.process.read({tags:h})}async getTokenCost({intent:t,purchaseType:r,years:h,name:o,quantity:l}){let p=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:t},{name:"Name",value:o},{name:"Years",value:h?.toString()},{name:"Quantity",value:l?.toString()},{name:"Purchase-Type",value:r},{name:"Timestamp",value:`${Date.now()}`}].filter(w=>w.value!==void 0);return this.process.read({tags:p})}},tk=class extends y8{signer;constructor({signer:t,...r}){if(Object.keys(r).length===0)super({process:new Js({processId:Qp})}),this.signer=t;else if(Tl(r))super({process:r.process}),this.signer=t;else if(xl(r))super({process:new Js({processId:r.processId})}),this.signer=t;else throw new No}async transfer({target:t,qty:r},h){let{tags:o=[]}=h||{};return this.process.send({tags:[...o,{name:"Action",value:"Transfer"},{name:"Recipient",value:t},{name:"Quantity",value:r.valueOf().toString()}],signer:this.signer})}async joinNetwork({operatorStake:t,allowDelegatedStaking:r,delegateRewardShareRatio:h,fqdn:o,label:l,minDelegatedStake:c,note:p,port:w,properties:m,protocol:y,autoStake:v,observerAddress:M},T){let{tags:A=[]}=T||{},B=[...A,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:t.valueOf().toString()},{name:"Allow-Delegated-Staking",value:r.toString()},{name:"Delegate-Reward-Share-Ratio",value:h.toString()},{name:"FQDN",value:o},{name:"Label",value:l},{name:"Min-Delegated-Stake",value:c.valueOf().toString()},{name:"Note",value:p},{name:"Port",value:w.toString()},{name:"Properties",value:m},{name:"Protocol",value:y},{name:"Auto-Stake",value:v.toString()},{name:"Observer-Address",value:M}].filter(C=>C.value!==void 0);return this.process.send({signer:this.signer,tags:B})}async updateGatewaySettings({allowDelegatedStaking:t,delegateRewardShareRatio:r,fqdn:h,label:o,minDelegatedStake:l,note:c,port:p,properties:w,protocol:m,autoStake:y,observerAddress:v},M){let{tags:T=[]}=M||{},R=[...T,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:o},{name:"Note",value:c},{name:"FQDN",value:h},{name:"Port",value:p?.toString()},{name:"Properties",value:w},{name:"Protocol",value:m},{name:"Observer-Address",value:v},{name:"Allow-Delegated-Staking",value:t?.toString()},{name:"Delegate-Reward-Share-Ratio",value:r?.toString()},{name:"Min-Delegated-Stake",value:l?.valueOf().toString()},{name:"Auto-Stake",value:y?.toString()}].filter(B=>B.value!==void 0);return this.process.send({signer:this.signer,tags:R})}async delegateStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:t.target},{name:"Quantity",value:t.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Decrease-Delegate-Stake"},{name:"Target",value:t.target},{name:"Quantity",value:t.decreaseQty.valueOf().toString()}]})}async increaseOperatorStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:t.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:t.decreaseQty.valueOf().toString()}]})}async saveObservations(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:t.reportTxId},{name:"Failed-Gateways",value:t.failedGateways.join(",")}],data:{reportTxId:t.reportTxId,failedGateways:t.failedGateways}})}async buyRecord(t,r){let{tags:h=[]}=r||{},l=[...h,{name:"Action",value:"Buy-Record"},{name:"Name",value:t.name},{name:"Years",value:t.years?.toString()??"1"},{name:"Process-Id",value:t.processId},{name:"Purchase-Type",value:t.type||"lease"}].filter(c=>c.value!==void 0);return this.process.send({signer:this.signer,tags:l})}async extendLease(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Extend-Lease"},{name:"Name",value:t.name},{name:"Years",value:t.years.toString()}]})}async increaseUndernameLimit(t,r){let{tags:h=[]}=r||{};return this.process.send({signer:this.signer,tags:[...h,{name:"Action",value:"Increase-Undername-Limit"},{name:"Name",value:t.name},{name:"Quantity",value:t.increaseCount.toString()}]})}};var PMt=rF(50),KKt=async({address:i,contract:t=v8.init({processId:Qp})})=>{let r=await t.getArNSRecords().then(o=>Object.values(o).filter(l=>l.processId!==void 0).map(l=>l.processId)),h=await Promise.all(r.filter(async o=>PMt(async()=>{let l=ky.init({processId:o}),c=await l.getOwner(),p=await l.getControllers();return c===i||p.includes(i)})));return[...new Set(h)]};Tt();Rt();xt();Tt();Rt();xt();var Eet=Sl(aR(),1),b8=Eet.default.init({host:"arweave.net",port:443,protocol:"https"});async function uHt({signer:i,module:t=wL,luaCodeTxId:r=_L,ao:h=bm(),scheduler:o=ML,state:l,stateContractTxId:c}){let p=await b8.transactions.getData(r,{decode:!0,string:!0}),w=await h.spawn({module:t,scheduler:o,signer:await Js.createAoSigner(i)}),m=new Js({processId:w,ao:h});return await m.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:r}],data:p,signer:i}),l&&await m.send({tags:[{name:"Action",value:"Initialize-State"},...c!==void 0?[{name:"State-Contract-TX-ID",value:c}]:[]],data:JSON.stringify(l),signer:i}),w}var w8=class{axios;logger;constructor({url:t,logger:r=new la}){this.logger=r,this.axios=Yq({axiosConfig:{baseURL:t},logger:this.logger})}async get({endpoint:t,signal:r,allowedStatuses:h=[200,202],headers:o,params:l}){this.logger.debug(`Get request to endpoint: ${t} with params ${JSON.stringify(l,void 0,2)}`);let{status:c,statusText:p,data:w}=await this.axios.get(t,{headers:o,signal:r,params:l});if(this.logger.debug(`Response status: ${c} ${p}`),!h.includes(c))switch(c){case 404:throw new xy(p);case 400:throw new Wl(c,p);default:throw new Ry(p)}return w}};var Kl=class{logger;http;contractTxId;cacheUrl;constructor({cacheUrl:t="https://api.arns.app",contractTxId:r,logger:h=new la}){this.cacheUrl=t,this.contractTxId=r,this.logger=h,this.http=new w8({url:`${t}/v1/contract/${r}`})}configuration(){return{contractTxId:this.contractTxId,cacheUrl:this.cacheUrl}}async getState({evaluationOptions:t}={}){this.logger.debug("Fetching contract state",{contractTxId:this.contractTxId,evaluationOptions:t});let{state:r}=await this.http.get({endpoint:"",params:{...t?.evalTo}});return r}async readInteraction({functionName:t,inputs:r,evaluationOptions:h}){this.logger.debug("Evaluating read interaction on contract",{functionName:t,inputs:r,evaluationOptions:h});let{result:o}=await this.http.get({endpoint:`/read/${t}`,params:{...h?.evalTo,...r}});return o}};var Aet=class{static createWriteableContract(t){if(!t||Object.keys(t).length===0)return new da({contractTxId:y6});if(Jf(t))return t.contract instanceof da?t.contract:new da(t.contract.configuration());if(Xf(t))return new da({contractTxId:t.contractTxId});throw new No}static init(t){if(t&&t.signer!==void 0){let{signer:r,...h}=t,o=this.createWriteableContract(h);return new ek({signer:r,contract:o})}else return new _8(t)}},_8=class{contract;constructor(t){if(!t||t===void 0)this.contract=new Kl({contractTxId:y6});else if(Jf(t))this.contract=t.contract;else if(Xf(t))this.contract=new Kl({contractTxId:t.contractTxId});else throw new No}async getState(t={}){return await this.contract.getState(t)}async getArNSRecord({domain:t,evaluationOptions:r}){return(await this.getArNSRecords({evaluationOptions:r}))[t]}async getArNSRecords({evaluationOptions:t}={}){return(await this.contract.getState({evaluationOptions:t})).records}async getArNSReservedNames({evaluationOptions:t}={}){return(await this.contract.getState({evaluationOptions:t})).reserved}async getArNSReservedName({domain:t,evaluationOptions:r}){return(await this.getArNSReservedNames({evaluationOptions:r}))[t]}async getBalance({address:t,evaluationOptions:r}){return(await this.getBalances({evaluationOptions:r}))[t]||0}async getBalances({evaluationOptions:t}={}){return(await this.contract.getState({evaluationOptions:t})).balances}async getGateway({address:t,evaluationOptions:r}){return this.contract.readInteraction({functionName:ho.GATEWAY,inputs:{target:t},evaluationOptions:r}).catch(()=>{})}async getGateways({evaluationOptions:t}={}){return this.contract.readInteraction({functionName:ho.GATEWAYS,evaluationOptions:t})}async getCurrentEpoch({evaluationOptions:t}={}){return this.contract.readInteraction({functionName:ho.EPOCH,evaluationOptions:t})}async getEpoch({blockHeight:t,evaluationOptions:r}){return this.contract.readInteraction({functionName:ho.EPOCH,inputs:{height:t},evaluationOptions:r})}async getPrescribedObservers({evaluationOptions:t}={}){return this.contract.readInteraction({functionName:ho.PRESCRIBED_OBSERVERS,evaluationOptions:t})}async getObservations({evaluationOptions:t}={}){let{observations:r}=await this.contract.getState({evaluationOptions:t});return r}async getDistributions({evaluationOptions:t}={}){let{distributions:r}=await this.contract.getState({evaluationOptions:t});return r}async getAuction({domain:t,type:r,evaluationOptions:h}){return this.contract.readInteraction({functionName:ho.AUCTION,inputs:{name:t,type:r},evaluationOptions:h})}async getAuctions({evaluationOptions:t}={}){let{auctions:r}=await this.contract.getState({evaluationOptions:t});return r}async getPriceForInteraction({interactionName:t,payload:r,evaluationOptions:h}){let{price:o}=await this.contract.readInteraction({functionName:ho.PRICE_FOR_INTERACTION,inputs:{interactionName:t,...r},evaluationOptions:h});return o}},ek=class extends _8{signer;constructor({signer:t,...r}){if(Object.keys(r).length===0)super({contract:new da({contractTxId:y6})}),this.signer=t;else if(Jf(r))super({contract:r.contract}),this.signer=t;else if(Xf(r))super({contract:new da({contractTxId:r.contractTxId})}),this.signer=t;else throw new No}async transfer({target:t,qty:r,denomination:h="IO"},o){let l=r;return h==="IO"&&typeof r=="number"&&(l=new t2(r).toMIO()),this.contract.writeInteraction({functionName:ho.TRANSFER,inputs:{target:t,qty:l.valueOf()},signer:this.signer},o)}async joinNetwork({qty:t,allowDelegatedStaking:r,delegateRewardShareRatio:h,fqdn:o,label:l,minDelegatedStake:c,note:p,port:w,properties:m,protocol:y,autoStake:v,observerWallet:M},T){return this.contract.writeInteraction({functionName:ho.JOIN_NETWORK,inputs:{qty:t.valueOf(),allowDelegatedStaking:r,delegateRewardShareRatio:h,fqdn:o,label:l,minDelegatedStake:c.valueOf(),note:p,port:w,properties:m,protocol:y,autoStake:v,observerWallet:M},signer:this.signer},T)}async updateGatewaySettings({allowDelegatedStaking:t,delegateRewardShareRatio:r,fqdn:h,label:o,minDelegatedStake:l,note:c,port:p,properties:w,protocol:m,autoStake:y,observerWallet:v},M){return this.contract.writeInteraction({functionName:ho.UPDATE_GATEWAY_SETTINGS,inputs:{allowDelegatedStaking:t,delegateRewardShareRatio:r,fqdn:h,label:o,minDelegatedStake:l?.valueOf(),note:c,port:p,properties:w,protocol:m,autoStake:y,observerWallet:v},signer:this.signer},M)}async increaseDelegateStake(t,r){return this.contract.writeInteraction({functionName:ho.DELEGATE_STAKE,inputs:{target:t.target,qty:t.qty.valueOf()},signer:this.signer},r)}async decreaseDelegateStake(t,r){return this.contract.writeInteraction({functionName:ho.DECREASE_DELEGATE_STAKE,inputs:{target:t.target,qty:t.qty.valueOf()},signer:this.signer},r)}async increaseOperatorStake(t,r){return this.contract.writeInteraction({functionName:ho.INCREASE_OPERATOR_STAKE,inputs:{qty:t.qty.valueOf()},signer:this.signer},r)}async decreaseOperatorStake(t,r){return this.contract.writeInteraction({functionName:ho.DECREASE_OPERATOR_STAKE,inputs:{qty:t.qty.valueOf()},signer:this.signer},r)}async saveObservations(t,r){return this.contract.writeInteraction({functionName:ho.SAVE_OBSERVATIONS,inputs:{observerReportTxId:t.reportTxId,failedGateways:t.failedGateways},signer:this.signer},r)}async extendLease(t,r){return this.contract.writeInteraction({functionName:ho.EXTEND_RECORD,inputs:{name:t.domain,years:t.years},signer:this.signer},r)}async increaseUndernameLimit(t,r){return this.contract.writeInteraction({functionName:ho.INCREASE_UNDERNAME_COUNT,inputs:{name:t.domain,qty:t.qty},signer:this.signer},r)}};Tt();Rt();xt();Tt();Rt();xt();var or=Sl($ot(),1);var cie=or.default.AbortError,lie=or.default.AbstractContractHandler,die=or.default.ArweaveContractDefinitionLoader,pie=or.default.ArweaveGatewayBundledContractDefinitionLoader,gie=or.default.ArweaveGatewayBundledInteractionLoader,mie=or.default.ArweaveGatewayInteractionsLoader,vie=or.default.ArweaveWrapper,yie=or.default.Benchmark,bie=or.default.CacheKey,wie=or.default.CacheableInteractionsLoader,_ie=or.default.CacheableStateEvaluator,Mie=or.default.ConsoleLogger,Sie=or.default.ConsoleLoggerFactory,Eie=or.default.ContractCache,Aie=or.default.ContractCallRecord,Tie=or.default.ContractError,xie=or.default.ContractInteractionState,Rie=or.default.ContractMetadata,kie=or.default.CustomEvent,Iie=or.default.DEFAULT_LEVEL_DB_LOCATION,Bie=or.default.DefaultEvaluationOptions,Oie=or.default.DefaultStateEvaluator,Cie=or.default.EvalStateResult,Pie=or.default.EvaluationOptionsEvaluator,Nie=or.default.HandlerBasedContract,Lie=or.default.HandlerExecutorFactory,Die=or.default.InnerWritesEvaluator,$ie=or.default.InteractionCall,Uie=or.default.InteractionCompleteEvent,qie=or.default.InteractionInput,Fie=or.default.InteractionOutput,jie=or.default.JsHandlerApi,zie=or.default.KV,Wie=or.default.KnownErrors,Kie=or.default.LevelDbCache,Hie=or.default.LexicographicalInteractionsSorter,Gie=or.default.LogLevelOrder,Uot=or.default.LoggerFactory,Vie=or.default.MemCache,Zie=or.default.NetworkCommunicationError,Jie=or.default.NonWhitelistedSourceError,Xie=or.default.PstContractImpl,Yie=or.default.REGISTER_PROVIDER,Qie=or.default.SMART_WEAVE_TAGS,tne=or.default.SUPPORTED_SRC_CONTENT_TYPES,ene=or.default.SWBlock,rne=or.default.SWTransaction,ine=or.default.SWVrf,qot=or.default.Signature,nne=or.default.SmartWeaveError,one=or.default.SmartWeaveErrorType,ane=or.default.SmartWeaveGlobal,sne=or.default.SortKeyCacheResult,hne=or.default.SourceType,fne=or.default.SrcCache,Fot=or.default.Tag,une=or.default.TagsParser,cne=or.default.Transaction,lne=or.default.WARP_GW_URL,dne=or.default.WARP_TAGS,pne=or.default.Warp,gne=or.default.WarpBuilder,jot=or.default.WarpFactory,mne=or.default.WarpFetchWrapper,vne=or.default.WarpGatewayContractDefinitionLoader,yne=or.default.WarpGatewayInteractionsLoader,bne=or.default.WasmHandlerApi,wne=or.default.WasmSrc,_ne=or.default.arrayToHex,Mne=or.default.asc,Sne=or.default.ascS,Ene=or.default.bufToBn,Ane=or.default.bundledTxsFilter,Tne=or.default.checkJsSrc,xne=or.default.createDummyTx,Rne=or.default.createInteractionTagsList,kne=or.default.createInteractionTx,Ine=or.default.deepCopy,Bne=or.default.defaultArweaveMs,zot=or.default.defaultCacheOptions,One=or.default.defaultWarpGwOptions,Cne=or.default.desc,Pne=or.default.descS,Nne=or.default.emptyTransfer,Lne=or.default.genesisSortKey,Dne=or.default.getJsonResponse,$ne=or.default.indent,Une=or.default.isBrowser,qne=or.default.isTxIdValid,Fne=or.default.knownWarpPlugins,jne=or.default.knownWarpPluginsPartial,zne=or.default.lastPossibleSortKey,Wne=or.default.lvlToOrder,Kne=or.default.mapReplacer,Hne=or.default.mapReviver,Gne=or.default.matchMutClosureDtor,Vne=or.default.normalizeContractSource,Zne=or.default.rustWasmImports,Jne=or.default.safeGet,Xne=or.default.safeParseInt,Yne=or.default.sleep,Qne=or.default.sortingFirst,toe=or.default.sortingLast,eoe=or.default.stripTrailingSlash,roe=or.default.timeout;Tt();Rt();xt();Px();var JRt="+",XRt="/",YRt="-",QRt="_",tkt="=";function ekt(i){return i.replaceAll(JRt,YRt).replaceAll(XRt,QRt).replaceAll(tkt,"")}function gv(i){let t=i.toString("base64");return ekt(t)}function Wot(i){return gv(Cx("sha256").update(i).digest())}Tt();Rt();xt();var Kot=jot.forMainnet({...zot,inMemory:!0},!0,b8);Uot.INST.logLevel("error");var da=class{contract;contractTxId;cacheUrl;logger;warp;constructor({contractTxId:t,cacheUrl:r="https://api.arns.app",warp:h=Kot,logger:o=new la({level:"info"})}){this.contractTxId=t,this.contract=h.contract(t),this.cacheUrl=r,this.warp=h,this.logger=o}configuration(){return{contractTxId:this.contractTxId,cacheUrl:this.cacheUrl}}async createWarpSigner(t){return t.publicKey===void 0&&"setPublicKey"in t&&await t.setPublicKey(),new qot(this.warp,{signer:async h=>{h.setOwner(gv(t.publicKey));let o=await h.getSignatureData(),l=await t.sign(o),c=ge.from(l),p=Wot(c);h.setSignature({id:p,owner:gv(t.publicKey),signature:gv(c)})},type:"arweave"})}async getState({evaluationOptions:t={}}){await this.ensureContractInit();let r=t?.evalTo,h;r&&"sortKey"in r?h=r.sortKey:r&&"blockHeight"in r&&(h=r.blockHeight);let o=await this.contract.readState(h);if(!o.cachedValue.state)throw new Wl(502,"Failed to evaluate contract state");return o.cachedValue.state}async ensureContractInit({signer:t}={}){this.logger.debug("Checking contract initialized",{contractTxId:this.contractTxId}),this.logger.debug("Fetching contract manifest",{contractTxId:this.contractTxId});let{evaluationOptions:r={}}=await EL({arweave:this.warp.arweave,contractTxId:this.contractTxId});this.contract.setEvaluationOptions(r),t&&this.contract.connect(await this.createWarpSigner(t)),this.cacheUrl!==void 0&&(this.logger.debug("Syncing contract state",{contractTxId:this.contractTxId,remoteCacheUrl:this.cacheUrl}),await this.contract.syncState(`${this.cacheUrl}/v1/contract/${this.contractTxId}`,{validity:!0}))}async readInteraction({functionName:t,inputs:r}){await this.ensureContractInit(),this.logger.debug(`Read interaction: ${t}`,{contractTxId:this.contractTxId,inputs:r});let h=await this.contract.viewState({function:t,...r});if(h.result===void 0)throw new Wl(502,"Failed to evaluate contract read interaction: "+JSON.stringify({error:h.errorMessage,functionName:t,inputs:r},null,2));return this.logger.debug("Successfully evaluated contract read interaction",{contractTxId:this.contractTxId,result:h.result}),h.result}async writeInteraction({functionName:t,inputs:r,signer:h},o){try{this.logger.debug(`Write interaction: ${t}`,{contractTxId:this.contractTxId}),await this.ensureContractInit({signer:h});let l=await this.contract.dryWrite({function:t,...r});if(l.type!=="ok")throw new Error(`Failed to dry write contract interaction ${t}: ${l.errorMessage}`);let c=await this.contract.writeInteraction({function:t,...r},{disableBundling:!0,tags:o?.tags?.map(p=>new Fot(p.name,p.value))});if(!c?.interactionTx)throw new Error(`Failed to write contract interaction: ${t}`);return this.logger.debug("Successfully wrote contract interaction",{contractTxId:this.contractTxId,interactionTxId:c.originalTxId}),c.interactionTx}catch(l){throw this.logger.error(`Failed to write contract interaction: ${l.message}`,{contractTxId:this.contractTxId}),new i1(l)}}};Tt();Rt();xt();var U2=class{process;constructor(t){if(Tl(t))this.process=t.process;else if(xl(t))this.process=new Js({processId:t.processId});else throw new No}async getState(){let t=[{name:"Action",value:"State"}];return await this.process.read({tags:t})}async getInfo(){let t=[{name:"Action",value:"Info"}];return await this.process.read({tags:t})}async getRecord({undername:t}){let r=[{name:"Sub-Domain",value:t},{name:"Action",value:"Record"}];return await this.process.read({tags:r})}async getRecords(){let t=[{name:"Action",value:"Records"}];return await this.process.read({tags:t})}async getOwner(){return(await this.getInfo()).Owner}async getControllers(){let t=[{name:"Action",value:"Controllers"}];return await this.process.read({tags:t})}async getName(){return(await this.getInfo()).Name}async getTicker(){return(await this.getInfo()).Ticker}async getBalances(){let t=[{name:"Action",value:"Balances"}];return await this.process.read({tags:t})}async getBalance({address:t}){let r=[{name:"Action",value:"Balance"},{name:"Recipient",value:t}];return await this.process.read({tags:r})}},By=class extends U2{signer;constructor({signer:t,...r}){super(r),this.signer=t}async transfer({target:t}){let r=[{name:"Action",value:"Transfer"},{name:"Recipient",value:t}];return this.process.send({tags:r,data:{},signer:this.signer})}async addController({controller:t}){let r=[{name:"Action",value:"Add-Controller"},{name:"Controller",value:t}];return this.process.send({tags:r,data:{},signer:this.signer})}async removeController({controller:t}){let r=[{name:"Action",value:"Remove-Controller"},{name:"Controller",value:t}];return this.process.send({tags:r,data:{},signer:this.signer})}async setRecord({undername:t,transactionId:r,ttlSeconds:h}){return this.process.send({tags:[{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:t},{name:"Transaction-Id",value:r},{name:"TTL-Seconds",value:h.toString()}],data:{transactionId:r,ttlSeconds:h},signer:this.signer})}async removeRecord({undername:t}){return this.process.send({tags:[{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:t}],data:{undername:t},signer:this.signer})}async setTicker({ticker:t}){return this.process.send({tags:[{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:t}],data:{ticker:t},signer:this.signer})}async setName({name:t}){return this.process.send({tags:[{name:"Action",value:"Set-Name"},{name:"Name",value:t}],data:{name:t},signer:this.signer})}};var export_ArconnectSigner=Hot.ArconnectSigner;var export_ArweaveSigner=Hot.ArweaveSigner;export{ky as ANT,Iy as ANTReadable,H9 as ANTWritable,hc as ANT_CONTRACT_FUNCTIONS,_L as ANT_LUA_ID,Js as AOProcess,wL as AOS_MODULE_ID,Pkt as ARNS_DEVNET_REGISTRY_TX,y6 as ARNS_TESTNET_REGISTRY_TX,yL as ARWEAVE_TX_REGEX,ho as AR_IO_CONTRACT_FUNCTIONS,n1 as AbortError,U2 as AoANTReadable,By as AoANTWriteable,Aet as ArIO,_8 as ArIOReadable,ek as ArIOWritable,export_ArconnectSigner as ArconnectSigner,export_ArweaveSigner as ArweaveSigner,Qq as BadRequest,yh as BaseError,ML as DEFAULT_SCHEDULER_ID,vL as DENOMINATIONS,la as DefaultLogger,Ckt as FQDN_REGEX,Wl as FailedRequestError,v8 as IO,y8 as IOReadable,t2 as IOToken,tk as IOWriteable,No as InvalidContractConfigurationError,eF as InvalidProcessConfigurationError,tF as InvalidSignerError,o1 as MAX_REQUEST_SIZE,q5 as MIO_PER_IO,xy as NotFound,Kl as RemoteContract,bL as SORT_KEY_REGEX,z5 as SmartWeaveSortKey,Ry as UnknownError,da as WarpContract,i1 as WriteInteractionError,Yq as createAxiosInstance,KKt as getANTProcessesOwnedByWallet,EL as getContractManifest,kqt as getContractsTransferredToOrControlledByWallet,xqt as getSmartweaveContractsFromGQL,Rqt as getSmartweaveTransactionsFromGQL,Akt as ioContractInteractions,bst as ioContractReadInteractions,wst as ioContractWriteInteractions,Qp as ioDevnetProcessId,Kkt as isBlockHeight,Jf as isContractConfiguration,Xf as isContractTxIdConfiguration,Ykt as isLeasedArNSRecord,Tl as isProcessConfiguration,xl as isProcessIdConfiguration,pIt as isSortKey,Hkt as isTransaction,j5 as mIOToken,uHt as spawnANT,SL as tagsToObject,b6 as validateArweaveId};
|
|
380
380
|
/*! Bundled license information:
|
|
381
381
|
|
|
382
382
|
@jspm/core/nodelibs/browser/buffer.js:
|
package/lib/cjs/common/io.js
CHANGED
|
@@ -288,6 +288,10 @@ class IOReadable {
|
|
|
288
288
|
name: 'Purchase-Type',
|
|
289
289
|
value: purchaseType,
|
|
290
290
|
},
|
|
291
|
+
{
|
|
292
|
+
name: 'Timestamp',
|
|
293
|
+
value: `${Date.now()}`,
|
|
294
|
+
},
|
|
291
295
|
];
|
|
292
296
|
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
293
297
|
return this.process.read({
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/common/io.js
CHANGED
|
@@ -281,6 +281,10 @@ export class IOReadable {
|
|
|
281
281
|
name: 'Purchase-Type',
|
|
282
282
|
value: purchaseType,
|
|
283
283
|
},
|
|
284
|
+
{
|
|
285
|
+
name: 'Timestamp',
|
|
286
|
+
value: `${Date.now()}`,
|
|
287
|
+
},
|
|
284
288
|
];
|
|
285
289
|
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
286
290
|
return this.process.read({
|
package/lib/esm/version.js
CHANGED
package/lib/types/version.d.ts
CHANGED