@permaweb/libs 0.0.36 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,15 +1,15 @@
1
- var Kt=Object.create;var Ye=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.getPrototypeOf,rr=Object.prototype.hasOwnProperty;var nr=(n,i)=>()=>(i||n((i={exports:{}}).exports,i),i.exports);var ir=(n,i,a,u)=>{if(i&&typeof i=="object"||typeof i=="function")for(let y of er(i))!rr.call(n,y)&&y!==a&&Ye(n,y,{get:()=>i[y],enumerable:!(u=Xt(i,y))||u.enumerable});return n};var A=(n,i,a)=>(a=n!=null?Kt(tr(n)):{},ir(i||!n||!n.__esModule?Ye(a,"default",{value:n,enumerable:!0}):a,n));var T=nr((vr,Xe)=>{var P=Xe.exports={},Y,H;function Re(){throw new Error("setTimeout has not been defined")}function Ue(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Y=setTimeout:Y=Re}catch{Y=Re}try{typeof clearTimeout=="function"?H=clearTimeout:H=Ue}catch{H=Ue}})();function He(n){if(Y===setTimeout)return setTimeout(n,0);if((Y===Re||!Y)&&setTimeout)return Y=setTimeout,setTimeout(n,0);try{return Y(n,0)}catch{try{return Y.call(null,n,0)}catch{return Y.call(this,n,0)}}}function or(n){if(H===clearTimeout)return clearTimeout(n);if((H===Ue||!H)&&clearTimeout)return H=clearTimeout,clearTimeout(n);try{return H(n)}catch{try{return H.call(null,n)}catch{return H.call(this,n)}}}var K=[],le=!1,ne,Te=-1;function ar(){!le||!ne||(le=!1,ne.length?K=ne.concat(K):Te=-1,K.length&&je())}function je(){if(!le){var n=He(ar);le=!0;for(var i=K.length;i;){for(ne=K,K=[];++Te<i;)ne&&ne[Te].run();Te=-1,i=K.length}ne=null,le=!1,or(n)}}P.nextTick=function(n){var i=new Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)i[a-1]=arguments[a];K.push(new Ke(n,i)),K.length===1&&!le&&He(je)};function Ke(n,i){this.fun=n,this.array=i}Ke.prototype.run=function(){this.fun.apply(null,this.array)};P.title="browser";P.browser=!0;P.env={};P.argv=[];P.version="";P.versions={};function X(){}P.on=X;P.addListener=X;P.once=X;P.off=X;P.removeListener=X;P.removeAllListeners=X;P.emit=X;P.prependListener=X;P.prependOnceListener=X;P.listeners=function(n){return[]};P.binding=function(n){throw new Error("process.binding is not supported")};P.cwd=function(){return"/"};P.chdir=function(n){throw new Error("process.chdir is not supported")};P.umask=function(){return 0}});var no=A(T(),1);var Wr=A(T());var Rr=A(T(),1);var he={},et=!1;function sr(){if(et)return he;et=!0,he.byteLength=f,he.toByteArray=E,he.fromByteArray=$;for(var n=[],i=[],a=typeof Uint8Array<"u"?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y=0,d=u.length;y<d;++y)n[y]=u[y],i[u.charCodeAt(y)]=y;i[45]=62,i[95]=63;function s(h){var m=h.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var x=h.indexOf("=");x===-1&&(x=m);var L=x===m?0:4-x%4;return[x,L]}function f(h){var m=s(h),x=m[0],L=m[1];return(x+L)*3/4-L}function g(h,m,x){return(m+x)*3/4-x}function E(h){var m,x=s(h),L=x[0],_=x[1],U=new a(g(h,L,_)),Q=0,Z=_>0?L-4:L,G;for(G=0;G<Z;G+=4)m=i[h.charCodeAt(G)]<<18|i[h.charCodeAt(G+1)]<<12|i[h.charCodeAt(G+2)]<<6|i[h.charCodeAt(G+3)],U[Q++]=m>>16&255,U[Q++]=m>>8&255,U[Q++]=m&255;return _===2&&(m=i[h.charCodeAt(G)]<<2|i[h.charCodeAt(G+1)]>>4,U[Q++]=m&255),_===1&&(m=i[h.charCodeAt(G)]<<10|i[h.charCodeAt(G+1)]<<4|i[h.charCodeAt(G+2)]>>2,U[Q++]=m>>8&255,U[Q++]=m&255),U}function B(h){return n[h>>18&63]+n[h>>12&63]+n[h>>6&63]+n[h&63]}function D(h,m,x){for(var L,_=[],U=m;U<x;U+=3)L=(h[U]<<16&16711680)+(h[U+1]<<8&65280)+(h[U+2]&255),_.push(B(L));return _.join("")}function $(h){for(var m,x=h.length,L=x%3,_=[],U=16383,Q=0,Z=x-L;Q<Z;Q+=U)_.push(D(h,Q,Q+U>Z?Z:Q+U));return L===1?(m=h[x-1],_.push(n[m>>2]+n[m<<4&63]+"==")):L===2&&(m=(h[x-2]<<8)+h[x-1],_.push(n[m>>10]+n[m>>4&63]+n[m<<2&63]+"=")),_.join("")}return he}var Ae={},tt=!1;function cr(){if(tt)return Ae;tt=!0;return Ae.read=function(n,i,a,u,y){var d,s,f=y*8-u-1,g=(1<<f)-1,E=g>>1,B=-7,D=a?y-1:0,$=a?-1:1,h=n[i+D];for(D+=$,d=h&(1<<-B)-1,h>>=-B,B+=f;B>0;d=d*256+n[i+D],D+=$,B-=8);for(s=d&(1<<-B)-1,d>>=-B,B+=u;B>0;s=s*256+n[i+D],D+=$,B-=8);if(d===0)d=1-E;else{if(d===g)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,u),d=d-E}return(h?-1:1)*s*Math.pow(2,d-u)},Ae.write=function(n,i,a,u,y,d){var s,f,g,E=d*8-y-1,B=(1<<E)-1,D=B>>1,$=y===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=u?0:d-1,m=u?1:-1,x=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(f=isNaN(i)?1:0,s=B):(s=Math.floor(Math.log(i)/Math.LN2),i*(g=Math.pow(2,-s))<1&&(s--,g*=2),s+D>=1?i+=$/g:i+=$*Math.pow(2,1-D),i*g>=2&&(s++,g/=2),s+D>=B?(f=0,s=B):s+D>=1?(f=(i*g-1)*Math.pow(2,y),s=s+D):(f=i*Math.pow(2,D-1)*Math.pow(2,y),s=0));y>=8;n[a+h]=f&255,h+=m,f/=256,y-=8);for(s=s<<y|f,E+=y;E>0;n[a+h]=s&255,h+=m,s/=256,E-=8);n[a+h-m]|=x*128},Ae}var ie={},rt=!1;function nt(){if(rt)return ie;rt=!0;let n=sr(),i=cr(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ie.Buffer=s,ie.SlowBuffer=_,ie.INSPECT_MAX_BYTES=50;let u=2147483647;ie.kMaxLength=u,s.TYPED_ARRAY_SUPPORT=y(),!s.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 y(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function d(r){if(r>u)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,s.prototype),e}function s(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(r)}return f(r,e,t)}s.poolSize=8192;function f(r,e,t){if(typeof r=="string")return D(r,e);if(ArrayBuffer.isView(r))return h(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(V(r,ArrayBuffer)||r&&V(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(V(r,SharedArrayBuffer)||r&&V(r.buffer,SharedArrayBuffer)))return m(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let o=r.valueOf&&r.valueOf();if(o!=null&&o!==r)return s.from(o,e,t);let c=x(r);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return s.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}s.from=function(r,e,t){return f(r,e,t)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function g(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function E(r,e,t){return g(r),r<=0?d(r):e!==void 0?typeof t=="string"?d(r).fill(e,t):d(r).fill(e):d(r)}s.alloc=function(r,e,t){return E(r,e,t)};function B(r){return g(r),d(r<0?0:L(r)|0)}s.allocUnsafe=function(r){return B(r)},s.allocUnsafeSlow=function(r){return B(r)};function D(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=U(r,e)|0,o=d(t),c=o.write(r,e);return c!==t&&(o=o.slice(0,c)),o}function $(r){let e=r.length<0?0:L(r.length)|0,t=d(e);for(let o=0;o<e;o+=1)t[o]=r[o]&255;return t}function h(r){if(V(r,Uint8Array)){let e=new Uint8Array(r);return m(e.buffer,e.byteOffset,e.byteLength)}return $(r)}function m(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let o;return e===void 0&&t===void 0?o=new Uint8Array(r):t===void 0?o=new Uint8Array(r,e):o=new Uint8Array(r,e,t),Object.setPrototypeOf(o,s.prototype),o}function x(r){if(s.isBuffer(r)){let e=L(r.length)|0,t=d(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Pe(r.length)?d(0):$(r);if(r.type==="Buffer"&&Array.isArray(r.data))return $(r.data)}function L(r){if(r>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return r|0}function _(r){return+r!=r&&(r=0),s.alloc(+r)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(V(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),V(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let o=e.length,c=t.length;for(let l=0,p=Math.min(o,c);l<p;++l)if(e[l]!==t[l]){o=e[l],c=t[l];break}return o<c?-1:c<o?1:0},s.isEncoding=function(e){switch(String(e).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}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return s.alloc(0);let o;if(t===void 0)for(t=0,o=0;o<e.length;++o)t+=e[o].length;let c=s.allocUnsafe(t),l=0;for(o=0;o<e.length;++o){let p=e[o];if(V(p,Uint8Array))l+p.length>c.length?(s.isBuffer(p)||(p=s.from(p)),p.copy(c,l)):Uint8Array.prototype.set.call(c,p,l);else if(s.isBuffer(p))p.copy(c,l);else throw new TypeError('"list" argument must be an Array of Buffers');l+=p.length}return c};function U(r,e){if(s.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||V(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&t===0)return 0;let c=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return be(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Ve(r).length;default:if(c)return o?-1:be(r).length;e=(""+e).toLowerCase(),c=!0}}s.byteLength=U;function Q(r,e,t){let o=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Ft(this,e,t);case"utf8":case"utf-8":return We(this,e,t);case"ascii":return _t(this,e,t);case"latin1":case"binary":return Qt(this,e,t);case"base64":return Wt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return zt(this,e,t);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),o=!0}}s.prototype._isBuffer=!0;function Z(r,e,t){let o=r[e];r[e]=r[t],r[t]=o}s.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)Z(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)Z(this,t,t+3),Z(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)Z(this,t,t+7),Z(this,t+1,t+6),Z(this,t+2,t+5),Z(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?We(this,0,e):Q.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let e="",t=ie.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a&&(s.prototype[a]=s.prototype.inspect),s.prototype.compare=function(e,t,o,c,l){if(V(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),o===void 0&&(o=e?e.length:0),c===void 0&&(c=0),l===void 0&&(l=this.length),t<0||o>e.length||c<0||l>this.length)throw new RangeError("out of range index");if(c>=l&&t>=o)return 0;if(c>=l)return-1;if(t>=o)return 1;if(t>>>=0,o>>>=0,c>>>=0,l>>>=0,this===e)return 0;let p=l-c,w=o-t,v=Math.min(p,w),S=this.slice(c,l),b=e.slice(t,o);for(let C=0;C<v;++C)if(S[C]!==b[C]){p=S[C],w=b[C];break}return p<w?-1:w<p?1:0};function G(r,e,t,o,c){if(r.length===0)return-1;if(typeof t=="string"?(o=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Pe(t)&&(t=c?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(c)return-1;t=r.length-1}else if(t<0)if(c)t=0;else return-1;if(typeof e=="string"&&(e=s.from(e,o)),s.isBuffer(e))return e.length===0?-1:Ge(r,e,t,o,c);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):Ge(r,[e],t,o,c);throw new TypeError("val must be string, number or Buffer")}function Ge(r,e,t,o,c){let l=1,p=r.length,w=e.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(r.length<2||e.length<2)return-1;l=2,p/=2,w/=2,t/=2}function v(b,C){return l===1?b[C]:b.readUInt16BE(C*l)}let S;if(c){let b=-1;for(S=t;S<p;S++)if(v(r,S)===v(e,b===-1?0:S-b)){if(b===-1&&(b=S),S-b+1===w)return b*l}else b!==-1&&(S-=S-b),b=-1}else for(t+w>p&&(t=p-w),S=t;S>=0;S--){let b=!0;for(let C=0;C<w;C++)if(v(r,S+C)!==v(e,C)){b=!1;break}if(b)return S}return-1}s.prototype.includes=function(e,t,o){return this.indexOf(e,t,o)!==-1},s.prototype.indexOf=function(e,t,o){return G(this,e,t,o,!0)},s.prototype.lastIndexOf=function(e,t,o){return G(this,e,t,o,!1)};function Nt(r,e,t,o){t=Number(t)||0;let c=r.length-t;o?(o=Number(o),o>c&&(o=c)):o=c;let l=e.length;o>l/2&&(o=l/2);let p;for(p=0;p<o;++p){let w=parseInt(e.substr(p*2,2),16);if(Pe(w))return p;r[t+p]=w}return p}function $t(r,e,t,o){return we(be(e,r.length-t),r,t,o)}function Mt(r,e,t,o){return we(Vt(e),r,t,o)}function kt(r,e,t,o){return we(Ve(e),r,t,o)}function Gt(r,e,t,o){return we(Yt(e,r.length-t),r,t,o)}s.prototype.write=function(e,t,o,c){if(t===void 0)c="utf8",o=this.length,t=0;else if(o===void 0&&typeof t=="string")c=t,o=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(o)?(o=o>>>0,c===void 0&&(c="utf8")):(c=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let l=this.length-t;if((o===void 0||o>l)&&(o=l),e.length>0&&(o<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");c||(c="utf8");let p=!1;for(;;)switch(c){case"hex":return Nt(this,e,t,o);case"utf8":case"utf-8":return $t(this,e,t,o);case"ascii":case"latin1":case"binary":return Mt(this,e,t,o);case"base64":return kt(this,e,t,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gt(this,e,t,o);default:if(p)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),p=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Wt(r,e,t){return e===0&&t===r.length?n.fromByteArray(r):n.fromByteArray(r.slice(e,t))}function We(r,e,t){t=Math.min(r.length,t);let o=[],c=e;for(;c<t;){let l=r[c],p=null,w=l>239?4:l>223?3:l>191?2:1;if(c+w<=t){let v,S,b,C;switch(w){case 1:l<128&&(p=l);break;case 2:v=r[c+1],(v&192)===128&&(C=(l&31)<<6|v&63,C>127&&(p=C));break;case 3:v=r[c+1],S=r[c+2],(v&192)===128&&(S&192)===128&&(C=(l&15)<<12|(v&63)<<6|S&63,C>2047&&(C<55296||C>57343)&&(p=C));break;case 4:v=r[c+1],S=r[c+2],b=r[c+3],(v&192)===128&&(S&192)===128&&(b&192)===128&&(C=(l&15)<<18|(v&63)<<12|(S&63)<<6|b&63,C>65535&&C<1114112&&(p=C))}}p===null?(p=65533,w=1):p>65535&&(p-=65536,o.push(p>>>10&1023|55296),p=56320|p&1023),o.push(p),c+=w}return Ot(o)}let Oe=4096;function Ot(r){let e=r.length;if(e<=Oe)return String.fromCharCode.apply(String,r);let t="",o=0;for(;o<e;)t+=String.fromCharCode.apply(String,r.slice(o,o+=Oe));return t}function _t(r,e,t){let o="";t=Math.min(r.length,t);for(let c=e;c<t;++c)o+=String.fromCharCode(r[c]&127);return o}function Qt(r,e,t){let o="";t=Math.min(r.length,t);for(let c=e;c<t;++c)o+=String.fromCharCode(r[c]);return o}function Ft(r,e,t){let o=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>o)&&(t=o);let c="";for(let l=e;l<t;++l)c+=Ht[r[l]];return c}function zt(r,e,t){let o=r.slice(e,t),c="";for(let l=0;l<o.length-1;l+=2)c+=String.fromCharCode(o[l]+o[l+1]*256);return c}s.prototype.slice=function(e,t){let o=this.length;e=~~e,t=t===void 0?o:~~t,e<0?(e+=o,e<0&&(e=0)):e>o&&(e=o),t<0?(t+=o,t<0&&(t=0)):t>o&&(t=o),t<e&&(t=e);let c=this.subarray(e,t);return Object.setPrototypeOf(c,s.prototype),c};function N(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,o){e=e>>>0,t=t>>>0,o||N(e,t,this.length);let c=this[e],l=1,p=0;for(;++p<t&&(l*=256);)c+=this[e+p]*l;return c},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,o){e=e>>>0,t=t>>>0,o||N(e,t,this.length);let c=this[e+--t],l=1;for(;t>0&&(l*=256);)c+=this[e+--t]*l;return c},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e=e>>>0,t||N(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||N(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||N(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=te(function(e){e=e>>>0,ue(e,"offset");let t=this[e],o=this[e+7];(t===void 0||o===void 0)&&de(e,this.length-8);let c=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,l=this[++e]+this[++e]*2**8+this[++e]*2**16+o*2**24;return BigInt(c)+(BigInt(l)<<BigInt(32))}),s.prototype.readBigUInt64BE=te(function(e){e=e>>>0,ue(e,"offset");let t=this[e],o=this[e+7];(t===void 0||o===void 0)&&de(e,this.length-8);let c=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],l=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+o;return(BigInt(c)<<BigInt(32))+BigInt(l)}),s.prototype.readIntLE=function(e,t,o){e=e>>>0,t=t>>>0,o||N(e,t,this.length);let c=this[e],l=1,p=0;for(;++p<t&&(l*=256);)c+=this[e+p]*l;return l*=128,c>=l&&(c-=Math.pow(2,8*t)),c},s.prototype.readIntBE=function(e,t,o){e=e>>>0,t=t>>>0,o||N(e,t,this.length);let c=t,l=1,p=this[e+--c];for(;c>0&&(l*=256);)p+=this[e+--c]*l;return l*=128,p>=l&&(p-=Math.pow(2,8*t)),p},s.prototype.readInt8=function(e,t){return e=e>>>0,t||N(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e=e>>>0,t||N(e,2,this.length);let o=this[e]|this[e+1]<<8;return o&32768?o|4294901760:o},s.prototype.readInt16BE=function(e,t){e=e>>>0,t||N(e,2,this.length);let o=this[e+1]|this[e]<<8;return o&32768?o|4294901760:o},s.prototype.readInt32LE=function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=te(function(e){e=e>>>0,ue(e,"offset");let t=this[e],o=this[e+7];(t===void 0||o===void 0)&&de(e,this.length-8);let c=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(o<<24);return(BigInt(c)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=te(function(e){e=e>>>0,ue(e,"offset");let t=this[e],o=this[e+7];(t===void 0||o===void 0)&&de(e,this.length-8);let c=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(c)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+o)}),s.prototype.readFloatLE=function(e,t){return e=e>>>0,t||N(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e=e>>>0,t||N(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||N(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||N(e,8,this.length),i.read(this,e,!1,52,8)};function F(r,e,t,o,c,l){if(!s.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>c||e<l)throw new RangeError('"value" argument is out of bounds');if(t+o>r.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,o,c){if(e=+e,t=t>>>0,o=o>>>0,!c){let w=Math.pow(2,8*o)-1;F(this,e,t,o,w,0)}let l=1,p=0;for(this[t]=e&255;++p<o&&(l*=256);)this[t+p]=e/l&255;return t+o},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,o,c){if(e=+e,t=t>>>0,o=o>>>0,!c){let w=Math.pow(2,8*o)-1;F(this,e,t,o,w,0)}let l=o-1,p=1;for(this[t+l]=e&255;--l>=0&&(p*=256);)this[t+l]=e/p&255;return t+o},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function _e(r,e,t,o,c){Je(e,o,c,r,t,7);let l=Number(e&BigInt(4294967295));r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l;let p=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=p,p=p>>8,r[t++]=p,p=p>>8,r[t++]=p,p=p>>8,r[t++]=p,t}function Qe(r,e,t,o,c){Je(e,o,c,r,t,7);let l=Number(e&BigInt(4294967295));r[t+7]=l,l=l>>8,r[t+6]=l,l=l>>8,r[t+5]=l,l=l>>8,r[t+4]=l;let p=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=p,p=p>>8,r[t+2]=p,p=p>>8,r[t+1]=p,p=p>>8,r[t]=p,t+8}s.prototype.writeBigUInt64LE=te(function(e,t=0){return _e(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=te(function(e,t=0){return Qe(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(e,t,o,c){if(e=+e,t=t>>>0,!c){let v=Math.pow(2,8*o-1);F(this,e,t,o,v-1,-v)}let l=0,p=1,w=0;for(this[t]=e&255;++l<o&&(p*=256);)e<0&&w===0&&this[t+l-1]!==0&&(w=1),this[t+l]=(e/p>>0)-w&255;return t+o},s.prototype.writeIntBE=function(e,t,o,c){if(e=+e,t=t>>>0,!c){let v=Math.pow(2,8*o-1);F(this,e,t,o,v-1,-v)}let l=o-1,p=1,w=0;for(this[t+l]=e&255;--l>=0&&(p*=256);)e<0&&w===0&&this[t+l+1]!==0&&(w=1),this[t+l]=(e/p>>0)-w&255;return t+o},s.prototype.writeInt8=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},s.prototype.writeBigInt64LE=te(function(e,t=0){return _e(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=te(function(e,t=0){return Qe(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Fe(r,e,t,o,c,l){if(t+o>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function ze(r,e,t,o,c){return e=+e,t=t>>>0,c||Fe(r,e,t,4),i.write(r,e,t,o,23,4),t+4}s.prototype.writeFloatLE=function(e,t,o){return ze(this,e,t,!0,o)},s.prototype.writeFloatBE=function(e,t,o){return ze(this,e,t,!1,o)};function Ze(r,e,t,o,c){return e=+e,t=t>>>0,c||Fe(r,e,t,8),i.write(r,e,t,o,52,8),t+8}s.prototype.writeDoubleLE=function(e,t,o){return Ze(this,e,t,!0,o)},s.prototype.writeDoubleBE=function(e,t,o){return Ze(this,e,t,!1,o)},s.prototype.copy=function(e,t,o,c){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(o||(o=0),!c&&c!==0&&(c=this.length),t>=e.length&&(t=e.length),t||(t=0),c>0&&c<o&&(c=o),c===o||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),e.length-t<c-o&&(c=e.length-t+o);let l=c-o;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,o,c):Uint8Array.prototype.set.call(e,this.subarray(o,c),t),l},s.prototype.fill=function(e,t,o,c){if(typeof e=="string"){if(typeof t=="string"?(c=t,t=0,o=this.length):typeof o=="string"&&(c=o,o=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!s.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(e.length===1){let p=e.charCodeAt(0);(c==="utf8"&&p<128||c==="latin1")&&(e=p)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<o)throw new RangeError("Out of range index");if(o<=t)return this;t=t>>>0,o=o===void 0?this.length:o>>>0,e||(e=0);let l;if(typeof e=="number")for(l=t;l<o;++l)this[l]=e;else{let p=s.isBuffer(e)?e:s.from(e,c),w=p.length;if(w===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(l=0;l<o-t;++l)this[l+t]=p[l%w]}return this};let ce={};function ve(r,e,t){ce[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(c){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:c,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}ve("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ve("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError),ve("ERR_OUT_OF_RANGE",function(r,e,t){let o=`The value of "${r}" is out of range.`,c=t;return Number.isInteger(t)&&Math.abs(t)>2**32?c=qe(String(t)):typeof t=="bigint"&&(c=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(c=qe(c)),c+="n"),o+=` It must be ${e}. Received ${c}`,o},RangeError);function qe(r){let e="",t=r.length,o=r[0]==="-"?1:0;for(;t>=o+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function Zt(r,e,t){ue(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&de(e,r.length-(t+1))}function Je(r,e,t,o,c,l){if(r>t||r<e){let p=typeof e=="bigint"?"n":"",w;throw e===0||e===BigInt(0)?w=`>= 0${p} and < 2${p} ** ${(l+1)*8}${p}`:w=`>= -(2${p} ** ${(l+1)*8-1}${p}) and < 2 ** ${(l+1)*8-1}${p}`,new ce.ERR_OUT_OF_RANGE("value",w,r)}Zt(o,c,l)}function ue(r,e){if(typeof r!="number")throw new ce.ERR_INVALID_ARG_TYPE(e,"number",r)}function de(r,e,t){throw Math.floor(r)!==r?(ue(r,t),new ce.ERR_OUT_OF_RANGE("offset","an integer",r)):e<0?new ce.ERR_BUFFER_OUT_OF_BOUNDS:new ce.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,r)}let qt=/[^+/0-9A-Za-z-_]/g;function Jt(r){if(r=r.split("=")[0],r=r.trim().replace(qt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function be(r,e){e=e||1/0;let t,o=r.length,c=null,l=[];for(let p=0;p<o;++p){if(t=r.charCodeAt(p),t>55295&&t<57344){if(!c){if(t>56319){(e-=3)>-1&&l.push(239,191,189);continue}else if(p+1===o){(e-=3)>-1&&l.push(239,191,189);continue}c=t;continue}if(t<56320){(e-=3)>-1&&l.push(239,191,189),c=t;continue}t=(c-55296<<10|t-56320)+65536}else c&&(e-=3)>-1&&l.push(239,191,189);if(c=null,t<128){if((e-=1)<0)break;l.push(t)}else if(t<2048){if((e-=2)<0)break;l.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;l.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;l.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return l}function Vt(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Yt(r,e){let t,o,c,l=[];for(let p=0;p<r.length&&!((e-=2)<0);++p)t=r.charCodeAt(p),o=t>>8,c=t%256,l.push(c),l.push(o);return l}function Ve(r){return n.toByteArray(Jt(r))}function we(r,e,t,o){let c;for(c=0;c<o&&!(c+t>=e.length||c>=r.length);++c)e[c+t]=r[c];return c}function V(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Pe(r){return r!==r}let Ht=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let o=t*16;for(let c=0;c<16;++c)e[o+c]=r[t]+r[c]}return e}();function te(r){return typeof BigInt>"u"?jt:r}function jt(){throw new Error("BigInt not supported")}return ie}var oe=nt();oe.Buffer;oe.SlowBuffer;oe.INSPECT_MAX_BYTES;oe.kMaxLength;var R=oe.Buffer,Mr=oe.INSPECT_MAX_BYTES,kr=oe.kMaxLength;var Ln=A(T(),1);var En=A(T(),1);var qr=A(T(),1);var W={module:"URgYpPQzvxxfYQtjrIQ116bl3YBfcImo3JEnNo8Hlrk",scheduler:"_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA",mu:"fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY",src:{asset:"jm8OfYb4PL8-AHvx3k0csQUWDpR24bh6l8uNCoWueHA",collection:"flkCYx4lJtOtsVFyUZLN-AKpkObNoTMYu4GfUTzNoGE",collectionActivity:"k8K8WIJb5kXOVvZRFXF5GIZW-7b2NtaTOd6G-E5MF0k",profile:"WBhJpPafkykqZZgTr7TAsz48RKG4vbOEAH4rZ3JxIQ8",zone:"EQxcaL4yo_tLz7emxBPewWs98tmxJ3z8G56CfcpH3aA"},collectionRegistry:"zwKi27GuKS3GOlwL3EhNGH02SJDDAO5Uy43ZJwomhZ4",profileRegistry:"SNy4m-DrqxWl01YqGM4sxI8qCni-58re8uuJLvZPypY"};var it={"application/json":{type:"application/json",serialize:n=>JSON.stringify(n)}},z={arweave:"arweave.net",goldsky:"arweave-search.goldsky.com"};var I={keys:{access:"Access-Fee",ans110:{title:"Title",description:"Description",topic:"Topic:*",type:"Type",implements:"Implements",license:"License"},assetType:"Asset-Type",banner:"Banner",bootloader:"Bootloader",collectionId:"Collection-Id",collectionName:"Collection-Name",commericalUse:"Commercial-Use",contentType:"Content-Type",creator:"Creator",currency:"Currency",dataModelTraining:"Data-Model-Training",dataProtocol:"Data-Protocol",dateCreated:"Date-Created",derivations:"Derivations",description:"Description",displayName:"Display-Name",handle:"Handle",implements:"Implements",initialOwner:"Initial-Owner",license:"License",name:"Name",onBoot:"On-Boot",paymentAddress:"Payment-Address",paymentMode:"Payment-Mode",profileCreator:"Profile-Creator",profileIndex:"Profile-Index",protocolName:"Protocol-Name",renderWith:"Render-With",thumbnail:"Thumbnail",title:"Title",topic:"Topic",type:"Type",zoneType:"Zone-Type"},values:{document:"Document",user:"User",zone:"Permaweb-Zone"}},ot={node1:"https://up.arweave.net",node2:"https://turbo.ardrive.io",batchSize:1,chunkSize:75e5,dispatchUploadSize:100*1024};var on=A(T(),1);var Kr=A(T(),1);function J(n){return n?/^[a-z0-9_-]{43}$/i.test(n):!1}function Ee(n,i){for(let a=0;a<n.length;a++)if(n[a]&&n[a].name===i)return n[a].value;return null}function at(n){let i=n.match(/^data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+);base64,/);return i?i[1]:null}function st(n){return n.split(",")[1]}function ct(n){let i;if(R.isBuffer(n))i=n.length;else if(typeof n=="string")i=R.byteLength(n,"utf-8");else throw new Error("Input must be a string or a Buffer");return i}function Le(n){let i;return i=n.replace(/\[|\]/g,""),`[[${i}]]`}function fe(n){let i;return i=n.replace(/\[|\]/g,""),i}var j=(...n)=>{console.log("[@permaweb/libs]",...n)};function ur(n){return n.replace(/^[a-z]/,i=>i.toUpperCase())}function pe(n){return Array.isArray(n)?n.map(pe):n&&typeof n=="object"?Object.entries(n).reduce((i,[a,u])=>{let y=ur(a);return i[y]=J(u)?u:pe(u),i},{}):n}function lr(n){return n.charAt(0).toLowerCase()+n.slice(1)}function re(n){return Array.isArray(n)?n.map(re):n&&typeof n=="object"?Object.entries(n).reduce((i,[a,u])=>{let y=J(a)||a.includes("-")?a:lr(a);return i[y]=J(u)?u:re(u),i},{}):n}function O(n,i){let a=n.charAt(0).toUpperCase()+n.slice(1);return{name:`${I.keys.bootloader}-${a}`,value:i}}var pr="https://arweave.net";function ye(n){return`${pr}/${n}`}var pn=A(T(),1);var Ne={p1:"P1",end:"END"},$e={default:100};async function q(n){let i=n.paginator?n.paginator:$e.default,a=[],u=0,y=null;if(n.ids&&!n.ids.length)return{data:a,count:u,nextCursor:y,previousCursor:null};try{let d=dr(n),s=await hr({gateway:n.gateway??z.goldsky,query:yr(d)});return s?.data?.transactions?.edges?.length?(a=[...s.data.transactions.edges],u=s.data.transactions.count??0,a.length<i||!s.data.transactions.pageInfo.hasNextPage?y=Ne.end:y=a[a.length-1].cursor,{data:a,count:u,nextCursor:y,previousCursor:null}):{data:a,count:u,nextCursor:y,previousCursor:null}}catch(d){return console.error(d),{data:a,count:u,nextCursor:y,previousCursor:null}}}async function ut(n,i){let a=1,u=await q(n);if(u&&u.data.length){let y=u.data;for(i&&i(`Count: ${u.count}`),i&&i(`Pages to fetch: ${Math.ceil(u.count/(n.paginator??$e.default))}`),i&&i(`Page ${a} fetched`);u.nextCursor&&u.nextCursor!==Ne.end;)a+=1,i&&i(`Fetching page ${a}...`),u=await q({...n,cursor:u.nextCursor}),u&&u.data.length&&(y=y.concat(u.data));return i&&i("All pages fetched!"),y}else i&&i("No data found");return null}function yr(n){let i={query:`query { ${n} }`};return JSON.stringify(i)}function dr(n){let i=n.paginator?n.paginator:$e.default,a=n.ids?JSON.stringify(n.ids):null,u=null;n.minBlock!==void 0&&n.minBlock!==null&&(u={},u.min=n.minBlock);let y=u?JSON.stringify(u).replace(/"([^"]+)":/g,"$1:"):null,d=n.tags?JSON.stringify(n.tags).replace(/"(name)":/g,"$1:").replace(/"(values)":/g,"$1:").replace(/"match"/g,"match").replace(/"FUZZY_OR"/g,"FUZZY_OR"):null,s=n.owners?JSON.stringify(n.owners):null,f=n.recipients?JSON.stringify(n.recipients):null,g=n.cursor&&n.cursor!==Ne.end?`"${n.cursor}"`:null,E="";if(n.sort)switch(E+="sort: ",n.sort){case"ascending":E+="HEIGHT_ASC";break;case"descending":E+="HEIGHT_DESC";break}let B=`first: ${i}`,D="",$="data { size type } owner { address } block { height timestamp }",h="";switch(n.gateway??z.goldsky){case z.arweave:break;case z.goldsky:g||(D="count"),f&&(h=`recipients: ${f}`),$+=" recipient";break}let x=`
1
+ var er=Object.create;var Je=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var rr=Object.getOwnPropertyNames;var nr=Object.getPrototypeOf,or=Object.prototype.hasOwnProperty;var ir=(n,o)=>()=>(o||n((o={exports:{}}).exports,o),o.exports);var ar=(n,o,a,u)=>{if(o&&typeof o=="object"||typeof o=="function")for(let p of rr(o))!or.call(n,p)&&p!==a&&Je(n,p,{get:()=>o[p],enumerable:!(u=tr(o,p))||u.enumerable});return n};var A=(n,o,a)=>(a=n!=null?er(nr(n)):{},ar(o||!n||!n.__esModule?Je(a,"default",{value:n,enumerable:!0}):a,n));var T=ir((Dr,tt)=>{var P=tt.exports={},j,Y;function Le(){throw new Error("setTimeout has not been defined")}function Ne(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?j=setTimeout:j=Le}catch{j=Le}try{typeof clearTimeout=="function"?Y=clearTimeout:Y=Ne}catch{Y=Ne}})();function Ke(n){if(j===setTimeout)return setTimeout(n,0);if((j===Le||!j)&&setTimeout)return j=setTimeout,setTimeout(n,0);try{return j(n,0)}catch{try{return j.call(null,n,0)}catch{return j.call(this,n,0)}}}function sr(n){if(Y===clearTimeout)return clearTimeout(n);if((Y===Ne||!Y)&&clearTimeout)return Y=clearTimeout,clearTimeout(n);try{return Y(n)}catch{try{return Y.call(null,n)}catch{return Y.call(this,n)}}}var J=[],le=!1,ne,Ae=-1;function cr(){!le||!ne||(le=!1,ne.length?J=ne.concat(J):Ae=-1,J.length&&Xe())}function Xe(){if(!le){var n=Ke(cr);le=!0;for(var o=J.length;o;){for(ne=J,J=[];++Ae<o;)ne&&ne[Ae].run();Ae=-1,o=J.length}ne=null,le=!1,sr(n)}}P.nextTick=function(n){var o=new Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)o[a-1]=arguments[a];J.push(new et(n,o)),J.length===1&&!le&&Ke(Xe)};function et(n,o){this.fun=n,this.array=o}et.prototype.run=function(){this.fun.apply(null,this.array)};P.title="browser";P.browser=!0;P.env={};P.argv=[];P.version="";P.versions={};function K(){}P.on=K;P.addListener=K;P.once=K;P.off=K;P.removeListener=K;P.removeAllListeners=K;P.emit=K;P.prependListener=K;P.prependOnceListener=K;P.listeners=function(n){return[]};P.binding=function(n){throw new Error("process.binding is not supported")};P.cwd=function(){return"/"};P.chdir=function(n){throw new Error("process.chdir is not supported")};P.umask=function(){return 0}});var ii=A(T(),1);var Wr=A(T());var Rr=A(T(),1);var fe={},rt=!1;function ur(){if(rt)return fe;rt=!0,fe.byteLength=h,fe.toByteArray=E,fe.fromByteArray=M;for(var n=[],o=[],a=typeof Uint8Array<"u"?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=u.length;p<d;++p)n[p]=u[p],o[u.charCodeAt(p)]=p;o[45]=62,o[95]=63;function s(f){var m=f.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var x=f.indexOf("=");x===-1&&(x=m);var L=x===m?0:4-x%4;return[x,L]}function h(f){var m=s(f),x=m[0],L=m[1];return(x+L)*3/4-L}function g(f,m,x){return(m+x)*3/4-x}function E(f){var m,x=s(f),L=x[0],_=x[1],U=new a(g(f,L,_)),z=0,Z=_>0?L-4:L,W;for(W=0;W<Z;W+=4)m=o[f.charCodeAt(W)]<<18|o[f.charCodeAt(W+1)]<<12|o[f.charCodeAt(W+2)]<<6|o[f.charCodeAt(W+3)],U[z++]=m>>16&255,U[z++]=m>>8&255,U[z++]=m&255;return _===2&&(m=o[f.charCodeAt(W)]<<2|o[f.charCodeAt(W+1)]>>4,U[z++]=m&255),_===1&&(m=o[f.charCodeAt(W)]<<10|o[f.charCodeAt(W+1)]<<4|o[f.charCodeAt(W+2)]>>2,U[z++]=m>>8&255,U[z++]=m&255),U}function B(f){return n[f>>18&63]+n[f>>12&63]+n[f>>6&63]+n[f&63]}function v(f,m,x){for(var L,_=[],U=m;U<x;U+=3)L=(f[U]<<16&16711680)+(f[U+1]<<8&65280)+(f[U+2]&255),_.push(B(L));return _.join("")}function M(f){for(var m,x=f.length,L=x%3,_=[],U=16383,z=0,Z=x-L;z<Z;z+=U)_.push(v(f,z,z+U>Z?Z:z+U));return L===1?(m=f[x-1],_.push(n[m>>2]+n[m<<4&63]+"==")):L===2&&(m=(f[x-2]<<8)+f[x-1],_.push(n[m>>10]+n[m>>4&63]+n[m<<2&63]+"=")),_.join("")}return fe}var Ee={},nt=!1;function lr(){if(nt)return Ee;nt=!0;return Ee.read=function(n,o,a,u,p){var d,s,h=p*8-u-1,g=(1<<h)-1,E=g>>1,B=-7,v=a?p-1:0,M=a?-1:1,f=n[o+v];for(v+=M,d=f&(1<<-B)-1,f>>=-B,B+=h;B>0;d=d*256+n[o+v],v+=M,B-=8);for(s=d&(1<<-B)-1,d>>=-B,B+=u;B>0;s=s*256+n[o+v],v+=M,B-=8);if(d===0)d=1-E;else{if(d===g)return s?NaN:(f?-1:1)*(1/0);s=s+Math.pow(2,u),d=d-E}return(f?-1:1)*s*Math.pow(2,d-u)},Ee.write=function(n,o,a,u,p,d){var s,h,g,E=d*8-p-1,B=(1<<E)-1,v=B>>1,M=p===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=u?0:d-1,m=u?1:-1,x=o<0||o===0&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(h=isNaN(o)?1:0,s=B):(s=Math.floor(Math.log(o)/Math.LN2),o*(g=Math.pow(2,-s))<1&&(s--,g*=2),s+v>=1?o+=M/g:o+=M*Math.pow(2,1-v),o*g>=2&&(s++,g/=2),s+v>=B?(h=0,s=B):s+v>=1?(h=(o*g-1)*Math.pow(2,p),s=s+v):(h=o*Math.pow(2,v-1)*Math.pow(2,p),s=0));p>=8;n[a+f]=h&255,f+=m,h/=256,p-=8);for(s=s<<p|h,E+=p;E>0;n[a+f]=s&255,f+=m,s/=256,E-=8);n[a+f-m]|=x*128},Ee}var oe={},ot=!1;function it(){if(ot)return oe;ot=!0;let n=ur(),o=lr(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;oe.Buffer=s,oe.SlowBuffer=_,oe.INSPECT_MAX_BYTES=50;let u=2147483647;oe.kMaxLength=u,s.TYPED_ARRAY_SUPPORT=p(),!s.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 p(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function d(r){if(r>u)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,s.prototype),e}function s(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(r)}return h(r,e,t)}s.poolSize=8192;function h(r,e,t){if(typeof r=="string")return v(r,e);if(ArrayBuffer.isView(r))return f(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(H(r,ArrayBuffer)||r&&H(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(H(r,SharedArrayBuffer)||r&&H(r.buffer,SharedArrayBuffer)))return m(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return s.from(i,e,t);let c=x(r);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return s.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}s.from=function(r,e,t){return h(r,e,t)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function g(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function E(r,e,t){return g(r),r<=0?d(r):e!==void 0?typeof t=="string"?d(r).fill(e,t):d(r).fill(e):d(r)}s.alloc=function(r,e,t){return E(r,e,t)};function B(r){return g(r),d(r<0?0:L(r)|0)}s.allocUnsafe=function(r){return B(r)},s.allocUnsafeSlow=function(r){return B(r)};function v(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=U(r,e)|0,i=d(t),c=i.write(r,e);return c!==t&&(i=i.slice(0,c)),i}function M(r){let e=r.length<0?0:L(r.length)|0,t=d(e);for(let i=0;i<e;i+=1)t[i]=r[i]&255;return t}function f(r){if(H(r,Uint8Array)){let e=new Uint8Array(r);return m(e.buffer,e.byteOffset,e.byteLength)}return M(r)}function m(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&t===void 0?i=new Uint8Array(r):t===void 0?i=new Uint8Array(r,e):i=new Uint8Array(r,e,t),Object.setPrototypeOf(i,s.prototype),i}function x(r){if(s.isBuffer(r)){let e=L(r.length)|0,t=d(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Ue(r.length)?d(0):M(r);if(r.type==="Buffer"&&Array.isArray(r.data))return M(r.data)}function L(r){if(r>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return r|0}function _(r){return+r!=r&&(r=0),s.alloc(+r)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(H(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,c=t.length;for(let l=0,y=Math.min(i,c);l<y;++l)if(e[l]!==t[l]){i=e[l],c=t[l];break}return i<c?-1:c<i?1:0},s.isEncoding=function(e){switch(String(e).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}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return s.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;let c=s.allocUnsafe(t),l=0;for(i=0;i<e.length;++i){let y=e[i];if(H(y,Uint8Array))l+y.length>c.length?(s.isBuffer(y)||(y=s.from(y)),y.copy(c,l)):Uint8Array.prototype.set.call(c,y,l);else if(s.isBuffer(y))y.copy(c,l);else throw new TypeError('"list" argument must be an Array of Buffers');l+=y.length}return c};function U(r,e){if(s.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||H(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let c=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Re(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Ye(r).length;default:if(c)return i?-1:Re(r).length;e=(""+e).toLowerCase(),c=!0}}s.byteLength=U;function z(r,e,t){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Zt(this,e,t);case"utf8":case"utf-8":return _e(this,e,t);case"ascii":return Qt(this,e,t);case"latin1":case"binary":return Ft(this,e,t);case"base64":return _t(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vt(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}s.prototype._isBuffer=!0;function Z(r,e,t){let i=r[e];r[e]=r[t],r[t]=i}s.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)Z(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)Z(this,t,t+3),Z(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)Z(this,t,t+7),Z(this,t+1,t+6),Z(this,t+2,t+5),Z(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?_e(this,0,e):z.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let e="",t=oe.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a&&(s.prototype[a]=s.prototype.inspect),s.prototype.compare=function(e,t,i,c,l){if(H(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),c===void 0&&(c=0),l===void 0&&(l=this.length),t<0||i>e.length||c<0||l>this.length)throw new RangeError("out of range index");if(c>=l&&t>=i)return 0;if(c>=l)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,c>>>=0,l>>>=0,this===e)return 0;let y=l-c,w=i-t,D=Math.min(y,w),C=this.slice(c,l),b=e.slice(t,i);for(let S=0;S<D;++S)if(C[S]!==b[S]){y=C[S],w=b[S];break}return y<w?-1:w<y?1:0};function W(r,e,t,i,c){if(r.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Ue(t)&&(t=c?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(c)return-1;t=r.length-1}else if(t<0)if(c)t=0;else return-1;if(typeof e=="string"&&(e=s.from(e,i)),s.isBuffer(e))return e.length===0?-1:Oe(r,e,t,i,c);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):Oe(r,[e],t,i,c);throw new TypeError("val must be string, number or Buffer")}function Oe(r,e,t,i,c){let l=1,y=r.length,w=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;l=2,y/=2,w/=2,t/=2}function D(b,S){return l===1?b[S]:b.readUInt16BE(S*l)}let C;if(c){let b=-1;for(C=t;C<y;C++)if(D(r,C)===D(e,b===-1?0:C-b)){if(b===-1&&(b=C),C-b+1===w)return b*l}else b!==-1&&(C-=C-b),b=-1}else for(t+w>y&&(t=y-w),C=t;C>=0;C--){let b=!0;for(let S=0;S<w;S++)if(D(r,C+S)!==D(e,S)){b=!1;break}if(b)return C}return-1}s.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1},s.prototype.indexOf=function(e,t,i){return W(this,e,t,i,!0)},s.prototype.lastIndexOf=function(e,t,i){return W(this,e,t,i,!1)};function Mt(r,e,t,i){t=Number(t)||0;let c=r.length-t;i?(i=Number(i),i>c&&(i=c)):i=c;let l=e.length;i>l/2&&(i=l/2);let y;for(y=0;y<i;++y){let w=parseInt(e.substr(y*2,2),16);if(Ue(w))return y;r[t+y]=w}return y}function kt(r,e,t,i){return Te(Re(e,r.length-t),r,t,i)}function Gt(r,e,t,i){return Te(Yt(e),r,t,i)}function Wt(r,e,t,i){return Te(Ye(e),r,t,i)}function Ot(r,e,t,i){return Te(Jt(e,r.length-t),r,t,i)}s.prototype.write=function(e,t,i,c){if(t===void 0)c="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")c=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,c===void 0&&(c="utf8")):(c=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let l=this.length-t;if((i===void 0||i>l)&&(i=l),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");c||(c="utf8");let y=!1;for(;;)switch(c){case"hex":return Mt(this,e,t,i);case"utf8":case"utf-8":return kt(this,e,t,i);case"ascii":case"latin1":case"binary":return Gt(this,e,t,i);case"base64":return Wt(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ot(this,e,t,i);default:if(y)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),y=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function _t(r,e,t){return e===0&&t===r.length?n.fromByteArray(r):n.fromByteArray(r.slice(e,t))}function _e(r,e,t){t=Math.min(r.length,t);let i=[],c=e;for(;c<t;){let l=r[c],y=null,w=l>239?4:l>223?3:l>191?2:1;if(c+w<=t){let D,C,b,S;switch(w){case 1:l<128&&(y=l);break;case 2:D=r[c+1],(D&192)===128&&(S=(l&31)<<6|D&63,S>127&&(y=S));break;case 3:D=r[c+1],C=r[c+2],(D&192)===128&&(C&192)===128&&(S=(l&15)<<12|(D&63)<<6|C&63,S>2047&&(S<55296||S>57343)&&(y=S));break;case 4:D=r[c+1],C=r[c+2],b=r[c+3],(D&192)===128&&(C&192)===128&&(b&192)===128&&(S=(l&15)<<18|(D&63)<<12|(C&63)<<6|b&63,S>65535&&S<1114112&&(y=S))}}y===null?(y=65533,w=1):y>65535&&(y-=65536,i.push(y>>>10&1023|55296),y=56320|y&1023),i.push(y),c+=w}return zt(i)}let ze=4096;function zt(r){let e=r.length;if(e<=ze)return String.fromCharCode.apply(String,r);let t="",i=0;for(;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=ze));return t}function Qt(r,e,t){let i="";t=Math.min(r.length,t);for(let c=e;c<t;++c)i+=String.fromCharCode(r[c]&127);return i}function Ft(r,e,t){let i="";t=Math.min(r.length,t);for(let c=e;c<t;++c)i+=String.fromCharCode(r[c]);return i}function Zt(r,e,t){let i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);let c="";for(let l=e;l<t;++l)c+=Kt[r[l]];return c}function Vt(r,e,t){let i=r.slice(e,t),c="";for(let l=0;l<i.length-1;l+=2)c+=String.fromCharCode(i[l]+i[l+1]*256);return c}s.prototype.slice=function(e,t){let i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);let c=this.subarray(e,t);return Object.setPrototypeOf(c,s.prototype),c};function $(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||$(e,t,this.length);let c=this[e],l=1,y=0;for(;++y<t&&(l*=256);)c+=this[e+y]*l;return c},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||$(e,t,this.length);let c=this[e+--t],l=1;for(;t>0&&(l*=256);)c+=this[e+--t]*l;return c},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e=e>>>0,t||$(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||$(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||$(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||$(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||$(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=ee(function(e){e=e>>>0,ue(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let c=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,l=this[++e]+this[++e]*2**8+this[++e]*2**16+i*2**24;return BigInt(c)+(BigInt(l)<<BigInt(32))}),s.prototype.readBigUInt64BE=ee(function(e){e=e>>>0,ue(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let c=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],l=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i;return(BigInt(c)<<BigInt(32))+BigInt(l)}),s.prototype.readIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||$(e,t,this.length);let c=this[e],l=1,y=0;for(;++y<t&&(l*=256);)c+=this[e+y]*l;return l*=128,c>=l&&(c-=Math.pow(2,8*t)),c},s.prototype.readIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||$(e,t,this.length);let c=t,l=1,y=this[e+--c];for(;c>0&&(l*=256);)y+=this[e+--c]*l;return l*=128,y>=l&&(y-=Math.pow(2,8*t)),y},s.prototype.readInt8=function(e,t){return e=e>>>0,t||$(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e=e>>>0,t||$(e,2,this.length);let i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i},s.prototype.readInt16BE=function(e,t){e=e>>>0,t||$(e,2,this.length);let i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i},s.prototype.readInt32LE=function(e,t){return e=e>>>0,t||$(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e=e>>>0,t||$(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=ee(function(e){e=e>>>0,ue(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let c=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(i<<24);return(BigInt(c)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=ee(function(e){e=e>>>0,ue(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&de(e,this.length-8);let c=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(c)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i)}),s.prototype.readFloatLE=function(e,t){return e=e>>>0,t||$(e,4,this.length),o.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e=e>>>0,t||$(e,4,this.length),o.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||$(e,8,this.length),o.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||$(e,8,this.length),o.read(this,e,!1,52,8)};function Q(r,e,t,i,c,l){if(!s.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>c||e<l)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,i,c){if(e=+e,t=t>>>0,i=i>>>0,!c){let w=Math.pow(2,8*i)-1;Q(this,e,t,i,w,0)}let l=1,y=0;for(this[t]=e&255;++y<i&&(l*=256);)this[t+y]=e/l&255;return t+i},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,i,c){if(e=+e,t=t>>>0,i=i>>>0,!c){let w=Math.pow(2,8*i)-1;Q(this,e,t,i,w,0)}let l=i-1,y=1;for(this[t+l]=e&255;--l>=0&&(y*=256);)this[t+l]=e/y&255;return t+i},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,i){return e=+e,t=t>>>0,i||Q(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||Q(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||Q(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||Q(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||Q(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Qe(r,e,t,i,c){je(e,i,c,r,t,7);let l=Number(e&BigInt(4294967295));r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l;let y=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=y,y=y>>8,r[t++]=y,y=y>>8,r[t++]=y,y=y>>8,r[t++]=y,t}function Fe(r,e,t,i,c){je(e,i,c,r,t,7);let l=Number(e&BigInt(4294967295));r[t+7]=l,l=l>>8,r[t+6]=l,l=l>>8,r[t+5]=l,l=l>>8,r[t+4]=l;let y=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=y,y=y>>8,r[t+2]=y,y=y>>8,r[t+1]=y,y=y>>8,r[t]=y,t+8}s.prototype.writeBigUInt64LE=ee(function(e,t=0){return Qe(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=ee(function(e,t=0){return Fe(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(e,t,i,c){if(e=+e,t=t>>>0,!c){let D=Math.pow(2,8*i-1);Q(this,e,t,i,D-1,-D)}let l=0,y=1,w=0;for(this[t]=e&255;++l<i&&(y*=256);)e<0&&w===0&&this[t+l-1]!==0&&(w=1),this[t+l]=(e/y>>0)-w&255;return t+i},s.prototype.writeIntBE=function(e,t,i,c){if(e=+e,t=t>>>0,!c){let D=Math.pow(2,8*i-1);Q(this,e,t,i,D-1,-D)}let l=i-1,y=1,w=0;for(this[t+l]=e&255;--l>=0&&(y*=256);)e<0&&w===0&&this[t+l+1]!==0&&(w=1),this[t+l]=(e/y>>0)-w&255;return t+i},s.prototype.writeInt8=function(e,t,i){return e=+e,t=t>>>0,i||Q(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||Q(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||Q(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||Q(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||Q(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},s.prototype.writeBigInt64LE=ee(function(e,t=0){return Qe(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=ee(function(e,t=0){return Fe(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ze(r,e,t,i,c,l){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Ve(r,e,t,i,c){return e=+e,t=t>>>0,c||Ze(r,e,t,4),o.write(r,e,t,i,23,4),t+4}s.prototype.writeFloatLE=function(e,t,i){return Ve(this,e,t,!0,i)},s.prototype.writeFloatBE=function(e,t,i){return Ve(this,e,t,!1,i)};function qe(r,e,t,i,c){return e=+e,t=t>>>0,c||Ze(r,e,t,8),o.write(r,e,t,i,52,8),t+8}s.prototype.writeDoubleLE=function(e,t,i){return qe(this,e,t,!0,i)},s.prototype.writeDoubleBE=function(e,t,i){return qe(this,e,t,!1,i)},s.prototype.copy=function(e,t,i,c){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!c&&c!==0&&(c=this.length),t>=e.length&&(t=e.length),t||(t=0),c>0&&c<i&&(c=i),c===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),e.length-t<c-i&&(c=e.length-t+i);let l=c-i;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,c):Uint8Array.prototype.set.call(e,this.subarray(i,c),t),l},s.prototype.fill=function(e,t,i,c){if(typeof e=="string"){if(typeof t=="string"?(c=t,t=0,i=this.length):typeof i=="string"&&(c=i,i=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!s.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(e.length===1){let y=e.charCodeAt(0);(c==="utf8"&&y<128||c==="latin1")&&(e=y)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let l;if(typeof e=="number")for(l=t;l<i;++l)this[l]=e;else{let y=s.isBuffer(e)?e:s.from(e,c),w=y.length;if(w===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(l=0;l<i-t;++l)this[l+t]=y[l%w]}return this};let ce={};function Pe(r,e,t){ce[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(c){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:c,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Pe("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Pe("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError),Pe("ERR_OUT_OF_RANGE",function(r,e,t){let i=`The value of "${r}" is out of range.`,c=t;return Number.isInteger(t)&&Math.abs(t)>2**32?c=He(String(t)):typeof t=="bigint"&&(c=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(c=He(c)),c+="n"),i+=` It must be ${e}. Received ${c}`,i},RangeError);function He(r){let e="",t=r.length,i=r[0]==="-"?1:0;for(;t>=i+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function qt(r,e,t){ue(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&de(e,r.length-(t+1))}function je(r,e,t,i,c,l){if(r>t||r<e){let y=typeof e=="bigint"?"n":"",w;throw e===0||e===BigInt(0)?w=`>= 0${y} and < 2${y} ** ${(l+1)*8}${y}`:w=`>= -(2${y} ** ${(l+1)*8-1}${y}) and < 2 ** ${(l+1)*8-1}${y}`,new ce.ERR_OUT_OF_RANGE("value",w,r)}qt(i,c,l)}function ue(r,e){if(typeof r!="number")throw new ce.ERR_INVALID_ARG_TYPE(e,"number",r)}function de(r,e,t){throw Math.floor(r)!==r?(ue(r,t),new ce.ERR_OUT_OF_RANGE("offset","an integer",r)):e<0?new ce.ERR_BUFFER_OUT_OF_BOUNDS:new ce.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,r)}let Ht=/[^+/0-9A-Za-z-_]/g;function jt(r){if(r=r.split("=")[0],r=r.trim().replace(Ht,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Re(r,e){e=e||1/0;let t,i=r.length,c=null,l=[];for(let y=0;y<i;++y){if(t=r.charCodeAt(y),t>55295&&t<57344){if(!c){if(t>56319){(e-=3)>-1&&l.push(239,191,189);continue}else if(y+1===i){(e-=3)>-1&&l.push(239,191,189);continue}c=t;continue}if(t<56320){(e-=3)>-1&&l.push(239,191,189),c=t;continue}t=(c-55296<<10|t-56320)+65536}else c&&(e-=3)>-1&&l.push(239,191,189);if(c=null,t<128){if((e-=1)<0)break;l.push(t)}else if(t<2048){if((e-=2)<0)break;l.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;l.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;l.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return l}function Yt(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Jt(r,e){let t,i,c,l=[];for(let y=0;y<r.length&&!((e-=2)<0);++y)t=r.charCodeAt(y),i=t>>8,c=t%256,l.push(c),l.push(i);return l}function Ye(r){return n.toByteArray(jt(r))}function Te(r,e,t,i){let c;for(c=0;c<i&&!(c+t>=e.length||c>=r.length);++c)e[c+t]=r[c];return c}function H(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Ue(r){return r!==r}let Kt=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let c=0;c<16;++c)e[i+c]=r[t]+r[c]}return e}();function ee(r){return typeof BigInt>"u"?Xt:r}function Xt(){throw new Error("BigInt not supported")}return oe}var ie=it();ie.Buffer;ie.SlowBuffer;ie.INSPECT_MAX_BYTES;ie.kMaxLength;var R=ie.Buffer,Mr=ie.INSPECT_MAX_BYTES,kr=ie.kMaxLength;var Ln=A(T(),1);var En=A(T(),1);var Vr=A(T(),1);var N={module:"URgYpPQzvxxfYQtjrIQ116bl3YBfcImo3JEnNo8Hlrk",scheduler:"_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA",mu:"fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY",src:{asset:"jm8OfYb4PL8-AHvx3k0csQUWDpR24bh6l8uNCoWueHA",collection:"flkCYx4lJtOtsVFyUZLN-AKpkObNoTMYu4GfUTzNoGE",collectionActivity:"k8K8WIJb5kXOVvZRFXF5GIZW-7b2NtaTOd6G-E5MF0k",zone:{id:"fAmxq5HS8V3ijkgTWHRcXtXzU0RPzKK9fmeVi1UwIs0",version:"0.0.2"}},collectionRegistry:"zwKi27GuKS3GOlwL3EhNGH02SJDDAO5Uy43ZJwomhZ4",profileRegistry:"SNy4m-DrqxWl01YqGM4sxI8qCni-58re8uuJLvZPypY"},at={defaultRouter:"https://router-1.forward.computer"},st={"application/json":{type:"application/json",serialize:n=>JSON.stringify(n)}},F={arweave:"arweave.net",goldsky:"arweave-search.goldsky.com"};var I={keys:{access:"Access-Fee",ans110:{title:"Title",description:"Description",topic:"Topic:*",type:"Type",implements:"Implements",license:"License"},assetType:"Asset-Type",banner:"Banner",bootloader:"Bootloader",collectionId:"Collection-Id",collectionName:"Collection-Name",commericalUse:"Commercial-Use",contentType:"Content-Type",creator:"Creator",currency:"Currency",dataModelTraining:"Data-Model-Training",dataProtocol:"Data-Protocol",dateCreated:"Date-Created",derivations:"Derivations",description:"Description",displayName:"Display-Name",handle:"Handle",implements:"Implements",initialOwner:"Initial-Owner",license:"License",name:"Name",onBoot:"On-Boot",paymentAddress:"Payment-Address",paymentMode:"Payment-Mode",profileCreator:"Profile-Creator",profileIndex:"Profile-Index",protocolName:"Protocol-Name",renderWith:"Render-With",thumbnail:"Thumbnail",title:"Title",topic:"Topic",type:"Type",zoneType:"Zone-Type"},values:{document:"Document",user:"User",zone:"Permaweb-Zone"}},ct={node1:"https://up.arweave.net",node2:"https://turbo.ardrive.io",batchSize:1,chunkSize:75e5,dispatchUploadSize:100*1024};var on=A(T(),1);var Kr=A(T(),1);function V(n){return n?/^[a-z0-9_-]{43}$/i.test(n):!1}function Ie(n,o){for(let a=0;a<n.length;a++)if(n[a]&&n[a].name===o)return n[a].value;return null}function ut(n){let o=n.match(/^data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+);base64,/);return o?o[1]:null}function lt(n){return n.split(",")[1]}function pt(n){let o;if(R.isBuffer(n))o=n.length;else if(typeof n=="string")o=R.byteLength(n,"utf-8");else throw new Error("Input must be a string or a Buffer");return o}function $e(n){let o;return o=n.replace(/\[|\]/g,""),`[[${o}]]`}function he(n){let o;return o=n.replace(/\[|\]/g,""),o}var re=(...n)=>{console.log("[@permaweb/libs]",...n)};function pr(n){return n.replace(/^[a-z]/,o=>o.toUpperCase())}function pe(n){return Array.isArray(n)?n.map(pe):n&&typeof n=="object"?Object.entries(n).reduce((o,[a,u])=>{let p=pr(a);return o[p]=V(u)?u:pe(u),o},{}):n}function yr(n){return n.charAt(0).toLowerCase()+n.slice(1)}function te(n){return Array.isArray(n)?n.map(te):n&&typeof n=="object"?Object.entries(n).reduce((o,[a,u])=>{let p=V(a)||a.includes("-")?a:yr(a);return o[p]=V(u)?u:te(u),o},{}):n}function O(n,o){let a=n.charAt(0).toUpperCase()+n.slice(1);return{name:`${I.keys.bootloader}-${a}`,value:o}}var dr="https://arweave.net";function ye(n){return`${dr}/${n}`}var pn=A(T(),1);var Me={p1:"P1",end:"END"},ke={default:100};async function q(n){let o=n.paginator?n.paginator:ke.default,a=[],u=0,p=null;if(n.ids&&!n.ids.length)return{data:a,count:u,nextCursor:p,previousCursor:null};try{let d=hr(n),s=await gr({gateway:n.gateway??F.goldsky,query:fr(d)});return s?.data?.transactions?.edges?.length?(a=[...s.data.transactions.edges],u=s.data.transactions.count??0,a.length<o||!s.data.transactions.pageInfo.hasNextPage?p=Me.end:p=a[a.length-1].cursor,{data:a,count:u,nextCursor:p,previousCursor:null}):{data:a,count:u,nextCursor:p,previousCursor:null}}catch(d){return console.error(d),{data:a,count:u,nextCursor:p,previousCursor:null}}}async function yt(n,o){let a=1,u=await q(n);if(u&&u.data.length){let p=u.data;for(o&&o(`Count: ${u.count}`),o&&o(`Pages to fetch: ${Math.ceil(u.count/(n.paginator??ke.default))}`),o&&o(`Page ${a} fetched`);u.nextCursor&&u.nextCursor!==Me.end;)a+=1,o&&o(`Fetching page ${a}...`),u=await q({...n,cursor:u.nextCursor}),u&&u.data.length&&(p=p.concat(u.data));return o&&o("All pages fetched!"),p}else o&&o("No data found");return null}function fr(n){let o={query:`query { ${n} }`};return JSON.stringify(o)}function hr(n){let o=n.paginator?n.paginator:ke.default,a=n.ids?JSON.stringify(n.ids):null,u=null;n.minBlock!==void 0&&n.minBlock!==null&&(u={},u.min=n.minBlock);let p=u?JSON.stringify(u).replace(/"([^"]+)":/g,"$1:"):null,d=n.tags?JSON.stringify(n.tags).replace(/"(name)":/g,"$1:").replace(/"(values)":/g,"$1:").replace(/"match"/g,"match").replace(/"FUZZY_OR"/g,"FUZZY_OR"):null,s=n.owners?JSON.stringify(n.owners):null,h=n.recipients?JSON.stringify(n.recipients):null,g=n.cursor&&n.cursor!==Me.end?`"${n.cursor}"`:null,E="";if(n.sort)switch(E+="sort: ",n.sort){case"ascending":E+="HEIGHT_ASC";break;case"descending":E+="HEIGHT_DESC";break}let B=`first: ${o}`,v="",M="data { size type } owner { address } block { height timestamp }",f="";switch(n.gateway??F.goldsky){case F.arweave:break;case F.goldsky:g||(v="count"),h&&(f=`recipients: ${h}`),M+=" recipient";break}let x=`
2
2
  transactions(
3
3
  ids: ${a},
4
4
  tags: ${d},
5
5
  ${B}
6
6
  owners: ${s},
7
- ${h},
8
- block: ${y},
7
+ ${f},
8
+ block: ${p},
9
9
  after: ${g},
10
10
  ${E}
11
11
  ){
12
- ${D}
12
+ ${v}
13
13
  pageInfo {
14
14
  hasNextPage
15
15
  }
@@ -21,10 +21,10 @@ var Kt=Object.create;var Ye=Object.defineProperty;var Xt=Object.getOwnPropertyDe
21
21
  name
22
22
  value
23
23
  }
24
- ${$}
24
+ ${M}
25
25
  }
26
26
  }
27
- }`;return n.queryKey&&(x=`${n.queryKey}: ${x}`),x}async function hr(n){try{return await(await fetch(`https://${n.gateway}/graphql`,{method:"POST",headers:{"Content-Type":"application/json"},body:n.query})).json()}catch(i){throw i}}var fr=z.goldsky,gr=100;async function lt(n,i){let a=[{name:"Authority",value:W.mu}];i.tags&&i.tags.length>0&&i.tags.forEach(u=>a.push(u));try{let u=await n.ao.spawn({module:i.module,scheduler:i.scheduler,signer:n.signer,tags:a,data:i.data});return j(`Process ID: ${u}`),u}catch(u){throw console.log(u),new Error(u.message??"Error spawning process")}}function pt(n){return async i=>await ee(n,i)}async function ee(n,i){try{let a=[{name:"Action",value:i.action}];i.tags&&a.push(...i.tags);let u=i.useRawData?i.data:JSON.stringify(i.data);return await n.ao.message({process:i.processId,signer:n.signer,tags:a,data:u})}catch(a){throw new Error(a)}}async function Ie(n,i){try{return console.log("State not found, dryrunning..."),await ge(n,{processId:i.processId,action:i.fallbackAction})}catch(a){throw new Error(a.message??"Error reading process from HyperBEAM")}}function yt(n){return async i=>await ge(n,i)}async function ge(n,i){try{let a=[{name:"Action",value:i.action}];i.tags&&a.push(...i.tags);let u;if(typeof i.data=="object")u=JSON.stringify(i.data||{});else if(typeof i.data=="string"){try{JSON.parse(i.data)}catch(d){throw console.error(d),new Error("Invalid JSON data")}u=i.data}let y=await n.ao.dryrun({process:i.processId,tags:a,data:u});if(y.Messages&&y.Messages.length){if(y.Messages[0].Data)return JSON.parse(y.Messages[0].Data);if(y.Messages[0].Tags)return y.Messages[0].Tags.reduce((d,s)=>(d[s.name]=s.value,d),{})}}catch(a){throw new Error(a.message??"Error dryrunning process")}}async function mr(n,i){try{let{Messages:a}=await n.ao.result({message:i.messageId,process:i.processId});if(a&&a.length){let u={};return a.forEach(y=>{let d=Ee(y.Tags,"Action")||i.action,s=null,f=y.Data;if(f)try{s=JSON.parse(f)}catch{s=f}let g=Ee(y.Tags,"Status"),E=Ee(y.Tags,"Message");u[d]={id:i.messageId,status:g,message:E,data:s}}),u}else return null}catch(a){console.error(a)}}async function dt(n,i){let a=null;if(i.evalSrc?a=i.evalSrc:i.evalTxId&&(a=await wr(i.evalTxId)),a)try{let u=await ee(n,{processId:i.processId,action:"Eval",data:a,tags:i.evalTags||null,useRawData:!0});return j(`Eval: ${u}`),await mr(n,{processId:i.processId,messageId:u,action:"Eval"})}catch(u){throw new Error(u.message??"Error sending process eval")}return null}function ht(n){return async(i,a)=>{try{let u={module:i.module||W.module,scheduler:i.scheduler||W.scheduler};i.data&&(u.data=i.data),i.tags&&(u.tags=i.tags),a&&a("Spawning process...");let y=await lt(n,u);if(i.evalTxId||i.evalSrc){a&&a("Process retrieved!"),a&&a("Sending eval...");try{await dt(n,{processId:y,evalTxId:i.evalTxId||null,evalSrc:i.evalSrc||null,evalTags:i.evalTags})&&a&&a("Eval complete")}catch(d){throw new Error(d.message??"Error creating process")}}return y}catch(u){throw new Error(u.message??"Error creating process")}}}async function ae(n,i,a){try{let u={module:i.module||W.module,scheduler:i.scheduler||W.scheduler};i.data&&(u.data=i.data),i.tags&&(u.tags=i.tags),a&&a("Spawning process...");let y=await lt(n,u);if(i.evalTxId||i.evalSrc){a&&a("Process retrieved!"),a&&a("Sending eval...");try{await dt(n,{processId:y,evalTxId:i.evalTxId||null,evalSrc:i.evalSrc||null,evalTags:i.evalTags})&&a&&a("Eval complete")}catch(d){throw new Error(d.message??"Error creating process")}}return y}catch(u){throw new Error(u.message??"Error creating process")}}async function wr(n){try{return await(await fetch(ye(n))).text()}catch(i){throw new Error(i)}}async function ft(n){let i=0,a=n.noRetryLimit?1/0:gr;for(;i<a;){await new Promise(y=>setTimeout(y,2e3));let u=await q({gateway:fr,ids:[n.processId]});if(u?.data?.length){let y=u.data[0].node.id;return j(`Process found: ${y} (Try ${i+1})`),y}else j(`Process not found: ${n.processId} (Try ${i+1})`),i++}if(a!==1/0)throw new Error("Process not found, please try again")}var bn=A(T(),1);function gt(n){return async i=>{if(J(i))return i;if(!n.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await mt(n,{data:i})}catch(a){throw new Error(a.message??"Error resolving transaction")}}}async function se(n,i){if(J(i))return i;if(!n.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await mt(n,{data:i})}catch(a){throw new Error(a.message??"Error resolving transaction")}}async function mt(n,i){let a=null,u=null,y=null;if(typeof i.data=="string"&&(a=R.from(st(i.data),"base64"),u=at(i.data),y=ct(a)),i.data instanceof File&&(a=new Uint8Array(await i.data.arrayBuffer()),u=i.data.type,y=i.data.size),a&&u&&y)if(y<Number(ot.dispatchUploadSize))try{let d=await n.arweave.createTransaction({data:a},"use_wallet");return d.addTag(I.keys.contentType,u),i.tags&&i.tags.length>0&&i.tags.forEach(f=>d.addTag(f.name,f.value)),(await global.window.arweaveWallet.dispatch(d)).id}catch(d){throw new Error(d.message??"Error dispatching transaction")}else throw new Error("Paid uploads are not yet supported");else throw new Error("Error preparing transaction data")}var zn=A(T(),1);var Ar={},On=A(T(),1);var qi=A(T(),1);var ii=A(T(),1);function Be(n){return async(i,a)=>{let u=Br(i);if(u)throw new Error(u);let y=it[i.contentType]?.serialize(i.data)??i.data,d=Ir(i);try{return await ae(n,{tags:d,data:y},a?f=>a(f):void 0)}catch(s){throw new Error(s.message??"Error creating asset")}}}async function Me(n,i,a){try{let u=re(await Ie(n,{processId:i,path:"asset",fallbackAction:"Info"}));if(a?.useGateway){let y=await q({gateway:z.goldsky,ids:[i],tags:null,owners:null,cursor:null});return{...y?.data?.[0]?xe(y.data[0]):{},...u}}return{id:i,...u}}catch(u){throw new Error(u.message||"Error fetching atomic asset")}}function wt(n){return async(i,a)=>await Me(n,i,a)}async function Tt(n){try{let i=await q({gateway:z.arweave,ids:n??null,tags:null,owners:null,cursor:null});return i&&i.data.length?i.data.map(a=>xe(a)):null}catch(i){throw new Error(i)}}function xe(n){let i={id:n.node.id,owner:n.node.owner.address};for(let a of n.node.tags){let u=a.name,d=(u.startsWith(`${I.keys.bootloader}-`)?u.slice(`${I.keys.bootloader}-`.length):u).split("-").map((f,g)=>g===0?f.toLowerCase():f.charAt(0).toUpperCase()+f.slice(1).toLowerCase()).join(""),s;try{s=JSON.parse(a.value)}catch{s=a.value.toString()}i[d]=s}return i}function Ir(n){let i=[{name:I.keys.onBoot,value:n.src??W.src.asset},{name:I.keys.creator,value:n.creator},{name:I.keys.assetType,value:n.assetType},{name:I.keys.contentType,value:n.contentType},{name:I.keys.implements,value:"ANS-110"},{name:I.keys.dateCreated,value:new Date().getTime().toString()},O("Name",n.name),O("Description",n.description),O("Topics",JSON.stringify(n.topics)),O("Ticker","ATOMIC"),O("Denomination",n.denomination?.toString()??"1"),O("TotalSupply",n.supply?.toString()??"1"),O("Transferable",n.transferable?.toString()??"true"),O("Creator",n.creator)];if(n.metadata)for(let a in n.metadata)i.push(O(pe(a),n.metadata[a].toString()));if(n.users)for(let a of n.users)i.push({name:"Auth-User",value:a});return n.tags&&n.tags.forEach(a=>i.push(a)),i}function Br(n){if(typeof n!="object"||n===null)return"The provided arguments are invalid or empty.";let i=["name","description","topics","creator","data","contentType","assetType"];for(let a of i)if(!(a in n))return`Missing field '${a}'`;return typeof n.name!="string"||n.name.trim()===""?"Name is required":typeof n.description!="string"?"The description must be a valid string":!Array.isArray(n.topics)||n.topics.length===0?"Topics are required":typeof n.creator!="string"||n.creator.trim()===""?"Creator is required":n.data===void 0||n.data===null?"Data field is required":typeof n.contentType!="string"||n.contentType.trim()===""?"Content type must be a non-empty string":typeof n.assetType!="string"||n.assetType.trim()===""?"Type must be a non-empty string":"supply"in n&&(typeof n.supply!="number"||n.supply<=0)?"Supply must be a positive number":"denomination"in n&&(typeof n.denomination!="number"||n.denomination<=0)?"Denomination must be a positive number":"transferable"in n&&typeof n.transferable!="boolean"?"Transferable must be a boolean value":"metadata"in n&&typeof n.metadata!="object"?"Metadata must be an object":"tags"in n&&(!Array.isArray(n.tags)||n.tags.some(a=>typeof a!="object"))?"Tags must be an array of objects":"src"in n&&typeof n.src!="string"?"Source must be a valid string":null}var hi=A(T(),1);var xr="eXCtpVbcd_jZ0dmU2PZ8focaKxBGECBQ8wMib7sIVPo",me="lJovHqM9hwNjHV5JoY9NGWtt0WD-5D4gOqNL2VWW5jk";function At(n){return async(i,a)=>{if(!n.signer)throw new Error("No signer provided");let u=new Date().getTime().toString(),y=[{name:I.keys.contentType,value:"application/json"},{name:I.keys.creator,value:i.creator},{name:I.keys.ans110.title,value:fe(i.title)},{name:I.keys.ans110.description,value:fe(i.description)},{name:I.keys.dateCreated,value:u},{name:I.keys.name,value:fe(i.title)},{name:"Action",value:"Add-Collection"}],d=null,s=null;try{d=i.banner?await se(n,i.thumbnail):me,s=i.banner?await se(n,i.banner):xr,i.thumbnail&&y.push({name:I.keys.thumbnail,value:d}),i.banner&&y.push({name:I.keys.banner,value:s})}catch(E){console.error(E)}let f=await fetch(ye(W.src.collection));if(!f.ok)throw new Error("Unable to fetch process src");let g=await f.text();g=g.replace(/'<NAME>'/g,Le(i.title)),g=g.replace(/'<DESCRIPTION>'/g,Le(i.description)),g=g.replace(/<CREATOR>/g,i.creator),g=g.replace(/<THUMBNAIL>/g,d||me),g=g.replace(/<BANNER>/g,s||me),g=g.replace(/<DATECREATED>/g,u),g=g.replace(/<LASTUPDATE>/g,u);try{let E=await ae(n,{tags:y},a?B=>a(B):void 0);if(j("Sending eval message to collection..."),a&&a("Sending eval message to collection..."),await n.ao.message({process:E,signer:n.signer,tags:[{name:"Action",value:"Eval"}],data:g}),!i.skipRegistry){j("Sending collection to registry..."),a&&a("Sending collection to registry...");let B=[{name:"Action",value:"Add-Collection"},{name:"CollectionId",value:E},{name:"Name",value:fe(i.title)},{name:"Creator",value:i.creator},{name:"DateCreated",value:u}];s&&B.push({name:"Banner",value:s}),d&&B.push({name:"Thumbnail",value:d}),await n.ao.message({process:W.collectionRegistry,signer:n.signer,tags:B})}if(!i.skipActivity){j("Creating collection activity process..."),a&&a("Creating collection activity process...");let B=[{name:"CollectionId",value:E},{name:"DateCreated",value:u},{name:"UCM-Process",value:"Collection-Activity"},{name:"On-Boot",value:W.src.collectionActivity}],D=await ae(n,{tags:B},a?$=>a($):void 0);j("Adding activity to collection process..."),a&&a("Adding activity to collection process..."),await n.ao.message({process:E,signer:n.signer,tags:[{name:"Action",value:"Eval"}],data:`ActivityProcess = '${D}'`})}return E}catch(E){throw new Error(E.message??"Error creating collection")}}}function Et(n){return async i=>await ee(n,{processId:i.creator,action:"Run-Action",tags:[{name:"ForwardTo",value:i.collectionId},{name:"ForwardAction",value:"Update-Assets"}],data:{Target:i.collectionId,Action:"Update-Assets",Input:JSON.stringify({AssetIds:i.assetIds,UpdateType:i.updateType})}})}function It(n){return async i=>{let a=await ge(n,{processId:i,action:"Info"});return{...{id:i,title:a.Name,description:a.Description,creator:a.Creator,dateCreated:a.DateCreated,thumbnail:a.Thumbnail??me,banner:a.Banner??me},assetIds:a.Assets}}}function Bt(n){return async i=>{let a=i.creator?"Get-Collections-By-User":"Get-Collections",u=await ge(n,{processId:W.collectionRegistry,action:a,tags:i.creator?[{name:"Creator",value:i.creator}]:null});return u&&u.Collections&&u.Collections.length?u.Collections.map(d=>({id:d.Id,title:d.Name.replace(/\[|\]/g,""),description:d.Description,creator:d.Creator,dateCreated:d.DateCreated,banner:d.Banner,thumbnail:d.Thumbnail})):null}}var Bi=A(T(),1);function xt(n){let i=Be(n);return async(a,u)=>{let y=a.tags?a.tags:[];y.push({name:"Data-Source",value:a.parentId}),y.push({name:"Root-Source",value:a.rootId??a.parentId});let d={name:`Comment on ${a.parentId}`,description:`Comment on ${a.parentId}`,topics:["comment"],creator:a.creator,data:a.content,contentType:"text/plain",assetType:"comment",tags:y};return i(d,u)}}function Ct(n){return async i=>{try{let a=await Me(n,i,{useGateway:!0}),u=a?.dataSource,y=a?.rootSource;if(!u||!y)throw new Error("dataSource and rootSource must be present on a comment");return{content:await Dt(i),parentId:u,rootId:y}}catch(a){throw new Error(a.message??"Error getting comment")}}}function St(n){return async i=>{if(!i.parentId&&!i.rootId)throw new Error("Must provide either parentId or rootId");let a=[];i.parentId&&a.push({name:"Data-Source",values:[i.parentId??""]}),i.rootId&&a.push({name:"Root-Source",values:[i.rootId??""]});let u=await q({gateway:z.goldsky,ids:null,tags:a,owners:null,cursor:null}),y=[];u&&u.data.length&&(y=u.data.map(s=>xe(s)));let d=[];for(let s of y){let f=s?.dataSource,g=s?.rootSource;if(!f||!g)throw new Error("dataSource and rootSource must be present on a comment");d.push({id:s.id,content:await Dt(s.id),parentId:f,rootId:g})}return d}}async function Dt(n){try{return await(await fetch(ye(n))).text()}catch(i){throw new Error(i.message??"Error getting comment data")}}var Qi=A(T(),1);var Ui=A(T(),1);function Ce(n){return async(i,a)=>{try{let u=[{name:I.keys.onBoot,value:W.src.zone}];return i.tags&&i.tags.length&&i.tags.forEach(d=>u.push(d)),await ae(n,{data:i.data,tags:u},a?d=>a(d):void 0)}catch(u){throw new Error(u.message??"Error creating zone")}}}function Se(n){return async(i,a)=>{try{let u=Object.entries(i).map(([d,s])=>({key:d,value:s}));return await ee(n,{processId:a,action:"Zone-Update",data:u})}catch(u){throw new Error(u)}}}function vt(n){return async(i,a)=>{try{return await ee(n,{processId:a,action:"Zone-Append",tags:[{name:"Path",value:i.path}],data:i.data})}catch(u){throw new Error(u)}}}function De(n){return async i=>{try{let a=await Ie(n,{processId:i,path:"zone",fallbackAction:"Info"});return re(a)}catch(a){throw new Error(a.message??"Error getting zone")}}}function bt(n){return async(i,a)=>{if(!J(a))throw new Error("Invalid zone address");let y=[];for(let d of i){if(!J(d.granteeId))throw new Error("Invalid granteeId address");if(d.type!=="wallet"&&d.type!=="process")throw new Error("Invalid role type");y.push({Id:d.granteeId,Roles:d.roles,Type:d.type,SendInvite:d.sendInvite})}try{return await ee(n,{processId:a,action:"Role-Set",tags:[],data:y})}catch(d){throw new Error(d)}}}function Pt(n){return async(i,a)=>{if(!(J(a)&&J(i.zoneToJoinId)))throw new Error("Invalid zone address");let y=[{name:"ZoneId",value:i.zoneToJoinId}];i.path&&y.push({name:"Path",value:i.path});try{return await ee(n,{processId:a,action:"Zone-Join",tags:y})}catch(d){throw new Error(d)}}}function Rt(n){let i=Ce(n);return async(a,u)=>{let y=null,d=[{name:I.keys.dataProtocol,value:I.values.zone},{name:I.keys.zoneType,value:I.values.user}],s=async f=>{let g=f.toLowerCase();if(a[g])try{let E=await se(n,a[g]);d.push(O(f,E))}catch(E){u?u(`Failed to resolve ${f}: ${E.message}`):console.error(E)}};a.username&&d.push(O("Username",a.username)),a.displayName&&d.push(O("DisplayName",a.displayName)),a.description&&d.push(O("Description",a.description)),await Promise.all([s("Thumbnail"),s("Banner")]);try{y=await i({tags:d},u)}catch(f){throw new Error(f.message??"Error creating profile")}return y}}function Ut(n){let i=Se(n);return async(a,u,y)=>{if(u){let d={Username:a.username,DisplayName:a.displayName,Description:a.description};if(a.thumbnail)try{d.Thumbnail=await se(n,a.thumbnail)}catch(s){y&&y(`Failed to resolve thumbnail: ${s.message}`)}if(a.banner)try{d.Banner=await se(n,a.banner)}catch(s){y&&y(`Failed to resolve banner: ${s.message}`)}try{return await i(d,u)}catch(s){throw new Error(s.message??"Error creating profile")}}else throw new Error("No profile provided")}}function ke(n){let i=De(n);return async a=>{try{let u=await i(a);if(!u)throw new Error("Error fetching profile - Not found");return{id:a,owner:u.owner,assets:u.assets,roles:u.roles,invites:u.invites,version:u.version,...u.store}}catch(u){throw new Error(u.message??"Error fetching profile")}}}function Lt(n){let i=ke(n);return async a=>{try{let u=await q({gateway:z.goldsky,tags:[{name:I.keys.dataProtocol,values:[I.values.zone]},{name:I.keys.zoneType,values:[I.values.user]}],owners:[a]});return u?.data?.length>0?(u.data.sort((y,d)=>{let s=y.node.block?.timestamp??0;return(d.node.block?.timestamp??0)-s}),await i(u.data[0].node.id)):{id:null}}catch(u){throw new Error(u.message??"Error fetching profile")}}}function Sr(n){return{createZone:Ce(n),updateZone:Se(n),addToZone:vt(n),getZone:De(n),setZoneRoles:bt(n),joinZone:Pt(n),createProfile:Rt(n),updateProfile:Ut(n),getProfileById:ke(n),getProfileByWalletAddress:Lt(n),createAtomicAsset:Be(n),getAtomicAsset:wt(n),getAtomicAssets:Tt,createComment:xt(n),getComment:Ct(n),getComments:St(n),createCollection:At(n),updateCollectionAssets:Et(n),getCollection:It(n),getCollections:Bt(n),resolveTransaction:gt(n),getGQLData:q,getAggregatedGQLData:ut,createProcess:ht(n),readProcess:yt(n),sendMessage:pt(n),waitForProcess:ft,mapFromProcessCase:re,mapToProcessCase:pe}}var to={init:Sr};export{Ar as Types,to as default};
27
+ }`;return n.queryKey&&(x=`${n.queryKey}: ${x}`),x}async function gr(n){try{return await(await fetch(`https://${n.gateway}/graphql`,{method:"POST",headers:{"Content-Type":"application/json"},body:n.query})).json()}catch(o){throw o}}var Tn=F.goldsky;async function dt(n,o){let a=[{name:"Authority",value:N.mu}];o.tags&&o.tags.length>0&&o.tags.forEach(u=>a.push(u));try{let u=await n.ao.spawn({module:o.module,scheduler:o.scheduler,signer:n.signer,tags:a,data:o.data});return re(`Process ID: ${u}`),u}catch(u){throw console.log(u),new Error(u.message??"Error spawning process")}}function ft(n){return async o=>await X(n,o)}async function X(n,o){try{let a=[{name:"Action",value:o.action}];o.tags&&a.push(...o.tags);let u=o.useRawData?o.data:JSON.stringify(o.data);return await n.ao.message({process:o.processId,signer:n.signer,tags:a,data:u})}catch(a){throw new Error(a)}}async function Be(n,o){let a=o.node??at.defaultRouter,u="now";try{console.log("Getting state from HyperBEAM...");let p=`${a}/${o.processId}~process@1.0/${u}/${o.path}`;console.log(`URL: ${p}`);let d=await fetch(p);return console.log("Returning state from HyperBEAM."),await d.json()}catch(p){if(o.fallbackAction){console.error(p.message??"Error reading process from HyperBEAM"),console.log("State not found, dryrunning...");let d=await ge(n,{processId:o.processId,action:o.fallbackAction});return console.log("Returning state from dryrun."),d}else throw new Error(p.message??"Error reading process from HyperBEAM")}}function ht(n){return async o=>await ge(n,o)}async function ge(n,o){try{let a=[{name:"Action",value:o.action}];o.tags&&a.push(...o.tags);let u;if(typeof o.data=="object")u=JSON.stringify(o.data||{});else if(typeof o.data=="string"){try{JSON.parse(o.data)}catch(d){throw console.error(d),new Error("Invalid JSON data")}u=o.data}let p=await n.ao.dryrun({process:o.processId,tags:a,data:u});if(p.Messages&&p.Messages.length){if(p.Messages[0].Data)return JSON.parse(p.Messages[0].Data);if(p.Messages[0].Tags)return p.Messages[0].Tags.reduce((d,s)=>(d[s.name]=s.value,d),{})}}catch(a){throw new Error(a.message??"Error dryrunning process")}}async function mr(n,o){try{let{Messages:a}=await n.ao.result({message:o.messageId,process:o.processId});if(a&&a.length){let u={};return a.forEach(p=>{let d=Ie(p.Tags,"Action")||o.action,s=null,h=p.Data;if(h)try{s=JSON.parse(h)}catch{s=h}let g=Ie(p.Tags,"Status"),E=Ie(p.Tags,"Message");u[d]={id:o.messageId,status:g,message:E,data:s}}),u}else return null}catch(a){console.error(a)}}async function me(n,o){let a=null;if(o.evalSrc?a=o.evalSrc:o.evalTxId&&(a=await wr(o.evalTxId)),a)try{let u=await X(n,{processId:o.processId,action:"Eval",data:a,tags:o.evalTags||null,useRawData:!0});return re(`Eval: ${u}`),await mr(n,{processId:o.processId,messageId:u,action:"Eval"})}catch(u){throw new Error(u.message??"Error sending process eval")}return null}function gt(n){return async(o,a)=>{try{let u={module:o.module||N.module,scheduler:o.scheduler||N.scheduler};o.data&&(u.data=o.data),o.tags&&(u.tags=o.tags),a&&a("Spawning process...");let p=await dt(n,u);if(o.evalTxId||o.evalSrc){a&&a("Process retrieved!"),a&&a("Sending eval...");try{await me(n,{processId:p,evalTxId:o.evalTxId||null,evalSrc:o.evalSrc||null,evalTags:o.evalTags})&&a&&a("Eval complete")}catch(d){throw new Error(d.message??"Error creating process")}}return p}catch(u){throw new Error(u.message??"Error creating process")}}}async function ae(n,o,a){try{let u={module:o.module||N.module,scheduler:o.scheduler||N.scheduler};o.data&&(u.data=o.data),o.tags&&(u.tags=o.tags),a&&a("Spawning process...");let p=await dt(n,u);if(o.evalTxId||o.evalSrc){a&&a("Process retrieved!"),a&&a("Sending eval...");try{await me(n,{processId:p,evalTxId:o.evalTxId||null,evalSrc:o.evalSrc||null,evalTags:o.evalTags})&&a&&a("Eval complete")}catch(d){throw new Error(d.message??"Error creating process")}}return p}catch(u){throw new Error(u.message??"Error creating process")}}async function wr(n){try{return await(await fetch(ye(n))).text()}catch(o){throw new Error(o)}}var bn=A(T(),1);function mt(n){return async o=>{if(V(o))return o;if(!n.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await wt(n,{data:o})}catch(a){throw new Error(a.message??"Error resolving transaction")}}}async function se(n,o){if(V(o))return o;if(!n.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await wt(n,{data:o})}catch(a){throw new Error(a.message??"Error resolving transaction")}}async function wt(n,o){let a=null,u=null,p=null;if(typeof o.data=="string"&&(a=R.from(lt(o.data),"base64"),u=ut(o.data),p=pt(a)),o.data instanceof File&&(a=new Uint8Array(await o.data.arrayBuffer()),u=o.data.type,p=o.data.size),a&&u&&p)if(p<Number(ct.dispatchUploadSize))try{let d=await n.arweave.createTransaction({data:a},"use_wallet");return d.addTag(I.keys.contentType,u),o.tags&&o.tags.length>0&&o.tags.forEach(h=>d.addTag(h.name,h.value)),(await global.window.arweaveWallet.dispatch(d)).id}catch(d){throw new Error(d.message??"Error dispatching transaction")}else throw new Error("Paid uploads are not yet supported");else throw new Error("Error preparing transaction data")}var Fn=A(T(),1);var Ar={},On=A(T(),1);var qo=A(T(),1);var oo=A(T(),1);function xe(n){return async(o,a)=>{let u=Br(o);if(u)throw new Error(u);let p=st[o.contentType]?.serialize(o.data)??o.data,d=Ir(o);try{return await ae(n,{tags:d,data:p},a?h=>a(h):void 0)}catch(s){throw new Error(s.message??"Error creating asset")}}}async function Ge(n,o,a){try{let u=te(await Be(n,{processId:o,path:"asset",fallbackAction:"Info"}));if(a?.useGateway){let p=await q({gateway:F.goldsky,ids:[o],tags:null,owners:null,cursor:null});return{...p?.data?.[0]?Se(p.data[0]):{},...u}}return{id:o,...u}}catch(u){throw new Error(u.message||"Error fetching atomic asset")}}function Tt(n){return async(o,a)=>await Ge(n,o,a)}async function At(n){try{let o=await q({gateway:F.arweave,ids:n??null,tags:null,owners:null,cursor:null});return o&&o.data.length?o.data.map(a=>Se(a)):null}catch(o){throw new Error(o)}}function Se(n){let o={id:n.node.id,owner:n.node.owner.address};for(let a of n.node.tags){let u=a.name,d=(u.startsWith(`${I.keys.bootloader}-`)?u.slice(`${I.keys.bootloader}-`.length):u).split("-").map((h,g)=>g===0?h.toLowerCase():h.charAt(0).toUpperCase()+h.slice(1).toLowerCase()).join(""),s;try{s=JSON.parse(a.value)}catch{s=a.value.toString()}o[d]=s}return o}function Ir(n){let o=[{name:I.keys.onBoot,value:n.src??N.src.asset},{name:I.keys.creator,value:n.creator},{name:I.keys.assetType,value:n.assetType},{name:I.keys.contentType,value:n.contentType},{name:I.keys.implements,value:"ANS-110"},{name:I.keys.dateCreated,value:new Date().getTime().toString()},O("Name",n.name),O("Description",n.description),O("Topics",JSON.stringify(n.topics)),O("Ticker","ATOMIC"),O("Denomination",n.denomination?.toString()??"1"),O("TotalSupply",n.supply?.toString()??"1"),O("Transferable",n.transferable?.toString()??"true"),O("Creator",n.creator)];if(n.metadata)for(let a in n.metadata)o.push(O(pe(a),n.metadata[a].toString()));if(n.users)for(let a of n.users)o.push({name:"Auth-User",value:a});return n.tags&&n.tags.forEach(a=>o.push(a)),o}function Br(n){if(typeof n!="object"||n===null)return"The provided arguments are invalid or empty.";let o=["name","description","topics","creator","data","contentType","assetType"];for(let a of o)if(!(a in n))return`Missing field '${a}'`;return typeof n.name!="string"||n.name.trim()===""?"Name is required":typeof n.description!="string"?"The description must be a valid string":!Array.isArray(n.topics)||n.topics.length===0?"Topics are required":typeof n.creator!="string"||n.creator.trim()===""?"Creator is required":n.data===void 0||n.data===null?"Data field is required":typeof n.contentType!="string"||n.contentType.trim()===""?"Content type must be a non-empty string":typeof n.assetType!="string"||n.assetType.trim()===""?"Type must be a non-empty string":"supply"in n&&(typeof n.supply!="number"||n.supply<=0)?"Supply must be a positive number":"denomination"in n&&(typeof n.denomination!="number"||n.denomination<=0)?"Denomination must be a positive number":"transferable"in n&&typeof n.transferable!="boolean"?"Transferable must be a boolean value":"metadata"in n&&typeof n.metadata!="object"?"Metadata must be an object":"tags"in n&&(!Array.isArray(n.tags)||n.tags.some(a=>typeof a!="object"))?"Tags must be an array of objects":"src"in n&&typeof n.src!="string"?"Source must be a valid string":null}var ho=A(T(),1);var xr="eXCtpVbcd_jZ0dmU2PZ8focaKxBGECBQ8wMib7sIVPo",we="lJovHqM9hwNjHV5JoY9NGWtt0WD-5D4gOqNL2VWW5jk";function Et(n){return async(o,a)=>{if(!n.signer)throw new Error("No signer provided");let u=new Date().getTime().toString(),p=[{name:I.keys.contentType,value:"application/json"},{name:I.keys.creator,value:o.creator},{name:I.keys.ans110.title,value:he(o.title)},{name:I.keys.ans110.description,value:he(o.description)},{name:I.keys.dateCreated,value:u},{name:I.keys.name,value:he(o.title)},{name:"Action",value:"Add-Collection"}],d=null,s=null;try{d=o.banner?await se(n,o.thumbnail):we,s=o.banner?await se(n,o.banner):xr,o.thumbnail&&p.push({name:I.keys.thumbnail,value:d}),o.banner&&p.push({name:I.keys.banner,value:s})}catch(E){console.error(E)}let h=await fetch(ye(N.src.collection));if(!h.ok)throw new Error("Unable to fetch process src");let g=await h.text();g=g.replace(/'<NAME>'/g,$e(o.title)),g=g.replace(/'<DESCRIPTION>'/g,$e(o.description)),g=g.replace(/<CREATOR>/g,o.creator),g=g.replace(/<THUMBNAIL>/g,d||we),g=g.replace(/<BANNER>/g,s||we),g=g.replace(/<DATECREATED>/g,u),g=g.replace(/<LASTUPDATE>/g,u);try{let E=await ae(n,{tags:p},a?B=>a(B):void 0);if(re("Sending eval message to collection..."),a&&a("Sending eval message to collection..."),await n.ao.message({process:E,signer:n.signer,tags:[{name:"Action",value:"Eval"}],data:g}),!o.skipRegistry){re("Sending collection to registry..."),a&&a("Sending collection to registry...");let B=[{name:"Action",value:"Add-Collection"},{name:"CollectionId",value:E},{name:"Name",value:he(o.title)},{name:"Creator",value:o.creator},{name:"DateCreated",value:u}];s&&B.push({name:"Banner",value:s}),d&&B.push({name:"Thumbnail",value:d}),await n.ao.message({process:N.collectionRegistry,signer:n.signer,tags:B})}if(!o.skipActivity){re("Creating collection activity process..."),a&&a("Creating collection activity process...");let B=[{name:"CollectionId",value:E},{name:"DateCreated",value:u},{name:"UCM-Process",value:"Collection-Activity"},{name:"On-Boot",value:N.src.collectionActivity}],v=await ae(n,{tags:B},a?M=>a(M):void 0);re("Adding activity to collection process..."),a&&a("Adding activity to collection process..."),await n.ao.message({process:E,signer:n.signer,tags:[{name:"Action",value:"Eval"}],data:`ActivityProcess = '${v}'`})}return E}catch(E){throw new Error(E.message??"Error creating collection")}}}function It(n){return async o=>await X(n,{processId:o.creator,action:"Run-Action",tags:[{name:"ForwardTo",value:o.collectionId},{name:"ForwardAction",value:"Update-Assets"}],data:{Target:o.collectionId,Action:"Update-Assets",Input:JSON.stringify({AssetIds:o.assetIds,UpdateType:o.updateType})}})}function Bt(n){return async o=>{let a=await ge(n,{processId:o,action:"Info"});return{...{id:o,title:a.Name,description:a.Description,creator:a.Creator,dateCreated:a.DateCreated,thumbnail:a.Thumbnail??we,banner:a.Banner??we},assetIds:a.Assets}}}function xt(n){return async o=>{let a=o.creator?"Get-Collections-By-User":"Get-Collections",u=await ge(n,{processId:N.collectionRegistry,action:a,tags:o.creator?[{name:"Creator",value:o.creator}]:null});return u&&u.Collections&&u.Collections.length?u.Collections.map(d=>({id:d.Id,title:d.Name.replace(/\[|\]/g,""),description:d.Description,creator:d.Creator,dateCreated:d.DateCreated,banner:d.Banner,thumbnail:d.Thumbnail})):null}}var xo=A(T(),1);function St(n){let o=xe(n);return async(a,u)=>{let p=a.tags?a.tags:[];p.push({name:"Data-Source",value:a.parentId}),p.push({name:"Root-Source",value:a.rootId??a.parentId});let d={name:`Comment on ${a.parentId}`,description:`Comment on ${a.parentId}`,topics:["comment"],creator:a.creator,data:a.content,contentType:"text/plain",assetType:"comment",tags:p};return o(d,u)}}function Ct(n){return async o=>{try{let a=await Ge(n,o,{useGateway:!0}),u=a?.dataSource,p=a?.rootSource;if(!u||!p)throw new Error("dataSource and rootSource must be present on a comment");return{content:await Dt(o),parentId:u,rootId:p}}catch(a){throw new Error(a.message??"Error getting comment")}}}function vt(n){return async o=>{if(!o.parentId&&!o.rootId)throw new Error("Must provide either parentId or rootId");let a=[];o.parentId&&a.push({name:"Data-Source",values:[o.parentId??""]}),o.rootId&&a.push({name:"Root-Source",values:[o.rootId??""]});let u=await q({gateway:F.goldsky,ids:null,tags:a,owners:null,cursor:null}),p=[];u&&u.data.length&&(p=u.data.map(s=>Se(s)));let d=[];for(let s of p){let h=s?.dataSource,g=s?.rootSource;if(!h||!g)throw new Error("dataSource and rootSource must be present on a comment");d.push({id:s.id,content:await Dt(s.id),parentId:h,rootId:g})}return d}}async function Dt(n){try{return await(await fetch(ye(n))).text()}catch(o){throw new Error(o.message??"Error getting comment data")}}var Qo=A(T(),1);var Lo=A(T(),1);function Ce(n){return async(o,a)=>{try{let u=[{name:I.keys.onBoot,value:N.src.zone.id}];return o.tags&&o.tags.length&&o.tags.forEach(d=>u.push(d)),await ae(n,{data:o.data,tags:u},a?d=>a(d):void 0)}catch(u){throw new Error(u.message??"Error creating zone")}}}function ve(n){return async(o,a)=>{try{let u=Object.entries(o).map(([d,s])=>({key:d,value:s}));return await X(n,{processId:a,action:"Zone-Update",data:u})}catch(u){throw new Error(u)}}}function bt(n){return async(o,a)=>{try{return await X(n,{processId:a,action:"Zone-Append",tags:[{name:"Path",value:o.path}],data:o.data})}catch(u){throw new Error(u)}}}function Pt(n){return async(o,a)=>{if(!V(a))throw new Error("Invalid zone address");let p=[];for(let d of o){if(!V(d.granteeId))throw new Error("Invalid granteeId address");if(d.type!=="wallet"&&d.type!=="process")throw new Error("Invalid role type");p.push({Id:d.granteeId,Roles:d.roles,Type:d.type,SendInvite:d.sendInvite})}try{return await X(n,{processId:a,action:"Role-Set",tags:[],data:p})}catch(d){throw new Error(d)}}}function Rt(n){return async(o,a)=>{if(!(V(a)&&V(o.zoneToJoinId)))throw new Error("Invalid zone address");let p=[{name:"ZoneId",value:o.zoneToJoinId}];o.path&&p.push({name:"Path",value:o.path});try{return await X(n,{processId:a,action:"Zone-Join",tags:p})}catch(d){throw new Error(d)}}}function De(n){return async o=>{try{return await me(n,{processId:o.zoneId,evalTxId:N.src.zone.id}),await me(n,{processId:o.zoneId,evalSrc:`Zone.Version = '${N.src.zone.version}'; SyncState()`})}catch(a){throw new Error(a)}}}function be(n){return async o=>{try{let a=await Be(n,{processId:o,path:"zone",fallbackAction:"Info"});return te(a)}catch(a){throw new Error(a.message??"Error getting zone")}}}function Ut(n){let o=Ce(n);return async(a,u)=>{let p=null,d=[{name:I.keys.dataProtocol,value:I.values.zone},{name:I.keys.zoneType,value:I.values.user}],s=async h=>{let g=h.toLowerCase();if(a[g])try{let E=await se(n,a[g]);d.push(O(h,E))}catch(E){u?u(`Failed to resolve ${h}: ${E.message}`):console.error(E)}};a.username&&d.push(O("Username",a.username)),a.displayName&&d.push(O("DisplayName",a.displayName)),a.description&&d.push(O("Description",a.description)),await Promise.all([s("Thumbnail"),s("Banner")]);try{p=await o({tags:d},u)}catch(h){throw new Error(h.message??"Error creating profile")}return p}}function Lt(n){let o=ve(n);return async(a,u,p)=>{if(u){let d={Username:a.username,DisplayName:a.displayName,Description:a.description};if(a.thumbnail)try{d.Thumbnail=await se(n,a.thumbnail)}catch(s){p&&p(`Failed to resolve thumbnail: ${s.message}`)}if(a.banner)try{d.Banner=await se(n,a.banner)}catch(s){p&&p(`Failed to resolve banner: ${s.message}`)}try{return await o(d,u)}catch(s){throw new Error(s.message??"Error creating profile")}}else throw new Error("No profile provided")}}function Nt(n){let o=De(n);return async a=>{try{return await o({zoneId:a.profileId})}catch(u){throw new Error(u)}}}function We(n){let o=be(n);return async a=>{try{let u=await o(a);if(!u)throw new Error("Error fetching profile - Not found");return{id:a,owner:u.owner,assets:u.assets,roles:u.roles,invites:u.invites,version:u.version,...u.store}}catch(u){throw new Error(u.message??"Error fetching profile")}}}function $t(n){let o=We(n);return async a=>{try{let u=await q({gateway:F.goldsky,tags:[{name:I.keys.dataProtocol,values:[I.values.zone]},{name:I.keys.zoneType,values:[I.values.user]}],owners:[a]});return u?.data?.length>0?(u.data.sort((p,d)=>{let s=p.node.block?.timestamp??0;return(d.node.block?.timestamp??0)-s}),await o(u.data[0].node.id)):{id:null}}catch(u){throw new Error(u.message??"Error fetching profile")}}}var ri=N.src.zone.version;function Cr(n){return{createZone:Ce(n),updateZone:ve(n),addToZone:bt(n),getZone:be(n),setZoneRoles:Pt(n),joinZone:Rt(n),updateZoneVersion:De(n),createProfile:Ut(n),updateProfile:Lt(n),updateProfileVersion:Nt(n),getProfileById:We(n),getProfileByWalletAddress:$t(n),createAtomicAsset:xe(n),getAtomicAsset:Tt(n),getAtomicAssets:At,createComment:St(n),getComment:Ct(n),getComments:vt(n),createCollection:Et(n),updateCollectionAssets:It(n),getCollection:Bt(n),getCollections:xt(n),resolveTransaction:mt(n),getGQLData:q,getAggregatedGQLData:yt,createProcess:gt(n),readProcess:ht(n),sendMessage:ft(n),mapFromProcessCase:te,mapToProcessCase:pe}}var ni={init:Cr};export{ri as CurrentZoneVersion,Ar as Types,ni as default};
28
28
  /*! Bundled license information:
29
29
 
30
30
  @jspm/core/nodelibs/browser/chunk-DtuTasat.js: