@junobuild/core-standalone 1.2.0 → 1.2.1-next-2025-08-27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,60 +1,60 @@
1
1
  import { createRequire as topLevelCreateRequire } from 'module';
2
2
  const require = topLevelCreateRequire(import.meta.url);
3
- var sm=Object.create;var sa=Object.defineProperty;var am=Object.getOwnPropertyDescriptor;var om=Object.getOwnPropertyNames;var cm=Object.getPrototypeOf,um=Object.prototype.hasOwnProperty;var oi=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Qd=(e,t)=>()=>(e&&(t=e(e=0)),t);var ee=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),lm=(e,t)=>{for(var r in t)sa(e,r,{get:t[r],enumerable:!0})},ef=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of om(t))!um.call(e,i)&&i!==r&&sa(e,i,{get:()=>t[i],enumerable:!(n=am(t,i))||n.enumerable});return e};var Ve=(e,t,r)=>(r=e!=null?sm(cm(e)):{},ef(t||!e||!e.__esModule?sa(r,"default",{value:e,enumerable:!0}):r,e)),dm=e=>ef(sa({},"__esModule",{value:!0}),e);var nf=ee(aa=>{"use strict";aa.byteLength=pm;aa.toByteArray=_m;aa.fromByteArray=gm;var Rr=[],ir=[],fm=typeof Uint8Array<"u"?Uint8Array:Array,Ic="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Mn=0,tf=Ic.length;Mn<tf;++Mn)Rr[Mn]=Ic[Mn],ir[Ic.charCodeAt(Mn)]=Mn;var Mn,tf;ir[45]=62;ir[95]=63;function rf(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function pm(e){var t=rf(e),r=t[0],n=t[1];return(r+n)*3/4-n}function hm(e,t,r){return(t+r)*3/4-r}function _m(e){var t,r=rf(e),n=r[0],i=r[1],s=new fm(hm(e,n,i)),a=0,o=i>0?n-4:n,c;for(c=0;c<o;c+=4)t=ir[e.charCodeAt(c)]<<18|ir[e.charCodeAt(c+1)]<<12|ir[e.charCodeAt(c+2)]<<6|ir[e.charCodeAt(c+3)],s[a++]=t>>16&255,s[a++]=t>>8&255,s[a++]=t&255;return i===2&&(t=ir[e.charCodeAt(c)]<<2|ir[e.charCodeAt(c+1)]>>4,s[a++]=t&255),i===1&&(t=ir[e.charCodeAt(c)]<<10|ir[e.charCodeAt(c+1)]<<4|ir[e.charCodeAt(c+2)]>>2,s[a++]=t>>8&255,s[a++]=t&255),s}function ym(e){return Rr[e>>18&63]+Rr[e>>12&63]+Rr[e>>6&63]+Rr[e&63]}function mm(e,t,r){for(var n,i=[],s=t;s<r;s+=3)n=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(e[s+2]&255),i.push(ym(n));return i.join("")}function gm(e){for(var t,r=e.length,n=r%3,i=[],s=16383,a=0,o=r-n;a<o;a+=s)i.push(mm(e,a,a+s>o?o:a+s));return n===1?(t=e[r-1],i.push(Rr[t>>2]+Rr[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Rr[t>>10]+Rr[t>>4&63]+Rr[t<<2&63]+"=")),i.join("")}});var Fc=ee(Pc=>{Pc.read=function(e,t,r,n,i){var s,a,o=i*8-n-1,c=(1<<o)-1,d=c>>1,f=-7,p=r?i-1:0,m=r?-1:1,b=e[t+p];for(p+=m,s=b&(1<<-f)-1,b>>=-f,f+=o;f>0;s=s*256+e[t+p],p+=m,f-=8);for(a=s&(1<<-f)-1,s>>=-f,f+=n;f>0;a=a*256+e[t+p],p+=m,f-=8);if(s===0)s=1-d;else{if(s===c)return a?NaN:(b?-1:1)*(1/0);a=a+Math.pow(2,n),s=s-d}return(b?-1:1)*a*Math.pow(2,s-n)};Pc.write=function(e,t,r,n,i,s){var a,o,c,d=s*8-i-1,f=(1<<d)-1,p=f>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:s-1,l=n?1:-1,A=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-a))<1&&(a--,c*=2),a+p>=1?t+=m/c:t+=m*Math.pow(2,1-p),t*c>=2&&(a++,c/=2),a+p>=f?(o=0,a=f):a+p>=1?(o=(t*c-1)*Math.pow(2,i),a=a+p):(o=t*Math.pow(2,p-1)*Math.pow(2,i),a=0));i>=8;e[r+b]=o&255,b+=l,o/=256,i-=8);for(a=a<<i|o,d+=i;d>0;e[r+b]=a&255,b+=l,a/=256,d-=8);e[r+b-l]|=A*128}});var xf=ee(di=>{"use strict";var Vc=nf(),ui=Fc(),sf=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;di.Buffer=G;di.SlowBuffer=Om;di.INSPECT_MAX_BYTES=50;var oa=2147483647;di.kMaxLength=oa;G.TYPED_ARRAY_SUPPORT=bm();!G.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 bm(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(G.prototype,"parent",{enumerable:!0,get:function(){if(G.isBuffer(this))return this.buffer}});Object.defineProperty(G.prototype,"offset",{enumerable:!0,get:function(){if(G.isBuffer(this))return this.byteOffset}});function Zr(e){if(e>oa)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,G.prototype),t}function G(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Mc(e)}return uf(e,t,r)}G.poolSize=8192;function uf(e,t,r){if(typeof e=="string")return xm(e,t);if(ArrayBuffer.isView(e))return Tm(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Ar(e,ArrayBuffer)||e&&Ar(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ar(e,SharedArrayBuffer)||e&&Ar(e.buffer,SharedArrayBuffer)))return Cc(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return G.from(n,t,r);let i=Nm(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return G.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}G.from=function(e,t,r){return uf(e,t,r)};Object.setPrototypeOf(G.prototype,Uint8Array.prototype);Object.setPrototypeOf(G,Uint8Array);function lf(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function wm(e,t,r){return lf(e),e<=0?Zr(e):t!==void 0?typeof r=="string"?Zr(e).fill(t,r):Zr(e).fill(t):Zr(e)}G.alloc=function(e,t,r){return wm(e,t,r)};function Mc(e){return lf(e),Zr(e<0?0:kc(e)|0)}G.allocUnsafe=function(e){return Mc(e)};G.allocUnsafeSlow=function(e){return Mc(e)};function xm(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!G.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=df(e,t)|0,n=Zr(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Uc(e){let t=e.length<0?0:kc(e.length)|0,r=Zr(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function Tm(e){if(Ar(e,Uint8Array)){let t=new Uint8Array(e);return Cc(t.buffer,t.byteOffset,t.byteLength)}return Uc(e)}function Cc(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,G.prototype),n}function Nm(e){if(G.isBuffer(e)){let t=kc(e.length)|0,r=Zr(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||jc(e.length)?Zr(0):Uc(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Uc(e.data)}function kc(e){if(e>=oa)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+oa.toString(16)+" bytes");return e|0}function Om(e){return+e!=e&&(e=0),G.alloc(+e)}G.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==G.prototype};G.compare=function(t,r){if(Ar(t,Uint8Array)&&(t=G.from(t,t.offset,t.byteLength)),Ar(r,Uint8Array)&&(r=G.from(r,r.offset,r.byteLength)),!G.isBuffer(t)||!G.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let s=0,a=Math.min(n,i);s<a;++s)if(t[s]!==r[s]){n=t[s],i=r[s];break}return n<i?-1:i<n?1:0};G.isEncoding=function(t){switch(String(t).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}};G.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return G.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=G.allocUnsafe(r),s=0;for(n=0;n<t.length;++n){let a=t[n];if(Ar(a,Uint8Array))s+a.length>i.length?(G.isBuffer(a)||(a=G.from(a)),a.copy(i,s)):Uint8Array.prototype.set.call(i,a,s);else if(G.isBuffer(a))a.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=a.length}return i};function df(e,t){if(G.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Ar(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return qc(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return wf(e).length;default:if(i)return n?-1:qc(e).length;t=(""+t).toLowerCase(),i=!0}}G.byteLength=df;function Em(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return Um(this,t,r);case"utf8":case"utf-8":return pf(this,t,r);case"ascii":return Fm(this,t,r);case"latin1":case"binary":return Vm(this,t,r);case"base64":return Im(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Cm(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}G.prototype._isBuffer=!0;function kn(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}G.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)kn(this,r,r+1);return this};G.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)kn(this,r,r+3),kn(this,r+1,r+2);return this};G.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)kn(this,r,r+7),kn(this,r+1,r+6),kn(this,r+2,r+5),kn(this,r+3,r+4);return this};G.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?pf(this,0,t):Em.apply(this,arguments)};G.prototype.toLocaleString=G.prototype.toString;G.prototype.equals=function(t){if(!G.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:G.compare(this,t)===0};G.prototype.inspect=function(){let t="",r=di.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};sf&&(G.prototype[sf]=G.prototype.inspect);G.prototype.compare=function(t,r,n,i,s){if(Ar(t,Uint8Array)&&(t=G.from(t,t.offset,t.byteLength)),!G.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;let a=s-i,o=n-r,c=Math.min(a,o),d=this.slice(i,s),f=t.slice(r,n);for(let p=0;p<c;++p)if(d[p]!==f[p]){a=d[p],o=f[p];break}return a<o?-1:o<a?1:0};function ff(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,jc(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=G.from(t,n)),G.isBuffer(t))return t.length===0?-1:af(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):af(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function af(e,t,r,n,i){let s=1,a=e.length,o=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;s=2,a/=2,o/=2,r/=2}function c(f,p){return s===1?f[p]:f.readUInt16BE(p*s)}let d;if(i){let f=-1;for(d=r;d<a;d++)if(c(e,d)===c(t,f===-1?0:d-f)){if(f===-1&&(f=d),d-f+1===o)return f*s}else f!==-1&&(d-=d-f),f=-1}else for(r+o>a&&(r=a-o),d=r;d>=0;d--){let f=!0;for(let p=0;p<o;p++)if(c(e,d+p)!==c(t,p)){f=!1;break}if(f)return d}return-1}G.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};G.prototype.indexOf=function(t,r,n){return ff(this,t,r,n,!0)};G.prototype.lastIndexOf=function(t,r,n){return ff(this,t,r,n,!1)};function vm(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=t.length;n>s/2&&(n=s/2);let a;for(a=0;a<n;++a){let o=parseInt(t.substr(a*2,2),16);if(jc(o))return a;e[r+a]=o}return a}function Rm(e,t,r,n){return ca(qc(t,e.length-r),e,r,n)}function Am(e,t,r,n){return ca(Dm(t),e,r,n)}function Sm(e,t,r,n){return ca(wf(t),e,r,n)}function Bm(e,t,r,n){return ca(jm(t,e.length-r),e,r,n)}G.prototype.write=function(t,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 s=this.length-r;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let a=!1;for(;;)switch(i){case"hex":return vm(this,t,r,n);case"utf8":case"utf-8":return Rm(this,t,r,n);case"ascii":case"latin1":case"binary":return Am(this,t,r,n);case"base64":return Sm(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Bm(this,t,r,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}};G.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Im(e,t,r){return t===0&&r===e.length?Vc.fromByteArray(e):Vc.fromByteArray(e.slice(t,r))}function pf(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let s=e[i],a=null,o=s>239?4:s>223?3:s>191?2:1;if(i+o<=r){let c,d,f,p;switch(o){case 1:s<128&&(a=s);break;case 2:c=e[i+1],(c&192)===128&&(p=(s&31)<<6|c&63,p>127&&(a=p));break;case 3:c=e[i+1],d=e[i+2],(c&192)===128&&(d&192)===128&&(p=(s&15)<<12|(c&63)<<6|d&63,p>2047&&(p<55296||p>57343)&&(a=p));break;case 4:c=e[i+1],d=e[i+2],f=e[i+3],(c&192)===128&&(d&192)===128&&(f&192)===128&&(p=(s&15)<<18|(c&63)<<12|(d&63)<<6|f&63,p>65535&&p<1114112&&(a=p))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),i+=o}return Pm(n)}var of=4096;function Pm(e){let t=e.length;if(t<=of)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=of));return r}function Fm(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function Vm(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function Um(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=t;s<r;++s)i+=Lm[e[s]];return i}function Cm(e,t,r){let n=e.slice(t,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}G.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,G.prototype),i};function pt(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}G.prototype.readUintLE=G.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=this[t],s=1,a=0;for(;++a<r&&(s*=256);)i+=this[t+a]*s;return i};G.prototype.readUintBE=G.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=this[t+--r],s=1;for(;r>0&&(s*=256);)i+=this[t+--r]*s;return i};G.prototype.readUint8=G.prototype.readUInt8=function(t,r){return t=t>>>0,r||pt(t,1,this.length),this[t]};G.prototype.readUint16LE=G.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||pt(t,2,this.length),this[t]|this[t+1]<<8};G.prototype.readUint16BE=G.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||pt(t,2,this.length),this[t]<<8|this[t+1]};G.prototype.readUint32LE=G.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};G.prototype.readUint32BE=G.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};G.prototype.readBigUInt64LE=un(function(t){t=t>>>0,li(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Xi(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,s=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});G.prototype.readBigUInt64BE=un(function(t){t=t>>>0,li(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Xi(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],s=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});G.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=this[t],s=1,a=0;for(;++a<r&&(s*=256);)i+=this[t+a]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};G.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=r,s=1,a=this[t+--i];for(;i>0&&(s*=256);)a+=this[t+--i]*s;return s*=128,a>=s&&(a-=Math.pow(2,8*r)),a};G.prototype.readInt8=function(t,r){return t=t>>>0,r||pt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};G.prototype.readInt16LE=function(t,r){t=t>>>0,r||pt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};G.prototype.readInt16BE=function(t,r){t=t>>>0,r||pt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};G.prototype.readInt32LE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};G.prototype.readInt32BE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};G.prototype.readBigInt64LE=un(function(t){t=t>>>0,li(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Xi(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});G.prototype.readBigInt64BE=un(function(t){t=t>>>0,li(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Xi(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});G.prototype.readFloatLE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),ui.read(this,t,!0,23,4)};G.prototype.readFloatBE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),ui.read(this,t,!1,23,4)};G.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||pt(t,8,this.length),ui.read(this,t,!0,52,8)};G.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||pt(t,8,this.length),ui.read(this,t,!1,52,8)};function Kt(e,t,r,n,i,s){if(!G.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}G.prototype.writeUintLE=G.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let o=Math.pow(2,8*n)-1;Kt(this,t,r,n,o,0)}let s=1,a=0;for(this[r]=t&255;++a<n&&(s*=256);)this[r+a]=t/s&255;return r+n};G.prototype.writeUintBE=G.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let o=Math.pow(2,8*n)-1;Kt(this,t,r,n,o,0)}let s=n-1,a=1;for(this[r+s]=t&255;--s>=0&&(a*=256);)this[r+s]=t/a&255;return r+n};G.prototype.writeUint8=G.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,1,255,0),this[r]=t&255,r+1};G.prototype.writeUint16LE=G.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};G.prototype.writeUint16BE=G.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};G.prototype.writeUint32LE=G.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};G.prototype.writeUint32BE=G.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function hf(e,t,r,n,i){bf(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a,r}function _f(e,t,r,n,i){bf(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r+7]=s,s=s>>8,e[r+6]=s,s=s>>8,e[r+5]=s,s=s>>8,e[r+4]=s;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=a,a=a>>8,e[r+2]=a,a=a>>8,e[r+1]=a,a=a>>8,e[r]=a,r+8}G.prototype.writeBigUInt64LE=un(function(t,r=0){return hf(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeBigUInt64BE=un(function(t,r=0){return _f(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Kt(this,t,r,n,c-1,-c)}let s=0,a=1,o=0;for(this[r]=t&255;++s<n&&(a*=256);)t<0&&o===0&&this[r+s-1]!==0&&(o=1),this[r+s]=(t/a>>0)-o&255;return r+n};G.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Kt(this,t,r,n,c-1,-c)}let s=n-1,a=1,o=0;for(this[r+s]=t&255;--s>=0&&(a*=256);)t<0&&o===0&&this[r+s+1]!==0&&(o=1),this[r+s]=(t/a>>0)-o&255;return r+n};G.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};G.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};G.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};G.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};G.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};G.prototype.writeBigInt64LE=un(function(t,r=0){return hf(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});G.prototype.writeBigInt64BE=un(function(t,r=0){return _f(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function yf(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function mf(e,t,r,n,i){return t=+t,r=r>>>0,i||yf(e,t,r,4,34028234663852886e22,-34028234663852886e22),ui.write(e,t,r,n,23,4),r+4}G.prototype.writeFloatLE=function(t,r,n){return mf(this,t,r,!0,n)};G.prototype.writeFloatBE=function(t,r,n){return mf(this,t,r,!1,n)};function gf(e,t,r,n,i){return t=+t,r=r>>>0,i||yf(e,t,r,8,17976931348623157e292,-17976931348623157e292),ui.write(e,t,r,n,52,8),r+8}G.prototype.writeDoubleLE=function(t,r,n){return gf(this,t,r,!0,n)};G.prototype.writeDoubleBE=function(t,r,n){return gf(this,t,r,!1,n)};G.prototype.copy=function(t,r,n,i){if(!G.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.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),t.length-r<i-n&&(i=t.length-r+n);let s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),s};G.prototype.fill=function(t,r,n,i){if(typeof t=="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"&&!G.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let a=t.charCodeAt(0);(i==="utf8"&&a<128||i==="latin1")&&(t=a)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));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,t||(t=0);let s;if(typeof t=="number")for(s=r;s<n;++s)this[s]=t;else{let a=G.isBuffer(t)?t:G.from(t,i),o=a.length;if(o===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=a[s%o]}return this};var ci={};function Dc(e,t,r){ci[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}Dc("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Dc("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);Dc("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=cf(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=cf(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function cf(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function qm(e,t,r){li(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&Xi(t,e.length-(r+1))}function bf(e,t,r,n,i,s){if(e>r||e<t){let a=typeof t=="bigint"?"n":"",o;throw s>3?t===0||t===BigInt(0)?o=`>= 0${a} and < 2${a} ** ${(s+1)*8}${a}`:o=`>= -(2${a} ** ${(s+1)*8-1}${a}) and < 2 ** ${(s+1)*8-1}${a}`:o=`>= ${t}${a} and <= ${r}${a}`,new ci.ERR_OUT_OF_RANGE("value",o,e)}qm(n,i,s)}function li(e,t){if(typeof e!="number")throw new ci.ERR_INVALID_ARG_TYPE(t,"number",e)}function Xi(e,t,r){throw Math.floor(e)!==e?(li(e,r),new ci.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new ci.ERR_BUFFER_OUT_OF_BOUNDS:new ci.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var Mm=/[^+/0-9A-Za-z-_]/g;function km(e){if(e=e.split("=")[0],e=e.trim().replace(Mm,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function qc(e,t){t=t||1/0;let r,n=e.length,i=null,s=[];for(let a=0;a<n;++a){if(r=e.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(a+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function Dm(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function jm(e,t){let r,n,i,s=[];for(let a=0;a<e.length&&!((t-=2)<0);++a)r=e.charCodeAt(a),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function wf(e){return Vc.toByteArray(km(e))}function ca(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ar(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function jc(e){return e!==e}var Lm=function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function un(e){return typeof BigInt>"u"?Hm:e}function Hm(){throw new Error("BigInt not supported")}});var Lc=ee(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.ReplicaRejectCode=void 0;var Km;(function(e){e[e.SysFatal=1]="SysFatal",e[e.SysTransient=2]="SysTransient",e[e.DestinationInvalid=3]="DestinationInvalid",e[e.CanisterReject=4]="CanisterReject",e[e.CanisterError=5]="CanisterError"})(Km=Qi.ReplicaRejectCode||(Qi.ReplicaRejectCode={}))});var Tf=ee(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});pi.decode=pi.encode=void 0;var ua="abcdefghijklmnopqrstuvwxyz234567",fi=Object.create(null);for(let e=0;e<ua.length;e++)fi[ua[e]]=e;fi[0]=fi.o;fi[1]=fi.i;function $m(e){let t=0,r=0,n="";function i(s){return t<0?r|=s>>-t:r=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=ua[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?ua[r>>3]:"")}pi.encode=$m;function Gm(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0;function s(a){let o=fi[a.toLowerCase()];if(o===void 0)throw new Error(`Invalid character: ${JSON.stringify(a)}`);o<<=3,r|=o>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=o<<5-t&255:r=0)}for(let a of e)s(a);return n.slice(0,i)}pi.decode=Gm});var Nf=ee(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.getCrc32=void 0;var zm=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]);function Wm(e){let t=new Uint8Array(e),r=-1;for(let n=0;n<t.length;n++){let s=(t[n]^r)&255;r=zm[s]^r>>>8}return(r^-1)>>>0}la.getCrc32=Wm});var Kc=ee(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.isBytes=Ef;Sr.number=da;Sr.bool=Of;Sr.bytes=Hc;Sr.hash=vf;Sr.exists=Rf;Sr.output=Af;function da(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Of(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function Ef(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Hc(e,...t){if(!Ef(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function vf(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");da(e.outputLen),da(e.blockLen)}function Rf(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Af(e,t){Hc(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Ym={number:da,bool:Of,bytes:Hc,hash:vf,exists:Rf,output:Af};Sr.default=Ym});var Sf=ee(fa=>{"use strict";Object.defineProperty(fa,"__esModule",{value:!0});fa.crypto=void 0;var ln=oi("node:crypto");fa.crypto=ln&&typeof ln=="object"&&"webcrypto"in ln?ln.webcrypto:ln&&typeof ln=="object"&&"randomBytes"in ln?ln:void 0});var Dn=ee(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.Hash=we.nextTick=we.byteSwapIfBE=we.byteSwap=we.isLE=we.rotl=we.rotr=we.createView=we.u32=we.u8=void 0;we.isBytes=Jm;we.byteSwap32=ng;we.bytesToHex=sg;we.hexToBytes=ag;we.asyncLoop=cg;we.utf8ToBytes=If;we.toBytes=pa;we.concatBytes=ug;we.checkOpts=dg;we.wrapConstructor=fg;we.wrapConstructorWithOpts=pg;we.wrapXOFConstructorWithOpts=hg;we.randomBytes=_g;var hi=Sf(),Gc=Kc();function Jm(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}var Zm=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);we.u8=Zm;var Xm=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));we.u32=Xm;var Qm=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);we.createView=Qm;var eg=(e,t)=>e<<32-t|e>>>t;we.rotr=eg;var tg=(e,t)=>e<<t|e>>>32-t>>>0;we.rotl=tg;we.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var rg=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;we.byteSwap=rg;we.byteSwapIfBE=we.isLE?e=>e:e=>(0,we.byteSwap)(e);function ng(e){for(let t=0;t<e.length;t++)e[t]=(0,we.byteSwap)(e[t])}var ig=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function sg(e){(0,Gc.bytes)(e);let t="";for(let r=0;r<e.length;r++)t+=ig[e[r]];return t}var Xr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Bf(e){if(e>=Xr._0&&e<=Xr._9)return e-Xr._0;if(e>=Xr._A&&e<=Xr._F)return e-(Xr._A-10);if(e>=Xr._a&&e<=Xr._f)return e-(Xr._a-10)}function ag(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let a=Bf(e.charCodeAt(s)),o=Bf(e.charCodeAt(s+1));if(a===void 0||o===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=a*16+o}return n}var og=async()=>{};we.nextTick=og;async function cg(e,t,r){let n=Date.now();for(let i=0;i<e;i++){r(i);let s=Date.now()-n;s>=0&&s<t||(await(0,we.nextTick)(),n+=s)}}function If(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function pa(e){return typeof e=="string"&&(e=If(e)),(0,Gc.bytes)(e),e}function ug(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];(0,Gc.bytes)(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let s=e[n];r.set(s,i),i+=s.length}return r}var $c=class{clone(){return this._cloneInto()}};we.Hash=$c;var lg={}.toString;function dg(e,t){if(t!==void 0&&lg.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(e,t)}function fg(e){let t=n=>e().update(pa(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function pg(e){let t=(n,i)=>e(i).update(pa(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function hg(e){let t=(n,i)=>e(i).update(pa(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function _g(e=32){if(hi.crypto&&typeof hi.crypto.getRandomValues=="function")return hi.crypto.getRandomValues(new Uint8Array(e));if(hi.crypto&&typeof hi.crypto.randomBytes=="function")return hi.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}});var Yc=ee(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});dn.HashMD=dn.Maj=dn.Chi=void 0;var zc=Kc(),es=Dn();function yg(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let i=BigInt(32),s=BigInt(4294967295),a=Number(r>>i&s),o=Number(r&s),c=n?4:0,d=n?0:4;e.setUint32(t+c,a,n),e.setUint32(t+d,o,n)}var mg=(e,t,r)=>e&t^~e&r;dn.Chi=mg;var gg=(e,t,r)=>e&t^e&r^t&r;dn.Maj=gg;var Wc=class extends es.Hash{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,es.createView)(this.buffer)}update(t){(0,zc.exists)(this);let{view:r,buffer:n,blockLen:i}=this;t=(0,es.toBytes)(t);let s=t.length;for(let a=0;a<s;){let o=Math.min(i-this.pos,s-a);if(o===i){let c=(0,es.createView)(t);for(;i<=s-a;a+=i)this.process(c,a);continue}n.set(t.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,zc.exists)(this),(0,zc.output)(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:a}=this;r[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>i-a&&(this.process(n,0),a=0);for(let p=a;p<i;p++)r[p]=0;yg(n,i-8,BigInt(this.length*8),s),this.process(n,0);let o=(0,es.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<d;p++)o.setUint32(4*p,f[p],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:a,pos:o}=this;return t.length=i,t.pos=o,t.finished=s,t.destroyed=a,i%r&&t.buffer.set(n),t}};dn.HashMD=Wc});var ha=ee(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.sha224=hn.sha256=hn.SHA256=void 0;var Jc=Yc(),sr=Dn(),bg=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),fn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),pn=new Uint32Array(64),ts=class extends Jc.HashMD{constructor(){super(64,32,8,!1),this.A=fn[0]|0,this.B=fn[1]|0,this.C=fn[2]|0,this.D=fn[3]|0,this.E=fn[4]|0,this.F=fn[5]|0,this.G=fn[6]|0,this.H=fn[7]|0}get(){let{A:t,B:r,C:n,D:i,E:s,F:a,G:o,H:c}=this;return[t,r,n,i,s,a,o,c]}set(t,r,n,i,s,a,o,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=a|0,this.G=o|0,this.H=c|0}process(t,r){for(let p=0;p<16;p++,r+=4)pn[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let m=pn[p-15],b=pn[p-2],l=(0,sr.rotr)(m,7)^(0,sr.rotr)(m,18)^m>>>3,A=(0,sr.rotr)(b,17)^(0,sr.rotr)(b,19)^b>>>10;pn[p]=A+pn[p-7]+l+pn[p-16]|0}let{A:n,B:i,C:s,D:a,E:o,F:c,G:d,H:f}=this;for(let p=0;p<64;p++){let m=(0,sr.rotr)(o,6)^(0,sr.rotr)(o,11)^(0,sr.rotr)(o,25),b=f+m+(0,Jc.Chi)(o,c,d)+bg[p]+pn[p]|0,A=((0,sr.rotr)(n,2)^(0,sr.rotr)(n,13)^(0,sr.rotr)(n,22))+(0,Jc.Maj)(n,i,s)|0;f=d,d=c,c=o,o=a+b|0,a=s,s=i,i=n,n=b+A|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,a=a+this.D|0,o=o+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,i,s,a,o,c,d,f)}roundClean(){pn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};hn.SHA256=ts;var Zc=class extends ts{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};hn.sha256=(0,sr.wrapConstructor)(()=>new ts);hn.sha224=(0,sr.wrapConstructor)(()=>new Zc)});var Pf=ee(_a=>{"use strict";Object.defineProperty(_a,"__esModule",{value:!0});_a.sha224=void 0;var wg=ha();function xg(e){return wg.sha224.create().update(new Uint8Array(e)).digest()}_a.sha224=xg});var vt=ee(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.Principal=Br.JSON_KEY_PRINCIPAL=void 0;var Ff=Tf(),Tg=Nf(),Ng=Pf();Br.JSON_KEY_PRINCIPAL="__principal__";var Og=2,Vf=4,Eg="aaaaa-aa",vg=e=>{var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))},Rg=e=>e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""),Xc=class e{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Vf]))}static managementCanister(){return this.fromHex(Eg)}static selfAuthenticating(t){let r=(0,Ng.sha224)(t);return new this(new Uint8Array([...r,Og]))}static from(t){if(typeof t=="string")return e.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new e(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new e(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(vg(t))}static fromText(t){let r=t;if(t.includes(Br.JSON_KEY_PRINCIPAL)){let a=JSON.parse(t);Br.JSON_KEY_PRINCIPAL in a&&(r=a[Br.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,Ff.decode)(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Vf}toUint8Array(){return this._arr}toHex(){return Rg(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,(0,Tg.getCrc32)(this._arr));let n=new Uint8Array(t),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),o=(0,Ff.encode)(s).match(/.{1,5}/g);if(!o)throw new Error;return o.join("-")}toString(){return this.toText()}toJSON(){return{[Br.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(t){for(let r=0;r<Math.min(this._arr.length,t._arr.length);r++){if(this._arr[r]<t._arr[r])return"lt";if(this._arr[r]>t._arr[r])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let r=this.compareTo(t);return r=="lt"||r=="eq"}gtEq(t){let r=this.compareTo(t);return r=="gt"||r=="eq"}};Br.Principal=Xc});var $t=ee(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.bufFromBufLike=Rt.uint8ToBuf=Rt.bufEquals=Rt.compare=Rt.fromHex=Rt.toHex=Rt.concat=void 0;function Ag(...e){let t=new Uint8Array(e.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t.buffer}Rt.concat=Ag;function Sg(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}Rt.toHex=Sg;var Bg=new RegExp(/^[0-9a-fA-F]+$/);function Ig(e){if(!Bg.test(e))throw new Error("Invalid hexadecimal string.");let t=[...e].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(t).buffer}Rt.fromHex=Ig;function Uf(e,t){if(e.byteLength!==t.byteLength)return e.byteLength-t.byteLength;let r=new Uint8Array(e),n=new Uint8Array(t);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}Rt.compare=Uf;function Pg(e,t){return Uf(e,t)===0}Rt.bufEquals=Pg;function ya(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}Rt.uint8ToBuf=ya;function Cf(e){return e instanceof Uint8Array?ya(e):e instanceof ArrayBuffer?e:Array.isArray(e)?ya(new Uint8Array(e)):"buffer"in e?Cf(e.buffer):ya(new Uint8Array(e))}Rt.bufFromBufLike=Cf});var _i=ee(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});Ir.UpdateCallRejectedError=Ir.QueryCallRejectedError=Ir.ActorCallError=Ir.AgentError=void 0;var tu=vt(),Fg=Lc(),Vg=$t(),ma=class e extends Error{constructor(t){super(t),this.message=t,this.name="AgentError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Ir.AgentError=ma;var rs=class e extends ma{constructor(t,r,n,i){let s=tu.Principal.from(t);super(["Call failed:",` Canister: ${s.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(a=>` "${a}": ${JSON.stringify(i[a])}`)].join(`
4
- `)),this.canisterId=t,this.methodName=r,this.type=n,this.props=i,this.name="ActorCallError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Ir.ActorCallError=rs;var Qc=class e extends rs{constructor(t,r,n){var i;let s=tu.Principal.from(t);super(s,r,"query",{Status:n.status,Code:(i=Fg.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n,this.name="QueryCallRejectedError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Ir.QueryCallRejectedError=Qc;var eu=class e extends rs{constructor(t,r,n,i){let s=tu.Principal.from(t);super(s,r,"update",Object.assign({"Request ID":(0,Vg.toHex)(n)},i.body?Object.assign(Object.assign({},i.body.error_code?{"Error code":i.body.error_code}:{}),{"Reject code":String(i.body.reject_code),"Reject message":i.body.reject_message}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.name="UpdateCallRejectedError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Ir.UpdateCallRejectedError=eu});var wa=ee(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.bufFromBufLike=Gt.uint8ToBuf=Gt.PipeArrayBuffer=Gt.fromHexString=Gt.toHexString=Gt.concat=void 0;function Ug(...e){let t=new Uint8Array(e.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t}Gt.concat=Ug;function Cg(e){return new Uint8Array(e).reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}Gt.toHexString=Cg;function qg(e){var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))}Gt.fromHexString=qg;var ru=class{constructor(t,r=t?.byteLength||0){this._buffer=ba(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return ba(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let r=this._view.subarray(0,t);return this._view=this._view.subarray(t),r.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let r=new Uint8Array(t),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(t){let r=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+t);n.set(this._view),this._buffer=r,this._view=n}};Gt.PipeArrayBuffer=ru;function ga(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}Gt.uint8ToBuf=ga;function ba(e){return e instanceof Uint8Array?ga(e):e instanceof ArrayBuffer?e:Array.isArray(e)?ga(new Uint8Array(e)):"buffer"in e?ba(e.buffer):ga(new Uint8Array(e))}Gt.bufFromBufLike=ba});var nu=ee(xa=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});xa.idlLabelToId=void 0;function Mg(e){let r=new TextEncoder().encode(e),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function kg(e){if(/^_\d+_$/.test(e)||/^_0x[0-9a-fA-F]+_$/.test(e)){let t=+e.slice(1,-1);if(Number.isSafeInteger(t)&&t>=0&&t<2**32)return t}return Mg(e)}xa.idlLabelToId=kg});var su=ee(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.readIntLE=Ze.readUIntLE=Ze.writeIntLE=Ze.writeUIntLE=Ze.slebDecode=Ze.slebEncode=Ze.lebDecode=Ze.lebEncode=Ze.safeReadUint8=Ze.safeRead=void 0;var iu=wa();function qf(){throw new Error("unexpected end of buffer")}function Mf(e,t){return e.byteLength<t&&qf(),e.read(t)}Ze.safeRead=Mf;function Ta(e){let t=e.readUint8();return t===void 0&&qf(),t}Ze.safeReadUint8=Ta;function Dg(e){if(typeof e=="number"&&(e=BigInt(e)),e<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,r=new iu.PipeArrayBuffer(new ArrayBuffer(t),0);for(;;){let n=Number(e&BigInt(127));if(e/=BigInt(128),e===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}Ze.lebEncode=Dg;function kf(e){let t=BigInt(1),r=BigInt(0),n;do n=Ta(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}Ze.lebDecode=kf;function jg(e){typeof e=="number"&&(e=BigInt(e));let t=e<BigInt(0);t&&(e=-e-BigInt(1));let r=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,n=new iu.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let s=i(e);if(e/=BigInt(128),t&&e===BigInt(0)&&(s&64)!==0||!t&&e===BigInt(0)&&(s&64)===0){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let a=s%BigInt(128);return Number(t?BigInt(128)-a-BigInt(1):a)}return n.buffer}Ze.slebEncode=jg;function Lg(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if((t[r]&64)===0)return kf(e);break}let n=new Uint8Array(Mf(e,r+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}Ze.slebDecode=Lg;function Hg(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return Df(e,t)}Ze.writeUIntLE=Hg;function Df(e,t){e=BigInt(e);let r=new iu.PipeArrayBuffer(new ArrayBuffer(Math.min(1,t)),0),n=0,i=BigInt(256),s=BigInt(0),a=Number(e%i);for(r.write(new Uint8Array([a]));++n<t;)e<0&&s===BigInt(0)&&a!==0&&(s=BigInt(1)),a=Number((e/i-s)%BigInt(256)),r.write(new Uint8Array([a])),i*=BigInt(256);return r.buffer}Ze.writeIntLE=Df;function jf(e,t){let r=BigInt(Ta(e)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(Ta(e));r=r+n*s}return r}Ze.readUIntLE=jf;function Kg(e,t){let r=jf(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Ze.readIntLE=Kg});var Lf=ee(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0});yi.iexp2=yi.ilog2=void 0;function $g(e){let t=BigInt(e);if(e<=0)throw new RangeError("Input must be positive");return t.toString(2).length-1}yi.ilog2=$g;function Gg(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}yi.iexp2=Gg});var lu=ee(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.Variant=z.Record=z.Opt=z.Vec=z.Tuple=z.Principal=z.Nat64=z.Nat32=z.Nat16=z.Nat8=z.Int64=z.Int32=z.Int16=z.Int8=z.Float64=z.Float32=z.Nat=z.Int=z.Text=z.Null=z.Bool=z.Unknown=z.Reserved=z.Empty=z.decode=z.encode=z.ServiceClass=z.FuncClass=z.PrincipalClass=z.RecClass=z.VariantClass=z.TupleClass=z.RecordClass=z.OptClass=z.VecClass=z.FixedNatClass=z.FixedIntClass=z.FloatClass=z.NatClass=z.IntClass=z.TextClass=z.ReservedClass=z.NullClass=z.BoolClass=z.UnknownClass=z.EmptyClass=z.ConstructType=z.PrimitiveType=z.Type=z.Visitor=void 0;z.Service=z.Func=z.Rec=void 0;var zg=vt(),Pe=wa(),Pr=nu(),ce=su(),au=Lf(),Na="DIDL",Hf=400;function ns(e,t,r){return e.map((n,i)=>r(n,t[i]))}var ou=class{constructor(){this._typs=[],this._idx=new Map}has(t){return this._idx.has(t.name)}add(t,r){let n=this._typs.length;this._idx.set(t.name,n),this._typs.push(r)}merge(t,r){let n=this._idx.get(t.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+t);if(i===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[i],this._typs.splice(i,1),this._idx.delete(r)}encode(){let t=(0,ce.lebEncode)(this._typs.length),r=(0,Pe.concat)(...this._typs);return(0,Pe.concat)(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return(0,ce.slebEncode)(this._idx.get(t)||0)}},cu=class{visitType(t,r){throw new Error("Not implemented")}visitPrimitive(t,r){return this.visitType(t,r)}visitEmpty(t,r){return this.visitPrimitive(t,r)}visitBool(t,r){return this.visitPrimitive(t,r)}visitNull(t,r){return this.visitPrimitive(t,r)}visitReserved(t,r){return this.visitPrimitive(t,r)}visitText(t,r){return this.visitPrimitive(t,r)}visitNumber(t,r){return this.visitPrimitive(t,r)}visitInt(t,r){return this.visitNumber(t,r)}visitNat(t,r){return this.visitNumber(t,r)}visitFloat(t,r){return this.visitPrimitive(t,r)}visitFixedInt(t,r){return this.visitNumber(t,r)}visitFixedNat(t,r){return this.visitNumber(t,r)}visitPrincipal(t,r){return this.visitPrimitive(t,r)}visitConstruct(t,r){return this.visitType(t,r)}visitVec(t,r,n){return this.visitConstruct(t,n)}visitOpt(t,r,n){return this.visitConstruct(t,n)}visitRecord(t,r,n){return this.visitConstruct(t,n)}visitTuple(t,r,n){let i=r.map((s,a)=>[`_${a}_`,s]);return this.visitRecord(t,i,n)}visitVariant(t,r,n){return this.visitConstruct(t,n)}visitRec(t,r,n){return this.visitConstruct(r,n)}visitFunc(t,r){return this.visitConstruct(t,r)}visitService(t,r){return this.visitConstruct(t,r)}};z.Visitor=cu;var mi=class{display(){return this.name}valueToString(t){return tt(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}};z.Type=mi;var zt=class extends mi{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}};z.PrimitiveType=zt;var Vr=class extends mi{checkType(t){if(t instanceof _n){let r=t.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}};z.ConstructType=Vr;var Oa=class extends zt{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,ce.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};z.EmptyClass=Oa;var Ea=class extends mi{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,r){throw t.visitType(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof _n?i=()=>r.getType():i=()=>r,Object.defineProperty(n,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}};z.UnknownClass=Ea;var va=class extends zt{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return(0,ce.slebEncode)(-2)}decodeValue(t,r){switch(this.checkType(r),(0,ce.safeReadUint8)(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};z.BoolClass=va;var Ra=class extends zt{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ce.slebEncode)(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}};z.NullClass=Ra;var gi=class extends zt{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ce.slebEncode)(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}};z.ReservedClass=gi;var Aa=class extends zt{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=(0,ce.lebEncode)(r.byteLength);return(0,Pe.concat)(n,r)}encodeType(){return(0,ce.slebEncode)(-15)}decodeValue(t,r){this.checkType(r);let n=(0,ce.lebDecode)(t),i=(0,ce.safeRead)(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(t){return'"'+t+'"'}};z.TextClass=Aa;var Sa=class extends zt{accept(t,r){return t.visitInt(this,r)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){return(0,ce.slebEncode)(t)}encodeType(){return(0,ce.slebEncode)(-4)}decodeValue(t,r){return this.checkType(r),(0,ce.slebDecode)(t)}get name(){return"int"}valueToString(t){return t.toString()}};z.IntClass=Sa;var Ba=class extends zt{accept(t,r){return t.visitNat(this,r)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){return(0,ce.lebEncode)(t)}encodeType(){return(0,ce.slebEncode)(-3)}decodeValue(t,r){return this.checkType(r),(0,ce.lebDecode)(t)}get name(){return"nat"}valueToString(t){return t.toString()}};z.NatClass=Ba;var is=class extends zt{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,r){return t.visitFloat(this,r)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),r}encodeType(){let t=this._bits===32?-13:-14;return(0,ce.slebEncode)(t)}decodeValue(t,r){this.checkType(r);let n=(0,ce.safeRead)(t,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}};z.FloatClass=is;var Qr=class extends zt{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=(0,au.iexp2)(this._bits-1)*BigInt(-1),n=(0,au.iexp2)(this._bits-1)-BigInt(1),i=!1;if(typeof t=="bigint")i=t>=r&&t<=n;else if(Number.isInteger(t)){let s=BigInt(t);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){return(0,ce.writeIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,ce.slebEncode)(-9-t)}decodeValue(t,r){this.checkType(r);let n=(0,ce.readIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}};z.FixedIntClass=Qr;var Fr=class extends zt{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=(0,au.iexp2)(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<r:Number.isInteger(t)&&t>=0?n=BigInt(t)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){return(0,ce.writeUIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,ce.slebEncode)(-5-t)}decodeValue(t,r){this.checkType(r);let n=(0,ce.readUIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}};z.FixedNatClass=Fr;var Ia=class e extends Vr{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof Fr&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof Fr?this._type._bits:this._type instanceof Qr?this._type._bits:0;if(ArrayBuffer.isView(t)&&r==t.BYTES_PER_ELEMENT*8||Array.isArray(t)&&t.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
3
+ var nm=Object.create;var ia=Object.defineProperty;var im=Object.getOwnPropertyDescriptor;var sm=Object.getOwnPropertyNames;var am=Object.getPrototypeOf,om=Object.prototype.hasOwnProperty;var oi=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Xd=(e,t)=>()=>(e&&(t=e(e=0)),t);var ee=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),cm=(e,t)=>{for(var r in t)ia(e,r,{get:t[r],enumerable:!0})},Qd=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of sm(t))!om.call(e,i)&&i!==r&&ia(e,i,{get:()=>t[i],enumerable:!(n=im(t,i))||n.enumerable});return e};var qe=(e,t,r)=>(r=e!=null?nm(am(e)):{},Qd(t||!e||!e.__esModule?ia(r,"default",{value:e,enumerable:!0}):r,e)),um=e=>Qd(ia({},"__esModule",{value:!0}),e);var rf=ee(sa=>{"use strict";sa.byteLength=dm;sa.toByteArray=pm;sa.fromByteArray=ym;var Rr=[],ir=[],lm=typeof Uint8Array<"u"?Uint8Array:Array,Bc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Mn=0,ef=Bc.length;Mn<ef;++Mn)Rr[Mn]=Bc[Mn],ir[Bc.charCodeAt(Mn)]=Mn;var Mn,ef;ir[45]=62;ir[95]=63;function tf(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function dm(e){var t=tf(e),r=t[0],n=t[1];return(r+n)*3/4-n}function fm(e,t,r){return(t+r)*3/4-r}function pm(e){var t,r=tf(e),n=r[0],i=r[1],s=new lm(fm(e,n,i)),a=0,o=i>0?n-4:n,c;for(c=0;c<o;c+=4)t=ir[e.charCodeAt(c)]<<18|ir[e.charCodeAt(c+1)]<<12|ir[e.charCodeAt(c+2)]<<6|ir[e.charCodeAt(c+3)],s[a++]=t>>16&255,s[a++]=t>>8&255,s[a++]=t&255;return i===2&&(t=ir[e.charCodeAt(c)]<<2|ir[e.charCodeAt(c+1)]>>4,s[a++]=t&255),i===1&&(t=ir[e.charCodeAt(c)]<<10|ir[e.charCodeAt(c+1)]<<4|ir[e.charCodeAt(c+2)]>>2,s[a++]=t>>8&255,s[a++]=t&255),s}function hm(e){return Rr[e>>18&63]+Rr[e>>12&63]+Rr[e>>6&63]+Rr[e&63]}function _m(e,t,r){for(var n,i=[],s=t;s<r;s+=3)n=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(e[s+2]&255),i.push(hm(n));return i.join("")}function ym(e){for(var t,r=e.length,n=r%3,i=[],s=16383,a=0,o=r-n;a<o;a+=s)i.push(_m(e,a,a+s>o?o:a+s));return n===1?(t=e[r-1],i.push(Rr[t>>2]+Rr[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Rr[t>>10]+Rr[t>>4&63]+Rr[t<<2&63]+"=")),i.join("")}});var Pc=ee(Ic=>{Ic.read=function(e,t,r,n,i){var s,a,o=i*8-n-1,c=(1<<o)-1,d=c>>1,f=-7,p=r?i-1:0,m=r?-1:1,b=e[t+p];for(p+=m,s=b&(1<<-f)-1,b>>=-f,f+=o;f>0;s=s*256+e[t+p],p+=m,f-=8);for(a=s&(1<<-f)-1,s>>=-f,f+=n;f>0;a=a*256+e[t+p],p+=m,f-=8);if(s===0)s=1-d;else{if(s===c)return a?NaN:(b?-1:1)*(1/0);a=a+Math.pow(2,n),s=s-d}return(b?-1:1)*a*Math.pow(2,s-n)};Ic.write=function(e,t,r,n,i,s){var a,o,c,d=s*8-i-1,f=(1<<d)-1,p=f>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:s-1,l=n?1:-1,A=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-a))<1&&(a--,c*=2),a+p>=1?t+=m/c:t+=m*Math.pow(2,1-p),t*c>=2&&(a++,c/=2),a+p>=f?(o=0,a=f):a+p>=1?(o=(t*c-1)*Math.pow(2,i),a=a+p):(o=t*Math.pow(2,p-1)*Math.pow(2,i),a=0));i>=8;e[r+b]=o&255,b+=l,o/=256,i-=8);for(a=a<<i|o,d+=i;d>0;e[r+b]=a&255,b+=l,a/=256,d-=8);e[r+b-l]|=A*128}});var wf=ee(di=>{"use strict";var Fc=rf(),ui=Pc(),nf=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;di.Buffer=G;di.SlowBuffer=Tm;di.INSPECT_MAX_BYTES=50;var aa=2147483647;di.kMaxLength=aa;G.TYPED_ARRAY_SUPPORT=mm();!G.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 mm(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(G.prototype,"parent",{enumerable:!0,get:function(){if(G.isBuffer(this))return this.buffer}});Object.defineProperty(G.prototype,"offset",{enumerable:!0,get:function(){if(G.isBuffer(this))return this.byteOffset}});function Zr(e){if(e>aa)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,G.prototype),t}function G(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return qc(e)}return cf(e,t,r)}G.poolSize=8192;function cf(e,t,r){if(typeof e=="string")return bm(e,t);if(ArrayBuffer.isView(e))return wm(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Ar(e,ArrayBuffer)||e&&Ar(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ar(e,SharedArrayBuffer)||e&&Ar(e.buffer,SharedArrayBuffer)))return Uc(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return G.from(n,t,r);let i=xm(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return G.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}G.from=function(e,t,r){return cf(e,t,r)};Object.setPrototypeOf(G.prototype,Uint8Array.prototype);Object.setPrototypeOf(G,Uint8Array);function uf(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function gm(e,t,r){return uf(e),e<=0?Zr(e):t!==void 0?typeof r=="string"?Zr(e).fill(t,r):Zr(e).fill(t):Zr(e)}G.alloc=function(e,t,r){return gm(e,t,r)};function qc(e){return uf(e),Zr(e<0?0:Mc(e)|0)}G.allocUnsafe=function(e){return qc(e)};G.allocUnsafeSlow=function(e){return qc(e)};function bm(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!G.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=lf(e,t)|0,n=Zr(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Vc(e){let t=e.length<0?0:Mc(e.length)|0,r=Zr(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function wm(e){if(Ar(e,Uint8Array)){let t=new Uint8Array(e);return Uc(t.buffer,t.byteOffset,t.byteLength)}return Vc(e)}function Uc(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,G.prototype),n}function xm(e){if(G.isBuffer(e)){let t=Mc(e.length)|0,r=Zr(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Dc(e.length)?Zr(0):Vc(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Vc(e.data)}function Mc(e){if(e>=aa)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+aa.toString(16)+" bytes");return e|0}function Tm(e){return+e!=e&&(e=0),G.alloc(+e)}G.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==G.prototype};G.compare=function(t,r){if(Ar(t,Uint8Array)&&(t=G.from(t,t.offset,t.byteLength)),Ar(r,Uint8Array)&&(r=G.from(r,r.offset,r.byteLength)),!G.isBuffer(t)||!G.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let s=0,a=Math.min(n,i);s<a;++s)if(t[s]!==r[s]){n=t[s],i=r[s];break}return n<i?-1:i<n?1:0};G.isEncoding=function(t){switch(String(t).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}};G.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return G.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=G.allocUnsafe(r),s=0;for(n=0;n<t.length;++n){let a=t[n];if(Ar(a,Uint8Array))s+a.length>i.length?(G.isBuffer(a)||(a=G.from(a)),a.copy(i,s)):Uint8Array.prototype.set.call(i,a,s);else if(G.isBuffer(a))a.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=a.length}return i};function lf(e,t){if(G.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Ar(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Cc(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return bf(e).length;default:if(i)return n?-1:Cc(e).length;t=(""+t).toLowerCase(),i=!0}}G.byteLength=lf;function Nm(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return Fm(this,t,r);case"utf8":case"utf-8":return ff(this,t,r);case"ascii":return Im(this,t,r);case"latin1":case"binary":return Pm(this,t,r);case"base64":return Sm(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vm(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}G.prototype._isBuffer=!0;function kn(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}G.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)kn(this,r,r+1);return this};G.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)kn(this,r,r+3),kn(this,r+1,r+2);return this};G.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)kn(this,r,r+7),kn(this,r+1,r+6),kn(this,r+2,r+5),kn(this,r+3,r+4);return this};G.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?ff(this,0,t):Nm.apply(this,arguments)};G.prototype.toLocaleString=G.prototype.toString;G.prototype.equals=function(t){if(!G.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:G.compare(this,t)===0};G.prototype.inspect=function(){let t="",r=di.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};nf&&(G.prototype[nf]=G.prototype.inspect);G.prototype.compare=function(t,r,n,i,s){if(Ar(t,Uint8Array)&&(t=G.from(t,t.offset,t.byteLength)),!G.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;let a=s-i,o=n-r,c=Math.min(a,o),d=this.slice(i,s),f=t.slice(r,n);for(let p=0;p<c;++p)if(d[p]!==f[p]){a=d[p],o=f[p];break}return a<o?-1:o<a?1:0};function df(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Dc(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=G.from(t,n)),G.isBuffer(t))return t.length===0?-1:sf(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):sf(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function sf(e,t,r,n,i){let s=1,a=e.length,o=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;s=2,a/=2,o/=2,r/=2}function c(f,p){return s===1?f[p]:f.readUInt16BE(p*s)}let d;if(i){let f=-1;for(d=r;d<a;d++)if(c(e,d)===c(t,f===-1?0:d-f)){if(f===-1&&(f=d),d-f+1===o)return f*s}else f!==-1&&(d-=d-f),f=-1}else for(r+o>a&&(r=a-o),d=r;d>=0;d--){let f=!0;for(let p=0;p<o;p++)if(c(e,d+p)!==c(t,p)){f=!1;break}if(f)return d}return-1}G.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};G.prototype.indexOf=function(t,r,n){return df(this,t,r,n,!0)};G.prototype.lastIndexOf=function(t,r,n){return df(this,t,r,n,!1)};function Om(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=t.length;n>s/2&&(n=s/2);let a;for(a=0;a<n;++a){let o=parseInt(t.substr(a*2,2),16);if(Dc(o))return a;e[r+a]=o}return a}function Em(e,t,r,n){return oa(Cc(t,e.length-r),e,r,n)}function vm(e,t,r,n){return oa(Mm(t),e,r,n)}function Rm(e,t,r,n){return oa(bf(t),e,r,n)}function Am(e,t,r,n){return oa(km(t,e.length-r),e,r,n)}G.prototype.write=function(t,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 s=this.length-r;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let a=!1;for(;;)switch(i){case"hex":return Om(this,t,r,n);case"utf8":case"utf-8":return Em(this,t,r,n);case"ascii":case"latin1":case"binary":return vm(this,t,r,n);case"base64":return Rm(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Am(this,t,r,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}};G.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Sm(e,t,r){return t===0&&r===e.length?Fc.fromByteArray(e):Fc.fromByteArray(e.slice(t,r))}function ff(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let s=e[i],a=null,o=s>239?4:s>223?3:s>191?2:1;if(i+o<=r){let c,d,f,p;switch(o){case 1:s<128&&(a=s);break;case 2:c=e[i+1],(c&192)===128&&(p=(s&31)<<6|c&63,p>127&&(a=p));break;case 3:c=e[i+1],d=e[i+2],(c&192)===128&&(d&192)===128&&(p=(s&15)<<12|(c&63)<<6|d&63,p>2047&&(p<55296||p>57343)&&(a=p));break;case 4:c=e[i+1],d=e[i+2],f=e[i+3],(c&192)===128&&(d&192)===128&&(f&192)===128&&(p=(s&15)<<18|(c&63)<<12|(d&63)<<6|f&63,p>65535&&p<1114112&&(a=p))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),i+=o}return Bm(n)}var af=4096;function Bm(e){let t=e.length;if(t<=af)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=af));return r}function Im(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function Pm(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function Fm(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=t;s<r;++s)i+=Dm[e[s]];return i}function Vm(e,t,r){let n=e.slice(t,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}G.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,G.prototype),i};function pt(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}G.prototype.readUintLE=G.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=this[t],s=1,a=0;for(;++a<r&&(s*=256);)i+=this[t+a]*s;return i};G.prototype.readUintBE=G.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=this[t+--r],s=1;for(;r>0&&(s*=256);)i+=this[t+--r]*s;return i};G.prototype.readUint8=G.prototype.readUInt8=function(t,r){return t=t>>>0,r||pt(t,1,this.length),this[t]};G.prototype.readUint16LE=G.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||pt(t,2,this.length),this[t]|this[t+1]<<8};G.prototype.readUint16BE=G.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||pt(t,2,this.length),this[t]<<8|this[t+1]};G.prototype.readUint32LE=G.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};G.prototype.readUint32BE=G.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};G.prototype.readBigUInt64LE=un(function(t){t=t>>>0,li(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Xi(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,s=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});G.prototype.readBigUInt64BE=un(function(t){t=t>>>0,li(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Xi(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],s=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});G.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=this[t],s=1,a=0;for(;++a<r&&(s*=256);)i+=this[t+a]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};G.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=r,s=1,a=this[t+--i];for(;i>0&&(s*=256);)a+=this[t+--i]*s;return s*=128,a>=s&&(a-=Math.pow(2,8*r)),a};G.prototype.readInt8=function(t,r){return t=t>>>0,r||pt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};G.prototype.readInt16LE=function(t,r){t=t>>>0,r||pt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};G.prototype.readInt16BE=function(t,r){t=t>>>0,r||pt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};G.prototype.readInt32LE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};G.prototype.readInt32BE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};G.prototype.readBigInt64LE=un(function(t){t=t>>>0,li(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Xi(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});G.prototype.readBigInt64BE=un(function(t){t=t>>>0,li(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Xi(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});G.prototype.readFloatLE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),ui.read(this,t,!0,23,4)};G.prototype.readFloatBE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),ui.read(this,t,!1,23,4)};G.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||pt(t,8,this.length),ui.read(this,t,!0,52,8)};G.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||pt(t,8,this.length),ui.read(this,t,!1,52,8)};function Kt(e,t,r,n,i,s){if(!G.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}G.prototype.writeUintLE=G.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let o=Math.pow(2,8*n)-1;Kt(this,t,r,n,o,0)}let s=1,a=0;for(this[r]=t&255;++a<n&&(s*=256);)this[r+a]=t/s&255;return r+n};G.prototype.writeUintBE=G.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let o=Math.pow(2,8*n)-1;Kt(this,t,r,n,o,0)}let s=n-1,a=1;for(this[r+s]=t&255;--s>=0&&(a*=256);)this[r+s]=t/a&255;return r+n};G.prototype.writeUint8=G.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,1,255,0),this[r]=t&255,r+1};G.prototype.writeUint16LE=G.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};G.prototype.writeUint16BE=G.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};G.prototype.writeUint32LE=G.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};G.prototype.writeUint32BE=G.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function pf(e,t,r,n,i){gf(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a,r}function hf(e,t,r,n,i){gf(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r+7]=s,s=s>>8,e[r+6]=s,s=s>>8,e[r+5]=s,s=s>>8,e[r+4]=s;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=a,a=a>>8,e[r+2]=a,a=a>>8,e[r+1]=a,a=a>>8,e[r]=a,r+8}G.prototype.writeBigUInt64LE=un(function(t,r=0){return pf(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeBigUInt64BE=un(function(t,r=0){return hf(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Kt(this,t,r,n,c-1,-c)}let s=0,a=1,o=0;for(this[r]=t&255;++s<n&&(a*=256);)t<0&&o===0&&this[r+s-1]!==0&&(o=1),this[r+s]=(t/a>>0)-o&255;return r+n};G.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Kt(this,t,r,n,c-1,-c)}let s=n-1,a=1,o=0;for(this[r+s]=t&255;--s>=0&&(a*=256);)t<0&&o===0&&this[r+s+1]!==0&&(o=1),this[r+s]=(t/a>>0)-o&255;return r+n};G.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};G.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};G.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};G.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};G.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Kt(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};G.prototype.writeBigInt64LE=un(function(t,r=0){return pf(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});G.prototype.writeBigInt64BE=un(function(t,r=0){return hf(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function _f(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function yf(e,t,r,n,i){return t=+t,r=r>>>0,i||_f(e,t,r,4,34028234663852886e22,-34028234663852886e22),ui.write(e,t,r,n,23,4),r+4}G.prototype.writeFloatLE=function(t,r,n){return yf(this,t,r,!0,n)};G.prototype.writeFloatBE=function(t,r,n){return yf(this,t,r,!1,n)};function mf(e,t,r,n,i){return t=+t,r=r>>>0,i||_f(e,t,r,8,17976931348623157e292,-17976931348623157e292),ui.write(e,t,r,n,52,8),r+8}G.prototype.writeDoubleLE=function(t,r,n){return mf(this,t,r,!0,n)};G.prototype.writeDoubleBE=function(t,r,n){return mf(this,t,r,!1,n)};G.prototype.copy=function(t,r,n,i){if(!G.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.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),t.length-r<i-n&&(i=t.length-r+n);let s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),s};G.prototype.fill=function(t,r,n,i){if(typeof t=="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"&&!G.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let a=t.charCodeAt(0);(i==="utf8"&&a<128||i==="latin1")&&(t=a)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));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,t||(t=0);let s;if(typeof t=="number")for(s=r;s<n;++s)this[s]=t;else{let a=G.isBuffer(t)?t:G.from(t,i),o=a.length;if(o===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=a[s%o]}return this};var ci={};function kc(e,t,r){ci[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}kc("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);kc("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);kc("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=of(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=of(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function of(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function Um(e,t,r){li(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&Xi(t,e.length-(r+1))}function gf(e,t,r,n,i,s){if(e>r||e<t){let a=typeof t=="bigint"?"n":"",o;throw s>3?t===0||t===BigInt(0)?o=`>= 0${a} and < 2${a} ** ${(s+1)*8}${a}`:o=`>= -(2${a} ** ${(s+1)*8-1}${a}) and < 2 ** ${(s+1)*8-1}${a}`:o=`>= ${t}${a} and <= ${r}${a}`,new ci.ERR_OUT_OF_RANGE("value",o,e)}Um(n,i,s)}function li(e,t){if(typeof e!="number")throw new ci.ERR_INVALID_ARG_TYPE(t,"number",e)}function Xi(e,t,r){throw Math.floor(e)!==e?(li(e,r),new ci.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new ci.ERR_BUFFER_OUT_OF_BOUNDS:new ci.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var Cm=/[^+/0-9A-Za-z-_]/g;function qm(e){if(e=e.split("=")[0],e=e.trim().replace(Cm,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function Cc(e,t){t=t||1/0;let r,n=e.length,i=null,s=[];for(let a=0;a<n;++a){if(r=e.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(a+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function Mm(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function km(e,t){let r,n,i,s=[];for(let a=0;a<e.length&&!((t-=2)<0);++a)r=e.charCodeAt(a),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function bf(e){return Fc.toByteArray(qm(e))}function oa(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ar(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Dc(e){return e!==e}var Dm=function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function un(e){return typeof BigInt>"u"?jm:e}function jm(){throw new Error("BigInt not supported")}});var jc=ee(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.ReplicaRejectCode=void 0;var Lm;(function(e){e[e.SysFatal=1]="SysFatal",e[e.SysTransient=2]="SysTransient",e[e.DestinationInvalid=3]="DestinationInvalid",e[e.CanisterReject=4]="CanisterReject",e[e.CanisterError=5]="CanisterError"})(Lm=Qi.ReplicaRejectCode||(Qi.ReplicaRejectCode={}))});var xf=ee(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});pi.decode=pi.encode=void 0;var ca="abcdefghijklmnopqrstuvwxyz234567",fi=Object.create(null);for(let e=0;e<ca.length;e++)fi[ca[e]]=e;fi[0]=fi.o;fi[1]=fi.i;function Hm(e){let t=0,r=0,n="";function i(s){return t<0?r|=s>>-t:r=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=ca[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?ca[r>>3]:"")}pi.encode=Hm;function Km(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0;function s(a){let o=fi[a.toLowerCase()];if(o===void 0)throw new Error(`Invalid character: ${JSON.stringify(a)}`);o<<=3,r|=o>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=o<<5-t&255:r=0)}for(let a of e)s(a);return n.slice(0,i)}pi.decode=Km});var Tf=ee(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.getCrc32=void 0;var $m=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]);function Gm(e){let t=new Uint8Array(e),r=-1;for(let n=0;n<t.length;n++){let s=(t[n]^r)&255;r=$m[s]^r>>>8}return(r^-1)>>>0}ua.getCrc32=Gm});var Hc=ee(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.isBytes=Of;Sr.number=la;Sr.bool=Nf;Sr.bytes=Lc;Sr.hash=Ef;Sr.exists=vf;Sr.output=Rf;function la(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Nf(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function Of(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Lc(e,...t){if(!Of(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Ef(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");la(e.outputLen),la(e.blockLen)}function vf(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Rf(e,t){Lc(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var zm={number:la,bool:Nf,bytes:Lc,hash:Ef,exists:vf,output:Rf};Sr.default=zm});var Af=ee(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});da.crypto=void 0;var ln=oi("node:crypto");da.crypto=ln&&typeof ln=="object"&&"webcrypto"in ln?ln.webcrypto:ln&&typeof ln=="object"&&"randomBytes"in ln?ln:void 0});var Dn=ee(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.Hash=we.nextTick=we.byteSwapIfBE=we.byteSwap=we.isLE=we.rotl=we.rotr=we.createView=we.u32=we.u8=void 0;we.isBytes=Wm;we.byteSwap32=tg;we.bytesToHex=ng;we.hexToBytes=ig;we.asyncLoop=ag;we.utf8ToBytes=Bf;we.toBytes=fa;we.concatBytes=og;we.checkOpts=ug;we.wrapConstructor=lg;we.wrapConstructorWithOpts=dg;we.wrapXOFConstructorWithOpts=fg;we.randomBytes=pg;var hi=Af(),$c=Hc();function Wm(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}var Ym=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);we.u8=Ym;var Jm=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));we.u32=Jm;var Zm=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);we.createView=Zm;var Xm=(e,t)=>e<<32-t|e>>>t;we.rotr=Xm;var Qm=(e,t)=>e<<t|e>>>32-t>>>0;we.rotl=Qm;we.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var eg=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;we.byteSwap=eg;we.byteSwapIfBE=we.isLE?e=>e:e=>(0,we.byteSwap)(e);function tg(e){for(let t=0;t<e.length;t++)e[t]=(0,we.byteSwap)(e[t])}var rg=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ng(e){(0,$c.bytes)(e);let t="";for(let r=0;r<e.length;r++)t+=rg[e[r]];return t}var Xr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Sf(e){if(e>=Xr._0&&e<=Xr._9)return e-Xr._0;if(e>=Xr._A&&e<=Xr._F)return e-(Xr._A-10);if(e>=Xr._a&&e<=Xr._f)return e-(Xr._a-10)}function ig(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let a=Sf(e.charCodeAt(s)),o=Sf(e.charCodeAt(s+1));if(a===void 0||o===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=a*16+o}return n}var sg=async()=>{};we.nextTick=sg;async function ag(e,t,r){let n=Date.now();for(let i=0;i<e;i++){r(i);let s=Date.now()-n;s>=0&&s<t||(await(0,we.nextTick)(),n+=s)}}function Bf(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function fa(e){return typeof e=="string"&&(e=Bf(e)),(0,$c.bytes)(e),e}function og(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];(0,$c.bytes)(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let s=e[n];r.set(s,i),i+=s.length}return r}var Kc=class{clone(){return this._cloneInto()}};we.Hash=Kc;var cg={}.toString;function ug(e,t){if(t!==void 0&&cg.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(e,t)}function lg(e){let t=n=>e().update(fa(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function dg(e){let t=(n,i)=>e(i).update(fa(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function fg(e){let t=(n,i)=>e(i).update(fa(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function pg(e=32){if(hi.crypto&&typeof hi.crypto.getRandomValues=="function")return hi.crypto.getRandomValues(new Uint8Array(e));if(hi.crypto&&typeof hi.crypto.randomBytes=="function")return hi.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}});var Wc=ee(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});dn.HashMD=dn.Maj=dn.Chi=void 0;var Gc=Hc(),es=Dn();function hg(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let i=BigInt(32),s=BigInt(4294967295),a=Number(r>>i&s),o=Number(r&s),c=n?4:0,d=n?0:4;e.setUint32(t+c,a,n),e.setUint32(t+d,o,n)}var _g=(e,t,r)=>e&t^~e&r;dn.Chi=_g;var yg=(e,t,r)=>e&t^e&r^t&r;dn.Maj=yg;var zc=class extends es.Hash{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,es.createView)(this.buffer)}update(t){(0,Gc.exists)(this);let{view:r,buffer:n,blockLen:i}=this;t=(0,es.toBytes)(t);let s=t.length;for(let a=0;a<s;){let o=Math.min(i-this.pos,s-a);if(o===i){let c=(0,es.createView)(t);for(;i<=s-a;a+=i)this.process(c,a);continue}n.set(t.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,Gc.exists)(this),(0,Gc.output)(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:a}=this;r[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>i-a&&(this.process(n,0),a=0);for(let p=a;p<i;p++)r[p]=0;hg(n,i-8,BigInt(this.length*8),s),this.process(n,0);let o=(0,es.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<d;p++)o.setUint32(4*p,f[p],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:a,pos:o}=this;return t.length=i,t.pos=o,t.finished=s,t.destroyed=a,i%r&&t.buffer.set(n),t}};dn.HashMD=zc});var pa=ee(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.sha224=hn.sha256=hn.SHA256=void 0;var Yc=Wc(),sr=Dn(),mg=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),fn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),pn=new Uint32Array(64),ts=class extends Yc.HashMD{constructor(){super(64,32,8,!1),this.A=fn[0]|0,this.B=fn[1]|0,this.C=fn[2]|0,this.D=fn[3]|0,this.E=fn[4]|0,this.F=fn[5]|0,this.G=fn[6]|0,this.H=fn[7]|0}get(){let{A:t,B:r,C:n,D:i,E:s,F:a,G:o,H:c}=this;return[t,r,n,i,s,a,o,c]}set(t,r,n,i,s,a,o,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=a|0,this.G=o|0,this.H=c|0}process(t,r){for(let p=0;p<16;p++,r+=4)pn[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let m=pn[p-15],b=pn[p-2],l=(0,sr.rotr)(m,7)^(0,sr.rotr)(m,18)^m>>>3,A=(0,sr.rotr)(b,17)^(0,sr.rotr)(b,19)^b>>>10;pn[p]=A+pn[p-7]+l+pn[p-16]|0}let{A:n,B:i,C:s,D:a,E:o,F:c,G:d,H:f}=this;for(let p=0;p<64;p++){let m=(0,sr.rotr)(o,6)^(0,sr.rotr)(o,11)^(0,sr.rotr)(o,25),b=f+m+(0,Yc.Chi)(o,c,d)+mg[p]+pn[p]|0,A=((0,sr.rotr)(n,2)^(0,sr.rotr)(n,13)^(0,sr.rotr)(n,22))+(0,Yc.Maj)(n,i,s)|0;f=d,d=c,c=o,o=a+b|0,a=s,s=i,i=n,n=b+A|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,a=a+this.D|0,o=o+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,i,s,a,o,c,d,f)}roundClean(){pn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};hn.SHA256=ts;var Jc=class extends ts{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};hn.sha256=(0,sr.wrapConstructor)(()=>new ts);hn.sha224=(0,sr.wrapConstructor)(()=>new Jc)});var If=ee(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.sha224=void 0;var gg=pa();function bg(e){return gg.sha224.create().update(new Uint8Array(e)).digest()}ha.sha224=bg});var Ut=ee(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.Principal=Br.JSON_KEY_PRINCIPAL=void 0;var Pf=xf(),wg=Tf(),xg=If();Br.JSON_KEY_PRINCIPAL="__principal__";var Tg=2,Ff=4,Ng="aaaaa-aa",Og=e=>{var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))},Eg=e=>e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""),Zc=class e{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Ff]))}static managementCanister(){return this.fromHex(Ng)}static selfAuthenticating(t){let r=(0,xg.sha224)(t);return new this(new Uint8Array([...r,Tg]))}static from(t){if(typeof t=="string")return e.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new e(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new e(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(Og(t))}static fromText(t){let r=t;if(t.includes(Br.JSON_KEY_PRINCIPAL)){let a=JSON.parse(t);Br.JSON_KEY_PRINCIPAL in a&&(r=a[Br.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,Pf.decode)(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Ff}toUint8Array(){return this._arr}toHex(){return Eg(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,(0,wg.getCrc32)(this._arr));let n=new Uint8Array(t),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),o=(0,Pf.encode)(s).match(/.{1,5}/g);if(!o)throw new Error;return o.join("-")}toString(){return this.toText()}toJSON(){return{[Br.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(t){for(let r=0;r<Math.min(this._arr.length,t._arr.length);r++){if(this._arr[r]<t._arr[r])return"lt";if(this._arr[r]>t._arr[r])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let r=this.compareTo(t);return r=="lt"||r=="eq"}gtEq(t){let r=this.compareTo(t);return r=="gt"||r=="eq"}};Br.Principal=Zc});var $t=ee(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.bufFromBufLike=Et.uint8ToBuf=Et.bufEquals=Et.compare=Et.fromHex=Et.toHex=Et.concat=void 0;function vg(...e){let t=new Uint8Array(e.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t.buffer}Et.concat=vg;function Rg(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}Et.toHex=Rg;var Ag=new RegExp(/^[0-9a-fA-F]+$/);function Sg(e){if(!Ag.test(e))throw new Error("Invalid hexadecimal string.");let t=[...e].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(t).buffer}Et.fromHex=Sg;function Vf(e,t){if(e.byteLength!==t.byteLength)return e.byteLength-t.byteLength;let r=new Uint8Array(e),n=new Uint8Array(t);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}Et.compare=Vf;function Bg(e,t){return Vf(e,t)===0}Et.bufEquals=Bg;function _a(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}Et.uint8ToBuf=_a;function Uf(e){return e instanceof Uint8Array?_a(e):e instanceof ArrayBuffer?e:Array.isArray(e)?_a(new Uint8Array(e)):"buffer"in e?Uf(e.buffer):_a(new Uint8Array(e))}Et.bufFromBufLike=Uf});var _i=ee(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});Ir.UpdateCallRejectedError=Ir.QueryCallRejectedError=Ir.ActorCallError=Ir.AgentError=void 0;var eu=Ut(),Ig=jc(),Pg=$t(),ya=class e extends Error{constructor(t){super(t),this.message=t,this.name="AgentError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Ir.AgentError=ya;var rs=class e extends ya{constructor(t,r,n,i){let s=eu.Principal.from(t);super(["Call failed:",` Canister: ${s.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(a=>` "${a}": ${JSON.stringify(i[a])}`)].join(`
4
+ `)),this.canisterId=t,this.methodName=r,this.type=n,this.props=i,this.name="ActorCallError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Ir.ActorCallError=rs;var Xc=class e extends rs{constructor(t,r,n){var i;let s=eu.Principal.from(t);super(s,r,"query",{Status:n.status,Code:(i=Ig.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n,this.name="QueryCallRejectedError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Ir.QueryCallRejectedError=Xc;var Qc=class e extends rs{constructor(t,r,n,i){let s=eu.Principal.from(t);super(s,r,"update",Object.assign({"Request ID":(0,Pg.toHex)(n)},i.body?Object.assign(Object.assign({},i.body.error_code?{"Error code":i.body.error_code}:{}),{"Reject code":String(i.body.reject_code),"Reject message":i.body.reject_message}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.name="UpdateCallRejectedError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Ir.UpdateCallRejectedError=Qc});var ba=ee(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.bufFromBufLike=Gt.uint8ToBuf=Gt.PipeArrayBuffer=Gt.fromHexString=Gt.toHexString=Gt.concat=void 0;function Fg(...e){let t=new Uint8Array(e.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t}Gt.concat=Fg;function Vg(e){return new Uint8Array(e).reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}Gt.toHexString=Vg;function Ug(e){var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))}Gt.fromHexString=Ug;var tu=class{constructor(t,r=t?.byteLength||0){this._buffer=ga(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return ga(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let r=this._view.subarray(0,t);return this._view=this._view.subarray(t),r.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let r=new Uint8Array(t),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(t){let r=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+t);n.set(this._view),this._buffer=r,this._view=n}};Gt.PipeArrayBuffer=tu;function ma(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}Gt.uint8ToBuf=ma;function ga(e){return e instanceof Uint8Array?ma(e):e instanceof ArrayBuffer?e:Array.isArray(e)?ma(new Uint8Array(e)):"buffer"in e?ga(e.buffer):ma(new Uint8Array(e))}Gt.bufFromBufLike=ga});var ru=ee(wa=>{"use strict";Object.defineProperty(wa,"__esModule",{value:!0});wa.idlLabelToId=void 0;function Cg(e){let r=new TextEncoder().encode(e),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function qg(e){if(/^_\d+_$/.test(e)||/^_0x[0-9a-fA-F]+_$/.test(e)){let t=+e.slice(1,-1);if(Number.isSafeInteger(t)&&t>=0&&t<2**32)return t}return Cg(e)}wa.idlLabelToId=qg});var iu=ee(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.readIntLE=Ze.readUIntLE=Ze.writeIntLE=Ze.writeUIntLE=Ze.slebDecode=Ze.slebEncode=Ze.lebDecode=Ze.lebEncode=Ze.safeReadUint8=Ze.safeRead=void 0;var nu=ba();function Cf(){throw new Error("unexpected end of buffer")}function qf(e,t){return e.byteLength<t&&Cf(),e.read(t)}Ze.safeRead=qf;function xa(e){let t=e.readUint8();return t===void 0&&Cf(),t}Ze.safeReadUint8=xa;function Mg(e){if(typeof e=="number"&&(e=BigInt(e)),e<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,r=new nu.PipeArrayBuffer(new ArrayBuffer(t),0);for(;;){let n=Number(e&BigInt(127));if(e/=BigInt(128),e===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}Ze.lebEncode=Mg;function Mf(e){let t=BigInt(1),r=BigInt(0),n;do n=xa(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}Ze.lebDecode=Mf;function kg(e){typeof e=="number"&&(e=BigInt(e));let t=e<BigInt(0);t&&(e=-e-BigInt(1));let r=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,n=new nu.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let s=i(e);if(e/=BigInt(128),t&&e===BigInt(0)&&(s&64)!==0||!t&&e===BigInt(0)&&(s&64)===0){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let a=s%BigInt(128);return Number(t?BigInt(128)-a-BigInt(1):a)}return n.buffer}Ze.slebEncode=kg;function Dg(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if((t[r]&64)===0)return Mf(e);break}let n=new Uint8Array(qf(e,r+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}Ze.slebDecode=Dg;function jg(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return kf(e,t)}Ze.writeUIntLE=jg;function kf(e,t){e=BigInt(e);let r=new nu.PipeArrayBuffer(new ArrayBuffer(Math.min(1,t)),0),n=0,i=BigInt(256),s=BigInt(0),a=Number(e%i);for(r.write(new Uint8Array([a]));++n<t;)e<0&&s===BigInt(0)&&a!==0&&(s=BigInt(1)),a=Number((e/i-s)%BigInt(256)),r.write(new Uint8Array([a])),i*=BigInt(256);return r.buffer}Ze.writeIntLE=kf;function Df(e,t){let r=BigInt(xa(e)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(xa(e));r=r+n*s}return r}Ze.readUIntLE=Df;function Lg(e,t){let r=Df(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Ze.readIntLE=Lg});var jf=ee(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0});yi.iexp2=yi.ilog2=void 0;function Hg(e){let t=BigInt(e);if(e<=0)throw new RangeError("Input must be positive");return t.toString(2).length-1}yi.ilog2=Hg;function Kg(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}yi.iexp2=Kg});var uu=ee(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.Variant=z.Record=z.Opt=z.Vec=z.Tuple=z.Principal=z.Nat64=z.Nat32=z.Nat16=z.Nat8=z.Int64=z.Int32=z.Int16=z.Int8=z.Float64=z.Float32=z.Nat=z.Int=z.Text=z.Null=z.Bool=z.Unknown=z.Reserved=z.Empty=z.decode=z.encode=z.ServiceClass=z.FuncClass=z.PrincipalClass=z.RecClass=z.VariantClass=z.TupleClass=z.RecordClass=z.OptClass=z.VecClass=z.FixedNatClass=z.FixedIntClass=z.FloatClass=z.NatClass=z.IntClass=z.TextClass=z.ReservedClass=z.NullClass=z.BoolClass=z.UnknownClass=z.EmptyClass=z.ConstructType=z.PrimitiveType=z.Type=z.Visitor=void 0;z.Service=z.Func=z.Rec=void 0;var $g=Ut(),Pe=ba(),Pr=ru(),ce=iu(),su=jf(),Ta="DIDL",Lf=400;function ns(e,t,r){return e.map((n,i)=>r(n,t[i]))}var au=class{constructor(){this._typs=[],this._idx=new Map}has(t){return this._idx.has(t.name)}add(t,r){let n=this._typs.length;this._idx.set(t.name,n),this._typs.push(r)}merge(t,r){let n=this._idx.get(t.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+t);if(i===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[i],this._typs.splice(i,1),this._idx.delete(r)}encode(){let t=(0,ce.lebEncode)(this._typs.length),r=(0,Pe.concat)(...this._typs);return(0,Pe.concat)(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return(0,ce.slebEncode)(this._idx.get(t)||0)}},ou=class{visitType(t,r){throw new Error("Not implemented")}visitPrimitive(t,r){return this.visitType(t,r)}visitEmpty(t,r){return this.visitPrimitive(t,r)}visitBool(t,r){return this.visitPrimitive(t,r)}visitNull(t,r){return this.visitPrimitive(t,r)}visitReserved(t,r){return this.visitPrimitive(t,r)}visitText(t,r){return this.visitPrimitive(t,r)}visitNumber(t,r){return this.visitPrimitive(t,r)}visitInt(t,r){return this.visitNumber(t,r)}visitNat(t,r){return this.visitNumber(t,r)}visitFloat(t,r){return this.visitPrimitive(t,r)}visitFixedInt(t,r){return this.visitNumber(t,r)}visitFixedNat(t,r){return this.visitNumber(t,r)}visitPrincipal(t,r){return this.visitPrimitive(t,r)}visitConstruct(t,r){return this.visitType(t,r)}visitVec(t,r,n){return this.visitConstruct(t,n)}visitOpt(t,r,n){return this.visitConstruct(t,n)}visitRecord(t,r,n){return this.visitConstruct(t,n)}visitTuple(t,r,n){let i=r.map((s,a)=>[`_${a}_`,s]);return this.visitRecord(t,i,n)}visitVariant(t,r,n){return this.visitConstruct(t,n)}visitRec(t,r,n){return this.visitConstruct(r,n)}visitFunc(t,r){return this.visitConstruct(t,r)}visitService(t,r){return this.visitConstruct(t,r)}};z.Visitor=ou;var mi=class{display(){return this.name}valueToString(t){return rt(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}};z.Type=mi;var zt=class extends mi{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}};z.PrimitiveType=zt;var Vr=class extends mi{checkType(t){if(t instanceof _n){let r=t.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}};z.ConstructType=Vr;var Na=class extends zt{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,ce.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};z.EmptyClass=Na;var Oa=class extends mi{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,r){throw t.visitType(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof _n?i=()=>r.getType():i=()=>r,Object.defineProperty(n,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}};z.UnknownClass=Oa;var Ea=class extends zt{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return(0,ce.slebEncode)(-2)}decodeValue(t,r){switch(this.checkType(r),(0,ce.safeReadUint8)(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};z.BoolClass=Ea;var va=class extends zt{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ce.slebEncode)(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}};z.NullClass=va;var gi=class extends zt{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ce.slebEncode)(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}};z.ReservedClass=gi;var Ra=class extends zt{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=(0,ce.lebEncode)(r.byteLength);return(0,Pe.concat)(n,r)}encodeType(){return(0,ce.slebEncode)(-15)}decodeValue(t,r){this.checkType(r);let n=(0,ce.lebDecode)(t),i=(0,ce.safeRead)(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(t){return'"'+t+'"'}};z.TextClass=Ra;var Aa=class extends zt{accept(t,r){return t.visitInt(this,r)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return(0,ce.slebEncode)(t)}encodeType(){return(0,ce.slebEncode)(-4)}decodeValue(t,r){return this.checkType(r),(0,ce.slebDecode)(t)}get name(){return"int"}valueToString(t){return t.toString()}};z.IntClass=Aa;var Sa=class extends zt{accept(t,r){return t.visitNat(this,r)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return(0,ce.lebEncode)(t)}encodeType(){return(0,ce.slebEncode)(-3)}decodeValue(t,r){return this.checkType(r),(0,ce.lebDecode)(t)}get name(){return"nat"}valueToString(t){return t.toString()}};z.NatClass=Sa;var is=class extends zt{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,r){return t.visitFloat(this,r)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),r}encodeType(){let t=this._bits===32?-13:-14;return(0,ce.slebEncode)(t)}decodeValue(t,r){this.checkType(r);let n=(0,ce.safeRead)(t,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}};z.FloatClass=is;var Qr=class extends zt{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=(0,su.iexp2)(this._bits-1)*BigInt(-1),n=(0,su.iexp2)(this._bits-1)-BigInt(1),i=!1;if(typeof t=="bigint")i=t>=r&&t<=n;else if(Number.isInteger(t)){let s=BigInt(t);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return(0,ce.writeIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,ce.slebEncode)(-9-t)}decodeValue(t,r){this.checkType(r);let n=(0,ce.readIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}};z.FixedIntClass=Qr;var Fr=class extends zt{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=(0,su.iexp2)(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<r:Number.isInteger(t)&&t>=0?n=BigInt(t)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return(0,ce.writeUIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,ce.slebEncode)(-5-t)}decodeValue(t,r){this.checkType(r);let n=(0,ce.readUIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}};z.FixedNatClass=Fr;var Ba=class e extends Vr{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof Fr&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof Fr?this._type._bits:this._type instanceof Qr?this._type._bits:0;if(ArrayBuffer.isView(t)&&r==t.BYTES_PER_ELEMENT*8||Array.isArray(t)&&t.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
5
5
 
6
- index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){let r=(0,ce.lebEncode)(t.length);if(this._blobOptimization)return(0,Pe.concat)(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return(0,Pe.concat)(r,new Uint8Array(t.buffer));let n=new Pe.PipeArrayBuffer(new ArrayBuffer(r.byteLength+t.length),0);n.write(r);for(let i of t){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=(0,ce.slebEncode)(-19),n=this._type.encodeType(t);t.add(this,(0,Pe.concat)(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a vector type");let i=Number((0,ce.lebDecode)(t));if(this._type instanceof Fr){if(this._type._bits==8)return new Uint8Array(t.read(i));if(this._type._bits==16)return new Uint16Array(t.read(i*2));if(this._type._bits==32)return new Uint32Array(t.read(i*4));if(this._type._bits==64)return new BigUint64Array(t.read(i*8))}if(this._type instanceof Qr){if(this._type._bits==8)return new Int8Array(t.read(i));if(this._type._bits==16)return new Int16Array(t.read(i*2));if(this._type._bits==32)return new Int32Array(t.read(i*4));if(this._type._bits==64)return new BigInt64Array(t.read(i*8))}let s=[];for(let a=0;a<i;a++)s.push(this._type.decodeValue(t,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(t){return"vec {"+t.map(n=>this._type.valueToString(n)).join("; ")+"}"}};z.VecClass=Ia;var bi=class e extends Vr{constructor(t){super(),this._type=t}accept(t,r){return t.visitOpt(this,this._type,r)}covariant(t){try{if(Array.isArray(t)&&(t.length===0||t.length===1&&this._type.covariant(t[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${tt(t)}
6
+ index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=(0,ce.lebEncode)(t.length);if(this._blobOptimization)return(0,Pe.concat)(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return(0,Pe.concat)(r,new Uint8Array(t.buffer));let n=new Pe.PipeArrayBuffer(new ArrayBuffer(r.byteLength+t.length),0);n.write(r);for(let i of t){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=(0,ce.slebEncode)(-19),n=this._type.encodeType(t);t.add(this,(0,Pe.concat)(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a vector type");let i=Number((0,ce.lebDecode)(t));if(this._type instanceof Fr){if(this._type._bits==8)return new Uint8Array(t.read(i));if(this._type._bits==16)return new Uint16Array(t.read(i*2));if(this._type._bits==32)return new Uint32Array(t.read(i*4));if(this._type._bits==64)return new BigUint64Array(t.read(i*8))}if(this._type instanceof Qr){if(this._type._bits==8)return new Int8Array(t.read(i));if(this._type._bits==16)return new Int16Array(t.read(i*2));if(this._type._bits==32)return new Int32Array(t.read(i*4));if(this._type._bits==64)return new BigInt64Array(t.read(i*8))}let s=[];for(let a=0;a<i;a++)s.push(this._type.decodeValue(t,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(t){return"vec {"+t.map(n=>this._type.valueToString(n)).join("; ")+"}"}};z.VecClass=Ba;var bi=class e extends Vr{constructor(t){super(),this._type=t}accept(t,r){return t.visitOpt(this,this._type,r)}covariant(t){try{if(Array.isArray(t)&&(t.length===0||t.length===1&&this._type.covariant(t[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${rt(t)}
7
7
 
8
- -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):(0,Pe.concat)(new Uint8Array([1]),this._type.encodeValue(t[0]))}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=(0,ce.slebEncode)(-18),n=this._type.encodeType(t);t.add(this,(0,Pe.concat)(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not an option type");switch((0,ce.safeReadUint8)(t)){case 0:return[];case 1:return[this._type.decodeValue(t,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(t){return t.length===0?"null":`opt ${this._type.valueToString(t[0])}`}};z.OptClass=bi;var ss=class e extends Vr{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,Pr.idlLabelToId)(r[0])-(0,Pr.idlLabelToId)(n[0]))}accept(t,r){return t.visitRecord(this,this._fields,r)}tryAsTuple(){let t=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;t.push(i)}return t}covariant(t){if(typeof t=="object"&&this._fields.every(([r,n])=>{if(!t.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(t[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
8
+ -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):(0,Pe.concat)(new Uint8Array([1]),this._type.encodeValue(t[0]))}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=(0,ce.slebEncode)(-18),n=this._type.encodeType(t);t.add(this,(0,Pe.concat)(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not an option type");switch((0,ce.safeReadUint8)(t)){case 0:return[];case 1:return[this._type.decodeValue(t,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(t){return t.length===0?"null":`opt ${this._type.valueToString(t[0])}`}};z.OptClass=bi;var ss=class e extends Vr{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,Pr.idlLabelToId)(r[0])-(0,Pr.idlLabelToId)(n[0]))}accept(t,r){return t.visitRecord(this,this._fields,r)}tryAsTuple(){let t=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;t.push(i)}return t}covariant(t){if(typeof t=="object"&&this._fields.every(([r,n])=>{if(!t.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(t[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
9
9
 
10
- field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){let r=this._fields.map(([i])=>t[i]),n=ns(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Pe.concat)(...n)}_buildTypeTableImpl(t){this._fields.forEach(([s,a])=>a.buildTypeTable(t));let r=(0,ce.slebEncode)(-20),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,a])=>(0,Pe.concat)((0,ce.lebEncode)((0,Pr.idlLabelToId)(s)),a.encodeType(t)));t.add(this,(0,Pe.concat)(r,n,(0,Pe.concat)(...i)))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a record type");let i={},s=0,a=0;for(;a<n._fields.length;){let[o,c]=n._fields[a];if(s>=this._fields.length){c.decodeValue(t,c),a++;continue}let[d,f]=this._fields[s],p=(0,Pr.idlLabelToId)(this._fields[s][0]),m=(0,Pr.idlLabelToId)(o);if(p===m)i[d]=f.decodeValue(t,c),s++,a++;else if(m>p)if(f instanceof bi||f instanceof gi)i[d]=[],s++;else throw new Error("Cannot find required field "+d);else c.decodeValue(t,c),a++}for(let[o,c]of this._fields.slice(s))if(c instanceof bi||c instanceof gi)i[o]=[];else throw new Error("Cannot find required field "+o);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(t){let r=this._fields.map(([i])=>t[i]);return`record {${ns(this._fields,r,([i,s],a)=>i+"="+s.valueToString(a)).join("; ")}}`}};z.RecordClass=ss;var Pa=class e extends ss{constructor(t){let r={};t.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=t}accept(t,r){return t.visitTuple(this,this._components,r)}covariant(t){if(Array.isArray(t)&&t.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(t[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
10
+ field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=this._fields.map(([i])=>t[i]),n=ns(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Pe.concat)(...n)}_buildTypeTableImpl(t){this._fields.forEach(([s,a])=>a.buildTypeTable(t));let r=(0,ce.slebEncode)(-20),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,a])=>(0,Pe.concat)((0,ce.lebEncode)((0,Pr.idlLabelToId)(s)),a.encodeType(t)));t.add(this,(0,Pe.concat)(r,n,(0,Pe.concat)(...i)))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a record type");let i={},s=0,a=0;for(;a<n._fields.length;){let[o,c]=n._fields[a];if(s>=this._fields.length){c.decodeValue(t,c),a++;continue}let[d,f]=this._fields[s],p=(0,Pr.idlLabelToId)(this._fields[s][0]),m=(0,Pr.idlLabelToId)(o);if(p===m)i[d]=f.decodeValue(t,c),s++,a++;else if(m>p)if(f instanceof bi||f instanceof gi)i[d]=[],s++;else throw new Error("Cannot find required field "+d);else c.decodeValue(t,c),a++}for(let[o,c]of this._fields.slice(s))if(c instanceof bi||c instanceof gi)i[o]=[];else throw new Error("Cannot find required field "+o);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(t){let r=this._fields.map(([i])=>t[i]);return`record {${ns(this._fields,r,([i,s],a)=>i+"="+s.valueToString(a)).join("; ")}}`}};z.RecordClass=ss;var Ia=class e extends ss{constructor(t){let r={};t.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=t}accept(t,r){return t.visitTuple(this,this._components,r)}covariant(t){if(Array.isArray(t)&&t.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(t[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
11
11
 
12
- index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){let r=ns(this._components,t,(n,i)=>n.encodeValue(i));return(0,Pe.concat)(...r)}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,a]of n._components.entries())s>=this._components.length?a.decodeValue(t,a):i.push(this._components[s].decodeValue(t,a));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${ns(this._components,t,(n,i)=>n.valueToString(i)).join("; ")}}`}};z.TupleClass=Pa;var Fa=class e extends Vr{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,Pr.idlLabelToId)(r[0])-(0,Pr.idlLabelToId)(n[0]))}accept(t,r){return t.visitVariant(this,this._fields,r)}covariant(t){if(typeof t=="object"&&Object.entries(t).length===1&&this._fields.every(([r,n])=>{try{return!t.hasOwnProperty(r)||n.covariant(t[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
12
+ index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=ns(this._components,t,(n,i)=>n.encodeValue(i));return(0,Pe.concat)(...r)}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,a]of n._components.entries())s>=this._components.length?a.decodeValue(t,a):i.push(this._components[s].decodeValue(t,a));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${ns(this._components,t,(n,i)=>n.valueToString(i)).join("; ")}}`}};z.TupleClass=Ia;var Pa=class e extends Vr{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,Pr.idlLabelToId)(r[0])-(0,Pr.idlLabelToId)(n[0]))}accept(t,r){return t.visitVariant(this,this._fields,r)}covariant(t){if(typeof t=="object"&&Object.entries(t).length===1&&this._fields.every(([r,n])=>{try{return!t.hasOwnProperty(r)||n.covariant(t[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
13
13
 
14
- variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(t.hasOwnProperty(n)){let s=(0,ce.lebEncode)(r),a=i.encodeValue(t[n]);return(0,Pe.concat)(s,a)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,s])=>{s.buildTypeTable(t)});let r=(0,ce.slebEncode)(-21),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,a])=>(0,Pe.concat)((0,ce.lebEncode)((0,Pr.idlLabelToId)(s)),a.encodeType(t)));t.add(this,(0,Pe.concat)(r,n,...i))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a variant type");let i=Number((0,ce.lebDecode)(t));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,a]=n._fields[i];for(let[o,c]of this._fields)if((0,Pr.idlLabelToId)(s)===(0,Pr.idlLabelToId)(o)){let d=c.decodeValue(t,a);return{[o]:d}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(t){for(let[r,n]of this._fields)if(t.hasOwnProperty(r)){let i=n.valueToString(t[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+t)}};z.VariantClass=Fa;var _n=class e extends Vr{constructor(){super(...arguments),this._id=e._counter++,this._type=void 0}accept(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,r)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};z.RecClass=_n;_n._counter=0;function uu(e){if((0,ce.safeReadUint8)(e)!==1)throw new Error("Cannot decode principal");let r=Number((0,ce.lebDecode)(e));return zg.Principal.fromUint8Array(new Uint8Array((0,ce.safeRead)(e,r)))}var Va=class extends zt{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,ce.lebEncode)(r.byteLength);return(0,Pe.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,ce.slebEncode)(-24)}decodeValue(t,r){return this.checkType(r),uu(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};z.PrincipalClass=Va;var as=class extends Vr{constructor(t,r,n=[]){super(),this.argTypes=t,this.retTypes=r,this.annotations=n}static argsToString(t,r){if(t.length!==r.length)throw new Error("arity mismatch");return"("+t.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(t,r){return t.visitFunc(this,r)}covariant(t){if(Array.isArray(t)&&t.length===2&&t[0]&&t[0]._isPrincipal&&typeof t[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),i=(0,ce.lebEncode)(n.byteLength),s=(0,Pe.concat)(new Uint8Array([1]),i,n),a=new TextEncoder().encode(r),o=(0,ce.lebEncode)(a.byteLength);return(0,Pe.concat)(new Uint8Array([1]),s,o,a)}_buildTypeTableImpl(t){this.argTypes.forEach(d=>d.buildTypeTable(t)),this.retTypes.forEach(d=>d.buildTypeTable(t));let r=(0,ce.slebEncode)(-22),n=(0,ce.lebEncode)(this.argTypes.length),i=(0,Pe.concat)(...this.argTypes.map(d=>d.encodeType(t))),s=(0,ce.lebEncode)(this.retTypes.length),a=(0,Pe.concat)(...this.retTypes.map(d=>d.encodeType(t))),o=(0,ce.lebEncode)(this.annotations.length),c=(0,Pe.concat)(...this.annotations.map(d=>this.encodeAnnotation(d)));t.add(this,(0,Pe.concat)(r,n,i,s,a,o,c))}decodeValue(t){if((0,ce.safeReadUint8)(t)!==1)throw new Error("Cannot decode function reference");let n=uu(t),i=Number((0,ce.lebDecode)(t)),s=(0,ce.safeRead)(t,i),o=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,o]}get name(){let t=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${t}) -> (${r})${n}`}valueToString([t,r]){return`func "${t.toText()}".${r}`}display(){let t=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${t}) \u2192 (${r})${n}`}encodeAnnotation(t){if(t==="query")return new Uint8Array([1]);if(t==="oneway")return new Uint8Array([2]);if(t==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};z.FuncClass=as;var Ua=class extends Vr{constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,ce.lebEncode)(r.length);return(0,Pe.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([s,a])=>a.buildTypeTable(t));let r=(0,ce.slebEncode)(-23),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,a])=>{let o=new TextEncoder().encode(s),c=(0,ce.lebEncode)(o.length);return(0,Pe.concat)(c,o,a.encodeType(t))});t.add(this,(0,Pe.concat)(r,n,...i))}decodeValue(t){return uu(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};z.ServiceClass=Ua;function tt(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>Hf?t.substring(0,Hf-3)+"...":t}function Wg(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new ou;e.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(Na),i=r.encode(),s=(0,ce.lebEncode)(t.length),a=(0,Pe.concat)(...e.map(c=>c.encodeType(r))),o=(0,Pe.concat)(...ns(e,t,(c,d)=>{try{c.covariant(d)}catch(f){throw new Error(f.message+`
14
+ variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(t.hasOwnProperty(n)){let s=(0,ce.lebEncode)(r),a=i.encodeValue(t[n]);return(0,Pe.concat)(s,a)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,s])=>{s.buildTypeTable(t)});let r=(0,ce.slebEncode)(-21),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,a])=>(0,Pe.concat)((0,ce.lebEncode)((0,Pr.idlLabelToId)(s)),a.encodeType(t)));t.add(this,(0,Pe.concat)(r,n,...i))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a variant type");let i=Number((0,ce.lebDecode)(t));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,a]=n._fields[i];for(let[o,c]of this._fields)if((0,Pr.idlLabelToId)(s)===(0,Pr.idlLabelToId)(o)){let d=c.decodeValue(t,a);return{[o]:d}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(t){for(let[r,n]of this._fields)if(t.hasOwnProperty(r)){let i=n.valueToString(t[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+t)}};z.VariantClass=Pa;var _n=class e extends Vr{constructor(){super(...arguments),this._id=e._counter++,this._type=void 0}accept(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,r)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};z.RecClass=_n;_n._counter=0;function cu(e){if((0,ce.safeReadUint8)(e)!==1)throw new Error("Cannot decode principal");let r=Number((0,ce.lebDecode)(e));return $g.Principal.fromUint8Array(new Uint8Array((0,ce.safeRead)(e,r)))}var Fa=class extends zt{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,ce.lebEncode)(r.byteLength);return(0,Pe.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,ce.slebEncode)(-24)}decodeValue(t,r){return this.checkType(r),cu(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};z.PrincipalClass=Fa;var as=class extends Vr{constructor(t,r,n=[]){super(),this.argTypes=t,this.retTypes=r,this.annotations=n}static argsToString(t,r){if(t.length!==r.length)throw new Error("arity mismatch");return"("+t.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(t,r){return t.visitFunc(this,r)}covariant(t){if(Array.isArray(t)&&t.length===2&&t[0]&&t[0]._isPrincipal&&typeof t[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),i=(0,ce.lebEncode)(n.byteLength),s=(0,Pe.concat)(new Uint8Array([1]),i,n),a=new TextEncoder().encode(r),o=(0,ce.lebEncode)(a.byteLength);return(0,Pe.concat)(new Uint8Array([1]),s,o,a)}_buildTypeTableImpl(t){this.argTypes.forEach(d=>d.buildTypeTable(t)),this.retTypes.forEach(d=>d.buildTypeTable(t));let r=(0,ce.slebEncode)(-22),n=(0,ce.lebEncode)(this.argTypes.length),i=(0,Pe.concat)(...this.argTypes.map(d=>d.encodeType(t))),s=(0,ce.lebEncode)(this.retTypes.length),a=(0,Pe.concat)(...this.retTypes.map(d=>d.encodeType(t))),o=(0,ce.lebEncode)(this.annotations.length),c=(0,Pe.concat)(...this.annotations.map(d=>this.encodeAnnotation(d)));t.add(this,(0,Pe.concat)(r,n,i,s,a,o,c))}decodeValue(t){if((0,ce.safeReadUint8)(t)!==1)throw new Error("Cannot decode function reference");let n=cu(t),i=Number((0,ce.lebDecode)(t)),s=(0,ce.safeRead)(t,i),o=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,o]}get name(){let t=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${t}) -> (${r})${n}`}valueToString([t,r]){return`func "${t.toText()}".${r}`}display(){let t=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${t}) \u2192 (${r})${n}`}encodeAnnotation(t){if(t==="query")return new Uint8Array([1]);if(t==="oneway")return new Uint8Array([2]);if(t==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};z.FuncClass=as;var Va=class extends Vr{constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,ce.lebEncode)(r.length);return(0,Pe.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([s,a])=>a.buildTypeTable(t));let r=(0,ce.slebEncode)(-23),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,a])=>{let o=new TextEncoder().encode(s),c=(0,ce.lebEncode)(o.length);return(0,Pe.concat)(c,o,a.encodeType(t))});t.add(this,(0,Pe.concat)(r,n,...i))}decodeValue(t){return cu(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};z.ServiceClass=Va;function rt(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>Lf?t.substring(0,Lf-3)+"...":t}function Gg(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new au;e.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(Ta),i=r.encode(),s=(0,ce.lebEncode)(t.length),a=(0,Pe.concat)(...e.map(c=>c.encodeType(r))),o=(0,Pe.concat)(...ns(e,t,(c,d)=>{try{c.covariant(d)}catch(f){throw new Error(f.message+`
15
15
 
16
- `)}return c.encodeValue(d)}));return(0,Pe.concat)(n,i,s,a,o)}z.encode=Wg;function Yg(e,t){let r=new Pe.PipeArrayBuffer(t);if(t.byteLength<Na.length)throw new Error("Message length smaller than magic number");let n=(0,ce.safeRead)(r,Na.length),i=new TextDecoder().decode(n);if(i!==Na)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(b){let l=[],A=Number((0,ce.lebDecode)(b));for(let C=0;C<A;C++){let O=Number((0,ce.slebDecode)(b));switch(O){case-18:case-19:{let H=Number((0,ce.slebDecode)(b));l.push([O,H]);break}case-20:case-21:{let H=[],x=Number((0,ce.lebDecode)(b)),q;for(;x--;){let K=Number((0,ce.lebDecode)(b));if(K>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof q=="number"&&q>=K)throw new Error("field id collision or not sorted");q=K;let $=Number((0,ce.slebDecode)(b));H.push([K,$])}l.push([O,H]);break}case-22:{let H=[],x=Number((0,ce.lebDecode)(b));for(;x--;)H.push(Number((0,ce.slebDecode)(b)));let q=[],K=Number((0,ce.lebDecode)(b));for(;K--;)q.push(Number((0,ce.slebDecode)(b)));let $=[],M=Number((0,ce.lebDecode)(b));for(;M--;)switch(Number((0,ce.lebDecode)(b))){case 1:{$.push("query");break}case 2:{$.push("oneway");break}case 3:{$.push("composite_query");break}default:throw new Error("unknown annotation")}l.push([O,[H,q,$]]);break}case-23:{let H=Number((0,ce.lebDecode)(b)),x=[];for(;H--;){let q=Number((0,ce.lebDecode)(b)),K=new TextDecoder().decode((0,ce.safeRead)(b,q)),$=(0,ce.slebDecode)(b);x.push([K,$])}l.push([O,x]);break}default:throw new Error("Illegal op_code: "+O)}}let v=[],F=Number((0,ce.lebDecode)(b));for(let C=0;C<F;C++)v.push(Number((0,ce.slebDecode)(b)));return[l,v]}let[a,o]=s(r);if(o.length<e.length)throw new Error("Wrong number of return values");let c=a.map(b=>Yf());function d(b){if(b<-24)throw new Error("future value not supported");if(b<0)switch(b){case-1:return z.Null;case-2:return z.Bool;case-3:return z.Nat;case-4:return z.Int;case-5:return z.Nat8;case-6:return z.Nat16;case-7:return z.Nat32;case-8:return z.Nat64;case-9:return z.Int8;case-10:return z.Int16;case-11:return z.Int32;case-12:return z.Int64;case-13:return z.Float32;case-14:return z.Float64;case-15:return z.Text;case-16:return z.Reserved;case-17:return z.Empty;case-24:return z.Principal;default:throw new Error("Illegal op_code: "+b)}if(b>=a.length)throw new Error("type index out of range");return c[b]}function f(b){switch(b[0]){case-19:{let l=d(b[1]);return $f(l)}case-18:{let l=d(b[1]);return Gf(l)}case-20:{let l={};for(let[F,C]of b[1]){let O=`_${F}_`;l[O]=d(C)}let A=zf(l),v=A.tryAsTuple();return Array.isArray(v)?Kf(...v):A}case-21:{let l={};for(let[A,v]of b[1]){let F=`_${A}_`;l[F]=d(v)}return Wf(l)}case-22:{let[l,A,v]=b[1];return Jf(l.map(F=>d(F)),A.map(F=>d(F)),v)}case-23:{let l={},A=b[1];for(let[v,F]of A){let C=d(F);if(C instanceof _n&&(C=C.getType()),!(C instanceof as))throw new Error("Illegal service definition: services can only contain functions");l[v]=C}return Zf(l)}default:throw new Error("Illegal op_code: "+b[0])}}a.forEach((b,l)=>{if(b[0]===-22){let A=f(b);c[l].fill(A)}}),a.forEach((b,l)=>{if(b[0]!==-22){let A=f(b);c[l].fill(A)}});let p=o.map(b=>d(b)),m=e.map((b,l)=>b.decodeValue(r,p[l]));for(let b=e.length;b<p.length;b++)p[b].decodeValue(r,p[b]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return m}z.decode=Yg;z.Empty=new Oa;z.Reserved=new gi;z.Unknown=new Ea;z.Bool=new va;z.Null=new Ra;z.Text=new Aa;z.Int=new Sa;z.Nat=new Ba;z.Float32=new is(32);z.Float64=new is(64);z.Int8=new Qr(8);z.Int16=new Qr(16);z.Int32=new Qr(32);z.Int64=new Qr(64);z.Nat8=new Fr(8);z.Nat16=new Fr(16);z.Nat32=new Fr(32);z.Nat64=new Fr(64);z.Principal=new Va;function Kf(...e){return new Pa(e)}z.Tuple=Kf;function $f(e){return new Ia(e)}z.Vec=$f;function Gf(e){return new bi(e)}z.Opt=Gf;function zf(e){return new ss(e)}z.Record=zf;function Wf(e){return new Fa(e)}z.Variant=Wf;function Yf(){return new _n}z.Rec=Yf;function Jf(e,t,r=[]){return new as(e,t,r)}z.Func=Jf;function Zf(e){return new Ua(e)}z.Service=Zf});var mu=ee(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.VecForm=At.OptionForm=At.VariantForm=At.TupleForm=At.RecordForm=At.InputForm=At.InputBox=void 0;var du=class{constructor(t,r){this.idl=t,this.ui=r,this.label=null,this.value=void 0;let n=document.createElement("span");n.className="status",this.status=n,r.input&&(r.input.addEventListener("blur",()=>{r.input.value!==""&&this.parse()}),r.input.addEventListener("input",()=>{n.style.display="none",r.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(t={}){if(this.ui.form){let r=this.ui.form.parse(t);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,t,r.value);if(!this.idl.covariant(n))throw new Error(`${r.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=n,n}catch(n){r.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+n.message,this.value=void 0;return}}return null}render(t){let r=document.createElement("span");if(this.label){let n=document.createElement("label");n.innerText=this.label,r.appendChild(n)}this.ui.input&&(r.appendChild(this.ui.input),r.appendChild(this.status)),this.ui.form&&this.ui.form.render(r),t.appendChild(r)}};At.InputBox=du;var yn=class{constructor(t){this.ui=t,this.form=[]}renderForm(t){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),t.appendChild(this.ui.container)):this.form.forEach(r=>r.render(t))}render(t){if(this.ui.open&&this.ui.event){t.appendChild(this.ui.open);let r=this;r.ui.open.addEventListener(r.ui.event,()=>{if(r.ui.container)r.ui.container.innerHTML="";else{let n=r.ui.open.nextElementSibling;n&&n.parentNode.removeChild(n)}r.generateForm(),r.renderForm(t)})}else this.generateForm(),this.renderForm(t)}};At.InputForm=yn;var fu=class extends yn{constructor(t,r){super(r),this.fields=t,this.ui=r}generateForm(){this.form=this.fields.map(([t,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(t)?n.label=this.ui.labelMap[t]+" ":n.label=t+" ",n})}parse(t){let r={};if(this.fields.forEach(([n,i],s)=>{let a=this.form[s].parse(t);r[n]=a}),!this.form.some(n=>n.isRejected()))return r}};At.RecordForm=fu;var pu=class extends yn{constructor(t,r){super(r),this.components=t,this.ui=r}generateForm(){this.form=this.components.map(t=>this.ui.render(t))}parse(t){let r=[];if(this.components.forEach((n,i)=>{let s=this.form[i].parse(t);r.push(s)}),!this.form.some(n=>n.isRejected()))return r}};At.TupleForm=pu;var hu=class extends yn{constructor(t,r){super(r),this.fields=t,this.ui=r}generateForm(){let t=this.ui.open.selectedIndex,[r,n]=this.fields[t],i=this.ui.render(n);this.form=[i]}parse(t){let r=this.ui.open,n=r.options[r.selectedIndex].value,i=this.form[0].parse(t);if(i===void 0)return;let s={};return s[n]=i,s}};At.VariantForm=hu;var _u=class extends yn{constructor(t,r){super(r),this.ty=t,this.ui=r}generateForm(){if(this.ui.open.checked){let t=this.ui.render(this.ty);this.form=[t]}else this.form=[]}parse(t){if(this.form.length===0)return[];{let r=this.form[0].parse(t);return r===void 0?void 0:[r]}}};At.OptionForm=_u;var yu=class extends yn{constructor(t,r){super(r),this.ty=t,this.ui=r}generateForm(){let t=+this.ui.open.value;this.form=[];for(let r=0;r<t;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(t){let r=this.form.map(n=>n.parse(t));if(!this.form.some(n=>n.isRejected()))return r}};At.VecForm=yu});var Qf=ee(xe=>{"use strict";var Jg=xe&&xe.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Zg=xe&&xe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Xf=xe&&xe.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&Jg(t,e,r);return Zg(t,e),t};Object.defineProperty(xe,"__esModule",{value:!0});xe.renderValue=xe.renderInput=xe.Render=xe.vecForm=xe.optForm=xe.variantForm=xe.tupleForm=xe.recordForm=xe.inputBox=void 0;var qa=Xf(lu()),gu=vt(),wi=Xf(mu()),Xg={parse:sb},os={render:Tu},Qg=(e,t)=>new wi.InputBox(e,Object.assign(Object.assign({},Xg),t));xe.inputBox=Qg;var eb=(e,t)=>new wi.RecordForm(e,Object.assign(Object.assign({},os),t));xe.recordForm=eb;var tb=(e,t)=>new wi.TupleForm(e,Object.assign(Object.assign({},os),t));xe.tupleForm=tb;var rb=(e,t)=>new wi.VariantForm(e,Object.assign(Object.assign({},os),t));xe.variantForm=rb;var nb=(e,t)=>new wi.OptionForm(e,Object.assign(Object.assign({},os),t));xe.optForm=nb;var ib=(e,t)=>new wi.VecForm(e,Object.assign(Object.assign({},os),t));xe.vecForm=ib;var Ca=class extends qa.Visitor{visitType(t,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=t.display(),(0,xe.inputBox)(t,{input:n})}visitNull(t,r){return(0,xe.inputBox)(t,{})}visitRecord(t,r,n){let i={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),i={container:a}}let s=(0,xe.recordForm)(r,i);return(0,xe.inputBox)(t,{form:s})}visitTuple(t,r,n){let i={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),i={container:a}}let s=(0,xe.tupleForm)(r,i);return(0,xe.inputBox)(t,{form:s})}visitVariant(t,r,n){let i=document.createElement("select");for(let[o,c]of r){let d=new Option(o);i.add(d)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},a=(0,xe.variantForm)(r,s);return(0,xe.inputBox)(t,{form:a})}visitOpt(t,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,xe.optForm)(r,{open:i,event:"change"});return(0,xe.inputBox)(t,{form:s})}visitVec(t,r,n){let i=document.createElement("input");i.type="number",i.min="0",i.max="100",i.style.width="8rem",i.placeholder="len",i.classList.add("open");let s=document.createElement("div");s.classList.add("popup-form");let a=(0,xe.vecForm)(r,{open:i,event:"change",container:s});return(0,xe.inputBox)(t,{form:a})}visitRec(t,r,n){return Tu(r)}};xe.Render=Ca;var bu=class extends qa.Visitor{visitNull(t,r){return null}visitBool(t,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(t,r){return r}visitFloat(t,r){return parseFloat(r)}visitFixedInt(t,r){return t._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(t,r){return t._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(t,r){return BigInt(r)}visitPrincipal(t,r){return gu.Principal.fromText(r)}visitService(t,r){return gu.Principal.fromText(r)}visitFunc(t,r){let n=r.split(".",2);return[gu.Principal.fromText(n[0]),n[1]]}},wu=class extends qa.Visitor{visitNull(t,r){return null}visitBool(t,r){return Math.random()<.5}visitText(t,r){return Math.random().toString(36).substring(6)}visitFloat(t,r){return Math.random()}visitInt(t,r){return BigInt(this.generateNumber(!0))}visitNat(t,r){return BigInt(this.generateNumber(!1))}visitFixedInt(t,r){let n=this.generateNumber(!0);return t._bits<=32?n:BigInt(r)}visitFixedNat(t,r){let n=this.generateNumber(!1);return t._bits<=32?n:BigInt(r)}generateNumber(t){let r=Math.floor(Math.random()*100);return t&&Math.random()<.5?-r:r}};function sb(e,t,r){return t.random&&r===""?e.accept(new wu,r):e.accept(new bu,r)}function Tu(e){return e.accept(new Ca,null)}xe.renderInput=Tu;function jn(e,t,r){return e.accept(new xu,{input:t,value:r})}xe.renderValue=jn;var xu=class extends qa.Visitor{visitType(t,r){r.input.ui.input.value=t.valueToString(r.value)}visitNull(t,r){}visitText(t,r){r.input.ui.input.value=r.value}visitRec(t,r,n){jn(r,n.input,n.value)}visitOpt(t,r,n){if(n.value.length!==0){let i=n.input.ui.form,s=i.ui.open;s.checked=!0,s.dispatchEvent(new Event(i.ui.event)),jn(r,i.form[0],n.value[0])}}visitRecord(t,r,n){let i=n.input.ui.form;r.forEach(([s,a],o)=>{jn(a,i.form[o],n.value[s])})}visitTuple(t,r,n){let i=n.input.ui.form;r.forEach((s,a)=>{jn(s,i.form[a],n.value[a])})}visitVariant(t,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([a,o],c)=>{if(a===s[0]){let d=i.ui.open;d.selectedIndex=c,d.dispatchEvent(new Event(i.ui.event)),jn(o,i.form[0],s[1])}})}visitVec(t,r,n){let i=n.input.ui.form,s=n.value.length,a=i.ui.open;a.value=s,a.dispatchEvent(new Event(i.ui.event)),n.value.forEach((o,c)=>{jn(r,i.form[c],o)})}}});var tp=ee(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0})});var Ti=ee(ht=>{"use strict";var rp=ht&&ht.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),ab=ht&&ht.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),xi=ht&&ht.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&rp(t,e,r)},ob=ht&&ht.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&rp(t,e,r);return ab(t,e),t};Object.defineProperty(ht,"__esModule",{value:!0});ht.IDL=void 0;xi(Qf(),ht);xi(mu(),ht);ht.IDL=ob(lu());xi(nu(),ht);xi(su(),ht);xi(wa(),ht);xi(tp(),ht)});var cs=ee((np,Ma)=>{(function(e){"use strict";var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",a=s+"Number primitive has more than 15 significant digits: ",o=1e14,c=14,d=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,m=1e9;function b(x){var q,K,$,M=V.prototype={constructor:V,toString:null,valueOf:null},ae=new V(1),Q=20,ne=4,w=-7,g=21,S=-1e7,R=1e7,B=!1,j=1,Y=0,oe={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},se="0123456789abcdefghijklmnopqrstuvwxyz",W=!0;function V(u,h){var y,P,E,I,D,T,U,L,k=this;if(!(k instanceof V))return new V(u,h);if(h==null){if(u&&u._isBigNumber===!0){k.s=u.s,!u.c||u.e>R?k.c=k.e=null:u.e<S?k.c=[k.e=0]:(k.e=u.e,k.c=u.c.slice());return}if((T=typeof u=="number")&&u*0==0){if(k.s=1/u<0?(u=-u,-1):1,u===~~u){for(I=0,D=u;D>=10;D/=10,I++);I>R?k.c=k.e=null:(k.e=I,k.c=[u]);return}L=String(u)}else{if(!r.test(L=String(u)))return $(k,L,T);k.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(I=L.indexOf("."))>-1&&(L=L.replace(".","")),(D=L.search(/e/i))>0?(I<0&&(I=D),I+=+L.slice(D+1),L=L.substring(0,D)):I<0&&(I=L.length)}else{if(F(h,2,se.length,"Base"),h==10&&W)return k=new V(u),le(k,Q+k.e+1,ne);if(L=String(u),T=typeof u=="number"){if(u*0!=0)return $(k,L,T,h);if(k.s=1/u<0?(L=L.slice(1),-1):1,V.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(a+u)}else k.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(y=se.slice(0,h),I=D=0,U=L.length;D<U;D++)if(y.indexOf(P=L.charAt(D))<0){if(P=="."){if(D>I){I=U;continue}}else if(!E&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){E=!0,D=-1,I=0;continue}return $(k,String(u),T,h)}T=!1,L=K(L,h,10,k.s),(I=L.indexOf("."))>-1?L=L.replace(".",""):I=L.length}for(D=0;L.charCodeAt(D)===48;D++);for(U=L.length;L.charCodeAt(--U)===48;);if(L=L.slice(D,++U)){if(U-=D,T&&V.DEBUG&&U>15&&(u>d||u!==i(u)))throw Error(a+k.s*u);if((I=I-D-1)>R)k.c=k.e=null;else if(I<S)k.c=[k.e=0];else{if(k.e=I,k.c=[],D=(I+1)%c,I<0&&(D+=c),D<U){for(D&&k.c.push(+L.slice(0,D)),U-=c;D<U;)k.c.push(+L.slice(D,D+=c));D=c-(L=L.slice(D)).length}else D-=U;for(;D--;L+="0");k.c.push(+L)}}else k.c=[k.e=0]}V.clone=b,V.ROUND_UP=0,V.ROUND_DOWN=1,V.ROUND_CEIL=2,V.ROUND_FLOOR=3,V.ROUND_HALF_UP=4,V.ROUND_HALF_DOWN=5,V.ROUND_HALF_EVEN=6,V.ROUND_HALF_CEIL=7,V.ROUND_HALF_FLOOR=8,V.EUCLID=9,V.config=V.set=function(u){var h,y;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(h="DECIMAL_PLACES")&&(y=u[h],F(y,0,m,h),Q=y),u.hasOwnProperty(h="ROUNDING_MODE")&&(y=u[h],F(y,0,8,h),ne=y),u.hasOwnProperty(h="EXPONENTIAL_AT")&&(y=u[h],y&&y.pop?(F(y[0],-m,0,h),F(y[1],0,m,h),w=y[0],g=y[1]):(F(y,-m,m,h),w=-(g=y<0?-y:y))),u.hasOwnProperty(h="RANGE"))if(y=u[h],y&&y.pop)F(y[0],-m,-1,h),F(y[1],1,m,h),S=y[0],R=y[1];else if(F(y,-m,m,h),y)S=-(R=y<0?-y:y);else throw Error(s+h+" cannot be zero: "+y);if(u.hasOwnProperty(h="CRYPTO"))if(y=u[h],y===!!y)if(y)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))B=y;else throw B=!y,Error(s+"crypto unavailable");else B=y;else throw Error(s+h+" not true or false: "+y);if(u.hasOwnProperty(h="MODULO_MODE")&&(y=u[h],F(y,0,9,h),j=y),u.hasOwnProperty(h="POW_PRECISION")&&(y=u[h],F(y,0,m,h),Y=y),u.hasOwnProperty(h="FORMAT"))if(y=u[h],typeof y=="object")oe=y;else throw Error(s+h+" not an object: "+y);if(u.hasOwnProperty(h="ALPHABET"))if(y=u[h],typeof y=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(y))W=y.slice(0,10)=="0123456789",se=y;else throw Error(s+h+" invalid: "+y)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:Q,ROUNDING_MODE:ne,EXPONENTIAL_AT:[w,g],RANGE:[S,R],CRYPTO:B,MODULO_MODE:j,POW_PRECISION:Y,FORMAT:oe,ALPHABET:se}},V.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!V.DEBUG)return!0;var h,y,P=u.c,E=u.e,I=u.s;e:if({}.toString.call(P)=="[object Array]"){if((I===1||I===-1)&&E>=-m&&E<=m&&E===i(E)){if(P[0]===0){if(E===0&&P.length===1)return!0;break e}if(h=(E+1)%c,h<1&&(h+=c),String(P[0]).length==h){for(h=0;h<P.length;h++)if(y=P[h],y<0||y>=o||y!==i(y))break e;if(y!==0)return!0}}}else if(P===null&&E===null&&(I===null||I===1||I===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},V.maximum=V.max=function(){return Z(arguments,-1)},V.minimum=V.min=function(){return Z(arguments,1)},V.random=function(){var u=9007199254740992,h=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(y){var P,E,I,D,T,U=0,L=[],k=new V(ae);if(y==null?y=Q:F(y,0,m),D=n(y/c),B)if(crypto.getRandomValues){for(P=crypto.getRandomValues(new Uint32Array(D*=2));U<D;)T=P[U]*131072+(P[U+1]>>>11),T>=9e15?(E=crypto.getRandomValues(new Uint32Array(2)),P[U]=E[0],P[U+1]=E[1]):(L.push(T%1e14),U+=2);U=D/2}else if(crypto.randomBytes){for(P=crypto.randomBytes(D*=7);U<D;)T=(P[U]&31)*281474976710656+P[U+1]*1099511627776+P[U+2]*4294967296+P[U+3]*16777216+(P[U+4]<<16)+(P[U+5]<<8)+P[U+6],T>=9e15?crypto.randomBytes(7).copy(P,U):(L.push(T%1e14),U+=7);U=D/7}else throw B=!1,Error(s+"crypto unavailable");if(!B)for(;U<D;)T=h(),T<9e15&&(L[U++]=T%1e14);for(D=L[--U],y%=c,D&&y&&(T=f[c-y],L[U]=i(D/T)*T);L[U]===0;L.pop(),U--);if(U<0)L=[I=0];else{for(I=-1;L[0]===0;L.splice(0,1),I-=c);for(U=1,T=L[0];T>=10;T/=10,U++);U<c&&(I-=c-U)}return k.e=I,k.c=L,k}}(),V.sum=function(){for(var u=1,h=arguments,y=new V(h[0]);u<h.length;)y=y.plus(h[u++]);return y},K=function(){var u="0123456789";function h(y,P,E,I){for(var D,T=[0],U,L=0,k=y.length;L<k;){for(U=T.length;U--;T[U]*=P);for(T[0]+=I.indexOf(y.charAt(L++)),D=0;D<T.length;D++)T[D]>E-1&&(T[D+1]==null&&(T[D+1]=0),T[D+1]+=T[D]/E|0,T[D]%=E)}return T.reverse()}return function(y,P,E,I,D){var T,U,L,k,J,te,de,ge,Se=y.indexOf("."),Fe=Q,_e=ne;for(Se>=0&&(k=Y,Y=0,y=y.replace(".",""),ge=new V(P),te=ge.pow(y.length-Se),Y=k,ge.c=h(H(A(te.c),te.e,"0"),10,E,u),ge.e=ge.c.length),de=h(y,P,E,D?(T=se,u):(T=u,se)),L=k=de.length;de[--k]==0;de.pop());if(!de[0])return T.charAt(0);if(Se<0?--L:(te.c=de,te.e=L,te.s=I,te=q(te,ge,Fe,_e,E),de=te.c,J=te.r,L=te.e),U=L+Fe+1,Se=de[U],k=E/2,J=J||U<0||de[U+1]!=null,J=_e<4?(Se!=null||J)&&(_e==0||_e==(te.s<0?3:2)):Se>k||Se==k&&(_e==4||J||_e==6&&de[U-1]&1||_e==(te.s<0?8:7)),U<1||!de[0])y=J?H(T.charAt(1),-Fe,T.charAt(0)):T.charAt(0);else{if(de.length=U,J)for(--E;++de[--U]>E;)de[U]=0,U||(++L,de=[1].concat(de));for(k=de.length;!de[--k];);for(Se=0,y="";Se<=k;y+=T.charAt(de[Se++]));y=H(y,L,T.charAt(0))}return y}}(),q=function(){function u(P,E,I){var D,T,U,L,k=0,J=P.length,te=E%p,de=E/p|0;for(P=P.slice();J--;)U=P[J]%p,L=P[J]/p|0,D=de*U+L*te,T=te*U+D%p*p+k,k=(T/I|0)+(D/p|0)+de*L,P[J]=T%I;return k&&(P=[k].concat(P)),P}function h(P,E,I,D){var T,U;if(I!=D)U=I>D?1:-1;else for(T=U=0;T<I;T++)if(P[T]!=E[T]){U=P[T]>E[T]?1:-1;break}return U}function y(P,E,I,D){for(var T=0;I--;)P[I]-=T,T=P[I]<E[I]?1:0,P[I]=T*D+P[I]-E[I];for(;!P[0]&&P.length>1;P.splice(0,1));}return function(P,E,I,D,T){var U,L,k,J,te,de,ge,Se,Fe,_e,fe,He,Lt,Ut,Ct,Ht,Be,Et=P.s==E.s?1:-1,at=P.c,Ke=E.c;if(!at||!at[0]||!Ke||!Ke[0])return new V(!P.s||!E.s||(at?Ke&&at[0]==Ke[0]:!Ke)?NaN:at&&at[0]==0||!Ke?Et*0:Et/0);for(Se=new V(Et),Fe=Se.c=[],L=P.e-E.e,Et=I+L+1,T||(T=o,L=l(P.e/c)-l(E.e/c),Et=Et/c|0),k=0;Ke[k]==(at[k]||0);k++);if(Ke[k]>(at[k]||0)&&L--,Et<0)Fe.push(1),J=!0;else{for(Ut=at.length,Ht=Ke.length,k=0,Et+=2,te=i(T/(Ke[0]+1)),te>1&&(Ke=u(Ke,te,T),at=u(at,te,T),Ht=Ke.length,Ut=at.length),Lt=Ht,_e=at.slice(0,Ht),fe=_e.length;fe<Ht;_e[fe++]=0);Be=Ke.slice(),Be=[0].concat(Be),Ct=Ke[0],Ke[1]>=T/2&&Ct++;do{if(te=0,U=h(Ke,_e,Ht,fe),U<0){if(He=_e[0],Ht!=fe&&(He=He*T+(_e[1]||0)),te=i(He/Ct),te>1)for(te>=T&&(te=T-1),de=u(Ke,te,T),ge=de.length,fe=_e.length;h(de,_e,ge,fe)==1;)te--,y(de,Ht<ge?Be:Ke,ge,T),ge=de.length,U=1;else te==0&&(U=te=1),de=Ke.slice(),ge=de.length;if(ge<fe&&(de=[0].concat(de)),y(_e,de,fe,T),fe=_e.length,U==-1)for(;h(Ke,_e,Ht,fe)<1;)te++,y(_e,Ht<fe?Be:Ke,fe,T),fe=_e.length}else U===0&&(te++,_e=[0]);Fe[k++]=te,_e[0]?_e[fe++]=at[Lt]||0:(_e=[at[Lt]],fe=1)}while((Lt++<Ut||_e[0]!=null)&&Et--);J=_e[0]!=null,Fe[0]||Fe.splice(0,1)}if(T==o){for(k=1,Et=Fe[0];Et>=10;Et/=10,k++);le(Se,I+(Se.e=k+L*c-1)+1,D,J)}else Se.e=L,Se.r=+J;return Se}}();function _(u,h,y,P){var E,I,D,T,U;if(y==null?y=ne:F(y,0,8),!u.c)return u.toString();if(E=u.c[0],D=u.e,h==null)U=A(u.c),U=P==1||P==2&&(D<=w||D>=g)?O(U,D):H(U,D,"0");else if(u=le(new V(u),h,y),I=u.e,U=A(u.c),T=U.length,P==1||P==2&&(h<=I||I<=w)){for(;T<h;U+="0",T++);U=O(U,I)}else if(h-=D,U=H(U,I,"0"),I+1>T){if(--h>0)for(U+=".";h--;U+="0");}else if(h+=I-T,h>0)for(I+1==T&&(U+=".");h--;U+="0");return u.s<0&&E?"-"+U:U}function Z(u,h){for(var y,P,E=1,I=new V(u[0]);E<u.length;E++)P=new V(u[E]),(!P.s||(y=v(I,P))===h||y===0&&I.s===h)&&(I=P);return I}function re(u,h,y){for(var P=1,E=h.length;!h[--E];h.pop());for(E=h[0];E>=10;E/=10,P++);return(y=P+y*c-1)>R?u.c=u.e=null:y<S?u.c=[u.e=0]:(u.e=y,u.c=h),u}$=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,h=/^([^.]+)\.$/,y=/^\.([^.]+)$/,P=/^-?(Infinity|NaN)$/,E=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(I,D,T,U){var L,k=T?D:D.replace(E,"");if(P.test(k))I.s=isNaN(k)?null:k<0?-1:1;else{if(!T&&(k=k.replace(u,function(J,te,de){return L=(de=de.toLowerCase())=="x"?16:de=="b"?2:8,!U||U==L?te:J}),U&&(L=U,k=k.replace(h,"$1").replace(y,"0.$1")),D!=k))return new V(k,L);if(V.DEBUG)throw Error(s+"Not a"+(U?" base "+U:"")+" number: "+D);I.s=null}I.c=I.e=null}}();function le(u,h,y,P){var E,I,D,T,U,L,k,J=u.c,te=f;if(J){e:{for(E=1,T=J[0];T>=10;T/=10,E++);if(I=h-E,I<0)I+=c,D=h,U=J[L=0],k=i(U/te[E-D-1]%10);else if(L=n((I+1)/c),L>=J.length)if(P){for(;J.length<=L;J.push(0));U=k=0,E=1,I%=c,D=I-c+1}else break e;else{for(U=T=J[L],E=1;T>=10;T/=10,E++);I%=c,D=I-c+E,k=D<0?0:i(U/te[E-D-1]%10)}if(P=P||h<0||J[L+1]!=null||(D<0?U:U%te[E-D-1]),P=y<4?(k||P)&&(y==0||y==(u.s<0?3:2)):k>5||k==5&&(y==4||P||y==6&&(I>0?D>0?U/te[E-D]:0:J[L-1])%10&1||y==(u.s<0?8:7)),h<1||!J[0])return J.length=0,P?(h-=u.e+1,J[0]=te[(c-h%c)%c],u.e=-h||0):J[0]=u.e=0,u;if(I==0?(J.length=L,T=1,L--):(J.length=L+1,T=te[c-I],J[L]=D>0?i(U/te[E-D]%te[D])*T:0),P)for(;;)if(L==0){for(I=1,D=J[0];D>=10;D/=10,I++);for(D=J[0]+=T,T=1;D>=10;D/=10,T++);I!=T&&(u.e++,J[0]==o&&(J[0]=1));break}else{if(J[L]+=T,J[L]!=o)break;J[L--]=0,T=1}for(I=J.length;J[--I]===0;J.pop());}u.e>R?u.c=u.e=null:u.e<S&&(u.c=[u.e=0])}return u}function X(u){var h,y=u.e;return y===null?u.toString():(h=A(u.c),h=y<=w||y>=g?O(h,y):H(h,y,"0"),u.s<0?"-"+h:h)}return M.absoluteValue=M.abs=function(){var u=new V(this);return u.s<0&&(u.s=1),u},M.comparedTo=function(u,h){return v(this,new V(u,h))},M.decimalPlaces=M.dp=function(u,h){var y,P,E,I=this;if(u!=null)return F(u,0,m),h==null?h=ne:F(h,0,8),le(new V(I),u+I.e+1,h);if(!(y=I.c))return null;if(P=((E=y.length-1)-l(this.e/c))*c,E=y[E])for(;E%10==0;E/=10,P--);return P<0&&(P=0),P},M.dividedBy=M.div=function(u,h){return q(this,new V(u,h),Q,ne)},M.dividedToIntegerBy=M.idiv=function(u,h){return q(this,new V(u,h),0,1)},M.exponentiatedBy=M.pow=function(u,h){var y,P,E,I,D,T,U,L,k,J=this;if(u=new V(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+X(u));if(h!=null&&(h=new V(h)),T=u.e>14,!J.c||!J.c[0]||J.c[0]==1&&!J.e&&J.c.length==1||!u.c||!u.c[0])return k=new V(Math.pow(+X(J),T?u.s*(2-C(u)):+X(u))),h?k.mod(h):k;if(U=u.s<0,h){if(h.c?!h.c[0]:!h.s)return new V(NaN);P=!U&&J.isInteger()&&h.isInteger(),P&&(J=J.mod(h))}else{if(u.e>9&&(J.e>0||J.e<-1||(J.e==0?J.c[0]>1||T&&J.c[1]>=24e7:J.c[0]<8e13||T&&J.c[0]<=9999975e7)))return I=J.s<0&&C(u)?-0:0,J.e>-1&&(I=1/I),new V(U?1/I:I);Y&&(I=n(Y/c+2))}for(T?(y=new V(.5),U&&(u.s=1),L=C(u)):(E=Math.abs(+X(u)),L=E%2),k=new V(ae);;){if(L){if(k=k.times(J),!k.c)break;I?k.c.length>I&&(k.c.length=I):P&&(k=k.mod(h))}if(E){if(E=i(E/2),E===0)break;L=E%2}else if(u=u.times(y),le(u,u.e+1,1),u.e>14)L=C(u);else{if(E=+X(u),E===0)break;L=E%2}J=J.times(J),I?J.c&&J.c.length>I&&(J.c.length=I):P&&(J=J.mod(h))}return P?k:(U&&(k=ae.div(k)),h?k.mod(h):I?le(k,Y,ne,D):k)},M.integerValue=function(u){var h=new V(this);return u==null?u=ne:F(u,0,8),le(h,h.e+1,u)},M.isEqualTo=M.eq=function(u,h){return v(this,new V(u,h))===0},M.isFinite=function(){return!!this.c},M.isGreaterThan=M.gt=function(u,h){return v(this,new V(u,h))>0},M.isGreaterThanOrEqualTo=M.gte=function(u,h){return(h=v(this,new V(u,h)))===1||h===0},M.isInteger=function(){return!!this.c&&l(this.e/c)>this.c.length-2},M.isLessThan=M.lt=function(u,h){return v(this,new V(u,h))<0},M.isLessThanOrEqualTo=M.lte=function(u,h){return(h=v(this,new V(u,h)))===-1||h===0},M.isNaN=function(){return!this.s},M.isNegative=function(){return this.s<0},M.isPositive=function(){return this.s>0},M.isZero=function(){return!!this.c&&this.c[0]==0},M.minus=function(u,h){var y,P,E,I,D=this,T=D.s;if(u=new V(u,h),h=u.s,!T||!h)return new V(NaN);if(T!=h)return u.s=-h,D.plus(u);var U=D.e/c,L=u.e/c,k=D.c,J=u.c;if(!U||!L){if(!k||!J)return k?(u.s=-h,u):new V(J?D:NaN);if(!k[0]||!J[0])return J[0]?(u.s=-h,u):new V(k[0]?D:ne==3?-0:0)}if(U=l(U),L=l(L),k=k.slice(),T=U-L){for((I=T<0)?(T=-T,E=k):(L=U,E=J),E.reverse(),h=T;h--;E.push(0));E.reverse()}else for(P=(I=(T=k.length)<(h=J.length))?T:h,T=h=0;h<P;h++)if(k[h]!=J[h]){I=k[h]<J[h];break}if(I&&(E=k,k=J,J=E,u.s=-u.s),h=(P=J.length)-(y=k.length),h>0)for(;h--;k[y++]=0);for(h=o-1;P>T;){if(k[--P]<J[P]){for(y=P;y&&!k[--y];k[y]=h);--k[y],k[P]+=o}k[P]-=J[P]}for(;k[0]==0;k.splice(0,1),--L);return k[0]?re(u,k,L):(u.s=ne==3?-1:1,u.c=[u.e=0],u)},M.modulo=M.mod=function(u,h){var y,P,E=this;return u=new V(u,h),!E.c||!u.s||u.c&&!u.c[0]?new V(NaN):!u.c||E.c&&!E.c[0]?new V(E):(j==9?(P=u.s,u.s=1,y=q(E,u,0,3),u.s=P,y.s*=P):y=q(E,u,0,j),u=E.minus(y.times(u)),!u.c[0]&&j==1&&(u.s=E.s),u)},M.multipliedBy=M.times=function(u,h){var y,P,E,I,D,T,U,L,k,J,te,de,ge,Se,Fe,_e=this,fe=_e.c,He=(u=new V(u,h)).c;if(!fe||!He||!fe[0]||!He[0])return!_e.s||!u.s||fe&&!fe[0]&&!He||He&&!He[0]&&!fe?u.c=u.e=u.s=null:(u.s*=_e.s,!fe||!He?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(P=l(_e.e/c)+l(u.e/c),u.s*=_e.s,U=fe.length,J=He.length,U<J&&(ge=fe,fe=He,He=ge,E=U,U=J,J=E),E=U+J,ge=[];E--;ge.push(0));for(Se=o,Fe=p,E=J;--E>=0;){for(y=0,te=He[E]%Fe,de=He[E]/Fe|0,D=U,I=E+D;I>E;)L=fe[--D]%Fe,k=fe[D]/Fe|0,T=de*L+k*te,L=te*L+T%Fe*Fe+ge[I]+y,y=(L/Se|0)+(T/Fe|0)+de*k,ge[I--]=L%Se;ge[I]=y}return y?++P:ge.splice(0,1),re(u,ge,P)},M.negated=function(){var u=new V(this);return u.s=-u.s||null,u},M.plus=function(u,h){var y,P=this,E=P.s;if(u=new V(u,h),h=u.s,!E||!h)return new V(NaN);if(E!=h)return u.s=-h,P.minus(u);var I=P.e/c,D=u.e/c,T=P.c,U=u.c;if(!I||!D){if(!T||!U)return new V(E/0);if(!T[0]||!U[0])return U[0]?u:new V(T[0]?P:E*0)}if(I=l(I),D=l(D),T=T.slice(),E=I-D){for(E>0?(D=I,y=U):(E=-E,y=T),y.reverse();E--;y.push(0));y.reverse()}for(E=T.length,h=U.length,E-h<0&&(y=U,U=T,T=y,h=E),E=0;h;)E=(T[--h]=T[h]+U[h]+E)/o|0,T[h]=o===T[h]?0:T[h]%o;return E&&(T=[E].concat(T),++D),re(u,T,D)},M.precision=M.sd=function(u,h){var y,P,E,I=this;if(u!=null&&u!==!!u)return F(u,1,m),h==null?h=ne:F(h,0,8),le(new V(I),u,h);if(!(y=I.c))return null;if(E=y.length-1,P=E*c+1,E=y[E]){for(;E%10==0;E/=10,P--);for(E=y[0];E>=10;E/=10,P++);}return u&&I.e+1>P&&(P=I.e+1),P},M.shiftedBy=function(u){return F(u,-d,d),this.times("1e"+u)},M.squareRoot=M.sqrt=function(){var u,h,y,P,E,I=this,D=I.c,T=I.s,U=I.e,L=Q+4,k=new V("0.5");if(T!==1||!D||!D[0])return new V(!T||T<0&&(!D||D[0])?NaN:D?I:1/0);if(T=Math.sqrt(+X(I)),T==0||T==1/0?(h=A(D),(h.length+U)%2==0&&(h+="0"),T=Math.sqrt(+h),U=l((U+1)/2)-(U<0||U%2),T==1/0?h="5e"+U:(h=T.toExponential(),h=h.slice(0,h.indexOf("e")+1)+U),y=new V(h)):y=new V(T+""),y.c[0]){for(U=y.e,T=U+L,T<3&&(T=0);;)if(E=y,y=k.times(E.plus(q(I,E,L,1))),A(E.c).slice(0,T)===(h=A(y.c)).slice(0,T))if(y.e<U&&--T,h=h.slice(T-3,T+1),h=="9999"||!P&&h=="4999"){if(!P&&(le(E,E.e+Q+2,0),E.times(E).eq(I))){y=E;break}L+=4,T+=4,P=1}else{(!+h||!+h.slice(1)&&h.charAt(0)=="5")&&(le(y,y.e+Q+2,1),u=!y.times(y).eq(I));break}}return le(y,y.e+Q+1,ne,u)},M.toExponential=function(u,h){return u!=null&&(F(u,0,m),u++),_(this,u,h,1)},M.toFixed=function(u,h){return u!=null&&(F(u,0,m),u=u+this.e+1),_(this,u,h)},M.toFormat=function(u,h,y){var P,E=this;if(y==null)u!=null&&h&&typeof h=="object"?(y=h,h=null):u&&typeof u=="object"?(y=u,u=h=null):y=oe;else if(typeof y!="object")throw Error(s+"Argument not an object: "+y);if(P=E.toFixed(u,h),E.c){var I,D=P.split("."),T=+y.groupSize,U=+y.secondaryGroupSize,L=y.groupSeparator||"",k=D[0],J=D[1],te=E.s<0,de=te?k.slice(1):k,ge=de.length;if(U&&(I=T,T=U,U=I,ge-=I),T>0&&ge>0){for(I=ge%T||T,k=de.substr(0,I);I<ge;I+=T)k+=L+de.substr(I,T);U>0&&(k+=L+de.slice(I)),te&&(k="-"+k)}P=J?k+(y.decimalSeparator||"")+((U=+y.fractionGroupSize)?J.replace(new RegExp("\\d{"+U+"}\\B","g"),"$&"+(y.fractionGroupSeparator||"")):J):k}return(y.prefix||"")+P+(y.suffix||"")},M.toFraction=function(u){var h,y,P,E,I,D,T,U,L,k,J,te,de=this,ge=de.c;if(u!=null&&(T=new V(u),!T.isInteger()&&(T.c||T.s!==1)||T.lt(ae)))throw Error(s+"Argument "+(T.isInteger()?"out of range: ":"not an integer: ")+X(T));if(!ge)return new V(de);for(h=new V(ae),L=y=new V(ae),P=U=new V(ae),te=A(ge),I=h.e=te.length-de.e-1,h.c[0]=f[(D=I%c)<0?c+D:D],u=!u||T.comparedTo(h)>0?I>0?h:L:T,D=R,R=1/0,T=new V(te),U.c[0]=0;k=q(T,h,0,1),E=y.plus(k.times(P)),E.comparedTo(u)!=1;)y=P,P=E,L=U.plus(k.times(E=L)),U=E,h=T.minus(k.times(E=h)),T=E;return E=q(u.minus(y),P,0,1),U=U.plus(E.times(L)),y=y.plus(E.times(P)),U.s=L.s=de.s,I=I*2,J=q(L,P,I,ne).minus(de).abs().comparedTo(q(U,y,I,ne).minus(de).abs())<1?[L,P]:[U,y],R=D,J},M.toNumber=function(){return+X(this)},M.toPrecision=function(u,h){return u!=null&&F(u,1,m),_(this,u,h,2)},M.toString=function(u){var h,y=this,P=y.s,E=y.e;return E===null?P?(h="Infinity",P<0&&(h="-"+h)):h="NaN":(u==null?h=E<=w||E>=g?O(A(y.c),E):H(A(y.c),E,"0"):u===10&&W?(y=le(new V(y),Q+E+1,ne),h=H(A(y.c),y.e,"0")):(F(u,2,se.length,"Base"),h=K(H(A(y.c),E,"0"),10,u,P,!0)),P<0&&y.c[0]&&(h="-"+h)),h},M.valueOf=M.toJSON=function(){return X(this)},M._isBigNumber=!0,x!=null&&V.set(x),V}function l(x){var q=x|0;return x>0||x===q?q:q-1}function A(x){for(var q,K,$=1,M=x.length,ae=x[0]+"";$<M;){for(q=x[$++]+"",K=c-q.length;K--;q="0"+q);ae+=q}for(M=ae.length;ae.charCodeAt(--M)===48;);return ae.slice(0,M+1||1)}function v(x,q){var K,$,M=x.c,ae=q.c,Q=x.s,ne=q.s,w=x.e,g=q.e;if(!Q||!ne)return null;if(K=M&&!M[0],$=ae&&!ae[0],K||$)return K?$?0:-ne:Q;if(Q!=ne)return Q;if(K=Q<0,$=w==g,!M||!ae)return $?0:!M^K?1:-1;if(!$)return w>g^K?1:-1;for(ne=(w=M.length)<(g=ae.length)?w:g,Q=0;Q<ne;Q++)if(M[Q]!=ae[Q])return M[Q]>ae[Q]^K?1:-1;return w==g?0:w>g^K?1:-1}function F(x,q,K,$){if(x<q||x>K||x!==i(x))throw Error(s+($||"Argument")+(typeof x=="number"?x<q||x>K?" out of range: ":" not an integer: ":" not a primitive number: ")+String(x))}function C(x){var q=x.c.length-1;return l(x.e/c)==q&&x.c[q]%2!=0}function O(x,q){return(x.length>1?x.charAt(0)+"."+x.slice(1):x)+(q<0?"e":"e+")+q}function H(x,q,K){var $,M;if(q<0){for(M=K+".";++q;M+=K);x=M+x}else if($=x.length,++q>$){for(M=K,q-=$;--q;M+=K);x+=M}else q<$&&(x=x.slice(0,q)+"."+x.slice(q));return x}t=b(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof Ma<"u"&&Ma.exports?Ma.exports=t:(e||(e=typeof self<"u"&&self?self:window),e.BigNumber=t)})(np)});var sp=ee((EN,ip)=>{ip.exports=function(t,r,n){var i=new t.Uint8Array(n),s=r.pushInt,a=r.pushInt32,o=r.pushInt32Neg,c=r.pushInt64,d=r.pushInt64Neg,f=r.pushFloat,p=r.pushFloatSingle,m=r.pushFloatDouble,b=r.pushTrue,l=r.pushFalse,A=r.pushUndefined,v=r.pushNull,F=r.pushInfinity,C=r.pushInfinityNeg,O=r.pushNaN,H=r.pushNaNNeg,x=r.pushArrayStart,q=r.pushArrayStartFixed,K=r.pushArrayStartFixed32,$=r.pushArrayStartFixed64,M=r.pushObjectStart,ae=r.pushObjectStartFixed,Q=r.pushObjectStartFixed32,ne=r.pushObjectStartFixed64,w=r.pushByteString,g=r.pushByteStringStart,S=r.pushUtf8String,R=r.pushUtf8StringStart,B=r.pushSimpleUnassigned,j=r.pushTagStart,Y=r.pushTagStart4,oe=r.pushTagStart8,se=r.pushTagUnassigned,W=r.pushBreak,V=t.Math.pow,_=0,Z=0,re=0;function le(N){for(N=N|0,_=0,Z=N;(_|0)<(Z|0)&&(re=im[i[_]&255](i[_]|0)|0,!((re|0)>0)););return re|0}function X(N){return N=N|0,((_|0)+(N|0)|0)<(Z|0)?0:1}function u(N){return N=N|0,i[N|0]<<8|i[N+1|0]|0}function h(N){return N=N|0,i[N|0]<<24|i[N+1|0]<<16|i[N+2|0]<<8|i[N+3|0]|0}function y(N){return N=N|0,s(N|0),_=_+1|0,0}function P(N){return N=N|0,X(1)|0?1:(s(i[_+1|0]|0),_=_+2|0,0)}function E(N){return N=N|0,X(2)|0?1:(s(u(_+1|0)|0),_=_+3|0,0)}function I(N){return N=N|0,X(4)|0?1:(a(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function D(N){return N=N|0,X(8)|0?1:(c(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function T(N){return N=N|0,s(-1-(N-32|0)|0),_=_+1|0,0}function U(N){return N=N|0,X(1)|0?1:(s(-1-(i[_+1|0]|0)|0),_=_+2|0,0)}function L(N){N=N|0;var Ee=0;return X(2)|0?1:(Ee=u(_+1|0)|0,s(-1-(Ee|0)|0),_=_+3|0,0)}function k(N){return N=N|0,X(4)|0?1:(o(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function J(N){return N=N|0,X(8)|0?1:(d(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function te(N){N=N|0;var Ee=0,Ae=0,Te=0;return Te=N-64|0,X(Te|0)|0?1:(Ee=_+1|0,Ae=(_+1|0)+(Te|0)|0,w(Ee|0,Ae|0),_=Ae|0,0)}function de(N){N=N|0;var Ee=0,Ae=0,Te=0;return X(1)|0||(Te=i[_+1|0]|0,Ee=_+2|0,Ae=(_+2|0)+(Te|0)|0,X(Te+1|0)|0)?1:(w(Ee|0,Ae|0),_=Ae|0,0)}function ge(N){N=N|0;var Ee=0,Ae=0,Te=0;return X(2)|0||(Te=u(_+1|0)|0,Ee=_+3|0,Ae=(_+3|0)+(Te|0)|0,X(Te+2|0)|0)?1:(w(Ee|0,Ae|0),_=Ae|0,0)}function Se(N){N=N|0;var Ee=0,Ae=0,Te=0;return X(4)|0||(Te=h(_+1|0)|0,Ee=_+5|0,Ae=(_+5|0)+(Te|0)|0,X(Te+4|0)|0)?1:(w(Ee|0,Ae|0),_=Ae|0,0)}function Fe(N){return N=N|0,1}function _e(N){return N=N|0,g(),_=_+1|0,0}function fe(N){N=N|0;var Ee=0,Ae=0,Te=0;return Te=N-96|0,X(Te|0)|0?1:(Ee=_+1|0,Ae=(_+1|0)+(Te|0)|0,S(Ee|0,Ae|0),_=Ae|0,0)}function He(N){N=N|0;var Ee=0,Ae=0,Te=0;return X(1)|0||(Te=i[_+1|0]|0,Ee=_+2|0,Ae=(_+2|0)+(Te|0)|0,X(Te+1|0)|0)?1:(S(Ee|0,Ae|0),_=Ae|0,0)}function Lt(N){N=N|0;var Ee=0,Ae=0,Te=0;return X(2)|0||(Te=u(_+1|0)|0,Ee=_+3|0,Ae=(_+3|0)+(Te|0)|0,X(Te+2|0)|0)?1:(S(Ee|0,Ae|0),_=Ae|0,0)}function Ut(N){N=N|0;var Ee=0,Ae=0,Te=0;return X(4)|0||(Te=h(_+1|0)|0,Ee=_+5|0,Ae=(_+5|0)+(Te|0)|0,X(Te+4|0)|0)?1:(S(Ee|0,Ae|0),_=Ae|0,0)}function Ct(N){return N=N|0,1}function Ht(N){return N=N|0,R(),_=_+1|0,0}function Be(N){return N=N|0,q(N-128|0),_=_+1|0,0}function Et(N){return N=N|0,X(1)|0?1:(q(i[_+1|0]|0),_=_+2|0,0)}function at(N){return N=N|0,X(2)|0?1:(q(u(_+1|0)|0),_=_+3|0,0)}function Ke(N){return N=N|0,X(4)|0?1:(K(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Oc(N){return N=N|0,X(8)|0?1:($(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function Ec(N){return N=N|0,x(),_=_+1|0,0}function $e(N){N=N|0;var Ee=0;return Ee=N-160|0,X(Ee|0)|0?1:(ae(Ee|0),_=_+1|0,0)}function vc(N){return N=N|0,X(1)|0?1:(ae(i[_+1|0]|0),_=_+2|0,0)}function Rc(N){return N=N|0,X(2)|0?1:(ae(u(_+1|0)|0),_=_+3|0,0)}function Ac(N){return N=N|0,X(4)|0?1:(Q(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Sc(N){return N=N|0,X(8)|0?1:(ne(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function Bc(N){return N=N|0,M(),_=_+1|0,0}function cn(N){return N=N|0,j(N-192|0|0),_=_+1|0,0}function $6(N){return N=N|0,j(N|0),_=_+1|0,0}function G6(N){return N=N|0,j(N|0),_=_+1|0,0}function z6(N){return N=N|0,j(N|0),_=_+1|0,0}function W6(N){return N=N|0,j(N|0),_=_+1|0,0}function ft(N){return N=N|0,j(N-192|0|0),_=_+1|0,0}function Y6(N){return N=N|0,j(N|0),_=_+1|0,0}function J6(N){return N=N|0,j(N|0),_=_+1|0,0}function Z6(N){return N=N|0,j(N|0),_=_+1|0,0}function $y(N){return N=N|0,X(1)|0?1:(j(i[_+1|0]|0),_=_+2|0,0)}function Gy(N){return N=N|0,X(2)|0?1:(j(u(_+1|0)|0),_=_+3|0,0)}function zy(N){return N=N|0,X(4)|0?1:(Y(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Wy(N){return N=N|0,X(8)|0?1:(oe(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function rt(N){return N=N|0,B((N|0)-224|0),_=_+1|0,0}function Yy(N){return N=N|0,l(),_=_+1|0,0}function Jy(N){return N=N|0,b(),_=_+1|0,0}function Zy(N){return N=N|0,v(),_=_+1|0,0}function Xy(N){return N=N|0,A(),_=_+1|0,0}function Qy(N){return N=N|0,X(1)|0?1:(B(i[_+1|0]|0),_=_+2|0,0)}function em(N){N=N|0;var Ee=0,Ae=0,Te=1,ia=0,Zi=0,X6=0;return X(2)|0?1:(Ee=i[_+1|0]|0,Ae=i[_+2|0]|0,(Ee|0)&128&&(Te=-1),ia=+(((Ee|0)&124)>>2),Zi=+(((Ee|0)&3)<<8|Ae),+ia==0?f(+(+Te*5960464477539063e-23*+Zi)):+ia==31?+Te==1?+Zi>0?O():F():+Zi>0?H():C():f(+(+Te*V(2,+(+ia-25))*+(1024+Zi))),_=_+3|0,0)}function tm(N){return N=N|0,X(4)|0?1:(p(i[_+1|0]|0,i[_+2|0]|0,i[_+3|0]|0,i[_+4|0]|0),_=_+5|0,0)}function rm(N){return N=N|0,X(8)|0?1:(m(i[_+1|0]|0,i[_+2|0]|0,i[_+3|0]|0,i[_+4|0]|0,i[_+5|0]|0,i[_+6|0]|0,i[_+7|0]|0,i[_+8|0]|0),_=_+9|0,0)}function je(N){return N=N|0,1}function nm(N){return N=N|0,W(),_=_+1|0,0}var im=[y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,P,E,I,D,je,je,je,je,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,U,L,k,J,je,je,je,je,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,de,ge,Se,Fe,je,je,je,_e,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,He,Lt,Ut,Ct,je,je,je,Ht,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Et,at,Ke,Oc,je,je,je,Ec,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,vc,Rc,Ac,Sc,je,je,je,Bc,cn,cn,cn,cn,cn,cn,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,$y,Gy,zy,Wy,je,je,je,je,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,Yy,Jy,Zy,Xy,Qy,em,tm,rm,je,je,je,nm];return{parse:le}}});var us=ee(Zt=>{"use strict";var Nu=cs().BigNumber;Zt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Zt.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};Zt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Zt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Zt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Zt.SHIFT32=Math.pow(2,32);Zt.SHIFT16=Math.pow(2,16);Zt.MAX_SAFE_HIGH=2097151;Zt.NEG_ONE=new Nu(-1);Zt.TEN=new Nu(10);Zt.TWO=new Nu(2);Zt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var ka=ee(ar=>{"use strict";var{Buffer:cb}=oi("buffer"),op=cs().BigNumber,cp=us(),ap=cp.SHIFT32,ub=cp.SHIFT16,lb=2097151;ar.parseHalf=function(t){var r,n,i;return i=t[0]&128?-1:1,r=(t[0]&124)>>2,n=(t[0]&3)<<8|t[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function db(e){return e<16?"0"+e.toString(16):e.toString(16)}ar.arrayBufferToBignumber=function(e){let t=e.byteLength,r="";for(let n=0;n<t;n++)r+=db(e[n]);return new op(r,16)};ar.buildMap=e=>{let t=new Map,r=Object.keys(e),n=r.length;for(let i=0;i<n;i++)t.set(r[i],e[r[i]]);return t};ar.buildInt32=(e,t)=>e*ub+t;ar.buildInt64=(e,t,r,n)=>{let i=ar.buildInt32(e,t),s=ar.buildInt32(r,n);return i>lb?new op(i).times(ap).plus(s):i*ap+s};ar.writeHalf=function(t,r){let n=cb.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if((i&8191)!==0)return!1;var s=i>>16&32768;let a=i>>23&255,o=i&8388607;if(a>=113&&a<=142)s+=(a-112<<10)+(o>>13);else if(a>=103&&a<113){if(o&(1<<126-a)-1)return!1;s+=o+8388608>>126-a}else return!1;return t.writeUInt16BE(s,0),!0};ar.keySorter=function(e,t){var r=e[0].byteLength,n=t[0].byteLength;return r>n?1:n>r?-1:e[0].compare(t[0])};ar.isNegativeZero=e=>e===0&&1/e<0;ar.nextPowerOf2=e=>{let t=0;if(e&&!(e&e-1))return e;for(;e!==0;)e>>=1,t+=1;return 1<<t}});var Ru=ee((AN,up)=>{"use strict";var vu=us(),fb=vu.MT,Da=vu.SIMPLE,Ou=vu.SYMS,Eu=class e{constructor(t){if(typeof t!="number")throw new Error("Invalid Simple type: "+typeof t);if(t<0||t>255||(t|0)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,fb.SIMPLE_FLOAT)}static isSimple(t){return t instanceof e}static decode(t,r){switch(r==null&&(r=!0),t){case Da.FALSE:return!1;case Da.TRUE:return!0;case Da.NULL:return r?null:Ou.NULL;case Da.UNDEFINED:return r?void 0:Ou.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Ou.BREAK;default:return new e(t)}}};up.exports=Eu});var Su=ee((SN,lp)=>{"use strict";var Au=class e{constructor(t,r,n){if(this.tag=t,this.value=r,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){var r,n;if(n=t?.[this.tag],typeof n!="function"&&(n=e["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(e,this.value)}catch(i){return r=i,this.err=r,this}}};lp.exports=Au});var Iu=ee((BN,fp)=>{"use strict";var{URL:pb,URLSearchParams:hb,format:_b}=oi("url"),dp="http://localhost",Bu=class extends pb{constructor(t="",r=dp){super(t,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}format(){return this.toString()}};fp.exports={URLWithLegacySupport:Bu,URLSearchParams:hb,format:_b,defaultBase:dp}});var _p=ee((IN,hp)=>{"use strict";var{URLWithLegacySupport:pp,format:yb}=Iu();hp.exports=(e,t={},r={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new pp(e)}catch{s={}}let a=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new pp(e,yb(a)).toString()}});var Pu=ee((PN,yp)=>{"use strict";var{URLWithLegacySupport:mb,format:gb,URLSearchParams:bb,defaultBase:wb}=Iu(),xb=_p();yp.exports={URL:mb,URLSearchParams:bb,format:gb,relative:xb,defaultBase:wb}});var Fu=ee((FN,gp)=>{"use strict";var{Buffer:Ni}=oi("buffer"),mp=Fc(),Tb=cs().BigNumber,Nb=sp(),qt=ka(),Me=us(),Ob=Ru(),Eb=Su(),{URL:vb}=Pu(),ls=class e{constructor(t){t=t||{},!t.size||t.size<65536?t.size=65536:t.size=qt.nextPowerOf2(t.size),this._heap=new ArrayBuffer(t.size),this._heap8=new Uint8Array(this._heap),this._buffer=Ni.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>qt.arrayBufferToBignumber(r),3:r=>Me.NEG_ONE.minus(qt.arrayBufferToBignumber(r)),4:r=>Me.TEN.pow(r[0]).times(r[1]),5:r=>Me.TWO.pow(r[0]).times(r[1]),32:r=>new vb(r),35:r=>new RegExp(r)},t.tags),this.parser=Nb(global,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var t=this._parents.pop();if(t.length>0)throw new Error(`Missing ${t.length} elements`);switch(t.type){case Me.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case Me.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case Me.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case Me.PARENT.MAP:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(t.ref,t.length));break;case Me.PARENT.OBJECT:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(t.ref,t.length));break;case Me.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===Me.PARENT.TAG&&this._dec()}_dec(){let t=this._currentParent;t.length<0||(t.length--,t.length===0&&this._closeParent())}_push(t,r){let n=this._currentParent;switch(n.values++,n.type){case Me.PARENT.ARRAY:case Me.PARENT.BYTE_STRING:case Me.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case Me.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=Me.PARENT.MAP,n.ref=qt.buildMap(n.ref)));break;case Me.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case Me.PARENT.TAG:this._ref.push(t),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(t,r,n){this._parents[this._depth]={type:r,length:n,ref:t,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:Me.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,r){let n=this._knownTags[t];return n?n(r):new Eb(t,r)}createMap(t,r){return t}createObject(t,r){return t}createArray(t,r){return t}createByteString(t,r){return Ni.concat(t)}createByteStringFromHeap(t,r){return t===r?Ni.alloc(0):Ni.from(this._heap.slice(t,r))}createInt(t){return t}createInt32(t,r){return qt.buildInt32(t,r)}createInt64(t,r,n,i){return qt.buildInt64(t,r,n,i)}createFloat(t){return t}createFloatSingle(t,r,n,i){return mp.read([t,r,n,i],0,!1,23,4)}createFloatDouble(t,r,n,i,s,a,o,c){return mp.read([t,r,n,i,s,a,o,c],0,!1,52,8)}createInt32Neg(t,r){return-1-qt.buildInt32(t,r)}createInt64Neg(t,r,n,i){let s=qt.buildInt32(t,r),a=qt.buildInt32(n,i);return s>Me.MAX_SAFE_HIGH?Me.NEG_ONE.minus(new Tb(s).times(Me.SHIFT32).plus(a)):-1-(s*Me.SHIFT32+a)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(t,r){return t.join("")}createUtf8StringFromHeap(t,r){return t===r?"":this._buffer.toString("utf8",t,r)}createSimpleUnassigned(t){return new Ob(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,r){this._push(this.createInt32(t,r))}pushInt64(t,r,n,i){this._push(this.createInt64(t,r,n,i))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,r,n,i){this._push(this.createFloatSingle(t,r,n,i))}pushFloatDouble(t,r,n,i,s,a,o,c){this._push(this.createFloatDouble(t,r,n,i,s,a,o,c))}pushInt32Neg(t,r){this._push(this.createInt32Neg(t,r))}pushInt64Neg(t,r,n,i){this._push(this.createInt64Neg(t,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],Me.PARENT.ARRAY,-1)}pushArrayStartFixed(t){this._createArrayStartFixed(t)}pushArrayStartFixed32(t,r){let n=qt.buildInt32(t,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(t,r,n,i){let s=qt.buildInt64(t,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(t){this._createObjectStartFixed(t)}pushObjectStartFixed32(t,r){let n=qt.buildInt32(t,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(t,r,n,i){let s=qt.buildInt64(t,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:Me.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(t,r){this._push(this.createByteStringFromHeap(t,r))}pushUtf8StringStart(){this._parents[this._depth]={type:Me.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(t,r){this._push(this.createUtf8StringFromHeap(t,r))}pushSimpleUnassigned(t){this._push(this.createSimpleUnassigned(t))}pushTagStart(t){this._parents[this._depth]={type:Me.PARENT.TAG,length:1,ref:[t]}}pushTagStart4(t,r){this.pushTagStart(qt.buildInt32(t,r))}pushTagStart8(t,r,n,i){this.pushTagStart(qt.buildInt64(t,r,n,i))}pushTagUnassigned(t){this._push(this.createTag(t))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(t){if(t===0){this._push(this.createObject({}));return}this._createParent({},Me.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),Me.PARENT.ARRAY,t)}_decode(t){if(t.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(t);let r=this.parser.parse(t.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(r>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(t){return this._decode(t),this._res[0]}decodeAll(t){return this._decode(t),this._res}static decode(t,r){return typeof t=="string"&&(t=Ni.from(t,r||"hex")),new e({size:t.length}).decodeFirst(t)}static decodeAll(t,r){return typeof t=="string"&&(t=Ni.from(t,r||"hex")),new e({size:t.length}).decodeAll(t)}};ls.decodeFirst=ls.decode;gp.exports=ls});var xp=ee((VN,wp)=>{"use strict";var{Buffer:Vu}=oi("buffer"),Rb=Fu(),Ab=ka(),Uu=class e extends Rb{createTag(t,r){return`${t}(${r})`}createInt(t){return super.createInt(t).toString()}createInt32(t,r){return super.createInt32(t,r).toString()}createInt64(t,r,n,i){return super.createInt64(t,r,n,i).toString()}createInt32Neg(t,r){return super.createInt32Neg(t,r).toString()}createInt64Neg(t,r,n,i){return super.createInt64Neg(t,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(t){let r=super.createFloat(t);return Ab.isNegativeZero(t)?"-0_1":`${r}_1`}createFloatSingle(t,r,n,i){return`${super.createFloatSingle(t,r,n,i)}_2`}createFloatDouble(t,r,n,i,s,a,o,c){return`${super.createFloatDouble(t,r,n,i,s,a,o,c)}_3`}createByteString(t,r){let n=t.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(t,r){return`h'${Vu.from(super.createByteStringFromHeap(t,r)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(t){return`simple(${t})`}createArray(t,r){let n=super.createArray(t,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(t,r){let n=super.createMap(t),i=Array.from(n.keys()).reduce(bp(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(t,r){let n=super.createObject(t),i=Object.keys(n).reduce(bp(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(t,r){let n=t.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(t,r){return`"${Vu.from(super.createUtf8StringFromHeap(t,r)).toString("utf8")}"`}static diagnose(t,r){return typeof t=="string"&&(t=Vu.from(t,r||"hex")),new e().decodeFirst(t)}};wp.exports=Uu;function bp(e){return(t,r)=>t?`${t}, ${r}: ${e[r]}`:`${r}: ${e[r]}`}});var vp=ee((UN,Ep)=>{"use strict";var{Buffer:Ur}=oi("buffer"),{URL:Sb}=Pu(),qu=cs().BigNumber,Cu=ka(),ot=us(),hr=ot.MT,ja=ot.NUMBYTES,Tp=ot.SHIFT32,Np=ot.SYMS,Oi=ot.TAG,Bb=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.TWO,Ib=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.FOUR,Pb=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.EIGHT,Fb=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.TRUE,Vb=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.FALSE,Ub=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.UNDEFINED,Op=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.NULL,Cb=new qu("0x20000000000000"),qb=Ur.from("f97e00","hex"),Mb=Ur.from("f9fc00","hex"),kb=Ur.from("f97c00","hex");function Db(e){return{}.toString.call(e).slice(8,-1)}var Mu=class e{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[Sb,this._pushUrl],[qu,this._pushBigNumber]];let r=t.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(t,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===t){let a=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,a}return this.semanticTypes.push([t,r]),null}push(t){return t&&(this.result[this.offset]=t,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=t.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(t,r,n){return this.result[this.offset]=t,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(t){return this.pushWrite(t,1,1)}_pushUInt16BE(t){return this.pushWrite(t,2,2)}_pushUInt32BE(t){return this.pushWrite(t,3,4)}_pushDoubleBE(t){return this.pushWrite(t,4,8)}_pushNaN(){return this.push(qb)}_pushInfinity(t){let r=t<0?Mb:kb;return this.push(r)}_pushFloat(t){let r=Ur.allocUnsafe(2);if(Cu.writeHalf(r,t)&&Cu.parseHalf(r)===t)return this._pushUInt8(Bb)&&this.push(r);let n=Ur.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(Ib)&&this.push(n):this._pushUInt8(Pb)&&this._pushDoubleBE(t)}_pushInt(t,r,n){let i=r<<5;return t<24?this._pushUInt8(i|t):t<=255?this._pushUInt8(i|ja.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|ja.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|ja.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|ja.EIGHT)&&this._pushUInt32BE(Math.floor(t/Tp))&&this._pushUInt32BE(t%Tp):r===hr.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,hr.NEG_INT,t):this._pushInt(t,hr.POS_INT)}_pushNumber(t){switch(!1){case t===t:return this._pushNaN(t);case isFinite(t):return this._pushInfinity(t);case t%1!==0:return this._pushIntNum(t);default:return this._pushFloat(t)}}_pushString(t){let r=Ur.byteLength(t,"utf8");return this._pushInt(r,hr.UTF8_STRING)&&this.pushWrite(t,5,r)}_pushBoolean(t){return this._pushUInt8(t?Fb:Vb)}_pushUndefined(t){return this._pushUInt8(Ub)}_pushArray(t,r){let n=r.length;if(!t._pushInt(n,hr.ARRAY))return!1;for(let i=0;i<n;i++)if(!t.pushAny(r[i]))return!1;return!0}_pushTag(t){return this._pushInt(t,hr.TAG)}_pushDate(t,r){return t._pushTag(Oi.DATE_EPOCH)&&t.pushAny(Math.round(r/1e3))}_pushBuffer(t,r){return t._pushInt(r.length,hr.BYTE_STRING)&&t.push(r)}_pushNoFilter(t,r){return t._pushBuffer(t,r.slice())}_pushRegexp(t,r){return t._pushTag(Oi.REGEXP)&&t.pushAny(r.source)}_pushSet(t,r){if(!t._pushInt(r.size,hr.ARRAY))return!1;for(let n of r)if(!t.pushAny(n))return!1;return!0}_pushUrl(t,r){return t._pushTag(Oi.URI)&&t.pushAny(r.format())}_pushBigint(t){let r=Oi.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),r=Oi.NEG_BIGINT);let n=t.toString(16);n.length%2&&(n="0"+n);let i=Ur.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(t,r){if(r.isNaN())return t._pushNaN();if(!r.isFinite())return t._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return t._pushBigint(r);if(!(t._pushTag(Oi.DECIMAL_FRAC)&&t._pushInt(2,hr.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new qu(10).pow(n));return t._pushIntNum(-n)?i.abs().isLessThan(Cb)?t._pushIntNum(i.toNumber()):t._pushBigint(i):!1}_pushMap(t,r){return t._pushInt(r.size,hr.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(t){if(!t)return this._pushUInt8(Op);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(t instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(t,this,t);var i=t.encodeCBOR;if(typeof i=="function")return i.call(t,this);var s=Object.keys(t),a=s.length;return this._pushInt(a,hr.MAP)?this._pushRawMap(a,s.map(o=>[o,t[o]])):!1}_pushRawMap(t,r){r=r.map(function(i){return i[0]=e.encode(i[0]),i}).sort(Cu.keySorter);for(var n=0;n<t;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(t){return this.pushAny(t)}pushAny(t){var r=Db(t);switch(r){case"Number":return this._pushNumber(t);case"String":return this._pushString(t);case"Boolean":return this._pushBoolean(t);case"Object":return this._pushObject(t);case"Array":return this._pushArray(this,t);case"Uint8Array":return this._pushBuffer(this,Ur.isBuffer(t)?t:Ur.from(t));case"Null":return this._pushUInt8(Op);case"Undefined":return this._pushUndefined(t);case"Map":return this._pushMap(this,t);case"Set":return this._pushSet(this,t);case"URL":return this._pushUrl(this,t);case"BigNumber":return this._pushBigNumber(this,t);case"Date":return this._pushDate(this,t);case"RegExp":return this._pushRegexp(this,t);case"Symbol":switch(t){case Np.NULL:return this._pushObject(null);case Np.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+t.toString())}default:throw new Error("Unknown type: "+typeof t+", "+(t?t.toString():""))}}finalize(){if(this.offset===0)return null;for(var t=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,a=0;a<i;a++)s+=r[a];var o=Ur.allocUnsafe(s),c=0,d=0;for(a=0;a<i;a++){switch(d=r[a],n[a]){case 0:t[a].copy(o,c);break;case 1:o.writeUInt8(t[a],c,!0);break;case 2:o.writeUInt16BE(t[a],c,!0);break;case 3:o.writeUInt32BE(t[a],c,!0);break;case 4:o.writeDoubleBE(t[a],c,!0);break;case 5:o.write(t[a],c,d,"utf8");break;default:throw new Error("unkown method")}c+=d}var f=o;return this._reset(),f}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(t){let r=new e;if(!r.pushAny(t))throw new Error("Failed to encode input");return r.finalize()}};Ep.exports=Mu});var La=ee(ct=>{"use strict";ct.Diagnose=xp();ct.Decoder=Fu();ct.Encoder=vp();ct.Simple=Ru();ct.Tagged=Su();ct.decodeAll=ct.Decoder.decodeAll;ct.decodeFirst=ct.Decoder.decodeFirst;ct.diagnose=ct.Diagnose.diagnose;ct.encode=ct.Encoder.encode;ct.decode=ct.Decoder.decode;ct.leveldb={decode:ct.Decoder.decodeAll,encode:ct.Encoder.encode,buffer:!0,name:"cbor"}});var ps=ee(or=>{"use strict";var jb=or&&or.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(or,"__esModule",{value:!0});or.hashOfMap=or.requestIdOf=or.hashValue=or.hash=void 0;var Rp=Ti(),Lb=jb(La()),Hb=ha(),ds=$t();function mn(e){return(0,ds.uint8ToBuf)(Hb.sha256.create().update(new Uint8Array(e)).digest())}or.hash=mn;function fs(e){if(e instanceof Lb.default.Tagged)return fs(e.value);if(typeof e=="string")return Ap(e);if(typeof e=="number")return mn((0,Rp.lebEncode)(e));if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return mn(e);if(Array.isArray(e)){let t=e.map(fs);return mn((0,ds.concat)(...t))}else{if(e&&typeof e=="object"&&e._isPrincipal)return mn(e.toUint8Array());if(typeof e=="object"&&e!==null&&typeof e.toHash=="function")return fs(e.toHash());if(typeof e=="object")return ku(e);if(typeof e=="bigint")return mn((0,Rp.lebEncode)(e))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${e}`),{value:e})}or.hashValue=fs;var Ap=e=>{let t=new TextEncoder().encode(e);return mn(t)};function Kb(e){return ku(e)}or.requestIdOf=Kb;function ku(e){let n=Object.entries(e).filter(([,a])=>a!==void 0).map(([a,o])=>{let c=Ap(a),d=fs(o);return[c,d]}).sort(([a],[o])=>(0,ds.compare)(a,o)),i=(0,ds.concat)(...n.map(a=>(0,ds.concat)(...a)));return mn(i)}or.hashOfMap=ku});var Lu=ee(Cr=>{"use strict";var $b=Cr&&Cr.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r};Object.defineProperty(Cr,"__esModule",{value:!0});Cr.createIdentityDescriptor=Cr.AnonymousIdentity=Cr.SignIdentity=void 0;var Sp=vt(),Gb=ps(),Bp=$t(),zb=new TextEncoder().encode(`
17
- ic-request`),Du=class{getPrincipal(){return this._principal||(this._principal=Sp.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:r}=t,n=$b(t,["body"]),i=(0,Gb.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,Bp.concat)(zb,i))}})}};Cr.SignIdentity=Du;var ju=class{getPrincipal(){return Sp.Principal.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}};Cr.AnonymousIdentity=ju;function Wb(e){return"getPublicKey"in e?{type:"PublicKeyIdentity",publicKey:(0,Bp.toHex)(e.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Cr.createIdentityDescriptor=Wb});var $u=ee(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});var Yb=9007199254740992;function en(e,...t){let r=new Uint8Array(e.byteLength+t.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(e),0);let n=e.byteLength;for(let i of t)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function _r(e,t,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(t-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(e<<5)+t].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function Ha(e,t){if(t<24)return new Uint8Array([(e<<5)+t]).buffer;{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27;return _r(e,r,t.toString(16))}}function Ip(e){let t=[];for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);n<128?t.push(n):n<2048?t.push(192|n>>6,128|n&63):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|e.charCodeAt(r)&1023,t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return en(new Uint8Array(Ha(3,e.length)),new Uint8Array(t))}function Jb(e,t){if(e==14277111)return en(new Uint8Array([217,217,247]),t);if(e<24)return en(new Uint8Array([192+e]),t);{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27,n=2**(r-24),i=e.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(a=>parseInt(a,16)));return new Uint8Array(s).buffer}}Ge.tagged=Jb;function hs(e){return new Uint8Array(e).buffer}Ge.raw=hs;function Hu(e){if(isNaN(e))throw new RangeError("Invalid number.");e=Math.min(Math.max(0,e),23);let t=[0+e];return new Uint8Array(t).buffer}Ge.uSmall=Hu;function Pp(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),255),e=e.toString(16),_r(0,24,e)}Ge.u8=Pp;function Fp(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),65535),e=e.toString(16),_r(0,25,e)}Ge.u16=Fp;function Vp(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),4294967295),e=e.toString(16),_r(0,26,e)}Ge.u32=Vp;function Ku(e,t){if(typeof e=="string"&&t==16){if(e.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return _r(0,27,e)}if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),Yb),e=e.toString(16),_r(0,27,e)}Ge.u64=Ku;function Up(e){if(isNaN(e))throw new RangeError("Invalid number.");if(e===0)return Hu(0);e=Math.min(Math.max(0,-e),24)-1;let t=[32+e];return new Uint8Array(t).buffer}Ge.iSmall=Up;function Cp(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),255),e=e.toString(16),_r(1,24,e)}Ge.i8=Cp;function qp(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),65535),e=e.toString(16),_r(1,25,e)}Ge.i16=qp;function Mp(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),4294967295),e=e.toString(16),_r(1,26,e)}Ge.i32=Mp;function kp(e,t){if(typeof e=="string"&&t==16){if(e.startsWith("-")?e=e.slice(1):e="0",e.match(/[^0-9a-fA-F]/)||e.length>16)throw new RangeError("Invalid number.");let r=!1,n=e.split("").reduceRight((i,s)=>{if(r)return s+i;let a=parseInt(s,16)-1;return a>=0?(r=!0,a.toString(16)+i):"f"+i},"");return r?_r(1,27,n):Ku(0)}if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),9007199254740992),e=e.toString(16),_r(1,27,e)}Ge.i64=kp;function Zb(e){return e>=0?e<24?Hu(e):e<=255?Pp(e):e<=65535?Fp(e):e<=4294967295?Vp(e):Ku(e):e>=-24?Up(e):e>=-255?Cp(e):e>=-65535?qp(e):e>=-4294967295?Mp(e):kp(e)}Ge.number=Zb;function Xb(e){return en(Ha(2,e.byteLength),e)}Ge.bytes=Xb;function Qb(e){return Ip(e)}Ge.string=Qb;function e1(e){return en(Ha(4,e.length),...e)}Ge.array=e1;function t1(e,t=!1){e instanceof Map||(e=new Map(Object.entries(e)));let r=Array.from(e.entries());return t&&(r=r.sort(([n],[i])=>n.localeCompare(i))),en(Ha(5,e.size),...r.map(([n,i])=>en(Ip(n),i)))}Ge.map=t1;function r1(e){let t=new Float32Array([e]);return en(new Uint8Array([250]),new Uint8Array(t.buffer))}Ge.singleFloat=r1;function n1(e){let t=new Float64Array([e]);return en(new Uint8Array([251]),new Uint8Array(t.buffer))}Ge.doubleFloat=n1;function i1(e){return e?Dp():jp()}Ge.bool=i1;function Dp(){return hs(new Uint8Array([245]))}Ge.true_=Dp;function jp(){return hs(new Uint8Array([244]))}Ge.false_=jp;function s1(){return hs(new Uint8Array([246]))}Ge.null_=s1;function a1(){return hs(new Uint8Array([247]))}Ge.undefined_=a1});var Lp=ee(gn=>{"use strict";var o1=gn&&gn.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(gn,"__esModule",{value:!0});var yr=o1($u()),c1=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Ka=class{constructor(t,r=!1){this._serializer=t,this._stable=r,this.name="jsonDefault",this.priority=-100}match(t){return["undefined","boolean","number","string","object"].indexOf(typeof t)!=-1}encode(t){switch(typeof t){case"undefined":return yr.undefined_();case"boolean":return yr.bool(t);case"number":return Math.floor(t)===t?yr.number(t):yr.doubleFloat(t);case"string":return yr.string(t);case"object":if(t===null)return yr.null_();if(Array.isArray(t))return yr.array(t.map(r=>this._serializer.serializeValue(r)));if(c1.find(r=>t instanceof r))return yr.bytes(t.buffer);if(Object.getOwnPropertyNames(t).indexOf("toJSON")!==-1)return this.encode(t.toJSON());if(t instanceof Map){let r=new Map;for(let[n,i]of t.entries())r.set(n,this._serializer.serializeValue(i));return yr.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(t))r.set(n,this._serializer.serializeValue(i));return yr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};gn.JsonDefaultCborEncoder=Ka;var $a=class{constructor(){this.name="cborEncoder",this.priority=-90}match(t){return typeof t=="object"&&typeof t.toCBOR=="function"}encode(t){return t.toCBOR()}};gn.ToCborEncoder=$a;var Ga=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let r=new this;return r.addEncoder(new Ka(r,t)),r.addEncoder(new $a),r}removeEncoder(t){for(let r of this._encoders.values())r.name==t&&this._encoders.delete(r)}addEncoder(t){this._encoders.add(t)}getEncoderFor(t){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(t)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(t){return this.getEncoderFor(t).encode(t)}serialize(t){return this.serializeValue(t)}};gn.CborSerializer=Ga;var Gu=class extends Ga{serialize(t){return yr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};gn.SelfDescribeCborSerializer=Gu});var _s=ee(Ln=>{"use strict";function u1(e){for(var t in e)Ln.hasOwnProperty(t)||(Ln[t]=e[t])}var l1=Ln&&Ln.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(Ln,"__esModule",{value:!0});u1(Lp());var d1=l1($u());Ln.value=d1});var ys=ee(gt=>{"use strict";var f1=gt&&gt.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),p1=gt&&gt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),h1=gt&&gt.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&f1(t,e,r);return p1(t,e),t},_1=gt&&gt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(gt,"__esModule",{value:!0});gt.decode=gt.encode=gt.CborTag=void 0;var y1=_1(La()),Ei=h1(_s()),m1=_s(),za=$t(),zu=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return Ei.value.bytes(t.toUint8Array())}},Wu=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return Ei.value.bytes(new Uint8Array(t))}},Yu=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?Ei.value.tagged(2,Ei.value.bytes((0,za.fromHex)(t.toString(16)))):Ei.value.tagged(3,Ei.value.bytes((0,za.fromHex)((BigInt("-1")*t).toString(16))))}},Wa=m1.SelfDescribeCborSerializer.withDefaultEncoders(!0);Wa.addEncoder(new zu);Wa.addEncoder(new Wu);Wa.addEncoder(new Yu);var Kp;(function(e){e[e.Uint64LittleEndian=71]="Uint64LittleEndian",e[e.Semantic=55799]="Semantic"})(Kp=gt.CborTag||(gt.CborTag={}));function g1(e){return Wa.serialize(e)}gt.encode=g1;function Hp(e){let t=e.byteLength,r=BigInt(0);for(let n=0;n<t;n++)r=r*BigInt(256)+BigInt(e[n]);return r}var Ju=class extends y1.default.Decoder{createByteString(t){return(0,za.concat)(...t)}createByteStringFromHeap(t,r){return t===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(t,r))}};function b1(e){let t=new Uint8Array(e),r=new Ju({size:t.byteLength,tags:{2:n=>Hp(n),3:n=>-Hp(n),[Kp.Semantic]:n=>n}});try{return r.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,za.toHex)(t)}`)}}gt.decode=b1});var Zu=ee(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});Ya.randomNumber=void 0;var w1=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let e=new Uint32Array(1);return window.crypto.getRandomValues(e),e[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};Ya.randomNumber=w1});var ms=ee(Hn=>{"use strict";Object.defineProperty(Hn,"__esModule",{value:!0});Hn.makeNonce=Hn.SubmitRequestType=void 0;var Ja=Zu(),x1;(function(e){e.Call="call"})(x1=Hn.SubmitRequestType||(Hn.SubmitRequestType={}));function T1(){let e=new ArrayBuffer(16),t=new DataView(e),r=(0,Ja.randomNumber)(),n=(0,Ja.randomNumber)(),i=(0,Ja.randomNumber)(),s=(0,Ja.randomNumber)();return t.setUint32(0,r),t.setUint32(4,n),t.setUint32(8,i),t.setUint32(12,s),e}Hn.makeNonce=T1});var Xa=ee(St=>{"use strict";var N1=St&&St.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),O1=St&&St.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),E1=St&&St.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&N1(t,e,r);return O1(t,e),t};Object.defineProperty(St,"__esModule",{value:!0});St.httpHeadersTransform=St.makeExpiryTransform=St.makeNonceTransform=St.Expiry=void 0;var v1=Ti(),R1=E1(_s()),A1=ms(),$p=BigInt(1e6),S1=60*1e3,Za=class{constructor(t){if(t<90*1e3){let o=BigInt(Date.now()+t)*$p/BigInt(1e9);this._value=o*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+t-S1))*$p/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return R1.value.u64(this._value.toString(16),16)}toHash(){return(0,v1.lebEncode)(this._value)}};St.Expiry=Za;function B1(e=A1.makeNonce){return async t=>{let r=t.request.headers;t.request.headers=r,t.endpoint==="call"&&(t.body.nonce=e())}}St.makeNonceTransform=B1;function I1(e){return async t=>{t.body.ingress_expiry=new Za(e)}}St.makeExpiryTransform=I1;function P1(e){let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t}St.httpHeadersTransform=P1});var eo=ee(qr=>{"use strict";Object.defineProperty(qr,"__esModule",{value:!0});qr.AgentReadStateError=qr.AgentQueryError=qr.AgentCallError=qr.AgentHTTPResponseError=void 0;var Qa=_i(),Xu=class extends Qa.AgentError{constructor(t,r){super(t),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};qr.AgentHTTPResponseError=Xu;var Qu=class extends Qa.AgentError{constructor(t,r,n,i,s,a){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=a,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}};qr.AgentCallError=Qu;var el=class extends Qa.AgentError{constructor(t,r,n,i,s,a){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=a,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}};qr.AgentQueryError=el;var tl=class extends Qa.AgentError{constructor(t,r,n,i,s,a){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=a,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};qr.AgentReadStateError=tl});var Xt=ee(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.notImplemented=Ue.bitMask=void 0;Ue.isBytes=ro;Ue.abytes=no;Ue.abool=V1;Ue.bytesToHex=sl;Ue.numberToHexUnpadded=Wp;Ue.hexToNumber=al;Ue.hexToBytes=io;Ue.bytesToNumberBE=C1;Ue.bytesToNumberLE=q1;Ue.numberToBytesBE=Yp;Ue.numberToBytesLE=M1;Ue.numberToVarBytesBE=k1;Ue.ensureBytes=D1;Ue.concatBytes=Jp;Ue.equalBytes=j1;Ue.utf8ToBytes=L1;Ue.inRange=Zp;Ue.aInRange=H1;Ue.bitLen=K1;Ue.bitGet=$1;Ue.bitSet=G1;Ue.createHmacDrbg=W1;Ue.validateObject=J1;Ue.memoized=X1;var il=BigInt(0),to=BigInt(1),F1=BigInt(2);function ro(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function no(e){if(!ro(e))throw new Error("Uint8Array expected")}function V1(e,t){if(typeof t!="boolean")throw new Error(`${e} must be valid boolean, got "${t}".`)}var U1=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function sl(e){no(e);let t="";for(let r=0;r<e.length;r++)t+=U1[e[r]];return t}function Wp(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function al(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}var tn={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Gp(e){if(e>=tn._0&&e<=tn._9)return e-tn._0;if(e>=tn._A&&e<=tn._F)return e-(tn._A-10);if(e>=tn._a&&e<=tn._f)return e-(tn._a-10)}function io(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let a=Gp(e.charCodeAt(s)),o=Gp(e.charCodeAt(s+1));if(a===void 0||o===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=a*16+o}return n}function C1(e){return al(sl(e))}function q1(e){return no(e),al(sl(Uint8Array.from(e).reverse()))}function Yp(e,t){return io(e.toString(16).padStart(t*2,"0"))}function M1(e,t){return Yp(e,t).reverse()}function k1(e){return io(Wp(e))}function D1(e,t,r){let n;if(typeof t=="string")try{n=io(t)}catch(s){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`)}else if(ro(t))n=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${e} expected ${r} bytes, got ${i}`);return n}function Jp(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];no(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let s=e[n];r.set(s,i),i+=s.length}return r}function j1(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function L1(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}var rl=e=>typeof e=="bigint"&&il<=e;function Zp(e,t,r){return rl(e)&&rl(t)&&rl(r)&&t<=e&&e<r}function H1(e,t,r,n){if(!Zp(t,r,n))throw new Error(`expected valid ${e}: ${r} <= n < ${n}, got ${typeof t} ${t}`)}function K1(e){let t;for(t=0;e>il;e>>=to,t+=1);return t}function $1(e,t){return e>>BigInt(t)&to}function G1(e,t,r){return e|(r?to:il)<<BigInt(t)}var z1=e=>(F1<<BigInt(e-1))-to;Ue.bitMask=z1;var nl=e=>new Uint8Array(e),zp=e=>Uint8Array.from(e);function W1(e,t,r){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=nl(e),i=nl(e),s=0,a=()=>{n.fill(1),i.fill(0),s=0},o=(...p)=>r(i,n,...p),c=(p=nl())=>{i=o(zp([0]),p),n=o(),p.length!==0&&(i=o(zp([1]),p),n=o())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let p=0,m=[];for(;p<t;){n=o();let b=n.slice();m.push(b),p+=n.length}return Jp(...m)};return(p,m)=>{a(),c(p);let b;for(;!(b=m(d()));)c();return a(),b}}var Y1={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||ro(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function J1(e,t,r={}){let n=(i,s,a)=>{let o=Y1[s];if(typeof o!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=e[i];if(!(a&&c===void 0)&&!o(c,e))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(t))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return e}var Z1=()=>{throw new Error("not implemented")};Ue.notImplemented=Z1;function X1(e){let t=new WeakMap;return(r,...n)=>{let i=t.get(r);if(i!==void 0)return i;let s=e(r,...n);return t.set(r,s),s}}});var Mr=ee(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.isNegativeLE=void 0;Ye.mod=Qt;Ye.pow=e0;Ye.pow2=rw;Ye.invert=so;Ye.tonelliShanks=t0;Ye.FpSqrt=r0;Ye.validateField=sw;Ye.FpPow=n0;Ye.FpInvertBatch=i0;Ye.FpDiv=aw;Ye.FpLegendre=s0;Ye.FpIsSquare=ow;Ye.nLength=cl;Ye.Field=cw;Ye.FpSqrtOdd=uw;Ye.FpSqrtEven=lw;Ye.hashToPrivateScalar=dw;Ye.getFieldBytesLength=ul;Ye.getMinHashLength=a0;Ye.mapHashToField=fw;var er=Xt(),ut=BigInt(0),Le=BigInt(1),bn=BigInt(2),Q1=BigInt(3),ol=BigInt(4),Xp=BigInt(5),Qp=BigInt(8),ew=BigInt(9),tw=BigInt(16);function Qt(e,t){let r=e%t;return r>=ut?r:t+r}function e0(e,t,r){if(r<=ut||t<ut)throw new Error("Expected power/modulo > 0");if(r===Le)return ut;let n=Le;for(;t>ut;)t&Le&&(n=n*e%r),e=e*e%r,t>>=Le;return n}function rw(e,t,r){let n=e;for(;t-- >ut;)n*=n,n%=r;return n}function so(e,t){if(e===ut||t<=ut)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=Qt(e,t),n=t,i=ut,s=Le,a=Le,o=ut;for(;r!==ut;){let d=n/r,f=n%r,p=i-a*d,m=s-o*d;n=r,r=f,i=a,s=o,a=p,o=m}if(n!==Le)throw new Error("invert: does not exist");return Qt(i,t)}function t0(e){let t=(e-Le)/bn,r,n,i;for(r=e-Le,n=0;r%bn===ut;r/=bn,n++);for(i=bn;i<e&&e0(i,t,e)!==e-Le;i++);if(n===1){let a=(e+Le)/ol;return function(c,d){let f=c.pow(d,a);if(!c.eql(c.sqr(f),d))throw new Error("Cannot find square root");return f}}let s=(r+Le)/bn;return function(o,c){if(o.pow(c,t)===o.neg(o.ONE))throw new Error("Cannot find square root");let d=n,f=o.pow(o.mul(o.ONE,i),r),p=o.pow(c,s),m=o.pow(c,r);for(;!o.eql(m,o.ONE);){if(o.eql(m,o.ZERO))return o.ZERO;let b=1;for(let A=o.sqr(m);b<d&&!o.eql(A,o.ONE);b++)A=o.sqr(A);let l=o.pow(f,Le<<BigInt(d-b-1));f=o.sqr(l),p=o.mul(p,l),m=o.mul(m,f),d=b}return p}}function r0(e){if(e%ol===Q1){let t=(e+Le)/ol;return function(n,i){let s=n.pow(i,t);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(e%Qp===Xp){let t=(e-Xp)/Qp;return function(n,i){let s=n.mul(i,bn),a=n.pow(s,t),o=n.mul(i,a),c=n.mul(n.mul(o,bn),a),d=n.mul(o,n.sub(c,n.ONE));if(!n.eql(n.sqr(d),i))throw new Error("Cannot find square root");return d}}return e%tw,t0(e)}var nw=(e,t)=>(Qt(e,t)&Le)===Le;Ye.isNegativeLE=nw;var iw=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function sw(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=iw.reduce((n,i)=>(n[i]="function",n),t);return(0,er.validateObject)(e,r)}function n0(e,t,r){if(r<ut)throw new Error("Expected power > 0");if(r===ut)return e.ONE;if(r===Le)return t;let n=e.ONE,i=t;for(;r>ut;)r&Le&&(n=e.mul(n,i)),i=e.sqr(i),r>>=Le;return n}function i0(e,t){let r=new Array(t.length),n=t.reduce((s,a,o)=>e.is0(a)?s:(r[o]=s,e.mul(s,a)),e.ONE),i=e.inv(n);return t.reduceRight((s,a,o)=>e.is0(a)?s:(r[o]=e.mul(s,r[o]),e.mul(s,a)),i),r}function aw(e,t,r){return e.mul(t,typeof r=="bigint"?so(r,e.ORDER):e.inv(r))}function s0(e){let t=(e-Le)/bn;return(r,n)=>r.pow(n,t)}function ow(e){let t=s0(e.ORDER);return r=>{let n=t(e,r);return e.eql(n,e.ZERO)||e.eql(n,e.ONE)}}function cl(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function cw(e,t,r=!1,n={}){if(e<=ut)throw new Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:s}=cl(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let a=r0(e),o=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:(0,er.bitMask)(i),ZERO:ut,ONE:Le,create:c=>Qt(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ut<=c&&c<e},is0:c=>c===ut,isOdd:c=>(c&Le)===Le,neg:c=>Qt(-c,e),eql:(c,d)=>c===d,sqr:c=>Qt(c*c,e),add:(c,d)=>Qt(c+d,e),sub:(c,d)=>Qt(c-d,e),mul:(c,d)=>Qt(c*d,e),pow:(c,d)=>n0(o,c,d),div:(c,d)=>Qt(c*so(d,e),e),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>so(c,e),sqrt:n.sqrt||(c=>a(o,c)),invertBatch:c=>i0(o,c),cmov:(c,d,f)=>f?d:c,toBytes:c=>r?(0,er.numberToBytesLE)(c,s):(0,er.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,er.bytesToNumberLE)(c):(0,er.bytesToNumberBE)(c)}});return Object.freeze(o)}function uw(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");let r=e.sqrt(t);return e.isOdd(r)?r:e.neg(r)}function lw(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");let r=e.sqrt(t);return e.isOdd(r)?e.neg(r):r}function dw(e,t,r=!1){e=(0,er.ensureBytes)("privateHash",e);let n=e.length,i=cl(t).nByteLength+8;if(i<24||n<i||n>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);let s=r?(0,er.bytesToNumberLE)(e):(0,er.bytesToNumberBE)(e);return Qt(s,t-Le)+Le}function ul(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function a0(e){let t=ul(e);return t+Math.ceil(t/2)}function fw(e,t,r=!1){let n=e.length,i=ul(t),s=a0(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let a=r?(0,er.bytesToNumberBE)(e):(0,er.bytesToNumberLE)(e),o=Qt(a,t-Le)+Le;return r?(0,er.numberToBytesLE)(o,i):(0,er.numberToBytesBE)(o,i)}});var ao=ee(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.expand_message_xmd=o0;Kn.expand_message_xof=c0;Kn.hash_to_field=ll;Kn.isogenyMap=yw;Kn.createHasher=mw;var pw=Mr(),Bt=Xt(),hw=Bt.bytesToNumberBE;function wn(e,t){if(gs(e),gs(t),e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function _w(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function gs(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function o0(e,t,r,n){(0,Bt.abytes)(e),(0,Bt.abytes)(t),gs(r),t.length>255&&(t=n((0,Bt.concatBytes)((0,Bt.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:s}=n,a=Math.ceil(r/i);if(r>65535||a>255)throw new Error("expand_message_xmd: invalid lenInBytes");let o=(0,Bt.concatBytes)(t,wn(t.length,1)),c=wn(0,s),d=wn(r,2),f=new Array(a),p=n((0,Bt.concatBytes)(c,e,d,wn(0,1),o));f[0]=n((0,Bt.concatBytes)(p,wn(1,1),o));for(let b=1;b<=a;b++){let l=[_w(p,f[b-1]),wn(b+1,1),o];f[b]=n((0,Bt.concatBytes)(...l))}return(0,Bt.concatBytes)(...f).slice(0,r)}function c0(e,t,r,n,i){if((0,Bt.abytes)(e),(0,Bt.abytes)(t),gs(r),t.length>255){let s=Math.ceil(2*n/8);t=i.create({dkLen:s}).update((0,Bt.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update(wn(r,2)).update(t).update(wn(t.length,1)).digest()}function ll(e,t,r){(0,Bt.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:a,expand:o,DST:c}=r;(0,Bt.abytes)(e),gs(t);let d=typeof c=="string"?(0,Bt.utf8ToBytes)(c):c,f=n.toString(2).length,p=Math.ceil((f+i)/8),m=t*s*p,b;if(o==="xmd")b=o0(e,d,m,a);else if(o==="xof")b=c0(e,d,m,i,a);else if(o==="_internal_pass")b=e;else throw new Error('expand must be "xmd" or "xof"');let l=new Array(t);for(let A=0;A<t;A++){let v=new Array(s);for(let F=0;F<s;F++){let C=p*(F+A*s),O=b.subarray(C,C+p);v[F]=(0,pw.mod)(hw(O),n)}l[A]=v}return l}function yw(e,t){let r=t.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,a,o,c]=r.map(d=>d.reduce((f,p)=>e.add(e.mul(f,n),p)));return n=e.div(s,a),i=e.mul(i,e.div(o,c)),{x:n,y:i}}}function mw(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=ll(n,2,{...r,DST:r.DST,...i}),a=e.fromAffine(t(s[0])),o=e.fromAffine(t(s[1])),c=a.add(o).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=ll(n,1,{...r,DST:r.encodeDST,...i}),a=e.fromAffine(t(s[0])).clearCofactor();return a.assertValidity(),a},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=e.fromAffine(t(n)).clearCofactor();return i.assertValidity(),i}}}});var pl=ee(bs=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});bs.wNAF=bw;bs.pippenger=ww;bs.validateBasic=xw;var u0=Mr(),d0=Xt(),gw=BigInt(0),dl=BigInt(1),fl=new WeakMap,l0=new WeakMap;function bw(e,t){let r=(s,a)=>{let o=a.negate();return s?o:a},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},i=s=>{n(s);let a=Math.ceil(t/s)+1,o=2**(s-1);return{windows:a,windowSize:o}};return{constTimeNegate:r,unsafeLadder(s,a){let o=e.ZERO,c=s;for(;a>gw;)a&dl&&(o=o.add(c)),c=c.double(),a>>=dl;return o},precomputeWindow(s,a){let{windows:o,windowSize:c}=i(a),d=[],f=s,p=f;for(let m=0;m<o;m++){p=f,d.push(p);for(let b=1;b<c;b++)p=p.add(f),d.push(p);f=p.double()}return d},wNAF(s,a,o){let{windows:c,windowSize:d}=i(s),f=e.ZERO,p=e.BASE,m=BigInt(2**s-1),b=2**s,l=BigInt(s);for(let A=0;A<c;A++){let v=A*d,F=Number(o&m);o>>=l,F>d&&(F-=b,o+=dl);let C=v,O=v+Math.abs(F)-1,H=A%2!==0,x=F<0;F===0?p=p.add(r(H,a[C])):f=f.add(r(x,a[O]))}return{p:f,f:p}},wNAFCached(s,a,o){let c=l0.get(s)||1,d=fl.get(s);return d||(d=this.precomputeWindow(s,c),c!==1&&fl.set(s,o(d))),this.wNAF(c,d,a)},setWindowSize(s,a){n(a),l0.set(s,a),fl.delete(s)}}}function ww(e,t,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((f,p)=>{if(!t.isValid(f))throw new Error(`wrong scalar at index ${p}`)}),r.forEach((f,p)=>{if(!(f instanceof e))throw new Error(`wrong point at index ${p}`)});let i=(0,d0.bitLen)(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<<s)-1,o=new Array(a+1).fill(e.ZERO),c=Math.floor((t.BITS-1)/s)*s,d=e.ZERO;for(let f=c;f>=0;f-=s){o.fill(e.ZERO);for(let m=0;m<n.length;m++){let b=n[m],l=Number(b>>BigInt(f)&BigInt(a));o[l]=o[l].add(r[m])}let p=e.ZERO;for(let m=o.length-1,b=e.ZERO;m>0;m--)b=b.add(o[m]),p=p.add(b);if(d=d.add(p),f!==0)for(let m=0;m<s;m++)d=d.double()}return d}function xw(e){return(0,u0.validateField)(e.Fp),(0,d0.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,u0.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}});var hl=ee(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.DER=void 0;wt.weierstrassPoints=h0;wt.weierstrass=vw;wt.SWUFpSqrtRatio=_0;wt.mapToCurveSimpleSWU=Rw;var oo=pl(),$n=Mr(),ve=Xt(),bt=Xt();function f0(e){e.lowS!==void 0&&(0,bt.abool)("lowS",e.lowS),e.prehash!==void 0&&(0,bt.abool)("prehash",e.prehash)}function Tw(e){let t=(0,oo.validateBasic)(e);ve.validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=t;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Nw,hexToBytes:Ow}=ve;wt.DER={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(e,t)=>{let{Err:r}=wt.DER;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=ve.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?ve.numberToHexUnpadded(i.length/2|128):"";return`${ve.numberToHexUnpadded(e)}${s}${i}${t}`},decode(e,t){let{Err:r}=wt.DER,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],s=!!(i&128),a=0;if(!s)a=i;else{let c=i&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let d=t.subarray(n,n+c);if(d.length!==c)throw new r("tlv.decode: length bytes not complete");if(d[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of d)a=a<<8|f;if(n+=c,a<128)throw new r("tlv.decode(long): not minimal encoding")}let o=t.subarray(n,n+a);if(o.length!==a)throw new r("tlv.decode: wrong value length");return{v:o,l:t.subarray(n+a)}}},_int:{encode(e){let{Err:t}=wt.DER;if(e<mr)throw new t("integer: negative integers are not allowed");let r=ve.numberToHexUnpadded(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected assertion");return r},decode(e){let{Err:t}=wt.DER;if(e[0]&128)throw new t("Invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return Nw(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=wt.DER,i=typeof e=="string"?Ow(e):e;ve.abytes(i);let{v:s,l:a}=n.decode(48,i);if(a.length)throw new t("Invalid signature: left bytes after parsing");let{v:o,l:c}=n.decode(2,s),{v:d,l:f}=n.decode(2,c);if(f.length)throw new t("Invalid signature: left bytes after parsing");return{r:r.decode(o),s:r.decode(d)}},hexFromSig(e){let{_tlv:t,_int:r}=wt.DER,n=`${t.encode(2,r.encode(e.r))}${t.encode(2,r.encode(e.s))}`;return t.encode(48,n)}};var mr=BigInt(0),ke=BigInt(1),xn=BigInt(2),co=BigInt(3),p0=BigInt(4);function h0(e){let t=Tw(e),{Fp:r}=t,n=$n.Field(t.n,t.nBitLength),i=t.toBytes||((A,v,F)=>{let C=v.toAffine();return ve.concatBytes(Uint8Array.from([4]),r.toBytes(C.x),r.toBytes(C.y))}),s=t.fromBytes||(A=>{let v=A.subarray(1),F=r.fromBytes(v.subarray(0,r.BYTES)),C=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x:F,y:C}});function a(A){let{a:v,b:F}=t,C=r.sqr(A),O=r.mul(C,A);return r.add(r.add(O,r.mul(A,v)),F)}if(!r.eql(r.sqr(t.Gy),a(t.Gx)))throw new Error("bad generator point: equation left != right");function o(A){return ve.inRange(A,ke,t.n)}function c(A){let{allowedPrivateKeyLengths:v,nByteLength:F,wrapPrivateKey:C,n:O}=t;if(v&&typeof A!="bigint"){if(ve.isBytes(A)&&(A=ve.bytesToHex(A)),typeof A!="string"||!v.includes(A.length))throw new Error("Invalid key");A=A.padStart(F*2,"0")}let H;try{H=typeof A=="bigint"?A:ve.bytesToNumberBE((0,bt.ensureBytes)("private key",A,F))}catch{throw new Error(`private key must be ${F} bytes, hex or bigint, not ${typeof A}`)}return C&&(H=$n.mod(H,O)),ve.aInRange("private key",H,ke,O),H}function d(A){if(!(A instanceof m))throw new Error("ProjectivePoint expected")}let f=(0,bt.memoized)((A,v)=>{let{px:F,py:C,pz:O}=A;if(r.eql(O,r.ONE))return{x:F,y:C};let H=A.is0();v==null&&(v=H?r.ONE:r.inv(O));let x=r.mul(F,v),q=r.mul(C,v),K=r.mul(O,v);if(H)return{x:r.ZERO,y:r.ZERO};if(!r.eql(K,r.ONE))throw new Error("invZ was invalid");return{x,y:q}}),p=(0,bt.memoized)(A=>{if(A.is0()){if(t.allowInfinityPoint&&!r.is0(A.py))return;throw new Error("bad point: ZERO")}let{x:v,y:F}=A.toAffine();if(!r.isValid(v)||!r.isValid(F))throw new Error("bad point: x or y not FE");let C=r.sqr(F),O=a(v);if(!r.eql(C,O))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(v,F,C){if(this.px=v,this.py=F,this.pz=C,v==null||!r.isValid(v))throw new Error("x required");if(F==null||!r.isValid(F))throw new Error("y required");if(C==null||!r.isValid(C))throw new Error("z required");Object.freeze(this)}static fromAffine(v){let{x:F,y:C}=v||{};if(!v||!r.isValid(F)||!r.isValid(C))throw new Error("invalid affine point");if(v instanceof m)throw new Error("projective point not allowed");let O=H=>r.eql(H,r.ZERO);return O(F)&&O(C)?m.ZERO:new m(F,C,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){let F=r.invertBatch(v.map(C=>C.pz));return v.map((C,O)=>C.toAffine(F[O])).map(m.fromAffine)}static fromHex(v){let F=m.fromAffine(s((0,bt.ensureBytes)("pointHex",v)));return F.assertValidity(),F}static fromPrivateKey(v){return m.BASE.multiply(c(v))}static msm(v,F){return(0,oo.pippenger)(m,n,v,F)}_setWindowSize(v){l.setWindowSize(this,v)}assertValidity(){p(this)}hasEvenY(){let{y:v}=this.toAffine();if(r.isOdd)return!r.isOdd(v);throw new Error("Field doesn't support isOdd")}equals(v){d(v);let{px:F,py:C,pz:O}=this,{px:H,py:x,pz:q}=v,K=r.eql(r.mul(F,q),r.mul(H,O)),$=r.eql(r.mul(C,q),r.mul(x,O));return K&&$}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:v,b:F}=t,C=r.mul(F,co),{px:O,py:H,pz:x}=this,q=r.ZERO,K=r.ZERO,$=r.ZERO,M=r.mul(O,O),ae=r.mul(H,H),Q=r.mul(x,x),ne=r.mul(O,H);return ne=r.add(ne,ne),$=r.mul(O,x),$=r.add($,$),q=r.mul(v,$),K=r.mul(C,Q),K=r.add(q,K),q=r.sub(ae,K),K=r.add(ae,K),K=r.mul(q,K),q=r.mul(ne,q),$=r.mul(C,$),Q=r.mul(v,Q),ne=r.sub(M,Q),ne=r.mul(v,ne),ne=r.add(ne,$),$=r.add(M,M),M=r.add($,M),M=r.add(M,Q),M=r.mul(M,ne),K=r.add(K,M),Q=r.mul(H,x),Q=r.add(Q,Q),M=r.mul(Q,ne),q=r.sub(q,M),$=r.mul(Q,ae),$=r.add($,$),$=r.add($,$),new m(q,K,$)}add(v){d(v);let{px:F,py:C,pz:O}=this,{px:H,py:x,pz:q}=v,K=r.ZERO,$=r.ZERO,M=r.ZERO,ae=t.a,Q=r.mul(t.b,co),ne=r.mul(F,H),w=r.mul(C,x),g=r.mul(O,q),S=r.add(F,C),R=r.add(H,x);S=r.mul(S,R),R=r.add(ne,w),S=r.sub(S,R),R=r.add(F,O);let B=r.add(H,q);return R=r.mul(R,B),B=r.add(ne,g),R=r.sub(R,B),B=r.add(C,O),K=r.add(x,q),B=r.mul(B,K),K=r.add(w,g),B=r.sub(B,K),M=r.mul(ae,R),K=r.mul(Q,g),M=r.add(K,M),K=r.sub(w,M),M=r.add(w,M),$=r.mul(K,M),w=r.add(ne,ne),w=r.add(w,ne),g=r.mul(ae,g),R=r.mul(Q,R),w=r.add(w,g),g=r.sub(ne,g),g=r.mul(ae,g),R=r.add(R,g),ne=r.mul(w,R),$=r.add($,ne),ne=r.mul(B,R),K=r.mul(S,K),K=r.sub(K,ne),ne=r.mul(S,w),M=r.mul(B,M),M=r.add(M,ne),new m(K,$,M)}subtract(v){return this.add(v.negate())}is0(){return this.equals(m.ZERO)}wNAF(v){return l.wNAFCached(this,v,m.normalizeZ)}multiplyUnsafe(v){ve.aInRange("scalar",v,mr,t.n);let F=m.ZERO;if(v===mr)return F;if(v===ke)return this;let{endo:C}=t;if(!C)return l.unsafeLadder(this,v);let{k1neg:O,k1:H,k2neg:x,k2:q}=C.splitScalar(v),K=F,$=F,M=this;for(;H>mr||q>mr;)H&ke&&(K=K.add(M)),q&ke&&($=$.add(M)),M=M.double(),H>>=ke,q>>=ke;return O&&(K=K.negate()),x&&($=$.negate()),$=new m(r.mul($.px,C.beta),$.py,$.pz),K.add($)}multiply(v){let{endo:F,n:C}=t;ve.aInRange("scalar",v,ke,C);let O,H;if(F){let{k1neg:x,k1:q,k2neg:K,k2:$}=F.splitScalar(v),{p:M,f:ae}=this.wNAF(q),{p:Q,f:ne}=this.wNAF($);M=l.constTimeNegate(x,M),Q=l.constTimeNegate(K,Q),Q=new m(r.mul(Q.px,F.beta),Q.py,Q.pz),O=M.add(Q),H=ae.add(ne)}else{let{p:x,f:q}=this.wNAF(v);O=x,H=q}return m.normalizeZ([O,H])[0]}multiplyAndAddUnsafe(v,F,C){let O=m.BASE,H=(q,K)=>K===mr||K===ke||!q.equals(O)?q.multiplyUnsafe(K):q.multiply(K),x=H(this,F).add(H(v,C));return x.is0()?void 0:x}toAffine(v){return f(this,v)}isTorsionFree(){let{h:v,isTorsionFree:F}=t;if(v===ke)return!0;if(F)return F(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:v,clearCofactor:F}=t;return v===ke?this:F?F(m,this):this.multiplyUnsafe(t.h)}toRawBytes(v=!0){return(0,bt.abool)("isCompressed",v),this.assertValidity(),i(m,this,v)}toHex(v=!0){return(0,bt.abool)("isCompressed",v),ve.bytesToHex(this.toRawBytes(v))}}m.BASE=new m(t.Gx,t.Gy,r.ONE),m.ZERO=new m(r.ZERO,r.ONE,r.ZERO);let b=t.nBitLength,l=(0,oo.wNAF)(m,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:o}}function Ew(e){let t=(0,oo.validateBasic)(e);return ve.validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function vw(e){let t=Ew(e),{Fp:r,n}=t,i=r.BYTES+1,s=2*r.BYTES+1;function a(g){return $n.mod(g,n)}function o(g){return $n.invert(g,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:p}=h0({...t,toBytes(g,S,R){let B=S.toAffine(),j=r.toBytes(B.x),Y=ve.concatBytes;return(0,bt.abool)("isCompressed",R),R?Y(Uint8Array.from([S.hasEvenY()?2:3]),j):Y(Uint8Array.from([4]),j,r.toBytes(B.y))},fromBytes(g){let S=g.length,R=g[0],B=g.subarray(1);if(S===i&&(R===2||R===3)){let j=ve.bytesToNumberBE(B);if(!ve.inRange(j,ke,r.ORDER))throw new Error("Point is not on curve");let Y=f(j),oe;try{oe=r.sqrt(Y)}catch(V){let _=V instanceof Error?": "+V.message:"";throw new Error("Point is not on curve"+_)}let se=(oe&ke)===ke;return(R&1)===1!==se&&(oe=r.neg(oe)),{x:j,y:oe}}else if(S===s&&R===4){let j=r.fromBytes(B.subarray(0,r.BYTES)),Y=r.fromBytes(B.subarray(r.BYTES,2*r.BYTES));return{x:j,y:Y}}else throw new Error(`Point of length ${S} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=g=>ve.bytesToHex(ve.numberToBytesBE(g,t.nByteLength));function b(g){let S=n>>ke;return g>S}function l(g){return b(g)?a(-g):g}let A=(g,S,R)=>ve.bytesToNumberBE(g.slice(S,R));class v{constructor(S,R,B){this.r=S,this.s=R,this.recovery=B,this.assertValidity()}static fromCompact(S){let R=t.nByteLength;return S=(0,bt.ensureBytes)("compactSignature",S,R*2),new v(A(S,0,R),A(S,R,2*R))}static fromDER(S){let{r:R,s:B}=wt.DER.toSig((0,bt.ensureBytes)("DER",S));return new v(R,B)}assertValidity(){ve.aInRange("r",this.r,ke,n),ve.aInRange("s",this.s,ke,n)}addRecoveryBit(S){return new v(this.r,this.s,S)}recoverPublicKey(S){let{r:R,s:B,recovery:j}=this,Y=q((0,bt.ensureBytes)("msgHash",S));if(j==null||![0,1,2,3].includes(j))throw new Error("recovery id invalid");let oe=j===2||j===3?R+t.n:R;if(oe>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let se=(j&1)===0?"02":"03",W=c.fromHex(se+m(oe)),V=o(oe),_=a(-Y*V),Z=a(B*V),re=c.BASE.multiplyAndAddUnsafe(W,_,Z);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new v(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return ve.hexToBytes(this.toDERHex())}toDERHex(){return wt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ve.hexToBytes(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let F={isValidPrivateKey(g){try{return d(g),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let g=$n.getMinHashLength(t.n);return $n.mapHashToField(t.randomBytes(g),t.n)},precompute(g=8,S=c.BASE){return S._setWindowSize(g),S.multiply(BigInt(3)),S}};function C(g,S=!0){return c.fromPrivateKey(g).toRawBytes(S)}function O(g){let S=ve.isBytes(g),R=typeof g=="string",B=(S||R)&&g.length;return S?B===i||B===s:R?B===2*i||B===2*s:g instanceof c}function H(g,S,R=!0){if(O(g))throw new Error("first arg must be private key");if(!O(S))throw new Error("second arg must be public key");return c.fromHex(S).multiply(d(g)).toRawBytes(R)}let x=t.bits2int||function(g){let S=ve.bytesToNumberBE(g),R=g.length*8-t.nBitLength;return R>0?S>>BigInt(R):S},q=t.bits2int_modN||function(g){return a(x(g))},K=ve.bitMask(t.nBitLength);function $(g){return ve.aInRange(`num < 2^${t.nBitLength}`,g,mr,K),ve.numberToBytesBE(g,t.nByteLength)}function M(g,S,R=ae){if(["recovered","canonical"].some(X=>X in R))throw new Error("sign() legacy options not supported");let{hash:B,randomBytes:j}=t,{lowS:Y,prehash:oe,extraEntropy:se}=R;Y==null&&(Y=!0),g=(0,bt.ensureBytes)("msgHash",g),f0(R),oe&&(g=(0,bt.ensureBytes)("prehashed msgHash",B(g)));let W=q(g),V=d(S),_=[$(V),$(W)];if(se!=null&&se!==!1){let X=se===!0?j(r.BYTES):se;_.push((0,bt.ensureBytes)("extraEntropy",X))}let Z=ve.concatBytes(..._),re=W;function le(X){let u=x(X);if(!p(u))return;let h=o(u),y=c.BASE.multiply(u).toAffine(),P=a(y.x);if(P===mr)return;let E=a(h*a(re+P*V));if(E===mr)return;let I=(y.x===P?0:2)|Number(y.y&ke),D=E;return Y&&b(E)&&(D=l(E),I^=1),new v(P,D,I)}return{seed:Z,k2sig:le}}let ae={lowS:t.lowS,prehash:!1},Q={lowS:t.lowS,prehash:!1};function ne(g,S,R=ae){let{seed:B,k2sig:j}=M(g,S,R),Y=t;return ve.createHmacDrbg(Y.hash.outputLen,Y.nByteLength,Y.hmac)(B,j)}c.BASE._setWindowSize(8);function w(g,S,R,B=Q){let j=g;if(S=(0,bt.ensureBytes)("msgHash",S),R=(0,bt.ensureBytes)("publicKey",R),"strict"in B)throw new Error("options.strict was renamed to lowS");f0(B);let{lowS:Y,prehash:oe}=B,se,W;try{if(typeof j=="string"||ve.isBytes(j))try{se=v.fromDER(j)}catch(y){if(!(y instanceof wt.DER.Err))throw y;se=v.fromCompact(j)}else if(typeof j=="object"&&typeof j.r=="bigint"&&typeof j.s=="bigint"){let{r:y,s:P}=j;se=new v(y,P)}else throw new Error("PARSE");W=c.fromHex(R)}catch(y){if(y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Y&&se.hasHighS())return!1;oe&&(S=t.hash(S));let{r:V,s:_}=se,Z=q(S),re=o(_),le=a(Z*re),X=a(V*re),u=c.BASE.multiplyAndAddUnsafe(W,le,X)?.toAffine();return u?a(u.x)===V:!1}return{CURVE:t,getPublicKey:C,getSharedSecret:H,sign:ne,verify:w,ProjectivePoint:c,Signature:v,utils:F}}function _0(e,t){let r=e.ORDER,n=mr;for(let l=r-ke;l%xn===mr;l/=xn)n+=ke;let i=n,s=xn<<i-ke-ke,a=s*xn,o=(r-ke)/a,c=(o-ke)/xn,d=a-ke,f=s,p=e.pow(t,o),m=e.pow(t,(o+ke)/xn),b=(l,A)=>{let v=p,F=e.pow(A,d),C=e.sqr(F);C=e.mul(C,A);let O=e.mul(l,C);O=e.pow(O,c),O=e.mul(O,F),F=e.mul(O,A),C=e.mul(O,l);let H=e.mul(C,F);O=e.pow(H,f);let x=e.eql(O,e.ONE);F=e.mul(C,m),O=e.mul(H,v),C=e.cmov(F,C,x),H=e.cmov(O,H,x);for(let q=i;q>ke;q--){let K=q-xn;K=xn<<K-ke;let $=e.pow(H,K),M=e.eql($,e.ONE);F=e.mul(C,v),v=e.mul(v,v),$=e.mul(H,v),C=e.cmov(F,C,M),H=e.cmov($,H,M)}return{isValid:x,value:C}};if(e.ORDER%p0===co){let l=(e.ORDER-co)/p0,A=e.sqrt(e.neg(t));b=(v,F)=>{let C=e.sqr(F),O=e.mul(v,F);C=e.mul(C,O);let H=e.pow(C,l);H=e.mul(H,O);let x=e.mul(H,A),q=e.mul(e.sqr(H),F),K=e.eql(q,v),$=e.cmov(x,H,K);return{isValid:K,value:$}}}return b}function Rw(e,t){if($n.validateField(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=_0(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,a,o,c,d,f,p;i=e.sqr(n),i=e.mul(i,t.Z),s=e.sqr(i),s=e.add(s,i),a=e.add(s,e.ONE),a=e.mul(a,t.B),o=e.cmov(t.Z,e.neg(s),!e.eql(s,e.ZERO)),o=e.mul(o,t.A),s=e.sqr(a),d=e.sqr(o),c=e.mul(d,t.A),s=e.add(s,c),s=e.mul(s,a),d=e.mul(d,o),c=e.mul(d,t.B),s=e.add(s,c),f=e.mul(i,a);let{isValid:m,value:b}=r(s,d);p=e.mul(i,n),p=e.mul(p,b),f=e.cmov(f,a,m),p=e.cmov(p,b,m);let l=e.isOdd(n)===e.isOdd(p);return p=e.cmov(e.neg(p),p,l),f=e.div(f,o),{x:f,y:p}}}});var w0=ee(yl=>{"use strict";Object.defineProperty(yl,"__esModule",{value:!0});yl.bls=Bw;var y0=Mr(),_l=Xt(),m0=ao(),g0=hl(),Aw=BigInt(0),uo=BigInt(1),b0=BigInt(2),vi=BigInt(3);function Sw(e){let t=[];for(;e>uo;e>>=uo)(e&uo)===Aw?t.unshift(0):(e&vi)===vi?(t.unshift(-1),e+=uo):t.unshift(1);return t}function Bw(e){let{Fp:t,Fr:r,Fp2:n,Fp6:i,Fp12:s}=e.fields,a=e.params.xNegative,o=e.params.twistType,c=(0,g0.weierstrassPoints)({n:r.ORDER,...e.G1}),d=Object.assign(c,(0,m0.createHasher)(c.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),f=(0,g0.weierstrassPoints)({n:r.ORDER,...e.G2}),p=Object.assign(f,(0,m0.createHasher)(f.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults})),m;if(o==="multiplicative")m=(W,V,_,Z,re,le)=>s.mul014(Z,W,n.mul(V,re),n.mul(_,le));else if(o==="divisive")m=(W,V,_,Z,re,le)=>s.mul034(Z,n.mul(_,le),n.mul(V,re),W);else throw new Error("bls: unknown twist type");let b=n.div(n.ONE,n.mul(n.ONE,b0));function l(W,V,_,Z){let re=n.sqr(_),le=n.sqr(Z),X=n.mulByB(n.mul(le,vi)),u=n.mul(X,vi),h=n.sub(n.sub(n.sqr(n.add(_,Z)),le),re),y=n.sub(X,re),P=n.mul(n.sqr(V),vi),E=n.neg(h);return W.push([y,P,E]),V=n.mul(n.mul(n.mul(n.sub(re,u),V),_),b),_=n.sub(n.sqr(n.mul(n.add(re,u),b)),n.mul(n.sqr(X),vi)),Z=n.mul(re,h),{Rx:V,Ry:_,Rz:Z}}function A(W,V,_,Z,re,le){let X=n.sub(_,n.mul(le,Z)),u=n.sub(V,n.mul(re,Z)),h=n.sub(n.mul(X,re),n.mul(u,le)),y=n.neg(X),P=u;W.push([h,y,P]);let E=n.sqr(u),I=n.mul(E,u),D=n.mul(E,V),T=n.add(n.sub(I,n.mul(D,b0)),n.mul(n.sqr(X),Z));return V=n.mul(u,T),_=n.sub(n.mul(n.sub(D,T),X),n.mul(I,_)),Z=n.mul(Z,I),{Rx:V,Ry:_,Rz:Z}}let v=Sw(e.params.ateLoopSize),F=(0,_l.memoized)(W=>{let V=W,{x:_,y:Z}=V.toAffine(),re=_,le=Z,X=n.neg(Z),u=re,h=le,y=n.ONE,P=[];for(let E of v){let I=[];({Rx:u,Ry:h,Rz:y}=l(I,u,h,y)),E&&({Rx:u,Ry:h,Rz:y}=A(I,u,h,y,re,E===-1?X:le)),P.push(I)}if(e.postPrecompute){let E=P[P.length-1];e.postPrecompute(u,h,y,re,le,A.bind(null,E))}return P});function C(W,V=!1){let _=s.ONE;if(W.length){let Z=W[0][0].length;for(let re=0;re<Z;re++){_=s.sqr(_);for(let[le,X,u]of W)for(let[h,y,P]of le[re])_=m(h,y,P,_,X,u)}}return a&&(_=s.conjugate(_)),V?s.finalExponentiate(_):_}function O(W,V=!0){let _=[];d.ProjectivePoint.normalizeZ(W.map(({g1:Z})=>Z)),p.ProjectivePoint.normalizeZ(W.map(({g2:Z})=>Z));for(let{g1:Z,g2:re}of W){if(Z.equals(d.ProjectivePoint.ZERO)||re.equals(p.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");Z.assertValidity(),re.assertValidity();let le=Z.toAffine();_.push([F(re),le.x,le.y])}return C(_,V)}function H(W,V,_=!0){return O([{g1:W,g2:V}],_)}let x={randomPrivateKey:()=>{let W=(0,y0.getMinHashLength)(r.ORDER);return(0,y0.mapHashToField)(e.randomBytes(W),r.ORDER)},calcPairingPrecomputes:F},{ShortSignature:q}=e.G1,{Signature:K}=e.G2;function $(W){return W instanceof d.ProjectivePoint?W:d.ProjectivePoint.fromHex(W)}function M(W,V){return W instanceof d.ProjectivePoint?W:d.hashToCurve((0,_l.ensureBytes)("point",W),V)}function ae(W){return W instanceof p.ProjectivePoint?W:K.fromHex(W)}function Q(W,V){return W instanceof p.ProjectivePoint?W:p.hashToCurve((0,_l.ensureBytes)("point",W),V)}function ne(W){return d.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function w(W){return p.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function g(W,V,_){let Z=Q(W,_);Z.assertValidity();let re=Z.multiply(d.normPrivateKeyToScalar(V));return W instanceof p.ProjectivePoint?re:K.toRawBytes(re)}function S(W,V,_){let Z=M(W,_);Z.assertValidity();let re=Z.multiply(d.normPrivateKeyToScalar(V));return W instanceof d.ProjectivePoint?re:q.toRawBytes(re)}function R(W,V,_,Z){let re=$(_),le=Q(V,Z),X=d.ProjectivePoint.BASE,u=ae(W),h=O([{g1:re.negate(),g2:le},{g1:X,g2:u}]);return s.eql(h,s.ONE)}function B(W,V,_,Z){let re=ae(_),le=M(V,Z),X=p.ProjectivePoint.BASE,u=$(W),h=O([{g1:le,g2:re},{g1:u,g2:X.negate()}]);return s.eql(h,s.ONE)}function j(W){if(!W.length)throw new Error("Expected non-empty array");let _=W.map($).reduce((Z,re)=>Z.add(re),d.ProjectivePoint.ZERO);return W[0]instanceof d.ProjectivePoint?(_.assertValidity(),_):_.toRawBytes(!0)}function Y(W){if(!W.length)throw new Error("Expected non-empty array");let _=W.map(ae).reduce((Z,re)=>Z.add(re),p.ProjectivePoint.ZERO);return W[0]instanceof p.ProjectivePoint?(_.assertValidity(),_):K.toRawBytes(_)}function oe(W){if(!W.length)throw new Error("Expected non-empty array");let _=W.map($).reduce((Z,re)=>Z.add(re),d.ProjectivePoint.ZERO);return W[0]instanceof d.ProjectivePoint?(_.assertValidity(),_):q.toRawBytes(_)}function se(W,V,_,Z){if(!V.length)throw new Error("Expected non-empty messages array");if(_.length!==V.length)throw new Error("Pubkey count should equal msg count");let re=ae(W),le=V.map(y=>Q(y,Z)),X=_.map($),u=new Map;for(let y=0;y<X.length;y++){let P=X[y],E=le[y],I=u.get(E);I===void 0&&(I=[],u.set(E,I)),I.push(P)}let h=[];try{for(let[y,P]of u){let E=P.reduce((I,D)=>I.add(D));h.push({g1:E,g2:y})}return h.push({g1:d.ProjectivePoint.BASE.negate(),g2:re}),s.eql(O(h),s.ONE)}catch{return!1}}return d.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ne,getPublicKeyForShortSignatures:w,sign:g,signShortSignature:S,verify:R,verifyBatch:se,verifyShortSignature:B,aggregatePublicKeys:j,aggregateSignatures:Y,aggregateShortSignatures:oe,millerLoopBatch:C,pairing:H,pairingBatch:O,G1:d,G2:p,Signature:K,ShortSignature:q,fields:{Fr:r,Fp:t,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:e.params.ateLoopSize,r:e.params.r,G1b:e.G1.b,G2b:e.G2.b},utils:x}}});var T0=ee(lo=>{"use strict";Object.defineProperty(lo,"__esModule",{value:!0});lo.psiFrobenius=Pw;lo.tower12=Fw;var Tn=Mr(),gr=Xt(),Iw=BigInt(0),Ri=BigInt(1),rn=BigInt(2),x0=BigInt(3);function ml(e,t,r,n,i=1,s){let a=BigInt(s===void 0?n:s),o=r**BigInt(n),c=[];for(let d=0;d<i;d++){let f=BigInt(d+1),p=[];for(let m=0,b=Ri;m<n;m++){let l=(f*b-f)/a%o;p.push(e.pow(t,l)),b*=r}c.push(p)}return c}function Pw(e,t,r){let n=t.pow(r,(e.ORDER-Ri)/x0),i=t.pow(r,(e.ORDER-Ri)/rn);function s(m,b){let l=t.mul(t.frobeniusMap(m,1),n),A=t.mul(t.frobeniusMap(b,1),i);return[l,A]}let a=t.pow(r,(e.ORDER**rn-Ri)/x0),o=t.pow(r,(e.ORDER**rn-Ri)/rn);if(!t.eql(o,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(m,b){return[t.mul(m,a),t.neg(b)]}let d=m=>(b,l)=>{let A=l.toAffine(),v=m(A.x,A.y);return b.fromAffine({x:v[0],y:v[1]})},f=d(s),p=d(c);return{psi:s,psi2:c,G2psi:f,G2psi2:p,PSI_X:n,PSI_Y:i,PSI2_X:a,PSI2_Y:o}}function Fw(e){let{ORDER:t}=e,r=Tn.Field(t),n=r.create(e.NONRESIDUE||BigInt(-1)),i=Tn.FpLegendre(t),s=r.div(r.ONE,rn),a=ml(r,n,r.ORDER,2)[0],o=({c0:w,c1:g},{c0:S,c1:R})=>({c0:r.add(w,S),c1:r.add(g,R)}),c=({c0:w,c1:g},{c0:S,c1:R})=>({c0:r.sub(w,S),c1:r.sub(g,R)}),d=({c0:w,c1:g},S)=>{if(typeof S=="bigint")return{c0:r.mul(w,S),c1:r.mul(g,S)};let{c0:R,c1:B}=S,j=r.mul(w,R),Y=r.mul(g,B),oe=r.sub(j,Y),se=r.sub(r.mul(r.add(w,g),r.add(R,B)),r.add(j,Y));return{c0:oe,c1:se}},f=({c0:w,c1:g})=>{let S=r.add(w,g),R=r.sub(w,g),B=r.add(w,w);return{c0:r.mul(S,R),c1:r.mul(B,g)}},p=w=>{if(w.length!==2)throw new Error("Invalid tuple");let g=w.map(S=>r.create(S));return{c0:g[0],c1:g[1]}},m=t*t,b=p(e.FP2_NONRESIDUE),l={ORDER:m,NONRESIDUE:b,BITS:(0,gr.bitLen)(m),BYTES:Math.ceil((0,gr.bitLen)(m)/8),MASK:(0,gr.bitMask)((0,gr.bitLen)(m)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:w=>w,isValid:({c0:w,c1:g})=>typeof w=="bigint"&&typeof g=="bigint",is0:({c0:w,c1:g})=>r.is0(w)&&r.is0(g),eql:({c0:w,c1:g},{c0:S,c1:R})=>r.eql(w,S)&&r.eql(g,R),neg:({c0:w,c1:g})=>({c0:r.neg(w),c1:r.neg(g)}),pow:(w,g)=>Tn.FpPow(l,w,g),invertBatch:w=>Tn.FpInvertBatch(l,w),add:o,sub:c,mul:d,sqr:f,addN:o,subN:c,mulN:d,sqrN:f,div:(w,g)=>l.mul(w,typeof g=="bigint"?r.inv(r.create(g)):l.inv(g)),inv:({c0:w,c1:g})=>{let S=r.inv(r.create(w*w+g*g));return{c0:r.mul(S,r.create(w)),c1:r.mul(S,r.create(-g))}},sqrt:w=>{if(e.Fp2sqrt)return e.Fp2sqrt(w);let{c0:g,c1:S}=w;if(r.is0(S))return r.eql(i(r,g),r.ONE)?l.create({c0:r.sqrt(g),c1:r.ZERO}):l.create({c0:r.ZERO,c1:r.sqrt(r.div(g,n))});let R=r.sqrt(r.sub(r.sqr(g),r.mul(r.sqr(S),n))),B=r.mul(r.add(R,g),s),j=i(r,B);!r.is0(j)&&!r.eql(j,r.ONE)&&(B=r.sub(B,R));let Y=r.sqrt(B),oe=l.create({c0:Y,c1:r.div(r.mul(S,s),Y)});if(!l.eql(l.sqr(oe),w))throw new Error("Cannot find square root");let se=oe,W=l.neg(se),{re:V,im:_}=l.reim(se),{re:Z,im:re}=l.reim(W);return _>re||_===re&&V>Z?se:W},isOdd:w=>{let{re:g,im:S}=l.reim(w),R=g%rn,B=g===Iw,j=S%rn;return BigInt(R||B&&j)==Ri},fromBytes(w){if(w.length!==l.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:r.fromBytes(w.subarray(0,r.BYTES)),c1:r.fromBytes(w.subarray(r.BYTES))}},toBytes:({c0:w,c1:g})=>(0,gr.concatBytes)(r.toBytes(w),r.toBytes(g)),cmov:({c0:w,c1:g},{c0:S,c1:R},B)=>({c0:r.cmov(w,S,B),c1:r.cmov(g,R,B)}),reim:({c0:w,c1:g})=>({re:w,im:g}),mulByNonresidue:({c0:w,c1:g})=>l.mul({c0:w,c1:g},b),mulByB:e.Fp2mulByB,fromBigTuple:p,frobeniusMap:({c0:w,c1:g},S)=>({c0:w,c1:r.mul(g,a[S%2])})},A=({c0:w,c1:g,c2:S},{c0:R,c1:B,c2:j})=>({c0:l.add(w,R),c1:l.add(g,B),c2:l.add(S,j)}),v=({c0:w,c1:g,c2:S},{c0:R,c1:B,c2:j})=>({c0:l.sub(w,R),c1:l.sub(g,B),c2:l.sub(S,j)}),F=({c0:w,c1:g,c2:S},R)=>{if(typeof R=="bigint")return{c0:l.mul(w,R),c1:l.mul(g,R),c2:l.mul(S,R)};let{c0:B,c1:j,c2:Y}=R,oe=l.mul(w,B),se=l.mul(g,j),W=l.mul(S,Y);return{c0:l.add(oe,l.mulByNonresidue(l.sub(l.mul(l.add(g,S),l.add(j,Y)),l.add(se,W)))),c1:l.add(l.sub(l.mul(l.add(w,g),l.add(B,j)),l.add(oe,se)),l.mulByNonresidue(W)),c2:l.sub(l.add(se,l.mul(l.add(w,S),l.add(B,Y))),l.add(oe,W))}},C=({c0:w,c1:g,c2:S})=>{let R=l.sqr(w),B=l.mul(l.mul(w,g),rn),j=l.mul(l.mul(g,S),rn),Y=l.sqr(S);return{c0:l.add(l.mulByNonresidue(j),R),c1:l.add(l.mulByNonresidue(Y),B),c2:l.sub(l.sub(l.add(l.add(B,l.sqr(l.add(l.sub(w,g),S))),j),R),Y)}},[O,H]=ml(l,b,r.ORDER,6,2,3),x={ORDER:l.ORDER,BITS:3*l.BITS,BYTES:3*l.BYTES,MASK:(0,gr.bitMask)(3*l.BITS),ZERO:{c0:l.ZERO,c1:l.ZERO,c2:l.ZERO},ONE:{c0:l.ONE,c1:l.ZERO,c2:l.ZERO},create:w=>w,isValid:({c0:w,c1:g,c2:S})=>l.isValid(w)&&l.isValid(g)&&l.isValid(S),is0:({c0:w,c1:g,c2:S})=>l.is0(w)&&l.is0(g)&&l.is0(S),neg:({c0:w,c1:g,c2:S})=>({c0:l.neg(w),c1:l.neg(g),c2:l.neg(S)}),eql:({c0:w,c1:g,c2:S},{c0:R,c1:B,c2:j})=>l.eql(w,R)&&l.eql(g,B)&&l.eql(S,j),sqrt:gr.notImplemented,div:(w,g)=>x.mul(w,typeof g=="bigint"?r.inv(r.create(g)):x.inv(g)),pow:(w,g)=>Tn.FpPow(x,w,g),invertBatch:w=>Tn.FpInvertBatch(x,w),add:A,sub:v,mul:F,sqr:C,addN:A,subN:v,mulN:F,sqrN:C,inv:({c0:w,c1:g,c2:S})=>{let R=l.sub(l.sqr(w),l.mulByNonresidue(l.mul(S,g))),B=l.sub(l.mulByNonresidue(l.sqr(S)),l.mul(w,g)),j=l.sub(l.sqr(g),l.mul(w,S)),Y=l.inv(l.add(l.mulByNonresidue(l.add(l.mul(S,B),l.mul(g,j))),l.mul(w,R)));return{c0:l.mul(Y,R),c1:l.mul(Y,B),c2:l.mul(Y,j)}},fromBytes:w=>{if(w.length!==x.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:l.fromBytes(w.subarray(0,l.BYTES)),c1:l.fromBytes(w.subarray(l.BYTES,2*l.BYTES)),c2:l.fromBytes(w.subarray(2*l.BYTES))}},toBytes:({c0:w,c1:g,c2:S})=>(0,gr.concatBytes)(l.toBytes(w),l.toBytes(g),l.toBytes(S)),cmov:({c0:w,c1:g,c2:S},{c0:R,c1:B,c2:j},Y)=>({c0:l.cmov(w,R,Y),c1:l.cmov(g,B,Y),c2:l.cmov(S,j,Y)}),fromBigSix:w=>{if(!Array.isArray(w)||w.length!==6)throw new Error("Invalid Fp6 usage");return{c0:l.fromBigTuple(w.slice(0,2)),c1:l.fromBigTuple(w.slice(2,4)),c2:l.fromBigTuple(w.slice(4,6))}},frobeniusMap:({c0:w,c1:g,c2:S},R)=>({c0:l.frobeniusMap(w,R),c1:l.mul(l.frobeniusMap(g,R),O[R%6]),c2:l.mul(l.frobeniusMap(S,R),H[R%6])}),mulByFp2:({c0:w,c1:g,c2:S},R)=>({c0:l.mul(w,R),c1:l.mul(g,R),c2:l.mul(S,R)}),mulByNonresidue:({c0:w,c1:g,c2:S})=>({c0:l.mulByNonresidue(S),c1:w,c2:g}),mul1:({c0:w,c1:g,c2:S},R)=>({c0:l.mulByNonresidue(l.mul(S,R)),c1:l.mul(w,R),c2:l.mul(g,R)}),mul01({c0:w,c1:g,c2:S},R,B){let j=l.mul(w,R),Y=l.mul(g,B);return{c0:l.add(l.mulByNonresidue(l.sub(l.mul(l.add(g,S),B),Y)),j),c1:l.sub(l.sub(l.mul(l.add(R,B),l.add(w,g)),j),Y),c2:l.add(l.sub(l.mul(l.add(w,S),R),j),Y)}}},q=ml(l,b,r.ORDER,12,1,6)[0],K=({c0:w,c1:g},{c0:S,c1:R})=>({c0:x.add(w,S),c1:x.add(g,R)}),$=({c0:w,c1:g},{c0:S,c1:R})=>({c0:x.sub(w,S),c1:x.sub(g,R)}),M=({c0:w,c1:g},S)=>{if(typeof S=="bigint")return{c0:x.mul(w,S),c1:x.mul(g,S)};let{c0:R,c1:B}=S,j=x.mul(w,R),Y=x.mul(g,B);return{c0:x.add(j,x.mulByNonresidue(Y)),c1:x.sub(x.mul(x.add(w,g),x.add(R,B)),x.add(j,Y))}},ae=({c0:w,c1:g})=>{let S=x.mul(w,g);return{c0:x.sub(x.sub(x.mul(x.add(x.mulByNonresidue(g),w),x.add(w,g)),S),x.mulByNonresidue(S)),c1:x.add(S,S)}};function Q(w,g){let S=l.sqr(w),R=l.sqr(g);return{first:l.add(l.mulByNonresidue(R),S),second:l.sub(l.sub(l.sqr(l.add(w,g)),S),R)}}let ne={ORDER:l.ORDER,BITS:2*l.BITS,BYTES:2*l.BYTES,MASK:(0,gr.bitMask)(2*l.BITS),ZERO:{c0:x.ZERO,c1:x.ZERO},ONE:{c0:x.ONE,c1:x.ZERO},create:w=>w,isValid:({c0:w,c1:g})=>x.isValid(w)&&x.isValid(g),is0:({c0:w,c1:g})=>x.is0(w)&&x.is0(g),neg:({c0:w,c1:g})=>({c0:x.neg(w),c1:x.neg(g)}),eql:({c0:w,c1:g},{c0:S,c1:R})=>x.eql(w,S)&&x.eql(g,R),sqrt:gr.notImplemented,inv:({c0:w,c1:g})=>{let S=x.inv(x.sub(x.sqr(w),x.mulByNonresidue(x.sqr(g))));return{c0:x.mul(w,S),c1:x.neg(x.mul(g,S))}},div:(w,g)=>ne.mul(w,typeof g=="bigint"?r.inv(r.create(g)):ne.inv(g)),pow:(w,g)=>Tn.FpPow(ne,w,g),invertBatch:w=>Tn.FpInvertBatch(ne,w),add:K,sub:$,mul:M,sqr:ae,addN:K,subN:$,mulN:M,sqrN:ae,fromBytes:w=>{if(w.length!==ne.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:x.fromBytes(w.subarray(0,x.BYTES)),c1:x.fromBytes(w.subarray(x.BYTES))}},toBytes:({c0:w,c1:g})=>(0,gr.concatBytes)(x.toBytes(w),x.toBytes(g)),cmov:({c0:w,c1:g},{c0:S,c1:R},B)=>({c0:x.cmov(w,S,B),c1:x.cmov(g,R,B)}),fromBigTwelve:w=>({c0:x.fromBigSix(w.slice(0,6)),c1:x.fromBigSix(w.slice(6,12))}),frobeniusMap(w,g){let{c0:S,c1:R,c2:B}=x.frobeniusMap(w.c1,g),j=q[g%12];return{c0:x.frobeniusMap(w.c0,g),c1:x.create({c0:l.mul(S,j),c1:l.mul(R,j),c2:l.mul(B,j)})}},mulByFp2:({c0:w,c1:g},S)=>({c0:x.mulByFp2(w,S),c1:x.mulByFp2(g,S)}),conjugate:({c0:w,c1:g})=>({c0:w,c1:x.neg(g)}),mul014:({c0:w,c1:g},S,R,B)=>{let j=x.mul01(w,S,R),Y=x.mul1(g,B);return{c0:x.add(x.mulByNonresidue(Y),j),c1:x.sub(x.sub(x.mul01(x.add(g,w),S,l.add(R,B)),j),Y)}},mul034:({c0:w,c1:g},S,R,B)=>{let j=x.create({c0:l.mul(w.c0,S),c1:l.mul(w.c1,S),c2:l.mul(w.c2,S)}),Y=x.mul01(g,R,B),oe=x.mul01(x.add(w,g),l.add(S,R),B);return{c0:x.add(x.mulByNonresidue(Y),j),c1:x.sub(oe,x.add(j,Y))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:r,Fp2:l,Fp6:x,Fp4Square:Q,Fp12:ne}}});var I0=ee(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.bls12_381=void 0;var R0=ha(),Vw=Dn(),Uw=w0(),Cw=Mr(),Re=Xt(),A0=ao(),S0=hl(),B0=T0(),Mt=BigInt(0),ho=BigInt(1),_t=BigInt(2),fo=BigInt(3),ws=BigInt(4),Nn=BigInt("0xd201000000010000"),qw=(0,Re.bitLen)(Nn),{Fp:pe,Fp2:he,Fp6:wl,Fp4Square:gl,Fp12:Ne}=(0,B0.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[ho,ho],Fp2mulByB:({c0:e,c1:t})=>{let r=pe.mul(e,ws),n=pe.mul(t,ws);return{c0:pe.sub(r,n),c1:pe.add(r,n)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{let{c0:r,c1:n,c2:i}=e,{c0:s,c1:a,c2:o}=t,{first:c,second:d}=gl(r,a),{first:f,second:p}=gl(s,i),{first:m,second:b}=gl(n,o),l=he.mulByNonresidue(b);return{c0:wl.create({c0:he.add(he.mul(he.sub(c,r),_t),c),c1:he.add(he.mul(he.sub(f,n),_t),f),c2:he.add(he.mul(he.sub(m,i),_t),m)}),c1:wl.create({c0:he.add(he.mul(he.add(l,s),_t),l),c1:he.add(he.mul(he.add(d,a),_t),d),c2:he.add(he.mul(he.add(p,o),_t),p)})}},Fp12cyclotomicExp(e,t){let r=Ne.ONE;for(let n=qw-1;n>=0;n--)r=Ne._cyclotomicSquare(r),(0,Re.bitGet)(t,n)&&(r=Ne.mul(r,e));return r},Fp12finalExponentiate:e=>{let t=Nn,r=Ne.div(Ne.frobeniusMap(e,6),e),n=Ne.mul(Ne.frobeniusMap(r,2),r),i=Ne.conjugate(Ne._cyclotomicExp(n,t)),s=Ne.mul(Ne.conjugate(Ne._cyclotomicSquare(n)),i),a=Ne.conjugate(Ne._cyclotomicExp(s,t)),o=Ne.conjugate(Ne._cyclotomicExp(a,t)),c=Ne.mul(Ne.conjugate(Ne._cyclotomicExp(o,t)),Ne._cyclotomicSquare(i)),d=Ne.conjugate(Ne._cyclotomicExp(c,t)),f=Ne.frobeniusMap(Ne.mul(i,o),2),p=Ne.frobeniusMap(Ne.mul(a,n),3),m=Ne.frobeniusMap(Ne.mul(c,Ne.conjugate(n)),1),b=Ne.mul(Ne.mul(d,Ne.conjugate(s)),n);return Ne.mul(Ne.mul(Ne.mul(f,p),m),b)}}),N0=Cw.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Mw=(0,A0.isogenyMap)(he,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(e=>e.map(t=>he.fromBigTuple(t.map(BigInt))))),kw=(0,A0.isogenyMap)(pe,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),Dw=(0,S0.mapToCurveSimpleSWU)(he,{A:he.create({c0:pe.create(Mt),c1:pe.create(BigInt(240))}),B:he.create({c0:pe.create(BigInt(1012)),c1:pe.create(BigInt(1012))}),Z:he.create({c0:pe.create(BigInt(-2)),c1:pe.create(BigInt(-1))})}),jw=(0,S0.mapToCurveSimpleSWU)(pe,{A:pe.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:pe.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:pe.create(BigInt(11))}),{G2psi:O0,G2psi2:Lw}=(0,B0.psiFrobenius)(pe,he,he.div(he.ONE,he.NONRESIDUE)),bl=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:pe.ORDER,m:2,k:128,expand:"xmd",hash:R0.sha256}),_o=xs(pe.toBytes(Mt),{infinity:!0,compressed:!0});function po(e){e=e.slice();let t=e[0]&224,r=!!(t>>7&1),n=!!(t>>6&1),i=!!(t>>5&1);return e[0]&=31,{compressed:r,infinity:n,sort:i,value:e}}function xs(e,t){if(e[0]&224)throw new Error("setMask: non-empty mask");return t.compressed&&(e[0]|=128),t.infinity&&(e[0]|=64),t.sort&&(e[0]|=32),e}function E0(e){e.assertValidity();let t=e.equals(kt.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=e.toAffine();if(t)return _o.slice();let i=pe.ORDER,s=!!(n*_t/i);return xs((0,Re.numberToBytesBE)(r,pe.BYTES),{compressed:!0,sort:s})}function v0(e){e.assertValidity();let t=pe.BYTES;if(e.equals(kt.bls12_381.G2.ProjectivePoint.ZERO))return(0,Re.concatBytes)(_o,(0,Re.numberToBytesBE)(Mt,t));let{x:r,y:n}=e.toAffine(),{re:i,im:s}=he.reim(r),{re:a,im:o}=he.reim(n),d=!!((o>Mt?o*_t:a*_t)/pe.ORDER&ho),f=i;return(0,Re.concatBytes)(xs((0,Re.numberToBytesBE)(s,t),{sort:d,compressed:!0}),(0,Re.numberToBytesBE)(f,t))}kt.bls12_381=(0,Uw.bls)({fields:{Fp:pe,Fp2:he,Fp6:wl,Fp12:Ne,Fr:N0},G1:{Fp:pe,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:pe.ZERO,b:ws,htfDefaults:{...bl,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(e,t)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new e(pe.mul(t.px,r),t.py,t.pz);return t.multiplyUnsafe(Nn).negate().multiplyUnsafe(Nn).equals(n)},clearCofactor:(e,t)=>t.multiplyUnsafe(Nn).add(t),mapToCurve:e=>{let{x:t,y:r}=jw(pe.create(e[0]));return kw(t,r)},fromBytes:e=>{let{compressed:t,infinity:r,sort:n,value:i}=po(e);if(i.length===48&&t){let s=pe.ORDER,a=(0,Re.bytesToNumberBE)(i),o=pe.create(a&pe.MASK);if(r){if(o!==Mt)throw new Error("G1: non-empty compressed point at infinity");return{x:Mt,y:Mt}}let c=pe.add(pe.pow(o,fo),pe.create(kt.bls12_381.params.G1b)),d=pe.sqrt(c);if(!d)throw new Error("Invalid compressed G1 point");return d*_t/s!==BigInt(n)&&(d=pe.neg(d)),{x:pe.create(o),y:pe.create(d)}}else if(i.length===96&&!t){let s=(0,Re.bytesToNumberBE)(i.subarray(0,pe.BYTES)),a=(0,Re.bytesToNumberBE)(i.subarray(pe.BYTES));if(r){if(s!==Mt||a!==Mt)throw new Error("G1: non-empty point at infinity");return kt.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:pe.create(s),y:pe.create(a)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(e,t,r)=>{let n=t.equals(e.ZERO),{x:i,y:s}=t.toAffine();if(r){if(n)return _o.slice();let a=pe.ORDER,o=!!(s*_t/a);return xs((0,Re.numberToBytesBE)(i,pe.BYTES),{compressed:!0,sort:o})}else return n?(0,Re.concatBytes)(new Uint8Array([64]),new Uint8Array(2*pe.BYTES-1)):(0,Re.concatBytes)((0,Re.numberToBytesBE)(i,pe.BYTES),(0,Re.numberToBytesBE)(s,pe.BYTES))},ShortSignature:{fromHex(e){let{infinity:t,sort:r,value:n}=po((0,Re.ensureBytes)("signatureHex",e,48)),i=pe.ORDER,s=(0,Re.bytesToNumberBE)(n);if(t)return kt.bls12_381.G1.ProjectivePoint.ZERO;let a=pe.create(s&pe.MASK),o=pe.add(pe.pow(a,fo),pe.create(kt.bls12_381.params.G1b)),c=pe.sqrt(o);if(!c)throw new Error("Invalid compressed G1 point");let d=BigInt(r);c*_t/i!==d&&(c=pe.neg(c));let f=kt.bls12_381.G1.ProjectivePoint.fromAffine({x:a,y:c});return f.assertValidity(),f},toRawBytes(e){return E0(e)},toHex(e){return(0,Re.bytesToHex)(E0(e))}}},G2:{Fp:he,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:he.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:he.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:he.ZERO,b:he.fromBigTuple([ws,ws]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...bl},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{let{x:t,y:r}=Dw(he.fromBigTuple(e));return Mw(t,r)},isTorsionFree:(e,t)=>t.multiplyUnsafe(Nn).negate().equals(O0(e,t)),clearCofactor:(e,t)=>{let r=Nn,n=t.multiplyUnsafe(r).negate(),i=O0(e,t),s=t.double();return s=Lw(e,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(t)},fromBytes:e=>{let{compressed:t,infinity:r,sort:n,value:i}=po(e);if(!t&&!r&&n||!t&&r&&n||n&&r&&t)throw new Error("Invalid encoding flag: "+(e[0]&224));let s=pe.BYTES,a=(o,c,d)=>(0,Re.bytesToNumberBE)(o.slice(c,d));if(i.length===96&&t){let o=kt.bls12_381.params.G2b,c=pe.ORDER;if(r){if(i.reduce((A,v)=>A!==0?v+1:v,0)>0)throw new Error("Invalid compressed G2 point");return{x:he.ZERO,y:he.ZERO}}let d=a(i,0,s),f=a(i,s,2*s),p=he.create({c0:pe.create(f),c1:pe.create(d)}),m=he.add(he.pow(p,fo),o),b=he.sqrt(m),l=b.c1===Mt?b.c0*_t/c:b.c1*_t/c?ho:Mt;return b=n&&l>0?b:he.neg(b),{x:p,y:b}}else if(i.length===192&&!t){if(r){if(i.reduce((p,m)=>p!==0?m+1:m,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:he.ZERO,y:he.ZERO}}let o=a(i,0,s),c=a(i,s,2*s),d=a(i,2*s,3*s),f=a(i,3*s,4*s);return{x:he.fromBigTuple([c,o]),y:he.fromBigTuple([f,d])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(e,t,r)=>{let{BYTES:n,ORDER:i}=pe,s=t.equals(e.ZERO),{x:a,y:o}=t.toAffine();if(r){if(s)return(0,Re.concatBytes)(_o,(0,Re.numberToBytesBE)(Mt,n));let c=!!(o.c1===Mt?o.c0*_t/i:o.c1*_t/i);return(0,Re.concatBytes)(xs((0,Re.numberToBytesBE)(a.c1,n),{compressed:!0,sort:c}),(0,Re.numberToBytesBE)(a.c0,n))}else{if(s)return(0,Re.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:d}=he.reim(a),{re:f,im:p}=he.reim(o);return(0,Re.concatBytes)((0,Re.numberToBytesBE)(d,n),(0,Re.numberToBytesBE)(c,n),(0,Re.numberToBytesBE)(p,n),(0,Re.numberToBytesBE)(f,n))}},Signature:{fromHex(e){let{infinity:t,sort:r,value:n}=po((0,Re.ensureBytes)("signatureHex",e)),i=pe.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let a=(0,Re.bytesToNumberBE)(n.slice(0,s)),o=(0,Re.bytesToNumberBE)(n.slice(s));if(t)return kt.bls12_381.G2.ProjectivePoint.ZERO;let c=pe.create(a&pe.MASK),d=pe.create(o),f=he.create({c0:d,c1:c}),p=he.add(he.pow(f,fo),kt.bls12_381.params.G2b),m=he.sqrt(p);if(!m)throw new Error("Failed to find a square root");let{re:b,im:l}=he.reim(m),A=BigInt(r),v=l>Mt&&l*_t/i!==A,F=l===Mt&&b*_t/i!==A;(v||F)&&(m=he.neg(m));let C=kt.bls12_381.G2.ProjectivePoint.fromAffine({x:f,y:m});return C.assertValidity(),C},toRawBytes(e){return v0(e)},toHex(e){return(0,Re.bytesToHex)(v0(e))}}},params:{ateLoopSize:Nn,r:N0.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:bl,hash:R0.sha256,randomBytes:Vw.randomBytes})});var Tl=ee(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.blsVerify=Ts.verify=void 0;var Hw=I0(),xl=$t();function Kw(e,t,r){let n=typeof e=="string"?e:(0,xl.toHex)(e),i=typeof t=="string"?t:(0,xl.toHex)(t),s=typeof r=="string"?r:(0,xl.toHex)(r);return Hw.bls12_381.verifyShortSignature(i,s,n)}Ts.blsVerify=Kw});var yo=ee(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});Gn.decodeTime=Gn.decodeLeb128=void 0;var P0=Ti(),$w=e=>(0,P0.lebDecode)(new P0.PipeArrayBuffer(e));Gn.decodeLeb128=$w;var Gw=e=>{let t=(0,Gn.decodeLeb128)(e);return new Date(Number(t)/1e6)};Gn.decodeTime=Gw});var Ai=ee(Oe=>{"use strict";var zw=Oe&&Oe.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Ww=Oe&&Oe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),F0=Oe&&Oe.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&zw(t,e,r);return Ww(t,e),t},Yw=Oe&&Oe.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},Jw=Oe&&Oe.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},go;Object.defineProperty(Oe,"__esModule",{value:!0});Oe.check_canister_ranges=Oe.find_label=Oe.flatten_forks=Oe.lookup_path=Oe.LookupStatus=Oe.reconstruct=Oe.lookupResultToBuffer=Oe.Certificate=Oe.hashTreeToString=Oe.NodeType=Oe.CertificateVerificationError=void 0;var V0=F0(ys()),Zw=_i(),mo=ps(),br=$t(),Nl=vt(),Xw=F0(Tl()),Qw=yo(),ex=Rs(),nn=class extends Zw.AgentError{constructor(t){super(`Invalid certificate: ${t}`)}};Oe.CertificateVerificationError=nn;var xt;(function(e){e[e.Empty=0]="Empty",e[e.Fork=1]="Fork",e[e.Labeled=2]="Labeled",e[e.Leaf=3]="Leaf",e[e.Pruned=4]="Pruned"})(xt=Oe.NodeType||(Oe.NodeType={}));function bo(e){let t=n=>n.split(`
16
+ `)}return c.encodeValue(d)}));return(0,Pe.concat)(n,i,s,a,o)}z.encode=Gg;function zg(e,t){let r=new Pe.PipeArrayBuffer(t);if(t.byteLength<Ta.length)throw new Error("Message length smaller than magic number");let n=(0,ce.safeRead)(r,Ta.length),i=new TextDecoder().decode(n);if(i!==Ta)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(b){let l=[],A=Number((0,ce.lebDecode)(b));for(let C=0;C<A;C++){let O=Number((0,ce.slebDecode)(b));switch(O){case-18:case-19:{let H=Number((0,ce.slebDecode)(b));l.push([O,H]);break}case-20:case-21:{let H=[],x=Number((0,ce.lebDecode)(b)),q;for(;x--;){let K=Number((0,ce.lebDecode)(b));if(K>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof q=="number"&&q>=K)throw new Error("field id collision or not sorted");q=K;let $=Number((0,ce.slebDecode)(b));H.push([K,$])}l.push([O,H]);break}case-22:{let H=[],x=Number((0,ce.lebDecode)(b));for(;x--;)H.push(Number((0,ce.slebDecode)(b)));let q=[],K=Number((0,ce.lebDecode)(b));for(;K--;)q.push(Number((0,ce.slebDecode)(b)));let $=[],M=Number((0,ce.lebDecode)(b));for(;M--;)switch(Number((0,ce.lebDecode)(b))){case 1:{$.push("query");break}case 2:{$.push("oneway");break}case 3:{$.push("composite_query");break}default:throw new Error("unknown annotation")}l.push([O,[H,q,$]]);break}case-23:{let H=Number((0,ce.lebDecode)(b)),x=[];for(;H--;){let q=Number((0,ce.lebDecode)(b)),K=new TextDecoder().decode((0,ce.safeRead)(b,q)),$=(0,ce.slebDecode)(b);x.push([K,$])}l.push([O,x]);break}default:throw new Error("Illegal op_code: "+O)}}let v=[],F=Number((0,ce.lebDecode)(b));for(let C=0;C<F;C++)v.push(Number((0,ce.slebDecode)(b)));return[l,v]}let[a,o]=s(r);if(o.length<e.length)throw new Error("Wrong number of return values");let c=a.map(b=>Wf());function d(b){if(b<-24)throw new Error("future value not supported");if(b<0)switch(b){case-1:return z.Null;case-2:return z.Bool;case-3:return z.Nat;case-4:return z.Int;case-5:return z.Nat8;case-6:return z.Nat16;case-7:return z.Nat32;case-8:return z.Nat64;case-9:return z.Int8;case-10:return z.Int16;case-11:return z.Int32;case-12:return z.Int64;case-13:return z.Float32;case-14:return z.Float64;case-15:return z.Text;case-16:return z.Reserved;case-17:return z.Empty;case-24:return z.Principal;default:throw new Error("Illegal op_code: "+b)}if(b>=a.length)throw new Error("type index out of range");return c[b]}function f(b){switch(b[0]){case-19:{let l=d(b[1]);return Kf(l)}case-18:{let l=d(b[1]);return $f(l)}case-20:{let l={};for(let[F,C]of b[1]){let O=`_${F}_`;l[O]=d(C)}let A=Gf(l),v=A.tryAsTuple();return Array.isArray(v)?Hf(...v):A}case-21:{let l={};for(let[A,v]of b[1]){let F=`_${A}_`;l[F]=d(v)}return zf(l)}case-22:{let[l,A,v]=b[1];return Yf(l.map(F=>d(F)),A.map(F=>d(F)),v)}case-23:{let l={},A=b[1];for(let[v,F]of A){let C=d(F);if(C instanceof _n&&(C=C.getType()),!(C instanceof as))throw new Error("Illegal service definition: services can only contain functions");l[v]=C}return Jf(l)}default:throw new Error("Illegal op_code: "+b[0])}}a.forEach((b,l)=>{if(b[0]===-22){let A=f(b);c[l].fill(A)}}),a.forEach((b,l)=>{if(b[0]!==-22){let A=f(b);c[l].fill(A)}});let p=o.map(b=>d(b)),m=e.map((b,l)=>b.decodeValue(r,p[l]));for(let b=e.length;b<p.length;b++)p[b].decodeValue(r,p[b]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return m}z.decode=zg;z.Empty=new Na;z.Reserved=new gi;z.Unknown=new Oa;z.Bool=new Ea;z.Null=new va;z.Text=new Ra;z.Int=new Aa;z.Nat=new Sa;z.Float32=new is(32);z.Float64=new is(64);z.Int8=new Qr(8);z.Int16=new Qr(16);z.Int32=new Qr(32);z.Int64=new Qr(64);z.Nat8=new Fr(8);z.Nat16=new Fr(16);z.Nat32=new Fr(32);z.Nat64=new Fr(64);z.Principal=new Fa;function Hf(...e){return new Ia(e)}z.Tuple=Hf;function Kf(e){return new Ba(e)}z.Vec=Kf;function $f(e){return new bi(e)}z.Opt=$f;function Gf(e){return new ss(e)}z.Record=Gf;function zf(e){return new Pa(e)}z.Variant=zf;function Wf(){return new _n}z.Rec=Wf;function Yf(e,t,r=[]){return new as(e,t,r)}z.Func=Yf;function Jf(e){return new Va(e)}z.Service=Jf});var yu=ee(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.VecForm=vt.OptionForm=vt.VariantForm=vt.TupleForm=vt.RecordForm=vt.InputForm=vt.InputBox=void 0;var lu=class{constructor(t,r){this.idl=t,this.ui=r,this.label=null,this.value=void 0;let n=document.createElement("span");n.className="status",this.status=n,r.input&&(r.input.addEventListener("blur",()=>{r.input.value!==""&&this.parse()}),r.input.addEventListener("input",()=>{n.style.display="none",r.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(t={}){if(this.ui.form){let r=this.ui.form.parse(t);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,t,r.value);if(!this.idl.covariant(n))throw new Error(`${r.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=n,n}catch(n){r.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+n.message,this.value=void 0;return}}return null}render(t){let r=document.createElement("span");if(this.label){let n=document.createElement("label");n.innerText=this.label,r.appendChild(n)}this.ui.input&&(r.appendChild(this.ui.input),r.appendChild(this.status)),this.ui.form&&this.ui.form.render(r),t.appendChild(r)}};vt.InputBox=lu;var yn=class{constructor(t){this.ui=t,this.form=[]}renderForm(t){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),t.appendChild(this.ui.container)):this.form.forEach(r=>r.render(t))}render(t){if(this.ui.open&&this.ui.event){t.appendChild(this.ui.open);let r=this;r.ui.open.addEventListener(r.ui.event,()=>{if(r.ui.container)r.ui.container.innerHTML="";else{let n=r.ui.open.nextElementSibling;n&&n.parentNode.removeChild(n)}r.generateForm(),r.renderForm(t)})}else this.generateForm(),this.renderForm(t)}};vt.InputForm=yn;var du=class extends yn{constructor(t,r){super(r),this.fields=t,this.ui=r}generateForm(){this.form=this.fields.map(([t,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(t)?n.label=this.ui.labelMap[t]+" ":n.label=t+" ",n})}parse(t){let r={};if(this.fields.forEach(([n,i],s)=>{let a=this.form[s].parse(t);r[n]=a}),!this.form.some(n=>n.isRejected()))return r}};vt.RecordForm=du;var fu=class extends yn{constructor(t,r){super(r),this.components=t,this.ui=r}generateForm(){this.form=this.components.map(t=>this.ui.render(t))}parse(t){let r=[];if(this.components.forEach((n,i)=>{let s=this.form[i].parse(t);r.push(s)}),!this.form.some(n=>n.isRejected()))return r}};vt.TupleForm=fu;var pu=class extends yn{constructor(t,r){super(r),this.fields=t,this.ui=r}generateForm(){let t=this.ui.open.selectedIndex,[r,n]=this.fields[t],i=this.ui.render(n);this.form=[i]}parse(t){let r=this.ui.open,n=r.options[r.selectedIndex].value,i=this.form[0].parse(t);if(i===void 0)return;let s={};return s[n]=i,s}};vt.VariantForm=pu;var hu=class extends yn{constructor(t,r){super(r),this.ty=t,this.ui=r}generateForm(){if(this.ui.open.checked){let t=this.ui.render(this.ty);this.form=[t]}else this.form=[]}parse(t){if(this.form.length===0)return[];{let r=this.form[0].parse(t);return r===void 0?void 0:[r]}}};vt.OptionForm=hu;var _u=class extends yn{constructor(t,r){super(r),this.ty=t,this.ui=r}generateForm(){let t=+this.ui.open.value;this.form=[];for(let r=0;r<t;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(t){let r=this.form.map(n=>n.parse(t));if(!this.form.some(n=>n.isRejected()))return r}};vt.VecForm=_u});var Xf=ee(xe=>{"use strict";var Wg=xe&&xe.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Yg=xe&&xe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Zf=xe&&xe.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&Wg(t,e,r);return Yg(t,e),t};Object.defineProperty(xe,"__esModule",{value:!0});xe.renderValue=xe.renderInput=xe.Render=xe.vecForm=xe.optForm=xe.variantForm=xe.tupleForm=xe.recordForm=xe.inputBox=void 0;var Ca=Zf(uu()),mu=Ut(),wi=Zf(yu()),Jg={parse:nb},os={render:xu},Zg=(e,t)=>new wi.InputBox(e,Object.assign(Object.assign({},Jg),t));xe.inputBox=Zg;var Xg=(e,t)=>new wi.RecordForm(e,Object.assign(Object.assign({},os),t));xe.recordForm=Xg;var Qg=(e,t)=>new wi.TupleForm(e,Object.assign(Object.assign({},os),t));xe.tupleForm=Qg;var eb=(e,t)=>new wi.VariantForm(e,Object.assign(Object.assign({},os),t));xe.variantForm=eb;var tb=(e,t)=>new wi.OptionForm(e,Object.assign(Object.assign({},os),t));xe.optForm=tb;var rb=(e,t)=>new wi.VecForm(e,Object.assign(Object.assign({},os),t));xe.vecForm=rb;var Ua=class extends Ca.Visitor{visitType(t,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=t.display(),(0,xe.inputBox)(t,{input:n})}visitNull(t,r){return(0,xe.inputBox)(t,{})}visitRecord(t,r,n){let i={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),i={container:a}}let s=(0,xe.recordForm)(r,i);return(0,xe.inputBox)(t,{form:s})}visitTuple(t,r,n){let i={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),i={container:a}}let s=(0,xe.tupleForm)(r,i);return(0,xe.inputBox)(t,{form:s})}visitVariant(t,r,n){let i=document.createElement("select");for(let[o,c]of r){let d=new Option(o);i.add(d)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},a=(0,xe.variantForm)(r,s);return(0,xe.inputBox)(t,{form:a})}visitOpt(t,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,xe.optForm)(r,{open:i,event:"change"});return(0,xe.inputBox)(t,{form:s})}visitVec(t,r,n){let i=document.createElement("input");i.type="number",i.min="0",i.max="100",i.style.width="8rem",i.placeholder="len",i.classList.add("open");let s=document.createElement("div");s.classList.add("popup-form");let a=(0,xe.vecForm)(r,{open:i,event:"change",container:s});return(0,xe.inputBox)(t,{form:a})}visitRec(t,r,n){return xu(r)}};xe.Render=Ua;var gu=class extends Ca.Visitor{visitNull(t,r){return null}visitBool(t,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(t,r){return r}visitFloat(t,r){return parseFloat(r)}visitFixedInt(t,r){return t._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(t,r){return t._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(t,r){return BigInt(r)}visitPrincipal(t,r){return mu.Principal.fromText(r)}visitService(t,r){return mu.Principal.fromText(r)}visitFunc(t,r){let n=r.split(".",2);return[mu.Principal.fromText(n[0]),n[1]]}},bu=class extends Ca.Visitor{visitNull(t,r){return null}visitBool(t,r){return Math.random()<.5}visitText(t,r){return Math.random().toString(36).substring(6)}visitFloat(t,r){return Math.random()}visitInt(t,r){return BigInt(this.generateNumber(!0))}visitNat(t,r){return BigInt(this.generateNumber(!1))}visitFixedInt(t,r){let n=this.generateNumber(!0);return t._bits<=32?n:BigInt(r)}visitFixedNat(t,r){let n=this.generateNumber(!1);return t._bits<=32?n:BigInt(r)}generateNumber(t){let r=Math.floor(Math.random()*100);return t&&Math.random()<.5?-r:r}};function nb(e,t,r){return t.random&&r===""?e.accept(new bu,r):e.accept(new gu,r)}function xu(e){return e.accept(new Ua,null)}xe.renderInput=xu;function jn(e,t,r){return e.accept(new wu,{input:t,value:r})}xe.renderValue=jn;var wu=class extends Ca.Visitor{visitType(t,r){r.input.ui.input.value=t.valueToString(r.value)}visitNull(t,r){}visitText(t,r){r.input.ui.input.value=r.value}visitRec(t,r,n){jn(r,n.input,n.value)}visitOpt(t,r,n){if(n.value.length!==0){let i=n.input.ui.form,s=i.ui.open;s.checked=!0,s.dispatchEvent(new Event(i.ui.event)),jn(r,i.form[0],n.value[0])}}visitRecord(t,r,n){let i=n.input.ui.form;r.forEach(([s,a],o)=>{jn(a,i.form[o],n.value[s])})}visitTuple(t,r,n){let i=n.input.ui.form;r.forEach((s,a)=>{jn(s,i.form[a],n.value[a])})}visitVariant(t,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([a,o],c)=>{if(a===s[0]){let d=i.ui.open;d.selectedIndex=c,d.dispatchEvent(new Event(i.ui.event)),jn(o,i.form[0],s[1])}})}visitVec(t,r,n){let i=n.input.ui.form,s=n.value.length,a=i.ui.open;a.value=s,a.dispatchEvent(new Event(i.ui.event)),n.value.forEach((o,c)=>{jn(r,i.form[c],o)})}}});var ep=ee(Qf=>{"use strict";Object.defineProperty(Qf,"__esModule",{value:!0})});var Ti=ee(ht=>{"use strict";var tp=ht&&ht.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),ib=ht&&ht.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),xi=ht&&ht.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&tp(t,e,r)},sb=ht&&ht.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&tp(t,e,r);return ib(t,e),t};Object.defineProperty(ht,"__esModule",{value:!0});ht.IDL=void 0;xi(Xf(),ht);xi(yu(),ht);ht.IDL=sb(uu());xi(ru(),ht);xi(iu(),ht);xi(ba(),ht);xi(ep(),ht)});var cs=ee((rp,qa)=>{(function(e){"use strict";var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",a=s+"Number primitive has more than 15 significant digits: ",o=1e14,c=14,d=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,m=1e9;function b(x){var q,K,$,M=V.prototype={constructor:V,toString:null,valueOf:null},ae=new V(1),Q=20,ne=4,w=-7,g=21,S=-1e7,R=1e7,B=!1,j=1,Y=0,oe={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},se="0123456789abcdefghijklmnopqrstuvwxyz",W=!0;function V(u,h){var y,P,E,I,D,T,U,L,k=this;if(!(k instanceof V))return new V(u,h);if(h==null){if(u&&u._isBigNumber===!0){k.s=u.s,!u.c||u.e>R?k.c=k.e=null:u.e<S?k.c=[k.e=0]:(k.e=u.e,k.c=u.c.slice());return}if((T=typeof u=="number")&&u*0==0){if(k.s=1/u<0?(u=-u,-1):1,u===~~u){for(I=0,D=u;D>=10;D/=10,I++);I>R?k.c=k.e=null:(k.e=I,k.c=[u]);return}L=String(u)}else{if(!r.test(L=String(u)))return $(k,L,T);k.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(I=L.indexOf("."))>-1&&(L=L.replace(".","")),(D=L.search(/e/i))>0?(I<0&&(I=D),I+=+L.slice(D+1),L=L.substring(0,D)):I<0&&(I=L.length)}else{if(F(h,2,se.length,"Base"),h==10&&W)return k=new V(u),le(k,Q+k.e+1,ne);if(L=String(u),T=typeof u=="number"){if(u*0!=0)return $(k,L,T,h);if(k.s=1/u<0?(L=L.slice(1),-1):1,V.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(a+u)}else k.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(y=se.slice(0,h),I=D=0,U=L.length;D<U;D++)if(y.indexOf(P=L.charAt(D))<0){if(P=="."){if(D>I){I=U;continue}}else if(!E&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){E=!0,D=-1,I=0;continue}return $(k,String(u),T,h)}T=!1,L=K(L,h,10,k.s),(I=L.indexOf("."))>-1?L=L.replace(".",""):I=L.length}for(D=0;L.charCodeAt(D)===48;D++);for(U=L.length;L.charCodeAt(--U)===48;);if(L=L.slice(D,++U)){if(U-=D,T&&V.DEBUG&&U>15&&(u>d||u!==i(u)))throw Error(a+k.s*u);if((I=I-D-1)>R)k.c=k.e=null;else if(I<S)k.c=[k.e=0];else{if(k.e=I,k.c=[],D=(I+1)%c,I<0&&(D+=c),D<U){for(D&&k.c.push(+L.slice(0,D)),U-=c;D<U;)k.c.push(+L.slice(D,D+=c));D=c-(L=L.slice(D)).length}else D-=U;for(;D--;L+="0");k.c.push(+L)}}else k.c=[k.e=0]}V.clone=b,V.ROUND_UP=0,V.ROUND_DOWN=1,V.ROUND_CEIL=2,V.ROUND_FLOOR=3,V.ROUND_HALF_UP=4,V.ROUND_HALF_DOWN=5,V.ROUND_HALF_EVEN=6,V.ROUND_HALF_CEIL=7,V.ROUND_HALF_FLOOR=8,V.EUCLID=9,V.config=V.set=function(u){var h,y;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(h="DECIMAL_PLACES")&&(y=u[h],F(y,0,m,h),Q=y),u.hasOwnProperty(h="ROUNDING_MODE")&&(y=u[h],F(y,0,8,h),ne=y),u.hasOwnProperty(h="EXPONENTIAL_AT")&&(y=u[h],y&&y.pop?(F(y[0],-m,0,h),F(y[1],0,m,h),w=y[0],g=y[1]):(F(y,-m,m,h),w=-(g=y<0?-y:y))),u.hasOwnProperty(h="RANGE"))if(y=u[h],y&&y.pop)F(y[0],-m,-1,h),F(y[1],1,m,h),S=y[0],R=y[1];else if(F(y,-m,m,h),y)S=-(R=y<0?-y:y);else throw Error(s+h+" cannot be zero: "+y);if(u.hasOwnProperty(h="CRYPTO"))if(y=u[h],y===!!y)if(y)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))B=y;else throw B=!y,Error(s+"crypto unavailable");else B=y;else throw Error(s+h+" not true or false: "+y);if(u.hasOwnProperty(h="MODULO_MODE")&&(y=u[h],F(y,0,9,h),j=y),u.hasOwnProperty(h="POW_PRECISION")&&(y=u[h],F(y,0,m,h),Y=y),u.hasOwnProperty(h="FORMAT"))if(y=u[h],typeof y=="object")oe=y;else throw Error(s+h+" not an object: "+y);if(u.hasOwnProperty(h="ALPHABET"))if(y=u[h],typeof y=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(y))W=y.slice(0,10)=="0123456789",se=y;else throw Error(s+h+" invalid: "+y)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:Q,ROUNDING_MODE:ne,EXPONENTIAL_AT:[w,g],RANGE:[S,R],CRYPTO:B,MODULO_MODE:j,POW_PRECISION:Y,FORMAT:oe,ALPHABET:se}},V.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!V.DEBUG)return!0;var h,y,P=u.c,E=u.e,I=u.s;e:if({}.toString.call(P)=="[object Array]"){if((I===1||I===-1)&&E>=-m&&E<=m&&E===i(E)){if(P[0]===0){if(E===0&&P.length===1)return!0;break e}if(h=(E+1)%c,h<1&&(h+=c),String(P[0]).length==h){for(h=0;h<P.length;h++)if(y=P[h],y<0||y>=o||y!==i(y))break e;if(y!==0)return!0}}}else if(P===null&&E===null&&(I===null||I===1||I===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},V.maximum=V.max=function(){return Z(arguments,-1)},V.minimum=V.min=function(){return Z(arguments,1)},V.random=function(){var u=9007199254740992,h=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(y){var P,E,I,D,T,U=0,L=[],k=new V(ae);if(y==null?y=Q:F(y,0,m),D=n(y/c),B)if(crypto.getRandomValues){for(P=crypto.getRandomValues(new Uint32Array(D*=2));U<D;)T=P[U]*131072+(P[U+1]>>>11),T>=9e15?(E=crypto.getRandomValues(new Uint32Array(2)),P[U]=E[0],P[U+1]=E[1]):(L.push(T%1e14),U+=2);U=D/2}else if(crypto.randomBytes){for(P=crypto.randomBytes(D*=7);U<D;)T=(P[U]&31)*281474976710656+P[U+1]*1099511627776+P[U+2]*4294967296+P[U+3]*16777216+(P[U+4]<<16)+(P[U+5]<<8)+P[U+6],T>=9e15?crypto.randomBytes(7).copy(P,U):(L.push(T%1e14),U+=7);U=D/7}else throw B=!1,Error(s+"crypto unavailable");if(!B)for(;U<D;)T=h(),T<9e15&&(L[U++]=T%1e14);for(D=L[--U],y%=c,D&&y&&(T=f[c-y],L[U]=i(D/T)*T);L[U]===0;L.pop(),U--);if(U<0)L=[I=0];else{for(I=-1;L[0]===0;L.splice(0,1),I-=c);for(U=1,T=L[0];T>=10;T/=10,U++);U<c&&(I-=c-U)}return k.e=I,k.c=L,k}}(),V.sum=function(){for(var u=1,h=arguments,y=new V(h[0]);u<h.length;)y=y.plus(h[u++]);return y},K=function(){var u="0123456789";function h(y,P,E,I){for(var D,T=[0],U,L=0,k=y.length;L<k;){for(U=T.length;U--;T[U]*=P);for(T[0]+=I.indexOf(y.charAt(L++)),D=0;D<T.length;D++)T[D]>E-1&&(T[D+1]==null&&(T[D+1]=0),T[D+1]+=T[D]/E|0,T[D]%=E)}return T.reverse()}return function(y,P,E,I,D){var T,U,L,k,J,te,de,ge,Se=y.indexOf("."),Fe=Q,_e=ne;for(Se>=0&&(k=Y,Y=0,y=y.replace(".",""),ge=new V(P),te=ge.pow(y.length-Se),Y=k,ge.c=h(H(A(te.c),te.e,"0"),10,E,u),ge.e=ge.c.length),de=h(y,P,E,D?(T=se,u):(T=u,se)),L=k=de.length;de[--k]==0;de.pop());if(!de[0])return T.charAt(0);if(Se<0?--L:(te.c=de,te.e=L,te.s=I,te=q(te,ge,Fe,_e,E),de=te.c,J=te.r,L=te.e),U=L+Fe+1,Se=de[U],k=E/2,J=J||U<0||de[U+1]!=null,J=_e<4?(Se!=null||J)&&(_e==0||_e==(te.s<0?3:2)):Se>k||Se==k&&(_e==4||J||_e==6&&de[U-1]&1||_e==(te.s<0?8:7)),U<1||!de[0])y=J?H(T.charAt(1),-Fe,T.charAt(0)):T.charAt(0);else{if(de.length=U,J)for(--E;++de[--U]>E;)de[U]=0,U||(++L,de=[1].concat(de));for(k=de.length;!de[--k];);for(Se=0,y="";Se<=k;y+=T.charAt(de[Se++]));y=H(y,L,T.charAt(0))}return y}}(),q=function(){function u(P,E,I){var D,T,U,L,k=0,J=P.length,te=E%p,de=E/p|0;for(P=P.slice();J--;)U=P[J]%p,L=P[J]/p|0,D=de*U+L*te,T=te*U+D%p*p+k,k=(T/I|0)+(D/p|0)+de*L,P[J]=T%I;return k&&(P=[k].concat(P)),P}function h(P,E,I,D){var T,U;if(I!=D)U=I>D?1:-1;else for(T=U=0;T<I;T++)if(P[T]!=E[T]){U=P[T]>E[T]?1:-1;break}return U}function y(P,E,I,D){for(var T=0;I--;)P[I]-=T,T=P[I]<E[I]?1:0,P[I]=T*D+P[I]-E[I];for(;!P[0]&&P.length>1;P.splice(0,1));}return function(P,E,I,D,T){var U,L,k,J,te,de,ge,Se,Fe,_e,fe,He,Lt,Ft,Vt,Ht,Be,Ot=P.s==E.s?1:-1,at=P.c,Ke=E.c;if(!at||!at[0]||!Ke||!Ke[0])return new V(!P.s||!E.s||(at?Ke&&at[0]==Ke[0]:!Ke)?NaN:at&&at[0]==0||!Ke?Ot*0:Ot/0);for(Se=new V(Ot),Fe=Se.c=[],L=P.e-E.e,Ot=I+L+1,T||(T=o,L=l(P.e/c)-l(E.e/c),Ot=Ot/c|0),k=0;Ke[k]==(at[k]||0);k++);if(Ke[k]>(at[k]||0)&&L--,Ot<0)Fe.push(1),J=!0;else{for(Ft=at.length,Ht=Ke.length,k=0,Ot+=2,te=i(T/(Ke[0]+1)),te>1&&(Ke=u(Ke,te,T),at=u(at,te,T),Ht=Ke.length,Ft=at.length),Lt=Ht,_e=at.slice(0,Ht),fe=_e.length;fe<Ht;_e[fe++]=0);Be=Ke.slice(),Be=[0].concat(Be),Vt=Ke[0],Ke[1]>=T/2&&Vt++;do{if(te=0,U=h(Ke,_e,Ht,fe),U<0){if(He=_e[0],Ht!=fe&&(He=He*T+(_e[1]||0)),te=i(He/Vt),te>1)for(te>=T&&(te=T-1),de=u(Ke,te,T),ge=de.length,fe=_e.length;h(de,_e,ge,fe)==1;)te--,y(de,Ht<ge?Be:Ke,ge,T),ge=de.length,U=1;else te==0&&(U=te=1),de=Ke.slice(),ge=de.length;if(ge<fe&&(de=[0].concat(de)),y(_e,de,fe,T),fe=_e.length,U==-1)for(;h(Ke,_e,Ht,fe)<1;)te++,y(_e,Ht<fe?Be:Ke,fe,T),fe=_e.length}else U===0&&(te++,_e=[0]);Fe[k++]=te,_e[0]?_e[fe++]=at[Lt]||0:(_e=[at[Lt]],fe=1)}while((Lt++<Ft||_e[0]!=null)&&Ot--);J=_e[0]!=null,Fe[0]||Fe.splice(0,1)}if(T==o){for(k=1,Ot=Fe[0];Ot>=10;Ot/=10,k++);le(Se,I+(Se.e=k+L*c-1)+1,D,J)}else Se.e=L,Se.r=+J;return Se}}();function _(u,h,y,P){var E,I,D,T,U;if(y==null?y=ne:F(y,0,8),!u.c)return u.toString();if(E=u.c[0],D=u.e,h==null)U=A(u.c),U=P==1||P==2&&(D<=w||D>=g)?O(U,D):H(U,D,"0");else if(u=le(new V(u),h,y),I=u.e,U=A(u.c),T=U.length,P==1||P==2&&(h<=I||I<=w)){for(;T<h;U+="0",T++);U=O(U,I)}else if(h-=D,U=H(U,I,"0"),I+1>T){if(--h>0)for(U+=".";h--;U+="0");}else if(h+=I-T,h>0)for(I+1==T&&(U+=".");h--;U+="0");return u.s<0&&E?"-"+U:U}function Z(u,h){for(var y,P,E=1,I=new V(u[0]);E<u.length;E++)P=new V(u[E]),(!P.s||(y=v(I,P))===h||y===0&&I.s===h)&&(I=P);return I}function re(u,h,y){for(var P=1,E=h.length;!h[--E];h.pop());for(E=h[0];E>=10;E/=10,P++);return(y=P+y*c-1)>R?u.c=u.e=null:y<S?u.c=[u.e=0]:(u.e=y,u.c=h),u}$=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,h=/^([^.]+)\.$/,y=/^\.([^.]+)$/,P=/^-?(Infinity|NaN)$/,E=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(I,D,T,U){var L,k=T?D:D.replace(E,"");if(P.test(k))I.s=isNaN(k)?null:k<0?-1:1;else{if(!T&&(k=k.replace(u,function(J,te,de){return L=(de=de.toLowerCase())=="x"?16:de=="b"?2:8,!U||U==L?te:J}),U&&(L=U,k=k.replace(h,"$1").replace(y,"0.$1")),D!=k))return new V(k,L);if(V.DEBUG)throw Error(s+"Not a"+(U?" base "+U:"")+" number: "+D);I.s=null}I.c=I.e=null}}();function le(u,h,y,P){var E,I,D,T,U,L,k,J=u.c,te=f;if(J){e:{for(E=1,T=J[0];T>=10;T/=10,E++);if(I=h-E,I<0)I+=c,D=h,U=J[L=0],k=i(U/te[E-D-1]%10);else if(L=n((I+1)/c),L>=J.length)if(P){for(;J.length<=L;J.push(0));U=k=0,E=1,I%=c,D=I-c+1}else break e;else{for(U=T=J[L],E=1;T>=10;T/=10,E++);I%=c,D=I-c+E,k=D<0?0:i(U/te[E-D-1]%10)}if(P=P||h<0||J[L+1]!=null||(D<0?U:U%te[E-D-1]),P=y<4?(k||P)&&(y==0||y==(u.s<0?3:2)):k>5||k==5&&(y==4||P||y==6&&(I>0?D>0?U/te[E-D]:0:J[L-1])%10&1||y==(u.s<0?8:7)),h<1||!J[0])return J.length=0,P?(h-=u.e+1,J[0]=te[(c-h%c)%c],u.e=-h||0):J[0]=u.e=0,u;if(I==0?(J.length=L,T=1,L--):(J.length=L+1,T=te[c-I],J[L]=D>0?i(U/te[E-D]%te[D])*T:0),P)for(;;)if(L==0){for(I=1,D=J[0];D>=10;D/=10,I++);for(D=J[0]+=T,T=1;D>=10;D/=10,T++);I!=T&&(u.e++,J[0]==o&&(J[0]=1));break}else{if(J[L]+=T,J[L]!=o)break;J[L--]=0,T=1}for(I=J.length;J[--I]===0;J.pop());}u.e>R?u.c=u.e=null:u.e<S&&(u.c=[u.e=0])}return u}function X(u){var h,y=u.e;return y===null?u.toString():(h=A(u.c),h=y<=w||y>=g?O(h,y):H(h,y,"0"),u.s<0?"-"+h:h)}return M.absoluteValue=M.abs=function(){var u=new V(this);return u.s<0&&(u.s=1),u},M.comparedTo=function(u,h){return v(this,new V(u,h))},M.decimalPlaces=M.dp=function(u,h){var y,P,E,I=this;if(u!=null)return F(u,0,m),h==null?h=ne:F(h,0,8),le(new V(I),u+I.e+1,h);if(!(y=I.c))return null;if(P=((E=y.length-1)-l(this.e/c))*c,E=y[E])for(;E%10==0;E/=10,P--);return P<0&&(P=0),P},M.dividedBy=M.div=function(u,h){return q(this,new V(u,h),Q,ne)},M.dividedToIntegerBy=M.idiv=function(u,h){return q(this,new V(u,h),0,1)},M.exponentiatedBy=M.pow=function(u,h){var y,P,E,I,D,T,U,L,k,J=this;if(u=new V(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+X(u));if(h!=null&&(h=new V(h)),T=u.e>14,!J.c||!J.c[0]||J.c[0]==1&&!J.e&&J.c.length==1||!u.c||!u.c[0])return k=new V(Math.pow(+X(J),T?u.s*(2-C(u)):+X(u))),h?k.mod(h):k;if(U=u.s<0,h){if(h.c?!h.c[0]:!h.s)return new V(NaN);P=!U&&J.isInteger()&&h.isInteger(),P&&(J=J.mod(h))}else{if(u.e>9&&(J.e>0||J.e<-1||(J.e==0?J.c[0]>1||T&&J.c[1]>=24e7:J.c[0]<8e13||T&&J.c[0]<=9999975e7)))return I=J.s<0&&C(u)?-0:0,J.e>-1&&(I=1/I),new V(U?1/I:I);Y&&(I=n(Y/c+2))}for(T?(y=new V(.5),U&&(u.s=1),L=C(u)):(E=Math.abs(+X(u)),L=E%2),k=new V(ae);;){if(L){if(k=k.times(J),!k.c)break;I?k.c.length>I&&(k.c.length=I):P&&(k=k.mod(h))}if(E){if(E=i(E/2),E===0)break;L=E%2}else if(u=u.times(y),le(u,u.e+1,1),u.e>14)L=C(u);else{if(E=+X(u),E===0)break;L=E%2}J=J.times(J),I?J.c&&J.c.length>I&&(J.c.length=I):P&&(J=J.mod(h))}return P?k:(U&&(k=ae.div(k)),h?k.mod(h):I?le(k,Y,ne,D):k)},M.integerValue=function(u){var h=new V(this);return u==null?u=ne:F(u,0,8),le(h,h.e+1,u)},M.isEqualTo=M.eq=function(u,h){return v(this,new V(u,h))===0},M.isFinite=function(){return!!this.c},M.isGreaterThan=M.gt=function(u,h){return v(this,new V(u,h))>0},M.isGreaterThanOrEqualTo=M.gte=function(u,h){return(h=v(this,new V(u,h)))===1||h===0},M.isInteger=function(){return!!this.c&&l(this.e/c)>this.c.length-2},M.isLessThan=M.lt=function(u,h){return v(this,new V(u,h))<0},M.isLessThanOrEqualTo=M.lte=function(u,h){return(h=v(this,new V(u,h)))===-1||h===0},M.isNaN=function(){return!this.s},M.isNegative=function(){return this.s<0},M.isPositive=function(){return this.s>0},M.isZero=function(){return!!this.c&&this.c[0]==0},M.minus=function(u,h){var y,P,E,I,D=this,T=D.s;if(u=new V(u,h),h=u.s,!T||!h)return new V(NaN);if(T!=h)return u.s=-h,D.plus(u);var U=D.e/c,L=u.e/c,k=D.c,J=u.c;if(!U||!L){if(!k||!J)return k?(u.s=-h,u):new V(J?D:NaN);if(!k[0]||!J[0])return J[0]?(u.s=-h,u):new V(k[0]?D:ne==3?-0:0)}if(U=l(U),L=l(L),k=k.slice(),T=U-L){for((I=T<0)?(T=-T,E=k):(L=U,E=J),E.reverse(),h=T;h--;E.push(0));E.reverse()}else for(P=(I=(T=k.length)<(h=J.length))?T:h,T=h=0;h<P;h++)if(k[h]!=J[h]){I=k[h]<J[h];break}if(I&&(E=k,k=J,J=E,u.s=-u.s),h=(P=J.length)-(y=k.length),h>0)for(;h--;k[y++]=0);for(h=o-1;P>T;){if(k[--P]<J[P]){for(y=P;y&&!k[--y];k[y]=h);--k[y],k[P]+=o}k[P]-=J[P]}for(;k[0]==0;k.splice(0,1),--L);return k[0]?re(u,k,L):(u.s=ne==3?-1:1,u.c=[u.e=0],u)},M.modulo=M.mod=function(u,h){var y,P,E=this;return u=new V(u,h),!E.c||!u.s||u.c&&!u.c[0]?new V(NaN):!u.c||E.c&&!E.c[0]?new V(E):(j==9?(P=u.s,u.s=1,y=q(E,u,0,3),u.s=P,y.s*=P):y=q(E,u,0,j),u=E.minus(y.times(u)),!u.c[0]&&j==1&&(u.s=E.s),u)},M.multipliedBy=M.times=function(u,h){var y,P,E,I,D,T,U,L,k,J,te,de,ge,Se,Fe,_e=this,fe=_e.c,He=(u=new V(u,h)).c;if(!fe||!He||!fe[0]||!He[0])return!_e.s||!u.s||fe&&!fe[0]&&!He||He&&!He[0]&&!fe?u.c=u.e=u.s=null:(u.s*=_e.s,!fe||!He?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(P=l(_e.e/c)+l(u.e/c),u.s*=_e.s,U=fe.length,J=He.length,U<J&&(ge=fe,fe=He,He=ge,E=U,U=J,J=E),E=U+J,ge=[];E--;ge.push(0));for(Se=o,Fe=p,E=J;--E>=0;){for(y=0,te=He[E]%Fe,de=He[E]/Fe|0,D=U,I=E+D;I>E;)L=fe[--D]%Fe,k=fe[D]/Fe|0,T=de*L+k*te,L=te*L+T%Fe*Fe+ge[I]+y,y=(L/Se|0)+(T/Fe|0)+de*k,ge[I--]=L%Se;ge[I]=y}return y?++P:ge.splice(0,1),re(u,ge,P)},M.negated=function(){var u=new V(this);return u.s=-u.s||null,u},M.plus=function(u,h){var y,P=this,E=P.s;if(u=new V(u,h),h=u.s,!E||!h)return new V(NaN);if(E!=h)return u.s=-h,P.minus(u);var I=P.e/c,D=u.e/c,T=P.c,U=u.c;if(!I||!D){if(!T||!U)return new V(E/0);if(!T[0]||!U[0])return U[0]?u:new V(T[0]?P:E*0)}if(I=l(I),D=l(D),T=T.slice(),E=I-D){for(E>0?(D=I,y=U):(E=-E,y=T),y.reverse();E--;y.push(0));y.reverse()}for(E=T.length,h=U.length,E-h<0&&(y=U,U=T,T=y,h=E),E=0;h;)E=(T[--h]=T[h]+U[h]+E)/o|0,T[h]=o===T[h]?0:T[h]%o;return E&&(T=[E].concat(T),++D),re(u,T,D)},M.precision=M.sd=function(u,h){var y,P,E,I=this;if(u!=null&&u!==!!u)return F(u,1,m),h==null?h=ne:F(h,0,8),le(new V(I),u,h);if(!(y=I.c))return null;if(E=y.length-1,P=E*c+1,E=y[E]){for(;E%10==0;E/=10,P--);for(E=y[0];E>=10;E/=10,P++);}return u&&I.e+1>P&&(P=I.e+1),P},M.shiftedBy=function(u){return F(u,-d,d),this.times("1e"+u)},M.squareRoot=M.sqrt=function(){var u,h,y,P,E,I=this,D=I.c,T=I.s,U=I.e,L=Q+4,k=new V("0.5");if(T!==1||!D||!D[0])return new V(!T||T<0&&(!D||D[0])?NaN:D?I:1/0);if(T=Math.sqrt(+X(I)),T==0||T==1/0?(h=A(D),(h.length+U)%2==0&&(h+="0"),T=Math.sqrt(+h),U=l((U+1)/2)-(U<0||U%2),T==1/0?h="5e"+U:(h=T.toExponential(),h=h.slice(0,h.indexOf("e")+1)+U),y=new V(h)):y=new V(T+""),y.c[0]){for(U=y.e,T=U+L,T<3&&(T=0);;)if(E=y,y=k.times(E.plus(q(I,E,L,1))),A(E.c).slice(0,T)===(h=A(y.c)).slice(0,T))if(y.e<U&&--T,h=h.slice(T-3,T+1),h=="9999"||!P&&h=="4999"){if(!P&&(le(E,E.e+Q+2,0),E.times(E).eq(I))){y=E;break}L+=4,T+=4,P=1}else{(!+h||!+h.slice(1)&&h.charAt(0)=="5")&&(le(y,y.e+Q+2,1),u=!y.times(y).eq(I));break}}return le(y,y.e+Q+1,ne,u)},M.toExponential=function(u,h){return u!=null&&(F(u,0,m),u++),_(this,u,h,1)},M.toFixed=function(u,h){return u!=null&&(F(u,0,m),u=u+this.e+1),_(this,u,h)},M.toFormat=function(u,h,y){var P,E=this;if(y==null)u!=null&&h&&typeof h=="object"?(y=h,h=null):u&&typeof u=="object"?(y=u,u=h=null):y=oe;else if(typeof y!="object")throw Error(s+"Argument not an object: "+y);if(P=E.toFixed(u,h),E.c){var I,D=P.split("."),T=+y.groupSize,U=+y.secondaryGroupSize,L=y.groupSeparator||"",k=D[0],J=D[1],te=E.s<0,de=te?k.slice(1):k,ge=de.length;if(U&&(I=T,T=U,U=I,ge-=I),T>0&&ge>0){for(I=ge%T||T,k=de.substr(0,I);I<ge;I+=T)k+=L+de.substr(I,T);U>0&&(k+=L+de.slice(I)),te&&(k="-"+k)}P=J?k+(y.decimalSeparator||"")+((U=+y.fractionGroupSize)?J.replace(new RegExp("\\d{"+U+"}\\B","g"),"$&"+(y.fractionGroupSeparator||"")):J):k}return(y.prefix||"")+P+(y.suffix||"")},M.toFraction=function(u){var h,y,P,E,I,D,T,U,L,k,J,te,de=this,ge=de.c;if(u!=null&&(T=new V(u),!T.isInteger()&&(T.c||T.s!==1)||T.lt(ae)))throw Error(s+"Argument "+(T.isInteger()?"out of range: ":"not an integer: ")+X(T));if(!ge)return new V(de);for(h=new V(ae),L=y=new V(ae),P=U=new V(ae),te=A(ge),I=h.e=te.length-de.e-1,h.c[0]=f[(D=I%c)<0?c+D:D],u=!u||T.comparedTo(h)>0?I>0?h:L:T,D=R,R=1/0,T=new V(te),U.c[0]=0;k=q(T,h,0,1),E=y.plus(k.times(P)),E.comparedTo(u)!=1;)y=P,P=E,L=U.plus(k.times(E=L)),U=E,h=T.minus(k.times(E=h)),T=E;return E=q(u.minus(y),P,0,1),U=U.plus(E.times(L)),y=y.plus(E.times(P)),U.s=L.s=de.s,I=I*2,J=q(L,P,I,ne).minus(de).abs().comparedTo(q(U,y,I,ne).minus(de).abs())<1?[L,P]:[U,y],R=D,J},M.toNumber=function(){return+X(this)},M.toPrecision=function(u,h){return u!=null&&F(u,1,m),_(this,u,h,2)},M.toString=function(u){var h,y=this,P=y.s,E=y.e;return E===null?P?(h="Infinity",P<0&&(h="-"+h)):h="NaN":(u==null?h=E<=w||E>=g?O(A(y.c),E):H(A(y.c),E,"0"):u===10&&W?(y=le(new V(y),Q+E+1,ne),h=H(A(y.c),y.e,"0")):(F(u,2,se.length,"Base"),h=K(H(A(y.c),E,"0"),10,u,P,!0)),P<0&&y.c[0]&&(h="-"+h)),h},M.valueOf=M.toJSON=function(){return X(this)},M._isBigNumber=!0,x!=null&&V.set(x),V}function l(x){var q=x|0;return x>0||x===q?q:q-1}function A(x){for(var q,K,$=1,M=x.length,ae=x[0]+"";$<M;){for(q=x[$++]+"",K=c-q.length;K--;q="0"+q);ae+=q}for(M=ae.length;ae.charCodeAt(--M)===48;);return ae.slice(0,M+1||1)}function v(x,q){var K,$,M=x.c,ae=q.c,Q=x.s,ne=q.s,w=x.e,g=q.e;if(!Q||!ne)return null;if(K=M&&!M[0],$=ae&&!ae[0],K||$)return K?$?0:-ne:Q;if(Q!=ne)return Q;if(K=Q<0,$=w==g,!M||!ae)return $?0:!M^K?1:-1;if(!$)return w>g^K?1:-1;for(ne=(w=M.length)<(g=ae.length)?w:g,Q=0;Q<ne;Q++)if(M[Q]!=ae[Q])return M[Q]>ae[Q]^K?1:-1;return w==g?0:w>g^K?1:-1}function F(x,q,K,$){if(x<q||x>K||x!==i(x))throw Error(s+($||"Argument")+(typeof x=="number"?x<q||x>K?" out of range: ":" not an integer: ":" not a primitive number: ")+String(x))}function C(x){var q=x.c.length-1;return l(x.e/c)==q&&x.c[q]%2!=0}function O(x,q){return(x.length>1?x.charAt(0)+"."+x.slice(1):x)+(q<0?"e":"e+")+q}function H(x,q,K){var $,M;if(q<0){for(M=K+".";++q;M+=K);x=M+x}else if($=x.length,++q>$){for(M=K,q-=$;--q;M+=K);x+=M}else q<$&&(x=x.slice(0,q)+"."+x.slice(q));return x}t=b(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof qa<"u"&&qa.exports?qa.exports=t:(e||(e=typeof self<"u"&&self?self:window),e.BigNumber=t)})(rp)});var ip=ee((EO,np)=>{np.exports=function(t,r,n){var i=new t.Uint8Array(n),s=r.pushInt,a=r.pushInt32,o=r.pushInt32Neg,c=r.pushInt64,d=r.pushInt64Neg,f=r.pushFloat,p=r.pushFloatSingle,m=r.pushFloatDouble,b=r.pushTrue,l=r.pushFalse,A=r.pushUndefined,v=r.pushNull,F=r.pushInfinity,C=r.pushInfinityNeg,O=r.pushNaN,H=r.pushNaNNeg,x=r.pushArrayStart,q=r.pushArrayStartFixed,K=r.pushArrayStartFixed32,$=r.pushArrayStartFixed64,M=r.pushObjectStart,ae=r.pushObjectStartFixed,Q=r.pushObjectStartFixed32,ne=r.pushObjectStartFixed64,w=r.pushByteString,g=r.pushByteStringStart,S=r.pushUtf8String,R=r.pushUtf8StringStart,B=r.pushSimpleUnassigned,j=r.pushTagStart,Y=r.pushTagStart4,oe=r.pushTagStart8,se=r.pushTagUnassigned,W=r.pushBreak,V=t.Math.pow,_=0,Z=0,re=0;function le(N){for(N=N|0,_=0,Z=N;(_|0)<(Z|0)&&(re=rm[i[_]&255](i[_]|0)|0,!((re|0)>0)););return re|0}function X(N){return N=N|0,((_|0)+(N|0)|0)<(Z|0)?0:1}function u(N){return N=N|0,i[N|0]<<8|i[N+1|0]|0}function h(N){return N=N|0,i[N|0]<<24|i[N+1|0]<<16|i[N+2|0]<<8|i[N+3|0]|0}function y(N){return N=N|0,s(N|0),_=_+1|0,0}function P(N){return N=N|0,X(1)|0?1:(s(i[_+1|0]|0),_=_+2|0,0)}function E(N){return N=N|0,X(2)|0?1:(s(u(_+1|0)|0),_=_+3|0,0)}function I(N){return N=N|0,X(4)|0?1:(a(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function D(N){return N=N|0,X(8)|0?1:(c(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function T(N){return N=N|0,s(-1-(N-32|0)|0),_=_+1|0,0}function U(N){return N=N|0,X(1)|0?1:(s(-1-(i[_+1|0]|0)|0),_=_+2|0,0)}function L(N){N=N|0;var Ee=0;return X(2)|0?1:(Ee=u(_+1|0)|0,s(-1-(Ee|0)|0),_=_+3|0,0)}function k(N){return N=N|0,X(4)|0?1:(o(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function J(N){return N=N|0,X(8)|0?1:(d(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function te(N){N=N|0;var Ee=0,Ae=0,Te=0;return Te=N-64|0,X(Te|0)|0?1:(Ee=_+1|0,Ae=(_+1|0)+(Te|0)|0,w(Ee|0,Ae|0),_=Ae|0,0)}function de(N){N=N|0;var Ee=0,Ae=0,Te=0;return X(1)|0||(Te=i[_+1|0]|0,Ee=_+2|0,Ae=(_+2|0)+(Te|0)|0,X(Te+1|0)|0)?1:(w(Ee|0,Ae|0),_=Ae|0,0)}function ge(N){N=N|0;var Ee=0,Ae=0,Te=0;return X(2)|0||(Te=u(_+1|0)|0,Ee=_+3|0,Ae=(_+3|0)+(Te|0)|0,X(Te+2|0)|0)?1:(w(Ee|0,Ae|0),_=Ae|0,0)}function Se(N){N=N|0;var Ee=0,Ae=0,Te=0;return X(4)|0||(Te=h(_+1|0)|0,Ee=_+5|0,Ae=(_+5|0)+(Te|0)|0,X(Te+4|0)|0)?1:(w(Ee|0,Ae|0),_=Ae|0,0)}function Fe(N){return N=N|0,1}function _e(N){return N=N|0,g(),_=_+1|0,0}function fe(N){N=N|0;var Ee=0,Ae=0,Te=0;return Te=N-96|0,X(Te|0)|0?1:(Ee=_+1|0,Ae=(_+1|0)+(Te|0)|0,S(Ee|0,Ae|0),_=Ae|0,0)}function He(N){N=N|0;var Ee=0,Ae=0,Te=0;return X(1)|0||(Te=i[_+1|0]|0,Ee=_+2|0,Ae=(_+2|0)+(Te|0)|0,X(Te+1|0)|0)?1:(S(Ee|0,Ae|0),_=Ae|0,0)}function Lt(N){N=N|0;var Ee=0,Ae=0,Te=0;return X(2)|0||(Te=u(_+1|0)|0,Ee=_+3|0,Ae=(_+3|0)+(Te|0)|0,X(Te+2|0)|0)?1:(S(Ee|0,Ae|0),_=Ae|0,0)}function Ft(N){N=N|0;var Ee=0,Ae=0,Te=0;return X(4)|0||(Te=h(_+1|0)|0,Ee=_+5|0,Ae=(_+5|0)+(Te|0)|0,X(Te+4|0)|0)?1:(S(Ee|0,Ae|0),_=Ae|0,0)}function Vt(N){return N=N|0,1}function Ht(N){return N=N|0,R(),_=_+1|0,0}function Be(N){return N=N|0,q(N-128|0),_=_+1|0,0}function Ot(N){return N=N|0,X(1)|0?1:(q(i[_+1|0]|0),_=_+2|0,0)}function at(N){return N=N|0,X(2)|0?1:(q(u(_+1|0)|0),_=_+3|0,0)}function Ke(N){return N=N|0,X(4)|0?1:(K(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Nc(N){return N=N|0,X(8)|0?1:($(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function Oc(N){return N=N|0,x(),_=_+1|0,0}function $e(N){N=N|0;var Ee=0;return Ee=N-160|0,X(Ee|0)|0?1:(ae(Ee|0),_=_+1|0,0)}function Ec(N){return N=N|0,X(1)|0?1:(ae(i[_+1|0]|0),_=_+2|0,0)}function vc(N){return N=N|0,X(2)|0?1:(ae(u(_+1|0)|0),_=_+3|0,0)}function Rc(N){return N=N|0,X(4)|0?1:(Q(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Ac(N){return N=N|0,X(8)|0?1:(ne(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function Sc(N){return N=N|0,M(),_=_+1|0,0}function cn(N){return N=N|0,j(N-192|0|0),_=_+1|0,0}function $N(N){return N=N|0,j(N|0),_=_+1|0,0}function GN(N){return N=N|0,j(N|0),_=_+1|0,0}function zN(N){return N=N|0,j(N|0),_=_+1|0,0}function WN(N){return N=N|0,j(N|0),_=_+1|0,0}function ft(N){return N=N|0,j(N-192|0|0),_=_+1|0,0}function YN(N){return N=N|0,j(N|0),_=_+1|0,0}function JN(N){return N=N|0,j(N|0),_=_+1|0,0}function ZN(N){return N=N|0,j(N|0),_=_+1|0,0}function Hy(N){return N=N|0,X(1)|0?1:(j(i[_+1|0]|0),_=_+2|0,0)}function Ky(N){return N=N|0,X(2)|0?1:(j(u(_+1|0)|0),_=_+3|0,0)}function $y(N){return N=N|0,X(4)|0?1:(Y(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Gy(N){return N=N|0,X(8)|0?1:(oe(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function nt(N){return N=N|0,B((N|0)-224|0),_=_+1|0,0}function zy(N){return N=N|0,l(),_=_+1|0,0}function Wy(N){return N=N|0,b(),_=_+1|0,0}function Yy(N){return N=N|0,v(),_=_+1|0,0}function Jy(N){return N=N|0,A(),_=_+1|0,0}function Zy(N){return N=N|0,X(1)|0?1:(B(i[_+1|0]|0),_=_+2|0,0)}function Xy(N){N=N|0;var Ee=0,Ae=0,Te=1,na=0,Zi=0,XN=0;return X(2)|0?1:(Ee=i[_+1|0]|0,Ae=i[_+2|0]|0,(Ee|0)&128&&(Te=-1),na=+(((Ee|0)&124)>>2),Zi=+(((Ee|0)&3)<<8|Ae),+na==0?f(+(+Te*5960464477539063e-23*+Zi)):+na==31?+Te==1?+Zi>0?O():F():+Zi>0?H():C():f(+(+Te*V(2,+(+na-25))*+(1024+Zi))),_=_+3|0,0)}function Qy(N){return N=N|0,X(4)|0?1:(p(i[_+1|0]|0,i[_+2|0]|0,i[_+3|0]|0,i[_+4|0]|0),_=_+5|0,0)}function em(N){return N=N|0,X(8)|0?1:(m(i[_+1|0]|0,i[_+2|0]|0,i[_+3|0]|0,i[_+4|0]|0,i[_+5|0]|0,i[_+6|0]|0,i[_+7|0]|0,i[_+8|0]|0),_=_+9|0,0)}function je(N){return N=N|0,1}function tm(N){return N=N|0,W(),_=_+1|0,0}var rm=[y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,P,E,I,D,je,je,je,je,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,U,L,k,J,je,je,je,je,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,de,ge,Se,Fe,je,je,je,_e,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,fe,He,Lt,Ft,Vt,je,je,je,Ht,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Ot,at,Ke,Nc,je,je,je,Oc,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,Ec,vc,Rc,Ac,je,je,je,Sc,cn,cn,cn,cn,cn,cn,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,Hy,Ky,$y,Gy,je,je,je,je,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,zy,Wy,Yy,Jy,Zy,Xy,Qy,em,je,je,je,tm];return{parse:le}}});var us=ee(Zt=>{"use strict";var Tu=cs().BigNumber;Zt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Zt.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};Zt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Zt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Zt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Zt.SHIFT32=Math.pow(2,32);Zt.SHIFT16=Math.pow(2,16);Zt.MAX_SAFE_HIGH=2097151;Zt.NEG_ONE=new Tu(-1);Zt.TEN=new Tu(10);Zt.TWO=new Tu(2);Zt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Ma=ee(ar=>{"use strict";var{Buffer:ab}=oi("buffer"),ap=cs().BigNumber,op=us(),sp=op.SHIFT32,ob=op.SHIFT16,cb=2097151;ar.parseHalf=function(t){var r,n,i;return i=t[0]&128?-1:1,r=(t[0]&124)>>2,n=(t[0]&3)<<8|t[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function ub(e){return e<16?"0"+e.toString(16):e.toString(16)}ar.arrayBufferToBignumber=function(e){let t=e.byteLength,r="";for(let n=0;n<t;n++)r+=ub(e[n]);return new ap(r,16)};ar.buildMap=e=>{let t=new Map,r=Object.keys(e),n=r.length;for(let i=0;i<n;i++)t.set(r[i],e[r[i]]);return t};ar.buildInt32=(e,t)=>e*ob+t;ar.buildInt64=(e,t,r,n)=>{let i=ar.buildInt32(e,t),s=ar.buildInt32(r,n);return i>cb?new ap(i).times(sp).plus(s):i*sp+s};ar.writeHalf=function(t,r){let n=ab.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if((i&8191)!==0)return!1;var s=i>>16&32768;let a=i>>23&255,o=i&8388607;if(a>=113&&a<=142)s+=(a-112<<10)+(o>>13);else if(a>=103&&a<113){if(o&(1<<126-a)-1)return!1;s+=o+8388608>>126-a}else return!1;return t.writeUInt16BE(s,0),!0};ar.keySorter=function(e,t){var r=e[0].byteLength,n=t[0].byteLength;return r>n?1:n>r?-1:e[0].compare(t[0])};ar.isNegativeZero=e=>e===0&&1/e<0;ar.nextPowerOf2=e=>{let t=0;if(e&&!(e&e-1))return e;for(;e!==0;)e>>=1,t+=1;return 1<<t}});var vu=ee((AO,cp)=>{"use strict";var Eu=us(),lb=Eu.MT,ka=Eu.SIMPLE,Nu=Eu.SYMS,Ou=class e{constructor(t){if(typeof t!="number")throw new Error("Invalid Simple type: "+typeof t);if(t<0||t>255||(t|0)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,lb.SIMPLE_FLOAT)}static isSimple(t){return t instanceof e}static decode(t,r){switch(r==null&&(r=!0),t){case ka.FALSE:return!1;case ka.TRUE:return!0;case ka.NULL:return r?null:Nu.NULL;case ka.UNDEFINED:return r?void 0:Nu.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Nu.BREAK;default:return new e(t)}}};cp.exports=Ou});var Au=ee((SO,up)=>{"use strict";var Ru=class e{constructor(t,r,n){if(this.tag=t,this.value=r,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){var r,n;if(n=t?.[this.tag],typeof n!="function"&&(n=e["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(e,this.value)}catch(i){return r=i,this.err=r,this}}};up.exports=Ru});var Bu=ee((BO,dp)=>{"use strict";var{URL:db,URLSearchParams:fb,format:pb}=oi("url"),lp="http://localhost",Su=class extends db{constructor(t="",r=lp){super(t,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}format(){return this.toString()}};dp.exports={URLWithLegacySupport:Su,URLSearchParams:fb,format:pb,defaultBase:lp}});var hp=ee((IO,pp)=>{"use strict";var{URLWithLegacySupport:fp,format:hb}=Bu();pp.exports=(e,t={},r={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new fp(e)}catch{s={}}let a=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new fp(e,hb(a)).toString()}});var Iu=ee((PO,_p)=>{"use strict";var{URLWithLegacySupport:_b,format:yb,URLSearchParams:mb,defaultBase:gb}=Bu(),bb=hp();_p.exports={URL:_b,URLSearchParams:mb,format:yb,relative:bb,defaultBase:gb}});var Pu=ee((FO,mp)=>{"use strict";var{Buffer:Ni}=oi("buffer"),yp=Pc(),wb=cs().BigNumber,xb=ip(),Ct=Ma(),Me=us(),Tb=vu(),Nb=Au(),{URL:Ob}=Iu(),ls=class e{constructor(t){t=t||{},!t.size||t.size<65536?t.size=65536:t.size=Ct.nextPowerOf2(t.size),this._heap=new ArrayBuffer(t.size),this._heap8=new Uint8Array(this._heap),this._buffer=Ni.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>Ct.arrayBufferToBignumber(r),3:r=>Me.NEG_ONE.minus(Ct.arrayBufferToBignumber(r)),4:r=>Me.TEN.pow(r[0]).times(r[1]),5:r=>Me.TWO.pow(r[0]).times(r[1]),32:r=>new Ob(r),35:r=>new RegExp(r)},t.tags),this.parser=xb(global,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var t=this._parents.pop();if(t.length>0)throw new Error(`Missing ${t.length} elements`);switch(t.type){case Me.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case Me.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case Me.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case Me.PARENT.MAP:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(t.ref,t.length));break;case Me.PARENT.OBJECT:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(t.ref,t.length));break;case Me.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===Me.PARENT.TAG&&this._dec()}_dec(){let t=this._currentParent;t.length<0||(t.length--,t.length===0&&this._closeParent())}_push(t,r){let n=this._currentParent;switch(n.values++,n.type){case Me.PARENT.ARRAY:case Me.PARENT.BYTE_STRING:case Me.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case Me.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=Me.PARENT.MAP,n.ref=Ct.buildMap(n.ref)));break;case Me.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case Me.PARENT.TAG:this._ref.push(t),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(t,r,n){this._parents[this._depth]={type:r,length:n,ref:t,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:Me.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,r){let n=this._knownTags[t];return n?n(r):new Nb(t,r)}createMap(t,r){return t}createObject(t,r){return t}createArray(t,r){return t}createByteString(t,r){return Ni.concat(t)}createByteStringFromHeap(t,r){return t===r?Ni.alloc(0):Ni.from(this._heap.slice(t,r))}createInt(t){return t}createInt32(t,r){return Ct.buildInt32(t,r)}createInt64(t,r,n,i){return Ct.buildInt64(t,r,n,i)}createFloat(t){return t}createFloatSingle(t,r,n,i){return yp.read([t,r,n,i],0,!1,23,4)}createFloatDouble(t,r,n,i,s,a,o,c){return yp.read([t,r,n,i,s,a,o,c],0,!1,52,8)}createInt32Neg(t,r){return-1-Ct.buildInt32(t,r)}createInt64Neg(t,r,n,i){let s=Ct.buildInt32(t,r),a=Ct.buildInt32(n,i);return s>Me.MAX_SAFE_HIGH?Me.NEG_ONE.minus(new wb(s).times(Me.SHIFT32).plus(a)):-1-(s*Me.SHIFT32+a)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(t,r){return t.join("")}createUtf8StringFromHeap(t,r){return t===r?"":this._buffer.toString("utf8",t,r)}createSimpleUnassigned(t){return new Tb(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,r){this._push(this.createInt32(t,r))}pushInt64(t,r,n,i){this._push(this.createInt64(t,r,n,i))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,r,n,i){this._push(this.createFloatSingle(t,r,n,i))}pushFloatDouble(t,r,n,i,s,a,o,c){this._push(this.createFloatDouble(t,r,n,i,s,a,o,c))}pushInt32Neg(t,r){this._push(this.createInt32Neg(t,r))}pushInt64Neg(t,r,n,i){this._push(this.createInt64Neg(t,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],Me.PARENT.ARRAY,-1)}pushArrayStartFixed(t){this._createArrayStartFixed(t)}pushArrayStartFixed32(t,r){let n=Ct.buildInt32(t,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(t,r,n,i){let s=Ct.buildInt64(t,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(t){this._createObjectStartFixed(t)}pushObjectStartFixed32(t,r){let n=Ct.buildInt32(t,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(t,r,n,i){let s=Ct.buildInt64(t,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:Me.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(t,r){this._push(this.createByteStringFromHeap(t,r))}pushUtf8StringStart(){this._parents[this._depth]={type:Me.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(t,r){this._push(this.createUtf8StringFromHeap(t,r))}pushSimpleUnassigned(t){this._push(this.createSimpleUnassigned(t))}pushTagStart(t){this._parents[this._depth]={type:Me.PARENT.TAG,length:1,ref:[t]}}pushTagStart4(t,r){this.pushTagStart(Ct.buildInt32(t,r))}pushTagStart8(t,r,n,i){this.pushTagStart(Ct.buildInt64(t,r,n,i))}pushTagUnassigned(t){this._push(this.createTag(t))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(t){if(t===0){this._push(this.createObject({}));return}this._createParent({},Me.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),Me.PARENT.ARRAY,t)}_decode(t){if(t.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(t);let r=this.parser.parse(t.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(r>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(t){return this._decode(t),this._res[0]}decodeAll(t){return this._decode(t),this._res}static decode(t,r){return typeof t=="string"&&(t=Ni.from(t,r||"hex")),new e({size:t.length}).decodeFirst(t)}static decodeAll(t,r){return typeof t=="string"&&(t=Ni.from(t,r||"hex")),new e({size:t.length}).decodeAll(t)}};ls.decodeFirst=ls.decode;mp.exports=ls});var wp=ee((VO,bp)=>{"use strict";var{Buffer:Fu}=oi("buffer"),Eb=Pu(),vb=Ma(),Vu=class e extends Eb{createTag(t,r){return`${t}(${r})`}createInt(t){return super.createInt(t).toString()}createInt32(t,r){return super.createInt32(t,r).toString()}createInt64(t,r,n,i){return super.createInt64(t,r,n,i).toString()}createInt32Neg(t,r){return super.createInt32Neg(t,r).toString()}createInt64Neg(t,r,n,i){return super.createInt64Neg(t,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(t){let r=super.createFloat(t);return vb.isNegativeZero(t)?"-0_1":`${r}_1`}createFloatSingle(t,r,n,i){return`${super.createFloatSingle(t,r,n,i)}_2`}createFloatDouble(t,r,n,i,s,a,o,c){return`${super.createFloatDouble(t,r,n,i,s,a,o,c)}_3`}createByteString(t,r){let n=t.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(t,r){return`h'${Fu.from(super.createByteStringFromHeap(t,r)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(t){return`simple(${t})`}createArray(t,r){let n=super.createArray(t,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(t,r){let n=super.createMap(t),i=Array.from(n.keys()).reduce(gp(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(t,r){let n=super.createObject(t),i=Object.keys(n).reduce(gp(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(t,r){let n=t.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(t,r){return`"${Fu.from(super.createUtf8StringFromHeap(t,r)).toString("utf8")}"`}static diagnose(t,r){return typeof t=="string"&&(t=Fu.from(t,r||"hex")),new e().decodeFirst(t)}};bp.exports=Vu;function gp(e){return(t,r)=>t?`${t}, ${r}: ${e[r]}`:`${r}: ${e[r]}`}});var Ep=ee((UO,Op)=>{"use strict";var{Buffer:Ur}=oi("buffer"),{URL:Rb}=Iu(),Cu=cs().BigNumber,Uu=Ma(),ot=us(),hr=ot.MT,Da=ot.NUMBYTES,xp=ot.SHIFT32,Tp=ot.SYMS,Oi=ot.TAG,Ab=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.TWO,Sb=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.FOUR,Bb=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.EIGHT,Ib=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.TRUE,Pb=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.FALSE,Fb=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.UNDEFINED,Np=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.NULL,Vb=new Cu("0x20000000000000"),Ub=Ur.from("f97e00","hex"),Cb=Ur.from("f9fc00","hex"),qb=Ur.from("f97c00","hex");function Mb(e){return{}.toString.call(e).slice(8,-1)}var qu=class e{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[Rb,this._pushUrl],[Cu,this._pushBigNumber]];let r=t.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(t,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===t){let a=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,a}return this.semanticTypes.push([t,r]),null}push(t){return t&&(this.result[this.offset]=t,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=t.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(t,r,n){return this.result[this.offset]=t,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(t){return this.pushWrite(t,1,1)}_pushUInt16BE(t){return this.pushWrite(t,2,2)}_pushUInt32BE(t){return this.pushWrite(t,3,4)}_pushDoubleBE(t){return this.pushWrite(t,4,8)}_pushNaN(){return this.push(Ub)}_pushInfinity(t){let r=t<0?Cb:qb;return this.push(r)}_pushFloat(t){let r=Ur.allocUnsafe(2);if(Uu.writeHalf(r,t)&&Uu.parseHalf(r)===t)return this._pushUInt8(Ab)&&this.push(r);let n=Ur.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(Sb)&&this.push(n):this._pushUInt8(Bb)&&this._pushDoubleBE(t)}_pushInt(t,r,n){let i=r<<5;return t<24?this._pushUInt8(i|t):t<=255?this._pushUInt8(i|Da.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|Da.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|Da.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Da.EIGHT)&&this._pushUInt32BE(Math.floor(t/xp))&&this._pushUInt32BE(t%xp):r===hr.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,hr.NEG_INT,t):this._pushInt(t,hr.POS_INT)}_pushNumber(t){switch(!1){case t===t:return this._pushNaN(t);case isFinite(t):return this._pushInfinity(t);case t%1!==0:return this._pushIntNum(t);default:return this._pushFloat(t)}}_pushString(t){let r=Ur.byteLength(t,"utf8");return this._pushInt(r,hr.UTF8_STRING)&&this.pushWrite(t,5,r)}_pushBoolean(t){return this._pushUInt8(t?Ib:Pb)}_pushUndefined(t){return this._pushUInt8(Fb)}_pushArray(t,r){let n=r.length;if(!t._pushInt(n,hr.ARRAY))return!1;for(let i=0;i<n;i++)if(!t.pushAny(r[i]))return!1;return!0}_pushTag(t){return this._pushInt(t,hr.TAG)}_pushDate(t,r){return t._pushTag(Oi.DATE_EPOCH)&&t.pushAny(Math.round(r/1e3))}_pushBuffer(t,r){return t._pushInt(r.length,hr.BYTE_STRING)&&t.push(r)}_pushNoFilter(t,r){return t._pushBuffer(t,r.slice())}_pushRegexp(t,r){return t._pushTag(Oi.REGEXP)&&t.pushAny(r.source)}_pushSet(t,r){if(!t._pushInt(r.size,hr.ARRAY))return!1;for(let n of r)if(!t.pushAny(n))return!1;return!0}_pushUrl(t,r){return t._pushTag(Oi.URI)&&t.pushAny(r.format())}_pushBigint(t){let r=Oi.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),r=Oi.NEG_BIGINT);let n=t.toString(16);n.length%2&&(n="0"+n);let i=Ur.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(t,r){if(r.isNaN())return t._pushNaN();if(!r.isFinite())return t._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return t._pushBigint(r);if(!(t._pushTag(Oi.DECIMAL_FRAC)&&t._pushInt(2,hr.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new Cu(10).pow(n));return t._pushIntNum(-n)?i.abs().isLessThan(Vb)?t._pushIntNum(i.toNumber()):t._pushBigint(i):!1}_pushMap(t,r){return t._pushInt(r.size,hr.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(t){if(!t)return this._pushUInt8(Np);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(t instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(t,this,t);var i=t.encodeCBOR;if(typeof i=="function")return i.call(t,this);var s=Object.keys(t),a=s.length;return this._pushInt(a,hr.MAP)?this._pushRawMap(a,s.map(o=>[o,t[o]])):!1}_pushRawMap(t,r){r=r.map(function(i){return i[0]=e.encode(i[0]),i}).sort(Uu.keySorter);for(var n=0;n<t;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(t){return this.pushAny(t)}pushAny(t){var r=Mb(t);switch(r){case"Number":return this._pushNumber(t);case"String":return this._pushString(t);case"Boolean":return this._pushBoolean(t);case"Object":return this._pushObject(t);case"Array":return this._pushArray(this,t);case"Uint8Array":return this._pushBuffer(this,Ur.isBuffer(t)?t:Ur.from(t));case"Null":return this._pushUInt8(Np);case"Undefined":return this._pushUndefined(t);case"Map":return this._pushMap(this,t);case"Set":return this._pushSet(this,t);case"URL":return this._pushUrl(this,t);case"BigNumber":return this._pushBigNumber(this,t);case"Date":return this._pushDate(this,t);case"RegExp":return this._pushRegexp(this,t);case"Symbol":switch(t){case Tp.NULL:return this._pushObject(null);case Tp.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+t.toString())}default:throw new Error("Unknown type: "+typeof t+", "+(t?t.toString():""))}}finalize(){if(this.offset===0)return null;for(var t=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,a=0;a<i;a++)s+=r[a];var o=Ur.allocUnsafe(s),c=0,d=0;for(a=0;a<i;a++){switch(d=r[a],n[a]){case 0:t[a].copy(o,c);break;case 1:o.writeUInt8(t[a],c,!0);break;case 2:o.writeUInt16BE(t[a],c,!0);break;case 3:o.writeUInt32BE(t[a],c,!0);break;case 4:o.writeDoubleBE(t[a],c,!0);break;case 5:o.write(t[a],c,d,"utf8");break;default:throw new Error("unkown method")}c+=d}var f=o;return this._reset(),f}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(t){let r=new e;if(!r.pushAny(t))throw new Error("Failed to encode input");return r.finalize()}};Op.exports=qu});var ja=ee(ct=>{"use strict";ct.Diagnose=wp();ct.Decoder=Pu();ct.Encoder=Ep();ct.Simple=vu();ct.Tagged=Au();ct.decodeAll=ct.Decoder.decodeAll;ct.decodeFirst=ct.Decoder.decodeFirst;ct.diagnose=ct.Diagnose.diagnose;ct.encode=ct.Encoder.encode;ct.decode=ct.Decoder.decode;ct.leveldb={decode:ct.Decoder.decodeAll,encode:ct.Encoder.encode,buffer:!0,name:"cbor"}});var ps=ee(or=>{"use strict";var kb=or&&or.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(or,"__esModule",{value:!0});or.hashOfMap=or.requestIdOf=or.hashValue=or.hash=void 0;var vp=Ti(),Db=kb(ja()),jb=pa(),ds=$t();function mn(e){return(0,ds.uint8ToBuf)(jb.sha256.create().update(new Uint8Array(e)).digest())}or.hash=mn;function fs(e){if(e instanceof Db.default.Tagged)return fs(e.value);if(typeof e=="string")return Rp(e);if(typeof e=="number")return mn((0,vp.lebEncode)(e));if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return mn(e);if(Array.isArray(e)){let t=e.map(fs);return mn((0,ds.concat)(...t))}else{if(e&&typeof e=="object"&&e._isPrincipal)return mn(e.toUint8Array());if(typeof e=="object"&&e!==null&&typeof e.toHash=="function")return fs(e.toHash());if(typeof e=="object")return Mu(e);if(typeof e=="bigint")return mn((0,vp.lebEncode)(e))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${e}`),{value:e})}or.hashValue=fs;var Rp=e=>{let t=new TextEncoder().encode(e);return mn(t)};function Lb(e){return Mu(e)}or.requestIdOf=Lb;function Mu(e){let n=Object.entries(e).filter(([,a])=>a!==void 0).map(([a,o])=>{let c=Rp(a),d=fs(o);return[c,d]}).sort(([a],[o])=>(0,ds.compare)(a,o)),i=(0,ds.concat)(...n.map(a=>(0,ds.concat)(...a)));return mn(i)}or.hashOfMap=Mu});var ju=ee(Cr=>{"use strict";var Hb=Cr&&Cr.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r};Object.defineProperty(Cr,"__esModule",{value:!0});Cr.createIdentityDescriptor=Cr.AnonymousIdentity=Cr.SignIdentity=void 0;var Ap=Ut(),Kb=ps(),Sp=$t(),$b=new TextEncoder().encode(`
17
+ ic-request`),ku=class{getPrincipal(){return this._principal||(this._principal=Ap.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:r}=t,n=Hb(t,["body"]),i=(0,Kb.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,Sp.concat)($b,i))}})}};Cr.SignIdentity=ku;var Du=class{getPrincipal(){return Ap.Principal.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}};Cr.AnonymousIdentity=Du;function Gb(e){return"getPublicKey"in e?{type:"PublicKeyIdentity",publicKey:(0,Sp.toHex)(e.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Cr.createIdentityDescriptor=Gb});var Ku=ee(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});var zb=9007199254740992;function en(e,...t){let r=new Uint8Array(e.byteLength+t.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(e),0);let n=e.byteLength;for(let i of t)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function _r(e,t,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(t-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(e<<5)+t].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function La(e,t){if(t<24)return new Uint8Array([(e<<5)+t]).buffer;{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27;return _r(e,r,t.toString(16))}}function Bp(e){let t=[];for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);n<128?t.push(n):n<2048?t.push(192|n>>6,128|n&63):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|e.charCodeAt(r)&1023,t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return en(new Uint8Array(La(3,e.length)),new Uint8Array(t))}function Wb(e,t){if(e==14277111)return en(new Uint8Array([217,217,247]),t);if(e<24)return en(new Uint8Array([192+e]),t);{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27,n=2**(r-24),i=e.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(a=>parseInt(a,16)));return new Uint8Array(s).buffer}}Ge.tagged=Wb;function hs(e){return new Uint8Array(e).buffer}Ge.raw=hs;function Lu(e){if(isNaN(e))throw new RangeError("Invalid number.");e=Math.min(Math.max(0,e),23);let t=[0+e];return new Uint8Array(t).buffer}Ge.uSmall=Lu;function Ip(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),255),e=e.toString(16),_r(0,24,e)}Ge.u8=Ip;function Pp(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),65535),e=e.toString(16),_r(0,25,e)}Ge.u16=Pp;function Fp(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),4294967295),e=e.toString(16),_r(0,26,e)}Ge.u32=Fp;function Hu(e,t){if(typeof e=="string"&&t==16){if(e.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return _r(0,27,e)}if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),zb),e=e.toString(16),_r(0,27,e)}Ge.u64=Hu;function Vp(e){if(isNaN(e))throw new RangeError("Invalid number.");if(e===0)return Lu(0);e=Math.min(Math.max(0,-e),24)-1;let t=[32+e];return new Uint8Array(t).buffer}Ge.iSmall=Vp;function Up(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),255),e=e.toString(16),_r(1,24,e)}Ge.i8=Up;function Cp(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),65535),e=e.toString(16),_r(1,25,e)}Ge.i16=Cp;function qp(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),4294967295),e=e.toString(16),_r(1,26,e)}Ge.i32=qp;function Mp(e,t){if(typeof e=="string"&&t==16){if(e.startsWith("-")?e=e.slice(1):e="0",e.match(/[^0-9a-fA-F]/)||e.length>16)throw new RangeError("Invalid number.");let r=!1,n=e.split("").reduceRight((i,s)=>{if(r)return s+i;let a=parseInt(s,16)-1;return a>=0?(r=!0,a.toString(16)+i):"f"+i},"");return r?_r(1,27,n):Hu(0)}if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),9007199254740992),e=e.toString(16),_r(1,27,e)}Ge.i64=Mp;function Yb(e){return e>=0?e<24?Lu(e):e<=255?Ip(e):e<=65535?Pp(e):e<=4294967295?Fp(e):Hu(e):e>=-24?Vp(e):e>=-255?Up(e):e>=-65535?Cp(e):e>=-4294967295?qp(e):Mp(e)}Ge.number=Yb;function Jb(e){return en(La(2,e.byteLength),e)}Ge.bytes=Jb;function Zb(e){return Bp(e)}Ge.string=Zb;function Xb(e){return en(La(4,e.length),...e)}Ge.array=Xb;function Qb(e,t=!1){e instanceof Map||(e=new Map(Object.entries(e)));let r=Array.from(e.entries());return t&&(r=r.sort(([n],[i])=>n.localeCompare(i))),en(La(5,e.size),...r.map(([n,i])=>en(Bp(n),i)))}Ge.map=Qb;function e1(e){let t=new Float32Array([e]);return en(new Uint8Array([250]),new Uint8Array(t.buffer))}Ge.singleFloat=e1;function t1(e){let t=new Float64Array([e]);return en(new Uint8Array([251]),new Uint8Array(t.buffer))}Ge.doubleFloat=t1;function r1(e){return e?kp():Dp()}Ge.bool=r1;function kp(){return hs(new Uint8Array([245]))}Ge.true_=kp;function Dp(){return hs(new Uint8Array([244]))}Ge.false_=Dp;function n1(){return hs(new Uint8Array([246]))}Ge.null_=n1;function i1(){return hs(new Uint8Array([247]))}Ge.undefined_=i1});var jp=ee(gn=>{"use strict";var s1=gn&&gn.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(gn,"__esModule",{value:!0});var yr=s1(Ku()),a1=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Ha=class{constructor(t,r=!1){this._serializer=t,this._stable=r,this.name="jsonDefault",this.priority=-100}match(t){return["undefined","boolean","number","string","object"].indexOf(typeof t)!=-1}encode(t){switch(typeof t){case"undefined":return yr.undefined_();case"boolean":return yr.bool(t);case"number":return Math.floor(t)===t?yr.number(t):yr.doubleFloat(t);case"string":return yr.string(t);case"object":if(t===null)return yr.null_();if(Array.isArray(t))return yr.array(t.map(r=>this._serializer.serializeValue(r)));if(a1.find(r=>t instanceof r))return yr.bytes(t.buffer);if(Object.getOwnPropertyNames(t).indexOf("toJSON")!==-1)return this.encode(t.toJSON());if(t instanceof Map){let r=new Map;for(let[n,i]of t.entries())r.set(n,this._serializer.serializeValue(i));return yr.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(t))r.set(n,this._serializer.serializeValue(i));return yr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};gn.JsonDefaultCborEncoder=Ha;var Ka=class{constructor(){this.name="cborEncoder",this.priority=-90}match(t){return typeof t=="object"&&typeof t.toCBOR=="function"}encode(t){return t.toCBOR()}};gn.ToCborEncoder=Ka;var $a=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let r=new this;return r.addEncoder(new Ha(r,t)),r.addEncoder(new Ka),r}removeEncoder(t){for(let r of this._encoders.values())r.name==t&&this._encoders.delete(r)}addEncoder(t){this._encoders.add(t)}getEncoderFor(t){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(t)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(t){return this.getEncoderFor(t).encode(t)}serialize(t){return this.serializeValue(t)}};gn.CborSerializer=$a;var $u=class extends $a{serialize(t){return yr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};gn.SelfDescribeCborSerializer=$u});var _s=ee(Ln=>{"use strict";function o1(e){for(var t in e)Ln.hasOwnProperty(t)||(Ln[t]=e[t])}var c1=Ln&&Ln.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(Ln,"__esModule",{value:!0});o1(jp());var u1=c1(Ku());Ln.value=u1});var ys=ee(gt=>{"use strict";var l1=gt&&gt.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),d1=gt&&gt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),f1=gt&&gt.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&l1(t,e,r);return d1(t,e),t},p1=gt&&gt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(gt,"__esModule",{value:!0});gt.decode=gt.encode=gt.CborTag=void 0;var h1=p1(ja()),Ei=f1(_s()),_1=_s(),Ga=$t(),Gu=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return Ei.value.bytes(t.toUint8Array())}},zu=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return Ei.value.bytes(new Uint8Array(t))}},Wu=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?Ei.value.tagged(2,Ei.value.bytes((0,Ga.fromHex)(t.toString(16)))):Ei.value.tagged(3,Ei.value.bytes((0,Ga.fromHex)((BigInt("-1")*t).toString(16))))}},za=_1.SelfDescribeCborSerializer.withDefaultEncoders(!0);za.addEncoder(new Gu);za.addEncoder(new zu);za.addEncoder(new Wu);var Hp;(function(e){e[e.Uint64LittleEndian=71]="Uint64LittleEndian",e[e.Semantic=55799]="Semantic"})(Hp=gt.CborTag||(gt.CborTag={}));function y1(e){return za.serialize(e)}gt.encode=y1;function Lp(e){let t=e.byteLength,r=BigInt(0);for(let n=0;n<t;n++)r=r*BigInt(256)+BigInt(e[n]);return r}var Yu=class extends h1.default.Decoder{createByteString(t){return(0,Ga.concat)(...t)}createByteStringFromHeap(t,r){return t===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(t,r))}};function m1(e){let t=new Uint8Array(e),r=new Yu({size:t.byteLength,tags:{2:n=>Lp(n),3:n=>-Lp(n),[Hp.Semantic]:n=>n}});try{return r.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,Ga.toHex)(t)}`)}}gt.decode=m1});var Ju=ee(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});Wa.randomNumber=void 0;var g1=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let e=new Uint32Array(1);return window.crypto.getRandomValues(e),e[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};Wa.randomNumber=g1});var ms=ee(Hn=>{"use strict";Object.defineProperty(Hn,"__esModule",{value:!0});Hn.makeNonce=Hn.SubmitRequestType=void 0;var Ya=Ju(),b1;(function(e){e.Call="call"})(b1=Hn.SubmitRequestType||(Hn.SubmitRequestType={}));function w1(){let e=new ArrayBuffer(16),t=new DataView(e),r=(0,Ya.randomNumber)(),n=(0,Ya.randomNumber)(),i=(0,Ya.randomNumber)(),s=(0,Ya.randomNumber)();return t.setUint32(0,r),t.setUint32(4,n),t.setUint32(8,i),t.setUint32(12,s),e}Hn.makeNonce=w1});var Za=ee(Rt=>{"use strict";var x1=Rt&&Rt.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),T1=Rt&&Rt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),N1=Rt&&Rt.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&x1(t,e,r);return T1(t,e),t};Object.defineProperty(Rt,"__esModule",{value:!0});Rt.httpHeadersTransform=Rt.makeExpiryTransform=Rt.makeNonceTransform=Rt.Expiry=void 0;var O1=Ti(),E1=N1(_s()),v1=ms(),Kp=BigInt(1e6),R1=60*1e3,Ja=class{constructor(t){if(t<90*1e3){let o=BigInt(Date.now()+t)*Kp/BigInt(1e9);this._value=o*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+t-R1))*Kp/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return E1.value.u64(this._value.toString(16),16)}toHash(){return(0,O1.lebEncode)(this._value)}};Rt.Expiry=Ja;function A1(e=v1.makeNonce){return async t=>{let r=t.request.headers;t.request.headers=r,t.endpoint==="call"&&(t.body.nonce=e())}}Rt.makeNonceTransform=A1;function S1(e){return async t=>{t.body.ingress_expiry=new Ja(e)}}Rt.makeExpiryTransform=S1;function B1(e){let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t}Rt.httpHeadersTransform=B1});var Qa=ee(qr=>{"use strict";Object.defineProperty(qr,"__esModule",{value:!0});qr.AgentReadStateError=qr.AgentQueryError=qr.AgentCallError=qr.AgentHTTPResponseError=void 0;var Xa=_i(),Zu=class extends Xa.AgentError{constructor(t,r){super(t),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};qr.AgentHTTPResponseError=Zu;var Xu=class extends Xa.AgentError{constructor(t,r,n,i,s,a){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=a,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}};qr.AgentCallError=Xu;var Qu=class extends Xa.AgentError{constructor(t,r,n,i,s,a){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=a,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}};qr.AgentQueryError=Qu;var el=class extends Xa.AgentError{constructor(t,r,n,i,s,a){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=a,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};qr.AgentReadStateError=el});var Xt=ee(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.notImplemented=Ve.bitMask=void 0;Ve.isBytes=to;Ve.abytes=ro;Ve.abool=P1;Ve.bytesToHex=il;Ve.numberToHexUnpadded=zp;Ve.hexToNumber=sl;Ve.hexToBytes=no;Ve.bytesToNumberBE=V1;Ve.bytesToNumberLE=U1;Ve.numberToBytesBE=Wp;Ve.numberToBytesLE=C1;Ve.numberToVarBytesBE=q1;Ve.ensureBytes=M1;Ve.concatBytes=Yp;Ve.equalBytes=k1;Ve.utf8ToBytes=D1;Ve.inRange=Jp;Ve.aInRange=j1;Ve.bitLen=L1;Ve.bitGet=H1;Ve.bitSet=K1;Ve.createHmacDrbg=G1;Ve.validateObject=W1;Ve.memoized=J1;var nl=BigInt(0),eo=BigInt(1),I1=BigInt(2);function to(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function ro(e){if(!to(e))throw new Error("Uint8Array expected")}function P1(e,t){if(typeof t!="boolean")throw new Error(`${e} must be valid boolean, got "${t}".`)}var F1=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function il(e){ro(e);let t="";for(let r=0;r<e.length;r++)t+=F1[e[r]];return t}function zp(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function sl(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}var tn={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function $p(e){if(e>=tn._0&&e<=tn._9)return e-tn._0;if(e>=tn._A&&e<=tn._F)return e-(tn._A-10);if(e>=tn._a&&e<=tn._f)return e-(tn._a-10)}function no(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let a=$p(e.charCodeAt(s)),o=$p(e.charCodeAt(s+1));if(a===void 0||o===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=a*16+o}return n}function V1(e){return sl(il(e))}function U1(e){return ro(e),sl(il(Uint8Array.from(e).reverse()))}function Wp(e,t){return no(e.toString(16).padStart(t*2,"0"))}function C1(e,t){return Wp(e,t).reverse()}function q1(e){return no(zp(e))}function M1(e,t,r){let n;if(typeof t=="string")try{n=no(t)}catch(s){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`)}else if(to(t))n=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${e} expected ${r} bytes, got ${i}`);return n}function Yp(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];ro(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let s=e[n];r.set(s,i),i+=s.length}return r}function k1(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function D1(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}var tl=e=>typeof e=="bigint"&&nl<=e;function Jp(e,t,r){return tl(e)&&tl(t)&&tl(r)&&t<=e&&e<r}function j1(e,t,r,n){if(!Jp(t,r,n))throw new Error(`expected valid ${e}: ${r} <= n < ${n}, got ${typeof t} ${t}`)}function L1(e){let t;for(t=0;e>nl;e>>=eo,t+=1);return t}function H1(e,t){return e>>BigInt(t)&eo}function K1(e,t,r){return e|(r?eo:nl)<<BigInt(t)}var $1=e=>(I1<<BigInt(e-1))-eo;Ve.bitMask=$1;var rl=e=>new Uint8Array(e),Gp=e=>Uint8Array.from(e);function G1(e,t,r){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=rl(e),i=rl(e),s=0,a=()=>{n.fill(1),i.fill(0),s=0},o=(...p)=>r(i,n,...p),c=(p=rl())=>{i=o(Gp([0]),p),n=o(),p.length!==0&&(i=o(Gp([1]),p),n=o())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let p=0,m=[];for(;p<t;){n=o();let b=n.slice();m.push(b),p+=n.length}return Yp(...m)};return(p,m)=>{a(),c(p);let b;for(;!(b=m(d()));)c();return a(),b}}var z1={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||to(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function W1(e,t,r={}){let n=(i,s,a)=>{let o=z1[s];if(typeof o!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=e[i];if(!(a&&c===void 0)&&!o(c,e))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(t))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return e}var Y1=()=>{throw new Error("not implemented")};Ve.notImplemented=Y1;function J1(e){let t=new WeakMap;return(r,...n)=>{let i=t.get(r);if(i!==void 0)return i;let s=e(r,...n);return t.set(r,s),s}}});var Mr=ee(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.isNegativeLE=void 0;Ye.mod=Qt;Ye.pow=Qp;Ye.pow2=ew;Ye.invert=io;Ye.tonelliShanks=e0;Ye.FpSqrt=t0;Ye.validateField=nw;Ye.FpPow=r0;Ye.FpInvertBatch=n0;Ye.FpDiv=iw;Ye.FpLegendre=i0;Ye.FpIsSquare=sw;Ye.nLength=ol;Ye.Field=aw;Ye.FpSqrtOdd=ow;Ye.FpSqrtEven=cw;Ye.hashToPrivateScalar=uw;Ye.getFieldBytesLength=cl;Ye.getMinHashLength=s0;Ye.mapHashToField=lw;var er=Xt(),ut=BigInt(0),Le=BigInt(1),bn=BigInt(2),Z1=BigInt(3),al=BigInt(4),Zp=BigInt(5),Xp=BigInt(8),X1=BigInt(9),Q1=BigInt(16);function Qt(e,t){let r=e%t;return r>=ut?r:t+r}function Qp(e,t,r){if(r<=ut||t<ut)throw new Error("Expected power/modulo > 0");if(r===Le)return ut;let n=Le;for(;t>ut;)t&Le&&(n=n*e%r),e=e*e%r,t>>=Le;return n}function ew(e,t,r){let n=e;for(;t-- >ut;)n*=n,n%=r;return n}function io(e,t){if(e===ut||t<=ut)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=Qt(e,t),n=t,i=ut,s=Le,a=Le,o=ut;for(;r!==ut;){let d=n/r,f=n%r,p=i-a*d,m=s-o*d;n=r,r=f,i=a,s=o,a=p,o=m}if(n!==Le)throw new Error("invert: does not exist");return Qt(i,t)}function e0(e){let t=(e-Le)/bn,r,n,i;for(r=e-Le,n=0;r%bn===ut;r/=bn,n++);for(i=bn;i<e&&Qp(i,t,e)!==e-Le;i++);if(n===1){let a=(e+Le)/al;return function(c,d){let f=c.pow(d,a);if(!c.eql(c.sqr(f),d))throw new Error("Cannot find square root");return f}}let s=(r+Le)/bn;return function(o,c){if(o.pow(c,t)===o.neg(o.ONE))throw new Error("Cannot find square root");let d=n,f=o.pow(o.mul(o.ONE,i),r),p=o.pow(c,s),m=o.pow(c,r);for(;!o.eql(m,o.ONE);){if(o.eql(m,o.ZERO))return o.ZERO;let b=1;for(let A=o.sqr(m);b<d&&!o.eql(A,o.ONE);b++)A=o.sqr(A);let l=o.pow(f,Le<<BigInt(d-b-1));f=o.sqr(l),p=o.mul(p,l),m=o.mul(m,f),d=b}return p}}function t0(e){if(e%al===Z1){let t=(e+Le)/al;return function(n,i){let s=n.pow(i,t);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(e%Xp===Zp){let t=(e-Zp)/Xp;return function(n,i){let s=n.mul(i,bn),a=n.pow(s,t),o=n.mul(i,a),c=n.mul(n.mul(o,bn),a),d=n.mul(o,n.sub(c,n.ONE));if(!n.eql(n.sqr(d),i))throw new Error("Cannot find square root");return d}}return e%Q1,e0(e)}var tw=(e,t)=>(Qt(e,t)&Le)===Le;Ye.isNegativeLE=tw;var rw=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function nw(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=rw.reduce((n,i)=>(n[i]="function",n),t);return(0,er.validateObject)(e,r)}function r0(e,t,r){if(r<ut)throw new Error("Expected power > 0");if(r===ut)return e.ONE;if(r===Le)return t;let n=e.ONE,i=t;for(;r>ut;)r&Le&&(n=e.mul(n,i)),i=e.sqr(i),r>>=Le;return n}function n0(e,t){let r=new Array(t.length),n=t.reduce((s,a,o)=>e.is0(a)?s:(r[o]=s,e.mul(s,a)),e.ONE),i=e.inv(n);return t.reduceRight((s,a,o)=>e.is0(a)?s:(r[o]=e.mul(s,r[o]),e.mul(s,a)),i),r}function iw(e,t,r){return e.mul(t,typeof r=="bigint"?io(r,e.ORDER):e.inv(r))}function i0(e){let t=(e-Le)/bn;return(r,n)=>r.pow(n,t)}function sw(e){let t=i0(e.ORDER);return r=>{let n=t(e,r);return e.eql(n,e.ZERO)||e.eql(n,e.ONE)}}function ol(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function aw(e,t,r=!1,n={}){if(e<=ut)throw new Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:s}=ol(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let a=t0(e),o=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:(0,er.bitMask)(i),ZERO:ut,ONE:Le,create:c=>Qt(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ut<=c&&c<e},is0:c=>c===ut,isOdd:c=>(c&Le)===Le,neg:c=>Qt(-c,e),eql:(c,d)=>c===d,sqr:c=>Qt(c*c,e),add:(c,d)=>Qt(c+d,e),sub:(c,d)=>Qt(c-d,e),mul:(c,d)=>Qt(c*d,e),pow:(c,d)=>r0(o,c,d),div:(c,d)=>Qt(c*io(d,e),e),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>io(c,e),sqrt:n.sqrt||(c=>a(o,c)),invertBatch:c=>n0(o,c),cmov:(c,d,f)=>f?d:c,toBytes:c=>r?(0,er.numberToBytesLE)(c,s):(0,er.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,er.bytesToNumberLE)(c):(0,er.bytesToNumberBE)(c)}});return Object.freeze(o)}function ow(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");let r=e.sqrt(t);return e.isOdd(r)?r:e.neg(r)}function cw(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");let r=e.sqrt(t);return e.isOdd(r)?e.neg(r):r}function uw(e,t,r=!1){e=(0,er.ensureBytes)("privateHash",e);let n=e.length,i=ol(t).nByteLength+8;if(i<24||n<i||n>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);let s=r?(0,er.bytesToNumberLE)(e):(0,er.bytesToNumberBE)(e);return Qt(s,t-Le)+Le}function cl(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function s0(e){let t=cl(e);return t+Math.ceil(t/2)}function lw(e,t,r=!1){let n=e.length,i=cl(t),s=s0(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let a=r?(0,er.bytesToNumberBE)(e):(0,er.bytesToNumberLE)(e),o=Qt(a,t-Le)+Le;return r?(0,er.numberToBytesLE)(o,i):(0,er.numberToBytesBE)(o,i)}});var so=ee(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.expand_message_xmd=a0;Kn.expand_message_xof=o0;Kn.hash_to_field=ul;Kn.isogenyMap=hw;Kn.createHasher=_w;var dw=Mr(),At=Xt(),fw=At.bytesToNumberBE;function wn(e,t){if(gs(e),gs(t),e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function pw(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function gs(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function a0(e,t,r,n){(0,At.abytes)(e),(0,At.abytes)(t),gs(r),t.length>255&&(t=n((0,At.concatBytes)((0,At.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:s}=n,a=Math.ceil(r/i);if(r>65535||a>255)throw new Error("expand_message_xmd: invalid lenInBytes");let o=(0,At.concatBytes)(t,wn(t.length,1)),c=wn(0,s),d=wn(r,2),f=new Array(a),p=n((0,At.concatBytes)(c,e,d,wn(0,1),o));f[0]=n((0,At.concatBytes)(p,wn(1,1),o));for(let b=1;b<=a;b++){let l=[pw(p,f[b-1]),wn(b+1,1),o];f[b]=n((0,At.concatBytes)(...l))}return(0,At.concatBytes)(...f).slice(0,r)}function o0(e,t,r,n,i){if((0,At.abytes)(e),(0,At.abytes)(t),gs(r),t.length>255){let s=Math.ceil(2*n/8);t=i.create({dkLen:s}).update((0,At.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update(wn(r,2)).update(t).update(wn(t.length,1)).digest()}function ul(e,t,r){(0,At.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:a,expand:o,DST:c}=r;(0,At.abytes)(e),gs(t);let d=typeof c=="string"?(0,At.utf8ToBytes)(c):c,f=n.toString(2).length,p=Math.ceil((f+i)/8),m=t*s*p,b;if(o==="xmd")b=a0(e,d,m,a);else if(o==="xof")b=o0(e,d,m,i,a);else if(o==="_internal_pass")b=e;else throw new Error('expand must be "xmd" or "xof"');let l=new Array(t);for(let A=0;A<t;A++){let v=new Array(s);for(let F=0;F<s;F++){let C=p*(F+A*s),O=b.subarray(C,C+p);v[F]=(0,dw.mod)(fw(O),n)}l[A]=v}return l}function hw(e,t){let r=t.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,a,o,c]=r.map(d=>d.reduce((f,p)=>e.add(e.mul(f,n),p)));return n=e.div(s,a),i=e.mul(i,e.div(o,c)),{x:n,y:i}}}function _w(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=ul(n,2,{...r,DST:r.DST,...i}),a=e.fromAffine(t(s[0])),o=e.fromAffine(t(s[1])),c=a.add(o).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=ul(n,1,{...r,DST:r.encodeDST,...i}),a=e.fromAffine(t(s[0])).clearCofactor();return a.assertValidity(),a},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=e.fromAffine(t(n)).clearCofactor();return i.assertValidity(),i}}}});var fl=ee(bs=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});bs.wNAF=mw;bs.pippenger=gw;bs.validateBasic=bw;var c0=Mr(),l0=Xt(),yw=BigInt(0),ll=BigInt(1),dl=new WeakMap,u0=new WeakMap;function mw(e,t){let r=(s,a)=>{let o=a.negate();return s?o:a},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},i=s=>{n(s);let a=Math.ceil(t/s)+1,o=2**(s-1);return{windows:a,windowSize:o}};return{constTimeNegate:r,unsafeLadder(s,a){let o=e.ZERO,c=s;for(;a>yw;)a&ll&&(o=o.add(c)),c=c.double(),a>>=ll;return o},precomputeWindow(s,a){let{windows:o,windowSize:c}=i(a),d=[],f=s,p=f;for(let m=0;m<o;m++){p=f,d.push(p);for(let b=1;b<c;b++)p=p.add(f),d.push(p);f=p.double()}return d},wNAF(s,a,o){let{windows:c,windowSize:d}=i(s),f=e.ZERO,p=e.BASE,m=BigInt(2**s-1),b=2**s,l=BigInt(s);for(let A=0;A<c;A++){let v=A*d,F=Number(o&m);o>>=l,F>d&&(F-=b,o+=ll);let C=v,O=v+Math.abs(F)-1,H=A%2!==0,x=F<0;F===0?p=p.add(r(H,a[C])):f=f.add(r(x,a[O]))}return{p:f,f:p}},wNAFCached(s,a,o){let c=u0.get(s)||1,d=dl.get(s);return d||(d=this.precomputeWindow(s,c),c!==1&&dl.set(s,o(d))),this.wNAF(c,d,a)},setWindowSize(s,a){n(a),u0.set(s,a),dl.delete(s)}}}function gw(e,t,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((f,p)=>{if(!t.isValid(f))throw new Error(`wrong scalar at index ${p}`)}),r.forEach((f,p)=>{if(!(f instanceof e))throw new Error(`wrong point at index ${p}`)});let i=(0,l0.bitLen)(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<<s)-1,o=new Array(a+1).fill(e.ZERO),c=Math.floor((t.BITS-1)/s)*s,d=e.ZERO;for(let f=c;f>=0;f-=s){o.fill(e.ZERO);for(let m=0;m<n.length;m++){let b=n[m],l=Number(b>>BigInt(f)&BigInt(a));o[l]=o[l].add(r[m])}let p=e.ZERO;for(let m=o.length-1,b=e.ZERO;m>0;m--)b=b.add(o[m]),p=p.add(b);if(d=d.add(p),f!==0)for(let m=0;m<s;m++)d=d.double()}return d}function bw(e){return(0,c0.validateField)(e.Fp),(0,l0.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,c0.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}});var pl=ee(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.DER=void 0;wt.weierstrassPoints=p0;wt.weierstrass=Ow;wt.SWUFpSqrtRatio=h0;wt.mapToCurveSimpleSWU=Ew;var ao=fl(),$n=Mr(),ve=Xt(),bt=Xt();function d0(e){e.lowS!==void 0&&(0,bt.abool)("lowS",e.lowS),e.prehash!==void 0&&(0,bt.abool)("prehash",e.prehash)}function ww(e){let t=(0,ao.validateBasic)(e);ve.validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=t;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:xw,hexToBytes:Tw}=ve;wt.DER={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(e,t)=>{let{Err:r}=wt.DER;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=ve.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?ve.numberToHexUnpadded(i.length/2|128):"";return`${ve.numberToHexUnpadded(e)}${s}${i}${t}`},decode(e,t){let{Err:r}=wt.DER,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],s=!!(i&128),a=0;if(!s)a=i;else{let c=i&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let d=t.subarray(n,n+c);if(d.length!==c)throw new r("tlv.decode: length bytes not complete");if(d[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of d)a=a<<8|f;if(n+=c,a<128)throw new r("tlv.decode(long): not minimal encoding")}let o=t.subarray(n,n+a);if(o.length!==a)throw new r("tlv.decode: wrong value length");return{v:o,l:t.subarray(n+a)}}},_int:{encode(e){let{Err:t}=wt.DER;if(e<mr)throw new t("integer: negative integers are not allowed");let r=ve.numberToHexUnpadded(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected assertion");return r},decode(e){let{Err:t}=wt.DER;if(e[0]&128)throw new t("Invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return xw(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=wt.DER,i=typeof e=="string"?Tw(e):e;ve.abytes(i);let{v:s,l:a}=n.decode(48,i);if(a.length)throw new t("Invalid signature: left bytes after parsing");let{v:o,l:c}=n.decode(2,s),{v:d,l:f}=n.decode(2,c);if(f.length)throw new t("Invalid signature: left bytes after parsing");return{r:r.decode(o),s:r.decode(d)}},hexFromSig(e){let{_tlv:t,_int:r}=wt.DER,n=`${t.encode(2,r.encode(e.r))}${t.encode(2,r.encode(e.s))}`;return t.encode(48,n)}};var mr=BigInt(0),ke=BigInt(1),xn=BigInt(2),oo=BigInt(3),f0=BigInt(4);function p0(e){let t=ww(e),{Fp:r}=t,n=$n.Field(t.n,t.nBitLength),i=t.toBytes||((A,v,F)=>{let C=v.toAffine();return ve.concatBytes(Uint8Array.from([4]),r.toBytes(C.x),r.toBytes(C.y))}),s=t.fromBytes||(A=>{let v=A.subarray(1),F=r.fromBytes(v.subarray(0,r.BYTES)),C=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x:F,y:C}});function a(A){let{a:v,b:F}=t,C=r.sqr(A),O=r.mul(C,A);return r.add(r.add(O,r.mul(A,v)),F)}if(!r.eql(r.sqr(t.Gy),a(t.Gx)))throw new Error("bad generator point: equation left != right");function o(A){return ve.inRange(A,ke,t.n)}function c(A){let{allowedPrivateKeyLengths:v,nByteLength:F,wrapPrivateKey:C,n:O}=t;if(v&&typeof A!="bigint"){if(ve.isBytes(A)&&(A=ve.bytesToHex(A)),typeof A!="string"||!v.includes(A.length))throw new Error("Invalid key");A=A.padStart(F*2,"0")}let H;try{H=typeof A=="bigint"?A:ve.bytesToNumberBE((0,bt.ensureBytes)("private key",A,F))}catch{throw new Error(`private key must be ${F} bytes, hex or bigint, not ${typeof A}`)}return C&&(H=$n.mod(H,O)),ve.aInRange("private key",H,ke,O),H}function d(A){if(!(A instanceof m))throw new Error("ProjectivePoint expected")}let f=(0,bt.memoized)((A,v)=>{let{px:F,py:C,pz:O}=A;if(r.eql(O,r.ONE))return{x:F,y:C};let H=A.is0();v==null&&(v=H?r.ONE:r.inv(O));let x=r.mul(F,v),q=r.mul(C,v),K=r.mul(O,v);if(H)return{x:r.ZERO,y:r.ZERO};if(!r.eql(K,r.ONE))throw new Error("invZ was invalid");return{x,y:q}}),p=(0,bt.memoized)(A=>{if(A.is0()){if(t.allowInfinityPoint&&!r.is0(A.py))return;throw new Error("bad point: ZERO")}let{x:v,y:F}=A.toAffine();if(!r.isValid(v)||!r.isValid(F))throw new Error("bad point: x or y not FE");let C=r.sqr(F),O=a(v);if(!r.eql(C,O))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(v,F,C){if(this.px=v,this.py=F,this.pz=C,v==null||!r.isValid(v))throw new Error("x required");if(F==null||!r.isValid(F))throw new Error("y required");if(C==null||!r.isValid(C))throw new Error("z required");Object.freeze(this)}static fromAffine(v){let{x:F,y:C}=v||{};if(!v||!r.isValid(F)||!r.isValid(C))throw new Error("invalid affine point");if(v instanceof m)throw new Error("projective point not allowed");let O=H=>r.eql(H,r.ZERO);return O(F)&&O(C)?m.ZERO:new m(F,C,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){let F=r.invertBatch(v.map(C=>C.pz));return v.map((C,O)=>C.toAffine(F[O])).map(m.fromAffine)}static fromHex(v){let F=m.fromAffine(s((0,bt.ensureBytes)("pointHex",v)));return F.assertValidity(),F}static fromPrivateKey(v){return m.BASE.multiply(c(v))}static msm(v,F){return(0,ao.pippenger)(m,n,v,F)}_setWindowSize(v){l.setWindowSize(this,v)}assertValidity(){p(this)}hasEvenY(){let{y:v}=this.toAffine();if(r.isOdd)return!r.isOdd(v);throw new Error("Field doesn't support isOdd")}equals(v){d(v);let{px:F,py:C,pz:O}=this,{px:H,py:x,pz:q}=v,K=r.eql(r.mul(F,q),r.mul(H,O)),$=r.eql(r.mul(C,q),r.mul(x,O));return K&&$}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:v,b:F}=t,C=r.mul(F,oo),{px:O,py:H,pz:x}=this,q=r.ZERO,K=r.ZERO,$=r.ZERO,M=r.mul(O,O),ae=r.mul(H,H),Q=r.mul(x,x),ne=r.mul(O,H);return ne=r.add(ne,ne),$=r.mul(O,x),$=r.add($,$),q=r.mul(v,$),K=r.mul(C,Q),K=r.add(q,K),q=r.sub(ae,K),K=r.add(ae,K),K=r.mul(q,K),q=r.mul(ne,q),$=r.mul(C,$),Q=r.mul(v,Q),ne=r.sub(M,Q),ne=r.mul(v,ne),ne=r.add(ne,$),$=r.add(M,M),M=r.add($,M),M=r.add(M,Q),M=r.mul(M,ne),K=r.add(K,M),Q=r.mul(H,x),Q=r.add(Q,Q),M=r.mul(Q,ne),q=r.sub(q,M),$=r.mul(Q,ae),$=r.add($,$),$=r.add($,$),new m(q,K,$)}add(v){d(v);let{px:F,py:C,pz:O}=this,{px:H,py:x,pz:q}=v,K=r.ZERO,$=r.ZERO,M=r.ZERO,ae=t.a,Q=r.mul(t.b,oo),ne=r.mul(F,H),w=r.mul(C,x),g=r.mul(O,q),S=r.add(F,C),R=r.add(H,x);S=r.mul(S,R),R=r.add(ne,w),S=r.sub(S,R),R=r.add(F,O);let B=r.add(H,q);return R=r.mul(R,B),B=r.add(ne,g),R=r.sub(R,B),B=r.add(C,O),K=r.add(x,q),B=r.mul(B,K),K=r.add(w,g),B=r.sub(B,K),M=r.mul(ae,R),K=r.mul(Q,g),M=r.add(K,M),K=r.sub(w,M),M=r.add(w,M),$=r.mul(K,M),w=r.add(ne,ne),w=r.add(w,ne),g=r.mul(ae,g),R=r.mul(Q,R),w=r.add(w,g),g=r.sub(ne,g),g=r.mul(ae,g),R=r.add(R,g),ne=r.mul(w,R),$=r.add($,ne),ne=r.mul(B,R),K=r.mul(S,K),K=r.sub(K,ne),ne=r.mul(S,w),M=r.mul(B,M),M=r.add(M,ne),new m(K,$,M)}subtract(v){return this.add(v.negate())}is0(){return this.equals(m.ZERO)}wNAF(v){return l.wNAFCached(this,v,m.normalizeZ)}multiplyUnsafe(v){ve.aInRange("scalar",v,mr,t.n);let F=m.ZERO;if(v===mr)return F;if(v===ke)return this;let{endo:C}=t;if(!C)return l.unsafeLadder(this,v);let{k1neg:O,k1:H,k2neg:x,k2:q}=C.splitScalar(v),K=F,$=F,M=this;for(;H>mr||q>mr;)H&ke&&(K=K.add(M)),q&ke&&($=$.add(M)),M=M.double(),H>>=ke,q>>=ke;return O&&(K=K.negate()),x&&($=$.negate()),$=new m(r.mul($.px,C.beta),$.py,$.pz),K.add($)}multiply(v){let{endo:F,n:C}=t;ve.aInRange("scalar",v,ke,C);let O,H;if(F){let{k1neg:x,k1:q,k2neg:K,k2:$}=F.splitScalar(v),{p:M,f:ae}=this.wNAF(q),{p:Q,f:ne}=this.wNAF($);M=l.constTimeNegate(x,M),Q=l.constTimeNegate(K,Q),Q=new m(r.mul(Q.px,F.beta),Q.py,Q.pz),O=M.add(Q),H=ae.add(ne)}else{let{p:x,f:q}=this.wNAF(v);O=x,H=q}return m.normalizeZ([O,H])[0]}multiplyAndAddUnsafe(v,F,C){let O=m.BASE,H=(q,K)=>K===mr||K===ke||!q.equals(O)?q.multiplyUnsafe(K):q.multiply(K),x=H(this,F).add(H(v,C));return x.is0()?void 0:x}toAffine(v){return f(this,v)}isTorsionFree(){let{h:v,isTorsionFree:F}=t;if(v===ke)return!0;if(F)return F(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:v,clearCofactor:F}=t;return v===ke?this:F?F(m,this):this.multiplyUnsafe(t.h)}toRawBytes(v=!0){return(0,bt.abool)("isCompressed",v),this.assertValidity(),i(m,this,v)}toHex(v=!0){return(0,bt.abool)("isCompressed",v),ve.bytesToHex(this.toRawBytes(v))}}m.BASE=new m(t.Gx,t.Gy,r.ONE),m.ZERO=new m(r.ZERO,r.ONE,r.ZERO);let b=t.nBitLength,l=(0,ao.wNAF)(m,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:o}}function Nw(e){let t=(0,ao.validateBasic)(e);return ve.validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ow(e){let t=Nw(e),{Fp:r,n}=t,i=r.BYTES+1,s=2*r.BYTES+1;function a(g){return $n.mod(g,n)}function o(g){return $n.invert(g,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:p}=p0({...t,toBytes(g,S,R){let B=S.toAffine(),j=r.toBytes(B.x),Y=ve.concatBytes;return(0,bt.abool)("isCompressed",R),R?Y(Uint8Array.from([S.hasEvenY()?2:3]),j):Y(Uint8Array.from([4]),j,r.toBytes(B.y))},fromBytes(g){let S=g.length,R=g[0],B=g.subarray(1);if(S===i&&(R===2||R===3)){let j=ve.bytesToNumberBE(B);if(!ve.inRange(j,ke,r.ORDER))throw new Error("Point is not on curve");let Y=f(j),oe;try{oe=r.sqrt(Y)}catch(V){let _=V instanceof Error?": "+V.message:"";throw new Error("Point is not on curve"+_)}let se=(oe&ke)===ke;return(R&1)===1!==se&&(oe=r.neg(oe)),{x:j,y:oe}}else if(S===s&&R===4){let j=r.fromBytes(B.subarray(0,r.BYTES)),Y=r.fromBytes(B.subarray(r.BYTES,2*r.BYTES));return{x:j,y:Y}}else throw new Error(`Point of length ${S} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=g=>ve.bytesToHex(ve.numberToBytesBE(g,t.nByteLength));function b(g){let S=n>>ke;return g>S}function l(g){return b(g)?a(-g):g}let A=(g,S,R)=>ve.bytesToNumberBE(g.slice(S,R));class v{constructor(S,R,B){this.r=S,this.s=R,this.recovery=B,this.assertValidity()}static fromCompact(S){let R=t.nByteLength;return S=(0,bt.ensureBytes)("compactSignature",S,R*2),new v(A(S,0,R),A(S,R,2*R))}static fromDER(S){let{r:R,s:B}=wt.DER.toSig((0,bt.ensureBytes)("DER",S));return new v(R,B)}assertValidity(){ve.aInRange("r",this.r,ke,n),ve.aInRange("s",this.s,ke,n)}addRecoveryBit(S){return new v(this.r,this.s,S)}recoverPublicKey(S){let{r:R,s:B,recovery:j}=this,Y=q((0,bt.ensureBytes)("msgHash",S));if(j==null||![0,1,2,3].includes(j))throw new Error("recovery id invalid");let oe=j===2||j===3?R+t.n:R;if(oe>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let se=(j&1)===0?"02":"03",W=c.fromHex(se+m(oe)),V=o(oe),_=a(-Y*V),Z=a(B*V),re=c.BASE.multiplyAndAddUnsafe(W,_,Z);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new v(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return ve.hexToBytes(this.toDERHex())}toDERHex(){return wt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ve.hexToBytes(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let F={isValidPrivateKey(g){try{return d(g),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let g=$n.getMinHashLength(t.n);return $n.mapHashToField(t.randomBytes(g),t.n)},precompute(g=8,S=c.BASE){return S._setWindowSize(g),S.multiply(BigInt(3)),S}};function C(g,S=!0){return c.fromPrivateKey(g).toRawBytes(S)}function O(g){let S=ve.isBytes(g),R=typeof g=="string",B=(S||R)&&g.length;return S?B===i||B===s:R?B===2*i||B===2*s:g instanceof c}function H(g,S,R=!0){if(O(g))throw new Error("first arg must be private key");if(!O(S))throw new Error("second arg must be public key");return c.fromHex(S).multiply(d(g)).toRawBytes(R)}let x=t.bits2int||function(g){let S=ve.bytesToNumberBE(g),R=g.length*8-t.nBitLength;return R>0?S>>BigInt(R):S},q=t.bits2int_modN||function(g){return a(x(g))},K=ve.bitMask(t.nBitLength);function $(g){return ve.aInRange(`num < 2^${t.nBitLength}`,g,mr,K),ve.numberToBytesBE(g,t.nByteLength)}function M(g,S,R=ae){if(["recovered","canonical"].some(X=>X in R))throw new Error("sign() legacy options not supported");let{hash:B,randomBytes:j}=t,{lowS:Y,prehash:oe,extraEntropy:se}=R;Y==null&&(Y=!0),g=(0,bt.ensureBytes)("msgHash",g),d0(R),oe&&(g=(0,bt.ensureBytes)("prehashed msgHash",B(g)));let W=q(g),V=d(S),_=[$(V),$(W)];if(se!=null&&se!==!1){let X=se===!0?j(r.BYTES):se;_.push((0,bt.ensureBytes)("extraEntropy",X))}let Z=ve.concatBytes(..._),re=W;function le(X){let u=x(X);if(!p(u))return;let h=o(u),y=c.BASE.multiply(u).toAffine(),P=a(y.x);if(P===mr)return;let E=a(h*a(re+P*V));if(E===mr)return;let I=(y.x===P?0:2)|Number(y.y&ke),D=E;return Y&&b(E)&&(D=l(E),I^=1),new v(P,D,I)}return{seed:Z,k2sig:le}}let ae={lowS:t.lowS,prehash:!1},Q={lowS:t.lowS,prehash:!1};function ne(g,S,R=ae){let{seed:B,k2sig:j}=M(g,S,R),Y=t;return ve.createHmacDrbg(Y.hash.outputLen,Y.nByteLength,Y.hmac)(B,j)}c.BASE._setWindowSize(8);function w(g,S,R,B=Q){let j=g;if(S=(0,bt.ensureBytes)("msgHash",S),R=(0,bt.ensureBytes)("publicKey",R),"strict"in B)throw new Error("options.strict was renamed to lowS");d0(B);let{lowS:Y,prehash:oe}=B,se,W;try{if(typeof j=="string"||ve.isBytes(j))try{se=v.fromDER(j)}catch(y){if(!(y instanceof wt.DER.Err))throw y;se=v.fromCompact(j)}else if(typeof j=="object"&&typeof j.r=="bigint"&&typeof j.s=="bigint"){let{r:y,s:P}=j;se=new v(y,P)}else throw new Error("PARSE");W=c.fromHex(R)}catch(y){if(y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Y&&se.hasHighS())return!1;oe&&(S=t.hash(S));let{r:V,s:_}=se,Z=q(S),re=o(_),le=a(Z*re),X=a(V*re),u=c.BASE.multiplyAndAddUnsafe(W,le,X)?.toAffine();return u?a(u.x)===V:!1}return{CURVE:t,getPublicKey:C,getSharedSecret:H,sign:ne,verify:w,ProjectivePoint:c,Signature:v,utils:F}}function h0(e,t){let r=e.ORDER,n=mr;for(let l=r-ke;l%xn===mr;l/=xn)n+=ke;let i=n,s=xn<<i-ke-ke,a=s*xn,o=(r-ke)/a,c=(o-ke)/xn,d=a-ke,f=s,p=e.pow(t,o),m=e.pow(t,(o+ke)/xn),b=(l,A)=>{let v=p,F=e.pow(A,d),C=e.sqr(F);C=e.mul(C,A);let O=e.mul(l,C);O=e.pow(O,c),O=e.mul(O,F),F=e.mul(O,A),C=e.mul(O,l);let H=e.mul(C,F);O=e.pow(H,f);let x=e.eql(O,e.ONE);F=e.mul(C,m),O=e.mul(H,v),C=e.cmov(F,C,x),H=e.cmov(O,H,x);for(let q=i;q>ke;q--){let K=q-xn;K=xn<<K-ke;let $=e.pow(H,K),M=e.eql($,e.ONE);F=e.mul(C,v),v=e.mul(v,v),$=e.mul(H,v),C=e.cmov(F,C,M),H=e.cmov($,H,M)}return{isValid:x,value:C}};if(e.ORDER%f0===oo){let l=(e.ORDER-oo)/f0,A=e.sqrt(e.neg(t));b=(v,F)=>{let C=e.sqr(F),O=e.mul(v,F);C=e.mul(C,O);let H=e.pow(C,l);H=e.mul(H,O);let x=e.mul(H,A),q=e.mul(e.sqr(H),F),K=e.eql(q,v),$=e.cmov(x,H,K);return{isValid:K,value:$}}}return b}function Ew(e,t){if($n.validateField(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=h0(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,a,o,c,d,f,p;i=e.sqr(n),i=e.mul(i,t.Z),s=e.sqr(i),s=e.add(s,i),a=e.add(s,e.ONE),a=e.mul(a,t.B),o=e.cmov(t.Z,e.neg(s),!e.eql(s,e.ZERO)),o=e.mul(o,t.A),s=e.sqr(a),d=e.sqr(o),c=e.mul(d,t.A),s=e.add(s,c),s=e.mul(s,a),d=e.mul(d,o),c=e.mul(d,t.B),s=e.add(s,c),f=e.mul(i,a);let{isValid:m,value:b}=r(s,d);p=e.mul(i,n),p=e.mul(p,b),f=e.cmov(f,a,m),p=e.cmov(p,b,m);let l=e.isOdd(n)===e.isOdd(p);return p=e.cmov(e.neg(p),p,l),f=e.div(f,o),{x:f,y:p}}}});var b0=ee(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});_l.bls=Aw;var _0=Mr(),hl=Xt(),y0=so(),m0=pl(),vw=BigInt(0),co=BigInt(1),g0=BigInt(2),vi=BigInt(3);function Rw(e){let t=[];for(;e>co;e>>=co)(e&co)===vw?t.unshift(0):(e&vi)===vi?(t.unshift(-1),e+=co):t.unshift(1);return t}function Aw(e){let{Fp:t,Fr:r,Fp2:n,Fp6:i,Fp12:s}=e.fields,a=e.params.xNegative,o=e.params.twistType,c=(0,m0.weierstrassPoints)({n:r.ORDER,...e.G1}),d=Object.assign(c,(0,y0.createHasher)(c.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),f=(0,m0.weierstrassPoints)({n:r.ORDER,...e.G2}),p=Object.assign(f,(0,y0.createHasher)(f.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults})),m;if(o==="multiplicative")m=(W,V,_,Z,re,le)=>s.mul014(Z,W,n.mul(V,re),n.mul(_,le));else if(o==="divisive")m=(W,V,_,Z,re,le)=>s.mul034(Z,n.mul(_,le),n.mul(V,re),W);else throw new Error("bls: unknown twist type");let b=n.div(n.ONE,n.mul(n.ONE,g0));function l(W,V,_,Z){let re=n.sqr(_),le=n.sqr(Z),X=n.mulByB(n.mul(le,vi)),u=n.mul(X,vi),h=n.sub(n.sub(n.sqr(n.add(_,Z)),le),re),y=n.sub(X,re),P=n.mul(n.sqr(V),vi),E=n.neg(h);return W.push([y,P,E]),V=n.mul(n.mul(n.mul(n.sub(re,u),V),_),b),_=n.sub(n.sqr(n.mul(n.add(re,u),b)),n.mul(n.sqr(X),vi)),Z=n.mul(re,h),{Rx:V,Ry:_,Rz:Z}}function A(W,V,_,Z,re,le){let X=n.sub(_,n.mul(le,Z)),u=n.sub(V,n.mul(re,Z)),h=n.sub(n.mul(X,re),n.mul(u,le)),y=n.neg(X),P=u;W.push([h,y,P]);let E=n.sqr(u),I=n.mul(E,u),D=n.mul(E,V),T=n.add(n.sub(I,n.mul(D,g0)),n.mul(n.sqr(X),Z));return V=n.mul(u,T),_=n.sub(n.mul(n.sub(D,T),X),n.mul(I,_)),Z=n.mul(Z,I),{Rx:V,Ry:_,Rz:Z}}let v=Rw(e.params.ateLoopSize),F=(0,hl.memoized)(W=>{let V=W,{x:_,y:Z}=V.toAffine(),re=_,le=Z,X=n.neg(Z),u=re,h=le,y=n.ONE,P=[];for(let E of v){let I=[];({Rx:u,Ry:h,Rz:y}=l(I,u,h,y)),E&&({Rx:u,Ry:h,Rz:y}=A(I,u,h,y,re,E===-1?X:le)),P.push(I)}if(e.postPrecompute){let E=P[P.length-1];e.postPrecompute(u,h,y,re,le,A.bind(null,E))}return P});function C(W,V=!1){let _=s.ONE;if(W.length){let Z=W[0][0].length;for(let re=0;re<Z;re++){_=s.sqr(_);for(let[le,X,u]of W)for(let[h,y,P]of le[re])_=m(h,y,P,_,X,u)}}return a&&(_=s.conjugate(_)),V?s.finalExponentiate(_):_}function O(W,V=!0){let _=[];d.ProjectivePoint.normalizeZ(W.map(({g1:Z})=>Z)),p.ProjectivePoint.normalizeZ(W.map(({g2:Z})=>Z));for(let{g1:Z,g2:re}of W){if(Z.equals(d.ProjectivePoint.ZERO)||re.equals(p.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");Z.assertValidity(),re.assertValidity();let le=Z.toAffine();_.push([F(re),le.x,le.y])}return C(_,V)}function H(W,V,_=!0){return O([{g1:W,g2:V}],_)}let x={randomPrivateKey:()=>{let W=(0,_0.getMinHashLength)(r.ORDER);return(0,_0.mapHashToField)(e.randomBytes(W),r.ORDER)},calcPairingPrecomputes:F},{ShortSignature:q}=e.G1,{Signature:K}=e.G2;function $(W){return W instanceof d.ProjectivePoint?W:d.ProjectivePoint.fromHex(W)}function M(W,V){return W instanceof d.ProjectivePoint?W:d.hashToCurve((0,hl.ensureBytes)("point",W),V)}function ae(W){return W instanceof p.ProjectivePoint?W:K.fromHex(W)}function Q(W,V){return W instanceof p.ProjectivePoint?W:p.hashToCurve((0,hl.ensureBytes)("point",W),V)}function ne(W){return d.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function w(W){return p.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function g(W,V,_){let Z=Q(W,_);Z.assertValidity();let re=Z.multiply(d.normPrivateKeyToScalar(V));return W instanceof p.ProjectivePoint?re:K.toRawBytes(re)}function S(W,V,_){let Z=M(W,_);Z.assertValidity();let re=Z.multiply(d.normPrivateKeyToScalar(V));return W instanceof d.ProjectivePoint?re:q.toRawBytes(re)}function R(W,V,_,Z){let re=$(_),le=Q(V,Z),X=d.ProjectivePoint.BASE,u=ae(W),h=O([{g1:re.negate(),g2:le},{g1:X,g2:u}]);return s.eql(h,s.ONE)}function B(W,V,_,Z){let re=ae(_),le=M(V,Z),X=p.ProjectivePoint.BASE,u=$(W),h=O([{g1:le,g2:re},{g1:u,g2:X.negate()}]);return s.eql(h,s.ONE)}function j(W){if(!W.length)throw new Error("Expected non-empty array");let _=W.map($).reduce((Z,re)=>Z.add(re),d.ProjectivePoint.ZERO);return W[0]instanceof d.ProjectivePoint?(_.assertValidity(),_):_.toRawBytes(!0)}function Y(W){if(!W.length)throw new Error("Expected non-empty array");let _=W.map(ae).reduce((Z,re)=>Z.add(re),p.ProjectivePoint.ZERO);return W[0]instanceof p.ProjectivePoint?(_.assertValidity(),_):K.toRawBytes(_)}function oe(W){if(!W.length)throw new Error("Expected non-empty array");let _=W.map($).reduce((Z,re)=>Z.add(re),d.ProjectivePoint.ZERO);return W[0]instanceof d.ProjectivePoint?(_.assertValidity(),_):q.toRawBytes(_)}function se(W,V,_,Z){if(!V.length)throw new Error("Expected non-empty messages array");if(_.length!==V.length)throw new Error("Pubkey count should equal msg count");let re=ae(W),le=V.map(y=>Q(y,Z)),X=_.map($),u=new Map;for(let y=0;y<X.length;y++){let P=X[y],E=le[y],I=u.get(E);I===void 0&&(I=[],u.set(E,I)),I.push(P)}let h=[];try{for(let[y,P]of u){let E=P.reduce((I,D)=>I.add(D));h.push({g1:E,g2:y})}return h.push({g1:d.ProjectivePoint.BASE.negate(),g2:re}),s.eql(O(h),s.ONE)}catch{return!1}}return d.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ne,getPublicKeyForShortSignatures:w,sign:g,signShortSignature:S,verify:R,verifyBatch:se,verifyShortSignature:B,aggregatePublicKeys:j,aggregateSignatures:Y,aggregateShortSignatures:oe,millerLoopBatch:C,pairing:H,pairingBatch:O,G1:d,G2:p,Signature:K,ShortSignature:q,fields:{Fr:r,Fp:t,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:e.params.ateLoopSize,r:e.params.r,G1b:e.G1.b,G2b:e.G2.b},utils:x}}});var x0=ee(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.psiFrobenius=Bw;uo.tower12=Iw;var Tn=Mr(),gr=Xt(),Sw=BigInt(0),Ri=BigInt(1),rn=BigInt(2),w0=BigInt(3);function yl(e,t,r,n,i=1,s){let a=BigInt(s===void 0?n:s),o=r**BigInt(n),c=[];for(let d=0;d<i;d++){let f=BigInt(d+1),p=[];for(let m=0,b=Ri;m<n;m++){let l=(f*b-f)/a%o;p.push(e.pow(t,l)),b*=r}c.push(p)}return c}function Bw(e,t,r){let n=t.pow(r,(e.ORDER-Ri)/w0),i=t.pow(r,(e.ORDER-Ri)/rn);function s(m,b){let l=t.mul(t.frobeniusMap(m,1),n),A=t.mul(t.frobeniusMap(b,1),i);return[l,A]}let a=t.pow(r,(e.ORDER**rn-Ri)/w0),o=t.pow(r,(e.ORDER**rn-Ri)/rn);if(!t.eql(o,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(m,b){return[t.mul(m,a),t.neg(b)]}let d=m=>(b,l)=>{let A=l.toAffine(),v=m(A.x,A.y);return b.fromAffine({x:v[0],y:v[1]})},f=d(s),p=d(c);return{psi:s,psi2:c,G2psi:f,G2psi2:p,PSI_X:n,PSI_Y:i,PSI2_X:a,PSI2_Y:o}}function Iw(e){let{ORDER:t}=e,r=Tn.Field(t),n=r.create(e.NONRESIDUE||BigInt(-1)),i=Tn.FpLegendre(t),s=r.div(r.ONE,rn),a=yl(r,n,r.ORDER,2)[0],o=({c0:w,c1:g},{c0:S,c1:R})=>({c0:r.add(w,S),c1:r.add(g,R)}),c=({c0:w,c1:g},{c0:S,c1:R})=>({c0:r.sub(w,S),c1:r.sub(g,R)}),d=({c0:w,c1:g},S)=>{if(typeof S=="bigint")return{c0:r.mul(w,S),c1:r.mul(g,S)};let{c0:R,c1:B}=S,j=r.mul(w,R),Y=r.mul(g,B),oe=r.sub(j,Y),se=r.sub(r.mul(r.add(w,g),r.add(R,B)),r.add(j,Y));return{c0:oe,c1:se}},f=({c0:w,c1:g})=>{let S=r.add(w,g),R=r.sub(w,g),B=r.add(w,w);return{c0:r.mul(S,R),c1:r.mul(B,g)}},p=w=>{if(w.length!==2)throw new Error("Invalid tuple");let g=w.map(S=>r.create(S));return{c0:g[0],c1:g[1]}},m=t*t,b=p(e.FP2_NONRESIDUE),l={ORDER:m,NONRESIDUE:b,BITS:(0,gr.bitLen)(m),BYTES:Math.ceil((0,gr.bitLen)(m)/8),MASK:(0,gr.bitMask)((0,gr.bitLen)(m)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:w=>w,isValid:({c0:w,c1:g})=>typeof w=="bigint"&&typeof g=="bigint",is0:({c0:w,c1:g})=>r.is0(w)&&r.is0(g),eql:({c0:w,c1:g},{c0:S,c1:R})=>r.eql(w,S)&&r.eql(g,R),neg:({c0:w,c1:g})=>({c0:r.neg(w),c1:r.neg(g)}),pow:(w,g)=>Tn.FpPow(l,w,g),invertBatch:w=>Tn.FpInvertBatch(l,w),add:o,sub:c,mul:d,sqr:f,addN:o,subN:c,mulN:d,sqrN:f,div:(w,g)=>l.mul(w,typeof g=="bigint"?r.inv(r.create(g)):l.inv(g)),inv:({c0:w,c1:g})=>{let S=r.inv(r.create(w*w+g*g));return{c0:r.mul(S,r.create(w)),c1:r.mul(S,r.create(-g))}},sqrt:w=>{if(e.Fp2sqrt)return e.Fp2sqrt(w);let{c0:g,c1:S}=w;if(r.is0(S))return r.eql(i(r,g),r.ONE)?l.create({c0:r.sqrt(g),c1:r.ZERO}):l.create({c0:r.ZERO,c1:r.sqrt(r.div(g,n))});let R=r.sqrt(r.sub(r.sqr(g),r.mul(r.sqr(S),n))),B=r.mul(r.add(R,g),s),j=i(r,B);!r.is0(j)&&!r.eql(j,r.ONE)&&(B=r.sub(B,R));let Y=r.sqrt(B),oe=l.create({c0:Y,c1:r.div(r.mul(S,s),Y)});if(!l.eql(l.sqr(oe),w))throw new Error("Cannot find square root");let se=oe,W=l.neg(se),{re:V,im:_}=l.reim(se),{re:Z,im:re}=l.reim(W);return _>re||_===re&&V>Z?se:W},isOdd:w=>{let{re:g,im:S}=l.reim(w),R=g%rn,B=g===Sw,j=S%rn;return BigInt(R||B&&j)==Ri},fromBytes(w){if(w.length!==l.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:r.fromBytes(w.subarray(0,r.BYTES)),c1:r.fromBytes(w.subarray(r.BYTES))}},toBytes:({c0:w,c1:g})=>(0,gr.concatBytes)(r.toBytes(w),r.toBytes(g)),cmov:({c0:w,c1:g},{c0:S,c1:R},B)=>({c0:r.cmov(w,S,B),c1:r.cmov(g,R,B)}),reim:({c0:w,c1:g})=>({re:w,im:g}),mulByNonresidue:({c0:w,c1:g})=>l.mul({c0:w,c1:g},b),mulByB:e.Fp2mulByB,fromBigTuple:p,frobeniusMap:({c0:w,c1:g},S)=>({c0:w,c1:r.mul(g,a[S%2])})},A=({c0:w,c1:g,c2:S},{c0:R,c1:B,c2:j})=>({c0:l.add(w,R),c1:l.add(g,B),c2:l.add(S,j)}),v=({c0:w,c1:g,c2:S},{c0:R,c1:B,c2:j})=>({c0:l.sub(w,R),c1:l.sub(g,B),c2:l.sub(S,j)}),F=({c0:w,c1:g,c2:S},R)=>{if(typeof R=="bigint")return{c0:l.mul(w,R),c1:l.mul(g,R),c2:l.mul(S,R)};let{c0:B,c1:j,c2:Y}=R,oe=l.mul(w,B),se=l.mul(g,j),W=l.mul(S,Y);return{c0:l.add(oe,l.mulByNonresidue(l.sub(l.mul(l.add(g,S),l.add(j,Y)),l.add(se,W)))),c1:l.add(l.sub(l.mul(l.add(w,g),l.add(B,j)),l.add(oe,se)),l.mulByNonresidue(W)),c2:l.sub(l.add(se,l.mul(l.add(w,S),l.add(B,Y))),l.add(oe,W))}},C=({c0:w,c1:g,c2:S})=>{let R=l.sqr(w),B=l.mul(l.mul(w,g),rn),j=l.mul(l.mul(g,S),rn),Y=l.sqr(S);return{c0:l.add(l.mulByNonresidue(j),R),c1:l.add(l.mulByNonresidue(Y),B),c2:l.sub(l.sub(l.add(l.add(B,l.sqr(l.add(l.sub(w,g),S))),j),R),Y)}},[O,H]=yl(l,b,r.ORDER,6,2,3),x={ORDER:l.ORDER,BITS:3*l.BITS,BYTES:3*l.BYTES,MASK:(0,gr.bitMask)(3*l.BITS),ZERO:{c0:l.ZERO,c1:l.ZERO,c2:l.ZERO},ONE:{c0:l.ONE,c1:l.ZERO,c2:l.ZERO},create:w=>w,isValid:({c0:w,c1:g,c2:S})=>l.isValid(w)&&l.isValid(g)&&l.isValid(S),is0:({c0:w,c1:g,c2:S})=>l.is0(w)&&l.is0(g)&&l.is0(S),neg:({c0:w,c1:g,c2:S})=>({c0:l.neg(w),c1:l.neg(g),c2:l.neg(S)}),eql:({c0:w,c1:g,c2:S},{c0:R,c1:B,c2:j})=>l.eql(w,R)&&l.eql(g,B)&&l.eql(S,j),sqrt:gr.notImplemented,div:(w,g)=>x.mul(w,typeof g=="bigint"?r.inv(r.create(g)):x.inv(g)),pow:(w,g)=>Tn.FpPow(x,w,g),invertBatch:w=>Tn.FpInvertBatch(x,w),add:A,sub:v,mul:F,sqr:C,addN:A,subN:v,mulN:F,sqrN:C,inv:({c0:w,c1:g,c2:S})=>{let R=l.sub(l.sqr(w),l.mulByNonresidue(l.mul(S,g))),B=l.sub(l.mulByNonresidue(l.sqr(S)),l.mul(w,g)),j=l.sub(l.sqr(g),l.mul(w,S)),Y=l.inv(l.add(l.mulByNonresidue(l.add(l.mul(S,B),l.mul(g,j))),l.mul(w,R)));return{c0:l.mul(Y,R),c1:l.mul(Y,B),c2:l.mul(Y,j)}},fromBytes:w=>{if(w.length!==x.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:l.fromBytes(w.subarray(0,l.BYTES)),c1:l.fromBytes(w.subarray(l.BYTES,2*l.BYTES)),c2:l.fromBytes(w.subarray(2*l.BYTES))}},toBytes:({c0:w,c1:g,c2:S})=>(0,gr.concatBytes)(l.toBytes(w),l.toBytes(g),l.toBytes(S)),cmov:({c0:w,c1:g,c2:S},{c0:R,c1:B,c2:j},Y)=>({c0:l.cmov(w,R,Y),c1:l.cmov(g,B,Y),c2:l.cmov(S,j,Y)}),fromBigSix:w=>{if(!Array.isArray(w)||w.length!==6)throw new Error("Invalid Fp6 usage");return{c0:l.fromBigTuple(w.slice(0,2)),c1:l.fromBigTuple(w.slice(2,4)),c2:l.fromBigTuple(w.slice(4,6))}},frobeniusMap:({c0:w,c1:g,c2:S},R)=>({c0:l.frobeniusMap(w,R),c1:l.mul(l.frobeniusMap(g,R),O[R%6]),c2:l.mul(l.frobeniusMap(S,R),H[R%6])}),mulByFp2:({c0:w,c1:g,c2:S},R)=>({c0:l.mul(w,R),c1:l.mul(g,R),c2:l.mul(S,R)}),mulByNonresidue:({c0:w,c1:g,c2:S})=>({c0:l.mulByNonresidue(S),c1:w,c2:g}),mul1:({c0:w,c1:g,c2:S},R)=>({c0:l.mulByNonresidue(l.mul(S,R)),c1:l.mul(w,R),c2:l.mul(g,R)}),mul01({c0:w,c1:g,c2:S},R,B){let j=l.mul(w,R),Y=l.mul(g,B);return{c0:l.add(l.mulByNonresidue(l.sub(l.mul(l.add(g,S),B),Y)),j),c1:l.sub(l.sub(l.mul(l.add(R,B),l.add(w,g)),j),Y),c2:l.add(l.sub(l.mul(l.add(w,S),R),j),Y)}}},q=yl(l,b,r.ORDER,12,1,6)[0],K=({c0:w,c1:g},{c0:S,c1:R})=>({c0:x.add(w,S),c1:x.add(g,R)}),$=({c0:w,c1:g},{c0:S,c1:R})=>({c0:x.sub(w,S),c1:x.sub(g,R)}),M=({c0:w,c1:g},S)=>{if(typeof S=="bigint")return{c0:x.mul(w,S),c1:x.mul(g,S)};let{c0:R,c1:B}=S,j=x.mul(w,R),Y=x.mul(g,B);return{c0:x.add(j,x.mulByNonresidue(Y)),c1:x.sub(x.mul(x.add(w,g),x.add(R,B)),x.add(j,Y))}},ae=({c0:w,c1:g})=>{let S=x.mul(w,g);return{c0:x.sub(x.sub(x.mul(x.add(x.mulByNonresidue(g),w),x.add(w,g)),S),x.mulByNonresidue(S)),c1:x.add(S,S)}};function Q(w,g){let S=l.sqr(w),R=l.sqr(g);return{first:l.add(l.mulByNonresidue(R),S),second:l.sub(l.sub(l.sqr(l.add(w,g)),S),R)}}let ne={ORDER:l.ORDER,BITS:2*l.BITS,BYTES:2*l.BYTES,MASK:(0,gr.bitMask)(2*l.BITS),ZERO:{c0:x.ZERO,c1:x.ZERO},ONE:{c0:x.ONE,c1:x.ZERO},create:w=>w,isValid:({c0:w,c1:g})=>x.isValid(w)&&x.isValid(g),is0:({c0:w,c1:g})=>x.is0(w)&&x.is0(g),neg:({c0:w,c1:g})=>({c0:x.neg(w),c1:x.neg(g)}),eql:({c0:w,c1:g},{c0:S,c1:R})=>x.eql(w,S)&&x.eql(g,R),sqrt:gr.notImplemented,inv:({c0:w,c1:g})=>{let S=x.inv(x.sub(x.sqr(w),x.mulByNonresidue(x.sqr(g))));return{c0:x.mul(w,S),c1:x.neg(x.mul(g,S))}},div:(w,g)=>ne.mul(w,typeof g=="bigint"?r.inv(r.create(g)):ne.inv(g)),pow:(w,g)=>Tn.FpPow(ne,w,g),invertBatch:w=>Tn.FpInvertBatch(ne,w),add:K,sub:$,mul:M,sqr:ae,addN:K,subN:$,mulN:M,sqrN:ae,fromBytes:w=>{if(w.length!==ne.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:x.fromBytes(w.subarray(0,x.BYTES)),c1:x.fromBytes(w.subarray(x.BYTES))}},toBytes:({c0:w,c1:g})=>(0,gr.concatBytes)(x.toBytes(w),x.toBytes(g)),cmov:({c0:w,c1:g},{c0:S,c1:R},B)=>({c0:x.cmov(w,S,B),c1:x.cmov(g,R,B)}),fromBigTwelve:w=>({c0:x.fromBigSix(w.slice(0,6)),c1:x.fromBigSix(w.slice(6,12))}),frobeniusMap(w,g){let{c0:S,c1:R,c2:B}=x.frobeniusMap(w.c1,g),j=q[g%12];return{c0:x.frobeniusMap(w.c0,g),c1:x.create({c0:l.mul(S,j),c1:l.mul(R,j),c2:l.mul(B,j)})}},mulByFp2:({c0:w,c1:g},S)=>({c0:x.mulByFp2(w,S),c1:x.mulByFp2(g,S)}),conjugate:({c0:w,c1:g})=>({c0:w,c1:x.neg(g)}),mul014:({c0:w,c1:g},S,R,B)=>{let j=x.mul01(w,S,R),Y=x.mul1(g,B);return{c0:x.add(x.mulByNonresidue(Y),j),c1:x.sub(x.sub(x.mul01(x.add(g,w),S,l.add(R,B)),j),Y)}},mul034:({c0:w,c1:g},S,R,B)=>{let j=x.create({c0:l.mul(w.c0,S),c1:l.mul(w.c1,S),c2:l.mul(w.c2,S)}),Y=x.mul01(g,R,B),oe=x.mul01(x.add(w,g),l.add(S,R),B);return{c0:x.add(x.mulByNonresidue(Y),j),c1:x.sub(oe,x.add(j,Y))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:r,Fp2:l,Fp6:x,Fp4Square:Q,Fp12:ne}}});var B0=ee(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.bls12_381=void 0;var v0=pa(),Pw=Dn(),Fw=b0(),Vw=Mr(),Re=Xt(),R0=so(),A0=pl(),S0=x0(),qt=BigInt(0),po=BigInt(1),_t=BigInt(2),lo=BigInt(3),ws=BigInt(4),Nn=BigInt("0xd201000000010000"),Uw=(0,Re.bitLen)(Nn),{Fp:pe,Fp2:he,Fp6:bl,Fp4Square:ml,Fp12:Ne}=(0,S0.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[po,po],Fp2mulByB:({c0:e,c1:t})=>{let r=pe.mul(e,ws),n=pe.mul(t,ws);return{c0:pe.sub(r,n),c1:pe.add(r,n)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{let{c0:r,c1:n,c2:i}=e,{c0:s,c1:a,c2:o}=t,{first:c,second:d}=ml(r,a),{first:f,second:p}=ml(s,i),{first:m,second:b}=ml(n,o),l=he.mulByNonresidue(b);return{c0:bl.create({c0:he.add(he.mul(he.sub(c,r),_t),c),c1:he.add(he.mul(he.sub(f,n),_t),f),c2:he.add(he.mul(he.sub(m,i),_t),m)}),c1:bl.create({c0:he.add(he.mul(he.add(l,s),_t),l),c1:he.add(he.mul(he.add(d,a),_t),d),c2:he.add(he.mul(he.add(p,o),_t),p)})}},Fp12cyclotomicExp(e,t){let r=Ne.ONE;for(let n=Uw-1;n>=0;n--)r=Ne._cyclotomicSquare(r),(0,Re.bitGet)(t,n)&&(r=Ne.mul(r,e));return r},Fp12finalExponentiate:e=>{let t=Nn,r=Ne.div(Ne.frobeniusMap(e,6),e),n=Ne.mul(Ne.frobeniusMap(r,2),r),i=Ne.conjugate(Ne._cyclotomicExp(n,t)),s=Ne.mul(Ne.conjugate(Ne._cyclotomicSquare(n)),i),a=Ne.conjugate(Ne._cyclotomicExp(s,t)),o=Ne.conjugate(Ne._cyclotomicExp(a,t)),c=Ne.mul(Ne.conjugate(Ne._cyclotomicExp(o,t)),Ne._cyclotomicSquare(i)),d=Ne.conjugate(Ne._cyclotomicExp(c,t)),f=Ne.frobeniusMap(Ne.mul(i,o),2),p=Ne.frobeniusMap(Ne.mul(a,n),3),m=Ne.frobeniusMap(Ne.mul(c,Ne.conjugate(n)),1),b=Ne.mul(Ne.mul(d,Ne.conjugate(s)),n);return Ne.mul(Ne.mul(Ne.mul(f,p),m),b)}}),T0=Vw.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Cw=(0,R0.isogenyMap)(he,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(e=>e.map(t=>he.fromBigTuple(t.map(BigInt))))),qw=(0,R0.isogenyMap)(pe,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),Mw=(0,A0.mapToCurveSimpleSWU)(he,{A:he.create({c0:pe.create(qt),c1:pe.create(BigInt(240))}),B:he.create({c0:pe.create(BigInt(1012)),c1:pe.create(BigInt(1012))}),Z:he.create({c0:pe.create(BigInt(-2)),c1:pe.create(BigInt(-1))})}),kw=(0,A0.mapToCurveSimpleSWU)(pe,{A:pe.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:pe.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:pe.create(BigInt(11))}),{G2psi:N0,G2psi2:Dw}=(0,S0.psiFrobenius)(pe,he,he.div(he.ONE,he.NONRESIDUE)),gl=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:pe.ORDER,m:2,k:128,expand:"xmd",hash:v0.sha256}),ho=xs(pe.toBytes(qt),{infinity:!0,compressed:!0});function fo(e){e=e.slice();let t=e[0]&224,r=!!(t>>7&1),n=!!(t>>6&1),i=!!(t>>5&1);return e[0]&=31,{compressed:r,infinity:n,sort:i,value:e}}function xs(e,t){if(e[0]&224)throw new Error("setMask: non-empty mask");return t.compressed&&(e[0]|=128),t.infinity&&(e[0]|=64),t.sort&&(e[0]|=32),e}function O0(e){e.assertValidity();let t=e.equals(Mt.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=e.toAffine();if(t)return ho.slice();let i=pe.ORDER,s=!!(n*_t/i);return xs((0,Re.numberToBytesBE)(r,pe.BYTES),{compressed:!0,sort:s})}function E0(e){e.assertValidity();let t=pe.BYTES;if(e.equals(Mt.bls12_381.G2.ProjectivePoint.ZERO))return(0,Re.concatBytes)(ho,(0,Re.numberToBytesBE)(qt,t));let{x:r,y:n}=e.toAffine(),{re:i,im:s}=he.reim(r),{re:a,im:o}=he.reim(n),d=!!((o>qt?o*_t:a*_t)/pe.ORDER&po),f=i;return(0,Re.concatBytes)(xs((0,Re.numberToBytesBE)(s,t),{sort:d,compressed:!0}),(0,Re.numberToBytesBE)(f,t))}Mt.bls12_381=(0,Fw.bls)({fields:{Fp:pe,Fp2:he,Fp6:bl,Fp12:Ne,Fr:T0},G1:{Fp:pe,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:pe.ZERO,b:ws,htfDefaults:{...gl,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(e,t)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new e(pe.mul(t.px,r),t.py,t.pz);return t.multiplyUnsafe(Nn).negate().multiplyUnsafe(Nn).equals(n)},clearCofactor:(e,t)=>t.multiplyUnsafe(Nn).add(t),mapToCurve:e=>{let{x:t,y:r}=kw(pe.create(e[0]));return qw(t,r)},fromBytes:e=>{let{compressed:t,infinity:r,sort:n,value:i}=fo(e);if(i.length===48&&t){let s=pe.ORDER,a=(0,Re.bytesToNumberBE)(i),o=pe.create(a&pe.MASK);if(r){if(o!==qt)throw new Error("G1: non-empty compressed point at infinity");return{x:qt,y:qt}}let c=pe.add(pe.pow(o,lo),pe.create(Mt.bls12_381.params.G1b)),d=pe.sqrt(c);if(!d)throw new Error("Invalid compressed G1 point");return d*_t/s!==BigInt(n)&&(d=pe.neg(d)),{x:pe.create(o),y:pe.create(d)}}else if(i.length===96&&!t){let s=(0,Re.bytesToNumberBE)(i.subarray(0,pe.BYTES)),a=(0,Re.bytesToNumberBE)(i.subarray(pe.BYTES));if(r){if(s!==qt||a!==qt)throw new Error("G1: non-empty point at infinity");return Mt.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:pe.create(s),y:pe.create(a)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(e,t,r)=>{let n=t.equals(e.ZERO),{x:i,y:s}=t.toAffine();if(r){if(n)return ho.slice();let a=pe.ORDER,o=!!(s*_t/a);return xs((0,Re.numberToBytesBE)(i,pe.BYTES),{compressed:!0,sort:o})}else return n?(0,Re.concatBytes)(new Uint8Array([64]),new Uint8Array(2*pe.BYTES-1)):(0,Re.concatBytes)((0,Re.numberToBytesBE)(i,pe.BYTES),(0,Re.numberToBytesBE)(s,pe.BYTES))},ShortSignature:{fromHex(e){let{infinity:t,sort:r,value:n}=fo((0,Re.ensureBytes)("signatureHex",e,48)),i=pe.ORDER,s=(0,Re.bytesToNumberBE)(n);if(t)return Mt.bls12_381.G1.ProjectivePoint.ZERO;let a=pe.create(s&pe.MASK),o=pe.add(pe.pow(a,lo),pe.create(Mt.bls12_381.params.G1b)),c=pe.sqrt(o);if(!c)throw new Error("Invalid compressed G1 point");let d=BigInt(r);c*_t/i!==d&&(c=pe.neg(c));let f=Mt.bls12_381.G1.ProjectivePoint.fromAffine({x:a,y:c});return f.assertValidity(),f},toRawBytes(e){return O0(e)},toHex(e){return(0,Re.bytesToHex)(O0(e))}}},G2:{Fp:he,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:he.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:he.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:he.ZERO,b:he.fromBigTuple([ws,ws]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...gl},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{let{x:t,y:r}=Mw(he.fromBigTuple(e));return Cw(t,r)},isTorsionFree:(e,t)=>t.multiplyUnsafe(Nn).negate().equals(N0(e,t)),clearCofactor:(e,t)=>{let r=Nn,n=t.multiplyUnsafe(r).negate(),i=N0(e,t),s=t.double();return s=Dw(e,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(t)},fromBytes:e=>{let{compressed:t,infinity:r,sort:n,value:i}=fo(e);if(!t&&!r&&n||!t&&r&&n||n&&r&&t)throw new Error("Invalid encoding flag: "+(e[0]&224));let s=pe.BYTES,a=(o,c,d)=>(0,Re.bytesToNumberBE)(o.slice(c,d));if(i.length===96&&t){let o=Mt.bls12_381.params.G2b,c=pe.ORDER;if(r){if(i.reduce((A,v)=>A!==0?v+1:v,0)>0)throw new Error("Invalid compressed G2 point");return{x:he.ZERO,y:he.ZERO}}let d=a(i,0,s),f=a(i,s,2*s),p=he.create({c0:pe.create(f),c1:pe.create(d)}),m=he.add(he.pow(p,lo),o),b=he.sqrt(m),l=b.c1===qt?b.c0*_t/c:b.c1*_t/c?po:qt;return b=n&&l>0?b:he.neg(b),{x:p,y:b}}else if(i.length===192&&!t){if(r){if(i.reduce((p,m)=>p!==0?m+1:m,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:he.ZERO,y:he.ZERO}}let o=a(i,0,s),c=a(i,s,2*s),d=a(i,2*s,3*s),f=a(i,3*s,4*s);return{x:he.fromBigTuple([c,o]),y:he.fromBigTuple([f,d])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(e,t,r)=>{let{BYTES:n,ORDER:i}=pe,s=t.equals(e.ZERO),{x:a,y:o}=t.toAffine();if(r){if(s)return(0,Re.concatBytes)(ho,(0,Re.numberToBytesBE)(qt,n));let c=!!(o.c1===qt?o.c0*_t/i:o.c1*_t/i);return(0,Re.concatBytes)(xs((0,Re.numberToBytesBE)(a.c1,n),{compressed:!0,sort:c}),(0,Re.numberToBytesBE)(a.c0,n))}else{if(s)return(0,Re.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:d}=he.reim(a),{re:f,im:p}=he.reim(o);return(0,Re.concatBytes)((0,Re.numberToBytesBE)(d,n),(0,Re.numberToBytesBE)(c,n),(0,Re.numberToBytesBE)(p,n),(0,Re.numberToBytesBE)(f,n))}},Signature:{fromHex(e){let{infinity:t,sort:r,value:n}=fo((0,Re.ensureBytes)("signatureHex",e)),i=pe.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let a=(0,Re.bytesToNumberBE)(n.slice(0,s)),o=(0,Re.bytesToNumberBE)(n.slice(s));if(t)return Mt.bls12_381.G2.ProjectivePoint.ZERO;let c=pe.create(a&pe.MASK),d=pe.create(o),f=he.create({c0:d,c1:c}),p=he.add(he.pow(f,lo),Mt.bls12_381.params.G2b),m=he.sqrt(p);if(!m)throw new Error("Failed to find a square root");let{re:b,im:l}=he.reim(m),A=BigInt(r),v=l>qt&&l*_t/i!==A,F=l===qt&&b*_t/i!==A;(v||F)&&(m=he.neg(m));let C=Mt.bls12_381.G2.ProjectivePoint.fromAffine({x:f,y:m});return C.assertValidity(),C},toRawBytes(e){return E0(e)},toHex(e){return(0,Re.bytesToHex)(E0(e))}}},params:{ateLoopSize:Nn,r:T0.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:gl,hash:v0.sha256,randomBytes:Pw.randomBytes})});var xl=ee(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.blsVerify=Ts.verify=void 0;var jw=B0(),wl=$t();function Lw(e,t,r){let n=typeof e=="string"?e:(0,wl.toHex)(e),i=typeof t=="string"?t:(0,wl.toHex)(t),s=typeof r=="string"?r:(0,wl.toHex)(r);return jw.bls12_381.verifyShortSignature(i,s,n)}Ts.blsVerify=Lw});var _o=ee(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});Gn.decodeTime=Gn.decodeLeb128=void 0;var I0=Ti(),Hw=e=>(0,I0.lebDecode)(new I0.PipeArrayBuffer(e));Gn.decodeLeb128=Hw;var Kw=e=>{let t=(0,Gn.decodeLeb128)(e);return new Date(Number(t)/1e6)};Gn.decodeTime=Kw});var Ai=ee(Oe=>{"use strict";var $w=Oe&&Oe.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Gw=Oe&&Oe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),P0=Oe&&Oe.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&$w(t,e,r);return Gw(t,e),t},zw=Oe&&Oe.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},Ww=Oe&&Oe.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},mo;Object.defineProperty(Oe,"__esModule",{value:!0});Oe.check_canister_ranges=Oe.find_label=Oe.flatten_forks=Oe.lookup_path=Oe.LookupStatus=Oe.reconstruct=Oe.lookupResultToBuffer=Oe.Certificate=Oe.hashTreeToString=Oe.NodeType=Oe.CertificateVerificationError=void 0;var F0=P0(ys()),Yw=_i(),yo=ps(),br=$t(),Tl=Ut(),Jw=P0(xl()),Zw=_o(),Xw=Rs(),nn=class extends Yw.AgentError{constructor(t){super(`Invalid certificate: ${t}`)}};Oe.CertificateVerificationError=nn;var xt;(function(e){e[e.Empty=0]="Empty",e[e.Fork=1]="Fork",e[e.Labeled=2]="Labeled",e[e.Leaf=3]="Leaf",e[e.Pruned=4]="Pruned"})(xt=Oe.NodeType||(Oe.NodeType={}));function go(e){let t=n=>n.split(`
18
18
  `).map(i=>" "+i).join(`
19
- `);function r(n){let i=new TextDecoder(void 0,{fatal:!0});try{return JSON.stringify(i.decode(n))}catch{return`data(...${n.byteLength} bytes)`}}switch(e[0]){case xt.Empty:return"()";case xt.Fork:if(e[1]instanceof Array&&e[2]instanceof ArrayBuffer){let n=bo(e[1]),i=bo(e[2]);return`sub(
19
+ `);function r(n){let i=new TextDecoder(void 0,{fatal:!0});try{return JSON.stringify(i.decode(n))}catch{return`data(...${n.byteLength} bytes)`}}switch(e[0]){case xt.Empty:return"()";case xt.Fork:if(e[1]instanceof Array&&e[2]instanceof ArrayBuffer){let n=go(e[1]),i=go(e[2]);return`sub(
20
20
  left:
21
21
  ${t(n)}
22
22
  ---
23
23
  right:
24
24
  ${t(i)}
25
- )`}else throw new Error("Invalid tree structure for fork");case xt.Labeled:if(e[1]instanceof ArrayBuffer&&e[2]instanceof ArrayBuffer){let n=r(e[1]),i=bo(e[2]);return`label(
25
+ )`}else throw new Error("Invalid tree structure for fork");case xt.Labeled:if(e[1]instanceof ArrayBuffer&&e[2]instanceof ArrayBuffer){let n=r(e[1]),i=go(e[2]);return`label(
26
26
  label:
27
27
  ${t(n)}
28
28
  sub:
29
29
  ${t(i)}
30
- )`}else throw new Error("Invalid tree structure for labeled");case xt.Leaf:{if(e[1]){if(Array.isArray(e[1]))return JSON.stringify(e[1])}else throw new Error("Invalid tree structure for leaf");return`leaf(...${e[1].byteLength} bytes)`}case xt.Pruned:{if(e[1]){if(Array.isArray(e[1]))return JSON.stringify(e[1])}else throw new Error("Invalid tree structure for pruned");return`pruned(${(0,br.toHex)(new Uint8Array(e[1]))}`}default:return`unknown(${JSON.stringify(e[0])})`}}Oe.hashTreeToString=bo;function tx(e,t){let r=new Uint8Array(e),n=new Uint8Array(t);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}var Ol=class e{constructor(t,r,n,i,s=5,a=!1){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,go.set(this,!1),Yw(this,go,a,"f"),this.cert=V0.decode(new Uint8Array(t))}static async create(t){let r=e.createUnverified(t);return await r.verify(),r}static createUnverified(t){let r=t.blsVerify;return r||(r=Xw.blsVerify),new e(t.certificate,t.rootKey,t.canisterId,r,t.maxAgeInMinutes,t.disableTimeVerification)}lookup(t){return wo(t,this.cert.tree)}lookup_label(t){return this.lookup([t])}async verify(){let t=await Es(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=nx(r),s=(0,br.concat)(Os("ic-state-root"),t),a=!1,o=El(this.lookup(["time"]));if(!o)throw new nn("Certificate does not contain a time");if(!Jw(this,go,"f")){let d=this._maxAgeInMinutes*60*1e3,f=Date.now(),p=f-d,m=f+3e5,b=(0,Qw.decodeTime)(o);if(b.getTime()<p)throw new nn(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+b.toISOString()+" Current time: "+new Date(f).toISOString());if(b.getTime()>m)throw new nn("Certificate is signed more than 5 minutes in the future. Certificate time: "+b.toISOString()+" Current time: "+new Date(f).toISOString())}try{a=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{a=!1}if(!a)throw new nn("Signature verification failed")}async _checkDelegationAndGetKey(t){if(!t)return this._rootKey;let r=await e.createUnverified({certificate:t.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new nn("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==ex.MANAGEMENT_CANISTER_ID&&!U0({canisterId:this._canisterId,subnetId:Nl.Principal.fromUint8Array(new Uint8Array(t.subnet_id)),tree:r.cert.tree}))throw new nn(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,br.toHex)(t.subnet_id)}`);let n=El(r.lookup(["subnet",t.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,br.toHex)(t.subnet_id)}`);return n}};Oe.Certificate=Ol;go=new WeakMap;var Ns=(0,br.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),rx=96;function nx(e){let t=Ns.byteLength+rx;if(e.byteLength!==t)throw new TypeError(`BLS DER-encoded public key must be ${t} bytes long`);let r=e.slice(0,Ns.byteLength);if(!(0,br.bufEquals)(r,Ns))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Ns}, but get ${r}`);return e.slice(Ns.byteLength)}function El(e){if(e.status===Dt.Found){if(e.value instanceof ArrayBuffer)return e.value;if(e.value instanceof Uint8Array)return e.value.buffer}}Oe.lookupResultToBuffer=El;async function Es(e){switch(e[0]){case xt.Empty:return(0,mo.hash)(Os("ic-hashtree-empty"));case xt.Pruned:return e[1];case xt.Leaf:return(0,mo.hash)((0,br.concat)(Os("ic-hashtree-leaf"),e[1]));case xt.Labeled:return(0,mo.hash)((0,br.concat)(Os("ic-hashtree-labeled"),e[1],await Es(e[2])));case xt.Fork:return(0,mo.hash)((0,br.concat)(Os("ic-hashtree-fork"),await Es(e[1]),await Es(e[2])));default:throw new Error("unreachable")}}Oe.reconstruct=Es;function Os(e){let t=new Uint8Array([e.length]),r=new TextEncoder().encode(e);return(0,br.concat)(t,r)}var Dt;(function(e){e.Unknown="unknown",e.Absent="absent",e.Found="found"})(Dt=Oe.LookupStatus||(Oe.LookupStatus={}));var sn;(function(e){e.Less="less",e.Greater="greater"})(sn||(sn={}));function wo(e,t){if(e.length===0)switch(t[0]){case xt.Leaf:{if(!t[1])throw new Error("Invalid tree structure for leaf");return t[1]instanceof ArrayBuffer?{status:Dt.Found,value:t[1]}:t[1]instanceof Uint8Array?{status:Dt.Found,value:t[1].buffer}:{status:Dt.Found,value:t[1]}}default:return{status:Dt.Found,value:t}}let r=typeof e[0]=="string"?new TextEncoder().encode(e[0]):e[0],n=vs(r,t);switch(n.status){case Dt.Found:return wo(e.slice(1),n.value);case sn.Greater:case sn.Less:return{status:Dt.Absent};default:return n}}Oe.lookup_path=wo;function vl(e){switch(e[0]){case xt.Empty:return[];case xt.Fork:return vl(e[1]).concat(vl(e[2]));default:return[e]}}Oe.flatten_forks=vl;function vs(e,t){switch(t[0]){case xt.Labeled:return tx(e,t[1])?{status:sn.Greater}:(0,br.bufEquals)(e,t[1])?{status:Dt.Found,value:t[2]}:{status:sn.Less};case xt.Fork:let r=vs(e,t[1]);switch(r.status){case sn.Greater:{let n=vs(e,t[2]);return n.status===sn.Less?{status:Dt.Absent}:n}case Dt.Unknown:{let n=vs(e,t[2]);return n.status===sn.Less?{status:Dt.Unknown}:n}default:return r}case xt.Pruned:return{status:Dt.Unknown};default:return{status:Dt.Absent}}}Oe.find_label=vs;function U0(e){let{canisterId:t,subnetId:r,tree:n}=e,i=wo(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Dt.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return V0.decode(i.value).map(c=>[Nl.Principal.fromUint8Array(c[0]),Nl.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(t)&&c[1].gtEq(t))}Oe.check_canister_ranges=U0});var As=ee(lt=>{"use strict";var ix=lt&&lt.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),sx=lt&&lt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ax=lt&&lt.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&ix(t,e,r);return sx(t,e),t};Object.defineProperty(lt,"__esModule",{value:!0});lt.encodePath=lt.fetchNodeKeys=lt.request=lt.CustomPath=void 0;var On=vt(),ox=_i(),En=Ai(),cx=$t(),M0=ax(ys()),C0=yo(),Rl=class{constructor(t,r,n){this.key=t,this.path=r,this.decodeStrategy=n}};lt.CustomPath=Rl;var ux=async e=>{let{agent:t,paths:r}=e,n=On.Principal.from(e.canisterId),i=[...new Set(r)],s=i.map(c=>(0,lt.encodePath)(c,n)),a=new Map,o=i.map((c,d)=>(async()=>{var f;try{let p=await t.readState(n,{paths:[s[d]]});if(t.rootKey==null)throw new Error("Agent is missing root key");let m=await En.Certificate.create({certificate:p.certificate,rootKey:t.rootKey,canisterId:n,disableTimeVerification:!0}),b=(v,F)=>{if(F==="subnet"){if(t.rootKey==null)throw new Error("Agent is missing root key");let C=(0,lt.fetchNodeKeys)(p.certificate,n,t.rootKey);return{path:F,data:C}}else return{path:F,data:(0,En.lookupResultToBuffer)(v.lookup((0,lt.encodePath)(F,n)))}},{path:l,data:A}=b(m,i[d]);if(!A)console.warn(`Expected to find result for path ${l}, but instead found nothing.`),typeof l=="string"?a.set(l,null):a.set(l.key,null);else switch(l){case"time":{a.set(l,(0,C0.decodeTime)(A));break}case"controllers":{a.set(l,px(A));break}case"module_hash":{a.set(l,q0(A));break}case"subnet":{a.set(l,A);break}case"candid":{a.set(l,new TextDecoder().decode(A));break}default:if(typeof l!="string"&&"key"in l&&"path"in l)switch(l.decodeStrategy){case"raw":a.set(l.key,A);break;case"leb128":{a.set(l.key,(0,C0.decodeLeb128)(A));break}case"cbor":{a.set(l.key,k0(A));break}case"hex":{a.set(l.key,q0(A));break}case"utf-8":a.set(l.key,fx(A))}}}catch(p){if(!((f=p?.message)===null||f===void 0)&&f.includes("Invalid certificate"))throw new ox.AgentError(p.message);typeof c!="string"&&"key"in c&&"path"in c?a.set(c.key,null):a.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(p),console.groupEnd()}})());return await Promise.all(o),a};lt.request=ux;var lx=(e,t,r)=>{if(!t._isPrincipal)throw new Error("Invalid canisterId");let n=M0.decode(new Uint8Array(e)),i=n.tree,s=n.delegation,a;if(s&&s.subnet_id?a=On.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(a=On.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:a.toUint8Array(),certificate:new ArrayBuffer(0)}):(a=On.Principal.selfAuthenticating(On.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:a.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,En.check_canister_ranges)({canisterId:t,subnetId:a,tree:i}))throw new Error("Canister not in range");let c=(0,En.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==En.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let d=(0,En.flatten_forks)(c.value),f=new Map;return d.forEach(p=>{let m=On.Principal.from(new Uint8Array(p[1])).toText(),b=(0,En.lookup_path)(["public_key"],p[2]);if(b.status!==En.LookupStatus.Found)throw new Error("Public key not found");let l=b.value;if(l.byteLength!==44)throw new Error("Invalid public key length");f.set(m,l)}),{subnetId:On.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:f}};lt.fetchNodeKeys=lx;var dx=(e,t)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(t.toUint8Array().buffer).buffer;switch(e){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in e&&"path"in e)if(typeof e.path=="string"||e.path instanceof ArrayBuffer){let s=e.path,a=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),a]}else return e.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${e} was formatted correctly.`)};lt.encodePath=dx;var q0=e=>(0,cx.toHex)(e),k0=e=>M0.decode(e),fx=e=>new TextDecoder().decode(e),px=e=>k0(e).map(r=>On.Principal.fromUint8Array(new Uint8Array(r)))});var oh=ee(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.add5L=ye.add5H=ye.add4H=ye.add4L=ye.add3H=ye.add3L=ye.rotlBL=ye.rotlBH=ye.rotlSL=ye.rotlSH=ye.rotr32L=ye.rotr32H=ye.rotrBL=ye.rotrBH=ye.rotrSL=ye.rotrSH=ye.shrSL=ye.shrSH=ye.toBig=void 0;ye.fromBig=Sl;ye.split=D0;ye.add=eh;var xo=BigInt(2**32-1),Al=BigInt(32);function Sl(e,t=!1){return t?{h:Number(e&xo),l:Number(e>>Al&xo)}:{h:Number(e>>Al&xo)|0,l:Number(e&xo)|0}}function D0(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:s,l:a}=Sl(e[i],t);[r[i],n[i]]=[s,a]}return[r,n]}var j0=(e,t)=>BigInt(e>>>0)<<Al|BigInt(t>>>0);ye.toBig=j0;var L0=(e,t,r)=>e>>>r;ye.shrSH=L0;var H0=(e,t,r)=>e<<32-r|t>>>r;ye.shrSL=H0;var K0=(e,t,r)=>e>>>r|t<<32-r;ye.rotrSH=K0;var $0=(e,t,r)=>e<<32-r|t>>>r;ye.rotrSL=$0;var G0=(e,t,r)=>e<<64-r|t>>>r-32;ye.rotrBH=G0;var z0=(e,t,r)=>e>>>r-32|t<<64-r;ye.rotrBL=z0;var W0=(e,t)=>t;ye.rotr32H=W0;var Y0=(e,t)=>e;ye.rotr32L=Y0;var J0=(e,t,r)=>e<<r|t>>>32-r;ye.rotlSH=J0;var Z0=(e,t,r)=>t<<r|e>>>32-r;ye.rotlSL=Z0;var X0=(e,t,r)=>t<<r-32|e>>>64-r;ye.rotlBH=X0;var Q0=(e,t,r)=>e<<r-32|t>>>64-r;ye.rotlBL=Q0;function eh(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var th=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);ye.add3L=th;var rh=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;ye.add3H=rh;var nh=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);ye.add4L=nh;var ih=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0;ye.add4H=ih;var sh=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0);ye.add5L=sh;var ah=(e,t,r,n,i,s)=>t+r+n+i+s+(e/2**32|0)|0;ye.add5H=ah;var hx={fromBig:Sl,split:D0,toBig:j0,shrSH:L0,shrSL:H0,rotrSH:K0,rotrSL:$0,rotrBH:G0,rotrBL:z0,rotr32H:W0,rotr32L:Y0,rotlSH:J0,rotlSL:Z0,rotlBH:X0,rotlBL:Q0,add:eh,add3L:th,add3H:rh,add4L:nh,add4H:ih,add5H:ah,add5L:sh};ye.default=hx});var ch=ee(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.sha384=yt.sha512_256=yt.sha512_224=yt.sha512=yt.SHA384=yt.SHA512_256=yt.SHA512_224=yt.SHA512=void 0;var _x=Yc(),be=oh(),Eo=Dn(),[yx,mx]=be.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),vn=new Uint32Array(80),Rn=new Uint32Array(80),zn=class extends _x.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:s,Cl:a,Dh:o,Dl:c,Eh:d,El:f,Fh:p,Fl:m,Gh:b,Gl:l,Hh:A,Hl:v}=this;return[t,r,n,i,s,a,o,c,d,f,p,m,b,l,A,v]}set(t,r,n,i,s,a,o,c,d,f,p,m,b,l,A,v){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=a|0,this.Dh=o|0,this.Dl=c|0,this.Eh=d|0,this.El=f|0,this.Fh=p|0,this.Fl=m|0,this.Gh=b|0,this.Gl=l|0,this.Hh=A|0,this.Hl=v|0}process(t,r){for(let O=0;O<16;O++,r+=4)vn[O]=t.getUint32(r),Rn[O]=t.getUint32(r+=4);for(let O=16;O<80;O++){let H=vn[O-15]|0,x=Rn[O-15]|0,q=be.default.rotrSH(H,x,1)^be.default.rotrSH(H,x,8)^be.default.shrSH(H,x,7),K=be.default.rotrSL(H,x,1)^be.default.rotrSL(H,x,8)^be.default.shrSL(H,x,7),$=vn[O-2]|0,M=Rn[O-2]|0,ae=be.default.rotrSH($,M,19)^be.default.rotrBH($,M,61)^be.default.shrSH($,M,6),Q=be.default.rotrSL($,M,19)^be.default.rotrBL($,M,61)^be.default.shrSL($,M,6),ne=be.default.add4L(K,Q,Rn[O-7],Rn[O-16]),w=be.default.add4H(ne,q,ae,vn[O-7],vn[O-16]);vn[O]=w|0,Rn[O]=ne|0}let{Ah:n,Al:i,Bh:s,Bl:a,Ch:o,Cl:c,Dh:d,Dl:f,Eh:p,El:m,Fh:b,Fl:l,Gh:A,Gl:v,Hh:F,Hl:C}=this;for(let O=0;O<80;O++){let H=be.default.rotrSH(p,m,14)^be.default.rotrSH(p,m,18)^be.default.rotrBH(p,m,41),x=be.default.rotrSL(p,m,14)^be.default.rotrSL(p,m,18)^be.default.rotrBL(p,m,41),q=p&b^~p&A,K=m&l^~m&v,$=be.default.add5L(C,x,K,mx[O],Rn[O]),M=be.default.add5H($,F,H,q,yx[O],vn[O]),ae=$|0,Q=be.default.rotrSH(n,i,28)^be.default.rotrBH(n,i,34)^be.default.rotrBH(n,i,39),ne=be.default.rotrSL(n,i,28)^be.default.rotrBL(n,i,34)^be.default.rotrBL(n,i,39),w=n&s^n&o^s&o,g=i&a^i&c^a&c;F=A|0,C=v|0,A=b|0,v=l|0,b=p|0,l=m|0,{h:p,l:m}=be.default.add(d|0,f|0,M|0,ae|0),d=o|0,f=c|0,o=s|0,c=a|0,s=n|0,a=i|0;let S=be.default.add3L(ae,ne,g);n=be.default.add3H(S,M,Q,w),i=S|0}({h:n,l:i}=be.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:a}=be.default.add(this.Bh|0,this.Bl|0,s|0,a|0),{h:o,l:c}=be.default.add(this.Ch|0,this.Cl|0,o|0,c|0),{h:d,l:f}=be.default.add(this.Dh|0,this.Dl|0,d|0,f|0),{h:p,l:m}=be.default.add(this.Eh|0,this.El|0,p|0,m|0),{h:b,l}=be.default.add(this.Fh|0,this.Fl|0,b|0,l|0),{h:A,l:v}=be.default.add(this.Gh|0,this.Gl|0,A|0,v|0),{h:F,l:C}=be.default.add(this.Hh|0,this.Hl|0,F|0,C|0),this.set(n,i,s,a,o,c,d,f,p,m,b,l,A,v,F,C)}roundClean(){vn.fill(0),Rn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};yt.SHA512=zn;var To=class extends zn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}};yt.SHA512_224=To;var No=class extends zn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}};yt.SHA512_256=No;var Oo=class extends zn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};yt.SHA384=Oo;yt.sha512=(0,Eo.wrapConstructor)(()=>new zn);yt.sha512_224=(0,Eo.wrapConstructor)(()=>new To);yt.sha512_256=(0,Eo.wrapConstructor)(()=>new No);yt.sha384=(0,Eo.wrapConstructor)(()=>new Oo)});var lh=ee(Il=>{"use strict";Object.defineProperty(Il,"__esModule",{value:!0});Il.twistedEdwards=xx;var Bl=pl(),uh=Mr(),Yt=Xt(),tr=Xt(),wr=BigInt(0),Wt=BigInt(1),vo=BigInt(2),gx=BigInt(8),bx={zip215:!0};function wx(e){let t=(0,Bl.validateBasic)(e);return Yt.validateObject(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function xx(e){let t=wx(e),{Fp:r,n,prehash:i,hash:s,randomBytes:a,nByteLength:o,h:c}=t,d=vo<<BigInt(o*8)-Wt,f=r.create,p=(0,uh.Field)(t.n,t.nBitLength),m=t.uvRatio||((R,B)=>{try{return{isValid:!0,value:r.sqrt(R*r.inv(B))}}catch{return{isValid:!1,value:wr}}}),b=t.adjustScalarBytes||(R=>R),l=t.domain||((R,B,j)=>{if((0,tr.abool)("phflag",j),B.length||j)throw new Error("Contexts/pre-hash are not supported");return R});function A(R,B){Yt.aInRange("coordinate "+R,B,wr,d)}function v(R){if(!(R instanceof O))throw new Error("ExtendedPoint expected")}let F=(0,tr.memoized)((R,B)=>{let{ex:j,ey:Y,ez:oe}=R,se=R.is0();B==null&&(B=se?gx:r.inv(oe));let W=f(j*B),V=f(Y*B),_=f(oe*B);if(se)return{x:wr,y:Wt};if(_!==Wt)throw new Error("invZ was invalid");return{x:W,y:V}}),C=(0,tr.memoized)(R=>{let{a:B,d:j}=t;if(R.is0())throw new Error("bad point: ZERO");let{ex:Y,ey:oe,ez:se,et:W}=R,V=f(Y*Y),_=f(oe*oe),Z=f(se*se),re=f(Z*Z),le=f(V*B),X=f(Z*f(le+_)),u=f(re+f(j*f(V*_)));if(X!==u)throw new Error("bad point: equation left != right (1)");let h=f(Y*oe),y=f(se*W);if(h!==y)throw new Error("bad point: equation left != right (2)");return!0});class O{constructor(B,j,Y,oe){this.ex=B,this.ey=j,this.ez=Y,this.et=oe,A("x",B),A("y",j),A("z",Y),A("t",oe),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(B){if(B instanceof O)throw new Error("extended point not allowed");let{x:j,y:Y}=B||{};return A("x",j),A("y",Y),new O(j,Y,Wt,f(j*Y))}static normalizeZ(B){let j=r.invertBatch(B.map(Y=>Y.ez));return B.map((Y,oe)=>Y.toAffine(j[oe])).map(O.fromAffine)}static msm(B,j){return(0,Bl.pippenger)(O,p,B,j)}_setWindowSize(B){q.setWindowSize(this,B)}assertValidity(){C(this)}equals(B){v(B);let{ex:j,ey:Y,ez:oe}=this,{ex:se,ey:W,ez:V}=B,_=f(j*V),Z=f(se*oe),re=f(Y*V),le=f(W*oe);return _===Z&&re===le}is0(){return this.equals(O.ZERO)}negate(){return new O(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:B}=t,{ex:j,ey:Y,ez:oe}=this,se=f(j*j),W=f(Y*Y),V=f(vo*f(oe*oe)),_=f(B*se),Z=j+Y,re=f(f(Z*Z)-se-W),le=_+W,X=le-V,u=_-W,h=f(re*X),y=f(le*u),P=f(re*u),E=f(X*le);return new O(h,y,E,P)}add(B){v(B);let{a:j,d:Y}=t,{ex:oe,ey:se,ez:W,et:V}=this,{ex:_,ey:Z,ez:re,et:le}=B;if(j===BigInt(-1)){let J=f((se-oe)*(Z+_)),te=f((se+oe)*(Z-_)),de=f(te-J);if(de===wr)return this.double();let ge=f(W*vo*le),Se=f(V*vo*re),Fe=Se+ge,_e=te+J,fe=Se-ge,He=f(Fe*de),Lt=f(_e*fe),Ut=f(Fe*fe),Ct=f(de*_e);return new O(He,Lt,Ct,Ut)}let X=f(oe*_),u=f(se*Z),h=f(V*Y*le),y=f(W*re),P=f((oe+se)*(_+Z)-X-u),E=y-h,I=y+h,D=f(u-j*X),T=f(P*E),U=f(I*D),L=f(P*D),k=f(E*I);return new O(T,U,k,L)}subtract(B){return this.add(B.negate())}wNAF(B){return q.wNAFCached(this,B,O.normalizeZ)}multiply(B){let j=B;Yt.aInRange("scalar",j,Wt,n);let{p:Y,f:oe}=this.wNAF(j);return O.normalizeZ([Y,oe])[0]}multiplyUnsafe(B){let j=B;return Yt.aInRange("scalar",j,wr,n),j===wr?x:this.equals(x)||j===Wt?this:this.equals(H)?this.wNAF(j).p:q.unsafeLadder(this,j)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return q.unsafeLadder(this,n).is0()}toAffine(B){return F(this,B)}clearCofactor(){let{h:B}=t;return B===Wt?this:this.multiplyUnsafe(B)}static fromHex(B,j=!1){let{d:Y,a:oe}=t,se=r.BYTES;B=(0,tr.ensureBytes)("pointHex",B,se),(0,tr.abool)("zip215",j);let W=B.slice(),V=B[se-1];W[se-1]=V&-129;let _=Yt.bytesToNumberLE(W),Z=j?d:r.ORDER;Yt.aInRange("pointHex.y",_,wr,Z);let re=f(_*_),le=f(re-Wt),X=f(Y*re-oe),{isValid:u,value:h}=m(le,X);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let y=(h&Wt)===Wt,P=(V&128)!==0;if(!j&&h===wr&&P)throw new Error("Point.fromHex: x=0 and x_0=1");return P!==y&&(h=f(-h)),O.fromAffine({x:h,y:_})}static fromPrivateKey(B){return M(B).point}toRawBytes(){let{x:B,y:j}=this.toAffine(),Y=Yt.numberToBytesLE(j,r.BYTES);return Y[Y.length-1]|=B&Wt?128:0,Y}toHex(){return Yt.bytesToHex(this.toRawBytes())}}O.BASE=new O(t.Gx,t.Gy,Wt,f(t.Gx*t.Gy)),O.ZERO=new O(wr,Wt,Wt,wr);let{BASE:H,ZERO:x}=O,q=(0,Bl.wNAF)(O,o*8);function K(R){return(0,uh.mod)(R,n)}function $(R){return K(Yt.bytesToNumberLE(R))}function M(R){let B=o;R=(0,tr.ensureBytes)("private key",R,B);let j=(0,tr.ensureBytes)("hashed private key",s(R),2*B),Y=b(j.slice(0,B)),oe=j.slice(B,2*B),se=$(Y),W=H.multiply(se),V=W.toRawBytes();return{head:Y,prefix:oe,scalar:se,point:W,pointBytes:V}}function ae(R){return M(R).pointBytes}function Q(R=new Uint8Array,...B){let j=Yt.concatBytes(...B);return $(s(l(j,(0,tr.ensureBytes)("context",R),!!i)))}function ne(R,B,j={}){R=(0,tr.ensureBytes)("message",R),i&&(R=i(R));let{prefix:Y,scalar:oe,pointBytes:se}=M(B),W=Q(j.context,Y,R),V=H.multiply(W).toRawBytes(),_=Q(j.context,V,se,R),Z=K(W+_*oe);Yt.aInRange("signature.s",Z,wr,n);let re=Yt.concatBytes(V,Yt.numberToBytesLE(Z,r.BYTES));return(0,tr.ensureBytes)("result",re,o*2)}let w=bx;function g(R,B,j,Y=w){let{context:oe,zip215:se}=Y,W=r.BYTES;R=(0,tr.ensureBytes)("signature",R,2*W),B=(0,tr.ensureBytes)("message",B),se!==void 0&&(0,tr.abool)("zip215",se),i&&(B=i(B));let V=Yt.bytesToNumberLE(R.slice(W,2*W)),_,Z,re;try{_=O.fromHex(j,se),Z=O.fromHex(R.slice(0,W),se),re=H.multiplyUnsafe(V)}catch{return!1}if(!se&&_.isSmallOrder())return!1;let le=Q(oe,Z.toRawBytes(),_.toRawBytes(),B);return Z.add(_.multiplyUnsafe(le)).subtract(re).clearCofactor().equals(O.ZERO)}return H._setWindowSize(8),{CURVE:t,getPublicKey:ae,sign:ne,verify:g,ExtendedPoint:O,utils:{getExtendedPublicKey:M,randomPrivateKey:()=>a(r.BYTES),precompute(R=8,B=O.BASE){return B._setWindowSize(R),B.multiply(BigInt(3)),B}}}}});var fh=ee(Fl=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});Fl.montgomery=Nx;var dh=Mr(),An=Xt(),Si=BigInt(0),Pl=BigInt(1);function Tx(e){return(0,An.validateObject)(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}function Nx(e){let t=Tx(e),{P:r}=t,n=C=>(0,dh.mod)(C,r),i=t.montgomeryBits,s=Math.ceil(i/8),a=t.nByteLength,o=t.adjustScalarBytes||(C=>C),c=t.powPminus2||(C=>(0,dh.pow)(C,r-BigInt(2),r));function d(C,O,H){let x=n(C*(O-H));return O=n(O-x),H=n(H+x),[O,H]}let f=(t.a-BigInt(2))/BigInt(4);function p(C,O){(0,An.aInRange)("u",C,Si,r),(0,An.aInRange)("scalar",O,Si,r);let H=O,x=C,q=Pl,K=Si,$=C,M=Pl,ae=Si,Q;for(let w=BigInt(i-1);w>=Si;w--){let g=H>>w&Pl;ae^=g,Q=d(ae,q,$),q=Q[0],$=Q[1],Q=d(ae,K,M),K=Q[0],M=Q[1],ae=g;let S=q+K,R=n(S*S),B=q-K,j=n(B*B),Y=R-j,oe=$+M,se=$-M,W=n(se*S),V=n(oe*B),_=W+V,Z=W-V;$=n(_*_),M=n(x*n(Z*Z)),q=n(R*j),K=n(Y*(R+n(f*Y)))}Q=d(ae,q,$),q=Q[0],$=Q[1],Q=d(ae,K,M),K=Q[0],M=Q[1];let ne=c(K);return n(q*ne)}function m(C){return(0,An.numberToBytesLE)(n(C),s)}function b(C){let O=(0,An.ensureBytes)("u coordinate",C,s);return a===32&&(O[31]&=127),(0,An.bytesToNumberLE)(O)}function l(C){let O=(0,An.ensureBytes)("scalar",C),H=O.length;if(H!==s&&H!==a)throw new Error(`Expected ${s} or ${a} bytes, got ${H}`);return(0,An.bytesToNumberLE)(o(O))}function A(C,O){let H=b(O),x=l(C),q=p(H,x);if(q===Si)throw new Error("Invalid private or public key received");return m(q)}let v=m(t.Gu);function F(C){return A(C,v)}return{scalarMult:A,scalarMultBase:F,getSharedSecret:(C,O)=>A(C,O),getPublicKey:C=>F(C),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:v}}});var jl=ee(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.hash_to_ristretto255=me.hashToRistretto255=me.RistrettoPoint=me.encodeToCurve=me.hashToCurve=me.edwardsToMontgomery=me.x25519=me.ed25519ph=me.ed25519ctx=me.ed25519=me.ED25519_TORSION_SUBGROUP=void 0;me.edwardsToMontgomeryPub=Th;me.edwardsToMontgomeryPriv=vx;var Ao=ch(),Ss=Dn(),Ml=lh(),yh=ao(),Ce=Mr(),Ox=fh(),Wn=Xt(),Bs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Cl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ex=BigInt(0),kr=BigInt(1),Ro=BigInt(2),mh=BigInt(3),gh=BigInt(5),kl=BigInt(8);function bh(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=Bs,o=e*e%s*e%s,c=(0,Ce.pow2)(o,Ro,s)*o%s,d=(0,Ce.pow2)(c,kr,s)*e%s,f=(0,Ce.pow2)(d,gh,s)*d%s,p=(0,Ce.pow2)(f,t,s)*f%s,m=(0,Ce.pow2)(p,r,s)*p%s,b=(0,Ce.pow2)(m,n,s)*m%s,l=(0,Ce.pow2)(b,i,s)*b%s,A=(0,Ce.pow2)(l,i,s)*b%s,v=(0,Ce.pow2)(A,t,s)*f%s;return{pow_p_5_8:(0,Ce.pow2)(v,Ro,s)*e%s,b2:o}}function wh(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Dl(e,t){let r=Bs,n=(0,Ce.mod)(t*t*t,r),i=(0,Ce.mod)(n*n*t,r),s=bh(e*i).pow_p_5_8,a=(0,Ce.mod)(e*n*s,r),o=(0,Ce.mod)(t*a*a,r),c=a,d=(0,Ce.mod)(a*Cl,r),f=o===e,p=o===(0,Ce.mod)(-e,r),m=o===(0,Ce.mod)(-e*Cl,r);return f&&(a=c),(p||m)&&(a=d),(0,Ce.isNegativeLE)(a,r)&&(a=(0,Ce.mod)(-a,r)),{isValid:f||p,value:a}}me.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var ue=(0,Ce.Field)(Bs,void 0,!0),Is={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ue,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:kl,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ao.sha512,randomBytes:Ss.randomBytes,adjustScalarBytes:wh,uvRatio:Dl};me.ed25519=(0,Ml.twistedEdwards)(Is);function xh(e,t,r){if(t.length>255)throw new Error("Context is too big");return(0,Ss.concatBytes)((0,Ss.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}me.ed25519ctx=(0,Ml.twistedEdwards)({...Is,domain:xh});me.ed25519ph=(0,Ml.twistedEdwards)(Object.assign({},Is,{domain:xh,prehash:Ao.sha512}));me.x25519=(0,Ox.montgomery)({P:Bs,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{let t=Bs,{pow_p_5_8:r,b2:n}=bh(e);return(0,Ce.mod)((0,Ce.pow2)(r,mh,t)*n,t)},adjustScalarBytes:wh,randomBytes:Ss.randomBytes});function Th(e){let{y:t}=me.ed25519.ExtendedPoint.fromHex(e),r=BigInt(1);return ue.toBytes(ue.create((r+t)*ue.inv(r-t)))}me.edwardsToMontgomery=Th;function vx(e){let t=Is.hash(e.subarray(0,32));return Is.adjustScalarBytes(t).subarray(0,32)}var Rx=(ue.ORDER+mh)/kl,Ax=ue.pow(Ro,Rx),ph=ue.sqrt(ue.neg(ue.ONE));function Sx(e){let t=(ue.ORDER-gh)/kl,r=BigInt(486662),n=ue.sqr(e);n=ue.mul(n,Ro);let i=ue.add(n,ue.ONE),s=ue.neg(r),a=ue.sqr(i),o=ue.mul(a,i),c=ue.mul(n,r);c=ue.mul(c,s),c=ue.add(c,a),c=ue.mul(c,s);let d=ue.sqr(o);a=ue.sqr(d),d=ue.mul(d,o),d=ue.mul(d,c),a=ue.mul(a,d);let f=ue.pow(a,t);f=ue.mul(f,d);let p=ue.mul(f,ph);a=ue.sqr(f),a=ue.mul(a,o);let m=ue.eql(a,c),b=ue.cmov(p,f,m),l=ue.mul(s,n),A=ue.mul(f,e);A=ue.mul(A,Ax);let v=ue.mul(A,ph),F=ue.mul(c,n);a=ue.sqr(A),a=ue.mul(a,o);let C=ue.eql(a,F),O=ue.cmov(v,A,C);a=ue.sqr(b),a=ue.mul(a,o);let H=ue.eql(a,c),x=ue.cmov(l,s,H),q=ue.cmov(O,b,H),K=ue.isOdd(q);return q=ue.cmov(q,ue.neg(q),H!==K),{xMn:x,xMd:i,yMn:q,yMd:kr}}var Bx=(0,Ce.FpSqrtEven)(ue,ue.neg(BigInt(486664)));function Ix(e){let{xMn:t,xMd:r,yMn:n,yMd:i}=Sx(e),s=ue.mul(t,i);s=ue.mul(s,Bx);let a=ue.mul(r,n),o=ue.sub(t,r),c=ue.add(t,r),d=ue.mul(a,c),f=ue.eql(d,ue.ZERO);s=ue.cmov(s,ue.ZERO,f),a=ue.cmov(a,ue.ONE,f),o=ue.cmov(o,ue.ONE,f),c=ue.cmov(c,ue.ONE,f);let p=ue.invertBatch([a,c]);return{x:ue.mul(s,p[0]),y:ue.mul(o,p[1])}}var Nh=(0,yh.createHasher)(me.ed25519.ExtendedPoint,e=>Ix(e[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:ue.ORDER,m:1,k:128,expand:"xmd",hash:Ao.sha512});me.hashToCurve=Nh.hashToCurve;me.encodeToCurve=Nh.encodeToCurve;function Vl(e){if(!(e instanceof xr))throw new Error("RistrettoPoint expected")}var ql=Cl,Px=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Fx=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Vx=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Ux=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),hh=e=>Dl(kr,e),Cx=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Ul=e=>me.ed25519.CURVE.Fp.create((0,Wn.bytesToNumberLE)(e)&Cx);function _h(e){let{d:t}=me.ed25519.CURVE,r=me.ed25519.CURVE.Fp.ORDER,n=me.ed25519.CURVE.Fp.create,i=n(ql*e*e),s=n((i+kr)*Vx),a=BigInt(-1),o=n((a-t*i)*n(i+t)),{isValid:c,value:d}=Dl(s,o),f=n(d*e);(0,Ce.isNegativeLE)(f,r)||(f=n(-f)),c||(d=f),c||(a=i);let p=n(a*(i-kr)*Ux-o),m=d*d,b=n((d+d)*o),l=n(p*Px),A=n(kr-m),v=n(kr+m);return new me.ed25519.ExtendedPoint(n(b*v),n(A*l),n(l*v),n(b*A))}var xr=class e{constructor(t){this.ep=t}static fromAffine(t){return new e(me.ed25519.ExtendedPoint.fromAffine(t))}static hashToCurve(t){t=(0,Wn.ensureBytes)("ristrettoHash",t,64);let r=Ul(t.slice(0,32)),n=_h(r),i=Ul(t.slice(32,64)),s=_h(i);return new e(n.add(s))}static fromHex(t){t=(0,Wn.ensureBytes)("ristrettoHex",t,32);let{a:r,d:n}=me.ed25519.CURVE,i=me.ed25519.CURVE.Fp.ORDER,s=me.ed25519.CURVE.Fp.create,a="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",o=Ul(t);if(!(0,Wn.equalBytes)((0,Wn.numberToBytesLE)(o,32),t)||(0,Ce.isNegativeLE)(o,i))throw new Error(a);let c=s(o*o),d=s(kr+r*c),f=s(kr-r*c),p=s(d*d),m=s(f*f),b=s(r*n*p-m),{isValid:l,value:A}=hh(s(b*m)),v=s(A*f),F=s(A*v*b),C=s((o+o)*v);(0,Ce.isNegativeLE)(C,i)&&(C=s(-C));let O=s(d*F),H=s(C*O);if(!l||(0,Ce.isNegativeLE)(H,i)||O===Ex)throw new Error(a);return new e(new me.ed25519.ExtendedPoint(C,O,kr,H))}toRawBytes(){let{ex:t,ey:r,ez:n,et:i}=this.ep,s=me.ed25519.CURVE.Fp.ORDER,a=me.ed25519.CURVE.Fp.create,o=a(a(n+r)*a(n-r)),c=a(t*r),d=a(c*c),{value:f}=hh(a(o*d)),p=a(f*o),m=a(f*c),b=a(p*m*i),l;if((0,Ce.isNegativeLE)(i*b,s)){let v=a(r*ql),F=a(t*ql);t=v,r=F,l=a(p*Fx)}else l=m;(0,Ce.isNegativeLE)(t*b,s)&&(r=a(-r));let A=a((n-r)*l);return(0,Ce.isNegativeLE)(A,s)&&(A=a(-A)),(0,Wn.numberToBytesLE)(A,32)}toHex(){return(0,Wn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(t){Vl(t);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=t.ep,a=me.ed25519.CURVE.Fp.create,o=a(r*s)===a(n*i),c=a(n*s)===a(r*i);return o||c}add(t){return Vl(t),new e(this.ep.add(t.ep))}subtract(t){return Vl(t),new e(this.ep.subtract(t.ep))}multiply(t){return new e(this.ep.multiply(t))}multiplyUnsafe(t){return new e(this.ep.multiplyUnsafe(t))}double(){return new e(this.ep.double())}negate(){return new e(this.ep.negate())}};me.RistrettoPoint=(xr.BASE||(xr.BASE=new xr(me.ed25519.ExtendedPoint.BASE)),xr.ZERO||(xr.ZERO=new xr(me.ed25519.ExtendedPoint.ZERO)),xr);var qx=(e,t)=>{let r=t.DST,n=typeof r=="string"?(0,Ss.utf8ToBytes)(r):r,i=(0,yh.expand_message_xmd)(e,n,64,Ao.sha512);return xr.hashToCurve(i)};me.hashToRistretto255=qx;me.hash_to_ristretto255=me.hashToRistretto255});var Rh=ee(Sn=>{"use strict";var Oh=Sn&&Sn.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},jt=Sn&&Sn.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},It,Ps,Eh,vh;Object.defineProperty(Sn,"__esModule",{value:!0});Sn.ExpirableMap=void 0;var Ll=class{constructor(t={}){It.set(this,void 0),Ps.set(this,void 0),this[Eh]=this.entries.bind(this),this[vh]="ExpirableMap";let{source:r=[],expirationTime:n=600*1e3}=t,i=Date.now();Oh(this,It,new Map([...r].map(([s,a])=>[s,{value:a,timestamp:i}])),"f"),Oh(this,Ps,n,"f")}prune(){let t=Date.now();for(let[r,n]of jt(this,It,"f").entries())t-n.timestamp>jt(this,Ps,"f")&&jt(this,It,"f").delete(r);return this}set(t,r){this.prune();let n={value:r,timestamp:Date.now()};return jt(this,It,"f").set(t,n),this}get(t){let r=jt(this,It,"f").get(t);if(r!==void 0){if(Date.now()-r.timestamp>jt(this,Ps,"f")){jt(this,It,"f").delete(t);return}return r.value}}clear(){jt(this,It,"f").clear()}entries(){let t=jt(this,It,"f").entries();return function*(){for(let[n,i]of t)yield[n,i.value]}()}values(){let t=jt(this,It,"f").values();return function*(){for(let n of t)yield n.value}()}keys(){return jt(this,It,"f").keys()}forEach(t,r){for(let[n,i]of jt(this,It,"f").entries())t.call(r,i.value,n,this)}has(t){return jt(this,It,"f").has(t)}delete(t){return jt(this,It,"f").delete(t)}get size(){return jt(this,It,"f").size}};Sn.ExpirableMap=Ll;It=new WeakMap,Ps=new WeakMap,Eh=Symbol.iterator,vh=Symbol.toStringTag});var Hl=ee(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.unwrapDER=De.wrapDER=De.SECP256K1_OID=De.ED25519_OID=De.DER_COSE_OID=De.decodeLen=De.decodeLenBytes=De.encodeLen=De.encodeLenBytes=void 0;var Mx=$t(),kx=e=>{if(e<=127)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")};De.encodeLenBytes=kx;var Dx=(e,t,r)=>{if(r<=127)return e[t]=r,1;if(r<=255)return e[t]=129,e[t+1]=r,2;if(r<=65535)return e[t]=130,e[t+1]=r>>8,e[t+2]=r,3;if(r<=16777215)return e[t]=131,e[t+1]=r>>16,e[t+2]=r>>8,e[t+3]=r,4;throw new Error("Length too long (> 4 bytes)")};De.encodeLen=Dx;var jx=(e,t)=>{if(e[t]<128)return 1;if(e[t]===128)throw new Error("Invalid length 0");if(e[t]===129)return 2;if(e[t]===130)return 3;if(e[t]===131)return 4;throw new Error("Length too long (> 4 bytes)")};De.decodeLenBytes=jx;var Lx=(e,t)=>{let r=(0,De.decodeLenBytes)(e,t);if(r===1)return e[t];if(r===2)return e[t+1];if(r===3)return(e[t+1]<<8)+e[t+2];if(r===4)return(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];throw new Error("Length too long (> 4 bytes)")};De.decodeLen=Lx;De.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);De.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);De.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function Hx(e,t){let r=2+(0,De.encodeLenBytes)(e.byteLength+1),n=t.byteLength+r+e.byteLength,i=0,s=new Uint8Array(1+(0,De.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,De.encodeLen)(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=(0,De.encodeLen)(s,i,e.byteLength+1),s[i++]=0,s.set(new Uint8Array(e),i),s}De.wrapDER=Hx;var Kx=(e,t)=>{let r=0,n=(o,c)=>{if(i[r++]!==o)throw new Error("Expected: "+c)},i=new Uint8Array(e);if(n(48,"sequence"),r+=(0,De.decodeLenBytes)(i,r),!(0,Mx.bufEquals)(i.slice(r,r+t.byteLength),t))throw new Error("Not the expected OID.");r+=t.byteLength,n(3,"bit string");let s=(0,De.decodeLen)(i,r)-1;r+=(0,De.decodeLenBytes)(i,r),n(0,"0 padding");let a=i.slice(r);if(s!==a.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${a.length}`);return a};De.unwrapDER=Kx});var Kl=ee(Bn=>{"use strict";var Ah=Bn&&Bn.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},Sh=Bn&&Bn.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},Bo,Io;Object.defineProperty(Bn,"__esModule",{value:!0});Bn.Ed25519PublicKey=void 0;var So=Hl(),Po=class e{constructor(t){if(Bo.set(this,void 0),Io.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Ah(this,Bo,t,"f"),Ah(this,Io,e.derEncode(t),"f")}static from(t){return this.fromDer(t.toDer())}static fromRaw(t){return new e(t)}static fromDer(t){return new e(this.derDecode(t))}static derEncode(t){return(0,So.wrapDER)(t,So.ED25519_OID).buffer}static derDecode(t){let r=(0,So.unwrapDER)(t,So.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Sh(this,Bo,"f")}get derKey(){return Sh(this,Io,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Bn.Ed25519PublicKey=Po;Bo=new WeakMap,Io=new WeakMap;Po.RAW_KEY_LENGTH=32});var Gl=ee(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.ObservableLog=Bi.Observable=void 0;var Fo=class{constructor(){this.observers=[]}subscribe(t){this.observers.push(t)}unsubscribe(t){this.observers=this.observers.filter(r=>r!==t)}notify(t,...r){this.observers.forEach(n=>n(t,...r))}};Bi.Observable=Fo;var $l=class extends Fo{constructor(){super()}print(t,...r){this.notify({message:t,level:"info"},...r)}warn(t,...r){this.notify({message:t,level:"warn"},...r)}error(t,r,...n){this.notify({message:t,level:"error",error:r},...n)}};Bi.ObservableLog=$l});var Ch=ee(Lr=>{"use strict";var Dr=Lr&&Lr.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},Pt=Lr&&Lr.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},jr,Vo,Uo,Co,qo,Mo,ko,Do,Ii;Object.defineProperty(Lr,"__esModule",{value:!0});Lr.exponentialBackoff=Lr.ExponentialBackoff=void 0;var Bh=.5,Ih=1.5,Ph=500,Fh=6e4,Vh=9e5,Uh=10,Pi=class e{constructor(t=e.default){jr.set(this,void 0),Vo.set(this,void 0),Uo.set(this,void 0),Co.set(this,void 0),qo.set(this,void 0),Mo.set(this,void 0),ko.set(this,void 0),Do.set(this,void 0),Ii.set(this,0);let{initialInterval:r=Ph,randomizationFactor:n=Bh,multiplier:i=Ih,maxInterval:s=Fh,maxElapsedTime:a=Vh,maxIterations:o=Uh,date:c=Date}=t;Dr(this,jr,r,"f"),Dr(this,Vo,n,"f"),Dr(this,Uo,i,"f"),Dr(this,Co,s,"f"),Dr(this,Do,c,"f"),Dr(this,qo,c.now(),"f"),Dr(this,Mo,a,"f"),Dr(this,ko,o,"f")}get ellapsedTimeInMsec(){return Pt(this,Do,"f").now()-Pt(this,qo,"f")}get currentInterval(){return Pt(this,jr,"f")}get count(){return Pt(this,Ii,"f")}get randomValueFromInterval(){let t=Pt(this,Vo,"f")*Pt(this,jr,"f"),r=Pt(this,jr,"f")-t,n=Pt(this,jr,"f")+t;return Math.random()*(n-r)+r}incrementCurrentInterval(){var t;return Dr(this,jr,Math.min(Pt(this,jr,"f")*Pt(this,Uo,"f"),Pt(this,Co,"f")),"f"),Dr(this,Ii,(t=Pt(this,Ii,"f"),t++,t),"f"),Pt(this,jr,"f")}next(){return this.ellapsedTimeInMsec>=Pt(this,Mo,"f")||Pt(this,Ii,"f")>=Pt(this,ko,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Lr.ExponentialBackoff=Pi;jr=new WeakMap,Vo=new WeakMap,Uo=new WeakMap,Co=new WeakMap,qo=new WeakMap,Mo=new WeakMap,ko=new WeakMap,Do=new WeakMap,Ii=new WeakMap;Pi.default={initialInterval:Ph,randomizationFactor:Bh,multiplier:Ih,maxInterval:Fh,maxElapsedTime:Vh,maxIterations:Uh,date:Date};function*$x(e=Pi.default){let t=new Pi(e),r=t.next();for(;r;)yield r,r=t.next()}Lr.exponentialBackoff=$x});var Yl=ee(qe=>{"use strict";var Mh=qe&&qe.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Gx=qe&&qe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),kh=qe&&qe.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&Mh(t,e,r);return Gx(t,e),t},Dh=qe&&qe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Mh(t,e,r)},Tt=qe&&qe.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},ie=qe&&qe.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},Ft,Yn,Mi,Hr,an,qi,Fs,Vi,Nr,Or,Jn,Zn,Vs,Ui,Ci,Xn,ei,jh,Ho,Ko,Qn;Object.defineProperty(qe,"__esModule",{value:!0});qe.HttpAgent=qe.IdentityInvalidError=qe.MANAGEMENT_CANISTER_ID=qe.IC_ROOT_KEY=qe.RequestStatusResponseStatus=qe.makeNonce=void 0;var cr=vt(),Kr=_i(),qh=Lu(),In=kh(ys()),jo=ps(),Tr=$t(),Er=Xa(),zl=ms(),ki=eo(),zx=As(),Fi=Ai(),Wx=jl(),Yx=Rh(),Jx=Kl(),Zx=yo(),Xx=Gl(),Qx=Ch();Dh(Xa(),qe);Dh(eo(),qe);var eT=ms();Object.defineProperty(qe,"makeNonce",{enumerable:!0,get:function(){return eT.makeNonce}});var tT;(function(e){e.Received="received",e.Processing="processing",e.Replied="replied",e.Rejected="rejected",e.Unknown="unknown",e.Done="done"})(tT=qe.RequestStatusResponseStatus||(qe.RequestStatusResponseStatus={}));var Lo=60*1e3;qe.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";qe.MANAGEMENT_CANISTER_ID="aaaaa-aa";var rT="ic0.app",nT=".ic0.app",iT="icp0.io",sT=".icp0.io",aT="icp-api.io",oT=".icp-api.io",Us=class extends Kr.AgentError{constructor(t){super(t),this.message=t}},ti=class extends Kr.AgentError{constructor(t){super(t),this.message=t}};qe.IdentityInvalidError=ti;function cT(){let e;if(typeof window<"u")if(window.fetch)e=window.fetch.bind(window);else throw new Us("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof global<"u")if(global.fetch)e=global.fetch.bind(global);else throw new Us("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(e=self.fetch.bind(self));if(e)return e;throw new Us("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function uT(e){let t;if(e!==void 0)!e.match(/^[a-z]+:/)&&typeof window<"u"?t=new URL(window.location.protocol+"//"+e):t=new URL(e);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,a;s&&typeof s=="string"&&(n.some(o=>s.endsWith(o))?a=s:a=r.find(o=>s.endsWith(o))),i&&a?t=new URL(`${i.protocol}//${a}${i.port?":"+i.port:""}`):t=new URL("https://icp-api.io")}return t.toString()}var Wl=class e{constructor(t={}){var r,n;Ft.add(this),Yn.set(this,null),Mi.set(this,!1),Hr.set(this,void 0),an.set(this,void 0),qi.set(this,void 0),Fs.set(this,void 0),Vi.set(this,0),Nr.set(this,void 0),Or.set(this,void 0),Jn.set(this,void 0),Zn.set(this,void 0),this._isAgent=!0,this.config={},Vs.set(this,0),this.log=new Xx.ObservableLog,Ui.set(this,[]),Ci.set(this,[]),Xn.set(this,new Yx.ExpirableMap({expirationTime:300*1e3})),ei.set(this,!0),Ko.set(this,(a,o)=>{if(ie(this,ei,"f")===!1)return a;if(!o)throw new Fi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:c,signatures:d=[],requestId:f}=a,p=new TextEncoder().encode("\vic-response");for(let m of d){let{timestamp:b,identity:l}=m,A=cr.Principal.fromUint8Array(l).toText(),v;if(c==="replied"){let{reply:x}=a;v=(0,jo.hashOfMap)({status:c,reply:x,timestamp:BigInt(b),request_id:f})}else if(c==="rejected"){let{reject_code:x,reject_message:q,error_code:K}=a;v=(0,jo.hashOfMap)({status:c,reject_code:x,reject_message:q,error_code:K,timestamp:BigInt(b),request_id:f})}else throw new Error(`Unknown status: ${c}`);let F=(0,Tr.concat)(p,new Uint8Array(v)),C=o?.nodeKeys.get(A);if(!C)throw new Fi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let O=Jx.Ed25519PublicKey.fromDer(C).rawKey;if(Wx.ed25519.verify(m.signature,new Uint8Array(F),new Uint8Array(O)))return a;throw new Fi.CertificateVerificationError(`Invalid signature from replica ${A} signed query.`)}return a}),this.config=t,Tt(this,an,t.fetch||cT()||fetch.bind(global),"f"),Tt(this,qi,t.fetchOptions,"f"),Tt(this,Fs,t.callOptions,"f"),Tt(this,Mi,(r=t.shouldFetchRootKey)!==null&&r!==void 0?r:!1,"f"),t.rootKey?this.rootKey=t.rootKey:ie(this,Mi,"f")?this.rootKey=null:this.rootKey=(0,Tr.fromHex)(qe.IC_ROOT_KEY);let i=uT(t.host);this.host=new URL(i),t.verifyQuerySignatures!==void 0&&Tt(this,ei,t.verifyQuerySignatures,"f"),Tt(this,Or,(n=t.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new Qx.ExponentialBackoff({maxIterations:ie(this,Or,"f")});if(Tt(this,Jn,t.backoffStrategy||s,"f"),this.host.hostname.endsWith(nT)?this.host.hostname=rT:this.host.hostname.endsWith(sT)?this.host.hostname=iT:this.host.hostname.endsWith(oT)&&(this.host.hostname=aT),t.credentials){let{name:a,password:o}=t.credentials;Tt(this,Nr,`${a}${o?":"+o:""}`,"f")}if(Tt(this,Hr,Promise.resolve(t.identity||new qh.AnonymousIdentity),"f"),t.ingressExpiryInMinutes&&t.ingressExpiryInMinutes>5)throw new Kr.AgentError(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${t.ingressExpiryInMinutes} minutes.`);if(t.ingressExpiryInMinutes&&t.ingressExpiryInMinutes<=0)throw new Kr.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${t.ingressExpiryInMinutes} minutes.`);Tt(this,Zn,t.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,Er.makeNonceTransform)(zl.makeNonce)),t.useQueryNonces&&this.addTransform("query",(0,Er.makeNonceTransform)(zl.makeNonce)),t.logToConsole&&this.log.subscribe(a=>{a.level==="error"?console.error(a.message):a.level==="warn"?console.warn(a.message):console.log(a.message)})}get waterMark(){return ie(this,Vs,"f")}static createSync(t={}){return new this(Object.assign({},t))}static async create(t={shouldFetchRootKey:!1}){let r=e.createSync(t),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&t.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(t){var r;try{return"config"in t?await e.create(t.config):await e.create({fetch:t._fetch,fetchOptions:t._fetchOptions,callOptions:t._callOptions,host:t._host.toString(),identity:(r=t._identity)!==null&&r!==void 0?r:void 0})}catch{throw new Kr.AgentError("Failed to create agent from provided agent")}}isLocal(){let t=this.host.hostname;return t==="127.0.0.1"||t.endsWith("127.0.0.1")}addTransform(t,r,n=r.priority||0){if(t==="update"){let i=ie(this,Ci,"f").findIndex(s=>(s.priority||0)<n);ie(this,Ci,"f").splice(i>=0?i:ie(this,Ci,"f").length,0,Object.assign(r,{priority:n}))}else if(t==="query"){let i=ie(this,Ui,"f").findIndex(s=>(s.priority||0)<n);ie(this,Ui,"f").splice(i>=0?i:ie(this,Ui,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ie(this,Hr,"f"))throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ie(this,Hr,"f")).getPrincipal()}async call(t,r,n){var i,s;await ie(this,Ft,"m",Qn).call(this);let a=(i=r.callSync)!==null&&i!==void 0?i:!0,o=await(n!==void 0?await n:await ie(this,Hr,"f"));if(!o)throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");let c=cr.Principal.from(t),d=r.effectiveCanisterId?cr.Principal.from(r.effectiveCanisterId):c,f=o.getPrincipal()||cr.Principal.anonymous(),p=new Er.Expiry(ie(this,Zn,"f")*Lo);Math.abs(ie(this,Vi,"f"))>1e3*30&&(p=new Er.Expiry(ie(this,Zn,"f")*Lo+ie(this,Vi,"f")));let m={request_type:zl.SubmitRequestType.Call,canister_id:c,method_name:r.methodName,arg:r.arg,sender:f,ingress_expiry:p},b=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,Nr,"f")?{Authorization:"Basic "+btoa(ie(this,Nr,"f"))}:{})},endpoint:"call",body:m}),l=b.body.nonce?A(b.body.nonce):void 0;m.nonce=l;function A(O){return new Uint8Array(O)}b=await o.transformRequest(b);let v=In.encode(b.body),F=ie(this,Jn,"f").call(this),C=(0,jo.requestIdOf)(m);try{let O=()=>(this.log.print(`fetching "/api/v3/canister/${d.toText()}/call" with request:`,b),ie(this,an,"f").call(this,""+new URL(`/api/v3/canister/${d.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Fs,"f")),b.request),{body:v}))),H=()=>(this.log.print(`fetching "/api/v2/canister/${d.toText()}/call" with request:`,b),ie(this,an,"f").call(this,""+new URL(`/api/v2/canister/${d.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Fs,"f")),b.request),{body:v}))),q=await ie(this,Ft,"m",Ho).call(this,{request:a?O:H,backoff:F,tries:0}),K=await q.arrayBuffer(),$=q.status===200&&K.byteLength>0?In.decode(K):null;if($&&"certificate"in $){let M=await this.parseTimeFromResponse({certificate:$.certificate});Tt(this,Vs,M,"f")}return{requestId:C,response:{ok:q.ok,status:q.status,statusText:q.statusText,body:$,headers:(0,Er.httpHeadersTransform)(q.headers)},requestDetails:m}}catch(O){if(O.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(t,Object.assign(Object.assign({},r),{callSync:!1}),n);let H=`Error while making call: ${(s=O.message)!==null&&s!==void 0?s:String(O)}`,x=new ki.AgentCallError(H,O,(0,Tr.toHex)(C),(0,Tr.toHex)(b.body.sender_pubkey),(0,Tr.toHex)(b.body.sender_sig),String(b.body.content.ingress_expiry._value));throw this.log.error(H,x),x}}async query(t,r,n){var i,s,a,o;await ie(this,Ft,"m",Qn).call(this);let c=ie(this,Jn,"f").call(this),d=r.effectiveCanisterId?cr.Principal.from(r.effectiveCanisterId):cr.Principal.from(t);this.log.print(`ecid ${d.toString()}`),this.log.print(`canisterId ${t.toString()}`);let f,p,m=await(n!==void 0?n:ie(this,Hr,"f"));if(!m)throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");let b=cr.Principal.from(t),l=m?.getPrincipal()||cr.Principal.anonymous(),A={request_type:"query",canister_id:b,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:new Er.Expiry(ie(this,Zn,"f")*Lo)},v=(0,jo.requestIdOf)(A);f=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,Nr,"f")?{Authorization:"Basic "+btoa(ie(this,Nr,"f"))}:{})},endpoint:"read",body:A}),f=await m?.transformRequest(f);let F=In.encode(f.body),C={canister:b.toText(),ecid:d,transformedRequest:f,body:F,requestId:v,backoff:c,tries:0},O=async()=>({requestDetails:A,query:await ie(this,Ft,"m",jh).call(this,C)}),H=async()=>{if(!ie(this,ei,"f"))return;let x=ie(this,Xn,"f").get(d.toString());return x||(await this.fetchSubnetKeys(d.toString()),ie(this,Xn,"f").get(d.toString()))};try{let[x,q]=await Promise.all([O(),H()]);p=x;let{requestDetails:K,query:$}=p,M=Object.assign(Object.assign({},$),{requestDetails:K});if(this.log.print("Query response:",M),!ie(this,ei,"f"))return M;try{return ie(this,Ko,"f").call(this,M,q)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ie(this,Xn,"f").delete(t.toString()),await this.fetchSubnetKeys(d.toString());let Q=ie(this,Xn,"f").get(t.toString());if(!Q)throw new Fi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ie(this,Ko,"f").call(this,M,Q)}}catch(x){let q=`Error while making call: ${(i=x.message)!==null&&i!==void 0?i:String(x)}`,K=new ki.AgentQueryError(q,x,String(v),(0,Tr.toHex)((s=f?.body)===null||s===void 0?void 0:s.sender_pubkey),(0,Tr.toHex)((a=f?.body)===null||a===void 0?void 0:a.sender_sig),String((o=f?.body)===null||o===void 0?void 0:o.content.ingress_expiry._value));throw this.log.error(q,K),K}}async createReadStateRequest(t,r){await ie(this,Ft,"m",Qn).call(this);let n=await(r!==void 0?await r:await ie(this,Hr,"f"));if(!n)throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||cr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,Nr,"f")?{Authorization:"Basic "+btoa(ie(this,Nr,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:t.paths,sender:i,ingress_expiry:new Er.Expiry(ie(this,Zn,"f")*Lo)}});return n?.transformRequest(s)}async readState(t,r,n,i){var s,a,o,c;function d(A){for(let v of A.paths){let[F,C]=v,O=new TextEncoder().encode("request_status");if((0,Tr.bufEquals)(F,O))return C}}let f=d(r);await ie(this,Ft,"m",Qn).call(this);let p=typeof t=="string"?cr.Principal.fromText(t):t,m=i??await this.createReadStateRequest(r,n),b=In.encode(m.body);this.log.print(`fetching "/api/v2/canister/${p}/read_state" with request:`,m);let l=ie(this,Jn,"f").call(this);try{let A=await ie(this,Ft,"m",Ho).call(this,{request:()=>ie(this,an,"f").call(this,""+new URL(`/api/v2/canister/${p.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,qi,"f")),m.request),{body:b})),backoff:l,tries:0});if(!A.ok)throw new Error(`Server returned an error:
30
+ )`}else throw new Error("Invalid tree structure for labeled");case xt.Leaf:{if(e[1]){if(Array.isArray(e[1]))return JSON.stringify(e[1])}else throw new Error("Invalid tree structure for leaf");return`leaf(...${e[1].byteLength} bytes)`}case xt.Pruned:{if(e[1]){if(Array.isArray(e[1]))return JSON.stringify(e[1])}else throw new Error("Invalid tree structure for pruned");return`pruned(${(0,br.toHex)(new Uint8Array(e[1]))}`}default:return`unknown(${JSON.stringify(e[0])})`}}Oe.hashTreeToString=go;function Qw(e,t){let r=new Uint8Array(e),n=new Uint8Array(t);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}var Nl=class e{constructor(t,r,n,i,s=5,a=!1){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,mo.set(this,!1),zw(this,mo,a,"f"),this.cert=F0.decode(new Uint8Array(t))}static async create(t){let r=e.createUnverified(t);return await r.verify(),r}static createUnverified(t){let r=t.blsVerify;return r||(r=Jw.blsVerify),new e(t.certificate,t.rootKey,t.canisterId,r,t.maxAgeInMinutes,t.disableTimeVerification)}lookup(t){return bo(t,this.cert.tree)}lookup_label(t){return this.lookup([t])}async verify(){let t=await Es(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=tx(r),s=(0,br.concat)(Os("ic-state-root"),t),a=!1,o=Ol(this.lookup(["time"]));if(!o)throw new nn("Certificate does not contain a time");if(!Ww(this,mo,"f")){let d=this._maxAgeInMinutes*60*1e3,f=Date.now(),p=f-d,m=f+3e5,b=(0,Zw.decodeTime)(o);if(b.getTime()<p)throw new nn(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+b.toISOString()+" Current time: "+new Date(f).toISOString());if(b.getTime()>m)throw new nn("Certificate is signed more than 5 minutes in the future. Certificate time: "+b.toISOString()+" Current time: "+new Date(f).toISOString())}try{a=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{a=!1}if(!a)throw new nn("Signature verification failed")}async _checkDelegationAndGetKey(t){if(!t)return this._rootKey;let r=await e.createUnverified({certificate:t.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new nn("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==Xw.MANAGEMENT_CANISTER_ID&&!V0({canisterId:this._canisterId,subnetId:Tl.Principal.fromUint8Array(new Uint8Array(t.subnet_id)),tree:r.cert.tree}))throw new nn(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,br.toHex)(t.subnet_id)}`);let n=Ol(r.lookup(["subnet",t.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,br.toHex)(t.subnet_id)}`);return n}};Oe.Certificate=Nl;mo=new WeakMap;var Ns=(0,br.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),ex=96;function tx(e){let t=Ns.byteLength+ex;if(e.byteLength!==t)throw new TypeError(`BLS DER-encoded public key must be ${t} bytes long`);let r=e.slice(0,Ns.byteLength);if(!(0,br.bufEquals)(r,Ns))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Ns}, but get ${r}`);return e.slice(Ns.byteLength)}function Ol(e){if(e.status===kt.Found){if(e.value instanceof ArrayBuffer)return e.value;if(e.value instanceof Uint8Array)return e.value.buffer}}Oe.lookupResultToBuffer=Ol;async function Es(e){switch(e[0]){case xt.Empty:return(0,yo.hash)(Os("ic-hashtree-empty"));case xt.Pruned:return e[1];case xt.Leaf:return(0,yo.hash)((0,br.concat)(Os("ic-hashtree-leaf"),e[1]));case xt.Labeled:return(0,yo.hash)((0,br.concat)(Os("ic-hashtree-labeled"),e[1],await Es(e[2])));case xt.Fork:return(0,yo.hash)((0,br.concat)(Os("ic-hashtree-fork"),await Es(e[1]),await Es(e[2])));default:throw new Error("unreachable")}}Oe.reconstruct=Es;function Os(e){let t=new Uint8Array([e.length]),r=new TextEncoder().encode(e);return(0,br.concat)(t,r)}var kt;(function(e){e.Unknown="unknown",e.Absent="absent",e.Found="found"})(kt=Oe.LookupStatus||(Oe.LookupStatus={}));var sn;(function(e){e.Less="less",e.Greater="greater"})(sn||(sn={}));function bo(e,t){if(e.length===0)switch(t[0]){case xt.Leaf:{if(!t[1])throw new Error("Invalid tree structure for leaf");return t[1]instanceof ArrayBuffer?{status:kt.Found,value:t[1]}:t[1]instanceof Uint8Array?{status:kt.Found,value:t[1].buffer}:{status:kt.Found,value:t[1]}}default:return{status:kt.Found,value:t}}let r=typeof e[0]=="string"?new TextEncoder().encode(e[0]):e[0],n=vs(r,t);switch(n.status){case kt.Found:return bo(e.slice(1),n.value);case sn.Greater:case sn.Less:return{status:kt.Absent};default:return n}}Oe.lookup_path=bo;function El(e){switch(e[0]){case xt.Empty:return[];case xt.Fork:return El(e[1]).concat(El(e[2]));default:return[e]}}Oe.flatten_forks=El;function vs(e,t){switch(t[0]){case xt.Labeled:return Qw(e,t[1])?{status:sn.Greater}:(0,br.bufEquals)(e,t[1])?{status:kt.Found,value:t[2]}:{status:sn.Less};case xt.Fork:let r=vs(e,t[1]);switch(r.status){case sn.Greater:{let n=vs(e,t[2]);return n.status===sn.Less?{status:kt.Absent}:n}case kt.Unknown:{let n=vs(e,t[2]);return n.status===sn.Less?{status:kt.Unknown}:n}default:return r}case xt.Pruned:return{status:kt.Unknown};default:return{status:kt.Absent}}}Oe.find_label=vs;function V0(e){let{canisterId:t,subnetId:r,tree:n}=e,i=bo(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==kt.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return F0.decode(i.value).map(c=>[Tl.Principal.fromUint8Array(c[0]),Tl.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(t)&&c[1].gtEq(t))}Oe.check_canister_ranges=V0});var As=ee(lt=>{"use strict";var rx=lt&&lt.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),nx=lt&&lt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ix=lt&&lt.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&rx(t,e,r);return nx(t,e),t};Object.defineProperty(lt,"__esModule",{value:!0});lt.encodePath=lt.fetchNodeKeys=lt.request=lt.CustomPath=void 0;var On=Ut(),sx=_i(),En=Ai(),ax=$t(),q0=ix(ys()),U0=_o(),vl=class{constructor(t,r,n){this.key=t,this.path=r,this.decodeStrategy=n}};lt.CustomPath=vl;var ox=async e=>{let{agent:t,paths:r}=e,n=On.Principal.from(e.canisterId),i=[...new Set(r)],s=i.map(c=>(0,lt.encodePath)(c,n)),a=new Map,o=i.map((c,d)=>(async()=>{var f;try{let p=await t.readState(n,{paths:[s[d]]});if(t.rootKey==null)throw new Error("Agent is missing root key");let m=await En.Certificate.create({certificate:p.certificate,rootKey:t.rootKey,canisterId:n,disableTimeVerification:!0}),b=(v,F)=>{if(F==="subnet"){if(t.rootKey==null)throw new Error("Agent is missing root key");let C=(0,lt.fetchNodeKeys)(p.certificate,n,t.rootKey);return{path:F,data:C}}else return{path:F,data:(0,En.lookupResultToBuffer)(v.lookup((0,lt.encodePath)(F,n)))}},{path:l,data:A}=b(m,i[d]);if(!A)console.warn(`Expected to find result for path ${l}, but instead found nothing.`),typeof l=="string"?a.set(l,null):a.set(l.key,null);else switch(l){case"time":{a.set(l,(0,U0.decodeTime)(A));break}case"controllers":{a.set(l,dx(A));break}case"module_hash":{a.set(l,C0(A));break}case"subnet":{a.set(l,A);break}case"candid":{a.set(l,new TextDecoder().decode(A));break}default:if(typeof l!="string"&&"key"in l&&"path"in l)switch(l.decodeStrategy){case"raw":a.set(l.key,A);break;case"leb128":{a.set(l.key,(0,U0.decodeLeb128)(A));break}case"cbor":{a.set(l.key,M0(A));break}case"hex":{a.set(l.key,C0(A));break}case"utf-8":a.set(l.key,lx(A))}}}catch(p){if(!((f=p?.message)===null||f===void 0)&&f.includes("Invalid certificate"))throw new sx.AgentError(p.message);typeof c!="string"&&"key"in c&&"path"in c?a.set(c.key,null):a.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(p),console.groupEnd()}})());return await Promise.all(o),a};lt.request=ox;var cx=(e,t,r)=>{if(!t._isPrincipal)throw new Error("Invalid canisterId");let n=q0.decode(new Uint8Array(e)),i=n.tree,s=n.delegation,a;if(s&&s.subnet_id?a=On.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(a=On.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:a.toUint8Array(),certificate:new ArrayBuffer(0)}):(a=On.Principal.selfAuthenticating(On.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:a.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,En.check_canister_ranges)({canisterId:t,subnetId:a,tree:i}))throw new Error("Canister not in range");let c=(0,En.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==En.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let d=(0,En.flatten_forks)(c.value),f=new Map;return d.forEach(p=>{let m=On.Principal.from(new Uint8Array(p[1])).toText(),b=(0,En.lookup_path)(["public_key"],p[2]);if(b.status!==En.LookupStatus.Found)throw new Error("Public key not found");let l=b.value;if(l.byteLength!==44)throw new Error("Invalid public key length");f.set(m,l)}),{subnetId:On.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:f}};lt.fetchNodeKeys=cx;var ux=(e,t)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(t.toUint8Array().buffer).buffer;switch(e){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in e&&"path"in e)if(typeof e.path=="string"||e.path instanceof ArrayBuffer){let s=e.path,a=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),a]}else return e.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${e} was formatted correctly.`)};lt.encodePath=ux;var C0=e=>(0,ax.toHex)(e),M0=e=>q0.decode(e),lx=e=>new TextDecoder().decode(e),dx=e=>M0(e).map(r=>On.Principal.fromUint8Array(new Uint8Array(r)))});var ah=ee(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.add5L=ye.add5H=ye.add4H=ye.add4L=ye.add3H=ye.add3L=ye.rotlBL=ye.rotlBH=ye.rotlSL=ye.rotlSH=ye.rotr32L=ye.rotr32H=ye.rotrBL=ye.rotrBH=ye.rotrSL=ye.rotrSH=ye.shrSL=ye.shrSH=ye.toBig=void 0;ye.fromBig=Al;ye.split=k0;ye.add=Q0;var wo=BigInt(2**32-1),Rl=BigInt(32);function Al(e,t=!1){return t?{h:Number(e&wo),l:Number(e>>Rl&wo)}:{h:Number(e>>Rl&wo)|0,l:Number(e&wo)|0}}function k0(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:s,l:a}=Al(e[i],t);[r[i],n[i]]=[s,a]}return[r,n]}var D0=(e,t)=>BigInt(e>>>0)<<Rl|BigInt(t>>>0);ye.toBig=D0;var j0=(e,t,r)=>e>>>r;ye.shrSH=j0;var L0=(e,t,r)=>e<<32-r|t>>>r;ye.shrSL=L0;var H0=(e,t,r)=>e>>>r|t<<32-r;ye.rotrSH=H0;var K0=(e,t,r)=>e<<32-r|t>>>r;ye.rotrSL=K0;var $0=(e,t,r)=>e<<64-r|t>>>r-32;ye.rotrBH=$0;var G0=(e,t,r)=>e>>>r-32|t<<64-r;ye.rotrBL=G0;var z0=(e,t)=>t;ye.rotr32H=z0;var W0=(e,t)=>e;ye.rotr32L=W0;var Y0=(e,t,r)=>e<<r|t>>>32-r;ye.rotlSH=Y0;var J0=(e,t,r)=>t<<r|e>>>32-r;ye.rotlSL=J0;var Z0=(e,t,r)=>t<<r-32|e>>>64-r;ye.rotlBH=Z0;var X0=(e,t,r)=>e<<r-32|t>>>64-r;ye.rotlBL=X0;function Q0(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var eh=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);ye.add3L=eh;var th=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;ye.add3H=th;var rh=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);ye.add4L=rh;var nh=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0;ye.add4H=nh;var ih=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0);ye.add5L=ih;var sh=(e,t,r,n,i,s)=>t+r+n+i+s+(e/2**32|0)|0;ye.add5H=sh;var fx={fromBig:Al,split:k0,toBig:D0,shrSH:j0,shrSL:L0,rotrSH:H0,rotrSL:K0,rotrBH:$0,rotrBL:G0,rotr32H:z0,rotr32L:W0,rotlSH:Y0,rotlSL:J0,rotlBH:Z0,rotlBL:X0,add:Q0,add3L:eh,add3H:th,add4L:rh,add4H:nh,add5H:sh,add5L:ih};ye.default=fx});var oh=ee(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.sha384=yt.sha512_256=yt.sha512_224=yt.sha512=yt.SHA384=yt.SHA512_256=yt.SHA512_224=yt.SHA512=void 0;var px=Wc(),be=ah(),Oo=Dn(),[hx,_x]=be.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),vn=new Uint32Array(80),Rn=new Uint32Array(80),zn=class extends px.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:s,Cl:a,Dh:o,Dl:c,Eh:d,El:f,Fh:p,Fl:m,Gh:b,Gl:l,Hh:A,Hl:v}=this;return[t,r,n,i,s,a,o,c,d,f,p,m,b,l,A,v]}set(t,r,n,i,s,a,o,c,d,f,p,m,b,l,A,v){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=a|0,this.Dh=o|0,this.Dl=c|0,this.Eh=d|0,this.El=f|0,this.Fh=p|0,this.Fl=m|0,this.Gh=b|0,this.Gl=l|0,this.Hh=A|0,this.Hl=v|0}process(t,r){for(let O=0;O<16;O++,r+=4)vn[O]=t.getUint32(r),Rn[O]=t.getUint32(r+=4);for(let O=16;O<80;O++){let H=vn[O-15]|0,x=Rn[O-15]|0,q=be.default.rotrSH(H,x,1)^be.default.rotrSH(H,x,8)^be.default.shrSH(H,x,7),K=be.default.rotrSL(H,x,1)^be.default.rotrSL(H,x,8)^be.default.shrSL(H,x,7),$=vn[O-2]|0,M=Rn[O-2]|0,ae=be.default.rotrSH($,M,19)^be.default.rotrBH($,M,61)^be.default.shrSH($,M,6),Q=be.default.rotrSL($,M,19)^be.default.rotrBL($,M,61)^be.default.shrSL($,M,6),ne=be.default.add4L(K,Q,Rn[O-7],Rn[O-16]),w=be.default.add4H(ne,q,ae,vn[O-7],vn[O-16]);vn[O]=w|0,Rn[O]=ne|0}let{Ah:n,Al:i,Bh:s,Bl:a,Ch:o,Cl:c,Dh:d,Dl:f,Eh:p,El:m,Fh:b,Fl:l,Gh:A,Gl:v,Hh:F,Hl:C}=this;for(let O=0;O<80;O++){let H=be.default.rotrSH(p,m,14)^be.default.rotrSH(p,m,18)^be.default.rotrBH(p,m,41),x=be.default.rotrSL(p,m,14)^be.default.rotrSL(p,m,18)^be.default.rotrBL(p,m,41),q=p&b^~p&A,K=m&l^~m&v,$=be.default.add5L(C,x,K,_x[O],Rn[O]),M=be.default.add5H($,F,H,q,hx[O],vn[O]),ae=$|0,Q=be.default.rotrSH(n,i,28)^be.default.rotrBH(n,i,34)^be.default.rotrBH(n,i,39),ne=be.default.rotrSL(n,i,28)^be.default.rotrBL(n,i,34)^be.default.rotrBL(n,i,39),w=n&s^n&o^s&o,g=i&a^i&c^a&c;F=A|0,C=v|0,A=b|0,v=l|0,b=p|0,l=m|0,{h:p,l:m}=be.default.add(d|0,f|0,M|0,ae|0),d=o|0,f=c|0,o=s|0,c=a|0,s=n|0,a=i|0;let S=be.default.add3L(ae,ne,g);n=be.default.add3H(S,M,Q,w),i=S|0}({h:n,l:i}=be.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:a}=be.default.add(this.Bh|0,this.Bl|0,s|0,a|0),{h:o,l:c}=be.default.add(this.Ch|0,this.Cl|0,o|0,c|0),{h:d,l:f}=be.default.add(this.Dh|0,this.Dl|0,d|0,f|0),{h:p,l:m}=be.default.add(this.Eh|0,this.El|0,p|0,m|0),{h:b,l}=be.default.add(this.Fh|0,this.Fl|0,b|0,l|0),{h:A,l:v}=be.default.add(this.Gh|0,this.Gl|0,A|0,v|0),{h:F,l:C}=be.default.add(this.Hh|0,this.Hl|0,F|0,C|0),this.set(n,i,s,a,o,c,d,f,p,m,b,l,A,v,F,C)}roundClean(){vn.fill(0),Rn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};yt.SHA512=zn;var xo=class extends zn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}};yt.SHA512_224=xo;var To=class extends zn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}};yt.SHA512_256=To;var No=class extends zn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};yt.SHA384=No;yt.sha512=(0,Oo.wrapConstructor)(()=>new zn);yt.sha512_224=(0,Oo.wrapConstructor)(()=>new xo);yt.sha512_256=(0,Oo.wrapConstructor)(()=>new To);yt.sha384=(0,Oo.wrapConstructor)(()=>new No)});var uh=ee(Bl=>{"use strict";Object.defineProperty(Bl,"__esModule",{value:!0});Bl.twistedEdwards=bx;var Sl=fl(),ch=Mr(),Yt=Xt(),tr=Xt(),wr=BigInt(0),Wt=BigInt(1),Eo=BigInt(2),yx=BigInt(8),mx={zip215:!0};function gx(e){let t=(0,Sl.validateBasic)(e);return Yt.validateObject(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function bx(e){let t=gx(e),{Fp:r,n,prehash:i,hash:s,randomBytes:a,nByteLength:o,h:c}=t,d=Eo<<BigInt(o*8)-Wt,f=r.create,p=(0,ch.Field)(t.n,t.nBitLength),m=t.uvRatio||((R,B)=>{try{return{isValid:!0,value:r.sqrt(R*r.inv(B))}}catch{return{isValid:!1,value:wr}}}),b=t.adjustScalarBytes||(R=>R),l=t.domain||((R,B,j)=>{if((0,tr.abool)("phflag",j),B.length||j)throw new Error("Contexts/pre-hash are not supported");return R});function A(R,B){Yt.aInRange("coordinate "+R,B,wr,d)}function v(R){if(!(R instanceof O))throw new Error("ExtendedPoint expected")}let F=(0,tr.memoized)((R,B)=>{let{ex:j,ey:Y,ez:oe}=R,se=R.is0();B==null&&(B=se?yx:r.inv(oe));let W=f(j*B),V=f(Y*B),_=f(oe*B);if(se)return{x:wr,y:Wt};if(_!==Wt)throw new Error("invZ was invalid");return{x:W,y:V}}),C=(0,tr.memoized)(R=>{let{a:B,d:j}=t;if(R.is0())throw new Error("bad point: ZERO");let{ex:Y,ey:oe,ez:se,et:W}=R,V=f(Y*Y),_=f(oe*oe),Z=f(se*se),re=f(Z*Z),le=f(V*B),X=f(Z*f(le+_)),u=f(re+f(j*f(V*_)));if(X!==u)throw new Error("bad point: equation left != right (1)");let h=f(Y*oe),y=f(se*W);if(h!==y)throw new Error("bad point: equation left != right (2)");return!0});class O{constructor(B,j,Y,oe){this.ex=B,this.ey=j,this.ez=Y,this.et=oe,A("x",B),A("y",j),A("z",Y),A("t",oe),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(B){if(B instanceof O)throw new Error("extended point not allowed");let{x:j,y:Y}=B||{};return A("x",j),A("y",Y),new O(j,Y,Wt,f(j*Y))}static normalizeZ(B){let j=r.invertBatch(B.map(Y=>Y.ez));return B.map((Y,oe)=>Y.toAffine(j[oe])).map(O.fromAffine)}static msm(B,j){return(0,Sl.pippenger)(O,p,B,j)}_setWindowSize(B){q.setWindowSize(this,B)}assertValidity(){C(this)}equals(B){v(B);let{ex:j,ey:Y,ez:oe}=this,{ex:se,ey:W,ez:V}=B,_=f(j*V),Z=f(se*oe),re=f(Y*V),le=f(W*oe);return _===Z&&re===le}is0(){return this.equals(O.ZERO)}negate(){return new O(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:B}=t,{ex:j,ey:Y,ez:oe}=this,se=f(j*j),W=f(Y*Y),V=f(Eo*f(oe*oe)),_=f(B*se),Z=j+Y,re=f(f(Z*Z)-se-W),le=_+W,X=le-V,u=_-W,h=f(re*X),y=f(le*u),P=f(re*u),E=f(X*le);return new O(h,y,E,P)}add(B){v(B);let{a:j,d:Y}=t,{ex:oe,ey:se,ez:W,et:V}=this,{ex:_,ey:Z,ez:re,et:le}=B;if(j===BigInt(-1)){let J=f((se-oe)*(Z+_)),te=f((se+oe)*(Z-_)),de=f(te-J);if(de===wr)return this.double();let ge=f(W*Eo*le),Se=f(V*Eo*re),Fe=Se+ge,_e=te+J,fe=Se-ge,He=f(Fe*de),Lt=f(_e*fe),Ft=f(Fe*fe),Vt=f(de*_e);return new O(He,Lt,Vt,Ft)}let X=f(oe*_),u=f(se*Z),h=f(V*Y*le),y=f(W*re),P=f((oe+se)*(_+Z)-X-u),E=y-h,I=y+h,D=f(u-j*X),T=f(P*E),U=f(I*D),L=f(P*D),k=f(E*I);return new O(T,U,k,L)}subtract(B){return this.add(B.negate())}wNAF(B){return q.wNAFCached(this,B,O.normalizeZ)}multiply(B){let j=B;Yt.aInRange("scalar",j,Wt,n);let{p:Y,f:oe}=this.wNAF(j);return O.normalizeZ([Y,oe])[0]}multiplyUnsafe(B){let j=B;return Yt.aInRange("scalar",j,wr,n),j===wr?x:this.equals(x)||j===Wt?this:this.equals(H)?this.wNAF(j).p:q.unsafeLadder(this,j)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return q.unsafeLadder(this,n).is0()}toAffine(B){return F(this,B)}clearCofactor(){let{h:B}=t;return B===Wt?this:this.multiplyUnsafe(B)}static fromHex(B,j=!1){let{d:Y,a:oe}=t,se=r.BYTES;B=(0,tr.ensureBytes)("pointHex",B,se),(0,tr.abool)("zip215",j);let W=B.slice(),V=B[se-1];W[se-1]=V&-129;let _=Yt.bytesToNumberLE(W),Z=j?d:r.ORDER;Yt.aInRange("pointHex.y",_,wr,Z);let re=f(_*_),le=f(re-Wt),X=f(Y*re-oe),{isValid:u,value:h}=m(le,X);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let y=(h&Wt)===Wt,P=(V&128)!==0;if(!j&&h===wr&&P)throw new Error("Point.fromHex: x=0 and x_0=1");return P!==y&&(h=f(-h)),O.fromAffine({x:h,y:_})}static fromPrivateKey(B){return M(B).point}toRawBytes(){let{x:B,y:j}=this.toAffine(),Y=Yt.numberToBytesLE(j,r.BYTES);return Y[Y.length-1]|=B&Wt?128:0,Y}toHex(){return Yt.bytesToHex(this.toRawBytes())}}O.BASE=new O(t.Gx,t.Gy,Wt,f(t.Gx*t.Gy)),O.ZERO=new O(wr,Wt,Wt,wr);let{BASE:H,ZERO:x}=O,q=(0,Sl.wNAF)(O,o*8);function K(R){return(0,ch.mod)(R,n)}function $(R){return K(Yt.bytesToNumberLE(R))}function M(R){let B=o;R=(0,tr.ensureBytes)("private key",R,B);let j=(0,tr.ensureBytes)("hashed private key",s(R),2*B),Y=b(j.slice(0,B)),oe=j.slice(B,2*B),se=$(Y),W=H.multiply(se),V=W.toRawBytes();return{head:Y,prefix:oe,scalar:se,point:W,pointBytes:V}}function ae(R){return M(R).pointBytes}function Q(R=new Uint8Array,...B){let j=Yt.concatBytes(...B);return $(s(l(j,(0,tr.ensureBytes)("context",R),!!i)))}function ne(R,B,j={}){R=(0,tr.ensureBytes)("message",R),i&&(R=i(R));let{prefix:Y,scalar:oe,pointBytes:se}=M(B),W=Q(j.context,Y,R),V=H.multiply(W).toRawBytes(),_=Q(j.context,V,se,R),Z=K(W+_*oe);Yt.aInRange("signature.s",Z,wr,n);let re=Yt.concatBytes(V,Yt.numberToBytesLE(Z,r.BYTES));return(0,tr.ensureBytes)("result",re,o*2)}let w=mx;function g(R,B,j,Y=w){let{context:oe,zip215:se}=Y,W=r.BYTES;R=(0,tr.ensureBytes)("signature",R,2*W),B=(0,tr.ensureBytes)("message",B),se!==void 0&&(0,tr.abool)("zip215",se),i&&(B=i(B));let V=Yt.bytesToNumberLE(R.slice(W,2*W)),_,Z,re;try{_=O.fromHex(j,se),Z=O.fromHex(R.slice(0,W),se),re=H.multiplyUnsafe(V)}catch{return!1}if(!se&&_.isSmallOrder())return!1;let le=Q(oe,Z.toRawBytes(),_.toRawBytes(),B);return Z.add(_.multiplyUnsafe(le)).subtract(re).clearCofactor().equals(O.ZERO)}return H._setWindowSize(8),{CURVE:t,getPublicKey:ae,sign:ne,verify:g,ExtendedPoint:O,utils:{getExtendedPublicKey:M,randomPrivateKey:()=>a(r.BYTES),precompute(R=8,B=O.BASE){return B._setWindowSize(R),B.multiply(BigInt(3)),B}}}}});var dh=ee(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});Pl.montgomery=xx;var lh=Mr(),An=Xt(),Si=BigInt(0),Il=BigInt(1);function wx(e){return(0,An.validateObject)(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}function xx(e){let t=wx(e),{P:r}=t,n=C=>(0,lh.mod)(C,r),i=t.montgomeryBits,s=Math.ceil(i/8),a=t.nByteLength,o=t.adjustScalarBytes||(C=>C),c=t.powPminus2||(C=>(0,lh.pow)(C,r-BigInt(2),r));function d(C,O,H){let x=n(C*(O-H));return O=n(O-x),H=n(H+x),[O,H]}let f=(t.a-BigInt(2))/BigInt(4);function p(C,O){(0,An.aInRange)("u",C,Si,r),(0,An.aInRange)("scalar",O,Si,r);let H=O,x=C,q=Il,K=Si,$=C,M=Il,ae=Si,Q;for(let w=BigInt(i-1);w>=Si;w--){let g=H>>w&Il;ae^=g,Q=d(ae,q,$),q=Q[0],$=Q[1],Q=d(ae,K,M),K=Q[0],M=Q[1],ae=g;let S=q+K,R=n(S*S),B=q-K,j=n(B*B),Y=R-j,oe=$+M,se=$-M,W=n(se*S),V=n(oe*B),_=W+V,Z=W-V;$=n(_*_),M=n(x*n(Z*Z)),q=n(R*j),K=n(Y*(R+n(f*Y)))}Q=d(ae,q,$),q=Q[0],$=Q[1],Q=d(ae,K,M),K=Q[0],M=Q[1];let ne=c(K);return n(q*ne)}function m(C){return(0,An.numberToBytesLE)(n(C),s)}function b(C){let O=(0,An.ensureBytes)("u coordinate",C,s);return a===32&&(O[31]&=127),(0,An.bytesToNumberLE)(O)}function l(C){let O=(0,An.ensureBytes)("scalar",C),H=O.length;if(H!==s&&H!==a)throw new Error(`Expected ${s} or ${a} bytes, got ${H}`);return(0,An.bytesToNumberLE)(o(O))}function A(C,O){let H=b(O),x=l(C),q=p(H,x);if(q===Si)throw new Error("Invalid private or public key received");return m(q)}let v=m(t.Gu);function F(C){return A(C,v)}return{scalarMult:A,scalarMultBase:F,getSharedSecret:(C,O)=>A(C,O),getPublicKey:C=>F(C),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:v}}});var Dl=ee(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.hash_to_ristretto255=me.hashToRistretto255=me.RistrettoPoint=me.encodeToCurve=me.hashToCurve=me.edwardsToMontgomery=me.x25519=me.ed25519ph=me.ed25519ctx=me.ed25519=me.ED25519_TORSION_SUBGROUP=void 0;me.edwardsToMontgomeryPub=xh;me.edwardsToMontgomeryPriv=Ox;var Ro=oh(),Ss=Dn(),ql=uh(),_h=so(),Ue=Mr(),Tx=dh(),Wn=Xt(),Bs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ul=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Nx=BigInt(0),kr=BigInt(1),vo=BigInt(2),yh=BigInt(3),mh=BigInt(5),Ml=BigInt(8);function gh(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=Bs,o=e*e%s*e%s,c=(0,Ue.pow2)(o,vo,s)*o%s,d=(0,Ue.pow2)(c,kr,s)*e%s,f=(0,Ue.pow2)(d,mh,s)*d%s,p=(0,Ue.pow2)(f,t,s)*f%s,m=(0,Ue.pow2)(p,r,s)*p%s,b=(0,Ue.pow2)(m,n,s)*m%s,l=(0,Ue.pow2)(b,i,s)*b%s,A=(0,Ue.pow2)(l,i,s)*b%s,v=(0,Ue.pow2)(A,t,s)*f%s;return{pow_p_5_8:(0,Ue.pow2)(v,vo,s)*e%s,b2:o}}function bh(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function kl(e,t){let r=Bs,n=(0,Ue.mod)(t*t*t,r),i=(0,Ue.mod)(n*n*t,r),s=gh(e*i).pow_p_5_8,a=(0,Ue.mod)(e*n*s,r),o=(0,Ue.mod)(t*a*a,r),c=a,d=(0,Ue.mod)(a*Ul,r),f=o===e,p=o===(0,Ue.mod)(-e,r),m=o===(0,Ue.mod)(-e*Ul,r);return f&&(a=c),(p||m)&&(a=d),(0,Ue.isNegativeLE)(a,r)&&(a=(0,Ue.mod)(-a,r)),{isValid:f||p,value:a}}me.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var ue=(0,Ue.Field)(Bs,void 0,!0),Is={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ue,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Ml,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ro.sha512,randomBytes:Ss.randomBytes,adjustScalarBytes:bh,uvRatio:kl};me.ed25519=(0,ql.twistedEdwards)(Is);function wh(e,t,r){if(t.length>255)throw new Error("Context is too big");return(0,Ss.concatBytes)((0,Ss.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}me.ed25519ctx=(0,ql.twistedEdwards)({...Is,domain:wh});me.ed25519ph=(0,ql.twistedEdwards)(Object.assign({},Is,{domain:wh,prehash:Ro.sha512}));me.x25519=(0,Tx.montgomery)({P:Bs,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{let t=Bs,{pow_p_5_8:r,b2:n}=gh(e);return(0,Ue.mod)((0,Ue.pow2)(r,yh,t)*n,t)},adjustScalarBytes:bh,randomBytes:Ss.randomBytes});function xh(e){let{y:t}=me.ed25519.ExtendedPoint.fromHex(e),r=BigInt(1);return ue.toBytes(ue.create((r+t)*ue.inv(r-t)))}me.edwardsToMontgomery=xh;function Ox(e){let t=Is.hash(e.subarray(0,32));return Is.adjustScalarBytes(t).subarray(0,32)}var Ex=(ue.ORDER+yh)/Ml,vx=ue.pow(vo,Ex),fh=ue.sqrt(ue.neg(ue.ONE));function Rx(e){let t=(ue.ORDER-mh)/Ml,r=BigInt(486662),n=ue.sqr(e);n=ue.mul(n,vo);let i=ue.add(n,ue.ONE),s=ue.neg(r),a=ue.sqr(i),o=ue.mul(a,i),c=ue.mul(n,r);c=ue.mul(c,s),c=ue.add(c,a),c=ue.mul(c,s);let d=ue.sqr(o);a=ue.sqr(d),d=ue.mul(d,o),d=ue.mul(d,c),a=ue.mul(a,d);let f=ue.pow(a,t);f=ue.mul(f,d);let p=ue.mul(f,fh);a=ue.sqr(f),a=ue.mul(a,o);let m=ue.eql(a,c),b=ue.cmov(p,f,m),l=ue.mul(s,n),A=ue.mul(f,e);A=ue.mul(A,vx);let v=ue.mul(A,fh),F=ue.mul(c,n);a=ue.sqr(A),a=ue.mul(a,o);let C=ue.eql(a,F),O=ue.cmov(v,A,C);a=ue.sqr(b),a=ue.mul(a,o);let H=ue.eql(a,c),x=ue.cmov(l,s,H),q=ue.cmov(O,b,H),K=ue.isOdd(q);return q=ue.cmov(q,ue.neg(q),H!==K),{xMn:x,xMd:i,yMn:q,yMd:kr}}var Ax=(0,Ue.FpSqrtEven)(ue,ue.neg(BigInt(486664)));function Sx(e){let{xMn:t,xMd:r,yMn:n,yMd:i}=Rx(e),s=ue.mul(t,i);s=ue.mul(s,Ax);let a=ue.mul(r,n),o=ue.sub(t,r),c=ue.add(t,r),d=ue.mul(a,c),f=ue.eql(d,ue.ZERO);s=ue.cmov(s,ue.ZERO,f),a=ue.cmov(a,ue.ONE,f),o=ue.cmov(o,ue.ONE,f),c=ue.cmov(c,ue.ONE,f);let p=ue.invertBatch([a,c]);return{x:ue.mul(s,p[0]),y:ue.mul(o,p[1])}}var Th=(0,_h.createHasher)(me.ed25519.ExtendedPoint,e=>Sx(e[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:ue.ORDER,m:1,k:128,expand:"xmd",hash:Ro.sha512});me.hashToCurve=Th.hashToCurve;me.encodeToCurve=Th.encodeToCurve;function Fl(e){if(!(e instanceof xr))throw new Error("RistrettoPoint expected")}var Cl=Ul,Bx=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Ix=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Px=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Fx=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),ph=e=>kl(kr,e),Vx=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Vl=e=>me.ed25519.CURVE.Fp.create((0,Wn.bytesToNumberLE)(e)&Vx);function hh(e){let{d:t}=me.ed25519.CURVE,r=me.ed25519.CURVE.Fp.ORDER,n=me.ed25519.CURVE.Fp.create,i=n(Cl*e*e),s=n((i+kr)*Px),a=BigInt(-1),o=n((a-t*i)*n(i+t)),{isValid:c,value:d}=kl(s,o),f=n(d*e);(0,Ue.isNegativeLE)(f,r)||(f=n(-f)),c||(d=f),c||(a=i);let p=n(a*(i-kr)*Fx-o),m=d*d,b=n((d+d)*o),l=n(p*Bx),A=n(kr-m),v=n(kr+m);return new me.ed25519.ExtendedPoint(n(b*v),n(A*l),n(l*v),n(b*A))}var xr=class e{constructor(t){this.ep=t}static fromAffine(t){return new e(me.ed25519.ExtendedPoint.fromAffine(t))}static hashToCurve(t){t=(0,Wn.ensureBytes)("ristrettoHash",t,64);let r=Vl(t.slice(0,32)),n=hh(r),i=Vl(t.slice(32,64)),s=hh(i);return new e(n.add(s))}static fromHex(t){t=(0,Wn.ensureBytes)("ristrettoHex",t,32);let{a:r,d:n}=me.ed25519.CURVE,i=me.ed25519.CURVE.Fp.ORDER,s=me.ed25519.CURVE.Fp.create,a="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",o=Vl(t);if(!(0,Wn.equalBytes)((0,Wn.numberToBytesLE)(o,32),t)||(0,Ue.isNegativeLE)(o,i))throw new Error(a);let c=s(o*o),d=s(kr+r*c),f=s(kr-r*c),p=s(d*d),m=s(f*f),b=s(r*n*p-m),{isValid:l,value:A}=ph(s(b*m)),v=s(A*f),F=s(A*v*b),C=s((o+o)*v);(0,Ue.isNegativeLE)(C,i)&&(C=s(-C));let O=s(d*F),H=s(C*O);if(!l||(0,Ue.isNegativeLE)(H,i)||O===Nx)throw new Error(a);return new e(new me.ed25519.ExtendedPoint(C,O,kr,H))}toRawBytes(){let{ex:t,ey:r,ez:n,et:i}=this.ep,s=me.ed25519.CURVE.Fp.ORDER,a=me.ed25519.CURVE.Fp.create,o=a(a(n+r)*a(n-r)),c=a(t*r),d=a(c*c),{value:f}=ph(a(o*d)),p=a(f*o),m=a(f*c),b=a(p*m*i),l;if((0,Ue.isNegativeLE)(i*b,s)){let v=a(r*Cl),F=a(t*Cl);t=v,r=F,l=a(p*Ix)}else l=m;(0,Ue.isNegativeLE)(t*b,s)&&(r=a(-r));let A=a((n-r)*l);return(0,Ue.isNegativeLE)(A,s)&&(A=a(-A)),(0,Wn.numberToBytesLE)(A,32)}toHex(){return(0,Wn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(t){Fl(t);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=t.ep,a=me.ed25519.CURVE.Fp.create,o=a(r*s)===a(n*i),c=a(n*s)===a(r*i);return o||c}add(t){return Fl(t),new e(this.ep.add(t.ep))}subtract(t){return Fl(t),new e(this.ep.subtract(t.ep))}multiply(t){return new e(this.ep.multiply(t))}multiplyUnsafe(t){return new e(this.ep.multiplyUnsafe(t))}double(){return new e(this.ep.double())}negate(){return new e(this.ep.negate())}};me.RistrettoPoint=(xr.BASE||(xr.BASE=new xr(me.ed25519.ExtendedPoint.BASE)),xr.ZERO||(xr.ZERO=new xr(me.ed25519.ExtendedPoint.ZERO)),xr);var Ux=(e,t)=>{let r=t.DST,n=typeof r=="string"?(0,Ss.utf8ToBytes)(r):r,i=(0,_h.expand_message_xmd)(e,n,64,Ro.sha512);return xr.hashToCurve(i)};me.hashToRistretto255=Ux;me.hash_to_ristretto255=me.hashToRistretto255});var vh=ee(Sn=>{"use strict";var Nh=Sn&&Sn.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},Dt=Sn&&Sn.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},St,Ps,Oh,Eh;Object.defineProperty(Sn,"__esModule",{value:!0});Sn.ExpirableMap=void 0;var jl=class{constructor(t={}){St.set(this,void 0),Ps.set(this,void 0),this[Oh]=this.entries.bind(this),this[Eh]="ExpirableMap";let{source:r=[],expirationTime:n=600*1e3}=t,i=Date.now();Nh(this,St,new Map([...r].map(([s,a])=>[s,{value:a,timestamp:i}])),"f"),Nh(this,Ps,n,"f")}prune(){let t=Date.now();for(let[r,n]of Dt(this,St,"f").entries())t-n.timestamp>Dt(this,Ps,"f")&&Dt(this,St,"f").delete(r);return this}set(t,r){this.prune();let n={value:r,timestamp:Date.now()};return Dt(this,St,"f").set(t,n),this}get(t){let r=Dt(this,St,"f").get(t);if(r!==void 0){if(Date.now()-r.timestamp>Dt(this,Ps,"f")){Dt(this,St,"f").delete(t);return}return r.value}}clear(){Dt(this,St,"f").clear()}entries(){let t=Dt(this,St,"f").entries();return function*(){for(let[n,i]of t)yield[n,i.value]}()}values(){let t=Dt(this,St,"f").values();return function*(){for(let n of t)yield n.value}()}keys(){return Dt(this,St,"f").keys()}forEach(t,r){for(let[n,i]of Dt(this,St,"f").entries())t.call(r,i.value,n,this)}has(t){return Dt(this,St,"f").has(t)}delete(t){return Dt(this,St,"f").delete(t)}get size(){return Dt(this,St,"f").size}};Sn.ExpirableMap=jl;St=new WeakMap,Ps=new WeakMap,Oh=Symbol.iterator,Eh=Symbol.toStringTag});var Ll=ee(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.unwrapDER=De.wrapDER=De.SECP256K1_OID=De.ED25519_OID=De.DER_COSE_OID=De.decodeLen=De.decodeLenBytes=De.encodeLen=De.encodeLenBytes=void 0;var Cx=$t(),qx=e=>{if(e<=127)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")};De.encodeLenBytes=qx;var Mx=(e,t,r)=>{if(r<=127)return e[t]=r,1;if(r<=255)return e[t]=129,e[t+1]=r,2;if(r<=65535)return e[t]=130,e[t+1]=r>>8,e[t+2]=r,3;if(r<=16777215)return e[t]=131,e[t+1]=r>>16,e[t+2]=r>>8,e[t+3]=r,4;throw new Error("Length too long (> 4 bytes)")};De.encodeLen=Mx;var kx=(e,t)=>{if(e[t]<128)return 1;if(e[t]===128)throw new Error("Invalid length 0");if(e[t]===129)return 2;if(e[t]===130)return 3;if(e[t]===131)return 4;throw new Error("Length too long (> 4 bytes)")};De.decodeLenBytes=kx;var Dx=(e,t)=>{let r=(0,De.decodeLenBytes)(e,t);if(r===1)return e[t];if(r===2)return e[t+1];if(r===3)return(e[t+1]<<8)+e[t+2];if(r===4)return(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];throw new Error("Length too long (> 4 bytes)")};De.decodeLen=Dx;De.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);De.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);De.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function jx(e,t){let r=2+(0,De.encodeLenBytes)(e.byteLength+1),n=t.byteLength+r+e.byteLength,i=0,s=new Uint8Array(1+(0,De.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,De.encodeLen)(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=(0,De.encodeLen)(s,i,e.byteLength+1),s[i++]=0,s.set(new Uint8Array(e),i),s}De.wrapDER=jx;var Lx=(e,t)=>{let r=0,n=(o,c)=>{if(i[r++]!==o)throw new Error("Expected: "+c)},i=new Uint8Array(e);if(n(48,"sequence"),r+=(0,De.decodeLenBytes)(i,r),!(0,Cx.bufEquals)(i.slice(r,r+t.byteLength),t))throw new Error("Not the expected OID.");r+=t.byteLength,n(3,"bit string");let s=(0,De.decodeLen)(i,r)-1;r+=(0,De.decodeLenBytes)(i,r),n(0,"0 padding");let a=i.slice(r);if(s!==a.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${a.length}`);return a};De.unwrapDER=Lx});var Hl=ee(Bn=>{"use strict";var Rh=Bn&&Bn.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},Ah=Bn&&Bn.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},So,Bo;Object.defineProperty(Bn,"__esModule",{value:!0});Bn.Ed25519PublicKey=void 0;var Ao=Ll(),Io=class e{constructor(t){if(So.set(this,void 0),Bo.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Rh(this,So,t,"f"),Rh(this,Bo,e.derEncode(t),"f")}static from(t){return this.fromDer(t.toDer())}static fromRaw(t){return new e(t)}static fromDer(t){return new e(this.derDecode(t))}static derEncode(t){return(0,Ao.wrapDER)(t,Ao.ED25519_OID).buffer}static derDecode(t){let r=(0,Ao.unwrapDER)(t,Ao.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Ah(this,So,"f")}get derKey(){return Ah(this,Bo,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Bn.Ed25519PublicKey=Io;So=new WeakMap,Bo=new WeakMap;Io.RAW_KEY_LENGTH=32});var $l=ee(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.ObservableLog=Bi.Observable=void 0;var Po=class{constructor(){this.observers=[]}subscribe(t){this.observers.push(t)}unsubscribe(t){this.observers=this.observers.filter(r=>r!==t)}notify(t,...r){this.observers.forEach(n=>n(t,...r))}};Bi.Observable=Po;var Kl=class extends Po{constructor(){super()}print(t,...r){this.notify({message:t,level:"info"},...r)}warn(t,...r){this.notify({message:t,level:"warn"},...r)}error(t,r,...n){this.notify({message:t,level:"error",error:r},...n)}};Bi.ObservableLog=Kl});var Uh=ee(Lr=>{"use strict";var Dr=Lr&&Lr.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},Bt=Lr&&Lr.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},jr,Fo,Vo,Uo,Co,qo,Mo,ko,Ii;Object.defineProperty(Lr,"__esModule",{value:!0});Lr.exponentialBackoff=Lr.ExponentialBackoff=void 0;var Sh=.5,Bh=1.5,Ih=500,Ph=6e4,Fh=9e5,Vh=10,Pi=class e{constructor(t=e.default){jr.set(this,void 0),Fo.set(this,void 0),Vo.set(this,void 0),Uo.set(this,void 0),Co.set(this,void 0),qo.set(this,void 0),Mo.set(this,void 0),ko.set(this,void 0),Ii.set(this,0);let{initialInterval:r=Ih,randomizationFactor:n=Sh,multiplier:i=Bh,maxInterval:s=Ph,maxElapsedTime:a=Fh,maxIterations:o=Vh,date:c=Date}=t;Dr(this,jr,r,"f"),Dr(this,Fo,n,"f"),Dr(this,Vo,i,"f"),Dr(this,Uo,s,"f"),Dr(this,ko,c,"f"),Dr(this,Co,c.now(),"f"),Dr(this,qo,a,"f"),Dr(this,Mo,o,"f")}get ellapsedTimeInMsec(){return Bt(this,ko,"f").now()-Bt(this,Co,"f")}get currentInterval(){return Bt(this,jr,"f")}get count(){return Bt(this,Ii,"f")}get randomValueFromInterval(){let t=Bt(this,Fo,"f")*Bt(this,jr,"f"),r=Bt(this,jr,"f")-t,n=Bt(this,jr,"f")+t;return Math.random()*(n-r)+r}incrementCurrentInterval(){var t;return Dr(this,jr,Math.min(Bt(this,jr,"f")*Bt(this,Vo,"f"),Bt(this,Uo,"f")),"f"),Dr(this,Ii,(t=Bt(this,Ii,"f"),t++,t),"f"),Bt(this,jr,"f")}next(){return this.ellapsedTimeInMsec>=Bt(this,qo,"f")||Bt(this,Ii,"f")>=Bt(this,Mo,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Lr.ExponentialBackoff=Pi;jr=new WeakMap,Fo=new WeakMap,Vo=new WeakMap,Uo=new WeakMap,Co=new WeakMap,qo=new WeakMap,Mo=new WeakMap,ko=new WeakMap,Ii=new WeakMap;Pi.default={initialInterval:Ih,randomizationFactor:Sh,multiplier:Bh,maxInterval:Ph,maxElapsedTime:Fh,maxIterations:Vh,date:Date};function*Hx(e=Pi.default){let t=new Pi(e),r=t.next();for(;r;)yield r,r=t.next()}Lr.exponentialBackoff=Hx});var Wl=ee(Ce=>{"use strict";var qh=Ce&&Ce.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Kx=Ce&&Ce.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Mh=Ce&&Ce.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&qh(t,e,r);return Kx(t,e),t},kh=Ce&&Ce.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&qh(t,e,r)},Tt=Ce&&Ce.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},ie=Ce&&Ce.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},It,Yn,Mi,Hr,an,qi,Fs,Vi,Nr,Or,Jn,Zn,Vs,Ui,Ci,Xn,ei,Dh,Lo,Ho,Qn;Object.defineProperty(Ce,"__esModule",{value:!0});Ce.HttpAgent=Ce.IdentityInvalidError=Ce.MANAGEMENT_CANISTER_ID=Ce.IC_ROOT_KEY=Ce.RequestStatusResponseStatus=Ce.makeNonce=void 0;var cr=Ut(),Kr=_i(),Ch=ju(),In=Mh(ys()),Do=ps(),Tr=$t(),Er=Za(),Gl=ms(),ki=Qa(),$x=As(),Fi=Ai(),Gx=Dl(),zx=vh(),Wx=Hl(),Yx=_o(),Jx=$l(),Zx=Uh();kh(Za(),Ce);kh(Qa(),Ce);var Xx=ms();Object.defineProperty(Ce,"makeNonce",{enumerable:!0,get:function(){return Xx.makeNonce}});var Qx;(function(e){e.Received="received",e.Processing="processing",e.Replied="replied",e.Rejected="rejected",e.Unknown="unknown",e.Done="done"})(Qx=Ce.RequestStatusResponseStatus||(Ce.RequestStatusResponseStatus={}));var jo=60*1e3;Ce.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Ce.MANAGEMENT_CANISTER_ID="aaaaa-aa";var eT="ic0.app",tT=".ic0.app",rT="icp0.io",nT=".icp0.io",iT="icp-api.io",sT=".icp-api.io",Us=class extends Kr.AgentError{constructor(t){super(t),this.message=t}},ti=class extends Kr.AgentError{constructor(t){super(t),this.message=t}};Ce.IdentityInvalidError=ti;function aT(){let e;if(typeof window<"u")if(window.fetch)e=window.fetch.bind(window);else throw new Us("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof global<"u")if(global.fetch)e=global.fetch.bind(global);else throw new Us("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(e=self.fetch.bind(self));if(e)return e;throw new Us("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function oT(e){let t;if(e!==void 0)!e.match(/^[a-z]+:/)&&typeof window<"u"?t=new URL(window.location.protocol+"//"+e):t=new URL(e);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,a;s&&typeof s=="string"&&(n.some(o=>s.endsWith(o))?a=s:a=r.find(o=>s.endsWith(o))),i&&a?t=new URL(`${i.protocol}//${a}${i.port?":"+i.port:""}`):t=new URL("https://icp-api.io")}return t.toString()}var zl=class e{constructor(t={}){var r,n;It.add(this),Yn.set(this,null),Mi.set(this,!1),Hr.set(this,void 0),an.set(this,void 0),qi.set(this,void 0),Fs.set(this,void 0),Vi.set(this,0),Nr.set(this,void 0),Or.set(this,void 0),Jn.set(this,void 0),Zn.set(this,void 0),this._isAgent=!0,this.config={},Vs.set(this,0),this.log=new Jx.ObservableLog,Ui.set(this,[]),Ci.set(this,[]),Xn.set(this,new zx.ExpirableMap({expirationTime:300*1e3})),ei.set(this,!0),Ho.set(this,(a,o)=>{if(ie(this,ei,"f")===!1)return a;if(!o)throw new Fi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:c,signatures:d=[],requestId:f}=a,p=new TextEncoder().encode("\vic-response");for(let m of d){let{timestamp:b,identity:l}=m,A=cr.Principal.fromUint8Array(l).toText(),v;if(c==="replied"){let{reply:x}=a;v=(0,Do.hashOfMap)({status:c,reply:x,timestamp:BigInt(b),request_id:f})}else if(c==="rejected"){let{reject_code:x,reject_message:q,error_code:K}=a;v=(0,Do.hashOfMap)({status:c,reject_code:x,reject_message:q,error_code:K,timestamp:BigInt(b),request_id:f})}else throw new Error(`Unknown status: ${c}`);let F=(0,Tr.concat)(p,new Uint8Array(v)),C=o?.nodeKeys.get(A);if(!C)throw new Fi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let O=Wx.Ed25519PublicKey.fromDer(C).rawKey;if(Gx.ed25519.verify(m.signature,new Uint8Array(F),new Uint8Array(O)))return a;throw new Fi.CertificateVerificationError(`Invalid signature from replica ${A} signed query.`)}return a}),this.config=t,Tt(this,an,t.fetch||aT()||fetch.bind(global),"f"),Tt(this,qi,t.fetchOptions,"f"),Tt(this,Fs,t.callOptions,"f"),Tt(this,Mi,(r=t.shouldFetchRootKey)!==null&&r!==void 0?r:!1,"f"),t.rootKey?this.rootKey=t.rootKey:ie(this,Mi,"f")?this.rootKey=null:this.rootKey=(0,Tr.fromHex)(Ce.IC_ROOT_KEY);let i=oT(t.host);this.host=new URL(i),t.verifyQuerySignatures!==void 0&&Tt(this,ei,t.verifyQuerySignatures,"f"),Tt(this,Or,(n=t.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new Zx.ExponentialBackoff({maxIterations:ie(this,Or,"f")});if(Tt(this,Jn,t.backoffStrategy||s,"f"),this.host.hostname.endsWith(tT)?this.host.hostname=eT:this.host.hostname.endsWith(nT)?this.host.hostname=rT:this.host.hostname.endsWith(sT)&&(this.host.hostname=iT),t.credentials){let{name:a,password:o}=t.credentials;Tt(this,Nr,`${a}${o?":"+o:""}`,"f")}if(Tt(this,Hr,Promise.resolve(t.identity||new Ch.AnonymousIdentity),"f"),t.ingressExpiryInMinutes&&t.ingressExpiryInMinutes>5)throw new Kr.AgentError(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${t.ingressExpiryInMinutes} minutes.`);if(t.ingressExpiryInMinutes&&t.ingressExpiryInMinutes<=0)throw new Kr.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${t.ingressExpiryInMinutes} minutes.`);Tt(this,Zn,t.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,Er.makeNonceTransform)(Gl.makeNonce)),t.useQueryNonces&&this.addTransform("query",(0,Er.makeNonceTransform)(Gl.makeNonce)),t.logToConsole&&this.log.subscribe(a=>{a.level==="error"?console.error(a.message):a.level==="warn"?console.warn(a.message):console.log(a.message)})}get waterMark(){return ie(this,Vs,"f")}static createSync(t={}){return new this(Object.assign({},t))}static async create(t={shouldFetchRootKey:!1}){let r=e.createSync(t),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&t.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(t){var r;try{return"config"in t?await e.create(t.config):await e.create({fetch:t._fetch,fetchOptions:t._fetchOptions,callOptions:t._callOptions,host:t._host.toString(),identity:(r=t._identity)!==null&&r!==void 0?r:void 0})}catch{throw new Kr.AgentError("Failed to create agent from provided agent")}}isLocal(){let t=this.host.hostname;return t==="127.0.0.1"||t.endsWith("127.0.0.1")}addTransform(t,r,n=r.priority||0){if(t==="update"){let i=ie(this,Ci,"f").findIndex(s=>(s.priority||0)<n);ie(this,Ci,"f").splice(i>=0?i:ie(this,Ci,"f").length,0,Object.assign(r,{priority:n}))}else if(t==="query"){let i=ie(this,Ui,"f").findIndex(s=>(s.priority||0)<n);ie(this,Ui,"f").splice(i>=0?i:ie(this,Ui,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ie(this,Hr,"f"))throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ie(this,Hr,"f")).getPrincipal()}async call(t,r,n){var i,s;await ie(this,It,"m",Qn).call(this);let a=(i=r.callSync)!==null&&i!==void 0?i:!0,o=await(n!==void 0?await n:await ie(this,Hr,"f"));if(!o)throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");let c=cr.Principal.from(t),d=r.effectiveCanisterId?cr.Principal.from(r.effectiveCanisterId):c,f=o.getPrincipal()||cr.Principal.anonymous(),p=new Er.Expiry(ie(this,Zn,"f")*jo);Math.abs(ie(this,Vi,"f"))>1e3*30&&(p=new Er.Expiry(ie(this,Zn,"f")*jo+ie(this,Vi,"f")));let m={request_type:Gl.SubmitRequestType.Call,canister_id:c,method_name:r.methodName,arg:r.arg,sender:f,ingress_expiry:p},b=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,Nr,"f")?{Authorization:"Basic "+btoa(ie(this,Nr,"f"))}:{})},endpoint:"call",body:m}),l=b.body.nonce?A(b.body.nonce):void 0;m.nonce=l;function A(O){return new Uint8Array(O)}b=await o.transformRequest(b);let v=In.encode(b.body),F=ie(this,Jn,"f").call(this),C=(0,Do.requestIdOf)(m);try{let O=()=>(this.log.print(`fetching "/api/v3/canister/${d.toText()}/call" with request:`,b),ie(this,an,"f").call(this,""+new URL(`/api/v3/canister/${d.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Fs,"f")),b.request),{body:v}))),H=()=>(this.log.print(`fetching "/api/v2/canister/${d.toText()}/call" with request:`,b),ie(this,an,"f").call(this,""+new URL(`/api/v2/canister/${d.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Fs,"f")),b.request),{body:v}))),q=await ie(this,It,"m",Lo).call(this,{request:a?O:H,backoff:F,tries:0}),K=await q.arrayBuffer(),$=q.status===200&&K.byteLength>0?In.decode(K):null;if($&&"certificate"in $){let M=await this.parseTimeFromResponse({certificate:$.certificate});Tt(this,Vs,M,"f")}return{requestId:C,response:{ok:q.ok,status:q.status,statusText:q.statusText,body:$,headers:(0,Er.httpHeadersTransform)(q.headers)},requestDetails:m}}catch(O){if(O.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(t,Object.assign(Object.assign({},r),{callSync:!1}),n);let H=`Error while making call: ${(s=O.message)!==null&&s!==void 0?s:String(O)}`,x=new ki.AgentCallError(H,O,(0,Tr.toHex)(C),(0,Tr.toHex)(b.body.sender_pubkey),(0,Tr.toHex)(b.body.sender_sig),String(b.body.content.ingress_expiry._value));throw this.log.error(H,x),x}}async query(t,r,n){var i,s,a,o;await ie(this,It,"m",Qn).call(this);let c=ie(this,Jn,"f").call(this),d=r.effectiveCanisterId?cr.Principal.from(r.effectiveCanisterId):cr.Principal.from(t);this.log.print(`ecid ${d.toString()}`),this.log.print(`canisterId ${t.toString()}`);let f,p,m=await(n!==void 0?n:ie(this,Hr,"f"));if(!m)throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");let b=cr.Principal.from(t),l=m?.getPrincipal()||cr.Principal.anonymous(),A={request_type:"query",canister_id:b,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:new Er.Expiry(ie(this,Zn,"f")*jo)},v=(0,Do.requestIdOf)(A);f=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,Nr,"f")?{Authorization:"Basic "+btoa(ie(this,Nr,"f"))}:{})},endpoint:"read",body:A}),f=await m?.transformRequest(f);let F=In.encode(f.body),C={canister:b.toText(),ecid:d,transformedRequest:f,body:F,requestId:v,backoff:c,tries:0},O=async()=>({requestDetails:A,query:await ie(this,It,"m",Dh).call(this,C)}),H=async()=>{if(!ie(this,ei,"f"))return;let x=ie(this,Xn,"f").get(d.toString());return x||(await this.fetchSubnetKeys(d.toString()),ie(this,Xn,"f").get(d.toString()))};try{let[x,q]=await Promise.all([O(),H()]);p=x;let{requestDetails:K,query:$}=p,M=Object.assign(Object.assign({},$),{requestDetails:K});if(this.log.print("Query response:",M),!ie(this,ei,"f"))return M;try{return ie(this,Ho,"f").call(this,M,q)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ie(this,Xn,"f").delete(t.toString()),await this.fetchSubnetKeys(d.toString());let Q=ie(this,Xn,"f").get(t.toString());if(!Q)throw new Fi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ie(this,Ho,"f").call(this,M,Q)}}catch(x){let q=`Error while making call: ${(i=x.message)!==null&&i!==void 0?i:String(x)}`,K=new ki.AgentQueryError(q,x,String(v),(0,Tr.toHex)((s=f?.body)===null||s===void 0?void 0:s.sender_pubkey),(0,Tr.toHex)((a=f?.body)===null||a===void 0?void 0:a.sender_sig),String((o=f?.body)===null||o===void 0?void 0:o.content.ingress_expiry._value));throw this.log.error(q,K),K}}async createReadStateRequest(t,r){await ie(this,It,"m",Qn).call(this);let n=await(r!==void 0?await r:await ie(this,Hr,"f"));if(!n)throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||cr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,Nr,"f")?{Authorization:"Basic "+btoa(ie(this,Nr,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:t.paths,sender:i,ingress_expiry:new Er.Expiry(ie(this,Zn,"f")*jo)}});return n?.transformRequest(s)}async readState(t,r,n,i){var s,a,o,c;function d(A){for(let v of A.paths){let[F,C]=v,O=new TextEncoder().encode("request_status");if((0,Tr.bufEquals)(F,O))return C}}let f=d(r);await ie(this,It,"m",Qn).call(this);let p=typeof t=="string"?cr.Principal.fromText(t):t,m=i??await this.createReadStateRequest(r,n),b=In.encode(m.body);this.log.print(`fetching "/api/v2/canister/${p}/read_state" with request:`,m);let l=ie(this,Jn,"f").call(this);try{let A=await ie(this,It,"m",Lo).call(this,{request:()=>ie(this,an,"f").call(this,""+new URL(`/api/v2/canister/${p.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,qi,"f")),m.request),{body:b})),backoff:l,tries:0});if(!A.ok)throw new Error(`Server returned an error:
31
31
  Code: ${A.status} (${A.statusText})
32
32
  Body: ${await A.text()}
33
- `);let v=In.decode(await A.arrayBuffer());this.log.print("Read state response:",v);let F=await this.parseTimeFromResponse(v);return F>0&&(this.log.print("Read state response time:",F),Tt(this,Vs,F,"f")),v}catch(A){let v=`Caught exception while attempting to read state: ${(s=A.message)!==null&&s!==void 0?s:String(A)}`,F=new ki.AgentReadStateError(v,A,String(f),(0,Tr.toHex)((a=m?.body)===null||a===void 0?void 0:a.sender_pubkey),(0,Tr.toHex)((o=m?.body)===null||o===void 0?void 0:o.sender_sig),String((c=m?.body)===null||c===void 0?void 0:c.content.ingress_expiry._value));throw this.log.error(v,F),F}}async parseTimeFromResponse(t){let r;if(t.certificate){let n=In.decode(t.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,Fi.lookup_path)(["time"],r);if(i.status!==Fi.LookupStatus.Found)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i.value instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let s=(0,Zx.decodeTime)((0,Tr.bufFromBufLike)(i.value));return this.log.print("Time from response:",s),this.log.print("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(t){await ie(this,Ft,"m",Qn).call(this);let r=await Promise.resolve().then(()=>kh(As())),n=Date.now();try{t||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let i=e.createSync({identity:new qh.AnonymousIdentity,host:this.host.toString(),fetch:ie(this,an,"f"),retryTimes:0}),a=(await r.request({canisterId:t??cr.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:i,paths:["time"]})).get("time");a&&(Tt(this,Vi,Number(a)-Number(n),"f"),this.log.notify({message:`Syncing time: offset of ${ie(this,Vi,"f")}`,level:"info"}))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let t=ie(this,Nr,"f")?{Authorization:"Basic "+btoa(ie(this,Nr,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ie(this,Jn,"f").call(this),n=await ie(this,Ft,"m",Ho).call(this,{backoff:r,request:()=>ie(this,an,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:t},ie(this,qi,"f"))),tries:0});return In.decode(await n.arrayBuffer())}async fetchRootKey(){let t;return ie(this,Yn,"f")?t=await ie(this,Yn,"f"):(Tt(this,Yn,new Promise((r,n)=>{this.status().then(i=>{let s=i.root_key;this.rootKey=s,r(s)}).catch(n)}),"f"),t=await ie(this,Yn,"f")),Tt(this,Yn,null,"f"),t}invalidateIdentity(){Tt(this,Hr,null,"f")}replaceIdentity(t){Tt(this,Hr,Promise.resolve(t),"f")}async fetchSubnetKeys(t){await ie(this,Ft,"m",Qn).call(this);let r=cr.Principal.from(t),i=(await(0,zx.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ie(this,Xn,"f").set(r.toText(),i),i}_transform(t){let r=Promise.resolve(t);if(t.endpoint==="call")for(let n of ie(this,Ci,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ie(this,Ui,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};qe.HttpAgent=Wl;Yn=new WeakMap,Mi=new WeakMap,Hr=new WeakMap,an=new WeakMap,qi=new WeakMap,Fs=new WeakMap,Vi=new WeakMap,Nr=new WeakMap,Or=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,Vs=new WeakMap,Ui=new WeakMap,Ci=new WeakMap,Xn=new WeakMap,ei=new WeakMap,Ko=new WeakMap,Ft=new WeakSet,jh=async function e(t){var r,n;let{ecid:i,transformedRequest:s,body:a,requestId:o,backoff:c,tries:d}=t,f=d===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:d,backoff:c,delay:f}),f===null)throw new Kr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ie(this,Or,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);f>0&&await new Promise(l=>setTimeout(l,f));let p;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let l=await ie(this,an,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,qi,"f")),s.request),{body:a}));if(l.status===200){let A=In.decode(await l.arrayBuffer());p=Object.assign(Object.assign({},A),{httpDetails:{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,Er.httpHeadersTransform)(l.headers)},requestId:o})}else throw new ki.AgentHTTPResponseError(`Gateway returned an error:
33
+ `);let v=In.decode(await A.arrayBuffer());this.log.print("Read state response:",v);let F=await this.parseTimeFromResponse(v);return F>0&&(this.log.print("Read state response time:",F),Tt(this,Vs,F,"f")),v}catch(A){let v=`Caught exception while attempting to read state: ${(s=A.message)!==null&&s!==void 0?s:String(A)}`,F=new ki.AgentReadStateError(v,A,String(f),(0,Tr.toHex)((a=m?.body)===null||a===void 0?void 0:a.sender_pubkey),(0,Tr.toHex)((o=m?.body)===null||o===void 0?void 0:o.sender_sig),String((c=m?.body)===null||c===void 0?void 0:c.content.ingress_expiry._value));throw this.log.error(v,F),F}}async parseTimeFromResponse(t){let r;if(t.certificate){let n=In.decode(t.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,Fi.lookup_path)(["time"],r);if(i.status!==Fi.LookupStatus.Found)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i.value instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let s=(0,Yx.decodeTime)((0,Tr.bufFromBufLike)(i.value));return this.log.print("Time from response:",s),this.log.print("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(t){await ie(this,It,"m",Qn).call(this);let r=await Promise.resolve().then(()=>Mh(As())),n=Date.now();try{t||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let i=e.createSync({identity:new Ch.AnonymousIdentity,host:this.host.toString(),fetch:ie(this,an,"f"),retryTimes:0}),a=(await r.request({canisterId:t??cr.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:i,paths:["time"]})).get("time");a&&(Tt(this,Vi,Number(a)-Number(n),"f"),this.log.notify({message:`Syncing time: offset of ${ie(this,Vi,"f")}`,level:"info"}))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let t=ie(this,Nr,"f")?{Authorization:"Basic "+btoa(ie(this,Nr,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ie(this,Jn,"f").call(this),n=await ie(this,It,"m",Lo).call(this,{backoff:r,request:()=>ie(this,an,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:t},ie(this,qi,"f"))),tries:0});return In.decode(await n.arrayBuffer())}async fetchRootKey(){let t;return ie(this,Yn,"f")?t=await ie(this,Yn,"f"):(Tt(this,Yn,new Promise((r,n)=>{this.status().then(i=>{let s=i.root_key;this.rootKey=s,r(s)}).catch(n)}),"f"),t=await ie(this,Yn,"f")),Tt(this,Yn,null,"f"),t}invalidateIdentity(){Tt(this,Hr,null,"f")}replaceIdentity(t){Tt(this,Hr,Promise.resolve(t),"f")}async fetchSubnetKeys(t){await ie(this,It,"m",Qn).call(this);let r=cr.Principal.from(t),i=(await(0,$x.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ie(this,Xn,"f").set(r.toText(),i),i}_transform(t){let r=Promise.resolve(t);if(t.endpoint==="call")for(let n of ie(this,Ci,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ie(this,Ui,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Ce.HttpAgent=zl;Yn=new WeakMap,Mi=new WeakMap,Hr=new WeakMap,an=new WeakMap,qi=new WeakMap,Fs=new WeakMap,Vi=new WeakMap,Nr=new WeakMap,Or=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,Vs=new WeakMap,Ui=new WeakMap,Ci=new WeakMap,Xn=new WeakMap,ei=new WeakMap,Ho=new WeakMap,It=new WeakSet,Dh=async function e(t){var r,n;let{ecid:i,transformedRequest:s,body:a,requestId:o,backoff:c,tries:d}=t,f=d===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:d,backoff:c,delay:f}),f===null)throw new Kr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ie(this,Or,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);f>0&&await new Promise(l=>setTimeout(l,f));let p;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let l=await ie(this,an,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,qi,"f")),s.request),{body:a}));if(l.status===200){let A=In.decode(await l.arrayBuffer());p=Object.assign(Object.assign({},A),{httpDetails:{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,Er.httpHeadersTransform)(l.headers)},requestId:o})}else throw new ki.AgentHTTPResponseError(`Gateway returned an error:
34
34
  Code: ${l.status} (${l.statusText})
35
35
  Body: ${await l.text()}
36
36
  `,{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,Er.httpHeadersTransform)(l.headers)})}catch(l){if(d<ie(this,Or,"f"))return this.log.warn(`Caught exception while attempting to make query:
37
37
  ${l}
38
- Retrying query.`),await ie(this,Ft,"m",e).call(this,Object.assign(Object.assign({},t),{tries:d+1}));throw l}let m=(n=(r=p.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ie(this,ei,"f"))return p;if(!m)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let b=Number(BigInt(m)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:b}),Number(this.waterMark)>b){let l=new Kr.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",l,{timestamp:m,waterMark:this.waterMark}),d<ie(this,Or,"f"))return await ie(this,Ft,"m",e).call(this,Object.assign(Object.assign({},t),{tries:d+1}));throw new Kr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ie(this,Or,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return p},Ho=async function e(t){let{request:r,backoff:n,tries:i}=t,s=i===0?0:n.next();if(s===null)throw new Kr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ie(this,Or,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(d=>setTimeout(d,s));let a;try{a=await r()}catch(d){if(ie(this,Or,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
38
+ Retrying query.`),await ie(this,It,"m",e).call(this,Object.assign(Object.assign({},t),{tries:d+1}));throw l}let m=(n=(r=p.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ie(this,ei,"f"))return p;if(!m)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let b=Number(BigInt(m)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:b}),Number(this.waterMark)>b){let l=new Kr.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",l,{timestamp:m,waterMark:this.waterMark}),d<ie(this,Or,"f"))return await ie(this,It,"m",e).call(this,Object.assign(Object.assign({},t),{tries:d+1}));throw new Kr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ie(this,Or,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return p},Lo=async function e(t){let{request:r,backoff:n,tries:i}=t,s=i===0?0:n.next();if(s===null)throw new Kr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ie(this,Or,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(d=>setTimeout(d,s));let a;try{a=await r()}catch(d){if(ie(this,Or,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
39
39
  ${d}
40
- Retrying request.`),await ie(this,Ft,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw d}if(a.ok)return a;let o=await a.clone().text(),c=`Server returned an error:
40
+ Retrying request.`),await ie(this,It,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw d}if(a.ok)return a;let o=await a.clone().text(),c=`Server returned an error:
41
41
  Code: ${a.status} (${a.statusText})
42
42
  Body: ${o}
43
- `;if(a.status===404&&a.url.includes("api/v3"))throw new ki.AgentHTTPResponseError("v3 api not supported. Fall back to v2",{ok:a.ok,status:a.status,statusText:a.statusText,headers:(0,Er.httpHeadersTransform)(a.headers)});if(i<ie(this,Or,"f"))return await ie(this,Ft,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw new ki.AgentHTTPResponseError(c,{ok:a.ok,status:a.status,statusText:a.statusText,headers:(0,Er.httpHeadersTransform)(a.headers)})},Qn=async function(){if(!this.rootKey)if(this.rootKey===null&&ie(this,Mi,"f"))await this.fetchRootKey();else throw new Kr.AgentError(`Invalid root key detected. The root key for this agent is ${this.rootKey} and the shouldFetchRootKey value is set to ${ie(this,Mi,"f")}. The root key should only be unknown if you are in local development. Otherwise you should avoid fetching and use the default IC Root Key or the known root key of your environment.`)}});var Lh=ee(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.ProxyAgent=on.ProxyStubAgent=on.ProxyMessageKind=void 0;var lT=vt(),Xe;(function(e){e.Error="err",e.GetPrincipal="gp",e.GetPrincipalResponse="gpr",e.Query="q",e.QueryResponse="qr",e.Call="c",e.CallResponse="cr",e.ReadState="rs",e.ReadStateResponse="rsr",e.Status="s",e.StatusResponse="sr"})(Xe=on.ProxyMessageKind||(on.ProxyMessageKind={}));var Jl=class{constructor(t,r){this._frontend=t,this._agent=r}onmessage(t){switch(t.type){case Xe.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:t.id,type:Xe.GetPrincipalResponse,response:r.toText()})});break;case Xe.Query:this._agent.query(...t.args).then(r=>{this._frontend({id:t.id,type:Xe.QueryResponse,response:r})});break;case Xe.Call:this._agent.call(...t.args).then(r=>{this._frontend({id:t.id,type:Xe.CallResponse,response:r})});break;case Xe.ReadState:this._agent.readState(...t.args).then(r=>{this._frontend({id:t.id,type:Xe.ReadStateResponse,response:r})});break;case Xe.Status:this._agent.status().then(r=>{this._frontend({id:t.id,type:Xe.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(t)}`)}}};on.ProxyStubAgent=Jl;var Zl=class{constructor(t){this._backend=t,this._nextId=0,this._pendingCalls=new Map,this.rootKey=null}onmessage(t){let r=t.id,n=this._pendingCalls.get(r);if(!n)throw new Error("A proxy get the same message twice...");this._pendingCalls.delete(r);let[i,s]=n;switch(t.type){case Xe.Error:return s(t.error);case Xe.GetPrincipalResponse:case Xe.CallResponse:case Xe.QueryResponse:case Xe.ReadStateResponse:case Xe.StatusResponse:return i(t.response);default:throw new Error(`Invalid message being sent to ProxyAgent: ${JSON.stringify(t)}`)}}async getPrincipal(){return this._sendAndWait({id:this._nextId++,type:Xe.GetPrincipal}).then(t=>{if(typeof t!="string")throw new Error("Invalid principal received.");return lT.Principal.fromText(t)})}readState(t,r){return this._sendAndWait({id:this._nextId++,type:Xe.ReadState,args:[t.toString(),r]})}call(t,r){return this._sendAndWait({id:this._nextId++,type:Xe.Call,args:[t.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:Xe.Status})}query(t,r){return this._sendAndWait({id:this._nextId++,type:Xe.Query,args:[t.toString(),r]})}async _sendAndWait(t){return new Promise((r,n)=>{this._pendingCalls.set(t.id,[r,n]),this._backend(t)})}async fetchRootKey(){let t=(await this.status()).root_key;return this.rootKey=t,t}};on.ProxyAgent=Zl});var Rs=ee(ur=>{"use strict";var dT=ur&&ur.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),$o=ur&&ur.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&dT(t,e,r)};Object.defineProperty(ur,"__esModule",{value:!0});ur.getDefaultAgent=void 0;$o(Lc(),ur);$o(Yl(),ur);$o(eo(),ur);$o(Lh(),ur);function fT(){let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.ic.agent:global.ic.agent:window.ic.agent;if(!e)throw new Error("No Agent could be found.");return e}ur.getDefaultAgent=fT});var Go=ee(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.chain=mt.backoff=mt.timeout=mt.throttle=mt.maxAttempts=mt.conditionalDelay=mt.once=mt.defaultStrategy=void 0;var Hh=$t(),pT=300*1e3;function hT(){return Wh($h(Kh(),1e3),zh(1e3,1.2),Gh(pT))}mt.defaultStrategy=hT;function Kh(){let e=!0;return async()=>e?(e=!1,!0):!1}mt.once=Kh;function $h(e,t){return async(r,n,i)=>{if(await e(r,n,i))return new Promise(s=>setTimeout(s,t))}}mt.conditionalDelay=$h;function _T(e){let t=e;return async(r,n,i)=>{if(--t<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
44
- Request ID: ${(0,Hh.toHex)(n)}
43
+ `;if(a.status===404&&a.url.includes("api/v3"))throw new ki.AgentHTTPResponseError("v3 api not supported. Fall back to v2",{ok:a.ok,status:a.status,statusText:a.statusText,headers:(0,Er.httpHeadersTransform)(a.headers)});if(i<ie(this,Or,"f"))return await ie(this,It,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw new ki.AgentHTTPResponseError(c,{ok:a.ok,status:a.status,statusText:a.statusText,headers:(0,Er.httpHeadersTransform)(a.headers)})},Qn=async function(){if(!this.rootKey)if(this.rootKey===null&&ie(this,Mi,"f"))await this.fetchRootKey();else throw new Kr.AgentError(`Invalid root key detected. The root key for this agent is ${this.rootKey} and the shouldFetchRootKey value is set to ${ie(this,Mi,"f")}. The root key should only be unknown if you are in local development. Otherwise you should avoid fetching and use the default IC Root Key or the known root key of your environment.`)}});var jh=ee(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.ProxyAgent=on.ProxyStubAgent=on.ProxyMessageKind=void 0;var cT=Ut(),Xe;(function(e){e.Error="err",e.GetPrincipal="gp",e.GetPrincipalResponse="gpr",e.Query="q",e.QueryResponse="qr",e.Call="c",e.CallResponse="cr",e.ReadState="rs",e.ReadStateResponse="rsr",e.Status="s",e.StatusResponse="sr"})(Xe=on.ProxyMessageKind||(on.ProxyMessageKind={}));var Yl=class{constructor(t,r){this._frontend=t,this._agent=r}onmessage(t){switch(t.type){case Xe.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:t.id,type:Xe.GetPrincipalResponse,response:r.toText()})});break;case Xe.Query:this._agent.query(...t.args).then(r=>{this._frontend({id:t.id,type:Xe.QueryResponse,response:r})});break;case Xe.Call:this._agent.call(...t.args).then(r=>{this._frontend({id:t.id,type:Xe.CallResponse,response:r})});break;case Xe.ReadState:this._agent.readState(...t.args).then(r=>{this._frontend({id:t.id,type:Xe.ReadStateResponse,response:r})});break;case Xe.Status:this._agent.status().then(r=>{this._frontend({id:t.id,type:Xe.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(t)}`)}}};on.ProxyStubAgent=Yl;var Jl=class{constructor(t){this._backend=t,this._nextId=0,this._pendingCalls=new Map,this.rootKey=null}onmessage(t){let r=t.id,n=this._pendingCalls.get(r);if(!n)throw new Error("A proxy get the same message twice...");this._pendingCalls.delete(r);let[i,s]=n;switch(t.type){case Xe.Error:return s(t.error);case Xe.GetPrincipalResponse:case Xe.CallResponse:case Xe.QueryResponse:case Xe.ReadStateResponse:case Xe.StatusResponse:return i(t.response);default:throw new Error(`Invalid message being sent to ProxyAgent: ${JSON.stringify(t)}`)}}async getPrincipal(){return this._sendAndWait({id:this._nextId++,type:Xe.GetPrincipal}).then(t=>{if(typeof t!="string")throw new Error("Invalid principal received.");return cT.Principal.fromText(t)})}readState(t,r){return this._sendAndWait({id:this._nextId++,type:Xe.ReadState,args:[t.toString(),r]})}call(t,r){return this._sendAndWait({id:this._nextId++,type:Xe.Call,args:[t.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:Xe.Status})}query(t,r){return this._sendAndWait({id:this._nextId++,type:Xe.Query,args:[t.toString(),r]})}async _sendAndWait(t){return new Promise((r,n)=>{this._pendingCalls.set(t.id,[r,n]),this._backend(t)})}async fetchRootKey(){let t=(await this.status()).root_key;return this.rootKey=t,t}};on.ProxyAgent=Jl});var Rs=ee(ur=>{"use strict";var uT=ur&&ur.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Ko=ur&&ur.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&uT(t,e,r)};Object.defineProperty(ur,"__esModule",{value:!0});ur.getDefaultAgent=void 0;Ko(jc(),ur);Ko(Wl(),ur);Ko(Qa(),ur);Ko(jh(),ur);function lT(){let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.ic.agent:global.ic.agent:window.ic.agent;if(!e)throw new Error("No Agent could be found.");return e}ur.getDefaultAgent=lT});var $o=ee(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.chain=mt.backoff=mt.timeout=mt.throttle=mt.maxAttempts=mt.conditionalDelay=mt.once=mt.defaultStrategy=void 0;var Lh=$t(),dT=300*1e3;function fT(){return zh(Kh(Hh(),1e3),Gh(1e3,1.2),$h(dT))}mt.defaultStrategy=fT;function Hh(){let e=!0;return async()=>e?(e=!1,!0):!1}mt.once=Hh;function Kh(e,t){return async(r,n,i)=>{if(await e(r,n,i))return new Promise(s=>setTimeout(s,t))}}mt.conditionalDelay=Kh;function pT(e){let t=e;return async(r,n,i)=>{if(--t<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
44
+ Request ID: ${(0,Lh.toHex)(n)}
45
45
  Request status: ${i}
46
- `)}}mt.maxAttempts=_T;function yT(e){return()=>new Promise(t=>setTimeout(t,e))}mt.throttle=yT;function Gh(e){let t=Date.now()+e;return async(r,n,i)=>{if(Date.now()>t)throw new Error(`Request timed out after ${e} msec:
47
- Request ID: ${(0,Hh.toHex)(n)}
46
+ `)}}mt.maxAttempts=pT;function hT(e){return()=>new Promise(t=>setTimeout(t,e))}mt.throttle=hT;function $h(e){let t=Date.now()+e;return async(r,n,i)=>{if(Date.now()>t)throw new Error(`Request timed out after ${e} msec:
47
+ Request ID: ${(0,Lh.toHex)(n)}
48
48
  Request status: ${i}
49
- `)}}mt.timeout=Gh;function zh(e,t){let r=e;return()=>new Promise(n=>setTimeout(()=>{r*=t,n()},r))}mt.backoff=zh;function Wh(...e){return async(t,r,n)=>{for(let i of e)await i(t,r,n)}}mt.chain=Wh});var zo=ee(Jt=>{"use strict";var mT=Jt&&Jt.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),gT=Jt&&Jt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),bT=Jt&&Jt.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&mT(t,e,r);return gT(t,e),t};Object.defineProperty(Jt,"__esModule",{value:!0});Jt.pollForResponse=Jt.defaultStrategy=Jt.strategy=void 0;var ri=Rs(),Cs=Ai(),Yh=$t();Jt.strategy=bT(Go());var wT=Go(),xT=Go();Object.defineProperty(Jt,"defaultStrategy",{enumerable:!0,get:function(){return xT.defaultStrategy}});async function Jh(e,t,r,n=(0,wT.defaultStrategy)(),i,s){var a;let o=[new TextEncoder().encode("request_status"),r],c=i??await((a=e.createReadStateRequest)===null||a===void 0?void 0:a.call(e,{paths:[o]})),d=await e.readState(t,{paths:[o]},void 0,c);if(e.rootKey==null)throw new Error("Agent root key not initialized before polling");let f=await Cs.Certificate.create({certificate:d.certificate,rootKey:e.rootKey,canisterId:t,blsVerify:s}),p=(0,Cs.lookupResultToBuffer)(f.lookup([...o,new TextEncoder().encode("status")])),m;switch(typeof p>"u"?m=ri.RequestStatusResponseStatus.Unknown:m=new TextDecoder().decode(p),m){case ri.RequestStatusResponseStatus.Replied:return{reply:(0,Cs.lookupResultToBuffer)(f.lookup([...o,"reply"])),certificate:f};case ri.RequestStatusResponseStatus.Received:case ri.RequestStatusResponseStatus.Unknown:case ri.RequestStatusResponseStatus.Processing:return await n(t,r,m),Jh(e,t,r,n,c,s);case ri.RequestStatusResponseStatus.Rejected:{let b=new Uint8Array((0,Cs.lookupResultToBuffer)(f.lookup([...o,"reject_code"])))[0],l=new TextDecoder().decode((0,Cs.lookupResultToBuffer)(f.lookup([...o,"reject_message"])));throw new Error(`Call was rejected:
50
- Request ID: ${(0,Yh.toHex)(r)}
49
+ `)}}mt.timeout=$h;function Gh(e,t){let r=e;return()=>new Promise(n=>setTimeout(()=>{r*=t,n()},r))}mt.backoff=Gh;function zh(...e){return async(t,r,n)=>{for(let i of e)await i(t,r,n)}}mt.chain=zh});var Go=ee(Jt=>{"use strict";var _T=Jt&&Jt.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),yT=Jt&&Jt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),mT=Jt&&Jt.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&_T(t,e,r);return yT(t,e),t};Object.defineProperty(Jt,"__esModule",{value:!0});Jt.pollForResponse=Jt.defaultStrategy=Jt.strategy=void 0;var ri=Rs(),Cs=Ai(),Wh=$t();Jt.strategy=mT($o());var gT=$o(),bT=$o();Object.defineProperty(Jt,"defaultStrategy",{enumerable:!0,get:function(){return bT.defaultStrategy}});async function Yh(e,t,r,n=(0,gT.defaultStrategy)(),i,s){var a;let o=[new TextEncoder().encode("request_status"),r],c=i??await((a=e.createReadStateRequest)===null||a===void 0?void 0:a.call(e,{paths:[o]})),d=await e.readState(t,{paths:[o]},void 0,c);if(e.rootKey==null)throw new Error("Agent root key not initialized before polling");let f=await Cs.Certificate.create({certificate:d.certificate,rootKey:e.rootKey,canisterId:t,blsVerify:s}),p=(0,Cs.lookupResultToBuffer)(f.lookup([...o,new TextEncoder().encode("status")])),m;switch(typeof p>"u"?m=ri.RequestStatusResponseStatus.Unknown:m=new TextDecoder().decode(p),m){case ri.RequestStatusResponseStatus.Replied:return{reply:(0,Cs.lookupResultToBuffer)(f.lookup([...o,"reply"])),certificate:f};case ri.RequestStatusResponseStatus.Received:case ri.RequestStatusResponseStatus.Unknown:case ri.RequestStatusResponseStatus.Processing:return await n(t,r,m),Yh(e,t,r,n,c,s);case ri.RequestStatusResponseStatus.Rejected:{let b=new Uint8Array((0,Cs.lookupResultToBuffer)(f.lookup([...o,"reject_code"])))[0],l=new TextDecoder().decode((0,Cs.lookupResultToBuffer)(f.lookup([...o,"reject_message"])));throw new Error(`Call was rejected:
50
+ Request ID: ${(0,Wh.toHex)(r)}
51
51
  Reject code: ${b}
52
52
  Reject text: ${l}
53
53
  `)}case ri.RequestStatusResponseStatus.Done:throw new Error(`Call was marked as done but we never saw the reply:
54
- Request ID: ${(0,Yh.toHex)(r)}
55
- `)}throw new Error("unreachable")}Jt.pollForResponse=Jh});var Zh=ee(Xl=>{"use strict";Object.defineProperty(Xl,"__esModule",{value:!0});Xl.default=({IDL:e})=>{let t=e.Variant({mainnet:e.Null,testnet:e.Null}),r=e.Text,n=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),i=e.Nat64,s=i,a=e.Nat32,o=e.Record({start_height:a,end_height:e.Opt(a),network:t}),c=e.Vec(e.Nat8),d=e.Record({tip_height:a,block_headers:e.Vec(c)}),f=e.Record({network:t}),p=e.Nat64,m=e.Vec(p),b=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),l=e.Vec(e.Nat8),A=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),v=e.Record({height:e.Nat32,value:i,outpoint:A}),F=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:a,tip_block_hash:l,utxos:e.Vec(v)}),C=e.Record({transaction:e.Vec(e.Nat8),network:t}),O=e.Principal,H=e.Record({canister_id:O,num_requested_changes:e.Opt(e.Nat64)}),x=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),q=e.Vec(e.Nat8),K=e.Variant({creation:e.Record({controllers:e.Vec(e.Principal)}),code_deployment:e.Record({mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),module_hash:e.Vec(e.Nat8)}),load_snapshot:e.Record({canister_version:e.Nat64,taken_at_timestamp:e.Nat64,snapshot_id:q}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),$=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:x,details:K}),M=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec($),total_num_changes:e.Nat64}),ae=e.Record({canister_id:O}),Q=e.Variant({controllers:e.Null,public:e.Null,allowed_viewers:e.Vec(e.Principal)}),ne=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:Q,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),w=e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:ne,query_stats:e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),g=e.Record({canister_id:O}),S=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),reserved_cycles_limit:e.Opt(e.Nat),log_visibility:e.Opt(Q),wasm_memory_limit:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),R=e.Record({settings:e.Opt(S),sender_canister_version:e.Opt(e.Nat64)}),B=e.Record({canister_id:O}),j=e.Record({canister_id:O}),Y=e.Record({canister_id:O,snapshot_id:q}),oe=e.Record({canister_id:O}),se=e.Variant({secp256k1:e.Null}),W=e.Record({key_id:e.Record({name:e.Text,curve:se}),canister_id:e.Opt(O),derivation_path:e.Vec(e.Vec(e.Nat8))}),V=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),_=e.Record({canister_id:O}),Z=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),re=e.Record({canister_log_records:e.Vec(Z)}),le=e.Record({value:e.Text,name:e.Text}),X=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(le)}),u=e.Record({url:e.Text,method:e.Variant({get:e.Null,head:e.Null,post:e.Null}),max_response_bytes:e.Opt(e.Nat64),body:e.Opt(e.Vec(e.Nat8)),transform:e.Opt(e.Record({function:e.Func([e.Record({context:e.Vec(e.Nat8),response:X})],[X],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(le)}),h=e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({wasm_memory_persistence:e.Opt(e.Variant({keep:e.Null,replace:e.Null})),skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),y=e.Record({hash:e.Vec(e.Nat8)}),P=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:h,chunk_hashes_list:e.Vec(y),target_canister:O,store_canister:e.Opt(O),sender_canister_version:e.Opt(e.Nat64)}),E=e.Vec(e.Nat8),I=e.Record({arg:e.Vec(e.Nat8),wasm_module:E,mode:h,canister_id:O,sender_canister_version:e.Opt(e.Nat64)}),D=e.Record({canister_id:O}),T=e.Record({id:q,total_size:e.Nat64,taken_at_timestamp:e.Nat64}),U=e.Vec(T),L=e.Record({canister_id:O,sender_canister_version:e.Opt(e.Nat64),snapshot_id:q}),k=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),J=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_proposed_total:e.Nat64}),te=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec(J)})),de=e.Record({settings:e.Opt(S),specified_id:e.Opt(O),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),ge=e.Record({canister_id:O}),Se=e.Record({canister_id:O,amount:e.Nat}),Fe=e.Vec(e.Nat8),_e=e.Variant({ed25519:e.Null,bip340secp256k1:e.Null}),fe=e.Record({key_id:e.Record({algorithm:_e,name:e.Text}),canister_id:e.Opt(O),derivation_path:e.Vec(e.Vec(e.Nat8))}),He=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),Lt=e.Record({key_id:e.Record({name:e.Text,curve:se}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),Ut=e.Record({signature:e.Vec(e.Nat8)}),Ct=e.Variant({bip341:e.Record({merkle_root_hash:e.Vec(e.Nat8)})}),Ht=e.Record({aux:e.Opt(Ct),key_id:e.Record({algorithm:_e,name:e.Text}),derivation_path:e.Vec(e.Vec(e.Nat8)),message:e.Vec(e.Nat8)}),Be=e.Record({signature:e.Vec(e.Nat8)}),Et=e.Record({canister_id:O}),at=e.Record({canister_id:O}),Ke=e.Record({canister_id:O}),Oc=e.Vec(y),Ec=e.Record({subnet_id:e.Principal}),$e=e.Record({replica_version:e.Text}),vc=e.Record({replace_snapshot:e.Opt(q),canister_id:O}),Rc=T,Ac=e.Record({canister_id:O,sender_canister_version:e.Opt(e.Nat64)}),Sc=e.Record({canister_id:e.Principal,settings:S,sender_canister_version:e.Opt(e.Nat64)}),Bc=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),cn=y;return e.Service({bitcoin_get_balance:e.Func([n],[s],[]),bitcoin_get_block_headers:e.Func([o],[d],[]),bitcoin_get_current_fee_percentiles:e.Func([f],[m],[]),bitcoin_get_utxos:e.Func([b],[F],[]),bitcoin_send_transaction:e.Func([C],[],[]),canister_info:e.Func([H],[M],[]),canister_status:e.Func([ae],[w],[]),clear_chunk_store:e.Func([g],[],[]),create_canister:e.Func([R],[B],[]),delete_canister:e.Func([j],[],[]),delete_canister_snapshot:e.Func([Y],[],[]),deposit_cycles:e.Func([oe],[],[]),ecdsa_public_key:e.Func([W],[V],[]),fetch_canister_logs:e.Func([_],[re],["query"]),http_request:e.Func([u],[X],[]),install_chunked_code:e.Func([P],[],[]),install_code:e.Func([I],[],[]),list_canister_snapshots:e.Func([D],[U],[]),load_canister_snapshot:e.Func([L],[],[]),node_metrics_history:e.Func([k],[te],[]),provisional_create_canister_with_cycles:e.Func([de],[ge],[]),provisional_top_up_canister:e.Func([Se],[],[]),raw_rand:e.Func([],[Fe],[]),schnorr_public_key:e.Func([fe],[He],[]),sign_with_ecdsa:e.Func([Lt],[Ut],[]),sign_with_schnorr:e.Func([Ht],[Be],[]),start_canister:e.Func([Et],[],[]),stop_canister:e.Func([at],[],[]),stored_chunks:e.Func([Ke],[Oc],[]),subnet_info:e.Func([Ec],[$e],[]),take_canister_snapshot:e.Func([vc],[Rc],[]),uninstall_code:e.Func([Ac],[],[]),update_settings:e.Func([Sc],[],[]),upload_chunk:e.Func([Bc],[cn],[])})}});var Yo=ee(ze=>{"use strict";var TT=ze&&ze.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ze,"__esModule",{value:!0});ze.AdvancedActor=ze.getManagementCanister=ze.ACTOR_METHOD_WITH_CERTIFICATE=ze.ACTOR_METHOD_WITH_HTTP_DETAILS=ze.Actor=ze.UpdateCallRejectedError=ze.QueryCallRejectedError=ze.ActorCallError=void 0;var NT=xf(),Ql=Rs(),ed=_i(),qs=Ti(),Xh=zo(),dr=vt(),OT=$t(),Di=Ai(),ET=TT(Zh()),Ms=class extends ed.AgentError{constructor(t,r,n,i){super(["Call failed:",` Canister: ${t.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
56
- `)),this.canisterId=t,this.methodName=r,this.type=n,this.props=i}};ze.ActorCallError=Ms;var Wo=class extends Ms{constructor(t,r,n){var i;super(t,r,"query",{Status:n.status,Code:(i=Ql.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};ze.QueryCallRejectedError=Wo;var ks=class extends Ms{constructor(t,r,n,i,s,a,o){super(t,r,"update",Object.assign({"Request ID":(0,OT.toHex)(n)},i.body?Object.assign(Object.assign({},o?{"Error code":o}:{}),{"Reject code":String(s),"Reject message":a}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=a,this.error_code=o}};ze.UpdateCallRejectedError=ks;var lr=Symbol.for("ic-agent-metadata"),Ds=class e{constructor(t){this[lr]=Object.freeze(t)}static agentOf(t){return t[lr].config.agent}static interfaceOf(t){return t[lr].service}static canisterIdOf(t){return dr.Principal.from(t[lr].config.canisterId)}static async install(t,r){let n=t.mode===void 0?{install:null}:t.mode,i=t.arg?[...new Uint8Array(t.arg)]:[],s=[...new Uint8Array(t.module)],a=typeof r.canisterId=="string"?dr.Principal.fromText(r.canisterId):r.canisterId;await td(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:a,sender_canister_version:[]})}static async createCanister(t,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await td(t||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(t,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(t,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(t,r){let n=t({IDL:qs.IDL});class i extends e{constructor(a){if(!a.canisterId)throw new ed.AgentError(`Canister ID is required, but received ${typeof a.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 o=typeof a.canisterId=="string"?dr.Principal.fromText(a.canisterId):a.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Qh),a),{canisterId:o}),service:n});for(let[c,d]of n._fields)r?.httpDetails&&d.annotations.push(ze.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&d.annotations.push(ze.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=vT(this,c,d,a.blsVerify)}}return i}static createActor(t,r){if(!r.canisterId)throw new ed.AgentError(`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(t))(r)}static createActorWithHttpDetails(t,r){return new(this.createActorClass(t,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(t,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(t,n))(r)}};ze.Actor=Ds;function ji(e,t){let r=qs.IDL.decode(e,NT.Buffer.from(t));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Qh={pollingStrategyFactory:Xh.strategy.defaultStrategy};ze.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";ze.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function vT(e,t,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(a,...o)=>{var c,d;a=Object.assign(Object.assign({},a),(d=(c=e[lr].config).queryTransform)===null||d===void 0?void 0:d.call(c,t,o,Object.assign(Object.assign({},e[lr].config),a)));let f=a.agent||e[lr].config.agent||(0,Ql.getDefaultAgent)(),p=dr.Principal.from(a.canisterId||e[lr].config.canisterId),m=qs.IDL.encode(r.argTypes,o),b=await f.query(p,{methodName:t,arg:m,effectiveCanisterId:a.effectiveCanisterId}),l=Object.assign(Object.assign({},b.httpDetails),{requestDetails:b.requestDetails});switch(b.status){case"rejected":throw new Wo(p,t,b);case"replied":return r.annotations.includes(ze.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:l,result:ji(r.retTypes,b.reply.arg)}:ji(r.retTypes,b.reply.arg)}}:i=async(a,...o)=>{var c,d;a=Object.assign(Object.assign({},a),(d=(c=e[lr].config).callTransform)===null||d===void 0?void 0:d.call(c,t,o,Object.assign(Object.assign({},e[lr].config),a)));let f=a.agent||e[lr].config.agent||(0,Ql.getDefaultAgent)(),{canisterId:p,effectiveCanisterId:m,pollingStrategyFactory:b}=Object.assign(Object.assign(Object.assign({},Qh),e[lr].config),a),l=dr.Principal.from(p),A=m!==void 0?dr.Principal.from(m):l,v=qs.IDL.encode(r.argTypes,o),{requestId:F,response:C,requestDetails:O}=await f.call(l,{methodName:t,arg:v,effectiveCanisterId:A}),H,x;if(C.body&&C.body.certificate){if(f.rootKey==null)throw new Error("Agent is missing root key");let M=C.body.certificate;x=await Di.Certificate.create({certificate:(0,qs.bufFromBufLike)(M),rootKey:f.rootKey,canisterId:dr.Principal.from(p),blsVerify:n});let ae=[new TextEncoder().encode("request_status"),F];switch(new TextDecoder().decode((0,Di.lookupResultToBuffer)(x.lookup([...ae,"status"])))){case"replied":H=(0,Di.lookupResultToBuffer)(x.lookup([...ae,"reply"]));break;case"rejected":{let ne=new Uint8Array((0,Di.lookupResultToBuffer)(x.lookup([...ae,"reject_code"])))[0],w=new TextDecoder().decode((0,Di.lookupResultToBuffer)(x.lookup([...ae,"reject_message"]))),g=(0,Di.lookupResultToBuffer)(x.lookup([...ae,"error_code"])),S=g?new TextDecoder().decode(g):void 0;throw new ks(l,t,F,C,ne,w,S)}}}else if(C.body&&"reject_message"in C.body){let{reject_code:M,reject_message:ae,error_code:Q}=C.body;throw new ks(l,t,F,C,M,ae,Q)}if(C.status===202){let M=b(),ae=await(0,Xh.pollForResponse)(f,A,F,M,n);x=ae.certificate,H=ae.reply}let q=r.annotations.includes(ze.ACTOR_METHOD_WITH_HTTP_DETAILS),K=r.annotations.includes(ze.ACTOR_METHOD_WITH_CERTIFICATE),$=Object.assign(Object.assign({},C),{requestDetails:O});if(H!==void 0)return q&&K?{httpDetails:$,certificate:x,result:ji(r.retTypes,H)}:K?{certificate:x,result:ji(r.retTypes,H)}:q?{httpDetails:$,result:ji(r.retTypes,H)}:ji(r.retTypes,H);if(r.retTypes.length===0)return q?{httpDetails:C,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...a)=>i({},...a);return s.withOptions=a=>(...o)=>i(a,...o),s}function td(e){function t(r,n){if(e.effectiveCanisterId)return{effectiveCanisterId:dr.Principal.from(e.effectiveCanisterId)};let i=n[0],s=dr.Principal.fromHex("");return i&&typeof i=="object"&&i.target_canister&&r==="install_chunked_code"&&(s=dr.Principal.from(i.target_canister)),i&&typeof i=="object"&&i.canister_id&&(s=dr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return Ds.createActor(ET.default,Object.assign(Object.assign(Object.assign({},e),{canisterId:dr.Principal.fromHex("")}),{callTransform:t,queryTransform:t}))}ze.getManagementCanister=td;var rd=class extends Ds{constructor(t){super(t)}};ze.AdvancedActor=rd});var e_=ee(nd=>{"use strict";Object.defineProperty(nd,"__esModule",{value:!0});nd.default=({IDL:e})=>e.Service({retrieve:e.Func([e.Text],[e.Vec(e.Nat8)],["query"]),store:e.Func([e.Text,e.Vec(e.Nat8)],[],[])})});var t_=ee(Li=>{"use strict";var RT=Li&&Li.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Li,"__esModule",{value:!0});Li.createAssetCanisterActor=void 0;var AT=Yo(),ST=RT(e_());function BT(e){return AT.Actor.createActor(ST.default,e)}Li.createAssetCanisterActor=BT});var r_=ee($r=>{"use strict";var IT=$r&&$r.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),PT=$r&&$r.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),FT=$r&&$r.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&IT(t,e,r);return PT(t,e),t};Object.defineProperty($r,"__esModule",{value:!0});$r.fetchCandid=void 0;var VT=vt(),UT=FT(As()),CT=Yl(),qT=Yo();async function MT(e,t){t||(t=await CT.HttpAgent.create());let n=(await UT.request({agent:t,canisterId:VT.Principal.fromText(e),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:a})=>a.Service({__get_candid_interface_tmp_hack:a.Func([],[a.Text],["query"])});return await qT.Actor.createActor(i,{agent:t,canisterId:e}).__get_candid_interface_tmp_hack()}$r.fetchCandid=MT});var Nt=ee(Ie=>{"use strict";var n_=Ie&&Ie.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),kT=Ie&&Ie.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Vt=Ie&&Ie.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&n_(t,e,r)},id=Ie&&Ie.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&n_(t,e,r);return kT(t,e),t};Object.defineProperty(Ie,"__esModule",{value:!0});Ie.Cbor=Ie.CanisterStatus=Ie.polling=void 0;Vt(Yo(),Ie);Vt(Rs(),Ie);Vt(Xa(),Ie);Vt(ms(),Ie);Vt(Lu(),Ie);Vt(t_(),Ie);Vt(Ai(),Ie);Vt(Hl(),Ie);Vt(r_(),Ie);Vt(Gl(),Ie);Vt(Kl(),Ie);Vt(ps(),Ie);Vt(Tl(),Ie);Vt($t(),Ie);Vt(Zu(),Ie);Ie.polling=id(zo());Ie.CanisterStatus=id(As());Ie.Cbor=id(ys());Vt(zo(),Ie)});var nt=ee((RO,T_)=>{"use strict";var ud=Object.defineProperty,DT=Object.getOwnPropertyDescriptor,jT=Object.getOwnPropertyNames,LT=Object.prototype.hasOwnProperty,HT=(e,t)=>{for(var r in t)ud(e,r,{get:t[r],enumerable:!0})},KT=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of jT(t))!LT.call(e,i)&&i!==r&&ud(e,i,{get:()=>t[i],enumerable:!(n=DT(t,i))||n.enumerable});return e},$T=e=>KT(ud({},"__esModule",{value:!0}),e),o_={};HT(o_,{AgentManager:()=>t2,Canister:()=>XT,FromStringToTokenError:()=>c_,ICPToken:()=>YT,InvalidPercentageError:()=>h_,NullishError:()=>__,TokenAmount:()=>JT,TokenAmountV2:()=>ZT,arrayBufferToUint8Array:()=>c2,arrayOfNumberToUint8Array:()=>l2,asNonNullish:()=>n2,asciiStringToByteArray:()=>d2,assertNonNullish:()=>$s,assertPercentageNumber:()=>i2,base64ToUint8Array:()=>m2,bigEndianCrc32:()=>w2,bigIntToUint8Array:()=>a2,candidNumberArrayToBigInt:()=>p2,convertStringToE8s:()=>u_,createAgent:()=>f_,createServices:()=>r2,debounce:()=>A2,decodeBase32:()=>_2,defaultAgent:()=>d_,encodeBase32:()=>h2,fromDefinedNullable:()=>B2,fromNullable:()=>ld,fromNullishNullable:()=>I2,hashObject:()=>T2,hashText:()=>b_,hexStringToUint8Array:()=>f2,isEmptyString:()=>QT,isNullish:()=>Ks,jsonReplacer:()=>g_,jsonReviver:()=>x2,nonNullish:()=>Gr,notEmptyString:()=>l_,nowInBigIntNanoSeconds:()=>v2,numberToUint8Array:()=>o2,principalToSubAccount:()=>P2,queryAndUpdate:()=>e2,secondsToDuration:()=>O2,smallerVersion:()=>F2,toBigIntNanoSeconds:()=>R2,toNullable:()=>S2,uint8ArrayToArrayOfNumber:()=>u2,uint8ArrayToBase64:()=>y2,uint8ArrayToBigInt:()=>s2,uint8ArrayToHexString:()=>y_});T_.exports=$T(o_);var c_=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(c_||{}),GT=BigInt(1e8),zT=8,u_=e=>{let t=e.includes("e")?Number(e).toLocaleString("en",{useGrouping:!1,maximumFractionDigits:20}):e;t=t.trim().replace(/[,']/g,"");let r=t.match(/\d*(\.\d*)?/);if(!r||r[0]!==t)return 1;let[n,i]=t.split("."),s=BigInt(0);if(n)try{s+=BigInt(n)*GT}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},WT=({amount:e,decimals:t})=>{e=e.trim().replace(/[,']/g,"");let r=e.match(/\d*(\.\d*)?/);if(!r||r[0]!==e)return 1;let[n,i]=e.split("."),s=0n,a=10n**BigInt(t);if(n)try{s+=BigInt(n)*a}catch{return 1}if(i){if(i.length>t)return 2;try{s+=BigInt(i.padEnd(t,"0"))}catch{return 1}}return s},YT={symbol:"ICP",name:"Internet Computer",decimals:8},JT=class Ls{constructor(t,r){if(this.e8s=t,this.token=r,r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8")}static fromE8s({amount:t,token:r}){return new Ls(t,r)}static fromString({amount:t,token:r}){if(r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8");let n=u_(t);return typeof n=="bigint"?new Ls(n,r):n}static fromNumber({amount:t,token:r}){let n=Ls.fromString({amount:t.toString(),token:r});if(n instanceof Ls)return n;throw n===0?new Error(`Number ${t} has more than 8 decimals`):new Error(`Invalid number ${t}`)}toE8s(){return this.e8s}},ZT=class Hs{constructor(t,r){this.ulps=t,this.token=r}static fromUlps({amount:t,token:r}){return new Hs(t,r)}static fromString({amount:t,token:r}){let n=WT({amount:t,decimals:r.decimals});return typeof n=="bigint"?new Hs(n,r):n}static fromNumber({amount:t,token:r}){let n=Hs.fromString({amount:t.toFixed(Math.min(zT,r.decimals)),token:r});if(n instanceof Hs)return n;throw n===2?new Error(`Number ${t} has more than ${r.decimals} decimals`):new Error(`Invalid number ${t}`)}toUlps(){return this.ulps}toE8s(){return this.token.decimals<8?this.ulps*10n**BigInt(8-this.token.decimals):this.token.decimals===8?this.ulps:this.ulps/10n**BigInt(this.token.decimals-8)}},XT=class{constructor(e,t,r){this.id=e,this.service=t,this.certifiedService=r,this.caller=({certified:n=!0})=>n?this.certifiedService:this.service}get canisterId(){return this.id}},Ks=e=>e==null,Gr=e=>!Ks(e),l_=e=>Gr(e)&&e!=="",QT=e=>!l_(e),e2=async({request:e,onLoad:t,onQueryError:r,onUpdateError:n,strategy:i="query_and_update",identity:s,resolution:a="race"})=>{let o=!1,c=f=>e({certified:f,identity:s}).then(p=>{o||t({certified:f,response:p})}).catch(p=>{f||r==null||r({error:p,identity:s}),!o&&(Ks(n)||(console.error(p),f&&n({error:p,identity:s})))}).finally(()=>o=o||f),d=i==="query"?[c(!1)]:i==="update"?[c(!0)]:[c(!1),c(!0)];await(a==="all_settled"?Promise.allSettled(d):Promise.race(d))},i_=Nt(),sd=Nt(),d_=()=>sd.HttpAgent.createSync({host:"https://icp-api.io",identity:new sd.AnonymousIdentity}),f_=async({identity:e,host:t,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await sd.HttpAgent.create({identity:e,...Gr(t)&&{host:t},verifyQuerySignatures:n,...Gr(i)&&{retryTimes:i},shouldFetchRootKey:r}),t2=class p_{constructor(t){this.config=t,this.agents=void 0,this.getAgent=async({identity:r})=>{let n=r.getPrincipal().toText();if(Ks(this.agents)||Ks(this.agents[n])){let i=await f_({identity:r,fetchRootKey:this.config.fetchRootKey,host:this.config.host,verifyQuerySignatures:!0});return this.agents={...this.agents??{},[n]:i},i}return this.agents[n]},this.clearAgents=()=>{this.agents=null}}static create(t){return new p_(t)}},r2=({options:{canisterId:e,serviceOverride:t,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:a,certifiedIdlFactory:o})=>{let c=n??d_(),d=t??i_.Actor.createActor(a,{agent:c,canisterId:e,callTransform:i,queryTransform:s}),f=r??i_.Actor.createActor(o,{agent:c,canisterId:e,callTransform:i,queryTransform:s});return{service:d,certifiedService:f,agent:c,canisterId:e}},h_=class extends Error{},__=class extends Error{},$s=(e,t)=>{if(e==null)throw new __(t)},n2=(e,t)=>($s(e,t),e),i2=e=>{if(e<0||e>100)throw new h_(`${e} is not a valid percentage number.`)},s2=e=>{let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(typeof t.getBigUint64=="function")return t.getBigUint64(0);{let r=BigInt(t.getUint32(0)),n=BigInt(t.getUint32(4));return(r<<BigInt(32))+n}},a2=e=>{let t=new ArrayBuffer(8),r=new DataView(t);if(typeof r.setBigUint64=="function")r.setBigUint64(0,e);else{let n=Number(e>>BigInt(32)),i=Number(e&BigInt(4294967295));r.setUint32(0,n),r.setUint32(4,i)}return new Uint8Array(t)},o2=e=>{let t=new DataView(new ArrayBuffer(8));for(let r=7;r>=0;--r)t.setUint8(r,e%256),e=e>>8;return new Uint8Array(t.buffer)},c2=e=>new Uint8Array(e),u2=e=>Array.from(e),l2=e=>new Uint8Array(e),d2=e=>Array.from(e).map(t=>t.charCodeAt(0)),f2=e=>{let t=e.match(/.{1,2}/g);return $s(t,"Invalid hex string."),Uint8Array.from(t.map(r=>parseInt(r,16)))},y_=e=>(e instanceof Uint8Array||(e=Uint8Array.from(e)),e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")),p2=e=>{let t=0n;for(let r=e.length-1;r>=0;r--)t=(t<<32n)+BigInt(e[r]);return t},Jo="abcdefghijklmnopqrstuvwxyz234567",Hi=Object.create(null);for(let e=0;e<Jo.length;e++)Hi[Jo[e]]=e;Hi[0]=Hi.o;Hi[1]=Hi.i;var h2=e=>{let t=0,r=0,n="";function i(s){return t<0?r|=s>>-t:r=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=Jo[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?Jo[r>>3]:"")};function _2(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0;function s(a){let o=Hi[a.toLowerCase()];$s(o,`Invalid character: ${JSON.stringify(a)}`),o<<=3,r|=o>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=o<<5-t&255:r=0)}for(let a of e)s(a);return n.slice(0,i)}var y2=e=>btoa(String.fromCharCode(...new Uint8Array(e))),m2=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)),g2=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]),b2=e=>{let t=-1;for(let r=0;r<e.length;r++){let n=(e[r]^t)&255;t=g2[n]^t>>>8}return(t^-1)>>>0},w2=e=>{let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,b2(e),!1),new Uint8Array(t)},m_=vt(),ad="__bigint__",od="__principal__",cd="__uint8array__",g_=(e,t)=>typeof t=="bigint"?{[ad]:`${t}`}:Gr(t)&&t instanceof m_.Principal?{[od]:t.toText()}:Gr(t)&&t instanceof Uint8Array?{[cd]:Array.from(t)}:t,x2=(e,t)=>{let r=n=>t[n];return Gr(t)&&typeof t=="object"&&ad in t?BigInt(r(ad)):Gr(t)&&typeof t=="object"&&od in t?m_.Principal.fromText(r(od)):Gr(t)&&typeof t=="object"&&cd in t?Uint8Array.from(r(cd)):t},T2=async e=>{let t=JSON.stringify(e,g_);return await b_(t)},b_=async e=>{let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return y_(new Uint8Array(r))},N2={year:"year",year_plural:"years",month:"month",month_plural:"months",day:"day",day_plural:"days",hour:"hour",hour_plural:"hours",minute:"minute",minute_plural:"minutes",second:"second",second_plural:"seconds"},O2=({seconds:e,i18n:t=N2})=>{let r=e/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=E2(i);return i-=w_(s),[js("year",s),js("day",i),js("hour",n),js("minute",r),...e>BigInt(0)&&e<BigInt(60)?[js("second",e)]:[]].filter(({amount:a})=>a>0).slice(0,2).map(a=>`${a.amount} ${a.amount===1?t[a.labelKey]:t[`${a.labelKey}_plural`]}`).join(", ")},E2=e=>{let t=e/BigInt(365);for(;w_(t)>e;)t--;return t},w_=e=>{let t=e/BigInt(4);return e*BigInt(365)+t},js=(e,t)=>({labelKey:e,amount:Number(t)}),x_=1000000n,v2=()=>BigInt(Date.now())*x_,R2=e=>BigInt(e.getTime())*x_,A2=(e,t)=>{let r;return(...n)=>{let i=()=>e(...n);r&&clearTimeout(r),r=setTimeout(i,t!==void 0&&t>0?t:300)}},S2=e=>Gr(e)?[e]:[],ld=e=>e?.[0],B2=e=>{let t=ld(e);return $s(t),t},I2=e=>ld(e??[]),P2=e=>{let t=e.toUint8Array(),r=new Uint8Array(32);return r[0]=t.length,r.set(t,1),r},s_=(e,t)=>t>e.length?[...e,...[...Array(t-e.length).keys()].map(()=>0)]:e,a_=e=>{if(!Number.isNaN(Number(e)))return Number(e);let t=e.split("").reduce((r,n)=>Number.isNaN(Number(n))?r:r+n,"");return Number(t)},F2=({minVersion:e,currentVersion:t})=>{let r=s_(e.split(".").map(a_),3).join(".");return s_(t.split(".").map(a_),3).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var O_=ee(Wr=>{"use strict";var Qo=Wr&&Wr.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},Pn=Wr&&Wr.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},Zo,Xo,$i,Gi;Object.defineProperty(Wr,"__esModule",{value:!0});Wr.Ed25519KeyIdentity=Wr.Ed25519PublicKey=void 0;var V2=Nt(),rr=Nt(),Gs=jl();function N_(e){return e!==null&&typeof e=="object"}var ni=class e{constructor(t){if(Zo.set(this,void 0),Xo.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Qo(this,Zo,t,"f"),Qo(this,Xo,e.derEncode(t),"f")}static from(t){if(typeof t=="string"){let r=(0,rr.fromHex)(t);return this.fromRaw(r)}else if(N_(t)){let r=t;if(N_(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,rr.bufFromBufLike)(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(t){return new e(t)}static fromDer(t){return new e(this.derDecode(t))}static derEncode(t){let r=(0,rr.wrapDER)(t,rr.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(t){let r=(0,rr.unwrapDER)(t,rr.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Pn(this,Zo,"f")}get derKey(){return Pn(this,Xo,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Wr.Ed25519PublicKey=ni;Zo=new WeakMap,Xo=new WeakMap;ni.RAW_KEY_LENGTH=32;var fd=class e extends rr.SignIdentity{constructor(t,r){super(),$i.set(this,void 0),Gi.set(this,void 0),Qo(this,$i,ni.from(t),"f"),Qo(this,Gi,new Uint8Array(r),"f")}static generate(t){if(t&&t.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");t||(t=Gs.ed25519.utils.randomPrivateKey()),(0,V2.bufEquals)(t,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(t)[i];let n=Gs.ed25519.getPublicKey(r);return e.fromKeyPair(n,r)}static fromParsedJson(t){let[r,n]=t;return new e(ni.fromDer((0,rr.fromHex)(r)),(0,rr.fromHex)(n))}static fromJSON(t){let r=JSON.parse(t);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(t)}`)}static fromKeyPair(t,r){return new e(ni.fromRaw(t),r)}static fromSecretKey(t){let r=Gs.ed25519.getPublicKey(new Uint8Array(t));return e.fromKeyPair(r,t)}toJSON(){return[(0,rr.toHex)(Pn(this,$i,"f").toDer()),(0,rr.toHex)(Pn(this,Gi,"f"))]}getKeyPair(){return{secretKey:Pn(this,Gi,"f"),publicKey:Pn(this,$i,"f")}}getPublicKey(){return Pn(this,$i,"f")}async sign(t){let r=new Uint8Array(t),n=(0,rr.uint8ToBuf)(Gs.ed25519.sign(r,Pn(this,Gi,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(t,r,n){let[i,s,a]=[t,r,n].map(o=>(typeof o=="string"&&(o=(0,rr.fromHex)(o)),o instanceof Uint8Array&&(o=o.buffer),new Uint8Array(o)));return Gs.ed25519.verify(s,i,a)}};Wr.Ed25519KeyIdentity=fd;$i=new WeakMap,Gi=new WeakMap});var v_=ee(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.ECDSAKeyIdentity=ii.CryptoError=void 0;var U2=Nt(),ec=class e extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,e.prototype)}};ii.CryptoError=ec;function E_(e){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(e)return e;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new ec("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 tc=class e extends U2.SignIdentity{constructor(t,r,n){super(),this._keyPair=t,this._derKey=r,this._subtleCrypto=n}static async generate(t){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=t??{},s=E_(i),a=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),o=await s.exportKey("spki",a.publicKey);return new this(a,o,s)}static async fromKeyPair(t,r){let n=E_(r),i=await n.exportKey("spki",t.publicKey);return new e(t,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let t=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return t},r}async sign(t){let r={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(r,this._keyPair.privateKey,t)}};ii.ECDSAKeyIdentity=tc;ii.default=tc});var hd=ee(Vn=>{"use strict";var C2=Vn&&Vn.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},zs=Vn&&Vn.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},Fn;Object.defineProperty(Vn,"__esModule",{value:!0});Vn.PartialIdentity=void 0;var q2=vt(),pd=class{constructor(t){Fn.set(this,void 0),C2(this,Fn,t,"f")}get rawKey(){return zs(this,Fn,"f").rawKey}get derKey(){return zs(this,Fn,"f").derKey}toDer(){return zs(this,Fn,"f").toDer()}getPublicKey(){return zs(this,Fn,"f")}getPrincipal(){return q2.Principal.from(zs(this,Fn,"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.")}};Vn.PartialIdentity=pd;Fn=new WeakMap});var R_=ee(Je=>{"use strict";var M2=Je&&Je.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),k2=Je&&Je.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),D2=Je&&Je.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&M2(t,e,r);return k2(t,e),t},j2=Je&&Je.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},L2=Je&&Je.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},H2=Je&&Je.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},rc;Object.defineProperty(Je,"__esModule",{value:!0});Je.isDelegationValid=Je.PartialDelegationIdentity=Je.DelegationIdentity=Je.DelegationChain=Je.Delegation=void 0;var Un=Nt(),yd=vt(),Ws=D2(_s()),K2=hd(),$2=new TextEncoder().encode("ic-request-auth-delegation"),G2=new TextEncoder().encode(`
57
- ic-request`);function _d(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return(0,Un.fromHex)(e)}var Ys=class{constructor(t,r,n){this.pubkey=t,this.expiration=r,this.targets=n}toCBOR(){return Ws.value.map(Object.assign({pubkey:Ws.value.bytes(this.pubkey),expiration:Ws.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Ws.value.array(this.targets.map(t=>Ws.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Un.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};Je.Delegation=Ys;async function z2(e,t,r,n){let i=new Ys(t.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...$2,...new Uint8Array((0,Un.requestIdOf)(Object.assign({},i)))]),a=await e.sign(s);return{delegation:i,signature:a}}var md=class e{constructor(t,r){this.delegations=t,this.publicKey=r}static async create(t,r,n=new Date(Date.now()+900*1e3),i={}){var s,a;let o=await z2(t,r,n,i.targets);return new e([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],o],((a=i.previous)===null||a===void 0?void 0:a.publicKey)||t.getPublicKey().toDer())}static fromJSON(t){let{publicKey:r,delegations:n}=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:a,signature:o}=s,{pubkey:c,expiration:d,targets:f}=a;if(f!==void 0&&!Array.isArray(f))throw new Error("Invalid targets.");return{delegation:new Ys(_d(c),BigInt("0x"+d),f&&f.map(p=>{if(typeof p!="string")throw new Error("Invalid target.");return yd.Principal.fromHex(p)})),signature:_d(o)}});return new this(i,_d(r))}static fromDelegations(t,r){return new this(t,r)}toJSON(){return{delegations:this.delegations.map(t=>{let{delegation:r,signature:n}=t,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:(0,Un.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Un.toHex)(n)}}),publicKey:(0,Un.toHex)(this.publicKey)}}};Je.DelegationChain=md;var gd=class extends Un.SignIdentity{constructor(t,r){super(),this._inner=t,this._delegation=r}static fromDelegation(t,r){return new this(t,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(t){return this._inner.sign(t)}async transformRequest(t){let{body:r}=t,n=H2(t,["body"]),i=await(0,Un.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...G2,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};Je.DelegationIdentity=gd;var bd=class e extends K2.PartialIdentity{constructor(t,r){super(t),rc.set(this,void 0),j2(this,rc,r,"f")}get delegation(){return L2(this,rc,"f")}static fromDelegation(t,r){return new e(t,r)}};Je.PartialDelegationIdentity=bd;rc=new WeakMap;function W2(e,t){for(let{delegation:i}of e.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=t?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?yd.Principal.fromText(i):i)):r.push(typeof n=="string"?yd.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:a}of e.delegations){if(a.targets===void 0)continue;let o=!0;for(let c of a.targets)if(c.toText()===s){o=!1;break}if(o)return!1}}return!0}Je.isDelegationValid=W2});var A_=ee(Cn=>{"use strict";var Y2=Cn&&Cn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Cn,"__esModule",{value:!0});Cn.WebAuthnIdentity=Cn.CosePublicKey=void 0;var si=Nt(),wd=Y2(La()),J2=Dn(),Z2=Ti();function X2(e){return(0,si.wrapDER)(e,si.DER_COSE_OID).buffer}function Q2(e){let t=new DataView(new ArrayBuffer(2)),r=e.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>t.setUint8(s,i));let n=t.getUint16(0);return e.slice(55+n)}var nc=class{constructor(t){this._cose=t,this._encodedKey=X2(t)}toDer(){return this._encodedKey}getCose(){return this._cose}};Cn.CosePublicKey=nc;function e6(e="<ic0.app>"){return typeof e=="string"?Uint8Array.from(e,t=>t.charCodeAt(0)):e}async function t6(e){let t=await navigator.credentials.create(e??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:e6(),pubKeyCredParams:[{type:"public-key",alg:xd.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,J2.randomBytes)(16),name:"Internet Identity",displayName:"Internet Identity"}}});return t===null?null:{id:t.id,response:t.response,type:t.type,authenticatorAttachment:t.authenticatorAttachment,getClientExtensionResults:t.getClientExtensionResults,rawId:(0,Z2.bufFromBufLike)(t.rawId)}}var xd;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(xd||(xd={}));var Td=class extends si.SignIdentity{constructor(t,r,n){super(),this.rawId=t,this.authenticatorAttachment=n,this._publicKey=new nc(r)}static fromJSON(t){let{publicKey:r,rawId:n}=JSON.parse(t);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,si.fromHex)(n),(0,si.fromHex)(r),void 0)}static async create(t){var r;let n=await t6(t);if(!n||n.type!=="public-key")throw new Error("Could not create credentials.");let i=n.response;if(i.attestationObject===void 0)throw new Error("Was expecting an attestation response.");let s=wd.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,Q2(s.authData),(r=n.authenticatorAttachment)!==null&&r!==void 0?r:void 0)}getPublicKey(){return this._publicKey}getAuthenticatorAttachment(){return this.authenticatorAttachment}async sign(t){let r=await navigator.credentials.get({publicKey:{allowCredentials:[{type:"public-key",id:this.rawId}],challenge:t,userVerification:"preferred"}});r.authenticatorAttachment!==null&&(this.authenticatorAttachment=r.authenticatorAttachment);let n=r.response,i=wd.default.encode(new wd.default.Tagged(55799,{authenticator_data:new Uint8Array(n.authenticatorData),client_data_json:new TextDecoder().decode(n.clientDataJSON),signature:new Uint8Array(n.signature)}));if(!i)throw new Error("failed to encode cbor");return i.buffer}toJSON(){return{publicKey:(0,si.toHex)(this._publicKey.getCose()),rawId:(0,si.toHex)(this.rawId)}}};Cn.WebAuthnIdentity=Td});var B_=ee(We=>{"use strict";var r6=We&&We.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Od=We&&We.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&r6(t,e,r)};Object.defineProperty(We,"__esModule",{value:!0});We.Secp256k1KeyIdentity=We.ED25519_OID=We.DER_COSE_OID=We.unwrapDER=We.wrapDER=We.WebAuthnIdentity=We.Ed25519PublicKey=We.Ed25519KeyIdentity=void 0;var S_=O_();Object.defineProperty(We,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return S_.Ed25519KeyIdentity}});Object.defineProperty(We,"Ed25519PublicKey",{enumerable:!0,get:function(){return S_.Ed25519PublicKey}});Od(v_(),We);Od(R_(),We);Od(hd(),We);var n6=A_();Object.defineProperty(We,"WebAuthnIdentity",{enumerable:!0,get:function(){return n6.WebAuthnIdentity}});var ic=Nt();Object.defineProperty(We,"wrapDER",{enumerable:!0,get:function(){return ic.wrapDER}});Object.defineProperty(We,"unwrapDER",{enumerable:!0,get:function(){return ic.unwrapDER}});Object.defineProperty(We,"DER_COSE_OID",{enumerable:!0,get:function(){return ic.DER_COSE_OID}});Object.defineProperty(We,"ED25519_OID",{enumerable:!0,get:function(){return ic.ED25519_OID}});var Nd=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};We.Secp256k1KeyIdentity=Nd});var vd=ee(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.IdleManager=void 0;var I_=["mousedown","mousemove","keydown","touchstart","wheel"],Ed=class{constructor(t={}){var r;this.callbacks=[],this.idleTimeout=600*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=600*1e3}=t||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),I_.forEach(function(o){document.addEventListener(o,s,!0)});let a=(o,c)=>{let d;return(...f)=>{let p=this,m=function(){d=void 0,o.apply(p,f)};clearTimeout(d),d=window.setTimeout(m,c)}};if(t?.captureScroll){let o=a(s,(r=t?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",o,!0)}s()}static create(t={}){return new this(t)}registerCallback(t){this.callbacks.push(t)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let t=this._resetTimer.bind(this);I_.forEach(function(r){document.removeEventListener(r,t,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let t=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(t,this.idleTimeout)}};sc.IdleManager=Ed});function s6(){return P_||(P_=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function a6(){return F_||(F_=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function o6(e){let t=new Promise((r,n)=>{let i=()=>{e.removeEventListener("success",s),e.removeEventListener("error",a)},s=()=>{r(fr(e.result)),i()},a=()=>{n(e.error),i()};e.addEventListener("success",s),e.addEventListener("error",a)});return t.then(r=>{r instanceof IDBCursor&&V_.set(r,e)}).catch(()=>{}),Bd.set(t,e),t}function c6(e){if(Ad.has(e))return;let t=new Promise((r,n)=>{let i=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",a),e.removeEventListener("abort",a)},s=()=>{r(),i()},a=()=>{n(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",s),e.addEventListener("error",a),e.addEventListener("abort",a)});Ad.set(e,t)}function C_(e){Sd=e(Sd)}function u6(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...r){let n=e.call(Js(this),t,...r);return U_.set(n,t.sort?t.sort():[t]),fr(n)}:a6().includes(e)?function(...t){return e.apply(Js(this),t),fr(V_.get(this))}:function(...t){return fr(e.apply(Js(this),t))}}function l6(e){return typeof e=="function"?u6(e):(e instanceof IDBTransaction&&c6(e),i6(e,s6())?new Proxy(e,Sd):e)}function fr(e){if(e instanceof IDBRequest)return o6(e);if(Rd.has(e))return Rd.get(e);let t=l6(e);return t!==e&&(Rd.set(e,t),Bd.set(t,e)),t}var i6,P_,F_,V_,Ad,U_,Rd,Bd,Sd,Js,Id=Qd(()=>{i6=(e,t)=>t.some(r=>e instanceof r);V_=new WeakMap,Ad=new WeakMap,U_=new WeakMap,Rd=new WeakMap,Bd=new WeakMap;Sd={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return Ad.get(e);if(t==="objectStoreNames")return e.objectStoreNames||U_.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return fr(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};Js=e=>Bd.get(e)});var M_={};lm(M_,{deleteDB:()=>f6,openDB:()=>d6,unwrap:()=>Js,wrap:()=>fr});function d6(e,t,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let a=indexedDB.open(e,t),o=fr(a);return n&&a.addEventListener("upgradeneeded",c=>{n(fr(a.result),c.oldVersion,c.newVersion,fr(a.transaction),c)}),r&&a.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),o.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",d=>i(d.oldVersion,d.newVersion,d))}).catch(()=>{}),o}function f6(e,{blocked:t}={}){let r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),fr(r).then(()=>{})}function q_(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(Pd.get(t))return Pd.get(t);let r=t.replace(/FromIndex$/,""),n=t!==r,i=h6.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||p6.includes(r)))return;let s=async function(a,...o){let c=this.transaction(a,i?"readwrite":"readonly"),d=c.store;return n&&(d=d.index(o.shift())),(await Promise.all([d[r](...o),i&&c.done]))[0]};return Pd.set(t,s),s}var p6,h6,Pd,k_=Qd(()=>{Id();Id();p6=["get","getKey","getAll","getAllKeys","count"],h6=["put","add","delete","clear"],Pd=new Map;C_(e=>({...e,get:(t,r,n)=>q_(t,r)||e.get(t,r,n),has:(t,r)=>!!q_(t,r)||e.has(t,r)}))});var Vd=ee(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});ac.IdbKeyVal=void 0;var _6=(k_(),dm(M_)),Zs=oc(),D_="auth-client-db",j_="ic-keyval",y6=async(e=D_,t=j_,r)=>(Zs.isBrowser&&(localStorage!=null&&localStorage.getItem(Zs.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Zs.KEY_STORAGE_DELEGATION),localStorage.removeItem(Zs.KEY_STORAGE_KEY)),await(0,_6.openDB)(e,r,{upgrade:n=>{n.objectStoreNames.contains(t)&&n.clear(t),n.createObjectStore(t)}}));async function m6(e,t,r){return await e.get(t,r)}async function g6(e,t,r,n){return await e.put(t,n,r)}async function b6(e,t,r){return await e.delete(t,r)}var Fd=class e{constructor(t,r){this._db=t,this._storeName=r}static async create(t){let{dbName:r=D_,storeName:n=j_,version:i=Zs.DB_VERSION}=t??{},s=await y6(r,n,i);return new e(s,n)}async set(t,r){return await g6(this._db,this._storeName,t,r)}async get(t){var r;return(r=await m6(this._db,this._storeName,t))!==null&&r!==void 0?r:null}async remove(t){return await b6(this._db,this._storeName,t)}};ac.IdbKeyVal=Fd});var oc=ee(it=>{"use strict";var w6=it&&it.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},x6=it&&it.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},cc;Object.defineProperty(it,"__esModule",{value:!0});it.IdbStorage=it.LocalStorage=it.isBrowser=it.DB_VERSION=it.KEY_VECTOR=it.KEY_STORAGE_DELEGATION=it.KEY_STORAGE_KEY=void 0;var T6=Vd();it.KEY_STORAGE_KEY="identity";it.KEY_STORAGE_DELEGATION="delegation";it.KEY_VECTOR="iv";it.DB_VERSION=1;it.isBrowser=typeof window<"u";var Ud=class{constructor(t="ic-",r){this.prefix=t,this._localStorage=r}get(t){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+t))}set(t,r){return this._getLocalStorage().setItem(this.prefix+t,r),Promise.resolve()}remove(t){return this._getLocalStorage().removeItem(this.prefix+t),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!t)throw new Error("Could not find local storage.");return t}};it.LocalStorage=Ud;var Cd=class{constructor(t){cc.set(this,void 0),w6(this,cc,t??{},"f")}get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}T6.IdbKeyVal.create(x6(this,cc,"f")).then(r=>{this.initializedDb=r,t(r)})})}async get(t){return await(await this._db).get(t)}async set(t,r){await(await this._db).set(t,r)}async remove(t){await(await this._db).remove(t)}};it.IdbStorage=Cd;cc=new WeakMap});var jd=ee(Qe=>{"use strict";var N6=Qe&&Qe.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),O6=Qe&&Qe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&N6(t,e,r)};Object.defineProperty(Qe,"__esModule",{value:!0});Qe.AuthClient=Qe.ERROR_USER_INTERRUPT=Qe.IdbKeyVal=Qe.KEY_STORAGE_KEY=Qe.KEY_STORAGE_DELEGATION=Qe.LocalStorage=Qe.IdbStorage=void 0;var L_=Nt(),nr=B_(),H_=vd(),Ot=oc(),uc=oc();Object.defineProperty(Qe,"IdbStorage",{enumerable:!0,get:function(){return uc.IdbStorage}});Object.defineProperty(Qe,"LocalStorage",{enumerable:!0,get:function(){return uc.LocalStorage}});Object.defineProperty(Qe,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return uc.KEY_STORAGE_DELEGATION}});Object.defineProperty(Qe,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return uc.KEY_STORAGE_KEY}});var E6=Vd();Object.defineProperty(Qe,"IdbKeyVal",{enumerable:!0,get:function(){return E6.IdbKeyVal}});var v6="https://identity.ic0.app",R6="#authorize",qd="ECDSA",Md="Ed25519",A6=500;Qe.ERROR_USER_INTERRUPT="UserInterrupt";O6(vd(),Qe);var Dd=class{constructor(t,r,n,i,s,a,o,c){this._identity=t,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=a,this._idpWindow=o,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(t={}){var r,n,i;let s=(r=t.storage)!==null&&r!==void 0?r:new Ot.IdbStorage,a=(n=t.keyType)!==null&&n!==void 0?n:qd,o=null;if(t.identity)o=t.identity;else{let p=await s.get(Ot.KEY_STORAGE_KEY);if(!p&&Ot.isBrowser)try{let m=new Ot.LocalStorage,b=await m.get(Ot.KEY_STORAGE_DELEGATION),l=await m.get(Ot.KEY_STORAGE_KEY);b&&l&&a===qd&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Ot.KEY_STORAGE_DELEGATION,b),await s.set(Ot.KEY_STORAGE_KEY,l),p=b,await m.remove(Ot.KEY_STORAGE_DELEGATION),await m.remove(Ot.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(p)try{typeof p=="object"?a===Md&&typeof p=="string"?o=await nr.Ed25519KeyIdentity.fromJSON(p):o=await nr.ECDSAKeyIdentity.fromKeyPair(p):typeof p=="string"&&(o=nr.Ed25519KeyIdentity.fromJSON(p))}catch{}}let c=new L_.AnonymousIdentity,d=null;if(o)try{let p=await s.get(Ot.KEY_STORAGE_DELEGATION);if(typeof p=="object"&&p!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?c=t.identity:p&&(d=nr.DelegationChain.fromJSON(p),(0,nr.isDelegationValid)(d)?"toDer"in o?c=nr.PartialDelegationIdentity.fromDelegation(o,d):c=nr.DelegationIdentity.fromDelegation(o,d):(await kd(s),o=null))}catch(p){console.error(p),await kd(s),o=null}let f;return!((i=t.idleOptions)===null||i===void 0)&&i.disableIdle?f=void 0:(d||t.identity)&&(f=H_.IdleManager.create(t.idleOptions)),o||(a===Md?(o=await nr.Ed25519KeyIdentity.generate(),await s.set(Ot.KEY_STORAGE_KEY,JSON.stringify(o.toJSON()))):(t.storage&&a===qd&&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 '${Md}' as the key type, as it can serialize to a string`),o=await nr.ECDSAKeyIdentity.generate(),await s.set(Ot.KEY_STORAGE_KEY,o.getKeyPair()))),new this(c,o,d,s,f,t)}_registerDefaultIdleCallback(){var t,r;let n=(t=this._createOptions)===null||t===void 0?void 0:t.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(t,r){var n,i;let s=t.delegations.map(d=>({delegation:new nr.Delegation(d.delegation.pubkey,d.delegation.expiration,d.delegation.targets),signature:d.signature.buffer})),a=nr.DelegationChain.fromDelegations(s,t.userPublicKey.buffer),o=this._key;if(!o)return;this._chain=a,"toDer"in o?this._identity=nr.PartialDelegationIdentity.fromDelegation(o,this._chain):this._identity=nr.DelegationIdentity.fromDelegation(o,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=H_.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Ot.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(t)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(t){var r,n,i,s;let a=BigInt(8)*BigInt(36e11),o=new URL(((r=t?.identityProvider)===null||r===void 0?void 0:r.toString())||v6);o.hash=R6,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(o,Object.assign({maxTimeToLive:(i=t?.maxTimeToLive)!==null&&i!==void 0?i:a},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(o.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Qe.ERROR_USER_INTERRUPT,t?.onError):setTimeout(c,A6))};c()}_getEventHandler(t,r){return async n=>{var i,s,a;if(n.origin!==t.origin)return;let o=n.data;switch(o.kind){case"authorize-ready":{let c=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:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(a=this._idpWindow)===null||a===void 0||a.postMessage(c,t.origin);break}case"authorize-client-success":try{await this._handleSuccess(o,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(o.text,r?.onError);break;default:break}}}_handleFailure(t,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(t),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(t={}){if(await kd(this._storage),this._identity=new L_.AnonymousIdentity,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};Qe.AuthClient=Dd;async function kd(e){await e.remove(Ot.KEY_STORAGE_KEY),await e.remove(Ot.KEY_STORAGE_DELEGATION),await e.remove(Ot.KEY_VECTOR)}});var Ky=Ve(nt(),1);var Ay=Ve(nt(),1);var Ki=class{callbacks=[];populate(t){this.callbacks.forEach(({callback:r})=>r(t))}subscribe(t){let r=Symbol();return this.callbacks.push({id:r,callback:t}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var zr=class e extends Ki{static instance;authUser=null;constructor(){super()}static getInstance(){return e.instance||(e.instance=new e),e.instance}set(t){this.authUser=t,this.populate(t)}get(){return this.authUser}subscribe(t){let r=super.subscribe(t);return t(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var dd=({message:e,detail:t})=>{let r=new CustomEvent(e,{detail:t,bubbles:!0});document.dispatchEvent(r)};var Ry=Ve(jd(),1),Jd=Ve(nt(),1);var K_=BigInt(144e11),$_=!1,G_={width:576,height:576},z_={width:505,height:705},W_="internetcomputer.org";var Xs=Ve(nt(),1);var zi="http://127.0.0.1:5987",Y_="rdmx6-jaaaa-aaaaa-aaadq-cai";var Yr=class e extends Ki{static instance;env;constructor(){super()}static getInstance(){return e.instance||(e.instance=new e),e.instance}set(t){this.env=t,this.populate(t)}get(){return this.env}reset(){this.env=null}subscribe(t){let r=super.subscribe(t);return t(this.env),r}};var Ld=Ve(nt(),1);var lc=Ve(nt(),1),J_=async e=>{let t=new Blob([JSON.stringify(e,lc.jsonReplacer)],{type:"application/json; charset=utf-8"});return new Uint8Array(await t.arrayBuffer())},dc=async e=>{let t=new Blob([e instanceof Uint8Array?e:new Uint8Array(e)],{type:"application/json; charset=utf-8"});return JSON.parse(await t.text(),lc.jsonReviver)},fc=()=>typeof window<"u";var Hd=({width:e,height:t})=>{if(!fc()||(0,Ld.isNullish)(window)||(0,Ld.isNullish)(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-t/2,s=r/2+screenX-e/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${e}, height=${t}, top=${i}, left=${s}`};var pc=class{#e;constructor({domain:t}){this.#e=t}get id(){return"internet_identity"}signInOptions({windowed:t}){let r=()=>{let n=Yr.getInstance().get()?.container;if((0,Xs.isNullish)(n)||n===!1)return`https://identity.${this.#e??W_}`;let i=Yr.getInstance().get(),s=(0,Xs.nonNullish)(i)&&(0,Xs.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:Y_,{host:a,protocol:o}=new URL(n===!0?zi:n);return/apple/i.test(navigator?.vendor)?`${o}//${a}?canisterId=${s}`:`${o}//${s}.${a.replace("127.0.0.1","localhost")}`};return{...t!==!1&&{windowOpenerFeatures:Hd(G_)},identityProvider:r()}}},Z_=class{#e;#t;constructor({appName:t,logoUrl:r}){this.#e=t,this.#t=r}get id(){return"nfid"}signInOptions({windowed:t}){return{...t!==!1&&{windowOpenerFeatures:Hd(z_)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var ey=Ve(Nt(),1),_c=Ve(nt(),1);var hc=Ve(nt(),1);var X_=Ve(Nt(),1),Kd=Ve(nt(),1);var Q_=async({identity:e,container:t})=>{let n=(0,Kd.nonNullish)(t)&&t!==!1?t===!0?zi:t:"https://icp-api.io",i=(0,Kd.nonNullish)(t);return await X_.HttpAgent.create({identity:e,shouldFetchRootKey:i,host:n})};var Wi=class e{static instance;#e=void 0;constructor(){}static getInstance(){return(0,hc.isNullish)(e.instance)&&(e.instance=new e),e.instance}async getAgent({identity:t,...r}){let n=t.getPrincipal().toText();if((0,hc.isNullish)(this.#e)||(0,hc.isNullish)(this.#e[n])){let i=await Q_({identity:t,...r});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}};var Yi=class e{static instance;#e=void 0;constructor(){}static getInstance(){return(0,_c.isNullish)(e.instance)&&(e.instance=new e),e.instance}async getActor({satelliteId:t,identity:r,actorKey:n,...i}){let s=`${n}#${r.getPrincipal().toText()}#${t};`;if((0,_c.isNullish)(this.#e)||(0,_c.isNullish)(this.#e[s])){let a=await this.createActor({satelliteId:t,identity:r,...i});return this.#e={...this.#e??{},[s]:a},a}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:t,satelliteId:r,...n}){let i=await Wi.getInstance().getAgent(n);return ey.Actor.createActor(t,{agent:i,canisterId:r})}};var yc=class extends Error{},mc=class extends Error{},gc=class extends Error{},bc=class extends Error{},wc=class extends Error{};var ty=Ve(jd(),1),xc=()=>ty.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var ta=Ve(nt(),1);var $d=({error:e,type:t})=>typeof e=="string"?e.includes(t):e instanceof Error?e.message.includes(t):!1;var ry="juno.datastore.error.user.cannot_update";var vr=Ve(nt(),1);var ny=async({data:e})=>{try{return await dc(e)}catch(t){console.error("The data parsing has failed, mapping to undefined as a fallback.",t);return}};var ai=Ve(nt(),1);var Gd=async e=>{let{data:t,version:r,description:n}=e;return{description:(0,ai.toNullable)(n),data:await J_(t),version:(0,ai.toNullable)(r)}},zd=e=>{let{version:t}=e;return{version:(0,ai.toNullable)(t)}},Qs=async({doc:e,key:t})=>{let{owner:r,version:n,description:i,data:s,...a}=e;return{key:t,description:(0,ai.fromNullable)(i),owner:r.toText(),data:await dc(s),version:(0,ai.fromNullable)(n),...a}};var sy=Ve(vt(),1),st=Ve(nt(),1);var iy=e=>{if((0,st.isNullish)(e))return(0,st.toNullable)();switch(e.matcher){case"equal":return(0,st.toNullable)({Equal:e.timestamp});case"greaterThan":return(0,st.toNullable)({GreaterThan:e.timestamp});case"lessThan":return(0,st.toNullable)({LessThan:e.timestamp});case"between":return(0,st.toNullable)({Between:[e.timestamps.start,e.timestamps.end]});default:throw new wc("Invalid list matcher for timestamp",e)}},qn=({matcher:e,paginate:t,order:r,owner:n})=>({matcher:(0,st.isNullish)(e)?[]:[{key:(0,st.toNullable)(e.key),description:(0,st.toNullable)(e.description),created_at:iy(e.createdAt),updated_at:iy(e.updatedAt)}],paginate:(0,st.toNullable)((0,st.isNullish)(t)?void 0:{start_after:(0,st.toNullable)(t.startAfter),limit:(0,st.toNullable)((0,st.isNullish)(t.limit)?void 0:BigInt(t.limit))}),order:(0,st.toNullable)((0,st.isNullish)(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:(0,st.toNullable)((0,st.isNullish)(n)?void 0:typeof n=="string"?sy.Principal.fromText(n):n)});var ly=Ve(nt(),1);var S6=Ve(Nt(),1),NE=Ve(Nt(),1),EE=Ve(Nt(),1),AE=Ve(vt(),1),I6=Ve(Nt(),1),B6=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(B6||{}),BE=BigInt(1e8);var ay="abcdefghijklmnopqrstuvwxyz234567",ea=Object.create(null);for(let e=0;e<ay.length;e++)ea[ay[e]]=e;ea[0]=ea.o;ea[1]=ea.i;var IE=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 oy=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),n=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),i=e.Record({field:n,desc:e.Bool}),s=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),a=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(s),description:e.Opt(e.Text),created_at:e.Opt(s)}),o=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),c=e.Record({order:e.Opt(i),owner:e.Opt(e.Principal),matcher:e.Opt(a),paginate:e.Opt(o)}),d=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),p=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:f,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),b=e.Variant({Db:e.Null,Storage:e.Null}),l=e.Record({version:e.Opt(e.Nat64)}),A=e.Record({proposal_ids:e.Vec(e.Nat)}),v=e.Record({cycles:e.Nat,destination_id:e.Principal}),F=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),C=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),O=e.Record({key:F,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,C)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),H=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),x=e.Record({allowed_callers:e.Vec(e.Principal)}),q=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),K=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),$=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),M=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),ae=e.Variant({Deny:e.Null,Allow:e.Null}),Q=e.Record({status_code:e.Nat16,location:e.Text}),ne=e.Record({iframe:e.Opt(M),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),w=e.Record({db:e.Opt($),authentication:e.Opt(q),storage:ne}),g=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),S=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),R=e.Record({clear_existing_assets:e.Opt(e.Bool)}),B=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),j=e.Variant({AssetsUpgrade:R,SegmentsDeployment:B}),Y=e.Record({status:S,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:j}),oe=e.Variant({Heap:e.Null,Stable:e.Null}),se=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),W=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),V=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:se,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(W),write:se,max_changes_per_user:e.Opt(e.Nat32)}),_=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),Z=e.Record({memory:oe,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),re=e.Variant({Callback:e.Record({token:Z,callback:e.Func([],[],["query"])})}),le=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(re),status_code:e.Nat16}),X=e.Record({token:e.Opt(Z),body:e.Vec(e.Nat8)}),u=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),h=e.Record({batch_id:e.Nat}),y=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,O)),items_length:e.Nat64}),P=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),E=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,g)),items_length:e.Nat64}),I=e.Record({desc:e.Bool}),D=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),T=e.Record({order:e.Opt(I),paginate:e.Opt(D)}),U=e.Record({proposal_id:e.Nat}),L=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(U,Y)),items_length:e.Nat64}),k=e.Record({include_system:e.Bool}),J=e.Record({matcher:e.Opt(k)}),te=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,V)),items_length:e.Nat64}),de=e.Record({stable:e.Nat64,heap:e.Nat64}),ge=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),Se=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:f,expires_at:e.Opt(e.Nat64)}),Fe=e.Record({controller:Se,controllers:e.Vec(e.Principal)}),_e=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),fe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),He=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),max_size:e.Opt(e.Nat),read:se,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(W),write:se,max_changes_per_user:e.Opt(e.Nat32)}),Lt=e.Record({iframe:e.Opt(M),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),Ut=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Ct=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),commit_proposal:e.Func([r],[e.Null],[]),commit_proposal_asset_upload:e.Func([t],[],[]),commit_proposal_many_assets_upload:e.Func([e.Vec(t)],[],[]),count_assets:e.Func([e.Text,c],[e.Nat64],["query"]),count_collection_assets:e.Func([e.Text],[e.Nat64],["query"]),count_collection_docs:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text,c],[e.Nat64],["query"]),count_proposals:e.Func([],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([d],[e.Vec(e.Tuple(e.Principal,p))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,c],[],[]),del_filtered_docs:e.Func([e.Text,c],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,m))],[],[]),del_rule:e.Func([b,e.Text,l],[],[]),delete_proposal_assets:e.Func([A],[],[]),deposit_cycles:e.Func([v],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(O)],["query"]),get_auth_config:e.Func([],[e.Opt(q)],["query"]),get_config:e.Func([],[w],[]),get_db_config:e.Func([],[e.Opt($)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(g)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(O)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(g)))],["query"]),get_proposal:e.Func([e.Nat],[e.Opt(Y)],["query"]),get_rule:e.Func([b,e.Text],[e.Opt(V)],["query"]),get_storage_config:e.Func([],[ne],["query"]),http_request:e.Func([_],[le],["query"]),http_request_streaming_callback:e.Func([Z],[X],["query"]),init_asset_upload:e.Func([u],[h],[]),init_proposal:e.Func([j],[e.Nat,Y],[]),init_proposal_asset_upload:e.Func([u,e.Nat],[h],[]),init_proposal_many_assets_upload:e.Func([e.Vec(u),e.Nat],[e.Vec(e.Tuple(e.Text,h))],[]),list_assets:e.Func([e.Text,c],[y],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,p))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,P))],["query"]),list_docs:e.Func([e.Text,c],[E],["query"]),list_proposals:e.Func([T],[L],["query"]),list_rules:e.Func([b,J],[te],["query"]),memory_size:e.Func([],[de],["query"]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([ge],[q],[]),set_controllers:e.Func([Fe],[e.Vec(e.Tuple(e.Principal,p))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([_e],[$],[]),set_doc:e.Func([e.Text,e.Text,fe],[g],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,fe))],[e.Vec(e.Tuple(e.Text,g))],[]),set_rule:e.Func([b,e.Text,He],[V],[]),set_storage_config:e.Func([Lt],[ne],[]),submit_proposal:e.Func([e.Nat],[e.Nat,Y],[]),upload_asset_chunk:e.Func([Ut],[Ct],[]),upload_proposal_asset_chunk:e.Func([Ut],[Ct],[])})},cy=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),n=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),i=e.Record({field:n,desc:e.Bool}),s=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),a=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(s),description:e.Opt(e.Text),created_at:e.Opt(s)}),o=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),c=e.Record({order:e.Opt(i),owner:e.Opt(e.Principal),matcher:e.Opt(a),paginate:e.Opt(o)}),d=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),p=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:f,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),b=e.Variant({Db:e.Null,Storage:e.Null}),l=e.Record({version:e.Opt(e.Nat64)}),A=e.Record({proposal_ids:e.Vec(e.Nat)}),v=e.Record({cycles:e.Nat,destination_id:e.Principal}),F=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),C=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),O=e.Record({key:F,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,C)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),H=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),x=e.Record({allowed_callers:e.Vec(e.Principal)}),q=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),K=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),$=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),M=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),ae=e.Variant({Deny:e.Null,Allow:e.Null}),Q=e.Record({status_code:e.Nat16,location:e.Text}),ne=e.Record({iframe:e.Opt(M),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),w=e.Record({db:e.Opt($),authentication:e.Opt(q),storage:ne}),g=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),S=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),R=e.Record({clear_existing_assets:e.Opt(e.Bool)}),B=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),j=e.Variant({AssetsUpgrade:R,SegmentsDeployment:B}),Y=e.Record({status:S,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:j}),oe=e.Variant({Heap:e.Null,Stable:e.Null}),se=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),W=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),V=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:se,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(W),write:se,max_changes_per_user:e.Opt(e.Nat32)}),_=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),Z=e.Record({memory:oe,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),re=e.Variant({Callback:e.Record({token:Z,callback:e.Func([],[],[])})}),le=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(re),status_code:e.Nat16}),X=e.Record({token:e.Opt(Z),body:e.Vec(e.Nat8)}),u=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),h=e.Record({batch_id:e.Nat}),y=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,O)),items_length:e.Nat64}),P=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),E=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,g)),items_length:e.Nat64}),I=e.Record({desc:e.Bool}),D=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),T=e.Record({order:e.Opt(I),paginate:e.Opt(D)}),U=e.Record({proposal_id:e.Nat}),L=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(U,Y)),items_length:e.Nat64}),k=e.Record({include_system:e.Bool}),J=e.Record({matcher:e.Opt(k)}),te=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,V)),items_length:e.Nat64}),de=e.Record({stable:e.Nat64,heap:e.Nat64}),ge=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),Se=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:f,expires_at:e.Opt(e.Nat64)}),Fe=e.Record({controller:Se,controllers:e.Vec(e.Principal)}),_e=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),fe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),He=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),max_size:e.Opt(e.Nat),read:se,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(W),write:se,max_changes_per_user:e.Opt(e.Nat32)}),Lt=e.Record({iframe:e.Opt(M),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),Ut=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Ct=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),commit_proposal:e.Func([r],[e.Null],[]),commit_proposal_asset_upload:e.Func([t],[],[]),commit_proposal_many_assets_upload:e.Func([e.Vec(t)],[],[]),count_assets:e.Func([e.Text,c],[e.Nat64],[]),count_collection_assets:e.Func([e.Text],[e.Nat64],[]),count_collection_docs:e.Func([e.Text],[e.Nat64],[]),count_docs:e.Func([e.Text,c],[e.Nat64],[]),count_proposals:e.Func([],[e.Nat64],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([d],[e.Vec(e.Tuple(e.Principal,p))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,c],[],[]),del_filtered_docs:e.Func([e.Text,c],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,m))],[],[]),del_rule:e.Func([b,e.Text,l],[],[]),delete_proposal_assets:e.Func([A],[],[]),deposit_cycles:e.Func([v],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(O)],[]),get_auth_config:e.Func([],[e.Opt(q)],[]),get_config:e.Func([],[w],[]),get_db_config:e.Func([],[e.Opt($)],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(g)],[]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(O)))],[]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(g)))],[]),get_proposal:e.Func([e.Nat],[e.Opt(Y)],[]),get_rule:e.Func([b,e.Text],[e.Opt(V)],[]),get_storage_config:e.Func([],[ne],[]),http_request:e.Func([_],[le],[]),http_request_streaming_callback:e.Func([Z],[X],[]),init_asset_upload:e.Func([u],[h],[]),init_proposal:e.Func([j],[e.Nat,Y],[]),init_proposal_asset_upload:e.Func([u,e.Nat],[h],[]),init_proposal_many_assets_upload:e.Func([e.Vec(u),e.Nat],[e.Vec(e.Tuple(e.Text,h))],[]),list_assets:e.Func([e.Text,c],[y],[]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,p))],[]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,P))],[]),list_docs:e.Func([e.Text,c],[E],[]),list_proposals:e.Func([T],[L],[]),list_rules:e.Func([b,J],[te],[]),memory_size:e.Func([],[de],[]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([ge],[q],[]),set_controllers:e.Func([Fe],[e.Vec(e.Tuple(e.Principal,p))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([_e],[$],[]),set_doc:e.Func([e.Text,e.Text,fe],[g],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,fe))],[e.Vec(e.Tuple(e.Text,g))],[]),set_rule:e.Func([b,e.Text,He],[V],[]),set_storage_config:e.Func([Lt],[ne],[]),submit_proposal:e.Func([e.Nat],[e.Nat,Y],[]),upload_asset_chunk:e.Func([Ut],[Ct],[]),upload_proposal_asset_chunk:e.Func([Ut],[Ct],[])})};var Tc=Ve(nt(),1);var uy=({satelliteId:e,container:t})=>{let{satelliteId:r}=Wd({satelliteId:e}),{container:n}=Yd({container:t});if((0,Tc.nonNullish)(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?zi:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Wd=({satelliteId:e})=>(0,Tc.nonNullish)(e)?{satelliteId:e}:Yr.getInstance().get()??{satelliteId:void 0},Yd=({container:e})=>(0,Tc.nonNullish)(e)?{container:e}:Yr.getInstance().get()??{container:void 0};var dt=({satellite:e,options:{certified:t}})=>fy({idlFactory:t?cy:oy,actorKey:`stock#${t?"update":"query"}`,...e}),dy=({idlFactory:e,...t})=>fy({idlFactory:e,actorKey:"extended#query",...t}),fy=async({satelliteId:e,container:t,...r})=>{let{satelliteId:n}=Wd({satelliteId:e});(0,ly.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Yd({container:t});return await Yi.getInstance().getActor({satelliteId:n,container:i,...r})};var py=async({collection:e,key:t,...r})=>{let{get_doc:n}=await dt(r),i=(0,vr.fromNullable)(await n(e,t));if(!(0,vr.isNullish)(i))return Qs({doc:i,key:t})},hy=async({docs:e,...t})=>{let{get_many_docs:r}=await dt(t),n=e.map(({collection:a,key:o})=>[a,o]),i=await r(n),s=[];for(let[a,o]of i){let c=(0,vr.fromNullable)(o);s.push((0,vr.nonNullish)(c)?await Qs({key:a,doc:c}):void 0)}return s},_y=async({collection:e,doc:t,...r})=>{let{set_doc:n}=await dt(r),{key:i}=t,s=await Gd(t),a=await n(e,i,s);return await Qs({key:i,doc:a})},yy=async({docs:e,...t})=>{let{set_many_docs:r}=await dt(t),n=[];for(let{collection:a,doc:o}of e){let{key:c}=o;n.push([a,c,await Gd(o)])}let i=await r(n),s=[];for(let[a,o]of i)s.push(await Qs({key:a,doc:o}));return s},my=async({collection:e,doc:t,...r})=>{let{del_doc:n}=await dt(r),{key:i}=t;return n(e,i,zd(t))},gy=async({docs:e,...t})=>{let{del_many_docs:r}=await dt(t),n=e.map(({collection:i,doc:s})=>[i,s.key,zd(s)]);await r(n)},by=async({collection:e,filter:t,...r})=>{let{del_filtered_docs:n}=await dt(r);return n(e,qn(t))},wy=async({collection:e,filter:t,...r})=>{let{list_docs:n}=await dt(r),{items:i,items_page:s,items_length:a,matches_length:o,matches_pages:c}=await n(e,qn(t)),d=[];for(let[f,p]of i){let{data:m,owner:b,description:l,version:A,...v}=p;d.push({key:f,description:(0,vr.fromNullable)(l),owner:b.toText(),data:await ny({data:m}),version:(0,vr.fromNullable)(A),...v})}return{items:d,items_length:a,items_page:(0,vr.fromNullable)(s),matches_length:o,matches_pages:(0,vr.fromNullable)(c)}},xy=async({collection:e,filter:t,...r})=>{let{count_docs:n}=await dt(r);return n(e,qn(t))};var Jr={certified:!1};var Ty=Ve(Nt(),1),Ny=Ve(nt(),1);var et=e=>(0,Ny.nonNullish)(e)?e:Nc()??new Ty.AnonymousIdentity;var Oy=async({satellite:e,options:t,...r})=>{let n=et(e?.identity);return await py({...r,satellite:{...e,identity:n},options:t??Jr})},ZE=async({satellite:e,options:t,...r})=>{let n=et(e?.identity);return await hy({...r,satellite:{...e,identity:n},options:t??Jr})},Ey=async({satellite:e,...t})=>{let r=et(e?.identity);return await _y({...t,satellite:{...e,identity:r},options:{certified:!0}})},XE=async({satellite:e,...t})=>{let r=et(e?.identity);return await yy({...t,satellite:{...e,identity:r},options:{certified:!0}})},QE=async({satellite:e,...t})=>{let r=et(e?.identity);return await my({...t,satellite:{...e,identity:r},options:{certified:!0}})},e4=async({satellite:e,...t})=>{let r=et(e?.identity);return await gy({...t,satellite:{...e,identity:r},options:{certified:!0}})},t4=async({satellite:e,filter:t,...r})=>{let n=et(e?.identity);return await by({...r,filter:t??{},satellite:{...e,identity:n},options:{certified:!0}})},r4=async({satellite:e,options:t,filter:r,...n})=>{let i=et(e?.identity);return await wy({...n,filter:r??{},satellite:{...e,identity:i},options:t??Jr})},n4=async({satellite:e,options:t,filter:r,...n})=>{let i=et(e?.identity);return await xy({...n,filter:r??{},satellite:{...e,identity:i},options:t??Jr})};var vy=async e=>{let t=Nc();if((0,ta.isNullish)(t))throw new bc("No identity to initialize the user. Have you initialized Juno?");let r=t.getPrincipal().toText(),n=()=>Oy({collection:"#user",key:r}),i=await n();if((0,ta.nonNullish)(i))return i;try{return await P6({userId:r,provider:e})}catch(s){if($d({error:s,type:ry})){let a=await n();if((0,ta.nonNullish)(a))return a}throw s}},P6=({userId:e,...t})=>Ey({collection:"#user",doc:{key:e,data:t}});var pr,Zd=async e=>{if(pr=pr??await xc(),!(await pr?.isAuthenticated()??!1))return;let r=await vy(e);zr.getInstance().set(r)},F6=e=>new Promise(async(t,r)=>{if((0,Jd.isNullish)(pr)){r(new mc("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=e?.provider??new pc({});await pr.login({onSuccess:async()=>{await Zd(n.id),t()},onError:i=>{if(i===Ry.ERROR_USER_INTERRUPT){r(new gc(i));return}r(new yc(i))},maxTimeToLive:e?.maxTimeToLive??K_,allowPinAuthentication:e?.allowPin??$_,...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...n.signInOptions({windowed:e?.windowed})})}),Xd=async()=>{await V6(),pr=await xc()},V6=async()=>{await pr?.logout(),pr=null,zr.getInstance().reset(),Yi.getInstance().reset(),Wi.getInstance().reset()},Nc=()=>pr?.getIdentity(),U6=async()=>(pr??await xc()).getIdentity(),C6=async()=>{let e=zr.getInstance().get();return(0,Jd.isNullish)(e)||!(await pr?.isAuthenticated()??!1)?null:pr?.getIdentity()??null};var Sy=e=>{let t=e===!0?"./workers/auth.worker.js":e,r=new Worker(t),n=async()=>{dd({message:"junoSignOutAuthTimer"}),await Xd()};return r.onmessage=async({data:i})=>{let{msg:s,data:a}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":dd({message:"junoDelegationRemainingTime",detail:a?.authRemainingTime});return}},zr.getInstance().subscribe(i=>{if((0,Ay.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var By=()=>{let e=()=>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??e():e()},Iy=()=>{let e=()=>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??e():e()};var v4=async({idlFactory:e,satellite:t})=>{let r=et(t?.identity);return await dy({idlFactory:e,...t,identity:r})};var na=Ve(nt(),1);var ra=Ve(nt(),1);var Ji=Ve(nt(),1);var Py=async({asset:{data:e,headers:t,...r},actor:n,progress:i})=>{let{init_asset_upload:s,upload_asset_chunk:a,commit_asset_upload:o}=n,{batch_id:c}=await s(q6(r));i?.onInitiatedBatch();let{chunkIds:d}=await D6({data:e,uploadFn:a,batchId:c});i?.onUploadedFileChunks(r.fullPath),await k6({commitFn:o,batchId:c,data:e,headers:t,chunkIds:d}),i?.onCommittedBatch()};var q6=({filename:e,collection:t,token:r,fullPath:n,encoding:i,description:s})=>({collection:t,full_path:n,name:e,token:(0,Ji.toNullable)(r),encoding_type:(0,Ji.toNullable)(i),description:(0,Ji.toNullable)(s)}),M6=({batchId:e,chunkIds:t,headers:r,data:n})=>{let i=r.find(([s,a])=>s.toLowerCase()==="content-type")===void 0&&n.type!==void 0&&n.type!==""?[["Content-Type",n.type]]:void 0;return{batch_id:e,chunk_ids:t.map(({chunk_id:s})=>s),headers:[...r,...i??[]]}},k6=async({commitFn:e,...t})=>{let r=M6(t);await e(r)},D6=async({data:e,uploadFn:t,batchId:r})=>{let n=[],i=fc()?new Blob([await e.arrayBuffer()]):e,s=0n;for(let o=0;o<i.size;o+=19e5){let c=i.slice(o,o+19e5);n.push({batchId:r,chunk:c,uploadFn:t,orderId:s}),s++}let a=[];for await(let o of j6({uploadChunks:n}))a=[...a,...o];return{chunkIds:a}};async function*j6({uploadChunks:e,limit:t=12}){for(let r=0;r<e.length;r=r+t){let n=e.slice(r,r+t);yield await Promise.all(n.map(i=>L6(i)))}}var L6=async({batchId:e,chunk:t,uploadFn:r,orderId:n})=>r({batch_id:e,content:new Uint8Array(await t.arrayBuffer()),order_id:(0,Ji.toNullable)(n)});var Fy=async({asset:e,...t})=>{let r=await dt(t);await Py({actor:r,asset:e})},Vy=async({collection:e,filter:t,...r})=>{let{list_assets:n}=await dt(r),{items:i,items_length:s,items_page:a,matches_length:o,matches_pages:c}=await n(e,qn(t));return{items:i.map(([d,f])=>f),items_length:s,items_page:(0,ra.fromNullable)(a),matches_length:o,matches_pages:(0,ra.fromNullable)(c)}},Uy=async({collection:e,filter:t,...r})=>{let{count_assets:n}=await dt(r);return n(e,qn(t))},Cy=async({collection:e,fullPath:t,...r})=>(await dt(r)).del_asset(e,t),qy=async({assets:e,satellite:t})=>{let{del_many_assets:r}=await dt({satellite:t,options:{certified:!0}}),n=e.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},My=async({collection:e,filter:t,...r})=>{let{del_filtered_assets:n}=await dt(r);return n(e,qn(t))},ky=async({collection:e,fullPath:t,...r})=>{let{get_asset:n}=await dt(r);return(0,ra.fromNullable)(await n(e,t))},Dy=async({assets:e,...t})=>{let{get_many_assets:r}=await dt(t),n=e.map(({collection:s,fullPath:a})=>[s,a]);return(await r(n)).map(([s,a])=>(0,ra.fromNullable)(a))};var jy=e=>btoa([...e].map(t=>String.fromCharCode(t)).join(""));var D4=e=>Ly(e),j4=e=>Ly({filename:e.data.name,...e}),Ly=async({filename:e,data:t,collection:r,headers:n=[],fullPath:i,token:s,satellite:a,encoding:o,description:c})=>{let d=et(a?.identity),f=decodeURI(e),p=i??`/${r}/${f}`,m={...a,identity:d};return await Fy({asset:{data:t,filename:f,collection:r,token:s,headers:n,fullPath:p,encoding:o,description:c},satellite:m,options:{certified:!0}}),{downloadUrl:Hy({satellite:m,assetKey:{fullPath:p,token:s}}),fullPath:p,name:f}},L4=async({collection:e,filter:t,satellite:r,options:n})=>{let i={...r,identity:et(r?.identity)},{items:s,...a}=await Vy({collection:e,filter:t??{},satellite:i,options:n??Jr}),o=s.map(({key:{full_path:c,token:d,name:f,owner:p,description:m},headers:b,encodings:l,created_at:A,updated_at:v})=>{let F=(0,na.fromNullable)(d);return{fullPath:c,description:(0,na.fromNullable)(m),name:f,downloadUrl:Hy({satellite:i,assetKey:{fullPath:c,token:F}}),token:F,headers:b,encodings:l.reduce((C,[O,{modified:H,sha256:x,total_length:q}])=>({...C,[O]:{modified:H,sha256:jy(x),total_length:q}}),{}),owner:p.toText(),created_at:A,updated_at:v}});return{items:o,assets:o,...a}},H4=async({collection:e,filter:t,satellite:r,options:n})=>{let i={...r,identity:et(r?.identity)};return await Uy({collection:e,satellite:i,filter:t??{},options:n??Jr})},K4=({collection:e,fullPath:t,satellite:r})=>Cy({collection:e,fullPath:t,satellite:{...r,identity:et(r?.identity)},options:{certified:!0}}),$4=({assets:e,satellite:t})=>qy({assets:e,satellite:{...t,identity:et(t?.identity)},options:{certified:!0}}),G4=async({collection:e,satellite:t,filter:r})=>{let n={...t,identity:et(t?.identity)};return await My({collection:e,satellite:n,filter:r??{},options:{certified:!0}})},z4=async({satellite:e,options:t,...r})=>{let n=et(e?.identity);return await ky({...r,satellite:{...e,identity:n},options:t??Jr})},W4=async({satellite:e,options:t,...r})=>{let n=et(e?.identity);return await Dy({...r,satellite:{...e,identity:n},options:t??Jr})},Hy=({assetKey:{fullPath:e,token:t},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${uy(n)}${e}${(0,na.nonNullish)(t)?`?token=${t}`:""}`};var H6=e=>{let t=e?.satelliteId??By();(0,Ky.assertNonNullish)(t,"Satellite ID is not configured. Juno cannot be initialized.");let r=e?.container??Iy();return{satelliteId:t,internetIdentityId:e?.internetIdentityId,workers:e?.workers,container:r}},t8=e=>K6(e),K6=async e=>{let t=H6(e);Yr.getInstance().set(t),await Zd();let r=t.workers?.auth!==void 0?Sy(t.workers.auth):void 0;return[...r?[r]:[]]},r8=e=>zr.getInstance().subscribe(e);export{bc as InitError,pc as InternetIdentityProvider,wc as ListError,Z_ as NFIDProvider,yc as SignInError,mc as SignInInitError,gc as SignInUserInterruptError,r8 as authSubscribe,H4 as countAssets,n4 as countDocs,K4 as deleteAsset,QE as deleteDoc,G4 as deleteFilteredAssets,t4 as deleteFilteredDocs,$4 as deleteManyAssets,e4 as deleteManyDocs,Hy as downloadUrl,z4 as getAsset,Oy as getDoc,C6 as getIdentityOnce,W4 as getManyAssets,ZE as getManyDocs,v4 as getSatelliteExtendedActor,t8 as initJuno,K6 as initSatellite,L4 as listAssets,r4 as listDocs,Ey as setDoc,XE as setManyDocs,F6 as signIn,Xd as signOut,U6 as unsafeIdentity,D4 as uploadBlob,j4 as uploadFile};
54
+ Request ID: ${(0,Wh.toHex)(r)}
55
+ `)}throw new Error("unreachable")}Jt.pollForResponse=Yh});var Jh=ee(Zl=>{"use strict";Object.defineProperty(Zl,"__esModule",{value:!0});Zl.default=({IDL:e})=>{let t=e.Variant({mainnet:e.Null,testnet:e.Null}),r=e.Text,n=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),i=e.Nat64,s=i,a=e.Nat32,o=e.Record({start_height:a,end_height:e.Opt(a),network:t}),c=e.Vec(e.Nat8),d=e.Record({tip_height:a,block_headers:e.Vec(c)}),f=e.Record({network:t}),p=e.Nat64,m=e.Vec(p),b=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),l=e.Vec(e.Nat8),A=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),v=e.Record({height:e.Nat32,value:i,outpoint:A}),F=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:a,tip_block_hash:l,utxos:e.Vec(v)}),C=e.Record({transaction:e.Vec(e.Nat8),network:t}),O=e.Principal,H=e.Record({canister_id:O,num_requested_changes:e.Opt(e.Nat64)}),x=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),q=e.Vec(e.Nat8),K=e.Variant({creation:e.Record({controllers:e.Vec(e.Principal)}),code_deployment:e.Record({mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),module_hash:e.Vec(e.Nat8)}),load_snapshot:e.Record({canister_version:e.Nat64,taken_at_timestamp:e.Nat64,snapshot_id:q}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),$=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:x,details:K}),M=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec($),total_num_changes:e.Nat64}),ae=e.Record({canister_id:O}),Q=e.Variant({controllers:e.Null,public:e.Null,allowed_viewers:e.Vec(e.Principal)}),ne=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:Q,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),w=e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:ne,query_stats:e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),g=e.Record({canister_id:O}),S=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),reserved_cycles_limit:e.Opt(e.Nat),log_visibility:e.Opt(Q),wasm_memory_limit:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),R=e.Record({settings:e.Opt(S),sender_canister_version:e.Opt(e.Nat64)}),B=e.Record({canister_id:O}),j=e.Record({canister_id:O}),Y=e.Record({canister_id:O,snapshot_id:q}),oe=e.Record({canister_id:O}),se=e.Variant({secp256k1:e.Null}),W=e.Record({key_id:e.Record({name:e.Text,curve:se}),canister_id:e.Opt(O),derivation_path:e.Vec(e.Vec(e.Nat8))}),V=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),_=e.Record({canister_id:O}),Z=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),re=e.Record({canister_log_records:e.Vec(Z)}),le=e.Record({value:e.Text,name:e.Text}),X=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(le)}),u=e.Record({url:e.Text,method:e.Variant({get:e.Null,head:e.Null,post:e.Null}),max_response_bytes:e.Opt(e.Nat64),body:e.Opt(e.Vec(e.Nat8)),transform:e.Opt(e.Record({function:e.Func([e.Record({context:e.Vec(e.Nat8),response:X})],[X],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(le)}),h=e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({wasm_memory_persistence:e.Opt(e.Variant({keep:e.Null,replace:e.Null})),skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),y=e.Record({hash:e.Vec(e.Nat8)}),P=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:h,chunk_hashes_list:e.Vec(y),target_canister:O,store_canister:e.Opt(O),sender_canister_version:e.Opt(e.Nat64)}),E=e.Vec(e.Nat8),I=e.Record({arg:e.Vec(e.Nat8),wasm_module:E,mode:h,canister_id:O,sender_canister_version:e.Opt(e.Nat64)}),D=e.Record({canister_id:O}),T=e.Record({id:q,total_size:e.Nat64,taken_at_timestamp:e.Nat64}),U=e.Vec(T),L=e.Record({canister_id:O,sender_canister_version:e.Opt(e.Nat64),snapshot_id:q}),k=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),J=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_proposed_total:e.Nat64}),te=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec(J)})),de=e.Record({settings:e.Opt(S),specified_id:e.Opt(O),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),ge=e.Record({canister_id:O}),Se=e.Record({canister_id:O,amount:e.Nat}),Fe=e.Vec(e.Nat8),_e=e.Variant({ed25519:e.Null,bip340secp256k1:e.Null}),fe=e.Record({key_id:e.Record({algorithm:_e,name:e.Text}),canister_id:e.Opt(O),derivation_path:e.Vec(e.Vec(e.Nat8))}),He=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),Lt=e.Record({key_id:e.Record({name:e.Text,curve:se}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),Ft=e.Record({signature:e.Vec(e.Nat8)}),Vt=e.Variant({bip341:e.Record({merkle_root_hash:e.Vec(e.Nat8)})}),Ht=e.Record({aux:e.Opt(Vt),key_id:e.Record({algorithm:_e,name:e.Text}),derivation_path:e.Vec(e.Vec(e.Nat8)),message:e.Vec(e.Nat8)}),Be=e.Record({signature:e.Vec(e.Nat8)}),Ot=e.Record({canister_id:O}),at=e.Record({canister_id:O}),Ke=e.Record({canister_id:O}),Nc=e.Vec(y),Oc=e.Record({subnet_id:e.Principal}),$e=e.Record({replica_version:e.Text}),Ec=e.Record({replace_snapshot:e.Opt(q),canister_id:O}),vc=T,Rc=e.Record({canister_id:O,sender_canister_version:e.Opt(e.Nat64)}),Ac=e.Record({canister_id:e.Principal,settings:S,sender_canister_version:e.Opt(e.Nat64)}),Sc=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),cn=y;return e.Service({bitcoin_get_balance:e.Func([n],[s],[]),bitcoin_get_block_headers:e.Func([o],[d],[]),bitcoin_get_current_fee_percentiles:e.Func([f],[m],[]),bitcoin_get_utxos:e.Func([b],[F],[]),bitcoin_send_transaction:e.Func([C],[],[]),canister_info:e.Func([H],[M],[]),canister_status:e.Func([ae],[w],[]),clear_chunk_store:e.Func([g],[],[]),create_canister:e.Func([R],[B],[]),delete_canister:e.Func([j],[],[]),delete_canister_snapshot:e.Func([Y],[],[]),deposit_cycles:e.Func([oe],[],[]),ecdsa_public_key:e.Func([W],[V],[]),fetch_canister_logs:e.Func([_],[re],["query"]),http_request:e.Func([u],[X],[]),install_chunked_code:e.Func([P],[],[]),install_code:e.Func([I],[],[]),list_canister_snapshots:e.Func([D],[U],[]),load_canister_snapshot:e.Func([L],[],[]),node_metrics_history:e.Func([k],[te],[]),provisional_create_canister_with_cycles:e.Func([de],[ge],[]),provisional_top_up_canister:e.Func([Se],[],[]),raw_rand:e.Func([],[Fe],[]),schnorr_public_key:e.Func([fe],[He],[]),sign_with_ecdsa:e.Func([Lt],[Ft],[]),sign_with_schnorr:e.Func([Ht],[Be],[]),start_canister:e.Func([Ot],[],[]),stop_canister:e.Func([at],[],[]),stored_chunks:e.Func([Ke],[Nc],[]),subnet_info:e.Func([Oc],[$e],[]),take_canister_snapshot:e.Func([Ec],[vc],[]),uninstall_code:e.Func([Rc],[],[]),update_settings:e.Func([Ac],[],[]),upload_chunk:e.Func([Sc],[cn],[])})}});var Wo=ee(ze=>{"use strict";var wT=ze&&ze.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ze,"__esModule",{value:!0});ze.AdvancedActor=ze.getManagementCanister=ze.ACTOR_METHOD_WITH_CERTIFICATE=ze.ACTOR_METHOD_WITH_HTTP_DETAILS=ze.Actor=ze.UpdateCallRejectedError=ze.QueryCallRejectedError=ze.ActorCallError=void 0;var xT=wf(),Xl=Rs(),Ql=_i(),qs=Ti(),Zh=Go(),dr=Ut(),TT=$t(),Di=Ai(),NT=wT(Jh()),Ms=class extends Ql.AgentError{constructor(t,r,n,i){super(["Call failed:",` Canister: ${t.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
56
+ `)),this.canisterId=t,this.methodName=r,this.type=n,this.props=i}};ze.ActorCallError=Ms;var zo=class extends Ms{constructor(t,r,n){var i;super(t,r,"query",{Status:n.status,Code:(i=Xl.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};ze.QueryCallRejectedError=zo;var ks=class extends Ms{constructor(t,r,n,i,s,a,o){super(t,r,"update",Object.assign({"Request ID":(0,TT.toHex)(n)},i.body?Object.assign(Object.assign({},o?{"Error code":o}:{}),{"Reject code":String(s),"Reject message":a}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=a,this.error_code=o}};ze.UpdateCallRejectedError=ks;var lr=Symbol.for("ic-agent-metadata"),Ds=class e{constructor(t){this[lr]=Object.freeze(t)}static agentOf(t){return t[lr].config.agent}static interfaceOf(t){return t[lr].service}static canisterIdOf(t){return dr.Principal.from(t[lr].config.canisterId)}static async install(t,r){let n=t.mode===void 0?{install:null}:t.mode,i=t.arg?[...new Uint8Array(t.arg)]:[],s=[...new Uint8Array(t.module)],a=typeof r.canisterId=="string"?dr.Principal.fromText(r.canisterId):r.canisterId;await ed(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:a,sender_canister_version:[]})}static async createCanister(t,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await ed(t||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(t,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(t,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(t,r){let n=t({IDL:qs.IDL});class i extends e{constructor(a){if(!a.canisterId)throw new Ql.AgentError(`Canister ID is required, but received ${typeof a.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 o=typeof a.canisterId=="string"?dr.Principal.fromText(a.canisterId):a.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Xh),a),{canisterId:o}),service:n});for(let[c,d]of n._fields)r?.httpDetails&&d.annotations.push(ze.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&d.annotations.push(ze.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=OT(this,c,d,a.blsVerify)}}return i}static createActor(t,r){if(!r.canisterId)throw new Ql.AgentError(`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(t))(r)}static createActorWithHttpDetails(t,r){return new(this.createActorClass(t,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(t,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(t,n))(r)}};ze.Actor=Ds;function ji(e,t){let r=qs.IDL.decode(e,xT.Buffer.from(t));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Xh={pollingStrategyFactory:Zh.strategy.defaultStrategy};ze.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";ze.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function OT(e,t,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(a,...o)=>{var c,d;a=Object.assign(Object.assign({},a),(d=(c=e[lr].config).queryTransform)===null||d===void 0?void 0:d.call(c,t,o,Object.assign(Object.assign({},e[lr].config),a)));let f=a.agent||e[lr].config.agent||(0,Xl.getDefaultAgent)(),p=dr.Principal.from(a.canisterId||e[lr].config.canisterId),m=qs.IDL.encode(r.argTypes,o),b=await f.query(p,{methodName:t,arg:m,effectiveCanisterId:a.effectiveCanisterId}),l=Object.assign(Object.assign({},b.httpDetails),{requestDetails:b.requestDetails});switch(b.status){case"rejected":throw new zo(p,t,b);case"replied":return r.annotations.includes(ze.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:l,result:ji(r.retTypes,b.reply.arg)}:ji(r.retTypes,b.reply.arg)}}:i=async(a,...o)=>{var c,d;a=Object.assign(Object.assign({},a),(d=(c=e[lr].config).callTransform)===null||d===void 0?void 0:d.call(c,t,o,Object.assign(Object.assign({},e[lr].config),a)));let f=a.agent||e[lr].config.agent||(0,Xl.getDefaultAgent)(),{canisterId:p,effectiveCanisterId:m,pollingStrategyFactory:b}=Object.assign(Object.assign(Object.assign({},Xh),e[lr].config),a),l=dr.Principal.from(p),A=m!==void 0?dr.Principal.from(m):l,v=qs.IDL.encode(r.argTypes,o),{requestId:F,response:C,requestDetails:O}=await f.call(l,{methodName:t,arg:v,effectiveCanisterId:A}),H,x;if(C.body&&C.body.certificate){if(f.rootKey==null)throw new Error("Agent is missing root key");let M=C.body.certificate;x=await Di.Certificate.create({certificate:(0,qs.bufFromBufLike)(M),rootKey:f.rootKey,canisterId:dr.Principal.from(p),blsVerify:n});let ae=[new TextEncoder().encode("request_status"),F];switch(new TextDecoder().decode((0,Di.lookupResultToBuffer)(x.lookup([...ae,"status"])))){case"replied":H=(0,Di.lookupResultToBuffer)(x.lookup([...ae,"reply"]));break;case"rejected":{let ne=new Uint8Array((0,Di.lookupResultToBuffer)(x.lookup([...ae,"reject_code"])))[0],w=new TextDecoder().decode((0,Di.lookupResultToBuffer)(x.lookup([...ae,"reject_message"]))),g=(0,Di.lookupResultToBuffer)(x.lookup([...ae,"error_code"])),S=g?new TextDecoder().decode(g):void 0;throw new ks(l,t,F,C,ne,w,S)}}}else if(C.body&&"reject_message"in C.body){let{reject_code:M,reject_message:ae,error_code:Q}=C.body;throw new ks(l,t,F,C,M,ae,Q)}if(C.status===202){let M=b(),ae=await(0,Zh.pollForResponse)(f,A,F,M,n);x=ae.certificate,H=ae.reply}let q=r.annotations.includes(ze.ACTOR_METHOD_WITH_HTTP_DETAILS),K=r.annotations.includes(ze.ACTOR_METHOD_WITH_CERTIFICATE),$=Object.assign(Object.assign({},C),{requestDetails:O});if(H!==void 0)return q&&K?{httpDetails:$,certificate:x,result:ji(r.retTypes,H)}:K?{certificate:x,result:ji(r.retTypes,H)}:q?{httpDetails:$,result:ji(r.retTypes,H)}:ji(r.retTypes,H);if(r.retTypes.length===0)return q?{httpDetails:C,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...a)=>i({},...a);return s.withOptions=a=>(...o)=>i(a,...o),s}function ed(e){function t(r,n){if(e.effectiveCanisterId)return{effectiveCanisterId:dr.Principal.from(e.effectiveCanisterId)};let i=n[0],s=dr.Principal.fromHex("");return i&&typeof i=="object"&&i.target_canister&&r==="install_chunked_code"&&(s=dr.Principal.from(i.target_canister)),i&&typeof i=="object"&&i.canister_id&&(s=dr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return Ds.createActor(NT.default,Object.assign(Object.assign(Object.assign({},e),{canisterId:dr.Principal.fromHex("")}),{callTransform:t,queryTransform:t}))}ze.getManagementCanister=ed;var td=class extends Ds{constructor(t){super(t)}};ze.AdvancedActor=td});var Qh=ee(rd=>{"use strict";Object.defineProperty(rd,"__esModule",{value:!0});rd.default=({IDL:e})=>e.Service({retrieve:e.Func([e.Text],[e.Vec(e.Nat8)],["query"]),store:e.Func([e.Text,e.Vec(e.Nat8)],[],[])})});var e_=ee(Li=>{"use strict";var ET=Li&&Li.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Li,"__esModule",{value:!0});Li.createAssetCanisterActor=void 0;var vT=Wo(),RT=ET(Qh());function AT(e){return vT.Actor.createActor(RT.default,e)}Li.createAssetCanisterActor=AT});var t_=ee($r=>{"use strict";var ST=$r&&$r.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),BT=$r&&$r.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),IT=$r&&$r.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&ST(t,e,r);return BT(t,e),t};Object.defineProperty($r,"__esModule",{value:!0});$r.fetchCandid=void 0;var PT=Ut(),FT=IT(As()),VT=Wl(),UT=Wo();async function CT(e,t){t||(t=await VT.HttpAgent.create());let n=(await FT.request({agent:t,canisterId:PT.Principal.fromText(e),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:a})=>a.Service({__get_candid_interface_tmp_hack:a.Func([],[a.Text],["query"])});return await UT.Actor.createActor(i,{agent:t,canisterId:e}).__get_candid_interface_tmp_hack()}$r.fetchCandid=CT});var jt=ee(Ie=>{"use strict";var r_=Ie&&Ie.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),qT=Ie&&Ie.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Pt=Ie&&Ie.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&r_(t,e,r)},nd=Ie&&Ie.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&r_(t,e,r);return qT(t,e),t};Object.defineProperty(Ie,"__esModule",{value:!0});Ie.Cbor=Ie.CanisterStatus=Ie.polling=void 0;Pt(Wo(),Ie);Pt(Rs(),Ie);Pt(Za(),Ie);Pt(ms(),Ie);Pt(ju(),Ie);Pt(e_(),Ie);Pt(Ai(),Ie);Pt(Ll(),Ie);Pt(t_(),Ie);Pt($l(),Ie);Pt(Hl(),Ie);Pt(ps(),Ie);Pt(xl(),Ie);Pt($t(),Ie);Pt(Ju(),Ie);Ie.polling=nd(Go());Ie.CanisterStatus=nd(As());Ie.Cbor=nd(ys());Pt(Go(),Ie)});var Qe=ee((RE,x_)=>{"use strict";var cd=Object.defineProperty,MT=Object.getOwnPropertyDescriptor,kT=Object.getOwnPropertyNames,DT=Object.prototype.hasOwnProperty,jT=(e,t)=>{for(var r in t)cd(e,r,{get:t[r],enumerable:!0})},LT=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of kT(t))!DT.call(e,i)&&i!==r&&cd(e,i,{get:()=>t[i],enumerable:!(n=MT(t,i))||n.enumerable});return e},HT=e=>LT(cd({},"__esModule",{value:!0}),e),a_={};jT(a_,{AgentManager:()=>QT,Canister:()=>JT,FromStringToTokenError:()=>o_,ICPToken:()=>zT,InvalidPercentageError:()=>p_,NullishError:()=>h_,TokenAmount:()=>WT,TokenAmountV2:()=>YT,arrayBufferToUint8Array:()=>a2,arrayOfNumberToUint8Array:()=>c2,asNonNullish:()=>t2,asciiStringToByteArray:()=>u2,assertNonNullish:()=>$s,assertPercentageNumber:()=>r2,base64ToUint8Array:()=>y2,bigEndianCrc32:()=>b2,bigIntToUint8Array:()=>i2,candidNumberArrayToBigInt:()=>f2,convertStringToE8s:()=>c_,createAgent:()=>d_,createServices:()=>e2,debounce:()=>R2,decodeBase32:()=>h2,defaultAgent:()=>l_,encodeBase32:()=>p2,fromDefinedNullable:()=>S2,fromNullable:()=>ud,fromNullishNullable:()=>B2,hashObject:()=>x2,hashText:()=>g_,hexStringToUint8Array:()=>l2,isEmptyString:()=>ZT,isNullish:()=>Ks,jsonReplacer:()=>m_,jsonReviver:()=>w2,nonNullish:()=>Gr,notEmptyString:()=>u_,nowInBigIntNanoSeconds:()=>E2,numberToUint8Array:()=>s2,principalToSubAccount:()=>I2,queryAndUpdate:()=>XT,secondsToDuration:()=>N2,smallerVersion:()=>P2,toBigIntNanoSeconds:()=>v2,toNullable:()=>A2,uint8ArrayToArrayOfNumber:()=>o2,uint8ArrayToBase64:()=>_2,uint8ArrayToBigInt:()=>n2,uint8ArrayToHexString:()=>__,uint8ArraysEqual:()=>d2});x_.exports=HT(a_);var o_=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(o_||{}),KT=BigInt(1e8),$T=8,c_=e=>{let t=e.includes("e")?Number(e).toLocaleString("en",{useGrouping:!1,maximumFractionDigits:20}):e;t=t.trim().replace(/[,']/g,"");let r=t.match(/\d*(\.\d*)?/);if(!r||r[0]!==t)return 1;let[n,i]=t.split("."),s=BigInt(0);if(n)try{s+=BigInt(n)*KT}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},GT=({amount:e,decimals:t})=>{e=e.trim().replace(/[,']/g,"");let r=e.match(/\d*(\.\d*)?/);if(!r||r[0]!==e)return 1;let[n,i]=e.split("."),s=0n,a=10n**BigInt(t);if(n)try{s+=BigInt(n)*a}catch{return 1}if(i){if(i.length>t)return 2;try{s+=BigInt(i.padEnd(t,"0"))}catch{return 1}}return s},zT={symbol:"ICP",name:"Internet Computer",decimals:8},WT=class Ls{constructor(t,r){if(this.e8s=t,this.token=r,r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8")}static fromE8s({amount:t,token:r}){return new Ls(t,r)}static fromString({amount:t,token:r}){if(r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8");let n=c_(t);return typeof n=="bigint"?new Ls(n,r):n}static fromNumber({amount:t,token:r}){let n=Ls.fromString({amount:t.toString(),token:r});if(n instanceof Ls)return n;throw n===0?new Error(`Number ${t} has more than 8 decimals`):new Error(`Invalid number ${t}`)}toE8s(){return this.e8s}},YT=class Hs{constructor(t,r){this.ulps=t,this.token=r}static fromUlps({amount:t,token:r}){return new Hs(t,r)}static fromString({amount:t,token:r}){let n=GT({amount:t,decimals:r.decimals});return typeof n=="bigint"?new Hs(n,r):n}static fromNumber({amount:t,token:r}){let n=Hs.fromString({amount:t.toFixed(Math.min($T,r.decimals)),token:r});if(n instanceof Hs)return n;throw n===2?new Error(`Number ${t} has more than ${r.decimals} decimals`):new Error(`Invalid number ${t}`)}toUlps(){return this.ulps}toE8s(){return this.token.decimals<8?this.ulps*10n**BigInt(8-this.token.decimals):this.token.decimals===8?this.ulps:this.ulps/10n**BigInt(this.token.decimals-8)}},JT=class{constructor(e,t,r){this.id=e,this.service=t,this.certifiedService=r}get canisterId(){return this.id}caller=({certified:e=!0})=>e?this.certifiedService:this.service},Ks=e=>e==null,Gr=e=>!Ks(e),u_=e=>Gr(e)&&e!=="",ZT=e=>!u_(e),XT=async({request:e,onLoad:t,onQueryError:r,onUpdateError:n,strategy:i="query_and_update",identity:s,resolution:a="race"})=>{let o=!1,c=f=>e({certified:f,identity:s}).then(p=>{o||t({certified:f,response:p})}).catch(p=>{f||r==null||r({error:p,identity:s}),!o&&(Ks(n)||(console.error(p),f&&n({error:p,identity:s})))}).finally(()=>o=o||f),d=i==="query"?[c(!1)]:i==="update"?[c(!0)]:[c(!1),c(!0)];await(a==="all_settled"?Promise.allSettled(d):Promise.race(d))},n_=jt(),id=jt(),l_=()=>id.HttpAgent.createSync({host:"https://icp-api.io",identity:new id.AnonymousIdentity}),d_=async({identity:e,host:t,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await id.HttpAgent.create({identity:e,...Gr(t)&&{host:t},verifyQuerySignatures:n,...Gr(i)&&{retryTimes:i},shouldFetchRootKey:r}),QT=class f_{constructor(t){this.config=t}agents=void 0;static create(t){return new f_(t)}getAgent=async({identity:t})=>{let r=t.getPrincipal().toText();if(Ks(this.agents)||Ks(this.agents[r])){let n=await d_({identity:t,fetchRootKey:this.config.fetchRootKey,host:this.config.host,verifyQuerySignatures:!0});return this.agents={...this.agents??{},[r]:n},n}return this.agents[r]};clearAgents=()=>{this.agents=null}},e2=({options:{canisterId:e,serviceOverride:t,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:a,certifiedIdlFactory:o})=>{let c=n??l_(),d=t??n_.Actor.createActor(a,{agent:c,canisterId:e,callTransform:i,queryTransform:s}),f=r??n_.Actor.createActor(o,{agent:c,canisterId:e,callTransform:i,queryTransform:s});return{service:d,certifiedService:f,agent:c,canisterId:e}},p_=class extends Error{},h_=class extends Error{},$s=(e,t)=>{if(e==null)throw new h_(t)},t2=(e,t)=>($s(e,t),e),r2=e=>{if(e<0||e>100)throw new p_(`${e} is not a valid percentage number.`)},n2=e=>{let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(typeof t.getBigUint64=="function")return t.getBigUint64(0);let r=BigInt(t.getUint32(0)),n=BigInt(t.getUint32(4));return(r<<BigInt(32))+n},i2=e=>{let t=new ArrayBuffer(8),r=new DataView(t);if(typeof r.setBigUint64=="function")r.setBigUint64(0,e);else{let n=Number(e>>BigInt(32)),i=Number(e&BigInt(4294967295));r.setUint32(0,n),r.setUint32(4,i)}return new Uint8Array(t)},s2=e=>{let t=new DataView(new ArrayBuffer(8));for(let r=7;r>=0;--r)t.setUint8(r,e%256),e=e>>8;return new Uint8Array(t.buffer)},a2=e=>new Uint8Array(e),o2=e=>Array.from(e),c2=e=>new Uint8Array(e),u2=e=>Array.from(e).map(t=>t.charCodeAt(0)),l2=e=>{let t=e.match(/.{1,2}/g);return $s(t,"Invalid hex string."),Uint8Array.from(t.map(r=>parseInt(r,16)))},d2=({a:e,b:t})=>e.length===t.length&&e.every((r,n)=>r===t[n]),__=e=>(e instanceof Uint8Array||(e=Uint8Array.from(e)),e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")),f2=e=>{let t=0n;for(let r=e.length-1;r>=0;r--)t=(t<<32n)+BigInt(e[r]);return t},Yo="abcdefghijklmnopqrstuvwxyz234567",Hi=Object.create(null);for(let e=0;e<Yo.length;e++)Hi[Yo[e]]=e;Hi[0]=Hi.o;Hi[1]=Hi.i;var p2=e=>{let t=0,r=0,n="",i=s=>(t<0?r|=s>>-t:r=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=Yo[r>>3],t+=5),0));for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?Yo[r>>3]:"")},h2=e=>{let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0,s=a=>{let o=Hi[a.toLowerCase()];$s(o,`Invalid character: ${JSON.stringify(a)}`),o<<=3,r|=o>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=o<<5-t&255:r=0)};for(let a of e)s(a);return n.slice(0,i)},_2=e=>btoa(String.fromCharCode(...new Uint8Array(e))),y2=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)),m2=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]),g2=e=>{let t=-1;for(let r=0;r<e.length;r++){let n=(e[r]^t)&255;t=m2[n]^t>>>8}return(t^-1)>>>0},b2=e=>{let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,g2(e),!1),new Uint8Array(t)},y_=Ut(),sd="__bigint__",ad="__principal__",od="__uint8array__",m_=(e,t)=>typeof t=="bigint"?{[sd]:`${t}`}:Gr(t)&&t instanceof y_.Principal?{[ad]:t.toText()}:Gr(t)&&t instanceof Uint8Array?{[od]:Array.from(t)}:t,w2=(e,t)=>{let r=n=>t[n];return Gr(t)&&typeof t=="object"&&sd in t?BigInt(r(sd)):Gr(t)&&typeof t=="object"&&ad in t?y_.Principal.fromText(r(ad)):Gr(t)&&typeof t=="object"&&od in t?Uint8Array.from(r(od)):t},x2=async e=>{let t=JSON.stringify(e,m_);return await g_(t)},g_=async e=>{let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return __(new Uint8Array(r))},T2={year:"year",year_plural:"years",month:"month",month_plural:"months",day:"day",day_plural:"days",hour:"hour",hour_plural:"hours",minute:"minute",minute_plural:"minutes",second:"second",second_plural:"seconds"},N2=({seconds:e,i18n:t=T2})=>{let r=e/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=O2(i);return i-=b_(s),[js({labelKey:"year",amount:s}),js({labelKey:"day",amount:i}),js({labelKey:"hour",amount:n}),js({labelKey:"minute",amount:r}),...e>BigInt(0)&&e<BigInt(60)?[js({labelKey:"second",amount:e})]:[]].filter(({amount:a})=>a>0).slice(0,2).map(a=>`${a.amount} ${a.amount===1?t[a.labelKey]:t[`${a.labelKey}_plural`]}`).join(", ")},O2=e=>{let t=e/BigInt(365);for(;b_(t)>e;)t--;return t},b_=e=>{let t=e/BigInt(4);return e*BigInt(365)+t},js=({labelKey:e,amount:t})=>({labelKey:e,amount:Number(t)}),w_=1000000n,E2=()=>BigInt(Date.now())*w_,v2=e=>BigInt(e.getTime())*w_,R2=(e,t)=>{let r;return(...n)=>{let i=()=>e(...n);r&&clearTimeout(r),r=setTimeout(i,t!==void 0&&t>0?t:300)}},A2=e=>Gr(e)?[e]:[],ud=e=>e?.[0],S2=e=>{let t=ud(e);return $s(t),t},B2=e=>ud(e??[]),I2=e=>{let t=e.toUint8Array(),r=new Uint8Array(32);return r[0]=t.length,r.set(t,1),r},i_=({nums:e,amountZeros:t})=>t>e.length?[...e,...[...Array(t-e.length).keys()].map(()=>0)]:e,s_=e=>{if(!Number.isNaN(Number(e)))return Number(e);let t=e.split("").reduce((r,n)=>Number.isNaN(Number(n))?r:r+n,"");return Number(t)},P2=({minVersion:e,currentVersion:t})=>{let r=i_({nums:e.split(".").map(s_),amountZeros:3}).join(".");return i_({nums:t.split(".").map(s_),amountZeros:3}).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var N_=ee(Wr=>{"use strict";var Xo=Wr&&Wr.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},Pn=Wr&&Wr.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},Jo,Zo,$i,Gi;Object.defineProperty(Wr,"__esModule",{value:!0});Wr.Ed25519KeyIdentity=Wr.Ed25519PublicKey=void 0;var F2=jt(),rr=jt(),Gs=Dl();function T_(e){return e!==null&&typeof e=="object"}var ni=class e{constructor(t){if(Jo.set(this,void 0),Zo.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Xo(this,Jo,t,"f"),Xo(this,Zo,e.derEncode(t),"f")}static from(t){if(typeof t=="string"){let r=(0,rr.fromHex)(t);return this.fromRaw(r)}else if(T_(t)){let r=t;if(T_(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,rr.bufFromBufLike)(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(t){return new e(t)}static fromDer(t){return new e(this.derDecode(t))}static derEncode(t){let r=(0,rr.wrapDER)(t,rr.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(t){let r=(0,rr.unwrapDER)(t,rr.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Pn(this,Jo,"f")}get derKey(){return Pn(this,Zo,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Wr.Ed25519PublicKey=ni;Jo=new WeakMap,Zo=new WeakMap;ni.RAW_KEY_LENGTH=32;var dd=class e extends rr.SignIdentity{constructor(t,r){super(),$i.set(this,void 0),Gi.set(this,void 0),Xo(this,$i,ni.from(t),"f"),Xo(this,Gi,new Uint8Array(r),"f")}static generate(t){if(t&&t.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");t||(t=Gs.ed25519.utils.randomPrivateKey()),(0,F2.bufEquals)(t,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(t)[i];let n=Gs.ed25519.getPublicKey(r);return e.fromKeyPair(n,r)}static fromParsedJson(t){let[r,n]=t;return new e(ni.fromDer((0,rr.fromHex)(r)),(0,rr.fromHex)(n))}static fromJSON(t){let r=JSON.parse(t);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(t)}`)}static fromKeyPair(t,r){return new e(ni.fromRaw(t),r)}static fromSecretKey(t){let r=Gs.ed25519.getPublicKey(new Uint8Array(t));return e.fromKeyPair(r,t)}toJSON(){return[(0,rr.toHex)(Pn(this,$i,"f").toDer()),(0,rr.toHex)(Pn(this,Gi,"f"))]}getKeyPair(){return{secretKey:Pn(this,Gi,"f"),publicKey:Pn(this,$i,"f")}}getPublicKey(){return Pn(this,$i,"f")}async sign(t){let r=new Uint8Array(t),n=(0,rr.uint8ToBuf)(Gs.ed25519.sign(r,Pn(this,Gi,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(t,r,n){let[i,s,a]=[t,r,n].map(o=>(typeof o=="string"&&(o=(0,rr.fromHex)(o)),o instanceof Uint8Array&&(o=o.buffer),new Uint8Array(o)));return Gs.ed25519.verify(s,i,a)}};Wr.Ed25519KeyIdentity=dd;$i=new WeakMap,Gi=new WeakMap});var E_=ee(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.ECDSAKeyIdentity=ii.CryptoError=void 0;var V2=jt(),Qo=class e extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,e.prototype)}};ii.CryptoError=Qo;function O_(e){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(e)return e;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new Qo("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 ec=class e extends V2.SignIdentity{constructor(t,r,n){super(),this._keyPair=t,this._derKey=r,this._subtleCrypto=n}static async generate(t){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=t??{},s=O_(i),a=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),o=await s.exportKey("spki",a.publicKey);return new this(a,o,s)}static async fromKeyPair(t,r){let n=O_(r),i=await n.exportKey("spki",t.publicKey);return new e(t,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let t=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return t},r}async sign(t){let r={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(r,this._keyPair.privateKey,t)}};ii.ECDSAKeyIdentity=ec;ii.default=ec});var pd=ee(Vn=>{"use strict";var U2=Vn&&Vn.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},zs=Vn&&Vn.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},Fn;Object.defineProperty(Vn,"__esModule",{value:!0});Vn.PartialIdentity=void 0;var C2=Ut(),fd=class{constructor(t){Fn.set(this,void 0),U2(this,Fn,t,"f")}get rawKey(){return zs(this,Fn,"f").rawKey}get derKey(){return zs(this,Fn,"f").derKey}toDer(){return zs(this,Fn,"f").toDer()}getPublicKey(){return zs(this,Fn,"f")}getPrincipal(){return C2.Principal.from(zs(this,Fn,"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.")}};Vn.PartialIdentity=fd;Fn=new WeakMap});var v_=ee(Je=>{"use strict";var q2=Je&&Je.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),M2=Je&&Je.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),k2=Je&&Je.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&q2(t,e,r);return M2(t,e),t},D2=Je&&Je.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},j2=Je&&Je.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},L2=Je&&Je.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},tc;Object.defineProperty(Je,"__esModule",{value:!0});Je.isDelegationValid=Je.PartialDelegationIdentity=Je.DelegationIdentity=Je.DelegationChain=Je.Delegation=void 0;var Un=jt(),_d=Ut(),Ws=k2(_s()),H2=pd(),K2=new TextEncoder().encode("ic-request-auth-delegation"),$2=new TextEncoder().encode(`
57
+ ic-request`);function hd(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return(0,Un.fromHex)(e)}var Ys=class{constructor(t,r,n){this.pubkey=t,this.expiration=r,this.targets=n}toCBOR(){return Ws.value.map(Object.assign({pubkey:Ws.value.bytes(this.pubkey),expiration:Ws.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Ws.value.array(this.targets.map(t=>Ws.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Un.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};Je.Delegation=Ys;async function G2(e,t,r,n){let i=new Ys(t.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...K2,...new Uint8Array((0,Un.requestIdOf)(Object.assign({},i)))]),a=await e.sign(s);return{delegation:i,signature:a}}var yd=class e{constructor(t,r){this.delegations=t,this.publicKey=r}static async create(t,r,n=new Date(Date.now()+900*1e3),i={}){var s,a;let o=await G2(t,r,n,i.targets);return new e([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],o],((a=i.previous)===null||a===void 0?void 0:a.publicKey)||t.getPublicKey().toDer())}static fromJSON(t){let{publicKey:r,delegations:n}=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:a,signature:o}=s,{pubkey:c,expiration:d,targets:f}=a;if(f!==void 0&&!Array.isArray(f))throw new Error("Invalid targets.");return{delegation:new Ys(hd(c),BigInt("0x"+d),f&&f.map(p=>{if(typeof p!="string")throw new Error("Invalid target.");return _d.Principal.fromHex(p)})),signature:hd(o)}});return new this(i,hd(r))}static fromDelegations(t,r){return new this(t,r)}toJSON(){return{delegations:this.delegations.map(t=>{let{delegation:r,signature:n}=t,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:(0,Un.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Un.toHex)(n)}}),publicKey:(0,Un.toHex)(this.publicKey)}}};Je.DelegationChain=yd;var md=class extends Un.SignIdentity{constructor(t,r){super(),this._inner=t,this._delegation=r}static fromDelegation(t,r){return new this(t,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(t){return this._inner.sign(t)}async transformRequest(t){let{body:r}=t,n=L2(t,["body"]),i=await(0,Un.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...$2,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};Je.DelegationIdentity=md;var gd=class e extends H2.PartialIdentity{constructor(t,r){super(t),tc.set(this,void 0),D2(this,tc,r,"f")}get delegation(){return j2(this,tc,"f")}static fromDelegation(t,r){return new e(t,r)}};Je.PartialDelegationIdentity=gd;tc=new WeakMap;function z2(e,t){for(let{delegation:i}of e.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=t?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?_d.Principal.fromText(i):i)):r.push(typeof n=="string"?_d.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:a}of e.delegations){if(a.targets===void 0)continue;let o=!0;for(let c of a.targets)if(c.toText()===s){o=!1;break}if(o)return!1}}return!0}Je.isDelegationValid=z2});var R_=ee(Cn=>{"use strict";var W2=Cn&&Cn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Cn,"__esModule",{value:!0});Cn.WebAuthnIdentity=Cn.CosePublicKey=void 0;var si=jt(),bd=W2(ja()),Y2=Dn(),J2=Ti();function Z2(e){return(0,si.wrapDER)(e,si.DER_COSE_OID).buffer}function X2(e){let t=new DataView(new ArrayBuffer(2)),r=e.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>t.setUint8(s,i));let n=t.getUint16(0);return e.slice(55+n)}var rc=class{constructor(t){this._cose=t,this._encodedKey=Z2(t)}toDer(){return this._encodedKey}getCose(){return this._cose}};Cn.CosePublicKey=rc;function Q2(e="<ic0.app>"){return typeof e=="string"?Uint8Array.from(e,t=>t.charCodeAt(0)):e}async function eN(e){let t=await navigator.credentials.create(e??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:Q2(),pubKeyCredParams:[{type:"public-key",alg:wd.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Y2.randomBytes)(16),name:"Internet Identity",displayName:"Internet Identity"}}});return t===null?null:{id:t.id,response:t.response,type:t.type,authenticatorAttachment:t.authenticatorAttachment,getClientExtensionResults:t.getClientExtensionResults,rawId:(0,J2.bufFromBufLike)(t.rawId)}}var wd;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(wd||(wd={}));var xd=class extends si.SignIdentity{constructor(t,r,n){super(),this.rawId=t,this.authenticatorAttachment=n,this._publicKey=new rc(r)}static fromJSON(t){let{publicKey:r,rawId:n}=JSON.parse(t);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,si.fromHex)(n),(0,si.fromHex)(r),void 0)}static async create(t){var r;let n=await eN(t);if(!n||n.type!=="public-key")throw new Error("Could not create credentials.");let i=n.response;if(i.attestationObject===void 0)throw new Error("Was expecting an attestation response.");let s=bd.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,X2(s.authData),(r=n.authenticatorAttachment)!==null&&r!==void 0?r:void 0)}getPublicKey(){return this._publicKey}getAuthenticatorAttachment(){return this.authenticatorAttachment}async sign(t){let r=await navigator.credentials.get({publicKey:{allowCredentials:[{type:"public-key",id:this.rawId}],challenge:t,userVerification:"preferred"}});r.authenticatorAttachment!==null&&(this.authenticatorAttachment=r.authenticatorAttachment);let n=r.response,i=bd.default.encode(new bd.default.Tagged(55799,{authenticator_data:new Uint8Array(n.authenticatorData),client_data_json:new TextDecoder().decode(n.clientDataJSON),signature:new Uint8Array(n.signature)}));if(!i)throw new Error("failed to encode cbor");return i.buffer}toJSON(){return{publicKey:(0,si.toHex)(this._publicKey.getCose()),rawId:(0,si.toHex)(this.rawId)}}};Cn.WebAuthnIdentity=xd});var S_=ee(We=>{"use strict";var tN=We&&We.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Nd=We&&We.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&tN(t,e,r)};Object.defineProperty(We,"__esModule",{value:!0});We.Secp256k1KeyIdentity=We.ED25519_OID=We.DER_COSE_OID=We.unwrapDER=We.wrapDER=We.WebAuthnIdentity=We.Ed25519PublicKey=We.Ed25519KeyIdentity=void 0;var A_=N_();Object.defineProperty(We,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return A_.Ed25519KeyIdentity}});Object.defineProperty(We,"Ed25519PublicKey",{enumerable:!0,get:function(){return A_.Ed25519PublicKey}});Nd(E_(),We);Nd(v_(),We);Nd(pd(),We);var rN=R_();Object.defineProperty(We,"WebAuthnIdentity",{enumerable:!0,get:function(){return rN.WebAuthnIdentity}});var nc=jt();Object.defineProperty(We,"wrapDER",{enumerable:!0,get:function(){return nc.wrapDER}});Object.defineProperty(We,"unwrapDER",{enumerable:!0,get:function(){return nc.unwrapDER}});Object.defineProperty(We,"DER_COSE_OID",{enumerable:!0,get:function(){return nc.DER_COSE_OID}});Object.defineProperty(We,"ED25519_OID",{enumerable:!0,get:function(){return nc.ED25519_OID}});var Td=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};We.Secp256k1KeyIdentity=Td});var Ed=ee(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.IdleManager=void 0;var B_=["mousedown","mousemove","keydown","touchstart","wheel"],Od=class{constructor(t={}){var r;this.callbacks=[],this.idleTimeout=600*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=600*1e3}=t||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),B_.forEach(function(o){document.addEventListener(o,s,!0)});let a=(o,c)=>{let d;return(...f)=>{let p=this,m=function(){d=void 0,o.apply(p,f)};clearTimeout(d),d=window.setTimeout(m,c)}};if(t?.captureScroll){let o=a(s,(r=t?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",o,!0)}s()}static create(t={}){return new this(t)}registerCallback(t){this.callbacks.push(t)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let t=this._resetTimer.bind(this);B_.forEach(function(r){document.removeEventListener(r,t,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let t=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(t,this.idleTimeout)}};ic.IdleManager=Od});function iN(){return I_||(I_=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function sN(){return P_||(P_=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function aN(e){let t=new Promise((r,n)=>{let i=()=>{e.removeEventListener("success",s),e.removeEventListener("error",a)},s=()=>{r(fr(e.result)),i()},a=()=>{n(e.error),i()};e.addEventListener("success",s),e.addEventListener("error",a)});return t.then(r=>{r instanceof IDBCursor&&F_.set(r,e)}).catch(()=>{}),Sd.set(t,e),t}function oN(e){if(Rd.has(e))return;let t=new Promise((r,n)=>{let i=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",a),e.removeEventListener("abort",a)},s=()=>{r(),i()},a=()=>{n(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",s),e.addEventListener("error",a),e.addEventListener("abort",a)});Rd.set(e,t)}function U_(e){Ad=e(Ad)}function cN(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...r){let n=e.call(Js(this),t,...r);return V_.set(n,t.sort?t.sort():[t]),fr(n)}:sN().includes(e)?function(...t){return e.apply(Js(this),t),fr(F_.get(this))}:function(...t){return fr(e.apply(Js(this),t))}}function uN(e){return typeof e=="function"?cN(e):(e instanceof IDBTransaction&&oN(e),nN(e,iN())?new Proxy(e,Ad):e)}function fr(e){if(e instanceof IDBRequest)return aN(e);if(vd.has(e))return vd.get(e);let t=uN(e);return t!==e&&(vd.set(e,t),Sd.set(t,e)),t}var nN,I_,P_,F_,Rd,V_,vd,Sd,Ad,Js,Bd=Xd(()=>{nN=(e,t)=>t.some(r=>e instanceof r);F_=new WeakMap,Rd=new WeakMap,V_=new WeakMap,vd=new WeakMap,Sd=new WeakMap;Ad={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return Rd.get(e);if(t==="objectStoreNames")return e.objectStoreNames||V_.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return fr(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};Js=e=>Sd.get(e)});var q_={};cm(q_,{deleteDB:()=>dN,openDB:()=>lN,unwrap:()=>Js,wrap:()=>fr});function lN(e,t,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let a=indexedDB.open(e,t),o=fr(a);return n&&a.addEventListener("upgradeneeded",c=>{n(fr(a.result),c.oldVersion,c.newVersion,fr(a.transaction),c)}),r&&a.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),o.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",d=>i(d.oldVersion,d.newVersion,d))}).catch(()=>{}),o}function dN(e,{blocked:t}={}){let r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),fr(r).then(()=>{})}function C_(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(Id.get(t))return Id.get(t);let r=t.replace(/FromIndex$/,""),n=t!==r,i=pN.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||fN.includes(r)))return;let s=async function(a,...o){let c=this.transaction(a,i?"readwrite":"readonly"),d=c.store;return n&&(d=d.index(o.shift())),(await Promise.all([d[r](...o),i&&c.done]))[0]};return Id.set(t,s),s}var fN,pN,Id,M_=Xd(()=>{Bd();Bd();fN=["get","getKey","getAll","getAllKeys","count"],pN=["put","add","delete","clear"],Id=new Map;U_(e=>({...e,get:(t,r,n)=>C_(t,r)||e.get(t,r,n),has:(t,r)=>!!C_(t,r)||e.has(t,r)}))});var Fd=ee(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.IdbKeyVal=void 0;var hN=(M_(),um(q_)),Zs=ac(),k_="auth-client-db",D_="ic-keyval",_N=async(e=k_,t=D_,r)=>(Zs.isBrowser&&(localStorage!=null&&localStorage.getItem(Zs.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Zs.KEY_STORAGE_DELEGATION),localStorage.removeItem(Zs.KEY_STORAGE_KEY)),await(0,hN.openDB)(e,r,{upgrade:n=>{n.objectStoreNames.contains(t)&&n.clear(t),n.createObjectStore(t)}}));async function yN(e,t,r){return await e.get(t,r)}async function mN(e,t,r,n){return await e.put(t,n,r)}async function gN(e,t,r){return await e.delete(t,r)}var Pd=class e{constructor(t,r){this._db=t,this._storeName=r}static async create(t){let{dbName:r=k_,storeName:n=D_,version:i=Zs.DB_VERSION}=t??{},s=await _N(r,n,i);return new e(s,n)}async set(t,r){return await mN(this._db,this._storeName,t,r)}async get(t){var r;return(r=await yN(this._db,this._storeName,t))!==null&&r!==void 0?r:null}async remove(t){return await gN(this._db,this._storeName,t)}};sc.IdbKeyVal=Pd});var ac=ee(it=>{"use strict";var bN=it&&it.__classPrivateFieldSet||function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},wN=it&&it.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},oc;Object.defineProperty(it,"__esModule",{value:!0});it.IdbStorage=it.LocalStorage=it.isBrowser=it.DB_VERSION=it.KEY_VECTOR=it.KEY_STORAGE_DELEGATION=it.KEY_STORAGE_KEY=void 0;var xN=Fd();it.KEY_STORAGE_KEY="identity";it.KEY_STORAGE_DELEGATION="delegation";it.KEY_VECTOR="iv";it.DB_VERSION=1;it.isBrowser=typeof window<"u";var Vd=class{constructor(t="ic-",r){this.prefix=t,this._localStorage=r}get(t){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+t))}set(t,r){return this._getLocalStorage().setItem(this.prefix+t,r),Promise.resolve()}remove(t){return this._getLocalStorage().removeItem(this.prefix+t),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!t)throw new Error("Could not find local storage.");return t}};it.LocalStorage=Vd;var Ud=class{constructor(t){oc.set(this,void 0),bN(this,oc,t??{},"f")}get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}xN.IdbKeyVal.create(wN(this,oc,"f")).then(r=>{this.initializedDb=r,t(r)})})}async get(t){return await(await this._db).get(t)}async set(t,r){await(await this._db).set(t,r)}async remove(t){await(await this._db).remove(t)}};it.IdbStorage=Ud;oc=new WeakMap});var Dd=ee(et=>{"use strict";var TN=et&&et.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),NN=et&&et.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&TN(t,e,r)};Object.defineProperty(et,"__esModule",{value:!0});et.AuthClient=et.ERROR_USER_INTERRUPT=et.IdbKeyVal=et.KEY_STORAGE_KEY=et.KEY_STORAGE_DELEGATION=et.LocalStorage=et.IdbStorage=void 0;var j_=jt(),nr=S_(),L_=Ed(),Nt=ac(),cc=ac();Object.defineProperty(et,"IdbStorage",{enumerable:!0,get:function(){return cc.IdbStorage}});Object.defineProperty(et,"LocalStorage",{enumerable:!0,get:function(){return cc.LocalStorage}});Object.defineProperty(et,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return cc.KEY_STORAGE_DELEGATION}});Object.defineProperty(et,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return cc.KEY_STORAGE_KEY}});var ON=Fd();Object.defineProperty(et,"IdbKeyVal",{enumerable:!0,get:function(){return ON.IdbKeyVal}});var EN="https://identity.ic0.app",vN="#authorize",Cd="ECDSA",qd="Ed25519",RN=500;et.ERROR_USER_INTERRUPT="UserInterrupt";NN(Ed(),et);var kd=class{constructor(t,r,n,i,s,a,o,c){this._identity=t,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=a,this._idpWindow=o,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(t={}){var r,n,i;let s=(r=t.storage)!==null&&r!==void 0?r:new Nt.IdbStorage,a=(n=t.keyType)!==null&&n!==void 0?n:Cd,o=null;if(t.identity)o=t.identity;else{let p=await s.get(Nt.KEY_STORAGE_KEY);if(!p&&Nt.isBrowser)try{let m=new Nt.LocalStorage,b=await m.get(Nt.KEY_STORAGE_DELEGATION),l=await m.get(Nt.KEY_STORAGE_KEY);b&&l&&a===Cd&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Nt.KEY_STORAGE_DELEGATION,b),await s.set(Nt.KEY_STORAGE_KEY,l),p=b,await m.remove(Nt.KEY_STORAGE_DELEGATION),await m.remove(Nt.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(p)try{typeof p=="object"?a===qd&&typeof p=="string"?o=await nr.Ed25519KeyIdentity.fromJSON(p):o=await nr.ECDSAKeyIdentity.fromKeyPair(p):typeof p=="string"&&(o=nr.Ed25519KeyIdentity.fromJSON(p))}catch{}}let c=new j_.AnonymousIdentity,d=null;if(o)try{let p=await s.get(Nt.KEY_STORAGE_DELEGATION);if(typeof p=="object"&&p!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?c=t.identity:p&&(d=nr.DelegationChain.fromJSON(p),(0,nr.isDelegationValid)(d)?"toDer"in o?c=nr.PartialDelegationIdentity.fromDelegation(o,d):c=nr.DelegationIdentity.fromDelegation(o,d):(await Md(s),o=null))}catch(p){console.error(p),await Md(s),o=null}let f;return!((i=t.idleOptions)===null||i===void 0)&&i.disableIdle?f=void 0:(d||t.identity)&&(f=L_.IdleManager.create(t.idleOptions)),o||(a===qd?(o=await nr.Ed25519KeyIdentity.generate(),await s.set(Nt.KEY_STORAGE_KEY,JSON.stringify(o.toJSON()))):(t.storage&&a===Cd&&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 '${qd}' as the key type, as it can serialize to a string`),o=await nr.ECDSAKeyIdentity.generate(),await s.set(Nt.KEY_STORAGE_KEY,o.getKeyPair()))),new this(c,o,d,s,f,t)}_registerDefaultIdleCallback(){var t,r;let n=(t=this._createOptions)===null||t===void 0?void 0:t.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(t,r){var n,i;let s=t.delegations.map(d=>({delegation:new nr.Delegation(d.delegation.pubkey,d.delegation.expiration,d.delegation.targets),signature:d.signature.buffer})),a=nr.DelegationChain.fromDelegations(s,t.userPublicKey.buffer),o=this._key;if(!o)return;this._chain=a,"toDer"in o?this._identity=nr.PartialDelegationIdentity.fromDelegation(o,this._chain):this._identity=nr.DelegationIdentity.fromDelegation(o,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=L_.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Nt.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(t)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(t){var r,n,i,s;let a=BigInt(8)*BigInt(36e11),o=new URL(((r=t?.identityProvider)===null||r===void 0?void 0:r.toString())||EN);o.hash=vN,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(o,Object.assign({maxTimeToLive:(i=t?.maxTimeToLive)!==null&&i!==void 0?i:a},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(o.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(et.ERROR_USER_INTERRUPT,t?.onError):setTimeout(c,RN))};c()}_getEventHandler(t,r){return async n=>{var i,s,a;if(n.origin!==t.origin)return;let o=n.data;switch(o.kind){case"authorize-ready":{let c=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:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(a=this._idpWindow)===null||a===void 0||a.postMessage(c,t.origin);break}case"authorize-client-success":try{await this._handleSuccess(o,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(o.text,r?.onError);break;default:break}}}_handleFailure(t,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(t),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(t={}){if(await Md(this._storage),this._identity=new j_.AnonymousIdentity,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};et.AuthClient=kd;async function Md(e){await e.remove(Nt.KEY_STORAGE_KEY),await e.remove(Nt.KEY_STORAGE_DELEGATION),await e.remove(Nt.KEY_VECTOR)}});var Ly=qe(Qe(),1);var vy=qe(Qe(),1);var Ki=class{callbacks=[];populate(t){this.callbacks.forEach(({callback:r})=>r(t))}subscribe(t){let r=Symbol();return this.callbacks.push({id:r,callback:t}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var zr=class e extends Ki{static instance;authUser=null;constructor(){super()}static getInstance(){return e.instance||(e.instance=new e),e.instance}set(t){this.authUser=t,this.populate(t)}get(){return this.authUser}subscribe(t){let r=super.subscribe(t);return t(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var ld=({message:e,detail:t})=>{let r=new CustomEvent(e,{detail:t,bubbles:!0});document.dispatchEvent(r)};var Ey=qe(Dd(),1),Yd=qe(Qe(),1);var H_=BigInt(144e11),K_=!1,$_={width:576,height:576},G_={width:505,height:705},z_="internetcomputer.org";var Xs=qe(Qe(),1);var zi="http://127.0.0.1:5987",W_="rdmx6-jaaaa-aaaaa-aaadq-cai";var Yr=class e extends Ki{static instance;env;constructor(){super()}static getInstance(){return e.instance||(e.instance=new e),e.instance}set(t){this.env=t,this.populate(t)}get(){return this.env}reset(){this.env=null}subscribe(t){let r=super.subscribe(t);return t(this.env),r}};var jd=qe(Qe(),1);var uc=qe(Qe(),1),Y_=async e=>{let t=new Blob([JSON.stringify(e,uc.jsonReplacer)],{type:"application/json; charset=utf-8"});return new Uint8Array(await t.arrayBuffer())},lc=async e=>{let t=new Blob([e instanceof Uint8Array?e:new Uint8Array(e)],{type:"application/json; charset=utf-8"});return JSON.parse(await t.text(),uc.jsonReviver)},dc=()=>typeof window<"u";var Ld=({width:e,height:t})=>{if(!dc()||(0,jd.isNullish)(window)||(0,jd.isNullish)(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-t/2,s=r/2+screenX-e/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${e}, height=${t}, top=${i}, left=${s}`};var fc=class{#e;constructor({domain:t}){this.#e=t}get id(){return"internet_identity"}signInOptions({windowed:t}){let r=()=>{let n=Yr.getInstance().get()?.container;if((0,Xs.isNullish)(n)||n===!1)return`https://identity.${this.#e??z_}`;let i=Yr.getInstance().get(),s=(0,Xs.nonNullish)(i)&&(0,Xs.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:W_,{host:a,protocol:o}=new URL(n===!0?zi:n);return/apple/i.test(navigator?.vendor)?`${o}//${a}?canisterId=${s}`:`${o}//${s}.${a.replace("127.0.0.1","localhost")}`};return{...t!==!1&&{windowOpenerFeatures:Ld($_)},identityProvider:r()}}},J_=class{#e;#t;constructor({appName:t,logoUrl:r}){this.#e=t,this.#t=r}get id(){return"nfid"}signInOptions({windowed:t}){return{...t!==!1&&{windowOpenerFeatures:Ld(G_)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var Q_=qe(jt(),1),hc=qe(Qe(),1);var pc=qe(Qe(),1);var Z_=qe(jt(),1),Hd=qe(Qe(),1);var X_=async({identity:e,container:t})=>{let n=(0,Hd.nonNullish)(t)&&t!==!1?t===!0?zi:t:"https://icp-api.io",i=(0,Hd.nonNullish)(t);return await Z_.HttpAgent.create({identity:e,shouldFetchRootKey:i,host:n})};var Wi=class e{static instance;#e=void 0;constructor(){}static getInstance(){return(0,pc.isNullish)(e.instance)&&(e.instance=new e),e.instance}async getAgent({identity:t,...r}){let n=t.getPrincipal().toText();if((0,pc.isNullish)(this.#e)||(0,pc.isNullish)(this.#e[n])){let i=await X_({identity:t,...r});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}};var Yi=class e{static instance;#e=void 0;constructor(){}static getInstance(){return(0,hc.isNullish)(e.instance)&&(e.instance=new e),e.instance}async getActor({satelliteId:t,identity:r,actorKey:n,...i}){let s=`${n}#${r.getPrincipal().toText()}#${t};`;if((0,hc.isNullish)(this.#e)||(0,hc.isNullish)(this.#e[s])){let a=await this.createActor({satelliteId:t,identity:r,...i});return this.#e={...this.#e??{},[s]:a},a}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:t,satelliteId:r,...n}){let i=await Wi.getInstance().getAgent(n);return Q_.Actor.createActor(t,{agent:i,canisterId:r})}};var _c=class extends Error{},yc=class extends Error{},mc=class extends Error{},gc=class extends Error{},bc=class extends Error{};var ey=qe(Dd(),1),wc=()=>ey.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var ea=qe(Qe(),1);var Kd=({error:e,type:t})=>typeof e=="string"?e.includes(t):e instanceof Error?e.message.includes(t):!1;var ty="juno.datastore.error.user.cannot_update";var vr=qe(Qe(),1);var ry=async({data:e})=>{try{return await lc(e)}catch(t){console.error("The data parsing has failed, mapping to undefined as a fallback.",t);return}};var ai=qe(Qe(),1);var $d=async e=>{let{data:t,version:r,description:n}=e;return{description:(0,ai.toNullable)(n),data:await Y_(t),version:(0,ai.toNullable)(r)}},Gd=e=>{let{version:t}=e;return{version:(0,ai.toNullable)(t)}},Qs=async({doc:e,key:t})=>{let{owner:r,version:n,description:i,data:s,...a}=e;return{key:t,description:(0,ai.fromNullable)(i),owner:r.toText(),data:await lc(s),version:(0,ai.fromNullable)(n),...a}};var iy=qe(Ut(),1),st=qe(Qe(),1);var ny=e=>{if((0,st.isNullish)(e))return(0,st.toNullable)();switch(e.matcher){case"equal":return(0,st.toNullable)({Equal:e.timestamp});case"greaterThan":return(0,st.toNullable)({GreaterThan:e.timestamp});case"lessThan":return(0,st.toNullable)({LessThan:e.timestamp});case"between":return(0,st.toNullable)({Between:[e.timestamps.start,e.timestamps.end]});default:throw new bc("Invalid list matcher for timestamp",e)}},qn=({matcher:e,paginate:t,order:r,owner:n})=>({matcher:(0,st.isNullish)(e)?[]:[{key:(0,st.toNullable)(e.key),description:(0,st.toNullable)(e.description),created_at:ny(e.createdAt),updated_at:ny(e.updatedAt)}],paginate:(0,st.toNullable)((0,st.isNullish)(t)?void 0:{start_after:(0,st.toNullable)(t.startAfter),limit:(0,st.toNullable)((0,st.isNullish)(t.limit)?void 0:BigInt(t.limit))}),order:(0,st.toNullable)((0,st.isNullish)(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:(0,st.toNullable)((0,st.isNullish)(n)?void 0:typeof n=="string"?iy.Principal.fromText(n):n)});var cy=qe(Qe(),1);var AN=qe(jt(),1),SN=qe(Qe(),1),BN=qe(Qe(),1),IN=qe(jt(),1);var sy=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),n=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),i=e.Record({field:n,desc:e.Bool}),s=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),a=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(s),description:e.Opt(e.Text),created_at:e.Opt(s)}),o=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),c=e.Record({order:e.Opt(i),owner:e.Opt(e.Principal),matcher:e.Opt(a),paginate:e.Opt(o)}),d=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),p=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:f,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),b=e.Variant({Db:e.Null,Storage:e.Null}),l=e.Record({version:e.Opt(e.Nat64)}),A=e.Record({proposal_ids:e.Vec(e.Nat)}),v=e.Record({cycles:e.Nat,destination_id:e.Principal}),F=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),C=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),O=e.Record({key:F,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,C)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),H=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),x=e.Record({allowed_callers:e.Vec(e.Principal)}),q=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),K=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),$=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),M=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),ae=e.Variant({Deny:e.Null,Allow:e.Null}),Q=e.Record({status_code:e.Nat16,location:e.Text}),ne=e.Record({iframe:e.Opt(M),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),w=e.Record({db:e.Opt($),authentication:e.Opt(q),storage:ne}),g=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),S=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),R=e.Record({clear_existing_assets:e.Opt(e.Bool)}),B=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),j=e.Variant({AssetsUpgrade:R,SegmentsDeployment:B}),Y=e.Record({status:S,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:j}),oe=e.Variant({Heap:e.Null,Stable:e.Null}),se=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),W=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),V=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:se,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(W),write:se,max_changes_per_user:e.Opt(e.Nat32)}),_=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),Z=e.Record({memory:oe,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),re=e.Variant({Callback:e.Record({token:Z,callback:e.Func([],[],["query"])})}),le=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(re),status_code:e.Nat16}),X=e.Record({token:e.Opt(Z),body:e.Vec(e.Nat8)}),u=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),h=e.Record({batch_id:e.Nat}),y=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,O)),items_length:e.Nat64}),P=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),E=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,g)),items_length:e.Nat64}),I=e.Record({desc:e.Bool}),D=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),T=e.Record({order:e.Opt(I),paginate:e.Opt(D)}),U=e.Record({proposal_id:e.Nat}),L=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(U,Y)),items_length:e.Nat64}),k=e.Record({include_system:e.Bool}),J=e.Record({matcher:e.Opt(k)}),te=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,V)),items_length:e.Nat64}),de=e.Record({stable:e.Nat64,heap:e.Nat64}),ge=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),Se=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:f,expires_at:e.Opt(e.Nat64)}),Fe=e.Record({controller:Se,controllers:e.Vec(e.Principal)}),_e=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),fe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),He=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),max_size:e.Opt(e.Nat),read:se,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(W),write:se,max_changes_per_user:e.Opt(e.Nat32)}),Lt=e.Record({iframe:e.Opt(M),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),Ft=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Vt=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),commit_proposal:e.Func([r],[e.Null],[]),commit_proposal_asset_upload:e.Func([t],[],[]),commit_proposal_many_assets_upload:e.Func([e.Vec(t)],[],[]),count_assets:e.Func([e.Text,c],[e.Nat64],["query"]),count_collection_assets:e.Func([e.Text],[e.Nat64],["query"]),count_collection_docs:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text,c],[e.Nat64],["query"]),count_proposals:e.Func([],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([d],[e.Vec(e.Tuple(e.Principal,p))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,c],[],[]),del_filtered_docs:e.Func([e.Text,c],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,m))],[],[]),del_rule:e.Func([b,e.Text,l],[],[]),delete_proposal_assets:e.Func([A],[],[]),deposit_cycles:e.Func([v],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(O)],["query"]),get_auth_config:e.Func([],[e.Opt(q)],["query"]),get_config:e.Func([],[w],[]),get_db_config:e.Func([],[e.Opt($)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(g)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(O)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(g)))],["query"]),get_proposal:e.Func([e.Nat],[e.Opt(Y)],["query"]),get_rule:e.Func([b,e.Text],[e.Opt(V)],["query"]),get_storage_config:e.Func([],[ne],["query"]),http_request:e.Func([_],[le],["query"]),http_request_streaming_callback:e.Func([Z],[X],["query"]),init_asset_upload:e.Func([u],[h],[]),init_proposal:e.Func([j],[e.Nat,Y],[]),init_proposal_asset_upload:e.Func([u,e.Nat],[h],[]),init_proposal_many_assets_upload:e.Func([e.Vec(u),e.Nat],[e.Vec(e.Tuple(e.Text,h))],[]),list_assets:e.Func([e.Text,c],[y],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,p))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,P))],["query"]),list_docs:e.Func([e.Text,c],[E],["query"]),list_proposals:e.Func([T],[L],["query"]),list_rules:e.Func([b,J],[te],["query"]),memory_size:e.Func([],[de],["query"]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([ge],[q],[]),set_controllers:e.Func([Fe],[e.Vec(e.Tuple(e.Principal,p))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([_e],[$],[]),set_doc:e.Func([e.Text,e.Text,fe],[g],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,fe))],[e.Vec(e.Tuple(e.Text,g))],[]),set_rule:e.Func([b,e.Text,He],[V],[]),set_storage_config:e.Func([Lt],[ne],[]),submit_proposal:e.Func([e.Nat],[e.Nat,Y],[]),upload_asset_chunk:e.Func([Ft],[Vt],[]),upload_proposal_asset_chunk:e.Func([Ft],[Vt],[])})},ay=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),n=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),i=e.Record({field:n,desc:e.Bool}),s=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),a=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(s),description:e.Opt(e.Text),created_at:e.Opt(s)}),o=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),c=e.Record({order:e.Opt(i),owner:e.Opt(e.Principal),matcher:e.Opt(a),paginate:e.Opt(o)}),d=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),p=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:f,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),b=e.Variant({Db:e.Null,Storage:e.Null}),l=e.Record({version:e.Opt(e.Nat64)}),A=e.Record({proposal_ids:e.Vec(e.Nat)}),v=e.Record({cycles:e.Nat,destination_id:e.Principal}),F=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),C=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),O=e.Record({key:F,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,C)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),H=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),x=e.Record({allowed_callers:e.Vec(e.Principal)}),q=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),K=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),$=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),M=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),ae=e.Variant({Deny:e.Null,Allow:e.Null}),Q=e.Record({status_code:e.Nat16,location:e.Text}),ne=e.Record({iframe:e.Opt(M),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),w=e.Record({db:e.Opt($),authentication:e.Opt(q),storage:ne}),g=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),S=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),R=e.Record({clear_existing_assets:e.Opt(e.Bool)}),B=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),j=e.Variant({AssetsUpgrade:R,SegmentsDeployment:B}),Y=e.Record({status:S,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:j}),oe=e.Variant({Heap:e.Null,Stable:e.Null}),se=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),W=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),V=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:se,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(W),write:se,max_changes_per_user:e.Opt(e.Nat32)}),_=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),Z=e.Record({memory:oe,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),re=e.Variant({Callback:e.Record({token:Z,callback:e.Func([],[],[])})}),le=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(re),status_code:e.Nat16}),X=e.Record({token:e.Opt(Z),body:e.Vec(e.Nat8)}),u=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),h=e.Record({batch_id:e.Nat}),y=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,O)),items_length:e.Nat64}),P=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),E=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,g)),items_length:e.Nat64}),I=e.Record({desc:e.Bool}),D=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),T=e.Record({order:e.Opt(I),paginate:e.Opt(D)}),U=e.Record({proposal_id:e.Nat}),L=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(U,Y)),items_length:e.Nat64}),k=e.Record({include_system:e.Bool}),J=e.Record({matcher:e.Opt(k)}),te=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,V)),items_length:e.Nat64}),de=e.Record({stable:e.Nat64,heap:e.Nat64}),ge=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),Se=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:f,expires_at:e.Opt(e.Nat64)}),Fe=e.Record({controller:Se,controllers:e.Vec(e.Principal)}),_e=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),fe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),He=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),max_size:e.Opt(e.Nat),read:se,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(W),write:se,max_changes_per_user:e.Opt(e.Nat32)}),Lt=e.Record({iframe:e.Opt(M),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),Ft=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Vt=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),commit_proposal:e.Func([r],[e.Null],[]),commit_proposal_asset_upload:e.Func([t],[],[]),commit_proposal_many_assets_upload:e.Func([e.Vec(t)],[],[]),count_assets:e.Func([e.Text,c],[e.Nat64],[]),count_collection_assets:e.Func([e.Text],[e.Nat64],[]),count_collection_docs:e.Func([e.Text],[e.Nat64],[]),count_docs:e.Func([e.Text,c],[e.Nat64],[]),count_proposals:e.Func([],[e.Nat64],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([d],[e.Vec(e.Tuple(e.Principal,p))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,c],[],[]),del_filtered_docs:e.Func([e.Text,c],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,m))],[],[]),del_rule:e.Func([b,e.Text,l],[],[]),delete_proposal_assets:e.Func([A],[],[]),deposit_cycles:e.Func([v],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(O)],[]),get_auth_config:e.Func([],[e.Opt(q)],[]),get_config:e.Func([],[w],[]),get_db_config:e.Func([],[e.Opt($)],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(g)],[]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(O)))],[]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(g)))],[]),get_proposal:e.Func([e.Nat],[e.Opt(Y)],[]),get_rule:e.Func([b,e.Text],[e.Opt(V)],[]),get_storage_config:e.Func([],[ne],[]),http_request:e.Func([_],[le],[]),http_request_streaming_callback:e.Func([Z],[X],[]),init_asset_upload:e.Func([u],[h],[]),init_proposal:e.Func([j],[e.Nat,Y],[]),init_proposal_asset_upload:e.Func([u,e.Nat],[h],[]),init_proposal_many_assets_upload:e.Func([e.Vec(u),e.Nat],[e.Vec(e.Tuple(e.Text,h))],[]),list_assets:e.Func([e.Text,c],[y],[]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,p))],[]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,P))],[]),list_docs:e.Func([e.Text,c],[E],[]),list_proposals:e.Func([T],[L],[]),list_rules:e.Func([b,J],[te],[]),memory_size:e.Func([],[de],[]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([ge],[q],[]),set_controllers:e.Func([Fe],[e.Vec(e.Tuple(e.Principal,p))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([_e],[$],[]),set_doc:e.Func([e.Text,e.Text,fe],[g],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,fe))],[e.Vec(e.Tuple(e.Text,g))],[]),set_rule:e.Func([b,e.Text,He],[V],[]),set_storage_config:e.Func([Lt],[ne],[]),submit_proposal:e.Func([e.Nat],[e.Nat,Y],[]),upload_asset_chunk:e.Func([Ft],[Vt],[]),upload_proposal_asset_chunk:e.Func([Ft],[Vt],[])})};var xc=qe(Qe(),1);var oy=({satelliteId:e,container:t})=>{let{satelliteId:r}=zd({satelliteId:e}),{container:n}=Wd({container:t});if((0,xc.nonNullish)(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?zi:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},zd=({satelliteId:e})=>(0,xc.nonNullish)(e)?{satelliteId:e}:Yr.getInstance().get()??{satelliteId:void 0},Wd=({container:e})=>(0,xc.nonNullish)(e)?{container:e}:Yr.getInstance().get()??{container:void 0};var dt=({satellite:e,options:{certified:t}})=>ly({idlFactory:t?ay:sy,actorKey:`stock#${t?"update":"query"}`,...e}),uy=({idlFactory:e,...t})=>ly({idlFactory:e,actorKey:"extended#query",...t}),ly=async({satelliteId:e,container:t,...r})=>{let{satelliteId:n}=zd({satelliteId:e});(0,cy.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Wd({container:t});return await Yi.getInstance().getActor({satelliteId:n,container:i,...r})};var dy=async({collection:e,key:t,...r})=>{let{get_doc:n}=await dt(r),i=(0,vr.fromNullable)(await n(e,t));if(!(0,vr.isNullish)(i))return Qs({doc:i,key:t})},fy=async({docs:e,...t})=>{let{get_many_docs:r}=await dt(t),n=e.map(({collection:a,key:o})=>[a,o]),i=await r(n),s=[];for(let[a,o]of i){let c=(0,vr.fromNullable)(o);s.push((0,vr.nonNullish)(c)?await Qs({key:a,doc:c}):void 0)}return s},py=async({collection:e,doc:t,...r})=>{let{set_doc:n}=await dt(r),{key:i}=t,s=await $d(t),a=await n(e,i,s);return await Qs({key:i,doc:a})},hy=async({docs:e,...t})=>{let{set_many_docs:r}=await dt(t),n=[];for(let{collection:a,doc:o}of e){let{key:c}=o;n.push([a,c,await $d(o)])}let i=await r(n),s=[];for(let[a,o]of i)s.push(await Qs({key:a,doc:o}));return s},_y=async({collection:e,doc:t,...r})=>{let{del_doc:n}=await dt(r),{key:i}=t;return n(e,i,Gd(t))},yy=async({docs:e,...t})=>{let{del_many_docs:r}=await dt(t),n=e.map(({collection:i,doc:s})=>[i,s.key,Gd(s)]);await r(n)},my=async({collection:e,filter:t,...r})=>{let{del_filtered_docs:n}=await dt(r);return n(e,qn(t))},gy=async({collection:e,filter:t,...r})=>{let{list_docs:n}=await dt(r),{items:i,items_page:s,items_length:a,matches_length:o,matches_pages:c}=await n(e,qn(t)),d=[];for(let[f,p]of i){let{data:m,owner:b,description:l,version:A,...v}=p;d.push({key:f,description:(0,vr.fromNullable)(l),owner:b.toText(),data:await ry({data:m}),version:(0,vr.fromNullable)(A),...v})}return{items:d,items_length:a,items_page:(0,vr.fromNullable)(s),matches_length:o,matches_pages:(0,vr.fromNullable)(c)}},by=async({collection:e,filter:t,...r})=>{let{count_docs:n}=await dt(r);return n(e,qn(t))};var Jr={certified:!1};var wy=qe(jt(),1),xy=qe(Qe(),1);var tt=e=>(0,xy.nonNullish)(e)?e:Tc()??new wy.AnonymousIdentity;var Ty=async({satellite:e,options:t,...r})=>{let n=tt(e?.identity);return await dy({...r,satellite:{...e,identity:n},options:t??Jr})},L6=async({satellite:e,options:t,...r})=>{let n=tt(e?.identity);return await fy({...r,satellite:{...e,identity:n},options:t??Jr})},Ny=async({satellite:e,...t})=>{let r=tt(e?.identity);return await py({...t,satellite:{...e,identity:r},options:{certified:!0}})},H6=async({satellite:e,...t})=>{let r=tt(e?.identity);return await hy({...t,satellite:{...e,identity:r},options:{certified:!0}})},K6=async({satellite:e,...t})=>{let r=tt(e?.identity);return await _y({...t,satellite:{...e,identity:r},options:{certified:!0}})},$6=async({satellite:e,...t})=>{let r=tt(e?.identity);return await yy({...t,satellite:{...e,identity:r},options:{certified:!0}})},G6=async({satellite:e,filter:t,...r})=>{let n=tt(e?.identity);return await my({...r,filter:t??{},satellite:{...e,identity:n},options:{certified:!0}})},z6=async({satellite:e,options:t,filter:r,...n})=>{let i=tt(e?.identity);return await gy({...n,filter:r??{},satellite:{...e,identity:i},options:t??Jr})},W6=async({satellite:e,options:t,filter:r,...n})=>{let i=tt(e?.identity);return await by({...n,filter:r??{},satellite:{...e,identity:i},options:t??Jr})};var Oy=async e=>{let t=Tc();if((0,ea.isNullish)(t))throw new gc("No identity to initialize the user. Have you initialized Juno?");let r=t.getPrincipal().toText(),n=()=>Ty({collection:"#user",key:r}),i=await n();if((0,ea.nonNullish)(i))return i;try{return await PN({userId:r,provider:e})}catch(s){if(Kd({error:s,type:ty})){let a=await n();if((0,ea.nonNullish)(a))return a}throw s}},PN=({userId:e,...t})=>Ny({collection:"#user",doc:{key:e,data:t}});var pr,Jd=async e=>{if(pr=pr??await wc(),!(await pr?.isAuthenticated()??!1))return;let r=await Oy(e);zr.getInstance().set(r)},FN=e=>new Promise(async(t,r)=>{if((0,Yd.isNullish)(pr)){r(new yc("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=e?.provider??new fc({});await pr.login({onSuccess:async()=>{await Jd(n.id),t()},onError:i=>{if(i===Ey.ERROR_USER_INTERRUPT){r(new mc(i));return}r(new _c(i))},maxTimeToLive:e?.maxTimeToLive??H_,allowPinAuthentication:e?.allowPin??K_,...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...n.signInOptions({windowed:e?.windowed})})}),Zd=async()=>{await VN(),pr=await wc()},VN=async()=>{await pr?.logout(),pr=null,zr.getInstance().reset(),Yi.getInstance().reset(),Wi.getInstance().reset()},Tc=()=>pr?.getIdentity(),UN=async()=>(pr??await wc()).getIdentity(),CN=async()=>{let e=zr.getInstance().get();return(0,Yd.isNullish)(e)||!(await pr?.isAuthenticated()??!1)?null:pr?.getIdentity()??null};var Ry=e=>{let t=e===!0?"./workers/auth.worker.js":e,r=new Worker(t),n=async()=>{ld({message:"junoSignOutAuthTimer"}),await Zd()};return r.onmessage=async({data:i})=>{let{msg:s,data:a}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":ld({message:"junoDelegationRemainingTime",detail:a?.authRemainingTime});return}},zr.getInstance().subscribe(i=>{if((0,vy.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Ay=()=>{let e=()=>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??e():e()},Sy=()=>{let e=()=>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??e():e()};var m4=async({idlFactory:e,satellite:t})=>{let r=tt(t?.identity);return await uy({idlFactory:e,...t,identity:r})};var ra=qe(Qe(),1);var ta=qe(Qe(),1);var Ji=qe(Qe(),1);var By=async({asset:{data:e,headers:t,...r},actor:n,progress:i})=>{let{init_asset_upload:s,upload_asset_chunk:a,commit_asset_upload:o}=n,{batch_id:c}=await s(qN(r));i?.onInitiatedBatch();let{chunkIds:d}=await DN({data:e,uploadFn:a,batchId:c});i?.onUploadedFileChunks(r.fullPath),await kN({commitFn:o,batchId:c,data:e,headers:t,chunkIds:d}),i?.onCommittedBatch()};var qN=({filename:e,collection:t,token:r,fullPath:n,encoding:i,description:s})=>({collection:t,full_path:n,name:e,token:(0,Ji.toNullable)(r),encoding_type:(0,Ji.toNullable)(i),description:(0,Ji.toNullable)(s)}),MN=({batchId:e,chunkIds:t,headers:r,data:n})=>{let i=r.find(([s,a])=>s.toLowerCase()==="content-type")===void 0&&n.type!==void 0&&n.type!==""?[["Content-Type",n.type]]:void 0;return{batch_id:e,chunk_ids:t.map(({chunk_id:s})=>s),headers:[...r,...i??[]]}},kN=async({commitFn:e,...t})=>{let r=MN(t);await e(r)},DN=async({data:e,uploadFn:t,batchId:r})=>{let n=[],i=dc()?new Blob([await e.arrayBuffer()]):e,s=0n;for(let o=0;o<i.size;o+=19e5){let c=i.slice(o,o+19e5);n.push({batchId:r,chunk:c,uploadFn:t,orderId:s}),s++}let a=[];for await(let o of jN({uploadChunks:n}))a=[...a,...o];return{chunkIds:a}};async function*jN({uploadChunks:e,limit:t=12}){for(let r=0;r<e.length;r=r+t){let n=e.slice(r,r+t);yield await Promise.all(n.map(i=>LN(i)))}}var LN=async({batchId:e,chunk:t,uploadFn:r,orderId:n})=>r({batch_id:e,content:new Uint8Array(await t.arrayBuffer()),order_id:(0,Ji.toNullable)(n)});var Iy=async({asset:e,...t})=>{let r=await dt(t);await By({actor:r,asset:e})},Py=async({collection:e,filter:t,...r})=>{let{list_assets:n}=await dt(r),{items:i,items_length:s,items_page:a,matches_length:o,matches_pages:c}=await n(e,qn(t));return{items:i.map(([d,f])=>f),items_length:s,items_page:(0,ta.fromNullable)(a),matches_length:o,matches_pages:(0,ta.fromNullable)(c)}},Fy=async({collection:e,filter:t,...r})=>{let{count_assets:n}=await dt(r);return n(e,qn(t))},Vy=async({collection:e,fullPath:t,...r})=>(await dt(r)).del_asset(e,t),Uy=async({assets:e,satellite:t})=>{let{del_many_assets:r}=await dt({satellite:t,options:{certified:!0}}),n=e.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},Cy=async({collection:e,filter:t,...r})=>{let{del_filtered_assets:n}=await dt(r);return n(e,qn(t))},qy=async({collection:e,fullPath:t,...r})=>{let{get_asset:n}=await dt(r);return(0,ta.fromNullable)(await n(e,t))},My=async({assets:e,...t})=>{let{get_many_assets:r}=await dt(t),n=e.map(({collection:s,fullPath:a})=>[s,a]);return(await r(n)).map(([s,a])=>(0,ta.fromNullable)(a))};var ky=e=>btoa([...e].map(t=>String.fromCharCode(t)).join(""));var I4=e=>Dy(e),P4=e=>Dy({filename:e.data.name,...e}),Dy=async({filename:e,data:t,collection:r,headers:n=[],fullPath:i,token:s,satellite:a,encoding:o,description:c})=>{let d=tt(a?.identity),f=decodeURI(e),p=i??`/${r}/${f}`,m={...a,identity:d};return await Iy({asset:{data:t,filename:f,collection:r,token:s,headers:n,fullPath:p,encoding:o,description:c},satellite:m,options:{certified:!0}}),{downloadUrl:jy({satellite:m,assetKey:{fullPath:p,token:s}}),fullPath:p,name:f}},F4=async({collection:e,filter:t,satellite:r,options:n})=>{let i={...r,identity:tt(r?.identity)},{items:s,...a}=await Py({collection:e,filter:t??{},satellite:i,options:n??Jr}),o=s.map(({key:{full_path:c,token:d,name:f,owner:p,description:m},headers:b,encodings:l,created_at:A,updated_at:v})=>{let F=(0,ra.fromNullable)(d);return{fullPath:c,description:(0,ra.fromNullable)(m),name:f,downloadUrl:jy({satellite:i,assetKey:{fullPath:c,token:F}}),token:F,headers:b,encodings:l.reduce((C,[O,{modified:H,sha256:x,total_length:q}])=>({...C,[O]:{modified:H,sha256:ky(x),total_length:q}}),{}),owner:p.toText(),created_at:A,updated_at:v}});return{items:o,assets:o,...a}},V4=async({collection:e,filter:t,satellite:r,options:n})=>{let i={...r,identity:tt(r?.identity)};return await Fy({collection:e,satellite:i,filter:t??{},options:n??Jr})},U4=({collection:e,fullPath:t,satellite:r})=>Vy({collection:e,fullPath:t,satellite:{...r,identity:tt(r?.identity)},options:{certified:!0}}),C4=({assets:e,satellite:t})=>Uy({assets:e,satellite:{...t,identity:tt(t?.identity)},options:{certified:!0}}),q4=async({collection:e,satellite:t,filter:r})=>{let n={...t,identity:tt(t?.identity)};return await Cy({collection:e,satellite:n,filter:r??{},options:{certified:!0}})},M4=async({satellite:e,options:t,...r})=>{let n=tt(e?.identity);return await qy({...r,satellite:{...e,identity:n},options:t??Jr})},k4=async({satellite:e,options:t,...r})=>{let n=tt(e?.identity);return await My({...r,satellite:{...e,identity:n},options:t??Jr})},jy=({assetKey:{fullPath:e,token:t},satellite:r})=>{let n={...r,identity:tt(r?.identity)};return`${oy(n)}${e}${(0,ra.nonNullish)(t)?`?token=${t}`:""}`};var HN=e=>{let t=e?.satelliteId??Ay();(0,Ly.assertNonNullish)(t,"Satellite ID is not configured. Juno cannot be initialized.");let r=e?.container??Sy();return{satelliteId:t,internetIdentityId:e?.internetIdentityId,workers:e?.workers,container:r}},G4=e=>KN(e),KN=async e=>{let t=HN(e);Yr.getInstance().set(t),await Jd();let r=t.workers?.auth!==void 0?Ry(t.workers.auth):void 0;return[...r?[r]:[]]},z4=e=>zr.getInstance().subscribe(e);export{gc as InitError,fc as InternetIdentityProvider,bc as ListError,J_ as NFIDProvider,_c as SignInError,yc as SignInInitError,mc as SignInUserInterruptError,z4 as authSubscribe,V4 as countAssets,W6 as countDocs,U4 as deleteAsset,K6 as deleteDoc,q4 as deleteFilteredAssets,G6 as deleteFilteredDocs,C4 as deleteManyAssets,$6 as deleteManyDocs,jy as downloadUrl,M4 as getAsset,Ty as getDoc,CN as getIdentityOnce,k4 as getManyAssets,L6 as getManyDocs,m4 as getSatelliteExtendedActor,G4 as initJuno,KN as initSatellite,F4 as listAssets,z6 as listDocs,Ny as setDoc,H6 as setManyDocs,FN as signIn,Zd as signOut,UN as unsafeIdentity,I4 as uploadBlob,P4 as uploadFile};
58
58
  /*! Bundled license information:
59
59
 
60
60
  ieee754/index.js: