@permaweb/libs 0.0.21 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,15 +1,15 @@
1
- var kt=Object.create;var De=Object.defineProperty;var Ut=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,Nt=Object.prototype.hasOwnProperty;var ee=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Mt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Pt(e))!Nt.call(r,i)&&i!==t&&De(r,i,{get:()=>e[i],enumerable:!(n=Ut(e,i))||n.enumerable});return r};var d=(r,e,t)=>(t=r!=null?kt(Lt(r)):{},Mt(e||!r||!r.__esModule?De(t,"default",{value:r,enumerable:!0}):t,r));var h=ee((Gr,Re)=>{var m=Re.exports={},D,S;function ye(){throw new Error("setTimeout has not been defined")}function fe(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?D=setTimeout:D=ye}catch{D=ye}try{typeof clearTimeout=="function"?S=clearTimeout:S=fe}catch{S=fe}})();function Se(r){if(D===setTimeout)return setTimeout(r,0);if((D===ye||!D)&&setTimeout)return D=setTimeout,setTimeout(r,0);try{return D(r,0)}catch{try{return D.call(null,r,0)}catch{return D.call(this,r,0)}}}function $t(r){if(S===clearTimeout)return clearTimeout(r);if((S===fe||!S)&&clearTimeout)return S=clearTimeout,clearTimeout(r);try{return S(r)}catch{try{return S.call(null,r)}catch{return S.call(this,r)}}}var R=[],q=!1,M,te=-1;function Wt(){!q||!M||(q=!1,M.length?R=M.concat(R):te=-1,R.length&&ve())}function ve(){if(!q){var r=Se(Wt);q=!0;for(var e=R.length;e;){for(M=R,R=[];++te<e;)M&&M[te].run();te=-1,e=R.length}M=null,q=!1,$t(r)}}m.nextTick=function(r){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];R.push(new Fe(r,e)),R.length===1&&!q&&Se(ve)};function Fe(r,e){this.fun=r,this.array=e}Fe.prototype.run=function(){this.fun.apply(null,this.array)};m.title="browser";m.browser=!0;m.env={};m.argv=[];m.version="";m.versions={};function k(){}m.on=k;m.addListener=k;m.once=k;m.off=k;m.removeListener=k;m.removeAllListeners=k;m.emit=k;m.prependListener=k;m.prependOnceListener=k;m.listeners=function(r){return[]};m.binding=function(r){throw new Error("process.binding is not supported")};m.cwd=function(){return"/"};m.chdir=function(r){throw new Error("process.chdir is not supported")};m.umask=function(){return 0}});var Pe=ee(re=>{"use strict";var _r=d(h());re.byteLength=Ot;re.toByteArray=Qt;re.fromByteArray=zt;var v=[],E=[],Gt=typeof Uint8Array<"u"?Uint8Array:Array,de="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for($=0,ke=de.length;$<ke;++$)v[$]=de[$],E[de.charCodeAt($)]=$;var $,ke;E[45]=62;E[95]=63;function Ue(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function Ot(r){var e=Ue(r),t=e[0],n=e[1];return(t+n)*3/4-n}function _t(r,e,t){return(e+t)*3/4-t}function Qt(r){var e,t=Ue(r),n=t[0],i=t[1],o=new Gt(_t(r,n,i)),a=0,c=i>0?n-4:n,l;for(l=0;l<c;l+=4)e=E[r.charCodeAt(l)]<<18|E[r.charCodeAt(l+1)]<<12|E[r.charCodeAt(l+2)]<<6|E[r.charCodeAt(l+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=e&255;return i===2&&(e=E[r.charCodeAt(l)]<<2|E[r.charCodeAt(l+1)]>>4,o[a++]=e&255),i===1&&(e=E[r.charCodeAt(l)]<<10|E[r.charCodeAt(l+1)]<<4|E[r.charCodeAt(l+2)]>>2,o[a++]=e>>8&255,o[a++]=e&255),o}function qt(r){return v[r>>18&63]+v[r>>12&63]+v[r>>6&63]+v[r&63]}function Zt(r,e,t){for(var n,i=[],o=e;o<t;o+=3)n=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),i.push(qt(n));return i.join("")}function zt(r){for(var e,t=r.length,n=t%3,i=[],o=16383,a=0,c=t-n;a<c;a+=o)i.push(Zt(r,a,a+o>c?c:a+o));return n===1?(e=r[t-1],i.push(v[e>>2]+v[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(v[e>>10]+v[e>>4&63]+v[e<<2&63]+"=")),i.join("")}});var Le=ee(he=>{var qr=d(h());he.read=function(r,e,t,n,i){var o,a,c=i*8-n-1,l=(1<<c)-1,p=l>>1,f=-7,y=t?i-1:0,b=t?-1:1,C=r[e+y];for(y+=b,o=C&(1<<-f)-1,C>>=-f,f+=c;f>0;o=o*256+r[e+y],y+=b,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=a*256+r[e+y],y+=b,f-=8);if(o===0)o=1-p;else{if(o===l)return a?NaN:(C?-1:1)*(1/0);a=a+Math.pow(2,n),o=o-p}return(C?-1:1)*a*Math.pow(2,o-n)};he.write=function(r,e,t,n,i,o){var a,c,l,p=o*8-i-1,f=(1<<p)-1,y=f>>1,b=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,C=n?0:o-1,pe=n?1:-1,Rt=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+y>=1?e+=b/l:e+=b*Math.pow(2,1-y),e*l>=2&&(a++,l/=2),a+y>=f?(c=0,a=f):a+y>=1?(c=(e*l-1)*Math.pow(2,i),a=a+y):(c=e*Math.pow(2,y-1)*Math.pow(2,i),a=0));i>=8;r[t+C]=c&255,C+=pe,c/=256,i-=8);for(a=a<<i|c,p+=i;p>0;r[t+C]=a&255,C+=pe,a/=256,p-=8);r[t+C-pe]|=Rt*128}});var Ke=ee(j=>{"use strict";var Hr=d(h());var ge=Pe(),z=Le(),Ne=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;j.Buffer=s;j.SlowBuffer=Kt;j.INSPECT_MAX_BYTES=50;var ne=2147483647;j.kMaxLength=ne;s.TYPED_ARRAY_SUPPORT=Ht();!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 Ht(){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 U(r){if(r>ne)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 xe(r)}return Ge(r,e,t)}s.poolSize=8192;function Ge(r,e,t){if(typeof r=="string")return Vt(r,e);if(ArrayBuffer.isView(r))return Yt(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(F(r,ArrayBuffer)||r&&F(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(F(r,SharedArrayBuffer)||r&&F(r.buffer,SharedArrayBuffer)))return Te(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return s.from(n,e,t);let i=Jt(r);if(i)return i;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 Ge(r,e,t)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function Oe(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 jt(r,e,t){return Oe(r),r<=0?U(r):e!==void 0?typeof t=="string"?U(r).fill(e,t):U(r).fill(e):U(r)}s.alloc=function(r,e,t){return jt(r,e,t)};function xe(r){return Oe(r),U(r<0?0:Ae(r)|0)}s.allocUnsafe=function(r){return xe(r)};s.allocUnsafeSlow=function(r){return xe(r)};function Vt(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=_e(r,e)|0,n=U(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function me(r){let e=r.length<0?0:Ae(r.length)|0,t=U(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function Yt(r){if(F(r,Uint8Array)){let e=new Uint8Array(r);return Te(e.buffer,e.byteOffset,e.byteLength)}return me(r)}function Te(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 n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,s.prototype),n}function Jt(r){if(s.isBuffer(r)){let e=Ae(r.length)|0,t=U(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Ie(r.length)?U(0):me(r);if(r.type==="Buffer"&&Array.isArray(r.data))return me(r.data)}function Ae(r){if(r>=ne)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ne.toString(16)+" bytes");return r|0}function Kt(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(F(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),F(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 n=e.length,i=t.length;for(let o=0,a=Math.min(n,i);o<a;++o)if(e[o]!==t[o]){n=e[o],i=t[o];break}return n<i?-1:i<n?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 n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=s.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){let a=e[n];if(F(a,Uint8Array))o+a.length>i.length?(s.isBuffer(a)||(a=s.from(a)),a.copy(i,o)):Uint8Array.prototype.set.call(i,a,o);else if(s.isBuffer(a))a.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=a.length}return i};function _e(r,e){if(s.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||F(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,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return we(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(i)return n?-1:we(r).length;e=(""+e).toLowerCase(),i=!0}}s.byteLength=_e;function Xt(r,e,t){let n=!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 ur(this,e,t);case"utf8":case"utf-8":return qe(this,e,t);case"ascii":return sr(this,e,t);case"latin1":case"binary":return cr(this,e,t);case"base64":return or(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return lr(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function W(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}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)W(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)W(this,t,t+3),W(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)W(this,t,t+7),W(this,t+1,t+6),W(this,t+2,t+5),W(this,t+3,t+4);return this};s.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?qe(this,0,e):Xt.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=j.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};Ne&&(s.prototype[Ne]=s.prototype.inspect);s.prototype.compare=function(e,t,n,i,o){if(F(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),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),t<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&t>=n)return 0;if(i>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let a=o-i,c=n-t,l=Math.min(a,c),p=this.slice(i,o),f=e.slice(t,n);for(let y=0;y<l;++y)if(p[y]!==f[y]){a=p[y],c=f[y];break}return a<c?-1:c<a?1:0};function Qe(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Ie(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=s.from(e,n)),s.isBuffer(e))return e.length===0?-1:Me(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):Me(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function Me(r,e,t,n,i){let o=1,a=r.length,c=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;o=2,a/=2,c/=2,t/=2}function l(f,y){return o===1?f[y]:f.readUInt16BE(y*o)}let p;if(i){let f=-1;for(p=t;p<a;p++)if(l(r,p)===l(e,f===-1?0:p-f)){if(f===-1&&(f=p),p-f+1===c)return f*o}else f!==-1&&(p-=p-f),f=-1}else for(t+c>a&&(t=a-c),p=t;p>=0;p--){let f=!0;for(let y=0;y<c;y++)if(l(r,p+y)!==l(e,y)){f=!1;break}if(f)return p}return-1}s.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};s.prototype.indexOf=function(e,t,n){return Qe(this,e,t,n,!0)};s.prototype.lastIndexOf=function(e,t,n){return Qe(this,e,t,n,!1)};function er(r,e,t,n){t=Number(t)||0;let i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let a;for(a=0;a<n;++a){let c=parseInt(e.substr(a*2,2),16);if(Ie(c))return a;r[t+a]=c}return a}function tr(r,e,t,n){return ie(we(e,r.length-t),r,t,n)}function rr(r,e,t,n){return ie(dr(e),r,t,n)}function nr(r,e,t,n){return ie(Je(e),r,t,n)}function ir(r,e,t,n){return ie(hr(e,r.length-t),r,t,n)}s.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let a=!1;for(;;)switch(i){case"hex":return er(this,e,t,n);case"utf8":case"utf-8":return tr(this,e,t,n);case"ascii":case"latin1":case"binary":return rr(this,e,t,n);case"base64":return nr(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ir(this,e,t,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function or(r,e,t){return e===0&&t===r.length?ge.fromByteArray(r):ge.fromByteArray(r.slice(e,t))}function qe(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i<t;){let o=r[i],a=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=t){let l,p,f,y;switch(c){case 1:o<128&&(a=o);break;case 2:l=r[i+1],(l&192)===128&&(y=(o&31)<<6|l&63,y>127&&(a=y));break;case 3:l=r[i+1],p=r[i+2],(l&192)===128&&(p&192)===128&&(y=(o&15)<<12|(l&63)<<6|p&63,y>2047&&(y<55296||y>57343)&&(a=y));break;case 4:l=r[i+1],p=r[i+2],f=r[i+3],(l&192)===128&&(p&192)===128&&(f&192)===128&&(y=(o&15)<<18|(l&63)<<12|(p&63)<<6|f&63,y>65535&&y<1114112&&(a=y))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),i+=c}return ar(n)}var $e=4096;function ar(r){let e=r.length;if(e<=$e)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=$e));return t}function sr(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function cr(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function ur(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let i="";for(let o=e;o<t;++o)i+=gr[r[o]];return i}function lr(r,e,t){let n=r.slice(e,t),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}s.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,s.prototype),i};function T(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,n){e=e>>>0,t=t>>>0,n||T(e,t,this.length);let i=this[e],o=1,a=0;for(;++a<t&&(o*=256);)i+=this[e+a]*o;return i};s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||T(e,t,this.length);let i=this[e+--t],o=1;for(;t>0&&(o*=256);)i+=this[e+--t]*o;return i};s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e=e>>>0,t||T(e,1,this.length),this[e]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||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||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||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||T(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};s.prototype.readBigUInt64LE=N(function(e){e=e>>>0,H(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&J(e,this.length-8);let i=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});s.prototype.readBigUInt64BE=N(function(e){e=e>>>0,H(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&J(e,this.length-8);let i=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});s.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||T(e,t,this.length);let i=this[e],o=1,a=0;for(;++a<t&&(o*=256);)i+=this[e+a]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i};s.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||T(e,t,this.length);let i=t,o=1,a=this[e+--i];for(;i>0&&(o*=256);)a+=this[e+--i]*o;return o*=128,a>=o&&(a-=Math.pow(2,8*t)),a};s.prototype.readInt8=function(e,t){return e=e>>>0,t||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||T(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(e,t){e=e>>>0,t||T(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(e,t){return e=e>>>0,t||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||T(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};s.prototype.readBigInt64LE=N(function(e){e=e>>>0,H(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&J(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});s.prototype.readBigInt64BE=N(function(e){e=e>>>0,H(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&J(e,this.length-8);let i=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});s.prototype.readFloatLE=function(e,t){return e=e>>>0,t||T(e,4,this.length),z.read(this,e,!0,23,4)};s.prototype.readFloatBE=function(e,t){return e=e>>>0,t||T(e,4,this.length),z.read(this,e,!1,23,4)};s.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||T(e,8,this.length),z.read(this,e,!0,52,8)};s.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||T(e,8,this.length),z.read(this,e,!1,52,8)};function x(r,e,t,n,i,o){if(!s.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(t+n>r.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;x(this,e,t,n,c,0)}let o=1,a=0;for(this[t]=e&255;++a<n&&(o*=256);)this[t+a]=e/o&255;return t+n};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;x(this,e,t,n,c,0)}let o=n-1,a=1;for(this[t+o]=e&255;--o>=0&&(a*=256);)this[t+o]=e/a&255;return t+n};s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||x(this,e,t,1,255,0),this[t]=e&255,t+1};s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||x(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,n){return e=+e,t=t>>>0,n||x(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,n){return e=+e,t=t>>>0,n||x(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,n){return e=+e,t=t>>>0,n||x(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,n,i){Ye(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=a,a=a>>8,r[t++]=a,a=a>>8,r[t++]=a,a=a>>8,r[t++]=a,t}function ze(r,e,t,n,i){Ye(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t+7]=o,o=o>>8,r[t+6]=o,o=o>>8,r[t+5]=o,o=o>>8,r[t+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=a,a=a>>8,r[t+2]=a,a=a>>8,r[t+1]=a,a=a>>8,r[t]=a,t+8}s.prototype.writeBigUInt64LE=N(function(e,t=0){return Ze(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeBigUInt64BE=N(function(e,t=0){return ze(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let l=Math.pow(2,8*n-1);x(this,e,t,n,l-1,-l)}let o=0,a=1,c=0;for(this[t]=e&255;++o<n&&(a*=256);)e<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(e/a>>0)-c&255;return t+n};s.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let l=Math.pow(2,8*n-1);x(this,e,t,n,l-1,-l)}let o=n-1,a=1,c=0;for(this[t+o]=e&255;--o>=0&&(a*=256);)e<0&&c===0&&this[t+o+1]!==0&&(c=1),this[t+o]=(e/a>>0)-c&255;return t+n};s.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||x(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};s.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||x(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};s.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||x(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};s.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||x(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,n){return e=+e,t=t>>>0,n||x(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=N(function(e,t=0){return Ze(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});s.prototype.writeBigInt64BE=N(function(e,t=0){return ze(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function He(r,e,t,n,i,o){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function je(r,e,t,n,i){return e=+e,t=t>>>0,i||He(r,e,t,4,34028234663852886e22,-34028234663852886e22),z.write(r,e,t,n,23,4),t+4}s.prototype.writeFloatLE=function(e,t,n){return je(this,e,t,!0,n)};s.prototype.writeFloatBE=function(e,t,n){return je(this,e,t,!1,n)};function Ve(r,e,t,n,i){return e=+e,t=t>>>0,i||He(r,e,t,8,17976931348623157e292,-17976931348623157e292),z.write(r,e,t,n,52,8),t+8}s.prototype.writeDoubleLE=function(e,t,n){return Ve(this,e,t,!0,n)};s.prototype.writeDoubleBE=function(e,t,n){return Ve(this,e,t,!1,n)};s.prototype.copy=function(e,t,n,i){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),t),o};s.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let a=e.charCodeAt(0);(i==="utf8"&&a<128||i==="latin1")&&(e=a)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<n;++o)this[o]=e;else{let a=s.isBuffer(e)?e:s.from(e,i),c=a.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=a[o%c]}return this};var Z={};function Ee(r,e,t){Z[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(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Ee("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ee("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);Ee("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=We(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=We(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function We(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function pr(r,e,t){H(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&J(e,r.length-(t+1))}function Ye(r,e,t,n,i,o){if(r>t||r<e){let a=typeof e=="bigint"?"n":"",c;throw o>3?e===0||e===BigInt(0)?c=`>= 0${a} and < 2${a} ** ${(o+1)*8}${a}`:c=`>= -(2${a} ** ${(o+1)*8-1}${a}) and < 2 ** ${(o+1)*8-1}${a}`:c=`>= ${e}${a} and <= ${t}${a}`,new Z.ERR_OUT_OF_RANGE("value",c,r)}pr(n,i,o)}function H(r,e){if(typeof r!="number")throw new Z.ERR_INVALID_ARG_TYPE(e,"number",r)}function J(r,e,t){throw Math.floor(r)!==r?(H(r,t),new Z.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new Z.ERR_BUFFER_OUT_OF_BOUNDS:new Z.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var yr=/[^+/0-9A-Za-z-_]/g;function fr(r){if(r=r.split("=")[0],r=r.trim().replace(yr,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function we(r,e){e=e||1/0;let t,n=r.length,i=null,o=[];for(let a=0;a<n;++a){if(t=r.charCodeAt(a),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&o.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;o.push(t)}else if(t<2048){if((e-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function dr(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function hr(r,e){let t,n,i,o=[];for(let a=0;a<r.length&&!((e-=2)<0);++a)t=r.charCodeAt(a),n=t>>8,i=t%256,o.push(i),o.push(n);return o}function Je(r){return ge.toByteArray(fr(r))}function ie(r,e,t,n){let i;for(i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function F(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Ie(r){return r!==r}var gr=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function N(r){return typeof BigInt>"u"?mr:r}function mr(){throw new Error("BigInt not supported")}});var li=d(h(),1),Ft=d(Ke(),1);var nn=d(h(),1);var Vr=d(h(),1),w={module:"Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM",scheduler:"_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA",mu:"fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY",src:{asset:"Xr4vjtRZLlW-8pv7jZC_89xXXfjQ_VgjdRbt8fN47mg",zone:"M9G2B9Uvk8VK1pxloESeT4XScguRKSzLyd4as1HFOJ8",collection:"2ZDuM2VUCN8WHoAKOOjiH4_7Apq0ZHKnTWdLppxCdGY"},collectionsRegistry:"TFWDmf8a3_nw43GCm_CuYlYoylHAjCcFGbgHfDaGcsg"},Xe={"application/json":{type:"application/json",serialize:r=>JSON.stringify(r)}},I={arweave:"arweave.net",goldsky:"arweave-search.goldsky.com"},et={udl:{label:"Universal Data License",address:"dE0rmDfl9_OWjkDznNEXHaSO_JohJkRolvMzaCroUdw"}},u={keys:{access:"Access-Fee",ans110:{title:"Title",description:"Description",topic:"Topic:*",type:"Type",implements:"Implements",license:"License"},assetType:"Asset-Type",banner:"Banner",bootloader:"Bootloader",bootloaderInit:"On-Boot",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",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"}},tt={node1:"https://up.arweave.net",node2:"https://turbo.ardrive.io",batchSize:1,chunkSize:75e5,dispatchUploadSize:100*1024};var tn=d(h(),1);var Kr=d(h(),1);function G(r){return r?/^[a-z0-9_-]{43}$/i.test(r):!1}function rt(r,e){if(!r)return"";if(!G(r))return r;let t=r.substring(0,5)+"..."+r.substring(36,r.length);return e?`(${t})`:t}function g(r,e){for(let t=0;t<r.length;t++)if(r[t]&&r[t].name===e)return r[t].value;return null}function nt(r){let e=r.match(/^data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+);base64,/);return e?e[1]:null}function it(r){return r.split(",")[1]}function ot(r){let e;if(Buffer.isBuffer(r))e=r.length;else if(typeof r=="string")e=Buffer.byteLength(r,"utf-8");else throw new Error("Input must be a string or a Buffer");return e}function Be(r){let e;return e=r.replace(/\[|\]/g,""),`[[${e}]]`}function K(r){let e;return e=r.replace(/\[|\]/g,""),e}var O=(...r)=>{console.log("[@permaweb/libs]",...r)};function Tr(r){return r.replace(/^[a-z]/,e=>e.toUpperCase())}function oe(r){return Array.isArray(r)?r.map(oe):r&&typeof r=="object"?Object.entries(r).reduce((e,[t,n])=>{let i=Tr(t);return e[i]=oe(n),e},{}):r}function wr(r){return r.charAt(0).toLowerCase()+r.slice(1)}function P(r){return Array.isArray(r)?r.map(P):r&&typeof r=="object"?Object.entries(r).reduce((e,[t,n])=>{let i=wr(t);return e[i]=P(n),e},{}):r}function A(r,e){return{name:`${u.keys.bootloader}-${r}`,value:e}}var xr="https://arweave.net";function V(r){return`${xr}/${r}`}var rn=d(h(),1);var En=d(h(),1);var mn=d(h(),1);var pn=d(h(),1);var at={p1:"P1",end:"END"},st={default:100};async function B(r){let e=r.paginator?r.paginator:st.default,t=[],n=0,i=null;if(r.ids&&!r.ids.length)return{data:t,count:n,nextCursor:i,previousCursor:null};try{let o=Ir(r),a=await Br({gateway:r.gateway,query:Er(o)});return a.data.transactions.edges.length?(t=[...a.data.transactions.edges],n=a.data.transactions.count??0,t.length<e||!a.data.transactions.pageInfo.hasNextPage?i=at.end:i=t[t.length-1].cursor,{data:t,count:n,nextCursor:i,previousCursor:null}):{data:t,count:n,nextCursor:i,previousCursor:null}}catch(o){return console.error(o),{data:t,count:n,nextCursor:i,previousCursor:null}}}function Er(r){let e={query:`query { ${r} }`};return JSON.stringify(e)}function Ir(r){let e=r.paginator?r.paginator:st.default,t=r.ids?JSON.stringify(r.ids):null,n=null;r.minBlock!==void 0&&r.minBlock!==null&&(n={},n.min=r.minBlock);let i=n?JSON.stringify(n).replace(/"([^"]+)":/g,"$1:"):null,o=r.tags?JSON.stringify(r.tags).replace(/"(name)":/g,"$1:").replace(/"(values)":/g,"$1:").replace(/"FUZZY_OR"/g,"FUZZY_OR"):null,a=r.owners?JSON.stringify(r.owners):null,c=r.cursor&&r.cursor!==at.end?`"${r.cursor}"`:null,l=`first: ${e}`,p="",f="data { size type } owner { address } block { height timestamp }",y="";switch(r.gateway){case I.arweave:break;case I.goldsky:p="count";break}let b=`
1
+ var Pt=Object.create;var Se=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var vt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var ee=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Nt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ut(e))!Lt.call(r,i)&&i!==t&&Se(r,i,{get:()=>e[i],enumerable:!(n=Rt(e,i))||n.enumerable});return r};var f=(r,e,t)=>(t=r!=null?Pt(vt(r)):{},Nt(e||!r||!r.__esModule?Se(t,"default",{value:r,enumerable:!0}):t,r));var h=ee((Lr,Re)=>{var g=Re.exports={},S,b;function ye(){throw new Error("setTimeout has not been defined")}function fe(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?S=setTimeout:S=ye}catch{S=ye}try{typeof clearTimeout=="function"?b=clearTimeout:b=fe}catch{b=fe}})();function be(r){if(S===setTimeout)return setTimeout(r,0);if((S===ye||!S)&&setTimeout)return S=setTimeout,setTimeout(r,0);try{return S(r,0)}catch{try{return S.call(null,r,0)}catch{return S.call(this,r,0)}}}function $t(r){if(b===clearTimeout)return clearTimeout(r);if((b===fe||!b)&&clearTimeout)return b=clearTimeout,clearTimeout(r);try{return b(r)}catch{try{return b.call(null,r)}catch{return b.call(this,r)}}}var R=[],_=!1,M,te=-1;function Mt(){!_||!M||(_=!1,M.length?R=M.concat(R):te=-1,R.length&&Fe())}function Fe(){if(!_){var r=be(Mt);_=!0;for(var e=R.length;e;){for(M=R,R=[];++te<e;)M&&M[te].run();te=-1,e=R.length}M=null,_=!1,$t(r)}}g.nextTick=function(r){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];R.push(new Pe(r,e)),R.length===1&&!_&&be(Fe)};function Pe(r,e){this.fun=r,this.array=e}Pe.prototype.run=function(){this.fun.apply(null,this.array)};g.title="browser";g.browser=!0;g.env={};g.argv=[];g.version="";g.versions={};function U(){}g.on=U;g.addListener=U;g.once=U;g.off=U;g.removeListener=U;g.removeAllListeners=U;g.emit=U;g.prependListener=U;g.prependOnceListener=U;g.listeners=function(r){return[]};g.binding=function(r){throw new Error("process.binding is not supported")};g.cwd=function(){return"/"};g.chdir=function(r){throw new Error("process.chdir is not supported")};g.umask=function(){return 0}});var Le=ee(re=>{"use strict";var $r=f(h());re.byteLength=Gt;re.toByteArray=Ot;re.fromByteArray=qt;var F=[],E=[],kt=typeof Uint8Array<"u"?Uint8Array:Array,he="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(k=0,Ue=he.length;k<Ue;++k)F[k]=he[k],E[he.charCodeAt(k)]=k;var k,Ue;E[45]=62;E[95]=63;function ve(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function Gt(r){var e=ve(r),t=e[0],n=e[1];return(t+n)*3/4-n}function Wt(r,e,t){return(e+t)*3/4-t}function Ot(r){var e,t=ve(r),n=t[0],i=t[1],o=new kt(Wt(r,n,i)),a=0,c=i>0?n-4:n,u;for(u=0;u<c;u+=4)e=E[r.charCodeAt(u)]<<18|E[r.charCodeAt(u+1)]<<12|E[r.charCodeAt(u+2)]<<6|E[r.charCodeAt(u+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=e&255;return i===2&&(e=E[r.charCodeAt(u)]<<2|E[r.charCodeAt(u+1)]>>4,o[a++]=e&255),i===1&&(e=E[r.charCodeAt(u)]<<10|E[r.charCodeAt(u+1)]<<4|E[r.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=e&255),o}function _t(r){return F[r>>18&63]+F[r>>12&63]+F[r>>6&63]+F[r&63]}function Qt(r,e,t){for(var n,i=[],o=e;o<t;o+=3)n=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),i.push(_t(n));return i.join("")}function qt(r){for(var e,t=r.length,n=t%3,i=[],o=16383,a=0,c=t-n;a<c;a+=o)i.push(Qt(r,a,a+o>c?c:a+o));return n===1?(e=r[t-1],i.push(F[e>>2]+F[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(F[e>>10]+F[e>>4&63]+F[e<<2&63]+"=")),i.join("")}});var Ne=ee(de=>{var kr=f(h());de.read=function(r,e,t,n,i){var o,a,c=i*8-n-1,u=(1<<c)-1,l=u>>1,y=-7,p=t?i-1:0,C=t?-1:1,D=r[e+p];for(p+=C,o=D&(1<<-y)-1,D>>=-y,y+=c;y>0;o=o*256+r[e+p],p+=C,y-=8);for(a=o&(1<<-y)-1,o>>=-y,y+=n;y>0;a=a*256+r[e+p],p+=C,y-=8);if(o===0)o=1-l;else{if(o===u)return a?NaN:(D?-1:1)*(1/0);a=a+Math.pow(2,n),o=o-l}return(D?-1:1)*a*Math.pow(2,o-n)};de.write=function(r,e,t,n,i,o){var a,c,u,l=o*8-i-1,y=(1<<l)-1,p=y>>1,C=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,D=n?0:o-1,pe=n?1:-1,Ft=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,a=y):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),a+p>=1?e+=C/u:e+=C*Math.pow(2,1-p),e*u>=2&&(a++,u/=2),a+p>=y?(c=0,a=y):a+p>=1?(c=(e*u-1)*Math.pow(2,i),a=a+p):(c=e*Math.pow(2,p-1)*Math.pow(2,i),a=0));i>=8;r[t+D]=c&255,D+=pe,c/=256,i-=8);for(a=a<<i|c,l+=i;l>0;r[t+D]=a&255,D+=pe,a/=256,l-=8);r[t+D-pe]|=Ft*128}});var Ke=ee(Z=>{"use strict";var Or=f(h());var ge=Le(),q=Ne(),$e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Z.Buffer=s;Z.SlowBuffer=Yt;Z.INSPECT_MAX_BYTES=50;var ne=2147483647;Z.kMaxLength=ne;s.TYPED_ARRAY_SUPPORT=zt();!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 zt(){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 v(r){if(r>ne)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 xe(r)}return We(r,e,t)}s.poolSize=8192;function We(r,e,t){if(typeof r=="string")return jt(r,e);if(ArrayBuffer.isView(r))return Vt(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(P(r,ArrayBuffer)||r&&P(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(P(r,SharedArrayBuffer)||r&&P(r.buffer,SharedArrayBuffer)))return we(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return s.from(n,e,t);let i=Ht(r);if(i)return i;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 We(r,e,t)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function Oe(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 Zt(r,e,t){return Oe(r),r<=0?v(r):e!==void 0?typeof t=="string"?v(r).fill(e,t):v(r).fill(e):v(r)}s.alloc=function(r,e,t){return Zt(r,e,t)};function xe(r){return Oe(r),v(r<0?0:Ee(r)|0)}s.allocUnsafe=function(r){return xe(r)};s.allocUnsafeSlow=function(r){return xe(r)};function jt(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=_e(r,e)|0,n=v(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function me(r){let e=r.length<0?0:Ee(r.length)|0,t=v(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function Vt(r){if(P(r,Uint8Array)){let e=new Uint8Array(r);return we(e.buffer,e.byteOffset,e.byteLength)}return me(r)}function we(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 n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,s.prototype),n}function Ht(r){if(s.isBuffer(r)){let e=Ee(r.length)|0,t=v(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Ie(r.length)?v(0):me(r);if(r.type==="Buffer"&&Array.isArray(r.data))return me(r.data)}function Ee(r){if(r>=ne)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ne.toString(16)+" bytes");return r|0}function Yt(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(P(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),P(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 n=e.length,i=t.length;for(let o=0,a=Math.min(n,i);o<a;++o)if(e[o]!==t[o]){n=e[o],i=t[o];break}return n<i?-1:i<n?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 n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=s.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){let a=e[n];if(P(a,Uint8Array))o+a.length>i.length?(s.isBuffer(a)||(a=s.from(a)),a.copy(i,o)):Uint8Array.prototype.set.call(i,a,o);else if(s.isBuffer(a))a.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=a.length}return i};function _e(r,e){if(s.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||P(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,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Te(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(i)return n?-1:Te(r).length;e=(""+e).toLowerCase(),i=!0}}s.byteLength=_e;function Jt(r,e,t){let n=!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 sr(this,e,t);case"utf8":case"utf-8":return qe(this,e,t);case"ascii":return or(this,e,t);case"latin1":case"binary":return ar(this,e,t);case"base64":return nr(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return cr(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function G(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}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)G(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)G(this,t,t+3),G(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)G(this,t,t+7),G(this,t+1,t+6),G(this,t+2,t+5),G(this,t+3,t+4);return this};s.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?qe(this,0,e):Jt.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=Z.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};$e&&(s.prototype[$e]=s.prototype.inspect);s.prototype.compare=function(e,t,n,i,o){if(P(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),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),t<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&t>=n)return 0;if(i>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let a=o-i,c=n-t,u=Math.min(a,c),l=this.slice(i,o),y=e.slice(t,n);for(let p=0;p<u;++p)if(l[p]!==y[p]){a=l[p],c=y[p];break}return a<c?-1:c<a?1:0};function Qe(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Ie(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=s.from(e,n)),s.isBuffer(e))return e.length===0?-1:Me(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):Me(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function Me(r,e,t,n,i){let o=1,a=r.length,c=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;o=2,a/=2,c/=2,t/=2}function u(y,p){return o===1?y[p]:y.readUInt16BE(p*o)}let l;if(i){let y=-1;for(l=t;l<a;l++)if(u(r,l)===u(e,y===-1?0:l-y)){if(y===-1&&(y=l),l-y+1===c)return y*o}else y!==-1&&(l-=l-y),y=-1}else for(t+c>a&&(t=a-c),l=t;l>=0;l--){let y=!0;for(let p=0;p<c;p++)if(u(r,l+p)!==u(e,p)){y=!1;break}if(y)return l}return-1}s.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};s.prototype.indexOf=function(e,t,n){return Qe(this,e,t,n,!0)};s.prototype.lastIndexOf=function(e,t,n){return Qe(this,e,t,n,!1)};function Kt(r,e,t,n){t=Number(t)||0;let i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let a;for(a=0;a<n;++a){let c=parseInt(e.substr(a*2,2),16);if(Ie(c))return a;r[t+a]=c}return a}function Xt(r,e,t,n){return ie(Te(e,r.length-t),r,t,n)}function er(r,e,t,n){return ie(yr(e),r,t,n)}function tr(r,e,t,n){return ie(Je(e),r,t,n)}function rr(r,e,t,n){return ie(fr(e,r.length-t),r,t,n)}s.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let a=!1;for(;;)switch(i){case"hex":return Kt(this,e,t,n);case"utf8":case"utf-8":return Xt(this,e,t,n);case"ascii":case"latin1":case"binary":return er(this,e,t,n);case"base64":return tr(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return rr(this,e,t,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function nr(r,e,t){return e===0&&t===r.length?ge.fromByteArray(r):ge.fromByteArray(r.slice(e,t))}function qe(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i<t;){let o=r[i],a=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=t){let u,l,y,p;switch(c){case 1:o<128&&(a=o);break;case 2:u=r[i+1],(u&192)===128&&(p=(o&31)<<6|u&63,p>127&&(a=p));break;case 3:u=r[i+1],l=r[i+2],(u&192)===128&&(l&192)===128&&(p=(o&15)<<12|(u&63)<<6|l&63,p>2047&&(p<55296||p>57343)&&(a=p));break;case 4:u=r[i+1],l=r[i+2],y=r[i+3],(u&192)===128&&(l&192)===128&&(y&192)===128&&(p=(o&15)<<18|(u&63)<<12|(l&63)<<6|y&63,p>65535&&p<1114112&&(a=p))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),i+=c}return ir(n)}var ke=4096;function ir(r){let e=r.length;if(e<=ke)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=ke));return t}function or(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function ar(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function sr(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let i="";for(let o=e;o<t;++o)i+=hr[r[o]];return i}function cr(r,e,t){let n=r.slice(e,t),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}s.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,s.prototype),i};function m(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,n){e=e>>>0,t=t>>>0,n||m(e,t,this.length);let i=this[e],o=1,a=0;for(;++a<t&&(o*=256);)i+=this[e+a]*o;return i};s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||m(e,t,this.length);let i=this[e+--t],o=1;for(;t>0&&(o*=256);)i+=this[e+--t]*o;return i};s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e=e>>>0,t||m(e,1,this.length),this[e]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||m(e,2,this.length),this[e]|this[e+1]<<8};s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||m(e,2,this.length),this[e]<<8|this[e+1]};s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||m(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||m(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};s.prototype.readBigUInt64LE=L(function(e){e=e>>>0,z(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&J(e,this.length-8);let i=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});s.prototype.readBigUInt64BE=L(function(e){e=e>>>0,z(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&J(e,this.length-8);let i=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});s.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||m(e,t,this.length);let i=this[e],o=1,a=0;for(;++a<t&&(o*=256);)i+=this[e+a]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i};s.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||m(e,t,this.length);let i=t,o=1,a=this[e+--i];for(;i>0&&(o*=256);)a+=this[e+--i]*o;return o*=128,a>=o&&(a-=Math.pow(2,8*t)),a};s.prototype.readInt8=function(e,t){return e=e>>>0,t||m(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};s.prototype.readInt16LE=function(e,t){e=e>>>0,t||m(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(e,t){e=e>>>0,t||m(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(e,t){return e=e>>>0,t||m(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||m(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};s.prototype.readBigInt64LE=L(function(e){e=e>>>0,z(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&J(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});s.prototype.readBigInt64BE=L(function(e){e=e>>>0,z(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&J(e,this.length-8);let i=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});s.prototype.readFloatLE=function(e,t){return e=e>>>0,t||m(e,4,this.length),q.read(this,e,!0,23,4)};s.prototype.readFloatBE=function(e,t){return e=e>>>0,t||m(e,4,this.length),q.read(this,e,!1,23,4)};s.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||m(e,8,this.length),q.read(this,e,!0,52,8)};s.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||m(e,8,this.length),q.read(this,e,!1,52,8)};function T(r,e,t,n,i,o){if(!s.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(t+n>r.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;T(this,e,t,n,c,0)}let o=1,a=0;for(this[t]=e&255;++a<n&&(o*=256);)this[t+a]=e/o&255;return t+n};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;T(this,e,t,n,c,0)}let o=n-1,a=1;for(this[t+o]=e&255;--o>=0&&(a*=256);)this[t+o]=e/a&255;return t+n};s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||T(this,e,t,1,255,0),this[t]=e&255,t+1};s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||T(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,n){return e=+e,t=t>>>0,n||T(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,n){return e=+e,t=t>>>0,n||T(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,n){return e=+e,t=t>>>0,n||T(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,n,i){Ye(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=a,a=a>>8,r[t++]=a,a=a>>8,r[t++]=a,a=a>>8,r[t++]=a,t}function Ze(r,e,t,n,i){Ye(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t+7]=o,o=o>>8,r[t+6]=o,o=o>>8,r[t+5]=o,o=o>>8,r[t+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=a,a=a>>8,r[t+2]=a,a=a>>8,r[t+1]=a,a=a>>8,r[t]=a,t+8}s.prototype.writeBigUInt64LE=L(function(e,t=0){return ze(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeBigUInt64BE=L(function(e,t=0){return Ze(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);T(this,e,t,n,u-1,-u)}let o=0,a=1,c=0;for(this[t]=e&255;++o<n&&(a*=256);)e<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(e/a>>0)-c&255;return t+n};s.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);T(this,e,t,n,u-1,-u)}let o=n-1,a=1,c=0;for(this[t+o]=e&255;--o>=0&&(a*=256);)e<0&&c===0&&this[t+o+1]!==0&&(c=1),this[t+o]=(e/a>>0)-c&255;return t+n};s.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||T(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};s.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||T(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};s.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||T(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};s.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||T(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,n){return e=+e,t=t>>>0,n||T(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=L(function(e,t=0){return ze(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});s.prototype.writeBigInt64BE=L(function(e,t=0){return Ze(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function je(r,e,t,n,i,o){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Ve(r,e,t,n,i){return e=+e,t=t>>>0,i||je(r,e,t,4,34028234663852886e22,-34028234663852886e22),q.write(r,e,t,n,23,4),t+4}s.prototype.writeFloatLE=function(e,t,n){return Ve(this,e,t,!0,n)};s.prototype.writeFloatBE=function(e,t,n){return Ve(this,e,t,!1,n)};function He(r,e,t,n,i){return e=+e,t=t>>>0,i||je(r,e,t,8,17976931348623157e292,-17976931348623157e292),q.write(r,e,t,n,52,8),t+8}s.prototype.writeDoubleLE=function(e,t,n){return He(this,e,t,!0,n)};s.prototype.writeDoubleBE=function(e,t,n){return He(this,e,t,!1,n)};s.prototype.copy=function(e,t,n,i){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),t),o};s.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let a=e.charCodeAt(0);(i==="utf8"&&a<128||i==="latin1")&&(e=a)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<n;++o)this[o]=e;else{let a=s.isBuffer(e)?e:s.from(e,i),c=a.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=a[o%c]}return this};var Q={};function Ae(r,e,t){Q[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(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Ae("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ae("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);Ae("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=Ge(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=Ge(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Ge(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function ur(r,e,t){z(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&J(e,r.length-(t+1))}function Ye(r,e,t,n,i,o){if(r>t||r<e){let a=typeof e=="bigint"?"n":"",c;throw o>3?e===0||e===BigInt(0)?c=`>= 0${a} and < 2${a} ** ${(o+1)*8}${a}`:c=`>= -(2${a} ** ${(o+1)*8-1}${a}) and < 2 ** ${(o+1)*8-1}${a}`:c=`>= ${e}${a} and <= ${t}${a}`,new Q.ERR_OUT_OF_RANGE("value",c,r)}ur(n,i,o)}function z(r,e){if(typeof r!="number")throw new Q.ERR_INVALID_ARG_TYPE(e,"number",r)}function J(r,e,t){throw Math.floor(r)!==r?(z(r,t),new Q.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new Q.ERR_BUFFER_OUT_OF_BOUNDS:new Q.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var lr=/[^+/0-9A-Za-z-_]/g;function pr(r){if(r=r.split("=")[0],r=r.trim().replace(lr,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Te(r,e){e=e||1/0;let t,n=r.length,i=null,o=[];for(let a=0;a<n;++a){if(t=r.charCodeAt(a),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&o.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;o.push(t)}else if(t<2048){if((e-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function yr(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function fr(r,e){let t,n,i,o=[];for(let a=0;a<r.length&&!((e-=2)<0);++a)t=r.charCodeAt(a),n=t>>8,i=t%256,o.push(i),o.push(n);return o}function Je(r){return ge.toByteArray(pr(r))}function ie(r,e,t,n){let i;for(i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function P(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Ie(r){return r!==r}var hr=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function L(r){return typeof BigInt>"u"?dr:r}function dr(){throw new Error("BigInt not supported")}});var ai=f(h(),1),bt=f(Ke(),1);var Jr=f(h(),1);var Qr=f(h(),1),x={module:"Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM",scheduler:"_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA",mu:"fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY",src:{asset:"XYz8buLR5LQdhOOzWuCt9kBjoXHMowouWpXcGm9wdEE",zone:"M9G2B9Uvk8VK1pxloESeT4XScguRKSzLyd4as1HFOJ8",collection:"2ZDuM2VUCN8WHoAKOOjiH4_7Apq0ZHKnTWdLppxCdGY"},collectionsRegistry:"TFWDmf8a3_nw43GCm_CuYlYoylHAjCcFGbgHfDaGcsg"},Xe={"application/json":{type:"application/json",serialize:r=>JSON.stringify(r)}},A={arweave:"arweave.net",goldsky:"arweave-search.goldsky.com"};var d={keys:{access:"Access-Fee",ans110:{title:"Title",description:"Description",topic:"Topic:*",type:"Type",implements:"Implements",license:"License"},assetType:"Asset-Type",banner:"Banner",bootloader:"Bootloader",bootloaderInit:"On-Boot",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",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"}},et={node1:"https://up.arweave.net",node2:"https://turbo.ardrive.io",batchSize:1,chunkSize:75e5,dispatchUploadSize:100*1024};var Hr=f(h(),1);var Zr=f(h(),1);function V(r){return r?/^[a-z0-9_-]{43}$/i.test(r):!1}function oe(r,e){for(let t=0;t<r.length;t++)if(r[t]&&r[t].name===e)return r[t].value;return null}function tt(r){let e=r.match(/^data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+);base64,/);return e?e[1]:null}function rt(r){return r.split(",")[1]}function nt(r){let e;if(Buffer.isBuffer(r))e=r.length;else if(typeof r=="string")e=Buffer.byteLength(r,"utf-8");else throw new Error("Input must be a string or a Buffer");return e}function Be(r){let e;return e=r.replace(/\[|\]/g,""),`[[${e}]]`}function K(r){let e;return e=r.replace(/\[|\]/g,""),e}var I=(...r)=>{console.log("[@permaweb/libs]",...r)};function gr(r){return r.replace(/^[a-z]/,e=>e.toUpperCase())}function j(r){return Array.isArray(r)?r.map(j):r&&typeof r=="object"?Object.entries(r).reduce((e,[t,n])=>{let i=gr(t);return e[i]=V(n)?n:j(n),e},{}):r}function mr(r){return r.charAt(0).toLowerCase()+r.slice(1)}function N(r){return Array.isArray(r)?r.map(N):r&&typeof r=="object"?Object.entries(r).reduce((e,[t,n])=>{let i=mr(t);return e[i]=V(n)?n:N(n),e},{}):r}function w(r,e){let t=r.charAt(0).toUpperCase()+r.slice(1);return{name:`${d.keys.bootloader}-${t}`,value:e}}var wr="https://arweave.net";function H(r){return`${wr}/${r}`}var Yr=f(h(),1);var gn=f(h(),1);var pn=f(h(),1);var on=f(h(),1);var it={p1:"P1",end:"END"},ot={default:100};async function B(r){let e=r.paginator?r.paginator:ot.default,t=[],n=0,i=null;if(r.ids&&!r.ids.length)return{data:t,count:n,nextCursor:i,previousCursor:null};try{let o=Er(r),a=await Ar({gateway:r.gateway,query:xr(o)});return a.data.transactions.edges.length?(t=[...a.data.transactions.edges],n=a.data.transactions.count??0,t.length<e||!a.data.transactions.pageInfo.hasNextPage?i=it.end:i=t[t.length-1].cursor,{data:t,count:n,nextCursor:i,previousCursor:null}):{data:t,count:n,nextCursor:i,previousCursor:null}}catch(o){return console.error(o),{data:t,count:n,nextCursor:i,previousCursor:null}}}function xr(r){let e={query:`query { ${r} }`};return JSON.stringify(e)}function Er(r){let e=r.paginator?r.paginator:ot.default,t=r.ids?JSON.stringify(r.ids):null,n=null;r.minBlock!==void 0&&r.minBlock!==null&&(n={},n.min=r.minBlock);let i=n?JSON.stringify(n).replace(/"([^"]+)":/g,"$1:"):null,o=r.tags?JSON.stringify(r.tags).replace(/"(name)":/g,"$1:").replace(/"(values)":/g,"$1:").replace(/"FUZZY_OR"/g,"FUZZY_OR"):null,a=r.owners?JSON.stringify(r.owners):null,c=r.cursor&&r.cursor!==it.end?`"${r.cursor}"`:null,u=`first: ${e}`,l="",y="data { size type } owner { address } block { height timestamp }",p="";switch(r.gateway){case A.arweave:break;case A.goldsky:l="count";break}let C=`
2
2
  transactions(
3
3
  ids: ${t},
4
4
  tags: ${o},
5
- ${l}
5
+ ${u}
6
6
  owners: ${a},
7
7
  block: ${i},
8
8
  after: ${c},
9
- ${y}
9
+ ${p}
10
10
 
11
11
  ){
12
- ${p}
12
+ ${l}
13
13
  pageInfo {
14
14
  hasNextPage
15
15
  }
@@ -21,10 +21,10 @@ var kt=Object.create;var De=Object.defineProperty;var Ut=Object.getOwnPropertyDe
21
21
  name
22
22
  value
23
23
  }
24
- ${f}
24
+ ${y}
25
25
  }
26
26
  }
27
- }`;return r.queryKey&&(b=`${r.queryKey}: ${b}`),b}async function Br(r){try{return await(await fetch(`https://${r.gateway}/graphql`,{method:"POST",headers:{"Content-Type":"application/json"},body:r.query})).json()}catch(e){throw e}}var br=I.goldsky,Cr=1e3;async function ct(r,e){let t=[{name:"Authority",value:w.mu}];e.tags&&e.tags.length>0&&e.tags.forEach(n=>t.push(n));try{let n=await r.ao.spawn({module:e.module,scheduler:e.scheduler,signer:r.signer,tags:t,data:e.data});return O(`Process ID: ${n}`),n}catch(n){throw new Error(n.message??"Error spawning process")}}function ut(r){return async e=>await _(r,e)}async function _(r,e){try{let t=[{name:"Action",value:e.action}];e.tags&&t.push(...e.tags);let n=e.useRawData?e.data:JSON.stringify(e.data);return await r.ao.message({process:e.processId,signer:r.signer,tags:t,data:n})}catch(t){throw new Error(t)}}function lt(r){return async e=>await L(r,e)}async function L(r,e){try{let t=[{name:"Action",value:e.action}];e.tags&&t.push(...e.tags);let n;if(typeof e.data=="object")n=JSON.stringify(e.data||{});else if(typeof e.data=="string"){try{JSON.parse(e.data)}catch(o){throw console.error(o),new Error("Invalid JSON data")}n=e.data}let i=await r.ao.dryrun({process:e.processId,tags:t,data:n});if(i.Messages&&i.Messages.length){if(i.Messages[0].Data)return JSON.parse(i.Messages[0].Data);if(i.Messages[0].Tags)return i.Messages[0].Tags.reduce((o,a)=>(o[a.name]=a.value,o),{})}}catch(t){throw new Error(t.message??"Error dryrunning process")}}async function Dr(r,e){try{let{Messages:t}=await r.ao.result({message:e.messageId,process:e.processId});if(t&&t.length){let n={};return t.forEach(i=>{let o=g(i.Tags,"Action")||e.action,a=null,c=i.Data;if(c)try{a=JSON.parse(c)}catch{a=c}let l=g(i.Tags,"Status"),p=g(i.Tags,"Message");n[o]={id:e.messageId,status:l,message:p,data:a}}),n}else return null}catch(t){console.error(t)}}async function pt(r,e){let t=null;if(e.evalSrc?t=e.evalSrc:e.evalTxId&&(t=await Sr(e.evalTxId)),t)try{let n=await _(r,{processId:e.processId,action:"Eval",data:t,tags:e.evalTags||null,useRawData:!0});return O(`Eval: ${n}`),await Dr(r,{processId:e.processId,messageId:n,action:"Eval"})}catch(n){throw new Error(n.message??"Error sending process eval")}return null}function yt(r){return async(e,t)=>{try{let n={module:e.module||w.module,scheduler:e.scheduler||w.scheduler};e.spawnData&&(n.data=e.spawnData),e.spawnTags&&(n.tags=e.spawnTags),t&&t("Spawning process...");let i=await ct(r,n);if(e.evalTxId||e.evalSrc){t&&t("Retrieving process..."),await ft(i,t),t&&t("Process retrieved!"),t&&t("Sending eval...");try{await pt(r,{processId:i,evalTxId:e.evalTxId||null,evalSrc:e.evalSrc||null,evalTags:e.evalTags})&&t&&t("Eval complete")}catch(o){throw new Error(o.message??"Error creating process")}}return i}catch(n){throw new Error(n.message??"Error creating process")}}}async function Y(r,e,t){try{let n={module:e.module||w.module,scheduler:e.scheduler||w.scheduler};e.spawnData&&(n.data=e.spawnData),e.spawnTags&&(n.tags=e.spawnTags),t&&t("Spawning process...");let i=await ct(r,n);if(t&&t("Retrieving process..."),await ft(i,t),e.evalTxId||e.evalSrc){t&&t("Process retrieved!"),t&&t("Sending eval...");try{await pt(r,{processId:i,evalTxId:e.evalTxId||null,evalSrc:e.evalSrc||null,evalTags:e.evalTags})&&t&&t("Eval complete")}catch(o){throw new Error(o.message??"Error creating process")}}return i}catch(n){throw new Error(n.message??"Error creating process")}}async function ft(r,e){let t=0;for(;t<Cr;){await new Promise(i=>setTimeout(i,2e3));let n=await B({gateway:br,ids:[r]});if(n?.data?.length){let i=n.data[0].node.id;return O(`Process found: ${i} (Try ${t+1})`),i}else O(`Process not found: ${r} (Try ${t+1})`),t++}throw new Error("Process not found, please try again")}async function Sr(r){try{return await(await fetch(V(r))).text()}catch(e){throw new Error(e)}}var An=d(h(),1);function dt(r){return async e=>{if(G(e))return e;if(!r.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await ht(r,{data:e})}catch(t){throw new Error(t.message??"Error resolving transaction")}}}async function Q(r,e){if(G(e))return e;if(!r.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await ht(r,{data:e})}catch(t){throw new Error(t.message??"Error resolving transaction")}}async function ht(r,e){let t=null,n=null;try{typeof e.data=="string"&&e.data.startsWith("data:")&&(t=Buffer.from(it(e.data),"base64"),n=nt(e.data))}catch(i){throw new Error(i)}if(t&&n){let i=ot(t);if(O(`Content upload size: ${i}`),i<Number(tt.dispatchUploadSize)){let o=await r.arweave.createTransaction({data:t},"use_wallet");return o.addTag(u.keys.contentType,n),e.tags&&e.tags.length>0&&e.tags.forEach(c=>o.addTag(c.name,c.value)),(await global.window.arweaveWallet.dispatch(o)).id}else throw new Error("Data exceeds max upload limit")}else throw new Error("Error preparing transaction data")}var ri=d(h(),1);var Rn=d(h(),1);function ae(r){return async(e,t)=>{let n=Lr(e);if(n)throw new Error(n);let i=Xe[e.contentType]?.serialize(e.data)??e.data,o=[{name:u.keys.bootloaderInit,value:e.src??w.src.asset}];o.push(...Pr(e)),o.push(A("Name",e.name)),o.push(A("Creator",e.creator)),o.push(A("Ticker","ATOMIC")),o.push(A("Denomination",e.denomination?e.denomination.toString():"1")),o.push(A("TotalSupply",e.supply?e.supply.toString():"1")),e.collectionId&&o.push(A("Collection",e.collectionId)),e.transferable||o.push(A("Transferable","false"));try{return await Y(r,{spawnTags:o,spawnData:i},t?c=>t(c):void 0)}catch(a){throw new Error(a.message??"Error creating asset")}}}async function be(r,e){try{let t=await B({gateway:I.goldsky,ids:[e],tags:null,owners:null,cursor:null});if(t&&t.data.length){let n=se(t.data[0]),i={ticker:null,denomination:null,balances:null,transferable:null,creator:null,metadata:{}},o=await L(r,{processId:n.id,action:"Info"});if(o=P(o),o&&(o.name&&(n.name=o.name),o.ticker&&(i.ticker=o.ticker),o.denomination&&(i.denomination=o.denomination),o.logo&&(n.thumbnail=o.logo),o.creator&&(i.creator=o.creator),o.balances&&(i.balances=Object.fromEntries(Object.entries(o.balances).filter(([a,c])=>Number(c)!==0))),o.transferable!==void 0?i.transferable=o.transferable:i.transferable=!0,o.assetMetadata))for(let[a,c]of Object.entries(o.assetMetadata))a in i||(i.metadata[a]=c);if(!i.balances)try{let a=await L(r,{processId:n.id,action:"Balances"});a&&(i.balances=a)}catch(a){console.error(a)}return{...n,...i}}return null}catch(t){throw new Error(t.message||"Error fetching atomic asset")}}function gt(r){return async e=>await be(r,e)}async function mt(r){try{let e=await B({gateway:I.arweave,ids:r??null,tags:null,owners:null,cursor:null});return e&&e.data.length?e.data.map(t=>se(t)):null}catch(e){throw new Error(e)}}function se(r){let e=new Set([u.keys.creator,u.keys.title,u.keys.name,u.keys.description,u.keys.type,u.keys.topic,u.keys.implements,u.keys.contentType,u.keys.renderWith,u.keys.thumbnail,u.keys.license,u.keys.access,u.keys.derivations,u.keys.commericalUse,u.keys.dataModelTraining,u.keys.paymentMode,u.keys.paymentAddress,u.keys.currency,u.keys.collectionId,u.keys.dateCreated]);return{id:r.node.id,owner:r.node.owner.address,creator:g(r.node.tags,u.keys.creator),name:Fr(r),description:g(r.node.tags,u.keys.description),type:g(r.node.tags,u.keys.type),topics:Rr(r),implementation:g(r.node.tags,u.keys.implements),contentType:g(r.node.tags,u.keys.contentType),renderWith:g(r.node.tags,u.keys.renderWith),thumbnail:g(r.node.tags,u.keys.thumbnail),udl:Ur(r),collectionId:g(r.node.tags,u.keys.collectionId),dateCreated:kr(r),blockHeight:r.node.block?r.node.block.height:0,tags:r.node.tags.filter(n=>!e.has(n.name))}}function Fr(r){return g(r.node.tags,u.keys.name)||g(r.node.tags,u.keys.title)||rt(r.node.id,!1)}function Rr(r){return r.node.tags.filter(e=>e.name.includes(u.keys.topic.toLowerCase())).map(e=>e.value)}function kr(r){if(r.node.block)return r.node.block.timestamp*1e3;let e=g(r.node.tags,u.keys.dateCreated);return e?Number(e):0}function Ur(r){let e=g(r.node.tags,u.keys.license);return e&&e===et.udl.address?{access:{value:g(r.node.tags,u.keys.access)},derivations:{value:g(r.node.tags,u.keys.derivations)},commercialUse:{value:g(r.node.tags,u.keys.commericalUse)},dataModelTraining:{value:g(r.node.tags,u.keys.dataModelTraining)},paymentMode:g(r.node.tags,u.keys.paymentMode),paymentAddress:g(r.node.tags,u.keys.paymentAddress),currency:g(r.node.tags,u.keys.currency)}:null}function Pr(r){let e=[{name:u.keys.title,value:r.name},{name:u.keys.description,value:r.description},{name:u.keys.assetType,value:r.type},{name:u.keys.contentType,value:r.contentType},{name:u.keys.implements,value:"ANS-110"},{name:u.keys.dateCreated,value:new Date().getTime().toString()}];return r.topics.forEach(t=>e.push({name:u.keys.topic,value:t})),r.creator&&e.push({name:u.keys.creator,value:r.creator}),r.collectionId&&e.push({name:u.keys.collectionId,value:r.collectionId}),r.renderWith&&e.push({name:u.keys.renderWith,value:r.renderWith}),r.thumbnail&&G(r.thumbnail)&&e.push({name:u.keys.thumbnail,value:r.thumbnail}),r.tags&&r.tags.forEach(t=>e.push(t)),e}function Lr(r){if(typeof r!="object"||r===null)return"The provided arguments are invalid or empty.";let e=["name","description","type","topics","contentType","data"];for(let t of e)if(!(t in r))return`Missing field '${t}'`;return typeof r.name!="string"||r.name.trim()===""?"Name is required":typeof r.description!="string"?"The description must be a valid string":typeof r.type!="string"||r.type.trim()===""?"Type must be a non-empty string":!Array.isArray(r.topics)||r.topics.length===0?"Topics are required":typeof r.contentType!="string"||r.contentType.trim()===""?"Content type must be a non-empty string":r.data===void 0||r.data===null?"Data field is required":typeof r.creator!="string"||r.creator.trim()===""?"Creator is required":"collectionId"in r&&typeof r.collectionId!="string"?"Collection ID must be a valid string":"renderWith"in r&&typeof r.renderWith!="string"?"Render with value must be a valid string":"thumbnail"in r&&typeof r.thumbnail!="string"?"Thumbnail must be a valid string":"supply"in r&&(typeof r.supply!="number"||r.supply<=0)?"Supply must be a positive number":"transferable"in r&&typeof r.transferable!="boolean"?"Transferable must be a boolean value":"tags"in r&&(!Array.isArray(r.tags)||r.tags.some(t=>typeof t!="object"))?"Tags must be an array of objects":"src"in r&&typeof r.src!="string"?"Source must be a valid string":null}var $n=d(h(),1);var Nr="eXCtpVbcd_jZ0dmU2PZ8focaKxBGECBQ8wMib7sIVPo",X="lJovHqM9hwNjHV5JoY9NGWtt0WD-5D4gOqNL2VWW5jk";function Tt(r){return async(e,t)=>{if(!r.signer)throw new Error("Must provide a signer when initializing to create collections");let n=new Date().getTime().toString(),i=[{name:u.keys.contentType,value:"application/json"},{name:u.keys.creator,value:e.creator},{name:u.keys.ans110.title,value:K(e.title)},{name:u.keys.ans110.description,value:K(e.description)},{name:u.keys.ans110.type,value:u.values.document},{name:u.keys.dateCreated,value:n},{name:u.keys.name,value:K(e.title)},{name:"Action",value:"Add-Collection"}],o=null,a=null;try{o=e.banner?await Q(r,e.thumbnail):X,a=e.banner?await Q(r,e.banner):Nr,e.thumbnail&&i.push({name:u.keys.thumbnail,value:o}),e.banner&&i.push({name:u.keys.banner,value:a})}catch(p){console.error(p)}let c=await fetch(V(w.src.collection));if(!c.ok)throw new Error("Unable to fetch process src");let l=await c.text();l=l.replace(/'<NAME>'/g,Be(e.title)),l=l.replace(/'<DESCRIPTION>'/g,Be(e.description)),l=l.replace(/<CREATOR>/g,e.creator),l=l.replace(/<THUMBNAIL>/g,o||X),l=l.replace(/<BANNER>/g,a||X),l=l.replace(/<DATECREATED>/g,n),l=l.replace(/<LASTUPDATE>/g,n);try{let p=await Y(r,{spawnTags:i},t?y=>t(y):void 0);await r.ao.message({process:p,signer:r.signer,tags:[{name:"Action",value:"Eval"}],data:l});let f=[{name:"Action",value:"Add-Collection"},{name:"CollectionId",value:p},{name:"Name",value:K(e.title)},{name:"Creator",value:e.creator},{name:"DateCreated",value:n}];return a&&f.push({name:"Banner",value:a}),o&&f.push({name:"Thumbnail",value:o}),await r.ao.message({process:w.collectionsRegistry,signer:r.signer,tags:f}),await r.ao.message({process:p,signer:r.signer,tags:[{name:"Action",value:"Add-Collection-To-Profile"},{name:"ProfileProcess",value:e.creator}]}),p}catch(p){throw new Error(p.message??"Error creating collection")}}}function wt(r){return async e=>await _(r,{processId:e.creator,action:"Run-Action",tags:[{name:"ForwardTo",value:e.collectionId},{name:"ForwardAction",value:"Update-Assets"}],data:{Target:e.collectionId,Action:"Update-Assets",Input:JSON.stringify({AssetIds:e.assetIds,UpdateType:e.updateType})}})}function xt(r){return async e=>{let t=await L(r,{processId:e,action:"Info"});return{...{id:e,title:t.Name,description:t.Description,creator:t.Creator,dateCreated:t.DateCreated,thumbnail:t.Thumbnail??X,banner:t.Banner??X},assetIds:t.Assets}}}function At(r){return async e=>{let t=e.creator?"Get-Collections-By-User":"Get-Collections",n=await L(r,{processId:w.collectionsRegistry,action:t,tags:e.creator?[{name:"Creator",value:e.creator}]:null});return n&&n.Collections&&n.Collections.length?n.Collections.map(o=>({id:o.Id,title:o.Name.replace(/\[|\]/g,""),description:o.Description,creator:o.Creator,dateCreated:o.DateCreated,banner:o.Banner,thumbnail:o.Thumbnail})):null}}var qn=d(h(),1);function Et(r){let e=ae(r);return async(t,n)=>{let i=t.tags?t.tags:[];i.push({name:"Data-Source",value:t.parentId}),i.push({name:"Root-Source",value:t.rootId??t.parentId});let o={name:`Comment on ${t.parentId}`,description:`Comment on ${t.parentId}`,type:"comment",topics:["comment"],contentType:"text/plain",data:t.content,creator:t.creator,src:w.src.asset,tags:i};return e(o,n)}}function It(r){return async e=>{try{let t=await be(r,e),n=t?.tags?.find(o=>o.name==="Data-Source")?.value,i=t?.tags?.find(o=>o.name==="Root-Source")?.value;if(!n||!i)throw new Error("dataSource and rootSource must be present on a comment");return{...t,content:await bt(e),dataSource:n,rootSource:i}}catch(t){throw new Error(t.message??"Error getting comment")}}}function Bt(r){return async e=>{if(!e.parentId&&!e.rootId)throw new Error("Must provide either parentId or rootId");let t=[];e.parentId&&t.push({name:"Data-Source",values:[e.parentId??""]}),e.rootId&&t.push({name:"Root-Source",values:[e.rootId??""]});let n=await B({gateway:I.goldsky,ids:null,tags:t,owners:null,cursor:null}),i=[];n&&n.data.length&&(i=n.data.map(a=>se(a)));let o=[];for(let a of i){let c=a?.tags?.find(p=>p.name==="Data-Source")?.value,l=a?.tags?.find(p=>p.name==="Root-Source")?.value;if(!c||!l)throw new Error("dataSource and rootSource must be present on a comment");o.push({...a,content:await bt(a.id),dataSource:c,rootSource:l})}return o}}async function bt(r){try{return await(await fetch(V(r))).text()}catch(e){throw new Error(e.message??"Error getting comment data")}}var ti=d(h(),1);var jn=d(h(),1);function ce(r){return async(e,t)=>{try{let n=[{name:u.keys.bootloaderInit,value:w.src.zone}];return e.tags&&e.tags.length&&e.tags.forEach(o=>n.push(o)),await Y(r,{spawnTags:n},t?o=>t(o):void 0)}catch(n){throw new Error(n.message??"Error creating zone")}}}function ue(r){return async(e,t)=>{try{let n=Object.entries(e).map(([o,a])=>({key:o,value:a}));return await _(r,{processId:t,action:"Zone-Update",data:n})}catch(n){throw new Error(n)}}}function Ct(r){return async(e,t)=>{try{return await _(r,{processId:t,action:"Zone-Append",tags:[{name:"Path",value:e.path}],data:e.data})}catch(n){throw new Error(n)}}}function le(r){return async e=>{try{return await L(r,{processId:e,action:"Info"})}catch(t){throw new Error(t)}}}function Dt(r){let e=ce(r);return async(t,n)=>{let i=null,o=[{name:u.keys.dataProtocol,value:"Zone"},{name:u.keys.zoneType,value:"User"}],a=async c=>{let l=c.toLowerCase();if(t[l])try{let p=await Q(r,t[l]);o.push(A(c,p))}catch(p){n?n(`Failed to resolve ${c}: ${p.message}`):console.error(p)}};o.push(A("Username",t.username)),o.push(A("DisplayName",t.displayName)),o.push(A("Description",t.description)),await Promise.all([a("Thumbnail"),a("Banner")]);try{i=await e({tags:o},n)}catch(c){throw new Error(c.message??"Error creating profile")}return i}}function St(r){let e=ue(r);return async(t,n,i)=>{if(n){let o={Username:t.username,DisplayName:t.displayName,Description:t.description};if(t.thumbnail)try{o.Thumbnail=await Q(r,t.thumbnail)}catch(a){i&&i(`Failed to resolve thumbnail: ${a.message}`)}if(t.banner)try{o.Banner=await Q(r,t.banner)}catch(a){i&&i(`Failed to resolve banner: ${a.message}`)}try{return await e(o,n)}catch(a){throw new Error(a.message??"Error creating profile")}}else throw new Error("No profile provided")}}function Ce(r){let e=le(r);return async t=>{try{let n=await e(t);return{id:t,...P(n.Store??{}),assets:P(n.Assets??[])}}catch(n){throw new Error(n.message??"Error fetching profile")}}}function vt(r){let e=Ce(r);return async t=>{try{let n=await B({gateway:I.goldsky,tags:[{name:u.keys.dataProtocol,values:["Zone"]},{name:u.keys.zoneType,values:["User"]}],owners:[t]});return n?.data?.length>0?(n.data.sort((i,o)=>{let a=i.node.block?.timestamp??0;return(o.node.block?.timestamp??0)-a}),await e(n.data[0].node.id)):{id:null}}catch(n){throw new Error(n.message??"Error fetching profile")}}}globalThis.Buffer||(globalThis.Buffer=Ft.Buffer);function $r(r){return{createZone:ce(r),updateZone:ue(r),addToZone:Ct(r),getZone:le(r),createAtomicAsset:ae(r),getAtomicAsset:gt(r),getAtomicAssets:mt,createProfile:Dt(r),updateProfile:St(r),getProfileById:Ce(r),getProfileByWalletAddress:vt(r),createComment:Et(r),getComment:It(r),getComments:Bt(r),createCollection:Tt(r),updateCollectionAssets:wt(r),getCollection:xt(r),getCollections:At(r),resolveTransaction:dt(r),getGQLData:B,createProcess:yt(r),readProcess:lt(r),sendMessage:ut(r),mapFromProcessCase:P,mapToProcessCase:oe}}var ci={init:$r};export{ci as default};
27
+ }`;return r.queryKey&&(C=`${r.queryKey}: ${C}`),C}async function Ar(r){try{return await(await fetch(`https://${r.gateway}/graphql`,{method:"POST",headers:{"Content-Type":"application/json"},body:r.query})).json()}catch(e){throw e}}var Ir=A.goldsky,Br=100;async function at(r,e){let t=[{name:"Authority",value:x.mu}];e.tags&&e.tags.length>0&&e.tags.forEach(n=>t.push(n));try{let n=await r.ao.spawn({module:e.module,scheduler:e.scheduler,signer:r.signer,tags:t,data:e.data});return I(`Process ID: ${n}`),n}catch(n){throw new Error(n.message??"Error spawning process")}}function st(r){return async e=>await W(r,e)}async function W(r,e){try{let t=[{name:"Action",value:e.action}];e.tags&&t.push(...e.tags);let n=e.useRawData?e.data:JSON.stringify(e.data);return await r.ao.message({process:e.processId,signer:r.signer,tags:t,data:n})}catch(t){throw new Error(t)}}function ct(r){return async e=>await $(r,e)}async function $(r,e){try{let t=[{name:"Action",value:e.action}];e.tags&&t.push(...e.tags);let n;if(typeof e.data=="object")n=JSON.stringify(e.data||{});else if(typeof e.data=="string"){try{JSON.parse(e.data)}catch(o){throw console.error(o),new Error("Invalid JSON data")}n=e.data}let i=await r.ao.dryrun({process:e.processId,tags:t,data:n});if(i.Messages&&i.Messages.length){if(i.Messages[0].Data)return JSON.parse(i.Messages[0].Data);if(i.Messages[0].Tags)return i.Messages[0].Tags.reduce((o,a)=>(o[a.name]=a.value,o),{})}}catch(t){throw new Error(t.message??"Error dryrunning process")}}async function Cr(r,e){try{let{Messages:t}=await r.ao.result({message:e.messageId,process:e.processId});if(t&&t.length){let n={};return t.forEach(i=>{let o=oe(i.Tags,"Action")||e.action,a=null,c=i.Data;if(c)try{a=JSON.parse(c)}catch{a=c}let u=oe(i.Tags,"Status"),l=oe(i.Tags,"Message");n[o]={id:e.messageId,status:u,message:l,data:a}}),n}else return null}catch(t){console.error(t)}}async function ut(r,e){let t=null;if(e.evalSrc?t=e.evalSrc:e.evalTxId&&(t=await Dr(e.evalTxId)),t)try{let n=await W(r,{processId:e.processId,action:"Eval",data:t,tags:e.evalTags||null,useRawData:!0});return I(`Eval: ${n}`),await Cr(r,{processId:e.processId,messageId:n,action:"Eval"})}catch(n){throw new Error(n.message??"Error sending process eval")}return null}function lt(r){return async(e,t)=>{try{let n={module:e.module||x.module,scheduler:e.scheduler||x.scheduler};e.spawnData&&(n.data=e.spawnData),e.spawnTags&&(n.tags=e.spawnTags),t&&t("Spawning process...");let i=await at(r,n);if(e.evalTxId||e.evalSrc){t&&t("Retrieving process..."),await pt(i,t),t&&t("Process retrieved!"),t&&t("Sending eval...");try{await ut(r,{processId:i,evalTxId:e.evalTxId||null,evalSrc:e.evalSrc||null,evalTags:e.evalTags})&&t&&t("Eval complete")}catch(o){throw new Error(o.message??"Error creating process")}}return i}catch(n){throw new Error(n.message??"Error creating process")}}}async function Y(r,e,t){try{let n={module:e.module||x.module,scheduler:e.scheduler||x.scheduler};e.spawnData&&(n.data=e.spawnData),e.spawnTags&&(n.tags=e.spawnTags),t&&t("Spawning process...");let i=await at(r,n);if(t&&t("Retrieving process..."),await pt(i,t),e.evalTxId||e.evalSrc){t&&t("Process retrieved!"),t&&t("Sending eval...");try{await ut(r,{processId:i,evalTxId:e.evalTxId||null,evalSrc:e.evalSrc||null,evalTags:e.evalTags})&&t&&t("Eval complete")}catch(o){throw new Error(o.message??"Error creating process")}}return i}catch(n){throw new Error(n.message??"Error creating process")}}async function pt(r,e){let t=0;for(;t<Br;){await new Promise(i=>setTimeout(i,2e3));let n=await B({gateway:Ir,ids:[r]});if(n?.data?.length){let i=n.data[0].node.id;return I(`Process found: ${i} (Try ${t+1})`),i}else I(`Process not found: ${r} (Try ${t+1})`),t++}throw new Error("Process not found, please try again")}async function Dr(r){try{return await(await fetch(H(r))).text()}catch(e){throw new Error(e)}}var dn=f(h(),1);function yt(r){return async e=>{if(V(e))return e;if(!r.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await ft(r,{data:e})}catch(t){throw new Error(t.message??"Error resolving transaction")}}}async function O(r,e){if(V(e))return e;if(!r.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await ft(r,{data:e})}catch(t){throw new Error(t.message??"Error resolving transaction")}}async function ft(r,e){let t=null,n=null;try{typeof e.data=="string"&&e.data.startsWith("data:")&&(t=Buffer.from(rt(e.data),"base64"),n=tt(e.data))}catch(i){throw new Error(i)}if(t&&n){let i=nt(t);if(I(`Content upload size: ${i}`),i<Number(et.dispatchUploadSize)){let o=await r.arweave.createTransaction({data:t},"use_wallet");return o.addTag(d.keys.contentType,n),e.tags&&e.tags.length>0&&e.tags.forEach(c=>o.addTag(c.name,c.value)),(await global.window.arweaveWallet.dispatch(o)).id}else throw new Error("Data exceeds max upload limit")}else throw new Error("Error preparing transaction data")}var Kn=f(h(),1);var Cn=f(h(),1);function ae(r){return async(e,t)=>{let n=Fr(e);if(n)throw new Error(n);let i=Xe[e.contentType]?.serialize(e.data)??e.data,o=br(e);try{return await Y(r,{spawnTags:o,spawnData:i},t?c=>t(c):void 0)}catch(a){throw new Error(a.message??"Error creating asset")}}}async function Ce(r,e,t){try{let n=N(await $(r,{processId:e,action:"Info"}));if(t?.useGateway){let i=await B({gateway:A.goldsky,ids:[e],tags:null,owners:null,cursor:null});return{...i?.data?.[0]?se(i.data[0]):{},...n}}return{id:e,...n}}catch(n){throw new Error(n.message||"Error fetching atomic asset")}}function ht(r){return async(e,t)=>await Ce(r,e,t)}async function dt(r){try{let e=await B({gateway:A.arweave,ids:r??null,tags:null,owners:null,cursor:null});return e&&e.data.length?e.data.map(t=>se(t)):null}catch(e){throw new Error(e)}}function se(r){let e={id:r.node.id,owner:r.node.owner.address};for(let t of r.node.tags){let n=t.name,o=(n.startsWith(`${d.keys.bootloader}-`)?n.slice(`${d.keys.bootloader}-`.length):n).split("-").map((c,u)=>u===0?c.toLowerCase():c.charAt(0).toUpperCase()+c.slice(1).toLowerCase()).join(""),a;try{a=JSON.parse(t.value)}catch{a=t.value.toString()}e[o]=a}return e}function br(r){let e=[{name:d.keys.bootloaderInit,value:r.src??x.src.asset},{name:d.keys.creator,value:r.creator},{name:d.keys.assetType,value:r.assetType},{name:d.keys.contentType,value:r.contentType},{name:d.keys.implements,value:"ANS-110"},{name:d.keys.dateCreated,value:new Date().getTime().toString()},w("Name",r.name),w("Description",r.description),w("Topics",JSON.stringify(r.topics)),w("Ticker","ATOMIC"),w("Denomination",r.denomination?.toString()??"1"),w("TotalSupply",r.supply?.toString()??"1"),w("Transferable",r.transferable?.toString()??"true"),w("Creator",r.creator)];if(r.metadata)for(let t in r.metadata)e.push(w(j(t),r.metadata[t].toString()));return r.tags&&r.tags.forEach(t=>e.push(t)),e}function Fr(r){if(typeof r!="object"||r===null)return"The provided arguments are invalid or empty.";let e=["name","description","topics","creator","data","contentType","assetType"];for(let t of e)if(!(t in r))return`Missing field '${t}'`;return typeof r.name!="string"||r.name.trim()===""?"Name is required":typeof r.description!="string"?"The description must be a valid string":!Array.isArray(r.topics)||r.topics.length===0?"Topics are required":typeof r.creator!="string"||r.creator.trim()===""?"Creator is required":r.data===void 0||r.data===null?"Data field is required":typeof r.contentType!="string"||r.contentType.trim()===""?"Content type must be a non-empty string":typeof r.assetType!="string"||r.assetType.trim()===""?"Type must be a non-empty string":"supply"in r&&(typeof r.supply!="number"||r.supply<=0)?"Supply must be a positive number":"denomination"in r&&(typeof r.denomination!="number"||r.denomination<=0)?"Denomination must be a positive number":"transferable"in r&&typeof r.transferable!="boolean"?"Transferable must be a boolean value":"metadata"in r&&typeof r.metadata!="object"?"Metadata must be an object":"tags"in r&&(!Array.isArray(r.tags)||r.tags.some(t=>typeof t!="object"))?"Tags must be an array of objects":"src"in r&&typeof r.src!="string"?"Source must be a valid string":null}var Un=f(h(),1);var Pr="eXCtpVbcd_jZ0dmU2PZ8focaKxBGECBQ8wMib7sIVPo",X="lJovHqM9hwNjHV5JoY9NGWtt0WD-5D4gOqNL2VWW5jk";function gt(r){return async(e,t)=>{if(!r.signer)throw new Error("No signer provided");let n=new Date().getTime().toString(),i=[{name:d.keys.contentType,value:"application/json"},{name:d.keys.creator,value:e.creator},{name:d.keys.ans110.title,value:K(e.title)},{name:d.keys.ans110.description,value:K(e.description)},{name:d.keys.ans110.type,value:d.values.document},{name:d.keys.dateCreated,value:n},{name:d.keys.name,value:K(e.title)},{name:"Action",value:"Add-Collection"}],o=null,a=null;try{o=e.banner?await O(r,e.thumbnail):X,a=e.banner?await O(r,e.banner):Pr,e.thumbnail&&i.push({name:d.keys.thumbnail,value:o}),e.banner&&i.push({name:d.keys.banner,value:a})}catch(l){console.error(l)}let c=await fetch(H(x.src.collection));if(!c.ok)throw new Error("Unable to fetch process src");let u=await c.text();u=u.replace(/'<NAME>'/g,Be(e.title)),u=u.replace(/'<DESCRIPTION>'/g,Be(e.description)),u=u.replace(/<CREATOR>/g,e.creator),u=u.replace(/<THUMBNAIL>/g,o||X),u=u.replace(/<BANNER>/g,a||X),u=u.replace(/<DATECREATED>/g,n),u=u.replace(/<LASTUPDATE>/g,n);try{let l=await Y(r,{spawnTags:i},t?p=>t(p):void 0);I("Sending eval message to collection..."),t&&t("Sending eval message to collection..."),await r.ao.message({process:l,signer:r.signer,tags:[{name:"Action",value:"Eval"}],data:u});let y=[{name:"Action",value:"Add-Collection"},{name:"CollectionId",value:l},{name:"Name",value:K(e.title)},{name:"Creator",value:e.creator},{name:"DateCreated",value:n}];return a&&y.push({name:"Banner",value:a}),o&&y.push({name:"Thumbnail",value:o}),e.skipRegistry||(I("Sending collection to registry..."),t&&t("Sending collection to registry..."),await r.ao.message({process:x.collectionsRegistry,signer:r.signer,tags:y})),I("Sending profile request..."),t&&t("Sending profile request..."),await r.ao.message({process:l,signer:r.signer,tags:[{name:"Action",value:"Add-Collection-To-Profile"},{name:"ProfileProcess",value:e.creator}]}),l}catch(l){throw new Error(l.message??"Error creating collection")}}}function mt(r){return async e=>await W(r,{processId:e.creator,action:"Run-Action",tags:[{name:"ForwardTo",value:e.collectionId},{name:"ForwardAction",value:"Update-Assets"}],data:{Target:e.collectionId,Action:"Update-Assets",Input:JSON.stringify({AssetIds:e.assetIds,UpdateType:e.updateType})}})}function wt(r){return async e=>{let t=await $(r,{processId:e,action:"Info"});return{...{id:e,title:t.Name,description:t.Description,creator:t.Creator,dateCreated:t.DateCreated,thumbnail:t.Thumbnail??X,banner:t.Banner??X},assetIds:t.Assets}}}function Tt(r){return async e=>{let t=e.creator?"Get-Collections-By-User":"Get-Collections",n=await $(r,{processId:x.collectionsRegistry,action:t,tags:e.creator?[{name:"Creator",value:e.creator}]:null});return n&&n.Collections&&n.Collections.length?n.Collections.map(o=>({id:o.Id,title:o.Name.replace(/\[|\]/g,""),description:o.Description,creator:o.Creator,dateCreated:o.DateCreated,banner:o.Banner,thumbnail:o.Thumbnail})):null}}var kn=f(h(),1);function xt(r){let e=ae(r);return async(t,n)=>{let i=t.tags?t.tags:[];i.push({name:"Data-Source",value:t.parentId}),i.push({name:"Root-Source",value:t.rootId??t.parentId});let o={name:`Comment on ${t.parentId}`,description:`Comment on ${t.parentId}`,topics:["comment"],creator:t.creator,data:t.content,contentType:"text/plain",assetType:"comment",tags:i};return e(o,n)}}function Et(r){return async e=>{try{let t=await Ce(r,e,{useGateway:!0}),n=t?.dataSource,i=t?.rootSource;if(!n||!i)throw new Error("dataSource and rootSource must be present on a comment");return{content:await It(e),parentId:n,rootId:i}}catch(t){throw new Error(t.message??"Error getting comment")}}}function At(r){return async e=>{if(!e.parentId&&!e.rootId)throw new Error("Must provide either parentId or rootId");let t=[];e.parentId&&t.push({name:"Data-Source",values:[e.parentId??""]}),e.rootId&&t.push({name:"Root-Source",values:[e.rootId??""]});let n=await B({gateway:A.goldsky,ids:null,tags:t,owners:null,cursor:null}),i=[];n&&n.data.length&&(i=n.data.map(a=>se(a)));let o=[];for(let a of i){let c=a?.dataSource,u=a?.rootSource;if(!c||!u)throw new Error("dataSource and rootSource must be present on a comment");o.push({id:a.id,content:await It(a.id),parentId:c,rootId:u})}return o}}async function It(r){try{return await(await fetch(H(r))).text()}catch(e){throw new Error(e.message??"Error getting comment data")}}var Jn=f(h(),1);var Qn=f(h(),1);function ce(r){return async(e,t)=>{try{let n=[{name:d.keys.bootloaderInit,value:x.src.zone}];return e.tags&&e.tags.length&&e.tags.forEach(o=>n.push(o)),await Y(r,{spawnTags:n},t?o=>t(o):void 0)}catch(n){throw new Error(n.message??"Error creating zone")}}}function ue(r){return async(e,t)=>{try{let n=Object.entries(e).map(([o,a])=>({key:o,value:a}));return await W(r,{processId:t,action:"Zone-Update",data:n})}catch(n){throw new Error(n)}}}function Bt(r){return async(e,t)=>{try{return await W(r,{processId:t,action:"Zone-Append",tags:[{name:"Path",value:e.path}],data:e.data})}catch(n){throw new Error(n)}}}function le(r){return async e=>{try{let t=await $(r,{processId:e,action:"Info"});return N(t)}catch(t){throw new Error(t)}}}function Ct(r){let e=ce(r);return async(t,n)=>{let i=null,o=[{name:d.keys.dataProtocol,value:"Zone"},{name:d.keys.zoneType,value:"User"}],a=async c=>{let u=c.toLowerCase();if(t[u])try{let l=await O(r,t[u]);o.push(w(c,l))}catch(l){n?n(`Failed to resolve ${c}: ${l.message}`):console.error(l)}};o.push(w("Username",t.username)),o.push(w("DisplayName",t.displayName)),o.push(w("Description",t.description)),await Promise.all([a("Thumbnail"),a("Banner")]);try{i=await e({tags:o},n)}catch(c){throw new Error(c.message??"Error creating profile")}return i}}function Dt(r){let e=ue(r);return async(t,n,i)=>{if(n){let o={Username:t.username,DisplayName:t.displayName,Description:t.description};if(t.thumbnail)try{o.Thumbnail=await O(r,t.thumbnail)}catch(a){i&&i(`Failed to resolve thumbnail: ${a.message}`)}if(t.banner)try{o.Banner=await O(r,t.banner)}catch(a){i&&i(`Failed to resolve banner: ${a.message}`)}try{return await e(o,n)}catch(a){throw new Error(a.message??"Error creating profile")}}else throw new Error("No profile provided")}}function De(r){let e=le(r);return async t=>{try{let n=await e(t);return{id:t,...n.store,assets:n.assets}}catch(n){throw new Error(n.message??"Error fetching profile")}}}function St(r){let e=De(r);return async t=>{try{let n=await B({gateway:A.goldsky,tags:[{name:d.keys.dataProtocol,values:["Zone"]},{name:d.keys.zoneType,values:["User"]}],owners:[t]});return n?.data?.length>0?(n.data.sort((i,o)=>{let a=i.node.block?.timestamp??0;return(o.node.block?.timestamp??0)-a}),await e(n.data[0].node.id)):{id:null}}catch(n){throw new Error(n.message??"Error fetching profile")}}}globalThis.Buffer||(globalThis.Buffer=bt.Buffer);function Ur(r){return{createZone:ce(r),updateZone:ue(r),addToZone:Bt(r),getZone:le(r),createProfile:Ct(r),updateProfile:Dt(r),getProfileById:De(r),getProfileByWalletAddress:St(r),createAtomicAsset:ae(r),getAtomicAsset:ht(r),getAtomicAssets:dt,createComment:xt(r),getComment:Et(r),getComments:At(r),createCollection:gt(r),updateCollectionAssets:mt(r),getCollection:wt(r),getCollections:Tt(r),resolveTransaction:yt(r),getGQLData:B,createProcess:lt(r),readProcess:ct(r),sendMessage:st(r),mapFromProcessCase:N,mapToProcessCase:j}}var ii={init:Ur};export{ii as default};
28
28
  /*! Bundled license information:
29
29
 
30
30
  ieee754/index.js: