@permaweb/libs 0.0.20 → 0.0.21

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,4 +1,4 @@
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:"gyvfBebLlNJw0_bdq6NLL_BK_dqpgj9nRTYebyoOmKI",zone:"Dw8yZwAc8Sg1lo2juHJc79RANWS7AOxe1DJDGScqmIo",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 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=`
2
2
  transactions(
3
3
  ids: ${t},
4
4
  tags: ${o},
@@ -24,7 +24,7 @@ var kt=Object.create;var De=Object.defineProperty;var Ut=Object.getOwnPropertyDe
24
24
  ${f}
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.title)),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.creator&&o.push(A("Creator",e.creator)),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&&((o.Name||o.name)&&(n.title=o.Name||o.name),(o.Ticker||o.ticker)&&(i.ticker=o.Ticker||o.ticker),(o.Denomination||o.denomination)&&(i.denomination=o.Denomination||o.denomination),(o.Logo||o.logo)&&(n.thumbnail=o.Logo||o.logo),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.Creator||o.creator)&&(i.creator=o.Creator||o.creator),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,...P(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),title: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.title)||g(r.node.tags,u.keys.name)||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.title},{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=["title","description","type","topics","contentType","data"];for(let t of e)if(!(t in r))return`Missing field '${t}'.`;return typeof r.title!="string"||r.title.trim()===""?"Title 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?"The data field is required":"creator"in r&&typeof r.creator!="string"?"Creator must be a valid string":"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={title:`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&&(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};
28
28
  /*! Bundled license information:
29
29
 
30
30
  ieee754/index.js: