@junobuild/core-standalone 1.0.1 → 1.0.3

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.
@@ -1,18 +1,18 @@
1
- import{A as Ne,B as xe,C as er,D as ut,E as Re,F as rr,a as qr,b as Xo,c as De,d as Qo,e as Jr,f as y,g as S,h as lt,i as Hr,j as $r,k as Gr,l as Oe,m as Le,n as ae,o as Zo,p as tr,q as Nt,r as Ct,s as Io,t as we,u as G,z as vt}from"./chunk-EMF4NSTU.js";var Yr=qr(Ee=>{"use strict";Ee.byteLength=Lo;Ee.toByteArray=ei;Ee.fromByteArray=oi;var Y=[],j=[],Do=typeof Uint8Array<"u"?Uint8Array:Array,nr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(xt=0,Wr=nr.length;xt<Wr;++xt)Y[xt]=nr[xt],j[nr.charCodeAt(xt)]=xt;var xt,Wr;j[45]=62;j[95]=63;function zr(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Lo(t){var e=zr(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ti(t,e,r){return(e+r)*3/4-r}function ei(t){var e,r=zr(t),n=r[0],o=r[1],i=new Do(ti(t,n,o)),s=0,a=o>0?n-4:n,l;for(l=0;l<a;l+=4)e=j[t.charCodeAt(l)]<<18|j[t.charCodeAt(l+1)]<<12|j[t.charCodeAt(l+2)]<<6|j[t.charCodeAt(l+3)],i[s++]=e>>16&255,i[s++]=e>>8&255,i[s++]=e&255;return o===2&&(e=j[t.charCodeAt(l)]<<2|j[t.charCodeAt(l+1)]>>4,i[s++]=e&255),o===1&&(e=j[t.charCodeAt(l)]<<10|j[t.charCodeAt(l+1)]<<4|j[t.charCodeAt(l+2)]>>2,i[s++]=e>>8&255,i[s++]=e&255),i}function ri(t){return Y[t>>18&63]+Y[t>>12&63]+Y[t>>6&63]+Y[t&63]}function ni(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(ri(n));return o.join("")}function oi(t){for(var e,r=t.length,n=r%3,o=[],i=16383,s=0,a=r-n;s<a;s+=i)o.push(ni(t,s,s+i>a?a:s+i));return n===1?(e=t[r-1],o.push(Y[e>>2]+Y[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(Y[e>>10]+Y[e>>4&63]+Y[e<<2&63]+"=")),o.join("")}});var dn=qr(Bt=>{"use strict";var or=Yr(),Ut=Qo(),Xr=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Bt.Buffer=c;Bt.SlowBuffer=ui;Bt.INSPECT_MAX_BYTES=50;var Ae=2147483647;Bt.kMaxLength=Ae;c.TYPED_ARRAY_SUPPORT=ii();!c.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 ii(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}});Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function ot(t){if(t>Ae)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return cr(t)}return Dr(t,e,r)}c.poolSize=8192;function Dr(t,e,r){if(typeof t=="string")return ai(t,e);if(ArrayBuffer.isView(t))return ci(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return sr(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return c.from(n,e,r);let o=li(t);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return c.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}c.from=function(t,e,r){return Dr(t,e,r)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function Lr(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function si(t,e,r){return Lr(t),t<=0?ot(t):e!==void 0?typeof r=="string"?ot(t).fill(e,r):ot(t).fill(e):ot(t)}c.alloc=function(t,e,r){return si(t,e,r)};function cr(t){return Lr(t),ot(t<0?0:lr(t)|0)}c.allocUnsafe=function(t){return cr(t)};c.allocUnsafeSlow=function(t){return cr(t)};function ai(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=tn(t,e)|0,n=ot(r),o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}function ir(t){let e=t.length<0?0:lr(t.length)|0,r=ot(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function ci(t){if(X(t,Uint8Array)){let e=new Uint8Array(t);return sr(e.buffer,e.byteOffset,e.byteLength)}return ir(t)}function sr(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,c.prototype),n}function li(t){if(c.isBuffer(t)){let e=lr(t.length)|0,r=ot(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||dr(t.length)?ot(0):ir(t);if(t.type==="Buffer"&&Array.isArray(t.data))return ir(t.data)}function lr(t){if(t>=Ae)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ae.toString(16)+" bytes");return t|0}function ui(t){return+t!=t&&(t=0),c.alloc(+t)}c.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==c.prototype};c.compare=function(e,r){if(X(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),X(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),!c.isBuffer(e)||!c.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,o=r.length;for(let i=0,s=Math.min(n,o);i<s;++i)if(e[i]!==r[i]){n=e[i],o=r[i];break}return n<o?-1:o<n?1:0};c.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}};c.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return c.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let o=c.allocUnsafe(r),i=0;for(n=0;n<e.length;++n){let s=e[n];if(X(s,Uint8Array))i+s.length>o.length?(c.isBuffer(s)||(s=c.from(s)),s.copy(o,i)):Uint8Array.prototype.set.call(o,s,i);else if(c.isBuffer(s))s.copy(o,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return o};function tn(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return ar(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return un(t).length;default:if(o)return n?-1:ar(t).length;e=(""+e).toLowerCase(),o=!0}}c.byteLength=tn;function di(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return wi(this,e,r);case"utf8":case"utf-8":return rn(this,e,r);case"ascii":return Ti(this,e,r);case"latin1":case"binary":return Oi(this,e,r);case"base64":return yi(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ni(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}c.prototype._isBuffer=!0;function Rt(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}c.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 r=0;r<e;r+=2)Rt(this,r,r+1);return this};c.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 r=0;r<e;r+=4)Rt(this,r,r+3),Rt(this,r+1,r+2);return this};c.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 r=0;r<e;r+=8)Rt(this,r,r+7),Rt(this,r+1,r+6),Rt(this,r+2,r+5),Rt(this,r+3,r+4);return this};c.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?rn(this,0,e):di.apply(this,arguments)};c.prototype.toLocaleString=c.prototype.toString;c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:c.compare(this,e)===0};c.prototype.inspect=function(){let e="",r=Bt.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Xr&&(c.prototype[Xr]=c.prototype.inspect);c.prototype.compare=function(e,r,n,o,i){if(X(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),r<0||n>e.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&r>=n)return 0;if(o>=i)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,o>>>=0,i>>>=0,this===e)return 0;let s=i-o,a=n-r,l=Math.min(s,a),u=this.slice(o,i),p=e.slice(r,n);for(let d=0;d<l;++d)if(u[d]!==p[d]){s=u[d],a=p[d];break}return s<a?-1:a<s?1:0};function en(t,e,r,n,o){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,dr(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0)if(o)r=0;else return-1;if(typeof e=="string"&&(e=c.from(e,n)),c.isBuffer(e))return e.length===0?-1:Qr(t,e,r,n,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Qr(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function Qr(t,e,r,n,o){let i=1,s=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;i=2,s/=2,a/=2,r/=2}function l(p,d){return i===1?p[d]:p.readUInt16BE(d*i)}let u;if(o){let p=-1;for(u=r;u<s;u++)if(l(t,u)===l(e,p===-1?0:u-p)){if(p===-1&&(p=u),u-p+1===a)return p*i}else p!==-1&&(u-=u-p),p=-1}else for(r+a>s&&(r=s-a),u=r;u>=0;u--){let p=!0;for(let d=0;d<a;d++)if(l(t,u+d)!==l(e,d)){p=!1;break}if(p)return u}return-1}c.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};c.prototype.indexOf=function(e,r,n){return en(this,e,r,n,!0)};c.prototype.lastIndexOf=function(e,r,n){return en(this,e,r,n,!1)};function pi(t,e,r,n){r=Number(r)||0;let o=t.length-r;n?(n=Number(n),n>o&&(n=o)):n=o;let i=e.length;n>i/2&&(n=i/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(dr(a))return s;t[r+s]=a}return s}function _i(t,e,r,n){return be(ar(e,t.length-r),t,r,n)}function mi(t,e,r,n){return be(Ai(e),t,r,n)}function fi(t,e,r,n){return be(un(e),t,r,n)}function hi(t,e,r,n){return be(bi(e,t.length-r),t,r,n)}c.prototype.write=function(e,r,n,o){if(r===void 0)o="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")o=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-r;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let s=!1;for(;;)switch(o){case"hex":return pi(this,e,r,n);case"utf8":case"utf-8":return _i(this,e,r,n);case"ascii":case"latin1":case"binary":return mi(this,e,r,n);case"base64":return fi(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hi(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),s=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function yi(t,e,r){return e===0&&r===t.length?or.fromByteArray(t):or.fromByteArray(t.slice(e,r))}function rn(t,e,r){r=Math.min(t.length,r);let n=[],o=e;for(;o<r;){let i=t[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a<=r){let l,u,p,d;switch(a){case 1:i<128&&(s=i);break;case 2:l=t[o+1],(l&192)===128&&(d=(i&31)<<6|l&63,d>127&&(s=d));break;case 3:l=t[o+1],u=t[o+2],(l&192)===128&&(u&192)===128&&(d=(i&15)<<12|(l&63)<<6|u&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:l=t[o+1],u=t[o+2],p=t[o+3],(l&192)===128&&(u&192)===128&&(p&192)===128&&(d=(i&15)<<18|(l&63)<<12|(u&63)<<6|p&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),o+=a}return gi(n)}var Zr=4096;function gi(t){let e=t.length;if(e<=Zr)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Zr));return r}function Ti(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]&127);return n}function Oi(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function wi(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let o="";for(let i=e;i<r;++i)o+=Si[t[i]];return o}function Ni(t,e,r){let n=t.slice(e,r),o="";for(let i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}c.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let o=this.subarray(e,r);return Object.setPrototypeOf(o,c.prototype),o};function E(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||E(e,r,this.length);let o=this[e],i=1,s=0;for(;++s<r&&(i*=256);)o+=this[e+s]*i;return o};c.prototype.readUintBE=c.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||E(e,r,this.length);let o=this[e+--r],i=1;for(;r>0&&(i*=256);)o+=this[e+--r]*i;return o};c.prototype.readUint8=c.prototype.readUInt8=function(e,r){return e=e>>>0,r||E(e,1,this.length),this[e]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||E(e,2,this.length),this[e]|this[e+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||E(e,2,this.length),this[e]<<8|this[e+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||E(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||E(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};c.prototype.readBigUInt64LE=dt(function(e){e=e>>>0,kt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ce(e,this.length-8);let o=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(o)+(BigInt(i)<<BigInt(32))});c.prototype.readBigUInt64BE=dt(function(e){e=e>>>0,kt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ce(e,this.length-8);let o=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(o)<<BigInt(32))+BigInt(i)});c.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||E(e,r,this.length);let o=this[e],i=1,s=0;for(;++s<r&&(i*=256);)o+=this[e+s]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*r)),o};c.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||E(e,r,this.length);let o=r,i=1,s=this[e+--o];for(;o>0&&(i*=256);)s+=this[e+--o]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*r)),s};c.prototype.readInt8=function(e,r){return e=e>>>0,r||E(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};c.prototype.readInt16LE=function(e,r){e=e>>>0,r||E(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function(e,r){e=e>>>0,r||E(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function(e,r){return e=e>>>0,r||E(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};c.prototype.readInt32BE=function(e,r){return e=e>>>0,r||E(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};c.prototype.readBigInt64LE=dt(function(e){e=e>>>0,kt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ce(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(o)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});c.prototype.readBigInt64BE=dt(function(e){e=e>>>0,kt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ce(e,this.length-8);let o=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});c.prototype.readFloatLE=function(e,r){return e=e>>>0,r||E(e,4,this.length),Ut.read(this,e,!0,23,4)};c.prototype.readFloatBE=function(e,r){return e=e>>>0,r||E(e,4,this.length),Ut.read(this,e,!1,23,4)};c.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||E(e,8,this.length),Ut.read(this,e,!0,52,8)};c.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||E(e,8,this.length),Ut.read(this,e,!1,52,8)};function F(t,e,r,n,o,i){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,r,n,o){if(e=+e,r=r>>>0,n=n>>>0,!o){let a=Math.pow(2,8*n)-1;F(this,e,r,n,a,0)}let i=1,s=0;for(this[r]=e&255;++s<n&&(i*=256);)this[r+s]=e/i&255;return r+n};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,r,n,o){if(e=+e,r=r>>>0,n=n>>>0,!o){let a=Math.pow(2,8*n)-1;F(this,e,r,n,a,0)}let i=n-1,s=1;for(this[r+i]=e&255;--i>=0&&(s*=256);)this[r+i]=e/s&255;return r+n};c.prototype.writeUint8=c.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,1,255,0),this[r]=e&255,r+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function nn(t,e,r,n,o){ln(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i=i>>8,t[r++]=i,i=i>>8,t[r++]=i,i=i>>8,t[r++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,r}function on(t,e,r,n,o){ln(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i=i>>8,t[r+6]=i,i=i>>8,t[r+5]=i,i=i>>8,t[r+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s=s>>8,t[r+2]=s,s=s>>8,t[r+1]=s,s=s>>8,t[r]=s,r+8}c.prototype.writeBigUInt64LE=dt(function(e,r=0){return nn(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=dt(function(e,r=0){return on(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(e,r,n,o){if(e=+e,r=r>>>0,!o){let l=Math.pow(2,8*n-1);F(this,e,r,n,l-1,-l)}let i=0,s=1,a=0;for(this[r]=e&255;++i<n&&(s*=256);)e<0&&a===0&&this[r+i-1]!==0&&(a=1),this[r+i]=(e/s>>0)-a&255;return r+n};c.prototype.writeIntBE=function(e,r,n,o){if(e=+e,r=r>>>0,!o){let l=Math.pow(2,8*n-1);F(this,e,r,n,l-1,-l)}let i=n-1,s=1,a=0;for(this[r+i]=e&255;--i>=0&&(s*=256);)e<0&&a===0&&this[r+i+1]!==0&&(a=1),this[r+i]=(e/s>>0)-a&255;return r+n};c.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};c.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};c.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};c.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};c.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};c.prototype.writeBigInt64LE=dt(function(e,r=0){return nn(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=dt(function(e,r=0){return on(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function sn(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function an(t,e,r,n,o){return e=+e,r=r>>>0,o||sn(t,e,r,4,34028234663852886e22,-34028234663852886e22),Ut.write(t,e,r,n,23,4),r+4}c.prototype.writeFloatLE=function(e,r,n){return an(this,e,r,!0,n)};c.prototype.writeFloatBE=function(e,r,n){return an(this,e,r,!1,n)};function cn(t,e,r,n,o){return e=+e,r=r>>>0,o||sn(t,e,r,8,17976931348623157e292,-17976931348623157e292),Ut.write(t,e,r,n,52,8),r+8}c.prototype.writeDoubleLE=function(e,r,n){return cn(this,e,r,!0,n)};c.prototype.writeDoubleBE=function(e,r,n){return cn(this,e,r,!1,n)};c.prototype.copy=function(e,r,n,o){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),r>=e.length&&(r=e.length),r||(r=0),o>0&&o<n&&(o=n),o===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-r<o-n&&(o=e.length-r+n);let i=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),r),i};c.prototype.fill=function(e,r,n,o){if(typeof e=="string"){if(typeof r=="string"?(o=r,r=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!c.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let s=e.charCodeAt(0);(o==="utf8"&&s<128||o==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let i;if(typeof e=="number")for(i=r;i<n;++i)this[i]=e;else{let s=c.isBuffer(e)?e:c.from(e,o),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<n-r;++i)this[i+r]=s[i%a]}return this};var Ft={};function ur(t,e,r){Ft[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}ur("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ur("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);ur("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=Ir(String(r)):typeof r=="bigint"&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=Ir(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n},RangeError);function Ir(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function xi(t,e,r){kt(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&ce(e,t.length-(r+1))}function ln(t,e,r,n,o,i){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw i>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(i+1)*8}${s}`:a=`>= -(2${s} ** ${(i+1)*8-1}${s}) and < 2 ** ${(i+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new Ft.ERR_OUT_OF_RANGE("value",a,t)}xi(n,o,i)}function kt(t,e){if(typeof t!="number")throw new Ft.ERR_INVALID_ARG_TYPE(e,"number",t)}function ce(t,e,r){throw Math.floor(t)!==t?(kt(t,r),new Ft.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Ft.ERR_BUFFER_OUT_OF_BOUNDS:new Ft.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Ri=/[^+/0-9A-Za-z-_]/g;function Ei(t){if(t=t.split("=")[0],t=t.trim().replace(Ri,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function ar(t,e){e=e||1/0;let r,n=t.length,o=null,i=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return i}function Ai(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function bi(t,e){let r,n,o,i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}function un(t){return or.toByteArray(Ei(t))}function be(t,e,r,n){let o;for(o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function X(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function dr(t){return t!==t}var Si=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function dt(t){return typeof BigInt>"u"?Pi:t}function Pi(){throw new Error("BigInt not supported")}});var Tn=De(dn());var Pe={};Xo(Pe,{backoff:()=>fn,chain:()=>hn,conditionalDelay:()=>_n,defaultStrategy:()=>Se,maxAttempts:()=>vi,once:()=>pn,throttle:()=>Fi,timeout:()=>mn});var Ci=300*1e3;function Se(){return hn(_n(pn(),1e3),fn(1e3,1.2),mn(Ci))}function pn(){let t=!0;return async()=>t?(t=!1,!0):!1}function _n(t,e){return async(r,n,o)=>{if(await t(r,n,o))return new Promise(i=>setTimeout(i,e))}}function vi(t){let e=t;return async(r,n,o)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
2
- Request ID: ${S(n)}
1
+ import{A as Ae,B as be,C as ir,D as ct,E as Se,F as sr,a as Gr,b as Xo,c as rr,d as Qo,e as Wr,f as y,g as C,h as at,i as zr,j as Yr,k as Xr,l as Re,m as nr,n as de,o as Zo,p as or,q as xt,r as vt,s as Io,t as Ee,u as z,z as Ft}from"./chunk-EMF4NSTU.js";var Ir=Gr(Pe=>{"use strict";Pe.byteLength=Lo;Pe.toByteArray=ei;Pe.fromByteArray=oi;var Q=[],K=[],Do=typeof Uint8Array<"u"?Uint8Array:Array,ar="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Rt=0,Qr=ar.length;Rt<Qr;++Rt)Q[Rt]=ar[Rt],K[ar.charCodeAt(Rt)]=Rt;var Rt,Qr;K[45]=62;K[95]=63;function Zr(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Lo(t){var e=Zr(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ti(t,e,r){return(e+r)*3/4-r}function ei(t){var e,r=Zr(t),n=r[0],o=r[1],i=new Do(ti(t,n,o)),s=0,a=o>0?n-4:n,l;for(l=0;l<a;l+=4)e=K[t.charCodeAt(l)]<<18|K[t.charCodeAt(l+1)]<<12|K[t.charCodeAt(l+2)]<<6|K[t.charCodeAt(l+3)],i[s++]=e>>16&255,i[s++]=e>>8&255,i[s++]=e&255;return o===2&&(e=K[t.charCodeAt(l)]<<2|K[t.charCodeAt(l+1)]>>4,i[s++]=e&255),o===1&&(e=K[t.charCodeAt(l)]<<10|K[t.charCodeAt(l+1)]<<4|K[t.charCodeAt(l+2)]>>2,i[s++]=e>>8&255,i[s++]=e&255),i}function ri(t){return Q[t>>18&63]+Q[t>>12&63]+Q[t>>6&63]+Q[t&63]}function ni(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(ri(n));return o.join("")}function oi(t){for(var e,r=t.length,n=r%3,o=[],i=16383,s=0,a=r-n;s<a;s+=i)o.push(ni(t,s,s+i>a?a:s+i));return n===1?(e=t[r-1],o.push(Q[e>>2]+Q[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(Q[e>>10]+Q[e>>4&63]+Q[e<<2&63]+"=")),o.join("")}});var fn=Gr(Vt=>{"use strict";var cr=Ir(),kt=Qo(),Dr=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Vt.Buffer=c;Vt.SlowBuffer=ui;Vt.INSPECT_MAX_BYTES=50;var Ce=2147483647;Vt.kMaxLength=Ce;c.TYPED_ARRAY_SUPPORT=ii();!c.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 ii(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}});Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function it(t){if(t>Ce)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return pr(t)}return rn(t,e,r)}c.poolSize=8192;function rn(t,e,r){if(typeof t=="string")return ai(t,e);if(ArrayBuffer.isView(t))return ci(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return ur(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return c.from(n,e,r);let o=li(t);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return c.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}c.from=function(t,e,r){return rn(t,e,r)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function nn(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function si(t,e,r){return nn(t),t<=0?it(t):e!==void 0?typeof r=="string"?it(t).fill(e,r):it(t).fill(e):it(t)}c.alloc=function(t,e,r){return si(t,e,r)};function pr(t){return nn(t),it(t<0?0:_r(t)|0)}c.allocUnsafe=function(t){return pr(t)};c.allocUnsafeSlow=function(t){return pr(t)};function ai(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=on(t,e)|0,n=it(r),o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}function lr(t){let e=t.length<0?0:_r(t.length)|0,r=it(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function ci(t){if(Z(t,Uint8Array)){let e=new Uint8Array(t);return ur(e.buffer,e.byteOffset,e.byteLength)}return lr(t)}function ur(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,c.prototype),n}function li(t){if(c.isBuffer(t)){let e=_r(t.length)|0,r=it(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||fr(t.length)?it(0):lr(t);if(t.type==="Buffer"&&Array.isArray(t.data))return lr(t.data)}function _r(t){if(t>=Ce)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ce.toString(16)+" bytes");return t|0}function ui(t){return+t!=t&&(t=0),c.alloc(+t)}c.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==c.prototype};c.compare=function(e,r){if(Z(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),Z(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),!c.isBuffer(e)||!c.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,o=r.length;for(let i=0,s=Math.min(n,o);i<s;++i)if(e[i]!==r[i]){n=e[i],o=r[i];break}return n<o?-1:o<n?1:0};c.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}};c.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return c.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let o=c.allocUnsafe(r),i=0;for(n=0;n<e.length;++n){let s=e[n];if(Z(s,Uint8Array))i+s.length>o.length?(c.isBuffer(s)||(s=c.from(s)),s.copy(o,i)):Uint8Array.prototype.set.call(o,s,i);else if(c.isBuffer(s))s.copy(o,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return o};function on(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return dr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return mn(t).length;default:if(o)return n?-1:dr(t).length;e=(""+e).toLowerCase(),o=!0}}c.byteLength=on;function di(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Ni(this,e,r);case"utf8":case"utf-8":return an(this,e,r);case"ascii":return Oi(this,e,r);case"latin1":case"binary":return Ti(this,e,r);case"base64":return yi(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return wi(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}c.prototype._isBuffer=!0;function Et(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}c.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 r=0;r<e;r+=2)Et(this,r,r+1);return this};c.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 r=0;r<e;r+=4)Et(this,r,r+3),Et(this,r+1,r+2);return this};c.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 r=0;r<e;r+=8)Et(this,r,r+7),Et(this,r+1,r+6),Et(this,r+2,r+5),Et(this,r+3,r+4);return this};c.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?an(this,0,e):di.apply(this,arguments)};c.prototype.toLocaleString=c.prototype.toString;c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:c.compare(this,e)===0};c.prototype.inspect=function(){let e="",r=Vt.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Dr&&(c.prototype[Dr]=c.prototype.inspect);c.prototype.compare=function(e,r,n,o,i){if(Z(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),r<0||n>e.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&r>=n)return 0;if(o>=i)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,o>>>=0,i>>>=0,this===e)return 0;let s=i-o,a=n-r,l=Math.min(s,a),u=this.slice(o,i),p=e.slice(r,n);for(let d=0;d<l;++d)if(u[d]!==p[d]){s=u[d],a=p[d];break}return s<a?-1:a<s?1:0};function sn(t,e,r,n,o){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,fr(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0)if(o)r=0;else return-1;if(typeof e=="string"&&(e=c.from(e,n)),c.isBuffer(e))return e.length===0?-1:Lr(t,e,r,n,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Lr(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function Lr(t,e,r,n,o){let i=1,s=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;i=2,s/=2,a/=2,r/=2}function l(p,d){return i===1?p[d]:p.readUInt16BE(d*i)}let u;if(o){let p=-1;for(u=r;u<s;u++)if(l(t,u)===l(e,p===-1?0:u-p)){if(p===-1&&(p=u),u-p+1===a)return p*i}else p!==-1&&(u-=u-p),p=-1}else for(r+a>s&&(r=s-a),u=r;u>=0;u--){let p=!0;for(let d=0;d<a;d++)if(l(t,u+d)!==l(e,d)){p=!1;break}if(p)return u}return-1}c.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};c.prototype.indexOf=function(e,r,n){return sn(this,e,r,n,!0)};c.prototype.lastIndexOf=function(e,r,n){return sn(this,e,r,n,!1)};function pi(t,e,r,n){r=Number(r)||0;let o=t.length-r;n?(n=Number(n),n>o&&(n=o)):n=o;let i=e.length;n>i/2&&(n=i/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(fr(a))return s;t[r+s]=a}return s}function _i(t,e,r,n){return ve(dr(e,t.length-r),t,r,n)}function mi(t,e,r,n){return ve(Ai(e),t,r,n)}function fi(t,e,r,n){return ve(mn(e),t,r,n)}function hi(t,e,r,n){return ve(bi(e,t.length-r),t,r,n)}c.prototype.write=function(e,r,n,o){if(r===void 0)o="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")o=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-r;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let s=!1;for(;;)switch(o){case"hex":return pi(this,e,r,n);case"utf8":case"utf-8":return _i(this,e,r,n);case"ascii":case"latin1":case"binary":return mi(this,e,r,n);case"base64":return fi(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hi(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),s=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function yi(t,e,r){return e===0&&r===t.length?cr.fromByteArray(t):cr.fromByteArray(t.slice(e,r))}function an(t,e,r){r=Math.min(t.length,r);let n=[],o=e;for(;o<r;){let i=t[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a<=r){let l,u,p,d;switch(a){case 1:i<128&&(s=i);break;case 2:l=t[o+1],(l&192)===128&&(d=(i&31)<<6|l&63,d>127&&(s=d));break;case 3:l=t[o+1],u=t[o+2],(l&192)===128&&(u&192)===128&&(d=(i&15)<<12|(l&63)<<6|u&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:l=t[o+1],u=t[o+2],p=t[o+3],(l&192)===128&&(u&192)===128&&(p&192)===128&&(d=(i&15)<<18|(l&63)<<12|(u&63)<<6|p&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),o+=a}return gi(n)}var tn=4096;function gi(t){let e=t.length;if(e<=tn)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=tn));return r}function Oi(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]&127);return n}function Ti(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function Ni(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let o="";for(let i=e;i<r;++i)o+=Si[t[i]];return o}function wi(t,e,r){let n=t.slice(e,r),o="";for(let i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}c.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let o=this.subarray(e,r);return Object.setPrototypeOf(o,c.prototype),o};function b(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||b(e,r,this.length);let o=this[e],i=1,s=0;for(;++s<r&&(i*=256);)o+=this[e+s]*i;return o};c.prototype.readUintBE=c.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||b(e,r,this.length);let o=this[e+--r],i=1;for(;r>0&&(i*=256);)o+=this[e+--r]*i;return o};c.prototype.readUint8=c.prototype.readUInt8=function(e,r){return e=e>>>0,r||b(e,1,this.length),this[e]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||b(e,2,this.length),this[e]|this[e+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||b(e,2,this.length),this[e]<<8|this[e+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||b(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||b(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};c.prototype.readBigUInt64LE=lt(function(e){e=e>>>0,Bt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&pe(e,this.length-8);let o=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(o)+(BigInt(i)<<BigInt(32))});c.prototype.readBigUInt64BE=lt(function(e){e=e>>>0,Bt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&pe(e,this.length-8);let o=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(o)<<BigInt(32))+BigInt(i)});c.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||b(e,r,this.length);let o=this[e],i=1,s=0;for(;++s<r&&(i*=256);)o+=this[e+s]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*r)),o};c.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||b(e,r,this.length);let o=r,i=1,s=this[e+--o];for(;o>0&&(i*=256);)s+=this[e+--o]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*r)),s};c.prototype.readInt8=function(e,r){return e=e>>>0,r||b(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};c.prototype.readInt16LE=function(e,r){e=e>>>0,r||b(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function(e,r){e=e>>>0,r||b(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function(e,r){return e=e>>>0,r||b(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};c.prototype.readInt32BE=function(e,r){return e=e>>>0,r||b(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};c.prototype.readBigInt64LE=lt(function(e){e=e>>>0,Bt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&pe(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(o)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});c.prototype.readBigInt64BE=lt(function(e){e=e>>>0,Bt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&pe(e,this.length-8);let o=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});c.prototype.readFloatLE=function(e,r){return e=e>>>0,r||b(e,4,this.length),kt.read(this,e,!0,23,4)};c.prototype.readFloatBE=function(e,r){return e=e>>>0,r||b(e,4,this.length),kt.read(this,e,!1,23,4)};c.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||b(e,8,this.length),kt.read(this,e,!0,52,8)};c.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||b(e,8,this.length),kt.read(this,e,!1,52,8)};function U(t,e,r,n,o,i){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,r,n,o){if(e=+e,r=r>>>0,n=n>>>0,!o){let a=Math.pow(2,8*n)-1;U(this,e,r,n,a,0)}let i=1,s=0;for(this[r]=e&255;++s<n&&(i*=256);)this[r+s]=e/i&255;return r+n};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,r,n,o){if(e=+e,r=r>>>0,n=n>>>0,!o){let a=Math.pow(2,8*n)-1;U(this,e,r,n,a,0)}let i=n-1,s=1;for(this[r+i]=e&255;--i>=0&&(s*=256);)this[r+i]=e/s&255;return r+n};c.prototype.writeUint8=c.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||U(this,e,r,1,255,0),this[r]=e&255,r+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||U(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||U(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||U(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||U(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function cn(t,e,r,n,o){_n(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i=i>>8,t[r++]=i,i=i>>8,t[r++]=i,i=i>>8,t[r++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,r}function ln(t,e,r,n,o){_n(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i=i>>8,t[r+6]=i,i=i>>8,t[r+5]=i,i=i>>8,t[r+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s=s>>8,t[r+2]=s,s=s>>8,t[r+1]=s,s=s>>8,t[r]=s,r+8}c.prototype.writeBigUInt64LE=lt(function(e,r=0){return cn(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=lt(function(e,r=0){return ln(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(e,r,n,o){if(e=+e,r=r>>>0,!o){let l=Math.pow(2,8*n-1);U(this,e,r,n,l-1,-l)}let i=0,s=1,a=0;for(this[r]=e&255;++i<n&&(s*=256);)e<0&&a===0&&this[r+i-1]!==0&&(a=1),this[r+i]=(e/s>>0)-a&255;return r+n};c.prototype.writeIntBE=function(e,r,n,o){if(e=+e,r=r>>>0,!o){let l=Math.pow(2,8*n-1);U(this,e,r,n,l-1,-l)}let i=n-1,s=1,a=0;for(this[r+i]=e&255;--i>=0&&(s*=256);)e<0&&a===0&&this[r+i+1]!==0&&(a=1),this[r+i]=(e/s>>0)-a&255;return r+n};c.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||U(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};c.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||U(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};c.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||U(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};c.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||U(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};c.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||U(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};c.prototype.writeBigInt64LE=lt(function(e,r=0){return cn(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=lt(function(e,r=0){return ln(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function un(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function dn(t,e,r,n,o){return e=+e,r=r>>>0,o||un(t,e,r,4,34028234663852886e22,-34028234663852886e22),kt.write(t,e,r,n,23,4),r+4}c.prototype.writeFloatLE=function(e,r,n){return dn(this,e,r,!0,n)};c.prototype.writeFloatBE=function(e,r,n){return dn(this,e,r,!1,n)};function pn(t,e,r,n,o){return e=+e,r=r>>>0,o||un(t,e,r,8,17976931348623157e292,-17976931348623157e292),kt.write(t,e,r,n,52,8),r+8}c.prototype.writeDoubleLE=function(e,r,n){return pn(this,e,r,!0,n)};c.prototype.writeDoubleBE=function(e,r,n){return pn(this,e,r,!1,n)};c.prototype.copy=function(e,r,n,o){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),r>=e.length&&(r=e.length),r||(r=0),o>0&&o<n&&(o=n),o===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-r<o-n&&(o=e.length-r+n);let i=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),r),i};c.prototype.fill=function(e,r,n,o){if(typeof e=="string"){if(typeof r=="string"?(o=r,r=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!c.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let s=e.charCodeAt(0);(o==="utf8"&&s<128||o==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let i;if(typeof e=="number")for(i=r;i<n;++i)this[i]=e;else{let s=c.isBuffer(e)?e:c.from(e,o),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<n-r;++i)this[i+r]=s[i%a]}return this};var Ut={};function mr(t,e,r){Ut[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}mr("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);mr("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);mr("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=en(String(r)):typeof r=="bigint"&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=en(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n},RangeError);function en(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function xi(t,e,r){Bt(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&pe(e,t.length-(r+1))}function _n(t,e,r,n,o,i){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw i>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(i+1)*8}${s}`:a=`>= -(2${s} ** ${(i+1)*8-1}${s}) and < 2 ** ${(i+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new Ut.ERR_OUT_OF_RANGE("value",a,t)}xi(n,o,i)}function Bt(t,e){if(typeof t!="number")throw new Ut.ERR_INVALID_ARG_TYPE(e,"number",t)}function pe(t,e,r){throw Math.floor(t)!==t?(Bt(t,r),new Ut.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Ut.ERR_BUFFER_OUT_OF_BOUNDS:new Ut.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Ri=/[^+/0-9A-Za-z-_]/g;function Ei(t){if(t=t.split("=")[0],t=t.trim().replace(Ri,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function dr(t,e){e=e||1/0;let r,n=t.length,o=null,i=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return i}function Ai(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function bi(t,e){let r,n,o,i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}function mn(t){return cr.toByteArray(Ei(t))}function ve(t,e,r,n){let o;for(o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function Z(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function fr(t){return t!==t}var Si=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function lt(t){return typeof BigInt>"u"?Pi:t}function Pi(){throw new Error("BigInt not supported")}});var xn=rr(fn());var Ue={};Xo(Ue,{backoff:()=>On,chain:()=>Tn,conditionalDelay:()=>yn,defaultStrategy:()=>Fe,maxAttempts:()=>vi,once:()=>hn,throttle:()=>Fi,timeout:()=>gn});var Ci=300*1e3;function Fe(){return Tn(yn(hn(),1e3),On(1e3,1.2),gn(Ci))}function hn(){let t=!0;return async()=>t?(t=!1,!0):!1}function yn(t,e){return async(r,n,o)=>{if(await t(r,n,o))return new Promise(i=>setTimeout(i,e))}}function vi(t){let e=t;return async(r,n,o)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
2
+ Request ID: ${C(n)}
3
3
  Request status: ${o}
4
- `)}}function Fi(t){return()=>new Promise(e=>setTimeout(e,t))}function mn(t){let e=Date.now()+t;return async(r,n,o)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
5
- Request ID: ${S(n)}
4
+ `)}}function Fi(t){return()=>new Promise(e=>setTimeout(e,t))}function gn(t){let e=Date.now()+t;return async(r,n,o)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
5
+ Request ID: ${C(n)}
6
6
  Request status: ${o}
7
- `)}}function fn(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function hn(...t){return async(e,r,n)=>{for(let o of t)await o(e,r,n)}}async function pr(t,e,r,n=Se(),o,i){var s;let a=[new TextEncoder().encode("request_status"),r],l=o??await((s=t.createReadStateRequest)===null||s===void 0?void 0:s.call(t,{paths:[a]})),u=await t.readState(e,{paths:[a]},void 0,l);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let p=await we.create({certificate:u.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:i}),d=G(p.lookup([...a,new TextEncoder().encode("status")])),m;switch(typeof d>"u"?m=ut.Unknown:m=new TextDecoder().decode(d),m){case ut.Replied:return{reply:G(p.lookup([...a,"reply"])),certificate:p};case ut.Received:case ut.Unknown:case ut.Processing:return await n(e,r,m),pr(t,e,r,n,l,i);case ut.Rejected:{let f=new Uint8Array(G(p.lookup([...a,"reject_code"])))[0],w=new TextDecoder().decode(G(p.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
8
- Request ID: ${S(r)}
7
+ `)}}function On(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function Tn(...t){return async(e,r,n)=>{for(let o of t)await o(e,r,n)}}async function hr(t,e,r,n=Fe(),o,i){var s;let a=[new TextEncoder().encode("request_status"),r],l=o??await((s=t.createReadStateRequest)===null||s===void 0?void 0:s.call(t,{paths:[a]})),u=await t.readState(e,{paths:[a]},void 0,l);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let p=await Ee.create({certificate:u.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:i}),d=z(p.lookup([...a,new TextEncoder().encode("status")])),m;switch(typeof d>"u"?m=ct.Unknown:m=new TextDecoder().decode(d),m){case ct.Replied:return{reply:z(p.lookup([...a,"reply"])),certificate:p};case ct.Received:case ct.Unknown:case ct.Processing:return await n(e,r,m),hr(t,e,r,n,l,i);case ct.Rejected:{let f=new Uint8Array(z(p.lookup([...a,"reject_code"])))[0],N=new TextDecoder().decode(z(p.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
8
+ Request ID: ${C(r)}
9
9
  Reject code: ${f}
10
- Reject text: ${w}
11
- `)}case ut.Done:throw new Error(`Call was marked as done but we never saw the reply:
12
- Request ID: ${S(r)}
13
- `)}throw new Error("unreachable")}var yn=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),o=t.Nat64,i=o,s=t.Nat32,a=t.Record({start_height:s,end_height:t.Opt(s),network:e}),l=t.Vec(t.Nat8),u=t.Record({tip_height:s,block_headers:t.Vec(l)}),p=t.Record({network:e}),d=t.Nat64,m=t.Vec(d),f=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),w=t.Vec(t.Nat8),B=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),q=t.Record({height:t.Nat32,value:o,outpoint:B}),U=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:s,tip_block_hash:w,utxos:t.Vec(q)}),x=t.Record({transaction:t.Vec(t.Nat8),network:e}),_=t.Principal,C=t.Record({canister_id:_,num_requested_changes:t.Opt(t.Nat64)}),N=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),b=t.Vec(t.Nat8),V=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),load_snapshot:t.Record({canister_version:t.Nat64,taken_at_timestamp:t.Nat64,snapshot_id:b}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),it=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:N,details:V}),J=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(it),total_num_changes:t.Nat64}),P=t.Record({canister_id:_}),k=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),ht=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:k,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),v=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:ht,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),st=t.Record({canister_id:_}),L=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(k),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),Wt=t.Record({settings:t.Opt(L),sender_canister_version:t.Opt(t.Nat64)}),yt=t.Record({canister_id:_}),H=t.Record({canister_id:_}),tt=t.Record({canister_id:_,snapshot_id:b}),$=t.Record({canister_id:_}),at=t.Variant({secp256k1:t.Null}),et=t.Record({key_id:t.Record({name:t.Text,curve:at}),canister_id:t.Opt(_),derivation_path:t.Vec(t.Vec(t.Nat8))}),zt=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),rt=t.Record({canister_id:_}),Yt=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),Xt=t.Record({canister_log_records:t.Vec(Yt)}),bt=t.Record({value:t.Text,name:t.Text}),nt=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(bt)}),gt=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:nt})],[nt],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(bt)}),St=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),Tt=t.Record({hash:t.Vec(t.Nat8)}),Qt=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:St,chunk_hashes_list:t.Vec(Tt),target_canister:_,store_canister:t.Opt(_),sender_canister_version:t.Opt(t.Nat64)}),Zt=t.Vec(t.Nat8),It=t.Record({arg:t.Vec(t.Nat8),wasm_module:Zt,mode:St,canister_id:_,sender_canister_version:t.Opt(t.Nat64)}),Dt=t.Record({canister_id:_}),Pt=t.Record({id:b,total_size:t.Nat64,taken_at_timestamp:t.Nat64}),Lt=t.Vec(Pt),te=t.Record({canister_id:_,sender_canister_version:t.Opt(t.Nat64),snapshot_id:b}),ee=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),re=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),ne=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(re)})),oe=t.Record({settings:t.Opt(L),specified_id:t.Opt(_),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),ie=t.Record({canister_id:_}),Ot=t.Record({canister_id:_,amount:t.Nat}),se=t.Vec(t.Nat8),ct=t.Variant({ed25519:t.Null,bip340secp256k1:t.Null}),wt=t.Record({key_id:t.Record({algorithm:ct,name:t.Text}),canister_id:t.Opt(_),derivation_path:t.Vec(t.Vec(t.Nat8))}),Co=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),vo=t.Record({key_id:t.Record({name:t.Text,curve:at}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),Fo=t.Record({signature:t.Vec(t.Nat8)}),Uo=t.Variant({bip341:t.Record({merkle_root_hash:t.Vec(t.Nat8)})}),ko=t.Record({aux:t.Opt(Uo),key_id:t.Record({algorithm:ct,name:t.Text}),derivation_path:t.Vec(t.Vec(t.Nat8)),message:t.Vec(t.Nat8)}),Bo=t.Record({signature:t.Vec(t.Nat8)}),Vo=t.Record({canister_id:_}),jo=t.Record({canister_id:_}),Mo=t.Record({canister_id:_}),Ko=t.Vec(Tt),qo=t.Record({subnet_id:t.Principal}),Jo=t.Record({replica_version:t.Text}),Ho=t.Record({replace_snapshot:t.Opt(b),canister_id:_}),$o=Pt,Go=t.Record({canister_id:_,sender_canister_version:t.Opt(t.Nat64)}),Wo=t.Record({canister_id:t.Principal,settings:L,sender_canister_version:t.Opt(t.Nat64)}),zo=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),Yo=Tt;return t.Service({bitcoin_get_balance:t.Func([n],[i],[]),bitcoin_get_block_headers:t.Func([a],[u],[]),bitcoin_get_current_fee_percentiles:t.Func([p],[m],[]),bitcoin_get_utxos:t.Func([f],[U],[]),bitcoin_send_transaction:t.Func([x],[],[]),canister_info:t.Func([C],[J],[]),canister_status:t.Func([P],[v],[]),clear_chunk_store:t.Func([st],[],[]),create_canister:t.Func([Wt],[yt],[]),delete_canister:t.Func([H],[],[]),delete_canister_snapshot:t.Func([tt],[],[]),deposit_cycles:t.Func([$],[],[]),ecdsa_public_key:t.Func([et],[zt],[]),fetch_canister_logs:t.Func([rt],[Xt],["query"]),http_request:t.Func([gt],[nt],[]),install_chunked_code:t.Func([Qt],[],[]),install_code:t.Func([It],[],[]),list_canister_snapshots:t.Func([Dt],[Lt],[]),load_canister_snapshot:t.Func([te],[],[]),node_metrics_history:t.Func([ee],[ne],[]),provisional_create_canister_with_cycles:t.Func([oe],[ie],[]),provisional_top_up_canister:t.Func([Ot],[],[]),raw_rand:t.Func([],[se],[]),schnorr_public_key:t.Func([wt],[Co],[]),sign_with_ecdsa:t.Func([vo],[Fo],[]),sign_with_schnorr:t.Func([ko],[Bo],[]),start_canister:t.Func([Vo],[],[]),stop_canister:t.Func([jo],[],[]),stored_chunks:t.Func([Mo],[Ko],[]),subnet_info:t.Func([qo],[Jo],[]),take_canister_snapshot:t.Func([Ho],[$o],[]),uninstall_code:t.Func([Go],[],[]),update_settings:t.Func([Wo],[],[]),upload_chunk:t.Func([zo],[Yo],[])})};var Ce=class extends Oe{constructor(e,r,n,o){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(o).map(i=>` "${i}": ${JSON.stringify(o[i])}`)].join(`
14
- `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=o}},_r=class extends Ce{constructor(e,r,n){var o;super(e,r,"query",{Status:n.status,Code:(o=Jr[n.reject_code])!==null&&o!==void 0?o:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},ve=class extends Ce{constructor(e,r,n,o,i,s,a){super(e,r,"update",Object.assign({"Request ID":S(n)},o.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(i),"Reject message":s}):{"HTTP status code":o.status.toString(),"HTTP status text":o.statusText})),this.requestId=n,this.response=o,this.reject_code=i,this.reject_message=s,this.error_code=a}},M=Symbol.for("ic-agent-metadata"),pt=class t{constructor(e){this[M]=Object.freeze(e)}static agentOf(e){return e[M].config.agent}static interfaceOf(e){return e[M].service}static canisterIdOf(e){return y.from(e[M].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,o=e.arg?[...new Uint8Array(e.arg)]:[],i=[...new Uint8Array(e.module)],s=typeof r.canisterId=="string"?y.fromText(r.canisterId):r.canisterId;await gn(r).install_code({mode:n,arg:o,wasm_module:i,canister_id:s,sender_canister_version:[]})}static async createCanister(e,r){function n(i){return[{controllers:i.controllers?[i.controllers]:[],compute_allocation:i.compute_allocation?[i.compute_allocation]:[],freezing_threshold:i.freezing_threshold?[i.freezing_threshold]:[],memory_allocation:i.memory_allocation?[i.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:o}=await gn(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return o}static async createAndInstallCanister(e,r,n){let o=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:o})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:o}))}static createActorClass(e,r){let n=e({IDL:ae});class o extends t{constructor(s){if(!s.canisterId)throw new Oe(`Canister ID is required, but received ${typeof s.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof s.canisterId=="string"?y.fromText(s.canisterId):s.canisterId;super({config:Object.assign(Object.assign(Object.assign({},On),s),{canisterId:a}),service:n});for(let[l,u]of n._fields)r?.httpDetails&&u.annotations.push(mr),r?.certificate&&u.annotations.push(wn),this[l]=ki(this,l,u,s.blsVerify)}}return o}static createActor(e,r){if(!r.canisterId)throw new Oe(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};function Vt(t,e){let r=ae.decode(t,Tn.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var On={pollingStrategyFactory:Pe.defaultStrategy},mr="http-details",wn="certificate";function ki(t,e,r,n){let o;r.annotations.includes("query")||r.annotations.includes("composite_query")?o=async(s,...a)=>{var l,u;s=Object.assign(Object.assign({},s),(u=(l=t[M].config).queryTransform)===null||u===void 0?void 0:u.call(l,e,a,Object.assign(Object.assign({},t[M].config),s)));let p=s.agent||t[M].config.agent||rr(),d=y.from(s.canisterId||t[M].config.canisterId),m=ae.encode(r.argTypes,a),f=await p.query(d,{methodName:e,arg:m,effectiveCanisterId:s.effectiveCanisterId}),w=Object.assign(Object.assign({},f.httpDetails),{requestDetails:f.requestDetails});switch(f.status){case"rejected":throw new _r(d,e,f);case"replied":return r.annotations.includes(mr)?{httpDetails:w,result:Vt(r.retTypes,f.reply.arg)}:Vt(r.retTypes,f.reply.arg)}}:o=async(s,...a)=>{var l,u;s=Object.assign(Object.assign({},s),(u=(l=t[M].config).callTransform)===null||u===void 0?void 0:u.call(l,e,a,Object.assign(Object.assign({},t[M].config),s)));let p=s.agent||t[M].config.agent||rr(),{canisterId:d,effectiveCanisterId:m,pollingStrategyFactory:f}=Object.assign(Object.assign(Object.assign({},On),t[M].config),s),w=y.from(d),B=m!==void 0?y.from(m):w,q=ae.encode(r.argTypes,a),{requestId:U,response:x,requestDetails:_}=await p.call(w,{methodName:e,arg:q,effectiveCanisterId:B}),C,N;if(x.body&&x.body.certificate){if(p.rootKey==null)throw new Error("Agent is missing root key");let J=x.body.certificate;N=await we.create({certificate:Le(J),rootKey:p.rootKey,canisterId:y.from(d),blsVerify:n});let P=[new TextEncoder().encode("request_status"),U];switch(new TextDecoder().decode(G(N.lookup([...P,"status"])))){case"replied":C=G(N.lookup([...P,"reply"]));break;case"rejected":{let ht=new Uint8Array(G(N.lookup([...P,"reject_code"])))[0],v=new TextDecoder().decode(G(N.lookup([...P,"reject_message"]))),st=G(N.lookup([...P,"error_code"])),L=st?new TextDecoder().decode(st):void 0;throw new ve(w,e,U,x,ht,v,L)}}}else if(x.body&&"reject_message"in x.body){let{reject_code:J,reject_message:P,error_code:k}=x.body;throw new ve(w,e,U,x,J,P,k)}if(x.status===202){let J=f(),P=await pr(p,B,U,J,n);N=P.certificate,C=P.reply}let b=r.annotations.includes(mr),V=r.annotations.includes(wn),it=Object.assign(Object.assign({},x),{requestDetails:_});if(C!==void 0)return b&&V?{httpDetails:it,certificate:N,result:Vt(r.retTypes,C)}:V?{certificate:N,result:Vt(r.retTypes,C)}:b?{httpDetails:it,result:Vt(r.retTypes,C)}:Vt(r.retTypes,C);if(r.retTypes.length===0)return b?{httpDetails:x,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let i=(...s)=>o({},...s);return i.withOptions=s=>(...a)=>o(s,...a),i}function gn(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:y.from(t.effectiveCanisterId)};let o=n[0],i=y.fromHex("");return o&&typeof o=="object"&&o.target_canister&&r==="install_chunked_code"&&(i=y.from(o.target_canister)),o&&typeof o=="object"&&o.canister_id&&(i=y.from(o.canister_id)),{effectiveCanisterId:i}}return pt.createActor(yn,Object.assign(Object.assign(Object.assign({},t),{canisterId:y.fromHex("")}),{callTransform:e,queryTransform:e}))}var Vi=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(Vi||{}),ha=BigInt(1e8);var h=t=>t==null,g=t=>!h(t);var ji=class extends Error{},Fe=(t,e)=>{if(t==null)throw new ji(e)};var Nn="abcdefghijklmnopqrstuvwxyz234567",le=Object.create(null);for(let t=0;t<Nn.length;t++)le[Nn[t]]=t;le[0]=le.o;le[1]=le.i;var Ta=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);var fr="__bigint__",hr="__principal__",yr="__uint8array__",xn=(t,e)=>typeof e=="bigint"?{[fr]:`${e}`}:g(e)&&e instanceof y?{[hr]:e.toText()}:g(e)&&e instanceof Uint8Array?{[yr]:Array.from(e)}:e,Rn=(t,e)=>{let r=n=>e[n];return g(e)&&typeof e=="object"&&fr in e?BigInt(r(fr)):g(e)&&typeof e=="object"&&hr in e?y.fromText(r(hr)):g(e)&&typeof e=="object"&&yr in e?Uint8Array.from(r(yr)):e};var T=t=>g(t)?[t]:[],A=t=>t?.[0];var jt=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var Q=class t extends jt{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var gr=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var Be=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},_t=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ue,ke,Mt,Kt;function En(t){return t!==null&&typeof t=="object"}var Et=class t{constructor(e){if(Ue.set(this,void 0),ke.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Be(this,Ue,e,"f"),Be(this,ke,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=lt(e);return this.fromRaw(r)}else if(En(e)){let r=e;if(En(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw(Gr(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=xe(e,Ne).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=er(e,Ne);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return _t(this,Ue,"f")}get derKey(){return _t(this,ke,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Ue=new WeakMap,ke=new WeakMap;Et.RAW_KEY_LENGTH=32;var At=class t extends Nt{constructor(e,r){super(),Mt.set(this,void 0),Kt.set(this,void 0),Be(this,Mt,Et.from(e),"f"),Be(this,Kt,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=vt.utils.randomPrivateKey()),Hr(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let o=0;o<32;o++)r[o]=new Uint8Array(e)[o];let n=vt.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(Et.fromDer(lt(r)),lt(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(Et.fromRaw(e),r)}static fromSecretKey(e){let r=vt.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[S(_t(this,Mt,"f").toDer()),S(_t(this,Kt,"f"))]}getKeyPair(){return{secretKey:_t(this,Kt,"f"),publicKey:_t(this,Mt,"f")}}getPublicKey(){return _t(this,Mt,"f")}async sign(e){let r=new Uint8Array(e),n=$r(vt.sign(r,_t(this,Kt,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[o,i,s]=[e,r,n].map(a=>(typeof a=="string"&&(a=lt(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return vt.verify(i,o,s)}};Mt=new WeakMap,Kt=new WeakMap;var Tr=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};function An(t){if(typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle)return globalThis.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new Tr("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var ue=class t extends Nt{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:o}=e??{},i=An(o),s=await i.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await i.exportKey("spki",s.publicKey);return new this(s,a,i)}static async fromKeyPair(e,r){let n=An(r),o=await n.exportKey("spki",e.publicKey);return new t(e,o,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};var qt=De(Io());var Mi=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},de=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},mt,Ve=class{constructor(e){mt.set(this,void 0),Mi(this,mt,e,"f")}get rawKey(){return de(this,mt,"f").rawKey}get derKey(){return de(this,mt,"f").derKey}toDer(){return de(this,mt,"f").toDer()}getPublicKey(){return de(this,mt,"f")}getPrincipal(){return y.from(de(this,mt,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};mt=new WeakMap;var Ki=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},qi=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ji=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r},je,Hi=new TextEncoder().encode("ic-request-auth-delegation"),$i=new TextEncoder().encode(`
15
- ic-request`);function Or(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return lt(t)}var Jt=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return qt.value.map(Object.assign({pubkey:qt.value.bytes(this.pubkey),expiration:qt.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:qt.value.array(this.targets.map(e=>qt.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:S(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};async function Gi(t,e,r,n){let o=new Jt(e.toDer(),BigInt(+r)*BigInt(1e6),n),i=new Uint8Array([...Hi,...new Uint8Array(tr(Object.assign({},o)))]),s=await t.sign(i);return{delegation:o,signature:s}}var pe=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+900*1e3),o={}){var i,s;let a=await Gi(e,r,n,o.targets);return new t([...((i=o.previous)===null||i===void 0?void 0:i.delegations)||[],a],((s=o.previous)===null||s===void 0?void 0:s.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let o=n.map(i=>{let{delegation:s,signature:a}=i,{pubkey:l,expiration:u,targets:p}=s;if(p!==void 0&&!Array.isArray(p))throw new Error("Invalid targets.");return{delegation:new Jt(Or(l),BigInt("0x"+u),p&&p.map(d=>{if(typeof d!="string")throw new Error("Invalid target.");return y.fromHex(d)})),signature:Or(a)}});return new this(o,Or(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:o}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:S(r.pubkey)},o&&{targets:o.map(i=>i.toHex())}),signature:S(n)}}),publicKey:S(this.publicKey)}}},_e=class extends Nt{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=Ji(e,["body"]),o=await tr(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...$i,...new Uint8Array(o)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},me=class t extends Ve{constructor(e,r){super(e),je.set(this,void 0),Ki(this,je,r,"f")}get delegation(){return qi(this,je,"f")}static fromDelegation(e,r){return new t(e,r)}};je=new WeakMap;function bn(t,e){for(let{delegation:o}of t.delegations)if(+new Date(Number(o.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(o=>typeof o=="string"?y.fromText(o):o)):r.push(typeof n=="string"?y.fromText(n):n));for(let o of r){let i=o.toText();for(let{delegation:s}of t.delegations){if(s.targets===void 0)continue;let a=!0;for(let l of s.targets)if(l.toText()===i){a=!1;break}if(a)return!1}}return!0}var zi=De(Zo());var Sn;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Sn||(Sn={}));var Pn=["mousedown","mousemove","keydown","touchstart","wheel"],fe=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=600*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:o=600*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=o;let i=this._resetTimer.bind(this);window.addEventListener("load",i,!0),Pn.forEach(function(a){document.addEventListener(a,i,!0)});let s=(a,l)=>{let u;return(...p)=>{let d=this,m=function(){u=void 0,a.apply(d,p)};clearTimeout(u),u=window.setTimeout(m,l)}};if(e?.captureScroll){let a=s(i,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}i()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);Pn.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};var Yi=(t,e)=>e.some(r=>t instanceof r),Cn,vn;function Xi(){return Cn||(Cn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Qi(){return vn||(vn=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Fn=new WeakMap,Nr=new WeakMap,Un=new WeakMap,wr=new WeakMap,Rr=new WeakMap;function Zi(t){let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("success",i),t.removeEventListener("error",s)},i=()=>{r(Z(t.result)),o()},s=()=>{n(t.error),o()};t.addEventListener("success",i),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&Fn.set(r,t)}).catch(()=>{}),Rr.set(e,t),e}function Ii(t){if(Nr.has(t))return;let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",s),t.removeEventListener("abort",s)},i=()=>{r(),o()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),o()};t.addEventListener("complete",i),t.addEventListener("error",s),t.addEventListener("abort",s)});Nr.set(t,e)}var xr={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Nr.get(t);if(e==="objectStoreNames")return t.objectStoreNames||Un.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Z(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function kn(t){xr=t(xr)}function Di(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Me(this),e,...r);return Un.set(n,e.sort?e.sort():[e]),Z(n)}:Qi().includes(t)?function(...e){return t.apply(Me(this),e),Z(Fn.get(this))}:function(...e){return Z(t.apply(Me(this),e))}}function Li(t){return typeof t=="function"?Di(t):(t instanceof IDBTransaction&&Ii(t),Yi(t,Xi())?new Proxy(t,xr):t)}function Z(t){if(t instanceof IDBRequest)return Zi(t);if(wr.has(t))return wr.get(t);let e=Li(t);return e!==t&&(wr.set(t,e),Rr.set(e,t)),e}var Me=t=>Rr.get(t);function Vn(t,e,{blocked:r,upgrade:n,blocking:o,terminated:i}={}){let s=indexedDB.open(t,e),a=Z(s);return n&&s.addEventListener("upgradeneeded",l=>{n(Z(s.result),l.oldVersion,l.newVersion,Z(s.transaction),l)}),r&&s.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),a.then(l=>{i&&l.addEventListener("close",()=>i()),o&&l.addEventListener("versionchange",u=>o(u.oldVersion,u.newVersion,u))}).catch(()=>{}),a}var ts=["get","getKey","getAll","getAllKeys","count"],es=["put","add","delete","clear"],Er=new Map;function Bn(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Er.get(e))return Er.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,o=es.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||ts.includes(r)))return;let i=async function(s,...a){let l=this.transaction(s,o?"readwrite":"readonly"),u=l.store;return n&&(u=u.index(a.shift())),(await Promise.all([u[r](...a),o&&l.done]))[0]};return Er.set(e,i),i}kn(t=>({...t,get:(e,r,n)=>Bn(e,r)||t.get(e,r,n),has:(e,r)=>!!Bn(e,r)||t.has(e,r)}));var jn="auth-client-db",Mn="ic-keyval",rs=async(t=jn,e=Mn,r)=>(Ke&&(localStorage!=null&&localStorage.getItem(W))&&(localStorage.removeItem(W),localStorage.removeItem(z)),await Vn(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function ns(t,e,r){return await t.get(e,r)}async function os(t,e,r,n){return await t.put(e,n,r)}async function is(t,e,r){return await t.delete(e,r)}var he=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=jn,storeName:n=Mn,version:o=Kn}=e??{},i=await rs(r,n,o);return new t(i,n)}async set(e,r){return await os(this._db,this._storeName,e,r)}async get(e){var r;return(r=await ns(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await is(this._db,this._storeName,e)}};var ss=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},as=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},qe,z="identity",W="delegation",qn="iv",Kn=1,Ke=typeof window<"u",ye=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.localStorage:globalThis.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}},ge=class{constructor(e){qe.set(this,void 0),ss(this,qe,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}he.create(as(this,qe,"f")).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};qe=new WeakMap;var cs="https://identity.ic0.app",ls="#authorize",Ar="ECDSA",br="Ed25519",us=500,Pr="UserInterrupt",Je=class{constructor(e,r,n,o,i,s,a,l){this._identity=e,this._key=r,this._chain=n,this._storage=o,this.idleManager=i,this._createOptions=s,this._idpWindow=a,this._eventHandler=l,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,o;let i=(r=e.storage)!==null&&r!==void 0?r:new ge,s=(n=e.keyType)!==null&&n!==void 0?n:Ar,a=null;if(e.identity)a=e.identity;else{let d=await i.get(z);if(!d&&Ke)try{let m=new ye,f=await m.get(W),w=await m.get(z);f&&w&&s===Ar&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await i.set(W,f),await i.set(z,w),d=f,await m.remove(W),await m.remove(z))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(d)try{typeof d=="object"?s===br&&typeof d=="string"?a=await At.fromJSON(d):a=await ue.fromKeyPair(d):typeof d=="string"&&(a=At.fromJSON(d))}catch{}}let l=new Ct,u=null;if(a)try{let d=await i.get(W);if(typeof d=="object"&&d!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?l=e.identity:d&&(u=pe.fromJSON(d),bn(u)?"toDer"in a?l=me.fromDelegation(a,u):l=_e.fromDelegation(a,u):(await Sr(i),a=null))}catch(d){console.error(d),await Sr(i),a=null}let p;return!((o=e.idleOptions)===null||o===void 0)&&o.disableIdle?p=void 0:(u||e.identity)&&(p=fe.create(e.idleOptions)),a||(s===br?(a=await At.generate(),await i.set(z,JSON.stringify(a.toJSON()))):(e.storage&&s===Ar&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${br}' as the key type, as it can serialize to a string`),a=await ue.generate(),await i.set(z,a.getKeyPair()))),new this(l,a,u,i,p,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,o;let i=e.delegations.map(u=>({delegation:new Jt(u.delegation.pubkey,u.delegation.expiration,u.delegation.targets),signature:u.signature.buffer})),s=pe.fromDelegations(i,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=s,"toDer"in a?this._identity=me.fromDelegation(a,this._chain):this._identity=_e.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let l=(o=this._createOptions)===null||o===void 0?void 0:o.idleOptions;!this.idleManager&&!l?.disableIdle&&(this.idleManager=fe.create(l),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(W,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,o,i;let s=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||cs);a.hash=ls,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(o=e?.maxTimeToLive)!==null&&o!==void 0?o:s},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(i=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&i!==void 0?i:void 0;let l=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Pr,e?.onError):setTimeout(l,us))};l()}_getEventHandler(e,r){return async n=>{var o,i,s;if(n.origin!==e.origin)return;let a=n.data;switch(a.kind){case"authorize-ready":{let l=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((o=this._key)===null||o===void 0?void 0:o.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(i=r?.derivationOrigin)===null||i===void 0?void 0:i.toString()},r?.customValues);(s=this._idpWindow)===null||s===void 0||s.postMessage(l,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(l){this._handleFailure(l.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await Sr(this._storage),this._identity=new Ct,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};async function Sr(t){await t.remove(z),await t.remove(W),await t.remove(qn)}var Jn=BigInt(144e11),Hn=!1,$n={width:576,height:576},Gn={width:505,height:705},Wn="internetcomputer.org";var Ht="http://127.0.0.1:5987",zn="rdmx6-jaaaa-aaaaa-aaadq-cai";var I=class t extends jt{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}reset(){this.env=null}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var Yn=async t=>{let e=new Blob([JSON.stringify(t,xn)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},He=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),Rn)},$e=()=>typeof window<"u";var Cr=({width:t,height:e})=>{if(!$e()||h(window)||h(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,o=n/2+screenY-e/2,i=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${o}, left=${i}`};var Ge=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=I.getInstance().get()?.container;if(h(n)||n===!1)return`https://identity.${this.#t??Wn}`;let o=I.getInstance().get(),i=g(o)&&g(o?.internetIdentityId)?o.internetIdentityId:zn,{host:s,protocol:a}=new URL(n===!0?Ht:n);return/apple/i.test(navigator?.vendor)?`${a}//${s}?canisterId=${i}`:`${a}//${i}.${s.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Cr($n)},identityProvider:r()}}},Xn=class{#t;#e;constructor({appName:e,logoUrl:r}){this.#t=e,this.#e=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:Cr(Gn)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};var Qn=async({identity:t,container:e})=>{let n=g(e)&&e!==!1?e===!0?Ht:e:"https://icp-api.io",o=g(e);return await Re.create({identity:t,shouldFetchRootKey:o,host:n})};var $t=class t{static instance;#t=void 0;constructor(){}static getInstance(){return h(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...r}){let n=e.getPrincipal().toText();if(h(this.#t)||h(this.#t[n])){let o=await Qn({identity:e,...r});return this.#t={...this.#t??{},[n]:o},o}return this.#t[n]}reset(){this.#t=null}};var Gt=class t{static instance;#t=void 0;constructor(){}static getInstance(){return h(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:r,actorKey:n,...o}){let i=`${n}#${r.getPrincipal().toText()}#${e};`;if(h(this.#t)||h(this.#t[i])){let s=await this.createActor({satelliteId:e,identity:r,...o});return this.#t={...this.#t??{},[i]:s},s}return this.#t[i]}reset(){this.#t=null}async createActor({idlFactory:e,satelliteId:r,...n}){let o=await $t.getInstance().getAgent(n);return pt.createActor(e,{agent:o,canisterId:r})}};var We=class extends Error{},ze=class extends Error{},Ye=class extends Error{},Xe=class extends Error{},Qe=class extends Error{};var Ze=()=>Je.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var vr=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;var Zn="juno.datastore.error.user.cannot_update";var In=async({data:t})=>{try{return await He(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var Fr=async t=>{let{data:e,version:r,description:n}=t;return{description:T(n),data:await Yn(e),version:T(r)}},Ur=t=>{let{version:e}=t;return{version:T(e)}},Te=async({doc:t,key:e})=>{let{owner:r,version:n,description:o,data:i,...s}=t;return{key:e,description:A(o),owner:r.toText(),data:await He(i),version:A(n),...s}};var Dn=t=>{if(h(t))return T();switch(t.matcher){case"equal":return T({Equal:t.timestamp});case"greaterThan":return T({GreaterThan:t.timestamp});case"lessThan":return T({LessThan:t.timestamp});case"between":return T({Between:[t.timestamps.start,t.timestamps.end]});default:throw new Qe("Invalid list matcher for timestamp",t)}},ft=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:h(t)?[]:[{key:T(t.key),description:T(t.description),created_at:Dn(t.createdAt),updated_at:Dn(t.updatedAt)}],paginate:T(h(e)?void 0:{start_after:T(e.startAfter),limit:T(h(e.limit)?void 0:BigInt(e.limit))}),order:T(h(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:T(h(n)?void 0:typeof n=="string"?y.fromText(n):n)});var Ln=({satelliteId:t,container:e})=>{let{satelliteId:r}=kr({satelliteId:t}),{container:n}=Br({container:e});if(g(n)&&n!==!1){let{host:o,protocol:i}=new URL(n===!0?Ht:n);return`${i}//${r??"unknown"}.${o.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},kr=({satelliteId:t})=>g(t)?{satelliteId:t}:I.getInstance().get()??{satelliteId:void 0},Br=({container:t})=>g(t)?{container:t}:I.getInstance().get()??{container:void 0};var Vr=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),n=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),o=t.Record({field:n,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),s=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),a=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),l=t.Record({order:t.Opt(o),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(a)}),u=t.Record({controllers:t.Vec(t.Principal)}),p=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:p,expires_at:t.Opt(t.Nat64)}),m=t.Record({version:t.Opt(t.Nat64)}),f=t.Variant({Db:t.Null,Storage:t.Null}),w=t.Record({version:t.Opt(t.Nat64)}),B=t.Record({proposal_ids:t.Vec(t.Nat)}),q=t.Record({cycles:t.Nat,destination_id:t.Principal}),U=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),x=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),_=t.Record({key:U,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,x)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),C=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),N=t.Record({internet_identity:t.Opt(C)}),b=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),V=t.Record({max_memory_size:t.Opt(b)}),it=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),J=t.Variant({Deny:t.Null,Allow:t.Null}),P=t.Record({status_code:t.Nat16,location:t.Text}),k=t.Record({iframe:t.Opt(it),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(b),raw_access:t.Opt(J),redirects:t.Opt(t.Vec(t.Tuple(t.Text,P)))}),ht=t.Record({db:t.Opt(V),authentication:t.Opt(N),storage:k}),v=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),st=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),L=t.Record({clear_existing_assets:t.Opt(t.Bool)}),Wt=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),yt=t.Variant({AssetsUpgrade:L,SegmentsDeployment:Wt}),H=t.Record({status:st,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:yt}),tt=t.Variant({Heap:t.Null,Stable:t.Null}),$=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),at=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),et=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(tt),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:$,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(at),write:$,max_changes_per_user:t.Opt(t.Nat32)}),zt=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),rt=t.Record({memory:tt,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),Yt=t.Variant({Callback:t.Record({token:rt,callback:t.Func([],[],["query"])})}),Xt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(Yt),status_code:t.Nat16}),bt=t.Record({token:t.Opt(rt),body:t.Vec(t.Nat8)}),nt=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),gt=t.Record({batch_id:t.Nat}),St=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,_)),items_length:t.Nat64}),Tt=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Qt=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,v)),items_length:t.Nat64}),Zt=t.Record({desc:t.Bool}),It=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),Dt=t.Record({order:t.Opt(Zt),paginate:t.Opt(It)}),Pt=t.Record({proposal_id:t.Nat}),Lt=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(Pt,H)),items_length:t.Nat64}),te=t.Record({include_system:t.Bool}),ee=t.Record({matcher:t.Opt(te)}),re=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,et)),items_length:t.Nat64}),ne=t.Record({stable:t.Nat64,heap:t.Nat64}),oe=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:p,expires_at:t.Opt(t.Nat64)}),ie=t.Record({controller:oe,controllers:t.Vec(t.Principal)}),Ot=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),se=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(tt),max_size:t.Opt(t.Nat),read:$,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(at),write:$,max_changes_per_user:t.Opt(t.Nat32)}),ct=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),wt=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([r],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,l],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,l],[t.Nat64],["query"]),count_proposals:t.Func([],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([u],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,m],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,l],[],[]),del_filtered_docs:t.Func([t.Text,l],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,m))],[],[]),del_rule:t.Func([f,t.Text,w],[],[]),delete_proposal_assets:t.Func([B],[],[]),deposit_cycles:t.Func([q],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(_)],["query"]),get_auth_config:t.Func([],[t.Opt(N)],["query"]),get_config:t.Func([],[ht],[]),get_db_config:t.Func([],[t.Opt(V)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(v)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(_)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(v)))],["query"]),get_proposal:t.Func([t.Nat],[t.Opt(H)],["query"]),get_rule:t.Func([f,t.Text],[t.Opt(et)],["query"]),get_storage_config:t.Func([],[k],["query"]),http_request:t.Func([zt],[Xt],["query"]),http_request_streaming_callback:t.Func([rt],[bt],["query"]),init_asset_upload:t.Func([nt],[gt],[]),init_proposal:t.Func([yt],[t.Nat,H],[]),init_proposal_asset_upload:t.Func([nt,t.Nat],[gt],[]),list_assets:t.Func([t.Text,l],[St],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Tt))],["query"]),list_docs:t.Func([t.Text,l],[Qt],["query"]),list_proposals:t.Func([Dt],[Lt],["query"]),list_rules:t.Func([f,ee],[re],["query"]),memory_size:t.Func([],[ne],["query"]),reject_proposal:t.Func([r],[t.Null],[]),set_auth_config:t.Func([N],[],[]),set_controllers:t.Func([ie],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([V],[],[]),set_doc:t.Func([t.Text,t.Text,Ot],[v],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Ot))],[t.Vec(t.Tuple(t.Text,v))],[]),set_rule:t.Func([f,t.Text,se],[et],[]),set_storage_config:t.Func([k],[],[]),submit_proposal:t.Func([t.Nat],[t.Nat,H],[]),upload_asset_chunk:t.Func([ct],[wt],[]),upload_proposal_asset_chunk:t.Func([ct],[wt],[])})};var jr=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),n=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),o=t.Record({field:n,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),s=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),a=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),l=t.Record({order:t.Opt(o),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(a)}),u=t.Record({controllers:t.Vec(t.Principal)}),p=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:p,expires_at:t.Opt(t.Nat64)}),m=t.Record({version:t.Opt(t.Nat64)}),f=t.Variant({Db:t.Null,Storage:t.Null}),w=t.Record({version:t.Opt(t.Nat64)}),B=t.Record({proposal_ids:t.Vec(t.Nat)}),q=t.Record({cycles:t.Nat,destination_id:t.Principal}),U=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),x=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),_=t.Record({key:U,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,x)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),C=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),N=t.Record({internet_identity:t.Opt(C)}),b=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),V=t.Record({max_memory_size:t.Opt(b)}),it=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),J=t.Variant({Deny:t.Null,Allow:t.Null}),P=t.Record({status_code:t.Nat16,location:t.Text}),k=t.Record({iframe:t.Opt(it),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(b),raw_access:t.Opt(J),redirects:t.Opt(t.Vec(t.Tuple(t.Text,P)))}),ht=t.Record({db:t.Opt(V),authentication:t.Opt(N),storage:k}),v=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),st=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),L=t.Record({clear_existing_assets:t.Opt(t.Bool)}),Wt=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),yt=t.Variant({AssetsUpgrade:L,SegmentsDeployment:Wt}),H=t.Record({status:st,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:yt}),tt=t.Variant({Heap:t.Null,Stable:t.Null}),$=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),at=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),et=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(tt),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:$,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(at),write:$,max_changes_per_user:t.Opt(t.Nat32)}),zt=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),rt=t.Record({memory:tt,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),Yt=t.Variant({Callback:t.Record({token:rt,callback:t.Func([],[],[])})}),Xt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(Yt),status_code:t.Nat16}),bt=t.Record({token:t.Opt(rt),body:t.Vec(t.Nat8)}),nt=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),gt=t.Record({batch_id:t.Nat}),St=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,_)),items_length:t.Nat64}),Tt=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Qt=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,v)),items_length:t.Nat64}),Zt=t.Record({desc:t.Bool}),It=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),Dt=t.Record({order:t.Opt(Zt),paginate:t.Opt(It)}),Pt=t.Record({proposal_id:t.Nat}),Lt=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(Pt,H)),items_length:t.Nat64}),te=t.Record({include_system:t.Bool}),ee=t.Record({matcher:t.Opt(te)}),re=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,et)),items_length:t.Nat64}),ne=t.Record({stable:t.Nat64,heap:t.Nat64}),oe=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:p,expires_at:t.Opt(t.Nat64)}),ie=t.Record({controller:oe,controllers:t.Vec(t.Principal)}),Ot=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),se=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(tt),max_size:t.Opt(t.Nat),read:$,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(at),write:$,max_changes_per_user:t.Opt(t.Nat32)}),ct=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),wt=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([r],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,l],[t.Nat64],[]),count_collection_assets:t.Func([t.Text],[t.Nat64],[]),count_collection_docs:t.Func([t.Text],[t.Nat64],[]),count_docs:t.Func([t.Text,l],[t.Nat64],[]),count_proposals:t.Func([],[t.Nat64],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([u],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,m],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,l],[],[]),del_filtered_docs:t.Func([t.Text,l],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,m))],[],[]),del_rule:t.Func([f,t.Text,w],[],[]),delete_proposal_assets:t.Func([B],[],[]),deposit_cycles:t.Func([q],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(_)],[]),get_auth_config:t.Func([],[t.Opt(N)],[]),get_config:t.Func([],[ht],[]),get_db_config:t.Func([],[t.Opt(V)],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(v)],[]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(_)))],[]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(v)))],[]),get_proposal:t.Func([t.Nat],[t.Opt(H)],[]),get_rule:t.Func([f,t.Text],[t.Opt(et)],[]),get_storage_config:t.Func([],[k],[]),http_request:t.Func([zt],[Xt],[]),http_request_streaming_callback:t.Func([rt],[bt],[]),init_asset_upload:t.Func([nt],[gt],[]),init_proposal:t.Func([yt],[t.Nat,H],[]),init_proposal_asset_upload:t.Func([nt,t.Nat],[gt],[]),list_assets:t.Func([t.Text,l],[St],[]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],[]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Tt))],[]),list_docs:t.Func([t.Text,l],[Qt],[]),list_proposals:t.Func([Dt],[Lt],[]),list_rules:t.Func([f,ee],[re],[]),memory_size:t.Func([],[ne],[]),reject_proposal:t.Func([r],[t.Null],[]),set_auth_config:t.Func([N],[],[]),set_controllers:t.Func([ie],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([V],[],[]),set_doc:t.Func([t.Text,t.Text,Ot],[v],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Ot))],[t.Vec(t.Tuple(t.Text,v))],[]),set_rule:t.Func([f,t.Text,se],[et],[]),set_storage_config:t.Func([k],[],[]),submit_proposal:t.Func([t.Nat],[t.Nat,H],[]),upload_asset_chunk:t.Func([ct],[wt],[]),upload_proposal_asset_chunk:t.Func([ct],[wt],[])})};var R=({satellite:t,options:{certified:e}})=>eo({idlFactory:e?jr:Vr,actorKey:`stock#${e?"update":"query"}`,...t}),to=({idlFactory:t,...e})=>eo({idlFactory:t,actorKey:"extended#query",...e}),eo=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=kr({satelliteId:t});Fe(n,"No satellite ID defined. Did you initialize Juno?");let{container:o}=Br({container:e});return await Gt.getInstance().getActor({satelliteId:n,container:o,...r})};var ro=async({collection:t,key:e,...r})=>{let{get_doc:n}=await R(r),o=A(await n(t,e));if(!h(o))return Te({doc:o,key:e})},no=async({docs:t,...e})=>{let{get_many_docs:r}=await R(e),n=t.map(({collection:s,key:a})=>[s,a]),o=await r(n),i=[];for(let[s,a]of o){let l=A(a);i.push(g(l)?await Te({key:s,doc:l}):void 0)}return i},oo=async({collection:t,doc:e,...r})=>{let{set_doc:n}=await R(r),{key:o}=e,i=await Fr(e),s=await n(t,o,i);return await Te({key:o,doc:s})},io=async({docs:t,...e})=>{let{set_many_docs:r}=await R(e),n=[];for(let{collection:s,doc:a}of t){let{key:l}=a;n.push([s,l,await Fr(a)])}let o=await r(n),i=[];for(let[s,a]of o)i.push(await Te({key:s,doc:a}));return i},so=async({collection:t,doc:e,...r})=>{let{del_doc:n}=await R(r),{key:o}=e;return n(t,o,Ur(e))},ao=async({docs:t,...e})=>{let{del_many_docs:r}=await R(e),n=t.map(({collection:o,doc:i})=>[o,i.key,Ur(i)]);await r(n)},co=async({collection:t,filter:e,...r})=>{let{del_filtered_docs:n}=await R(r);return n(t,ft(e))},lo=async({collection:t,filter:e,...r})=>{let{list_docs:n}=await R(r),{items:o,items_page:i,items_length:s,matches_length:a,matches_pages:l}=await n(t,ft(e)),u=[];for(let[p,d]of o){let{data:m,owner:f,description:w,version:B,...q}=d;u.push({key:p,description:A(w),owner:f.toText(),data:await In({data:m}),version:A(B),...q})}return{items:u,items_length:s,items_page:A(i),matches_length:a,matches_pages:A(l)}},uo=async({collection:t,filter:e,...r})=>{let{count_docs:n}=await R(r);return n(t,ft(e))};var D={certified:!1};var O=t=>g(t)?t:Ie()??new Ct;var po=async({satellite:t,options:e,...r})=>{let n=O(t?.identity);return await ro({...r,satellite:{...t,identity:n},options:e??D})},Fl=async({satellite:t,options:e,...r})=>{let n=O(t?.identity);return await no({...r,satellite:{...t,identity:n},options:e??D})},_o=async({satellite:t,...e})=>{let r=O(t?.identity);return await oo({...e,satellite:{...t,identity:r},options:{certified:!0}})},Ul=async({satellite:t,...e})=>{let r=O(t?.identity);return await io({...e,satellite:{...t,identity:r},options:{certified:!0}})},kl=async({satellite:t,...e})=>{let r=O(t?.identity);return await so({...e,satellite:{...t,identity:r},options:{certified:!0}})},Bl=async({satellite:t,...e})=>{let r=O(t?.identity);return await ao({...e,satellite:{...t,identity:r},options:{certified:!0}})},Vl=async({satellite:t,filter:e,...r})=>{let n=O(t?.identity);return await co({...r,filter:e??{},satellite:{...t,identity:n},options:{certified:!0}})},jl=async({satellite:t,options:e,filter:r,...n})=>{let o=O(t?.identity);return await lo({...n,filter:r??{},satellite:{...t,identity:o},options:e??D})},Ml=async({satellite:t,options:e,filter:r,...n})=>{let o=O(t?.identity);return await uo({...n,filter:r??{},satellite:{...t,identity:o},options:e??D})};var mo=async t=>{let e=Ie();if(h(e))throw new Xe("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=()=>po({collection:"#user",key:r}),o=await n();if(g(o))return o;try{return await ds({userId:r,provider:t})}catch(i){if(vr({error:i,type:Zn})){let s=await n();if(g(s))return s}throw i}},ds=({userId:t,...e})=>_o({collection:"#user",doc:{key:t,data:e}});var K,Mr=async t=>{if(K=K??await Ze(),!(await K?.isAuthenticated()??!1))return;let r=await mo(t);Q.getInstance().set(r)},ps=t=>new Promise(async(e,r)=>{if(h(K)){r(new ze("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=t?.provider??new Ge({});await K.login({onSuccess:async()=>{await Mr(n.id),e()},onError:o=>{if(o===Pr){r(new Ye(o));return}r(new We(o))},maxTimeToLive:t?.maxTimeToLive??Jn,allowPinAuthentication:t?.allowPin??Hn,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Kr=async()=>{await _s(),K=await Ze()},_s=async()=>{await K?.logout(),K=null,Q.getInstance().reset(),Gt.getInstance().reset(),$t.getInstance().reset()},Ie=()=>K?.getIdentity(),ms=async()=>(K??await Ze()).getIdentity(),fs=async()=>{let t=Q.getInstance().get();return h(t)||!(await K?.isAuthenticated()??!1)?null:K?.getIdentity()??null};var fo=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{gr({message:"junoSignOutAuthTimer"}),await Kr()};return r.onmessage=async({data:o})=>{let{msg:i,data:s}=o;switch(i){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":gr({message:"junoDelegationRemainingTime",detail:s?.authRemainingTime});return}},Q.getInstance().subscribe(o=>{if(h(o)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var ho=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},yo=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var du=async({idlFactory:t,satellite:e})=>{let r=O(e?.identity);return await to({idlFactory:t,...e,identity:r})};var go=async({asset:{data:t,headers:e,...r},actor:n})=>{let{init_asset_upload:o,upload_asset_chunk:i,commit_asset_upload:s}=n,{batch_id:a}=await o(hs(r)),{chunkIds:l}=await gs({data:t,uploadFn:i,batchId:a});await ys({commitFn:s,batchId:a,data:t,headers:e,chunkIds:l})};var hs=({filename:t,collection:e,token:r,fullPath:n,encoding:o,description:i})=>({collection:e,full_path:n,name:t,token:T(r),encoding_type:T(o),description:T(i)}),ys=async({commitFn:t,batchId:e,chunkIds:r,headers:n,data:o})=>{let i=n.find(([s,a])=>s.toLowerCase()==="content-type")===void 0&&o.type!==void 0&&o.type!==""?[["Content-Type",o.type]]:void 0;await t({batch_id:e,chunk_ids:r.map(({chunk_id:s})=>s),headers:[...n,...i??[]]})},gs=async({data:t,uploadFn:e,batchId:r})=>{let n=[],o=$e()?new Blob([await t.arrayBuffer()]):t,i=0n;for(let a=0;a<o.size;a+=19e5){let l=o.slice(a,a+19e5);n.push({batchId:r,chunk:l,uploadFn:e,orderId:i}),i++}let s=[];for await(let a of Ts({uploadChunks:n}))s=[...s,...a];return{chunkIds:s}};async function*Ts({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(o=>Os(o)))}}var Os=async({batchId:t,chunk:e,uploadFn:r,orderId:n})=>r({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:T(n)});var To=async({asset:t,...e})=>{let r=await R(e);await go({actor:r,asset:t})},Oo=async({collection:t,filter:e,...r})=>{let{list_assets:n}=await R(r),{items:o,items_length:i,items_page:s,matches_length:a,matches_pages:l}=await n(t,ft(e));return{items:o.map(([u,p])=>p),items_length:i,items_page:A(s),matches_length:a,matches_pages:A(l)}},wo=async({collection:t,filter:e,...r})=>{let{count_assets:n}=await R(r);return n(t,ft(e))},No=async({collection:t,fullPath:e,...r})=>(await R(r)).del_asset(t,e),xo=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await R({satellite:e,options:{certified:!0}}),n=t.map(({collection:o,fullPath:i})=>[o,i]);await r(n)},Ro=async({collection:t,filter:e,...r})=>{let{del_filtered_assets:n}=await R(r);return n(t,ft(e))},Eo=async({collection:t,fullPath:e,...r})=>{let{get_asset:n}=await R(r);return A(await n(t,e))},Ao=async({assets:t,...e})=>{let{get_many_assets:r}=await R(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);return(await r(n)).map(([i,s])=>A(s))};var bo=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Su=t=>So(t),Pu=t=>So({filename:t.data.name,...t}),So=async({filename:t,data:e,collection:r,headers:n=[],fullPath:o,token:i,satellite:s,encoding:a,description:l})=>{let u=O(s?.identity),p=decodeURI(t),d=o??`/${r}/${p}`,m={...s,identity:u};return await To({asset:{data:e,filename:p,collection:r,token:i,headers:n,fullPath:d,encoding:a,description:l},satellite:m,options:{certified:!0}}),{downloadUrl:Po({satellite:m,assetKey:{fullPath:d,token:i}}),fullPath:d,name:p}},Cu=async({collection:t,filter:e,satellite:r,options:n})=>{let o={...r,identity:O(r?.identity)},{items:i,...s}=await Oo({collection:t,filter:e??{},satellite:o,options:n??D}),a=i.map(({key:{full_path:l,token:u,name:p,owner:d,description:m},headers:f,encodings:w,created_at:B,updated_at:q})=>{let U=A(u);return{fullPath:l,description:A(m),name:p,downloadUrl:Po({satellite:o,assetKey:{fullPath:l,token:U}}),token:U,headers:f,encodings:w.reduce((x,[_,{modified:C,sha256:N,total_length:b}])=>({...x,[_]:{modified:C,sha256:bo(N),total_length:b}}),{}),owner:d.toText(),created_at:B,updated_at:q}});return{items:a,assets:a,...s}},vu=async({collection:t,filter:e,satellite:r,options:n})=>{let o={...r,identity:O(r?.identity)};return await wo({collection:t,satellite:o,filter:e??{},options:n??D})},Fu=({collection:t,fullPath:e,satellite:r})=>No({collection:t,fullPath:e,satellite:{...r,identity:O(r?.identity)},options:{certified:!0}}),Uu=({assets:t,satellite:e})=>xo({assets:t,satellite:{...e,identity:O(e?.identity)},options:{certified:!0}}),ku=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:O(e?.identity)};return await Ro({collection:t,satellite:n,filter:r??{},options:{certified:!0}})},Bu=async({satellite:t,options:e,...r})=>{let n=O(t?.identity);return await Eo({...r,satellite:{...t,identity:n},options:e??D})},Vu=async({satellite:t,options:e,...r})=>{let n=O(t?.identity);return await Ao({...r,satellite:{...t,identity:n},options:e??D})},Po=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:O(r?.identity)};return`${Ln(n)}${t}${g(e)?`?token=${e}`:""}`};var ws=t=>{let e=t?.satelliteId??ho();Fe(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??yo();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},Gu=t=>Ns(t),Ns=async t=>{let e=ws(t);I.getInstance().set(e),await Mr();let r=e.workers?.auth!==void 0?fo(e.workers.auth):void 0;return[...r?[r]:[]]},Wu=t=>Q.getInstance().subscribe(t);export{Xe as InitError,Ge as InternetIdentityProvider,Qe as ListError,Xn as NFIDProvider,We as SignInError,ze as SignInInitError,Ye as SignInUserInterruptError,Wu as authSubscribe,vu as countAssets,Ml as countDocs,Fu as deleteAsset,kl as deleteDoc,ku as deleteFilteredAssets,Vl as deleteFilteredDocs,Uu as deleteManyAssets,Bl as deleteManyDocs,Po as downloadUrl,Bu as getAsset,po as getDoc,fs as getIdentityOnce,Vu as getManyAssets,Fl as getManyDocs,du as getSatelliteExtendedActor,Gu as initJuno,Ns as initSatellite,Cu as listAssets,jl as listDocs,_o as setDoc,Ul as setManyDocs,ps as signIn,Kr as signOut,ms as unsafeIdentity,Su as uploadBlob,Pu as uploadFile};
10
+ Reject text: ${N}
11
+ `)}case ct.Done:throw new Error(`Call was marked as done but we never saw the reply:
12
+ Request ID: ${C(r)}
13
+ `)}throw new Error("unreachable")}var Nn=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),o=t.Nat64,i=o,s=t.Nat32,a=t.Record({start_height:s,end_height:t.Opt(s),network:e}),l=t.Vec(t.Nat8),u=t.Record({tip_height:s,block_headers:t.Vec(l)}),p=t.Record({network:e}),d=t.Nat64,m=t.Vec(d),f=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),N=t.Vec(t.Nat8),V=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),H=t.Record({height:t.Nat32,value:o,outpoint:V}),k=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:s,tip_block_hash:N,utxos:t.Vec(H)}),w=t.Record({transaction:t.Vec(t.Nat8),network:e}),_=t.Principal,P=t.Record({canister_id:_,num_requested_changes:t.Opt(t.Nat64)}),x=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),R=t.Vec(t.Nat8),F=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),load_snapshot:t.Record({canister_version:t.Nat64,taken_at_timestamp:t.Nat64,snapshot_id:R}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),j=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:x,details:F}),B=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(j),total_num_changes:t.Nat64}),A=t.Record({canister_id:_}),$=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),G=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:$,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),mt=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:G,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),v=t.Record({canister_id:_}),et=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt($),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),zt=t.Record({settings:t.Opt(et),sender_canister_version:t.Opt(t.Nat64)}),Yt=t.Record({canister_id:_}),ft=t.Record({canister_id:_}),W=t.Record({canister_id:_,snapshot_id:R}),rt=t.Record({canister_id:_}),M=t.Variant({secp256k1:t.Null}),ht=t.Record({key_id:t.Record({name:t.Text,curve:M}),canister_id:t.Opt(_),derivation_path:t.Vec(t.Vec(t.Nat8))}),nt=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),Xt=t.Record({canister_id:_}),ot=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),Qt=t.Record({canister_log_records:t.Vec(ot)}),St=t.Record({value:t.Text,name:t.Text}),yt=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(St)}),gt=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:yt})],[yt],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(St)}),st=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),Ot=t.Record({hash:t.Vec(t.Nat8)}),Zt=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:st,chunk_hashes_list:t.Vec(Ot),target_canister:_,store_canister:t.Opt(_),sender_canister_version:t.Opt(t.Nat64)}),It=t.Vec(t.Nat8),Dt=t.Record({arg:t.Vec(t.Nat8),wasm_module:It,mode:st,canister_id:_,sender_canister_version:t.Opt(t.Nat64)}),Lt=t.Record({canister_id:_}),Pt=t.Record({id:R,total_size:t.Nat64,taken_at_timestamp:t.Nat64}),te=t.Vec(Pt),ee=t.Record({canister_id:_,sender_canister_version:t.Opt(t.Nat64),snapshot_id:R}),re=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),ne=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),oe=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(ne)})),ie=t.Record({settings:t.Opt(et),specified_id:t.Opt(_),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),se=t.Record({canister_id:_}),ae=t.Record({canister_id:_,amount:t.Nat}),ce=t.Vec(t.Nat8),Ct=t.Variant({ed25519:t.Null,bip340secp256k1:t.Null}),Tt=t.Record({key_id:t.Record({algorithm:Ct,name:t.Text}),canister_id:t.Opt(_),derivation_path:t.Vec(t.Vec(t.Nat8))}),le=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),ue=t.Record({key_id:t.Record({name:t.Text,curve:M}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),Nt=t.Record({signature:t.Vec(t.Nat8)}),wt=t.Variant({bip341:t.Record({merkle_root_hash:t.Vec(t.Nat8)})}),ko=t.Record({aux:t.Opt(wt),key_id:t.Record({algorithm:Ct,name:t.Text}),derivation_path:t.Vec(t.Vec(t.Nat8)),message:t.Vec(t.Nat8)}),Bo=t.Record({signature:t.Vec(t.Nat8)}),Vo=t.Record({canister_id:_}),jo=t.Record({canister_id:_}),Mo=t.Record({canister_id:_}),Ko=t.Vec(Ot),qo=t.Record({subnet_id:t.Principal}),Jo=t.Record({replica_version:t.Text}),Ho=t.Record({replace_snapshot:t.Opt(R),canister_id:_}),$o=Pt,Go=t.Record({canister_id:_,sender_canister_version:t.Opt(t.Nat64)}),Wo=t.Record({canister_id:t.Principal,settings:et,sender_canister_version:t.Opt(t.Nat64)}),zo=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),Yo=Ot;return t.Service({bitcoin_get_balance:t.Func([n],[i],[]),bitcoin_get_block_headers:t.Func([a],[u],[]),bitcoin_get_current_fee_percentiles:t.Func([p],[m],[]),bitcoin_get_utxos:t.Func([f],[k],[]),bitcoin_send_transaction:t.Func([w],[],[]),canister_info:t.Func([P],[B],[]),canister_status:t.Func([A],[mt],[]),clear_chunk_store:t.Func([v],[],[]),create_canister:t.Func([zt],[Yt],[]),delete_canister:t.Func([ft],[],[]),delete_canister_snapshot:t.Func([W],[],[]),deposit_cycles:t.Func([rt],[],[]),ecdsa_public_key:t.Func([ht],[nt],[]),fetch_canister_logs:t.Func([Xt],[Qt],["query"]),http_request:t.Func([gt],[yt],[]),install_chunked_code:t.Func([Zt],[],[]),install_code:t.Func([Dt],[],[]),list_canister_snapshots:t.Func([Lt],[te],[]),load_canister_snapshot:t.Func([ee],[],[]),node_metrics_history:t.Func([re],[oe],[]),provisional_create_canister_with_cycles:t.Func([ie],[se],[]),provisional_top_up_canister:t.Func([ae],[],[]),raw_rand:t.Func([],[ce],[]),schnorr_public_key:t.Func([Tt],[le],[]),sign_with_ecdsa:t.Func([ue],[Nt],[]),sign_with_schnorr:t.Func([ko],[Bo],[]),start_canister:t.Func([Vo],[],[]),stop_canister:t.Func([jo],[],[]),stored_chunks:t.Func([Mo],[Ko],[]),subnet_info:t.Func([qo],[Jo],[]),take_canister_snapshot:t.Func([Ho],[$o],[]),uninstall_code:t.Func([Go],[],[]),update_settings:t.Func([Wo],[],[]),upload_chunk:t.Func([zo],[Yo],[])})};var ke=class extends Re{constructor(e,r,n,o){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(o).map(i=>` "${i}": ${JSON.stringify(o[i])}`)].join(`
14
+ `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=o}},yr=class extends ke{constructor(e,r,n){var o;super(e,r,"query",{Status:n.status,Code:(o=Wr[n.reject_code])!==null&&o!==void 0?o:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},Be=class extends ke{constructor(e,r,n,o,i,s,a){super(e,r,"update",Object.assign({"Request ID":C(n)},o.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(i),"Reject message":s}):{"HTTP status code":o.status.toString(),"HTTP status text":o.statusText})),this.requestId=n,this.response=o,this.reject_code=i,this.reject_message=s,this.error_code=a}},q=Symbol.for("ic-agent-metadata"),ut=class t{constructor(e){this[q]=Object.freeze(e)}static agentOf(e){return e[q].config.agent}static interfaceOf(e){return e[q].service}static canisterIdOf(e){return y.from(e[q].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,o=e.arg?[...new Uint8Array(e.arg)]:[],i=[...new Uint8Array(e.module)],s=typeof r.canisterId=="string"?y.fromText(r.canisterId):r.canisterId;await wn(r).install_code({mode:n,arg:o,wasm_module:i,canister_id:s,sender_canister_version:[]})}static async createCanister(e,r){function n(i){return[{controllers:i.controllers?[i.controllers]:[],compute_allocation:i.compute_allocation?[i.compute_allocation]:[],freezing_threshold:i.freezing_threshold?[i.freezing_threshold]:[],memory_allocation:i.memory_allocation?[i.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:o}=await wn(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return o}static async createAndInstallCanister(e,r,n){let o=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:o})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:o}))}static createActorClass(e,r){let n=e({IDL:de});class o extends t{constructor(s){if(!s.canisterId)throw new Re(`Canister ID is required, but received ${typeof s.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof s.canisterId=="string"?y.fromText(s.canisterId):s.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Rn),s),{canisterId:a}),service:n});for(let[l,u]of n._fields)r?.httpDetails&&u.annotations.push(gr),r?.certificate&&u.annotations.push(En),this[l]=ki(this,l,u,s.blsVerify)}}return o}static createActor(e,r){if(!r.canisterId)throw new Re(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};function jt(t,e){let r=de.decode(t,xn.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Rn={pollingStrategyFactory:Ue.defaultStrategy},gr="http-details",En="certificate";function ki(t,e,r,n){let o;r.annotations.includes("query")||r.annotations.includes("composite_query")?o=async(s,...a)=>{var l,u;s=Object.assign(Object.assign({},s),(u=(l=t[q].config).queryTransform)===null||u===void 0?void 0:u.call(l,e,a,Object.assign(Object.assign({},t[q].config),s)));let p=s.agent||t[q].config.agent||sr(),d=y.from(s.canisterId||t[q].config.canisterId),m=de.encode(r.argTypes,a),f=await p.query(d,{methodName:e,arg:m,effectiveCanisterId:s.effectiveCanisterId}),N=Object.assign(Object.assign({},f.httpDetails),{requestDetails:f.requestDetails});switch(f.status){case"rejected":throw new yr(d,e,f);case"replied":return r.annotations.includes(gr)?{httpDetails:N,result:jt(r.retTypes,f.reply.arg)}:jt(r.retTypes,f.reply.arg)}}:o=async(s,...a)=>{var l,u;s=Object.assign(Object.assign({},s),(u=(l=t[q].config).callTransform)===null||u===void 0?void 0:u.call(l,e,a,Object.assign(Object.assign({},t[q].config),s)));let p=s.agent||t[q].config.agent||sr(),{canisterId:d,effectiveCanisterId:m,pollingStrategyFactory:f}=Object.assign(Object.assign(Object.assign({},Rn),t[q].config),s),N=y.from(d),V=m!==void 0?y.from(m):N,H=de.encode(r.argTypes,a),{requestId:k,response:w,requestDetails:_}=await p.call(N,{methodName:e,arg:H,effectiveCanisterId:V}),P,x;if(w.body&&w.body.certificate){if(p.rootKey==null)throw new Error("Agent is missing root key");let B=w.body.certificate;x=await Ee.create({certificate:nr(B),rootKey:p.rootKey,canisterId:y.from(d),blsVerify:n});let A=[new TextEncoder().encode("request_status"),k];switch(new TextDecoder().decode(z(x.lookup([...A,"status"])))){case"replied":P=z(x.lookup([...A,"reply"]));break;case"rejected":{let G=new Uint8Array(z(x.lookup([...A,"reject_code"])))[0],mt=new TextDecoder().decode(z(x.lookup([...A,"reject_message"]))),v=z(x.lookup([...A,"error_code"])),et=v?new TextDecoder().decode(v):void 0;throw new Be(N,e,k,w,G,mt,et)}}}else if(w.body&&"reject_message"in w.body){let{reject_code:B,reject_message:A,error_code:$}=w.body;throw new Be(N,e,k,w,B,A,$)}if(w.status===202){let B=f(),A=await hr(p,V,k,B,n);x=A.certificate,P=A.reply}let R=r.annotations.includes(gr),F=r.annotations.includes(En),j=Object.assign(Object.assign({},w),{requestDetails:_});if(P!==void 0)return R&&F?{httpDetails:j,certificate:x,result:jt(r.retTypes,P)}:F?{certificate:x,result:jt(r.retTypes,P)}:R?{httpDetails:j,result:jt(r.retTypes,P)}:jt(r.retTypes,P);if(r.retTypes.length===0)return R?{httpDetails:w,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let i=(...s)=>o({},...s);return i.withOptions=s=>(...a)=>o(s,...a),i}function wn(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:y.from(t.effectiveCanisterId)};let o=n[0],i=y.fromHex("");return o&&typeof o=="object"&&o.target_canister&&r==="install_chunked_code"&&(i=y.from(o.target_canister)),o&&typeof o=="object"&&o.canister_id&&(i=y.from(o.canister_id)),{effectiveCanisterId:i}}return ut.createActor(Nn,Object.assign(Object.assign(Object.assign({},t),{canisterId:y.fromHex("")}),{callTransform:e,queryTransform:e}))}var Vi=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(Vi||{}),ha=BigInt(1e8);var h=t=>t==null,g=t=>!h(t);var ji=class extends Error{},Ve=(t,e)=>{if(t==null)throw new ji(e)};var An="abcdefghijklmnopqrstuvwxyz234567",_e=Object.create(null);for(let t=0;t<An.length;t++)_e[An[t]]=t;_e[0]=_e.o;_e[1]=_e.i;var Oa=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);var Or="__bigint__",Tr="__principal__",Nr="__uint8array__",bn=(t,e)=>typeof e=="bigint"?{[Or]:`${e}`}:g(e)&&e instanceof y?{[Tr]:e.toText()}:g(e)&&e instanceof Uint8Array?{[Nr]:Array.from(e)}:e,Sn=(t,e)=>{let r=n=>e[n];return g(e)&&typeof e=="object"&&Or in e?BigInt(r(Or)):g(e)&&typeof e=="object"&&Tr in e?y.fromText(r(Tr)):g(e)&&typeof e=="object"&&Nr in e?Uint8Array.from(r(Nr)):e};var O=t=>g(t)?[t]:[],S=t=>t?.[0];var Mt=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var I=class t extends Mt{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var wr=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var Ke=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},dt=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},je,Me,Kt,qt;function Pn(t){return t!==null&&typeof t=="object"}var At=class t{constructor(e){if(je.set(this,void 0),Me.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Ke(this,je,e,"f"),Ke(this,Me,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=at(e);return this.fromRaw(r)}else if(Pn(e)){let r=e;if(Pn(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw(Xr(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=be(e,Ae).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=ir(e,Ae);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return dt(this,je,"f")}get derKey(){return dt(this,Me,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};je=new WeakMap,Me=new WeakMap;At.RAW_KEY_LENGTH=32;var bt=class t extends xt{constructor(e,r){super(),Kt.set(this,void 0),qt.set(this,void 0),Ke(this,Kt,At.from(e),"f"),Ke(this,qt,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=Ft.utils.randomPrivateKey()),zr(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let o=0;o<32;o++)r[o]=new Uint8Array(e)[o];let n=Ft.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(At.fromDer(at(r)),at(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(At.fromRaw(e),r)}static fromSecretKey(e){let r=Ft.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[C(dt(this,Kt,"f").toDer()),C(dt(this,qt,"f"))]}getKeyPair(){return{secretKey:dt(this,qt,"f"),publicKey:dt(this,Kt,"f")}}getPublicKey(){return dt(this,Kt,"f")}async sign(e){let r=new Uint8Array(e),n=Yr(Ft.sign(r,dt(this,qt,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[o,i,s]=[e,r,n].map(a=>(typeof a=="string"&&(a=at(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Ft.verify(i,o,s)}};Kt=new WeakMap,qt=new WeakMap;var xr=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};function Cn(t){if(typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle)return globalThis.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new xr("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var me=class t extends xt{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:o}=e??{},i=Cn(o),s=await i.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await i.exportKey("spki",s.publicKey);return new this(s,a,i)}static async fromKeyPair(e,r){let n=Cn(r),o=await n.exportKey("spki",e.publicKey);return new t(e,o,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};var Jt=rr(Io());var Mi=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},fe=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},pt,qe=class{constructor(e){pt.set(this,void 0),Mi(this,pt,e,"f")}get rawKey(){return fe(this,pt,"f").rawKey}get derKey(){return fe(this,pt,"f").derKey}toDer(){return fe(this,pt,"f").toDer()}getPublicKey(){return fe(this,pt,"f")}getPrincipal(){return y.from(fe(this,pt,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};pt=new WeakMap;var Ki=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},qi=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ji=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r},Je,Hi=new TextEncoder().encode("ic-request-auth-delegation"),$i=new TextEncoder().encode(`
15
+ ic-request`);function Rr(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return at(t)}var Ht=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return Jt.value.map(Object.assign({pubkey:Jt.value.bytes(this.pubkey),expiration:Jt.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Jt.value.array(this.targets.map(e=>Jt.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:C(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};async function Gi(t,e,r,n){let o=new Ht(e.toDer(),BigInt(+r)*BigInt(1e6),n),i=new Uint8Array([...Hi,...new Uint8Array(or(Object.assign({},o)))]),s=await t.sign(i);return{delegation:o,signature:s}}var he=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+900*1e3),o={}){var i,s;let a=await Gi(e,r,n,o.targets);return new t([...((i=o.previous)===null||i===void 0?void 0:i.delegations)||[],a],((s=o.previous)===null||s===void 0?void 0:s.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let o=n.map(i=>{let{delegation:s,signature:a}=i,{pubkey:l,expiration:u,targets:p}=s;if(p!==void 0&&!Array.isArray(p))throw new Error("Invalid targets.");return{delegation:new Ht(Rr(l),BigInt("0x"+u),p&&p.map(d=>{if(typeof d!="string")throw new Error("Invalid target.");return y.fromHex(d)})),signature:Rr(a)}});return new this(o,Rr(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:o}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:C(r.pubkey)},o&&{targets:o.map(i=>i.toHex())}),signature:C(n)}}),publicKey:C(this.publicKey)}}},ye=class extends xt{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=Ji(e,["body"]),o=await or(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...$i,...new Uint8Array(o)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},ge=class t extends qe{constructor(e,r){super(e),Je.set(this,void 0),Ki(this,Je,r,"f")}get delegation(){return qi(this,Je,"f")}static fromDelegation(e,r){return new t(e,r)}};Je=new WeakMap;function vn(t,e){for(let{delegation:o}of t.delegations)if(+new Date(Number(o.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(o=>typeof o=="string"?y.fromText(o):o)):r.push(typeof n=="string"?y.fromText(n):n));for(let o of r){let i=o.toText();for(let{delegation:s}of t.delegations){if(s.targets===void 0)continue;let a=!0;for(let l of s.targets)if(l.toText()===i){a=!1;break}if(a)return!1}}return!0}var zi=rr(Zo());var Fn;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Fn||(Fn={}));var Un=["mousedown","mousemove","keydown","touchstart","wheel"],Oe=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=600*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:o=600*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=o;let i=this._resetTimer.bind(this);window.addEventListener("load",i,!0),Un.forEach(function(a){document.addEventListener(a,i,!0)});let s=(a,l)=>{let u;return(...p)=>{let d=this,m=function(){u=void 0,a.apply(d,p)};clearTimeout(u),u=window.setTimeout(m,l)}};if(e?.captureScroll){let a=s(i,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}i()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);Un.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};var Yi=(t,e)=>e.some(r=>t instanceof r),kn,Bn;function Xi(){return kn||(kn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Qi(){return Bn||(Bn=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Vn=new WeakMap,Ar=new WeakMap,jn=new WeakMap,Er=new WeakMap,Sr=new WeakMap;function Zi(t){let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("success",i),t.removeEventListener("error",s)},i=()=>{r(D(t.result)),o()},s=()=>{n(t.error),o()};t.addEventListener("success",i),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&Vn.set(r,t)}).catch(()=>{}),Sr.set(e,t),e}function Ii(t){if(Ar.has(t))return;let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",s),t.removeEventListener("abort",s)},i=()=>{r(),o()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),o()};t.addEventListener("complete",i),t.addEventListener("error",s),t.addEventListener("abort",s)});Ar.set(t,e)}var br={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Ar.get(t);if(e==="objectStoreNames")return t.objectStoreNames||jn.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return D(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function Mn(t){br=t(br)}function Di(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(He(this),e,...r);return jn.set(n,e.sort?e.sort():[e]),D(n)}:Qi().includes(t)?function(...e){return t.apply(He(this),e),D(Vn.get(this))}:function(...e){return D(t.apply(He(this),e))}}function Li(t){return typeof t=="function"?Di(t):(t instanceof IDBTransaction&&Ii(t),Yi(t,Xi())?new Proxy(t,br):t)}function D(t){if(t instanceof IDBRequest)return Zi(t);if(Er.has(t))return Er.get(t);let e=Li(t);return e!==t&&(Er.set(t,e),Sr.set(e,t)),e}var He=t=>Sr.get(t);function qn(t,e,{blocked:r,upgrade:n,blocking:o,terminated:i}={}){let s=indexedDB.open(t,e),a=D(s);return n&&s.addEventListener("upgradeneeded",l=>{n(D(s.result),l.oldVersion,l.newVersion,D(s.transaction),l)}),r&&s.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),a.then(l=>{i&&l.addEventListener("close",()=>i()),o&&l.addEventListener("versionchange",u=>o(u.oldVersion,u.newVersion,u))}).catch(()=>{}),a}var ts=["get","getKey","getAll","getAllKeys","count"],es=["put","add","delete","clear"],Pr=new Map;function Kn(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Pr.get(e))return Pr.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,o=es.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||ts.includes(r)))return;let i=async function(s,...a){let l=this.transaction(s,o?"readwrite":"readonly"),u=l.store;return n&&(u=u.index(a.shift())),(await Promise.all([u[r](...a),o&&l.done]))[0]};return Pr.set(e,i),i}Mn(t=>({...t,get:(e,r,n)=>Kn(e,r)||t.get(e,r,n),has:(e,r)=>!!Kn(e,r)||t.has(e,r)}));var Jn="auth-client-db",Hn="ic-keyval",rs=async(t=Jn,e=Hn,r)=>($e&&(localStorage!=null&&localStorage.getItem(Y))&&(localStorage.removeItem(Y),localStorage.removeItem(X)),await qn(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function ns(t,e,r){return await t.get(e,r)}async function os(t,e,r,n){return await t.put(e,n,r)}async function is(t,e,r){return await t.delete(e,r)}var Te=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=Jn,storeName:n=Hn,version:o=$n}=e??{},i=await rs(r,n,o);return new t(i,n)}async set(e,r){return await os(this._db,this._storeName,e,r)}async get(e){var r;return(r=await ns(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await is(this._db,this._storeName,e)}};var ss=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},as=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ge,X="identity",Y="delegation",Gn="iv",$n=1,$e=typeof window<"u",Ne=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.localStorage:globalThis.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}},we=class{constructor(e){Ge.set(this,void 0),ss(this,Ge,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}Te.create(as(this,Ge,"f")).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};Ge=new WeakMap;var cs="https://identity.ic0.app",ls="#authorize",Cr="ECDSA",vr="Ed25519",us=500,Ur="UserInterrupt",We=class{constructor(e,r,n,o,i,s,a,l){this._identity=e,this._key=r,this._chain=n,this._storage=o,this.idleManager=i,this._createOptions=s,this._idpWindow=a,this._eventHandler=l,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,o;let i=(r=e.storage)!==null&&r!==void 0?r:new we,s=(n=e.keyType)!==null&&n!==void 0?n:Cr,a=null;if(e.identity)a=e.identity;else{let d=await i.get(X);if(!d&&$e)try{let m=new Ne,f=await m.get(Y),N=await m.get(X);f&&N&&s===Cr&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await i.set(Y,f),await i.set(X,N),d=f,await m.remove(Y),await m.remove(X))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(d)try{typeof d=="object"?s===vr&&typeof d=="string"?a=await bt.fromJSON(d):a=await me.fromKeyPair(d):typeof d=="string"&&(a=bt.fromJSON(d))}catch{}}let l=new vt,u=null;if(a)try{let d=await i.get(Y);if(typeof d=="object"&&d!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?l=e.identity:d&&(u=he.fromJSON(d),vn(u)?"toDer"in a?l=ge.fromDelegation(a,u):l=ye.fromDelegation(a,u):(await Fr(i),a=null))}catch(d){console.error(d),await Fr(i),a=null}let p;return!((o=e.idleOptions)===null||o===void 0)&&o.disableIdle?p=void 0:(u||e.identity)&&(p=Oe.create(e.idleOptions)),a||(s===vr?(a=await bt.generate(),await i.set(X,JSON.stringify(a.toJSON()))):(e.storage&&s===Cr&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${vr}' as the key type, as it can serialize to a string`),a=await me.generate(),await i.set(X,a.getKeyPair()))),new this(l,a,u,i,p,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,o;let i=e.delegations.map(u=>({delegation:new Ht(u.delegation.pubkey,u.delegation.expiration,u.delegation.targets),signature:u.signature.buffer})),s=he.fromDelegations(i,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=s,"toDer"in a?this._identity=ge.fromDelegation(a,this._chain):this._identity=ye.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let l=(o=this._createOptions)===null||o===void 0?void 0:o.idleOptions;!this.idleManager&&!l?.disableIdle&&(this.idleManager=Oe.create(l),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Y,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,o,i;let s=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||cs);a.hash=ls,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(o=e?.maxTimeToLive)!==null&&o!==void 0?o:s},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(i=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&i!==void 0?i:void 0;let l=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Ur,e?.onError):setTimeout(l,us))};l()}_getEventHandler(e,r){return async n=>{var o,i,s;if(n.origin!==e.origin)return;let a=n.data;switch(a.kind){case"authorize-ready":{let l=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((o=this._key)===null||o===void 0?void 0:o.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(i=r?.derivationOrigin)===null||i===void 0?void 0:i.toString()},r?.customValues);(s=this._idpWindow)===null||s===void 0||s.postMessage(l,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(l){this._handleFailure(l.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await Fr(this._storage),this._identity=new vt,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};async function Fr(t){await t.remove(X),await t.remove(Y),await t.remove(Gn)}var Wn=BigInt(144e11),zn=!1,Yn={width:576,height:576},Xn={width:505,height:705},Qn="internetcomputer.org";var $t="http://127.0.0.1:5987",Zn="rdmx6-jaaaa-aaaaa-aaadq-cai";var L=class t extends Mt{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}reset(){this.env=null}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var In=async t=>{let e=new Blob([JSON.stringify(t,bn)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},ze=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),Sn)},Ye=()=>typeof window<"u";var kr=({width:t,height:e})=>{if(!Ye()||h(window)||h(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,o=n/2+screenY-e/2,i=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${o}, left=${i}`};var Xe=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=L.getInstance().get()?.container;if(h(n)||n===!1)return`https://identity.${this.#t??Qn}`;let o=L.getInstance().get(),i=g(o)&&g(o?.internetIdentityId)?o.internetIdentityId:Zn,{host:s,protocol:a}=new URL(n===!0?$t:n);return/apple/i.test(navigator?.vendor)?`${a}//${s}?canisterId=${i}`:`${a}//${i}.${s.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:kr(Yn)},identityProvider:r()}}},Dn=class{#t;#e;constructor({appName:e,logoUrl:r}){this.#t=e,this.#e=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:kr(Xn)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};var Ln=async({identity:t,container:e})=>{let n=g(e)&&e!==!1?e===!0?$t:e:"https://icp-api.io",o=g(e);return await Se.create({identity:t,shouldFetchRootKey:o,host:n})};var Gt=class t{static instance;#t=void 0;constructor(){}static getInstance(){return h(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...r}){let n=e.getPrincipal().toText();if(h(this.#t)||h(this.#t[n])){let o=await Ln({identity:e,...r});return this.#t={...this.#t??{},[n]:o},o}return this.#t[n]}reset(){this.#t=null}};var Wt=class t{static instance;#t=void 0;constructor(){}static getInstance(){return h(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:r,actorKey:n,...o}){let i=`${n}#${r.getPrincipal().toText()}#${e};`;if(h(this.#t)||h(this.#t[i])){let s=await this.createActor({satelliteId:e,identity:r,...o});return this.#t={...this.#t??{},[i]:s},s}return this.#t[i]}reset(){this.#t=null}async createActor({idlFactory:e,satelliteId:r,...n}){let o=await Gt.getInstance().getAgent(n);return ut.createActor(e,{agent:o,canisterId:r})}};var Qe=class extends Error{},Ze=class extends Error{},Ie=class extends Error{},De=class extends Error{},Le=class extends Error{};var tr=()=>We.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Br=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;var to="juno.datastore.error.user.cannot_update";var eo=async({data:t})=>{try{return await ze(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var Vr=async t=>{let{data:e,version:r,description:n}=t;return{description:O(n),data:await In(e),version:O(r)}},jr=t=>{let{version:e}=t;return{version:O(e)}},xe=async({doc:t,key:e})=>{let{owner:r,version:n,description:o,data:i,...s}=t;return{key:e,description:S(o),owner:r.toText(),data:await ze(i),version:S(n),...s}};var ro=t=>{if(h(t))return O();switch(t.matcher){case"equal":return O({Equal:t.timestamp});case"greaterThan":return O({GreaterThan:t.timestamp});case"lessThan":return O({LessThan:t.timestamp});case"between":return O({Between:[t.timestamps.start,t.timestamps.end]});default:throw new Le("Invalid list matcher for timestamp",t)}},_t=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:h(t)?[]:[{key:O(t.key),description:O(t.description),created_at:ro(t.createdAt),updated_at:ro(t.updatedAt)}],paginate:O(h(e)?void 0:{start_after:O(e.startAfter),limit:O(h(e.limit)?void 0:BigInt(e.limit))}),order:O(h(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:O(h(n)?void 0:typeof n=="string"?y.fromText(n):n)});var no=({satelliteId:t,container:e})=>{let{satelliteId:r}=Mr({satelliteId:t}),{container:n}=Kr({container:e});if(g(n)&&n!==!1){let{host:o,protocol:i}=new URL(n===!0?$t:n);return`${i}//${r??"unknown"}.${o.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Mr=({satelliteId:t})=>g(t)?{satelliteId:t}:L.getInstance().get()??{satelliteId:void 0},Kr=({container:t})=>g(t)?{container:t}:L.getInstance().get()??{container:void 0};var qr=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),n=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),o=t.Record({field:n,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),s=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),a=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),l=t.Record({order:t.Opt(o),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(a)}),u=t.Record({controllers:t.Vec(t.Principal)}),p=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:p,expires_at:t.Opt(t.Nat64)}),m=t.Record({version:t.Opt(t.Nat64)}),f=t.Variant({Db:t.Null,Storage:t.Null}),N=t.Record({version:t.Opt(t.Nat64)}),V=t.Record({proposal_ids:t.Vec(t.Nat)}),H=t.Record({cycles:t.Nat,destination_id:t.Principal}),k=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),w=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),_=t.Record({key:k,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,w)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),P=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),x=t.Record({allowed_callers:t.Vec(t.Principal)}),R=t.Record({updated_at:t.Opt(t.Nat64),created_at:t.Opt(t.Nat64),version:t.Opt(t.Nat64),internet_identity:t.Opt(P),rules:t.Opt(x)}),F=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),j=t.Record({updated_at:t.Opt(t.Nat64),created_at:t.Opt(t.Nat64),version:t.Opt(t.Nat64),max_memory_size:t.Opt(F)}),B=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),A=t.Variant({Deny:t.Null,Allow:t.Null}),$=t.Record({status_code:t.Nat16,location:t.Text}),G=t.Record({iframe:t.Opt(B),updated_at:t.Opt(t.Nat64),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),created_at:t.Opt(t.Nat64),version:t.Opt(t.Nat64),max_memory_size:t.Opt(F),raw_access:t.Opt(A),redirects:t.Opt(t.Vec(t.Tuple(t.Text,$)))}),mt=t.Record({db:t.Opt(j),authentication:t.Opt(R),storage:G}),v=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),et=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),zt=t.Record({clear_existing_assets:t.Opt(t.Bool)}),Yt=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),ft=t.Variant({AssetsUpgrade:zt,SegmentsDeployment:Yt}),W=t.Record({status:et,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:ft}),rt=t.Variant({Heap:t.Null,Stable:t.Null}),M=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),ht=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),nt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(rt),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:M,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(ht),write:M,max_changes_per_user:t.Opt(t.Nat32)}),Xt=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),ot=t.Record({memory:rt,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),Qt=t.Variant({Callback:t.Record({token:ot,callback:t.Func([],[],["query"])})}),St=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(Qt),status_code:t.Nat16}),yt=t.Record({token:t.Opt(ot),body:t.Vec(t.Nat8)}),gt=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),st=t.Record({batch_id:t.Nat}),Ot=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,_)),items_length:t.Nat64}),Zt=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),It=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,v)),items_length:t.Nat64}),Dt=t.Record({desc:t.Bool}),Lt=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),Pt=t.Record({order:t.Opt(Dt),paginate:t.Opt(Lt)}),te=t.Record({proposal_id:t.Nat}),ee=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(te,W)),items_length:t.Nat64}),re=t.Record({include_system:t.Bool}),ne=t.Record({matcher:t.Opt(re)}),oe=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,nt)),items_length:t.Nat64}),ie=t.Record({stable:t.Nat64,heap:t.Nat64}),se=t.Record({version:t.Opt(t.Nat64),internet_identity:t.Opt(P),rules:t.Opt(x)}),ae=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:p,expires_at:t.Opt(t.Nat64)}),ce=t.Record({controller:ae,controllers:t.Vec(t.Principal)}),Ct=t.Record({version:t.Opt(t.Nat64),max_memory_size:t.Opt(F)}),Tt=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),le=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(rt),max_size:t.Opt(t.Nat),read:M,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(ht),write:M,max_changes_per_user:t.Opt(t.Nat32)}),ue=t.Record({iframe:t.Opt(B),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),version:t.Opt(t.Nat64),max_memory_size:t.Opt(F),raw_access:t.Opt(A),redirects:t.Opt(t.Vec(t.Tuple(t.Text,$)))}),Nt=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),wt=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([r],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,l],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,l],[t.Nat64],["query"]),count_proposals:t.Func([],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([u],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,m],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,l],[],[]),del_filtered_docs:t.Func([t.Text,l],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,m))],[],[]),del_rule:t.Func([f,t.Text,N],[],[]),delete_proposal_assets:t.Func([V],[],[]),deposit_cycles:t.Func([H],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(_)],["query"]),get_auth_config:t.Func([],[t.Opt(R)],["query"]),get_config:t.Func([],[mt],[]),get_db_config:t.Func([],[t.Opt(j)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(v)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(_)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(v)))],["query"]),get_proposal:t.Func([t.Nat],[t.Opt(W)],["query"]),get_rule:t.Func([f,t.Text],[t.Opt(nt)],["query"]),get_storage_config:t.Func([],[G],["query"]),http_request:t.Func([Xt],[St],["query"]),http_request_streaming_callback:t.Func([ot],[yt],["query"]),init_asset_upload:t.Func([gt],[st],[]),init_proposal:t.Func([ft],[t.Nat,W],[]),init_proposal_asset_upload:t.Func([gt,t.Nat],[st],[]),list_assets:t.Func([t.Text,l],[Ot],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Zt))],["query"]),list_docs:t.Func([t.Text,l],[It],["query"]),list_proposals:t.Func([Pt],[ee],["query"]),list_rules:t.Func([f,ne],[oe],["query"]),memory_size:t.Func([],[ie],["query"]),reject_proposal:t.Func([r],[t.Null],[]),set_auth_config:t.Func([se],[R],[]),set_controllers:t.Func([ce],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([Ct],[j],[]),set_doc:t.Func([t.Text,t.Text,Tt],[v],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Tt))],[t.Vec(t.Tuple(t.Text,v))],[]),set_rule:t.Func([f,t.Text,le],[nt],[]),set_storage_config:t.Func([ue],[G],[]),submit_proposal:t.Func([t.Nat],[t.Nat,W],[]),upload_asset_chunk:t.Func([Nt],[wt],[]),upload_proposal_asset_chunk:t.Func([Nt],[wt],[])})};var Jr=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),n=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),o=t.Record({field:n,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),s=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),a=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),l=t.Record({order:t.Opt(o),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(a)}),u=t.Record({controllers:t.Vec(t.Principal)}),p=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:p,expires_at:t.Opt(t.Nat64)}),m=t.Record({version:t.Opt(t.Nat64)}),f=t.Variant({Db:t.Null,Storage:t.Null}),N=t.Record({version:t.Opt(t.Nat64)}),V=t.Record({proposal_ids:t.Vec(t.Nat)}),H=t.Record({cycles:t.Nat,destination_id:t.Principal}),k=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),w=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),_=t.Record({key:k,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,w)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),P=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),x=t.Record({allowed_callers:t.Vec(t.Principal)}),R=t.Record({updated_at:t.Opt(t.Nat64),created_at:t.Opt(t.Nat64),version:t.Opt(t.Nat64),internet_identity:t.Opt(P),rules:t.Opt(x)}),F=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),j=t.Record({updated_at:t.Opt(t.Nat64),created_at:t.Opt(t.Nat64),version:t.Opt(t.Nat64),max_memory_size:t.Opt(F)}),B=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),A=t.Variant({Deny:t.Null,Allow:t.Null}),$=t.Record({status_code:t.Nat16,location:t.Text}),G=t.Record({iframe:t.Opt(B),updated_at:t.Opt(t.Nat64),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),created_at:t.Opt(t.Nat64),version:t.Opt(t.Nat64),max_memory_size:t.Opt(F),raw_access:t.Opt(A),redirects:t.Opt(t.Vec(t.Tuple(t.Text,$)))}),mt=t.Record({db:t.Opt(j),authentication:t.Opt(R),storage:G}),v=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),et=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),zt=t.Record({clear_existing_assets:t.Opt(t.Bool)}),Yt=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),ft=t.Variant({AssetsUpgrade:zt,SegmentsDeployment:Yt}),W=t.Record({status:et,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:ft}),rt=t.Variant({Heap:t.Null,Stable:t.Null}),M=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),ht=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),nt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(rt),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:M,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(ht),write:M,max_changes_per_user:t.Opt(t.Nat32)}),Xt=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),ot=t.Record({memory:rt,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),Qt=t.Variant({Callback:t.Record({token:ot,callback:t.Func([],[],[])})}),St=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(Qt),status_code:t.Nat16}),yt=t.Record({token:t.Opt(ot),body:t.Vec(t.Nat8)}),gt=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),st=t.Record({batch_id:t.Nat}),Ot=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,_)),items_length:t.Nat64}),Zt=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),It=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,v)),items_length:t.Nat64}),Dt=t.Record({desc:t.Bool}),Lt=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),Pt=t.Record({order:t.Opt(Dt),paginate:t.Opt(Lt)}),te=t.Record({proposal_id:t.Nat}),ee=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(te,W)),items_length:t.Nat64}),re=t.Record({include_system:t.Bool}),ne=t.Record({matcher:t.Opt(re)}),oe=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,nt)),items_length:t.Nat64}),ie=t.Record({stable:t.Nat64,heap:t.Nat64}),se=t.Record({version:t.Opt(t.Nat64),internet_identity:t.Opt(P),rules:t.Opt(x)}),ae=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:p,expires_at:t.Opt(t.Nat64)}),ce=t.Record({controller:ae,controllers:t.Vec(t.Principal)}),Ct=t.Record({version:t.Opt(t.Nat64),max_memory_size:t.Opt(F)}),Tt=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),le=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(rt),max_size:t.Opt(t.Nat),read:M,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(ht),write:M,max_changes_per_user:t.Opt(t.Nat32)}),ue=t.Record({iframe:t.Opt(B),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),version:t.Opt(t.Nat64),max_memory_size:t.Opt(F),raw_access:t.Opt(A),redirects:t.Opt(t.Vec(t.Tuple(t.Text,$)))}),Nt=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),wt=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([r],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,l],[t.Nat64],[]),count_collection_assets:t.Func([t.Text],[t.Nat64],[]),count_collection_docs:t.Func([t.Text],[t.Nat64],[]),count_docs:t.Func([t.Text,l],[t.Nat64],[]),count_proposals:t.Func([],[t.Nat64],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([u],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,m],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,l],[],[]),del_filtered_docs:t.Func([t.Text,l],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,m))],[],[]),del_rule:t.Func([f,t.Text,N],[],[]),delete_proposal_assets:t.Func([V],[],[]),deposit_cycles:t.Func([H],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(_)],[]),get_auth_config:t.Func([],[t.Opt(R)],[]),get_config:t.Func([],[mt],[]),get_db_config:t.Func([],[t.Opt(j)],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(v)],[]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(_)))],[]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(v)))],[]),get_proposal:t.Func([t.Nat],[t.Opt(W)],[]),get_rule:t.Func([f,t.Text],[t.Opt(nt)],[]),get_storage_config:t.Func([],[G],[]),http_request:t.Func([Xt],[St],[]),http_request_streaming_callback:t.Func([ot],[yt],[]),init_asset_upload:t.Func([gt],[st],[]),init_proposal:t.Func([ft],[t.Nat,W],[]),init_proposal_asset_upload:t.Func([gt,t.Nat],[st],[]),list_assets:t.Func([t.Text,l],[Ot],[]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],[]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Zt))],[]),list_docs:t.Func([t.Text,l],[It],[]),list_proposals:t.Func([Pt],[ee],[]),list_rules:t.Func([f,ne],[oe],[]),memory_size:t.Func([],[ie],[]),reject_proposal:t.Func([r],[t.Null],[]),set_auth_config:t.Func([se],[R],[]),set_controllers:t.Func([ce],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([Ct],[j],[]),set_doc:t.Func([t.Text,t.Text,Tt],[v],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Tt))],[t.Vec(t.Tuple(t.Text,v))],[]),set_rule:t.Func([f,t.Text,le],[nt],[]),set_storage_config:t.Func([ue],[G],[]),submit_proposal:t.Func([t.Nat],[t.Nat,W],[]),upload_asset_chunk:t.Func([Nt],[wt],[]),upload_proposal_asset_chunk:t.Func([Nt],[wt],[])})};var E=({satellite:t,options:{certified:e}})=>io({idlFactory:e?Jr:qr,actorKey:`stock#${e?"update":"query"}`,...t}),oo=({idlFactory:t,...e})=>io({idlFactory:t,actorKey:"extended#query",...e}),io=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Mr({satelliteId:t});Ve(n,"No satellite ID defined. Did you initialize Juno?");let{container:o}=Kr({container:e});return await Wt.getInstance().getActor({satelliteId:n,container:o,...r})};var so=async({collection:t,key:e,...r})=>{let{get_doc:n}=await E(r),o=S(await n(t,e));if(!h(o))return xe({doc:o,key:e})},ao=async({docs:t,...e})=>{let{get_many_docs:r}=await E(e),n=t.map(({collection:s,key:a})=>[s,a]),o=await r(n),i=[];for(let[s,a]of o){let l=S(a);i.push(g(l)?await xe({key:s,doc:l}):void 0)}return i},co=async({collection:t,doc:e,...r})=>{let{set_doc:n}=await E(r),{key:o}=e,i=await Vr(e),s=await n(t,o,i);return await xe({key:o,doc:s})},lo=async({docs:t,...e})=>{let{set_many_docs:r}=await E(e),n=[];for(let{collection:s,doc:a}of t){let{key:l}=a;n.push([s,l,await Vr(a)])}let o=await r(n),i=[];for(let[s,a]of o)i.push(await xe({key:s,doc:a}));return i},uo=async({collection:t,doc:e,...r})=>{let{del_doc:n}=await E(r),{key:o}=e;return n(t,o,jr(e))},po=async({docs:t,...e})=>{let{del_many_docs:r}=await E(e),n=t.map(({collection:o,doc:i})=>[o,i.key,jr(i)]);await r(n)},_o=async({collection:t,filter:e,...r})=>{let{del_filtered_docs:n}=await E(r);return n(t,_t(e))},mo=async({collection:t,filter:e,...r})=>{let{list_docs:n}=await E(r),{items:o,items_page:i,items_length:s,matches_length:a,matches_pages:l}=await n(t,_t(e)),u=[];for(let[p,d]of o){let{data:m,owner:f,description:N,version:V,...H}=d;u.push({key:p,description:S(N),owner:f.toText(),data:await eo({data:m}),version:S(V),...H})}return{items:u,items_length:s,items_page:S(i),matches_length:a,matches_pages:S(l)}},fo=async({collection:t,filter:e,...r})=>{let{count_docs:n}=await E(r);return n(t,_t(e))};var tt={certified:!1};var T=t=>g(t)?t:er()??new vt;var ho=async({satellite:t,options:e,...r})=>{let n=T(t?.identity);return await so({...r,satellite:{...t,identity:n},options:e??tt})},Fl=async({satellite:t,options:e,...r})=>{let n=T(t?.identity);return await ao({...r,satellite:{...t,identity:n},options:e??tt})},yo=async({satellite:t,...e})=>{let r=T(t?.identity);return await co({...e,satellite:{...t,identity:r},options:{certified:!0}})},Ul=async({satellite:t,...e})=>{let r=T(t?.identity);return await lo({...e,satellite:{...t,identity:r},options:{certified:!0}})},kl=async({satellite:t,...e})=>{let r=T(t?.identity);return await uo({...e,satellite:{...t,identity:r},options:{certified:!0}})},Bl=async({satellite:t,...e})=>{let r=T(t?.identity);return await po({...e,satellite:{...t,identity:r},options:{certified:!0}})},Vl=async({satellite:t,filter:e,...r})=>{let n=T(t?.identity);return await _o({...r,filter:e??{},satellite:{...t,identity:n},options:{certified:!0}})},jl=async({satellite:t,options:e,filter:r,...n})=>{let o=T(t?.identity);return await mo({...n,filter:r??{},satellite:{...t,identity:o},options:e??tt})},Ml=async({satellite:t,options:e,filter:r,...n})=>{let o=T(t?.identity);return await fo({...n,filter:r??{},satellite:{...t,identity:o},options:e??tt})};var go=async t=>{let e=er();if(h(e))throw new De("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=()=>ho({collection:"#user",key:r}),o=await n();if(g(o))return o;try{return await ds({userId:r,provider:t})}catch(i){if(Br({error:i,type:to})){let s=await n();if(g(s))return s}throw i}},ds=({userId:t,...e})=>yo({collection:"#user",doc:{key:t,data:e}});var J,Hr=async t=>{if(J=J??await tr(),!(await J?.isAuthenticated()??!1))return;let r=await go(t);I.getInstance().set(r)},ps=t=>new Promise(async(e,r)=>{if(h(J)){r(new Ze("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=t?.provider??new Xe({});await J.login({onSuccess:async()=>{await Hr(n.id),e()},onError:o=>{if(o===Ur){r(new Ie(o));return}r(new Qe(o))},maxTimeToLive:t?.maxTimeToLive??Wn,allowPinAuthentication:t?.allowPin??zn,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),$r=async()=>{await _s(),J=await tr()},_s=async()=>{await J?.logout(),J=null,I.getInstance().reset(),Wt.getInstance().reset(),Gt.getInstance().reset()},er=()=>J?.getIdentity(),ms=async()=>(J??await tr()).getIdentity(),fs=async()=>{let t=I.getInstance().get();return h(t)||!(await J?.isAuthenticated()??!1)?null:J?.getIdentity()??null};var Oo=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{wr({message:"junoSignOutAuthTimer"}),await $r()};return r.onmessage=async({data:o})=>{let{msg:i,data:s}=o;switch(i){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":wr({message:"junoDelegationRemainingTime",detail:s?.authRemainingTime});return}},I.getInstance().subscribe(o=>{if(h(o)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var To=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},No=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var du=async({idlFactory:t,satellite:e})=>{let r=T(e?.identity);return await oo({idlFactory:t,...e,identity:r})};var wo=async({asset:{data:t,headers:e,...r},actor:n})=>{let{init_asset_upload:o,upload_asset_chunk:i,commit_asset_upload:s}=n,{batch_id:a}=await o(hs(r)),{chunkIds:l}=await gs({data:t,uploadFn:i,batchId:a});await ys({commitFn:s,batchId:a,data:t,headers:e,chunkIds:l})};var hs=({filename:t,collection:e,token:r,fullPath:n,encoding:o,description:i})=>({collection:e,full_path:n,name:t,token:O(r),encoding_type:O(o),description:O(i)}),ys=async({commitFn:t,batchId:e,chunkIds:r,headers:n,data:o})=>{let i=n.find(([s,a])=>s.toLowerCase()==="content-type")===void 0&&o.type!==void 0&&o.type!==""?[["Content-Type",o.type]]:void 0;await t({batch_id:e,chunk_ids:r.map(({chunk_id:s})=>s),headers:[...n,...i??[]]})},gs=async({data:t,uploadFn:e,batchId:r})=>{let n=[],o=Ye()?new Blob([await t.arrayBuffer()]):t,i=0n;for(let a=0;a<o.size;a+=19e5){let l=o.slice(a,a+19e5);n.push({batchId:r,chunk:l,uploadFn:e,orderId:i}),i++}let s=[];for await(let a of Os({uploadChunks:n}))s=[...s,...a];return{chunkIds:s}};async function*Os({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(o=>Ts(o)))}}var Ts=async({batchId:t,chunk:e,uploadFn:r,orderId:n})=>r({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:O(n)});var xo=async({asset:t,...e})=>{let r=await E(e);await wo({actor:r,asset:t})},Ro=async({collection:t,filter:e,...r})=>{let{list_assets:n}=await E(r),{items:o,items_length:i,items_page:s,matches_length:a,matches_pages:l}=await n(t,_t(e));return{items:o.map(([u,p])=>p),items_length:i,items_page:S(s),matches_length:a,matches_pages:S(l)}},Eo=async({collection:t,filter:e,...r})=>{let{count_assets:n}=await E(r);return n(t,_t(e))},Ao=async({collection:t,fullPath:e,...r})=>(await E(r)).del_asset(t,e),bo=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await E({satellite:e,options:{certified:!0}}),n=t.map(({collection:o,fullPath:i})=>[o,i]);await r(n)},So=async({collection:t,filter:e,...r})=>{let{del_filtered_assets:n}=await E(r);return n(t,_t(e))},Po=async({collection:t,fullPath:e,...r})=>{let{get_asset:n}=await E(r);return S(await n(t,e))},Co=async({assets:t,...e})=>{let{get_many_assets:r}=await E(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);return(await r(n)).map(([i,s])=>S(s))};var vo=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Su=t=>Fo(t),Pu=t=>Fo({filename:t.data.name,...t}),Fo=async({filename:t,data:e,collection:r,headers:n=[],fullPath:o,token:i,satellite:s,encoding:a,description:l})=>{let u=T(s?.identity),p=decodeURI(t),d=o??`/${r}/${p}`,m={...s,identity:u};return await xo({asset:{data:e,filename:p,collection:r,token:i,headers:n,fullPath:d,encoding:a,description:l},satellite:m,options:{certified:!0}}),{downloadUrl:Uo({satellite:m,assetKey:{fullPath:d,token:i}}),fullPath:d,name:p}},Cu=async({collection:t,filter:e,satellite:r,options:n})=>{let o={...r,identity:T(r?.identity)},{items:i,...s}=await Ro({collection:t,filter:e??{},satellite:o,options:n??tt}),a=i.map(({key:{full_path:l,token:u,name:p,owner:d,description:m},headers:f,encodings:N,created_at:V,updated_at:H})=>{let k=S(u);return{fullPath:l,description:S(m),name:p,downloadUrl:Uo({satellite:o,assetKey:{fullPath:l,token:k}}),token:k,headers:f,encodings:N.reduce((w,[_,{modified:P,sha256:x,total_length:R}])=>({...w,[_]:{modified:P,sha256:vo(x),total_length:R}}),{}),owner:d.toText(),created_at:V,updated_at:H}});return{items:a,assets:a,...s}},vu=async({collection:t,filter:e,satellite:r,options:n})=>{let o={...r,identity:T(r?.identity)};return await Eo({collection:t,satellite:o,filter:e??{},options:n??tt})},Fu=({collection:t,fullPath:e,satellite:r})=>Ao({collection:t,fullPath:e,satellite:{...r,identity:T(r?.identity)},options:{certified:!0}}),Uu=({assets:t,satellite:e})=>bo({assets:t,satellite:{...e,identity:T(e?.identity)},options:{certified:!0}}),ku=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:T(e?.identity)};return await So({collection:t,satellite:n,filter:r??{},options:{certified:!0}})},Bu=async({satellite:t,options:e,...r})=>{let n=T(t?.identity);return await Po({...r,satellite:{...t,identity:n},options:e??tt})},Vu=async({satellite:t,options:e,...r})=>{let n=T(t?.identity);return await Co({...r,satellite:{...t,identity:n},options:e??tt})},Uo=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:T(r?.identity)};return`${no(n)}${t}${g(e)?`?token=${e}`:""}`};var Ns=t=>{let e=t?.satelliteId??To();Ve(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??No();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},Gu=t=>ws(t),ws=async t=>{let e=Ns(t);L.getInstance().set(e),await Hr();let r=e.workers?.auth!==void 0?Oo(e.workers.auth):void 0;return[...r?[r]:[]]},Wu=t=>I.getInstance().subscribe(t);export{De as InitError,Xe as InternetIdentityProvider,Le as ListError,Dn as NFIDProvider,Qe as SignInError,Ze as SignInInitError,Ie as SignInUserInterruptError,Wu as authSubscribe,vu as countAssets,Ml as countDocs,Fu as deleteAsset,kl as deleteDoc,ku as deleteFilteredAssets,Vl as deleteFilteredDocs,Uu as deleteManyAssets,Bl as deleteManyDocs,Uo as downloadUrl,Bu as getAsset,ho as getDoc,fs as getIdentityOnce,Vu as getManyAssets,Fl as getManyDocs,du as getSatelliteExtendedActor,Gu as initJuno,ws as initSatellite,Cu as listAssets,jl as listDocs,yo as setDoc,Ul as setManyDocs,ps as signIn,$r as signOut,ms as unsafeIdentity,Su as uploadBlob,Pu as uploadFile};
16
16
  /*! Bundled license information:
17
17
 
18
18
  buffer/index.js: