@junobuild/core-standalone 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +6 -6
- package/dist/browser/index.js.map +4 -4
- package/dist/node/index.mjs +23 -23
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/index.d.ts +1 -0
- package/dist/types/services/auth.services.d.ts +2 -1
- package/dist/types/types/errors.types.d.ts +6 -0
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import{A as mt,B as Qt,C as Zt,D as Ce,E as D,F as It,G as Ue,a as yr,b as Ai,c as Be,d as Ti,e as gr,f as g,g as P,h as I,i as _r,j as wr,k as xr,l as Bt,m as Fe,n as Ft,o as Ei,p as ke,q as st,r as ft,s as vi,t as br,u as Xt,v as V}from"./chunk-YQER5335.js";var Er=yr(Dt=>{"use strict";Dt.byteLength=Si;Dt.toByteArray=Oi;Dt.fromByteArray=Fi;var $=[],k=[],Ni=typeof Uint8Array<"u"?Uint8Array:Array,Ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(at=0,Ar=Ve.length;at<Ar;++at)$[at]=Ve[at],k[Ve.charCodeAt(at)]=at;var at,Ar;k[45]=62;k[95]=63;function Tr(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 Si(t){var e=Tr(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Pi(t,e,r){return(e+r)*3/4-r}function Oi(t){var e,r=Tr(t),n=r[0],i=r[1],o=new Ni(Pi(t,n,i)),s=0,a=i>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)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=k[t.charCodeAt(l)]<<2|k[t.charCodeAt(l+1)]>>4,o[s++]=e&255),i===1&&(e=k[t.charCodeAt(l)]<<10|k[t.charCodeAt(l+1)]<<4|k[t.charCodeAt(l+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Ri(t){return $[t>>18&63]+$[t>>12&63]+$[t>>6&63]+$[t&63]}function Bi(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(Ri(n));return i.join("")}function Fi(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(Bi(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push($[e>>2]+$[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push($[e>>10]+$[e>>4&63]+$[e<<2&63]+"=")),i.join("")}});var qr=yr(_t=>{"use strict";var Ke=Er(),yt=Ti(),vr=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;_t.Buffer=c;_t.SlowBuffer=Mi;_t.INSPECT_MAX_BYTES=50;var Lt=2147483647;_t.kMaxLength=Lt;c.TYPED_ARRAY_SUPPORT=ki();!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 ki(){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 z(t){if(t>Lt)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 qe(t)}return Or(t,e,r)}c.poolSize=8192;function Or(t,e,r){if(typeof t=="string")return Ui(t,e);if(ArrayBuffer.isView(t))return Vi(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(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return je(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 i=Ki(t);if(i)return i;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 Or(t,e,r)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function Rr(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 Ci(t,e,r){return Rr(t),t<=0?z(t):e!==void 0?typeof r=="string"?z(t).fill(e,r):z(t).fill(e):z(t)}c.alloc=function(t,e,r){return Ci(t,e,r)};function qe(t){return Rr(t),z(t<0?0:He(t)|0)}c.allocUnsafe=function(t){return qe(t)};c.allocUnsafeSlow=function(t){return qe(t)};function Ui(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Br(t,e)|0,n=z(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Me(t){let e=t.length<0?0:He(t.length)|0,r=z(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Vi(t){if(q(t,Uint8Array)){let e=new Uint8Array(t);return je(e.buffer,e.byteOffset,e.byteLength)}return Me(t)}function je(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 Ki(t){if(c.isBuffer(t)){let e=He(t.length)|0,r=z(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Ge(t.length)?z(0):Me(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Me(t.data)}function He(t){if(t>=Lt)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Lt.toString(16)+" bytes");return t|0}function Mi(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(q(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),q(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,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<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 i=c.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(q(s,Uint8Array))o+s.length>i.length?(c.isBuffer(s)||(s=c.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(c.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Br(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(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 i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return $e(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return $r(t).length;default:if(i)return n?-1:$e(t).length;e=(""+e).toLowerCase(),i=!0}}c.byteLength=Br;function ji(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 Qi(this,e,r);case"utf8":case"utf-8":return kr(this,e,r);case"ascii":return Ji(this,e,r);case"latin1":case"binary":return Xi(this,e,r);case"base64":return Yi(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Zi(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}c.prototype._isBuffer=!0;function ct(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)ct(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)ct(this,r,r+3),ct(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)ct(this,r,r+7),ct(this,r+1,r+6),ct(this,r+2,r+5),ct(this,r+3,r+4);return this};c.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?kr(this,0,e):ji.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=_t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};vr&&(c.prototype[vr]=c.prototype.inspect);c.prototype.compare=function(e,r,n,i,o){if(q(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),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,a=n-r,l=Math.min(s,a),u=this.slice(i,o),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 Fr(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Ge(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=c.from(e,n)),c.isBuffer(e))return e.length===0?-1:Nr(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Nr(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Nr(t,e,r,n,i){let o=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;o=2,s/=2,a/=2,r/=2}function l(p,d){return o===1?p[d]:p.readUInt16BE(d*o)}let u;if(i){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*o}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 Fr(this,e,r,n,!0)};c.prototype.lastIndexOf=function(e,r,n){return Fr(this,e,r,n,!1)};function $i(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(Ge(a))return s;t[r+s]=a}return s}function qi(t,e,r,n){return te($e(e,t.length-r),t,r,n)}function Hi(t,e,r,n){return te(to(e),t,r,n)}function Wi(t,e,r,n){return te($r(e),t,r,n)}function Gi(t,e,r,n){return te(eo(e,t.length-r),t,r,n)}c.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return $i(this,e,r,n);case"utf8":case"utf-8":return qi(this,e,r,n);case"ascii":case"latin1":case"binary":return Hi(this,e,r,n);case"base64":return Wi(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gi(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).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?Ke.fromByteArray(t):Ke.fromByteArray(t.slice(e,r))}function kr(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let l,u,p,d;switch(a){case 1:o<128&&(s=o);break;case 2:l=t[i+1],(l&192)===128&&(d=(o&31)<<6|l&63,d>127&&(s=d));break;case 3:l=t[i+1],u=t[i+2],(l&192)===128&&(u&192)===128&&(d=(o&15)<<12|(l&63)<<6|u&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:l=t[i+1],u=t[i+2],p=t[i+3],(l&192)===128&&(u&192)===128&&(p&192)===128&&(d=(o&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),i+=a}return zi(n)}var Sr=4096;function zi(t){let e=t.length;if(e<=Sr)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Sr));return r}function Ji(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Xi(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Qi(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=e;o<r;++o)i+=ro[t[o]];return i}function Zi(t,e,r){let n=t.slice(e,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}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 i=this.subarray(e,r);return Object.setPrototypeOf(i,c.prototype),i};function v(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||v(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};c.prototype.readUintBE=c.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||v(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};c.prototype.readUint8=c.prototype.readUInt8=function(e,r){return e=e>>>0,r||v(e,1,this.length),this[e]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||v(e,2,this.length),this[e]|this[e+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||v(e,2,this.length),this[e]<<8|this[e+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||v(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||v(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};c.prototype.readBigUInt64LE=L(function(e){e=e>>>0,gt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&kt(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});c.prototype.readBigUInt64BE=L(function(e){e=e>>>0,gt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&kt(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});c.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||v(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};c.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||v(e,r,this.length);let i=r,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};c.prototype.readInt8=function(e,r){return e=e>>>0,r||v(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};c.prototype.readInt16LE=function(e,r){e=e>>>0,r||v(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||v(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||v(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||v(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};c.prototype.readBigInt64LE=L(function(e){e=e>>>0,gt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&kt(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});c.prototype.readBigInt64BE=L(function(e){e=e>>>0,gt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&kt(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});c.prototype.readFloatLE=function(e,r){return e=e>>>0,r||v(e,4,this.length),yt.read(this,e,!0,23,4)};c.prototype.readFloatBE=function(e,r){return e=e>>>0,r||v(e,4,this.length),yt.read(this,e,!1,23,4)};c.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||v(e,8,this.length),yt.read(this,e,!0,52,8)};c.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||v(e,8,this.length),yt.read(this,e,!1,52,8)};function B(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;B(this,e,r,n,a,0)}let o=1,s=0;for(this[r]=e&255;++s<n&&(o*=256);)this[r+s]=e/o&255;return r+n};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;B(this,e,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=e&255;--o>=0&&(s*=256);)this[r+o]=e/s&255;return r+n};c.prototype.writeUint8=c.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||B(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||B(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||B(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||B(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||B(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 Cr(t,e,r,n,i){jr(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o;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 Ur(t,e,r,n,i){jr(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o=o>>8,t[r+6]=o,o=o>>8,t[r+5]=o,o=o>>8,t[r+4]=o;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=L(function(e,r=0){return Cr(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=L(function(e,r=0){return Ur(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);B(this,e,r,n,l-1,-l)}let o=0,s=1,a=0;for(this[r]=e&255;++o<n&&(s*=256);)e<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};c.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);B(this,e,r,n,l-1,-l)}let o=n-1,s=1,a=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};c.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||B(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||B(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||B(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||B(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||B(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=L(function(e,r=0){return Cr(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=L(function(e,r=0){return Ur(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Vr(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Kr(t,e,r,n,i){return e=+e,r=r>>>0,i||Vr(t,e,r,4,34028234663852886e22,-34028234663852886e22),yt.write(t,e,r,n,23,4),r+4}c.prototype.writeFloatLE=function(e,r,n){return Kr(this,e,r,!0,n)};c.prototype.writeFloatBE=function(e,r,n){return Kr(this,e,r,!1,n)};function Mr(t,e,r,n,i){return e=+e,r=r>>>0,i||Vr(t,e,r,8,17976931348623157e292,-17976931348623157e292),yt.write(t,e,r,n,52,8),r+8}c.prototype.writeDoubleLE=function(e,r,n){return Mr(this,e,r,!0,n)};c.prototype.writeDoubleBE=function(e,r,n){return Mr(this,e,r,!1,n)};c.prototype.copy=function(e,r,n,i){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===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(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),o};c.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="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 o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{let s=c.isBuffer(e)?e:c.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var ht={};function We(t,e,r){ht[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(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}We("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);We("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);We("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Pr(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Pr(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Pr(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 Ii(t,e,r){gt(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&kt(e,t.length-(r+1))}function jr(t,e,r,n,i,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new ht.ERR_OUT_OF_RANGE("value",a,t)}Ii(n,i,o)}function gt(t,e){if(typeof t!="number")throw new ht.ERR_INVALID_ARG_TYPE(e,"number",t)}function kt(t,e,r){throw Math.floor(t)!==t?(gt(t,r),new ht.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ht.ERR_BUFFER_OUT_OF_BOUNDS:new ht.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Di=/[^+/0-9A-Za-z-_]/g;function Li(t){if(t=t.split("=")[0],t=t.trim().replace(Di,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function $e(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function to(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function eo(t,e){let r,n,i,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function $r(t){return Ke.toByteArray(Li(t))}function te(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function q(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Ge(t){return t!==t}var ro=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function L(t){return typeof BigInt>"u"?no:t}function no(){throw new Error("BigInt not supported")}});var Qr=Be(qr());var re={};Ai(re,{backoff:()=>Yr,chain:()=>zr,conditionalDelay:()=>Wr,defaultStrategy:()=>ee,maxAttempts:()=>oo,once:()=>Hr,throttle:()=>so,timeout:()=>Gr});var io=5*60*1e3;function ee(){return zr(Wr(Hr(),1e3),Yr(1e3,1.2),Gr(io))}function Hr(){let t=!0;return async()=>t?(t=!1,!0):!1}function Wr(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(o=>setTimeout(o,e))}}function oo(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
|
|
1
|
+
import{A as mt,B as Zt,C as It,D as Ve,E as D,F as Dt,G as Ke,a as wr,b as vi,c as ke,d as Ni,e as xr,f as g,g as P,h as I,i as br,j as Ar,k as Tr,l as Bt,m as Ce,n as Ft,o as Si,p as Ue,q as st,r as ft,s as Pi,t as Er,u as Qt,v as V}from"./chunk-YQER5335.js";var Sr=wr(Lt=>{"use strict";Lt.byteLength=Ri;Lt.toByteArray=Fi;Lt.fromByteArray=Ui;var $=[],k=[],Oi=typeof Uint8Array<"u"?Uint8Array:Array,Me="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(at=0,vr=Me.length;at<vr;++at)$[at]=Me[at],k[Me.charCodeAt(at)]=at;var at,vr;k[45]=62;k[95]=63;function Nr(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 Ri(t){var e=Nr(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Bi(t,e,r){return(e+r)*3/4-r}function Fi(t){var e,r=Nr(t),n=r[0],i=r[1],o=new Oi(Bi(t,n,i)),s=0,a=i>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)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=k[t.charCodeAt(l)]<<2|k[t.charCodeAt(l+1)]>>4,o[s++]=e&255),i===1&&(e=k[t.charCodeAt(l)]<<10|k[t.charCodeAt(l+1)]<<4|k[t.charCodeAt(l+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function ki(t){return $[t>>18&63]+$[t>>12&63]+$[t>>6&63]+$[t&63]}function Ci(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(ki(n));return i.join("")}function Ui(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(Ci(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push($[e>>2]+$[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push($[e>>10]+$[e>>4&63]+$[e<<2&63]+"=")),i.join("")}});var Gr=wr(_t=>{"use strict";var je=Sr(),yt=Ni(),Pr=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;_t.Buffer=c;_t.SlowBuffer=qi;_t.INSPECT_MAX_BYTES=50;var te=2147483647;_t.kMaxLength=te;c.TYPED_ARRAY_SUPPORT=Vi();!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 Vi(){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 Y(t){if(t>te)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 We(t)}return Fr(t,e,r)}c.poolSize=8192;function Fr(t,e,r){if(typeof t=="string")return Mi(t,e);if(ArrayBuffer.isView(t))return ji(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(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return qe(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 i=$i(t);if(i)return i;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 Fr(t,e,r)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function kr(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 Ki(t,e,r){return kr(t),t<=0?Y(t):e!==void 0?typeof r=="string"?Y(t).fill(e,r):Y(t).fill(e):Y(t)}c.alloc=function(t,e,r){return Ki(t,e,r)};function We(t){return kr(t),Y(t<0?0:Ge(t)|0)}c.allocUnsafe=function(t){return We(t)};c.allocUnsafeSlow=function(t){return We(t)};function Mi(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Cr(t,e)|0,n=Y(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function $e(t){let e=t.length<0?0:Ge(t.length)|0,r=Y(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function ji(t){if(q(t,Uint8Array)){let e=new Uint8Array(t);return qe(e.buffer,e.byteOffset,e.byteLength)}return $e(t)}function qe(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 $i(t){if(c.isBuffer(t)){let e=Ge(t.length)|0,r=Y(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||ze(t.length)?Y(0):$e(t);if(t.type==="Buffer"&&Array.isArray(t.data))return $e(t.data)}function Ge(t){if(t>=te)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+te.toString(16)+" bytes");return t|0}function qi(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(q(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),q(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,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<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 i=c.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(q(s,Uint8Array))o+s.length>i.length?(c.isBuffer(s)||(s=c.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(c.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Cr(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(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 i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return He(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Wr(t).length;default:if(i)return n?-1:He(t).length;e=(""+e).toLowerCase(),i=!0}}c.byteLength=Cr;function Hi(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 Di(this,e,r);case"utf8":case"utf-8":return Vr(this,e,r);case"ascii":return Zi(this,e,r);case"latin1":case"binary":return Ii(this,e,r);case"base64":return Xi(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Li(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}c.prototype._isBuffer=!0;function ct(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)ct(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)ct(this,r,r+3),ct(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)ct(this,r,r+7),ct(this,r+1,r+6),ct(this,r+2,r+5),ct(this,r+3,r+4);return this};c.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Vr(this,0,e):Hi.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=_t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Pr&&(c.prototype[Pr]=c.prototype.inspect);c.prototype.compare=function(e,r,n,i,o){if(q(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),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,a=n-r,l=Math.min(s,a),u=this.slice(i,o),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 Ur(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,ze(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=c.from(e,n)),c.isBuffer(e))return e.length===0?-1:Or(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Or(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Or(t,e,r,n,i){let o=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;o=2,s/=2,a/=2,r/=2}function l(p,d){return o===1?p[d]:p.readUInt16BE(d*o)}let u;if(i){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*o}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 Ur(this,e,r,n,!0)};c.prototype.lastIndexOf=function(e,r,n){return Ur(this,e,r,n,!1)};function Wi(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(ze(a))return s;t[r+s]=a}return s}function Gi(t,e,r,n){return ee(He(e,t.length-r),t,r,n)}function Yi(t,e,r,n){return ee(no(e),t,r,n)}function zi(t,e,r,n){return ee(Wr(e),t,r,n)}function Ji(t,e,r,n){return ee(io(e,t.length-r),t,r,n)}c.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return Wi(this,e,r,n);case"utf8":case"utf-8":return Gi(this,e,r,n);case"ascii":case"latin1":case"binary":return Yi(this,e,r,n);case"base64":return zi(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ji(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Xi(t,e,r){return e===0&&r===t.length?je.fromByteArray(t):je.fromByteArray(t.slice(e,r))}function Vr(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let l,u,p,d;switch(a){case 1:o<128&&(s=o);break;case 2:l=t[i+1],(l&192)===128&&(d=(o&31)<<6|l&63,d>127&&(s=d));break;case 3:l=t[i+1],u=t[i+2],(l&192)===128&&(u&192)===128&&(d=(o&15)<<12|(l&63)<<6|u&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:l=t[i+1],u=t[i+2],p=t[i+3],(l&192)===128&&(u&192)===128&&(p&192)===128&&(d=(o&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),i+=a}return Qi(n)}var Rr=4096;function Qi(t){let e=t.length;if(e<=Rr)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Rr));return r}function Zi(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Ii(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Di(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=e;o<r;++o)i+=oo[t[o]];return i}function Li(t,e,r){let n=t.slice(e,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}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 i=this.subarray(e,r);return Object.setPrototypeOf(i,c.prototype),i};function v(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||v(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};c.prototype.readUintBE=c.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||v(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};c.prototype.readUint8=c.prototype.readUInt8=function(e,r){return e=e>>>0,r||v(e,1,this.length),this[e]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||v(e,2,this.length),this[e]|this[e+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||v(e,2,this.length),this[e]<<8|this[e+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||v(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||v(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};c.prototype.readBigUInt64LE=L(function(e){e=e>>>0,gt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&kt(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});c.prototype.readBigUInt64BE=L(function(e){e=e>>>0,gt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&kt(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});c.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||v(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};c.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||v(e,r,this.length);let i=r,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};c.prototype.readInt8=function(e,r){return e=e>>>0,r||v(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};c.prototype.readInt16LE=function(e,r){e=e>>>0,r||v(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||v(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||v(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||v(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};c.prototype.readBigInt64LE=L(function(e){e=e>>>0,gt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&kt(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});c.prototype.readBigInt64BE=L(function(e){e=e>>>0,gt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&kt(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});c.prototype.readFloatLE=function(e,r){return e=e>>>0,r||v(e,4,this.length),yt.read(this,e,!0,23,4)};c.prototype.readFloatBE=function(e,r){return e=e>>>0,r||v(e,4,this.length),yt.read(this,e,!1,23,4)};c.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||v(e,8,this.length),yt.read(this,e,!0,52,8)};c.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||v(e,8,this.length),yt.read(this,e,!1,52,8)};function B(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;B(this,e,r,n,a,0)}let o=1,s=0;for(this[r]=e&255;++s<n&&(o*=256);)this[r+s]=e/o&255;return r+n};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;B(this,e,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=e&255;--o>=0&&(s*=256);)this[r+o]=e/s&255;return r+n};c.prototype.writeUint8=c.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||B(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||B(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||B(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||B(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||B(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 Kr(t,e,r,n,i){Hr(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o;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 Mr(t,e,r,n,i){Hr(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o=o>>8,t[r+6]=o,o=o>>8,t[r+5]=o,o=o>>8,t[r+4]=o;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=L(function(e,r=0){return Kr(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=L(function(e,r=0){return Mr(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);B(this,e,r,n,l-1,-l)}let o=0,s=1,a=0;for(this[r]=e&255;++o<n&&(s*=256);)e<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};c.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);B(this,e,r,n,l-1,-l)}let o=n-1,s=1,a=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};c.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||B(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||B(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||B(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||B(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||B(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=L(function(e,r=0){return Kr(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=L(function(e,r=0){return Mr(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function jr(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function $r(t,e,r,n,i){return e=+e,r=r>>>0,i||jr(t,e,r,4,34028234663852886e22,-34028234663852886e22),yt.write(t,e,r,n,23,4),r+4}c.prototype.writeFloatLE=function(e,r,n){return $r(this,e,r,!0,n)};c.prototype.writeFloatBE=function(e,r,n){return $r(this,e,r,!1,n)};function qr(t,e,r,n,i){return e=+e,r=r>>>0,i||jr(t,e,r,8,17976931348623157e292,-17976931348623157e292),yt.write(t,e,r,n,52,8),r+8}c.prototype.writeDoubleLE=function(e,r,n){return qr(this,e,r,!0,n)};c.prototype.writeDoubleBE=function(e,r,n){return qr(this,e,r,!1,n)};c.prototype.copy=function(e,r,n,i){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===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(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),o};c.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="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 o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{let s=c.isBuffer(e)?e:c.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var ht={};function Ye(t,e,r){ht[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(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Ye("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ye("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Ye("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Br(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Br(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Br(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 to(t,e,r){gt(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&kt(e,t.length-(r+1))}function Hr(t,e,r,n,i,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new ht.ERR_OUT_OF_RANGE("value",a,t)}to(n,i,o)}function gt(t,e){if(typeof t!="number")throw new ht.ERR_INVALID_ARG_TYPE(e,"number",t)}function kt(t,e,r){throw Math.floor(t)!==t?(gt(t,r),new ht.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ht.ERR_BUFFER_OUT_OF_BOUNDS:new ht.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var eo=/[^+/0-9A-Za-z-_]/g;function ro(t){if(t=t.split("=")[0],t=t.trim().replace(eo,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function He(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function no(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function io(t,e){let r,n,i,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function Wr(t){return je.toByteArray(ro(t))}function ee(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function q(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function ze(t){return t!==t}var oo=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function L(t){return typeof BigInt>"u"?so:t}function so(){throw new Error("BigInt not supported")}});var Dr=ke(Gr());var ne={};vi(ne,{backoff:()=>Xr,chain:()=>Qr,conditionalDelay:()=>zr,defaultStrategy:()=>re,maxAttempts:()=>co,once:()=>Yr,throttle:()=>lo,timeout:()=>Jr});var ao=5*60*1e3;function re(){return Qr(zr(Yr(),1e3),Xr(1e3,1.2),Jr(ao))}function Yr(){let t=!0;return async()=>t?(t=!1,!0):!1}function zr(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(o=>setTimeout(o,e))}}function co(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
|
|
2
2
|
Request ID: ${P(n)}
|
|
3
3
|
Request status: ${i}
|
|
4
|
-
`)}}function
|
|
4
|
+
`)}}function lo(t){return()=>new Promise(e=>setTimeout(e,t))}function Jr(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
|
|
5
5
|
Request ID: ${P(n)}
|
|
6
6
|
Request status: ${i}
|
|
7
|
-
`)}}function
|
|
7
|
+
`)}}function Xr(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function Qr(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}async function Je(t,e,r,n=re(),i,o){var s;let a=[new TextEncoder().encode("request_status"),r],l=i??await((s=t.createReadStateRequest)===null||s===void 0?void 0:s.call(t,{paths:[a]}));l.body.content.ingress_expiry=new Er(3e5);let 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 Qt.create({certificate:u.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:o}),d=V(p.lookup([...a,new TextEncoder().encode("status")])),f;switch(typeof d>"u"?f=D.Unknown:f=new TextDecoder().decode(d),f){case D.Replied:return{reply:V(p.lookup([...a,"reply"])),certificate:p};case D.Received:case D.Unknown:case D.Processing:return await n(e,r,f),Je(t,e,r,n,l,o);case D.Rejected:{let y=new Uint8Array(V(p.lookup([...a,"reject_code"])))[0],w=new TextDecoder().decode(V(p.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
|
|
8
8
|
Request ID: ${P(r)}
|
|
9
9
|
Reject code: ${y}
|
|
10
10
|
Reject text: ${w}
|
|
11
11
|
`)}case D.Done:throw new Error(`Call was marked as done but we never saw the reply:
|
|
12
12
|
Request ID: ${P(r)}
|
|
13
|
-
`)}throw new Error("unreachable")}var
|
|
14
|
-
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},ze=class extends ne{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=gr[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},ie=class extends ne{constructor(e,r,n,i,o,s,a){super(e,r,"update",Object.assign({"Request ID":P(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(o),"Reject message":s}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=o,this.reject_message=s,this.error_code=a}},C=Symbol.for("ic-agent-metadata"),tt=class t{constructor(e){this[C]=Object.freeze(e)}static agentOf(e){return e[C].config.agent}static interfaceOf(e){return e[C].service}static canisterIdOf(e){return g.from(e[C].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],o=[...new Uint8Array(e.module)],s=typeof r.canisterId=="string"?g.fromText(r.canisterId):r.canisterId;await Xr(r).install_code({mode:n,arg:i,wasm_module:o,canister_id:s,sender_canister_version:[]})}static async createCanister(e,r){function n(o){return[{controllers:o.controllers?[o.controllers]:[],compute_allocation:o.compute_allocation?[o.compute_allocation]:[],freezing_threshold:o.freezing_threshold?[o.freezing_threshold]:[],memory_allocation:o.memory_allocation?[o.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await Xr(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:Ft});class i extends t{constructor(s){if(!s.canisterId)throw new Bt(`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"?g.fromText(s.canisterId):s.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Zr),s),{canisterId:a}),service:n});for(let[l,u]of n._fields)r?.httpDetails&&u.annotations.push(Je),r?.certificate&&u.annotations.push(Ir),this[l]=lo(this,l,u,s.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Bt(`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 wt(t,e){let r=Ft.decode(t,Qr.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Zr={pollingStrategyFactory:re.defaultStrategy},Je="http-details",Ir="certificate";function lo(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(s,...a)=>{var l,u;s=Object.assign(Object.assign({},s),(u=(l=t[C].config).queryTransform)===null||u===void 0?void 0:u.call(l,e,a,Object.assign(Object.assign({},t[C].config),s)));let p=s.agent||t[C].config.agent||Ue(),d=g.from(s.canisterId||t[C].config.canisterId),f=Ft.encode(r.argTypes,a),y=await p.query(d,{methodName:e,arg:f,effectiveCanisterId:s.effectiveCanisterId}),w=Object.assign(Object.assign({},y.httpDetails),{requestDetails:y.requestDetails});switch(y.status){case"rejected":throw new ze(d,e,y);case"replied":return r.annotations.includes(Je)?{httpDetails:w,result:wt(r.retTypes,y.reply.arg)}:wt(r.retTypes,y.reply.arg)}}:i=async(s,...a)=>{var l,u;s=Object.assign(Object.assign({},s),(u=(l=t[C].config).callTransform)===null||u===void 0?void 0:u.call(l,e,a,Object.assign(Object.assign({},t[C].config),s)));let p=s.agent||t[C].config.agent||Ue(),{canisterId:d,effectiveCanisterId:f,pollingStrategyFactory:y}=Object.assign(Object.assign(Object.assign({},Zr),t[C].config),s),w=g.from(d),m=f!==void 0?g.from(f):w,F=Ft.encode(r.argTypes,a);if(p.rootKey==null)throw new Bt("Agent root key not initialized before making call");let{requestId:_,response:A,requestDetails:Y}=await p.call(w,{methodName:e,arg:F,effectiveCanisterId:m}),R,S;if(A.body&&A.body.certificate){let U=A.body.certificate;S=await Xt.create({certificate:Fe(U),rootKey:p.rootKey,canisterId:g.from(d),blsVerify:n});let O=[new TextEncoder().encode("request_status"),_];switch(new TextDecoder().decode(V(S.lookup([...O,"status"])))){case"replied":R=V(S.lookup([...O,"reply"]));break;case"rejected":{let it=new Uint8Array(V(S.lookup([...O,"reject_code"])))[0],Q=new TextDecoder().decode(V(S.lookup([...O,"reject_message"]))),ot=V(S.lookup([...O,"error_code"])),Z=ot?new TextDecoder().decode(ot):void 0;throw new ie(w,e,_,A,it,Q,Z)}}}else if(A.body&&"reject_message"in A.body){let{reject_code:U,reject_message:O,error_code:j}=A.body;throw new ie(w,e,_,A,U,O,j)}if(A.status===202){let U=y(),O=await Ye(p,m,_,U,n);S=O.certificate,R=O.reply}let X=r.annotations.includes(Je),dt=r.annotations.includes(Ir),pt=Object.assign(Object.assign({},A),{requestDetails:Y});if(R!==void 0)return X&&dt?{httpDetails:pt,certificate:S,result:wt(r.retTypes,R)}:dt?{certificate:S,result:wt(r.retTypes,R)}:X?{httpDetails:pt,result:wt(r.retTypes,R)}:wt(r.retTypes,R);if(r.retTypes.length===0)return X?{httpDetails:A,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let o=(...s)=>i({},...s);return o.withOptions=s=>(...a)=>i(s,...a),o}function Xr(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:g.from(t.effectiveCanisterId)};let i=n[0],o=g.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(o=g.from(i.canister_id)),{effectiveCanisterId:o}}return tt.createActor(Jr,Object.assign(Object.assign(Object.assign({},t),{canisterId:g.fromHex("")}),{callTransform:e,queryTransform:e}))}var po=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(po||{}),Hs=BigInt(1e8);var h=t=>t==null,T=t=>!h(t);var fo=class extends Error{},oe=(t,e)=>{if(t==null)throw new fo(e)};var Dr="abcdefghijklmnopqrstuvwxyz234567",Ct=Object.create(null);for(let t=0;t<Dr.length;t++)Ct[Dr[t]]=t;Ct[0]=Ct.o;Ct[1]=Ct.i;var Ys=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 x=t=>T(t)?[t]:[],N=t=>t?.[0];var Xe="__bigint__",Qe="__principal__",Ze="__uint8array__",Lr=(t,e)=>typeof e=="bigint"?{[Xe]:`${e}`}:T(e)&&e instanceof g?{[Qe]:e.toText()}:T(e)&&e instanceof Uint8Array?{[Ze]:Array.from(e)}:e,tn=(t,e)=>{let r=n=>e[n];return T(e)&&typeof e=="object"&&Xe in e?BigInt(r(Xe)):T(e)&&typeof e=="object"&&Qe in e?g.fromText(r(Qe)):T(e)&&typeof e=="object"&&Ze in e?Uint8Array.from(r(Ze)):e};var xt=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 J=class t extends xt{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 Ie=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var en=BigInt(144e11),rn=!1,nn={width:576,height:576},on={width:505,height:705},sn="internetcomputer.org";var bt="http://127.0.0.1:5987",an="rdmx6-jaaaa-aaaaa-aaadq-cai";var H=class t extends xt{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}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var cn=async t=>{let e=new Blob([JSON.stringify(t,Lr)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},se=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(),tn)},ae=()=>typeof window<"u";var De=({width:t,height:e})=>{if(!ae()||h(window)||h(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,o=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=${i}, left=${o}`};var ce=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=H.getInstance().get()?.container;if(h(n)||n===!1)return`https://identity.${this.#t??sn}`;let i=H.getInstance().get(),o=T(i)&&T(i?.internetIdentityId)?i.internetIdentityId:an,{host:s,protocol:a}=new URL(n===!0?bt:n);return/apple/i.test(navigator?.vendor)?`${a}//${s}?canisterId=${o}`:`${a}//${o}.${s.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:De(nn)},identityProvider:r()}}},ln=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:De(on)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};var At=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 i=await this.createAgent({identity:e,...r});return this.#t={...this.#t??{},[n]:i},i}return this.#t[n]}reset(){this.#t=null}async createAgent({identity:e,fetch:r,container:n}){let o=T(n)&&n!==!1?n===!0?bt:n:"https://icp-api.io",s=T(n);return await It.create({identity:e,shouldFetchRootKey:s,host:o,...r&&{fetch:r}})}};var Tt=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,buildType:n,...i}){let o=`${n}#${r.getPrincipal().toText()}#${e};`;if(h(this.#t)||h(this.#t[o])){let s=await this.createActor({satelliteId:e,identity:r,...i});return this.#t={...this.#t??{},[o]:s},s}return this.#t[o]}reset(){this.#t=null}async createActor({idlFactory:e,satelliteId:r,...n}){let i=await At.getInstance().getAgent(n);return tt.createActor(e,{agent:i,canisterId:r})}};var de=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},et=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)},le,ue,Et,vt;function un(t){return t!==null&&typeof t=="object"}var lt=class t{constructor(e){if(le.set(this,void 0),ue.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");de(this,le,e,"f"),de(this,ue,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=I(e);return this.fromRaw(r)}else if(un(e)){let r=e;if(un(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=Zt(e,Qt).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=Ce(e,Qt);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return et(this,le,"f")}get derKey(){return et(this,ue,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};le=new WeakMap,ue=new WeakMap;lt.RAW_KEY_LENGTH=32;var ut=class t extends st{constructor(e,r){super(),Et.set(this,void 0),vt.set(this,void 0),de(this,Et,lt.from(e),"f"),de(this,vt,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=mt.utils.randomPrivateKey()),_r(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 i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=mt.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(lt.fromDer(I(r)),I(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(lt.fromRaw(e),r)}static fromSecretKey(e){let r=mt.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[P(et(this,Et,"f").toDer()),P(et(this,vt,"f"))]}getKeyPair(){return{secretKey:et(this,vt,"f"),publicKey:et(this,Et,"f")}}getPublicKey(){return et(this,Et,"f")}async sign(e){let r=new Uint8Array(e),n=wr(mt.sign(r,et(this,vt,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,o,s]=[e,r,n].map(a=>(typeof a=="string"&&(a=I(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return mt.verify(o,i,s)}};Et=new WeakMap,vt=new WeakMap;var Le=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};function dn(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 Le("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 Ut=class t extends st{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:i}=e??{},o=dn(i),s=await o.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await o.exportKey("spki",s.publicKey);return new this(s,a,o)}static async fromKeyPair(e,r){let n=dn(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,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 Nt=Be(vi());var mo=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Vt=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)},rt,pe=class{constructor(e){rt.set(this,void 0),mo(this,rt,e,"f")}get rawKey(){return Vt(this,rt,"f").rawKey}get derKey(){return Vt(this,rt,"f").derKey}toDer(){return Vt(this,rt,"f").toDer()}getPublicKey(){return Vt(this,rt,"f")}getPrincipal(){return g.from(Vt(this,rt,"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.")}};rt=new WeakMap;var ho=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},yo=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)},go=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 i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},fe,_o=new TextEncoder().encode("ic-request-auth-delegation"),wo=new TextEncoder().encode(`
|
|
15
|
-
ic-request`);function tr(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return I(t)}var St=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return Nt.value.map(Object.assign({pubkey:Nt.value.bytes(this.pubkey),expiration:Nt.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Nt.value.array(this.targets.map(e=>Nt.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:P(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};async function xo(t,e,r,n){let i=new St(e.toDer(),BigInt(+r)*BigInt(1e6),n),o=new Uint8Array([..._o,...new Uint8Array(ke(i))]),s=await t.sign(o);return{delegation:i,signature:s}}var Kt=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var o,s;let a=await xo(e,r,n,i.targets);return new t([...((o=i.previous)===null||o===void 0?void 0:o.delegations)||[],a],((s=i.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 i=n.map(o=>{let{delegation:s,signature:a}=o,{pubkey:l,expiration:u,targets:p}=s;if(p!==void 0&&!Array.isArray(p))throw new Error("Invalid targets.");return{delegation:new St(tr(l),BigInt("0x"+u),p&&p.map(d=>{if(typeof d!="string")throw new Error("Invalid target.");return g.fromHex(d)})),signature:tr(a)}});return new this(i,tr(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:P(r.pubkey)},i&&{targets:i.map(o=>o.toHex())}),signature:P(n)}}),publicKey:P(this.publicKey)}}},Mt=class extends st{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=go(e,["body"]),i=await ke(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...wo,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},jt=class t extends pe{constructor(e,r){super(e),fe.set(this,void 0),ho(this,fe,r,"f")}get delegation(){return yo(this,fe,"f")}static fromDelegation(e,r){return new t(e,r)}};fe=new WeakMap;function pn(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?g.fromText(i):i)):r.push(typeof n=="string"?g.fromText(n):n));for(let i of r){let o=i.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()===o){a=!1;break}if(a)return!1}}return!0}var Ao=Be(Ei());var fn;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(fn||(fn={}));var mn=["mousedown","mousemove","keydown","touchstart","wheel"],$t=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let o=this._resetTimer.bind(this);window.addEventListener("load",o,!0),mn.forEach(function(a){document.addEventListener(a,o,!0)});let s=(a,l)=>{let u;return(...p)=>{let d=this,f=function(){u=void 0,a.apply(d,p)};clearTimeout(u),u=window.setTimeout(f,l)}};if(e?.captureScroll){let a=s(o,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}o()}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);mn.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 To=(t,e)=>e.some(r=>t instanceof r),hn,yn;function Eo(){return hn||(hn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function vo(){return yn||(yn=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var gn=new WeakMap,rr=new WeakMap,_n=new WeakMap,er=new WeakMap,ir=new WeakMap;function No(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",o),t.removeEventListener("error",s)},o=()=>{r(W(t.result)),i()},s=()=>{n(t.error),i()};t.addEventListener("success",o),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&gn.set(r,t)}).catch(()=>{}),ir.set(e,t),e}function So(t){if(rr.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",o),t.removeEventListener("error",s),t.removeEventListener("abort",s)},o=()=>{r(),i()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",o),t.addEventListener("error",s),t.addEventListener("abort",s)});rr.set(t,e)}var nr={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return rr.get(t);if(e==="objectStoreNames")return t.objectStoreNames||_n.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return W(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 wn(t){nr=t(nr)}function Po(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(me(this),e,...r);return _n.set(n,e.sort?e.sort():[e]),W(n)}:vo().includes(t)?function(...e){return t.apply(me(this),e),W(gn.get(this))}:function(...e){return W(t.apply(me(this),e))}}function Oo(t){return typeof t=="function"?Po(t):(t instanceof IDBTransaction&&So(t),To(t,Eo())?new Proxy(t,nr):t)}function W(t){if(t instanceof IDBRequest)return No(t);if(er.has(t))return er.get(t);let e=Oo(t);return e!==t&&(er.set(t,e),ir.set(e,t)),e}var me=t=>ir.get(t);function bn(t,e,{blocked:r,upgrade:n,blocking:i,terminated:o}={}){let s=indexedDB.open(t,e),a=W(s);return n&&s.addEventListener("upgradeneeded",l=>{n(W(s.result),l.oldVersion,l.newVersion,W(s.transaction),l)}),r&&s.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),a.then(l=>{o&&l.addEventListener("close",()=>o()),i&&l.addEventListener("versionchange",u=>i(u.oldVersion,u.newVersion,u))}).catch(()=>{}),a}var Ro=["get","getKey","getAll","getAllKeys","count"],Bo=["put","add","delete","clear"],or=new Map;function xn(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(or.get(e))return or.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=Bo.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||Ro.includes(r)))return;let o=async function(s,...a){let l=this.transaction(s,i?"readwrite":"readonly"),u=l.store;return n&&(u=u.index(a.shift())),(await Promise.all([u[r](...a),i&&l.done]))[0]};return or.set(e,o),o}wn(t=>({...t,get:(e,r,n)=>xn(e,r)||t.get(e,r,n),has:(e,r)=>!!xn(e,r)||t.has(e,r)}));var An="auth-client-db",Tn="ic-keyval",Fo=async(t=An,e=Tn,r)=>(he&&(localStorage!=null&&localStorage.getItem(K))&&(localStorage.removeItem(K),localStorage.removeItem(M)),await bn(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function ko(t,e,r){return await t.get(e,r)}async function Co(t,e,r,n){return await t.put(e,n,r)}async function Uo(t,e,r){return await t.delete(e,r)}var qt=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=An,storeName:n=Tn,version:i=En}=e??{},o=await Fo(r,n,i);return new t(o,n)}async set(e,r){return await Co(this._db,this._storeName,e,r)}async get(e){var r;return(r=await ko(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await Uo(this._db,this._storeName,e)}};var Vo=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ko=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)},ye,M="identity",K="delegation",vn="iv",En=1,he=typeof window<"u",Ht=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}},Wt=class{constructor(e){ye.set(this,void 0),Vo(this,ye,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}qt.create(Ko(this,ye,"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)}};ye=new WeakMap;var Mo="https://identity.ic0.app",jo="#authorize",sr="ECDSA",ar="Ed25519",$o=500,qo="UserInterrupt",ge=class{constructor(e,r,n,i,o,s,a,l){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=o,this._createOptions=s,this._idpWindow=a,this._eventHandler=l,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let o=(r=e.storage)!==null&&r!==void 0?r:new Wt,s=(n=e.keyType)!==null&&n!==void 0?n:sr,a=null;if(e.identity)a=e.identity;else{let d=await o.get(M);if(!d&&he)try{let f=new Ht,y=await f.get(K),w=await f.get(M);y&&w&&s===sr&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await o.set(K,y),await o.set(M,w),d=y,await f.remove(K),await f.remove(M))}catch(f){console.error("error while attempting to recover localstorage: "+f)}if(d)try{typeof d=="object"?s===ar&&typeof d=="string"?a=await ut.fromJSON(d):a=await Ut.fromKeyPair(d):typeof d=="string"&&(a=ut.fromJSON(d))}catch{}}let l=new ft,u=null;if(a)try{let d=await o.get(K);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=Kt.fromJSON(d),pn(u)?"toDer"in a?l=jt.fromDelegation(a,u):l=Mt.fromDelegation(a,u):(await cr(o),a=null))}catch(d){console.error(d),await cr(o),a=null}let p;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?p=void 0:(u||e.identity)&&(p=$t.create(e.idleOptions)),a||(s===ar?(a=await ut.generate(),await o.set(M,JSON.stringify(a.toJSON()))):(e.storage&&s===sr&&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 '${ar}' as the key type, as it can serialize to a string`),a=await Ut.generate(),await o.set(M,a.getKeyPair()))),new this(l,a,u,o,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,i;let o=e.delegations.map(u=>({delegation:new St(u.delegation.pubkey,u.delegation.expiration,u.delegation.targets),signature:u.signature.buffer})),s=Kt.fromDelegations(o,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=s,"toDer"in a?this._identity=jt.fromDelegation(a,this._chain):this._identity=Mt.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let l=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!l?.disableIdle&&(this.idleManager=$t.create(l),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(K,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,i,o;let s=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||Mo);a.hash=jo,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:s},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(o=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&o!==void 0?o:void 0;let l=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(qo,e?.onError):setTimeout(l,$o))};l()}_getEventHandler(e,r){return async n=>{var i,o,s;if(n.origin!==e.origin){console.warn(`WARNING: expected origin '${e.origin}', got '${n.origin}' (ignoring)`);return}let a=n.data;switch(a.kind){case"authorize-ready":{let l=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(o=r?.derivationOrigin)===null||o===void 0?void 0:o.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 cr(this._storage),this._identity=new ft,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};async function cr(t){await t.remove(M),await t.remove(K),await t.remove(vn)}var _e=()=>ge.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Nn=async({data:t})=>{try{return await se(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var lr=async t=>{let{data:e,version:r,description:n}=t;return{description:x(n),data:await cn(e),version:x(r)}},ur=t=>{let{version:e}=t;return{version:x(e)}},Gt=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:o,...s}=t;return{key:e,description:N(i),owner:r.toText(),data:await se(o),version:N(n),...s}};var Sn=t=>{if(h(t))return x();switch(t.matcher){case"equal":return x({Equal:t.timestamp});case"greaterThan":return x({GreaterThan:t.timestamp});case"lessThan":return x({LessThan:t.timestamp});case"between":return x({Between:[t.timestamps.start,t.timestamps.end]});default:throw new Error("Invalid list matcher for timestamp",t)}},nt=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:h(t)?[]:[{key:x(t.key),description:x(t.description),created_at:Sn(t.createdAt),updated_at:Sn(t.updatedAt)}],paginate:x(h(e)?void 0:{start_after:x(e.startAfter),limit:x(h(e.limit)?void 0:BigInt(e.limit))}),order:x(h(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:x(h(n)?void 0:typeof n=="string"?g.fromText(n):n)});var Pn=({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.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:r,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),o=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),s=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),a=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(o),paginate:t.Opt(s)}),l=t.Record({controllers:t.Vec(t.Principal)}),u=t.Variant({Write:t.Null,Admin:t.Null}),p=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:u,expires_at:t.Opt(t.Nat64)}),d=t.Record({version:t.Opt(t.Nat64)}),f=t.Variant({Db:t.Null,Storage:t.Null}),y=t.Record({version:t.Opt(t.Nat64)}),w=t.Record({cycles:t.Nat,destination_id:t.Principal}),m=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}),F=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),_=t.Record({key:m,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,F)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),A=t.Record({derivation_origin:t.Opt(t.Text)}),Y=t.Record({internet_identity:t.Opt(A)}),R=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),S=t.Record({max_memory_size:t.Opt(R)}),X=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),dt=t.Variant({Deny:t.Null,Allow:t.Null}),pt=t.Record({status_code:t.Nat16,location:t.Text}),U=t.Record({iframe:t.Opt(X),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(R),raw_access:t.Opt(dt),redirects:t.Opt(t.Vec(t.Tuple(t.Text,pt)))}),O=t.Record({db:t.Opt(S),authentication:t.Opt(Y),storage:U}),j=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)}),it=t.Variant({Heap:t.Null,Stable:t.Null}),Q=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),ot=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),Z=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(it),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:Q,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(ot),write:Q}),xe=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)}),Pt=t.Record({memory:it,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}),be=t.Variant({Callback:t.Record({token:Pt,callback:t.Func([],[],["query"])})}),Ae=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(be),status_code:t.Nat16}),Te=t.Record({token:t.Opt(Pt),body:t.Vec(t.Nat8)}),Yt=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}),Ot=t.Record({batch_id:t.Nat}),Ee=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)}),Rt=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,j)),items_length:t.Nat64}),ve=t.Record({stable:t.Nat64,heap:t.Nat64}),Ne=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:u,expires_at:t.Opt(t.Nat64)}),Se=t.Record({controller:Ne,controllers:t.Vec(t.Principal)}),Jt=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Pe=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(it),max_size:t.Opt(t.Nat),read:Q,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(ot),write:Q}),Oe=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),Re=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,a],[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,a],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([l],[t.Vec(t.Tuple(t.Principal,p))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,d],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,a],[],[]),del_filtered_docs:t.Func([t.Text,a],[],[]),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,d))],[],[]),del_rule:t.Func([f,t.Text,y],[],[]),deposit_cycles:t.Func([w],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(_)],["query"]),get_auth_config:t.Func([],[t.Opt(Y)],["query"]),get_config:t.Func([],[O],[]),get_db_config:t.Func([],[t.Opt(S)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(j)],["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(j)))],["query"]),get_rule:t.Func([f,t.Text],[t.Opt(Z)],["query"]),get_storage_config:t.Func([],[U],["query"]),http_request:t.Func([xe],[Ae],["query"]),http_request_streaming_callback:t.Func([Pt],[Te],["query"]),init_asset_upload:t.Func([Yt],[Ot],[]),list_assets:t.Func([t.Text,a],[Ee],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,p))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,zt))],["query"]),list_docs:t.Func([t.Text,a],[Rt],["query"]),list_rules:t.Func([f],[t.Vec(t.Tuple(t.Text,Z))],["query"]),memory_size:t.Func([],[ve],["query"]),set_auth_config:t.Func([Y],[],[]),set_controllers:t.Func([Se],[t.Vec(t.Tuple(t.Principal,p))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([S],[],[]),set_doc:t.Func([t.Text,t.Text,Jt],[j],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Jt))],[t.Vec(t.Tuple(t.Text,j))],[]),set_rule:t.Func([f,t.Text,Pe],[Z],[]),set_storage_config:t.Func([U],[],[]),upload_asset_chunk:t.Func([Oe],[Re],[]),version:t.Func([],[t.Text],["query"])})};var On=({satelliteId:t,container:e})=>{let{satelliteId:r}=dr({satelliteId:t}),{container:n}=pr({container:e});if(T(n)&&n!==!1){let{host:i,protocol:o}=new URL(n===!0?bt:n);return`${o}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},dr=({satelliteId:t})=>T(t)?{satelliteId:t}:H.getInstance().get()??{satelliteId:void 0},pr=({container:t})=>T(t)?{container:t}:H.getInstance().get()??{container:void 0};var E=t=>Bn({idlFactory:Pn,buildType:"stock",...t}),Rn=({idlFactory:t,...e})=>Bn({idlFactory:t,buildType:"extended",...e}),Bn=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=dr({satelliteId:t});oe(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=pr({container:e});return await Tt.getInstance().getActor({satelliteId:n,container:i,...r})};var Fn=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await E(r),i=N(await n(t,e));if(!h(i))return Gt({doc:i,key:e})},kn=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await E(e),n=t.map(({collection:s,key:a})=>[s,a]),i=await r(n),o=[];for(let[s,a]of i){let l=N(a);o.push(T(l)?await Gt({key:s,doc:l}):void 0)}return o},Cn=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await E(r),{key:i}=e,o=await lr(e),s=await n(t,i,o);return await Gt({key:i,doc:s})},Un=async({docs:t,satellite: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 lr(a)])}let i=await r(n),o=[];for(let[s,a]of i)o.push(await Gt({key:s,doc:a}));return o},Vn=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await E(r),{key:i}=e;return n(t,i,ur(e))},Kn=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await E(e),n=t.map(({collection:i,doc:o})=>[i,o.key,ur(o)]);await r(n)},Mn=async({collection:t,filter:e,satellite:r})=>{let{del_filtered_docs:n}=await E(r);return n(t,nt(e))},jn=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await E(r),{items:i,items_page:o,items_length:s,matches_length:a,matches_pages:l}=await n(t,nt(e)),u=[];for(let[p,d]of i){let{data:f,owner:y,description:w,version:m,...F}=d;u.push({key:p,description:N(w),owner:y.toText(),data:await Nn({data:f}),version:N(m),...F})}return{items:u,items_length:s,items_page:N(o),matches_length:a,matches_pages:N(l)}},$n=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await E(r);return n(t,nt(e))};var b=t=>t!==void 0?t:we()??new ft;var qn=async({satellite:t,...e})=>{let r=b(t?.identity);return await Fn({...e,satellite:{...t,identity:r}})},$c=async({satellite:t,...e})=>{let r=b(t?.identity);return await kn({...e,satellite:{...t,identity:r}})},Hn=async({satellite:t,...e})=>{let r=b(t?.identity);return await Cn({...e,satellite:{...t,identity:r}})},qc=async({satellite:t,...e})=>{let r=b(t?.identity);return await Un({...e,satellite:{...t,identity:r}})},Hc=async({satellite:t,...e})=>{let r=b(t?.identity);return await Vn({...e,satellite:{...t,identity:r}})},Wc=async({satellite:t,...e})=>{let r=b(t?.identity);return await Kn({...e,satellite:{...t,identity:r}})},Gc=async({satellite:t,filter:e,...r})=>{let n=b(t?.identity);return await Mn({...r,filter:e??{},satellite:{...t,identity:n}})},Yc=async({satellite:t,filter:e,...r})=>{let n=b(t?.identity);return await jn({...r,filter:e??{},satellite:{...t,identity:n}})},zc=async({satellite:t,filter:e,...r})=>{let n=b(t?.identity);return await $n({...r,filter:e??{},satellite:{...t,identity:n}})};var Wn=async t=>{let e=we();if(h(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await qn({collection:"#user",key:r});return h(n)?await Ho({userId:r,provider:t}):n},Ho=({userId:t,...e})=>Hn({collection:"#user",doc:{key:t,data:e}});var G,fr=async t=>{if(G=G??await _e(),!(await G?.isAuthenticated()??!1))return;let r=await Wn(t);J.getInstance().set(r)},Wo=t=>new Promise(async(e,r)=>{G=G??await _e();let n=t?.provider??new ce({});await G.login({onSuccess:async()=>{await fr(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??en,allowPinAuthentication:t?.allowPin??rn,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),mr=async()=>{await G?.logout(),G=void 0,J.getInstance().reset(),Tt.getInstance().reset(),At.getInstance().reset()},we=()=>G?.getIdentity(),Go=async()=>(G??await _e()).getIdentity();var Gn=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{Ie({message:"junoSignOutAuthTimer"}),await mr()};return r.onmessage=async({data:i})=>{let{msg:o,data:s}=i;switch(o){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Ie({message:"junoDelegationRemainingTime",detail:s?.authRemainingTime});return}},J.getInstance().subscribe(i=>{if(h(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Yn=()=>{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()},zn=()=>{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 ml=async({idlFactory:t,satellite:e})=>{let r=b(e?.identity);return await Rn({idlFactory:t,...e,identity:r})};var Jn=async({asset:{data:t,filename:e,collection:r,headers:n,token:i,fullPath:o,encoding:s,description:a},actor:l,init_asset_upload:u})=>{let{batch_id:p}=await u({collection:r,full_path:o,name:e,token:x(i),encoding_type:x(s),description:x(a)}),d=19e5,f=[],y=ae()?new Blob([await t.arrayBuffer()]):t,w=0n;for(let _=0;_<y.size;_+=d){let A=y.slice(_,_+d);f.push({batchId:p,chunk:A,actor:l,orderId:w}),w++}let m=[];for await(let _ of Yo({uploadChunks:f}))m=[...m,..._];let F=n.find(([_,A])=>_.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await l.commit_asset_upload({batch_id:p,chunk_ids:m.map(({chunk_id:_})=>_),headers:[...n,...F||[]]})};async function*Yo({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(i=>zo(i)))}}var zo=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:x(n)});var Xn=async({satellite:t,...e})=>{let r=await E(t);await Jn({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},Qn=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await E(e),{items:i,items_length:o,items_page:s,matches_length:a,matches_pages:l}=await n(t,nt(r));return{items:i.map(([u,p])=>p),items_length:o,items_page:N(s),matches_length:a,matches_pages:N(l)}},Zn=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await E(e);return n(t,nt(r))},In=async({collection:t,fullPath:e,satellite:r})=>(await E(r)).del_asset(t,e),Dn=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await E(e),n=t.map(({collection:i,fullPath:o})=>[i,o]);await r(n)},Ln=async({collection:t,satellite:e,filter:r})=>{let{del_filtered_assets:n}=await E(e);return n(t,nt(r))},ti=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await E(r);return N(await n(t,e))},ei=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await E(e),n=t.map(({collection:o,fullPath:s})=>[o,s]);return(await r(n)).map(([o,s])=>N(s))};var ri=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Rl=t=>ni(t),Bl=t=>ni({filename:t.data.name,...t}),ni=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:o,satellite:s,encoding:a,description:l})=>{let u=b(s?.identity),p=decodeURI(t),d=i??`/${r}/${p}`,f={...s,identity:u};return await Xn({data:e,filename:p,collection:r,token:o,headers:n,fullPath:d,encoding:a,satellite:f,description:l}),{downloadUrl:ii({satellite:f,assetKey:{fullPath:d,token:o}}),fullPath:d,name:p}},Fl=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:b(e?.identity)},{items:i,...o}=await Qn({collection:t,satellite:n,filter:r??{}}),s=i.map(({key:{full_path:a,token:l,name:u,owner:p,description:d},headers:f,encodings:y,created_at:w,updated_at:m})=>{let F=N(l);return{fullPath:a,description:N(d),name:u,downloadUrl:ii({satellite:n,assetKey:{fullPath:a,token:F}}),token:F,headers:f,encodings:y.reduce((_,[A,{modified:Y,sha256:R,total_length:S}])=>({..._,[A]:{modified:Y,sha256:ri(R),total_length:S}}),{}),owner:p.toText(),created_at:w,updated_at:m}});return{items:s,assets:s,...o}},kl=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:b(e?.identity)};return await Zn({collection:t,satellite:n,filter:r??{}})},Cl=({collection:t,fullPath:e,satellite:r})=>In({collection:t,fullPath:e,satellite:{...r,identity:b(r?.identity)}}),Ul=({assets:t,satellite:e})=>Dn({assets:t,satellite:{...e,identity:b(e?.identity)}}),Vl=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:b(e?.identity)};return await Ln({collection:t,satellite:n,filter:r??{}})},Kl=async({satellite:t,...e})=>{let r=b(t?.identity);return await ti({...e,satellite:{...t,identity:r}})},Ml=async({satellite:t,...e})=>{let r=b(t?.identity);return await ei({...e,satellite:{...t,identity:r}})},ii=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:b(r?.identity)};return`${On(n)}${t}${T(e)?`?token=${e}`:""}`};var Jo=t=>{let e=t?.satelliteId??Yn();oe(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??zn();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},zl=t=>Xo(t),Xo=async t=>{let e=Jo(t);H.getInstance().set(e),await fr();let r=e.workers?.auth!==void 0?Gn(e.workers.auth):void 0;return[...r?[r]:[]]},Jl=t=>J.getInstance().subscribe(t);export{ce as InternetIdentityProvider,ln as NFIDProvider,Jl as authSubscribe,kl as countAssets,zc as countDocs,Cl as deleteAsset,Hc as deleteDoc,Vl as deleteFilteredAssets,Gc as deleteFilteredDocs,Ul as deleteManyAssets,Wc as deleteManyDocs,ii as downloadUrl,Kl as getAsset,qn as getDoc,Ml as getManyAssets,$c as getManyDocs,ml as getSatelliteExtendedActor,zl as initJuno,Xo as initSatellite,Fl as listAssets,Yc as listDocs,Hn as setDoc,qc as setManyDocs,Wo as signIn,mr as signOut,Go as unsafeIdentity,Rl as uploadBlob,Bl as uploadFile};
|
|
13
|
+
`)}throw new Error("unreachable")}var Zr=({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)}),i=t.Nat64,o=i,s=t.Record({network:e}),a=t.Nat64,l=t.Vec(a),u=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),p=t.Vec(t.Nat8),d=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),f=t.Record({height:t.Nat32,value:i,outpoint:d}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:p,utxos:t.Vec(f)}),w=t.Record({transaction:t.Vec(t.Nat8),network:e}),m=t.Principal,F=t.Record({canister_id:m,num_requested_changes:t.Opt(t.Nat64)}),_=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),A=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)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),G=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:_,details:A}),R=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(G),total_num_changes:t.Nat64}),S=t.Record({canister_id:m}),X=t.Variant({controllers:t.Null,public:t.Null}),dt=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:X,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),pt=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:dt,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}),U=t.Record({canister_id:m}),O=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(X),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),j=t.Record({settings:t.Opt(O),sender_canister_version:t.Opt(t.Nat64)}),it=t.Record({canister_id:m}),Q=t.Record({canister_id:m}),ot=t.Record({canister_id:m}),Z=t.Variant({secp256k1:t.Null}),Ae=t.Record({key_id:t.Record({name:t.Text,curve:Z}),canister_id:t.Opt(m),derivation_path:t.Vec(t.Vec(t.Nat8))}),Pt=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),Te=t.Record({canister_id:m}),Ee=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),ve=t.Record({canister_log_records:t.Vec(Ee)}),zt=t.Record({value:t.Text,name:t.Text}),Ot=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(zt)}),Ne=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:Ot})],[Ot],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(zt)}),Jt=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}),Rt=t.Record({hash:t.Vec(t.Nat8)}),Se=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:Jt,chunk_hashes_list:t.Vec(Rt),target_canister:m,store_canister:t.Opt(m),sender_canister_version:t.Opt(t.Nat64)}),Pe=t.Vec(t.Nat8),Oe=t.Record({arg:t.Vec(t.Nat8),wasm_module:Pe,mode:Jt,canister_id:m,sender_canister_version:t.Opt(t.Nat64)}),Xt=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}),Be=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(Re)})),Fe=t.Record({settings:t.Opt(O),specified_id:t.Opt(m),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),ci=t.Record({canister_id:m}),li=t.Record({canister_id:m,amount:t.Nat}),ui=t.Vec(t.Nat8),_r=t.Variant({ed25519:t.Null,bip340secp256k1:t.Null}),di=t.Record({key_id:t.Record({algorithm:_r,name:t.Text}),canister_id:t.Opt(m),derivation_path:t.Vec(t.Vec(t.Nat8))}),pi=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),fi=t.Record({key_id:t.Record({name:t.Text,curve:Z}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),mi=t.Record({signature:t.Vec(t.Nat8)}),hi=t.Record({key_id:t.Record({algorithm:_r,name:t.Text}),derivation_path:t.Vec(t.Vec(t.Nat8)),message:t.Vec(t.Nat8)}),yi=t.Record({signature:t.Vec(t.Nat8)}),gi=t.Record({canister_id:m}),_i=t.Record({canister_id:m}),wi=t.Record({canister_id:m}),xi=t.Vec(Rt),bi=t.Record({canister_id:m,sender_canister_version:t.Opt(t.Nat64)}),Ai=t.Record({canister_id:t.Principal,settings:O,sender_canister_version:t.Opt(t.Nat64)}),Ti=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),Ei=Rt;return t.Service({bitcoin_get_balance:t.Func([n],[o],[]),bitcoin_get_current_fee_percentiles:t.Func([s],[l],[]),bitcoin_get_utxos:t.Func([u],[y],[]),bitcoin_send_transaction:t.Func([w],[],[]),canister_info:t.Func([F],[R],[]),canister_status:t.Func([S],[pt],[]),clear_chunk_store:t.Func([U],[],[]),create_canister:t.Func([j],[it],[]),delete_canister:t.Func([Q],[],[]),deposit_cycles:t.Func([ot],[],[]),ecdsa_public_key:t.Func([Ae],[Pt],[]),fetch_canister_logs:t.Func([Te],[ve],["query"]),http_request:t.Func([Ne],[Ot],[]),install_chunked_code:t.Func([Se],[],[]),install_code:t.Func([Oe],[],[]),node_metrics_history:t.Func([Xt],[Be],[]),provisional_create_canister_with_cycles:t.Func([Fe],[ci],[]),provisional_top_up_canister:t.Func([li],[],[]),raw_rand:t.Func([],[ui],[]),schnorr_public_key:t.Func([di],[pi],[]),sign_with_ecdsa:t.Func([fi],[mi],[]),sign_with_schnorr:t.Func([hi],[yi],[]),start_canister:t.Func([gi],[],[]),stop_canister:t.Func([_i],[],[]),stored_chunks:t.Func([wi],[xi],[]),uninstall_code:t.Func([bi],[],[]),update_settings:t.Func([Ai],[],[]),upload_chunk:t.Func([Ti],[Ei],[])})};var ie=class extends Bt{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(o=>` "${o}": ${JSON.stringify(i[o])}`)].join(`
|
|
14
|
+
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},Xe=class extends ie{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=xr[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},oe=class extends ie{constructor(e,r,n,i,o,s,a){super(e,r,"update",Object.assign({"Request ID":P(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(o),"Reject message":s}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=o,this.reject_message=s,this.error_code=a}},C=Symbol.for("ic-agent-metadata"),tt=class t{constructor(e){this[C]=Object.freeze(e)}static agentOf(e){return e[C].config.agent}static interfaceOf(e){return e[C].service}static canisterIdOf(e){return g.from(e[C].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],o=[...new Uint8Array(e.module)],s=typeof r.canisterId=="string"?g.fromText(r.canisterId):r.canisterId;await Ir(r).install_code({mode:n,arg:i,wasm_module:o,canister_id:s,sender_canister_version:[]})}static async createCanister(e,r){function n(o){return[{controllers:o.controllers?[o.controllers]:[],compute_allocation:o.compute_allocation?[o.compute_allocation]:[],freezing_threshold:o.freezing_threshold?[o.freezing_threshold]:[],memory_allocation:o.memory_allocation?[o.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await Ir(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:Ft});class i extends t{constructor(s){if(!s.canisterId)throw new Bt(`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"?g.fromText(s.canisterId):s.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Lr),s),{canisterId:a}),service:n});for(let[l,u]of n._fields)r?.httpDetails&&u.annotations.push(Qe),r?.certificate&&u.annotations.push(tn),this[l]=fo(this,l,u,s.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Bt(`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 wt(t,e){let r=Ft.decode(t,Dr.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Lr={pollingStrategyFactory:ne.defaultStrategy},Qe="http-details",tn="certificate";function fo(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(s,...a)=>{var l,u;s=Object.assign(Object.assign({},s),(u=(l=t[C].config).queryTransform)===null||u===void 0?void 0:u.call(l,e,a,Object.assign(Object.assign({},t[C].config),s)));let p=s.agent||t[C].config.agent||Ke(),d=g.from(s.canisterId||t[C].config.canisterId),f=Ft.encode(r.argTypes,a),y=await p.query(d,{methodName:e,arg:f,effectiveCanisterId:s.effectiveCanisterId}),w=Object.assign(Object.assign({},y.httpDetails),{requestDetails:y.requestDetails});switch(y.status){case"rejected":throw new Xe(d,e,y);case"replied":return r.annotations.includes(Qe)?{httpDetails:w,result:wt(r.retTypes,y.reply.arg)}:wt(r.retTypes,y.reply.arg)}}:i=async(s,...a)=>{var l,u;s=Object.assign(Object.assign({},s),(u=(l=t[C].config).callTransform)===null||u===void 0?void 0:u.call(l,e,a,Object.assign(Object.assign({},t[C].config),s)));let p=s.agent||t[C].config.agent||Ke(),{canisterId:d,effectiveCanisterId:f,pollingStrategyFactory:y}=Object.assign(Object.assign(Object.assign({},Lr),t[C].config),s),w=g.from(d),m=f!==void 0?g.from(f):w,F=Ft.encode(r.argTypes,a);if(p.rootKey==null)throw new Bt("Agent root key not initialized before making call");let{requestId:_,response:A,requestDetails:G}=await p.call(w,{methodName:e,arg:F,effectiveCanisterId:m}),R,S;if(A.body&&A.body.certificate){let U=A.body.certificate;S=await Qt.create({certificate:Ce(U),rootKey:p.rootKey,canisterId:g.from(d),blsVerify:n});let O=[new TextEncoder().encode("request_status"),_];switch(new TextDecoder().decode(V(S.lookup([...O,"status"])))){case"replied":R=V(S.lookup([...O,"reply"]));break;case"rejected":{let it=new Uint8Array(V(S.lookup([...O,"reject_code"])))[0],Q=new TextDecoder().decode(V(S.lookup([...O,"reject_message"]))),ot=V(S.lookup([...O,"error_code"])),Z=ot?new TextDecoder().decode(ot):void 0;throw new oe(w,e,_,A,it,Q,Z)}}}else if(A.body&&"reject_message"in A.body){let{reject_code:U,reject_message:O,error_code:j}=A.body;throw new oe(w,e,_,A,U,O,j)}if(A.status===202){let U=y(),O=await Je(p,m,_,U,n);S=O.certificate,R=O.reply}let X=r.annotations.includes(Qe),dt=r.annotations.includes(tn),pt=Object.assign(Object.assign({},A),{requestDetails:G});if(R!==void 0)return X&&dt?{httpDetails:pt,certificate:S,result:wt(r.retTypes,R)}:dt?{certificate:S,result:wt(r.retTypes,R)}:X?{httpDetails:pt,result:wt(r.retTypes,R)}:wt(r.retTypes,R);if(r.retTypes.length===0)return X?{httpDetails:A,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let o=(...s)=>i({},...s);return o.withOptions=s=>(...a)=>i(s,...a),o}function Ir(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:g.from(t.effectiveCanisterId)};let i=n[0],o=g.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(o=g.from(i.canister_id)),{effectiveCanisterId:o}}return tt.createActor(Zr,Object.assign(Object.assign(Object.assign({},t),{canisterId:g.fromHex("")}),{callTransform:e,queryTransform:e}))}var ho=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(ho||{}),Ys=BigInt(1e8);var h=t=>t==null,T=t=>!h(t);var yo=class extends Error{},se=(t,e)=>{if(t==null)throw new yo(e)};var en="abcdefghijklmnopqrstuvwxyz234567",Ct=Object.create(null);for(let t=0;t<en.length;t++)Ct[en[t]]=t;Ct[0]=Ct.o;Ct[1]=Ct.i;var Xs=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 x=t=>T(t)?[t]:[],N=t=>t?.[0];var Ze="__bigint__",Ie="__principal__",De="__uint8array__",rn=(t,e)=>typeof e=="bigint"?{[Ze]:`${e}`}:T(e)&&e instanceof g?{[Ie]:e.toText()}:T(e)&&e instanceof Uint8Array?{[De]:Array.from(e)}:e,nn=(t,e)=>{let r=n=>e[n];return T(e)&&typeof e=="object"&&Ze in e?BigInt(r(Ze)):T(e)&&typeof e=="object"&&Ie in e?g.fromText(r(Ie)):T(e)&&typeof e=="object"&&De in e?Uint8Array.from(r(De)):e};var xt=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 z=class t extends xt{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 Le=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var on=BigInt(144e11),sn=!1,an={width:576,height:576},cn={width:505,height:705},ln="internetcomputer.org";var bt="http://127.0.0.1:5987",un="rdmx6-jaaaa-aaaaa-aaadq-cai";var H=class t extends xt{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}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var dn=async t=>{let e=new Blob([JSON.stringify(t,rn)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},ae=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(),nn)},ce=()=>typeof window<"u";var tr=({width:t,height:e})=>{if(!ce()||h(window)||h(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,o=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=${i}, left=${o}`};var le=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=H.getInstance().get()?.container;if(h(n)||n===!1)return`https://identity.${this.#t??ln}`;let i=H.getInstance().get(),o=T(i)&&T(i?.internetIdentityId)?i.internetIdentityId:un,{host:s,protocol:a}=new URL(n===!0?bt:n);return/apple/i.test(navigator?.vendor)?`${a}//${s}?canisterId=${o}`:`${a}//${o}.${s.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:tr(an)},identityProvider:r()}}},pn=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:tr(cn)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};var At=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 i=await this.createAgent({identity:e,...r});return this.#t={...this.#t??{},[n]:i},i}return this.#t[n]}reset(){this.#t=null}async createAgent({identity:e,fetch:r,container:n}){let o=T(n)&&n!==!1?n===!0?bt:n:"https://icp-api.io",s=T(n);return await Dt.create({identity:e,shouldFetchRootKey:s,host:o,...r&&{fetch:r}})}};var Tt=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,buildType:n,...i}){let o=`${n}#${r.getPrincipal().toText()}#${e};`;if(h(this.#t)||h(this.#t[o])){let s=await this.createActor({satelliteId:e,identity:r,...i});return this.#t={...this.#t??{},[o]:s},s}return this.#t[o]}reset(){this.#t=null}async createActor({idlFactory:e,satelliteId:r,...n}){let i=await At.getInstance().getAgent(n);return tt.createActor(e,{agent:i,canisterId:r})}};var Ut=class extends Error{},ue=class extends Error{},de=class extends Error{};var me=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},et=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)},pe,fe,Et,vt;function fn(t){return t!==null&&typeof t=="object"}var lt=class t{constructor(e){if(pe.set(this,void 0),fe.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");me(this,pe,e,"f"),me(this,fe,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=I(e);return this.fromRaw(r)}else if(fn(e)){let r=e;if(fn(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw(Tr(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=It(e,Zt).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=Ve(e,Zt);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return et(this,pe,"f")}get derKey(){return et(this,fe,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};pe=new WeakMap,fe=new WeakMap;lt.RAW_KEY_LENGTH=32;var ut=class t extends st{constructor(e,r){super(),Et.set(this,void 0),vt.set(this,void 0),me(this,Et,lt.from(e),"f"),me(this,vt,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=mt.utils.randomPrivateKey()),br(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 i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=mt.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(lt.fromDer(I(r)),I(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(lt.fromRaw(e),r)}static fromSecretKey(e){let r=mt.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[P(et(this,Et,"f").toDer()),P(et(this,vt,"f"))]}getKeyPair(){return{secretKey:et(this,vt,"f"),publicKey:et(this,Et,"f")}}getPublicKey(){return et(this,Et,"f")}async sign(e){let r=new Uint8Array(e),n=Ar(mt.sign(r,et(this,vt,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,o,s]=[e,r,n].map(a=>(typeof a=="string"&&(a=I(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return mt.verify(o,i,s)}};Et=new WeakMap,vt=new WeakMap;var er=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};function mn(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 er("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 Vt=class t extends st{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:i}=e??{},o=mn(i),s=await o.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await o.exportKey("spki",s.publicKey);return new this(s,a,o)}static async fromKeyPair(e,r){let n=mn(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,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 Nt=ke(Pi());var go=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Kt=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)},rt,he=class{constructor(e){rt.set(this,void 0),go(this,rt,e,"f")}get rawKey(){return Kt(this,rt,"f").rawKey}get derKey(){return Kt(this,rt,"f").derKey}toDer(){return Kt(this,rt,"f").toDer()}getPublicKey(){return Kt(this,rt,"f")}getPrincipal(){return g.from(Kt(this,rt,"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.")}};rt=new WeakMap;var _o=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},wo=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)},xo=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 i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},ye,bo=new TextEncoder().encode("ic-request-auth-delegation"),Ao=new TextEncoder().encode(`
|
|
15
|
+
ic-request`);function rr(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return I(t)}var St=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return Nt.value.map(Object.assign({pubkey:Nt.value.bytes(this.pubkey),expiration:Nt.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Nt.value.array(this.targets.map(e=>Nt.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:P(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};async function To(t,e,r,n){let i=new St(e.toDer(),BigInt(+r)*BigInt(1e6),n),o=new Uint8Array([...bo,...new Uint8Array(Ue(i))]),s=await t.sign(o);return{delegation:i,signature:s}}var Mt=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var o,s;let a=await To(e,r,n,i.targets);return new t([...((o=i.previous)===null||o===void 0?void 0:o.delegations)||[],a],((s=i.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 i=n.map(o=>{let{delegation:s,signature:a}=o,{pubkey:l,expiration:u,targets:p}=s;if(p!==void 0&&!Array.isArray(p))throw new Error("Invalid targets.");return{delegation:new St(rr(l),BigInt("0x"+u),p&&p.map(d=>{if(typeof d!="string")throw new Error("Invalid target.");return g.fromHex(d)})),signature:rr(a)}});return new this(i,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:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:P(r.pubkey)},i&&{targets:i.map(o=>o.toHex())}),signature:P(n)}}),publicKey:P(this.publicKey)}}},jt=class extends st{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=xo(e,["body"]),i=await Ue(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Ao,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},$t=class t extends he{constructor(e,r){super(e),ye.set(this,void 0),_o(this,ye,r,"f")}get delegation(){return wo(this,ye,"f")}static fromDelegation(e,r){return new t(e,r)}};ye=new WeakMap;function hn(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?g.fromText(i):i)):r.push(typeof n=="string"?g.fromText(n):n));for(let i of r){let o=i.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()===o){a=!1;break}if(a)return!1}}return!0}var vo=ke(Si());var yn;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(yn||(yn={}));var gn=["mousedown","mousemove","keydown","touchstart","wheel"],qt=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let o=this._resetTimer.bind(this);window.addEventListener("load",o,!0),gn.forEach(function(a){document.addEventListener(a,o,!0)});let s=(a,l)=>{let u;return(...p)=>{let d=this,f=function(){u=void 0,a.apply(d,p)};clearTimeout(u),u=window.setTimeout(f,l)}};if(e?.captureScroll){let a=s(o,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}o()}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);gn.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 No=(t,e)=>e.some(r=>t instanceof r),_n,wn;function So(){return _n||(_n=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Po(){return wn||(wn=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var xn=new WeakMap,ir=new WeakMap,bn=new WeakMap,nr=new WeakMap,sr=new WeakMap;function Oo(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",o),t.removeEventListener("error",s)},o=()=>{r(W(t.result)),i()},s=()=>{n(t.error),i()};t.addEventListener("success",o),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&xn.set(r,t)}).catch(()=>{}),sr.set(e,t),e}function Ro(t){if(ir.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",o),t.removeEventListener("error",s),t.removeEventListener("abort",s)},o=()=>{r(),i()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",o),t.addEventListener("error",s),t.addEventListener("abort",s)});ir.set(t,e)}var or={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return ir.get(t);if(e==="objectStoreNames")return t.objectStoreNames||bn.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return W(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 An(t){or=t(or)}function Bo(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(ge(this),e,...r);return bn.set(n,e.sort?e.sort():[e]),W(n)}:Po().includes(t)?function(...e){return t.apply(ge(this),e),W(xn.get(this))}:function(...e){return W(t.apply(ge(this),e))}}function Fo(t){return typeof t=="function"?Bo(t):(t instanceof IDBTransaction&&Ro(t),No(t,So())?new Proxy(t,or):t)}function W(t){if(t instanceof IDBRequest)return Oo(t);if(nr.has(t))return nr.get(t);let e=Fo(t);return e!==t&&(nr.set(t,e),sr.set(e,t)),e}var ge=t=>sr.get(t);function En(t,e,{blocked:r,upgrade:n,blocking:i,terminated:o}={}){let s=indexedDB.open(t,e),a=W(s);return n&&s.addEventListener("upgradeneeded",l=>{n(W(s.result),l.oldVersion,l.newVersion,W(s.transaction),l)}),r&&s.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),a.then(l=>{o&&l.addEventListener("close",()=>o()),i&&l.addEventListener("versionchange",u=>i(u.oldVersion,u.newVersion,u))}).catch(()=>{}),a}var ko=["get","getKey","getAll","getAllKeys","count"],Co=["put","add","delete","clear"],ar=new Map;function Tn(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(ar.get(e))return ar.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=Co.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||ko.includes(r)))return;let o=async function(s,...a){let l=this.transaction(s,i?"readwrite":"readonly"),u=l.store;return n&&(u=u.index(a.shift())),(await Promise.all([u[r](...a),i&&l.done]))[0]};return ar.set(e,o),o}An(t=>({...t,get:(e,r,n)=>Tn(e,r)||t.get(e,r,n),has:(e,r)=>!!Tn(e,r)||t.has(e,r)}));var vn="auth-client-db",Nn="ic-keyval",Uo=async(t=vn,e=Nn,r)=>(_e&&(localStorage!=null&&localStorage.getItem(K))&&(localStorage.removeItem(K),localStorage.removeItem(M)),await En(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function Vo(t,e,r){return await t.get(e,r)}async function Ko(t,e,r,n){return await t.put(e,n,r)}async function Mo(t,e,r){return await t.delete(e,r)}var Ht=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=vn,storeName:n=Nn,version:i=Sn}=e??{},o=await Uo(r,n,i);return new t(o,n)}async set(e,r){return await Ko(this._db,this._storeName,e,r)}async get(e){var r;return(r=await Vo(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await Mo(this._db,this._storeName,e)}};var jo=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},$o=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)},we,M="identity",K="delegation",Pn="iv",Sn=1,_e=typeof window<"u",Wt=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}},Gt=class{constructor(e){we.set(this,void 0),jo(this,we,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}Ht.create($o(this,we,"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)}};we=new WeakMap;var qo="https://identity.ic0.app",Ho="#authorize",cr="ECDSA",lr="Ed25519",Wo=500,Go="UserInterrupt",xe=class{constructor(e,r,n,i,o,s,a,l){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=o,this._createOptions=s,this._idpWindow=a,this._eventHandler=l,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let o=(r=e.storage)!==null&&r!==void 0?r:new Gt,s=(n=e.keyType)!==null&&n!==void 0?n:cr,a=null;if(e.identity)a=e.identity;else{let d=await o.get(M);if(!d&&_e)try{let f=new Wt,y=await f.get(K),w=await f.get(M);y&&w&&s===cr&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await o.set(K,y),await o.set(M,w),d=y,await f.remove(K),await f.remove(M))}catch(f){console.error("error while attempting to recover localstorage: "+f)}if(d)try{typeof d=="object"?s===lr&&typeof d=="string"?a=await ut.fromJSON(d):a=await Vt.fromKeyPair(d):typeof d=="string"&&(a=ut.fromJSON(d))}catch{}}let l=new ft,u=null;if(a)try{let d=await o.get(K);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=Mt.fromJSON(d),hn(u)?"toDer"in a?l=$t.fromDelegation(a,u):l=jt.fromDelegation(a,u):(await ur(o),a=null))}catch(d){console.error(d),await ur(o),a=null}let p;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?p=void 0:(u||e.identity)&&(p=qt.create(e.idleOptions)),a||(s===lr?(a=await ut.generate(),await o.set(M,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 '${lr}' as the key type, as it can serialize to a string`),a=await Vt.generate(),await o.set(M,a.getKeyPair()))),new this(l,a,u,o,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,i;let o=e.delegations.map(u=>({delegation:new St(u.delegation.pubkey,u.delegation.expiration,u.delegation.targets),signature:u.signature.buffer})),s=Mt.fromDelegations(o,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=s,"toDer"in a?this._identity=$t.fromDelegation(a,this._chain):this._identity=jt.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let l=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!l?.disableIdle&&(this.idleManager=qt.create(l),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(K,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,i,o;let s=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||qo);a.hash=Ho,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:s},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(o=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&o!==void 0?o:void 0;let l=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Go,e?.onError):setTimeout(l,Wo))};l()}_getEventHandler(e,r){return async n=>{var i,o,s;if(n.origin!==e.origin){console.warn(`WARNING: expected origin '${e.origin}', got '${n.origin}' (ignoring)`);return}let a=n.data;switch(a.kind){case"authorize-ready":{let l=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(o=r?.derivationOrigin)===null||o===void 0?void 0:o.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 ur(this._storage),this._identity=new ft,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};async function ur(t){await t.remove(M),await t.remove(K),await t.remove(Pn)}var dr=()=>xe.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var On=async({data:t})=>{try{return await ae(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var pr=async t=>{let{data:e,version:r,description:n}=t;return{description:x(n),data:await dn(e),version:x(r)}},fr=t=>{let{version:e}=t;return{version:x(e)}},Yt=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:o,...s}=t;return{key:e,description:N(i),owner:r.toText(),data:await ae(o),version:N(n),...s}};var Rn=t=>{if(h(t))return x();switch(t.matcher){case"equal":return x({Equal:t.timestamp});case"greaterThan":return x({GreaterThan:t.timestamp});case"lessThan":return x({LessThan:t.timestamp});case"between":return x({Between:[t.timestamps.start,t.timestamps.end]});default:throw new de("Invalid list matcher for timestamp",t)}},nt=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:h(t)?[]:[{key:x(t.key),description:x(t.description),created_at:Rn(t.createdAt),updated_at:Rn(t.updatedAt)}],paginate:x(h(e)?void 0:{start_after:x(e.startAfter),limit:x(h(e.limit)?void 0:BigInt(e.limit))}),order:x(h(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:x(h(n)?void 0:typeof n=="string"?g.fromText(n):n)});var Bn=({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.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:r,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),o=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),s=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),a=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(o),paginate:t.Opt(s)}),l=t.Record({controllers:t.Vec(t.Principal)}),u=t.Variant({Write:t.Null,Admin:t.Null}),p=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:u,expires_at:t.Opt(t.Nat64)}),d=t.Record({version:t.Opt(t.Nat64)}),f=t.Variant({Db:t.Null,Storage:t.Null}),y=t.Record({version:t.Opt(t.Nat64)}),w=t.Record({cycles:t.Nat,destination_id:t.Principal}),m=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}),F=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),_=t.Record({key:m,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,F)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),A=t.Record({derivation_origin:t.Opt(t.Text)}),G=t.Record({internet_identity:t.Opt(A)}),R=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),S=t.Record({max_memory_size:t.Opt(R)}),X=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),dt=t.Variant({Deny:t.Null,Allow:t.Null}),pt=t.Record({status_code:t.Nat16,location:t.Text}),U=t.Record({iframe:t.Opt(X),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(R),raw_access:t.Opt(dt),redirects:t.Opt(t.Vec(t.Tuple(t.Text,pt)))}),O=t.Record({db:t.Opt(S),authentication:t.Opt(G),storage:U}),j=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)}),it=t.Variant({Heap:t.Null,Stable:t.Null}),Q=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),ot=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),Z=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(it),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:Q,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(ot),write:Q}),Ae=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)}),Pt=t.Record({memory:it,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}),Te=t.Variant({Callback:t.Record({token:Pt,callback:t.Func([],[],["query"])})}),Ee=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(Te),status_code:t.Nat16}),ve=t.Record({token:t.Opt(Pt),body:t.Vec(t.Nat8)}),zt=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}),Ot=t.Record({batch_id:t.Nat}),Ne=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}),Jt=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Rt=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,j)),items_length:t.Nat64}),Se=t.Record({stable:t.Nat64,heap:t.Nat64}),Pe=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:u,expires_at:t.Opt(t.Nat64)}),Oe=t.Record({controller:Pe,controllers:t.Vec(t.Principal)}),Xt=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Re=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(it),max_size:t.Opt(t.Nat),read:Q,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(ot),write:Q}),Be=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),Fe=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,a],[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,a],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([l],[t.Vec(t.Tuple(t.Principal,p))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,d],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,a],[],[]),del_filtered_docs:t.Func([t.Text,a],[],[]),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,d))],[],[]),del_rule:t.Func([f,t.Text,y],[],[]),deposit_cycles:t.Func([w],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(_)],["query"]),get_auth_config:t.Func([],[t.Opt(G)],["query"]),get_config:t.Func([],[O],[]),get_db_config:t.Func([],[t.Opt(S)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(j)],["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(j)))],["query"]),get_rule:t.Func([f,t.Text],[t.Opt(Z)],["query"]),get_storage_config:t.Func([],[U],["query"]),http_request:t.Func([Ae],[Ee],["query"]),http_request_streaming_callback:t.Func([Pt],[ve],["query"]),init_asset_upload:t.Func([zt],[Ot],[]),list_assets:t.Func([t.Text,a],[Ne],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,p))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Jt))],["query"]),list_docs:t.Func([t.Text,a],[Rt],["query"]),list_rules:t.Func([f],[t.Vec(t.Tuple(t.Text,Z))],["query"]),memory_size:t.Func([],[Se],["query"]),set_auth_config:t.Func([G],[],[]),set_controllers:t.Func([Oe],[t.Vec(t.Tuple(t.Principal,p))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([S],[],[]),set_doc:t.Func([t.Text,t.Text,Xt],[j],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Xt))],[t.Vec(t.Tuple(t.Text,j))],[]),set_rule:t.Func([f,t.Text,Re],[Z],[]),set_storage_config:t.Func([U],[],[]),upload_asset_chunk:t.Func([Be],[Fe],[]),version:t.Func([],[t.Text],["query"])})};var Fn=({satelliteId:t,container:e})=>{let{satelliteId:r}=mr({satelliteId:t}),{container:n}=hr({container:e});if(T(n)&&n!==!1){let{host:i,protocol:o}=new URL(n===!0?bt:n);return`${o}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},mr=({satelliteId:t})=>T(t)?{satelliteId:t}:H.getInstance().get()??{satelliteId:void 0},hr=({container:t})=>T(t)?{container:t}:H.getInstance().get()??{container:void 0};var E=t=>Cn({idlFactory:Bn,buildType:"stock",...t}),kn=({idlFactory:t,...e})=>Cn({idlFactory:t,buildType:"extended",...e}),Cn=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=mr({satelliteId:t});se(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=hr({container:e});return await Tt.getInstance().getActor({satelliteId:n,container:i,...r})};var Un=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await E(r),i=N(await n(t,e));if(!h(i))return Yt({doc:i,key:e})},Vn=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await E(e),n=t.map(({collection:s,key:a})=>[s,a]),i=await r(n),o=[];for(let[s,a]of i){let l=N(a);o.push(T(l)?await Yt({key:s,doc:l}):void 0)}return o},Kn=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await E(r),{key:i}=e,o=await pr(e),s=await n(t,i,o);return await Yt({key:i,doc:s})},Mn=async({docs:t,satellite: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 pr(a)])}let i=await r(n),o=[];for(let[s,a]of i)o.push(await Yt({key:s,doc:a}));return o},jn=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await E(r),{key:i}=e;return n(t,i,fr(e))},$n=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await E(e),n=t.map(({collection:i,doc:o})=>[i,o.key,fr(o)]);await r(n)},qn=async({collection:t,filter:e,satellite:r})=>{let{del_filtered_docs:n}=await E(r);return n(t,nt(e))},Hn=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await E(r),{items:i,items_page:o,items_length:s,matches_length:a,matches_pages:l}=await n(t,nt(e)),u=[];for(let[p,d]of i){let{data:f,owner:y,description:w,version:m,...F}=d;u.push({key:p,description:N(w),owner:y.toText(),data:await On({data:f}),version:N(m),...F})}return{items:u,items_length:s,items_page:N(o),matches_length:a,matches_pages:N(l)}},Wn=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await E(r);return n(t,nt(e))};var b=t=>t!==void 0?t:be()??new ft;var Gn=async({satellite:t,...e})=>{let r=b(t?.identity);return await Un({...e,satellite:{...t,identity:r}})},Yc=async({satellite:t,...e})=>{let r=b(t?.identity);return await Vn({...e,satellite:{...t,identity:r}})},Yn=async({satellite:t,...e})=>{let r=b(t?.identity);return await Kn({...e,satellite:{...t,identity:r}})},zc=async({satellite:t,...e})=>{let r=b(t?.identity);return await Mn({...e,satellite:{...t,identity:r}})},Jc=async({satellite:t,...e})=>{let r=b(t?.identity);return await jn({...e,satellite:{...t,identity:r}})},Xc=async({satellite:t,...e})=>{let r=b(t?.identity);return await $n({...e,satellite:{...t,identity:r}})},Qc=async({satellite:t,filter:e,...r})=>{let n=b(t?.identity);return await qn({...r,filter:e??{},satellite:{...t,identity:n}})},Zc=async({satellite:t,filter:e,...r})=>{let n=b(t?.identity);return await Hn({...r,filter:e??{},satellite:{...t,identity:n}})},Ic=async({satellite:t,filter:e,...r})=>{let n=b(t?.identity);return await Wn({...r,filter:e??{},satellite:{...t,identity:n}})};var zn=async t=>{let e=be();if(h(e))throw new ue("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await Gn({collection:"#user",key:r});return h(n)?await Yo({userId:r,provider:t}):n},Yo=({userId:t,...e})=>Yn({collection:"#user",doc:{key:t,data:e}});var J,yr=async t=>{if(J=J??await dr(),!(await J?.isAuthenticated()??!1))return;let r=await zn(t);z.getInstance().set(r)},zo=t=>new Promise(async(e,r)=>{if(h(J)){r(new Ut("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=t?.provider??new le({});await J.login({onSuccess:async()=>{await yr(n.id),e()},onError:i=>r(new Ut(i)),maxTimeToLive:t?.maxTimeToLive??on,allowPinAuthentication:t?.allowPin??sn,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),gr=async()=>{await J?.logout(),J=void 0,z.getInstance().reset(),Tt.getInstance().reset(),At.getInstance().reset()},be=()=>J?.getIdentity(),Jo=async()=>(J??await dr()).getIdentity();var Jn=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{Le({message:"junoSignOutAuthTimer"}),await gr()};return r.onmessage=async({data:i})=>{let{msg:o,data:s}=i;switch(o){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Le({message:"junoDelegationRemainingTime",detail:s?.authRemainingTime});return}},z.getInstance().subscribe(i=>{if(h(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Xn=()=>{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()},Qn=()=>{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 Al=async({idlFactory:t,satellite:e})=>{let r=b(e?.identity);return await kn({idlFactory:t,...e,identity:r})};var Zn=async({asset:{data:t,filename:e,collection:r,headers:n,token:i,fullPath:o,encoding:s,description:a},actor:l,init_asset_upload:u})=>{let{batch_id:p}=await u({collection:r,full_path:o,name:e,token:x(i),encoding_type:x(s),description:x(a)}),d=19e5,f=[],y=ce()?new Blob([await t.arrayBuffer()]):t,w=0n;for(let _=0;_<y.size;_+=d){let A=y.slice(_,_+d);f.push({batchId:p,chunk:A,actor:l,orderId:w}),w++}let m=[];for await(let _ of Xo({uploadChunks:f}))m=[...m,..._];let F=n.find(([_,A])=>_.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await l.commit_asset_upload({batch_id:p,chunk_ids:m.map(({chunk_id:_})=>_),headers:[...n,...F||[]]})};async function*Xo({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(i=>Qo(i)))}}var Qo=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:x(n)});var In=async({satellite:t,...e})=>{let r=await E(t);await Zn({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},Dn=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await E(e),{items:i,items_length:o,items_page:s,matches_length:a,matches_pages:l}=await n(t,nt(r));return{items:i.map(([u,p])=>p),items_length:o,items_page:N(s),matches_length:a,matches_pages:N(l)}},Ln=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await E(e);return n(t,nt(r))},ti=async({collection:t,fullPath:e,satellite:r})=>(await E(r)).del_asset(t,e),ei=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await E(e),n=t.map(({collection:i,fullPath:o})=>[i,o]);await r(n)},ri=async({collection:t,satellite:e,filter:r})=>{let{del_filtered_assets:n}=await E(e);return n(t,nt(r))},ni=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await E(r);return N(await n(t,e))},ii=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await E(e),n=t.map(({collection:o,fullPath:s})=>[o,s]);return(await r(n)).map(([o,s])=>N(s))};var oi=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Ml=t=>si(t),jl=t=>si({filename:t.data.name,...t}),si=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:o,satellite:s,encoding:a,description:l})=>{let u=b(s?.identity),p=decodeURI(t),d=i??`/${r}/${p}`,f={...s,identity:u};return await In({data:e,filename:p,collection:r,token:o,headers:n,fullPath:d,encoding:a,satellite:f,description:l}),{downloadUrl:ai({satellite:f,assetKey:{fullPath:d,token:o}}),fullPath:d,name:p}},$l=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:b(e?.identity)},{items:i,...o}=await Dn({collection:t,satellite:n,filter:r??{}}),s=i.map(({key:{full_path:a,token:l,name:u,owner:p,description:d},headers:f,encodings:y,created_at:w,updated_at:m})=>{let F=N(l);return{fullPath:a,description:N(d),name:u,downloadUrl:ai({satellite:n,assetKey:{fullPath:a,token:F}}),token:F,headers:f,encodings:y.reduce((_,[A,{modified:G,sha256:R,total_length:S}])=>({..._,[A]:{modified:G,sha256:oi(R),total_length:S}}),{}),owner:p.toText(),created_at:w,updated_at:m}});return{items:s,assets:s,...o}},ql=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:b(e?.identity)};return await Ln({collection:t,satellite:n,filter:r??{}})},Hl=({collection:t,fullPath:e,satellite:r})=>ti({collection:t,fullPath:e,satellite:{...r,identity:b(r?.identity)}}),Wl=({assets:t,satellite:e})=>ei({assets:t,satellite:{...e,identity:b(e?.identity)}}),Gl=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:b(e?.identity)};return await ri({collection:t,satellite:n,filter:r??{}})},Yl=async({satellite:t,...e})=>{let r=b(t?.identity);return await ni({...e,satellite:{...t,identity:r}})},zl=async({satellite:t,...e})=>{let r=b(t?.identity);return await ii({...e,satellite:{...t,identity:r}})},ai=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:b(r?.identity)};return`${Fn(n)}${t}${T(e)?`?token=${e}`:""}`};var Zo=t=>{let e=t?.satelliteId??Xn();se(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??Qn();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},tu=t=>Io(t),Io=async t=>{let e=Zo(t);H.getInstance().set(e),await yr();let r=e.workers?.auth!==void 0?Jn(e.workers.auth):void 0;return[...r?[r]:[]]},eu=t=>z.getInstance().subscribe(t);export{ue as InitError,le as InternetIdentityProvider,de as ListError,pn as NFIDProvider,Ut as SignInError,eu as authSubscribe,ql as countAssets,Ic as countDocs,Hl as deleteAsset,Jc as deleteDoc,Gl as deleteFilteredAssets,Qc as deleteFilteredDocs,Wl as deleteManyAssets,Xc as deleteManyDocs,ai as downloadUrl,Yl as getAsset,Gn as getDoc,zl as getManyAssets,Yc as getManyDocs,Al as getSatelliteExtendedActor,tu as initJuno,Io as initSatellite,$l as listAssets,Zc as listDocs,Yn as setDoc,zc as setManyDocs,zo as signIn,gr as signOut,Jo as unsafeIdentity,Ml as uploadBlob,jl as uploadFile};
|
|
16
16
|
/*! Bundled license information:
|
|
17
17
|
|
|
18
18
|
buffer/index.js:
|