@permaweb/libs 0.0.37 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +3 -3
- package/dist/index.esm.js +3 -3
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +5 -5
- package/dist/index.js.map +3 -3
- package/dist/types/common/ao.d.ts +3 -7
- package/dist/types/helpers/config.d.ts +0 -1
- package/dist/types/helpers/types.d.ts +6 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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=`
|
|
1
|
+
var tr=Object.create;var Ye=Object.defineProperty;var rr=Object.getOwnPropertyDescriptor;var nr=Object.getOwnPropertyNames;var or=Object.getPrototypeOf,ir=Object.prototype.hasOwnProperty;var ar=(n,o)=>()=>(o||n((o={exports:{}}).exports,o),o.exports);var sr=(n,o,a,u)=>{if(o&&typeof o=="object"||typeof o=="function")for(let p of nr(o))!ir.call(n,p)&&p!==a&&Ye(n,p,{get:()=>o[p],enumerable:!(u=rr(o,p))||u.enumerable});return n};var A=(n,o,a)=>(a=n!=null?tr(or(n)):{},sr(o||!n||!n.__esModule?Ye(a,"default",{value:n,enumerable:!0}):a,n));var T=ar((Pr,tt)=>{var b=tt.exports={},j,J;function Ue(){throw new Error("setTimeout has not been defined")}function Le(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?j=setTimeout:j=Ue}catch{j=Ue}try{typeof clearTimeout=="function"?J=clearTimeout:J=Le}catch{J=Le}})();function Ke(n){if(j===setTimeout)return setTimeout(n,0);if((j===Ue||!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 cr(n){if(J===clearTimeout)return clearTimeout(n);if((J===Le||!J)&&clearTimeout)return J=clearTimeout,clearTimeout(n);try{return J(n)}catch{try{return J.call(null,n)}catch{return J.call(this,n)}}}var K=[],pe=!1,ne,Te=-1;function ur(){!pe||!ne||(pe=!1,ne.length?K=ne.concat(K):Te=-1,K.length&&Xe())}function Xe(){if(!pe){var n=Ke(ur);pe=!0;for(var o=K.length;o;){for(ne=K,K=[];++Te<o;)ne&&ne[Te].run();Te=-1,o=K.length}ne=null,pe=!1,cr(n)}}b.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];K.push(new et(n,o)),K.length===1&&!pe&&Ke(Xe)};function et(n,o){this.fun=n,this.array=o}et.prototype.run=function(){this.fun.apply(null,this.array)};b.title="browser";b.browser=!0;b.env={};b.argv=[];b.version="";b.versions={};function X(){}b.on=X;b.addListener=X;b.once=X;b.off=X;b.removeListener=X;b.removeAllListeners=X;b.emit=X;b.prependListener=X;b.prependOnceListener=X;b.listeners=function(n){return[]};b.binding=function(n){throw new Error("process.binding is not supported")};b.cwd=function(){return"/"};b.chdir=function(n){throw new Error("process.chdir is not supported")};b.umask=function(){return 0}});var ai=A(T(),1);var Or=A(T());var Ur=A(T(),1);var he={},rt=!1;function lr(){if(rt)return he;rt=!0,he.byteLength=h,he.toByteArray=E,he.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,_)),Q=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[Q++]=m>>16&255,U[Q++]=m>>8&255,U[Q++]=m&255;return _===2&&(m=o[f.charCodeAt(W)]<<2|o[f.charCodeAt(W+1)]>>4,U[Q++]=m&255),_===1&&(m=o[f.charCodeAt(W)]<<10|o[f.charCodeAt(W+1)]<<4|o[f.charCodeAt(W+2)]>>2,U[Q++]=m>>8&255,U[Q++]=m&255),U}function I(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(I(L));return _.join("")}function M(f){for(var m,x=f.length,L=x%3,_=[],U=16383,Q=0,Z=x-L;Q<Z;Q+=U)_.push(v(f,Q,Q+U>Z?Z:Q+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 he}var Ae={},nt=!1;function pr(){if(nt)return Ae;nt=!0;return Ae.read=function(n,o,a,u,p){var d,s,h=p*8-u-1,g=(1<<h)-1,E=g>>1,I=-7,v=a?p-1:0,M=a?-1:1,f=n[o+v];for(v+=M,d=f&(1<<-I)-1,f>>=-I,I+=h;I>0;d=d*256+n[o+v],v+=M,I-=8);for(s=d&(1<<-I)-1,d>>=-I,I+=u;I>0;s=s*256+n[o+v],v+=M,I-=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)},Ae.write=function(n,o,a,u,p,d){var s,h,g,E=d*8-p-1,I=(1<<E)-1,v=I>>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=I):(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>=I?(h=0,s=I):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},Ae}var oe={},ot=!1;function it(){if(ot)return oe;ot=!0;let n=lr(),o=pr(),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 I(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 I(r){return g(r),d(r<0?0:L(r)|0)}s.allocUnsafe=function(r){return I(r)},s.allocUnsafeSlow=function(r){return I(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"||Re(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 be(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Je(r).length;default:if(c)return i?-1:be(r).length;e=(""+e).toLowerCase(),c=!0}}s.byteLength=U;function Q(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 Vt(this,e,t);case"utf8":case"utf-8":return _e(this,e,t);case"ascii":return Ft(this,e,t);case"latin1":case"binary":return Zt(this,e,t);case"base64":return Qt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qt(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):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=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),P=e.slice(t,i);for(let S=0;S<D;++S)if(C[S]!==P[S]){y=C[S],w=P[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,Re(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(P,S){return l===1?P[S]:P.readUInt16BE(S*l)}let C;if(c){let P=-1;for(C=t;C<y;C++)if(D(r,C)===D(e,P===-1?0:C-P)){if(P===-1&&(P=C),C-P+1===w)return P*l}else P!==-1&&(C-=C-P),P=-1}else for(t+w>y&&(t=y-w),C=t;C>=0;C--){let P=!0;for(let S=0;S<w;S++)if(D(r,C+S)!==D(e,S)){P=!1;break}if(P)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 kt(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(Re(w))return y;r[t+y]=w}return y}function Gt(r,e,t,i){return we(be(e,r.length-t),r,t,i)}function Wt(r,e,t,i){return we(Yt(e),r,t,i)}function Ot(r,e,t,i){return we(Je(e),r,t,i)}function _t(r,e,t,i){return we(Kt(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 kt(this,e,t,i);case"utf8":case"utf-8":return Gt(this,e,t,i);case"ascii":case"latin1":case"binary":return Wt(this,e,t,i);case"base64":return Ot(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _t(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 Qt(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,P,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],P=r[c+3],(D&192)===128&&(C&192)===128&&(P&192)===128&&(S=(l&15)<<18|(D&63)<<12|(C&63)<<6|P&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 Qe=4096;function zt(r){let e=r.length;if(e<=Qe)return String.fromCharCode.apply(String,r);let t="",i=0;for(;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=Qe));return t}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]&127);return i}function Zt(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 Vt(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+=Xt[r[l]];return c}function qt(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=te(function(e){e=e>>>0,le(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&fe(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=te(function(e){e=e>>>0,le(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&fe(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=te(function(e){e=e>>>0,le(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&fe(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=te(function(e){e=e>>>0,le(e,"offset");let t=this[e],i=this[e+7];(t===void 0||i===void 0)&&fe(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 z(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;z(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;z(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||z(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||z(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||z(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||z(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||z(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 ze(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=te(function(e,t=0){return ze(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=te(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);z(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);z(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||z(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||z(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||z(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||z(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||z(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 ze(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=te(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 ue={};function Pe(r,e,t){ue[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 Ht(r,e,t){le(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&fe(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 ue.ERR_OUT_OF_RANGE("value",w,r)}Ht(i,c,l)}function le(r,e){if(typeof r!="number")throw new ue.ERR_INVALID_ARG_TYPE(e,"number",r)}function fe(r,e,t){throw Math.floor(r)!==r?(le(r,t),new ue.ERR_OUT_OF_RANGE("offset","an integer",r)):e<0?new ue.ERR_BUFFER_OUT_OF_BOUNDS:new ue.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,r)}let jt=/[^+/0-9A-Za-z-_]/g;function Jt(r){if(r=r.split("=")[0],r=r.trim().replace(jt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function be(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 Kt(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 Je(r){return n.toByteArray(Jt(r))}function we(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 Re(r){return r!==r}let Xt=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 te(r){return typeof BigInt>"u"?er:r}function er(){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,kr=ie.INSPECT_MAX_BYTES,Gr=ie.kMaxLength;var Nn=A(T(),1);var In=A(T(),1);var qr=A(T(),1);var N={module:"URgYpPQzvxxfYQtjrIQ116bl3YBfcImo3JEnNo8Hlrk",scheduler:"_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA",mu:"fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY",src:{asset:"dvlU-5HfAPWcukvnRHwSzMSEsoCqkZAEQsykMQgQ-wE",collection:"ssAijCOysZ33xGj1MwpZXMcMMN1eKfJrfeFeDe32-dg",collectionActivity:"ZoObVeEjstNEgnQl33C0w1CRH_7mn7u4HZ2BsyfsRIQ",zone:{id:"fAmxq5HS8V3ijkgTWHRcXtXzU0RPzKK9fmeVi1UwIs0",version:"0.0.2"}},collectionRegistry:"zwKi27GuKS3GOlwL3EhNGH02SJDDAO5Uy43ZJwomhZ4"},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 B={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 an=A(T(),1);var Xr=A(T(),1);function V(n){return n?/^[a-z0-9_-]{43}$/i.test(n):!1}function Ee(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 Ne(n){let o;return o=n.replace(/\[|\]/g,""),`[[${o}]]`}function ge(n){let o;return o=n.replace(/\[|\]/g,""),o}var re=(...n)=>{console.log("[@permaweb/libs]",...n)};function yr(n){return n.replace(/^[a-z]/,o=>o.toUpperCase())}function ye(n){return Array.isArray(n)?n.map(ye):n&&typeof n=="object"?Object.entries(n).reduce((o,[a,u])=>{let p=yr(a);return o[p]=V(u)?u:ye(u),o},{}):n}function dr(n){return n.charAt(0).toLowerCase()+n.slice(1)}function Y(n){return Array.isArray(n)?n.map(Y):n&&typeof n=="object"?Object.entries(n).reduce((o,[a,u])=>{let p=V(a)||a.includes("-")?a:dr(a);return o[p]=V(u)?u:Y(u),o},{}):n}function O(n,o){let a=n.charAt(0).toUpperCase()+n.slice(1);return{name:`${B.keys.bootloader}-${a}`,value:o}}var fr="https://arweave.net";function de(n){return`${fr}/${n}`}var yn=A(T(),1);var $e={p1:"P1",end:"END"},Me={default:100};async function q(n){let o=n.paginator?n.paginator:Me.default,a=[],u=0,p=null;if(n.ids&&!n.ids.length)return{data:a,count:u,nextCursor:p,previousCursor:null};try{let d=gr(n),s=await mr({gateway:n.gateway??F.goldsky,query:hr(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=$e.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??Me.default))}`),o&&o(`Page ${a} fetched`);u.nextCursor&&u.nextCursor!==$e.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 hr(n){let o={query:`query { ${n} }`};return JSON.stringify(o)}function gr(n){let o=n.paginator?n.paginator:Me.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!==$e.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 I=`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
|
+
${I}
|
|
6
6
|
owners: ${s},
|
|
7
7
|
${f},
|
|
8
8
|
block: ${p},
|
|
@@ -24,7 +24,7 @@ var er=Object.create;var Je=Object.defineProperty;var tr=Object.getOwnPropertyDe
|
|
|
24
24
|
${M}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
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};
|
|
27
|
+
}`;return n.queryKey&&(x=`${n.queryKey}: ${x}`),x}async function mr(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 An=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 ee(n,o)}async function ee(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)}}function ht(n){return async o=>await ae(n,o)}async function ae(n,o){let u=`${o.node??at.defaultRouter}/${o.processId}~process@1.0/now/${o.path}`;console.log("Fetching state from HyperBEAM:",u);try{let p=await fetch(u);if(p.ok)return console.log("Returning state from HyperBEAM."),p.json();throw new Error(`Unexpected status ${p.status}`)}catch(p){if(console.error(p.message),o.fallbackAction){console.log("State not found, dryrunning...");let d=await Ie(n,{processId:o.processId,action:o.fallbackAction});return console.log("Returning state from dryrun."),d}throw p}}function gt(n){return async o=>await Ie(n,o)}async function Ie(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 wr(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=Ee(p.Tags,"Action")||o.action,s=null,h=p.Data;if(h)try{s=JSON.parse(h)}catch{s=h}let g=Ee(p.Tags,"Status"),E=Ee(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 Tr(o.evalTxId)),a)try{let u=await ee(n,{processId:o.processId,action:"Eval",data:a,tags:o.evalTags||null,useRawData:!0});return re(`Eval: ${u}`),await wr(n,{processId:o.processId,messageId:u,action:"Eval"})}catch(u){throw new Error(u.message??"Error sending process eval")}return null}function mt(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 se(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 Tr(n){try{return await(await fetch(de(n))).text()}catch(o){throw new Error(o)}}var bn=A(T(),1);function wt(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 Tt(n,{data:o})}catch(a){throw new Error(a.message??"Error resolving transaction")}}}async function ce(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 Tt(n,{data:o})}catch(a){throw new Error(a.message??"Error resolving transaction")}}async function Tt(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(B.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 Zn=A(T(),1);var Er={},_n=A(T(),1);var Ho=A(T(),1);var io=A(T(),1);function Be(n){return async(o,a)=>{let u=xr(o);if(u)throw new Error(u);let p=st[o.contentType]?.serialize(o.data)??o.data,d=Br(o);try{return await se(n,{tags:d,data:p},a?h=>a(h):void 0)}catch(s){throw new Error(s.message??"Error creating asset")}}}async function ke(n,o,a){try{let u=Y(await ae(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]?xe(p.data[0]):{},...u}}return{id:o,...u}}catch(u){throw new Error(u.message||"Error fetching atomic asset")}}function At(n){return async(o,a)=>await ke(n,o,a)}async function Et(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=>xe(a)):null}catch(o){throw new Error(o)}}function xe(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(`${B.keys.bootloader}-`)?u.slice(`${B.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 Br(n){let o=[{name:B.keys.onBoot,value:n.src??N.src.asset},{name:B.keys.creator,value:n.creator},{name:B.keys.assetType,value:n.assetType},{name:B.keys.contentType,value:n.contentType},{name:B.keys.implements,value:"ANS-110"},{name:B.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(ye(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 xr(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 go=A(T(),1);var Sr="eXCtpVbcd_jZ0dmU2PZ8focaKxBGECBQ8wMib7sIVPo",Ge="lJovHqM9hwNjHV5JoY9NGWtt0WD-5D4gOqNL2VWW5jk";function It(n){return async(o,a)=>{if(!n.signer)throw new Error("No signer provided");let u=new Date().getTime().toString(),p=[{name:B.keys.creator,value:o.creator},{name:B.keys.ans110.title,value:ge(o.title)},{name:B.keys.name,value:ge(o.title)},{name:B.keys.ans110.description,value:ge(o.description)}],d=null,s=null;try{d=o.banner?await ce(n,o.thumbnail):Ge,s=o.banner?await ce(n,o.banner):Sr,o.thumbnail&&p.push({name:B.keys.thumbnail,value:d}),o.banner&&p.push({name:B.keys.banner,value:s})}catch(E){console.error(E)}let h=await fetch(de(N.src.collection));if(!h.ok)throw new Error("Unable to fetch process src");let g=await h.text();g=g.replace(/'<NAME>'/g,Ne(o.title)),g=g.replace(/'<DESCRIPTION>'/g,Ne(o.description)),g=g.replace(/<CREATOR>/g,o.creator),g=g.replace(/<THUMBNAIL>/g,d||Ge),g=g.replace(/<BANNER>/g,s||Ge),g=g.replace(/<DATECREATED>/g,u),g=g.replace(/<LASTUPDATE>/g,u);try{let E=await se(n,{tags:p},a?I=>a(I):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 I=[{name:"Action",value:"Add-Collection"},{name:"CollectionId",value:E},{name:"Name",value:ge(o.title)},{name:"Creator",value:o.creator},{name:"DateCreated",value:u}];s&&I.push({name:"Banner",value:s}),d&&I.push({name:"Thumbnail",value:d}),await n.ao.message({process:N.collectionRegistry,signer:n.signer,tags:I})}if(!o.skipActivity){re("Creating collection activity process..."),a&&a("Creating collection activity process...");let I=[{name:"CollectionId",value:E},{name:"DateCreated",value:u},{name:"UCM-Process",value:"Collection-Activity"},{name:"On-Boot",value:N.src.collectionActivity}],v=await se(n,{tags:I},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 Bt(n){return async o=>await ee(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:{AssetIds:o.assetIds,UpdateType:o.updateType}}})}function xt(n){return async o=>{let a=await ae(n,{processId:o,path:"collection",fallbackAction:"Info"});return a?Y(a):null}}function St(n){return async o=>{let a=o.creator?"Get-Collections-By-User":"Get-Collections",u=await Ie(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 So=A(T(),1);function Ct(n){let o=Be(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 vt(n){return async o=>{try{let a=await ke(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 Pt(o),parentId:u,rootId:p}}catch(a){throw new Error(a.message??"Error getting comment")}}}function Dt(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=>xe(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 Pt(s.id),parentId:h,rootId:g})}return d}}async function Pt(n){try{return await(await fetch(de(n))).text()}catch(o){throw new Error(o.message??"Error getting comment data")}}var Fo=A(T(),1);var No=A(T(),1);function Se(n){return async(o,a)=>{try{let u=[{name:B.keys.onBoot,value:N.src.zone.id}];return o.tags&&o.tags.length&&o.tags.forEach(d=>u.push(d)),await se(n,{data:o.data,tags:u},a?d=>a(d):void 0)}catch(u){throw new Error(u.message??"Error creating zone")}}}function Ce(n){return async(o,a)=>{try{let u=Object.entries(o).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 bt(n){return async(o,a)=>{try{return await ee(n,{processId:a,action:"Zone-Append",tags:[{name:"Path",value:o.path}],data:o.data})}catch(u){throw new Error(u)}}}function Rt(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 ee(n,{processId:a,action:"Role-Set",tags:[],data:p})}catch(d){throw new Error(d)}}}function Ut(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 ee(n,{processId:a,action:"Zone-Join",tags:p})}catch(d){throw new Error(d)}}}function ve(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 De(n){return async o=>{try{let a=await ae(n,{processId:o,path:"zone",fallbackAction:"Info"});return Y(a)}catch(a){throw new Error(a.message??"Error getting zone")}}}function Lt(n){let o=Se(n);return async(a,u)=>{let p=null,d=[{name:B.keys.dataProtocol,value:B.values.zone},{name:B.keys.zoneType,value:B.values.user}],s=async h=>{let g=h.toLowerCase();if(a[g])try{let E=await ce(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 Nt(n){let o=Ce(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 ce(n,a.thumbnail)}catch(s){p&&p(`Failed to resolve thumbnail: ${s.message}`)}if(a.banner)try{d.Banner=await ce(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 $t(n){let o=ve(n);return async a=>{try{return await o({zoneId:a.profileId})}catch(u){throw new Error(u)}}}function We(n){let o=De(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 Mt(n){let o=We(n);return async a=>{try{let u=await q({gateway:F.goldsky,tags:[{name:B.keys.dataProtocol,values:[B.values.zone]},{name:B.keys.zoneType,values:[B.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 ni=N.src.zone.version;function vr(n){return{createZone:Se(n),updateZone:Ce(n),addToZone:bt(n),getZone:De(n),setZoneRoles:Rt(n),joinZone:Ut(n),updateZoneVersion:ve(n),createProfile:Lt(n),updateProfile:Nt(n),updateProfileVersion:$t(n),getProfileById:We(n),getProfileByWalletAddress:Mt(n),createAtomicAsset:Be(n),getAtomicAsset:At(n),getAtomicAssets:Et,createComment:Ct(n),getComment:vt(n),getComments:Dt(n),createCollection:It(n),updateCollectionAssets:Bt(n),getCollection:xt(n),getCollections:St(n),resolveTransaction:wt(n),getGQLData:q,getAggregatedGQLData:yt,createProcess:mt(n),readProcess:gt(n),readState:ht(n),sendMessage:ft(n),mapFromProcessCase:Y,mapToProcessCase:ye}}var oi={init:vr};export{ni as CurrentZoneVersion,Er as Types,oi as default};
|
|
28
28
|
/*! Bundled license information:
|
|
29
29
|
|
|
30
30
|
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|