@junobuild/core-standalone 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,20 @@
1
1
  import { createRequire as topLevelCreateRequire } from 'module';
2
2
  const require = topLevelCreateRequire(import.meta.url);
3
- var nm=Object.create;var io=Object.defineProperty;var im=Object.getOwnPropertyDescriptor;var sm=Object.getOwnPropertyNames;var om=Object.getPrototypeOf,am=Object.prototype.hasOwnProperty;var ai=(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 ef=(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)io(e,r,{get:t[r],enumerable:!0})},tf=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of sm(t))!am.call(e,i)&&i!==r&&io(e,i,{get:()=>t[i],enumerable:!(n=im(t,i))||n.enumerable});return e};var We=(e,t,r)=>(r=e!=null?nm(om(e)):{},tf(t||!e||!e.__esModule?io(r,"default",{value:e,enumerable:!0}):r,e)),um=e=>tf(io({},"__esModule",{value:!0}),e);var sf=ee(so=>{"use strict";so.byteLength=dm;so.toByteArray=hm;so.fromByteArray=ym;var Or=[],tr=[],lm=typeof Uint8Array<"u"?Uint8Array:Array,Bc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(kn=0,rf=Bc.length;kn<rf;++kn)Or[kn]=Bc[kn],tr[Bc.charCodeAt(kn)]=kn;var kn,rf;tr[45]=62;tr[95]=63;function nf(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=nf(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 hm(e){var t,r=nf(e),n=r[0],i=r[1],s=new lm(fm(e,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)t=tr[e.charCodeAt(c)]<<18|tr[e.charCodeAt(c+1)]<<12|tr[e.charCodeAt(c+2)]<<6|tr[e.charCodeAt(c+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=tr[e.charCodeAt(c)]<<2|tr[e.charCodeAt(c+1)]>>4,s[o++]=t&255),i===1&&(t=tr[e.charCodeAt(c)]<<10|tr[e.charCodeAt(c+1)]<<4|tr[e.charCodeAt(c+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function pm(e){return Or[e>>18&63]+Or[e>>12&63]+Or[e>>6&63]+Or[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(pm(n));return i.join("")}function ym(e){for(var t,r=e.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(_m(e,o,o+s>a?a:o+s));return n===1?(t=e[r-1],i.push(Or[t>>2]+Or[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Or[t>>10]+Or[t>>4&63]+Or[t<<2&63]+"=")),i.join("")}});var Uc=ee(Pc=>{Pc.read=function(e,t,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,d=c>>1,f=-7,h=r?i-1:0,m=r?-1:1,b=e[t+h];for(h+=m,s=b&(1<<-f)-1,b>>=-f,f+=a;f>0;s=s*256+e[t+h],h+=m,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=n;f>0;o=o*256+e[t+h],h+=m,f-=8);if(s===0)s=1-d;else{if(s===c)return o?NaN:(b?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-d}return(b?-1:1)*o*Math.pow(2,s-n)};Pc.write=function(e,t,r,n,i,s){var o,a,c,d=s*8-i-1,f=(1<<d)-1,h=f>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:s-1,l=n?1:-1,S=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=f):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?t+=m/c:t+=m*Math.pow(2,1-h),t*c>=2&&(o++,c/=2),o+h>=f?(a=0,o=f):o+h>=1?(a=(t*c-1)*Math.pow(2,i),o=o+h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[r+b]=a&255,b+=l,a/=256,i-=8);for(o=o<<i|a,d+=i;d>0;e[r+b]=o&255,b+=l,o/=256,d-=8);e[r+b-l]|=S*128}});var xf=ee(di=>{"use strict";var Fc=sf(),ui=Uc(),of=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;di.Buffer=z;di.SlowBuffer=xm;di.INSPECT_MAX_BYTES=50;var oo=2147483647;di.kMaxLength=oo;z.TYPED_ARRAY_SUPPORT=mm();!z.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(z.prototype,"parent",{enumerable:!0,get:function(){if(z.isBuffer(this))return this.buffer}});Object.defineProperty(z.prototype,"offset",{enumerable:!0,get:function(){if(z.isBuffer(this))return this.byteOffset}});function Ir(e){if(e>oo)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,z.prototype),t}function z(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 jc(e)}return lf(e,t,r)}z.poolSize=8192;function lf(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 Mc(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 z.from(n,t,r);let i=Em(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return z.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)}z.from=function(e,t,r){return lf(e,t,r)};Object.setPrototypeOf(z.prototype,Uint8Array.prototype);Object.setPrototypeOf(z,Uint8Array);function df(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 df(e),e<=0?Ir(e):t!==void 0?typeof r=="string"?Ir(e).fill(t,r):Ir(e).fill(t):Ir(e)}z.alloc=function(e,t,r){return gm(e,t,r)};function jc(e){return df(e),Ir(e<0?0:kc(e)|0)}z.allocUnsafe=function(e){return jc(e)};z.allocUnsafeSlow=function(e){return jc(e)};function bm(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!z.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=ff(e,t)|0,n=Ir(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Cc(e){let t=e.length<0?0:kc(e.length)|0,r=Ir(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 Mc(t.buffer,t.byteOffset,t.byteLength)}return Cc(e)}function Mc(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,z.prototype),n}function Em(e){if(z.isBuffer(e)){let t=kc(e.length)|0,r=Ir(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Hc(e.length)?Ir(0):Cc(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Cc(e.data)}function kc(e){if(e>=oo)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+oo.toString(16)+" bytes");return e|0}function xm(e){return+e!=e&&(e=0),z.alloc(+e)}z.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==z.prototype};z.compare=function(t,r){if(Ar(t,Uint8Array)&&(t=z.from(t,t.offset,t.byteLength)),Ar(r,Uint8Array)&&(r=z.from(r,r.offset,r.byteLength)),!z.isBuffer(t)||!z.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,o=Math.min(n,i);s<o;++s)if(t[s]!==r[s]){n=t[s],i=r[s];break}return n<i?-1:i<n?1:0};z.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}};z.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return z.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=z.allocUnsafe(r),s=0;for(n=0;n<t.length;++n){let o=t[n];if(Ar(o,Uint8Array))s+o.length>i.length?(z.isBuffer(o)||(o=z.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(z.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function ff(e,t){if(z.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 Ef(e).length;default:if(i)return n?-1:qc(e).length;t=(""+t).toLowerCase(),i=!0}}z.byteLength=ff;function Tm(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 pf(this,t,r);case"ascii":return Pm(this,t,r);case"latin1":case"binary":return Um(this,t,r);case"base64":return Rm(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}}z.prototype._isBuffer=!0;function Vn(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}z.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)Vn(this,r,r+1);return this};z.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)Vn(this,r,r+3),Vn(this,r+1,r+2);return this};z.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)Vn(this,r,r+7),Vn(this,r+1,r+6),Vn(this,r+2,r+5),Vn(this,r+3,r+4);return this};z.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?pf(this,0,t):Tm.apply(this,arguments)};z.prototype.toLocaleString=z.prototype.toString;z.prototype.equals=function(t){if(!z.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:z.compare(this,t)===0};z.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+">"};of&&(z.prototype[of]=z.prototype.inspect);z.prototype.compare=function(t,r,n,i,s){if(Ar(t,Uint8Array)&&(t=z.from(t,t.offset,t.byteLength)),!z.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 o=s-i,a=n-r,c=Math.min(o,a),d=this.slice(i,s),f=t.slice(r,n);for(let h=0;h<c;++h)if(d[h]!==f[h]){o=d[h],a=f[h];break}return o<a?-1:a<o?1:0};function hf(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,Hc(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=z.from(t,n)),z.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,o=e.length,a=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,o/=2,a/=2,r/=2}function c(f,h){return s===1?f[h]:f.readUInt16BE(h*s)}let d;if(i){let f=-1;for(d=r;d<o;d++)if(c(e,d)===c(t,f===-1?0:d-f)){if(f===-1&&(f=d),d-f+1===a)return f*s}else f!==-1&&(d-=d-f),f=-1}else for(r+a>o&&(r=o-a),d=r;d>=0;d--){let f=!0;for(let h=0;h<a;h++)if(c(e,d+h)!==c(t,h)){f=!1;break}if(f)return d}return-1}z.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};z.prototype.indexOf=function(t,r,n){return hf(this,t,r,n,!0)};z.prototype.lastIndexOf=function(t,r,n){return hf(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 o;for(o=0;o<n;++o){let a=parseInt(t.substr(o*2,2),16);if(Hc(a))return o;e[r+o]=a}return o}function Om(e,t,r,n){return ao(qc(t,e.length-r),e,r,n)}function Am(e,t,r,n){return ao(km(t),e,r,n)}function Nm(e,t,r,n){return ao(Ef(t),e,r,n)}function Sm(e,t,r,n){return ao(Vm(t,e.length-r),e,r,n)}z.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 o=!1;for(;;)switch(i){case"hex":return vm(this,t,r,n);case"utf8":case"utf-8":return Om(this,t,r,n);case"ascii":case"latin1":case"binary":return Am(this,t,r,n);case"base64":return Nm(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Sm(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};z.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Rm(e,t,r){return t===0&&r===e.length?Fc.fromByteArray(e):Fc.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],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,d,f,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=e[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=e[i+1],d=e[i+2],(c&192)===128&&(d&192)===128&&(h=(s&15)<<12|(c&63)<<6|d&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=e[i+1],d=e[i+2],f=e[i+3],(c&192)===128&&(d&192)===128&&(f&192)===128&&(h=(s&15)<<18|(c&63)<<12|(d&63)<<6|f&63,h>65535&&h<1114112&&(o=h))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return Bm(n)}var cf=4096;function Bm(e){let t=e.length;if(t<=cf)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=cf));return r}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]&127);return n}function Um(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+=Hm[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}z.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,z.prototype),i};function ht(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")}z.prototype.readUintLE=z.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||ht(t,r,this.length);let i=this[t],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[t+o]*s;return i};z.prototype.readUintBE=z.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||ht(t,r,this.length);let i=this[t+--r],s=1;for(;r>0&&(s*=256);)i+=this[t+--r]*s;return i};z.prototype.readUint8=z.prototype.readUInt8=function(t,r){return t=t>>>0,r||ht(t,1,this.length),this[t]};z.prototype.readUint16LE=z.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||ht(t,2,this.length),this[t]|this[t+1]<<8};z.prototype.readUint16BE=z.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||ht(t,2,this.length),this[t]<<8|this[t+1]};z.prototype.readUint32LE=z.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};z.prototype.readUint32BE=z.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};z.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)&&Ii(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))});z.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)&&Ii(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)});z.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||ht(t,r,this.length);let i=this[t],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};z.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||ht(t,r,this.length);let i=r,s=1,o=this[t+--i];for(;i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};z.prototype.readInt8=function(t,r){return t=t>>>0,r||ht(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};z.prototype.readInt16LE=function(t,r){t=t>>>0,r||ht(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};z.prototype.readInt16BE=function(t,r){t=t>>>0,r||ht(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};z.prototype.readInt32LE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};z.prototype.readInt32BE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};z.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)&&Ii(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)});z.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)&&Ii(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)});z.prototype.readFloatLE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),ui.read(this,t,!0,23,4)};z.prototype.readFloatBE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),ui.read(this,t,!1,23,4)};z.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||ht(t,8,this.length),ui.read(this,t,!0,52,8)};z.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||ht(t,8,this.length),ui.read(this,t,!1,52,8)};function Ht(e,t,r,n,i,s){if(!z.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")}z.prototype.writeUintLE=z.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Ht(this,t,r,n,a,0)}let s=1,o=0;for(this[r]=t&255;++o<n&&(s*=256);)this[r+o]=t/s&255;return r+n};z.prototype.writeUintBE=z.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Ht(this,t,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=t&255;--s>=0&&(o*=256);)this[r+s]=t/o&255;return r+n};z.prototype.writeUint8=z.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||Ht(this,t,r,1,255,0),this[r]=t&255,r+1};z.prototype.writeUint16LE=z.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Ht(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};z.prototype.writeUint16BE=z.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Ht(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};z.prototype.writeUint32LE=z.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Ht(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};z.prototype.writeUint32BE=z.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Ht(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 _f(e,t,r,n,i){wf(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 o=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,r}function yf(e,t,r,n,i){wf(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 o=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=o,o=o>>8,e[r+2]=o,o=o>>8,e[r+1]=o,o=o>>8,e[r]=o,r+8}z.prototype.writeBigUInt64LE=un(function(t,r=0){return _f(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});z.prototype.writeBigUInt64BE=un(function(t,r=0){return yf(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});z.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Ht(this,t,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=t&255;++s<n&&(o*=256);)t<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(t/o>>0)-a&255;return r+n};z.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Ht(this,t,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=t&255;--s>=0&&(o*=256);)t<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(t/o>>0)-a&255;return r+n};z.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||Ht(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};z.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Ht(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};z.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Ht(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};z.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Ht(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};z.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Ht(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};z.prototype.writeBigInt64LE=un(function(t,r=0){return _f(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});z.prototype.writeBigInt64BE=un(function(t,r=0){return yf(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function mf(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 gf(e,t,r,n,i){return t=+t,r=r>>>0,i||mf(e,t,r,4,34028234663852886e22,-34028234663852886e22),ui.write(e,t,r,n,23,4),r+4}z.prototype.writeFloatLE=function(t,r,n){return gf(this,t,r,!0,n)};z.prototype.writeFloatBE=function(t,r,n){return gf(this,t,r,!1,n)};function bf(e,t,r,n,i){return t=+t,r=r>>>0,i||mf(e,t,r,8,17976931348623157e292,-17976931348623157e292),ui.write(e,t,r,n,52,8),r+8}z.prototype.writeDoubleLE=function(t,r,n){return bf(this,t,r,!0,n)};z.prototype.writeDoubleBE=function(t,r,n){return bf(this,t,r,!1,n)};z.prototype.copy=function(t,r,n,i){if(!z.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};z.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"&&!z.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let o=t.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(t=o)}}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 o=z.isBuffer(t)?t:z.from(t,i),a=o.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var ci={};function Vc(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}`}}}Vc("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Vc("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);Vc("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=uf(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=uf(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function uf(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 Mm(e,t,r){li(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&Ii(t,e.length-(r+1))}function wf(e,t,r,n,i,s){if(e>r||e<t){let o=typeof t=="bigint"?"n":"",a;throw s>3?t===0||t===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${t}${o} and <= ${r}${o}`,new ci.ERR_OUT_OF_RANGE("value",a,e)}Mm(n,i,s)}function li(e,t){if(typeof e!="number")throw new ci.ERR_INVALID_ARG_TYPE(t,"number",e)}function Ii(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 qm=/[^+/0-9A-Za-z-_]/g;function jm(e){if(e=e.split("=")[0],e=e.trim().replace(qm,""),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 o=0;o<n;++o){if(r=e.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+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 km(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Vm(e,t){let r,n,i,s=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function Ef(e){return Fc.toByteArray(jm(e))}function ao(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 Hc(e){return e!==e}var Hm=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"?Km:e}function Km(){throw new Error("BigInt not supported")}});var Kc=ee(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.ReplicaRejectCode=void 0;var $m;(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"})($m=Di.ReplicaRejectCode||(Di.ReplicaRejectCode={}))});var Tf=ee(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.decode=hi.encode=void 0;var co="abcdefghijklmnopqrstuvwxyz234567",fi=Object.create(null);for(let e=0;e<co.length;e++)fi[co[e]]=e;fi[0]=fi.o;fi[1]=fi.i;function Gm(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+=co[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?co[r>>3]:"")}hi.encode=Gm;function Ym(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0;function s(o){let a=fi[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=a<<5-t&255:r=0)}for(let o of e)s(o);return n.slice(0,i)}hi.decode=Ym});var vf=ee(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.getCrc32=void 0;var Wm=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 zm(e){let t=new Uint8Array(e),r=-1;for(let n=0;n<t.length;n++){let s=(t[n]^r)&255;r=Wm[s]^r>>>8}return(r^-1)>>>0}uo.getCrc32=zm});var Gc=ee(Nr=>{"use strict";Object.defineProperty(Nr,"__esModule",{value:!0});Nr.isBytes=Af;Nr.number=lo;Nr.bool=Of;Nr.bytes=$c;Nr.hash=Nf;Nr.exists=Sf;Nr.output=Rf;function lo(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 Af(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function $c(e,...t){if(!Af(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 Nf(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");lo(e.outputLen),lo(e.blockLen)}function Sf(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){$c(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Jm={number:lo,bool:Of,bytes:$c,hash:Nf,exists:Sf,output:Rf};Nr.default=Jm});var Bf=ee(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.crypto=void 0;var ln=ai("node:crypto");fo.crypto=ln&&typeof ln=="object"&&"webcrypto"in ln?ln.webcrypto:ln&&typeof ln=="object"&&"randomBytes"in ln?ln:void 0});var Hn=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=Zm;we.byteSwap32=tg;we.bytesToHex=ng;we.hexToBytes=ig;we.asyncLoop=og;we.utf8ToBytes=Uf;we.toBytes=ho;we.concatBytes=ag;we.checkOpts=ug;we.wrapConstructor=lg;we.wrapConstructorWithOpts=dg;we.wrapXOFConstructorWithOpts=fg;we.randomBytes=hg;var pi=Bf(),Wc=Gc();function Zm(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}var Xm=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);we.u8=Xm;var Qm=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));we.u32=Qm;var Im=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);we.createView=Im;var Dm=(e,t)=>e<<32-t|e>>>t;we.rotr=Dm;var Lm=(e,t)=>e<<t|e>>>32-t>>>0;we.rotl=Lm;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,Wc.bytes)(e);let t="";for(let r=0;r<e.length;r++)t+=rg[e[r]];return t}var Dr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Pf(e){if(e>=Dr._0&&e<=Dr._9)return e-Dr._0;if(e>=Dr._A&&e<=Dr._F)return e-(Dr._A-10);if(e>=Dr._a&&e<=Dr._f)return e-(Dr._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 o=Pf(e.charCodeAt(s)),a=Pf(e.charCodeAt(s+1));if(o===void 0||a===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]=o*16+a}return n}var sg=async()=>{};we.nextTick=sg;async function og(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 Uf(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function ho(e){return typeof e=="string"&&(e=Uf(e)),(0,Wc.bytes)(e),e}function ag(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];(0,Wc.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 Yc=class{clone(){return this._cloneInto()}};we.Hash=Yc;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(ho(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(ho(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(ho(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function hg(e=32){if(pi.crypto&&typeof pi.crypto.getRandomValues=="function")return pi.crypto.getRandomValues(new Uint8Array(e));if(pi.crypto&&typeof pi.crypto.randomBytes=="function")return pi.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}});var Zc=ee(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});dn.HashMD=dn.Maj=dn.Chi=void 0;var zc=Gc(),Li=Hn();function pg(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,d=n?0:4;e.setUint32(t+c,o,n),e.setUint32(t+d,a,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 Jc=class extends Li.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,Li.createView)(this.buffer)}update(t){(0,zc.exists)(this);let{view:r,buffer:n,blockLen:i}=this;t=(0,Li.toBytes)(t);let s=t.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=(0,Li.createView)(t);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,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:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let h=o;h<i;h++)r[h]=0;pg(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,Li.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 h=0;h<d;h++)a.setUint32(4*h,f[h],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:o,pos:a}=this;return t.length=i,t.pos=a,t.finished=s,t.destroyed=o,i%r&&t.buffer.set(n),t}};dn.HashMD=Jc});var po=ee(pn=>{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});pn.sha224=pn.sha256=pn.SHA256=void 0;var Xc=Zc(),rr=Hn(),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]),hn=new Uint32Array(64),es=class extends Xc.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:o,G:a,H:c}=this;return[t,r,n,i,s,o,a,c]}set(t,r,n,i,s,o,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(t,r){for(let h=0;h<16;h++,r+=4)hn[h]=t.getUint32(r,!1);for(let h=16;h<64;h++){let m=hn[h-15],b=hn[h-2],l=(0,rr.rotr)(m,7)^(0,rr.rotr)(m,18)^m>>>3,S=(0,rr.rotr)(b,17)^(0,rr.rotr)(b,19)^b>>>10;hn[h]=S+hn[h-7]+l+hn[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:d,H:f}=this;for(let h=0;h<64;h++){let m=(0,rr.rotr)(a,6)^(0,rr.rotr)(a,11)^(0,rr.rotr)(a,25),b=f+m+(0,Xc.Chi)(a,c,d)+mg[h]+hn[h]|0,S=((0,rr.rotr)(n,2)^(0,rr.rotr)(n,13)^(0,rr.rotr)(n,22))+(0,Xc.Maj)(n,i,s)|0;f=d,d=c,c=a,a=o+b|0,o=s,s=i,i=n,n=b+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,i,s,o,a,c,d,f)}roundClean(){hn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};pn.SHA256=es;var Qc=class extends es{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}};pn.sha256=(0,rr.wrapConstructor)(()=>new es);pn.sha224=(0,rr.wrapConstructor)(()=>new Qc)});var Ff=ee(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.sha224=void 0;var gg=po();function bg(e){return gg.sha224.create().update(new Uint8Array(e)).digest()}_o.sha224=bg});var Ft=ee(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.Principal=Sr.JSON_KEY_PRINCIPAL=void 0;var Cf=Tf(),wg=vf(),Eg=Ff();Sr.JSON_KEY_PRINCIPAL="__principal__";var xg=2,Mf=4,Tg="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)))},Og=e=>e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""),Ic=class e{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Mf]))}static managementCanister(){return this.fromHex(Tg)}static selfAuthenticating(t){let r=(0,Eg.sha224)(t);return new this(new Uint8Array([...r,xg]))}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(Sr.JSON_KEY_PRINCIPAL)){let o=JSON.parse(t);Sr.JSON_KEY_PRINCIPAL in o&&(r=o[Sr.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,Cf.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]===Mf}toUint8Array(){return this._arr}toHex(){return Og(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]),a=(0,Cf.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[Sr.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"}};Sr.Principal=Ic});var Kt=ee(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.bufFromBufLike=Ot.uint8ToBuf=Ot.bufEquals=Ot.compare=Ot.fromHex=Ot.toHex=Ot.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}Ot.concat=Ag;function Ng(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}Ot.toHex=Ng;var Sg=new RegExp(/^[0-9a-fA-F]+$/);function Rg(e){if(!Sg.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}Ot.fromHex=Rg;function qf(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}Ot.compare=qf;function Bg(e,t){return qf(e,t)===0}Ot.bufEquals=Bg;function yo(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}Ot.uint8ToBuf=yo;function jf(e){return e instanceof Uint8Array?yo(e):e instanceof ArrayBuffer?e:Array.isArray(e)?yo(new Uint8Array(e)):"buffer"in e?jf(e.buffer):yo(new Uint8Array(e))}Ot.bufFromBufLike=jf});var _i=ee(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Rr.UpdateCallRejectedError=Rr.QueryCallRejectedError=Rr.ActorCallError=Rr.AgentError=void 0;var eu=Ft(),Pg=Kc(),Ug=Kt(),mo=class e extends Error{constructor(t){super(t),this.message=t,this.name="AgentError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Rr.AgentError=mo;var ts=class e extends mo{constructor(t,r,n,i){let s=eu.Principal.from(t);super(["Call failed:",` Canister: ${s.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(o=>` "${o}": ${JSON.stringify(i[o])}`)].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)}};Rr.ActorCallError=ts;var Dc=class e extends ts{constructor(t,r,n){var i;let s=eu.Principal.from(t);super(s,r,"query",{Status:n.status,Code:(i=Pg.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)}};Rr.QueryCallRejectedError=Dc;var Lc=class e extends ts{constructor(t,r,n,i){let s=eu.Principal.from(t);super(s,r,"update",Object.assign({"Request ID":(0,Ug.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)}};Rr.UpdateCallRejectedError=Lc});var wo=ee($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.bufFromBufLike=$t.uint8ToBuf=$t.PipeArrayBuffer=$t.fromHexString=$t.toHexString=$t.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}$t.concat=Fg;function Cg(e){return new Uint8Array(e).reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}$t.toHexString=Cg;function Mg(e){var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))}$t.fromHexString=Mg;var tu=class{constructor(t,r=t?.byteLength||0){this._buffer=bo(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return bo(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}};$t.PipeArrayBuffer=tu;function go(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}$t.uint8ToBuf=go;function bo(e){return e instanceof Uint8Array?go(e):e instanceof ArrayBuffer?e:Array.isArray(e)?go(new Uint8Array(e)):"buffer"in e?bo(e.buffer):go(new Uint8Array(e))}$t.bufFromBufLike=bo});var ru=ee(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.idlLabelToId=void 0;function qg(e){let r=new TextEncoder().encode(e),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function jg(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 qg(e)}Eo.idlLabelToId=jg});var iu=ee(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.readIntLE=Ie.readUIntLE=Ie.writeIntLE=Ie.writeUIntLE=Ie.slebDecode=Ie.slebEncode=Ie.lebDecode=Ie.lebEncode=Ie.safeReadUint8=Ie.safeRead=void 0;var nu=wo();function kf(){throw new Error("unexpected end of buffer")}function Vf(e,t){return e.byteLength<t&&kf(),e.read(t)}Ie.safeRead=Vf;function xo(e){let t=e.readUint8();return t===void 0&&kf(),t}Ie.safeReadUint8=xo;function kg(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}Ie.lebEncode=kg;function Hf(e){let t=BigInt(1),r=BigInt(0),n;do n=xo(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}Ie.lebDecode=Hf;function Vg(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 o=s%BigInt(128);return Number(t?BigInt(128)-o-BigInt(1):o)}return n.buffer}Ie.slebEncode=Vg;function Hg(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if((t[r]&64)===0)return Hf(e);break}let n=new Uint8Array(Vf(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)}Ie.slebDecode=Hg;function Kg(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return Kf(e,t)}Ie.writeUIntLE=Kg;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),o=Number(e%i);for(r.write(new Uint8Array([o]));++n<t;)e<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((e/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}Ie.writeIntLE=Kf;function $f(e,t){let r=BigInt(xo(e)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(xo(e));r=r+n*s}return r}Ie.readUIntLE=$f;function $g(e,t){let r=$f(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Ie.readIntLE=$g});var Gf=ee(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0});yi.iexp2=yi.ilog2=void 0;function Gg(e){let t=BigInt(e);if(e<=0)throw new RangeError("Input must be positive");return t.toString(2).length-1}yi.ilog2=Gg;function Yg(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}yi.iexp2=Yg});var uu=ee(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.Variant=J.Record=J.Opt=J.Vec=J.Tuple=J.Principal=J.Nat64=J.Nat32=J.Nat16=J.Nat8=J.Int64=J.Int32=J.Int16=J.Int8=J.Float64=J.Float32=J.Nat=J.Int=J.Text=J.Null=J.Bool=J.Unknown=J.Reserved=J.Empty=J.decode=J.encode=J.ServiceClass=J.FuncClass=J.PrincipalClass=J.RecClass=J.VariantClass=J.TupleClass=J.RecordClass=J.OptClass=J.VecClass=J.FixedNatClass=J.FixedIntClass=J.FloatClass=J.NatClass=J.IntClass=J.TextClass=J.ReservedClass=J.NullClass=J.BoolClass=J.UnknownClass=J.EmptyClass=J.ConstructType=J.PrimitiveType=J.Type=J.Visitor=void 0;J.Service=J.Func=J.Rec=void 0;var Wg=Ft(),Ue=wo(),Br=ru(),ce=iu(),su=Gf(),To="DIDL",Yf=400;function rs(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,Ue.concat)(...this._typs);return(0,Ue.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)}},au=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,o)=>[`_${o}_`,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)}};J.Visitor=au;var mi=class{display(){return this.name}valueToString(t){return tt(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}};J.Type=mi;var Gt=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){}};J.PrimitiveType=Gt;var Ur=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)}};J.ConstructType=Ur;var vo=class extends Gt{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"}};J.EmptyClass=vo;var Oo=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"}};J.UnknownClass=Oo;var Ao=class extends Gt{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"}};J.BoolClass=Ao;var No=class extends Gt{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"}};J.NullClass=No;var gi=class extends Gt{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"}};J.ReservedClass=gi;var So=class extends Gt{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,Ue.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+'"'}};J.TextClass=So;var Ro=class extends Gt{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()}};J.IntClass=Ro;var Bo=class extends Gt{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()}};J.NatClass=Bo;var ns=class extends Gt{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()}};J.FloatClass=ns;var Lr=class extends Gt{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: ${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()}};J.FixedIntClass=Lr;var Pr=class extends Gt{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: ${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()}};J.FixedNatClass=Pr;var Po=class e extends Ur{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof Pr&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof Pr?this._type._bits:this._type instanceof Lr?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 io=Object.defineProperty;var im=Object.getOwnPropertyDescriptor;var sm=Object.getOwnPropertyNames;var om=Object.getPrototypeOf,am=Object.prototype.hasOwnProperty;var ai=(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 ef=(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)io(e,r,{get:t[r],enumerable:!0})},tf=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of sm(t))!am.call(e,i)&&i!==r&&io(e,i,{get:()=>t[i],enumerable:!(n=im(t,i))||n.enumerable});return e};var We=(e,t,r)=>(r=e!=null?nm(om(e)):{},tf(t||!e||!e.__esModule?io(r,"default",{value:e,enumerable:!0}):r,e)),um=e=>tf(io({},"__esModule",{value:!0}),e);var sf=ee(so=>{"use strict";so.byteLength=dm;so.toByteArray=hm;so.fromByteArray=ym;var Ar=[],ir=[],lm=typeof Uint8Array<"u"?Uint8Array:Array,Bc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(kn=0,rf=Bc.length;kn<rf;++kn)Ar[kn]=Bc[kn],ir[Bc.charCodeAt(kn)]=kn;var kn,rf;ir[45]=62;ir[95]=63;function nf(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=nf(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 hm(e){var t,r=nf(e),n=r[0],i=r[1],s=new lm(fm(e,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;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[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=ir[e.charCodeAt(c)]<<2|ir[e.charCodeAt(c+1)]>>4,s[o++]=t&255),i===1&&(t=ir[e.charCodeAt(c)]<<10|ir[e.charCodeAt(c+1)]<<4|ir[e.charCodeAt(c+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function pm(e){return Ar[e>>18&63]+Ar[e>>12&63]+Ar[e>>6&63]+Ar[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(pm(n));return i.join("")}function ym(e){for(var t,r=e.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(_m(e,o,o+s>a?a:o+s));return n===1?(t=e[r-1],i.push(Ar[t>>2]+Ar[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Ar[t>>10]+Ar[t>>4&63]+Ar[t<<2&63]+"=")),i.join("")}});var Uc=ee(Pc=>{Pc.read=function(e,t,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,d=c>>1,f=-7,h=r?i-1:0,m=r?-1:1,b=e[t+h];for(h+=m,s=b&(1<<-f)-1,b>>=-f,f+=a;f>0;s=s*256+e[t+h],h+=m,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=n;f>0;o=o*256+e[t+h],h+=m,f-=8);if(s===0)s=1-d;else{if(s===c)return o?NaN:(b?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-d}return(b?-1:1)*o*Math.pow(2,s-n)};Pc.write=function(e,t,r,n,i,s){var o,a,c,d=s*8-i-1,f=(1<<d)-1,h=f>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:s-1,l=n?1:-1,S=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=f):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?t+=m/c:t+=m*Math.pow(2,1-h),t*c>=2&&(o++,c/=2),o+h>=f?(a=0,o=f):o+h>=1?(a=(t*c-1)*Math.pow(2,i),o=o+h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[r+b]=a&255,b+=l,a/=256,i-=8);for(o=o<<i|a,d+=i;d>0;e[r+b]=o&255,b+=l,o/=256,d-=8);e[r+b-l]|=S*128}});var xf=ee(di=>{"use strict";var Fc=sf(),ui=Uc(),of=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;di.Buffer=W;di.SlowBuffer=xm;di.INSPECT_MAX_BYTES=50;var oo=2147483647;di.kMaxLength=oo;W.TYPED_ARRAY_SUPPORT=mm();!W.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(W.prototype,"parent",{enumerable:!0,get:function(){if(W.isBuffer(this))return this.buffer}});Object.defineProperty(W.prototype,"offset",{enumerable:!0,get:function(){if(W.isBuffer(this))return this.byteOffset}});function Ir(e){if(e>oo)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,W.prototype),t}function W(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 jc(e)}return lf(e,t,r)}W.poolSize=8192;function lf(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(Sr(e,ArrayBuffer)||e&&Sr(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Sr(e,SharedArrayBuffer)||e&&Sr(e.buffer,SharedArrayBuffer)))return Mc(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 W.from(n,t,r);let i=Em(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return W.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)}W.from=function(e,t,r){return lf(e,t,r)};Object.setPrototypeOf(W.prototype,Uint8Array.prototype);Object.setPrototypeOf(W,Uint8Array);function df(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 df(e),e<=0?Ir(e):t!==void 0?typeof r=="string"?Ir(e).fill(t,r):Ir(e).fill(t):Ir(e)}W.alloc=function(e,t,r){return gm(e,t,r)};function jc(e){return df(e),Ir(e<0?0:kc(e)|0)}W.allocUnsafe=function(e){return jc(e)};W.allocUnsafeSlow=function(e){return jc(e)};function bm(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!W.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=ff(e,t)|0,n=Ir(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Cc(e){let t=e.length<0?0:kc(e.length)|0,r=Ir(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function wm(e){if(Sr(e,Uint8Array)){let t=new Uint8Array(e);return Mc(t.buffer,t.byteOffset,t.byteLength)}return Cc(e)}function Mc(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,W.prototype),n}function Em(e){if(W.isBuffer(e)){let t=kc(e.length)|0,r=Ir(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Hc(e.length)?Ir(0):Cc(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Cc(e.data)}function kc(e){if(e>=oo)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+oo.toString(16)+" bytes");return e|0}function xm(e){return+e!=e&&(e=0),W.alloc(+e)}W.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==W.prototype};W.compare=function(t,r){if(Sr(t,Uint8Array)&&(t=W.from(t,t.offset,t.byteLength)),Sr(r,Uint8Array)&&(r=W.from(r,r.offset,r.byteLength)),!W.isBuffer(t)||!W.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,o=Math.min(n,i);s<o;++s)if(t[s]!==r[s]){n=t[s],i=r[s];break}return n<i?-1:i<n?1:0};W.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}};W.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return W.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=W.allocUnsafe(r),s=0;for(n=0;n<t.length;++n){let o=t[n];if(Sr(o,Uint8Array))s+o.length>i.length?(W.isBuffer(o)||(o=W.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(W.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function ff(e,t){if(W.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Sr(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 Ef(e).length;default:if(i)return n?-1:qc(e).length;t=(""+t).toLowerCase(),i=!0}}W.byteLength=ff;function Tm(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 pf(this,t,r);case"ascii":return Pm(this,t,r);case"latin1":case"binary":return Um(this,t,r);case"base64":return Rm(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}}W.prototype._isBuffer=!0;function Vn(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}W.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)Vn(this,r,r+1);return this};W.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)Vn(this,r,r+3),Vn(this,r+1,r+2);return this};W.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)Vn(this,r,r+7),Vn(this,r+1,r+6),Vn(this,r+2,r+5),Vn(this,r+3,r+4);return this};W.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?pf(this,0,t):Tm.apply(this,arguments)};W.prototype.toLocaleString=W.prototype.toString;W.prototype.equals=function(t){if(!W.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:W.compare(this,t)===0};W.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+">"};of&&(W.prototype[of]=W.prototype.inspect);W.prototype.compare=function(t,r,n,i,s){if(Sr(t,Uint8Array)&&(t=W.from(t,t.offset,t.byteLength)),!W.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 o=s-i,a=n-r,c=Math.min(o,a),d=this.slice(i,s),f=t.slice(r,n);for(let h=0;h<c;++h)if(d[h]!==f[h]){o=d[h],a=f[h];break}return o<a?-1:a<o?1:0};function hf(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,Hc(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=W.from(t,n)),W.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,o=e.length,a=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,o/=2,a/=2,r/=2}function c(f,h){return s===1?f[h]:f.readUInt16BE(h*s)}let d;if(i){let f=-1;for(d=r;d<o;d++)if(c(e,d)===c(t,f===-1?0:d-f)){if(f===-1&&(f=d),d-f+1===a)return f*s}else f!==-1&&(d-=d-f),f=-1}else for(r+a>o&&(r=o-a),d=r;d>=0;d--){let f=!0;for(let h=0;h<a;h++)if(c(e,d+h)!==c(t,h)){f=!1;break}if(f)return d}return-1}W.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};W.prototype.indexOf=function(t,r,n){return hf(this,t,r,n,!0)};W.prototype.lastIndexOf=function(t,r,n){return hf(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 o;for(o=0;o<n;++o){let a=parseInt(t.substr(o*2,2),16);if(Hc(a))return o;e[r+o]=a}return o}function vm(e,t,r,n){return ao(qc(t,e.length-r),e,r,n)}function Nm(e,t,r,n){return ao(km(t),e,r,n)}function Am(e,t,r,n){return ao(Ef(t),e,r,n)}function Sm(e,t,r,n){return ao(Vm(t,e.length-r),e,r,n)}W.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 o=!1;for(;;)switch(i){case"hex":return Om(this,t,r,n);case"utf8":case"utf-8":return vm(this,t,r,n);case"ascii":case"latin1":case"binary":return Nm(this,t,r,n);case"base64":return Am(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Sm(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};W.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Rm(e,t,r){return t===0&&r===e.length?Fc.fromByteArray(e):Fc.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],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,d,f,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=e[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=e[i+1],d=e[i+2],(c&192)===128&&(d&192)===128&&(h=(s&15)<<12|(c&63)<<6|d&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=e[i+1],d=e[i+2],f=e[i+3],(c&192)===128&&(d&192)===128&&(f&192)===128&&(h=(s&15)<<18|(c&63)<<12|(d&63)<<6|f&63,h>65535&&h<1114112&&(o=h))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return Bm(n)}var cf=4096;function Bm(e){let t=e.length;if(t<=cf)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=cf));return r}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]&127);return n}function Um(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+=Hm[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}W.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,W.prototype),i};function ht(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")}W.prototype.readUintLE=W.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||ht(t,r,this.length);let i=this[t],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[t+o]*s;return i};W.prototype.readUintBE=W.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||ht(t,r,this.length);let i=this[t+--r],s=1;for(;r>0&&(s*=256);)i+=this[t+--r]*s;return i};W.prototype.readUint8=W.prototype.readUInt8=function(t,r){return t=t>>>0,r||ht(t,1,this.length),this[t]};W.prototype.readUint16LE=W.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||ht(t,2,this.length),this[t]|this[t+1]<<8};W.prototype.readUint16BE=W.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||ht(t,2,this.length),this[t]<<8|this[t+1]};W.prototype.readUint32LE=W.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};W.prototype.readUint32BE=W.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};W.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)&&Ii(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))});W.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)&&Ii(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)});W.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||ht(t,r,this.length);let i=this[t],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};W.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||ht(t,r,this.length);let i=r,s=1,o=this[t+--i];for(;i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};W.prototype.readInt8=function(t,r){return t=t>>>0,r||ht(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};W.prototype.readInt16LE=function(t,r){t=t>>>0,r||ht(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};W.prototype.readInt16BE=function(t,r){t=t>>>0,r||ht(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};W.prototype.readInt32LE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};W.prototype.readInt32BE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};W.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)&&Ii(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)});W.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)&&Ii(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)});W.prototype.readFloatLE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),ui.read(this,t,!0,23,4)};W.prototype.readFloatBE=function(t,r){return t=t>>>0,r||ht(t,4,this.length),ui.read(this,t,!1,23,4)};W.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||ht(t,8,this.length),ui.read(this,t,!0,52,8)};W.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||ht(t,8,this.length),ui.read(this,t,!1,52,8)};function Gt(e,t,r,n,i,s){if(!W.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")}W.prototype.writeUintLE=W.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Gt(this,t,r,n,a,0)}let s=1,o=0;for(this[r]=t&255;++o<n&&(s*=256);)this[r+o]=t/s&255;return r+n};W.prototype.writeUintBE=W.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Gt(this,t,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=t&255;--s>=0&&(o*=256);)this[r+s]=t/o&255;return r+n};W.prototype.writeUint8=W.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||Gt(this,t,r,1,255,0),this[r]=t&255,r+1};W.prototype.writeUint16LE=W.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Gt(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};W.prototype.writeUint16BE=W.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Gt(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};W.prototype.writeUint32LE=W.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Gt(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};W.prototype.writeUint32BE=W.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Gt(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 _f(e,t,r,n,i){wf(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 o=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,r}function yf(e,t,r,n,i){wf(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 o=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=o,o=o>>8,e[r+2]=o,o=o>>8,e[r+1]=o,o=o>>8,e[r]=o,r+8}W.prototype.writeBigUInt64LE=un(function(t,r=0){return _f(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});W.prototype.writeBigUInt64BE=un(function(t,r=0){return yf(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});W.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Gt(this,t,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=t&255;++s<n&&(o*=256);)t<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(t/o>>0)-a&255;return r+n};W.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Gt(this,t,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=t&255;--s>=0&&(o*=256);)t<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(t/o>>0)-a&255;return r+n};W.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||Gt(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};W.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||Gt(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};W.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||Gt(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};W.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||Gt(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};W.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||Gt(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};W.prototype.writeBigInt64LE=un(function(t,r=0){return _f(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});W.prototype.writeBigInt64BE=un(function(t,r=0){return yf(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function mf(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 gf(e,t,r,n,i){return t=+t,r=r>>>0,i||mf(e,t,r,4,34028234663852886e22,-34028234663852886e22),ui.write(e,t,r,n,23,4),r+4}W.prototype.writeFloatLE=function(t,r,n){return gf(this,t,r,!0,n)};W.prototype.writeFloatBE=function(t,r,n){return gf(this,t,r,!1,n)};function bf(e,t,r,n,i){return t=+t,r=r>>>0,i||mf(e,t,r,8,17976931348623157e292,-17976931348623157e292),ui.write(e,t,r,n,52,8),r+8}W.prototype.writeDoubleLE=function(t,r,n){return bf(this,t,r,!0,n)};W.prototype.writeDoubleBE=function(t,r,n){return bf(this,t,r,!1,n)};W.prototype.copy=function(t,r,n,i){if(!W.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};W.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"&&!W.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let o=t.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(t=o)}}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 o=W.isBuffer(t)?t:W.from(t,i),a=o.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var ci={};function Vc(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}`}}}Vc("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Vc("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);Vc("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=uf(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=uf(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function uf(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 Mm(e,t,r){li(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&Ii(t,e.length-(r+1))}function wf(e,t,r,n,i,s){if(e>r||e<t){let o=typeof t=="bigint"?"n":"",a;throw s>3?t===0||t===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${t}${o} and <= ${r}${o}`,new ci.ERR_OUT_OF_RANGE("value",a,e)}Mm(n,i,s)}function li(e,t){if(typeof e!="number")throw new ci.ERR_INVALID_ARG_TYPE(t,"number",e)}function Ii(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 qm=/[^+/0-9A-Za-z-_]/g;function jm(e){if(e=e.split("=")[0],e=e.trim().replace(qm,""),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 o=0;o<n;++o){if(r=e.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+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 km(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Vm(e,t){let r,n,i,s=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function Ef(e){return Fc.toByteArray(jm(e))}function ao(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 Sr(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Hc(e){return e!==e}var Hm=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"?Km:e}function Km(){throw new Error("BigInt not supported")}});var Kc=ee(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.ReplicaRejectCode=void 0;var $m;(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"})($m=Di.ReplicaRejectCode||(Di.ReplicaRejectCode={}))});var Tf=ee(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.decode=hi.encode=void 0;var co="abcdefghijklmnopqrstuvwxyz234567",fi=Object.create(null);for(let e=0;e<co.length;e++)fi[co[e]]=e;fi[0]=fi.o;fi[1]=fi.i;function Gm(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+=co[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?co[r>>3]:"")}hi.encode=Gm;function Ym(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0;function s(o){let a=fi[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=a<<5-t&255:r=0)}for(let o of e)s(o);return n.slice(0,i)}hi.decode=Ym});var Of=ee(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.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}uo.getCrc32=Wm});var Gc=ee(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Rr.isBytes=Nf;Rr.number=lo;Rr.bool=vf;Rr.bytes=$c;Rr.hash=Af;Rr.exists=Sf;Rr.output=Rf;function lo(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function vf(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function Nf(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function $c(e,...t){if(!Nf(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 Af(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");lo(e.outputLen),lo(e.blockLen)}function Sf(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){$c(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Jm={number:lo,bool:vf,bytes:$c,hash:Af,exists:Sf,output:Rf};Rr.default=Jm});var Bf=ee(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.crypto=void 0;var ln=ai("node:crypto");fo.crypto=ln&&typeof ln=="object"&&"webcrypto"in ln?ln.webcrypto:ln&&typeof ln=="object"&&"randomBytes"in ln?ln:void 0});var Hn=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=Zm;we.byteSwap32=tg;we.bytesToHex=ng;we.hexToBytes=ig;we.asyncLoop=og;we.utf8ToBytes=Uf;we.toBytes=ho;we.concatBytes=ag;we.checkOpts=ug;we.wrapConstructor=lg;we.wrapConstructorWithOpts=dg;we.wrapXOFConstructorWithOpts=fg;we.randomBytes=hg;var pi=Bf(),zc=Gc();function Zm(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}var Xm=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);we.u8=Xm;var Qm=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));we.u32=Qm;var Im=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);we.createView=Im;var Dm=(e,t)=>e<<32-t|e>>>t;we.rotr=Dm;var Lm=(e,t)=>e<<t|e>>>32-t>>>0;we.rotl=Lm;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,zc.bytes)(e);let t="";for(let r=0;r<e.length;r++)t+=rg[e[r]];return t}var Dr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Pf(e){if(e>=Dr._0&&e<=Dr._9)return e-Dr._0;if(e>=Dr._A&&e<=Dr._F)return e-(Dr._A-10);if(e>=Dr._a&&e<=Dr._f)return e-(Dr._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 o=Pf(e.charCodeAt(s)),a=Pf(e.charCodeAt(s+1));if(o===void 0||a===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]=o*16+a}return n}var sg=async()=>{};we.nextTick=sg;async function og(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 Uf(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function ho(e){return typeof e=="string"&&(e=Uf(e)),(0,zc.bytes)(e),e}function ag(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];(0,zc.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 Yc=class{clone(){return this._cloneInto()}};we.Hash=Yc;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(ho(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(ho(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(ho(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function hg(e=32){if(pi.crypto&&typeof pi.crypto.getRandomValues=="function")return pi.crypto.getRandomValues(new Uint8Array(e));if(pi.crypto&&typeof pi.crypto.randomBytes=="function")return pi.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}});var Zc=ee(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});dn.HashMD=dn.Maj=dn.Chi=void 0;var Wc=Gc(),Li=Hn();function pg(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,d=n?0:4;e.setUint32(t+c,o,n),e.setUint32(t+d,a,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 Jc=class extends Li.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,Li.createView)(this.buffer)}update(t){(0,Wc.exists)(this);let{view:r,buffer:n,blockLen:i}=this;t=(0,Li.toBytes)(t);let s=t.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=(0,Li.createView)(t);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,Wc.exists)(this),(0,Wc.output)(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let h=o;h<i;h++)r[h]=0;pg(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,Li.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 h=0;h<d;h++)a.setUint32(4*h,f[h],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:o,pos:a}=this;return t.length=i,t.pos=a,t.finished=s,t.destroyed=o,i%r&&t.buffer.set(n),t}};dn.HashMD=Jc});var po=ee(pn=>{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});pn.sha224=pn.sha256=pn.SHA256=void 0;var Xc=Zc(),sr=Hn(),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]),hn=new Uint32Array(64),es=class extends Xc.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:o,G:a,H:c}=this;return[t,r,n,i,s,o,a,c]}set(t,r,n,i,s,o,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(t,r){for(let h=0;h<16;h++,r+=4)hn[h]=t.getUint32(r,!1);for(let h=16;h<64;h++){let m=hn[h-15],b=hn[h-2],l=(0,sr.rotr)(m,7)^(0,sr.rotr)(m,18)^m>>>3,S=(0,sr.rotr)(b,17)^(0,sr.rotr)(b,19)^b>>>10;hn[h]=S+hn[h-7]+l+hn[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:d,H:f}=this;for(let h=0;h<64;h++){let m=(0,sr.rotr)(a,6)^(0,sr.rotr)(a,11)^(0,sr.rotr)(a,25),b=f+m+(0,Xc.Chi)(a,c,d)+mg[h]+hn[h]|0,S=((0,sr.rotr)(n,2)^(0,sr.rotr)(n,13)^(0,sr.rotr)(n,22))+(0,Xc.Maj)(n,i,s)|0;f=d,d=c,c=a,a=o+b|0,o=s,s=i,i=n,n=b+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,i,s,o,a,c,d,f)}roundClean(){hn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};pn.SHA256=es;var Qc=class extends es{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}};pn.sha256=(0,sr.wrapConstructor)(()=>new es);pn.sha224=(0,sr.wrapConstructor)(()=>new Qc)});var Ff=ee(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.sha224=void 0;var gg=po();function bg(e){return gg.sha224.create().update(new Uint8Array(e)).digest()}_o.sha224=bg});var Mt=ee(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.Principal=Br.JSON_KEY_PRINCIPAL=void 0;var Cf=Tf(),wg=Of(),Eg=Ff();Br.JSON_KEY_PRINCIPAL="__principal__";var xg=2,Mf=4,Tg="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)))},vg=e=>e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""),Ic=class e{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Mf]))}static managementCanister(){return this.fromHex(Tg)}static selfAuthenticating(t){let r=(0,Eg.sha224)(t);return new this(new Uint8Array([...r,xg]))}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 o=JSON.parse(t);Br.JSON_KEY_PRINCIPAL in o&&(r=o[Br.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,Cf.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]===Mf}toUint8Array(){return this._arr}toHex(){return vg(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]),a=(0,Cf.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.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=Ic});var Yt=ee(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.bufFromBufLike=vt.uint8ToBuf=vt.bufEquals=vt.compare=vt.fromHex=vt.toHex=vt.concat=void 0;function Ng(...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}vt.concat=Ng;function Ag(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}vt.toHex=Ag;var Sg=new RegExp(/^[0-9a-fA-F]+$/);function Rg(e){if(!Sg.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}vt.fromHex=Rg;function qf(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}vt.compare=qf;function Bg(e,t){return qf(e,t)===0}vt.bufEquals=Bg;function yo(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}vt.uint8ToBuf=yo;function jf(e){return e instanceof Uint8Array?yo(e):e instanceof ArrayBuffer?e:Array.isArray(e)?yo(new Uint8Array(e)):"buffer"in e?jf(e.buffer):yo(new Uint8Array(e))}vt.bufFromBufLike=jf});var _i=ee(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Pr.UpdateCallRejectedError=Pr.QueryCallRejectedError=Pr.ActorCallError=Pr.AgentError=void 0;var eu=Mt(),Pg=Kc(),Ug=Yt(),mo=class e extends Error{constructor(t){super(t),this.message=t,this.name="AgentError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Pr.AgentError=mo;var ts=class e extends mo{constructor(t,r,n,i){let s=eu.Principal.from(t);super(["Call failed:",` Canister: ${s.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(o=>` "${o}": ${JSON.stringify(i[o])}`)].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)}};Pr.ActorCallError=ts;var Dc=class e extends ts{constructor(t,r,n){var i;let s=eu.Principal.from(t);super(s,r,"query",{Status:n.status,Code:(i=Pg.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)}};Pr.QueryCallRejectedError=Dc;var Lc=class e extends ts{constructor(t,r,n,i){let s=eu.Principal.from(t);super(s,r,"update",Object.assign({"Request ID":(0,Ug.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)}};Pr.UpdateCallRejectedError=Lc});var wo=ee(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.bufFromBufLike=zt.uint8ToBuf=zt.PipeArrayBuffer=zt.fromHexString=zt.toHexString=zt.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}zt.concat=Fg;function Cg(e){return new Uint8Array(e).reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}zt.toHexString=Cg;function Mg(e){var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))}zt.fromHexString=Mg;var tu=class{constructor(t,r=t?.byteLength||0){this._buffer=bo(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return bo(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}};zt.PipeArrayBuffer=tu;function go(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}zt.uint8ToBuf=go;function bo(e){return e instanceof Uint8Array?go(e):e instanceof ArrayBuffer?e:Array.isArray(e)?go(new Uint8Array(e)):"buffer"in e?bo(e.buffer):go(new Uint8Array(e))}zt.bufFromBufLike=bo});var ru=ee(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.idlLabelToId=void 0;function qg(e){let r=new TextEncoder().encode(e),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function jg(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 qg(e)}Eo.idlLabelToId=jg});var iu=ee(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.readIntLE=Ie.readUIntLE=Ie.writeIntLE=Ie.writeUIntLE=Ie.slebDecode=Ie.slebEncode=Ie.lebDecode=Ie.lebEncode=Ie.safeReadUint8=Ie.safeRead=void 0;var nu=wo();function kf(){throw new Error("unexpected end of buffer")}function Vf(e,t){return e.byteLength<t&&kf(),e.read(t)}Ie.safeRead=Vf;function xo(e){let t=e.readUint8();return t===void 0&&kf(),t}Ie.safeReadUint8=xo;function kg(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}Ie.lebEncode=kg;function Hf(e){let t=BigInt(1),r=BigInt(0),n;do n=xo(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}Ie.lebDecode=Hf;function Vg(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 o=s%BigInt(128);return Number(t?BigInt(128)-o-BigInt(1):o)}return n.buffer}Ie.slebEncode=Vg;function Hg(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if((t[r]&64)===0)return Hf(e);break}let n=new Uint8Array(Vf(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)}Ie.slebDecode=Hg;function Kg(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return Kf(e,t)}Ie.writeUIntLE=Kg;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),o=Number(e%i);for(r.write(new Uint8Array([o]));++n<t;)e<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((e/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}Ie.writeIntLE=Kf;function $f(e,t){let r=BigInt(xo(e)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(xo(e));r=r+n*s}return r}Ie.readUIntLE=$f;function $g(e,t){let r=$f(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Ie.readIntLE=$g});var Gf=ee(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0});yi.iexp2=yi.ilog2=void 0;function Gg(e){let t=BigInt(e);if(e<=0)throw new RangeError("Input must be positive");return t.toString(2).length-1}yi.ilog2=Gg;function Yg(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}yi.iexp2=Yg});var uu=ee(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.Variant=J.Record=J.Opt=J.Vec=J.Tuple=J.Principal=J.Nat64=J.Nat32=J.Nat16=J.Nat8=J.Int64=J.Int32=J.Int16=J.Int8=J.Float64=J.Float32=J.Nat=J.Int=J.Text=J.Null=J.Bool=J.Unknown=J.Reserved=J.Empty=J.decode=J.encode=J.ServiceClass=J.FuncClass=J.PrincipalClass=J.RecClass=J.VariantClass=J.TupleClass=J.RecordClass=J.OptClass=J.VecClass=J.FixedNatClass=J.FixedIntClass=J.FloatClass=J.NatClass=J.IntClass=J.TextClass=J.ReservedClass=J.NullClass=J.BoolClass=J.UnknownClass=J.EmptyClass=J.ConstructType=J.PrimitiveType=J.Type=J.Visitor=void 0;J.Service=J.Func=J.Rec=void 0;var zg=Mt(),Ue=wo(),Ur=ru(),ce=iu(),su=Gf(),To="DIDL",Yf=400;function rs(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,Ue.concat)(...this._typs);return(0,Ue.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)}},au=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,o)=>[`_${o}_`,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)}};J.Visitor=au;var mi=class{display(){return this.name}valueToString(t){return tt(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}};J.Type=mi;var Wt=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){}};J.PrimitiveType=Wt;var Cr=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)}};J.ConstructType=Cr;var Oo=class extends Wt{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"}};J.EmptyClass=Oo;var vo=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"}};J.UnknownClass=vo;var No=class extends Wt{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"}};J.BoolClass=No;var Ao=class extends Wt{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"}};J.NullClass=Ao;var gi=class extends Wt{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"}};J.ReservedClass=gi;var So=class extends Wt{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,Ue.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+'"'}};J.TextClass=So;var Ro=class extends Wt{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()}};J.IntClass=Ro;var Bo=class extends Wt{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()}};J.NatClass=Bo;var ns=class extends Wt{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()}};J.FloatClass=ns;var Lr=class extends Wt{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: ${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()}};J.FixedIntClass=Lr;var Fr=class extends Wt{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: ${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()}};J.FixedNatClass=Fr;var Po=class e extends Cr{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 Lr?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,Ue.concat)(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return(0,Ue.concat)(r,new Uint8Array(t.buffer));let n=new Ue.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,Ue.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 Pr){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 Lr){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 o=0;o<i;o++)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("; ")+"}"}};J.VecClass=Po;var bi=class e extends Ur{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: ${tt(t)}`)}encodeValue(t){let r=(0,ce.lebEncode)(t.length);if(this._blobOptimization)return(0,Ue.concat)(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return(0,Ue.concat)(r,new Uint8Array(t.buffer));let n=new Ue.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,Ue.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 Lr){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 o=0;o<i;o++)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("; ")+"}"}};J.VecClass=Po;var bi=class e extends Cr{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)}
7
7
 
8
- -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${tt(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):(0,Ue.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,Ue.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])}`}};J.OptClass=bi;var is=class e extends Ur{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,Br.idlLabelToId)(r[0])-(0,Br.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: ${tt(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):(0,Ue.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,Ue.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])}`}};J.OptClass=bi;var is=class e extends Cr{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,Ur.idlLabelToId)(r[0])-(0,Ur.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=rs(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Ue.concat)(...n)}_buildTypeTableImpl(t){this._fields.forEach(([s,o])=>o.buildTypeTable(t));let r=(0,ce.slebEncode)(-20),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Ue.concat)((0,ce.lebEncode)((0,Br.idlLabelToId)(s)),o.encodeType(t)));t.add(this,(0,Ue.concat)(r,n,(0,Ue.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,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(t,c),o++;continue}let[d,f]=this._fields[s],h=(0,Br.idlLabelToId)(this._fields[s][0]),m=(0,Br.idlLabelToId)(a);if(h===m)i[d]=f.decodeValue(t,c),s++,o++;else if(m>h)if(f instanceof bi||f instanceof gi)i[d]=[],s++;else throw new Error("Cannot find required field "+d);else c.decodeValue(t,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof bi||c instanceof gi)i[a]=[];else throw new Error("Cannot find required field "+a);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 {${rs(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}};J.RecordClass=is;var Uo=class e extends is{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: ${tt(t)}`)}encodeValue(t){let r=this._fields.map(([i])=>t[i]),n=rs(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Ue.concat)(...n)}_buildTypeTableImpl(t){this._fields.forEach(([s,o])=>o.buildTypeTable(t));let r=(0,ce.slebEncode)(-20),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Ue.concat)((0,ce.lebEncode)((0,Ur.idlLabelToId)(s)),o.encodeType(t)));t.add(this,(0,Ue.concat)(r,n,(0,Ue.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,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(t,c),o++;continue}let[d,f]=this._fields[s],h=(0,Ur.idlLabelToId)(this._fields[s][0]),m=(0,Ur.idlLabelToId)(a);if(h===m)i[d]=f.decodeValue(t,c),s++,o++;else if(m>h)if(f instanceof bi||f instanceof gi)i[d]=[],s++;else throw new Error("Cannot find required field "+d);else c.decodeValue(t,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof bi||c instanceof gi)i[a]=[];else throw new Error("Cannot find required field "+a);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 {${rs(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}};J.RecordClass=is;var Uo=class e extends is{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=rs(this._components,t,(n,i)=>n.encodeValue(i));return(0,Ue.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,o]of n._components.entries())s>=this._components.length?o.decodeValue(t,o):i.push(this._components[s].decodeValue(t,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${rs(this._components,t,(n,i)=>n.valueToString(i)).join("; ")}}`}};J.TupleClass=Uo;var Fo=class e extends Ur{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,Br.idlLabelToId)(r[0])-(0,Br.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: ${tt(t)}`)}encodeValue(t){let r=rs(this._components,t,(n,i)=>n.encodeValue(i));return(0,Ue.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,o]of n._components.entries())s>=this._components.length?o.decodeValue(t,o):i.push(this._components[s].decodeValue(t,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${rs(this._components,t,(n,i)=>n.valueToString(i)).join("; ")}}`}};J.TupleClass=Uo;var Fo=class e extends Cr{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,Ur.idlLabelToId)(r[0])-(0,Ur.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),o=i.encodeValue(t[n]);return(0,Ue.concat)(s,o)}}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,o])=>(0,Ue.concat)((0,ce.lebEncode)((0,Br.idlLabelToId)(s)),o.encodeType(t)));t.add(this,(0,Ue.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,o]=n._fields[i];for(let[a,c]of this._fields)if((0,Br.idlLabelToId)(s)===(0,Br.idlLabelToId)(a)){let d=c.decodeValue(t,o);return{[a]: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)}};J.VariantClass=Fo;var _n=class e extends Ur{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)}};J.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 Wg.Principal.fromUint8Array(new Uint8Array((0,ce.safeRead)(e,r)))}var Co=class extends Gt{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,Ue.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()}"`}};J.PrincipalClass=Co;var ss=class extends Ur{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,Ue.concat)(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=(0,ce.lebEncode)(o.byteLength);return(0,Ue.concat)(new Uint8Array([1]),s,a,o)}_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,Ue.concat)(...this.argTypes.map(d=>d.encodeType(t))),s=(0,ce.lebEncode)(this.retTypes.length),o=(0,Ue.concat)(...this.retTypes.map(d=>d.encodeType(t))),a=(0,ce.lebEncode)(this.annotations.length),c=(0,Ue.concat)(...this.annotations.map(d=>this.encodeAnnotation(d)));t.add(this,(0,Ue.concat)(r,n,i,s,o,a,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),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}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")}};J.FuncClass=ss;var Mo=class extends Ur{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,Ue.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([s,o])=>o.buildTypeTable(t));let r=(0,ce.slebEncode)(-23),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=(0,ce.lebEncode)(a.length);return(0,Ue.concat)(c,a,o.encodeType(t))});t.add(this,(0,Ue.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()}"`}};J.ServiceClass=Mo;function tt(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>Yf?t.substring(0,Yf-3)+"...":t}function zg(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(To),i=r.encode(),s=(0,ce.lebEncode)(t.length),o=(0,Ue.concat)(...e.map(c=>c.encodeType(r))),a=(0,Ue.concat)(...rs(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: ${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),o=i.encodeValue(t[n]);return(0,Ue.concat)(s,o)}}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,o])=>(0,Ue.concat)((0,ce.lebEncode)((0,Ur.idlLabelToId)(s)),o.encodeType(t)));t.add(this,(0,Ue.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,o]=n._fields[i];for(let[a,c]of this._fields)if((0,Ur.idlLabelToId)(s)===(0,Ur.idlLabelToId)(a)){let d=c.decodeValue(t,o);return{[a]: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)}};J.VariantClass=Fo;var _n=class e extends Cr{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)}};J.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 zg.Principal.fromUint8Array(new Uint8Array((0,ce.safeRead)(e,r)))}var Co=class extends Wt{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,Ue.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()}"`}};J.PrincipalClass=Co;var ss=class extends Cr{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,Ue.concat)(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=(0,ce.lebEncode)(o.byteLength);return(0,Ue.concat)(new Uint8Array([1]),s,a,o)}_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,Ue.concat)(...this.argTypes.map(d=>d.encodeType(t))),s=(0,ce.lebEncode)(this.retTypes.length),o=(0,Ue.concat)(...this.retTypes.map(d=>d.encodeType(t))),a=(0,ce.lebEncode)(this.annotations.length),c=(0,Ue.concat)(...this.annotations.map(d=>this.encodeAnnotation(d)));t.add(this,(0,Ue.concat)(r,n,i,s,o,a,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),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}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")}};J.FuncClass=ss;var Mo=class extends Cr{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,Ue.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([s,o])=>o.buildTypeTable(t));let r=(0,ce.slebEncode)(-23),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=(0,ce.lebEncode)(a.length);return(0,Ue.concat)(c,a,o.encodeType(t))});t.add(this,(0,Ue.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()}"`}};J.ServiceClass=Mo;function tt(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>Yf?t.substring(0,Yf-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(To),i=r.encode(),s=(0,ce.lebEncode)(t.length),o=(0,Ue.concat)(...e.map(c=>c.encodeType(r))),a=(0,Ue.concat)(...rs(e,t,(c,d)=>{try{c.covariant(d)}catch(f){throw new Error(f.message+`
15
15
 
16
- `)}return c.encodeValue(d)}));return(0,Ue.concat)(n,i,s,o,a)}J.encode=zg;function Jg(e,t){let r=new Ue.PipeArrayBuffer(t);if(t.byteLength<To.length)throw new Error("Message length smaller than magic number");let n=(0,ce.safeRead)(r,To.length),i=new TextDecoder().decode(n);if(i!==To)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(b){let l=[],S=Number((0,ce.lebDecode)(b));for(let q=0;q<S;q++){let v=Number((0,ce.slebDecode)(b));switch(v){case-18:case-19:{let G=Number((0,ce.slebDecode)(b));l.push([v,G]);break}case-20:case-21:{let G=[],E=Number((0,ce.lebDecode)(b)),j;for(;E--;){let Y=Number((0,ce.lebDecode)(b));if(Y>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof j=="number"&&j>=Y)throw new Error("field id collision or not sorted");j=Y;let Z=Number((0,ce.slebDecode)(b));G.push([Y,Z])}l.push([v,G]);break}case-22:{let G=[],E=Number((0,ce.lebDecode)(b));for(;E--;)G.push(Number((0,ce.slebDecode)(b)));let j=[],Y=Number((0,ce.lebDecode)(b));for(;Y--;)j.push(Number((0,ce.slebDecode)(b)));let Z=[],k=Number((0,ce.lebDecode)(b));for(;k--;)switch(Number((0,ce.lebDecode)(b))){case 1:{Z.push("query");break}case 2:{Z.push("oneway");break}case 3:{Z.push("composite_query");break}default:throw new Error("unknown annotation")}l.push([v,[G,j,Z]]);break}case-23:{let G=Number((0,ce.lebDecode)(b)),E=[];for(;G--;){let j=Number((0,ce.lebDecode)(b)),Y=new TextDecoder().decode((0,ce.safeRead)(b,j)),Z=(0,ce.slebDecode)(b);E.push([Y,Z])}l.push([v,E]);break}default:throw new Error("Illegal op_code: "+v)}}let A=[],F=Number((0,ce.lebDecode)(b));for(let q=0;q<F;q++)A.push(Number((0,ce.slebDecode)(b)));return[l,A]}let[o,a]=s(r);if(a.length<e.length)throw new Error("Wrong number of return values");let c=o.map(b=>Qf());function d(b){if(b<-24)throw new Error("future value not supported");if(b<0)switch(b){case-1:return J.Null;case-2:return J.Bool;case-3:return J.Nat;case-4:return J.Int;case-5:return J.Nat8;case-6:return J.Nat16;case-7:return J.Nat32;case-8:return J.Nat64;case-9:return J.Int8;case-10:return J.Int16;case-11:return J.Int32;case-12:return J.Int64;case-13:return J.Float32;case-14:return J.Float64;case-15:return J.Text;case-16:return J.Reserved;case-17:return J.Empty;case-24:return J.Principal;default:throw new Error("Illegal op_code: "+b)}if(b>=o.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 zf(l)}case-18:{let l=d(b[1]);return Jf(l)}case-20:{let l={};for(let[F,q]of b[1]){let v=`_${F}_`;l[v]=d(q)}let S=Zf(l),A=S.tryAsTuple();return Array.isArray(A)?Wf(...A):S}case-21:{let l={};for(let[S,A]of b[1]){let F=`_${S}_`;l[F]=d(A)}return Xf(l)}case-22:{let[l,S,A]=b[1];return If(l.map(F=>d(F)),S.map(F=>d(F)),A)}case-23:{let l={},S=b[1];for(let[A,F]of S){let q=d(F);if(q instanceof _n&&(q=q.getType()),!(q instanceof ss))throw new Error("Illegal service definition: services can only contain functions");l[A]=q}return Df(l)}default:throw new Error("Illegal op_code: "+b[0])}}o.forEach((b,l)=>{if(b[0]===-22){let S=f(b);c[l].fill(S)}}),o.forEach((b,l)=>{if(b[0]!==-22){let S=f(b);c[l].fill(S)}});let h=a.map(b=>d(b)),m=e.map((b,l)=>b.decodeValue(r,h[l]));for(let b=e.length;b<h.length;b++)h[b].decodeValue(r,h[b]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return m}J.decode=Jg;J.Empty=new vo;J.Reserved=new gi;J.Unknown=new Oo;J.Bool=new Ao;J.Null=new No;J.Text=new So;J.Int=new Ro;J.Nat=new Bo;J.Float32=new ns(32);J.Float64=new ns(64);J.Int8=new Lr(8);J.Int16=new Lr(16);J.Int32=new Lr(32);J.Int64=new Lr(64);J.Nat8=new Pr(8);J.Nat16=new Pr(16);J.Nat32=new Pr(32);J.Nat64=new Pr(64);J.Principal=new Co;function Wf(...e){return new Uo(e)}J.Tuple=Wf;function zf(e){return new Po(e)}J.Vec=zf;function Jf(e){return new bi(e)}J.Opt=Jf;function Zf(e){return new is(e)}J.Record=Zf;function Xf(e){return new Fo(e)}J.Variant=Xf;function Qf(){return new _n}J.Rec=Qf;function If(e,t,r=[]){return new ss(e,t,r)}J.Func=If;function Df(e){return new Mo(e)}J.Service=Df});var yu=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 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)}};At.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)}};At.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 o=this.form[s].parse(t);r[n]=o}),!this.form.some(n=>n.isRejected()))return r}};At.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}};At.TupleForm=fu;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 pu=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=pu;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}};At.VecForm=_u});var e0=ee(Ee=>{"use strict";var Zg=Ee&&Ee.__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]}),Xg=Ee&&Ee.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Lf=Ee&&Ee.__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)&&Zg(t,e,r);return Xg(t,e),t};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.renderValue=Ee.renderInput=Ee.Render=Ee.vecForm=Ee.optForm=Ee.variantForm=Ee.tupleForm=Ee.recordForm=Ee.inputBox=void 0;var jo=Lf(uu()),mu=Ft(),wi=Lf(yu()),Qg={parse:nb},os={render:Eu},Ig=(e,t)=>new wi.InputBox(e,Object.assign(Object.assign({},Qg),t));Ee.inputBox=Ig;var Dg=(e,t)=>new wi.RecordForm(e,Object.assign(Object.assign({},os),t));Ee.recordForm=Dg;var Lg=(e,t)=>new wi.TupleForm(e,Object.assign(Object.assign({},os),t));Ee.tupleForm=Lg;var eb=(e,t)=>new wi.VariantForm(e,Object.assign(Object.assign({},os),t));Ee.variantForm=eb;var tb=(e,t)=>new wi.OptionForm(e,Object.assign(Object.assign({},os),t));Ee.optForm=tb;var rb=(e,t)=>new wi.VecForm(e,Object.assign(Object.assign({},os),t));Ee.vecForm=rb;var qo=class extends jo.Visitor{visitType(t,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=t.display(),(0,Ee.inputBox)(t,{input:n})}visitNull(t,r){return(0,Ee.inputBox)(t,{})}visitRecord(t,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.recordForm)(r,i);return(0,Ee.inputBox)(t,{form:s})}visitTuple(t,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.tupleForm)(r,i);return(0,Ee.inputBox)(t,{form:s})}visitVariant(t,r,n){let i=document.createElement("select");for(let[a,c]of r){let d=new Option(a);i.add(d)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},o=(0,Ee.variantForm)(r,s);return(0,Ee.inputBox)(t,{form:o})}visitOpt(t,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Ee.optForm)(r,{open:i,event:"change"});return(0,Ee.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 o=(0,Ee.vecForm)(r,{open:i,event:"change",container:s});return(0,Ee.inputBox)(t,{form:o})}visitRec(t,r,n){return Eu(r)}};Ee.Render=qo;var gu=class extends jo.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 jo.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 Eu(e){return e.accept(new qo,null)}Ee.renderInput=Eu;function Kn(e,t,r){return e.accept(new wu,{input:t,value:r})}Ee.renderValue=Kn;var wu=class extends jo.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){Kn(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)),Kn(r,i.form[0],n.value[0])}}visitRecord(t,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{Kn(o,i.form[a],n.value[s])})}visitTuple(t,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{Kn(s,i.form[o],n.value[o])})}visitVariant(t,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([o,a],c)=>{if(o===s[0]){let d=i.ui.open;d.selectedIndex=c,d.dispatchEvent(new Event(i.ui.event)),Kn(a,i.form[0],s[1])}})}visitVec(t,r,n){let i=n.input.ui.form,s=n.value.length,o=i.ui.open;o.value=s,o.dispatchEvent(new Event(i.ui.event)),n.value.forEach((a,c)=>{Kn(r,i.form[c],a)})}}});var r0=ee(t0=>{"use strict";Object.defineProperty(t0,"__esModule",{value:!0})});var xi=ee(pt=>{"use strict";var n0=pt&&pt.__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=pt&&pt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ei=pt&&pt.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&n0(t,e,r)},sb=pt&&pt.__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)&&n0(t,e,r);return ib(t,e),t};Object.defineProperty(pt,"__esModule",{value:!0});pt.IDL=void 0;Ei(e0(),pt);Ei(yu(),pt);pt.IDL=sb(uu());Ei(ru(),pt);Ei(iu(),pt);Ei(wo(),pt);Ei(r0(),pt)});var as=ee((i0,ko)=>{(function(e){"use strict";var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,d=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,m=1e9;function b(E){var j,Y,Z,k=M.prototype={constructor:M,toString:null,valueOf:null},ae=new M(1),D=20,se=4,w=-7,g=21,R=-1e7,N=1e7,B=!1,H=1,X=0,ie={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},oe="0123456789abcdefghijklmnopqrstuvwxyz",W=!0;function M(u,_){var y,U,O,P,K,x,C,$,V=this;if(!(V instanceof M))return new M(u,_);if(_==null){if(u&&u._isBigNumber===!0){V.s=u.s,!u.c||u.e>N?V.c=V.e=null:u.e<R?V.c=[V.e=0]:(V.e=u.e,V.c=u.c.slice());return}if((x=typeof u=="number")&&u*0==0){if(V.s=1/u<0?(u=-u,-1):1,u===~~u){for(P=0,K=u;K>=10;K/=10,P++);P>N?V.c=V.e=null:(V.e=P,V.c=[u]);return}$=String(u)}else{if(!r.test($=String(u)))return Z(V,$,x);V.s=$.charCodeAt(0)==45?($=$.slice(1),-1):1}(P=$.indexOf("."))>-1&&($=$.replace(".","")),(K=$.search(/e/i))>0?(P<0&&(P=K),P+=+$.slice(K+1),$=$.substring(0,K)):P<0&&(P=$.length)}else{if(F(_,2,oe.length,"Base"),_==10&&W)return V=new M(u),le(V,D+V.e+1,se);if($=String(u),x=typeof u=="number"){if(u*0!=0)return Z(V,$,x,_);if(V.s=1/u<0?($=$.slice(1),-1):1,M.DEBUG&&$.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else V.s=$.charCodeAt(0)===45?($=$.slice(1),-1):1;for(y=oe.slice(0,_),P=K=0,C=$.length;K<C;K++)if(y.indexOf(U=$.charAt(K))<0){if(U=="."){if(K>P){P=C;continue}}else if(!O&&($==$.toUpperCase()&&($=$.toLowerCase())||$==$.toLowerCase()&&($=$.toUpperCase()))){O=!0,K=-1,P=0;continue}return Z(V,String(u),x,_)}x=!1,$=Y($,_,10,V.s),(P=$.indexOf("."))>-1?$=$.replace(".",""):P=$.length}for(K=0;$.charCodeAt(K)===48;K++);for(C=$.length;$.charCodeAt(--C)===48;);if($=$.slice(K,++C)){if(C-=K,x&&M.DEBUG&&C>15&&(u>d||u!==i(u)))throw Error(o+V.s*u);if((P=P-K-1)>N)V.c=V.e=null;else if(P<R)V.c=[V.e=0];else{if(V.e=P,V.c=[],K=(P+1)%c,P<0&&(K+=c),K<C){for(K&&V.c.push(+$.slice(0,K)),C-=c;K<C;)V.c.push(+$.slice(K,K+=c));K=c-($=$.slice(K)).length}else K-=C;for(;K--;$+="0");V.c.push(+$)}}else V.c=[V.e=0]}M.clone=b,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(u){var _,y;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(_="DECIMAL_PLACES")&&(y=u[_],F(y,0,m,_),D=y),u.hasOwnProperty(_="ROUNDING_MODE")&&(y=u[_],F(y,0,8,_),se=y),u.hasOwnProperty(_="EXPONENTIAL_AT")&&(y=u[_],y&&y.pop?(F(y[0],-m,0,_),F(y[1],0,m,_),w=y[0],g=y[1]):(F(y,-m,m,_),w=-(g=y<0?-y:y))),u.hasOwnProperty(_="RANGE"))if(y=u[_],y&&y.pop)F(y[0],-m,-1,_),F(y[1],1,m,_),R=y[0],N=y[1];else if(F(y,-m,m,_),y)R=-(N=y<0?-y:y);else throw Error(s+_+" cannot be zero: "+y);if(u.hasOwnProperty(_="CRYPTO"))if(y=u[_],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+_+" not true or false: "+y);if(u.hasOwnProperty(_="MODULO_MODE")&&(y=u[_],F(y,0,9,_),H=y),u.hasOwnProperty(_="POW_PRECISION")&&(y=u[_],F(y,0,m,_),X=y),u.hasOwnProperty(_="FORMAT"))if(y=u[_],typeof y=="object")ie=y;else throw Error(s+_+" not an object: "+y);if(u.hasOwnProperty(_="ALPHABET"))if(y=u[_],typeof y=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(y))W=y.slice(0,10)=="0123456789",oe=y;else throw Error(s+_+" invalid: "+y)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:D,ROUNDING_MODE:se,EXPONENTIAL_AT:[w,g],RANGE:[R,N],CRYPTO:B,MODULO_MODE:H,POW_PRECISION:X,FORMAT:ie,ALPHABET:oe}},M.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!M.DEBUG)return!0;var _,y,U=u.c,O=u.e,P=u.s;e:if({}.toString.call(U)=="[object Array]"){if((P===1||P===-1)&&O>=-m&&O<=m&&O===i(O)){if(U[0]===0){if(O===0&&U.length===1)return!0;break e}if(_=(O+1)%c,_<1&&(_+=c),String(U[0]).length==_){for(_=0;_<U.length;_++)if(y=U[_],y<0||y>=a||y!==i(y))break e;if(y!==0)return!0}}}else if(U===null&&O===null&&(P===null||P===1||P===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},M.maximum=M.max=function(){return L(arguments,-1)},M.minimum=M.min=function(){return L(arguments,1)},M.random=function(){var u=9007199254740992,_=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 U,O,P,K,x,C=0,$=[],V=new M(ae);if(y==null?y=D:F(y,0,m),K=n(y/c),B)if(crypto.getRandomValues){for(U=crypto.getRandomValues(new Uint32Array(K*=2));C<K;)x=U[C]*131072+(U[C+1]>>>11),x>=9e15?(O=crypto.getRandomValues(new Uint32Array(2)),U[C]=O[0],U[C+1]=O[1]):($.push(x%1e14),C+=2);C=K/2}else if(crypto.randomBytes){for(U=crypto.randomBytes(K*=7);C<K;)x=(U[C]&31)*281474976710656+U[C+1]*1099511627776+U[C+2]*4294967296+U[C+3]*16777216+(U[C+4]<<16)+(U[C+5]<<8)+U[C+6],x>=9e15?crypto.randomBytes(7).copy(U,C):($.push(x%1e14),C+=7);C=K/7}else throw B=!1,Error(s+"crypto unavailable");if(!B)for(;C<K;)x=_(),x<9e15&&($[C++]=x%1e14);for(K=$[--C],y%=c,K&&y&&(x=f[c-y],$[C]=i(K/x)*x);$[C]===0;$.pop(),C--);if(C<0)$=[P=0];else{for(P=-1;$[0]===0;$.splice(0,1),P-=c);for(C=1,x=$[0];x>=10;x/=10,C++);C<c&&(P-=c-C)}return V.e=P,V.c=$,V}}(),M.sum=function(){for(var u=1,_=arguments,y=new M(_[0]);u<_.length;)y=y.plus(_[u++]);return y},Y=function(){var u="0123456789";function _(y,U,O,P){for(var K,x=[0],C,$=0,V=y.length;$<V;){for(C=x.length;C--;x[C]*=U);for(x[0]+=P.indexOf(y.charAt($++)),K=0;K<x.length;K++)x[K]>O-1&&(x[K+1]==null&&(x[K+1]=0),x[K+1]+=x[K]/O|0,x[K]%=O)}return x.reverse()}return function(y,U,O,P,K){var x,C,$,V,Q,te,de,ge,Oe=y.indexOf("."),Fe=D,_e=se;for(Oe>=0&&(V=X,X=0,y=y.replace(".",""),ge=new M(U),te=ge.pow(y.length-Oe),X=V,ge.c=_(G(S(te.c),te.e,"0"),10,O,u),ge.e=ge.c.length),de=_(y,U,O,K?(x=oe,u):(x=u,oe)),$=V=de.length;de[--V]==0;de.pop());if(!de[0])return x.charAt(0);if(Oe<0?--$:(te.c=de,te.e=$,te.s=P,te=j(te,ge,Fe,_e,O),de=te.c,Q=te.r,$=te.e),C=$+Fe+1,Oe=de[C],V=O/2,Q=Q||C<0||de[C+1]!=null,Q=_e<4?(Oe!=null||Q)&&(_e==0||_e==(te.s<0?3:2)):Oe>V||Oe==V&&(_e==4||Q||_e==6&&de[C-1]&1||_e==(te.s<0?8:7)),C<1||!de[0])y=Q?G(x.charAt(1),-Fe,x.charAt(0)):x.charAt(0);else{if(de.length=C,Q)for(--O;++de[--C]>O;)de[C]=0,C||(++$,de=[1].concat(de));for(V=de.length;!de[--V];);for(Oe=0,y="";Oe<=V;y+=x.charAt(de[Oe++]));y=G(y,$,x.charAt(0))}return y}}(),j=function(){function u(U,O,P){var K,x,C,$,V=0,Q=U.length,te=O%h,de=O/h|0;for(U=U.slice();Q--;)C=U[Q]%h,$=U[Q]/h|0,K=de*C+$*te,x=te*C+K%h*h+V,V=(x/P|0)+(K/h|0)+de*$,U[Q]=x%P;return V&&(U=[V].concat(U)),U}function _(U,O,P,K){var x,C;if(P!=K)C=P>K?1:-1;else for(x=C=0;x<P;x++)if(U[x]!=O[x]){C=U[x]>O[x]?1:-1;break}return C}function y(U,O,P,K){for(var x=0;P--;)U[P]-=x,x=U[P]<O[P]?1:0,U[P]=x*K+U[P]-O[P];for(;!U[0]&&U.length>1;U.splice(0,1));}return function(U,O,P,K,x){var C,$,V,Q,te,de,ge,Oe,Fe,_e,fe,Qe,vr,Xr,Qr,Vt,Be,vt=U.s==O.s?1:-1,ot=U.c,$e=O.c;if(!ot||!ot[0]||!$e||!$e[0])return new M(!U.s||!O.s||(ot?$e&&ot[0]==$e[0]:!$e)?NaN:ot&&ot[0]==0||!$e?vt*0:vt/0);for(Oe=new M(vt),Fe=Oe.c=[],$=U.e-O.e,vt=P+$+1,x||(x=a,$=l(U.e/c)-l(O.e/c),vt=vt/c|0),V=0;$e[V]==(ot[V]||0);V++);if($e[V]>(ot[V]||0)&&$--,vt<0)Fe.push(1),Q=!0;else{for(Xr=ot.length,Vt=$e.length,V=0,vt+=2,te=i(x/($e[0]+1)),te>1&&($e=u($e,te,x),ot=u(ot,te,x),Vt=$e.length,Xr=ot.length),vr=Vt,_e=ot.slice(0,Vt),fe=_e.length;fe<Vt;_e[fe++]=0);Be=$e.slice(),Be=[0].concat(Be),Qr=$e[0],$e[1]>=x/2&&Qr++;do{if(te=0,C=_($e,_e,Vt,fe),C<0){if(Qe=_e[0],Vt!=fe&&(Qe=Qe*x+(_e[1]||0)),te=i(Qe/Qr),te>1)for(te>=x&&(te=x-1),de=u($e,te,x),ge=de.length,fe=_e.length;_(de,_e,ge,fe)==1;)te--,y(de,Vt<ge?Be:$e,ge,x),ge=de.length,C=1;else te==0&&(C=te=1),de=$e.slice(),ge=de.length;if(ge<fe&&(de=[0].concat(de)),y(_e,de,fe,x),fe=_e.length,C==-1)for(;_($e,_e,Vt,fe)<1;)te++,y(_e,Vt<fe?Be:$e,fe,x),fe=_e.length}else C===0&&(te++,_e=[0]);Fe[V++]=te,_e[0]?_e[fe++]=ot[vr]||0:(_e=[ot[vr]],fe=1)}while((vr++<Xr||_e[0]!=null)&&vt--);Q=_e[0]!=null,Fe[0]||Fe.splice(0,1)}if(x==a){for(V=1,vt=Fe[0];vt>=10;vt/=10,V++);le(Oe,P+(Oe.e=V+$*c-1)+1,K,Q)}else Oe.e=$,Oe.r=+Q;return Oe}}();function p(u,_,y,U){var O,P,K,x,C;if(y==null?y=se:F(y,0,8),!u.c)return u.toString();if(O=u.c[0],K=u.e,_==null)C=S(u.c),C=U==1||U==2&&(K<=w||K>=g)?v(C,K):G(C,K,"0");else if(u=le(new M(u),_,y),P=u.e,C=S(u.c),x=C.length,U==1||U==2&&(_<=P||P<=w)){for(;x<_;C+="0",x++);C=v(C,P)}else if(_-=K,C=G(C,P,"0"),P+1>x){if(--_>0)for(C+=".";_--;C+="0");}else if(_+=P-x,_>0)for(P+1==x&&(C+=".");_--;C+="0");return u.s<0&&O?"-"+C:C}function L(u,_){for(var y,U,O=1,P=new M(u[0]);O<u.length;O++)U=new M(u[O]),(!U.s||(y=A(P,U))===_||y===0&&P.s===_)&&(P=U);return P}function re(u,_,y){for(var U=1,O=_.length;!_[--O];_.pop());for(O=_[0];O>=10;O/=10,U++);return(y=U+y*c-1)>N?u.c=u.e=null:y<R?u.c=[u.e=0]:(u.e=y,u.c=_),u}Z=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,_=/^([^.]+)\.$/,y=/^\.([^.]+)$/,U=/^-?(Infinity|NaN)$/,O=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(P,K,x,C){var $,V=x?K:K.replace(O,"");if(U.test(V))P.s=isNaN(V)?null:V<0?-1:1;else{if(!x&&(V=V.replace(u,function(Q,te,de){return $=(de=de.toLowerCase())=="x"?16:de=="b"?2:8,!C||C==$?te:Q}),C&&($=C,V=V.replace(_,"$1").replace(y,"0.$1")),K!=V))return new M(V,$);if(M.DEBUG)throw Error(s+"Not a"+(C?" base "+C:"")+" number: "+K);P.s=null}P.c=P.e=null}}();function le(u,_,y,U){var O,P,K,x,C,$,V,Q=u.c,te=f;if(Q){e:{for(O=1,x=Q[0];x>=10;x/=10,O++);if(P=_-O,P<0)P+=c,K=_,C=Q[$=0],V=i(C/te[O-K-1]%10);else if($=n((P+1)/c),$>=Q.length)if(U){for(;Q.length<=$;Q.push(0));C=V=0,O=1,P%=c,K=P-c+1}else break e;else{for(C=x=Q[$],O=1;x>=10;x/=10,O++);P%=c,K=P-c+O,V=K<0?0:i(C/te[O-K-1]%10)}if(U=U||_<0||Q[$+1]!=null||(K<0?C:C%te[O-K-1]),U=y<4?(V||U)&&(y==0||y==(u.s<0?3:2)):V>5||V==5&&(y==4||U||y==6&&(P>0?K>0?C/te[O-K]:0:Q[$-1])%10&1||y==(u.s<0?8:7)),_<1||!Q[0])return Q.length=0,U?(_-=u.e+1,Q[0]=te[(c-_%c)%c],u.e=-_||0):Q[0]=u.e=0,u;if(P==0?(Q.length=$,x=1,$--):(Q.length=$+1,x=te[c-P],Q[$]=K>0?i(C/te[O-K]%te[K])*x:0),U)for(;;)if($==0){for(P=1,K=Q[0];K>=10;K/=10,P++);for(K=Q[0]+=x,x=1;K>=10;K/=10,x++);P!=x&&(u.e++,Q[0]==a&&(Q[0]=1));break}else{if(Q[$]+=x,Q[$]!=a)break;Q[$--]=0,x=1}for(P=Q.length;Q[--P]===0;Q.pop());}u.e>N?u.c=u.e=null:u.e<R&&(u.c=[u.e=0])}return u}function I(u){var _,y=u.e;return y===null?u.toString():(_=S(u.c),_=y<=w||y>=g?v(_,y):G(_,y,"0"),u.s<0?"-"+_:_)}return k.absoluteValue=k.abs=function(){var u=new M(this);return u.s<0&&(u.s=1),u},k.comparedTo=function(u,_){return A(this,new M(u,_))},k.decimalPlaces=k.dp=function(u,_){var y,U,O,P=this;if(u!=null)return F(u,0,m),_==null?_=se:F(_,0,8),le(new M(P),u+P.e+1,_);if(!(y=P.c))return null;if(U=((O=y.length-1)-l(this.e/c))*c,O=y[O])for(;O%10==0;O/=10,U--);return U<0&&(U=0),U},k.dividedBy=k.div=function(u,_){return j(this,new M(u,_),D,se)},k.dividedToIntegerBy=k.idiv=function(u,_){return j(this,new M(u,_),0,1)},k.exponentiatedBy=k.pow=function(u,_){var y,U,O,P,K,x,C,$,V,Q=this;if(u=new M(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+I(u));if(_!=null&&(_=new M(_)),x=u.e>14,!Q.c||!Q.c[0]||Q.c[0]==1&&!Q.e&&Q.c.length==1||!u.c||!u.c[0])return V=new M(Math.pow(+I(Q),x?u.s*(2-q(u)):+I(u))),_?V.mod(_):V;if(C=u.s<0,_){if(_.c?!_.c[0]:!_.s)return new M(NaN);U=!C&&Q.isInteger()&&_.isInteger(),U&&(Q=Q.mod(_))}else{if(u.e>9&&(Q.e>0||Q.e<-1||(Q.e==0?Q.c[0]>1||x&&Q.c[1]>=24e7:Q.c[0]<8e13||x&&Q.c[0]<=9999975e7)))return P=Q.s<0&&q(u)?-0:0,Q.e>-1&&(P=1/P),new M(C?1/P:P);X&&(P=n(X/c+2))}for(x?(y=new M(.5),C&&(u.s=1),$=q(u)):(O=Math.abs(+I(u)),$=O%2),V=new M(ae);;){if($){if(V=V.times(Q),!V.c)break;P?V.c.length>P&&(V.c.length=P):U&&(V=V.mod(_))}if(O){if(O=i(O/2),O===0)break;$=O%2}else if(u=u.times(y),le(u,u.e+1,1),u.e>14)$=q(u);else{if(O=+I(u),O===0)break;$=O%2}Q=Q.times(Q),P?Q.c&&Q.c.length>P&&(Q.c.length=P):U&&(Q=Q.mod(_))}return U?V:(C&&(V=ae.div(V)),_?V.mod(_):P?le(V,X,se,K):V)},k.integerValue=function(u){var _=new M(this);return u==null?u=se:F(u,0,8),le(_,_.e+1,u)},k.isEqualTo=k.eq=function(u,_){return A(this,new M(u,_))===0},k.isFinite=function(){return!!this.c},k.isGreaterThan=k.gt=function(u,_){return A(this,new M(u,_))>0},k.isGreaterThanOrEqualTo=k.gte=function(u,_){return(_=A(this,new M(u,_)))===1||_===0},k.isInteger=function(){return!!this.c&&l(this.e/c)>this.c.length-2},k.isLessThan=k.lt=function(u,_){return A(this,new M(u,_))<0},k.isLessThanOrEqualTo=k.lte=function(u,_){return(_=A(this,new M(u,_)))===-1||_===0},k.isNaN=function(){return!this.s},k.isNegative=function(){return this.s<0},k.isPositive=function(){return this.s>0},k.isZero=function(){return!!this.c&&this.c[0]==0},k.minus=function(u,_){var y,U,O,P,K=this,x=K.s;if(u=new M(u,_),_=u.s,!x||!_)return new M(NaN);if(x!=_)return u.s=-_,K.plus(u);var C=K.e/c,$=u.e/c,V=K.c,Q=u.c;if(!C||!$){if(!V||!Q)return V?(u.s=-_,u):new M(Q?K:NaN);if(!V[0]||!Q[0])return Q[0]?(u.s=-_,u):new M(V[0]?K:se==3?-0:0)}if(C=l(C),$=l($),V=V.slice(),x=C-$){for((P=x<0)?(x=-x,O=V):($=C,O=Q),O.reverse(),_=x;_--;O.push(0));O.reverse()}else for(U=(P=(x=V.length)<(_=Q.length))?x:_,x=_=0;_<U;_++)if(V[_]!=Q[_]){P=V[_]<Q[_];break}if(P&&(O=V,V=Q,Q=O,u.s=-u.s),_=(U=Q.length)-(y=V.length),_>0)for(;_--;V[y++]=0);for(_=a-1;U>x;){if(V[--U]<Q[U]){for(y=U;y&&!V[--y];V[y]=_);--V[y],V[U]+=a}V[U]-=Q[U]}for(;V[0]==0;V.splice(0,1),--$);return V[0]?re(u,V,$):(u.s=se==3?-1:1,u.c=[u.e=0],u)},k.modulo=k.mod=function(u,_){var y,U,O=this;return u=new M(u,_),!O.c||!u.s||u.c&&!u.c[0]?new M(NaN):!u.c||O.c&&!O.c[0]?new M(O):(H==9?(U=u.s,u.s=1,y=j(O,u,0,3),u.s=U,y.s*=U):y=j(O,u,0,H),u=O.minus(y.times(u)),!u.c[0]&&H==1&&(u.s=O.s),u)},k.multipliedBy=k.times=function(u,_){var y,U,O,P,K,x,C,$,V,Q,te,de,ge,Oe,Fe,_e=this,fe=_e.c,Qe=(u=new M(u,_)).c;if(!fe||!Qe||!fe[0]||!Qe[0])return!_e.s||!u.s||fe&&!fe[0]&&!Qe||Qe&&!Qe[0]&&!fe?u.c=u.e=u.s=null:(u.s*=_e.s,!fe||!Qe?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(U=l(_e.e/c)+l(u.e/c),u.s*=_e.s,C=fe.length,Q=Qe.length,C<Q&&(ge=fe,fe=Qe,Qe=ge,O=C,C=Q,Q=O),O=C+Q,ge=[];O--;ge.push(0));for(Oe=a,Fe=h,O=Q;--O>=0;){for(y=0,te=Qe[O]%Fe,de=Qe[O]/Fe|0,K=C,P=O+K;P>O;)$=fe[--K]%Fe,V=fe[K]/Fe|0,x=de*$+V*te,$=te*$+x%Fe*Fe+ge[P]+y,y=($/Oe|0)+(x/Fe|0)+de*V,ge[P--]=$%Oe;ge[P]=y}return y?++U:ge.splice(0,1),re(u,ge,U)},k.negated=function(){var u=new M(this);return u.s=-u.s||null,u},k.plus=function(u,_){var y,U=this,O=U.s;if(u=new M(u,_),_=u.s,!O||!_)return new M(NaN);if(O!=_)return u.s=-_,U.minus(u);var P=U.e/c,K=u.e/c,x=U.c,C=u.c;if(!P||!K){if(!x||!C)return new M(O/0);if(!x[0]||!C[0])return C[0]?u:new M(x[0]?U:O*0)}if(P=l(P),K=l(K),x=x.slice(),O=P-K){for(O>0?(K=P,y=C):(O=-O,y=x),y.reverse();O--;y.push(0));y.reverse()}for(O=x.length,_=C.length,O-_<0&&(y=C,C=x,x=y,_=O),O=0;_;)O=(x[--_]=x[_]+C[_]+O)/a|0,x[_]=a===x[_]?0:x[_]%a;return O&&(x=[O].concat(x),++K),re(u,x,K)},k.precision=k.sd=function(u,_){var y,U,O,P=this;if(u!=null&&u!==!!u)return F(u,1,m),_==null?_=se:F(_,0,8),le(new M(P),u,_);if(!(y=P.c))return null;if(O=y.length-1,U=O*c+1,O=y[O]){for(;O%10==0;O/=10,U--);for(O=y[0];O>=10;O/=10,U++);}return u&&P.e+1>U&&(U=P.e+1),U},k.shiftedBy=function(u){return F(u,-d,d),this.times("1e"+u)},k.squareRoot=k.sqrt=function(){var u,_,y,U,O,P=this,K=P.c,x=P.s,C=P.e,$=D+4,V=new M("0.5");if(x!==1||!K||!K[0])return new M(!x||x<0&&(!K||K[0])?NaN:K?P:1/0);if(x=Math.sqrt(+I(P)),x==0||x==1/0?(_=S(K),(_.length+C)%2==0&&(_+="0"),x=Math.sqrt(+_),C=l((C+1)/2)-(C<0||C%2),x==1/0?_="5e"+C:(_=x.toExponential(),_=_.slice(0,_.indexOf("e")+1)+C),y=new M(_)):y=new M(x+""),y.c[0]){for(C=y.e,x=C+$,x<3&&(x=0);;)if(O=y,y=V.times(O.plus(j(P,O,$,1))),S(O.c).slice(0,x)===(_=S(y.c)).slice(0,x))if(y.e<C&&--x,_=_.slice(x-3,x+1),_=="9999"||!U&&_=="4999"){if(!U&&(le(O,O.e+D+2,0),O.times(O).eq(P))){y=O;break}$+=4,x+=4,U=1}else{(!+_||!+_.slice(1)&&_.charAt(0)=="5")&&(le(y,y.e+D+2,1),u=!y.times(y).eq(P));break}}return le(y,y.e+D+1,se,u)},k.toExponential=function(u,_){return u!=null&&(F(u,0,m),u++),p(this,u,_,1)},k.toFixed=function(u,_){return u!=null&&(F(u,0,m),u=u+this.e+1),p(this,u,_)},k.toFormat=function(u,_,y){var U,O=this;if(y==null)u!=null&&_&&typeof _=="object"?(y=_,_=null):u&&typeof u=="object"?(y=u,u=_=null):y=ie;else if(typeof y!="object")throw Error(s+"Argument not an object: "+y);if(U=O.toFixed(u,_),O.c){var P,K=U.split("."),x=+y.groupSize,C=+y.secondaryGroupSize,$=y.groupSeparator||"",V=K[0],Q=K[1],te=O.s<0,de=te?V.slice(1):V,ge=de.length;if(C&&(P=x,x=C,C=P,ge-=P),x>0&&ge>0){for(P=ge%x||x,V=de.substr(0,P);P<ge;P+=x)V+=$+de.substr(P,x);C>0&&(V+=$+de.slice(P)),te&&(V="-"+V)}U=Q?V+(y.decimalSeparator||"")+((C=+y.fractionGroupSize)?Q.replace(new RegExp("\\d{"+C+"}\\B","g"),"$&"+(y.fractionGroupSeparator||"")):Q):V}return(y.prefix||"")+U+(y.suffix||"")},k.toFraction=function(u){var _,y,U,O,P,K,x,C,$,V,Q,te,de=this,ge=de.c;if(u!=null&&(x=new M(u),!x.isInteger()&&(x.c||x.s!==1)||x.lt(ae)))throw Error(s+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+I(x));if(!ge)return new M(de);for(_=new M(ae),$=y=new M(ae),U=C=new M(ae),te=S(ge),P=_.e=te.length-de.e-1,_.c[0]=f[(K=P%c)<0?c+K:K],u=!u||x.comparedTo(_)>0?P>0?_:$:x,K=N,N=1/0,x=new M(te),C.c[0]=0;V=j(x,_,0,1),O=y.plus(V.times(U)),O.comparedTo(u)!=1;)y=U,U=O,$=C.plus(V.times(O=$)),C=O,_=x.minus(V.times(O=_)),x=O;return O=j(u.minus(y),U,0,1),C=C.plus(O.times($)),y=y.plus(O.times(U)),C.s=$.s=de.s,P=P*2,Q=j($,U,P,se).minus(de).abs().comparedTo(j(C,y,P,se).minus(de).abs())<1?[$,U]:[C,y],N=K,Q},k.toNumber=function(){return+I(this)},k.toPrecision=function(u,_){return u!=null&&F(u,1,m),p(this,u,_,2)},k.toString=function(u){var _,y=this,U=y.s,O=y.e;return O===null?U?(_="Infinity",U<0&&(_="-"+_)):_="NaN":(u==null?_=O<=w||O>=g?v(S(y.c),O):G(S(y.c),O,"0"):u===10&&W?(y=le(new M(y),D+O+1,se),_=G(S(y.c),y.e,"0")):(F(u,2,oe.length,"Base"),_=Y(G(S(y.c),O,"0"),10,u,U,!0)),U<0&&y.c[0]&&(_="-"+_)),_},k.valueOf=k.toJSON=function(){return I(this)},k._isBigNumber=!0,E!=null&&M.set(E),M}function l(E){var j=E|0;return E>0||E===j?j:j-1}function S(E){for(var j,Y,Z=1,k=E.length,ae=E[0]+"";Z<k;){for(j=E[Z++]+"",Y=c-j.length;Y--;j="0"+j);ae+=j}for(k=ae.length;ae.charCodeAt(--k)===48;);return ae.slice(0,k+1||1)}function A(E,j){var Y,Z,k=E.c,ae=j.c,D=E.s,se=j.s,w=E.e,g=j.e;if(!D||!se)return null;if(Y=k&&!k[0],Z=ae&&!ae[0],Y||Z)return Y?Z?0:-se:D;if(D!=se)return D;if(Y=D<0,Z=w==g,!k||!ae)return Z?0:!k^Y?1:-1;if(!Z)return w>g^Y?1:-1;for(se=(w=k.length)<(g=ae.length)?w:g,D=0;D<se;D++)if(k[D]!=ae[D])return k[D]>ae[D]^Y?1:-1;return w==g?0:w>g^Y?1:-1}function F(E,j,Y,Z){if(E<j||E>Y||E!==i(E))throw Error(s+(Z||"Argument")+(typeof E=="number"?E<j||E>Y?" out of range: ":" not an integer: ":" not a primitive number: ")+String(E))}function q(E){var j=E.c.length-1;return l(E.e/c)==j&&E.c[j]%2!=0}function v(E,j){return(E.length>1?E.charAt(0)+"."+E.slice(1):E)+(j<0?"e":"e+")+j}function G(E,j,Y){var Z,k;if(j<0){for(k=Y+".";++j;k+=Y);E=k+E}else if(Z=E.length,++j>Z){for(k=Y,j-=Z;--j;k+=Y);E+=k}else j<Z&&(E=E.slice(0,j)+"."+E.slice(j));return E}t=b(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof ko<"u"&&ko.exports?ko.exports=t:(e||(e=typeof self<"u"&&self?self:window),e.BigNumber=t)})(i0)});var o0=ee((b8,s0)=>{s0.exports=function(t,r,n){var i=new t.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,d=r.pushInt64Neg,f=r.pushFloat,h=r.pushFloatSingle,m=r.pushFloatDouble,b=r.pushTrue,l=r.pushFalse,S=r.pushUndefined,A=r.pushNull,F=r.pushInfinity,q=r.pushInfinityNeg,v=r.pushNaN,G=r.pushNaNNeg,E=r.pushArrayStart,j=r.pushArrayStartFixed,Y=r.pushArrayStartFixed32,Z=r.pushArrayStartFixed64,k=r.pushObjectStart,ae=r.pushObjectStartFixed,D=r.pushObjectStartFixed32,se=r.pushObjectStartFixed64,w=r.pushByteString,g=r.pushByteStringStart,R=r.pushUtf8String,N=r.pushUtf8StringStart,B=r.pushSimpleUnassigned,H=r.pushTagStart,X=r.pushTagStart4,ie=r.pushTagStart8,oe=r.pushTagUnassigned,W=r.pushBreak,M=t.Math.pow,p=0,L=0,re=0;function le(T){for(T=T|0,p=0,L=T;(p|0)<(L|0)&&(re=rm[i[p]&255](i[p]|0)|0,!((re|0)>0)););return re|0}function I(T){return T=T|0,((p|0)+(T|0)|0)<(L|0)?0:1}function u(T){return T=T|0,i[T|0]<<8|i[T+1|0]|0}function _(T){return T=T|0,i[T|0]<<24|i[T+1|0]<<16|i[T+2|0]<<8|i[T+3|0]|0}function y(T){return T=T|0,s(T|0),p=p+1|0,0}function U(T){return T=T|0,I(1)|0?1:(s(i[p+1|0]|0),p=p+2|0,0)}function O(T){return T=T|0,I(2)|0?1:(s(u(p+1|0)|0),p=p+3|0,0)}function P(T){return T=T|0,I(4)|0?1:(o(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function K(T){return T=T|0,I(8)|0?1:(c(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function x(T){return T=T|0,s(-1-(T-32|0)|0),p=p+1|0,0}function C(T){return T=T|0,I(1)|0?1:(s(-1-(i[p+1|0]|0)|0),p=p+2|0,0)}function $(T){T=T|0;var Ae=0;return I(2)|0?1:(Ae=u(p+1|0)|0,s(-1-(Ae|0)|0),p=p+3|0,0)}function V(T){return T=T|0,I(4)|0?1:(a(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function Q(T){return T=T|0,I(8)|0?1:(d(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function te(T){T=T|0;var Ae=0,Re=0,xe=0;return xe=T-64|0,I(xe|0)|0?1:(Ae=p+1|0,Re=(p+1|0)+(xe|0)|0,w(Ae|0,Re|0),p=Re|0,0)}function de(T){T=T|0;var Ae=0,Re=0,xe=0;return I(1)|0||(xe=i[p+1|0]|0,Ae=p+2|0,Re=(p+2|0)+(xe|0)|0,I(xe+1|0)|0)?1:(w(Ae|0,Re|0),p=Re|0,0)}function ge(T){T=T|0;var Ae=0,Re=0,xe=0;return I(2)|0||(xe=u(p+1|0)|0,Ae=p+3|0,Re=(p+3|0)+(xe|0)|0,I(xe+2|0)|0)?1:(w(Ae|0,Re|0),p=Re|0,0)}function Oe(T){T=T|0;var Ae=0,Re=0,xe=0;return I(4)|0||(xe=_(p+1|0)|0,Ae=p+5|0,Re=(p+5|0)+(xe|0)|0,I(xe+4|0)|0)?1:(w(Ae|0,Re|0),p=Re|0,0)}function Fe(T){return T=T|0,1}function _e(T){return T=T|0,g(),p=p+1|0,0}function fe(T){T=T|0;var Ae=0,Re=0,xe=0;return xe=T-96|0,I(xe|0)|0?1:(Ae=p+1|0,Re=(p+1|0)+(xe|0)|0,R(Ae|0,Re|0),p=Re|0,0)}function Qe(T){T=T|0;var Ae=0,Re=0,xe=0;return I(1)|0||(xe=i[p+1|0]|0,Ae=p+2|0,Re=(p+2|0)+(xe|0)|0,I(xe+1|0)|0)?1:(R(Ae|0,Re|0),p=Re|0,0)}function vr(T){T=T|0;var Ae=0,Re=0,xe=0;return I(2)|0||(xe=u(p+1|0)|0,Ae=p+3|0,Re=(p+3|0)+(xe|0)|0,I(xe+2|0)|0)?1:(R(Ae|0,Re|0),p=Re|0,0)}function Xr(T){T=T|0;var Ae=0,Re=0,xe=0;return I(4)|0||(xe=_(p+1|0)|0,Ae=p+5|0,Re=(p+5|0)+(xe|0)|0,I(xe+4|0)|0)?1:(R(Ae|0,Re|0),p=Re|0,0)}function Qr(T){return T=T|0,1}function Vt(T){return T=T|0,N(),p=p+1|0,0}function Be(T){return T=T|0,j(T-128|0),p=p+1|0,0}function vt(T){return T=T|0,I(1)|0?1:(j(i[p+1|0]|0),p=p+2|0,0)}function ot(T){return T=T|0,I(2)|0?1:(j(u(p+1|0)|0),p=p+3|0,0)}function $e(T){return T=T|0,I(4)|0?1:(Y(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function Tc(T){return T=T|0,I(8)|0?1:(Z(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function vc(T){return T=T|0,E(),p=p+1|0,0}function Ge(T){T=T|0;var Ae=0;return Ae=T-160|0,I(Ae|0)|0?1:(ae(Ae|0),p=p+1|0,0)}function Oc(T){return T=T|0,I(1)|0?1:(ae(i[p+1|0]|0),p=p+2|0,0)}function Ac(T){return T=T|0,I(2)|0?1:(ae(u(p+1|0)|0),p=p+3|0,0)}function Nc(T){return T=T|0,I(4)|0?1:(D(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function Sc(T){return T=T|0,I(8)|0?1:(se(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function Rc(T){return T=T|0,k(),p=p+1|0,0}function cn(T){return T=T|0,H(T-192|0|0),p=p+1|0,0}function VT(T){return T=T|0,H(T|0),p=p+1|0,0}function HT(T){return T=T|0,H(T|0),p=p+1|0,0}function KT(T){return T=T|0,H(T|0),p=p+1|0,0}function $T(T){return T=T|0,H(T|0),p=p+1|0,0}function ft(T){return T=T|0,H(T-192|0|0),p=p+1|0,0}function GT(T){return T=T|0,H(T|0),p=p+1|0,0}function YT(T){return T=T|0,H(T|0),p=p+1|0,0}function WT(T){return T=T|0,H(T|0),p=p+1|0,0}function Gy(T){return T=T|0,I(1)|0?1:(H(i[p+1|0]|0),p=p+2|0,0)}function Yy(T){return T=T|0,I(2)|0?1:(H(u(p+1|0)|0),p=p+3|0,0)}function Wy(T){return T=T|0,I(4)|0?1:(X(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function zy(T){return T=T|0,I(8)|0?1:(ie(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function rt(T){return T=T|0,B((T|0)-224|0),p=p+1|0,0}function Jy(T){return T=T|0,l(),p=p+1|0,0}function Zy(T){return T=T|0,b(),p=p+1|0,0}function Xy(T){return T=T|0,A(),p=p+1|0,0}function Qy(T){return T=T|0,S(),p=p+1|0,0}function Iy(T){return T=T|0,I(1)|0?1:(B(i[p+1|0]|0),p=p+2|0,0)}function Dy(T){T=T|0;var Ae=0,Re=0,xe=1,no=0,Qi=0,zT=0;return I(2)|0?1:(Ae=i[p+1|0]|0,Re=i[p+2|0]|0,(Ae|0)&128&&(xe=-1),no=+(((Ae|0)&124)>>2),Qi=+(((Ae|0)&3)<<8|Re),+no==0?f(+(+xe*5960464477539063e-23*+Qi)):+no==31?+xe==1?+Qi>0?v():F():+Qi>0?G():q():f(+(+xe*M(2,+(+no-25))*+(1024+Qi))),p=p+3|0,0)}function Ly(T){return T=T|0,I(4)|0?1:(h(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0),p=p+5|0,0)}function em(T){return T=T|0,I(8)|0?1:(m(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0,i[p+5|0]|0,i[p+6|0]|0,i[p+7|0]|0,i[p+8|0]|0),p=p+9|0,0)}function He(T){return T=T|0,1}function tm(T){return T=T|0,W(),p=p+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,U,O,P,K,He,He,He,He,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,C,$,V,Q,He,He,He,He,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,Oe,Fe,He,He,He,_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,Qe,vr,Xr,Qr,He,He,He,Vt,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,vt,ot,$e,Tc,He,He,He,vc,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Ge,Oc,Ac,Nc,Sc,He,He,He,Rc,cn,cn,cn,cn,cn,cn,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,Gy,Yy,Wy,zy,He,He,He,He,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,Jy,Zy,Xy,Qy,Iy,Dy,Ly,em,He,He,He,tm];return{parse:le}}});var cs=ee(Jt=>{"use strict";var xu=as().BigNumber;Jt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Jt.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};Jt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Jt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Jt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Jt.SHIFT32=Math.pow(2,32);Jt.SHIFT16=Math.pow(2,16);Jt.MAX_SAFE_HIGH=2097151;Jt.NEG_ONE=new xu(-1);Jt.TEN=new xu(10);Jt.TWO=new xu(2);Jt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Vo=ee(nr=>{"use strict";var{Buffer:ob}=ai("buffer"),c0=as().BigNumber,u0=cs(),a0=u0.SHIFT32,ab=u0.SHIFT16,cb=2097151;nr.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)}nr.arrayBufferToBignumber=function(e){let t=e.byteLength,r="";for(let n=0;n<t;n++)r+=ub(e[n]);return new c0(r,16)};nr.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};nr.buildInt32=(e,t)=>e*ab+t;nr.buildInt64=(e,t,r,n)=>{let i=nr.buildInt32(e,t),s=nr.buildInt32(r,n);return i>cb?new c0(i).times(a0).plus(s):i*a0+s};nr.writeHalf=function(t,r){let n=ob.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if((i&8191)!==0)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return t.writeUInt16BE(s,0),!0};nr.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])};nr.isNegativeZero=e=>e===0&&1/e<0;nr.nextPowerOf2=e=>{let t=0;if(e&&!(e&e-1))return e;for(;e!==0;)e>>=1,t+=1;return 1<<t}});var Au=ee((x8,l0)=>{"use strict";var Ou=cs(),lb=Ou.MT,Ho=Ou.SIMPLE,Tu=Ou.SYMS,vu=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 Ho.FALSE:return!1;case Ho.TRUE:return!0;case Ho.NULL:return r?null:Tu.NULL;case Ho.UNDEFINED:return r?void 0:Tu.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Tu.BREAK;default:return new e(t)}}};l0.exports=vu});var Su=ee((T8,d0)=>{"use strict";var Nu=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}}};d0.exports=Nu});var Bu=ee((v8,h0)=>{"use strict";var{URL:db,URLSearchParams:fb,format:hb}=ai("url"),f0="http://localhost",Ru=class extends db{constructor(t="",r=f0){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()}};h0.exports={URLWithLegacySupport:Ru,URLSearchParams:fb,format:hb,defaultBase:f0}});var y0=ee((O8,_0)=>{"use strict";var{URLWithLegacySupport:p0,format:pb}=Bu();_0.exports=(e,t={},r={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new p0(e)}catch{s={}}let o=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new p0(e,pb(o)).toString()}});var Pu=ee((A8,m0)=>{"use strict";var{URLWithLegacySupport:_b,format:yb,URLSearchParams:mb,defaultBase:gb}=Bu(),bb=y0();m0.exports={URL:_b,URLSearchParams:mb,format:yb,relative:bb,defaultBase:gb}});var Uu=ee((N8,b0)=>{"use strict";var{Buffer:Ti}=ai("buffer"),g0=Uc(),wb=as().BigNumber,Eb=o0(),Ct=Vo(),je=cs(),xb=Au(),Tb=Su(),{URL:vb}=Pu(),us=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=Ti.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=>je.NEG_ONE.minus(Ct.arrayBufferToBignumber(r)),4:r=>je.TEN.pow(r[0]).times(r[1]),5:r=>je.TWO.pow(r[0]).times(r[1]),32:r=>new vb(r),35:r=>new RegExp(r)},t.tags),this.parser=Eb(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 je.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case je.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case je.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case je.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 je.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 je.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===je.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 je.PARENT.ARRAY:case je.PARENT.BYTE_STRING:case je.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case je.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=je.PARENT.MAP,n.ref=Ct.buildMap(n.ref)));break;case je.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case je.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:je.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,r){let n=this._knownTags[t];return n?n(r):new Tb(t,r)}createMap(t,r){return t}createObject(t,r){return t}createArray(t,r){return t}createByteString(t,r){return Ti.concat(t)}createByteStringFromHeap(t,r){return t===r?Ti.alloc(0):Ti.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 g0.read([t,r,n,i],0,!1,23,4)}createFloatDouble(t,r,n,i,s,o,a,c){return g0.read([t,r,n,i,s,o,a,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),o=Ct.buildInt32(n,i);return s>je.MAX_SAFE_HIGH?je.NEG_ONE.minus(new wb(s).times(je.SHIFT32).plus(o)):-1-(s*je.SHIFT32+o)}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 xb(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,o,a,c){this._push(this.createFloatDouble(t,r,n,i,s,o,a,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([],je.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:je.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:je.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:je.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({},je.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),je.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=Ti.from(t,r||"hex")),new e({size:t.length}).decodeFirst(t)}static decodeAll(t,r){return typeof t=="string"&&(t=Ti.from(t,r||"hex")),new e({size:t.length}).decodeAll(t)}};us.decodeFirst=us.decode;b0.exports=us});var x0=ee((S8,E0)=>{"use strict";var{Buffer:Fu}=ai("buffer"),Ob=Uu(),Ab=Vo(),Cu=class e extends Ob{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,o,a,c){return`${super.createFloatDouble(t,r,n,i,s,o,a,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(w0(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(t,r){let n=super.createObject(t),i=Object.keys(n).reduce(w0(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)}};E0.exports=Cu;function w0(e){return(t,r)=>t?`${t}, ${r}: ${e[r]}`:`${r}: ${e[r]}`}});var N0=ee((R8,A0)=>{"use strict";var{Buffer:Fr}=ai("buffer"),{URL:Nb}=Pu(),qu=as().BigNumber,Mu=Vo(),at=cs(),dr=at.MT,Ko=at.NUMBYTES,T0=at.SHIFT32,v0=at.SYMS,vi=at.TAG,Sb=at.MT.SIMPLE_FLOAT<<5|at.NUMBYTES.TWO,Rb=at.MT.SIMPLE_FLOAT<<5|at.NUMBYTES.FOUR,Bb=at.MT.SIMPLE_FLOAT<<5|at.NUMBYTES.EIGHT,Pb=at.MT.SIMPLE_FLOAT<<5|at.SIMPLE.TRUE,Ub=at.MT.SIMPLE_FLOAT<<5|at.SIMPLE.FALSE,Fb=at.MT.SIMPLE_FLOAT<<5|at.SIMPLE.UNDEFINED,O0=at.MT.SIMPLE_FLOAT<<5|at.SIMPLE.NULL,Cb=new qu("0x20000000000000"),Mb=Fr.from("f97e00","hex"),qb=Fr.from("f9fc00","hex"),jb=Fr.from("f97c00","hex");function kb(e){return{}.toString.call(e).slice(8,-1)}var ju=class e{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[Nb,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 o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}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(Mb)}_pushInfinity(t){let r=t<0?qb:jb;return this.push(r)}_pushFloat(t){let r=Fr.allocUnsafe(2);if(Mu.writeHalf(r,t)&&Mu.parseHalf(r)===t)return this._pushUInt8(Sb)&&this.push(r);let n=Fr.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(Rb)&&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|Ko.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|Ko.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|Ko.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Ko.EIGHT)&&this._pushUInt32BE(Math.floor(t/T0))&&this._pushUInt32BE(t%T0):r===dr.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,dr.NEG_INT,t):this._pushInt(t,dr.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=Fr.byteLength(t,"utf8");return this._pushInt(r,dr.UTF8_STRING)&&this.pushWrite(t,5,r)}_pushBoolean(t){return this._pushUInt8(t?Pb:Ub)}_pushUndefined(t){return this._pushUInt8(Fb)}_pushArray(t,r){let n=r.length;if(!t._pushInt(n,dr.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,dr.TAG)}_pushDate(t,r){return t._pushTag(vi.DATE_EPOCH)&&t.pushAny(Math.round(r/1e3))}_pushBuffer(t,r){return t._pushInt(r.length,dr.BYTE_STRING)&&t.push(r)}_pushNoFilter(t,r){return t._pushBuffer(t,r.slice())}_pushRegexp(t,r){return t._pushTag(vi.REGEXP)&&t.pushAny(r.source)}_pushSet(t,r){if(!t._pushInt(r.size,dr.ARRAY))return!1;for(let n of r)if(!t.pushAny(n))return!1;return!0}_pushUrl(t,r){return t._pushTag(vi.URI)&&t.pushAny(r.format())}_pushBigint(t){let r=vi.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),r=vi.NEG_BIGINT);let n=t.toString(16);n.length%2&&(n="0"+n);let i=Fr.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(vi.DECIMAL_FRAC)&&t._pushInt(2,dr.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,dr.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(t){if(!t)return this._pushUInt8(O0);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),o=s.length;return this._pushInt(o,dr.MAP)?this._pushRawMap(o,s.map(a=>[a,t[a]])):!1}_pushRawMap(t,r){r=r.map(function(i){return i[0]=e.encode(i[0]),i}).sort(Mu.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=kb(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,Fr.isBuffer(t)?t:Fr.from(t));case"Null":return this._pushUInt8(O0);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 v0.NULL:return this._pushObject(null);case v0.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,o=0;o<i;o++)s+=r[o];var a=Fr.allocUnsafe(s),c=0,d=0;for(o=0;o<i;o++){switch(d=r[o],n[o]){case 0:t[o].copy(a,c);break;case 1:a.writeUInt8(t[o],c,!0);break;case 2:a.writeUInt16BE(t[o],c,!0);break;case 3:a.writeUInt32BE(t[o],c,!0);break;case 4:a.writeDoubleBE(t[o],c,!0);break;case 5:a.write(t[o],c,d,"utf8");break;default:throw new Error("unkown method")}c+=d}var f=a;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()}};A0.exports=ju});var $o=ee(ct=>{"use strict";ct.Diagnose=x0();ct.Decoder=Uu();ct.Encoder=N0();ct.Simple=Au();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 fs=ee(ir=>{"use strict";var Vb=ir&&ir.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ir,"__esModule",{value:!0});ir.hashOfMap=ir.requestIdOf=ir.hashValue=ir.hash=void 0;var S0=xi(),Hb=Vb($o()),Kb=po(),ls=Kt();function mn(e){return(0,ls.uint8ToBuf)(Kb.sha256.create().update(new Uint8Array(e)).digest())}ir.hash=mn;function ds(e){if(e instanceof Hb.default.Tagged)return ds(e.value);if(typeof e=="string")return R0(e);if(typeof e=="number")return mn((0,S0.lebEncode)(e));if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return mn(e);if(Array.isArray(e)){let t=e.map(ds);return mn((0,ls.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 ds(e.toHash());if(typeof e=="object")return ku(e);if(typeof e=="bigint")return mn((0,S0.lebEncode)(e))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${e}`),{value:e})}ir.hashValue=ds;var R0=e=>{let t=new TextEncoder().encode(e);return mn(t)};function $b(e){return ku(e)}ir.requestIdOf=$b;function ku(e){let n=Object.entries(e).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=R0(o),d=ds(a);return[c,d]}).sort(([o],[a])=>(0,ls.compare)(o,a)),i=(0,ls.concat)(...n.map(o=>(0,ls.concat)(...o)));return mn(i)}ir.hashOfMap=ku});var Ku=ee(Cr=>{"use strict";var Gb=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 B0=Ft(),Yb=fs(),P0=Kt(),Wb=new TextEncoder().encode(`
17
- ic-request`),Vu=class{getPrincipal(){return this._principal||(this._principal=B0.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:r}=t,n=Gb(t,["body"]),i=(0,Yb.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,P0.concat)(Wb,i))}})}};Cr.SignIdentity=Vu;var Hu=class{getPrincipal(){return B0.Principal.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}};Cr.AnonymousIdentity=Hu;function zb(e){return"getPublicKey"in e?{type:"PublicKeyIdentity",publicKey:(0,P0.toHex)(e.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Cr.createIdentityDescriptor=zb});var Yu=ee(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});var Jb=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 fr(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 Go(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 fr(e,r,t.toString(16))}}function U0(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(Go(3,e.length)),new Uint8Array(t))}function Zb(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(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}Ye.tagged=Zb;function hs(e){return new Uint8Array(e).buffer}Ye.raw=hs;function $u(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}Ye.uSmall=$u;function F0(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),fr(0,24,e)}Ye.u8=F0;function C0(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),fr(0,25,e)}Ye.u16=C0;function M0(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),fr(0,26,e)}Ye.u32=M0;function Gu(e,t){if(typeof e=="string"&&t==16){if(e.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return fr(0,27,e)}if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),Jb),e=e.toString(16),fr(0,27,e)}Ye.u64=Gu;function q0(e){if(isNaN(e))throw new RangeError("Invalid number.");if(e===0)return $u(0);e=Math.min(Math.max(0,-e),24)-1;let t=[32+e];return new Uint8Array(t).buffer}Ye.iSmall=q0;function j0(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),fr(1,24,e)}Ye.i8=j0;function k0(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),fr(1,25,e)}Ye.i16=k0;function V0(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),fr(1,26,e)}Ye.i32=V0;function H0(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 o=parseInt(s,16)-1;return o>=0?(r=!0,o.toString(16)+i):"f"+i},"");return r?fr(1,27,n):Gu(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),fr(1,27,e)}Ye.i64=H0;function Xb(e){return e>=0?e<24?$u(e):e<=255?F0(e):e<=65535?C0(e):e<=4294967295?M0(e):Gu(e):e>=-24?q0(e):e>=-255?j0(e):e>=-65535?k0(e):e>=-4294967295?V0(e):H0(e)}Ye.number=Xb;function Qb(e){return en(Go(2,e.byteLength),e)}Ye.bytes=Qb;function Ib(e){return U0(e)}Ye.string=Ib;function Db(e){return en(Go(4,e.length),...e)}Ye.array=Db;function Lb(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(Go(5,e.size),...r.map(([n,i])=>en(U0(n),i)))}Ye.map=Lb;function e1(e){let t=new Float32Array([e]);return en(new Uint8Array([250]),new Uint8Array(t.buffer))}Ye.singleFloat=e1;function t1(e){let t=new Float64Array([e]);return en(new Uint8Array([251]),new Uint8Array(t.buffer))}Ye.doubleFloat=t1;function r1(e){return e?K0():$0()}Ye.bool=r1;function K0(){return hs(new Uint8Array([245]))}Ye.true_=K0;function $0(){return hs(new Uint8Array([244]))}Ye.false_=$0;function n1(){return hs(new Uint8Array([246]))}Ye.null_=n1;function i1(){return hs(new Uint8Array([247]))}Ye.undefined_=i1});var G0=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 hr=s1(Yu()),o1=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Yo=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 hr.undefined_();case"boolean":return hr.bool(t);case"number":return Math.floor(t)===t?hr.number(t):hr.doubleFloat(t);case"string":return hr.string(t);case"object":if(t===null)return hr.null_();if(Array.isArray(t))return hr.array(t.map(r=>this._serializer.serializeValue(r)));if(o1.find(r=>t instanceof r))return hr.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 hr.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 hr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};gn.JsonDefaultCborEncoder=Yo;var Wo=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=Wo;var zo=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let r=new this;return r.addEncoder(new Yo(r,t)),r.addEncoder(new Wo),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=zo;var Wu=class extends zo{serialize(t){return hr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};gn.SelfDescribeCborSerializer=Wu});var ps=ee($n=>{"use strict";function a1(e){for(var t in e)$n.hasOwnProperty(t)||($n[t]=e[t])}var c1=$n&&$n.__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($n,"__esModule",{value:!0});a1(G0());var u1=c1(Yu());$n.value=u1});var _s=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},h1=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 p1=h1($o()),Oi=f1(ps()),_1=ps(),Jo=Kt(),zu=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return Oi.value.bytes(t.toUint8Array())}},Ju=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return Oi.value.bytes(new Uint8Array(t))}},Zu=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?Oi.value.tagged(2,Oi.value.bytes((0,Jo.fromHex)(t.toString(16)))):Oi.value.tagged(3,Oi.value.bytes((0,Jo.fromHex)((BigInt("-1")*t).toString(16))))}},Zo=_1.SelfDescribeCborSerializer.withDefaultEncoders(!0);Zo.addEncoder(new zu);Zo.addEncoder(new Ju);Zo.addEncoder(new Zu);var W0;(function(e){e[e.Uint64LittleEndian=71]="Uint64LittleEndian",e[e.Semantic=55799]="Semantic"})(W0=gt.CborTag||(gt.CborTag={}));function y1(e){return Zo.serialize(e)}gt.encode=y1;function Y0(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 Xu=class extends p1.default.Decoder{createByteString(t){return(0,Jo.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 Xu({size:t.byteLength,tags:{2:n=>Y0(n),3:n=>-Y0(n),[W0.Semantic]:n=>n}});try{return r.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,Jo.toHex)(t)}`)}}gt.decode=m1});var Qu=ee(Xo=>{"use strict";Object.defineProperty(Xo,"__esModule",{value:!0});Xo.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)};Xo.randomNumber=g1});var ys=ee(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});Gn.makeNonce=Gn.SubmitRequestType=void 0;var Qo=Qu(),b1;(function(e){e.Call="call"})(b1=Gn.SubmitRequestType||(Gn.SubmitRequestType={}));function w1(){let e=new ArrayBuffer(16),t=new DataView(e),r=(0,Qo.randomNumber)(),n=(0,Qo.randomNumber)(),i=(0,Qo.randomNumber)(),s=(0,Qo.randomNumber)();return t.setUint32(0,r),t.setUint32(4,n),t.setUint32(8,i),t.setUint32(12,s),e}Gn.makeNonce=w1});var Do=ee(Nt=>{"use strict";var E1=Nt&&Nt.__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]}),x1=Nt&&Nt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),T1=Nt&&Nt.__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)&&E1(t,e,r);return x1(t,e),t};Object.defineProperty(Nt,"__esModule",{value:!0});Nt.httpHeadersTransform=Nt.makeExpiryTransform=Nt.makeNonceTransform=Nt.Expiry=void 0;var v1=xi(),O1=T1(ps()),A1=ys(),z0=BigInt(1e6),N1=60*1e3,Io=class{constructor(t){if(t<90*1e3){let a=BigInt(Date.now()+t)*z0/BigInt(1e9);this._value=a*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+t-N1))*z0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return O1.value.u64(this._value.toString(16),16)}toHash(){return(0,v1.lebEncode)(this._value)}};Nt.Expiry=Io;function S1(e=A1.makeNonce){return async t=>{let r=t.request.headers;t.request.headers=r,t.endpoint==="call"&&(t.body.nonce=e())}}Nt.makeNonceTransform=S1;function R1(e){return async t=>{t.body.ingress_expiry=new Io(e)}}Nt.makeExpiryTransform=R1;function B1(e){let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t}Nt.httpHeadersTransform=B1});var ea=ee(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.AgentReadStateError=Mr.AgentQueryError=Mr.AgentCallError=Mr.AgentHTTPResponseError=void 0;var Lo=_i(),Iu=class extends Lo.AgentError{constructor(t,r){super(t),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Mr.AgentHTTPResponseError=Iu;var Du=class extends Lo.AgentError{constructor(t,r,n,i,s,o){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}};Mr.AgentCallError=Du;var Lu=class extends Lo.AgentError{constructor(t,r,n,i,s,o){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}};Mr.AgentQueryError=Lu;var el=class extends Lo.AgentError{constructor(t,r,n,i,s,o){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};Mr.AgentReadStateError=el});var Zt=ee(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.notImplemented=Ce.bitMask=void 0;Ce.isBytes=ra;Ce.abytes=na;Ce.abool=U1;Ce.bytesToHex=il;Ce.numberToHexUnpadded=X0;Ce.hexToNumber=sl;Ce.hexToBytes=ia;Ce.bytesToNumberBE=C1;Ce.bytesToNumberLE=M1;Ce.numberToBytesBE=Q0;Ce.numberToBytesLE=q1;Ce.numberToVarBytesBE=j1;Ce.ensureBytes=k1;Ce.concatBytes=I0;Ce.equalBytes=V1;Ce.utf8ToBytes=H1;Ce.inRange=D0;Ce.aInRange=K1;Ce.bitLen=$1;Ce.bitGet=G1;Ce.bitSet=Y1;Ce.createHmacDrbg=z1;Ce.validateObject=Z1;Ce.memoized=Q1;var nl=BigInt(0),ta=BigInt(1),P1=BigInt(2);function ra(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function na(e){if(!ra(e))throw new Error("Uint8Array expected")}function U1(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){na(e);let t="";for(let r=0;r<e.length;r++)t+=F1[e[r]];return t}function X0(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 J0(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 ia(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 o=J0(e.charCodeAt(s)),a=J0(e.charCodeAt(s+1));if(o===void 0||a===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]=o*16+a}return n}function C1(e){return sl(il(e))}function M1(e){return na(e),sl(il(Uint8Array.from(e).reverse()))}function Q0(e,t){return ia(e.toString(16).padStart(t*2,"0"))}function q1(e,t){return Q0(e,t).reverse()}function j1(e){return ia(X0(e))}function k1(e,t,r){let n;if(typeof t=="string")try{n=ia(t)}catch(s){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`)}else if(ra(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 I0(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];na(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 V1(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 H1(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 D0(e,t,r){return tl(e)&&tl(t)&&tl(r)&&t<=e&&e<r}function K1(e,t,r,n){if(!D0(t,r,n))throw new Error(`expected valid ${e}: ${r} <= n < ${n}, got ${typeof t} ${t}`)}function $1(e){let t;for(t=0;e>nl;e>>=ta,t+=1);return t}function G1(e,t){return e>>BigInt(t)&ta}function Y1(e,t,r){return e|(r?ta:nl)<<BigInt(t)}var W1=e=>(P1<<BigInt(e-1))-ta;Ce.bitMask=W1;var rl=e=>new Uint8Array(e),Z0=e=>Uint8Array.from(e);function z1(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,o=()=>{n.fill(1),i.fill(0),s=0},a=(...h)=>r(i,n,...h),c=(h=rl())=>{i=a(Z0([0]),h),n=a(),h.length!==0&&(i=a(Z0([1]),h),n=a())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,m=[];for(;h<t;){n=a();let b=n.slice();m.push(b),h+=n.length}return I0(...m)};return(h,m)=>{o(),c(h);let b;for(;!(b=m(d()));)c();return o(),b}}var J1={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"||ra(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 Z1(e,t,r={}){let n=(i,s,o)=>{let a=J1[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=e[i];if(!(o&&c===void 0)&&!a(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 X1=()=>{throw new Error("not implemented")};Ce.notImplemented=X1;function Q1(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 qr=ee(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.isNegativeLE=void 0;Ze.mod=Xt;Ze.pow=th;Ze.pow2=ew;Ze.invert=sa;Ze.tonelliShanks=rh;Ze.FpSqrt=nh;Ze.validateField=nw;Ze.FpPow=ih;Ze.FpInvertBatch=sh;Ze.FpDiv=iw;Ze.FpLegendre=oh;Ze.FpIsSquare=sw;Ze.nLength=al;Ze.Field=ow;Ze.FpSqrtOdd=aw;Ze.FpSqrtEven=cw;Ze.hashToPrivateScalar=uw;Ze.getFieldBytesLength=cl;Ze.getMinHashLength=ah;Ze.mapHashToField=lw;var Qt=Zt(),ut=BigInt(0),Ke=BigInt(1),bn=BigInt(2),I1=BigInt(3),ol=BigInt(4),L0=BigInt(5),eh=BigInt(8),D1=BigInt(9),L1=BigInt(16);function Xt(e,t){let r=e%t;return r>=ut?r:t+r}function th(e,t,r){if(r<=ut||t<ut)throw new Error("Expected power/modulo > 0");if(r===Ke)return ut;let n=Ke;for(;t>ut;)t&Ke&&(n=n*e%r),e=e*e%r,t>>=Ke;return n}function ew(e,t,r){let n=e;for(;t-- >ut;)n*=n,n%=r;return n}function sa(e,t){if(e===ut||t<=ut)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=Xt(e,t),n=t,i=ut,s=Ke,o=Ke,a=ut;for(;r!==ut;){let d=n/r,f=n%r,h=i-o*d,m=s-a*d;n=r,r=f,i=o,s=a,o=h,a=m}if(n!==Ke)throw new Error("invert: does not exist");return Xt(i,t)}function rh(e){let t=(e-Ke)/bn,r,n,i;for(r=e-Ke,n=0;r%bn===ut;r/=bn,n++);for(i=bn;i<e&&th(i,t,e)!==e-Ke;i++);if(n===1){let o=(e+Ke)/ol;return function(c,d){let f=c.pow(d,o);if(!c.eql(c.sqr(f),d))throw new Error("Cannot find square root");return f}}let s=(r+Ke)/bn;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let d=n,f=a.pow(a.mul(a.ONE,i),r),h=a.pow(c,s),m=a.pow(c,r);for(;!a.eql(m,a.ONE);){if(a.eql(m,a.ZERO))return a.ZERO;let b=1;for(let S=a.sqr(m);b<d&&!a.eql(S,a.ONE);b++)S=a.sqr(S);let l=a.pow(f,Ke<<BigInt(d-b-1));f=a.sqr(l),h=a.mul(h,l),m=a.mul(m,f),d=b}return h}}function nh(e){if(e%ol===I1){let t=(e+Ke)/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%eh===L0){let t=(e-L0)/eh;return function(n,i){let s=n.mul(i,bn),o=n.pow(s,t),a=n.mul(i,o),c=n.mul(n.mul(a,bn),o),d=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(d),i))throw new Error("Cannot find square root");return d}}return e%L1,rh(e)}var tw=(e,t)=>(Xt(e,t)&Ke)===Ke;Ze.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,Qt.validateObject)(e,r)}function ih(e,t,r){if(r<ut)throw new Error("Expected power > 0");if(r===ut)return e.ONE;if(r===Ke)return t;let n=e.ONE,i=t;for(;r>ut;)r&Ke&&(n=e.mul(n,i)),i=e.sqr(i),r>>=Ke;return n}function sh(e,t){let r=new Array(t.length),n=t.reduce((s,o,a)=>e.is0(o)?s:(r[a]=s,e.mul(s,o)),e.ONE),i=e.inv(n);return t.reduceRight((s,o,a)=>e.is0(o)?s:(r[a]=e.mul(s,r[a]),e.mul(s,o)),i),r}function iw(e,t,r){return e.mul(t,typeof r=="bigint"?sa(r,e.ORDER):e.inv(r))}function oh(e){let t=(e-Ke)/bn;return(r,n)=>r.pow(n,t)}function sw(e){let t=oh(e.ORDER);return r=>{let n=t(e,r);return e.eql(n,e.ZERO)||e.eql(n,e.ONE)}}function al(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function ow(e,t,r=!1,n={}){if(e<=ut)throw new Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:s}=al(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=nh(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:(0,Qt.bitMask)(i),ZERO:ut,ONE:Ke,create:c=>Xt(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&Ke)===Ke,neg:c=>Xt(-c,e),eql:(c,d)=>c===d,sqr:c=>Xt(c*c,e),add:(c,d)=>Xt(c+d,e),sub:(c,d)=>Xt(c-d,e),mul:(c,d)=>Xt(c*d,e),pow:(c,d)=>ih(a,c,d),div:(c,d)=>Xt(c*sa(d,e),e),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>sa(c,e),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>sh(a,c),cmov:(c,d,f)=>f?d:c,toBytes:c=>r?(0,Qt.numberToBytesLE)(c,s):(0,Qt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Qt.bytesToNumberLE)(c):(0,Qt.bytesToNumberBE)(c)}});return Object.freeze(a)}function aw(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,Qt.ensureBytes)("privateHash",e);let n=e.length,i=al(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,Qt.bytesToNumberLE)(e):(0,Qt.bytesToNumberBE)(e);return Xt(s,t-Ke)+Ke}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 ah(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=ah(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Qt.bytesToNumberBE)(e):(0,Qt.bytesToNumberLE)(e),a=Xt(o,t-Ke)+Ke;return r?(0,Qt.numberToBytesLE)(a,i):(0,Qt.numberToBytesBE)(a,i)}});var oa=ee(Yn=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.expand_message_xmd=ch;Yn.expand_message_xof=uh;Yn.hash_to_field=ul;Yn.isogenyMap=pw;Yn.createHasher=_w;var dw=qr(),St=Zt(),fw=St.bytesToNumberBE;function wn(e,t){if(ms(e),ms(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 hw(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 ms(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function ch(e,t,r,n){(0,St.abytes)(e),(0,St.abytes)(t),ms(r),t.length>255&&(t=n((0,St.concatBytes)((0,St.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=(0,St.concatBytes)(t,wn(t.length,1)),c=wn(0,s),d=wn(r,2),f=new Array(o),h=n((0,St.concatBytes)(c,e,d,wn(0,1),a));f[0]=n((0,St.concatBytes)(h,wn(1,1),a));for(let b=1;b<=o;b++){let l=[hw(h,f[b-1]),wn(b+1,1),a];f[b]=n((0,St.concatBytes)(...l))}return(0,St.concatBytes)(...f).slice(0,r)}function uh(e,t,r,n,i){if((0,St.abytes)(e),(0,St.abytes)(t),ms(r),t.length>255){let s=Math.ceil(2*n/8);t=i.create({dkLen:s}).update((0,St.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,St.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:a,DST:c}=r;(0,St.abytes)(e),ms(t);let d=typeof c=="string"?(0,St.utf8ToBytes)(c):c,f=n.toString(2).length,h=Math.ceil((f+i)/8),m=t*s*h,b;if(a==="xmd")b=ch(e,d,m,o);else if(a==="xof")b=uh(e,d,m,i,o);else if(a==="_internal_pass")b=e;else throw new Error('expand must be "xmd" or "xof"');let l=new Array(t);for(let S=0;S<t;S++){let A=new Array(s);for(let F=0;F<s;F++){let q=h*(F+S*s),v=b.subarray(q,q+h);A[F]=(0,dw.mod)(fw(v),n)}l[S]=A}return l}function pw(e,t){let r=t.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(d=>d.reduce((f,h)=>e.add(e.mul(f,n),h)));return n=e.div(s,o),i=e.mul(i,e.div(a,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}),o=e.fromAffine(t(s[0])),a=e.fromAffine(t(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=ul(n,1,{...r,DST:r.encodeDST,...i}),o=e.fromAffine(t(s[0])).clearCofactor();return o.assertValidity(),o},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(gs=>{"use strict";Object.defineProperty(gs,"__esModule",{value:!0});gs.wNAF=mw;gs.pippenger=gw;gs.validateBasic=bw;var lh=qr(),fh=Zt(),yw=BigInt(0),ll=BigInt(1),dl=new WeakMap,dh=new WeakMap;function mw(e,t){let r=(s,o)=>{let a=o.negate();return s?a:o},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 o=Math.ceil(t/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=e.ZERO,c=s;for(;o>yw;)o&ll&&(a=a.add(c)),c=c.double(),o>>=ll;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),d=[],f=s,h=f;for(let m=0;m<a;m++){h=f,d.push(h);for(let b=1;b<c;b++)h=h.add(f),d.push(h);f=h.double()}return d},wNAF(s,o,a){let{windows:c,windowSize:d}=i(s),f=e.ZERO,h=e.BASE,m=BigInt(2**s-1),b=2**s,l=BigInt(s);for(let S=0;S<c;S++){let A=S*d,F=Number(a&m);a>>=l,F>d&&(F-=b,a+=ll);let q=A,v=A+Math.abs(F)-1,G=S%2!==0,E=F<0;F===0?h=h.add(r(G,o[q])):f=f.add(r(E,o[v]))}return{p:f,f:h}},wNAFCached(s,o,a){let c=dh.get(s)||1,d=dl.get(s);return d||(d=this.precomputeWindow(s,c),c!==1&&dl.set(s,a(d))),this.wNAF(c,d,o)},setWindowSize(s,o){n(o),dh.set(s,o),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,h)=>{if(!t.isValid(f))throw new Error(`wrong scalar at index ${h}`)}),r.forEach((f,h)=>{if(!(f instanceof e))throw new Error(`wrong point at index ${h}`)});let i=(0,fh.bitLen)(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,a=new Array(o+1).fill(e.ZERO),c=Math.floor((t.BITS-1)/s)*s,d=e.ZERO;for(let f=c;f>=0;f-=s){a.fill(e.ZERO);for(let m=0;m<n.length;m++){let b=n[m],l=Number(b>>BigInt(f)&BigInt(o));a[l]=a[l].add(r[m])}let h=e.ZERO;for(let m=a.length-1,b=e.ZERO;m>0;m--)b=b.add(a[m]),h=h.add(b);if(d=d.add(h),f!==0)for(let m=0;m<s;m++)d=d.double()}return d}function bw(e){return(0,lh.validateField)(e.Fp),(0,fh.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,lh.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=_h;wt.weierstrass=vw;wt.SWUFpSqrtRatio=yh;wt.mapToCurveSimpleSWU=Ow;var aa=fl(),Wn=qr(),Ne=Zt(),bt=Zt();function hh(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,aa.validateBasic)(e);Ne.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:Ew,hexToBytes:xw}=Ne;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=Ne.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Ne.numberToHexUnpadded(i.length/2|128):"";return`${Ne.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),o=0;if(!s)o=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)o=o<<8|f;if(n+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+o)}}},_int:{encode(e){let{Err:t}=wt.DER;if(e<pr)throw new t("integer: negative integers are not allowed");let r=Ne.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 Ew(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=wt.DER,i=typeof e=="string"?xw(e):e;Ne.abytes(i);let{v:s,l:o}=n.decode(48,i);if(o.length)throw new t("Invalid signature: left bytes after parsing");let{v:a,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(a),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 pr=BigInt(0),ke=BigInt(1),En=BigInt(2),ca=BigInt(3),ph=BigInt(4);function _h(e){let t=ww(e),{Fp:r}=t,n=Wn.Field(t.n,t.nBitLength),i=t.toBytes||((S,A,F)=>{let q=A.toAffine();return Ne.concatBytes(Uint8Array.from([4]),r.toBytes(q.x),r.toBytes(q.y))}),s=t.fromBytes||(S=>{let A=S.subarray(1),F=r.fromBytes(A.subarray(0,r.BYTES)),q=r.fromBytes(A.subarray(r.BYTES,2*r.BYTES));return{x:F,y:q}});function o(S){let{a:A,b:F}=t,q=r.sqr(S),v=r.mul(q,S);return r.add(r.add(v,r.mul(S,A)),F)}if(!r.eql(r.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function a(S){return Ne.inRange(S,ke,t.n)}function c(S){let{allowedPrivateKeyLengths:A,nByteLength:F,wrapPrivateKey:q,n:v}=t;if(A&&typeof S!="bigint"){if(Ne.isBytes(S)&&(S=Ne.bytesToHex(S)),typeof S!="string"||!A.includes(S.length))throw new Error("Invalid key");S=S.padStart(F*2,"0")}let G;try{G=typeof S=="bigint"?S:Ne.bytesToNumberBE((0,bt.ensureBytes)("private key",S,F))}catch{throw new Error(`private key must be ${F} bytes, hex or bigint, not ${typeof S}`)}return q&&(G=Wn.mod(G,v)),Ne.aInRange("private key",G,ke,v),G}function d(S){if(!(S instanceof m))throw new Error("ProjectivePoint expected")}let f=(0,bt.memoized)((S,A)=>{let{px:F,py:q,pz:v}=S;if(r.eql(v,r.ONE))return{x:F,y:q};let G=S.is0();A==null&&(A=G?r.ONE:r.inv(v));let E=r.mul(F,A),j=r.mul(q,A),Y=r.mul(v,A);if(G)return{x:r.ZERO,y:r.ZERO};if(!r.eql(Y,r.ONE))throw new Error("invZ was invalid");return{x:E,y:j}}),h=(0,bt.memoized)(S=>{if(S.is0()){if(t.allowInfinityPoint&&!r.is0(S.py))return;throw new Error("bad point: ZERO")}let{x:A,y:F}=S.toAffine();if(!r.isValid(A)||!r.isValid(F))throw new Error("bad point: x or y not FE");let q=r.sqr(F),v=o(A);if(!r.eql(q,v))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(A,F,q){if(this.px=A,this.py=F,this.pz=q,A==null||!r.isValid(A))throw new Error("x required");if(F==null||!r.isValid(F))throw new Error("y required");if(q==null||!r.isValid(q))throw new Error("z required");Object.freeze(this)}static fromAffine(A){let{x:F,y:q}=A||{};if(!A||!r.isValid(F)||!r.isValid(q))throw new Error("invalid affine point");if(A instanceof m)throw new Error("projective point not allowed");let v=G=>r.eql(G,r.ZERO);return v(F)&&v(q)?m.ZERO:new m(F,q,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(A){let F=r.invertBatch(A.map(q=>q.pz));return A.map((q,v)=>q.toAffine(F[v])).map(m.fromAffine)}static fromHex(A){let F=m.fromAffine(s((0,bt.ensureBytes)("pointHex",A)));return F.assertValidity(),F}static fromPrivateKey(A){return m.BASE.multiply(c(A))}static msm(A,F){return(0,aa.pippenger)(m,n,A,F)}_setWindowSize(A){l.setWindowSize(this,A)}assertValidity(){h(this)}hasEvenY(){let{y:A}=this.toAffine();if(r.isOdd)return!r.isOdd(A);throw new Error("Field doesn't support isOdd")}equals(A){d(A);let{px:F,py:q,pz:v}=this,{px:G,py:E,pz:j}=A,Y=r.eql(r.mul(F,j),r.mul(G,v)),Z=r.eql(r.mul(q,j),r.mul(E,v));return Y&&Z}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:A,b:F}=t,q=r.mul(F,ca),{px:v,py:G,pz:E}=this,j=r.ZERO,Y=r.ZERO,Z=r.ZERO,k=r.mul(v,v),ae=r.mul(G,G),D=r.mul(E,E),se=r.mul(v,G);return se=r.add(se,se),Z=r.mul(v,E),Z=r.add(Z,Z),j=r.mul(A,Z),Y=r.mul(q,D),Y=r.add(j,Y),j=r.sub(ae,Y),Y=r.add(ae,Y),Y=r.mul(j,Y),j=r.mul(se,j),Z=r.mul(q,Z),D=r.mul(A,D),se=r.sub(k,D),se=r.mul(A,se),se=r.add(se,Z),Z=r.add(k,k),k=r.add(Z,k),k=r.add(k,D),k=r.mul(k,se),Y=r.add(Y,k),D=r.mul(G,E),D=r.add(D,D),k=r.mul(D,se),j=r.sub(j,k),Z=r.mul(D,ae),Z=r.add(Z,Z),Z=r.add(Z,Z),new m(j,Y,Z)}add(A){d(A);let{px:F,py:q,pz:v}=this,{px:G,py:E,pz:j}=A,Y=r.ZERO,Z=r.ZERO,k=r.ZERO,ae=t.a,D=r.mul(t.b,ca),se=r.mul(F,G),w=r.mul(q,E),g=r.mul(v,j),R=r.add(F,q),N=r.add(G,E);R=r.mul(R,N),N=r.add(se,w),R=r.sub(R,N),N=r.add(F,v);let B=r.add(G,j);return N=r.mul(N,B),B=r.add(se,g),N=r.sub(N,B),B=r.add(q,v),Y=r.add(E,j),B=r.mul(B,Y),Y=r.add(w,g),B=r.sub(B,Y),k=r.mul(ae,N),Y=r.mul(D,g),k=r.add(Y,k),Y=r.sub(w,k),k=r.add(w,k),Z=r.mul(Y,k),w=r.add(se,se),w=r.add(w,se),g=r.mul(ae,g),N=r.mul(D,N),w=r.add(w,g),g=r.sub(se,g),g=r.mul(ae,g),N=r.add(N,g),se=r.mul(w,N),Z=r.add(Z,se),se=r.mul(B,N),Y=r.mul(R,Y),Y=r.sub(Y,se),se=r.mul(R,w),k=r.mul(B,k),k=r.add(k,se),new m(Y,Z,k)}subtract(A){return this.add(A.negate())}is0(){return this.equals(m.ZERO)}wNAF(A){return l.wNAFCached(this,A,m.normalizeZ)}multiplyUnsafe(A){Ne.aInRange("scalar",A,pr,t.n);let F=m.ZERO;if(A===pr)return F;if(A===ke)return this;let{endo:q}=t;if(!q)return l.unsafeLadder(this,A);let{k1neg:v,k1:G,k2neg:E,k2:j}=q.splitScalar(A),Y=F,Z=F,k=this;for(;G>pr||j>pr;)G&ke&&(Y=Y.add(k)),j&ke&&(Z=Z.add(k)),k=k.double(),G>>=ke,j>>=ke;return v&&(Y=Y.negate()),E&&(Z=Z.negate()),Z=new m(r.mul(Z.px,q.beta),Z.py,Z.pz),Y.add(Z)}multiply(A){let{endo:F,n:q}=t;Ne.aInRange("scalar",A,ke,q);let v,G;if(F){let{k1neg:E,k1:j,k2neg:Y,k2:Z}=F.splitScalar(A),{p:k,f:ae}=this.wNAF(j),{p:D,f:se}=this.wNAF(Z);k=l.constTimeNegate(E,k),D=l.constTimeNegate(Y,D),D=new m(r.mul(D.px,F.beta),D.py,D.pz),v=k.add(D),G=ae.add(se)}else{let{p:E,f:j}=this.wNAF(A);v=E,G=j}return m.normalizeZ([v,G])[0]}multiplyAndAddUnsafe(A,F,q){let v=m.BASE,G=(j,Y)=>Y===pr||Y===ke||!j.equals(v)?j.multiplyUnsafe(Y):j.multiply(Y),E=G(this,F).add(G(A,q));return E.is0()?void 0:E}toAffine(A){return f(this,A)}isTorsionFree(){let{h:A,isTorsionFree:F}=t;if(A===ke)return!0;if(F)return F(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:A,clearCofactor:F}=t;return A===ke?this:F?F(m,this):this.multiplyUnsafe(t.h)}toRawBytes(A=!0){return(0,bt.abool)("isCompressed",A),this.assertValidity(),i(m,this,A)}toHex(A=!0){return(0,bt.abool)("isCompressed",A),Ne.bytesToHex(this.toRawBytes(A))}}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,aa.wNAF)(m,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function Tw(e){let t=(0,aa.validateBasic)(e);return Ne.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=Tw(e),{Fp:r,n}=t,i=r.BYTES+1,s=2*r.BYTES+1;function o(g){return Wn.mod(g,n)}function a(g){return Wn.invert(g,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:h}=_h({...t,toBytes(g,R,N){let B=R.toAffine(),H=r.toBytes(B.x),X=Ne.concatBytes;return(0,bt.abool)("isCompressed",N),N?X(Uint8Array.from([R.hasEvenY()?2:3]),H):X(Uint8Array.from([4]),H,r.toBytes(B.y))},fromBytes(g){let R=g.length,N=g[0],B=g.subarray(1);if(R===i&&(N===2||N===3)){let H=Ne.bytesToNumberBE(B);if(!Ne.inRange(H,ke,r.ORDER))throw new Error("Point is not on curve");let X=f(H),ie;try{ie=r.sqrt(X)}catch(M){let p=M instanceof Error?": "+M.message:"";throw new Error("Point is not on curve"+p)}let oe=(ie&ke)===ke;return(N&1)===1!==oe&&(ie=r.neg(ie)),{x:H,y:ie}}else if(R===s&&N===4){let H=r.fromBytes(B.subarray(0,r.BYTES)),X=r.fromBytes(B.subarray(r.BYTES,2*r.BYTES));return{x:H,y:X}}else throw new Error(`Point of length ${R} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=g=>Ne.bytesToHex(Ne.numberToBytesBE(g,t.nByteLength));function b(g){let R=n>>ke;return g>R}function l(g){return b(g)?o(-g):g}let S=(g,R,N)=>Ne.bytesToNumberBE(g.slice(R,N));class A{constructor(R,N,B){this.r=R,this.s=N,this.recovery=B,this.assertValidity()}static fromCompact(R){let N=t.nByteLength;return R=(0,bt.ensureBytes)("compactSignature",R,N*2),new A(S(R,0,N),S(R,N,2*N))}static fromDER(R){let{r:N,s:B}=wt.DER.toSig((0,bt.ensureBytes)("DER",R));return new A(N,B)}assertValidity(){Ne.aInRange("r",this.r,ke,n),Ne.aInRange("s",this.s,ke,n)}addRecoveryBit(R){return new A(this.r,this.s,R)}recoverPublicKey(R){let{r:N,s:B,recovery:H}=this,X=j((0,bt.ensureBytes)("msgHash",R));if(H==null||![0,1,2,3].includes(H))throw new Error("recovery id invalid");let ie=H===2||H===3?N+t.n:N;if(ie>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let oe=(H&1)===0?"02":"03",W=c.fromHex(oe+m(ie)),M=a(ie),p=o(-X*M),L=o(B*M),re=c.BASE.multiplyAndAddUnsafe(W,p,L);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new A(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ne.hexToBytes(this.toDERHex())}toDERHex(){return wt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ne.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=Wn.getMinHashLength(t.n);return Wn.mapHashToField(t.randomBytes(g),t.n)},precompute(g=8,R=c.BASE){return R._setWindowSize(g),R.multiply(BigInt(3)),R}};function q(g,R=!0){return c.fromPrivateKey(g).toRawBytes(R)}function v(g){let R=Ne.isBytes(g),N=typeof g=="string",B=(R||N)&&g.length;return R?B===i||B===s:N?B===2*i||B===2*s:g instanceof c}function G(g,R,N=!0){if(v(g))throw new Error("first arg must be private key");if(!v(R))throw new Error("second arg must be public key");return c.fromHex(R).multiply(d(g)).toRawBytes(N)}let E=t.bits2int||function(g){let R=Ne.bytesToNumberBE(g),N=g.length*8-t.nBitLength;return N>0?R>>BigInt(N):R},j=t.bits2int_modN||function(g){return o(E(g))},Y=Ne.bitMask(t.nBitLength);function Z(g){return Ne.aInRange(`num < 2^${t.nBitLength}`,g,pr,Y),Ne.numberToBytesBE(g,t.nByteLength)}function k(g,R,N=ae){if(["recovered","canonical"].some(I=>I in N))throw new Error("sign() legacy options not supported");let{hash:B,randomBytes:H}=t,{lowS:X,prehash:ie,extraEntropy:oe}=N;X==null&&(X=!0),g=(0,bt.ensureBytes)("msgHash",g),hh(N),ie&&(g=(0,bt.ensureBytes)("prehashed msgHash",B(g)));let W=j(g),M=d(R),p=[Z(M),Z(W)];if(oe!=null&&oe!==!1){let I=oe===!0?H(r.BYTES):oe;p.push((0,bt.ensureBytes)("extraEntropy",I))}let L=Ne.concatBytes(...p),re=W;function le(I){let u=E(I);if(!h(u))return;let _=a(u),y=c.BASE.multiply(u).toAffine(),U=o(y.x);if(U===pr)return;let O=o(_*o(re+U*M));if(O===pr)return;let P=(y.x===U?0:2)|Number(y.y&ke),K=O;return X&&b(O)&&(K=l(O),P^=1),new A(U,K,P)}return{seed:L,k2sig:le}}let ae={lowS:t.lowS,prehash:!1},D={lowS:t.lowS,prehash:!1};function se(g,R,N=ae){let{seed:B,k2sig:H}=k(g,R,N),X=t;return Ne.createHmacDrbg(X.hash.outputLen,X.nByteLength,X.hmac)(B,H)}c.BASE._setWindowSize(8);function w(g,R,N,B=D){let H=g;if(R=(0,bt.ensureBytes)("msgHash",R),N=(0,bt.ensureBytes)("publicKey",N),"strict"in B)throw new Error("options.strict was renamed to lowS");hh(B);let{lowS:X,prehash:ie}=B,oe,W;try{if(typeof H=="string"||Ne.isBytes(H))try{oe=A.fromDER(H)}catch(y){if(!(y instanceof wt.DER.Err))throw y;oe=A.fromCompact(H)}else if(typeof H=="object"&&typeof H.r=="bigint"&&typeof H.s=="bigint"){let{r:y,s:U}=H;oe=new A(y,U)}else throw new Error("PARSE");W=c.fromHex(N)}catch(y){if(y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(X&&oe.hasHighS())return!1;ie&&(R=t.hash(R));let{r:M,s:p}=oe,L=j(R),re=a(p),le=o(L*re),I=o(M*re),u=c.BASE.multiplyAndAddUnsafe(W,le,I)?.toAffine();return u?o(u.x)===M:!1}return{CURVE:t,getPublicKey:q,getSharedSecret:G,sign:se,verify:w,ProjectivePoint:c,Signature:A,utils:F}}function yh(e,t){let r=e.ORDER,n=pr;for(let l=r-ke;l%En===pr;l/=En)n+=ke;let i=n,s=En<<i-ke-ke,o=s*En,a=(r-ke)/o,c=(a-ke)/En,d=o-ke,f=s,h=e.pow(t,a),m=e.pow(t,(a+ke)/En),b=(l,S)=>{let A=h,F=e.pow(S,d),q=e.sqr(F);q=e.mul(q,S);let v=e.mul(l,q);v=e.pow(v,c),v=e.mul(v,F),F=e.mul(v,S),q=e.mul(v,l);let G=e.mul(q,F);v=e.pow(G,f);let E=e.eql(v,e.ONE);F=e.mul(q,m),v=e.mul(G,A),q=e.cmov(F,q,E),G=e.cmov(v,G,E);for(let j=i;j>ke;j--){let Y=j-En;Y=En<<Y-ke;let Z=e.pow(G,Y),k=e.eql(Z,e.ONE);F=e.mul(q,A),A=e.mul(A,A),Z=e.mul(G,A),q=e.cmov(F,q,k),G=e.cmov(Z,G,k)}return{isValid:E,value:q}};if(e.ORDER%ph===ca){let l=(e.ORDER-ca)/ph,S=e.sqrt(e.neg(t));b=(A,F)=>{let q=e.sqr(F),v=e.mul(A,F);q=e.mul(q,v);let G=e.pow(q,l);G=e.mul(G,v);let E=e.mul(G,S),j=e.mul(e.sqr(G),F),Y=e.eql(j,A),Z=e.cmov(E,G,Y);return{isValid:Y,value:Z}}}return b}function Ow(e,t){if(Wn.validateField(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=yh(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,d,f,h;i=e.sqr(n),i=e.mul(i,t.Z),s=e.sqr(i),s=e.add(s,i),o=e.add(s,e.ONE),o=e.mul(o,t.B),a=e.cmov(t.Z,e.neg(s),!e.eql(s,e.ZERO)),a=e.mul(a,t.A),s=e.sqr(o),d=e.sqr(a),c=e.mul(d,t.A),s=e.add(s,c),s=e.mul(s,o),d=e.mul(d,a),c=e.mul(d,t.B),s=e.add(s,c),f=e.mul(i,o);let{isValid:m,value:b}=r(s,d);h=e.mul(i,n),h=e.mul(h,b),f=e.cmov(f,o,m),h=e.cmov(h,b,m);let l=e.isOdd(n)===e.isOdd(h);return h=e.cmov(e.neg(h),h,l),f=e.div(f,a),{x:f,y:h}}}});var Eh=ee(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});_l.bls=Sw;var mh=qr(),pl=Zt(),gh=oa(),bh=hl(),Aw=BigInt(0),ua=BigInt(1),wh=BigInt(2),Ai=BigInt(3);function Nw(e){let t=[];for(;e>ua;e>>=ua)(e&ua)===Aw?t.unshift(0):(e&Ai)===Ai?(t.unshift(-1),e+=ua):t.unshift(1);return t}function Sw(e){let{Fp:t,Fr:r,Fp2:n,Fp6:i,Fp12:s}=e.fields,o=e.params.xNegative,a=e.params.twistType,c=(0,bh.weierstrassPoints)({n:r.ORDER,...e.G1}),d=Object.assign(c,(0,gh.createHasher)(c.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),f=(0,bh.weierstrassPoints)({n:r.ORDER,...e.G2}),h=Object.assign(f,(0,gh.createHasher)(f.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults})),m;if(a==="multiplicative")m=(W,M,p,L,re,le)=>s.mul014(L,W,n.mul(M,re),n.mul(p,le));else if(a==="divisive")m=(W,M,p,L,re,le)=>s.mul034(L,n.mul(p,le),n.mul(M,re),W);else throw new Error("bls: unknown twist type");let b=n.div(n.ONE,n.mul(n.ONE,wh));function l(W,M,p,L){let re=n.sqr(p),le=n.sqr(L),I=n.mulByB(n.mul(le,Ai)),u=n.mul(I,Ai),_=n.sub(n.sub(n.sqr(n.add(p,L)),le),re),y=n.sub(I,re),U=n.mul(n.sqr(M),Ai),O=n.neg(_);return W.push([y,U,O]),M=n.mul(n.mul(n.mul(n.sub(re,u),M),p),b),p=n.sub(n.sqr(n.mul(n.add(re,u),b)),n.mul(n.sqr(I),Ai)),L=n.mul(re,_),{Rx:M,Ry:p,Rz:L}}function S(W,M,p,L,re,le){let I=n.sub(p,n.mul(le,L)),u=n.sub(M,n.mul(re,L)),_=n.sub(n.mul(I,re),n.mul(u,le)),y=n.neg(I),U=u;W.push([_,y,U]);let O=n.sqr(u),P=n.mul(O,u),K=n.mul(O,M),x=n.add(n.sub(P,n.mul(K,wh)),n.mul(n.sqr(I),L));return M=n.mul(u,x),p=n.sub(n.mul(n.sub(K,x),I),n.mul(P,p)),L=n.mul(L,P),{Rx:M,Ry:p,Rz:L}}let A=Nw(e.params.ateLoopSize),F=(0,pl.memoized)(W=>{let M=W,{x:p,y:L}=M.toAffine(),re=p,le=L,I=n.neg(L),u=re,_=le,y=n.ONE,U=[];for(let O of A){let P=[];({Rx:u,Ry:_,Rz:y}=l(P,u,_,y)),O&&({Rx:u,Ry:_,Rz:y}=S(P,u,_,y,re,O===-1?I:le)),U.push(P)}if(e.postPrecompute){let O=U[U.length-1];e.postPrecompute(u,_,y,re,le,S.bind(null,O))}return U});function q(W,M=!1){let p=s.ONE;if(W.length){let L=W[0][0].length;for(let re=0;re<L;re++){p=s.sqr(p);for(let[le,I,u]of W)for(let[_,y,U]of le[re])p=m(_,y,U,p,I,u)}}return o&&(p=s.conjugate(p)),M?s.finalExponentiate(p):p}function v(W,M=!0){let p=[];d.ProjectivePoint.normalizeZ(W.map(({g1:L})=>L)),h.ProjectivePoint.normalizeZ(W.map(({g2:L})=>L));for(let{g1:L,g2:re}of W){if(L.equals(d.ProjectivePoint.ZERO)||re.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");L.assertValidity(),re.assertValidity();let le=L.toAffine();p.push([F(re),le.x,le.y])}return q(p,M)}function G(W,M,p=!0){return v([{g1:W,g2:M}],p)}let E={randomPrivateKey:()=>{let W=(0,mh.getMinHashLength)(r.ORDER);return(0,mh.mapHashToField)(e.randomBytes(W),r.ORDER)},calcPairingPrecomputes:F},{ShortSignature:j}=e.G1,{Signature:Y}=e.G2;function Z(W){return W instanceof d.ProjectivePoint?W:d.ProjectivePoint.fromHex(W)}function k(W,M){return W instanceof d.ProjectivePoint?W:d.hashToCurve((0,pl.ensureBytes)("point",W),M)}function ae(W){return W instanceof h.ProjectivePoint?W:Y.fromHex(W)}function D(W,M){return W instanceof h.ProjectivePoint?W:h.hashToCurve((0,pl.ensureBytes)("point",W),M)}function se(W){return d.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function w(W){return h.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function g(W,M,p){let L=D(W,p);L.assertValidity();let re=L.multiply(d.normPrivateKeyToScalar(M));return W instanceof h.ProjectivePoint?re:Y.toRawBytes(re)}function R(W,M,p){let L=k(W,p);L.assertValidity();let re=L.multiply(d.normPrivateKeyToScalar(M));return W instanceof d.ProjectivePoint?re:j.toRawBytes(re)}function N(W,M,p,L){let re=Z(p),le=D(M,L),I=d.ProjectivePoint.BASE,u=ae(W),_=v([{g1:re.negate(),g2:le},{g1:I,g2:u}]);return s.eql(_,s.ONE)}function B(W,M,p,L){let re=ae(p),le=k(M,L),I=h.ProjectivePoint.BASE,u=Z(W),_=v([{g1:le,g2:re},{g1:u,g2:I.negate()}]);return s.eql(_,s.ONE)}function H(W){if(!W.length)throw new Error("Expected non-empty array");let p=W.map(Z).reduce((L,re)=>L.add(re),d.ProjectivePoint.ZERO);return W[0]instanceof d.ProjectivePoint?(p.assertValidity(),p):p.toRawBytes(!0)}function X(W){if(!W.length)throw new Error("Expected non-empty array");let p=W.map(ae).reduce((L,re)=>L.add(re),h.ProjectivePoint.ZERO);return W[0]instanceof h.ProjectivePoint?(p.assertValidity(),p):Y.toRawBytes(p)}function ie(W){if(!W.length)throw new Error("Expected non-empty array");let p=W.map(Z).reduce((L,re)=>L.add(re),d.ProjectivePoint.ZERO);return W[0]instanceof d.ProjectivePoint?(p.assertValidity(),p):j.toRawBytes(p)}function oe(W,M,p,L){if(!M.length)throw new Error("Expected non-empty messages array");if(p.length!==M.length)throw new Error("Pubkey count should equal msg count");let re=ae(W),le=M.map(y=>D(y,L)),I=p.map(Z),u=new Map;for(let y=0;y<I.length;y++){let U=I[y],O=le[y],P=u.get(O);P===void 0&&(P=[],u.set(O,P)),P.push(U)}let _=[];try{for(let[y,U]of u){let O=U.reduce((P,K)=>P.add(K));_.push({g1:O,g2:y})}return _.push({g1:d.ProjectivePoint.BASE.negate(),g2:re}),s.eql(v(_),s.ONE)}catch{return!1}}return d.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:se,getPublicKeyForShortSignatures:w,sign:g,signShortSignature:R,verify:N,verifyBatch:oe,verifyShortSignature:B,aggregatePublicKeys:H,aggregateSignatures:X,aggregateShortSignatures:ie,millerLoopBatch:q,pairing:G,pairingBatch:v,G1:d,G2:h,Signature:Y,ShortSignature:j,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:E}}});var Th=ee(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.psiFrobenius=Bw;la.tower12=Pw;var xn=qr(),_r=Zt(),Rw=BigInt(0),Ni=BigInt(1),rn=BigInt(2),xh=BigInt(3);function yl(e,t,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let d=0;d<i;d++){let f=BigInt(d+1),h=[];for(let m=0,b=Ni;m<n;m++){let l=(f*b-f)/o%a;h.push(e.pow(t,l)),b*=r}c.push(h)}return c}function Bw(e,t,r){let n=t.pow(r,(e.ORDER-Ni)/xh),i=t.pow(r,(e.ORDER-Ni)/rn);function s(m,b){let l=t.mul(t.frobeniusMap(m,1),n),S=t.mul(t.frobeniusMap(b,1),i);return[l,S]}let o=t.pow(r,(e.ORDER**rn-Ni)/xh),a=t.pow(r,(e.ORDER**rn-Ni)/rn);if(!t.eql(a,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(m,b){return[t.mul(m,o),t.neg(b)]}let d=m=>(b,l)=>{let S=l.toAffine(),A=m(S.x,S.y);return b.fromAffine({x:A[0],y:A[1]})},f=d(s),h=d(c);return{psi:s,psi2:c,G2psi:f,G2psi2:h,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function Pw(e){let{ORDER:t}=e,r=xn.Field(t),n=r.create(e.NONRESIDUE||BigInt(-1)),i=xn.FpLegendre(t),s=r.div(r.ONE,rn),o=yl(r,n,r.ORDER,2)[0],a=({c0:w,c1:g},{c0:R,c1:N})=>({c0:r.add(w,R),c1:r.add(g,N)}),c=({c0:w,c1:g},{c0:R,c1:N})=>({c0:r.sub(w,R),c1:r.sub(g,N)}),d=({c0:w,c1:g},R)=>{if(typeof R=="bigint")return{c0:r.mul(w,R),c1:r.mul(g,R)};let{c0:N,c1:B}=R,H=r.mul(w,N),X=r.mul(g,B),ie=r.sub(H,X),oe=r.sub(r.mul(r.add(w,g),r.add(N,B)),r.add(H,X));return{c0:ie,c1:oe}},f=({c0:w,c1:g})=>{let R=r.add(w,g),N=r.sub(w,g),B=r.add(w,w);return{c0:r.mul(R,N),c1:r.mul(B,g)}},h=w=>{if(w.length!==2)throw new Error("Invalid tuple");let g=w.map(R=>r.create(R));return{c0:g[0],c1:g[1]}},m=t*t,b=h(e.FP2_NONRESIDUE),l={ORDER:m,NONRESIDUE:b,BITS:(0,_r.bitLen)(m),BYTES:Math.ceil((0,_r.bitLen)(m)/8),MASK:(0,_r.bitMask)((0,_r.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:R,c1:N})=>r.eql(w,R)&&r.eql(g,N),neg:({c0:w,c1:g})=>({c0:r.neg(w),c1:r.neg(g)}),pow:(w,g)=>xn.FpPow(l,w,g),invertBatch:w=>xn.FpInvertBatch(l,w),add:a,sub:c,mul:d,sqr:f,addN:a,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 R=r.inv(r.create(w*w+g*g));return{c0:r.mul(R,r.create(w)),c1:r.mul(R,r.create(-g))}},sqrt:w=>{if(e.Fp2sqrt)return e.Fp2sqrt(w);let{c0:g,c1:R}=w;if(r.is0(R))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 N=r.sqrt(r.sub(r.sqr(g),r.mul(r.sqr(R),n))),B=r.mul(r.add(N,g),s),H=i(r,B);!r.is0(H)&&!r.eql(H,r.ONE)&&(B=r.sub(B,N));let X=r.sqrt(B),ie=l.create({c0:X,c1:r.div(r.mul(R,s),X)});if(!l.eql(l.sqr(ie),w))throw new Error("Cannot find square root");let oe=ie,W=l.neg(oe),{re:M,im:p}=l.reim(oe),{re:L,im:re}=l.reim(W);return p>re||p===re&&M>L?oe:W},isOdd:w=>{let{re:g,im:R}=l.reim(w),N=g%rn,B=g===Rw,H=R%rn;return BigInt(N||B&&H)==Ni},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,_r.concatBytes)(r.toBytes(w),r.toBytes(g)),cmov:({c0:w,c1:g},{c0:R,c1:N},B)=>({c0:r.cmov(w,R,B),c1:r.cmov(g,N,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:h,frobeniusMap:({c0:w,c1:g},R)=>({c0:w,c1:r.mul(g,o[R%2])})},S=({c0:w,c1:g,c2:R},{c0:N,c1:B,c2:H})=>({c0:l.add(w,N),c1:l.add(g,B),c2:l.add(R,H)}),A=({c0:w,c1:g,c2:R},{c0:N,c1:B,c2:H})=>({c0:l.sub(w,N),c1:l.sub(g,B),c2:l.sub(R,H)}),F=({c0:w,c1:g,c2:R},N)=>{if(typeof N=="bigint")return{c0:l.mul(w,N),c1:l.mul(g,N),c2:l.mul(R,N)};let{c0:B,c1:H,c2:X}=N,ie=l.mul(w,B),oe=l.mul(g,H),W=l.mul(R,X);return{c0:l.add(ie,l.mulByNonresidue(l.sub(l.mul(l.add(g,R),l.add(H,X)),l.add(oe,W)))),c1:l.add(l.sub(l.mul(l.add(w,g),l.add(B,H)),l.add(ie,oe)),l.mulByNonresidue(W)),c2:l.sub(l.add(oe,l.mul(l.add(w,R),l.add(B,X))),l.add(ie,W))}},q=({c0:w,c1:g,c2:R})=>{let N=l.sqr(w),B=l.mul(l.mul(w,g),rn),H=l.mul(l.mul(g,R),rn),X=l.sqr(R);return{c0:l.add(l.mulByNonresidue(H),N),c1:l.add(l.mulByNonresidue(X),B),c2:l.sub(l.sub(l.add(l.add(B,l.sqr(l.add(l.sub(w,g),R))),H),N),X)}},[v,G]=yl(l,b,r.ORDER,6,2,3),E={ORDER:l.ORDER,BITS:3*l.BITS,BYTES:3*l.BYTES,MASK:(0,_r.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:R})=>l.isValid(w)&&l.isValid(g)&&l.isValid(R),is0:({c0:w,c1:g,c2:R})=>l.is0(w)&&l.is0(g)&&l.is0(R),neg:({c0:w,c1:g,c2:R})=>({c0:l.neg(w),c1:l.neg(g),c2:l.neg(R)}),eql:({c0:w,c1:g,c2:R},{c0:N,c1:B,c2:H})=>l.eql(w,N)&&l.eql(g,B)&&l.eql(R,H),sqrt:_r.notImplemented,div:(w,g)=>E.mul(w,typeof g=="bigint"?r.inv(r.create(g)):E.inv(g)),pow:(w,g)=>xn.FpPow(E,w,g),invertBatch:w=>xn.FpInvertBatch(E,w),add:S,sub:A,mul:F,sqr:q,addN:S,subN:A,mulN:F,sqrN:q,inv:({c0:w,c1:g,c2:R})=>{let N=l.sub(l.sqr(w),l.mulByNonresidue(l.mul(R,g))),B=l.sub(l.mulByNonresidue(l.sqr(R)),l.mul(w,g)),H=l.sub(l.sqr(g),l.mul(w,R)),X=l.inv(l.add(l.mulByNonresidue(l.add(l.mul(R,B),l.mul(g,H))),l.mul(w,N)));return{c0:l.mul(X,N),c1:l.mul(X,B),c2:l.mul(X,H)}},fromBytes:w=>{if(w.length!==E.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:R})=>(0,_r.concatBytes)(l.toBytes(w),l.toBytes(g),l.toBytes(R)),cmov:({c0:w,c1:g,c2:R},{c0:N,c1:B,c2:H},X)=>({c0:l.cmov(w,N,X),c1:l.cmov(g,B,X),c2:l.cmov(R,H,X)}),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:R},N)=>({c0:l.frobeniusMap(w,N),c1:l.mul(l.frobeniusMap(g,N),v[N%6]),c2:l.mul(l.frobeniusMap(R,N),G[N%6])}),mulByFp2:({c0:w,c1:g,c2:R},N)=>({c0:l.mul(w,N),c1:l.mul(g,N),c2:l.mul(R,N)}),mulByNonresidue:({c0:w,c1:g,c2:R})=>({c0:l.mulByNonresidue(R),c1:w,c2:g}),mul1:({c0:w,c1:g,c2:R},N)=>({c0:l.mulByNonresidue(l.mul(R,N)),c1:l.mul(w,N),c2:l.mul(g,N)}),mul01({c0:w,c1:g,c2:R},N,B){let H=l.mul(w,N),X=l.mul(g,B);return{c0:l.add(l.mulByNonresidue(l.sub(l.mul(l.add(g,R),B),X)),H),c1:l.sub(l.sub(l.mul(l.add(N,B),l.add(w,g)),H),X),c2:l.add(l.sub(l.mul(l.add(w,R),N),H),X)}}},j=yl(l,b,r.ORDER,12,1,6)[0],Y=({c0:w,c1:g},{c0:R,c1:N})=>({c0:E.add(w,R),c1:E.add(g,N)}),Z=({c0:w,c1:g},{c0:R,c1:N})=>({c0:E.sub(w,R),c1:E.sub(g,N)}),k=({c0:w,c1:g},R)=>{if(typeof R=="bigint")return{c0:E.mul(w,R),c1:E.mul(g,R)};let{c0:N,c1:B}=R,H=E.mul(w,N),X=E.mul(g,B);return{c0:E.add(H,E.mulByNonresidue(X)),c1:E.sub(E.mul(E.add(w,g),E.add(N,B)),E.add(H,X))}},ae=({c0:w,c1:g})=>{let R=E.mul(w,g);return{c0:E.sub(E.sub(E.mul(E.add(E.mulByNonresidue(g),w),E.add(w,g)),R),E.mulByNonresidue(R)),c1:E.add(R,R)}};function D(w,g){let R=l.sqr(w),N=l.sqr(g);return{first:l.add(l.mulByNonresidue(N),R),second:l.sub(l.sub(l.sqr(l.add(w,g)),R),N)}}let se={ORDER:l.ORDER,BITS:2*l.BITS,BYTES:2*l.BYTES,MASK:(0,_r.bitMask)(2*l.BITS),ZERO:{c0:E.ZERO,c1:E.ZERO},ONE:{c0:E.ONE,c1:E.ZERO},create:w=>w,isValid:({c0:w,c1:g})=>E.isValid(w)&&E.isValid(g),is0:({c0:w,c1:g})=>E.is0(w)&&E.is0(g),neg:({c0:w,c1:g})=>({c0:E.neg(w),c1:E.neg(g)}),eql:({c0:w,c1:g},{c0:R,c1:N})=>E.eql(w,R)&&E.eql(g,N),sqrt:_r.notImplemented,inv:({c0:w,c1:g})=>{let R=E.inv(E.sub(E.sqr(w),E.mulByNonresidue(E.sqr(g))));return{c0:E.mul(w,R),c1:E.neg(E.mul(g,R))}},div:(w,g)=>se.mul(w,typeof g=="bigint"?r.inv(r.create(g)):se.inv(g)),pow:(w,g)=>xn.FpPow(se,w,g),invertBatch:w=>xn.FpInvertBatch(se,w),add:Y,sub:Z,mul:k,sqr:ae,addN:Y,subN:Z,mulN:k,sqrN:ae,fromBytes:w=>{if(w.length!==se.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:E.fromBytes(w.subarray(0,E.BYTES)),c1:E.fromBytes(w.subarray(E.BYTES))}},toBytes:({c0:w,c1:g})=>(0,_r.concatBytes)(E.toBytes(w),E.toBytes(g)),cmov:({c0:w,c1:g},{c0:R,c1:N},B)=>({c0:E.cmov(w,R,B),c1:E.cmov(g,N,B)}),fromBigTwelve:w=>({c0:E.fromBigSix(w.slice(0,6)),c1:E.fromBigSix(w.slice(6,12))}),frobeniusMap(w,g){let{c0:R,c1:N,c2:B}=E.frobeniusMap(w.c1,g),H=j[g%12];return{c0:E.frobeniusMap(w.c0,g),c1:E.create({c0:l.mul(R,H),c1:l.mul(N,H),c2:l.mul(B,H)})}},mulByFp2:({c0:w,c1:g},R)=>({c0:E.mulByFp2(w,R),c1:E.mulByFp2(g,R)}),conjugate:({c0:w,c1:g})=>({c0:w,c1:E.neg(g)}),mul014:({c0:w,c1:g},R,N,B)=>{let H=E.mul01(w,R,N),X=E.mul1(g,B);return{c0:E.add(E.mulByNonresidue(X),H),c1:E.sub(E.sub(E.mul01(E.add(g,w),R,l.add(N,B)),H),X)}},mul034:({c0:w,c1:g},R,N,B)=>{let H=E.create({c0:l.mul(w.c0,R),c1:l.mul(w.c1,R),c2:l.mul(w.c2,R)}),X=E.mul01(g,N,B),ie=E.mul01(E.add(w,g),l.add(R,N),B);return{c0:E.add(E.mulByNonresidue(X),H),c1:E.sub(ie,E.add(H,X))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:r,Fp2:l,Fp6:E,Fp4Square:D,Fp12:se}}});var Uh=ee(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.bls12_381=void 0;var Sh=po(),Uw=Hn(),Fw=Eh(),Cw=qr(),Se=Zt(),Rh=oa(),Bh=hl(),Ph=Th(),Mt=BigInt(0),ha=BigInt(1),_t=BigInt(2),da=BigInt(3),bs=BigInt(4),Tn=BigInt("0xd201000000010000"),Mw=(0,Se.bitLen)(Tn),{Fp:he,Fp2:pe,Fp6:bl,Fp4Square:ml,Fp12:Te}=(0,Ph.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[ha,ha],Fp2mulByB:({c0:e,c1:t})=>{let r=he.mul(e,bs),n=he.mul(t,bs);return{c0:he.sub(r,n),c1:he.add(r,n)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{let{c0:r,c1:n,c2:i}=e,{c0:s,c1:o,c2:a}=t,{first:c,second:d}=ml(r,o),{first:f,second:h}=ml(s,i),{first:m,second:b}=ml(n,a),l=pe.mulByNonresidue(b);return{c0:bl.create({c0:pe.add(pe.mul(pe.sub(c,r),_t),c),c1:pe.add(pe.mul(pe.sub(f,n),_t),f),c2:pe.add(pe.mul(pe.sub(m,i),_t),m)}),c1:bl.create({c0:pe.add(pe.mul(pe.add(l,s),_t),l),c1:pe.add(pe.mul(pe.add(d,o),_t),d),c2:pe.add(pe.mul(pe.add(h,a),_t),h)})}},Fp12cyclotomicExp(e,t){let r=Te.ONE;for(let n=Mw-1;n>=0;n--)r=Te._cyclotomicSquare(r),(0,Se.bitGet)(t,n)&&(r=Te.mul(r,e));return r},Fp12finalExponentiate:e=>{let t=Tn,r=Te.div(Te.frobeniusMap(e,6),e),n=Te.mul(Te.frobeniusMap(r,2),r),i=Te.conjugate(Te._cyclotomicExp(n,t)),s=Te.mul(Te.conjugate(Te._cyclotomicSquare(n)),i),o=Te.conjugate(Te._cyclotomicExp(s,t)),a=Te.conjugate(Te._cyclotomicExp(o,t)),c=Te.mul(Te.conjugate(Te._cyclotomicExp(a,t)),Te._cyclotomicSquare(i)),d=Te.conjugate(Te._cyclotomicExp(c,t)),f=Te.frobeniusMap(Te.mul(i,a),2),h=Te.frobeniusMap(Te.mul(o,n),3),m=Te.frobeniusMap(Te.mul(c,Te.conjugate(n)),1),b=Te.mul(Te.mul(d,Te.conjugate(s)),n);return Te.mul(Te.mul(Te.mul(f,h),m),b)}}),vh=Cw.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),qw=(0,Rh.isogenyMap)(pe,[[["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=>pe.fromBigTuple(t.map(BigInt))))),jw=(0,Rh.isogenyMap)(he,[["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)))),kw=(0,Bh.mapToCurveSimpleSWU)(pe,{A:pe.create({c0:he.create(Mt),c1:he.create(BigInt(240))}),B:pe.create({c0:he.create(BigInt(1012)),c1:he.create(BigInt(1012))}),Z:pe.create({c0:he.create(BigInt(-2)),c1:he.create(BigInt(-1))})}),Vw=(0,Bh.mapToCurveSimpleSWU)(he,{A:he.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:he.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:he.create(BigInt(11))}),{G2psi:Oh,G2psi2:Hw}=(0,Ph.psiFrobenius)(he,pe,pe.div(pe.ONE,pe.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:he.ORDER,m:2,k:128,expand:"xmd",hash:Sh.sha256}),pa=ws(he.toBytes(Mt),{infinity:!0,compressed:!0});function fa(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 ws(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 Ah(e){e.assertValidity();let t=e.equals(qt.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=e.toAffine();if(t)return pa.slice();let i=he.ORDER,s=!!(n*_t/i);return ws((0,Se.numberToBytesBE)(r,he.BYTES),{compressed:!0,sort:s})}function Nh(e){e.assertValidity();let t=he.BYTES;if(e.equals(qt.bls12_381.G2.ProjectivePoint.ZERO))return(0,Se.concatBytes)(pa,(0,Se.numberToBytesBE)(Mt,t));let{x:r,y:n}=e.toAffine(),{re:i,im:s}=pe.reim(r),{re:o,im:a}=pe.reim(n),d=!!((a>Mt?a*_t:o*_t)/he.ORDER&ha),f=i;return(0,Se.concatBytes)(ws((0,Se.numberToBytesBE)(s,t),{sort:d,compressed:!0}),(0,Se.numberToBytesBE)(f,t))}qt.bls12_381=(0,Fw.bls)({fields:{Fp:he,Fp2:pe,Fp6:bl,Fp12:Te,Fr:vh},G1:{Fp:he,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:he.ZERO,b:bs,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(he.mul(t.px,r),t.py,t.pz);return t.multiplyUnsafe(Tn).negate().multiplyUnsafe(Tn).equals(n)},clearCofactor:(e,t)=>t.multiplyUnsafe(Tn).add(t),mapToCurve:e=>{let{x:t,y:r}=Vw(he.create(e[0]));return jw(t,r)},fromBytes:e=>{let{compressed:t,infinity:r,sort:n,value:i}=fa(e);if(i.length===48&&t){let s=he.ORDER,o=(0,Se.bytesToNumberBE)(i),a=he.create(o&he.MASK);if(r){if(a!==Mt)throw new Error("G1: non-empty compressed point at infinity");return{x:Mt,y:Mt}}let c=he.add(he.pow(a,da),he.create(qt.bls12_381.params.G1b)),d=he.sqrt(c);if(!d)throw new Error("Invalid compressed G1 point");return d*_t/s!==BigInt(n)&&(d=he.neg(d)),{x:he.create(a),y:he.create(d)}}else if(i.length===96&&!t){let s=(0,Se.bytesToNumberBE)(i.subarray(0,he.BYTES)),o=(0,Se.bytesToNumberBE)(i.subarray(he.BYTES));if(r){if(s!==Mt||o!==Mt)throw new Error("G1: non-empty point at infinity");return qt.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:he.create(s),y:he.create(o)}}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 pa.slice();let o=he.ORDER,a=!!(s*_t/o);return ws((0,Se.numberToBytesBE)(i,he.BYTES),{compressed:!0,sort:a})}else return n?(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(2*he.BYTES-1)):(0,Se.concatBytes)((0,Se.numberToBytesBE)(i,he.BYTES),(0,Se.numberToBytesBE)(s,he.BYTES))},ShortSignature:{fromHex(e){let{infinity:t,sort:r,value:n}=fa((0,Se.ensureBytes)("signatureHex",e,48)),i=he.ORDER,s=(0,Se.bytesToNumberBE)(n);if(t)return qt.bls12_381.G1.ProjectivePoint.ZERO;let o=he.create(s&he.MASK),a=he.add(he.pow(o,da),he.create(qt.bls12_381.params.G1b)),c=he.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let d=BigInt(r);c*_t/i!==d&&(c=he.neg(c));let f=qt.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return f.assertValidity(),f},toRawBytes(e){return Ah(e)},toHex(e){return(0,Se.bytesToHex)(Ah(e))}}},G2:{Fp:pe,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:pe.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:pe.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:pe.ZERO,b:pe.fromBigTuple([bs,bs]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...gl},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{let{x:t,y:r}=kw(pe.fromBigTuple(e));return qw(t,r)},isTorsionFree:(e,t)=>t.multiplyUnsafe(Tn).negate().equals(Oh(e,t)),clearCofactor:(e,t)=>{let r=Tn,n=t.multiplyUnsafe(r).negate(),i=Oh(e,t),s=t.double();return s=Hw(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}=fa(e);if(!t&&!r&&n||!t&&r&&n||n&&r&&t)throw new Error("Invalid encoding flag: "+(e[0]&224));let s=he.BYTES,o=(a,c,d)=>(0,Se.bytesToNumberBE)(a.slice(c,d));if(i.length===96&&t){let a=qt.bls12_381.params.G2b,c=he.ORDER;if(r){if(i.reduce((S,A)=>S!==0?A+1:A,0)>0)throw new Error("Invalid compressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let d=o(i,0,s),f=o(i,s,2*s),h=pe.create({c0:he.create(f),c1:he.create(d)}),m=pe.add(pe.pow(h,da),a),b=pe.sqrt(m),l=b.c1===Mt?b.c0*_t/c:b.c1*_t/c?ha:Mt;return b=n&&l>0?b:pe.neg(b),{x:h,y:b}}else if(i.length===192&&!t){if(r){if(i.reduce((h,m)=>h!==0?m+1:m,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),d=o(i,2*s,3*s),f=o(i,3*s,4*s);return{x:pe.fromBigTuple([c,a]),y:pe.fromBigTuple([f,d])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(e,t,r)=>{let{BYTES:n,ORDER:i}=he,s=t.equals(e.ZERO),{x:o,y:a}=t.toAffine();if(r){if(s)return(0,Se.concatBytes)(pa,(0,Se.numberToBytesBE)(Mt,n));let c=!!(a.c1===Mt?a.c0*_t/i:a.c1*_t/i);return(0,Se.concatBytes)(ws((0,Se.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,Se.numberToBytesBE)(o.c0,n))}else{if(s)return(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:d}=pe.reim(o),{re:f,im:h}=pe.reim(a);return(0,Se.concatBytes)((0,Se.numberToBytesBE)(d,n),(0,Se.numberToBytesBE)(c,n),(0,Se.numberToBytesBE)(h,n),(0,Se.numberToBytesBE)(f,n))}},Signature:{fromHex(e){let{infinity:t,sort:r,value:n}=fa((0,Se.ensureBytes)("signatureHex",e)),i=he.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=(0,Se.bytesToNumberBE)(n.slice(0,s)),a=(0,Se.bytesToNumberBE)(n.slice(s));if(t)return qt.bls12_381.G2.ProjectivePoint.ZERO;let c=he.create(o&he.MASK),d=he.create(a),f=pe.create({c0:d,c1:c}),h=pe.add(pe.pow(f,da),qt.bls12_381.params.G2b),m=pe.sqrt(h);if(!m)throw new Error("Failed to find a square root");let{re:b,im:l}=pe.reim(m),S=BigInt(r),A=l>Mt&&l*_t/i!==S,F=l===Mt&&b*_t/i!==S;(A||F)&&(m=pe.neg(m));let q=qt.bls12_381.G2.ProjectivePoint.fromAffine({x:f,y:m});return q.assertValidity(),q},toRawBytes(e){return Nh(e)},toHex(e){return(0,Se.bytesToHex)(Nh(e))}}},params:{ateLoopSize:Tn,r:vh.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:gl,hash:Sh.sha256,randomBytes:Uw.randomBytes})});var El=ee(Es=>{"use strict";Object.defineProperty(Es,"__esModule",{value:!0});Es.blsVerify=Es.verify=void 0;var Kw=Uh(),wl=Kt();function $w(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 Kw.bls12_381.verifyShortSignature(i,s,n)}Es.blsVerify=$w});var _a=ee(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.decodeTime=zn.decodeLeb128=void 0;var Fh=xi(),Gw=e=>(0,Fh.lebDecode)(new Fh.PipeArrayBuffer(e));zn.decodeLeb128=Gw;var Yw=e=>{let t=(0,zn.decodeLeb128)(e);return new Date(Number(t)/1e6)};zn.decodeTime=Yw});var Si=ee(ve=>{"use strict";var Ww=ve&&ve.__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]}),zw=ve&&ve.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ch=ve&&ve.__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)&&Ww(t,e,r);return zw(t,e),t},Jw=ve&&ve.__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},Zw=ve&&ve.__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)},ma;Object.defineProperty(ve,"__esModule",{value:!0});ve.check_canister_ranges=ve.find_label=ve.flatten_forks=ve.lookup_path=ve.LookupStatus=ve.reconstruct=ve.lookupResultToBuffer=ve.Certificate=ve.hashTreeToString=ve.NodeType=ve.CertificateVerificationError=void 0;var Mh=Ch(_s()),Xw=_i(),ya=fs(),yr=Kt(),xl=Ft(),Qw=Ch(El()),Iw=_a(),Dw=As(),nn=class extends Xw.AgentError{constructor(t){super(`Invalid certificate: ${t}`)}};ve.CertificateVerificationError=nn;var Et;(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"})(Et=ve.NodeType||(ve.NodeType={}));function ga(e){let t=n=>n.split(`
16
+ `)}return c.encodeValue(d)}));return(0,Ue.concat)(n,i,s,o,a)}J.encode=Wg;function Jg(e,t){let r=new Ue.PipeArrayBuffer(t);if(t.byteLength<To.length)throw new Error("Message length smaller than magic number");let n=(0,ce.safeRead)(r,To.length),i=new TextDecoder().decode(n);if(i!==To)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(b){let l=[],S=Number((0,ce.lebDecode)(b));for(let q=0;q<S;q++){let O=Number((0,ce.slebDecode)(b));switch(O){case-18:case-19:{let G=Number((0,ce.slebDecode)(b));l.push([O,G]);break}case-20:case-21:{let G=[],E=Number((0,ce.lebDecode)(b)),j;for(;E--;){let Y=Number((0,ce.lebDecode)(b));if(Y>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof j=="number"&&j>=Y)throw new Error("field id collision or not sorted");j=Y;let z=Number((0,ce.slebDecode)(b));G.push([Y,z])}l.push([O,G]);break}case-22:{let G=[],E=Number((0,ce.lebDecode)(b));for(;E--;)G.push(Number((0,ce.slebDecode)(b)));let j=[],Y=Number((0,ce.lebDecode)(b));for(;Y--;)j.push(Number((0,ce.slebDecode)(b)));let z=[],k=Number((0,ce.lebDecode)(b));for(;k--;)switch(Number((0,ce.lebDecode)(b))){case 1:{z.push("query");break}case 2:{z.push("oneway");break}case 3:{z.push("composite_query");break}default:throw new Error("unknown annotation")}l.push([O,[G,j,z]]);break}case-23:{let G=Number((0,ce.lebDecode)(b)),E=[];for(;G--;){let j=Number((0,ce.lebDecode)(b)),Y=new TextDecoder().decode((0,ce.safeRead)(b,j)),z=(0,ce.slebDecode)(b);E.push([Y,z])}l.push([O,E]);break}default:throw new Error("Illegal op_code: "+O)}}let N=[],F=Number((0,ce.lebDecode)(b));for(let q=0;q<F;q++)N.push(Number((0,ce.slebDecode)(b)));return[l,N]}let[o,a]=s(r);if(a.length<e.length)throw new Error("Wrong number of return values");let c=o.map(b=>Qf());function d(b){if(b<-24)throw new Error("future value not supported");if(b<0)switch(b){case-1:return J.Null;case-2:return J.Bool;case-3:return J.Nat;case-4:return J.Int;case-5:return J.Nat8;case-6:return J.Nat16;case-7:return J.Nat32;case-8:return J.Nat64;case-9:return J.Int8;case-10:return J.Int16;case-11:return J.Int32;case-12:return J.Int64;case-13:return J.Float32;case-14:return J.Float64;case-15:return J.Text;case-16:return J.Reserved;case-17:return J.Empty;case-24:return J.Principal;default:throw new Error("Illegal op_code: "+b)}if(b>=o.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 Wf(l)}case-18:{let l=d(b[1]);return Jf(l)}case-20:{let l={};for(let[F,q]of b[1]){let O=`_${F}_`;l[O]=d(q)}let S=Zf(l),N=S.tryAsTuple();return Array.isArray(N)?zf(...N):S}case-21:{let l={};for(let[S,N]of b[1]){let F=`_${S}_`;l[F]=d(N)}return Xf(l)}case-22:{let[l,S,N]=b[1];return If(l.map(F=>d(F)),S.map(F=>d(F)),N)}case-23:{let l={},S=b[1];for(let[N,F]of S){let q=d(F);if(q instanceof _n&&(q=q.getType()),!(q instanceof ss))throw new Error("Illegal service definition: services can only contain functions");l[N]=q}return Df(l)}default:throw new Error("Illegal op_code: "+b[0])}}o.forEach((b,l)=>{if(b[0]===-22){let S=f(b);c[l].fill(S)}}),o.forEach((b,l)=>{if(b[0]!==-22){let S=f(b);c[l].fill(S)}});let h=a.map(b=>d(b)),m=e.map((b,l)=>b.decodeValue(r,h[l]));for(let b=e.length;b<h.length;b++)h[b].decodeValue(r,h[b]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return m}J.decode=Jg;J.Empty=new Oo;J.Reserved=new gi;J.Unknown=new vo;J.Bool=new No;J.Null=new Ao;J.Text=new So;J.Int=new Ro;J.Nat=new Bo;J.Float32=new ns(32);J.Float64=new ns(64);J.Int8=new Lr(8);J.Int16=new Lr(16);J.Int32=new Lr(32);J.Int64=new Lr(64);J.Nat8=new Fr(8);J.Nat16=new Fr(16);J.Nat32=new Fr(32);J.Nat64=new Fr(64);J.Principal=new Co;function zf(...e){return new Uo(e)}J.Tuple=zf;function Wf(e){return new Po(e)}J.Vec=Wf;function Jf(e){return new bi(e)}J.Opt=Jf;function Zf(e){return new is(e)}J.Record=Zf;function Xf(e){return new Fo(e)}J.Variant=Xf;function Qf(){return new _n}J.Rec=Qf;function If(e,t,r=[]){return new ss(e,t,r)}J.Func=If;function Df(e){return new Mo(e)}J.Service=Df});var yu=ee(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.VecForm=Nt.OptionForm=Nt.VariantForm=Nt.TupleForm=Nt.RecordForm=Nt.InputForm=Nt.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)}};Nt.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)}};Nt.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 o=this.form[s].parse(t);r[n]=o}),!this.form.some(n=>n.isRejected()))return r}};Nt.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}};Nt.TupleForm=fu;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}};Nt.VariantForm=hu;var pu=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]}}};Nt.OptionForm=pu;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}};Nt.VecForm=_u});var e0=ee(Ee=>{"use strict";var Zg=Ee&&Ee.__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]}),Xg=Ee&&Ee.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Lf=Ee&&Ee.__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)&&Zg(t,e,r);return Xg(t,e),t};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.renderValue=Ee.renderInput=Ee.Render=Ee.vecForm=Ee.optForm=Ee.variantForm=Ee.tupleForm=Ee.recordForm=Ee.inputBox=void 0;var jo=Lf(uu()),mu=Mt(),wi=Lf(yu()),Qg={parse:nb},os={render:Eu},Ig=(e,t)=>new wi.InputBox(e,Object.assign(Object.assign({},Qg),t));Ee.inputBox=Ig;var Dg=(e,t)=>new wi.RecordForm(e,Object.assign(Object.assign({},os),t));Ee.recordForm=Dg;var Lg=(e,t)=>new wi.TupleForm(e,Object.assign(Object.assign({},os),t));Ee.tupleForm=Lg;var eb=(e,t)=>new wi.VariantForm(e,Object.assign(Object.assign({},os),t));Ee.variantForm=eb;var tb=(e,t)=>new wi.OptionForm(e,Object.assign(Object.assign({},os),t));Ee.optForm=tb;var rb=(e,t)=>new wi.VecForm(e,Object.assign(Object.assign({},os),t));Ee.vecForm=rb;var qo=class extends jo.Visitor{visitType(t,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=t.display(),(0,Ee.inputBox)(t,{input:n})}visitNull(t,r){return(0,Ee.inputBox)(t,{})}visitRecord(t,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.recordForm)(r,i);return(0,Ee.inputBox)(t,{form:s})}visitTuple(t,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.tupleForm)(r,i);return(0,Ee.inputBox)(t,{form:s})}visitVariant(t,r,n){let i=document.createElement("select");for(let[a,c]of r){let d=new Option(a);i.add(d)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},o=(0,Ee.variantForm)(r,s);return(0,Ee.inputBox)(t,{form:o})}visitOpt(t,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Ee.optForm)(r,{open:i,event:"change"});return(0,Ee.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 o=(0,Ee.vecForm)(r,{open:i,event:"change",container:s});return(0,Ee.inputBox)(t,{form:o})}visitRec(t,r,n){return Eu(r)}};Ee.Render=qo;var gu=class extends jo.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 jo.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 Eu(e){return e.accept(new qo,null)}Ee.renderInput=Eu;function Kn(e,t,r){return e.accept(new wu,{input:t,value:r})}Ee.renderValue=Kn;var wu=class extends jo.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){Kn(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)),Kn(r,i.form[0],n.value[0])}}visitRecord(t,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{Kn(o,i.form[a],n.value[s])})}visitTuple(t,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{Kn(s,i.form[o],n.value[o])})}visitVariant(t,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([o,a],c)=>{if(o===s[0]){let d=i.ui.open;d.selectedIndex=c,d.dispatchEvent(new Event(i.ui.event)),Kn(a,i.form[0],s[1])}})}visitVec(t,r,n){let i=n.input.ui.form,s=n.value.length,o=i.ui.open;o.value=s,o.dispatchEvent(new Event(i.ui.event)),n.value.forEach((a,c)=>{Kn(r,i.form[c],a)})}}});var r0=ee(t0=>{"use strict";Object.defineProperty(t0,"__esModule",{value:!0})});var xi=ee(pt=>{"use strict";var n0=pt&&pt.__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=pt&&pt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ei=pt&&pt.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&n0(t,e,r)},sb=pt&&pt.__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)&&n0(t,e,r);return ib(t,e),t};Object.defineProperty(pt,"__esModule",{value:!0});pt.IDL=void 0;Ei(e0(),pt);Ei(yu(),pt);pt.IDL=sb(uu());Ei(ru(),pt);Ei(iu(),pt);Ei(wo(),pt);Ei(r0(),pt)});var as=ee((i0,ko)=>{(function(e){"use strict";var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,d=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,m=1e9;function b(E){var j,Y,z,k=C.prototype={constructor:C,toString:null,valueOf:null},oe=new C(1),L=20,ne=4,w=-7,g=21,R=-1e7,A=1e7,B=!1,K=1,X=0,ae={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},se="0123456789abcdefghijklmnopqrstuvwxyz",Z=!0;function C(u,p){var y,U,v,P,H,x,M,$,V=this;if(!(V instanceof C))return new C(u,p);if(p==null){if(u&&u._isBigNumber===!0){V.s=u.s,!u.c||u.e>A?V.c=V.e=null:u.e<R?V.c=[V.e=0]:(V.e=u.e,V.c=u.c.slice());return}if((x=typeof u=="number")&&u*0==0){if(V.s=1/u<0?(u=-u,-1):1,u===~~u){for(P=0,H=u;H>=10;H/=10,P++);P>A?V.c=V.e=null:(V.e=P,V.c=[u]);return}$=String(u)}else{if(!r.test($=String(u)))return z(V,$,x);V.s=$.charCodeAt(0)==45?($=$.slice(1),-1):1}(P=$.indexOf("."))>-1&&($=$.replace(".","")),(H=$.search(/e/i))>0?(P<0&&(P=H),P+=+$.slice(H+1),$=$.substring(0,H)):P<0&&(P=$.length)}else{if(F(p,2,se.length,"Base"),p==10&&Z)return V=new C(u),le(V,L+V.e+1,ne);if($=String(u),x=typeof u=="number"){if(u*0!=0)return z(V,$,x,p);if(V.s=1/u<0?($=$.slice(1),-1):1,C.DEBUG&&$.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else V.s=$.charCodeAt(0)===45?($=$.slice(1),-1):1;for(y=se.slice(0,p),P=H=0,M=$.length;H<M;H++)if(y.indexOf(U=$.charAt(H))<0){if(U=="."){if(H>P){P=M;continue}}else if(!v&&($==$.toUpperCase()&&($=$.toLowerCase())||$==$.toLowerCase()&&($=$.toUpperCase()))){v=!0,H=-1,P=0;continue}return z(V,String(u),x,p)}x=!1,$=Y($,p,10,V.s),(P=$.indexOf("."))>-1?$=$.replace(".",""):P=$.length}for(H=0;$.charCodeAt(H)===48;H++);for(M=$.length;$.charCodeAt(--M)===48;);if($=$.slice(H,++M)){if(M-=H,x&&C.DEBUG&&M>15&&(u>d||u!==i(u)))throw Error(o+V.s*u);if((P=P-H-1)>A)V.c=V.e=null;else if(P<R)V.c=[V.e=0];else{if(V.e=P,V.c=[],H=(P+1)%c,P<0&&(H+=c),H<M){for(H&&V.c.push(+$.slice(0,H)),M-=c;H<M;)V.c.push(+$.slice(H,H+=c));H=c-($=$.slice(H)).length}else H-=M;for(;H--;$+="0");V.c.push(+$)}}else V.c=[V.e=0]}C.clone=b,C.ROUND_UP=0,C.ROUND_DOWN=1,C.ROUND_CEIL=2,C.ROUND_FLOOR=3,C.ROUND_HALF_UP=4,C.ROUND_HALF_DOWN=5,C.ROUND_HALF_EVEN=6,C.ROUND_HALF_CEIL=7,C.ROUND_HALF_FLOOR=8,C.EUCLID=9,C.config=C.set=function(u){var p,y;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(p="DECIMAL_PLACES")&&(y=u[p],F(y,0,m,p),L=y),u.hasOwnProperty(p="ROUNDING_MODE")&&(y=u[p],F(y,0,8,p),ne=y),u.hasOwnProperty(p="EXPONENTIAL_AT")&&(y=u[p],y&&y.pop?(F(y[0],-m,0,p),F(y[1],0,m,p),w=y[0],g=y[1]):(F(y,-m,m,p),w=-(g=y<0?-y:y))),u.hasOwnProperty(p="RANGE"))if(y=u[p],y&&y.pop)F(y[0],-m,-1,p),F(y[1],1,m,p),R=y[0],A=y[1];else if(F(y,-m,m,p),y)R=-(A=y<0?-y:y);else throw Error(s+p+" cannot be zero: "+y);if(u.hasOwnProperty(p="CRYPTO"))if(y=u[p],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+p+" not true or false: "+y);if(u.hasOwnProperty(p="MODULO_MODE")&&(y=u[p],F(y,0,9,p),K=y),u.hasOwnProperty(p="POW_PRECISION")&&(y=u[p],F(y,0,m,p),X=y),u.hasOwnProperty(p="FORMAT"))if(y=u[p],typeof y=="object")ae=y;else throw Error(s+p+" not an object: "+y);if(u.hasOwnProperty(p="ALPHABET"))if(y=u[p],typeof y=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(y))Z=y.slice(0,10)=="0123456789",se=y;else throw Error(s+p+" invalid: "+y)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:L,ROUNDING_MODE:ne,EXPONENTIAL_AT:[w,g],RANGE:[R,A],CRYPTO:B,MODULO_MODE:K,POW_PRECISION:X,FORMAT:ae,ALPHABET:se}},C.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!C.DEBUG)return!0;var p,y,U=u.c,v=u.e,P=u.s;e:if({}.toString.call(U)=="[object Array]"){if((P===1||P===-1)&&v>=-m&&v<=m&&v===i(v)){if(U[0]===0){if(v===0&&U.length===1)return!0;break e}if(p=(v+1)%c,p<1&&(p+=c),String(U[0]).length==p){for(p=0;p<U.length;p++)if(y=U[p],y<0||y>=a||y!==i(y))break e;if(y!==0)return!0}}}else if(U===null&&v===null&&(P===null||P===1||P===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},C.maximum=C.max=function(){return I(arguments,-1)},C.minimum=C.min=function(){return I(arguments,1)},C.random=function(){var u=9007199254740992,p=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 U,v,P,H,x,M=0,$=[],V=new C(oe);if(y==null?y=L:F(y,0,m),H=n(y/c),B)if(crypto.getRandomValues){for(U=crypto.getRandomValues(new Uint32Array(H*=2));M<H;)x=U[M]*131072+(U[M+1]>>>11),x>=9e15?(v=crypto.getRandomValues(new Uint32Array(2)),U[M]=v[0],U[M+1]=v[1]):($.push(x%1e14),M+=2);M=H/2}else if(crypto.randomBytes){for(U=crypto.randomBytes(H*=7);M<H;)x=(U[M]&31)*281474976710656+U[M+1]*1099511627776+U[M+2]*4294967296+U[M+3]*16777216+(U[M+4]<<16)+(U[M+5]<<8)+U[M+6],x>=9e15?crypto.randomBytes(7).copy(U,M):($.push(x%1e14),M+=7);M=H/7}else throw B=!1,Error(s+"crypto unavailable");if(!B)for(;M<H;)x=p(),x<9e15&&($[M++]=x%1e14);for(H=$[--M],y%=c,H&&y&&(x=f[c-y],$[M]=i(H/x)*x);$[M]===0;$.pop(),M--);if(M<0)$=[P=0];else{for(P=-1;$[0]===0;$.splice(0,1),P-=c);for(M=1,x=$[0];x>=10;x/=10,M++);M<c&&(P-=c-M)}return V.e=P,V.c=$,V}}(),C.sum=function(){for(var u=1,p=arguments,y=new C(p[0]);u<p.length;)y=y.plus(p[u++]);return y},Y=function(){var u="0123456789";function p(y,U,v,P){for(var H,x=[0],M,$=0,V=y.length;$<V;){for(M=x.length;M--;x[M]*=U);for(x[0]+=P.indexOf(y.charAt($++)),H=0;H<x.length;H++)x[H]>v-1&&(x[H+1]==null&&(x[H+1]=0),x[H+1]+=x[H]/v|0,x[H]%=v)}return x.reverse()}return function(y,U,v,P,H){var x,M,$,V,Q,te,de,ge,Re=y.indexOf("."),Fe=L,_e=ne;for(Re>=0&&(V=X,X=0,y=y.replace(".",""),ge=new C(U),te=ge.pow(y.length-Re),X=V,ge.c=p(G(S(te.c),te.e,"0"),10,v,u),ge.e=ge.c.length),de=p(y,U,v,H?(x=se,u):(x=u,se)),$=V=de.length;de[--V]==0;de.pop());if(!de[0])return x.charAt(0);if(Re<0?--$:(te.c=de,te.e=$,te.s=P,te=j(te,ge,Fe,_e,v),de=te.c,Q=te.r,$=te.e),M=$+Fe+1,Re=de[M],V=v/2,Q=Q||M<0||de[M+1]!=null,Q=_e<4?(Re!=null||Q)&&(_e==0||_e==(te.s<0?3:2)):Re>V||Re==V&&(_e==4||Q||_e==6&&de[M-1]&1||_e==(te.s<0?8:7)),M<1||!de[0])y=Q?G(x.charAt(1),-Fe,x.charAt(0)):x.charAt(0);else{if(de.length=M,Q)for(--v;++de[--M]>v;)de[M]=0,M||(++$,de=[1].concat(de));for(V=de.length;!de[--V];);for(Re=0,y="";Re<=V;y+=x.charAt(de[Re++]));y=G(y,$,x.charAt(0))}return y}}(),j=function(){function u(U,v,P){var H,x,M,$,V=0,Q=U.length,te=v%h,de=v/h|0;for(U=U.slice();Q--;)M=U[Q]%h,$=U[Q]/h|0,H=de*M+$*te,x=te*M+H%h*h+V,V=(x/P|0)+(H/h|0)+de*$,U[Q]=x%P;return V&&(U=[V].concat(U)),U}function p(U,v,P,H){var x,M;if(P!=H)M=P>H?1:-1;else for(x=M=0;x<P;x++)if(U[x]!=v[x]){M=U[x]>v[x]?1:-1;break}return M}function y(U,v,P,H){for(var x=0;P--;)U[P]-=x,x=U[P]<v[P]?1:0,U[P]=x*H+U[P]-v[P];for(;!U[0]&&U.length>1;U.splice(0,1));}return function(U,v,P,H,x){var M,$,V,Q,te,de,ge,Re,Fe,_e,fe,$e,Kt,Ft,Ct,$t,Be,Ot=U.s==v.s?1:-1,ot=U.c,Ge=v.c;if(!ot||!ot[0]||!Ge||!Ge[0])return new C(!U.s||!v.s||(ot?Ge&&ot[0]==Ge[0]:!Ge)?NaN:ot&&ot[0]==0||!Ge?Ot*0:Ot/0);for(Re=new C(Ot),Fe=Re.c=[],$=U.e-v.e,Ot=P+$+1,x||(x=a,$=l(U.e/c)-l(v.e/c),Ot=Ot/c|0),V=0;Ge[V]==(ot[V]||0);V++);if(Ge[V]>(ot[V]||0)&&$--,Ot<0)Fe.push(1),Q=!0;else{for(Ft=ot.length,$t=Ge.length,V=0,Ot+=2,te=i(x/(Ge[0]+1)),te>1&&(Ge=u(Ge,te,x),ot=u(ot,te,x),$t=Ge.length,Ft=ot.length),Kt=$t,_e=ot.slice(0,$t),fe=_e.length;fe<$t;_e[fe++]=0);Be=Ge.slice(),Be=[0].concat(Be),Ct=Ge[0],Ge[1]>=x/2&&Ct++;do{if(te=0,M=p(Ge,_e,$t,fe),M<0){if($e=_e[0],$t!=fe&&($e=$e*x+(_e[1]||0)),te=i($e/Ct),te>1)for(te>=x&&(te=x-1),de=u(Ge,te,x),ge=de.length,fe=_e.length;p(de,_e,ge,fe)==1;)te--,y(de,$t<ge?Be:Ge,ge,x),ge=de.length,M=1;else te==0&&(M=te=1),de=Ge.slice(),ge=de.length;if(ge<fe&&(de=[0].concat(de)),y(_e,de,fe,x),fe=_e.length,M==-1)for(;p(Ge,_e,$t,fe)<1;)te++,y(_e,$t<fe?Be:Ge,fe,x),fe=_e.length}else M===0&&(te++,_e=[0]);Fe[V++]=te,_e[0]?_e[fe++]=ot[Kt]||0:(_e=[ot[Kt]],fe=1)}while((Kt++<Ft||_e[0]!=null)&&Ot--);Q=_e[0]!=null,Fe[0]||Fe.splice(0,1)}if(x==a){for(V=1,Ot=Fe[0];Ot>=10;Ot/=10,V++);le(Re,P+(Re.e=V+$*c-1)+1,H,Q)}else Re.e=$,Re.r=+Q;return Re}}();function _(u,p,y,U){var v,P,H,x,M;if(y==null?y=ne:F(y,0,8),!u.c)return u.toString();if(v=u.c[0],H=u.e,p==null)M=S(u.c),M=U==1||U==2&&(H<=w||H>=g)?O(M,H):G(M,H,"0");else if(u=le(new C(u),p,y),P=u.e,M=S(u.c),x=M.length,U==1||U==2&&(p<=P||P<=w)){for(;x<p;M+="0",x++);M=O(M,P)}else if(p-=H,M=G(M,P,"0"),P+1>x){if(--p>0)for(M+=".";p--;M+="0");}else if(p+=P-x,p>0)for(P+1==x&&(M+=".");p--;M+="0");return u.s<0&&v?"-"+M:M}function I(u,p){for(var y,U,v=1,P=new C(u[0]);v<u.length;v++)U=new C(u[v]),(!U.s||(y=N(P,U))===p||y===0&&P.s===p)&&(P=U);return P}function re(u,p,y){for(var U=1,v=p.length;!p[--v];p.pop());for(v=p[0];v>=10;v/=10,U++);return(y=U+y*c-1)>A?u.c=u.e=null:y<R?u.c=[u.e=0]:(u.e=y,u.c=p),u}z=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,p=/^([^.]+)\.$/,y=/^\.([^.]+)$/,U=/^-?(Infinity|NaN)$/,v=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(P,H,x,M){var $,V=x?H:H.replace(v,"");if(U.test(V))P.s=isNaN(V)?null:V<0?-1:1;else{if(!x&&(V=V.replace(u,function(Q,te,de){return $=(de=de.toLowerCase())=="x"?16:de=="b"?2:8,!M||M==$?te:Q}),M&&($=M,V=V.replace(p,"$1").replace(y,"0.$1")),H!=V))return new C(V,$);if(C.DEBUG)throw Error(s+"Not a"+(M?" base "+M:"")+" number: "+H);P.s=null}P.c=P.e=null}}();function le(u,p,y,U){var v,P,H,x,M,$,V,Q=u.c,te=f;if(Q){e:{for(v=1,x=Q[0];x>=10;x/=10,v++);if(P=p-v,P<0)P+=c,H=p,M=Q[$=0],V=i(M/te[v-H-1]%10);else if($=n((P+1)/c),$>=Q.length)if(U){for(;Q.length<=$;Q.push(0));M=V=0,v=1,P%=c,H=P-c+1}else break e;else{for(M=x=Q[$],v=1;x>=10;x/=10,v++);P%=c,H=P-c+v,V=H<0?0:i(M/te[v-H-1]%10)}if(U=U||p<0||Q[$+1]!=null||(H<0?M:M%te[v-H-1]),U=y<4?(V||U)&&(y==0||y==(u.s<0?3:2)):V>5||V==5&&(y==4||U||y==6&&(P>0?H>0?M/te[v-H]:0:Q[$-1])%10&1||y==(u.s<0?8:7)),p<1||!Q[0])return Q.length=0,U?(p-=u.e+1,Q[0]=te[(c-p%c)%c],u.e=-p||0):Q[0]=u.e=0,u;if(P==0?(Q.length=$,x=1,$--):(Q.length=$+1,x=te[c-P],Q[$]=H>0?i(M/te[v-H]%te[H])*x:0),U)for(;;)if($==0){for(P=1,H=Q[0];H>=10;H/=10,P++);for(H=Q[0]+=x,x=1;H>=10;H/=10,x++);P!=x&&(u.e++,Q[0]==a&&(Q[0]=1));break}else{if(Q[$]+=x,Q[$]!=a)break;Q[$--]=0,x=1}for(P=Q.length;Q[--P]===0;Q.pop());}u.e>A?u.c=u.e=null:u.e<R&&(u.c=[u.e=0])}return u}function D(u){var p,y=u.e;return y===null?u.toString():(p=S(u.c),p=y<=w||y>=g?O(p,y):G(p,y,"0"),u.s<0?"-"+p:p)}return k.absoluteValue=k.abs=function(){var u=new C(this);return u.s<0&&(u.s=1),u},k.comparedTo=function(u,p){return N(this,new C(u,p))},k.decimalPlaces=k.dp=function(u,p){var y,U,v,P=this;if(u!=null)return F(u,0,m),p==null?p=ne:F(p,0,8),le(new C(P),u+P.e+1,p);if(!(y=P.c))return null;if(U=((v=y.length-1)-l(this.e/c))*c,v=y[v])for(;v%10==0;v/=10,U--);return U<0&&(U=0),U},k.dividedBy=k.div=function(u,p){return j(this,new C(u,p),L,ne)},k.dividedToIntegerBy=k.idiv=function(u,p){return j(this,new C(u,p),0,1)},k.exponentiatedBy=k.pow=function(u,p){var y,U,v,P,H,x,M,$,V,Q=this;if(u=new C(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+D(u));if(p!=null&&(p=new C(p)),x=u.e>14,!Q.c||!Q.c[0]||Q.c[0]==1&&!Q.e&&Q.c.length==1||!u.c||!u.c[0])return V=new C(Math.pow(+D(Q),x?u.s*(2-q(u)):+D(u))),p?V.mod(p):V;if(M=u.s<0,p){if(p.c?!p.c[0]:!p.s)return new C(NaN);U=!M&&Q.isInteger()&&p.isInteger(),U&&(Q=Q.mod(p))}else{if(u.e>9&&(Q.e>0||Q.e<-1||(Q.e==0?Q.c[0]>1||x&&Q.c[1]>=24e7:Q.c[0]<8e13||x&&Q.c[0]<=9999975e7)))return P=Q.s<0&&q(u)?-0:0,Q.e>-1&&(P=1/P),new C(M?1/P:P);X&&(P=n(X/c+2))}for(x?(y=new C(.5),M&&(u.s=1),$=q(u)):(v=Math.abs(+D(u)),$=v%2),V=new C(oe);;){if($){if(V=V.times(Q),!V.c)break;P?V.c.length>P&&(V.c.length=P):U&&(V=V.mod(p))}if(v){if(v=i(v/2),v===0)break;$=v%2}else if(u=u.times(y),le(u,u.e+1,1),u.e>14)$=q(u);else{if(v=+D(u),v===0)break;$=v%2}Q=Q.times(Q),P?Q.c&&Q.c.length>P&&(Q.c.length=P):U&&(Q=Q.mod(p))}return U?V:(M&&(V=oe.div(V)),p?V.mod(p):P?le(V,X,ne,H):V)},k.integerValue=function(u){var p=new C(this);return u==null?u=ne:F(u,0,8),le(p,p.e+1,u)},k.isEqualTo=k.eq=function(u,p){return N(this,new C(u,p))===0},k.isFinite=function(){return!!this.c},k.isGreaterThan=k.gt=function(u,p){return N(this,new C(u,p))>0},k.isGreaterThanOrEqualTo=k.gte=function(u,p){return(p=N(this,new C(u,p)))===1||p===0},k.isInteger=function(){return!!this.c&&l(this.e/c)>this.c.length-2},k.isLessThan=k.lt=function(u,p){return N(this,new C(u,p))<0},k.isLessThanOrEqualTo=k.lte=function(u,p){return(p=N(this,new C(u,p)))===-1||p===0},k.isNaN=function(){return!this.s},k.isNegative=function(){return this.s<0},k.isPositive=function(){return this.s>0},k.isZero=function(){return!!this.c&&this.c[0]==0},k.minus=function(u,p){var y,U,v,P,H=this,x=H.s;if(u=new C(u,p),p=u.s,!x||!p)return new C(NaN);if(x!=p)return u.s=-p,H.plus(u);var M=H.e/c,$=u.e/c,V=H.c,Q=u.c;if(!M||!$){if(!V||!Q)return V?(u.s=-p,u):new C(Q?H:NaN);if(!V[0]||!Q[0])return Q[0]?(u.s=-p,u):new C(V[0]?H:ne==3?-0:0)}if(M=l(M),$=l($),V=V.slice(),x=M-$){for((P=x<0)?(x=-x,v=V):($=M,v=Q),v.reverse(),p=x;p--;v.push(0));v.reverse()}else for(U=(P=(x=V.length)<(p=Q.length))?x:p,x=p=0;p<U;p++)if(V[p]!=Q[p]){P=V[p]<Q[p];break}if(P&&(v=V,V=Q,Q=v,u.s=-u.s),p=(U=Q.length)-(y=V.length),p>0)for(;p--;V[y++]=0);for(p=a-1;U>x;){if(V[--U]<Q[U]){for(y=U;y&&!V[--y];V[y]=p);--V[y],V[U]+=a}V[U]-=Q[U]}for(;V[0]==0;V.splice(0,1),--$);return V[0]?re(u,V,$):(u.s=ne==3?-1:1,u.c=[u.e=0],u)},k.modulo=k.mod=function(u,p){var y,U,v=this;return u=new C(u,p),!v.c||!u.s||u.c&&!u.c[0]?new C(NaN):!u.c||v.c&&!v.c[0]?new C(v):(K==9?(U=u.s,u.s=1,y=j(v,u,0,3),u.s=U,y.s*=U):y=j(v,u,0,K),u=v.minus(y.times(u)),!u.c[0]&&K==1&&(u.s=v.s),u)},k.multipliedBy=k.times=function(u,p){var y,U,v,P,H,x,M,$,V,Q,te,de,ge,Re,Fe,_e=this,fe=_e.c,$e=(u=new C(u,p)).c;if(!fe||!$e||!fe[0]||!$e[0])return!_e.s||!u.s||fe&&!fe[0]&&!$e||$e&&!$e[0]&&!fe?u.c=u.e=u.s=null:(u.s*=_e.s,!fe||!$e?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(U=l(_e.e/c)+l(u.e/c),u.s*=_e.s,M=fe.length,Q=$e.length,M<Q&&(ge=fe,fe=$e,$e=ge,v=M,M=Q,Q=v),v=M+Q,ge=[];v--;ge.push(0));for(Re=a,Fe=h,v=Q;--v>=0;){for(y=0,te=$e[v]%Fe,de=$e[v]/Fe|0,H=M,P=v+H;P>v;)$=fe[--H]%Fe,V=fe[H]/Fe|0,x=de*$+V*te,$=te*$+x%Fe*Fe+ge[P]+y,y=($/Re|0)+(x/Fe|0)+de*V,ge[P--]=$%Re;ge[P]=y}return y?++U:ge.splice(0,1),re(u,ge,U)},k.negated=function(){var u=new C(this);return u.s=-u.s||null,u},k.plus=function(u,p){var y,U=this,v=U.s;if(u=new C(u,p),p=u.s,!v||!p)return new C(NaN);if(v!=p)return u.s=-p,U.minus(u);var P=U.e/c,H=u.e/c,x=U.c,M=u.c;if(!P||!H){if(!x||!M)return new C(v/0);if(!x[0]||!M[0])return M[0]?u:new C(x[0]?U:v*0)}if(P=l(P),H=l(H),x=x.slice(),v=P-H){for(v>0?(H=P,y=M):(v=-v,y=x),y.reverse();v--;y.push(0));y.reverse()}for(v=x.length,p=M.length,v-p<0&&(y=M,M=x,x=y,p=v),v=0;p;)v=(x[--p]=x[p]+M[p]+v)/a|0,x[p]=a===x[p]?0:x[p]%a;return v&&(x=[v].concat(x),++H),re(u,x,H)},k.precision=k.sd=function(u,p){var y,U,v,P=this;if(u!=null&&u!==!!u)return F(u,1,m),p==null?p=ne:F(p,0,8),le(new C(P),u,p);if(!(y=P.c))return null;if(v=y.length-1,U=v*c+1,v=y[v]){for(;v%10==0;v/=10,U--);for(v=y[0];v>=10;v/=10,U++);}return u&&P.e+1>U&&(U=P.e+1),U},k.shiftedBy=function(u){return F(u,-d,d),this.times("1e"+u)},k.squareRoot=k.sqrt=function(){var u,p,y,U,v,P=this,H=P.c,x=P.s,M=P.e,$=L+4,V=new C("0.5");if(x!==1||!H||!H[0])return new C(!x||x<0&&(!H||H[0])?NaN:H?P:1/0);if(x=Math.sqrt(+D(P)),x==0||x==1/0?(p=S(H),(p.length+M)%2==0&&(p+="0"),x=Math.sqrt(+p),M=l((M+1)/2)-(M<0||M%2),x==1/0?p="5e"+M:(p=x.toExponential(),p=p.slice(0,p.indexOf("e")+1)+M),y=new C(p)):y=new C(x+""),y.c[0]){for(M=y.e,x=M+$,x<3&&(x=0);;)if(v=y,y=V.times(v.plus(j(P,v,$,1))),S(v.c).slice(0,x)===(p=S(y.c)).slice(0,x))if(y.e<M&&--x,p=p.slice(x-3,x+1),p=="9999"||!U&&p=="4999"){if(!U&&(le(v,v.e+L+2,0),v.times(v).eq(P))){y=v;break}$+=4,x+=4,U=1}else{(!+p||!+p.slice(1)&&p.charAt(0)=="5")&&(le(y,y.e+L+2,1),u=!y.times(y).eq(P));break}}return le(y,y.e+L+1,ne,u)},k.toExponential=function(u,p){return u!=null&&(F(u,0,m),u++),_(this,u,p,1)},k.toFixed=function(u,p){return u!=null&&(F(u,0,m),u=u+this.e+1),_(this,u,p)},k.toFormat=function(u,p,y){var U,v=this;if(y==null)u!=null&&p&&typeof p=="object"?(y=p,p=null):u&&typeof u=="object"?(y=u,u=p=null):y=ae;else if(typeof y!="object")throw Error(s+"Argument not an object: "+y);if(U=v.toFixed(u,p),v.c){var P,H=U.split("."),x=+y.groupSize,M=+y.secondaryGroupSize,$=y.groupSeparator||"",V=H[0],Q=H[1],te=v.s<0,de=te?V.slice(1):V,ge=de.length;if(M&&(P=x,x=M,M=P,ge-=P),x>0&&ge>0){for(P=ge%x||x,V=de.substr(0,P);P<ge;P+=x)V+=$+de.substr(P,x);M>0&&(V+=$+de.slice(P)),te&&(V="-"+V)}U=Q?V+(y.decimalSeparator||"")+((M=+y.fractionGroupSize)?Q.replace(new RegExp("\\d{"+M+"}\\B","g"),"$&"+(y.fractionGroupSeparator||"")):Q):V}return(y.prefix||"")+U+(y.suffix||"")},k.toFraction=function(u){var p,y,U,v,P,H,x,M,$,V,Q,te,de=this,ge=de.c;if(u!=null&&(x=new C(u),!x.isInteger()&&(x.c||x.s!==1)||x.lt(oe)))throw Error(s+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+D(x));if(!ge)return new C(de);for(p=new C(oe),$=y=new C(oe),U=M=new C(oe),te=S(ge),P=p.e=te.length-de.e-1,p.c[0]=f[(H=P%c)<0?c+H:H],u=!u||x.comparedTo(p)>0?P>0?p:$:x,H=A,A=1/0,x=new C(te),M.c[0]=0;V=j(x,p,0,1),v=y.plus(V.times(U)),v.comparedTo(u)!=1;)y=U,U=v,$=M.plus(V.times(v=$)),M=v,p=x.minus(V.times(v=p)),x=v;return v=j(u.minus(y),U,0,1),M=M.plus(v.times($)),y=y.plus(v.times(U)),M.s=$.s=de.s,P=P*2,Q=j($,U,P,ne).minus(de).abs().comparedTo(j(M,y,P,ne).minus(de).abs())<1?[$,U]:[M,y],A=H,Q},k.toNumber=function(){return+D(this)},k.toPrecision=function(u,p){return u!=null&&F(u,1,m),_(this,u,p,2)},k.toString=function(u){var p,y=this,U=y.s,v=y.e;return v===null?U?(p="Infinity",U<0&&(p="-"+p)):p="NaN":(u==null?p=v<=w||v>=g?O(S(y.c),v):G(S(y.c),v,"0"):u===10&&Z?(y=le(new C(y),L+v+1,ne),p=G(S(y.c),y.e,"0")):(F(u,2,se.length,"Base"),p=Y(G(S(y.c),v,"0"),10,u,U,!0)),U<0&&y.c[0]&&(p="-"+p)),p},k.valueOf=k.toJSON=function(){return D(this)},k._isBigNumber=!0,E!=null&&C.set(E),C}function l(E){var j=E|0;return E>0||E===j?j:j-1}function S(E){for(var j,Y,z=1,k=E.length,oe=E[0]+"";z<k;){for(j=E[z++]+"",Y=c-j.length;Y--;j="0"+j);oe+=j}for(k=oe.length;oe.charCodeAt(--k)===48;);return oe.slice(0,k+1||1)}function N(E,j){var Y,z,k=E.c,oe=j.c,L=E.s,ne=j.s,w=E.e,g=j.e;if(!L||!ne)return null;if(Y=k&&!k[0],z=oe&&!oe[0],Y||z)return Y?z?0:-ne:L;if(L!=ne)return L;if(Y=L<0,z=w==g,!k||!oe)return z?0:!k^Y?1:-1;if(!z)return w>g^Y?1:-1;for(ne=(w=k.length)<(g=oe.length)?w:g,L=0;L<ne;L++)if(k[L]!=oe[L])return k[L]>oe[L]^Y?1:-1;return w==g?0:w>g^Y?1:-1}function F(E,j,Y,z){if(E<j||E>Y||E!==i(E))throw Error(s+(z||"Argument")+(typeof E=="number"?E<j||E>Y?" out of range: ":" not an integer: ":" not a primitive number: ")+String(E))}function q(E){var j=E.c.length-1;return l(E.e/c)==j&&E.c[j]%2!=0}function O(E,j){return(E.length>1?E.charAt(0)+"."+E.slice(1):E)+(j<0?"e":"e+")+j}function G(E,j,Y){var z,k;if(j<0){for(k=Y+".";++j;k+=Y);E=k+E}else if(z=E.length,++j>z){for(k=Y,j-=z;--j;k+=Y);E+=k}else j<z&&(E=E.slice(0,j)+"."+E.slice(j));return E}t=b(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof ko<"u"&&ko.exports?ko.exports=t:(e||(e=typeof self<"u"&&self?self:window),e.BigNumber=t)})(i0)});var o0=ee((bO,s0)=>{s0.exports=function(t,r,n){var i=new t.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,d=r.pushInt64Neg,f=r.pushFloat,h=r.pushFloatSingle,m=r.pushFloatDouble,b=r.pushTrue,l=r.pushFalse,S=r.pushUndefined,N=r.pushNull,F=r.pushInfinity,q=r.pushInfinityNeg,O=r.pushNaN,G=r.pushNaNNeg,E=r.pushArrayStart,j=r.pushArrayStartFixed,Y=r.pushArrayStartFixed32,z=r.pushArrayStartFixed64,k=r.pushObjectStart,oe=r.pushObjectStartFixed,L=r.pushObjectStartFixed32,ne=r.pushObjectStartFixed64,w=r.pushByteString,g=r.pushByteStringStart,R=r.pushUtf8String,A=r.pushUtf8StringStart,B=r.pushSimpleUnassigned,K=r.pushTagStart,X=r.pushTagStart4,ae=r.pushTagStart8,se=r.pushTagUnassigned,Z=r.pushBreak,C=t.Math.pow,_=0,I=0,re=0;function le(T){for(T=T|0,_=0,I=T;(_|0)<(I|0)&&(re=rm[i[_]&255](i[_]|0)|0,!((re|0)>0)););return re|0}function D(T){return T=T|0,((_|0)+(T|0)|0)<(I|0)?0:1}function u(T){return T=T|0,i[T|0]<<8|i[T+1|0]|0}function p(T){return T=T|0,i[T|0]<<24|i[T+1|0]<<16|i[T+2|0]<<8|i[T+3|0]|0}function y(T){return T=T|0,s(T|0),_=_+1|0,0}function U(T){return T=T|0,D(1)|0?1:(s(i[_+1|0]|0),_=_+2|0,0)}function v(T){return T=T|0,D(2)|0?1:(s(u(_+1|0)|0),_=_+3|0,0)}function P(T){return T=T|0,D(4)|0?1:(o(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function H(T){return T=T|0,D(8)|0?1:(c(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function x(T){return T=T|0,s(-1-(T-32|0)|0),_=_+1|0,0}function M(T){return T=T|0,D(1)|0?1:(s(-1-(i[_+1|0]|0)|0),_=_+2|0,0)}function $(T){T=T|0;var ve=0;return D(2)|0?1:(ve=u(_+1|0)|0,s(-1-(ve|0)|0),_=_+3|0,0)}function V(T){return T=T|0,D(4)|0?1:(a(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Q(T){return T=T|0,D(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(T){T=T|0;var ve=0,Se=0,xe=0;return xe=T-64|0,D(xe|0)|0?1:(ve=_+1|0,Se=(_+1|0)+(xe|0)|0,w(ve|0,Se|0),_=Se|0,0)}function de(T){T=T|0;var ve=0,Se=0,xe=0;return D(1)|0||(xe=i[_+1|0]|0,ve=_+2|0,Se=(_+2|0)+(xe|0)|0,D(xe+1|0)|0)?1:(w(ve|0,Se|0),_=Se|0,0)}function ge(T){T=T|0;var ve=0,Se=0,xe=0;return D(2)|0||(xe=u(_+1|0)|0,ve=_+3|0,Se=(_+3|0)+(xe|0)|0,D(xe+2|0)|0)?1:(w(ve|0,Se|0),_=Se|0,0)}function Re(T){T=T|0;var ve=0,Se=0,xe=0;return D(4)|0||(xe=p(_+1|0)|0,ve=_+5|0,Se=(_+5|0)+(xe|0)|0,D(xe+4|0)|0)?1:(w(ve|0,Se|0),_=Se|0,0)}function Fe(T){return T=T|0,1}function _e(T){return T=T|0,g(),_=_+1|0,0}function fe(T){T=T|0;var ve=0,Se=0,xe=0;return xe=T-96|0,D(xe|0)|0?1:(ve=_+1|0,Se=(_+1|0)+(xe|0)|0,R(ve|0,Se|0),_=Se|0,0)}function $e(T){T=T|0;var ve=0,Se=0,xe=0;return D(1)|0||(xe=i[_+1|0]|0,ve=_+2|0,Se=(_+2|0)+(xe|0)|0,D(xe+1|0)|0)?1:(R(ve|0,Se|0),_=Se|0,0)}function Kt(T){T=T|0;var ve=0,Se=0,xe=0;return D(2)|0||(xe=u(_+1|0)|0,ve=_+3|0,Se=(_+3|0)+(xe|0)|0,D(xe+2|0)|0)?1:(R(ve|0,Se|0),_=Se|0,0)}function Ft(T){T=T|0;var ve=0,Se=0,xe=0;return D(4)|0||(xe=p(_+1|0)|0,ve=_+5|0,Se=(_+5|0)+(xe|0)|0,D(xe+4|0)|0)?1:(R(ve|0,Se|0),_=Se|0,0)}function Ct(T){return T=T|0,1}function $t(T){return T=T|0,A(),_=_+1|0,0}function Be(T){return T=T|0,j(T-128|0),_=_+1|0,0}function Ot(T){return T=T|0,D(1)|0?1:(j(i[_+1|0]|0),_=_+2|0,0)}function ot(T){return T=T|0,D(2)|0?1:(j(u(_+1|0)|0),_=_+3|0,0)}function Ge(T){return T=T|0,D(4)|0?1:(Y(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Tc(T){return T=T|0,D(8)|0?1:(z(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function Oc(T){return T=T|0,E(),_=_+1|0,0}function Ye(T){T=T|0;var ve=0;return ve=T-160|0,D(ve|0)|0?1:(oe(ve|0),_=_+1|0,0)}function vc(T){return T=T|0,D(1)|0?1:(oe(i[_+1|0]|0),_=_+2|0,0)}function Nc(T){return T=T|0,D(2)|0?1:(oe(u(_+1|0)|0),_=_+3|0,0)}function Ac(T){return T=T|0,D(4)|0?1:(L(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Sc(T){return T=T|0,D(8)|0?1:(ne(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function Rc(T){return T=T|0,k(),_=_+1|0,0}function cn(T){return T=T|0,K(T-192|0|0),_=_+1|0,0}function VT(T){return T=T|0,K(T|0),_=_+1|0,0}function HT(T){return T=T|0,K(T|0),_=_+1|0,0}function KT(T){return T=T|0,K(T|0),_=_+1|0,0}function $T(T){return T=T|0,K(T|0),_=_+1|0,0}function ft(T){return T=T|0,K(T-192|0|0),_=_+1|0,0}function GT(T){return T=T|0,K(T|0),_=_+1|0,0}function YT(T){return T=T|0,K(T|0),_=_+1|0,0}function zT(T){return T=T|0,K(T|0),_=_+1|0,0}function Gy(T){return T=T|0,D(1)|0?1:(K(i[_+1|0]|0),_=_+2|0,0)}function Yy(T){return T=T|0,D(2)|0?1:(K(u(_+1|0)|0),_=_+3|0,0)}function zy(T){return T=T|0,D(4)|0?1:(X(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Wy(T){return T=T|0,D(8)|0?1:(ae(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function rt(T){return T=T|0,B((T|0)-224|0),_=_+1|0,0}function Jy(T){return T=T|0,l(),_=_+1|0,0}function Zy(T){return T=T|0,b(),_=_+1|0,0}function Xy(T){return T=T|0,N(),_=_+1|0,0}function Qy(T){return T=T|0,S(),_=_+1|0,0}function Iy(T){return T=T|0,D(1)|0?1:(B(i[_+1|0]|0),_=_+2|0,0)}function Dy(T){T=T|0;var ve=0,Se=0,xe=1,no=0,Qi=0,WT=0;return D(2)|0?1:(ve=i[_+1|0]|0,Se=i[_+2|0]|0,(ve|0)&128&&(xe=-1),no=+(((ve|0)&124)>>2),Qi=+(((ve|0)&3)<<8|Se),+no==0?f(+(+xe*5960464477539063e-23*+Qi)):+no==31?+xe==1?+Qi>0?O():F():+Qi>0?G():q():f(+(+xe*C(2,+(+no-25))*+(1024+Qi))),_=_+3|0,0)}function Ly(T){return T=T|0,D(4)|0?1:(h(i[_+1|0]|0,i[_+2|0]|0,i[_+3|0]|0,i[_+4|0]|0),_=_+5|0,0)}function em(T){return T=T|0,D(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 He(T){return T=T|0,1}function tm(T){return T=T|0,Z(),_=_+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,U,v,P,H,He,He,He,He,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,M,$,V,Q,He,He,He,He,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,Re,Fe,He,He,He,_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,$e,Kt,Ft,Ct,He,He,He,$t,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,ot,Ge,Tc,He,He,He,Oc,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,vc,Nc,Ac,Sc,He,He,He,Rc,cn,cn,cn,cn,cn,cn,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,Gy,Yy,zy,Wy,He,He,He,He,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,Jy,Zy,Xy,Qy,Iy,Dy,Ly,em,He,He,He,tm];return{parse:le}}});var cs=ee(Qt=>{"use strict";var xu=as().BigNumber;Qt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Qt.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};Qt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Qt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Qt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Qt.SHIFT32=Math.pow(2,32);Qt.SHIFT16=Math.pow(2,16);Qt.MAX_SAFE_HIGH=2097151;Qt.NEG_ONE=new xu(-1);Qt.TEN=new xu(10);Qt.TWO=new xu(2);Qt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Vo=ee(or=>{"use strict";var{Buffer:ob}=ai("buffer"),c0=as().BigNumber,u0=cs(),a0=u0.SHIFT32,ab=u0.SHIFT16,cb=2097151;or.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)}or.arrayBufferToBignumber=function(e){let t=e.byteLength,r="";for(let n=0;n<t;n++)r+=ub(e[n]);return new c0(r,16)};or.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};or.buildInt32=(e,t)=>e*ab+t;or.buildInt64=(e,t,r,n)=>{let i=or.buildInt32(e,t),s=or.buildInt32(r,n);return i>cb?new c0(i).times(a0).plus(s):i*a0+s};or.writeHalf=function(t,r){let n=ob.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if((i&8191)!==0)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return t.writeUInt16BE(s,0),!0};or.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])};or.isNegativeZero=e=>e===0&&1/e<0;or.nextPowerOf2=e=>{let t=0;if(e&&!(e&e-1))return e;for(;e!==0;)e>>=1,t+=1;return 1<<t}});var Nu=ee((xO,l0)=>{"use strict";var vu=cs(),lb=vu.MT,Ho=vu.SIMPLE,Tu=vu.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 Ho.FALSE:return!1;case Ho.TRUE:return!0;case Ho.NULL:return r?null:Tu.NULL;case Ho.UNDEFINED:return r?void 0:Tu.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Tu.BREAK;default:return new e(t)}}};l0.exports=Ou});var Su=ee((TO,d0)=>{"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}}};d0.exports=Au});var Bu=ee((OO,h0)=>{"use strict";var{URL:db,URLSearchParams:fb,format:hb}=ai("url"),f0="http://localhost",Ru=class extends db{constructor(t="",r=f0){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()}};h0.exports={URLWithLegacySupport:Ru,URLSearchParams:fb,format:hb,defaultBase:f0}});var y0=ee((vO,_0)=>{"use strict";var{URLWithLegacySupport:p0,format:pb}=Bu();_0.exports=(e,t={},r={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new p0(e)}catch{s={}}let o=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new p0(e,pb(o)).toString()}});var Pu=ee((NO,m0)=>{"use strict";var{URLWithLegacySupport:_b,format:yb,URLSearchParams:mb,defaultBase:gb}=Bu(),bb=y0();m0.exports={URL:_b,URLSearchParams:mb,format:yb,relative:bb,defaultBase:gb}});var Uu=ee((AO,b0)=>{"use strict";var{Buffer:Ti}=ai("buffer"),g0=Uc(),wb=as().BigNumber,Eb=o0(),qt=Vo(),je=cs(),xb=Nu(),Tb=Su(),{URL:Ob}=Pu(),us=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=Ti.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=>je.NEG_ONE.minus(qt.arrayBufferToBignumber(r)),4:r=>je.TEN.pow(r[0]).times(r[1]),5:r=>je.TWO.pow(r[0]).times(r[1]),32:r=>new Ob(r),35:r=>new RegExp(r)},t.tags),this.parser=Eb(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 je.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case je.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case je.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case je.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 je.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 je.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===je.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 je.PARENT.ARRAY:case je.PARENT.BYTE_STRING:case je.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case je.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=je.PARENT.MAP,n.ref=qt.buildMap(n.ref)));break;case je.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case je.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:je.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,r){let n=this._knownTags[t];return n?n(r):new Tb(t,r)}createMap(t,r){return t}createObject(t,r){return t}createArray(t,r){return t}createByteString(t,r){return Ti.concat(t)}createByteStringFromHeap(t,r){return t===r?Ti.alloc(0):Ti.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 g0.read([t,r,n,i],0,!1,23,4)}createFloatDouble(t,r,n,i,s,o,a,c){return g0.read([t,r,n,i,s,o,a,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),o=qt.buildInt32(n,i);return s>je.MAX_SAFE_HIGH?je.NEG_ONE.minus(new wb(s).times(je.SHIFT32).plus(o)):-1-(s*je.SHIFT32+o)}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 xb(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,o,a,c){this._push(this.createFloatDouble(t,r,n,i,s,o,a,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([],je.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:je.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:je.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:je.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({},je.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),je.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=Ti.from(t,r||"hex")),new e({size:t.length}).decodeFirst(t)}static decodeAll(t,r){return typeof t=="string"&&(t=Ti.from(t,r||"hex")),new e({size:t.length}).decodeAll(t)}};us.decodeFirst=us.decode;b0.exports=us});var x0=ee((SO,E0)=>{"use strict";var{Buffer:Fu}=ai("buffer"),vb=Uu(),Nb=Vo(),Cu=class e extends vb{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 Nb.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,o,a,c){return`${super.createFloatDouble(t,r,n,i,s,o,a,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(w0(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(t,r){let n=super.createObject(t),i=Object.keys(n).reduce(w0(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)}};E0.exports=Cu;function w0(e){return(t,r)=>t?`${t}, ${r}: ${e[r]}`:`${r}: ${e[r]}`}});var A0=ee((RO,N0)=>{"use strict";var{Buffer:Mr}=ai("buffer"),{URL:Ab}=Pu(),qu=as().BigNumber,Mu=Vo(),at=cs(),pr=at.MT,Ko=at.NUMBYTES,T0=at.SHIFT32,O0=at.SYMS,Oi=at.TAG,Sb=at.MT.SIMPLE_FLOAT<<5|at.NUMBYTES.TWO,Rb=at.MT.SIMPLE_FLOAT<<5|at.NUMBYTES.FOUR,Bb=at.MT.SIMPLE_FLOAT<<5|at.NUMBYTES.EIGHT,Pb=at.MT.SIMPLE_FLOAT<<5|at.SIMPLE.TRUE,Ub=at.MT.SIMPLE_FLOAT<<5|at.SIMPLE.FALSE,Fb=at.MT.SIMPLE_FLOAT<<5|at.SIMPLE.UNDEFINED,v0=at.MT.SIMPLE_FLOAT<<5|at.SIMPLE.NULL,Cb=new qu("0x20000000000000"),Mb=Mr.from("f97e00","hex"),qb=Mr.from("f9fc00","hex"),jb=Mr.from("f97c00","hex");function kb(e){return{}.toString.call(e).slice(8,-1)}var ju=class e{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[Ab,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 o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}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(Mb)}_pushInfinity(t){let r=t<0?qb:jb;return this.push(r)}_pushFloat(t){let r=Mr.allocUnsafe(2);if(Mu.writeHalf(r,t)&&Mu.parseHalf(r)===t)return this._pushUInt8(Sb)&&this.push(r);let n=Mr.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(Rb)&&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|Ko.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|Ko.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|Ko.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Ko.EIGHT)&&this._pushUInt32BE(Math.floor(t/T0))&&this._pushUInt32BE(t%T0):r===pr.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,pr.NEG_INT,t):this._pushInt(t,pr.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=Mr.byteLength(t,"utf8");return this._pushInt(r,pr.UTF8_STRING)&&this.pushWrite(t,5,r)}_pushBoolean(t){return this._pushUInt8(t?Pb:Ub)}_pushUndefined(t){return this._pushUInt8(Fb)}_pushArray(t,r){let n=r.length;if(!t._pushInt(n,pr.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,pr.TAG)}_pushDate(t,r){return t._pushTag(Oi.DATE_EPOCH)&&t.pushAny(Math.round(r/1e3))}_pushBuffer(t,r){return t._pushInt(r.length,pr.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,pr.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=Mr.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,pr.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,pr.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(t){if(!t)return this._pushUInt8(v0);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),o=s.length;return this._pushInt(o,pr.MAP)?this._pushRawMap(o,s.map(a=>[a,t[a]])):!1}_pushRawMap(t,r){r=r.map(function(i){return i[0]=e.encode(i[0]),i}).sort(Mu.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=kb(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,Mr.isBuffer(t)?t:Mr.from(t));case"Null":return this._pushUInt8(v0);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 O0.NULL:return this._pushObject(null);case O0.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,o=0;o<i;o++)s+=r[o];var a=Mr.allocUnsafe(s),c=0,d=0;for(o=0;o<i;o++){switch(d=r[o],n[o]){case 0:t[o].copy(a,c);break;case 1:a.writeUInt8(t[o],c,!0);break;case 2:a.writeUInt16BE(t[o],c,!0);break;case 3:a.writeUInt32BE(t[o],c,!0);break;case 4:a.writeDoubleBE(t[o],c,!0);break;case 5:a.write(t[o],c,d,"utf8");break;default:throw new Error("unkown method")}c+=d}var f=a;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()}};N0.exports=ju});var $o=ee(ct=>{"use strict";ct.Diagnose=x0();ct.Decoder=Uu();ct.Encoder=A0();ct.Simple=Nu();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 fs=ee(ar=>{"use strict";var Vb=ar&&ar.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ar,"__esModule",{value:!0});ar.hashOfMap=ar.requestIdOf=ar.hashValue=ar.hash=void 0;var S0=xi(),Hb=Vb($o()),Kb=po(),ls=Yt();function mn(e){return(0,ls.uint8ToBuf)(Kb.sha256.create().update(new Uint8Array(e)).digest())}ar.hash=mn;function ds(e){if(e instanceof Hb.default.Tagged)return ds(e.value);if(typeof e=="string")return R0(e);if(typeof e=="number")return mn((0,S0.lebEncode)(e));if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return mn(e);if(Array.isArray(e)){let t=e.map(ds);return mn((0,ls.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 ds(e.toHash());if(typeof e=="object")return ku(e);if(typeof e=="bigint")return mn((0,S0.lebEncode)(e))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${e}`),{value:e})}ar.hashValue=ds;var R0=e=>{let t=new TextEncoder().encode(e);return mn(t)};function $b(e){return ku(e)}ar.requestIdOf=$b;function ku(e){let n=Object.entries(e).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=R0(o),d=ds(a);return[c,d]}).sort(([o],[a])=>(0,ls.compare)(o,a)),i=(0,ls.concat)(...n.map(o=>(0,ls.concat)(...o)));return mn(i)}ar.hashOfMap=ku});var Ku=ee(qr=>{"use strict";var Gb=qr&&qr.__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(qr,"__esModule",{value:!0});qr.createIdentityDescriptor=qr.AnonymousIdentity=qr.SignIdentity=void 0;var B0=Mt(),Yb=fs(),P0=Yt(),zb=new TextEncoder().encode(`
17
+ ic-request`),Vu=class{getPrincipal(){return this._principal||(this._principal=B0.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:r}=t,n=Gb(t,["body"]),i=(0,Yb.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,P0.concat)(zb,i))}})}};qr.SignIdentity=Vu;var Hu=class{getPrincipal(){return B0.Principal.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}};qr.AnonymousIdentity=Hu;function Wb(e){return"getPublicKey"in e?{type:"PublicKeyIdentity",publicKey:(0,P0.toHex)(e.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}qr.createIdentityDescriptor=Wb});var Yu=ee(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});var Jb=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 Go(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 U0(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(Go(3,e.length)),new Uint8Array(t))}function Zb(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(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}ze.tagged=Zb;function hs(e){return new Uint8Array(e).buffer}ze.raw=hs;function $u(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}ze.uSmall=$u;function F0(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)}ze.u8=F0;function C0(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)}ze.u16=C0;function M0(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)}ze.u32=M0;function Gu(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),Jb),e=e.toString(16),_r(0,27,e)}ze.u64=Gu;function q0(e){if(isNaN(e))throw new RangeError("Invalid number.");if(e===0)return $u(0);e=Math.min(Math.max(0,-e),24)-1;let t=[32+e];return new Uint8Array(t).buffer}ze.iSmall=q0;function j0(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)}ze.i8=j0;function k0(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)}ze.i16=k0;function V0(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)}ze.i32=V0;function H0(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 o=parseInt(s,16)-1;return o>=0?(r=!0,o.toString(16)+i):"f"+i},"");return r?_r(1,27,n):Gu(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)}ze.i64=H0;function Xb(e){return e>=0?e<24?$u(e):e<=255?F0(e):e<=65535?C0(e):e<=4294967295?M0(e):Gu(e):e>=-24?q0(e):e>=-255?j0(e):e>=-65535?k0(e):e>=-4294967295?V0(e):H0(e)}ze.number=Xb;function Qb(e){return en(Go(2,e.byteLength),e)}ze.bytes=Qb;function Ib(e){return U0(e)}ze.string=Ib;function Db(e){return en(Go(4,e.length),...e)}ze.array=Db;function Lb(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(Go(5,e.size),...r.map(([n,i])=>en(U0(n),i)))}ze.map=Lb;function e1(e){let t=new Float32Array([e]);return en(new Uint8Array([250]),new Uint8Array(t.buffer))}ze.singleFloat=e1;function t1(e){let t=new Float64Array([e]);return en(new Uint8Array([251]),new Uint8Array(t.buffer))}ze.doubleFloat=t1;function r1(e){return e?K0():$0()}ze.bool=r1;function K0(){return hs(new Uint8Array([245]))}ze.true_=K0;function $0(){return hs(new Uint8Array([244]))}ze.false_=$0;function n1(){return hs(new Uint8Array([246]))}ze.null_=n1;function i1(){return hs(new Uint8Array([247]))}ze.undefined_=i1});var G0=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(Yu()),o1=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Yo=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(o1.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=Yo;var zo=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=zo;var Wo=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let r=new this;return r.addEncoder(new Yo(r,t)),r.addEncoder(new zo),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=Wo;var zu=class extends Wo{serialize(t){return yr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};gn.SelfDescribeCborSerializer=zu});var ps=ee($n=>{"use strict";function a1(e){for(var t in e)$n.hasOwnProperty(t)||($n[t]=e[t])}var c1=$n&&$n.__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($n,"__esModule",{value:!0});a1(G0());var u1=c1(Yu());$n.value=u1});var _s=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},h1=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 p1=h1($o()),vi=f1(ps()),_1=ps(),Jo=Yt(),Wu=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return vi.value.bytes(t.toUint8Array())}},Ju=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return vi.value.bytes(new Uint8Array(t))}},Zu=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?vi.value.tagged(2,vi.value.bytes((0,Jo.fromHex)(t.toString(16)))):vi.value.tagged(3,vi.value.bytes((0,Jo.fromHex)((BigInt("-1")*t).toString(16))))}},Zo=_1.SelfDescribeCborSerializer.withDefaultEncoders(!0);Zo.addEncoder(new Wu);Zo.addEncoder(new Ju);Zo.addEncoder(new Zu);var z0;(function(e){e[e.Uint64LittleEndian=71]="Uint64LittleEndian",e[e.Semantic=55799]="Semantic"})(z0=gt.CborTag||(gt.CborTag={}));function y1(e){return Zo.serialize(e)}gt.encode=y1;function Y0(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 Xu=class extends p1.default.Decoder{createByteString(t){return(0,Jo.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 Xu({size:t.byteLength,tags:{2:n=>Y0(n),3:n=>-Y0(n),[z0.Semantic]:n=>n}});try{return r.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,Jo.toHex)(t)}`)}}gt.decode=m1});var Qu=ee(Xo=>{"use strict";Object.defineProperty(Xo,"__esModule",{value:!0});Xo.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)};Xo.randomNumber=g1});var ys=ee(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});Gn.makeNonce=Gn.SubmitRequestType=void 0;var Qo=Qu(),b1;(function(e){e.Call="call"})(b1=Gn.SubmitRequestType||(Gn.SubmitRequestType={}));function w1(){let e=new ArrayBuffer(16),t=new DataView(e),r=(0,Qo.randomNumber)(),n=(0,Qo.randomNumber)(),i=(0,Qo.randomNumber)(),s=(0,Qo.randomNumber)();return t.setUint32(0,r),t.setUint32(4,n),t.setUint32(8,i),t.setUint32(12,s),e}Gn.makeNonce=w1});var Do=ee(At=>{"use strict";var E1=At&&At.__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]}),x1=At&&At.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),T1=At&&At.__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)&&E1(t,e,r);return x1(t,e),t};Object.defineProperty(At,"__esModule",{value:!0});At.httpHeadersTransform=At.makeExpiryTransform=At.makeNonceTransform=At.Expiry=void 0;var O1=xi(),v1=T1(ps()),N1=ys(),W0=BigInt(1e6),A1=60*1e3,Io=class{constructor(t){if(t<90*1e3){let a=BigInt(Date.now()+t)*W0/BigInt(1e9);this._value=a*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+t-A1))*W0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return v1.value.u64(this._value.toString(16),16)}toHash(){return(0,O1.lebEncode)(this._value)}};At.Expiry=Io;function S1(e=N1.makeNonce){return async t=>{let r=t.request.headers;t.request.headers=r,t.endpoint==="call"&&(t.body.nonce=e())}}At.makeNonceTransform=S1;function R1(e){return async t=>{t.body.ingress_expiry=new Io(e)}}At.makeExpiryTransform=R1;function B1(e){let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t}At.httpHeadersTransform=B1});var ea=ee(jr=>{"use strict";Object.defineProperty(jr,"__esModule",{value:!0});jr.AgentReadStateError=jr.AgentQueryError=jr.AgentCallError=jr.AgentHTTPResponseError=void 0;var Lo=_i(),Iu=class extends Lo.AgentError{constructor(t,r){super(t),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};jr.AgentHTTPResponseError=Iu;var Du=class extends Lo.AgentError{constructor(t,r,n,i,s,o){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}};jr.AgentCallError=Du;var Lu=class extends Lo.AgentError{constructor(t,r,n,i,s,o){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}};jr.AgentQueryError=Lu;var el=class extends Lo.AgentError{constructor(t,r,n,i,s,o){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};jr.AgentReadStateError=el});var It=ee(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.notImplemented=Ce.bitMask=void 0;Ce.isBytes=ra;Ce.abytes=na;Ce.abool=U1;Ce.bytesToHex=il;Ce.numberToHexUnpadded=X0;Ce.hexToNumber=sl;Ce.hexToBytes=ia;Ce.bytesToNumberBE=C1;Ce.bytesToNumberLE=M1;Ce.numberToBytesBE=Q0;Ce.numberToBytesLE=q1;Ce.numberToVarBytesBE=j1;Ce.ensureBytes=k1;Ce.concatBytes=I0;Ce.equalBytes=V1;Ce.utf8ToBytes=H1;Ce.inRange=D0;Ce.aInRange=K1;Ce.bitLen=$1;Ce.bitGet=G1;Ce.bitSet=Y1;Ce.createHmacDrbg=W1;Ce.validateObject=Z1;Ce.memoized=Q1;var nl=BigInt(0),ta=BigInt(1),P1=BigInt(2);function ra(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function na(e){if(!ra(e))throw new Error("Uint8Array expected")}function U1(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){na(e);let t="";for(let r=0;r<e.length;r++)t+=F1[e[r]];return t}function X0(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 J0(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 ia(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 o=J0(e.charCodeAt(s)),a=J0(e.charCodeAt(s+1));if(o===void 0||a===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]=o*16+a}return n}function C1(e){return sl(il(e))}function M1(e){return na(e),sl(il(Uint8Array.from(e).reverse()))}function Q0(e,t){return ia(e.toString(16).padStart(t*2,"0"))}function q1(e,t){return Q0(e,t).reverse()}function j1(e){return ia(X0(e))}function k1(e,t,r){let n;if(typeof t=="string")try{n=ia(t)}catch(s){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`)}else if(ra(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 I0(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];na(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 V1(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 H1(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 D0(e,t,r){return tl(e)&&tl(t)&&tl(r)&&t<=e&&e<r}function K1(e,t,r,n){if(!D0(t,r,n))throw new Error(`expected valid ${e}: ${r} <= n < ${n}, got ${typeof t} ${t}`)}function $1(e){let t;for(t=0;e>nl;e>>=ta,t+=1);return t}function G1(e,t){return e>>BigInt(t)&ta}function Y1(e,t,r){return e|(r?ta:nl)<<BigInt(t)}var z1=e=>(P1<<BigInt(e-1))-ta;Ce.bitMask=z1;var rl=e=>new Uint8Array(e),Z0=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=rl(e),i=rl(e),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...h)=>r(i,n,...h),c=(h=rl())=>{i=a(Z0([0]),h),n=a(),h.length!==0&&(i=a(Z0([1]),h),n=a())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,m=[];for(;h<t;){n=a();let b=n.slice();m.push(b),h+=n.length}return I0(...m)};return(h,m)=>{o(),c(h);let b;for(;!(b=m(d()));)c();return o(),b}}var J1={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"||ra(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 Z1(e,t,r={}){let n=(i,s,o)=>{let a=J1[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=e[i];if(!(o&&c===void 0)&&!a(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 X1=()=>{throw new Error("not implemented")};Ce.notImplemented=X1;function Q1(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 kr=ee(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.isNegativeLE=void 0;Xe.mod=Dt;Xe.pow=th;Xe.pow2=ew;Xe.invert=sa;Xe.tonelliShanks=rh;Xe.FpSqrt=nh;Xe.validateField=nw;Xe.FpPow=ih;Xe.FpInvertBatch=sh;Xe.FpDiv=iw;Xe.FpLegendre=oh;Xe.FpIsSquare=sw;Xe.nLength=al;Xe.Field=ow;Xe.FpSqrtOdd=aw;Xe.FpSqrtEven=cw;Xe.hashToPrivateScalar=uw;Xe.getFieldBytesLength=cl;Xe.getMinHashLength=ah;Xe.mapHashToField=lw;var Lt=It(),ut=BigInt(0),Ke=BigInt(1),bn=BigInt(2),I1=BigInt(3),ol=BigInt(4),L0=BigInt(5),eh=BigInt(8),D1=BigInt(9),L1=BigInt(16);function Dt(e,t){let r=e%t;return r>=ut?r:t+r}function th(e,t,r){if(r<=ut||t<ut)throw new Error("Expected power/modulo > 0");if(r===Ke)return ut;let n=Ke;for(;t>ut;)t&Ke&&(n=n*e%r),e=e*e%r,t>>=Ke;return n}function ew(e,t,r){let n=e;for(;t-- >ut;)n*=n,n%=r;return n}function sa(e,t){if(e===ut||t<=ut)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=Dt(e,t),n=t,i=ut,s=Ke,o=Ke,a=ut;for(;r!==ut;){let d=n/r,f=n%r,h=i-o*d,m=s-a*d;n=r,r=f,i=o,s=a,o=h,a=m}if(n!==Ke)throw new Error("invert: does not exist");return Dt(i,t)}function rh(e){let t=(e-Ke)/bn,r,n,i;for(r=e-Ke,n=0;r%bn===ut;r/=bn,n++);for(i=bn;i<e&&th(i,t,e)!==e-Ke;i++);if(n===1){let o=(e+Ke)/ol;return function(c,d){let f=c.pow(d,o);if(!c.eql(c.sqr(f),d))throw new Error("Cannot find square root");return f}}let s=(r+Ke)/bn;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let d=n,f=a.pow(a.mul(a.ONE,i),r),h=a.pow(c,s),m=a.pow(c,r);for(;!a.eql(m,a.ONE);){if(a.eql(m,a.ZERO))return a.ZERO;let b=1;for(let S=a.sqr(m);b<d&&!a.eql(S,a.ONE);b++)S=a.sqr(S);let l=a.pow(f,Ke<<BigInt(d-b-1));f=a.sqr(l),h=a.mul(h,l),m=a.mul(m,f),d=b}return h}}function nh(e){if(e%ol===I1){let t=(e+Ke)/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%eh===L0){let t=(e-L0)/eh;return function(n,i){let s=n.mul(i,bn),o=n.pow(s,t),a=n.mul(i,o),c=n.mul(n.mul(a,bn),o),d=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(d),i))throw new Error("Cannot find square root");return d}}return e%L1,rh(e)}var tw=(e,t)=>(Dt(e,t)&Ke)===Ke;Xe.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,Lt.validateObject)(e,r)}function ih(e,t,r){if(r<ut)throw new Error("Expected power > 0");if(r===ut)return e.ONE;if(r===Ke)return t;let n=e.ONE,i=t;for(;r>ut;)r&Ke&&(n=e.mul(n,i)),i=e.sqr(i),r>>=Ke;return n}function sh(e,t){let r=new Array(t.length),n=t.reduce((s,o,a)=>e.is0(o)?s:(r[a]=s,e.mul(s,o)),e.ONE),i=e.inv(n);return t.reduceRight((s,o,a)=>e.is0(o)?s:(r[a]=e.mul(s,r[a]),e.mul(s,o)),i),r}function iw(e,t,r){return e.mul(t,typeof r=="bigint"?sa(r,e.ORDER):e.inv(r))}function oh(e){let t=(e-Ke)/bn;return(r,n)=>r.pow(n,t)}function sw(e){let t=oh(e.ORDER);return r=>{let n=t(e,r);return e.eql(n,e.ZERO)||e.eql(n,e.ONE)}}function al(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function ow(e,t,r=!1,n={}){if(e<=ut)throw new Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:s}=al(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=nh(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:(0,Lt.bitMask)(i),ZERO:ut,ONE:Ke,create:c=>Dt(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&Ke)===Ke,neg:c=>Dt(-c,e),eql:(c,d)=>c===d,sqr:c=>Dt(c*c,e),add:(c,d)=>Dt(c+d,e),sub:(c,d)=>Dt(c-d,e),mul:(c,d)=>Dt(c*d,e),pow:(c,d)=>ih(a,c,d),div:(c,d)=>Dt(c*sa(d,e),e),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>sa(c,e),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>sh(a,c),cmov:(c,d,f)=>f?d:c,toBytes:c=>r?(0,Lt.numberToBytesLE)(c,s):(0,Lt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Lt.bytesToNumberLE)(c):(0,Lt.bytesToNumberBE)(c)}});return Object.freeze(a)}function aw(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,Lt.ensureBytes)("privateHash",e);let n=e.length,i=al(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,Lt.bytesToNumberLE)(e):(0,Lt.bytesToNumberBE)(e);return Dt(s,t-Ke)+Ke}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 ah(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=ah(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Lt.bytesToNumberBE)(e):(0,Lt.bytesToNumberLE)(e),a=Dt(o,t-Ke)+Ke;return r?(0,Lt.numberToBytesLE)(a,i):(0,Lt.numberToBytesBE)(a,i)}});var oa=ee(Yn=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.expand_message_xmd=ch;Yn.expand_message_xof=uh;Yn.hash_to_field=ul;Yn.isogenyMap=pw;Yn.createHasher=_w;var dw=kr(),St=It(),fw=St.bytesToNumberBE;function wn(e,t){if(ms(e),ms(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 hw(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 ms(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function ch(e,t,r,n){(0,St.abytes)(e),(0,St.abytes)(t),ms(r),t.length>255&&(t=n((0,St.concatBytes)((0,St.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=(0,St.concatBytes)(t,wn(t.length,1)),c=wn(0,s),d=wn(r,2),f=new Array(o),h=n((0,St.concatBytes)(c,e,d,wn(0,1),a));f[0]=n((0,St.concatBytes)(h,wn(1,1),a));for(let b=1;b<=o;b++){let l=[hw(h,f[b-1]),wn(b+1,1),a];f[b]=n((0,St.concatBytes)(...l))}return(0,St.concatBytes)(...f).slice(0,r)}function uh(e,t,r,n,i){if((0,St.abytes)(e),(0,St.abytes)(t),ms(r),t.length>255){let s=Math.ceil(2*n/8);t=i.create({dkLen:s}).update((0,St.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,St.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:a,DST:c}=r;(0,St.abytes)(e),ms(t);let d=typeof c=="string"?(0,St.utf8ToBytes)(c):c,f=n.toString(2).length,h=Math.ceil((f+i)/8),m=t*s*h,b;if(a==="xmd")b=ch(e,d,m,o);else if(a==="xof")b=uh(e,d,m,i,o);else if(a==="_internal_pass")b=e;else throw new Error('expand must be "xmd" or "xof"');let l=new Array(t);for(let S=0;S<t;S++){let N=new Array(s);for(let F=0;F<s;F++){let q=h*(F+S*s),O=b.subarray(q,q+h);N[F]=(0,dw.mod)(fw(O),n)}l[S]=N}return l}function pw(e,t){let r=t.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(d=>d.reduce((f,h)=>e.add(e.mul(f,n),h)));return n=e.div(s,o),i=e.mul(i,e.div(a,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}),o=e.fromAffine(t(s[0])),a=e.fromAffine(t(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=ul(n,1,{...r,DST:r.encodeDST,...i}),o=e.fromAffine(t(s[0])).clearCofactor();return o.assertValidity(),o},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(gs=>{"use strict";Object.defineProperty(gs,"__esModule",{value:!0});gs.wNAF=mw;gs.pippenger=gw;gs.validateBasic=bw;var lh=kr(),fh=It(),yw=BigInt(0),ll=BigInt(1),dl=new WeakMap,dh=new WeakMap;function mw(e,t){let r=(s,o)=>{let a=o.negate();return s?a:o},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 o=Math.ceil(t/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=e.ZERO,c=s;for(;o>yw;)o&ll&&(a=a.add(c)),c=c.double(),o>>=ll;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),d=[],f=s,h=f;for(let m=0;m<a;m++){h=f,d.push(h);for(let b=1;b<c;b++)h=h.add(f),d.push(h);f=h.double()}return d},wNAF(s,o,a){let{windows:c,windowSize:d}=i(s),f=e.ZERO,h=e.BASE,m=BigInt(2**s-1),b=2**s,l=BigInt(s);for(let S=0;S<c;S++){let N=S*d,F=Number(a&m);a>>=l,F>d&&(F-=b,a+=ll);let q=N,O=N+Math.abs(F)-1,G=S%2!==0,E=F<0;F===0?h=h.add(r(G,o[q])):f=f.add(r(E,o[O]))}return{p:f,f:h}},wNAFCached(s,o,a){let c=dh.get(s)||1,d=dl.get(s);return d||(d=this.precomputeWindow(s,c),c!==1&&dl.set(s,a(d))),this.wNAF(c,d,o)},setWindowSize(s,o){n(o),dh.set(s,o),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,h)=>{if(!t.isValid(f))throw new Error(`wrong scalar at index ${h}`)}),r.forEach((f,h)=>{if(!(f instanceof e))throw new Error(`wrong point at index ${h}`)});let i=(0,fh.bitLen)(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,a=new Array(o+1).fill(e.ZERO),c=Math.floor((t.BITS-1)/s)*s,d=e.ZERO;for(let f=c;f>=0;f-=s){a.fill(e.ZERO);for(let m=0;m<n.length;m++){let b=n[m],l=Number(b>>BigInt(f)&BigInt(o));a[l]=a[l].add(r[m])}let h=e.ZERO;for(let m=a.length-1,b=e.ZERO;m>0;m--)b=b.add(a[m]),h=h.add(b);if(d=d.add(h),f!==0)for(let m=0;m<s;m++)d=d.double()}return d}function bw(e){return(0,lh.validateField)(e.Fp),(0,fh.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,lh.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=_h;wt.weierstrass=Ow;wt.SWUFpSqrtRatio=yh;wt.mapToCurveSimpleSWU=vw;var aa=fl(),zn=kr(),Ne=It(),bt=It();function hh(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,aa.validateBasic)(e);Ne.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:Ew,hexToBytes:xw}=Ne;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=Ne.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Ne.numberToHexUnpadded(i.length/2|128):"";return`${Ne.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),o=0;if(!s)o=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)o=o<<8|f;if(n+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+o)}}},_int:{encode(e){let{Err:t}=wt.DER;if(e<mr)throw new t("integer: negative integers are not allowed");let r=Ne.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 Ew(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=wt.DER,i=typeof e=="string"?xw(e):e;Ne.abytes(i);let{v:s,l:o}=n.decode(48,i);if(o.length)throw new t("Invalid signature: left bytes after parsing");let{v:a,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(a),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),En=BigInt(2),ca=BigInt(3),ph=BigInt(4);function _h(e){let t=ww(e),{Fp:r}=t,n=zn.Field(t.n,t.nBitLength),i=t.toBytes||((S,N,F)=>{let q=N.toAffine();return Ne.concatBytes(Uint8Array.from([4]),r.toBytes(q.x),r.toBytes(q.y))}),s=t.fromBytes||(S=>{let N=S.subarray(1),F=r.fromBytes(N.subarray(0,r.BYTES)),q=r.fromBytes(N.subarray(r.BYTES,2*r.BYTES));return{x:F,y:q}});function o(S){let{a:N,b:F}=t,q=r.sqr(S),O=r.mul(q,S);return r.add(r.add(O,r.mul(S,N)),F)}if(!r.eql(r.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function a(S){return Ne.inRange(S,ke,t.n)}function c(S){let{allowedPrivateKeyLengths:N,nByteLength:F,wrapPrivateKey:q,n:O}=t;if(N&&typeof S!="bigint"){if(Ne.isBytes(S)&&(S=Ne.bytesToHex(S)),typeof S!="string"||!N.includes(S.length))throw new Error("Invalid key");S=S.padStart(F*2,"0")}let G;try{G=typeof S=="bigint"?S:Ne.bytesToNumberBE((0,bt.ensureBytes)("private key",S,F))}catch{throw new Error(`private key must be ${F} bytes, hex or bigint, not ${typeof S}`)}return q&&(G=zn.mod(G,O)),Ne.aInRange("private key",G,ke,O),G}function d(S){if(!(S instanceof m))throw new Error("ProjectivePoint expected")}let f=(0,bt.memoized)((S,N)=>{let{px:F,py:q,pz:O}=S;if(r.eql(O,r.ONE))return{x:F,y:q};let G=S.is0();N==null&&(N=G?r.ONE:r.inv(O));let E=r.mul(F,N),j=r.mul(q,N),Y=r.mul(O,N);if(G)return{x:r.ZERO,y:r.ZERO};if(!r.eql(Y,r.ONE))throw new Error("invZ was invalid");return{x:E,y:j}}),h=(0,bt.memoized)(S=>{if(S.is0()){if(t.allowInfinityPoint&&!r.is0(S.py))return;throw new Error("bad point: ZERO")}let{x:N,y:F}=S.toAffine();if(!r.isValid(N)||!r.isValid(F))throw new Error("bad point: x or y not FE");let q=r.sqr(F),O=o(N);if(!r.eql(q,O))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(N,F,q){if(this.px=N,this.py=F,this.pz=q,N==null||!r.isValid(N))throw new Error("x required");if(F==null||!r.isValid(F))throw new Error("y required");if(q==null||!r.isValid(q))throw new Error("z required");Object.freeze(this)}static fromAffine(N){let{x:F,y:q}=N||{};if(!N||!r.isValid(F)||!r.isValid(q))throw new Error("invalid affine point");if(N instanceof m)throw new Error("projective point not allowed");let O=G=>r.eql(G,r.ZERO);return O(F)&&O(q)?m.ZERO:new m(F,q,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(N){let F=r.invertBatch(N.map(q=>q.pz));return N.map((q,O)=>q.toAffine(F[O])).map(m.fromAffine)}static fromHex(N){let F=m.fromAffine(s((0,bt.ensureBytes)("pointHex",N)));return F.assertValidity(),F}static fromPrivateKey(N){return m.BASE.multiply(c(N))}static msm(N,F){return(0,aa.pippenger)(m,n,N,F)}_setWindowSize(N){l.setWindowSize(this,N)}assertValidity(){h(this)}hasEvenY(){let{y:N}=this.toAffine();if(r.isOdd)return!r.isOdd(N);throw new Error("Field doesn't support isOdd")}equals(N){d(N);let{px:F,py:q,pz:O}=this,{px:G,py:E,pz:j}=N,Y=r.eql(r.mul(F,j),r.mul(G,O)),z=r.eql(r.mul(q,j),r.mul(E,O));return Y&&z}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:N,b:F}=t,q=r.mul(F,ca),{px:O,py:G,pz:E}=this,j=r.ZERO,Y=r.ZERO,z=r.ZERO,k=r.mul(O,O),oe=r.mul(G,G),L=r.mul(E,E),ne=r.mul(O,G);return ne=r.add(ne,ne),z=r.mul(O,E),z=r.add(z,z),j=r.mul(N,z),Y=r.mul(q,L),Y=r.add(j,Y),j=r.sub(oe,Y),Y=r.add(oe,Y),Y=r.mul(j,Y),j=r.mul(ne,j),z=r.mul(q,z),L=r.mul(N,L),ne=r.sub(k,L),ne=r.mul(N,ne),ne=r.add(ne,z),z=r.add(k,k),k=r.add(z,k),k=r.add(k,L),k=r.mul(k,ne),Y=r.add(Y,k),L=r.mul(G,E),L=r.add(L,L),k=r.mul(L,ne),j=r.sub(j,k),z=r.mul(L,oe),z=r.add(z,z),z=r.add(z,z),new m(j,Y,z)}add(N){d(N);let{px:F,py:q,pz:O}=this,{px:G,py:E,pz:j}=N,Y=r.ZERO,z=r.ZERO,k=r.ZERO,oe=t.a,L=r.mul(t.b,ca),ne=r.mul(F,G),w=r.mul(q,E),g=r.mul(O,j),R=r.add(F,q),A=r.add(G,E);R=r.mul(R,A),A=r.add(ne,w),R=r.sub(R,A),A=r.add(F,O);let B=r.add(G,j);return A=r.mul(A,B),B=r.add(ne,g),A=r.sub(A,B),B=r.add(q,O),Y=r.add(E,j),B=r.mul(B,Y),Y=r.add(w,g),B=r.sub(B,Y),k=r.mul(oe,A),Y=r.mul(L,g),k=r.add(Y,k),Y=r.sub(w,k),k=r.add(w,k),z=r.mul(Y,k),w=r.add(ne,ne),w=r.add(w,ne),g=r.mul(oe,g),A=r.mul(L,A),w=r.add(w,g),g=r.sub(ne,g),g=r.mul(oe,g),A=r.add(A,g),ne=r.mul(w,A),z=r.add(z,ne),ne=r.mul(B,A),Y=r.mul(R,Y),Y=r.sub(Y,ne),ne=r.mul(R,w),k=r.mul(B,k),k=r.add(k,ne),new m(Y,z,k)}subtract(N){return this.add(N.negate())}is0(){return this.equals(m.ZERO)}wNAF(N){return l.wNAFCached(this,N,m.normalizeZ)}multiplyUnsafe(N){Ne.aInRange("scalar",N,mr,t.n);let F=m.ZERO;if(N===mr)return F;if(N===ke)return this;let{endo:q}=t;if(!q)return l.unsafeLadder(this,N);let{k1neg:O,k1:G,k2neg:E,k2:j}=q.splitScalar(N),Y=F,z=F,k=this;for(;G>mr||j>mr;)G&ke&&(Y=Y.add(k)),j&ke&&(z=z.add(k)),k=k.double(),G>>=ke,j>>=ke;return O&&(Y=Y.negate()),E&&(z=z.negate()),z=new m(r.mul(z.px,q.beta),z.py,z.pz),Y.add(z)}multiply(N){let{endo:F,n:q}=t;Ne.aInRange("scalar",N,ke,q);let O,G;if(F){let{k1neg:E,k1:j,k2neg:Y,k2:z}=F.splitScalar(N),{p:k,f:oe}=this.wNAF(j),{p:L,f:ne}=this.wNAF(z);k=l.constTimeNegate(E,k),L=l.constTimeNegate(Y,L),L=new m(r.mul(L.px,F.beta),L.py,L.pz),O=k.add(L),G=oe.add(ne)}else{let{p:E,f:j}=this.wNAF(N);O=E,G=j}return m.normalizeZ([O,G])[0]}multiplyAndAddUnsafe(N,F,q){let O=m.BASE,G=(j,Y)=>Y===mr||Y===ke||!j.equals(O)?j.multiplyUnsafe(Y):j.multiply(Y),E=G(this,F).add(G(N,q));return E.is0()?void 0:E}toAffine(N){return f(this,N)}isTorsionFree(){let{h:N,isTorsionFree:F}=t;if(N===ke)return!0;if(F)return F(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:N,clearCofactor:F}=t;return N===ke?this:F?F(m,this):this.multiplyUnsafe(t.h)}toRawBytes(N=!0){return(0,bt.abool)("isCompressed",N),this.assertValidity(),i(m,this,N)}toHex(N=!0){return(0,bt.abool)("isCompressed",N),Ne.bytesToHex(this.toRawBytes(N))}}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,aa.wNAF)(m,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function Tw(e){let t=(0,aa.validateBasic)(e);return Ne.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=Tw(e),{Fp:r,n}=t,i=r.BYTES+1,s=2*r.BYTES+1;function o(g){return zn.mod(g,n)}function a(g){return zn.invert(g,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:h}=_h({...t,toBytes(g,R,A){let B=R.toAffine(),K=r.toBytes(B.x),X=Ne.concatBytes;return(0,bt.abool)("isCompressed",A),A?X(Uint8Array.from([R.hasEvenY()?2:3]),K):X(Uint8Array.from([4]),K,r.toBytes(B.y))},fromBytes(g){let R=g.length,A=g[0],B=g.subarray(1);if(R===i&&(A===2||A===3)){let K=Ne.bytesToNumberBE(B);if(!Ne.inRange(K,ke,r.ORDER))throw new Error("Point is not on curve");let X=f(K),ae;try{ae=r.sqrt(X)}catch(C){let _=C instanceof Error?": "+C.message:"";throw new Error("Point is not on curve"+_)}let se=(ae&ke)===ke;return(A&1)===1!==se&&(ae=r.neg(ae)),{x:K,y:ae}}else if(R===s&&A===4){let K=r.fromBytes(B.subarray(0,r.BYTES)),X=r.fromBytes(B.subarray(r.BYTES,2*r.BYTES));return{x:K,y:X}}else throw new Error(`Point of length ${R} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=g=>Ne.bytesToHex(Ne.numberToBytesBE(g,t.nByteLength));function b(g){let R=n>>ke;return g>R}function l(g){return b(g)?o(-g):g}let S=(g,R,A)=>Ne.bytesToNumberBE(g.slice(R,A));class N{constructor(R,A,B){this.r=R,this.s=A,this.recovery=B,this.assertValidity()}static fromCompact(R){let A=t.nByteLength;return R=(0,bt.ensureBytes)("compactSignature",R,A*2),new N(S(R,0,A),S(R,A,2*A))}static fromDER(R){let{r:A,s:B}=wt.DER.toSig((0,bt.ensureBytes)("DER",R));return new N(A,B)}assertValidity(){Ne.aInRange("r",this.r,ke,n),Ne.aInRange("s",this.s,ke,n)}addRecoveryBit(R){return new N(this.r,this.s,R)}recoverPublicKey(R){let{r:A,s:B,recovery:K}=this,X=j((0,bt.ensureBytes)("msgHash",R));if(K==null||![0,1,2,3].includes(K))throw new Error("recovery id invalid");let ae=K===2||K===3?A+t.n:A;if(ae>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let se=(K&1)===0?"02":"03",Z=c.fromHex(se+m(ae)),C=a(ae),_=o(-X*C),I=o(B*C),re=c.BASE.multiplyAndAddUnsafe(Z,_,I);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new N(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ne.hexToBytes(this.toDERHex())}toDERHex(){return wt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ne.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=zn.getMinHashLength(t.n);return zn.mapHashToField(t.randomBytes(g),t.n)},precompute(g=8,R=c.BASE){return R._setWindowSize(g),R.multiply(BigInt(3)),R}};function q(g,R=!0){return c.fromPrivateKey(g).toRawBytes(R)}function O(g){let R=Ne.isBytes(g),A=typeof g=="string",B=(R||A)&&g.length;return R?B===i||B===s:A?B===2*i||B===2*s:g instanceof c}function G(g,R,A=!0){if(O(g))throw new Error("first arg must be private key");if(!O(R))throw new Error("second arg must be public key");return c.fromHex(R).multiply(d(g)).toRawBytes(A)}let E=t.bits2int||function(g){let R=Ne.bytesToNumberBE(g),A=g.length*8-t.nBitLength;return A>0?R>>BigInt(A):R},j=t.bits2int_modN||function(g){return o(E(g))},Y=Ne.bitMask(t.nBitLength);function z(g){return Ne.aInRange(`num < 2^${t.nBitLength}`,g,mr,Y),Ne.numberToBytesBE(g,t.nByteLength)}function k(g,R,A=oe){if(["recovered","canonical"].some(D=>D in A))throw new Error("sign() legacy options not supported");let{hash:B,randomBytes:K}=t,{lowS:X,prehash:ae,extraEntropy:se}=A;X==null&&(X=!0),g=(0,bt.ensureBytes)("msgHash",g),hh(A),ae&&(g=(0,bt.ensureBytes)("prehashed msgHash",B(g)));let Z=j(g),C=d(R),_=[z(C),z(Z)];if(se!=null&&se!==!1){let D=se===!0?K(r.BYTES):se;_.push((0,bt.ensureBytes)("extraEntropy",D))}let I=Ne.concatBytes(..._),re=Z;function le(D){let u=E(D);if(!h(u))return;let p=a(u),y=c.BASE.multiply(u).toAffine(),U=o(y.x);if(U===mr)return;let v=o(p*o(re+U*C));if(v===mr)return;let P=(y.x===U?0:2)|Number(y.y&ke),H=v;return X&&b(v)&&(H=l(v),P^=1),new N(U,H,P)}return{seed:I,k2sig:le}}let oe={lowS:t.lowS,prehash:!1},L={lowS:t.lowS,prehash:!1};function ne(g,R,A=oe){let{seed:B,k2sig:K}=k(g,R,A),X=t;return Ne.createHmacDrbg(X.hash.outputLen,X.nByteLength,X.hmac)(B,K)}c.BASE._setWindowSize(8);function w(g,R,A,B=L){let K=g;if(R=(0,bt.ensureBytes)("msgHash",R),A=(0,bt.ensureBytes)("publicKey",A),"strict"in B)throw new Error("options.strict was renamed to lowS");hh(B);let{lowS:X,prehash:ae}=B,se,Z;try{if(typeof K=="string"||Ne.isBytes(K))try{se=N.fromDER(K)}catch(y){if(!(y instanceof wt.DER.Err))throw y;se=N.fromCompact(K)}else if(typeof K=="object"&&typeof K.r=="bigint"&&typeof K.s=="bigint"){let{r:y,s:U}=K;se=new N(y,U)}else throw new Error("PARSE");Z=c.fromHex(A)}catch(y){if(y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(X&&se.hasHighS())return!1;ae&&(R=t.hash(R));let{r:C,s:_}=se,I=j(R),re=a(_),le=o(I*re),D=o(C*re),u=c.BASE.multiplyAndAddUnsafe(Z,le,D)?.toAffine();return u?o(u.x)===C:!1}return{CURVE:t,getPublicKey:q,getSharedSecret:G,sign:ne,verify:w,ProjectivePoint:c,Signature:N,utils:F}}function yh(e,t){let r=e.ORDER,n=mr;for(let l=r-ke;l%En===mr;l/=En)n+=ke;let i=n,s=En<<i-ke-ke,o=s*En,a=(r-ke)/o,c=(a-ke)/En,d=o-ke,f=s,h=e.pow(t,a),m=e.pow(t,(a+ke)/En),b=(l,S)=>{let N=h,F=e.pow(S,d),q=e.sqr(F);q=e.mul(q,S);let O=e.mul(l,q);O=e.pow(O,c),O=e.mul(O,F),F=e.mul(O,S),q=e.mul(O,l);let G=e.mul(q,F);O=e.pow(G,f);let E=e.eql(O,e.ONE);F=e.mul(q,m),O=e.mul(G,N),q=e.cmov(F,q,E),G=e.cmov(O,G,E);for(let j=i;j>ke;j--){let Y=j-En;Y=En<<Y-ke;let z=e.pow(G,Y),k=e.eql(z,e.ONE);F=e.mul(q,N),N=e.mul(N,N),z=e.mul(G,N),q=e.cmov(F,q,k),G=e.cmov(z,G,k)}return{isValid:E,value:q}};if(e.ORDER%ph===ca){let l=(e.ORDER-ca)/ph,S=e.sqrt(e.neg(t));b=(N,F)=>{let q=e.sqr(F),O=e.mul(N,F);q=e.mul(q,O);let G=e.pow(q,l);G=e.mul(G,O);let E=e.mul(G,S),j=e.mul(e.sqr(G),F),Y=e.eql(j,N),z=e.cmov(E,G,Y);return{isValid:Y,value:z}}}return b}function vw(e,t){if(zn.validateField(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=yh(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,d,f,h;i=e.sqr(n),i=e.mul(i,t.Z),s=e.sqr(i),s=e.add(s,i),o=e.add(s,e.ONE),o=e.mul(o,t.B),a=e.cmov(t.Z,e.neg(s),!e.eql(s,e.ZERO)),a=e.mul(a,t.A),s=e.sqr(o),d=e.sqr(a),c=e.mul(d,t.A),s=e.add(s,c),s=e.mul(s,o),d=e.mul(d,a),c=e.mul(d,t.B),s=e.add(s,c),f=e.mul(i,o);let{isValid:m,value:b}=r(s,d);h=e.mul(i,n),h=e.mul(h,b),f=e.cmov(f,o,m),h=e.cmov(h,b,m);let l=e.isOdd(n)===e.isOdd(h);return h=e.cmov(e.neg(h),h,l),f=e.div(f,a),{x:f,y:h}}}});var Eh=ee(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});_l.bls=Sw;var mh=kr(),pl=It(),gh=oa(),bh=hl(),Nw=BigInt(0),ua=BigInt(1),wh=BigInt(2),Ni=BigInt(3);function Aw(e){let t=[];for(;e>ua;e>>=ua)(e&ua)===Nw?t.unshift(0):(e&Ni)===Ni?(t.unshift(-1),e+=ua):t.unshift(1);return t}function Sw(e){let{Fp:t,Fr:r,Fp2:n,Fp6:i,Fp12:s}=e.fields,o=e.params.xNegative,a=e.params.twistType,c=(0,bh.weierstrassPoints)({n:r.ORDER,...e.G1}),d=Object.assign(c,(0,gh.createHasher)(c.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),f=(0,bh.weierstrassPoints)({n:r.ORDER,...e.G2}),h=Object.assign(f,(0,gh.createHasher)(f.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults})),m;if(a==="multiplicative")m=(Z,C,_,I,re,le)=>s.mul014(I,Z,n.mul(C,re),n.mul(_,le));else if(a==="divisive")m=(Z,C,_,I,re,le)=>s.mul034(I,n.mul(_,le),n.mul(C,re),Z);else throw new Error("bls: unknown twist type");let b=n.div(n.ONE,n.mul(n.ONE,wh));function l(Z,C,_,I){let re=n.sqr(_),le=n.sqr(I),D=n.mulByB(n.mul(le,Ni)),u=n.mul(D,Ni),p=n.sub(n.sub(n.sqr(n.add(_,I)),le),re),y=n.sub(D,re),U=n.mul(n.sqr(C),Ni),v=n.neg(p);return Z.push([y,U,v]),C=n.mul(n.mul(n.mul(n.sub(re,u),C),_),b),_=n.sub(n.sqr(n.mul(n.add(re,u),b)),n.mul(n.sqr(D),Ni)),I=n.mul(re,p),{Rx:C,Ry:_,Rz:I}}function S(Z,C,_,I,re,le){let D=n.sub(_,n.mul(le,I)),u=n.sub(C,n.mul(re,I)),p=n.sub(n.mul(D,re),n.mul(u,le)),y=n.neg(D),U=u;Z.push([p,y,U]);let v=n.sqr(u),P=n.mul(v,u),H=n.mul(v,C),x=n.add(n.sub(P,n.mul(H,wh)),n.mul(n.sqr(D),I));return C=n.mul(u,x),_=n.sub(n.mul(n.sub(H,x),D),n.mul(P,_)),I=n.mul(I,P),{Rx:C,Ry:_,Rz:I}}let N=Aw(e.params.ateLoopSize),F=(0,pl.memoized)(Z=>{let C=Z,{x:_,y:I}=C.toAffine(),re=_,le=I,D=n.neg(I),u=re,p=le,y=n.ONE,U=[];for(let v of N){let P=[];({Rx:u,Ry:p,Rz:y}=l(P,u,p,y)),v&&({Rx:u,Ry:p,Rz:y}=S(P,u,p,y,re,v===-1?D:le)),U.push(P)}if(e.postPrecompute){let v=U[U.length-1];e.postPrecompute(u,p,y,re,le,S.bind(null,v))}return U});function q(Z,C=!1){let _=s.ONE;if(Z.length){let I=Z[0][0].length;for(let re=0;re<I;re++){_=s.sqr(_);for(let[le,D,u]of Z)for(let[p,y,U]of le[re])_=m(p,y,U,_,D,u)}}return o&&(_=s.conjugate(_)),C?s.finalExponentiate(_):_}function O(Z,C=!0){let _=[];d.ProjectivePoint.normalizeZ(Z.map(({g1:I})=>I)),h.ProjectivePoint.normalizeZ(Z.map(({g2:I})=>I));for(let{g1:I,g2:re}of Z){if(I.equals(d.ProjectivePoint.ZERO)||re.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");I.assertValidity(),re.assertValidity();let le=I.toAffine();_.push([F(re),le.x,le.y])}return q(_,C)}function G(Z,C,_=!0){return O([{g1:Z,g2:C}],_)}let E={randomPrivateKey:()=>{let Z=(0,mh.getMinHashLength)(r.ORDER);return(0,mh.mapHashToField)(e.randomBytes(Z),r.ORDER)},calcPairingPrecomputes:F},{ShortSignature:j}=e.G1,{Signature:Y}=e.G2;function z(Z){return Z instanceof d.ProjectivePoint?Z:d.ProjectivePoint.fromHex(Z)}function k(Z,C){return Z instanceof d.ProjectivePoint?Z:d.hashToCurve((0,pl.ensureBytes)("point",Z),C)}function oe(Z){return Z instanceof h.ProjectivePoint?Z:Y.fromHex(Z)}function L(Z,C){return Z instanceof h.ProjectivePoint?Z:h.hashToCurve((0,pl.ensureBytes)("point",Z),C)}function ne(Z){return d.ProjectivePoint.fromPrivateKey(Z).toRawBytes(!0)}function w(Z){return h.ProjectivePoint.fromPrivateKey(Z).toRawBytes(!0)}function g(Z,C,_){let I=L(Z,_);I.assertValidity();let re=I.multiply(d.normPrivateKeyToScalar(C));return Z instanceof h.ProjectivePoint?re:Y.toRawBytes(re)}function R(Z,C,_){let I=k(Z,_);I.assertValidity();let re=I.multiply(d.normPrivateKeyToScalar(C));return Z instanceof d.ProjectivePoint?re:j.toRawBytes(re)}function A(Z,C,_,I){let re=z(_),le=L(C,I),D=d.ProjectivePoint.BASE,u=oe(Z),p=O([{g1:re.negate(),g2:le},{g1:D,g2:u}]);return s.eql(p,s.ONE)}function B(Z,C,_,I){let re=oe(_),le=k(C,I),D=h.ProjectivePoint.BASE,u=z(Z),p=O([{g1:le,g2:re},{g1:u,g2:D.negate()}]);return s.eql(p,s.ONE)}function K(Z){if(!Z.length)throw new Error("Expected non-empty array");let _=Z.map(z).reduce((I,re)=>I.add(re),d.ProjectivePoint.ZERO);return Z[0]instanceof d.ProjectivePoint?(_.assertValidity(),_):_.toRawBytes(!0)}function X(Z){if(!Z.length)throw new Error("Expected non-empty array");let _=Z.map(oe).reduce((I,re)=>I.add(re),h.ProjectivePoint.ZERO);return Z[0]instanceof h.ProjectivePoint?(_.assertValidity(),_):Y.toRawBytes(_)}function ae(Z){if(!Z.length)throw new Error("Expected non-empty array");let _=Z.map(z).reduce((I,re)=>I.add(re),d.ProjectivePoint.ZERO);return Z[0]instanceof d.ProjectivePoint?(_.assertValidity(),_):j.toRawBytes(_)}function se(Z,C,_,I){if(!C.length)throw new Error("Expected non-empty messages array");if(_.length!==C.length)throw new Error("Pubkey count should equal msg count");let re=oe(Z),le=C.map(y=>L(y,I)),D=_.map(z),u=new Map;for(let y=0;y<D.length;y++){let U=D[y],v=le[y],P=u.get(v);P===void 0&&(P=[],u.set(v,P)),P.push(U)}let p=[];try{for(let[y,U]of u){let v=U.reduce((P,H)=>P.add(H));p.push({g1:v,g2:y})}return p.push({g1:d.ProjectivePoint.BASE.negate(),g2:re}),s.eql(O(p),s.ONE)}catch{return!1}}return d.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ne,getPublicKeyForShortSignatures:w,sign:g,signShortSignature:R,verify:A,verifyBatch:se,verifyShortSignature:B,aggregatePublicKeys:K,aggregateSignatures:X,aggregateShortSignatures:ae,millerLoopBatch:q,pairing:G,pairingBatch:O,G1:d,G2:h,Signature:Y,ShortSignature:j,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:E}}});var Th=ee(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.psiFrobenius=Bw;la.tower12=Pw;var xn=kr(),gr=It(),Rw=BigInt(0),Ai=BigInt(1),rn=BigInt(2),xh=BigInt(3);function yl(e,t,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let d=0;d<i;d++){let f=BigInt(d+1),h=[];for(let m=0,b=Ai;m<n;m++){let l=(f*b-f)/o%a;h.push(e.pow(t,l)),b*=r}c.push(h)}return c}function Bw(e,t,r){let n=t.pow(r,(e.ORDER-Ai)/xh),i=t.pow(r,(e.ORDER-Ai)/rn);function s(m,b){let l=t.mul(t.frobeniusMap(m,1),n),S=t.mul(t.frobeniusMap(b,1),i);return[l,S]}let o=t.pow(r,(e.ORDER**rn-Ai)/xh),a=t.pow(r,(e.ORDER**rn-Ai)/rn);if(!t.eql(a,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(m,b){return[t.mul(m,o),t.neg(b)]}let d=m=>(b,l)=>{let S=l.toAffine(),N=m(S.x,S.y);return b.fromAffine({x:N[0],y:N[1]})},f=d(s),h=d(c);return{psi:s,psi2:c,G2psi:f,G2psi2:h,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function Pw(e){let{ORDER:t}=e,r=xn.Field(t),n=r.create(e.NONRESIDUE||BigInt(-1)),i=xn.FpLegendre(t),s=r.div(r.ONE,rn),o=yl(r,n,r.ORDER,2)[0],a=({c0:w,c1:g},{c0:R,c1:A})=>({c0:r.add(w,R),c1:r.add(g,A)}),c=({c0:w,c1:g},{c0:R,c1:A})=>({c0:r.sub(w,R),c1:r.sub(g,A)}),d=({c0:w,c1:g},R)=>{if(typeof R=="bigint")return{c0:r.mul(w,R),c1:r.mul(g,R)};let{c0:A,c1:B}=R,K=r.mul(w,A),X=r.mul(g,B),ae=r.sub(K,X),se=r.sub(r.mul(r.add(w,g),r.add(A,B)),r.add(K,X));return{c0:ae,c1:se}},f=({c0:w,c1:g})=>{let R=r.add(w,g),A=r.sub(w,g),B=r.add(w,w);return{c0:r.mul(R,A),c1:r.mul(B,g)}},h=w=>{if(w.length!==2)throw new Error("Invalid tuple");let g=w.map(R=>r.create(R));return{c0:g[0],c1:g[1]}},m=t*t,b=h(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:R,c1:A})=>r.eql(w,R)&&r.eql(g,A),neg:({c0:w,c1:g})=>({c0:r.neg(w),c1:r.neg(g)}),pow:(w,g)=>xn.FpPow(l,w,g),invertBatch:w=>xn.FpInvertBatch(l,w),add:a,sub:c,mul:d,sqr:f,addN:a,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 R=r.inv(r.create(w*w+g*g));return{c0:r.mul(R,r.create(w)),c1:r.mul(R,r.create(-g))}},sqrt:w=>{if(e.Fp2sqrt)return e.Fp2sqrt(w);let{c0:g,c1:R}=w;if(r.is0(R))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 A=r.sqrt(r.sub(r.sqr(g),r.mul(r.sqr(R),n))),B=r.mul(r.add(A,g),s),K=i(r,B);!r.is0(K)&&!r.eql(K,r.ONE)&&(B=r.sub(B,A));let X=r.sqrt(B),ae=l.create({c0:X,c1:r.div(r.mul(R,s),X)});if(!l.eql(l.sqr(ae),w))throw new Error("Cannot find square root");let se=ae,Z=l.neg(se),{re:C,im:_}=l.reim(se),{re:I,im:re}=l.reim(Z);return _>re||_===re&&C>I?se:Z},isOdd:w=>{let{re:g,im:R}=l.reim(w),A=g%rn,B=g===Rw,K=R%rn;return BigInt(A||B&&K)==Ai},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:R,c1:A},B)=>({c0:r.cmov(w,R,B),c1:r.cmov(g,A,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:h,frobeniusMap:({c0:w,c1:g},R)=>({c0:w,c1:r.mul(g,o[R%2])})},S=({c0:w,c1:g,c2:R},{c0:A,c1:B,c2:K})=>({c0:l.add(w,A),c1:l.add(g,B),c2:l.add(R,K)}),N=({c0:w,c1:g,c2:R},{c0:A,c1:B,c2:K})=>({c0:l.sub(w,A),c1:l.sub(g,B),c2:l.sub(R,K)}),F=({c0:w,c1:g,c2:R},A)=>{if(typeof A=="bigint")return{c0:l.mul(w,A),c1:l.mul(g,A),c2:l.mul(R,A)};let{c0:B,c1:K,c2:X}=A,ae=l.mul(w,B),se=l.mul(g,K),Z=l.mul(R,X);return{c0:l.add(ae,l.mulByNonresidue(l.sub(l.mul(l.add(g,R),l.add(K,X)),l.add(se,Z)))),c1:l.add(l.sub(l.mul(l.add(w,g),l.add(B,K)),l.add(ae,se)),l.mulByNonresidue(Z)),c2:l.sub(l.add(se,l.mul(l.add(w,R),l.add(B,X))),l.add(ae,Z))}},q=({c0:w,c1:g,c2:R})=>{let A=l.sqr(w),B=l.mul(l.mul(w,g),rn),K=l.mul(l.mul(g,R),rn),X=l.sqr(R);return{c0:l.add(l.mulByNonresidue(K),A),c1:l.add(l.mulByNonresidue(X),B),c2:l.sub(l.sub(l.add(l.add(B,l.sqr(l.add(l.sub(w,g),R))),K),A),X)}},[O,G]=yl(l,b,r.ORDER,6,2,3),E={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:R})=>l.isValid(w)&&l.isValid(g)&&l.isValid(R),is0:({c0:w,c1:g,c2:R})=>l.is0(w)&&l.is0(g)&&l.is0(R),neg:({c0:w,c1:g,c2:R})=>({c0:l.neg(w),c1:l.neg(g),c2:l.neg(R)}),eql:({c0:w,c1:g,c2:R},{c0:A,c1:B,c2:K})=>l.eql(w,A)&&l.eql(g,B)&&l.eql(R,K),sqrt:gr.notImplemented,div:(w,g)=>E.mul(w,typeof g=="bigint"?r.inv(r.create(g)):E.inv(g)),pow:(w,g)=>xn.FpPow(E,w,g),invertBatch:w=>xn.FpInvertBatch(E,w),add:S,sub:N,mul:F,sqr:q,addN:S,subN:N,mulN:F,sqrN:q,inv:({c0:w,c1:g,c2:R})=>{let A=l.sub(l.sqr(w),l.mulByNonresidue(l.mul(R,g))),B=l.sub(l.mulByNonresidue(l.sqr(R)),l.mul(w,g)),K=l.sub(l.sqr(g),l.mul(w,R)),X=l.inv(l.add(l.mulByNonresidue(l.add(l.mul(R,B),l.mul(g,K))),l.mul(w,A)));return{c0:l.mul(X,A),c1:l.mul(X,B),c2:l.mul(X,K)}},fromBytes:w=>{if(w.length!==E.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:R})=>(0,gr.concatBytes)(l.toBytes(w),l.toBytes(g),l.toBytes(R)),cmov:({c0:w,c1:g,c2:R},{c0:A,c1:B,c2:K},X)=>({c0:l.cmov(w,A,X),c1:l.cmov(g,B,X),c2:l.cmov(R,K,X)}),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:R},A)=>({c0:l.frobeniusMap(w,A),c1:l.mul(l.frobeniusMap(g,A),O[A%6]),c2:l.mul(l.frobeniusMap(R,A),G[A%6])}),mulByFp2:({c0:w,c1:g,c2:R},A)=>({c0:l.mul(w,A),c1:l.mul(g,A),c2:l.mul(R,A)}),mulByNonresidue:({c0:w,c1:g,c2:R})=>({c0:l.mulByNonresidue(R),c1:w,c2:g}),mul1:({c0:w,c1:g,c2:R},A)=>({c0:l.mulByNonresidue(l.mul(R,A)),c1:l.mul(w,A),c2:l.mul(g,A)}),mul01({c0:w,c1:g,c2:R},A,B){let K=l.mul(w,A),X=l.mul(g,B);return{c0:l.add(l.mulByNonresidue(l.sub(l.mul(l.add(g,R),B),X)),K),c1:l.sub(l.sub(l.mul(l.add(A,B),l.add(w,g)),K),X),c2:l.add(l.sub(l.mul(l.add(w,R),A),K),X)}}},j=yl(l,b,r.ORDER,12,1,6)[0],Y=({c0:w,c1:g},{c0:R,c1:A})=>({c0:E.add(w,R),c1:E.add(g,A)}),z=({c0:w,c1:g},{c0:R,c1:A})=>({c0:E.sub(w,R),c1:E.sub(g,A)}),k=({c0:w,c1:g},R)=>{if(typeof R=="bigint")return{c0:E.mul(w,R),c1:E.mul(g,R)};let{c0:A,c1:B}=R,K=E.mul(w,A),X=E.mul(g,B);return{c0:E.add(K,E.mulByNonresidue(X)),c1:E.sub(E.mul(E.add(w,g),E.add(A,B)),E.add(K,X))}},oe=({c0:w,c1:g})=>{let R=E.mul(w,g);return{c0:E.sub(E.sub(E.mul(E.add(E.mulByNonresidue(g),w),E.add(w,g)),R),E.mulByNonresidue(R)),c1:E.add(R,R)}};function L(w,g){let R=l.sqr(w),A=l.sqr(g);return{first:l.add(l.mulByNonresidue(A),R),second:l.sub(l.sub(l.sqr(l.add(w,g)),R),A)}}let ne={ORDER:l.ORDER,BITS:2*l.BITS,BYTES:2*l.BYTES,MASK:(0,gr.bitMask)(2*l.BITS),ZERO:{c0:E.ZERO,c1:E.ZERO},ONE:{c0:E.ONE,c1:E.ZERO},create:w=>w,isValid:({c0:w,c1:g})=>E.isValid(w)&&E.isValid(g),is0:({c0:w,c1:g})=>E.is0(w)&&E.is0(g),neg:({c0:w,c1:g})=>({c0:E.neg(w),c1:E.neg(g)}),eql:({c0:w,c1:g},{c0:R,c1:A})=>E.eql(w,R)&&E.eql(g,A),sqrt:gr.notImplemented,inv:({c0:w,c1:g})=>{let R=E.inv(E.sub(E.sqr(w),E.mulByNonresidue(E.sqr(g))));return{c0:E.mul(w,R),c1:E.neg(E.mul(g,R))}},div:(w,g)=>ne.mul(w,typeof g=="bigint"?r.inv(r.create(g)):ne.inv(g)),pow:(w,g)=>xn.FpPow(ne,w,g),invertBatch:w=>xn.FpInvertBatch(ne,w),add:Y,sub:z,mul:k,sqr:oe,addN:Y,subN:z,mulN:k,sqrN:oe,fromBytes:w=>{if(w.length!==ne.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:E.fromBytes(w.subarray(0,E.BYTES)),c1:E.fromBytes(w.subarray(E.BYTES))}},toBytes:({c0:w,c1:g})=>(0,gr.concatBytes)(E.toBytes(w),E.toBytes(g)),cmov:({c0:w,c1:g},{c0:R,c1:A},B)=>({c0:E.cmov(w,R,B),c1:E.cmov(g,A,B)}),fromBigTwelve:w=>({c0:E.fromBigSix(w.slice(0,6)),c1:E.fromBigSix(w.slice(6,12))}),frobeniusMap(w,g){let{c0:R,c1:A,c2:B}=E.frobeniusMap(w.c1,g),K=j[g%12];return{c0:E.frobeniusMap(w.c0,g),c1:E.create({c0:l.mul(R,K),c1:l.mul(A,K),c2:l.mul(B,K)})}},mulByFp2:({c0:w,c1:g},R)=>({c0:E.mulByFp2(w,R),c1:E.mulByFp2(g,R)}),conjugate:({c0:w,c1:g})=>({c0:w,c1:E.neg(g)}),mul014:({c0:w,c1:g},R,A,B)=>{let K=E.mul01(w,R,A),X=E.mul1(g,B);return{c0:E.add(E.mulByNonresidue(X),K),c1:E.sub(E.sub(E.mul01(E.add(g,w),R,l.add(A,B)),K),X)}},mul034:({c0:w,c1:g},R,A,B)=>{let K=E.create({c0:l.mul(w.c0,R),c1:l.mul(w.c1,R),c2:l.mul(w.c2,R)}),X=E.mul01(g,A,B),ae=E.mul01(E.add(w,g),l.add(R,A),B);return{c0:E.add(E.mulByNonresidue(X),K),c1:E.sub(ae,E.add(K,X))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:r,Fp2:l,Fp6:E,Fp4Square:L,Fp12:ne}}});var Uh=ee(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.bls12_381=void 0;var Sh=po(),Uw=Hn(),Fw=Eh(),Cw=kr(),Ae=It(),Rh=oa(),Bh=hl(),Ph=Th(),jt=BigInt(0),ha=BigInt(1),_t=BigInt(2),da=BigInt(3),bs=BigInt(4),Tn=BigInt("0xd201000000010000"),Mw=(0,Ae.bitLen)(Tn),{Fp:he,Fp2:pe,Fp6:bl,Fp4Square:ml,Fp12:Te}=(0,Ph.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[ha,ha],Fp2mulByB:({c0:e,c1:t})=>{let r=he.mul(e,bs),n=he.mul(t,bs);return{c0:he.sub(r,n),c1:he.add(r,n)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{let{c0:r,c1:n,c2:i}=e,{c0:s,c1:o,c2:a}=t,{first:c,second:d}=ml(r,o),{first:f,second:h}=ml(s,i),{first:m,second:b}=ml(n,a),l=pe.mulByNonresidue(b);return{c0:bl.create({c0:pe.add(pe.mul(pe.sub(c,r),_t),c),c1:pe.add(pe.mul(pe.sub(f,n),_t),f),c2:pe.add(pe.mul(pe.sub(m,i),_t),m)}),c1:bl.create({c0:pe.add(pe.mul(pe.add(l,s),_t),l),c1:pe.add(pe.mul(pe.add(d,o),_t),d),c2:pe.add(pe.mul(pe.add(h,a),_t),h)})}},Fp12cyclotomicExp(e,t){let r=Te.ONE;for(let n=Mw-1;n>=0;n--)r=Te._cyclotomicSquare(r),(0,Ae.bitGet)(t,n)&&(r=Te.mul(r,e));return r},Fp12finalExponentiate:e=>{let t=Tn,r=Te.div(Te.frobeniusMap(e,6),e),n=Te.mul(Te.frobeniusMap(r,2),r),i=Te.conjugate(Te._cyclotomicExp(n,t)),s=Te.mul(Te.conjugate(Te._cyclotomicSquare(n)),i),o=Te.conjugate(Te._cyclotomicExp(s,t)),a=Te.conjugate(Te._cyclotomicExp(o,t)),c=Te.mul(Te.conjugate(Te._cyclotomicExp(a,t)),Te._cyclotomicSquare(i)),d=Te.conjugate(Te._cyclotomicExp(c,t)),f=Te.frobeniusMap(Te.mul(i,a),2),h=Te.frobeniusMap(Te.mul(o,n),3),m=Te.frobeniusMap(Te.mul(c,Te.conjugate(n)),1),b=Te.mul(Te.mul(d,Te.conjugate(s)),n);return Te.mul(Te.mul(Te.mul(f,h),m),b)}}),Oh=Cw.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),qw=(0,Rh.isogenyMap)(pe,[[["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=>pe.fromBigTuple(t.map(BigInt))))),jw=(0,Rh.isogenyMap)(he,[["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)))),kw=(0,Bh.mapToCurveSimpleSWU)(pe,{A:pe.create({c0:he.create(jt),c1:he.create(BigInt(240))}),B:pe.create({c0:he.create(BigInt(1012)),c1:he.create(BigInt(1012))}),Z:pe.create({c0:he.create(BigInt(-2)),c1:he.create(BigInt(-1))})}),Vw=(0,Bh.mapToCurveSimpleSWU)(he,{A:he.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:he.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:he.create(BigInt(11))}),{G2psi:vh,G2psi2:Hw}=(0,Ph.psiFrobenius)(he,pe,pe.div(pe.ONE,pe.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:he.ORDER,m:2,k:128,expand:"xmd",hash:Sh.sha256}),pa=ws(he.toBytes(jt),{infinity:!0,compressed:!0});function fa(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 ws(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 Nh(e){e.assertValidity();let t=e.equals(kt.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=e.toAffine();if(t)return pa.slice();let i=he.ORDER,s=!!(n*_t/i);return ws((0,Ae.numberToBytesBE)(r,he.BYTES),{compressed:!0,sort:s})}function Ah(e){e.assertValidity();let t=he.BYTES;if(e.equals(kt.bls12_381.G2.ProjectivePoint.ZERO))return(0,Ae.concatBytes)(pa,(0,Ae.numberToBytesBE)(jt,t));let{x:r,y:n}=e.toAffine(),{re:i,im:s}=pe.reim(r),{re:o,im:a}=pe.reim(n),d=!!((a>jt?a*_t:o*_t)/he.ORDER&ha),f=i;return(0,Ae.concatBytes)(ws((0,Ae.numberToBytesBE)(s,t),{sort:d,compressed:!0}),(0,Ae.numberToBytesBE)(f,t))}kt.bls12_381=(0,Fw.bls)({fields:{Fp:he,Fp2:pe,Fp6:bl,Fp12:Te,Fr:Oh},G1:{Fp:he,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:he.ZERO,b:bs,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(he.mul(t.px,r),t.py,t.pz);return t.multiplyUnsafe(Tn).negate().multiplyUnsafe(Tn).equals(n)},clearCofactor:(e,t)=>t.multiplyUnsafe(Tn).add(t),mapToCurve:e=>{let{x:t,y:r}=Vw(he.create(e[0]));return jw(t,r)},fromBytes:e=>{let{compressed:t,infinity:r,sort:n,value:i}=fa(e);if(i.length===48&&t){let s=he.ORDER,o=(0,Ae.bytesToNumberBE)(i),a=he.create(o&he.MASK);if(r){if(a!==jt)throw new Error("G1: non-empty compressed point at infinity");return{x:jt,y:jt}}let c=he.add(he.pow(a,da),he.create(kt.bls12_381.params.G1b)),d=he.sqrt(c);if(!d)throw new Error("Invalid compressed G1 point");return d*_t/s!==BigInt(n)&&(d=he.neg(d)),{x:he.create(a),y:he.create(d)}}else if(i.length===96&&!t){let s=(0,Ae.bytesToNumberBE)(i.subarray(0,he.BYTES)),o=(0,Ae.bytesToNumberBE)(i.subarray(he.BYTES));if(r){if(s!==jt||o!==jt)throw new Error("G1: non-empty point at infinity");return kt.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:he.create(s),y:he.create(o)}}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 pa.slice();let o=he.ORDER,a=!!(s*_t/o);return ws((0,Ae.numberToBytesBE)(i,he.BYTES),{compressed:!0,sort:a})}else return n?(0,Ae.concatBytes)(new Uint8Array([64]),new Uint8Array(2*he.BYTES-1)):(0,Ae.concatBytes)((0,Ae.numberToBytesBE)(i,he.BYTES),(0,Ae.numberToBytesBE)(s,he.BYTES))},ShortSignature:{fromHex(e){let{infinity:t,sort:r,value:n}=fa((0,Ae.ensureBytes)("signatureHex",e,48)),i=he.ORDER,s=(0,Ae.bytesToNumberBE)(n);if(t)return kt.bls12_381.G1.ProjectivePoint.ZERO;let o=he.create(s&he.MASK),a=he.add(he.pow(o,da),he.create(kt.bls12_381.params.G1b)),c=he.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let d=BigInt(r);c*_t/i!==d&&(c=he.neg(c));let f=kt.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return f.assertValidity(),f},toRawBytes(e){return Nh(e)},toHex(e){return(0,Ae.bytesToHex)(Nh(e))}}},G2:{Fp:pe,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:pe.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:pe.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:pe.ZERO,b:pe.fromBigTuple([bs,bs]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...gl},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{let{x:t,y:r}=kw(pe.fromBigTuple(e));return qw(t,r)},isTorsionFree:(e,t)=>t.multiplyUnsafe(Tn).negate().equals(vh(e,t)),clearCofactor:(e,t)=>{let r=Tn,n=t.multiplyUnsafe(r).negate(),i=vh(e,t),s=t.double();return s=Hw(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}=fa(e);if(!t&&!r&&n||!t&&r&&n||n&&r&&t)throw new Error("Invalid encoding flag: "+(e[0]&224));let s=he.BYTES,o=(a,c,d)=>(0,Ae.bytesToNumberBE)(a.slice(c,d));if(i.length===96&&t){let a=kt.bls12_381.params.G2b,c=he.ORDER;if(r){if(i.reduce((S,N)=>S!==0?N+1:N,0)>0)throw new Error("Invalid compressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let d=o(i,0,s),f=o(i,s,2*s),h=pe.create({c0:he.create(f),c1:he.create(d)}),m=pe.add(pe.pow(h,da),a),b=pe.sqrt(m),l=b.c1===jt?b.c0*_t/c:b.c1*_t/c?ha:jt;return b=n&&l>0?b:pe.neg(b),{x:h,y:b}}else if(i.length===192&&!t){if(r){if(i.reduce((h,m)=>h!==0?m+1:m,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),d=o(i,2*s,3*s),f=o(i,3*s,4*s);return{x:pe.fromBigTuple([c,a]),y:pe.fromBigTuple([f,d])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(e,t,r)=>{let{BYTES:n,ORDER:i}=he,s=t.equals(e.ZERO),{x:o,y:a}=t.toAffine();if(r){if(s)return(0,Ae.concatBytes)(pa,(0,Ae.numberToBytesBE)(jt,n));let c=!!(a.c1===jt?a.c0*_t/i:a.c1*_t/i);return(0,Ae.concatBytes)(ws((0,Ae.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,Ae.numberToBytesBE)(o.c0,n))}else{if(s)return(0,Ae.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:d}=pe.reim(o),{re:f,im:h}=pe.reim(a);return(0,Ae.concatBytes)((0,Ae.numberToBytesBE)(d,n),(0,Ae.numberToBytesBE)(c,n),(0,Ae.numberToBytesBE)(h,n),(0,Ae.numberToBytesBE)(f,n))}},Signature:{fromHex(e){let{infinity:t,sort:r,value:n}=fa((0,Ae.ensureBytes)("signatureHex",e)),i=he.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=(0,Ae.bytesToNumberBE)(n.slice(0,s)),a=(0,Ae.bytesToNumberBE)(n.slice(s));if(t)return kt.bls12_381.G2.ProjectivePoint.ZERO;let c=he.create(o&he.MASK),d=he.create(a),f=pe.create({c0:d,c1:c}),h=pe.add(pe.pow(f,da),kt.bls12_381.params.G2b),m=pe.sqrt(h);if(!m)throw new Error("Failed to find a square root");let{re:b,im:l}=pe.reim(m),S=BigInt(r),N=l>jt&&l*_t/i!==S,F=l===jt&&b*_t/i!==S;(N||F)&&(m=pe.neg(m));let q=kt.bls12_381.G2.ProjectivePoint.fromAffine({x:f,y:m});return q.assertValidity(),q},toRawBytes(e){return Ah(e)},toHex(e){return(0,Ae.bytesToHex)(Ah(e))}}},params:{ateLoopSize:Tn,r:Oh.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:gl,hash:Sh.sha256,randomBytes:Uw.randomBytes})});var El=ee(Es=>{"use strict";Object.defineProperty(Es,"__esModule",{value:!0});Es.blsVerify=Es.verify=void 0;var Kw=Uh(),wl=Yt();function $w(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 Kw.bls12_381.verifyShortSignature(i,s,n)}Es.blsVerify=$w});var _a=ee(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.decodeTime=Wn.decodeLeb128=void 0;var Fh=xi(),Gw=e=>(0,Fh.lebDecode)(new Fh.PipeArrayBuffer(e));Wn.decodeLeb128=Gw;var Yw=e=>{let t=(0,Wn.decodeLeb128)(e);return new Date(Number(t)/1e6)};Wn.decodeTime=Yw});var Si=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}),Ch=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},Jw=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},Zw=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)},ma;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 Mh=Ch(_s()),Xw=_i(),ya=fs(),br=Yt(),xl=Mt(),Qw=Ch(El()),Iw=_a(),Dw=Ns(),nn=class extends Xw.AgentError{constructor(t){super(`Invalid certificate: ${t}`)}};Oe.CertificateVerificationError=nn;var Et;(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"})(Et=Oe.NodeType||(Oe.NodeType={}));function ga(e){let t=n=>n.split(`
18
18
  `).map(i=>" "+i).join(`
19
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 Et.Empty:return"()";case Et.Fork:if(e[1]instanceof Array&&e[2]instanceof ArrayBuffer){let n=ga(e[1]),i=ga(e[2]);return`sub(
20
20
  left:
@@ -27,34 +27,34 @@ ${t(i)}
27
27
  ${t(n)}
28
28
  sub:
29
29
  ${t(i)}
30
- )`}else throw new Error("Invalid tree structure for labeled");case Et.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 Et.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,yr.toHex)(new Uint8Array(e[1]))}`}default:return`unknown(${JSON.stringify(e[0])})`}}ve.hashTreeToString=ga;function Lw(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 Tl=class e{constructor(t,r,n,i,s=5,o=!1){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,ma.set(this,!1),Jw(this,ma,o,"f"),this.cert=Mh.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=Qw.blsVerify),new e(t.certificate,t.rootKey,t.canisterId,r,t.maxAgeInMinutes,t.disableTimeVerification)}lookup(t){return ba(t,this.cert.tree)}lookup_label(t){return this.lookup([t])}async verify(){let t=await vs(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=t2(r),s=(0,yr.concat)(Ts("ic-state-root"),t),o=!1,a=vl(this.lookup(["time"]));if(!a)throw new nn("Certificate does not contain a time");if(!Zw(this,ma,"f")){let d=this._maxAgeInMinutes*60*1e3,f=Date.now(),h=f-d,m=f+3e5,b=(0,Iw.decodeTime)(a);if(b.getTime()<h)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{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)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()!==Dw.MANAGEMENT_CANISTER_ID&&!qh({canisterId:this._canisterId,subnetId:xl.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,yr.toHex)(t.subnet_id)}`);let n=vl(r.lookup(["subnet",t.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,yr.toHex)(t.subnet_id)}`);return n}};ve.Certificate=Tl;ma=new WeakMap;var xs=(0,yr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),e2=96;function t2(e){let t=xs.byteLength+e2;if(e.byteLength!==t)throw new TypeError(`BLS DER-encoded public key must be ${t} bytes long`);let r=e.slice(0,xs.byteLength);if(!(0,yr.bufEquals)(r,xs))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${xs}, but get ${r}`);return e.slice(xs.byteLength)}function vl(e){if(e.status===jt.Found){if(e.value instanceof ArrayBuffer)return e.value;if(e.value instanceof Uint8Array)return e.value.buffer}}ve.lookupResultToBuffer=vl;async function vs(e){switch(e[0]){case Et.Empty:return(0,ya.hash)(Ts("ic-hashtree-empty"));case Et.Pruned:return e[1];case Et.Leaf:return(0,ya.hash)((0,yr.concat)(Ts("ic-hashtree-leaf"),e[1]));case Et.Labeled:return(0,ya.hash)((0,yr.concat)(Ts("ic-hashtree-labeled"),e[1],await vs(e[2])));case Et.Fork:return(0,ya.hash)((0,yr.concat)(Ts("ic-hashtree-fork"),await vs(e[1]),await vs(e[2])));default:throw new Error("unreachable")}}ve.reconstruct=vs;function Ts(e){let t=new Uint8Array([e.length]),r=new TextEncoder().encode(e);return(0,yr.concat)(t,r)}var jt;(function(e){e.Unknown="unknown",e.Absent="absent",e.Found="found"})(jt=ve.LookupStatus||(ve.LookupStatus={}));var sn;(function(e){e.Less="less",e.Greater="greater"})(sn||(sn={}));function ba(e,t){if(e.length===0)switch(t[0]){case Et.Leaf:{if(!t[1])throw new Error("Invalid tree structure for leaf");return t[1]instanceof ArrayBuffer?{status:jt.Found,value:t[1]}:t[1]instanceof Uint8Array?{status:jt.Found,value:t[1].buffer}:{status:jt.Found,value:t[1]}}default:return{status:jt.Found,value:t}}let r=typeof e[0]=="string"?new TextEncoder().encode(e[0]):e[0],n=Os(r,t);switch(n.status){case jt.Found:return ba(e.slice(1),n.value);case sn.Greater:case sn.Less:return{status:jt.Absent};default:return n}}ve.lookup_path=ba;function Ol(e){switch(e[0]){case Et.Empty:return[];case Et.Fork:return Ol(e[1]).concat(Ol(e[2]));default:return[e]}}ve.flatten_forks=Ol;function Os(e,t){switch(t[0]){case Et.Labeled:return Lw(e,t[1])?{status:sn.Greater}:(0,yr.bufEquals)(e,t[1])?{status:jt.Found,value:t[2]}:{status:sn.Less};case Et.Fork:let r=Os(e,t[1]);switch(r.status){case sn.Greater:{let n=Os(e,t[2]);return n.status===sn.Less?{status:jt.Absent}:n}case jt.Unknown:{let n=Os(e,t[2]);return n.status===sn.Less?{status:jt.Unknown}:n}default:return r}case Et.Pruned:return{status:jt.Unknown};default:return{status:jt.Absent}}}ve.find_label=Os;function qh(e){let{canisterId:t,subnetId:r,tree:n}=e,i=ba(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==jt.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return Mh.decode(i.value).map(c=>[xl.Principal.fromUint8Array(c[0]),xl.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(t)&&c[1].gtEq(t))}ve.check_canister_ranges=qh});var Ns=ee(lt=>{"use strict";var r2=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]}),n2=lt&&lt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i2=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)&&r2(t,e,r);return n2(t,e),t};Object.defineProperty(lt,"__esModule",{value:!0});lt.encodePath=lt.fetchNodeKeys=lt.request=lt.CustomPath=void 0;var vn=Ft(),s2=_i(),On=Si(),o2=Kt(),Vh=i2(_s()),jh=_a(),Al=class{constructor(t,r,n){this.key=t,this.path=r,this.decodeStrategy=n}};lt.CustomPath=Al;var a2=async e=>{let{agent:t,paths:r}=e,n=vn.Principal.from(e.canisterId),i=[...new Set(r)],s=i.map(c=>(0,lt.encodePath)(c,n)),o=new Map,a=i.map((c,d)=>(async()=>{var f;try{let h=await t.readState(n,{paths:[s[d]]});if(t.rootKey==null)throw new Error("Agent is missing root key");let m=await On.Certificate.create({certificate:h.certificate,rootKey:t.rootKey,canisterId:n,disableTimeVerification:!0}),b=(A,F)=>{if(F==="subnet"){if(t.rootKey==null)throw new Error("Agent is missing root key");let q=(0,lt.fetchNodeKeys)(h.certificate,n,t.rootKey);return{path:F,data:q}}else return{path:F,data:(0,On.lookupResultToBuffer)(A.lookup((0,lt.encodePath)(F,n)))}},{path:l,data:S}=b(m,i[d]);if(!S)console.warn(`Expected to find result for path ${l}, but instead found nothing.`),typeof l=="string"?o.set(l,null):o.set(l.key,null);else switch(l){case"time":{o.set(l,(0,jh.decodeTime)(S));break}case"controllers":{o.set(l,d2(S));break}case"module_hash":{o.set(l,kh(S));break}case"subnet":{o.set(l,S);break}case"candid":{o.set(l,new TextDecoder().decode(S));break}default:if(typeof l!="string"&&"key"in l&&"path"in l)switch(l.decodeStrategy){case"raw":o.set(l.key,S);break;case"leb128":{o.set(l.key,(0,jh.decodeLeb128)(S));break}case"cbor":{o.set(l.key,Hh(S));break}case"hex":{o.set(l.key,kh(S));break}case"utf-8":o.set(l.key,l2(S))}}}catch(h){if(!((f=h?.message)===null||f===void 0)&&f.includes("Invalid certificate"))throw new s2.AgentError(h.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(h),console.groupEnd()}})());return await Promise.all(a),o};lt.request=a2;var c2=(e,t,r)=>{if(!t._isPrincipal)throw new Error("Invalid canisterId");let n=Vh.decode(new Uint8Array(e)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=vn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=vn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=vn.Principal.selfAuthenticating(vn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,On.check_canister_ranges)({canisterId:t,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,On.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==On.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let d=(0,On.flatten_forks)(c.value),f=new Map;return d.forEach(h=>{let m=vn.Principal.from(new Uint8Array(h[1])).toText(),b=(0,On.lookup_path)(["public_key"],h[2]);if(b.status!==On.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:vn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:f}};lt.fetchNodeKeys=c2;var u2=(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,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}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=u2;var kh=e=>(0,o2.toHex)(e),Hh=e=>Vh.decode(e),l2=e=>new TextDecoder().decode(e),d2=e=>Hh(e).map(r=>vn.Principal.fromUint8Array(new Uint8Array(r)))});var cp=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=Kh;ye.add=tp;var wa=BigInt(2**32-1),Nl=BigInt(32);function Sl(e,t=!1){return t?{h:Number(e&wa),l:Number(e>>Nl&wa)}:{h:Number(e>>Nl&wa)|0,l:Number(e&wa)|0}}function Kh(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:o}=Sl(e[i],t);[r[i],n[i]]=[s,o]}return[r,n]}var $h=(e,t)=>BigInt(e>>>0)<<Nl|BigInt(t>>>0);ye.toBig=$h;var Gh=(e,t,r)=>e>>>r;ye.shrSH=Gh;var Yh=(e,t,r)=>e<<32-r|t>>>r;ye.shrSL=Yh;var Wh=(e,t,r)=>e>>>r|t<<32-r;ye.rotrSH=Wh;var zh=(e,t,r)=>e<<32-r|t>>>r;ye.rotrSL=zh;var Jh=(e,t,r)=>e<<64-r|t>>>r-32;ye.rotrBH=Jh;var Zh=(e,t,r)=>e>>>r-32|t<<64-r;ye.rotrBL=Zh;var Xh=(e,t)=>t;ye.rotr32H=Xh;var Qh=(e,t)=>e;ye.rotr32L=Qh;var Ih=(e,t,r)=>e<<r|t>>>32-r;ye.rotlSH=Ih;var Dh=(e,t,r)=>t<<r|e>>>32-r;ye.rotlSL=Dh;var Lh=(e,t,r)=>t<<r-32|e>>>64-r;ye.rotlBH=Lh;var ep=(e,t,r)=>e<<r-32|t>>>64-r;ye.rotlBL=ep;function tp(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var rp=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);ye.add3L=rp;var np=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;ye.add3H=np;var ip=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);ye.add4L=ip;var sp=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0;ye.add4H=sp;var op=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0);ye.add5L=op;var ap=(e,t,r,n,i,s)=>t+r+n+i+s+(e/2**32|0)|0;ye.add5H=ap;var f2={fromBig:Sl,split:Kh,toBig:$h,shrSH:Gh,shrSL:Yh,rotrSH:Wh,rotrSL:zh,rotrBH:Jh,rotrBL:Zh,rotr32H:Xh,rotr32L:Qh,rotlSH:Ih,rotlSL:Dh,rotlBH:Lh,rotlBL:ep,add:tp,add3L:rp,add3H:np,add4L:ip,add4H:sp,add5H:ap,add5L:op};ye.default=f2});var up=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 h2=Zc(),be=cp(),va=Hn(),[p2,_2]=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))),An=new Uint32Array(80),Nn=new Uint32Array(80),Jn=class extends h2.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:o,Dh:a,Dl:c,Eh:d,El:f,Fh:h,Fl:m,Gh:b,Gl:l,Hh:S,Hl:A}=this;return[t,r,n,i,s,o,a,c,d,f,h,m,b,l,S,A]}set(t,r,n,i,s,o,a,c,d,f,h,m,b,l,S,A){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=d|0,this.El=f|0,this.Fh=h|0,this.Fl=m|0,this.Gh=b|0,this.Gl=l|0,this.Hh=S|0,this.Hl=A|0}process(t,r){for(let v=0;v<16;v++,r+=4)An[v]=t.getUint32(r),Nn[v]=t.getUint32(r+=4);for(let v=16;v<80;v++){let G=An[v-15]|0,E=Nn[v-15]|0,j=be.default.rotrSH(G,E,1)^be.default.rotrSH(G,E,8)^be.default.shrSH(G,E,7),Y=be.default.rotrSL(G,E,1)^be.default.rotrSL(G,E,8)^be.default.shrSL(G,E,7),Z=An[v-2]|0,k=Nn[v-2]|0,ae=be.default.rotrSH(Z,k,19)^be.default.rotrBH(Z,k,61)^be.default.shrSH(Z,k,6),D=be.default.rotrSL(Z,k,19)^be.default.rotrBL(Z,k,61)^be.default.shrSL(Z,k,6),se=be.default.add4L(Y,D,Nn[v-7],Nn[v-16]),w=be.default.add4H(se,j,ae,An[v-7],An[v-16]);An[v]=w|0,Nn[v]=se|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:d,Dl:f,Eh:h,El:m,Fh:b,Fl:l,Gh:S,Gl:A,Hh:F,Hl:q}=this;for(let v=0;v<80;v++){let G=be.default.rotrSH(h,m,14)^be.default.rotrSH(h,m,18)^be.default.rotrBH(h,m,41),E=be.default.rotrSL(h,m,14)^be.default.rotrSL(h,m,18)^be.default.rotrBL(h,m,41),j=h&b^~h&S,Y=m&l^~m&A,Z=be.default.add5L(q,E,Y,_2[v],Nn[v]),k=be.default.add5H(Z,F,G,j,p2[v],An[v]),ae=Z|0,D=be.default.rotrSH(n,i,28)^be.default.rotrBH(n,i,34)^be.default.rotrBH(n,i,39),se=be.default.rotrSL(n,i,28)^be.default.rotrBL(n,i,34)^be.default.rotrBL(n,i,39),w=n&s^n&a^s&a,g=i&o^i&c^o&c;F=S|0,q=A|0,S=b|0,A=l|0,b=h|0,l=m|0,{h,l:m}=be.default.add(d|0,f|0,k|0,ae|0),d=a|0,f=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let R=be.default.add3L(ae,se,g);n=be.default.add3H(R,k,D,w),i=R|0}({h:n,l:i}=be.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=be.default.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=be.default.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:d,l:f}=be.default.add(this.Dh|0,this.Dl|0,d|0,f|0),{h,l:m}=be.default.add(this.Eh|0,this.El|0,h|0,m|0),{h:b,l}=be.default.add(this.Fh|0,this.Fl|0,b|0,l|0),{h:S,l:A}=be.default.add(this.Gh|0,this.Gl|0,S|0,A|0),{h:F,l:q}=be.default.add(this.Hh|0,this.Hl|0,F|0,q|0),this.set(n,i,s,o,a,c,d,f,h,m,b,l,S,A,F,q)}roundClean(){An.fill(0),Nn.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=Jn;var Ea=class extends Jn{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=Ea;var xa=class extends Jn{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=xa;var Ta=class extends Jn{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=Ta;yt.sha512=(0,va.wrapConstructor)(()=>new Jn);yt.sha512_224=(0,va.wrapConstructor)(()=>new Ea);yt.sha512_256=(0,va.wrapConstructor)(()=>new xa);yt.sha384=(0,va.wrapConstructor)(()=>new Ta)});var dp=ee(Bl=>{"use strict";Object.defineProperty(Bl,"__esModule",{value:!0});Bl.twistedEdwards=b2;var Rl=fl(),lp=qr(),Wt=Zt(),It=Zt(),mr=BigInt(0),Yt=BigInt(1),Oa=BigInt(2),y2=BigInt(8),m2={zip215:!0};function g2(e){let t=(0,Rl.validateBasic)(e);return Wt.validateObject(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function b2(e){let t=g2(e),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=t,d=Oa<<BigInt(a*8)-Yt,f=r.create,h=(0,lp.Field)(t.n,t.nBitLength),m=t.uvRatio||((N,B)=>{try{return{isValid:!0,value:r.sqrt(N*r.inv(B))}}catch{return{isValid:!1,value:mr}}}),b=t.adjustScalarBytes||(N=>N),l=t.domain||((N,B,H)=>{if((0,It.abool)("phflag",H),B.length||H)throw new Error("Contexts/pre-hash are not supported");return N});function S(N,B){Wt.aInRange("coordinate "+N,B,mr,d)}function A(N){if(!(N instanceof v))throw new Error("ExtendedPoint expected")}let F=(0,It.memoized)((N,B)=>{let{ex:H,ey:X,ez:ie}=N,oe=N.is0();B==null&&(B=oe?y2:r.inv(ie));let W=f(H*B),M=f(X*B),p=f(ie*B);if(oe)return{x:mr,y:Yt};if(p!==Yt)throw new Error("invZ was invalid");return{x:W,y:M}}),q=(0,It.memoized)(N=>{let{a:B,d:H}=t;if(N.is0())throw new Error("bad point: ZERO");let{ex:X,ey:ie,ez:oe,et:W}=N,M=f(X*X),p=f(ie*ie),L=f(oe*oe),re=f(L*L),le=f(M*B),I=f(L*f(le+p)),u=f(re+f(H*f(M*p)));if(I!==u)throw new Error("bad point: equation left != right (1)");let _=f(X*ie),y=f(oe*W);if(_!==y)throw new Error("bad point: equation left != right (2)");return!0});class v{constructor(B,H,X,ie){this.ex=B,this.ey=H,this.ez=X,this.et=ie,S("x",B),S("y",H),S("z",X),S("t",ie),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(B){if(B instanceof v)throw new Error("extended point not allowed");let{x:H,y:X}=B||{};return S("x",H),S("y",X),new v(H,X,Yt,f(H*X))}static normalizeZ(B){let H=r.invertBatch(B.map(X=>X.ez));return B.map((X,ie)=>X.toAffine(H[ie])).map(v.fromAffine)}static msm(B,H){return(0,Rl.pippenger)(v,h,B,H)}_setWindowSize(B){j.setWindowSize(this,B)}assertValidity(){q(this)}equals(B){A(B);let{ex:H,ey:X,ez:ie}=this,{ex:oe,ey:W,ez:M}=B,p=f(H*M),L=f(oe*ie),re=f(X*M),le=f(W*ie);return p===L&&re===le}is0(){return this.equals(v.ZERO)}negate(){return new v(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:B}=t,{ex:H,ey:X,ez:ie}=this,oe=f(H*H),W=f(X*X),M=f(Oa*f(ie*ie)),p=f(B*oe),L=H+X,re=f(f(L*L)-oe-W),le=p+W,I=le-M,u=p-W,_=f(re*I),y=f(le*u),U=f(re*u),O=f(I*le);return new v(_,y,O,U)}add(B){A(B);let{a:H,d:X}=t,{ex:ie,ey:oe,ez:W,et:M}=this,{ex:p,ey:L,ez:re,et:le}=B;if(H===BigInt(-1)){let Q=f((oe-ie)*(L+p)),te=f((oe+ie)*(L-p)),de=f(te-Q);if(de===mr)return this.double();let ge=f(W*Oa*le),Oe=f(M*Oa*re),Fe=Oe+ge,_e=te+Q,fe=Oe-ge,Qe=f(Fe*de),vr=f(_e*fe),Xr=f(Fe*fe),Qr=f(de*_e);return new v(Qe,vr,Qr,Xr)}let I=f(ie*p),u=f(oe*L),_=f(M*X*le),y=f(W*re),U=f((ie+oe)*(p+L)-I-u),O=y-_,P=y+_,K=f(u-H*I),x=f(U*O),C=f(P*K),$=f(U*K),V=f(O*P);return new v(x,C,V,$)}subtract(B){return this.add(B.negate())}wNAF(B){return j.wNAFCached(this,B,v.normalizeZ)}multiply(B){let H=B;Wt.aInRange("scalar",H,Yt,n);let{p:X,f:ie}=this.wNAF(H);return v.normalizeZ([X,ie])[0]}multiplyUnsafe(B){let H=B;return Wt.aInRange("scalar",H,mr,n),H===mr?E:this.equals(E)||H===Yt?this:this.equals(G)?this.wNAF(H).p:j.unsafeLadder(this,H)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return j.unsafeLadder(this,n).is0()}toAffine(B){return F(this,B)}clearCofactor(){let{h:B}=t;return B===Yt?this:this.multiplyUnsafe(B)}static fromHex(B,H=!1){let{d:X,a:ie}=t,oe=r.BYTES;B=(0,It.ensureBytes)("pointHex",B,oe),(0,It.abool)("zip215",H);let W=B.slice(),M=B[oe-1];W[oe-1]=M&-129;let p=Wt.bytesToNumberLE(W),L=H?d:r.ORDER;Wt.aInRange("pointHex.y",p,mr,L);let re=f(p*p),le=f(re-Yt),I=f(X*re-ie),{isValid:u,value:_}=m(le,I);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let y=(_&Yt)===Yt,U=(M&128)!==0;if(!H&&_===mr&&U)throw new Error("Point.fromHex: x=0 and x_0=1");return U!==y&&(_=f(-_)),v.fromAffine({x:_,y:p})}static fromPrivateKey(B){return k(B).point}toRawBytes(){let{x:B,y:H}=this.toAffine(),X=Wt.numberToBytesLE(H,r.BYTES);return X[X.length-1]|=B&Yt?128:0,X}toHex(){return Wt.bytesToHex(this.toRawBytes())}}v.BASE=new v(t.Gx,t.Gy,Yt,f(t.Gx*t.Gy)),v.ZERO=new v(mr,Yt,Yt,mr);let{BASE:G,ZERO:E}=v,j=(0,Rl.wNAF)(v,a*8);function Y(N){return(0,lp.mod)(N,n)}function Z(N){return Y(Wt.bytesToNumberLE(N))}function k(N){let B=a;N=(0,It.ensureBytes)("private key",N,B);let H=(0,It.ensureBytes)("hashed private key",s(N),2*B),X=b(H.slice(0,B)),ie=H.slice(B,2*B),oe=Z(X),W=G.multiply(oe),M=W.toRawBytes();return{head:X,prefix:ie,scalar:oe,point:W,pointBytes:M}}function ae(N){return k(N).pointBytes}function D(N=new Uint8Array,...B){let H=Wt.concatBytes(...B);return Z(s(l(H,(0,It.ensureBytes)("context",N),!!i)))}function se(N,B,H={}){N=(0,It.ensureBytes)("message",N),i&&(N=i(N));let{prefix:X,scalar:ie,pointBytes:oe}=k(B),W=D(H.context,X,N),M=G.multiply(W).toRawBytes(),p=D(H.context,M,oe,N),L=Y(W+p*ie);Wt.aInRange("signature.s",L,mr,n);let re=Wt.concatBytes(M,Wt.numberToBytesLE(L,r.BYTES));return(0,It.ensureBytes)("result",re,a*2)}let w=m2;function g(N,B,H,X=w){let{context:ie,zip215:oe}=X,W=r.BYTES;N=(0,It.ensureBytes)("signature",N,2*W),B=(0,It.ensureBytes)("message",B),oe!==void 0&&(0,It.abool)("zip215",oe),i&&(B=i(B));let M=Wt.bytesToNumberLE(N.slice(W,2*W)),p,L,re;try{p=v.fromHex(H,oe),L=v.fromHex(N.slice(0,W),oe),re=G.multiplyUnsafe(M)}catch{return!1}if(!oe&&p.isSmallOrder())return!1;let le=D(ie,L.toRawBytes(),p.toRawBytes(),B);return L.add(p.multiplyUnsafe(le)).subtract(re).clearCofactor().equals(v.ZERO)}return G._setWindowSize(8),{CURVE:t,getPublicKey:ae,sign:se,verify:g,ExtendedPoint:v,utils:{getExtendedPublicKey:k,randomPrivateKey:()=>o(r.BYTES),precompute(N=8,B=v.BASE){return B._setWindowSize(N),B.multiply(BigInt(3)),B}}}}});var hp=ee(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});Ul.montgomery=E2;var fp=qr(),Sn=Zt(),Ri=BigInt(0),Pl=BigInt(1);function w2(e){return(0,Sn.validateObject)(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}function E2(e){let t=w2(e),{P:r}=t,n=q=>(0,fp.mod)(q,r),i=t.montgomeryBits,s=Math.ceil(i/8),o=t.nByteLength,a=t.adjustScalarBytes||(q=>q),c=t.powPminus2||(q=>(0,fp.pow)(q,r-BigInt(2),r));function d(q,v,G){let E=n(q*(v-G));return v=n(v-E),G=n(G+E),[v,G]}let f=(t.a-BigInt(2))/BigInt(4);function h(q,v){(0,Sn.aInRange)("u",q,Ri,r),(0,Sn.aInRange)("scalar",v,Ri,r);let G=v,E=q,j=Pl,Y=Ri,Z=q,k=Pl,ae=Ri,D;for(let w=BigInt(i-1);w>=Ri;w--){let g=G>>w&Pl;ae^=g,D=d(ae,j,Z),j=D[0],Z=D[1],D=d(ae,Y,k),Y=D[0],k=D[1],ae=g;let R=j+Y,N=n(R*R),B=j-Y,H=n(B*B),X=N-H,ie=Z+k,oe=Z-k,W=n(oe*R),M=n(ie*B),p=W+M,L=W-M;Z=n(p*p),k=n(E*n(L*L)),j=n(N*H),Y=n(X*(N+n(f*X)))}D=d(ae,j,Z),j=D[0],Z=D[1],D=d(ae,Y,k),Y=D[0],k=D[1];let se=c(Y);return n(j*se)}function m(q){return(0,Sn.numberToBytesLE)(n(q),s)}function b(q){let v=(0,Sn.ensureBytes)("u coordinate",q,s);return o===32&&(v[31]&=127),(0,Sn.bytesToNumberLE)(v)}function l(q){let v=(0,Sn.ensureBytes)("scalar",q),G=v.length;if(G!==s&&G!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${G}`);return(0,Sn.bytesToNumberLE)(a(v))}function S(q,v){let G=b(v),E=l(q),j=h(G,E);if(j===Ri)throw new Error("Invalid private or public key received");return m(j)}let A=m(t.Gu);function F(q){return S(q,A)}return{scalarMult:S,scalarMultBase:F,getSharedSecret:(q,v)=>S(q,v),getPublicKey:q=>F(q),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:A}}});var Hl=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=Tp;me.edwardsToMontgomeryPriv=v2;var Na=up(),Ss=Hn(),jl=dp(),mp=oa(),Me=qr(),x2=hp(),Zn=Zt(),Rs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ml=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),T2=BigInt(0),jr=BigInt(1),Aa=BigInt(2),gp=BigInt(3),bp=BigInt(5),kl=BigInt(8);function wp(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=Rs,a=e*e%s*e%s,c=(0,Me.pow2)(a,Aa,s)*a%s,d=(0,Me.pow2)(c,jr,s)*e%s,f=(0,Me.pow2)(d,bp,s)*d%s,h=(0,Me.pow2)(f,t,s)*f%s,m=(0,Me.pow2)(h,r,s)*h%s,b=(0,Me.pow2)(m,n,s)*m%s,l=(0,Me.pow2)(b,i,s)*b%s,S=(0,Me.pow2)(l,i,s)*b%s,A=(0,Me.pow2)(S,t,s)*f%s;return{pow_p_5_8:(0,Me.pow2)(A,Aa,s)*e%s,b2:a}}function Ep(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Vl(e,t){let r=Rs,n=(0,Me.mod)(t*t*t,r),i=(0,Me.mod)(n*n*t,r),s=wp(e*i).pow_p_5_8,o=(0,Me.mod)(e*n*s,r),a=(0,Me.mod)(t*o*o,r),c=o,d=(0,Me.mod)(o*Ml,r),f=a===e,h=a===(0,Me.mod)(-e,r),m=a===(0,Me.mod)(-e*Ml,r);return f&&(o=c),(h||m)&&(o=d),(0,Me.isNegativeLE)(o,r)&&(o=(0,Me.mod)(-o,r)),{isValid:f||h,value:o}}me.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var ue=(0,Me.Field)(Rs,void 0,!0),Bs={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ue,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:kl,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Na.sha512,randomBytes:Ss.randomBytes,adjustScalarBytes:Ep,uvRatio:Vl};me.ed25519=(0,jl.twistedEdwards)(Bs);function xp(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,jl.twistedEdwards)({...Bs,domain:xp});me.ed25519ph=(0,jl.twistedEdwards)(Object.assign({},Bs,{domain:xp,prehash:Na.sha512}));me.x25519=(0,x2.montgomery)({P:Rs,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{let t=Rs,{pow_p_5_8:r,b2:n}=wp(e);return(0,Me.mod)((0,Me.pow2)(r,gp,t)*n,t)},adjustScalarBytes:Ep,randomBytes:Ss.randomBytes});function Tp(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=Tp;function v2(e){let t=Bs.hash(e.subarray(0,32));return Bs.adjustScalarBytes(t).subarray(0,32)}var O2=(ue.ORDER+gp)/kl,A2=ue.pow(Aa,O2),pp=ue.sqrt(ue.neg(ue.ONE));function N2(e){let t=(ue.ORDER-bp)/kl,r=BigInt(486662),n=ue.sqr(e);n=ue.mul(n,Aa);let i=ue.add(n,ue.ONE),s=ue.neg(r),o=ue.sqr(i),a=ue.mul(o,i),c=ue.mul(n,r);c=ue.mul(c,s),c=ue.add(c,o),c=ue.mul(c,s);let d=ue.sqr(a);o=ue.sqr(d),d=ue.mul(d,a),d=ue.mul(d,c),o=ue.mul(o,d);let f=ue.pow(o,t);f=ue.mul(f,d);let h=ue.mul(f,pp);o=ue.sqr(f),o=ue.mul(o,a);let m=ue.eql(o,c),b=ue.cmov(h,f,m),l=ue.mul(s,n),S=ue.mul(f,e);S=ue.mul(S,A2);let A=ue.mul(S,pp),F=ue.mul(c,n);o=ue.sqr(S),o=ue.mul(o,a);let q=ue.eql(o,F),v=ue.cmov(A,S,q);o=ue.sqr(b),o=ue.mul(o,a);let G=ue.eql(o,c),E=ue.cmov(l,s,G),j=ue.cmov(v,b,G),Y=ue.isOdd(j);return j=ue.cmov(j,ue.neg(j),G!==Y),{xMn:E,xMd:i,yMn:j,yMd:jr}}var S2=(0,Me.FpSqrtEven)(ue,ue.neg(BigInt(486664)));function R2(e){let{xMn:t,xMd:r,yMn:n,yMd:i}=N2(e),s=ue.mul(t,i);s=ue.mul(s,S2);let o=ue.mul(r,n),a=ue.sub(t,r),c=ue.add(t,r),d=ue.mul(o,c),f=ue.eql(d,ue.ZERO);s=ue.cmov(s,ue.ZERO,f),o=ue.cmov(o,ue.ONE,f),a=ue.cmov(a,ue.ONE,f),c=ue.cmov(c,ue.ONE,f);let h=ue.invertBatch([o,c]);return{x:ue.mul(s,h[0]),y:ue.mul(a,h[1])}}var vp=(0,mp.createHasher)(me.ed25519.ExtendedPoint,e=>R2(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:Na.sha512});me.hashToCurve=vp.hashToCurve;me.encodeToCurve=vp.encodeToCurve;function Fl(e){if(!(e instanceof gr))throw new Error("RistrettoPoint expected")}var ql=Ml,B2=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),P2=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),U2=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),F2=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),_p=e=>Vl(jr,e),C2=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Cl=e=>me.ed25519.CURVE.Fp.create((0,Zn.bytesToNumberLE)(e)&C2);function yp(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+jr)*U2),o=BigInt(-1),a=n((o-t*i)*n(i+t)),{isValid:c,value:d}=Vl(s,a),f=n(d*e);(0,Me.isNegativeLE)(f,r)||(f=n(-f)),c||(d=f),c||(o=i);let h=n(o*(i-jr)*F2-a),m=d*d,b=n((d+d)*a),l=n(h*B2),S=n(jr-m),A=n(jr+m);return new me.ed25519.ExtendedPoint(n(b*A),n(S*l),n(l*A),n(b*S))}var gr=class e{constructor(t){this.ep=t}static fromAffine(t){return new e(me.ed25519.ExtendedPoint.fromAffine(t))}static hashToCurve(t){t=(0,Zn.ensureBytes)("ristrettoHash",t,64);let r=Cl(t.slice(0,32)),n=yp(r),i=Cl(t.slice(32,64)),s=yp(i);return new e(n.add(s))}static fromHex(t){t=(0,Zn.ensureBytes)("ristrettoHex",t,32);let{a:r,d:n}=me.ed25519.CURVE,i=me.ed25519.CURVE.Fp.ORDER,s=me.ed25519.CURVE.Fp.create,o="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=Cl(t);if(!(0,Zn.equalBytes)((0,Zn.numberToBytesLE)(a,32),t)||(0,Me.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),d=s(jr+r*c),f=s(jr-r*c),h=s(d*d),m=s(f*f),b=s(r*n*h-m),{isValid:l,value:S}=_p(s(b*m)),A=s(S*f),F=s(S*A*b),q=s((a+a)*A);(0,Me.isNegativeLE)(q,i)&&(q=s(-q));let v=s(d*F),G=s(q*v);if(!l||(0,Me.isNegativeLE)(G,i)||v===T2)throw new Error(o);return new e(new me.ed25519.ExtendedPoint(q,v,jr,G))}toRawBytes(){let{ex:t,ey:r,ez:n,et:i}=this.ep,s=me.ed25519.CURVE.Fp.ORDER,o=me.ed25519.CURVE.Fp.create,a=o(o(n+r)*o(n-r)),c=o(t*r),d=o(c*c),{value:f}=_p(o(a*d)),h=o(f*a),m=o(f*c),b=o(h*m*i),l;if((0,Me.isNegativeLE)(i*b,s)){let A=o(r*ql),F=o(t*ql);t=A,r=F,l=o(h*P2)}else l=m;(0,Me.isNegativeLE)(t*b,s)&&(r=o(-r));let S=o((n-r)*l);return(0,Me.isNegativeLE)(S,s)&&(S=o(-S)),(0,Zn.numberToBytesLE)(S,32)}toHex(){return(0,Zn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(t){Fl(t);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=t.ep,o=me.ed25519.CURVE.Fp.create,a=o(r*s)===o(n*i),c=o(n*s)===o(r*i);return a||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=(gr.BASE||(gr.BASE=new gr(me.ed25519.ExtendedPoint.BASE)),gr.ZERO||(gr.ZERO=new gr(me.ed25519.ExtendedPoint.ZERO)),gr);var M2=(e,t)=>{let r=t.DST,n=typeof r=="string"?(0,Ss.utf8ToBytes)(r):r,i=(0,mp.expand_message_xmd)(e,n,64,Na.sha512);return gr.hashToCurve(i)};me.hashToRistretto255=M2;me.hash_to_ristretto255=me.hashToRistretto255});var Sp=ee(Rn=>{"use strict";var Op=Rn&&Rn.__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},kt=Rn&&Rn.__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)},Rt,Ps,Ap,Np;Object.defineProperty(Rn,"__esModule",{value:!0});Rn.ExpirableMap=void 0;var Kl=class{constructor(t={}){Rt.set(this,void 0),Ps.set(this,void 0),this[Ap]=this.entries.bind(this),this[Np]="ExpirableMap";let{source:r=[],expirationTime:n=600*1e3}=t,i=Date.now();Op(this,Rt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),Op(this,Ps,n,"f")}prune(){let t=Date.now();for(let[r,n]of kt(this,Rt,"f").entries())t-n.timestamp>kt(this,Ps,"f")&&kt(this,Rt,"f").delete(r);return this}set(t,r){this.prune();let n={value:r,timestamp:Date.now()};return kt(this,Rt,"f").set(t,n),this}get(t){let r=kt(this,Rt,"f").get(t);if(r!==void 0){if(Date.now()-r.timestamp>kt(this,Ps,"f")){kt(this,Rt,"f").delete(t);return}return r.value}}clear(){kt(this,Rt,"f").clear()}entries(){let t=kt(this,Rt,"f").entries();return function*(){for(let[n,i]of t)yield[n,i.value]}()}values(){let t=kt(this,Rt,"f").values();return function*(){for(let n of t)yield n.value}()}keys(){return kt(this,Rt,"f").keys()}forEach(t,r){for(let[n,i]of kt(this,Rt,"f").entries())t.call(r,i.value,n,this)}has(t){return kt(this,Rt,"f").has(t)}delete(t){return kt(this,Rt,"f").delete(t)}get size(){return kt(this,Rt,"f").size}};Rn.ExpirableMap=Kl;Rt=new WeakMap,Ps=new WeakMap,Ap=Symbol.iterator,Np=Symbol.toStringTag});var $l=ee(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.unwrapDER=Ve.wrapDER=Ve.SECP256K1_OID=Ve.ED25519_OID=Ve.DER_COSE_OID=Ve.decodeLen=Ve.decodeLenBytes=Ve.encodeLen=Ve.encodeLenBytes=void 0;var q2=Kt(),j2=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)")};Ve.encodeLenBytes=j2;var k2=(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)")};Ve.encodeLen=k2;var V2=(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)")};Ve.decodeLenBytes=V2;var H2=(e,t)=>{let r=(0,Ve.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)")};Ve.decodeLen=H2;Ve.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);Ve.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);Ve.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function K2(e,t){let r=2+(0,Ve.encodeLenBytes)(e.byteLength+1),n=t.byteLength+r+e.byteLength,i=0,s=new Uint8Array(1+(0,Ve.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,Ve.encodeLen)(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=(0,Ve.encodeLen)(s,i,e.byteLength+1),s[i++]=0,s.set(new Uint8Array(e),i),s}Ve.wrapDER=K2;var $2=(e,t)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(e);if(n(48,"sequence"),r+=(0,Ve.decodeLenBytes)(i,r),!(0,q2.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,Ve.decodeLen)(i,r)-1;r+=(0,Ve.decodeLenBytes)(i,r),n(0,"0 padding");let o=i.slice(r);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};Ve.unwrapDER=$2});var Gl=ee(Bn=>{"use strict";var Rp=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},Bp=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)},Ra,Ba;Object.defineProperty(Bn,"__esModule",{value:!0});Bn.Ed25519PublicKey=void 0;var Sa=$l(),Pa=class e{constructor(t){if(Ra.set(this,void 0),Ba.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Rp(this,Ra,t,"f"),Rp(this,Ba,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,Sa.wrapDER)(t,Sa.ED25519_OID).buffer}static derDecode(t){let r=(0,Sa.unwrapDER)(t,Sa.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 Bp(this,Ra,"f")}get derKey(){return Bp(this,Ba,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Bn.Ed25519PublicKey=Pa;Ra=new WeakMap,Ba=new WeakMap;Pa.RAW_KEY_LENGTH=32});var Wl=ee(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.ObservableLog=Bi.Observable=void 0;var Ua=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=Ua;var Yl=class extends Ua{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=Yl});var jp=ee(Hr=>{"use strict";var kr=Hr&&Hr.__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=Hr&&Hr.__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)},Vr,Fa,Ca,Ma,qa,ja,ka,Va,Pi;Object.defineProperty(Hr,"__esModule",{value:!0});Hr.exponentialBackoff=Hr.ExponentialBackoff=void 0;var Pp=.5,Up=1.5,Fp=500,Cp=6e4,Mp=9e5,qp=10,Ui=class e{constructor(t=e.default){Vr.set(this,void 0),Fa.set(this,void 0),Ca.set(this,void 0),Ma.set(this,void 0),qa.set(this,void 0),ja.set(this,void 0),ka.set(this,void 0),Va.set(this,void 0),Pi.set(this,0);let{initialInterval:r=Fp,randomizationFactor:n=Pp,multiplier:i=Up,maxInterval:s=Cp,maxElapsedTime:o=Mp,maxIterations:a=qp,date:c=Date}=t;kr(this,Vr,r,"f"),kr(this,Fa,n,"f"),kr(this,Ca,i,"f"),kr(this,Ma,s,"f"),kr(this,Va,c,"f"),kr(this,qa,c.now(),"f"),kr(this,ja,o,"f"),kr(this,ka,a,"f")}get ellapsedTimeInMsec(){return Bt(this,Va,"f").now()-Bt(this,qa,"f")}get currentInterval(){return Bt(this,Vr,"f")}get count(){return Bt(this,Pi,"f")}get randomValueFromInterval(){let t=Bt(this,Fa,"f")*Bt(this,Vr,"f"),r=Bt(this,Vr,"f")-t,n=Bt(this,Vr,"f")+t;return Math.random()*(n-r)+r}incrementCurrentInterval(){var t;return kr(this,Vr,Math.min(Bt(this,Vr,"f")*Bt(this,Ca,"f"),Bt(this,Ma,"f")),"f"),kr(this,Pi,(t=Bt(this,Pi,"f"),t++,t),"f"),Bt(this,Vr,"f")}next(){return this.ellapsedTimeInMsec>=Bt(this,ja,"f")||Bt(this,Pi,"f")>=Bt(this,ka,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Hr.ExponentialBackoff=Ui;Vr=new WeakMap,Fa=new WeakMap,Ca=new WeakMap,Ma=new WeakMap,qa=new WeakMap,ja=new WeakMap,ka=new WeakMap,Va=new WeakMap,Pi=new WeakMap;Ui.default={initialInterval:Fp,randomizationFactor:Pp,multiplier:Up,maxInterval:Cp,maxElapsedTime:Mp,maxIterations:qp,date:Date};function*G2(e=Ui.default){let t=new Ui(e),r=t.next();for(;r;)yield r,r=t.next()}Hr.exponentialBackoff=G2});var Zl=ee(qe=>{"use strict";var Vp=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]}),Y2=qe&&qe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Hp=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)&&Vp(t,e,r);return Y2(t,e),t},Kp=qe&&qe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Vp(t,e,r)},xt=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},ne=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)},Pt,Xn,ki,Kr,on,ji,Us,Ci,wr,Er,Qn,In,Fs,Mi,qi,Dn,ei,$p,$a,Ga,Ln;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 sr=Ft(),$r=_i(),kp=Ku(),Pn=Hp(_s()),Ha=fs(),br=Kt(),xr=Do(),zl=ys(),Vi=ea(),W2=Ns(),Fi=Si(),z2=Hl(),J2=Sp(),Z2=Gl(),X2=_a(),Q2=Wl(),I2=jp();Kp(Do(),qe);Kp(ea(),qe);var D2=ys();Object.defineProperty(qe,"makeNonce",{enumerable:!0,get:function(){return D2.makeNonce}});var L2;(function(e){e.Received="received",e.Processing="processing",e.Replied="replied",e.Rejected="rejected",e.Unknown="unknown",e.Done="done"})(L2=qe.RequestStatusResponseStatus||(qe.RequestStatusResponseStatus={}));var Ka=60*1e3;qe.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";qe.MANAGEMENT_CANISTER_ID="aaaaa-aa";var eE="ic0.app",tE=".ic0.app",rE="icp0.io",nE=".icp0.io",iE="icp-api.io",sE=".icp-api.io",Cs=class extends $r.AgentError{constructor(t){super(t),this.message=t}},ti=class extends $r.AgentError{constructor(t){super(t),this.message=t}};qe.IdentityInvalidError=ti;function oE(){let e;if(typeof window<"u")if(window.fetch)e=window.fetch.bind(window);else throw new Cs("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 Cs("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 Cs("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function aE(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,o;s&&typeof s=="string"&&(n.some(a=>s.endsWith(a))?o=s:o=r.find(a=>s.endsWith(a))),i&&o?t=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):t=new URL("https://icp-api.io")}return t.toString()}var Jl=class e{constructor(t={}){var r,n;Pt.add(this),Xn.set(this,null),ki.set(this,!1),Kr.set(this,void 0),on.set(this,void 0),ji.set(this,void 0),Us.set(this,void 0),Ci.set(this,0),wr.set(this,void 0),Er.set(this,void 0),Qn.set(this,void 0),In.set(this,void 0),this._isAgent=!0,this.config={},Fs.set(this,0),this.log=new Q2.ObservableLog,Mi.set(this,[]),qi.set(this,[]),Dn.set(this,new J2.ExpirableMap({expirationTime:300*1e3})),ei.set(this,!0),Ga.set(this,(o,a)=>{if(ne(this,ei,"f")===!1)return o;if(!a)throw new Fi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:c,signatures:d=[],requestId:f}=o,h=new TextEncoder().encode("\vic-response");for(let m of d){let{timestamp:b,identity:l}=m,S=sr.Principal.fromUint8Array(l).toText(),A;if(c==="replied"){let{reply:E}=o;A=(0,Ha.hashOfMap)({status:c,reply:E,timestamp:BigInt(b),request_id:f})}else if(c==="rejected"){let{reject_code:E,reject_message:j,error_code:Y}=o;A=(0,Ha.hashOfMap)({status:c,reject_code:E,reject_message:j,error_code:Y,timestamp:BigInt(b),request_id:f})}else throw new Error(`Unknown status: ${c}`);let F=(0,br.concat)(h,new Uint8Array(A)),q=a?.nodeKeys.get(S);if(!q)throw new Fi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let v=Z2.Ed25519PublicKey.fromDer(q).rawKey;if(z2.ed25519.verify(m.signature,new Uint8Array(F),new Uint8Array(v)))return o;throw new Fi.CertificateVerificationError(`Invalid signature from replica ${S} signed query.`)}return o}),this.config=t,xt(this,on,t.fetch||oE()||fetch.bind(global),"f"),xt(this,ji,t.fetchOptions,"f"),xt(this,Us,t.callOptions,"f"),xt(this,ki,(r=t.shouldFetchRootKey)!==null&&r!==void 0?r:!1,"f"),t.rootKey?this.rootKey=t.rootKey:ne(this,ki,"f")?this.rootKey=null:this.rootKey=(0,br.fromHex)(qe.IC_ROOT_KEY);let i=aE(t.host);this.host=new URL(i),t.verifyQuerySignatures!==void 0&&xt(this,ei,t.verifyQuerySignatures,"f"),xt(this,Er,(n=t.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new I2.ExponentialBackoff({maxIterations:ne(this,Er,"f")});if(xt(this,Qn,t.backoffStrategy||s,"f"),this.host.hostname.endsWith(tE)?this.host.hostname=eE:this.host.hostname.endsWith(nE)?this.host.hostname=rE:this.host.hostname.endsWith(sE)&&(this.host.hostname=iE),t.credentials){let{name:o,password:a}=t.credentials;xt(this,wr,`${o}${a?":"+a:""}`,"f")}if(xt(this,Kr,Promise.resolve(t.identity||new kp.AnonymousIdentity),"f"),t.ingressExpiryInMinutes&&t.ingressExpiryInMinutes>5)throw new $r.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 $r.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${t.ingressExpiryInMinutes} minutes.`);xt(this,In,t.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,xr.makeNonceTransform)(zl.makeNonce)),t.useQueryNonces&&this.addTransform("query",(0,xr.makeNonceTransform)(zl.makeNonce)),t.logToConsole&&this.log.subscribe(o=>{o.level==="error"?console.error(o.message):o.level==="warn"?console.warn(o.message):console.log(o.message)})}get waterMark(){return ne(this,Fs,"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 $r.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=ne(this,qi,"f").findIndex(s=>(s.priority||0)<n);ne(this,qi,"f").splice(i>=0?i:ne(this,qi,"f").length,0,Object.assign(r,{priority:n}))}else if(t==="query"){let i=ne(this,Mi,"f").findIndex(s=>(s.priority||0)<n);ne(this,Mi,"f").splice(i>=0?i:ne(this,Mi,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ne(this,Kr,"f"))throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ne(this,Kr,"f")).getPrincipal()}async call(t,r,n){var i,s;await ne(this,Pt,"m",Ln).call(this);let o=(i=r.callSync)!==null&&i!==void 0?i:!0,a=await(n!==void 0?await n:await ne(this,Kr,"f"));if(!a)throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");let c=sr.Principal.from(t),d=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):c,f=a.getPrincipal()||sr.Principal.anonymous(),h=new xr.Expiry(ne(this,In,"f")*Ka);Math.abs(ne(this,Ci,"f"))>1e3*30&&(h=new xr.Expiry(ne(this,In,"f")*Ka+ne(this,Ci,"f")));let m={request_type:zl.SubmitRequestType.Call,canister_id:c,method_name:r.methodName,arg:r.arg,sender:f,ingress_expiry:h},b=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,wr,"f")?{Authorization:"Basic "+btoa(ne(this,wr,"f"))}:{})},endpoint:"call",body:m}),l=b.body.nonce?S(b.body.nonce):void 0;m.nonce=l;function S(v){return new Uint8Array(v)}b=await a.transformRequest(b);let A=Pn.encode(b.body),F=ne(this,Qn,"f").call(this),q=(0,Ha.requestIdOf)(m);try{let v=()=>(this.log.print(`fetching "/api/v3/canister/${d.toText()}/call" with request:`,b),ne(this,on,"f").call(this,""+new URL(`/api/v3/canister/${d.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Us,"f")),b.request),{body:A}))),G=()=>(this.log.print(`fetching "/api/v2/canister/${d.toText()}/call" with request:`,b),ne(this,on,"f").call(this,""+new URL(`/api/v2/canister/${d.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Us,"f")),b.request),{body:A}))),j=await ne(this,Pt,"m",$a).call(this,{request:o?v:G,backoff:F,tries:0}),Y=await j.arrayBuffer(),Z=j.status===200&&Y.byteLength>0?Pn.decode(Y):null;if(Z&&"certificate"in Z){let k=await this.parseTimeFromResponse({certificate:Z.certificate});xt(this,Fs,k,"f")}return{requestId:q,response:{ok:j.ok,status:j.status,statusText:j.statusText,body:Z,headers:(0,xr.httpHeadersTransform)(j.headers)},requestDetails:m}}catch(v){if(v.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 G=`Error while making call: ${(s=v.message)!==null&&s!==void 0?s:String(v)}`,E=new Vi.AgentCallError(G,v,(0,br.toHex)(q),(0,br.toHex)(b.body.sender_pubkey),(0,br.toHex)(b.body.sender_sig),String(b.body.content.ingress_expiry._value));throw this.log.error(G,E),E}}async query(t,r,n){var i,s,o,a;await ne(this,Pt,"m",Ln).call(this);let c=ne(this,Qn,"f").call(this),d=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):sr.Principal.from(t);this.log.print(`ecid ${d.toString()}`),this.log.print(`canisterId ${t.toString()}`);let f,h,m=await(n!==void 0?n:ne(this,Kr,"f"));if(!m)throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");let b=sr.Principal.from(t),l=m?.getPrincipal()||sr.Principal.anonymous(),S={request_type:"query",canister_id:b,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:new xr.Expiry(ne(this,In,"f")*Ka)},A=(0,Ha.requestIdOf)(S);f=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,wr,"f")?{Authorization:"Basic "+btoa(ne(this,wr,"f"))}:{})},endpoint:"read",body:S}),f=await m?.transformRequest(f);let F=Pn.encode(f.body),q={canister:b.toText(),ecid:d,transformedRequest:f,body:F,requestId:A,backoff:c,tries:0},v=async()=>({requestDetails:S,query:await ne(this,Pt,"m",$p).call(this,q)}),G=async()=>{if(!ne(this,ei,"f"))return;let E=ne(this,Dn,"f").get(d.toString());return E||(await this.fetchSubnetKeys(d.toString()),ne(this,Dn,"f").get(d.toString()))};try{let[E,j]=await Promise.all([v(),G()]);h=E;let{requestDetails:Y,query:Z}=h,k=Object.assign(Object.assign({},Z),{requestDetails:Y});if(this.log.print("Query response:",k),!ne(this,ei,"f"))return k;try{return ne(this,Ga,"f").call(this,k,j)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ne(this,Dn,"f").delete(t.toString()),await this.fetchSubnetKeys(d.toString());let D=ne(this,Dn,"f").get(t.toString());if(!D)throw new Fi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ne(this,Ga,"f").call(this,k,D)}}catch(E){let j=`Error while making call: ${(i=E.message)!==null&&i!==void 0?i:String(E)}`,Y=new Vi.AgentQueryError(j,E,String(A),(0,br.toHex)((s=f?.body)===null||s===void 0?void 0:s.sender_pubkey),(0,br.toHex)((o=f?.body)===null||o===void 0?void 0:o.sender_sig),String((a=f?.body)===null||a===void 0?void 0:a.content.ingress_expiry._value));throw this.log.error(j,Y),Y}}async createReadStateRequest(t,r){await ne(this,Pt,"m",Ln).call(this);let n=await(r!==void 0?await r:await ne(this,Kr,"f"));if(!n)throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||sr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,wr,"f")?{Authorization:"Basic "+btoa(ne(this,wr,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:t.paths,sender:i,ingress_expiry:new xr.Expiry(ne(this,In,"f")*Ka)}});return n?.transformRequest(s)}async readState(t,r,n,i){var s,o,a,c;function d(S){for(let A of S.paths){let[F,q]=A,v=new TextEncoder().encode("request_status");if((0,br.bufEquals)(F,v))return q}}let f=d(r);await ne(this,Pt,"m",Ln).call(this);let h=typeof t=="string"?sr.Principal.fromText(t):t,m=i??await this.createReadStateRequest(r,n),b=Pn.encode(m.body);this.log.print(`fetching "/api/v2/canister/${h}/read_state" with request:`,m);let l=ne(this,Qn,"f").call(this);try{let S=await ne(this,Pt,"m",$a).call(this,{request:()=>ne(this,on,"f").call(this,""+new URL(`/api/v2/canister/${h.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,ji,"f")),m.request),{body:b})),backoff:l,tries:0});if(!S.ok)throw new Error(`Server returned an error:
30
+ )`}else throw new Error("Invalid tree structure for labeled");case Et.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 Et.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=ga;function Lw(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 Tl=class e{constructor(t,r,n,i,s=5,o=!1){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,ma.set(this,!1),Jw(this,ma,o,"f"),this.cert=Mh.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=Qw.blsVerify),new e(t.certificate,t.rootKey,t.canisterId,r,t.maxAgeInMinutes,t.disableTimeVerification)}lookup(t){return ba(t,this.cert.tree)}lookup_label(t){return this.lookup([t])}async verify(){let t=await Os(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=t2(r),s=(0,br.concat)(Ts("ic-state-root"),t),o=!1,a=Ol(this.lookup(["time"]));if(!a)throw new nn("Certificate does not contain a time");if(!Zw(this,ma,"f")){let d=this._maxAgeInMinutes*60*1e3,f=Date.now(),h=f-d,m=f+3e5,b=(0,Iw.decodeTime)(a);if(b.getTime()<h)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{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)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()!==Dw.MANAGEMENT_CANISTER_ID&&!qh({canisterId:this._canisterId,subnetId:xl.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=Tl;ma=new WeakMap;var xs=(0,br.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),e2=96;function t2(e){let t=xs.byteLength+e2;if(e.byteLength!==t)throw new TypeError(`BLS DER-encoded public key must be ${t} bytes long`);let r=e.slice(0,xs.byteLength);if(!(0,br.bufEquals)(r,xs))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${xs}, but get ${r}`);return e.slice(xs.byteLength)}function Ol(e){if(e.status===Vt.Found){if(e.value instanceof ArrayBuffer)return e.value;if(e.value instanceof Uint8Array)return e.value.buffer}}Oe.lookupResultToBuffer=Ol;async function Os(e){switch(e[0]){case Et.Empty:return(0,ya.hash)(Ts("ic-hashtree-empty"));case Et.Pruned:return e[1];case Et.Leaf:return(0,ya.hash)((0,br.concat)(Ts("ic-hashtree-leaf"),e[1]));case Et.Labeled:return(0,ya.hash)((0,br.concat)(Ts("ic-hashtree-labeled"),e[1],await Os(e[2])));case Et.Fork:return(0,ya.hash)((0,br.concat)(Ts("ic-hashtree-fork"),await Os(e[1]),await Os(e[2])));default:throw new Error("unreachable")}}Oe.reconstruct=Os;function Ts(e){let t=new Uint8Array([e.length]),r=new TextEncoder().encode(e);return(0,br.concat)(t,r)}var Vt;(function(e){e.Unknown="unknown",e.Absent="absent",e.Found="found"})(Vt=Oe.LookupStatus||(Oe.LookupStatus={}));var sn;(function(e){e.Less="less",e.Greater="greater"})(sn||(sn={}));function ba(e,t){if(e.length===0)switch(t[0]){case Et.Leaf:{if(!t[1])throw new Error("Invalid tree structure for leaf");return t[1]instanceof ArrayBuffer?{status:Vt.Found,value:t[1]}:t[1]instanceof Uint8Array?{status:Vt.Found,value:t[1].buffer}:{status:Vt.Found,value:t[1]}}default:return{status:Vt.Found,value:t}}let r=typeof e[0]=="string"?new TextEncoder().encode(e[0]):e[0],n=vs(r,t);switch(n.status){case Vt.Found:return ba(e.slice(1),n.value);case sn.Greater:case sn.Less:return{status:Vt.Absent};default:return n}}Oe.lookup_path=ba;function vl(e){switch(e[0]){case Et.Empty:return[];case Et.Fork:return vl(e[1]).concat(vl(e[2]));default:return[e]}}Oe.flatten_forks=vl;function vs(e,t){switch(t[0]){case Et.Labeled:return Lw(e,t[1])?{status:sn.Greater}:(0,br.bufEquals)(e,t[1])?{status:Vt.Found,value:t[2]}:{status:sn.Less};case Et.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:Vt.Absent}:n}case Vt.Unknown:{let n=vs(e,t[2]);return n.status===sn.Less?{status:Vt.Unknown}:n}default:return r}case Et.Pruned:return{status:Vt.Unknown};default:return{status:Vt.Absent}}}Oe.find_label=vs;function qh(e){let{canisterId:t,subnetId:r,tree:n}=e,i=ba(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Vt.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return Mh.decode(i.value).map(c=>[xl.Principal.fromUint8Array(c[0]),xl.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(t)&&c[1].gtEq(t))}Oe.check_canister_ranges=qh});var As=ee(lt=>{"use strict";var r2=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]}),n2=lt&&lt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i2=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)&&r2(t,e,r);return n2(t,e),t};Object.defineProperty(lt,"__esModule",{value:!0});lt.encodePath=lt.fetchNodeKeys=lt.request=lt.CustomPath=void 0;var On=Mt(),s2=_i(),vn=Si(),o2=Yt(),Vh=i2(_s()),jh=_a(),Nl=class{constructor(t,r,n){this.key=t,this.path=r,this.decodeStrategy=n}};lt.CustomPath=Nl;var a2=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)),o=new Map,a=i.map((c,d)=>(async()=>{var f;try{let h=await t.readState(n,{paths:[s[d]]});if(t.rootKey==null)throw new Error("Agent is missing root key");let m=await vn.Certificate.create({certificate:h.certificate,rootKey:t.rootKey,canisterId:n,disableTimeVerification:!0}),b=(N,F)=>{if(F==="subnet"){if(t.rootKey==null)throw new Error("Agent is missing root key");let q=(0,lt.fetchNodeKeys)(h.certificate,n,t.rootKey);return{path:F,data:q}}else return{path:F,data:(0,vn.lookupResultToBuffer)(N.lookup((0,lt.encodePath)(F,n)))}},{path:l,data:S}=b(m,i[d]);if(!S)console.warn(`Expected to find result for path ${l}, but instead found nothing.`),typeof l=="string"?o.set(l,null):o.set(l.key,null);else switch(l){case"time":{o.set(l,(0,jh.decodeTime)(S));break}case"controllers":{o.set(l,d2(S));break}case"module_hash":{o.set(l,kh(S));break}case"subnet":{o.set(l,S);break}case"candid":{o.set(l,new TextDecoder().decode(S));break}default:if(typeof l!="string"&&"key"in l&&"path"in l)switch(l.decodeStrategy){case"raw":o.set(l.key,S);break;case"leb128":{o.set(l.key,(0,jh.decodeLeb128)(S));break}case"cbor":{o.set(l.key,Hh(S));break}case"hex":{o.set(l.key,kh(S));break}case"utf-8":o.set(l.key,l2(S))}}}catch(h){if(!((f=h?.message)===null||f===void 0)&&f.includes("Invalid certificate"))throw new s2.AgentError(h.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(h),console.groupEnd()}})());return await Promise.all(a),o};lt.request=a2;var c2=(e,t,r)=>{if(!t._isPrincipal)throw new Error("Invalid canisterId");let n=Vh.decode(new Uint8Array(e)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=On.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=On.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=On.Principal.selfAuthenticating(On.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,vn.check_canister_ranges)({canisterId:t,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,vn.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==vn.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let d=(0,vn.flatten_forks)(c.value),f=new Map;return d.forEach(h=>{let m=On.Principal.from(new Uint8Array(h[1])).toText(),b=(0,vn.lookup_path)(["public_key"],h[2]);if(b.status!==vn.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=c2;var u2=(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,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}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=u2;var kh=e=>(0,o2.toHex)(e),Hh=e=>Vh.decode(e),l2=e=>new TextDecoder().decode(e),d2=e=>Hh(e).map(r=>On.Principal.fromUint8Array(new Uint8Array(r)))});var cp=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=Kh;ye.add=tp;var wa=BigInt(2**32-1),Al=BigInt(32);function Sl(e,t=!1){return t?{h:Number(e&wa),l:Number(e>>Al&wa)}:{h:Number(e>>Al&wa)|0,l:Number(e&wa)|0}}function Kh(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:o}=Sl(e[i],t);[r[i],n[i]]=[s,o]}return[r,n]}var $h=(e,t)=>BigInt(e>>>0)<<Al|BigInt(t>>>0);ye.toBig=$h;var Gh=(e,t,r)=>e>>>r;ye.shrSH=Gh;var Yh=(e,t,r)=>e<<32-r|t>>>r;ye.shrSL=Yh;var zh=(e,t,r)=>e>>>r|t<<32-r;ye.rotrSH=zh;var Wh=(e,t,r)=>e<<32-r|t>>>r;ye.rotrSL=Wh;var Jh=(e,t,r)=>e<<64-r|t>>>r-32;ye.rotrBH=Jh;var Zh=(e,t,r)=>e>>>r-32|t<<64-r;ye.rotrBL=Zh;var Xh=(e,t)=>t;ye.rotr32H=Xh;var Qh=(e,t)=>e;ye.rotr32L=Qh;var Ih=(e,t,r)=>e<<r|t>>>32-r;ye.rotlSH=Ih;var Dh=(e,t,r)=>t<<r|e>>>32-r;ye.rotlSL=Dh;var Lh=(e,t,r)=>t<<r-32|e>>>64-r;ye.rotlBH=Lh;var ep=(e,t,r)=>e<<r-32|t>>>64-r;ye.rotlBL=ep;function tp(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var rp=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);ye.add3L=rp;var np=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;ye.add3H=np;var ip=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);ye.add4L=ip;var sp=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0;ye.add4H=sp;var op=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0);ye.add5L=op;var ap=(e,t,r,n,i,s)=>t+r+n+i+s+(e/2**32|0)|0;ye.add5H=ap;var f2={fromBig:Sl,split:Kh,toBig:$h,shrSH:Gh,shrSL:Yh,rotrSH:zh,rotrSL:Wh,rotrBH:Jh,rotrBL:Zh,rotr32H:Xh,rotr32L:Qh,rotlSH:Ih,rotlSL:Dh,rotlBH:Lh,rotlBL:ep,add:tp,add3L:rp,add3H:np,add4L:ip,add4H:sp,add5H:ap,add5L:op};ye.default=f2});var up=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 h2=Zc(),be=cp(),Oa=Hn(),[p2,_2]=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))),Nn=new Uint32Array(80),An=new Uint32Array(80),Jn=class extends h2.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:o,Dh:a,Dl:c,Eh:d,El:f,Fh:h,Fl:m,Gh:b,Gl:l,Hh:S,Hl:N}=this;return[t,r,n,i,s,o,a,c,d,f,h,m,b,l,S,N]}set(t,r,n,i,s,o,a,c,d,f,h,m,b,l,S,N){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=d|0,this.El=f|0,this.Fh=h|0,this.Fl=m|0,this.Gh=b|0,this.Gl=l|0,this.Hh=S|0,this.Hl=N|0}process(t,r){for(let O=0;O<16;O++,r+=4)Nn[O]=t.getUint32(r),An[O]=t.getUint32(r+=4);for(let O=16;O<80;O++){let G=Nn[O-15]|0,E=An[O-15]|0,j=be.default.rotrSH(G,E,1)^be.default.rotrSH(G,E,8)^be.default.shrSH(G,E,7),Y=be.default.rotrSL(G,E,1)^be.default.rotrSL(G,E,8)^be.default.shrSL(G,E,7),z=Nn[O-2]|0,k=An[O-2]|0,oe=be.default.rotrSH(z,k,19)^be.default.rotrBH(z,k,61)^be.default.shrSH(z,k,6),L=be.default.rotrSL(z,k,19)^be.default.rotrBL(z,k,61)^be.default.shrSL(z,k,6),ne=be.default.add4L(Y,L,An[O-7],An[O-16]),w=be.default.add4H(ne,j,oe,Nn[O-7],Nn[O-16]);Nn[O]=w|0,An[O]=ne|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:d,Dl:f,Eh:h,El:m,Fh:b,Fl:l,Gh:S,Gl:N,Hh:F,Hl:q}=this;for(let O=0;O<80;O++){let G=be.default.rotrSH(h,m,14)^be.default.rotrSH(h,m,18)^be.default.rotrBH(h,m,41),E=be.default.rotrSL(h,m,14)^be.default.rotrSL(h,m,18)^be.default.rotrBL(h,m,41),j=h&b^~h&S,Y=m&l^~m&N,z=be.default.add5L(q,E,Y,_2[O],An[O]),k=be.default.add5H(z,F,G,j,p2[O],Nn[O]),oe=z|0,L=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&a^s&a,g=i&o^i&c^o&c;F=S|0,q=N|0,S=b|0,N=l|0,b=h|0,l=m|0,{h,l:m}=be.default.add(d|0,f|0,k|0,oe|0),d=a|0,f=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let R=be.default.add3L(oe,ne,g);n=be.default.add3H(R,k,L,w),i=R|0}({h:n,l:i}=be.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=be.default.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=be.default.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:d,l:f}=be.default.add(this.Dh|0,this.Dl|0,d|0,f|0),{h,l:m}=be.default.add(this.Eh|0,this.El|0,h|0,m|0),{h:b,l}=be.default.add(this.Fh|0,this.Fl|0,b|0,l|0),{h:S,l:N}=be.default.add(this.Gh|0,this.Gl|0,S|0,N|0),{h:F,l:q}=be.default.add(this.Hh|0,this.Hl|0,F|0,q|0),this.set(n,i,s,o,a,c,d,f,h,m,b,l,S,N,F,q)}roundClean(){Nn.fill(0),An.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=Jn;var Ea=class extends Jn{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=Ea;var xa=class extends Jn{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=xa;var Ta=class extends Jn{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=Ta;yt.sha512=(0,Oa.wrapConstructor)(()=>new Jn);yt.sha512_224=(0,Oa.wrapConstructor)(()=>new Ea);yt.sha512_256=(0,Oa.wrapConstructor)(()=>new xa);yt.sha384=(0,Oa.wrapConstructor)(()=>new Ta)});var dp=ee(Bl=>{"use strict";Object.defineProperty(Bl,"__esModule",{value:!0});Bl.twistedEdwards=b2;var Rl=fl(),lp=kr(),Zt=It(),er=It(),wr=BigInt(0),Jt=BigInt(1),va=BigInt(2),y2=BigInt(8),m2={zip215:!0};function g2(e){let t=(0,Rl.validateBasic)(e);return Zt.validateObject(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function b2(e){let t=g2(e),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=t,d=va<<BigInt(a*8)-Jt,f=r.create,h=(0,lp.Field)(t.n,t.nBitLength),m=t.uvRatio||((A,B)=>{try{return{isValid:!0,value:r.sqrt(A*r.inv(B))}}catch{return{isValid:!1,value:wr}}}),b=t.adjustScalarBytes||(A=>A),l=t.domain||((A,B,K)=>{if((0,er.abool)("phflag",K),B.length||K)throw new Error("Contexts/pre-hash are not supported");return A});function S(A,B){Zt.aInRange("coordinate "+A,B,wr,d)}function N(A){if(!(A instanceof O))throw new Error("ExtendedPoint expected")}let F=(0,er.memoized)((A,B)=>{let{ex:K,ey:X,ez:ae}=A,se=A.is0();B==null&&(B=se?y2:r.inv(ae));let Z=f(K*B),C=f(X*B),_=f(ae*B);if(se)return{x:wr,y:Jt};if(_!==Jt)throw new Error("invZ was invalid");return{x:Z,y:C}}),q=(0,er.memoized)(A=>{let{a:B,d:K}=t;if(A.is0())throw new Error("bad point: ZERO");let{ex:X,ey:ae,ez:se,et:Z}=A,C=f(X*X),_=f(ae*ae),I=f(se*se),re=f(I*I),le=f(C*B),D=f(I*f(le+_)),u=f(re+f(K*f(C*_)));if(D!==u)throw new Error("bad point: equation left != right (1)");let p=f(X*ae),y=f(se*Z);if(p!==y)throw new Error("bad point: equation left != right (2)");return!0});class O{constructor(B,K,X,ae){this.ex=B,this.ey=K,this.ez=X,this.et=ae,S("x",B),S("y",K),S("z",X),S("t",ae),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:K,y:X}=B||{};return S("x",K),S("y",X),new O(K,X,Jt,f(K*X))}static normalizeZ(B){let K=r.invertBatch(B.map(X=>X.ez));return B.map((X,ae)=>X.toAffine(K[ae])).map(O.fromAffine)}static msm(B,K){return(0,Rl.pippenger)(O,h,B,K)}_setWindowSize(B){j.setWindowSize(this,B)}assertValidity(){q(this)}equals(B){N(B);let{ex:K,ey:X,ez:ae}=this,{ex:se,ey:Z,ez:C}=B,_=f(K*C),I=f(se*ae),re=f(X*C),le=f(Z*ae);return _===I&&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:K,ey:X,ez:ae}=this,se=f(K*K),Z=f(X*X),C=f(va*f(ae*ae)),_=f(B*se),I=K+X,re=f(f(I*I)-se-Z),le=_+Z,D=le-C,u=_-Z,p=f(re*D),y=f(le*u),U=f(re*u),v=f(D*le);return new O(p,y,v,U)}add(B){N(B);let{a:K,d:X}=t,{ex:ae,ey:se,ez:Z,et:C}=this,{ex:_,ey:I,ez:re,et:le}=B;if(K===BigInt(-1)){let Q=f((se-ae)*(I+_)),te=f((se+ae)*(I-_)),de=f(te-Q);if(de===wr)return this.double();let ge=f(Z*va*le),Re=f(C*va*re),Fe=Re+ge,_e=te+Q,fe=Re-ge,$e=f(Fe*de),Kt=f(_e*fe),Ft=f(Fe*fe),Ct=f(de*_e);return new O($e,Kt,Ct,Ft)}let D=f(ae*_),u=f(se*I),p=f(C*X*le),y=f(Z*re),U=f((ae+se)*(_+I)-D-u),v=y-p,P=y+p,H=f(u-K*D),x=f(U*v),M=f(P*H),$=f(U*H),V=f(v*P);return new O(x,M,V,$)}subtract(B){return this.add(B.negate())}wNAF(B){return j.wNAFCached(this,B,O.normalizeZ)}multiply(B){let K=B;Zt.aInRange("scalar",K,Jt,n);let{p:X,f:ae}=this.wNAF(K);return O.normalizeZ([X,ae])[0]}multiplyUnsafe(B){let K=B;return Zt.aInRange("scalar",K,wr,n),K===wr?E:this.equals(E)||K===Jt?this:this.equals(G)?this.wNAF(K).p:j.unsafeLadder(this,K)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return j.unsafeLadder(this,n).is0()}toAffine(B){return F(this,B)}clearCofactor(){let{h:B}=t;return B===Jt?this:this.multiplyUnsafe(B)}static fromHex(B,K=!1){let{d:X,a:ae}=t,se=r.BYTES;B=(0,er.ensureBytes)("pointHex",B,se),(0,er.abool)("zip215",K);let Z=B.slice(),C=B[se-1];Z[se-1]=C&-129;let _=Zt.bytesToNumberLE(Z),I=K?d:r.ORDER;Zt.aInRange("pointHex.y",_,wr,I);let re=f(_*_),le=f(re-Jt),D=f(X*re-ae),{isValid:u,value:p}=m(le,D);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let y=(p&Jt)===Jt,U=(C&128)!==0;if(!K&&p===wr&&U)throw new Error("Point.fromHex: x=0 and x_0=1");return U!==y&&(p=f(-p)),O.fromAffine({x:p,y:_})}static fromPrivateKey(B){return k(B).point}toRawBytes(){let{x:B,y:K}=this.toAffine(),X=Zt.numberToBytesLE(K,r.BYTES);return X[X.length-1]|=B&Jt?128:0,X}toHex(){return Zt.bytesToHex(this.toRawBytes())}}O.BASE=new O(t.Gx,t.Gy,Jt,f(t.Gx*t.Gy)),O.ZERO=new O(wr,Jt,Jt,wr);let{BASE:G,ZERO:E}=O,j=(0,Rl.wNAF)(O,a*8);function Y(A){return(0,lp.mod)(A,n)}function z(A){return Y(Zt.bytesToNumberLE(A))}function k(A){let B=a;A=(0,er.ensureBytes)("private key",A,B);let K=(0,er.ensureBytes)("hashed private key",s(A),2*B),X=b(K.slice(0,B)),ae=K.slice(B,2*B),se=z(X),Z=G.multiply(se),C=Z.toRawBytes();return{head:X,prefix:ae,scalar:se,point:Z,pointBytes:C}}function oe(A){return k(A).pointBytes}function L(A=new Uint8Array,...B){let K=Zt.concatBytes(...B);return z(s(l(K,(0,er.ensureBytes)("context",A),!!i)))}function ne(A,B,K={}){A=(0,er.ensureBytes)("message",A),i&&(A=i(A));let{prefix:X,scalar:ae,pointBytes:se}=k(B),Z=L(K.context,X,A),C=G.multiply(Z).toRawBytes(),_=L(K.context,C,se,A),I=Y(Z+_*ae);Zt.aInRange("signature.s",I,wr,n);let re=Zt.concatBytes(C,Zt.numberToBytesLE(I,r.BYTES));return(0,er.ensureBytes)("result",re,a*2)}let w=m2;function g(A,B,K,X=w){let{context:ae,zip215:se}=X,Z=r.BYTES;A=(0,er.ensureBytes)("signature",A,2*Z),B=(0,er.ensureBytes)("message",B),se!==void 0&&(0,er.abool)("zip215",se),i&&(B=i(B));let C=Zt.bytesToNumberLE(A.slice(Z,2*Z)),_,I,re;try{_=O.fromHex(K,se),I=O.fromHex(A.slice(0,Z),se),re=G.multiplyUnsafe(C)}catch{return!1}if(!se&&_.isSmallOrder())return!1;let le=L(ae,I.toRawBytes(),_.toRawBytes(),B);return I.add(_.multiplyUnsafe(le)).subtract(re).clearCofactor().equals(O.ZERO)}return G._setWindowSize(8),{CURVE:t,getPublicKey:oe,sign:ne,verify:g,ExtendedPoint:O,utils:{getExtendedPublicKey:k,randomPrivateKey:()=>o(r.BYTES),precompute(A=8,B=O.BASE){return B._setWindowSize(A),B.multiply(BigInt(3)),B}}}}});var hp=ee(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});Ul.montgomery=E2;var fp=kr(),Sn=It(),Ri=BigInt(0),Pl=BigInt(1);function w2(e){return(0,Sn.validateObject)(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}function E2(e){let t=w2(e),{P:r}=t,n=q=>(0,fp.mod)(q,r),i=t.montgomeryBits,s=Math.ceil(i/8),o=t.nByteLength,a=t.adjustScalarBytes||(q=>q),c=t.powPminus2||(q=>(0,fp.pow)(q,r-BigInt(2),r));function d(q,O,G){let E=n(q*(O-G));return O=n(O-E),G=n(G+E),[O,G]}let f=(t.a-BigInt(2))/BigInt(4);function h(q,O){(0,Sn.aInRange)("u",q,Ri,r),(0,Sn.aInRange)("scalar",O,Ri,r);let G=O,E=q,j=Pl,Y=Ri,z=q,k=Pl,oe=Ri,L;for(let w=BigInt(i-1);w>=Ri;w--){let g=G>>w&Pl;oe^=g,L=d(oe,j,z),j=L[0],z=L[1],L=d(oe,Y,k),Y=L[0],k=L[1],oe=g;let R=j+Y,A=n(R*R),B=j-Y,K=n(B*B),X=A-K,ae=z+k,se=z-k,Z=n(se*R),C=n(ae*B),_=Z+C,I=Z-C;z=n(_*_),k=n(E*n(I*I)),j=n(A*K),Y=n(X*(A+n(f*X)))}L=d(oe,j,z),j=L[0],z=L[1],L=d(oe,Y,k),Y=L[0],k=L[1];let ne=c(Y);return n(j*ne)}function m(q){return(0,Sn.numberToBytesLE)(n(q),s)}function b(q){let O=(0,Sn.ensureBytes)("u coordinate",q,s);return o===32&&(O[31]&=127),(0,Sn.bytesToNumberLE)(O)}function l(q){let O=(0,Sn.ensureBytes)("scalar",q),G=O.length;if(G!==s&&G!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${G}`);return(0,Sn.bytesToNumberLE)(a(O))}function S(q,O){let G=b(O),E=l(q),j=h(G,E);if(j===Ri)throw new Error("Invalid private or public key received");return m(j)}let N=m(t.Gu);function F(q){return S(q,N)}return{scalarMult:S,scalarMultBase:F,getSharedSecret:(q,O)=>S(q,O),getPublicKey:q=>F(q),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:N}}});var Hl=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=Tp;me.edwardsToMontgomeryPriv=O2;var Aa=up(),Ss=Hn(),jl=dp(),mp=oa(),Me=kr(),x2=hp(),Zn=It(),Rs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ml=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),T2=BigInt(0),Vr=BigInt(1),Na=BigInt(2),gp=BigInt(3),bp=BigInt(5),kl=BigInt(8);function wp(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=Rs,a=e*e%s*e%s,c=(0,Me.pow2)(a,Na,s)*a%s,d=(0,Me.pow2)(c,Vr,s)*e%s,f=(0,Me.pow2)(d,bp,s)*d%s,h=(0,Me.pow2)(f,t,s)*f%s,m=(0,Me.pow2)(h,r,s)*h%s,b=(0,Me.pow2)(m,n,s)*m%s,l=(0,Me.pow2)(b,i,s)*b%s,S=(0,Me.pow2)(l,i,s)*b%s,N=(0,Me.pow2)(S,t,s)*f%s;return{pow_p_5_8:(0,Me.pow2)(N,Na,s)*e%s,b2:a}}function Ep(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Vl(e,t){let r=Rs,n=(0,Me.mod)(t*t*t,r),i=(0,Me.mod)(n*n*t,r),s=wp(e*i).pow_p_5_8,o=(0,Me.mod)(e*n*s,r),a=(0,Me.mod)(t*o*o,r),c=o,d=(0,Me.mod)(o*Ml,r),f=a===e,h=a===(0,Me.mod)(-e,r),m=a===(0,Me.mod)(-e*Ml,r);return f&&(o=c),(h||m)&&(o=d),(0,Me.isNegativeLE)(o,r)&&(o=(0,Me.mod)(-o,r)),{isValid:f||h,value:o}}me.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var ue=(0,Me.Field)(Rs,void 0,!0),Bs={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ue,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:kl,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Aa.sha512,randomBytes:Ss.randomBytes,adjustScalarBytes:Ep,uvRatio:Vl};me.ed25519=(0,jl.twistedEdwards)(Bs);function xp(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,jl.twistedEdwards)({...Bs,domain:xp});me.ed25519ph=(0,jl.twistedEdwards)(Object.assign({},Bs,{domain:xp,prehash:Aa.sha512}));me.x25519=(0,x2.montgomery)({P:Rs,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{let t=Rs,{pow_p_5_8:r,b2:n}=wp(e);return(0,Me.mod)((0,Me.pow2)(r,gp,t)*n,t)},adjustScalarBytes:Ep,randomBytes:Ss.randomBytes});function Tp(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=Tp;function O2(e){let t=Bs.hash(e.subarray(0,32));return Bs.adjustScalarBytes(t).subarray(0,32)}var v2=(ue.ORDER+gp)/kl,N2=ue.pow(Na,v2),pp=ue.sqrt(ue.neg(ue.ONE));function A2(e){let t=(ue.ORDER-bp)/kl,r=BigInt(486662),n=ue.sqr(e);n=ue.mul(n,Na);let i=ue.add(n,ue.ONE),s=ue.neg(r),o=ue.sqr(i),a=ue.mul(o,i),c=ue.mul(n,r);c=ue.mul(c,s),c=ue.add(c,o),c=ue.mul(c,s);let d=ue.sqr(a);o=ue.sqr(d),d=ue.mul(d,a),d=ue.mul(d,c),o=ue.mul(o,d);let f=ue.pow(o,t);f=ue.mul(f,d);let h=ue.mul(f,pp);o=ue.sqr(f),o=ue.mul(o,a);let m=ue.eql(o,c),b=ue.cmov(h,f,m),l=ue.mul(s,n),S=ue.mul(f,e);S=ue.mul(S,N2);let N=ue.mul(S,pp),F=ue.mul(c,n);o=ue.sqr(S),o=ue.mul(o,a);let q=ue.eql(o,F),O=ue.cmov(N,S,q);o=ue.sqr(b),o=ue.mul(o,a);let G=ue.eql(o,c),E=ue.cmov(l,s,G),j=ue.cmov(O,b,G),Y=ue.isOdd(j);return j=ue.cmov(j,ue.neg(j),G!==Y),{xMn:E,xMd:i,yMn:j,yMd:Vr}}var S2=(0,Me.FpSqrtEven)(ue,ue.neg(BigInt(486664)));function R2(e){let{xMn:t,xMd:r,yMn:n,yMd:i}=A2(e),s=ue.mul(t,i);s=ue.mul(s,S2);let o=ue.mul(r,n),a=ue.sub(t,r),c=ue.add(t,r),d=ue.mul(o,c),f=ue.eql(d,ue.ZERO);s=ue.cmov(s,ue.ZERO,f),o=ue.cmov(o,ue.ONE,f),a=ue.cmov(a,ue.ONE,f),c=ue.cmov(c,ue.ONE,f);let h=ue.invertBatch([o,c]);return{x:ue.mul(s,h[0]),y:ue.mul(a,h[1])}}var Op=(0,mp.createHasher)(me.ed25519.ExtendedPoint,e=>R2(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:Aa.sha512});me.hashToCurve=Op.hashToCurve;me.encodeToCurve=Op.encodeToCurve;function Fl(e){if(!(e instanceof Er))throw new Error("RistrettoPoint expected")}var ql=Ml,B2=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),P2=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),U2=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),F2=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),_p=e=>Vl(Vr,e),C2=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Cl=e=>me.ed25519.CURVE.Fp.create((0,Zn.bytesToNumberLE)(e)&C2);function yp(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+Vr)*U2),o=BigInt(-1),a=n((o-t*i)*n(i+t)),{isValid:c,value:d}=Vl(s,a),f=n(d*e);(0,Me.isNegativeLE)(f,r)||(f=n(-f)),c||(d=f),c||(o=i);let h=n(o*(i-Vr)*F2-a),m=d*d,b=n((d+d)*a),l=n(h*B2),S=n(Vr-m),N=n(Vr+m);return new me.ed25519.ExtendedPoint(n(b*N),n(S*l),n(l*N),n(b*S))}var Er=class e{constructor(t){this.ep=t}static fromAffine(t){return new e(me.ed25519.ExtendedPoint.fromAffine(t))}static hashToCurve(t){t=(0,Zn.ensureBytes)("ristrettoHash",t,64);let r=Cl(t.slice(0,32)),n=yp(r),i=Cl(t.slice(32,64)),s=yp(i);return new e(n.add(s))}static fromHex(t){t=(0,Zn.ensureBytes)("ristrettoHex",t,32);let{a:r,d:n}=me.ed25519.CURVE,i=me.ed25519.CURVE.Fp.ORDER,s=me.ed25519.CURVE.Fp.create,o="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=Cl(t);if(!(0,Zn.equalBytes)((0,Zn.numberToBytesLE)(a,32),t)||(0,Me.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),d=s(Vr+r*c),f=s(Vr-r*c),h=s(d*d),m=s(f*f),b=s(r*n*h-m),{isValid:l,value:S}=_p(s(b*m)),N=s(S*f),F=s(S*N*b),q=s((a+a)*N);(0,Me.isNegativeLE)(q,i)&&(q=s(-q));let O=s(d*F),G=s(q*O);if(!l||(0,Me.isNegativeLE)(G,i)||O===T2)throw new Error(o);return new e(new me.ed25519.ExtendedPoint(q,O,Vr,G))}toRawBytes(){let{ex:t,ey:r,ez:n,et:i}=this.ep,s=me.ed25519.CURVE.Fp.ORDER,o=me.ed25519.CURVE.Fp.create,a=o(o(n+r)*o(n-r)),c=o(t*r),d=o(c*c),{value:f}=_p(o(a*d)),h=o(f*a),m=o(f*c),b=o(h*m*i),l;if((0,Me.isNegativeLE)(i*b,s)){let N=o(r*ql),F=o(t*ql);t=N,r=F,l=o(h*P2)}else l=m;(0,Me.isNegativeLE)(t*b,s)&&(r=o(-r));let S=o((n-r)*l);return(0,Me.isNegativeLE)(S,s)&&(S=o(-S)),(0,Zn.numberToBytesLE)(S,32)}toHex(){return(0,Zn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(t){Fl(t);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=t.ep,o=me.ed25519.CURVE.Fp.create,a=o(r*s)===o(n*i),c=o(n*s)===o(r*i);return a||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=(Er.BASE||(Er.BASE=new Er(me.ed25519.ExtendedPoint.BASE)),Er.ZERO||(Er.ZERO=new Er(me.ed25519.ExtendedPoint.ZERO)),Er);var M2=(e,t)=>{let r=t.DST,n=typeof r=="string"?(0,Ss.utf8ToBytes)(r):r,i=(0,mp.expand_message_xmd)(e,n,64,Aa.sha512);return Er.hashToCurve(i)};me.hashToRistretto255=M2;me.hash_to_ristretto255=me.hashToRistretto255});var Sp=ee(Rn=>{"use strict";var vp=Rn&&Rn.__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},Ht=Rn&&Rn.__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)},Rt,Ps,Np,Ap;Object.defineProperty(Rn,"__esModule",{value:!0});Rn.ExpirableMap=void 0;var Kl=class{constructor(t={}){Rt.set(this,void 0),Ps.set(this,void 0),this[Np]=this.entries.bind(this),this[Ap]="ExpirableMap";let{source:r=[],expirationTime:n=600*1e3}=t,i=Date.now();vp(this,Rt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),vp(this,Ps,n,"f")}prune(){let t=Date.now();for(let[r,n]of Ht(this,Rt,"f").entries())t-n.timestamp>Ht(this,Ps,"f")&&Ht(this,Rt,"f").delete(r);return this}set(t,r){this.prune();let n={value:r,timestamp:Date.now()};return Ht(this,Rt,"f").set(t,n),this}get(t){let r=Ht(this,Rt,"f").get(t);if(r!==void 0){if(Date.now()-r.timestamp>Ht(this,Ps,"f")){Ht(this,Rt,"f").delete(t);return}return r.value}}clear(){Ht(this,Rt,"f").clear()}entries(){let t=Ht(this,Rt,"f").entries();return function*(){for(let[n,i]of t)yield[n,i.value]}()}values(){let t=Ht(this,Rt,"f").values();return function*(){for(let n of t)yield n.value}()}keys(){return Ht(this,Rt,"f").keys()}forEach(t,r){for(let[n,i]of Ht(this,Rt,"f").entries())t.call(r,i.value,n,this)}has(t){return Ht(this,Rt,"f").has(t)}delete(t){return Ht(this,Rt,"f").delete(t)}get size(){return Ht(this,Rt,"f").size}};Rn.ExpirableMap=Kl;Rt=new WeakMap,Ps=new WeakMap,Np=Symbol.iterator,Ap=Symbol.toStringTag});var $l=ee(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.unwrapDER=Ve.wrapDER=Ve.SECP256K1_OID=Ve.ED25519_OID=Ve.DER_COSE_OID=Ve.decodeLen=Ve.decodeLenBytes=Ve.encodeLen=Ve.encodeLenBytes=void 0;var q2=Yt(),j2=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)")};Ve.encodeLenBytes=j2;var k2=(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)")};Ve.encodeLen=k2;var V2=(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)")};Ve.decodeLenBytes=V2;var H2=(e,t)=>{let r=(0,Ve.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)")};Ve.decodeLen=H2;Ve.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);Ve.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);Ve.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function K2(e,t){let r=2+(0,Ve.encodeLenBytes)(e.byteLength+1),n=t.byteLength+r+e.byteLength,i=0,s=new Uint8Array(1+(0,Ve.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,Ve.encodeLen)(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=(0,Ve.encodeLen)(s,i,e.byteLength+1),s[i++]=0,s.set(new Uint8Array(e),i),s}Ve.wrapDER=K2;var $2=(e,t)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(e);if(n(48,"sequence"),r+=(0,Ve.decodeLenBytes)(i,r),!(0,q2.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,Ve.decodeLen)(i,r)-1;r+=(0,Ve.decodeLenBytes)(i,r),n(0,"0 padding");let o=i.slice(r);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};Ve.unwrapDER=$2});var Gl=ee(Bn=>{"use strict";var Rp=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},Bp=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)},Ra,Ba;Object.defineProperty(Bn,"__esModule",{value:!0});Bn.Ed25519PublicKey=void 0;var Sa=$l(),Pa=class e{constructor(t){if(Ra.set(this,void 0),Ba.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Rp(this,Ra,t,"f"),Rp(this,Ba,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,Sa.wrapDER)(t,Sa.ED25519_OID).buffer}static derDecode(t){let r=(0,Sa.unwrapDER)(t,Sa.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 Bp(this,Ra,"f")}get derKey(){return Bp(this,Ba,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Bn.Ed25519PublicKey=Pa;Ra=new WeakMap,Ba=new WeakMap;Pa.RAW_KEY_LENGTH=32});var zl=ee(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.ObservableLog=Bi.Observable=void 0;var Ua=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=Ua;var Yl=class extends Ua{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=Yl});var jp=ee($r=>{"use strict";var Hr=$r&&$r.__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=$r&&$r.__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)},Kr,Fa,Ca,Ma,qa,ja,ka,Va,Pi;Object.defineProperty($r,"__esModule",{value:!0});$r.exponentialBackoff=$r.ExponentialBackoff=void 0;var Pp=.5,Up=1.5,Fp=500,Cp=6e4,Mp=9e5,qp=10,Ui=class e{constructor(t=e.default){Kr.set(this,void 0),Fa.set(this,void 0),Ca.set(this,void 0),Ma.set(this,void 0),qa.set(this,void 0),ja.set(this,void 0),ka.set(this,void 0),Va.set(this,void 0),Pi.set(this,0);let{initialInterval:r=Fp,randomizationFactor:n=Pp,multiplier:i=Up,maxInterval:s=Cp,maxElapsedTime:o=Mp,maxIterations:a=qp,date:c=Date}=t;Hr(this,Kr,r,"f"),Hr(this,Fa,n,"f"),Hr(this,Ca,i,"f"),Hr(this,Ma,s,"f"),Hr(this,Va,c,"f"),Hr(this,qa,c.now(),"f"),Hr(this,ja,o,"f"),Hr(this,ka,a,"f")}get ellapsedTimeInMsec(){return Bt(this,Va,"f").now()-Bt(this,qa,"f")}get currentInterval(){return Bt(this,Kr,"f")}get count(){return Bt(this,Pi,"f")}get randomValueFromInterval(){let t=Bt(this,Fa,"f")*Bt(this,Kr,"f"),r=Bt(this,Kr,"f")-t,n=Bt(this,Kr,"f")+t;return Math.random()*(n-r)+r}incrementCurrentInterval(){var t;return Hr(this,Kr,Math.min(Bt(this,Kr,"f")*Bt(this,Ca,"f"),Bt(this,Ma,"f")),"f"),Hr(this,Pi,(t=Bt(this,Pi,"f"),t++,t),"f"),Bt(this,Kr,"f")}next(){return this.ellapsedTimeInMsec>=Bt(this,ja,"f")||Bt(this,Pi,"f")>=Bt(this,ka,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};$r.ExponentialBackoff=Ui;Kr=new WeakMap,Fa=new WeakMap,Ca=new WeakMap,Ma=new WeakMap,qa=new WeakMap,ja=new WeakMap,ka=new WeakMap,Va=new WeakMap,Pi=new WeakMap;Ui.default={initialInterval:Fp,randomizationFactor:Pp,multiplier:Up,maxInterval:Cp,maxElapsedTime:Mp,maxIterations:qp,date:Date};function*G2(e=Ui.default){let t=new Ui(e),r=t.next();for(;r;)yield r,r=t.next()}$r.exponentialBackoff=G2});var Zl=ee(qe=>{"use strict";var Vp=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]}),Y2=qe&&qe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Hp=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)&&Vp(t,e,r);return Y2(t,e),t},Kp=qe&&qe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Vp(t,e,r)},xt=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)},Pt,Xn,ki,Gr,on,ji,Us,Ci,Tr,Or,Qn,In,Fs,Mi,qi,Dn,ei,$p,$a,Ga,Ln;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=Mt(),Yr=_i(),kp=Ku(),Pn=Hp(_s()),Ha=fs(),xr=Yt(),vr=Do(),Wl=ys(),Vi=ea(),z2=As(),Fi=Si(),W2=Hl(),J2=Sp(),Z2=Gl(),X2=_a(),Q2=zl(),I2=jp();Kp(Do(),qe);Kp(ea(),qe);var D2=ys();Object.defineProperty(qe,"makeNonce",{enumerable:!0,get:function(){return D2.makeNonce}});var L2;(function(e){e.Received="received",e.Processing="processing",e.Replied="replied",e.Rejected="rejected",e.Unknown="unknown",e.Done="done"})(L2=qe.RequestStatusResponseStatus||(qe.RequestStatusResponseStatus={}));var Ka=60*1e3;qe.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";qe.MANAGEMENT_CANISTER_ID="aaaaa-aa";var eE="ic0.app",tE=".ic0.app",rE="icp0.io",nE=".icp0.io",iE="icp-api.io",sE=".icp-api.io",Cs=class extends Yr.AgentError{constructor(t){super(t),this.message=t}},ti=class extends Yr.AgentError{constructor(t){super(t),this.message=t}};qe.IdentityInvalidError=ti;function oE(){let e;if(typeof window<"u")if(window.fetch)e=window.fetch.bind(window);else throw new Cs("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 Cs("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 Cs("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function aE(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,o;s&&typeof s=="string"&&(n.some(a=>s.endsWith(a))?o=s:o=r.find(a=>s.endsWith(a))),i&&o?t=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):t=new URL("https://icp-api.io")}return t.toString()}var Jl=class e{constructor(t={}){var r,n;Pt.add(this),Xn.set(this,null),ki.set(this,!1),Gr.set(this,void 0),on.set(this,void 0),ji.set(this,void 0),Us.set(this,void 0),Ci.set(this,0),Tr.set(this,void 0),Or.set(this,void 0),Qn.set(this,void 0),In.set(this,void 0),this._isAgent=!0,this.config={},Fs.set(this,0),this.log=new Q2.ObservableLog,Mi.set(this,[]),qi.set(this,[]),Dn.set(this,new J2.ExpirableMap({expirationTime:300*1e3})),ei.set(this,!0),Ga.set(this,(o,a)=>{if(ie(this,ei,"f")===!1)return o;if(!a)throw new Fi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:c,signatures:d=[],requestId:f}=o,h=new TextEncoder().encode("\vic-response");for(let m of d){let{timestamp:b,identity:l}=m,S=cr.Principal.fromUint8Array(l).toText(),N;if(c==="replied"){let{reply:E}=o;N=(0,Ha.hashOfMap)({status:c,reply:E,timestamp:BigInt(b),request_id:f})}else if(c==="rejected"){let{reject_code:E,reject_message:j,error_code:Y}=o;N=(0,Ha.hashOfMap)({status:c,reject_code:E,reject_message:j,error_code:Y,timestamp:BigInt(b),request_id:f})}else throw new Error(`Unknown status: ${c}`);let F=(0,xr.concat)(h,new Uint8Array(N)),q=a?.nodeKeys.get(S);if(!q)throw new Fi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let O=Z2.Ed25519PublicKey.fromDer(q).rawKey;if(W2.ed25519.verify(m.signature,new Uint8Array(F),new Uint8Array(O)))return o;throw new Fi.CertificateVerificationError(`Invalid signature from replica ${S} signed query.`)}return o}),this.config=t,xt(this,on,t.fetch||oE()||fetch.bind(global),"f"),xt(this,ji,t.fetchOptions,"f"),xt(this,Us,t.callOptions,"f"),xt(this,ki,(r=t.shouldFetchRootKey)!==null&&r!==void 0?r:!1,"f"),t.rootKey?this.rootKey=t.rootKey:ie(this,ki,"f")?this.rootKey=null:this.rootKey=(0,xr.fromHex)(qe.IC_ROOT_KEY);let i=aE(t.host);this.host=new URL(i),t.verifyQuerySignatures!==void 0&&xt(this,ei,t.verifyQuerySignatures,"f"),xt(this,Or,(n=t.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new I2.ExponentialBackoff({maxIterations:ie(this,Or,"f")});if(xt(this,Qn,t.backoffStrategy||s,"f"),this.host.hostname.endsWith(tE)?this.host.hostname=eE:this.host.hostname.endsWith(nE)?this.host.hostname=rE:this.host.hostname.endsWith(sE)&&(this.host.hostname=iE),t.credentials){let{name:o,password:a}=t.credentials;xt(this,Tr,`${o}${a?":"+a:""}`,"f")}if(xt(this,Gr,Promise.resolve(t.identity||new kp.AnonymousIdentity),"f"),t.ingressExpiryInMinutes&&t.ingressExpiryInMinutes>5)throw new Yr.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 Yr.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${t.ingressExpiryInMinutes} minutes.`);xt(this,In,t.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,vr.makeNonceTransform)(Wl.makeNonce)),t.useQueryNonces&&this.addTransform("query",(0,vr.makeNonceTransform)(Wl.makeNonce)),t.logToConsole&&this.log.subscribe(o=>{o.level==="error"?console.error(o.message):o.level==="warn"?console.warn(o.message):console.log(o.message)})}get waterMark(){return ie(this,Fs,"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 Yr.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,qi,"f").findIndex(s=>(s.priority||0)<n);ie(this,qi,"f").splice(i>=0?i:ie(this,qi,"f").length,0,Object.assign(r,{priority:n}))}else if(t==="query"){let i=ie(this,Mi,"f").findIndex(s=>(s.priority||0)<n);ie(this,Mi,"f").splice(i>=0?i:ie(this,Mi,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ie(this,Gr,"f"))throw new ti("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ie(this,Gr,"f")).getPrincipal()}async call(t,r,n){var i,s;await ie(this,Pt,"m",Ln).call(this);let o=(i=r.callSync)!==null&&i!==void 0?i:!0,a=await(n!==void 0?await n:await ie(this,Gr,"f"));if(!a)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=a.getPrincipal()||cr.Principal.anonymous(),h=new vr.Expiry(ie(this,In,"f")*Ka);Math.abs(ie(this,Ci,"f"))>1e3*30&&(h=new vr.Expiry(ie(this,In,"f")*Ka+ie(this,Ci,"f")));let m={request_type:Wl.SubmitRequestType.Call,canister_id:c,method_name:r.methodName,arg:r.arg,sender:f,ingress_expiry:h},b=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,Tr,"f")?{Authorization:"Basic "+btoa(ie(this,Tr,"f"))}:{})},endpoint:"call",body:m}),l=b.body.nonce?S(b.body.nonce):void 0;m.nonce=l;function S(O){return new Uint8Array(O)}b=await a.transformRequest(b);let N=Pn.encode(b.body),F=ie(this,Qn,"f").call(this),q=(0,Ha.requestIdOf)(m);try{let O=()=>(this.log.print(`fetching "/api/v3/canister/${d.toText()}/call" with request:`,b),ie(this,on,"f").call(this,""+new URL(`/api/v3/canister/${d.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Us,"f")),b.request),{body:N}))),G=()=>(this.log.print(`fetching "/api/v2/canister/${d.toText()}/call" with request:`,b),ie(this,on,"f").call(this,""+new URL(`/api/v2/canister/${d.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Us,"f")),b.request),{body:N}))),j=await ie(this,Pt,"m",$a).call(this,{request:o?O:G,backoff:F,tries:0}),Y=await j.arrayBuffer(),z=j.status===200&&Y.byteLength>0?Pn.decode(Y):null;if(z&&"certificate"in z){let k=await this.parseTimeFromResponse({certificate:z.certificate});xt(this,Fs,k,"f")}return{requestId:q,response:{ok:j.ok,status:j.status,statusText:j.statusText,body:z,headers:(0,vr.httpHeadersTransform)(j.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 G=`Error while making call: ${(s=O.message)!==null&&s!==void 0?s:String(O)}`,E=new Vi.AgentCallError(G,O,(0,xr.toHex)(q),(0,xr.toHex)(b.body.sender_pubkey),(0,xr.toHex)(b.body.sender_sig),String(b.body.content.ingress_expiry._value));throw this.log.error(G,E),E}}async query(t,r,n){var i,s,o,a;await ie(this,Pt,"m",Ln).call(this);let c=ie(this,Qn,"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,h,m=await(n!==void 0?n:ie(this,Gr,"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(),S={request_type:"query",canister_id:b,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:new vr.Expiry(ie(this,In,"f")*Ka)},N=(0,Ha.requestIdOf)(S);f=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,Tr,"f")?{Authorization:"Basic "+btoa(ie(this,Tr,"f"))}:{})},endpoint:"read",body:S}),f=await m?.transformRequest(f);let F=Pn.encode(f.body),q={canister:b.toText(),ecid:d,transformedRequest:f,body:F,requestId:N,backoff:c,tries:0},O=async()=>({requestDetails:S,query:await ie(this,Pt,"m",$p).call(this,q)}),G=async()=>{if(!ie(this,ei,"f"))return;let E=ie(this,Dn,"f").get(d.toString());return E||(await this.fetchSubnetKeys(d.toString()),ie(this,Dn,"f").get(d.toString()))};try{let[E,j]=await Promise.all([O(),G()]);h=E;let{requestDetails:Y,query:z}=h,k=Object.assign(Object.assign({},z),{requestDetails:Y});if(this.log.print("Query response:",k),!ie(this,ei,"f"))return k;try{return ie(this,Ga,"f").call(this,k,j)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ie(this,Dn,"f").delete(t.toString()),await this.fetchSubnetKeys(d.toString());let L=ie(this,Dn,"f").get(t.toString());if(!L)throw new Fi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ie(this,Ga,"f").call(this,k,L)}}catch(E){let j=`Error while making call: ${(i=E.message)!==null&&i!==void 0?i:String(E)}`,Y=new Vi.AgentQueryError(j,E,String(N),(0,xr.toHex)((s=f?.body)===null||s===void 0?void 0:s.sender_pubkey),(0,xr.toHex)((o=f?.body)===null||o===void 0?void 0:o.sender_sig),String((a=f?.body)===null||a===void 0?void 0:a.content.ingress_expiry._value));throw this.log.error(j,Y),Y}}async createReadStateRequest(t,r){await ie(this,Pt,"m",Ln).call(this);let n=await(r!==void 0?await r:await ie(this,Gr,"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,Tr,"f")?{Authorization:"Basic "+btoa(ie(this,Tr,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:t.paths,sender:i,ingress_expiry:new vr.Expiry(ie(this,In,"f")*Ka)}});return n?.transformRequest(s)}async readState(t,r,n,i){var s,o,a,c;function d(S){for(let N of S.paths){let[F,q]=N,O=new TextEncoder().encode("request_status");if((0,xr.bufEquals)(F,O))return q}}let f=d(r);await ie(this,Pt,"m",Ln).call(this);let h=typeof t=="string"?cr.Principal.fromText(t):t,m=i??await this.createReadStateRequest(r,n),b=Pn.encode(m.body);this.log.print(`fetching "/api/v2/canister/${h}/read_state" with request:`,m);let l=ie(this,Qn,"f").call(this);try{let S=await ie(this,Pt,"m",$a).call(this,{request:()=>ie(this,on,"f").call(this,""+new URL(`/api/v2/canister/${h.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,ji,"f")),m.request),{body:b})),backoff:l,tries:0});if(!S.ok)throw new Error(`Server returned an error:
31
31
  Code: ${S.status} (${S.statusText})
32
32
  Body: ${await S.text()}
33
- `);let A=Pn.decode(await S.arrayBuffer());this.log.print("Read state response:",A);let F=await this.parseTimeFromResponse(A);return F>0&&(this.log.print("Read state response time:",F),xt(this,Fs,F,"f")),A}catch(S){let A=`Caught exception while attempting to read state: ${(s=S.message)!==null&&s!==void 0?s:String(S)}`,F=new Vi.AgentReadStateError(A,S,String(f),(0,br.toHex)((o=m?.body)===null||o===void 0?void 0:o.sender_pubkey),(0,br.toHex)((a=m?.body)===null||a===void 0?void 0:a.sender_sig),String((c=m?.body)===null||c===void 0?void 0:c.content.ingress_expiry._value));throw this.log.error(A,F),F}}async parseTimeFromResponse(t){let r;if(t.certificate){let n=Pn.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,X2.decodeTime)((0,br.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 ne(this,Pt,"m",Ln).call(this);let r=await Promise.resolve().then(()=>Hp(Ns())),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 kp.AnonymousIdentity,host:this.host.toString(),fetch:ne(this,on,"f"),retryTimes:0}),o=(await r.request({canisterId:t??sr.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:i,paths:["time"]})).get("time");o&&(xt(this,Ci,Number(o)-Number(n),"f"),this.log.notify({message:`Syncing time: offset of ${ne(this,Ci,"f")}`,level:"info"}))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let t=ne(this,wr,"f")?{Authorization:"Basic "+btoa(ne(this,wr,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ne(this,Qn,"f").call(this),n=await ne(this,Pt,"m",$a).call(this,{backoff:r,request:()=>ne(this,on,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:t},ne(this,ji,"f"))),tries:0});return Pn.decode(await n.arrayBuffer())}async fetchRootKey(){let t;return ne(this,Xn,"f")?t=await ne(this,Xn,"f"):(xt(this,Xn,new Promise((r,n)=>{this.status().then(i=>{let s=i.root_key;this.rootKey=s,r(s)}).catch(n)}),"f"),t=await ne(this,Xn,"f")),xt(this,Xn,null,"f"),t}invalidateIdentity(){xt(this,Kr,null,"f")}replaceIdentity(t){xt(this,Kr,Promise.resolve(t),"f")}async fetchSubnetKeys(t){await ne(this,Pt,"m",Ln).call(this);let r=sr.Principal.from(t),i=(await(0,W2.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ne(this,Dn,"f").set(r.toText(),i),i}_transform(t){let r=Promise.resolve(t);if(t.endpoint==="call")for(let n of ne(this,qi,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ne(this,Mi,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};qe.HttpAgent=Jl;Xn=new WeakMap,ki=new WeakMap,Kr=new WeakMap,on=new WeakMap,ji=new WeakMap,Us=new WeakMap,Ci=new WeakMap,wr=new WeakMap,Er=new WeakMap,Qn=new WeakMap,In=new WeakMap,Fs=new WeakMap,Mi=new WeakMap,qi=new WeakMap,Dn=new WeakMap,ei=new WeakMap,Ga=new WeakMap,Pt=new WeakSet,$p=async function e(t){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,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 $r.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,Er,"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 h;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let l=await ne(this,on,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,ji,"f")),s.request),{body:o}));if(l.status===200){let S=Pn.decode(await l.arrayBuffer());h=Object.assign(Object.assign({},S),{httpDetails:{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,xr.httpHeadersTransform)(l.headers)},requestId:a})}else throw new Vi.AgentHTTPResponseError(`Gateway returned an error:
33
+ `);let N=Pn.decode(await S.arrayBuffer());this.log.print("Read state response:",N);let F=await this.parseTimeFromResponse(N);return F>0&&(this.log.print("Read state response time:",F),xt(this,Fs,F,"f")),N}catch(S){let N=`Caught exception while attempting to read state: ${(s=S.message)!==null&&s!==void 0?s:String(S)}`,F=new Vi.AgentReadStateError(N,S,String(f),(0,xr.toHex)((o=m?.body)===null||o===void 0?void 0:o.sender_pubkey),(0,xr.toHex)((a=m?.body)===null||a===void 0?void 0:a.sender_sig),String((c=m?.body)===null||c===void 0?void 0:c.content.ingress_expiry._value));throw this.log.error(N,F),F}}async parseTimeFromResponse(t){let r;if(t.certificate){let n=Pn.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,X2.decodeTime)((0,xr.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,Pt,"m",Ln).call(this);let r=await Promise.resolve().then(()=>Hp(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 kp.AnonymousIdentity,host:this.host.toString(),fetch:ie(this,on,"f"),retryTimes:0}),o=(await r.request({canisterId:t??cr.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:i,paths:["time"]})).get("time");o&&(xt(this,Ci,Number(o)-Number(n),"f"),this.log.notify({message:`Syncing time: offset of ${ie(this,Ci,"f")}`,level:"info"}))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let t=ie(this,Tr,"f")?{Authorization:"Basic "+btoa(ie(this,Tr,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ie(this,Qn,"f").call(this),n=await ie(this,Pt,"m",$a).call(this,{backoff:r,request:()=>ie(this,on,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:t},ie(this,ji,"f"))),tries:0});return Pn.decode(await n.arrayBuffer())}async fetchRootKey(){let t;return ie(this,Xn,"f")?t=await ie(this,Xn,"f"):(xt(this,Xn,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,Xn,"f")),xt(this,Xn,null,"f"),t}invalidateIdentity(){xt(this,Gr,null,"f")}replaceIdentity(t){xt(this,Gr,Promise.resolve(t),"f")}async fetchSubnetKeys(t){await ie(this,Pt,"m",Ln).call(this);let r=cr.Principal.from(t),i=(await(0,z2.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ie(this,Dn,"f").set(r.toText(),i),i}_transform(t){let r=Promise.resolve(t);if(t.endpoint==="call")for(let n of ie(this,qi,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ie(this,Mi,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};qe.HttpAgent=Jl;Xn=new WeakMap,ki=new WeakMap,Gr=new WeakMap,on=new WeakMap,ji=new WeakMap,Us=new WeakMap,Ci=new WeakMap,Tr=new WeakMap,Or=new WeakMap,Qn=new WeakMap,In=new WeakMap,Fs=new WeakMap,Mi=new WeakMap,qi=new WeakMap,Dn=new WeakMap,ei=new WeakMap,Ga=new WeakMap,Pt=new WeakSet,$p=async function e(t){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,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 Yr.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 h;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let l=await ie(this,on,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,ji,"f")),s.request),{body:o}));if(l.status===200){let S=Pn.decode(await l.arrayBuffer());h=Object.assign(Object.assign({},S),{httpDetails:{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,vr.httpHeadersTransform)(l.headers)},requestId:a})}else throw new Vi.AgentHTTPResponseError(`Gateway returned an error:
34
34
  Code: ${l.status} (${l.statusText})
35
35
  Body: ${await l.text()}
36
- `,{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,xr.httpHeadersTransform)(l.headers)})}catch(l){if(d<ne(this,Er,"f"))return this.log.warn(`Caught exception while attempting to make query:
36
+ `,{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,vr.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 ne(this,Pt,"m",e).call(this,Object.assign(Object.assign({},t),{tries:d+1}));throw l}let m=(n=(r=h.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ne(this,ei,"f"))return h;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 $r.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",l,{timestamp:m,waterMark:this.waterMark}),d<ne(this,Er,"f"))return await ne(this,Pt,"m",e).call(this,Object.assign(Object.assign({},t),{tries:d+1}));throw new $r.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,Er,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return h},$a=async function e(t){let{request:r,backoff:n,tries:i}=t,s=i===0?0:n.next();if(s===null)throw new $r.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,Er,"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 o;try{o=await r()}catch(d){if(ne(this,Er,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
38
+ Retrying query.`),await ie(this,Pt,"m",e).call(this,Object.assign(Object.assign({},t),{tries:d+1}));throw l}let m=(n=(r=h.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ie(this,ei,"f"))return h;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 Yr.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,Pt,"m",e).call(this,Object.assign(Object.assign({},t),{tries:d+1}));throw new Yr.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 h},$a=async function e(t){let{request:r,backoff:n,tries:i}=t,s=i===0?0:n.next();if(s===null)throw new Yr.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 o;try{o=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 ne(this,Pt,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw d}if(o.ok)return o;let a=await o.clone().text(),c=`Server returned an error:
40
+ Retrying request.`),await ie(this,Pt,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw d}if(o.ok)return o;let a=await o.clone().text(),c=`Server returned an error:
41
41
  Code: ${o.status} (${o.statusText})
42
42
  Body: ${a}
43
- `;if(o.status===404&&o.url.includes("api/v3"))throw new Vi.AgentHTTPResponseError("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,xr.httpHeadersTransform)(o.headers)});if(i<ne(this,Er,"f"))return await ne(this,Pt,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw new Vi.AgentHTTPResponseError(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,xr.httpHeadersTransform)(o.headers)})},Ln=async function(){if(!this.rootKey)if(this.rootKey===null&&ne(this,ki,"f"))await this.fetchRootKey();else throw new $r.AgentError(`Invalid root key detected. The root key for this agent is ${this.rootKey} and the shouldFetchRootKey value is set to ${ne(this,ki,"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 Gp=ee(an=>{"use strict";Object.defineProperty(an,"__esModule",{value:!0});an.ProxyAgent=an.ProxyStubAgent=an.ProxyMessageKind=void 0;var cE=Ft(),De;(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"})(De=an.ProxyMessageKind||(an.ProxyMessageKind={}));var Xl=class{constructor(t,r){this._frontend=t,this._agent=r}onmessage(t){switch(t.type){case De.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:t.id,type:De.GetPrincipalResponse,response:r.toText()})});break;case De.Query:this._agent.query(...t.args).then(r=>{this._frontend({id:t.id,type:De.QueryResponse,response:r})});break;case De.Call:this._agent.call(...t.args).then(r=>{this._frontend({id:t.id,type:De.CallResponse,response:r})});break;case De.ReadState:this._agent.readState(...t.args).then(r=>{this._frontend({id:t.id,type:De.ReadStateResponse,response:r})});break;case De.Status:this._agent.status().then(r=>{this._frontend({id:t.id,type:De.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(t)}`)}}};an.ProxyStubAgent=Xl;var Ql=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 De.Error:return s(t.error);case De.GetPrincipalResponse:case De.CallResponse:case De.QueryResponse:case De.ReadStateResponse:case De.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:De.GetPrincipal}).then(t=>{if(typeof t!="string")throw new Error("Invalid principal received.");return cE.Principal.fromText(t)})}readState(t,r){return this._sendAndWait({id:this._nextId++,type:De.ReadState,args:[t.toString(),r]})}call(t,r){return this._sendAndWait({id:this._nextId++,type:De.Call,args:[t.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:De.Status})}query(t,r){return this._sendAndWait({id:this._nextId++,type:De.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}};an.ProxyAgent=Ql});var As=ee(or=>{"use strict";var uE=or&&or.__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]}),Ya=or&&or.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&uE(t,e,r)};Object.defineProperty(or,"__esModule",{value:!0});or.getDefaultAgent=void 0;Ya(Kc(),or);Ya(Zl(),or);Ya(ea(),or);Ya(Gp(),or);function lE(){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}or.getDefaultAgent=lE});var Wa=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 Yp=Kt(),dE=300*1e3;function fE(){return Xp(zp(Wp(),1e3),Zp(1e3,1.2),Jp(dE))}mt.defaultStrategy=fE;function Wp(){let e=!0;return async()=>e?(e=!1,!0):!1}mt.once=Wp;function zp(e,t){return async(r,n,i)=>{if(await e(r,n,i))return new Promise(s=>setTimeout(s,t))}}mt.conditionalDelay=zp;function hE(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:
43
+ `;if(o.status===404&&o.url.includes("api/v3"))throw new Vi.AgentHTTPResponseError("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,vr.httpHeadersTransform)(o.headers)});if(i<ie(this,Or,"f"))return await ie(this,Pt,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw new Vi.AgentHTTPResponseError(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,vr.httpHeadersTransform)(o.headers)})},Ln=async function(){if(!this.rootKey)if(this.rootKey===null&&ie(this,ki,"f"))await this.fetchRootKey();else throw new Yr.AgentError(`Invalid root key detected. The root key for this agent is ${this.rootKey} and the shouldFetchRootKey value is set to ${ie(this,ki,"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 Gp=ee(an=>{"use strict";Object.defineProperty(an,"__esModule",{value:!0});an.ProxyAgent=an.ProxyStubAgent=an.ProxyMessageKind=void 0;var cE=Mt(),De;(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"})(De=an.ProxyMessageKind||(an.ProxyMessageKind={}));var Xl=class{constructor(t,r){this._frontend=t,this._agent=r}onmessage(t){switch(t.type){case De.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:t.id,type:De.GetPrincipalResponse,response:r.toText()})});break;case De.Query:this._agent.query(...t.args).then(r=>{this._frontend({id:t.id,type:De.QueryResponse,response:r})});break;case De.Call:this._agent.call(...t.args).then(r=>{this._frontend({id:t.id,type:De.CallResponse,response:r})});break;case De.ReadState:this._agent.readState(...t.args).then(r=>{this._frontend({id:t.id,type:De.ReadStateResponse,response:r})});break;case De.Status:this._agent.status().then(r=>{this._frontend({id:t.id,type:De.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(t)}`)}}};an.ProxyStubAgent=Xl;var Ql=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 De.Error:return s(t.error);case De.GetPrincipalResponse:case De.CallResponse:case De.QueryResponse:case De.ReadStateResponse:case De.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:De.GetPrincipal}).then(t=>{if(typeof t!="string")throw new Error("Invalid principal received.");return cE.Principal.fromText(t)})}readState(t,r){return this._sendAndWait({id:this._nextId++,type:De.ReadState,args:[t.toString(),r]})}call(t,r){return this._sendAndWait({id:this._nextId++,type:De.Call,args:[t.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:De.Status})}query(t,r){return this._sendAndWait({id:this._nextId++,type:De.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}};an.ProxyAgent=Ql});var Ns=ee(ur=>{"use strict";var uE=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]}),Ya=ur&&ur.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&uE(t,e,r)};Object.defineProperty(ur,"__esModule",{value:!0});ur.getDefaultAgent=void 0;Ya(Kc(),ur);Ya(Zl(),ur);Ya(ea(),ur);Ya(Gp(),ur);function lE(){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=lE});var za=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 Yp=Yt(),dE=300*1e3;function fE(){return Xp(Wp(zp(),1e3),Zp(1e3,1.2),Jp(dE))}mt.defaultStrategy=fE;function zp(){let e=!0;return async()=>e?(e=!1,!0):!1}mt.once=zp;function Wp(e,t){return async(r,n,i)=>{if(await e(r,n,i))return new Promise(s=>setTimeout(s,t))}}mt.conditionalDelay=Wp;function hE(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
44
  Request ID: ${(0,Yp.toHex)(n)}
45
45
  Request status: ${i}
46
46
  `)}}mt.maxAttempts=hE;function pE(e){return()=>new Promise(t=>setTimeout(t,e))}mt.throttle=pE;function Jp(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
47
  Request ID: ${(0,Yp.toHex)(n)}
48
48
  Request status: ${i}
49
- `)}}mt.timeout=Jp;function Zp(e,t){let r=e;return()=>new Promise(n=>setTimeout(()=>{r*=t,n()},r))}mt.backoff=Zp;function Xp(...e){return async(t,r,n)=>{for(let i of e)await i(t,r,n)}}mt.chain=Xp});var za=ee(zt=>{"use strict";var _E=zt&&zt.__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]}),yE=zt&&zt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),mE=zt&&zt.__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)&&_E(t,e,r);return yE(t,e),t};Object.defineProperty(zt,"__esModule",{value:!0});zt.pollForResponse=zt.defaultStrategy=zt.strategy=void 0;var ri=As(),Ms=Si(),Qp=Kt();zt.strategy=mE(Wa());var gE=Wa(),bE=Wa();Object.defineProperty(zt,"defaultStrategy",{enumerable:!0,get:function(){return bE.defaultStrategy}});async function Ip(e,t,r,n=(0,gE.defaultStrategy)(),i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=e.createReadStateRequest)===null||o===void 0?void 0:o.call(e,{paths:[a]})),d=await e.readState(t,{paths:[a]},void 0,c);if(e.rootKey==null)throw new Error("Agent root key not initialized before polling");let f=await Ms.Certificate.create({certificate:d.certificate,rootKey:e.rootKey,canisterId:t,blsVerify:s}),h=(0,Ms.lookupResultToBuffer)(f.lookup([...a,new TextEncoder().encode("status")])),m;switch(typeof h>"u"?m=ri.RequestStatusResponseStatus.Unknown:m=new TextDecoder().decode(h),m){case ri.RequestStatusResponseStatus.Replied:return{reply:(0,Ms.lookupResultToBuffer)(f.lookup([...a,"reply"])),certificate:f};case ri.RequestStatusResponseStatus.Received:case ri.RequestStatusResponseStatus.Unknown:case ri.RequestStatusResponseStatus.Processing:return await n(t,r,m),Ip(e,t,r,n,c,s);case ri.RequestStatusResponseStatus.Rejected:{let b=new Uint8Array((0,Ms.lookupResultToBuffer)(f.lookup([...a,"reject_code"])))[0],l=new TextDecoder().decode((0,Ms.lookupResultToBuffer)(f.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
49
+ `)}}mt.timeout=Jp;function Zp(e,t){let r=e;return()=>new Promise(n=>setTimeout(()=>{r*=t,n()},r))}mt.backoff=Zp;function Xp(...e){return async(t,r,n)=>{for(let i of e)await i(t,r,n)}}mt.chain=Xp});var Wa=ee(Xt=>{"use strict";var _E=Xt&&Xt.__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]}),yE=Xt&&Xt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),mE=Xt&&Xt.__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)&&_E(t,e,r);return yE(t,e),t};Object.defineProperty(Xt,"__esModule",{value:!0});Xt.pollForResponse=Xt.defaultStrategy=Xt.strategy=void 0;var ri=Ns(),Ms=Si(),Qp=Yt();Xt.strategy=mE(za());var gE=za(),bE=za();Object.defineProperty(Xt,"defaultStrategy",{enumerable:!0,get:function(){return bE.defaultStrategy}});async function Ip(e,t,r,n=(0,gE.defaultStrategy)(),i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=e.createReadStateRequest)===null||o===void 0?void 0:o.call(e,{paths:[a]})),d=await e.readState(t,{paths:[a]},void 0,c);if(e.rootKey==null)throw new Error("Agent root key not initialized before polling");let f=await Ms.Certificate.create({certificate:d.certificate,rootKey:e.rootKey,canisterId:t,blsVerify:s}),h=(0,Ms.lookupResultToBuffer)(f.lookup([...a,new TextEncoder().encode("status")])),m;switch(typeof h>"u"?m=ri.RequestStatusResponseStatus.Unknown:m=new TextDecoder().decode(h),m){case ri.RequestStatusResponseStatus.Replied:return{reply:(0,Ms.lookupResultToBuffer)(f.lookup([...a,"reply"])),certificate:f};case ri.RequestStatusResponseStatus.Received:case ri.RequestStatusResponseStatus.Unknown:case ri.RequestStatusResponseStatus.Processing:return await n(t,r,m),Ip(e,t,r,n,c,s);case ri.RequestStatusResponseStatus.Rejected:{let b=new Uint8Array((0,Ms.lookupResultToBuffer)(f.lookup([...a,"reject_code"])))[0],l=new TextDecoder().decode((0,Ms.lookupResultToBuffer)(f.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
50
50
  Request ID: ${(0,Qp.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
54
  Request ID: ${(0,Qp.toHex)(r)}
55
- `)}throw new Error("unreachable")}zt.pollForResponse=Ip});var Dp=ee(Il=>{"use strict";Object.defineProperty(Il,"__esModule",{value:!0});Il.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,o=e.Nat32,a=e.Record({start_height:o,end_height:e.Opt(o),network:t}),c=e.Vec(e.Nat8),d=e.Record({tip_height:o,block_headers:e.Vec(c)}),f=e.Record({network:t}),h=e.Nat64,m=e.Vec(h),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),S=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),A=e.Record({height:e.Nat32,value:i,outpoint:S}),F=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:o,tip_block_hash:l,utxos:e.Vec(A)}),q=e.Record({transaction:e.Vec(e.Nat8),network:t}),v=e.Principal,G=e.Record({canister_id:v,num_requested_changes:e.Opt(e.Nat64)}),E=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),j=e.Vec(e.Nat8),Y=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:j}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),Z=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:E,details:Y}),k=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(Z),total_num_changes:e.Nat64}),ae=e.Record({canister_id:v}),D=e.Variant({controllers:e.Null,public:e.Null,allowed_viewers:e.Vec(e.Principal)}),se=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:D,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:se,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:v}),R=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(D),wasm_memory_limit:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),N=e.Record({settings:e.Opt(R),sender_canister_version:e.Opt(e.Nat64)}),B=e.Record({canister_id:v}),H=e.Record({canister_id:v}),X=e.Record({canister_id:v,snapshot_id:j}),ie=e.Record({canister_id:v}),oe=e.Variant({secp256k1:e.Null}),W=e.Record({key_id:e.Record({name:e.Text,curve:oe}),canister_id:e.Opt(v),derivation_path:e.Vec(e.Vec(e.Nat8))}),M=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),p=e.Record({canister_id:v}),L=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),re=e.Record({canister_log_records:e.Vec(L)}),le=e.Record({value:e.Text,name:e.Text}),I=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:I})],[I],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(le)}),_=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)}),U=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:_,chunk_hashes_list:e.Vec(y),target_canister:v,store_canister:e.Opt(v),sender_canister_version:e.Opt(e.Nat64)}),O=e.Vec(e.Nat8),P=e.Record({arg:e.Vec(e.Nat8),wasm_module:O,mode:_,canister_id:v,sender_canister_version:e.Opt(e.Nat64)}),K=e.Record({canister_id:v}),x=e.Record({id:j,total_size:e.Nat64,taken_at_timestamp:e.Nat64}),C=e.Vec(x),$=e.Record({canister_id:v,sender_canister_version:e.Opt(e.Nat64),snapshot_id:j}),V=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),Q=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(Q)})),de=e.Record({settings:e.Opt(R),specified_id:e.Opt(v),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),ge=e.Record({canister_id:v}),Oe=e.Record({canister_id:v,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(v),derivation_path:e.Vec(e.Vec(e.Nat8))}),Qe=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),vr=e.Record({key_id:e.Record({name:e.Text,curve:oe}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),Xr=e.Record({signature:e.Vec(e.Nat8)}),Qr=e.Variant({bip341:e.Record({merkle_root_hash:e.Vec(e.Nat8)})}),Vt=e.Record({aux:e.Opt(Qr),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)}),vt=e.Record({canister_id:v}),ot=e.Record({canister_id:v}),$e=e.Record({canister_id:v}),Tc=e.Vec(y),vc=e.Record({subnet_id:e.Principal}),Ge=e.Record({replica_version:e.Text}),Oc=e.Record({replace_snapshot:e.Opt(j),canister_id:v}),Ac=x,Nc=e.Record({canister_id:v,sender_canister_version:e.Opt(e.Nat64)}),Sc=e.Record({canister_id:e.Principal,settings:R,sender_canister_version:e.Opt(e.Nat64)}),Rc=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([a],[d],[]),bitcoin_get_current_fee_percentiles:e.Func([f],[m],[]),bitcoin_get_utxos:e.Func([b],[F],[]),bitcoin_send_transaction:e.Func([q],[],[]),canister_info:e.Func([G],[k],[]),canister_status:e.Func([ae],[w],[]),clear_chunk_store:e.Func([g],[],[]),create_canister:e.Func([N],[B],[]),delete_canister:e.Func([H],[],[]),delete_canister_snapshot:e.Func([X],[],[]),deposit_cycles:e.Func([ie],[],[]),ecdsa_public_key:e.Func([W],[M],[]),fetch_canister_logs:e.Func([p],[re],["query"]),http_request:e.Func([u],[I],[]),install_chunked_code:e.Func([U],[],[]),install_code:e.Func([P],[],[]),list_canister_snapshots:e.Func([K],[C],[]),load_canister_snapshot:e.Func([$],[],[]),node_metrics_history:e.Func([V],[te],[]),provisional_create_canister_with_cycles:e.Func([de],[ge],[]),provisional_top_up_canister:e.Func([Oe],[],[]),raw_rand:e.Func([],[Fe],[]),schnorr_public_key:e.Func([fe],[Qe],[]),sign_with_ecdsa:e.Func([vr],[Xr],[]),sign_with_schnorr:e.Func([Vt],[Be],[]),start_canister:e.Func([vt],[],[]),stop_canister:e.Func([ot],[],[]),stored_chunks:e.Func([$e],[Tc],[]),subnet_info:e.Func([vc],[Ge],[]),take_canister_snapshot:e.Func([Oc],[Ac],[]),uninstall_code:e.Func([Nc],[],[]),update_settings:e.Func([Sc],[],[]),upload_chunk:e.Func([Rc],[cn],[])})}});var Za=ee(ze=>{"use strict";var wE=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 EE=xf(),Dl=As(),Ll=_i(),qs=xi(),Lp=za(),cr=Ft(),xE=Kt(),Hi=Si(),TE=wE(Dp()),js=class extends Ll.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=js;var Ja=class extends js{constructor(t,r,n){var i;super(t,r,"query",{Status:n.status,Code:(i=Dl.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};ze.QueryCallRejectedError=Ja;var ks=class extends js{constructor(t,r,n,i,s,o,a){super(t,r,"update",Object.assign({"Request ID":(0,xE.toHex)(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(s),"Reject message":o}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=o,this.error_code=a}};ze.UpdateCallRejectedError=ks;var ar=Symbol.for("ic-agent-metadata"),Vs=class e{constructor(t){this[ar]=Object.freeze(t)}static agentOf(t){return t[ar].config.agent}static interfaceOf(t){return t[ar].service}static canisterIdOf(t){return cr.Principal.from(t[ar].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)],o=typeof r.canisterId=="string"?cr.Principal.fromText(r.canisterId):r.canisterId;await ed(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,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(o){if(!o.canisterId)throw new Ll.AgentError(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?cr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},e_),o),{canisterId:a}),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]=vE(this,c,d,o.blsVerify)}}return i}static createActor(t,r){if(!r.canisterId)throw new Ll.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=Vs;function Ki(e,t){let r=qs.IDL.decode(e,EE.Buffer.from(t));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var e_={pollingStrategyFactory:Lp.strategy.defaultStrategy};ze.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";ze.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function vE(e,t,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,d;o=Object.assign(Object.assign({},o),(d=(c=e[ar].config).queryTransform)===null||d===void 0?void 0:d.call(c,t,a,Object.assign(Object.assign({},e[ar].config),o)));let f=o.agent||e[ar].config.agent||(0,Dl.getDefaultAgent)(),h=cr.Principal.from(o.canisterId||e[ar].config.canisterId),m=qs.IDL.encode(r.argTypes,a),b=await f.query(h,{methodName:t,arg:m,effectiveCanisterId:o.effectiveCanisterId}),l=Object.assign(Object.assign({},b.httpDetails),{requestDetails:b.requestDetails});switch(b.status){case"rejected":throw new Ja(h,t,b);case"replied":return r.annotations.includes(ze.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:l,result:Ki(r.retTypes,b.reply.arg)}:Ki(r.retTypes,b.reply.arg)}}:i=async(o,...a)=>{var c,d;o=Object.assign(Object.assign({},o),(d=(c=e[ar].config).callTransform)===null||d===void 0?void 0:d.call(c,t,a,Object.assign(Object.assign({},e[ar].config),o)));let f=o.agent||e[ar].config.agent||(0,Dl.getDefaultAgent)(),{canisterId:h,effectiveCanisterId:m,pollingStrategyFactory:b}=Object.assign(Object.assign(Object.assign({},e_),e[ar].config),o),l=cr.Principal.from(h),S=m!==void 0?cr.Principal.from(m):l,A=qs.IDL.encode(r.argTypes,a),{requestId:F,response:q,requestDetails:v}=await f.call(l,{methodName:t,arg:A,effectiveCanisterId:S}),G,E;if(q.body&&q.body.certificate){if(f.rootKey==null)throw new Error("Agent is missing root key");let k=q.body.certificate;E=await Hi.Certificate.create({certificate:(0,qs.bufFromBufLike)(k),rootKey:f.rootKey,canisterId:cr.Principal.from(h),blsVerify:n});let ae=[new TextEncoder().encode("request_status"),F];switch(new TextDecoder().decode((0,Hi.lookupResultToBuffer)(E.lookup([...ae,"status"])))){case"replied":G=(0,Hi.lookupResultToBuffer)(E.lookup([...ae,"reply"]));break;case"rejected":{let se=new Uint8Array((0,Hi.lookupResultToBuffer)(E.lookup([...ae,"reject_code"])))[0],w=new TextDecoder().decode((0,Hi.lookupResultToBuffer)(E.lookup([...ae,"reject_message"]))),g=(0,Hi.lookupResultToBuffer)(E.lookup([...ae,"error_code"])),R=g?new TextDecoder().decode(g):void 0;throw new ks(l,t,F,q,se,w,R)}}}else if(q.body&&"reject_message"in q.body){let{reject_code:k,reject_message:ae,error_code:D}=q.body;throw new ks(l,t,F,q,k,ae,D)}if(q.status===202){let k=b(),ae=await(0,Lp.pollForResponse)(f,S,F,k,n);E=ae.certificate,G=ae.reply}let j=r.annotations.includes(ze.ACTOR_METHOD_WITH_HTTP_DETAILS),Y=r.annotations.includes(ze.ACTOR_METHOD_WITH_CERTIFICATE),Z=Object.assign(Object.assign({},q),{requestDetails:v});if(G!==void 0)return j&&Y?{httpDetails:Z,certificate:E,result:Ki(r.retTypes,G)}:Y?{certificate:E,result:Ki(r.retTypes,G)}:j?{httpDetails:Z,result:Ki(r.retTypes,G)}:Ki(r.retTypes,G);if(r.retTypes.length===0)return j?{httpDetails:q,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),s}function ed(e){function t(r,n){if(e.effectiveCanisterId)return{effectiveCanisterId:cr.Principal.from(e.effectiveCanisterId)};let i=n[0],s=cr.Principal.fromHex("");return i&&typeof i=="object"&&i.target_canister&&r==="install_chunked_code"&&(s=cr.Principal.from(i.target_canister)),i&&typeof i=="object"&&i.canister_id&&(s=cr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return Vs.createActor(TE.default,Object.assign(Object.assign(Object.assign({},e),{canisterId:cr.Principal.fromHex("")}),{callTransform:t,queryTransform:t}))}ze.getManagementCanister=ed;var td=class extends Vs{constructor(t){super(t)}};ze.AdvancedActor=td});var t_=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 r_=ee($i=>{"use strict";var OE=$i&&$i.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty($i,"__esModule",{value:!0});$i.createAssetCanisterActor=void 0;var AE=Za(),NE=OE(t_());function SE(e){return AE.Actor.createActor(NE.default,e)}$i.createAssetCanisterActor=SE});var n_=ee(Gr=>{"use strict";var RE=Gr&&Gr.__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]}),BE=Gr&&Gr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),PE=Gr&&Gr.__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)&&RE(t,e,r);return BE(t,e),t};Object.defineProperty(Gr,"__esModule",{value:!0});Gr.fetchCandid=void 0;var UE=Ft(),FE=PE(Ns()),CE=Zl(),ME=Za();async function qE(e,t){t||(t=await CE.HttpAgent.create());let n=(await FE.request({agent:t,canisterId:UE.Principal.fromText(e),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:o})=>o.Service({__get_candid_interface_tmp_hack:o.Func([],[o.Text],["query"])});return await ME.Actor.createActor(i,{agent:t,canisterId:e}).__get_candid_interface_tmp_hack()}Gr.fetchCandid=qE});var Dt=ee(Pe=>{"use strict";var i_=Pe&&Pe.__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]}),jE=Pe&&Pe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ut=Pe&&Pe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&i_(t,e,r)},nd=Pe&&Pe.__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)&&i_(t,e,r);return jE(t,e),t};Object.defineProperty(Pe,"__esModule",{value:!0});Pe.Cbor=Pe.CanisterStatus=Pe.polling=void 0;Ut(Za(),Pe);Ut(As(),Pe);Ut(Do(),Pe);Ut(ys(),Pe);Ut(Ku(),Pe);Ut(r_(),Pe);Ut(Si(),Pe);Ut($l(),Pe);Ut(n_(),Pe);Ut(Wl(),Pe);Ut(Gl(),Pe);Ut(fs(),Pe);Ut(El(),Pe);Ut(Kt(),Pe);Ut(Qu(),Pe);Pe.polling=nd(za());Pe.CanisterStatus=nd(Ns());Pe.Cbor=nd(_s());Ut(za(),Pe)});var nt=ee((Ev,T_)=>{"use strict";var cd=Object.defineProperty,kE=Object.getOwnPropertyDescriptor,VE=Object.getOwnPropertyNames,HE=Object.prototype.hasOwnProperty,KE=(e,t)=>{for(var r in t)cd(e,r,{get:t[r],enumerable:!0})},$E=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of VE(t))!HE.call(e,i)&&i!==r&&cd(e,i,{get:()=>t[i],enumerable:!(n=kE(t,i))||n.enumerable});return e},GE=e=>$E(cd({},"__esModule",{value:!0}),e),c_={};KE(c_,{AgentManager:()=>LE,Canister:()=>QE,FromStringToTokenError:()=>u_,ICPToken:()=>JE,InvalidPercentageError:()=>__,NullishError:()=>y_,TokenAmount:()=>ZE,TokenAmountV2:()=>XE,arrayBufferToUint8Array:()=>ox,arrayOfNumberToUint8Array:()=>cx,asNonNullish:()=>tx,asciiStringToByteArray:()=>ux,assertNonNullish:()=>Ys,assertPercentageNumber:()=>rx,base64ToUint8Array:()=>_x,bigEndianCrc32:()=>gx,bigIntToUint8Array:()=>ix,candidNumberArrayToBigInt:()=>dx,convertStringToE8s:()=>l_,createAgent:()=>h_,createServices:()=>ex,debounce:()=>Ax,decodeBase32:()=>hx,defaultAgent:()=>f_,encodeBase32:()=>fx,fromDefinedNullable:()=>Sx,fromNullable:()=>ud,fromNullishNullable:()=>Rx,hashObject:()=>wx,hashText:()=>w_,hexStringToUint8Array:()=>lx,isEmptyString:()=>IE,isNullish:()=>Gs,jsonReplacer:()=>b_,jsonReviver:()=>bx,nonNullish:()=>Yr,notEmptyString:()=>d_,nowInBigIntNanoSeconds:()=>vx,numberToUint8Array:()=>sx,principalToSubAccount:()=>Bx,queryAndUpdate:()=>DE,secondsToDuration:()=>xx,smallerVersion:()=>Px,toBigIntNanoSeconds:()=>Ox,toNullable:()=>Nx,uint8ArrayToArrayOfNumber:()=>ax,uint8ArrayToBase64:()=>px,uint8ArrayToBigInt:()=>nx,uint8ArrayToHexString:()=>m_});T_.exports=GE(c_);var u_=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(u_||{}),YE=BigInt(1e8),WE=8,l_=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)*YE}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},zE=({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,o=10n**BigInt(t);if(n)try{s+=BigInt(n)*o}catch{return 1}if(i){if(i.length>t)return 2;try{s+=BigInt(i.padEnd(t,"0"))}catch{return 1}}return s},JE={symbol:"ICP",name:"Internet Computer",decimals:8},ZE=class Ks{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 Ks(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=l_(t);return typeof n=="bigint"?new Ks(n,r):n}static fromNumber({amount:t,token:r}){let n=Ks.fromString({amount:t.toString(),token:r});if(n instanceof Ks)return n;throw n===0?new Error(`Number ${t} has more than 8 decimals`):new Error(`Invalid number ${t}`)}toE8s(){return this.e8s}},XE=class $s{constructor(t,r){this.ulps=t,this.token=r}static fromUlps({amount:t,token:r}){return new $s(t,r)}static fromString({amount:t,token:r}){let n=zE({amount:t,decimals:r.decimals});return typeof n=="bigint"?new $s(n,r):n}static fromNumber({amount:t,token:r}){let n=$s.fromString({amount:t.toFixed(Math.min(WE,r.decimals)),token:r});if(n instanceof $s)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)}},QE=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}},Gs=e=>e==null,Yr=e=>!Gs(e),d_=e=>Yr(e)&&e!=="",IE=e=>!d_(e),DE=async({request:e,onLoad:t,onQueryError:r,onUpdateError:n,strategy:i="query_and_update",identity:s,resolution:o="race"})=>{let a=!1,c=f=>e({certified:f,identity:s}).then(h=>{a||t({certified:f,response:h})}).catch(h=>{f||r==null||r({error:h,identity:s}),!a&&(Gs(n)||(console.error(h),f&&n({error:h,identity:s})))}).finally(()=>a=a||f),d=i==="query"?[c(!1)]:i==="update"?[c(!0)]:[c(!1),c(!0)];await(o==="all_settled"?Promise.allSettled(d):Promise.race(d))},s_=Dt(),id=Dt(),f_=()=>id.HttpAgent.createSync({host:"https://icp-api.io",identity:new id.AnonymousIdentity}),h_=async({identity:e,host:t,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await id.HttpAgent.create({identity:e,...Yr(t)&&{host:t},verifyQuerySignatures:n,...Yr(i)&&{retryTimes:i},shouldFetchRootKey:r}),LE=class p_{constructor(t){this.config=t,this.agents=void 0,this.getAgent=async({identity:r})=>{let n=r.getPrincipal().toText();if(Gs(this.agents)||Gs(this.agents[n])){let i=await h_({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)}},ex=({options:{canisterId:e,serviceOverride:t,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:o,certifiedIdlFactory:a})=>{let c=n??f_(),d=t??s_.Actor.createActor(o,{agent:c,canisterId:e,callTransform:i,queryTransform:s}),f=r??s_.Actor.createActor(a,{agent:c,canisterId:e,callTransform:i,queryTransform:s});return{service:d,certifiedService:f,agent:c,canisterId:e}},__=class extends Error{},y_=class extends Error{},Ys=(e,t)=>{if(e==null)throw new y_(t)},tx=(e,t)=>(Ys(e,t),e),rx=e=>{if(e<0||e>100)throw new __(`${e} is not a valid percentage number.`)},nx=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}},ix=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)},sx=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)},ox=e=>new Uint8Array(e),ax=e=>Array.from(e),cx=e=>new Uint8Array(e),ux=e=>Array.from(e).map(t=>t.charCodeAt(0)),lx=e=>{let t=e.match(/.{1,2}/g);return Ys(t,"Invalid hex string."),Uint8Array.from(t.map(r=>parseInt(r,16)))},m_=e=>(e instanceof Uint8Array||(e=Uint8Array.from(e)),e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")),dx=e=>{let t=0n;for(let r=e.length-1;r>=0;r--)t=(t<<32n)+BigInt(e[r]);return t},Xa="abcdefghijklmnopqrstuvwxyz234567",Gi=Object.create(null);for(let e=0;e<Xa.length;e++)Gi[Xa[e]]=e;Gi[0]=Gi.o;Gi[1]=Gi.i;var fx=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+=Xa[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?Xa[r>>3]:"")};function hx(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0;function s(o){let a=Gi[o.toLowerCase()];Ys(a,`Invalid character: ${JSON.stringify(o)}`),a<<=3,r|=a>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=a<<5-t&255:r=0)}for(let o of e)s(o);return n.slice(0,i)}var px=e=>btoa(String.fromCharCode(...new Uint8Array(e))),_x=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)),yx=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]),mx=e=>{let t=-1;for(let r=0;r<e.length;r++){let n=(e[r]^t)&255;t=yx[n]^t>>>8}return(t^-1)>>>0},gx=e=>{let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,mx(e),!1),new Uint8Array(t)},g_=Ft(),sd="__bigint__",od="__principal__",ad="__uint8array__",b_=(e,t)=>typeof t=="bigint"?{[sd]:`${t}`}:Yr(t)&&t instanceof g_.Principal?{[od]:t.toText()}:Yr(t)&&t instanceof Uint8Array?{[ad]:Array.from(t)}:t,bx=(e,t)=>{let r=n=>t[n];return Yr(t)&&typeof t=="object"&&sd in t?BigInt(r(sd)):Yr(t)&&typeof t=="object"&&od in t?g_.Principal.fromText(r(od)):Yr(t)&&typeof t=="object"&&ad in t?Uint8Array.from(r(ad)):t},wx=async e=>{let t=JSON.stringify(e,b_);return await w_(t)},w_=async e=>{let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return m_(new Uint8Array(r))},Ex={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"},xx=({seconds:e,i18n:t=Ex})=>{let r=e/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=Tx(i);return i-=E_(s),[Hs("year",s),Hs("day",i),Hs("hour",n),Hs("minute",r),...e>BigInt(0)&&e<BigInt(60)?[Hs("second",e)]:[]].filter(({amount:o})=>o>0).slice(0,2).map(o=>`${o.amount} ${o.amount===1?t[o.labelKey]:t[`${o.labelKey}_plural`]}`).join(", ")},Tx=e=>{let t=e/BigInt(365);for(;E_(t)>e;)t--;return t},E_=e=>{let t=e/BigInt(4);return e*BigInt(365)+t},Hs=(e,t)=>({labelKey:e,amount:Number(t)}),x_=1000000n,vx=()=>BigInt(Date.now())*x_,Ox=e=>BigInt(e.getTime())*x_,Ax=(e,t)=>{let r;return(...n)=>{let i=()=>e(...n);r&&clearTimeout(r),r=setTimeout(i,t!==void 0&&t>0?t:300)}},Nx=e=>Yr(e)?[e]:[],ud=e=>e?.[0],Sx=e=>{let t=ud(e);return Ys(t),t},Rx=e=>ud(e??[]),Bx=e=>{let t=e.toUint8Array(),r=new Uint8Array(32);return r[0]=t.length,r.set(t,1),r},o_=(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)},Px=({minVersion:e,currentVersion:t})=>{let r=o_(e.split(".").map(a_),3).join(".");return o_(t.split(".").map(a_),3).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var O_=ee(zr=>{"use strict";var Da=zr&&zr.__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},Un=zr&&zr.__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)},Qa,Ia,Wi,zi;Object.defineProperty(zr,"__esModule",{value:!0});zr.Ed25519KeyIdentity=zr.Ed25519PublicKey=void 0;var Ux=Dt(),Lt=Dt(),Ws=Hl();function v_(e){return e!==null&&typeof e=="object"}var ni=class e{constructor(t){if(Qa.set(this,void 0),Ia.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Da(this,Qa,t,"f"),Da(this,Ia,e.derEncode(t),"f")}static from(t){if(typeof t=="string"){let r=(0,Lt.fromHex)(t);return this.fromRaw(r)}else if(v_(t)){let r=t;if(v_(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Lt.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,Lt.wrapDER)(t,Lt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(t){let r=(0,Lt.unwrapDER)(t,Lt.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 Un(this,Qa,"f")}get derKey(){return Un(this,Ia,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};zr.Ed25519PublicKey=ni;Qa=new WeakMap,Ia=new WeakMap;ni.RAW_KEY_LENGTH=32;var dd=class e extends Lt.SignIdentity{constructor(t,r){super(),Wi.set(this,void 0),zi.set(this,void 0),Da(this,Wi,ni.from(t),"f"),Da(this,zi,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=Ws.ed25519.utils.randomPrivateKey()),(0,Ux.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=Ws.ed25519.getPublicKey(r);return e.fromKeyPair(n,r)}static fromParsedJson(t){let[r,n]=t;return new e(ni.fromDer((0,Lt.fromHex)(r)),(0,Lt.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=Ws.ed25519.getPublicKey(new Uint8Array(t));return e.fromKeyPair(r,t)}toJSON(){return[(0,Lt.toHex)(Un(this,Wi,"f").toDer()),(0,Lt.toHex)(Un(this,zi,"f"))]}getKeyPair(){return{secretKey:Un(this,zi,"f"),publicKey:Un(this,Wi,"f")}}getPublicKey(){return Un(this,Wi,"f")}async sign(t){let r=new Uint8Array(t),n=(0,Lt.uint8ToBuf)(Ws.ed25519.sign(r,Un(this,zi,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(t,r,n){let[i,s,o]=[t,r,n].map(a=>(typeof a=="string"&&(a=(0,Lt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Ws.ed25519.verify(s,i,o)}};zr.Ed25519KeyIdentity=dd;Wi=new WeakMap,zi=new WeakMap});var N_=ee(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.ECDSAKeyIdentity=ii.CryptoError=void 0;var Fx=Dt(),La=class e extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,e.prototype)}};ii.CryptoError=La;function A_(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 La("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 Fx.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=A_(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await s.exportKey("spki",o.publicKey);return new this(o,a,s)}static async fromKeyPair(t,r){let n=A_(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 hd=ee(Cn=>{"use strict";var Cx=Cn&&Cn.__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=Cn&&Cn.__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(Cn,"__esModule",{value:!0});Cn.PartialIdentity=void 0;var Mx=Ft(),fd=class{constructor(t){Fn.set(this,void 0),Cx(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 Mx.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.")}};Cn.PartialIdentity=fd;Fn=new WeakMap});var S_=ee(Xe=>{"use strict";var qx=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]}),jx=Xe&&Xe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),kx=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)&&qx(t,e,r);return jx(t,e),t},Vx=Xe&&Xe.__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},Hx=Xe&&Xe.__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)},Kx=Xe&&Xe.__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(Xe,"__esModule",{value:!0});Xe.isDelegationValid=Xe.PartialDelegationIdentity=Xe.DelegationIdentity=Xe.DelegationChain=Xe.Delegation=void 0;var Mn=Dt(),_d=Ft(),Js=kx(ps()),$x=hd(),Gx=new TextEncoder().encode("ic-request-auth-delegation"),Yx=new TextEncoder().encode(`
57
- ic-request`);function pd(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return(0,Mn.fromHex)(e)}var Zs=class{constructor(t,r,n){this.pubkey=t,this.expiration=r,this.targets=n}toCBOR(){return Js.value.map(Object.assign({pubkey:Js.value.bytes(this.pubkey),expiration:Js.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Js.value.array(this.targets.map(t=>Js.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Mn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};Xe.Delegation=Zs;async function Wx(e,t,r,n){let i=new Zs(t.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...Gx,...new Uint8Array((0,Mn.requestIdOf)(Object.assign({},i)))]),o=await e.sign(s);return{delegation:i,signature:o}}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,o;let a=await Wx(t,r,n,i.targets);return new e([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],a],((o=i.previous)===null||o===void 0?void 0:o.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:o,signature:a}=s,{pubkey:c,expiration:d,targets:f}=o;if(f!==void 0&&!Array.isArray(f))throw new Error("Invalid targets.");return{delegation:new Zs(pd(c),BigInt("0x"+d),f&&f.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return _d.Principal.fromHex(h)})),signature:pd(a)}});return new this(i,pd(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,Mn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Mn.toHex)(n)}}),publicKey:(0,Mn.toHex)(this.publicKey)}}};Xe.DelegationChain=yd;var md=class extends Mn.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=Kx(t,["body"]),i=await(0,Mn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Yx,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};Xe.DelegationIdentity=md;var gd=class e extends $x.PartialIdentity{constructor(t,r){super(t),tc.set(this,void 0),Vx(this,tc,r,"f")}get delegation(){return Hx(this,tc,"f")}static fromDelegation(t,r){return new e(t,r)}};Xe.PartialDelegationIdentity=gd;tc=new WeakMap;function zx(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:o}of e.delegations){if(o.targets===void 0)continue;let a=!0;for(let c of o.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}Xe.isDelegationValid=zx});var R_=ee(qn=>{"use strict";var Jx=qn&&qn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(qn,"__esModule",{value:!0});qn.WebAuthnIdentity=qn.CosePublicKey=void 0;var si=Dt(),bd=Jx($o()),Zx=Hn(),Xx=xi();function Qx(e){return(0,si.wrapDER)(e,si.DER_COSE_OID).buffer}function Ix(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=Qx(t)}toDer(){return this._encodedKey}getCose(){return this._cose}};qn.CosePublicKey=rc;function Dx(e="<ic0.app>"){return typeof e=="string"?Uint8Array.from(e,t=>t.charCodeAt(0)):e}async function Lx(e){let t=await navigator.credentials.create(e??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:Dx(),pubKeyCredParams:[{type:"public-key",alg:wd.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Zx.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,Xx.bufFromBufLike)(t.rawId)}}var wd;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(wd||(wd={}));var Ed=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 Lx(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,Ix(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)}}};qn.WebAuthnIdentity=Ed});var P_=ee(Je=>{"use strict";var eT=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]}),Td=Je&&Je.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&eT(t,e,r)};Object.defineProperty(Je,"__esModule",{value:!0});Je.Secp256k1KeyIdentity=Je.ED25519_OID=Je.DER_COSE_OID=Je.unwrapDER=Je.wrapDER=Je.WebAuthnIdentity=Je.Ed25519PublicKey=Je.Ed25519KeyIdentity=void 0;var B_=O_();Object.defineProperty(Je,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return B_.Ed25519KeyIdentity}});Object.defineProperty(Je,"Ed25519PublicKey",{enumerable:!0,get:function(){return B_.Ed25519PublicKey}});Td(N_(),Je);Td(S_(),Je);Td(hd(),Je);var tT=R_();Object.defineProperty(Je,"WebAuthnIdentity",{enumerable:!0,get:function(){return tT.WebAuthnIdentity}});var nc=Dt();Object.defineProperty(Je,"wrapDER",{enumerable:!0,get:function(){return nc.wrapDER}});Object.defineProperty(Je,"unwrapDER",{enumerable:!0,get:function(){return nc.unwrapDER}});Object.defineProperty(Je,"DER_COSE_OID",{enumerable:!0,get:function(){return nc.DER_COSE_OID}});Object.defineProperty(Je,"ED25519_OID",{enumerable:!0,get:function(){return nc.ED25519_OID}});var xd=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};Je.Secp256k1KeyIdentity=xd});var Od=ee(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.IdleManager=void 0;var U_=["mousedown","mousemove","keydown","touchstart","wheel"],vd=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),U_.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let d;return(...f)=>{let h=this,m=function(){d=void 0,a.apply(h,f)};clearTimeout(d),d=window.setTimeout(m,c)}};if(t?.captureScroll){let a=o(s,(r=t?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!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);U_.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=vd});function nT(){return F_||(F_=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function iT(){return C_||(C_=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function sT(e){let t=new Promise((r,n)=>{let i=()=>{e.removeEventListener("success",s),e.removeEventListener("error",o)},s=()=>{r(ur(e.result)),i()},o=()=>{n(e.error),i()};e.addEventListener("success",s),e.addEventListener("error",o)});return t.then(r=>{r instanceof IDBCursor&&M_.set(r,e)}).catch(()=>{}),Rd.set(t,e),t}function oT(e){if(Nd.has(e))return;let t=new Promise((r,n)=>{let i=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",o),e.removeEventListener("abort",o)},s=()=>{r(),i()},o=()=>{n(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",s),e.addEventListener("error",o),e.addEventListener("abort",o)});Nd.set(e,t)}function j_(e){Sd=e(Sd)}function aT(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...r){let n=e.call(Xs(this),t,...r);return q_.set(n,t.sort?t.sort():[t]),ur(n)}:iT().includes(e)?function(...t){return e.apply(Xs(this),t),ur(M_.get(this))}:function(...t){return ur(e.apply(Xs(this),t))}}function cT(e){return typeof e=="function"?aT(e):(e instanceof IDBTransaction&&oT(e),rT(e,nT())?new Proxy(e,Sd):e)}function ur(e){if(e instanceof IDBRequest)return sT(e);if(Ad.has(e))return Ad.get(e);let t=cT(e);return t!==e&&(Ad.set(e,t),Rd.set(t,e)),t}var rT,F_,C_,M_,Nd,q_,Ad,Rd,Sd,Xs,Bd=ef(()=>{rT=(e,t)=>t.some(r=>e instanceof r);M_=new WeakMap,Nd=new WeakMap,q_=new WeakMap,Ad=new WeakMap,Rd=new WeakMap;Sd={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return Nd.get(e);if(t==="objectStoreNames")return e.objectStoreNames||q_.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ur(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}};Xs=e=>Rd.get(e)});var V_={};cm(V_,{deleteDB:()=>lT,openDB:()=>uT,unwrap:()=>Xs,wrap:()=>ur});function uT(e,t,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(e,t),a=ur(o);return n&&o.addEventListener("upgradeneeded",c=>{n(ur(o.result),c.oldVersion,c.newVersion,ur(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",d=>i(d.oldVersion,d.newVersion,d))}).catch(()=>{}),a}function lT(e,{blocked:t}={}){let r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),ur(r).then(()=>{})}function k_(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=fT.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||dT.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),d=c.store;return n&&(d=d.index(a.shift())),(await Promise.all([d[r](...a),i&&c.done]))[0]};return Pd.set(t,s),s}var dT,fT,Pd,H_=ef(()=>{Bd();Bd();dT=["get","getKey","getAll","getAllKeys","count"],fT=["put","add","delete","clear"],Pd=new Map;j_(e=>({...e,get:(t,r,n)=>k_(t,r)||e.get(t,r,n),has:(t,r)=>!!k_(t,r)||e.has(t,r)}))});var Fd=ee(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.IdbKeyVal=void 0;var hT=(H_(),um(V_)),Qs=oc(),K_="auth-client-db",$_="ic-keyval",pT=async(e=K_,t=$_,r)=>(Qs.isBrowser&&(localStorage!=null&&localStorage.getItem(Qs.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Qs.KEY_STORAGE_DELEGATION),localStorage.removeItem(Qs.KEY_STORAGE_KEY)),await(0,hT.openDB)(e,r,{upgrade:n=>{n.objectStoreNames.contains(t)&&n.clear(t),n.createObjectStore(t)}}));async function _T(e,t,r){return await e.get(t,r)}async function yT(e,t,r,n){return await e.put(t,n,r)}async function mT(e,t,r){return await e.delete(t,r)}var Ud=class e{constructor(t,r){this._db=t,this._storeName=r}static async create(t){let{dbName:r=K_,storeName:n=$_,version:i=Qs.DB_VERSION}=t??{},s=await pT(r,n,i);return new e(s,n)}async set(t,r){return await yT(this._db,this._storeName,t,r)}async get(t){var r;return(r=await _T(this._db,this._storeName,t))!==null&&r!==void 0?r:null}async remove(t){return await mT(this._db,this._storeName,t)}};sc.IdbKeyVal=Ud});var oc=ee(it=>{"use strict";var gT=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},bT=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)},ac;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 wT=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 Cd=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=Cd;var Md=class{constructor(t){ac.set(this,void 0),gT(this,ac,t??{},"f")}get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}wT.IdbKeyVal.create(bT(this,ac,"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=Md;ac=new WeakMap});var Hd=ee(Le=>{"use strict";var ET=Le&&Le.__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]}),xT=Le&&Le.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&ET(t,e,r)};Object.defineProperty(Le,"__esModule",{value:!0});Le.AuthClient=Le.ERROR_USER_INTERRUPT=Le.IdbKeyVal=Le.KEY_STORAGE_KEY=Le.KEY_STORAGE_DELEGATION=Le.LocalStorage=Le.IdbStorage=void 0;var G_=Dt(),er=P_(),Y_=Od(),Tt=oc(),cc=oc();Object.defineProperty(Le,"IdbStorage",{enumerable:!0,get:function(){return cc.IdbStorage}});Object.defineProperty(Le,"LocalStorage",{enumerable:!0,get:function(){return cc.LocalStorage}});Object.defineProperty(Le,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return cc.KEY_STORAGE_DELEGATION}});Object.defineProperty(Le,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return cc.KEY_STORAGE_KEY}});var TT=Fd();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return TT.IdbKeyVal}});var vT="https://identity.ic0.app",OT="#authorize",qd="ECDSA",jd="Ed25519",AT=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";xT(Od(),Le);var Vd=class{constructor(t,r,n,i,s,o,a,c){this._identity=t,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(t={}){var r,n,i;let s=(r=t.storage)!==null&&r!==void 0?r:new Tt.IdbStorage,o=(n=t.keyType)!==null&&n!==void 0?n:qd,a=null;if(t.identity)a=t.identity;else{let h=await s.get(Tt.KEY_STORAGE_KEY);if(!h&&Tt.isBrowser)try{let m=new Tt.LocalStorage,b=await m.get(Tt.KEY_STORAGE_DELEGATION),l=await m.get(Tt.KEY_STORAGE_KEY);b&&l&&o===qd&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Tt.KEY_STORAGE_DELEGATION,b),await s.set(Tt.KEY_STORAGE_KEY,l),h=b,await m.remove(Tt.KEY_STORAGE_DELEGATION),await m.remove(Tt.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(h)try{typeof h=="object"?o===jd&&typeof h=="string"?a=await er.Ed25519KeyIdentity.fromJSON(h):a=await er.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=er.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new G_.AnonymousIdentity,d=null;if(a)try{let h=await s.get(Tt.KEY_STORAGE_DELEGATION);if(typeof h=="object"&&h!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?c=t.identity:h&&(d=er.DelegationChain.fromJSON(h),(0,er.isDelegationValid)(d)?"toDer"in a?c=er.PartialDelegationIdentity.fromDelegation(a,d):c=er.DelegationIdentity.fromDelegation(a,d):(await kd(s),a=null))}catch(h){console.error(h),await kd(s),a=null}let f;return!((i=t.idleOptions)===null||i===void 0)&&i.disableIdle?f=void 0:(d||t.identity)&&(f=Y_.IdleManager.create(t.idleOptions)),a||(o===jd?(a=await er.Ed25519KeyIdentity.generate(),await s.set(Tt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(t.storage&&o===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 '${jd}' as the key type, as it can serialize to a string`),a=await er.ECDSAKeyIdentity.generate(),await s.set(Tt.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,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 er.Delegation(d.delegation.pubkey,d.delegation.expiration,d.delegation.targets),signature:d.signature.buffer})),o=er.DelegationChain.fromDelegations(s,t.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=er.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=er.DelegationIdentity.fromDelegation(a,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=Y_.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Tt.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 o=BigInt(8)*BigInt(36e11),a=new URL(((r=t?.identityProvider)===null||r===void 0?void 0:r.toString())||vT);a.hash=OT,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=t?.maxTimeToLive)!==null&&i!==void 0?i:o},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(a.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Le.ERROR_USER_INTERRUPT,t?.onError):setTimeout(c,AT))};c()}_getEventHandler(t,r){return async n=>{var i,s,o;if(n.origin!==t.origin)return;let a=n.data;switch(a.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);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,t.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.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 G_.AnonymousIdentity,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};Le.AuthClient=Vd;async function kd(e){await e.remove(Tt.KEY_STORAGE_KEY),await e.remove(Tt.KEY_STORAGE_DELEGATION),await e.remove(Tt.KEY_VECTOR)}});var $y=We(nt(),1);var Ay=We(nt(),1);var Yi=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 Wr=class e extends Yi{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 Oy=We(Hd(),1),Id=We(nt(),1);var W_=BigInt(144e11),z_=!1,J_={width:576,height:576},Z_={width:505,height:705},X_="internetcomputer.org";var Is=We(nt(),1);var Ji="http://127.0.0.1:5987",Q_="rdmx6-jaaaa-aaaaa-aaadq-cai";var Jr=class e extends Yi{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 Kd=We(nt(),1);var uc=We(nt(),1),I_=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 $d=({width:e,height:t})=>{if(!dc()||(0,Kd.isNullish)(window)||(0,Kd.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=Jr.getInstance().get()?.container;if((0,Is.isNullish)(n)||n===!1)return`https://identity.${this.#e??X_}`;let i=Jr.getInstance().get(),s=(0,Is.nonNullish)(i)&&(0,Is.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:Q_,{host:o,protocol:a}=new URL(n===!0?Ji:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...t!==!1&&{windowOpenerFeatures:$d(J_)},identityProvider:r()}}},D_=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:$d(Z_)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var ty=We(Dt(),1),pc=We(nt(),1);var hc=We(nt(),1);var L_=We(Dt(),1),Gd=We(nt(),1);var ey=async({identity:e,container:t})=>{let n=(0,Gd.nonNullish)(t)&&t!==!1?t===!0?Ji:t:"https://icp-api.io",i=(0,Gd.nonNullish)(t);return await L_.HttpAgent.create({identity:e,shouldFetchRootKey:i,host:n})};var Zi=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 ey({identity:t,...r});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}};var Xi=class e{static instance;#e=void 0;constructor(){}static getInstance(){return(0,pc.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,pc.isNullish)(this.#e)||(0,pc.isNullish)(this.#e[s])){let o=await this.createActor({satelliteId:t,identity:r,...i});return this.#e={...this.#e??{},[s]:o},o}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:t,satelliteId:r,...n}){let i=await Zi.getInstance().getAgent(n);return ty.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 ry=We(Hd(),1),wc=()=>ry.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Ls=We(nt(),1);var Yd=({error:e,type:t})=>typeof e=="string"?e.includes(t):e instanceof Error?e.message.includes(t):!1;var ny="juno.datastore.error.user.cannot_update";var Tr=We(nt(),1);var iy=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 oi=We(nt(),1);var Wd=async e=>{let{data:t,version:r,description:n}=e;return{description:(0,oi.toNullable)(n),data:await I_(t),version:(0,oi.toNullable)(r)}},zd=e=>{let{version:t}=e;return{version:(0,oi.toNullable)(t)}},Ds=async({doc:e,key:t})=>{let{owner:r,version:n,description:i,data:s,...o}=e;return{key:t,description:(0,oi.fromNullable)(i),owner:r.toText(),data:await lc(s),version:(0,oi.fromNullable)(n),...o}};var oy=We(Ft(),1),st=We(nt(),1);var sy=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)}},jn=({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:sy(e.createdAt),updated_at:sy(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"?oy.Principal.fromText(n):n)});var cy=We(nt(),1);var Ec=We(nt(),1);var ay=({satelliteId:e,container:t})=>{let{satelliteId:r}=Jd({satelliteId:e}),{container:n}=Zd({container:t});if((0,Ec.nonNullish)(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?Ji:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Jd=({satelliteId:e})=>(0,Ec.nonNullish)(e)?{satelliteId:e}:Jr.getInstance().get()??{satelliteId:void 0},Zd=({container:e})=>(0,Ec.nonNullish)(e)?{container:e}:Jr.getInstance().get()??{container:void 0};var Xd=({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}),o=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(s),description:e.Opt(e.Text),created_at:e.Opt(s)}),a=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(o),paginate:e.Opt(a)}),d=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),h=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)}),S=e.Record({proposal_ids:e.Vec(e.Nat)}),A=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}),q=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),v=e.Record({key:F,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,q)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),G=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),E=e.Record({internet_identity:e.Opt(G)}),j=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),Y=e.Record({max_memory_size:e.Opt(j)}),Z=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),k=e.Variant({Deny:e.Null,Allow:e.Null}),ae=e.Record({status_code:e.Nat16,location:e.Text}),D=e.Record({iframe:e.Opt(Z),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),max_memory_size:e.Opt(j),raw_access:e.Opt(k),redirects:e.Opt(e.Vec(e.Tuple(e.Text,ae)))}),se=e.Record({db:e.Opt(Y),authentication:e.Opt(E),storage:D}),w=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)}),g=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)}),N=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),B=e.Variant({AssetsUpgrade:R,SegmentsDeployment:N}),H=e.Record({status:g,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:B}),X=e.Variant({Heap:e.Null,Stable:e.Null}),ie=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),oe=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),W=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(X),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:ie,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(oe),write:ie,max_changes_per_user:e.Opt(e.Nat32)}),M=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)}),p=e.Record({memory:X,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}),L=e.Variant({Callback:e.Record({token:p,callback:e.Func([],[],["query"])})}),re=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(L),status_code:e.Nat16}),le=e.Record({token:e.Opt(p),body:e.Vec(e.Nat8)}),I=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}),u=e.Record({batch_id:e.Nat}),_=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,v)),items_length:e.Nat64}),y=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),U=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,w)),items_length:e.Nat64}),O=e.Record({desc:e.Bool}),P=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),K=e.Record({order:e.Opt(O),paginate:e.Opt(P)}),x=e.Record({proposal_id:e.Nat}),C=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(x,H)),items_length:e.Nat64}),$=e.Record({include_system:e.Bool}),V=e.Record({matcher:e.Opt($)}),Q=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,W)),items_length:e.Nat64}),te=e.Record({stable:e.Nat64,heap:e.Nat64}),de=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:f,expires_at:e.Opt(e.Nat64)}),ge=e.Record({controller:de,controllers:e.Vec(e.Principal)}),Oe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Fe=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(X),max_size:e.Opt(e.Nat),read:ie,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(oe),write:ie,max_changes_per_user:e.Opt(e.Nat32)}),_e=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),fe=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],[],[]),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,h))],[]),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([S],[],[]),deposit_cycles:e.Func([A],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(v)],["query"]),get_auth_config:e.Func([],[e.Opt(E)],["query"]),get_config:e.Func([],[se],[]),get_db_config:e.Func([],[e.Opt(Y)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(w)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(v)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(w)))],["query"]),get_proposal:e.Func([e.Nat],[e.Opt(H)],["query"]),get_rule:e.Func([b,e.Text],[e.Opt(W)],["query"]),get_storage_config:e.Func([],[D],["query"]),http_request:e.Func([M],[re],["query"]),http_request_streaming_callback:e.Func([p],[le],["query"]),init_asset_upload:e.Func([I],[u],[]),init_proposal:e.Func([B],[e.Nat,H],[]),init_proposal_asset_upload:e.Func([I,e.Nat],[u],[]),list_assets:e.Func([e.Text,c],[_],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,h))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,y))],["query"]),list_docs:e.Func([e.Text,c],[U],["query"]),list_proposals:e.Func([K],[C],["query"]),list_rules:e.Func([b,V],[Q],["query"]),memory_size:e.Func([],[te],["query"]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([E],[],[]),set_controllers:e.Func([ge],[e.Vec(e.Tuple(e.Principal,h))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([Y],[],[]),set_doc:e.Func([e.Text,e.Text,Oe],[w],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,Oe))],[e.Vec(e.Tuple(e.Text,w))],[]),set_rule:e.Func([b,e.Text,Fe],[W],[]),set_storage_config:e.Func([D],[],[]),submit_proposal:e.Func([e.Nat],[e.Nat,H],[]),upload_asset_chunk:e.Func([_e],[fe],[]),upload_proposal_asset_chunk:e.Func([_e],[fe],[])})};var Qd=({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}),o=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(s),description:e.Opt(e.Text),created_at:e.Opt(s)}),a=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(o),paginate:e.Opt(a)}),d=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),h=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)}),S=e.Record({proposal_ids:e.Vec(e.Nat)}),A=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}),q=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),v=e.Record({key:F,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,q)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),G=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),E=e.Record({internet_identity:e.Opt(G)}),j=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),Y=e.Record({max_memory_size:e.Opt(j)}),Z=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),k=e.Variant({Deny:e.Null,Allow:e.Null}),ae=e.Record({status_code:e.Nat16,location:e.Text}),D=e.Record({iframe:e.Opt(Z),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),max_memory_size:e.Opt(j),raw_access:e.Opt(k),redirects:e.Opt(e.Vec(e.Tuple(e.Text,ae)))}),se=e.Record({db:e.Opt(Y),authentication:e.Opt(E),storage:D}),w=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)}),g=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)}),N=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),B=e.Variant({AssetsUpgrade:R,SegmentsDeployment:N}),H=e.Record({status:g,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:B}),X=e.Variant({Heap:e.Null,Stable:e.Null}),ie=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),oe=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),W=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(X),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:ie,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(oe),write:ie,max_changes_per_user:e.Opt(e.Nat32)}),M=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)}),p=e.Record({memory:X,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}),L=e.Variant({Callback:e.Record({token:p,callback:e.Func([],[],[])})}),re=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(L),status_code:e.Nat16}),le=e.Record({token:e.Opt(p),body:e.Vec(e.Nat8)}),I=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}),u=e.Record({batch_id:e.Nat}),_=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,v)),items_length:e.Nat64}),y=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),U=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,w)),items_length:e.Nat64}),O=e.Record({desc:e.Bool}),P=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),K=e.Record({order:e.Opt(O),paginate:e.Opt(P)}),x=e.Record({proposal_id:e.Nat}),C=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(x,H)),items_length:e.Nat64}),$=e.Record({include_system:e.Bool}),V=e.Record({matcher:e.Opt($)}),Q=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,W)),items_length:e.Nat64}),te=e.Record({stable:e.Nat64,heap:e.Nat64}),de=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:f,expires_at:e.Opt(e.Nat64)}),ge=e.Record({controller:de,controllers:e.Vec(e.Principal)}),Oe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Fe=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(X),max_size:e.Opt(e.Nat),read:ie,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(oe),write:ie,max_changes_per_user:e.Opt(e.Nat32)}),_e=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),fe=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],[],[]),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,h))],[]),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([S],[],[]),deposit_cycles:e.Func([A],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(v)],[]),get_auth_config:e.Func([],[e.Opt(E)],[]),get_config:e.Func([],[se],[]),get_db_config:e.Func([],[e.Opt(Y)],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(w)],[]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(v)))],[]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(w)))],[]),get_proposal:e.Func([e.Nat],[e.Opt(H)],[]),get_rule:e.Func([b,e.Text],[e.Opt(W)],[]),get_storage_config:e.Func([],[D],[]),http_request:e.Func([M],[re],[]),http_request_streaming_callback:e.Func([p],[le],[]),init_asset_upload:e.Func([I],[u],[]),init_proposal:e.Func([B],[e.Nat,H],[]),init_proposal_asset_upload:e.Func([I,e.Nat],[u],[]),list_assets:e.Func([e.Text,c],[_],[]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,h))],[]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,y))],[]),list_docs:e.Func([e.Text,c],[U],[]),list_proposals:e.Func([K],[C],[]),list_rules:e.Func([b,V],[Q],[]),memory_size:e.Func([],[te],[]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([E],[],[]),set_controllers:e.Func([ge],[e.Vec(e.Tuple(e.Principal,h))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([Y],[],[]),set_doc:e.Func([e.Text,e.Text,Oe],[w],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,Oe))],[e.Vec(e.Tuple(e.Text,w))],[]),set_rule:e.Func([b,e.Text,Fe],[W],[]),set_storage_config:e.Func([D],[],[]),submit_proposal:e.Func([e.Nat],[e.Nat,H],[]),upload_asset_chunk:e.Func([_e],[fe],[]),upload_proposal_asset_chunk:e.Func([_e],[fe],[])})};var dt=({satellite:e,options:{certified:t}})=>ly({idlFactory:t?Qd:Xd,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}=Jd({satelliteId:e});(0,cy.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Zd({container:t});return await Xi.getInstance().getActor({satelliteId:n,container:i,...r})};var dy=async({collection:e,key:t,...r})=>{let{get_doc:n}=await dt(r),i=(0,Tr.fromNullable)(await n(e,t));if(!(0,Tr.isNullish)(i))return Ds({doc:i,key:t})},fy=async({docs:e,...t})=>{let{get_many_docs:r}=await dt(t),n=e.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=(0,Tr.fromNullable)(a);s.push((0,Tr.nonNullish)(c)?await Ds({key:o,doc:c}):void 0)}return s},hy=async({collection:e,doc:t,...r})=>{let{set_doc:n}=await dt(r),{key:i}=t,s=await Wd(t),o=await n(e,i,s);return await Ds({key:i,doc:o})},py=async({docs:e,...t})=>{let{set_many_docs:r}=await dt(t),n=[];for(let{collection:o,doc:a}of e){let{key:c}=a;n.push([o,c,await Wd(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await Ds({key:o,doc:a}));return s},_y=async({collection:e,doc:t,...r})=>{let{del_doc:n}=await dt(r),{key:i}=t;return n(e,i,zd(t))},yy=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)},my=async({collection:e,filter:t,...r})=>{let{del_filtered_docs:n}=await dt(r);return n(e,jn(t))},gy=async({collection:e,filter:t,...r})=>{let{list_docs:n}=await dt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(e,jn(t)),d=[];for(let[f,h]of i){let{data:m,owner:b,description:l,version:S,...A}=h;d.push({key:f,description:(0,Tr.fromNullable)(l),owner:b.toText(),data:await iy({data:m}),version:(0,Tr.fromNullable)(S),...A})}return{items:d,items_length:o,items_page:(0,Tr.fromNullable)(s),matches_length:a,matches_pages:(0,Tr.fromNullable)(c)}},by=async({collection:e,filter:t,...r})=>{let{count_docs:n}=await dt(r);return n(e,jn(t))};var Zr={certified:!1};var wy=We(Dt(),1),Ey=We(nt(),1);var et=e=>(0,Ey.nonNullish)(e)?e:xc()??new wy.AnonymousIdentity;var xy=async({satellite:e,options:t,...r})=>{let n=et(e?.identity);return await dy({...r,satellite:{...e,identity:n},options:t??Zr})},GO=async({satellite:e,options:t,...r})=>{let n=et(e?.identity);return await fy({...r,satellite:{...e,identity:n},options:t??Zr})},Ty=async({satellite:e,...t})=>{let r=et(e?.identity);return await hy({...t,satellite:{...e,identity:r},options:{certified:!0}})},YO=async({satellite:e,...t})=>{let r=et(e?.identity);return await py({...t,satellite:{...e,identity:r},options:{certified:!0}})},WO=async({satellite:e,...t})=>{let r=et(e?.identity);return await _y({...t,satellite:{...e,identity:r},options:{certified:!0}})},zO=async({satellite:e,...t})=>{let r=et(e?.identity);return await yy({...t,satellite:{...e,identity:r},options:{certified:!0}})},JO=async({satellite:e,filter:t,...r})=>{let n=et(e?.identity);return await my({...r,filter:t??{},satellite:{...e,identity:n},options:{certified:!0}})},ZO=async({satellite:e,options:t,filter:r,...n})=>{let i=et(e?.identity);return await gy({...n,filter:r??{},satellite:{...e,identity:i},options:t??Zr})},XO=async({satellite:e,options:t,filter:r,...n})=>{let i=et(e?.identity);return await by({...n,filter:r??{},satellite:{...e,identity:i},options:t??Zr})};var vy=async e=>{let t=xc();if((0,Ls.isNullish)(t))throw new gc("No identity to initialize the user. Have you initialized Juno?");let r=t.getPrincipal().toText(),n=()=>xy({collection:"#user",key:r}),i=await n();if((0,Ls.nonNullish)(i))return i;try{return await NT({userId:r,provider:e})}catch(s){if(Yd({error:s,type:ny})){let o=await n();if((0,Ls.nonNullish)(o))return o}throw s}},NT=({userId:e,...t})=>Ty({collection:"#user",doc:{key:e,data:t}});var lr,Dd=async e=>{if(lr=lr??await wc(),!(await lr?.isAuthenticated()??!1))return;let r=await vy(e);Wr.getInstance().set(r)},ST=e=>new Promise(async(t,r)=>{if((0,Id.isNullish)(lr)){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 lr.login({onSuccess:async()=>{await Dd(n.id),t()},onError:i=>{if(i===Oy.ERROR_USER_INTERRUPT){r(new mc(i));return}r(new _c(i))},maxTimeToLive:e?.maxTimeToLive??W_,allowPinAuthentication:e?.allowPin??z_,...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...n.signInOptions({windowed:e?.windowed})})}),Ld=async()=>{await RT(),lr=await wc()},RT=async()=>{await lr?.logout(),lr=null,Wr.getInstance().reset(),Xi.getInstance().reset(),Zi.getInstance().reset()},xc=()=>lr?.getIdentity(),BT=async()=>(lr??await wc()).getIdentity(),PT=async()=>{let e=Wr.getInstance().get();return(0,Id.isNullish)(e)||!(await lr?.isAuthenticated()??!1)?null:lr?.getIdentity()??null};var Ny=e=>{let t=e===!0?"./workers/auth.worker.js":e,r=new Worker(t),n=async()=>{ld({message:"junoSignOutAuthTimer"}),await Ld()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":ld({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},Wr.getInstance().subscribe(i=>{if((0,Ay.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Sy=()=>{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()},Ry=()=>{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 g6=async({idlFactory:e,satellite:t})=>{let r=et(t?.identity);return await uy({idlFactory:e,...t,identity:r})};var ro=We(nt(),1);var to=We(nt(),1);var eo=We(nt(),1);var By=async({asset:{data:e,headers:t,...r},actor:n})=>{let{init_asset_upload:i,upload_asset_chunk:s,commit_asset_upload:o}=n,{batch_id:a}=await i(UT(r)),{chunkIds:c}=await CT({data:e,uploadFn:s,batchId:a});await FT({commitFn:o,batchId:a,data:e,headers:t,chunkIds:c})};var UT=({filename:e,collection:t,token:r,fullPath:n,encoding:i,description:s})=>({collection:t,full_path:n,name:e,token:(0,eo.toNullable)(r),encoding_type:(0,eo.toNullable)(i),description:(0,eo.toNullable)(s)}),FT=async({commitFn:e,batchId:t,chunkIds:r,headers:n,data:i})=>{let s=n.find(([o,a])=>o.toLowerCase()==="content-type")===void 0&&i.type!==void 0&&i.type!==""?[["Content-Type",i.type]]:void 0;await e({batch_id:t,chunk_ids:r.map(({chunk_id:o})=>o),headers:[...n,...s??[]]})},CT=async({data:e,uploadFn:t,batchId:r})=>{let n=[],i=dc()?new Blob([await e.arrayBuffer()]):e,s=0n;for(let a=0;a<i.size;a+=19e5){let c=i.slice(a,a+19e5);n.push({batchId:r,chunk:c,uploadFn:t,orderId:s}),s++}let o=[];for await(let a of MT({uploadChunks:n}))o=[...o,...a];return{chunkIds:o}};async function*MT({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=>qT(i)))}}var qT=async({batchId:e,chunk:t,uploadFn:r,orderId:n})=>r({batch_id:e,content:new Uint8Array(await t.arrayBuffer()),order_id:(0,eo.toNullable)(n)});var Py=async({asset:e,...t})=>{let r=await dt(t);await By({actor:r,asset:e})},Uy=async({collection:e,filter:t,...r})=>{let{list_assets:n}=await dt(r),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(e,jn(t));return{items:i.map(([d,f])=>f),items_length:s,items_page:(0,to.fromNullable)(o),matches_length:a,matches_pages:(0,to.fromNullable)(c)}},Fy=async({collection:e,filter:t,...r})=>{let{count_assets:n}=await dt(r);return n(e,jn(t))},Cy=async({collection:e,fullPath:t,...r})=>(await dt(r)).del_asset(e,t),My=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)},qy=async({collection:e,filter:t,...r})=>{let{del_filtered_assets:n}=await dt(r);return n(e,jn(t))},jy=async({collection:e,fullPath:t,...r})=>{let{get_asset:n}=await dt(r);return(0,to.fromNullable)(await n(e,t))},ky=async({assets:e,...t})=>{let{get_many_assets:r}=await dt(t),n=e.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>(0,to.fromNullable)(o))};var Vy=e=>btoa([...e].map(t=>String.fromCharCode(t)).join(""));var U6=e=>Hy(e),F6=e=>Hy({filename:e.data.name,...e}),Hy=async({filename:e,data:t,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let d=et(o?.identity),f=decodeURI(e),h=i??`/${r}/${f}`,m={...o,identity:d};return await Py({asset:{data:t,filename:f,collection:r,token:s,headers:n,fullPath:h,encoding:a,description:c},satellite:m,options:{certified:!0}}),{downloadUrl:Ky({satellite:m,assetKey:{fullPath:h,token:s}}),fullPath:h,name:f}},C6=async({collection:e,filter:t,satellite:r,options:n})=>{let i={...r,identity:et(r?.identity)},{items:s,...o}=await Uy({collection:e,filter:t??{},satellite:i,options:n??Zr}),a=s.map(({key:{full_path:c,token:d,name:f,owner:h,description:m},headers:b,encodings:l,created_at:S,updated_at:A})=>{let F=(0,ro.fromNullable)(d);return{fullPath:c,description:(0,ro.fromNullable)(m),name:f,downloadUrl:Ky({satellite:i,assetKey:{fullPath:c,token:F}}),token:F,headers:b,encodings:l.reduce((q,[v,{modified:G,sha256:E,total_length:j}])=>({...q,[v]:{modified:G,sha256:Vy(E),total_length:j}}),{}),owner:h.toText(),created_at:S,updated_at:A}});return{items:a,assets:a,...o}},M6=async({collection:e,filter:t,satellite:r,options:n})=>{let i={...r,identity:et(r?.identity)};return await Fy({collection:e,satellite:i,filter:t??{},options:n??Zr})},q6=({collection:e,fullPath:t,satellite:r})=>Cy({collection:e,fullPath:t,satellite:{...r,identity:et(r?.identity)},options:{certified:!0}}),j6=({assets:e,satellite:t})=>My({assets:e,satellite:{...t,identity:et(t?.identity)},options:{certified:!0}}),k6=async({collection:e,satellite:t,filter:r})=>{let n={...t,identity:et(t?.identity)};return await qy({collection:e,satellite:n,filter:r??{},options:{certified:!0}})},V6=async({satellite:e,options:t,...r})=>{let n=et(e?.identity);return await jy({...r,satellite:{...e,identity:n},options:t??Zr})},H6=async({satellite:e,options:t,...r})=>{let n=et(e?.identity);return await ky({...r,satellite:{...e,identity:n},options:t??Zr})},Ky=({assetKey:{fullPath:e,token:t},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${ay(n)}${e}${(0,ro.nonNullish)(t)?`?token=${t}`:""}`};var jT=e=>{let t=e?.satelliteId??Sy();(0,$y.assertNonNullish)(t,"Satellite ID is not configured. Juno cannot be initialized.");let r=e?.container??Ry();return{satelliteId:t,internetIdentityId:e?.internetIdentityId,workers:e?.workers,container:r}},J6=e=>kT(e),kT=async e=>{let t=jT(e);Jr.getInstance().set(t),await Dd();let r=t.workers?.auth!==void 0?Ny(t.workers.auth):void 0;return[...r?[r]:[]]},Z6=e=>Wr.getInstance().subscribe(e);export{gc as InitError,fc as InternetIdentityProvider,bc as ListError,D_ as NFIDProvider,_c as SignInError,yc as SignInInitError,mc as SignInUserInterruptError,Z6 as authSubscribe,M6 as countAssets,XO as countDocs,q6 as deleteAsset,WO as deleteDoc,k6 as deleteFilteredAssets,JO as deleteFilteredDocs,j6 as deleteManyAssets,zO as deleteManyDocs,Ky as downloadUrl,V6 as getAsset,xy as getDoc,PT as getIdentityOnce,H6 as getManyAssets,GO as getManyDocs,g6 as getSatelliteExtendedActor,J6 as initJuno,kT as initSatellite,C6 as listAssets,ZO as listDocs,Ty as setDoc,YO as setManyDocs,ST as signIn,Ld as signOut,BT as unsafeIdentity,U6 as uploadBlob,F6 as uploadFile};
55
+ `)}throw new Error("unreachable")}Xt.pollForResponse=Ip});var Dp=ee(Il=>{"use strict";Object.defineProperty(Il,"__esModule",{value:!0});Il.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,o=e.Nat32,a=e.Record({start_height:o,end_height:e.Opt(o),network:t}),c=e.Vec(e.Nat8),d=e.Record({tip_height:o,block_headers:e.Vec(c)}),f=e.Record({network:t}),h=e.Nat64,m=e.Vec(h),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),S=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),N=e.Record({height:e.Nat32,value:i,outpoint:S}),F=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:o,tip_block_hash:l,utxos:e.Vec(N)}),q=e.Record({transaction:e.Vec(e.Nat8),network:t}),O=e.Principal,G=e.Record({canister_id:O,num_requested_changes:e.Opt(e.Nat64)}),E=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),j=e.Vec(e.Nat8),Y=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:j}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),z=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:E,details:Y}),k=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(z),total_num_changes:e.Nat64}),oe=e.Record({canister_id:O}),L=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:L,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}),R=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(L),wasm_memory_limit:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),A=e.Record({settings:e.Opt(R),sender_canister_version:e.Opt(e.Nat64)}),B=e.Record({canister_id:O}),K=e.Record({canister_id:O}),X=e.Record({canister_id:O,snapshot_id:j}),ae=e.Record({canister_id:O}),se=e.Variant({secp256k1:e.Null}),Z=e.Record({key_id:e.Record({name:e.Text,curve:se}),canister_id:e.Opt(O),derivation_path:e.Vec(e.Vec(e.Nat8))}),C=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),_=e.Record({canister_id:O}),I=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),re=e.Record({canister_log_records:e.Vec(I)}),le=e.Record({value:e.Text,name:e.Text}),D=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:D})],[D],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(le)}),p=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)}),U=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:p,chunk_hashes_list:e.Vec(y),target_canister:O,store_canister:e.Opt(O),sender_canister_version:e.Opt(e.Nat64)}),v=e.Vec(e.Nat8),P=e.Record({arg:e.Vec(e.Nat8),wasm_module:v,mode:p,canister_id:O,sender_canister_version:e.Opt(e.Nat64)}),H=e.Record({canister_id:O}),x=e.Record({id:j,total_size:e.Nat64,taken_at_timestamp:e.Nat64}),M=e.Vec(x),$=e.Record({canister_id:O,sender_canister_version:e.Opt(e.Nat64),snapshot_id:j}),V=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),Q=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(Q)})),de=e.Record({settings:e.Opt(R),specified_id:e.Opt(O),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),ge=e.Record({canister_id:O}),Re=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))}),$e=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),Kt=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)}),Ct=e.Variant({bip341:e.Record({merkle_root_hash:e.Vec(e.Nat8)})}),$t=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)}),Ot=e.Record({canister_id:O}),ot=e.Record({canister_id:O}),Ge=e.Record({canister_id:O}),Tc=e.Vec(y),Oc=e.Record({subnet_id:e.Principal}),Ye=e.Record({replica_version:e.Text}),vc=e.Record({replace_snapshot:e.Opt(j),canister_id:O}),Nc=x,Ac=e.Record({canister_id:O,sender_canister_version:e.Opt(e.Nat64)}),Sc=e.Record({canister_id:e.Principal,settings:R,sender_canister_version:e.Opt(e.Nat64)}),Rc=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([a],[d],[]),bitcoin_get_current_fee_percentiles:e.Func([f],[m],[]),bitcoin_get_utxos:e.Func([b],[F],[]),bitcoin_send_transaction:e.Func([q],[],[]),canister_info:e.Func([G],[k],[]),canister_status:e.Func([oe],[w],[]),clear_chunk_store:e.Func([g],[],[]),create_canister:e.Func([A],[B],[]),delete_canister:e.Func([K],[],[]),delete_canister_snapshot:e.Func([X],[],[]),deposit_cycles:e.Func([ae],[],[]),ecdsa_public_key:e.Func([Z],[C],[]),fetch_canister_logs:e.Func([_],[re],["query"]),http_request:e.Func([u],[D],[]),install_chunked_code:e.Func([U],[],[]),install_code:e.Func([P],[],[]),list_canister_snapshots:e.Func([H],[M],[]),load_canister_snapshot:e.Func([$],[],[]),node_metrics_history:e.Func([V],[te],[]),provisional_create_canister_with_cycles:e.Func([de],[ge],[]),provisional_top_up_canister:e.Func([Re],[],[]),raw_rand:e.Func([],[Fe],[]),schnorr_public_key:e.Func([fe],[$e],[]),sign_with_ecdsa:e.Func([Kt],[Ft],[]),sign_with_schnorr:e.Func([$t],[Be],[]),start_canister:e.Func([Ot],[],[]),stop_canister:e.Func([ot],[],[]),stored_chunks:e.Func([Ge],[Tc],[]),subnet_info:e.Func([Oc],[Ye],[]),take_canister_snapshot:e.Func([vc],[Nc],[]),uninstall_code:e.Func([Ac],[],[]),update_settings:e.Func([Sc],[],[]),upload_chunk:e.Func([Rc],[cn],[])})}});var Za=ee(Je=>{"use strict";var wE=Je&&Je.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Je,"__esModule",{value:!0});Je.AdvancedActor=Je.getManagementCanister=Je.ACTOR_METHOD_WITH_CERTIFICATE=Je.ACTOR_METHOD_WITH_HTTP_DETAILS=Je.Actor=Je.UpdateCallRejectedError=Je.QueryCallRejectedError=Je.ActorCallError=void 0;var EE=xf(),Dl=Ns(),Ll=_i(),qs=xi(),Lp=Wa(),dr=Mt(),xE=Yt(),Hi=Si(),TE=wE(Dp()),js=class extends Ll.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}};Je.ActorCallError=js;var Ja=class extends js{constructor(t,r,n){var i;super(t,r,"query",{Status:n.status,Code:(i=Dl.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};Je.QueryCallRejectedError=Ja;var ks=class extends js{constructor(t,r,n,i,s,o,a){super(t,r,"update",Object.assign({"Request ID":(0,xE.toHex)(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(s),"Reject message":o}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=o,this.error_code=a}};Je.UpdateCallRejectedError=ks;var lr=Symbol.for("ic-agent-metadata"),Vs=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)],o=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:o,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(o){if(!o.canisterId)throw new Ll.AgentError(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?dr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},e_),o),{canisterId:a}),service:n});for(let[c,d]of n._fields)r?.httpDetails&&d.annotations.push(Je.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&d.annotations.push(Je.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=OE(this,c,d,o.blsVerify)}}return i}static createActor(t,r){if(!r.canisterId)throw new Ll.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)}};Je.Actor=Vs;function Ki(e,t){let r=qs.IDL.decode(e,EE.Buffer.from(t));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var e_={pollingStrategyFactory:Lp.strategy.defaultStrategy};Je.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";Je.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function OE(e,t,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,d;o=Object.assign(Object.assign({},o),(d=(c=e[lr].config).queryTransform)===null||d===void 0?void 0:d.call(c,t,a,Object.assign(Object.assign({},e[lr].config),o)));let f=o.agent||e[lr].config.agent||(0,Dl.getDefaultAgent)(),h=dr.Principal.from(o.canisterId||e[lr].config.canisterId),m=qs.IDL.encode(r.argTypes,a),b=await f.query(h,{methodName:t,arg:m,effectiveCanisterId:o.effectiveCanisterId}),l=Object.assign(Object.assign({},b.httpDetails),{requestDetails:b.requestDetails});switch(b.status){case"rejected":throw new Ja(h,t,b);case"replied":return r.annotations.includes(Je.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:l,result:Ki(r.retTypes,b.reply.arg)}:Ki(r.retTypes,b.reply.arg)}}:i=async(o,...a)=>{var c,d;o=Object.assign(Object.assign({},o),(d=(c=e[lr].config).callTransform)===null||d===void 0?void 0:d.call(c,t,a,Object.assign(Object.assign({},e[lr].config),o)));let f=o.agent||e[lr].config.agent||(0,Dl.getDefaultAgent)(),{canisterId:h,effectiveCanisterId:m,pollingStrategyFactory:b}=Object.assign(Object.assign(Object.assign({},e_),e[lr].config),o),l=dr.Principal.from(h),S=m!==void 0?dr.Principal.from(m):l,N=qs.IDL.encode(r.argTypes,a),{requestId:F,response:q,requestDetails:O}=await f.call(l,{methodName:t,arg:N,effectiveCanisterId:S}),G,E;if(q.body&&q.body.certificate){if(f.rootKey==null)throw new Error("Agent is missing root key");let k=q.body.certificate;E=await Hi.Certificate.create({certificate:(0,qs.bufFromBufLike)(k),rootKey:f.rootKey,canisterId:dr.Principal.from(h),blsVerify:n});let oe=[new TextEncoder().encode("request_status"),F];switch(new TextDecoder().decode((0,Hi.lookupResultToBuffer)(E.lookup([...oe,"status"])))){case"replied":G=(0,Hi.lookupResultToBuffer)(E.lookup([...oe,"reply"]));break;case"rejected":{let ne=new Uint8Array((0,Hi.lookupResultToBuffer)(E.lookup([...oe,"reject_code"])))[0],w=new TextDecoder().decode((0,Hi.lookupResultToBuffer)(E.lookup([...oe,"reject_message"]))),g=(0,Hi.lookupResultToBuffer)(E.lookup([...oe,"error_code"])),R=g?new TextDecoder().decode(g):void 0;throw new ks(l,t,F,q,ne,w,R)}}}else if(q.body&&"reject_message"in q.body){let{reject_code:k,reject_message:oe,error_code:L}=q.body;throw new ks(l,t,F,q,k,oe,L)}if(q.status===202){let k=b(),oe=await(0,Lp.pollForResponse)(f,S,F,k,n);E=oe.certificate,G=oe.reply}let j=r.annotations.includes(Je.ACTOR_METHOD_WITH_HTTP_DETAILS),Y=r.annotations.includes(Je.ACTOR_METHOD_WITH_CERTIFICATE),z=Object.assign(Object.assign({},q),{requestDetails:O});if(G!==void 0)return j&&Y?{httpDetails:z,certificate:E,result:Ki(r.retTypes,G)}:Y?{certificate:E,result:Ki(r.retTypes,G)}:j?{httpDetails:z,result:Ki(r.retTypes,G)}:Ki(r.retTypes,G);if(r.retTypes.length===0)return j?{httpDetails:q,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),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 Vs.createActor(TE.default,Object.assign(Object.assign(Object.assign({},e),{canisterId:dr.Principal.fromHex("")}),{callTransform:t,queryTransform:t}))}Je.getManagementCanister=ed;var td=class extends Vs{constructor(t){super(t)}};Je.AdvancedActor=td});var t_=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 r_=ee($i=>{"use strict";var vE=$i&&$i.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty($i,"__esModule",{value:!0});$i.createAssetCanisterActor=void 0;var NE=Za(),AE=vE(t_());function SE(e){return NE.Actor.createActor(AE.default,e)}$i.createAssetCanisterActor=SE});var n_=ee(zr=>{"use strict";var RE=zr&&zr.__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]}),BE=zr&&zr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),PE=zr&&zr.__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)&&RE(t,e,r);return BE(t,e),t};Object.defineProperty(zr,"__esModule",{value:!0});zr.fetchCandid=void 0;var UE=Mt(),FE=PE(As()),CE=Zl(),ME=Za();async function qE(e,t){t||(t=await CE.HttpAgent.create());let n=(await FE.request({agent:t,canisterId:UE.Principal.fromText(e),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:o})=>o.Service({__get_candid_interface_tmp_hack:o.Func([],[o.Text],["query"])});return await ME.Actor.createActor(i,{agent:t,canisterId:e}).__get_candid_interface_tmp_hack()}zr.fetchCandid=qE});var tr=ee(Pe=>{"use strict";var i_=Pe&&Pe.__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]}),jE=Pe&&Pe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ut=Pe&&Pe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&i_(t,e,r)},nd=Pe&&Pe.__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)&&i_(t,e,r);return jE(t,e),t};Object.defineProperty(Pe,"__esModule",{value:!0});Pe.Cbor=Pe.CanisterStatus=Pe.polling=void 0;Ut(Za(),Pe);Ut(Ns(),Pe);Ut(Do(),Pe);Ut(ys(),Pe);Ut(Ku(),Pe);Ut(r_(),Pe);Ut(Si(),Pe);Ut($l(),Pe);Ut(n_(),Pe);Ut(zl(),Pe);Ut(Gl(),Pe);Ut(fs(),Pe);Ut(El(),Pe);Ut(Yt(),Pe);Ut(Qu(),Pe);Pe.polling=nd(Wa());Pe.CanisterStatus=nd(As());Pe.Cbor=nd(_s());Ut(Wa(),Pe)});var nt=ee((E8,T_)=>{"use strict";var cd=Object.defineProperty,kE=Object.getOwnPropertyDescriptor,VE=Object.getOwnPropertyNames,HE=Object.prototype.hasOwnProperty,KE=(e,t)=>{for(var r in t)cd(e,r,{get:t[r],enumerable:!0})},$E=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of VE(t))!HE.call(e,i)&&i!==r&&cd(e,i,{get:()=>t[i],enumerable:!(n=kE(t,i))||n.enumerable});return e},GE=e=>$E(cd({},"__esModule",{value:!0}),e),c_={};KE(c_,{AgentManager:()=>LE,Canister:()=>QE,FromStringToTokenError:()=>u_,ICPToken:()=>JE,InvalidPercentageError:()=>__,NullishError:()=>y_,TokenAmount:()=>ZE,TokenAmountV2:()=>XE,arrayBufferToUint8Array:()=>ox,arrayOfNumberToUint8Array:()=>cx,asNonNullish:()=>tx,asciiStringToByteArray:()=>ux,assertNonNullish:()=>Ys,assertPercentageNumber:()=>rx,base64ToUint8Array:()=>_x,bigEndianCrc32:()=>gx,bigIntToUint8Array:()=>ix,candidNumberArrayToBigInt:()=>dx,convertStringToE8s:()=>l_,createAgent:()=>h_,createServices:()=>ex,debounce:()=>Nx,decodeBase32:()=>hx,defaultAgent:()=>f_,encodeBase32:()=>fx,fromDefinedNullable:()=>Sx,fromNullable:()=>ud,fromNullishNullable:()=>Rx,hashObject:()=>wx,hashText:()=>w_,hexStringToUint8Array:()=>lx,isEmptyString:()=>IE,isNullish:()=>Gs,jsonReplacer:()=>b_,jsonReviver:()=>bx,nonNullish:()=>Wr,notEmptyString:()=>d_,nowInBigIntNanoSeconds:()=>Ox,numberToUint8Array:()=>sx,principalToSubAccount:()=>Bx,queryAndUpdate:()=>DE,secondsToDuration:()=>xx,smallerVersion:()=>Px,toBigIntNanoSeconds:()=>vx,toNullable:()=>Ax,uint8ArrayToArrayOfNumber:()=>ax,uint8ArrayToBase64:()=>px,uint8ArrayToBigInt:()=>nx,uint8ArrayToHexString:()=>m_});T_.exports=GE(c_);var u_=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(u_||{}),YE=BigInt(1e8),zE=8,l_=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)*YE}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},WE=({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,o=10n**BigInt(t);if(n)try{s+=BigInt(n)*o}catch{return 1}if(i){if(i.length>t)return 2;try{s+=BigInt(i.padEnd(t,"0"))}catch{return 1}}return s},JE={symbol:"ICP",name:"Internet Computer",decimals:8},ZE=class Ks{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 Ks(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=l_(t);return typeof n=="bigint"?new Ks(n,r):n}static fromNumber({amount:t,token:r}){let n=Ks.fromString({amount:t.toString(),token:r});if(n instanceof Ks)return n;throw n===0?new Error(`Number ${t} has more than 8 decimals`):new Error(`Invalid number ${t}`)}toE8s(){return this.e8s}},XE=class $s{constructor(t,r){this.ulps=t,this.token=r}static fromUlps({amount:t,token:r}){return new $s(t,r)}static fromString({amount:t,token:r}){let n=WE({amount:t,decimals:r.decimals});return typeof n=="bigint"?new $s(n,r):n}static fromNumber({amount:t,token:r}){let n=$s.fromString({amount:t.toFixed(Math.min(zE,r.decimals)),token:r});if(n instanceof $s)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)}},QE=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}},Gs=e=>e==null,Wr=e=>!Gs(e),d_=e=>Wr(e)&&e!=="",IE=e=>!d_(e),DE=async({request:e,onLoad:t,onQueryError:r,onUpdateError:n,strategy:i="query_and_update",identity:s,resolution:o="race"})=>{let a=!1,c=f=>e({certified:f,identity:s}).then(h=>{a||t({certified:f,response:h})}).catch(h=>{f||r==null||r({error:h,identity:s}),!a&&(Gs(n)||(console.error(h),f&&n({error:h,identity:s})))}).finally(()=>a=a||f),d=i==="query"?[c(!1)]:i==="update"?[c(!0)]:[c(!1),c(!0)];await(o==="all_settled"?Promise.allSettled(d):Promise.race(d))},s_=tr(),id=tr(),f_=()=>id.HttpAgent.createSync({host:"https://icp-api.io",identity:new id.AnonymousIdentity}),h_=async({identity:e,host:t,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await id.HttpAgent.create({identity:e,...Wr(t)&&{host:t},verifyQuerySignatures:n,...Wr(i)&&{retryTimes:i},shouldFetchRootKey:r}),LE=class p_{constructor(t){this.config=t,this.agents=void 0,this.getAgent=async({identity:r})=>{let n=r.getPrincipal().toText();if(Gs(this.agents)||Gs(this.agents[n])){let i=await h_({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)}},ex=({options:{canisterId:e,serviceOverride:t,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:o,certifiedIdlFactory:a})=>{let c=n??f_(),d=t??s_.Actor.createActor(o,{agent:c,canisterId:e,callTransform:i,queryTransform:s}),f=r??s_.Actor.createActor(a,{agent:c,canisterId:e,callTransform:i,queryTransform:s});return{service:d,certifiedService:f,agent:c,canisterId:e}},__=class extends Error{},y_=class extends Error{},Ys=(e,t)=>{if(e==null)throw new y_(t)},tx=(e,t)=>(Ys(e,t),e),rx=e=>{if(e<0||e>100)throw new __(`${e} is not a valid percentage number.`)},nx=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}},ix=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)},sx=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)},ox=e=>new Uint8Array(e),ax=e=>Array.from(e),cx=e=>new Uint8Array(e),ux=e=>Array.from(e).map(t=>t.charCodeAt(0)),lx=e=>{let t=e.match(/.{1,2}/g);return Ys(t,"Invalid hex string."),Uint8Array.from(t.map(r=>parseInt(r,16)))},m_=e=>(e instanceof Uint8Array||(e=Uint8Array.from(e)),e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")),dx=e=>{let t=0n;for(let r=e.length-1;r>=0;r--)t=(t<<32n)+BigInt(e[r]);return t},Xa="abcdefghijklmnopqrstuvwxyz234567",Gi=Object.create(null);for(let e=0;e<Xa.length;e++)Gi[Xa[e]]=e;Gi[0]=Gi.o;Gi[1]=Gi.i;var fx=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+=Xa[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?Xa[r>>3]:"")};function hx(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0;function s(o){let a=Gi[o.toLowerCase()];Ys(a,`Invalid character: ${JSON.stringify(o)}`),a<<=3,r|=a>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=a<<5-t&255:r=0)}for(let o of e)s(o);return n.slice(0,i)}var px=e=>btoa(String.fromCharCode(...new Uint8Array(e))),_x=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)),yx=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]),mx=e=>{let t=-1;for(let r=0;r<e.length;r++){let n=(e[r]^t)&255;t=yx[n]^t>>>8}return(t^-1)>>>0},gx=e=>{let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,mx(e),!1),new Uint8Array(t)},g_=Mt(),sd="__bigint__",od="__principal__",ad="__uint8array__",b_=(e,t)=>typeof t=="bigint"?{[sd]:`${t}`}:Wr(t)&&t instanceof g_.Principal?{[od]:t.toText()}:Wr(t)&&t instanceof Uint8Array?{[ad]:Array.from(t)}:t,bx=(e,t)=>{let r=n=>t[n];return Wr(t)&&typeof t=="object"&&sd in t?BigInt(r(sd)):Wr(t)&&typeof t=="object"&&od in t?g_.Principal.fromText(r(od)):Wr(t)&&typeof t=="object"&&ad in t?Uint8Array.from(r(ad)):t},wx=async e=>{let t=JSON.stringify(e,b_);return await w_(t)},w_=async e=>{let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return m_(new Uint8Array(r))},Ex={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"},xx=({seconds:e,i18n:t=Ex})=>{let r=e/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=Tx(i);return i-=E_(s),[Hs("year",s),Hs("day",i),Hs("hour",n),Hs("minute",r),...e>BigInt(0)&&e<BigInt(60)?[Hs("second",e)]:[]].filter(({amount:o})=>o>0).slice(0,2).map(o=>`${o.amount} ${o.amount===1?t[o.labelKey]:t[`${o.labelKey}_plural`]}`).join(", ")},Tx=e=>{let t=e/BigInt(365);for(;E_(t)>e;)t--;return t},E_=e=>{let t=e/BigInt(4);return e*BigInt(365)+t},Hs=(e,t)=>({labelKey:e,amount:Number(t)}),x_=1000000n,Ox=()=>BigInt(Date.now())*x_,vx=e=>BigInt(e.getTime())*x_,Nx=(e,t)=>{let r;return(...n)=>{let i=()=>e(...n);r&&clearTimeout(r),r=setTimeout(i,t!==void 0&&t>0?t:300)}},Ax=e=>Wr(e)?[e]:[],ud=e=>e?.[0],Sx=e=>{let t=ud(e);return Ys(t),t},Rx=e=>ud(e??[]),Bx=e=>{let t=e.toUint8Array(),r=new Uint8Array(32);return r[0]=t.length,r.set(t,1),r},o_=(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)},Px=({minVersion:e,currentVersion:t})=>{let r=o_(e.split(".").map(a_),3).join(".");return o_(t.split(".").map(a_),3).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var v_=ee(Zr=>{"use strict";var Da=Zr&&Zr.__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},Un=Zr&&Zr.__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)},Qa,Ia,zi,Wi;Object.defineProperty(Zr,"__esModule",{value:!0});Zr.Ed25519KeyIdentity=Zr.Ed25519PublicKey=void 0;var Ux=tr(),rr=tr(),zs=Hl();function O_(e){return e!==null&&typeof e=="object"}var ni=class e{constructor(t){if(Qa.set(this,void 0),Ia.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Da(this,Qa,t,"f"),Da(this,Ia,e.derEncode(t),"f")}static from(t){if(typeof t=="string"){let r=(0,rr.fromHex)(t);return this.fromRaw(r)}else if(O_(t)){let r=t;if(O_(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 Un(this,Qa,"f")}get derKey(){return Un(this,Ia,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Zr.Ed25519PublicKey=ni;Qa=new WeakMap,Ia=new WeakMap;ni.RAW_KEY_LENGTH=32;var dd=class e extends rr.SignIdentity{constructor(t,r){super(),zi.set(this,void 0),Wi.set(this,void 0),Da(this,zi,ni.from(t),"f"),Da(this,Wi,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=zs.ed25519.utils.randomPrivateKey()),(0,Ux.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=zs.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=zs.ed25519.getPublicKey(new Uint8Array(t));return e.fromKeyPair(r,t)}toJSON(){return[(0,rr.toHex)(Un(this,zi,"f").toDer()),(0,rr.toHex)(Un(this,Wi,"f"))]}getKeyPair(){return{secretKey:Un(this,Wi,"f"),publicKey:Un(this,zi,"f")}}getPublicKey(){return Un(this,zi,"f")}async sign(t){let r=new Uint8Array(t),n=(0,rr.uint8ToBuf)(zs.ed25519.sign(r,Un(this,Wi,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(t,r,n){let[i,s,o]=[t,r,n].map(a=>(typeof a=="string"&&(a=(0,rr.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return zs.ed25519.verify(s,i,o)}};Zr.Ed25519KeyIdentity=dd;zi=new WeakMap,Wi=new WeakMap});var A_=ee(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.ECDSAKeyIdentity=ii.CryptoError=void 0;var Fx=tr(),La=class e extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,e.prototype)}};ii.CryptoError=La;function N_(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 La("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 Fx.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=N_(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await s.exportKey("spki",o.publicKey);return new this(o,a,s)}static async fromKeyPair(t,r){let n=N_(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 hd=ee(Cn=>{"use strict";var Cx=Cn&&Cn.__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},Ws=Cn&&Cn.__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(Cn,"__esModule",{value:!0});Cn.PartialIdentity=void 0;var Mx=Mt(),fd=class{constructor(t){Fn.set(this,void 0),Cx(this,Fn,t,"f")}get rawKey(){return Ws(this,Fn,"f").rawKey}get derKey(){return Ws(this,Fn,"f").derKey}toDer(){return Ws(this,Fn,"f").toDer()}getPublicKey(){return Ws(this,Fn,"f")}getPrincipal(){return Mx.Principal.from(Ws(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.")}};Cn.PartialIdentity=fd;Fn=new WeakMap});var S_=ee(Qe=>{"use strict";var qx=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]}),jx=Qe&&Qe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),kx=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)&&qx(t,e,r);return jx(t,e),t},Vx=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},Hx=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)},Kx=Qe&&Qe.__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(Qe,"__esModule",{value:!0});Qe.isDelegationValid=Qe.PartialDelegationIdentity=Qe.DelegationIdentity=Qe.DelegationChain=Qe.Delegation=void 0;var Mn=tr(),_d=Mt(),Js=kx(ps()),$x=hd(),Gx=new TextEncoder().encode("ic-request-auth-delegation"),Yx=new TextEncoder().encode(`
57
+ ic-request`);function pd(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return(0,Mn.fromHex)(e)}var Zs=class{constructor(t,r,n){this.pubkey=t,this.expiration=r,this.targets=n}toCBOR(){return Js.value.map(Object.assign({pubkey:Js.value.bytes(this.pubkey),expiration:Js.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Js.value.array(this.targets.map(t=>Js.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Mn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};Qe.Delegation=Zs;async function zx(e,t,r,n){let i=new Zs(t.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...Gx,...new Uint8Array((0,Mn.requestIdOf)(Object.assign({},i)))]),o=await e.sign(s);return{delegation:i,signature:o}}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,o;let a=await zx(t,r,n,i.targets);return new e([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],a],((o=i.previous)===null||o===void 0?void 0:o.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:o,signature:a}=s,{pubkey:c,expiration:d,targets:f}=o;if(f!==void 0&&!Array.isArray(f))throw new Error("Invalid targets.");return{delegation:new Zs(pd(c),BigInt("0x"+d),f&&f.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return _d.Principal.fromHex(h)})),signature:pd(a)}});return new this(i,pd(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,Mn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Mn.toHex)(n)}}),publicKey:(0,Mn.toHex)(this.publicKey)}}};Qe.DelegationChain=yd;var md=class extends Mn.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=Kx(t,["body"]),i=await(0,Mn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Yx,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};Qe.DelegationIdentity=md;var gd=class e extends $x.PartialIdentity{constructor(t,r){super(t),tc.set(this,void 0),Vx(this,tc,r,"f")}get delegation(){return Hx(this,tc,"f")}static fromDelegation(t,r){return new e(t,r)}};Qe.PartialDelegationIdentity=gd;tc=new WeakMap;function Wx(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:o}of e.delegations){if(o.targets===void 0)continue;let a=!0;for(let c of o.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}Qe.isDelegationValid=Wx});var R_=ee(qn=>{"use strict";var Jx=qn&&qn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(qn,"__esModule",{value:!0});qn.WebAuthnIdentity=qn.CosePublicKey=void 0;var si=tr(),bd=Jx($o()),Zx=Hn(),Xx=xi();function Qx(e){return(0,si.wrapDER)(e,si.DER_COSE_OID).buffer}function Ix(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=Qx(t)}toDer(){return this._encodedKey}getCose(){return this._cose}};qn.CosePublicKey=rc;function Dx(e="<ic0.app>"){return typeof e=="string"?Uint8Array.from(e,t=>t.charCodeAt(0)):e}async function Lx(e){let t=await navigator.credentials.create(e??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:Dx(),pubKeyCredParams:[{type:"public-key",alg:wd.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Zx.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,Xx.bufFromBufLike)(t.rawId)}}var wd;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(wd||(wd={}));var Ed=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 Lx(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,Ix(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)}}};qn.WebAuthnIdentity=Ed});var P_=ee(Ze=>{"use strict";var eT=Ze&&Ze.__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]}),Td=Ze&&Ze.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&eT(t,e,r)};Object.defineProperty(Ze,"__esModule",{value:!0});Ze.Secp256k1KeyIdentity=Ze.ED25519_OID=Ze.DER_COSE_OID=Ze.unwrapDER=Ze.wrapDER=Ze.WebAuthnIdentity=Ze.Ed25519PublicKey=Ze.Ed25519KeyIdentity=void 0;var B_=v_();Object.defineProperty(Ze,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return B_.Ed25519KeyIdentity}});Object.defineProperty(Ze,"Ed25519PublicKey",{enumerable:!0,get:function(){return B_.Ed25519PublicKey}});Td(A_(),Ze);Td(S_(),Ze);Td(hd(),Ze);var tT=R_();Object.defineProperty(Ze,"WebAuthnIdentity",{enumerable:!0,get:function(){return tT.WebAuthnIdentity}});var nc=tr();Object.defineProperty(Ze,"wrapDER",{enumerable:!0,get:function(){return nc.wrapDER}});Object.defineProperty(Ze,"unwrapDER",{enumerable:!0,get:function(){return nc.unwrapDER}});Object.defineProperty(Ze,"DER_COSE_OID",{enumerable:!0,get:function(){return nc.DER_COSE_OID}});Object.defineProperty(Ze,"ED25519_OID",{enumerable:!0,get:function(){return nc.ED25519_OID}});var xd=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};Ze.Secp256k1KeyIdentity=xd});var vd=ee(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.IdleManager=void 0;var U_=["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),U_.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let d;return(...f)=>{let h=this,m=function(){d=void 0,a.apply(h,f)};clearTimeout(d),d=window.setTimeout(m,c)}};if(t?.captureScroll){let a=o(s,(r=t?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!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);U_.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 nT(){return F_||(F_=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function iT(){return C_||(C_=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function sT(e){let t=new Promise((r,n)=>{let i=()=>{e.removeEventListener("success",s),e.removeEventListener("error",o)},s=()=>{r(fr(e.result)),i()},o=()=>{n(e.error),i()};e.addEventListener("success",s),e.addEventListener("error",o)});return t.then(r=>{r instanceof IDBCursor&&M_.set(r,e)}).catch(()=>{}),Rd.set(t,e),t}function oT(e){if(Ad.has(e))return;let t=new Promise((r,n)=>{let i=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",o),e.removeEventListener("abort",o)},s=()=>{r(),i()},o=()=>{n(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",s),e.addEventListener("error",o),e.addEventListener("abort",o)});Ad.set(e,t)}function j_(e){Sd=e(Sd)}function aT(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...r){let n=e.call(Xs(this),t,...r);return q_.set(n,t.sort?t.sort():[t]),fr(n)}:iT().includes(e)?function(...t){return e.apply(Xs(this),t),fr(M_.get(this))}:function(...t){return fr(e.apply(Xs(this),t))}}function cT(e){return typeof e=="function"?aT(e):(e instanceof IDBTransaction&&oT(e),rT(e,nT())?new Proxy(e,Sd):e)}function fr(e){if(e instanceof IDBRequest)return sT(e);if(Nd.has(e))return Nd.get(e);let t=cT(e);return t!==e&&(Nd.set(e,t),Rd.set(t,e)),t}var rT,F_,C_,M_,Ad,q_,Nd,Rd,Sd,Xs,Bd=ef(()=>{rT=(e,t)=>t.some(r=>e instanceof r);M_=new WeakMap,Ad=new WeakMap,q_=new WeakMap,Nd=new WeakMap,Rd=new WeakMap;Sd={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return Ad.get(e);if(t==="objectStoreNames")return e.objectStoreNames||q_.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}};Xs=e=>Rd.get(e)});var V_={};cm(V_,{deleteDB:()=>lT,openDB:()=>uT,unwrap:()=>Xs,wrap:()=>fr});function uT(e,t,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(e,t),a=fr(o);return n&&o.addEventListener("upgradeneeded",c=>{n(fr(o.result),c.oldVersion,c.newVersion,fr(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",d=>i(d.oldVersion,d.newVersion,d))}).catch(()=>{}),a}function lT(e,{blocked:t}={}){let r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),fr(r).then(()=>{})}function k_(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=fT.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||dT.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),d=c.store;return n&&(d=d.index(a.shift())),(await Promise.all([d[r](...a),i&&c.done]))[0]};return Pd.set(t,s),s}var dT,fT,Pd,H_=ef(()=>{Bd();Bd();dT=["get","getKey","getAll","getAllKeys","count"],fT=["put","add","delete","clear"],Pd=new Map;j_(e=>({...e,get:(t,r,n)=>k_(t,r)||e.get(t,r,n),has:(t,r)=>!!k_(t,r)||e.has(t,r)}))});var Fd=ee(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.IdbKeyVal=void 0;var hT=(H_(),um(V_)),Qs=oc(),K_="auth-client-db",$_="ic-keyval",pT=async(e=K_,t=$_,r)=>(Qs.isBrowser&&(localStorage!=null&&localStorage.getItem(Qs.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Qs.KEY_STORAGE_DELEGATION),localStorage.removeItem(Qs.KEY_STORAGE_KEY)),await(0,hT.openDB)(e,r,{upgrade:n=>{n.objectStoreNames.contains(t)&&n.clear(t),n.createObjectStore(t)}}));async function _T(e,t,r){return await e.get(t,r)}async function yT(e,t,r,n){return await e.put(t,n,r)}async function mT(e,t,r){return await e.delete(t,r)}var Ud=class e{constructor(t,r){this._db=t,this._storeName=r}static async create(t){let{dbName:r=K_,storeName:n=$_,version:i=Qs.DB_VERSION}=t??{},s=await pT(r,n,i);return new e(s,n)}async set(t,r){return await yT(this._db,this._storeName,t,r)}async get(t){var r;return(r=await _T(this._db,this._storeName,t))!==null&&r!==void 0?r:null}async remove(t){return await mT(this._db,this._storeName,t)}};sc.IdbKeyVal=Ud});var oc=ee(it=>{"use strict";var gT=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},bT=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)},ac;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 wT=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 Cd=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=Cd;var Md=class{constructor(t){ac.set(this,void 0),gT(this,ac,t??{},"f")}get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}wT.IdbKeyVal.create(bT(this,ac,"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=Md;ac=new WeakMap});var Hd=ee(Le=>{"use strict";var ET=Le&&Le.__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]}),xT=Le&&Le.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&ET(t,e,r)};Object.defineProperty(Le,"__esModule",{value:!0});Le.AuthClient=Le.ERROR_USER_INTERRUPT=Le.IdbKeyVal=Le.KEY_STORAGE_KEY=Le.KEY_STORAGE_DELEGATION=Le.LocalStorage=Le.IdbStorage=void 0;var G_=tr(),nr=P_(),Y_=vd(),Tt=oc(),cc=oc();Object.defineProperty(Le,"IdbStorage",{enumerable:!0,get:function(){return cc.IdbStorage}});Object.defineProperty(Le,"LocalStorage",{enumerable:!0,get:function(){return cc.LocalStorage}});Object.defineProperty(Le,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return cc.KEY_STORAGE_DELEGATION}});Object.defineProperty(Le,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return cc.KEY_STORAGE_KEY}});var TT=Fd();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return TT.IdbKeyVal}});var OT="https://identity.ic0.app",vT="#authorize",qd="ECDSA",jd="Ed25519",NT=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";xT(vd(),Le);var Vd=class{constructor(t,r,n,i,s,o,a,c){this._identity=t,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(t={}){var r,n,i;let s=(r=t.storage)!==null&&r!==void 0?r:new Tt.IdbStorage,o=(n=t.keyType)!==null&&n!==void 0?n:qd,a=null;if(t.identity)a=t.identity;else{let h=await s.get(Tt.KEY_STORAGE_KEY);if(!h&&Tt.isBrowser)try{let m=new Tt.LocalStorage,b=await m.get(Tt.KEY_STORAGE_DELEGATION),l=await m.get(Tt.KEY_STORAGE_KEY);b&&l&&o===qd&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Tt.KEY_STORAGE_DELEGATION,b),await s.set(Tt.KEY_STORAGE_KEY,l),h=b,await m.remove(Tt.KEY_STORAGE_DELEGATION),await m.remove(Tt.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(h)try{typeof h=="object"?o===jd&&typeof h=="string"?a=await nr.Ed25519KeyIdentity.fromJSON(h):a=await nr.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=nr.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new G_.AnonymousIdentity,d=null;if(a)try{let h=await s.get(Tt.KEY_STORAGE_DELEGATION);if(typeof h=="object"&&h!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?c=t.identity:h&&(d=nr.DelegationChain.fromJSON(h),(0,nr.isDelegationValid)(d)?"toDer"in a?c=nr.PartialDelegationIdentity.fromDelegation(a,d):c=nr.DelegationIdentity.fromDelegation(a,d):(await kd(s),a=null))}catch(h){console.error(h),await kd(s),a=null}let f;return!((i=t.idleOptions)===null||i===void 0)&&i.disableIdle?f=void 0:(d||t.identity)&&(f=Y_.IdleManager.create(t.idleOptions)),a||(o===jd?(a=await nr.Ed25519KeyIdentity.generate(),await s.set(Tt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(t.storage&&o===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 '${jd}' as the key type, as it can serialize to a string`),a=await nr.ECDSAKeyIdentity.generate(),await s.set(Tt.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,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})),o=nr.DelegationChain.fromDelegations(s,t.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=nr.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=nr.DelegationIdentity.fromDelegation(a,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=Y_.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Tt.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 o=BigInt(8)*BigInt(36e11),a=new URL(((r=t?.identityProvider)===null||r===void 0?void 0:r.toString())||OT);a.hash=vT,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=t?.maxTimeToLive)!==null&&i!==void 0?i:o},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(a.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Le.ERROR_USER_INTERRUPT,t?.onError):setTimeout(c,NT))};c()}_getEventHandler(t,r){return async n=>{var i,s,o;if(n.origin!==t.origin)return;let a=n.data;switch(a.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);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,t.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.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 G_.AnonymousIdentity,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};Le.AuthClient=Vd;async function kd(e){await e.remove(Tt.KEY_STORAGE_KEY),await e.remove(Tt.KEY_STORAGE_DELEGATION),await e.remove(Tt.KEY_VECTOR)}});var $y=We(nt(),1);var Ny=We(nt(),1);var Yi=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 Jr=class e extends Yi{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 vy=We(Hd(),1),Id=We(nt(),1);var z_=BigInt(144e11),W_=!1,J_={width:576,height:576},Z_={width:505,height:705},X_="internetcomputer.org";var Is=We(nt(),1);var Ji="http://127.0.0.1:5987",Q_="rdmx6-jaaaa-aaaaa-aaadq-cai";var Xr=class e extends Yi{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 Kd=We(nt(),1);var uc=We(nt(),1),I_=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 $d=({width:e,height:t})=>{if(!dc()||(0,Kd.isNullish)(window)||(0,Kd.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=Xr.getInstance().get()?.container;if((0,Is.isNullish)(n)||n===!1)return`https://identity.${this.#e??X_}`;let i=Xr.getInstance().get(),s=(0,Is.nonNullish)(i)&&(0,Is.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:Q_,{host:o,protocol:a}=new URL(n===!0?Ji:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...t!==!1&&{windowOpenerFeatures:$d(J_)},identityProvider:r()}}},D_=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:$d(Z_)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var ty=We(tr(),1),pc=We(nt(),1);var hc=We(nt(),1);var L_=We(tr(),1),Gd=We(nt(),1);var ey=async({identity:e,container:t})=>{let n=(0,Gd.nonNullish)(t)&&t!==!1?t===!0?Ji:t:"https://icp-api.io",i=(0,Gd.nonNullish)(t);return await L_.HttpAgent.create({identity:e,shouldFetchRootKey:i,host:n})};var Zi=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 ey({identity:t,...r});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}};var Xi=class e{static instance;#e=void 0;constructor(){}static getInstance(){return(0,pc.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,pc.isNullish)(this.#e)||(0,pc.isNullish)(this.#e[s])){let o=await this.createActor({satelliteId:t,identity:r,...i});return this.#e={...this.#e??{},[s]:o},o}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:t,satelliteId:r,...n}){let i=await Zi.getInstance().getAgent(n);return ty.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 ry=We(Hd(),1),wc=()=>ry.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Ls=We(nt(),1);var Yd=({error:e,type:t})=>typeof e=="string"?e.includes(t):e instanceof Error?e.message.includes(t):!1;var ny="juno.datastore.error.user.cannot_update";var Nr=We(nt(),1);var iy=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 oi=We(nt(),1);var zd=async e=>{let{data:t,version:r,description:n}=e;return{description:(0,oi.toNullable)(n),data:await I_(t),version:(0,oi.toNullable)(r)}},Wd=e=>{let{version:t}=e;return{version:(0,oi.toNullable)(t)}},Ds=async({doc:e,key:t})=>{let{owner:r,version:n,description:i,data:s,...o}=e;return{key:t,description:(0,oi.fromNullable)(i),owner:r.toText(),data:await lc(s),version:(0,oi.fromNullable)(n),...o}};var oy=We(Mt(),1),st=We(nt(),1);var sy=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)}},jn=({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:sy(e.createdAt),updated_at:sy(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"?oy.Principal.fromText(n):n)});var cy=We(nt(),1);var Ec=We(nt(),1);var ay=({satelliteId:e,container:t})=>{let{satelliteId:r}=Jd({satelliteId:e}),{container:n}=Zd({container:t});if((0,Ec.nonNullish)(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?Ji:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Jd=({satelliteId:e})=>(0,Ec.nonNullish)(e)?{satelliteId:e}:Xr.getInstance().get()??{satelliteId:void 0},Zd=({container:e})=>(0,Ec.nonNullish)(e)?{container:e}:Xr.getInstance().get()??{container:void 0};var Xd=({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}),o=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(s),description:e.Opt(e.Text),created_at:e.Opt(s)}),a=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(o),paginate:e.Opt(a)}),d=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),h=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)}),S=e.Record({proposal_ids:e.Vec(e.Nat)}),N=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}),q=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,q)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),G=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),E=e.Record({allowed_callers:e.Vec(e.Principal)}),j=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(G),rules:e.Opt(E)}),Y=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),z=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(Y)}),k=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),oe=e.Variant({Deny:e.Null,Allow:e.Null}),L=e.Record({status_code:e.Nat16,location:e.Text}),ne=e.Record({iframe:e.Opt(k),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(Y),raw_access:e.Opt(oe),redirects:e.Opt(e.Vec(e.Tuple(e.Text,L)))}),w=e.Record({db:e.Opt(z),authentication:e.Opt(j),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)}),R=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),A=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)}),K=e.Variant({AssetsUpgrade:A,SegmentsDeployment:B}),X=e.Record({status:R,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:K}),ae=e.Variant({Heap:e.Null,Stable:e.Null}),se=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),Z=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),C=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(ae),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(Z),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)}),I=e.Record({memory:ae,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:I,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}),D=e.Record({token:e.Opt(I),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}),p=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}),U=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),v=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}),P=e.Record({desc:e.Bool}),H=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),x=e.Record({order:e.Opt(P),paginate:e.Opt(H)}),M=e.Record({proposal_id:e.Nat}),$=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(M,X)),items_length:e.Nat64}),V=e.Record({include_system:e.Bool}),Q=e.Record({matcher:e.Opt(V)}),te=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,C)),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(G),rules:e.Opt(E)}),Re=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:f,expires_at:e.Opt(e.Nat64)}),Fe=e.Record({controller:Re,controllers:e.Vec(e.Principal)}),_e=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(Y)}),fe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),$e=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(ae),max_size:e.Opt(e.Nat),read:se,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(Z),write:se,max_changes_per_user:e.Opt(e.Nat32)}),Kt=e.Record({iframe:e.Opt(k),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(Y),raw_access:e.Opt(oe),redirects:e.Opt(e.Vec(e.Tuple(e.Text,L)))}),Ft=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],[],[]),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,h))],[]),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([S],[],[]),deposit_cycles:e.Func([N],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(O)],["query"]),get_auth_config:e.Func([],[e.Opt(j)],["query"]),get_config:e.Func([],[w],[]),get_db_config:e.Func([],[e.Opt(z)],["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(X)],["query"]),get_rule:e.Func([b,e.Text],[e.Opt(C)],["query"]),get_storage_config:e.Func([],[ne],["query"]),http_request:e.Func([_],[le],["query"]),http_request_streaming_callback:e.Func([I],[D],["query"]),init_asset_upload:e.Func([u],[p],[]),init_proposal:e.Func([K],[e.Nat,X],[]),init_proposal_asset_upload:e.Func([u,e.Nat],[p],[]),list_assets:e.Func([e.Text,c],[y],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,h))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,U))],["query"]),list_docs:e.Func([e.Text,c],[v],["query"]),list_proposals:e.Func([x],[$],["query"]),list_rules:e.Func([b,Q],[te],["query"]),memory_size:e.Func([],[de],["query"]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([ge],[j],[]),set_controllers:e.Func([Fe],[e.Vec(e.Tuple(e.Principal,h))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([_e],[z],[]),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,$e],[C],[]),set_storage_config:e.Func([Kt],[ne],[]),submit_proposal:e.Func([e.Nat],[e.Nat,X],[]),upload_asset_chunk:e.Func([Ft],[Ct],[]),upload_proposal_asset_chunk:e.Func([Ft],[Ct],[])})};var Qd=({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}),o=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(s),description:e.Opt(e.Text),created_at:e.Opt(s)}),a=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(o),paginate:e.Opt(a)}),d=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),h=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)}),S=e.Record({proposal_ids:e.Vec(e.Nat)}),N=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}),q=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,q)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),G=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),E=e.Record({allowed_callers:e.Vec(e.Principal)}),j=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(G),rules:e.Opt(E)}),Y=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),z=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(Y)}),k=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),oe=e.Variant({Deny:e.Null,Allow:e.Null}),L=e.Record({status_code:e.Nat16,location:e.Text}),ne=e.Record({iframe:e.Opt(k),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(Y),raw_access:e.Opt(oe),redirects:e.Opt(e.Vec(e.Tuple(e.Text,L)))}),w=e.Record({db:e.Opt(z),authentication:e.Opt(j),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)}),R=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),A=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)}),K=e.Variant({AssetsUpgrade:A,SegmentsDeployment:B}),X=e.Record({status:R,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:K}),ae=e.Variant({Heap:e.Null,Stable:e.Null}),se=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),Z=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),C=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(ae),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(Z),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)}),I=e.Record({memory:ae,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:I,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}),D=e.Record({token:e.Opt(I),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}),p=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}),U=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),v=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}),P=e.Record({desc:e.Bool}),H=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),x=e.Record({order:e.Opt(P),paginate:e.Opt(H)}),M=e.Record({proposal_id:e.Nat}),$=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(M,X)),items_length:e.Nat64}),V=e.Record({include_system:e.Bool}),Q=e.Record({matcher:e.Opt(V)}),te=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,C)),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(G),rules:e.Opt(E)}),Re=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:f,expires_at:e.Opt(e.Nat64)}),Fe=e.Record({controller:Re,controllers:e.Vec(e.Principal)}),_e=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(Y)}),fe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),$e=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(ae),max_size:e.Opt(e.Nat),read:se,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(Z),write:se,max_changes_per_user:e.Opt(e.Nat32)}),Kt=e.Record({iframe:e.Opt(k),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(Y),raw_access:e.Opt(oe),redirects:e.Opt(e.Vec(e.Tuple(e.Text,L)))}),Ft=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],[],[]),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,h))],[]),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([S],[],[]),deposit_cycles:e.Func([N],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(O)],[]),get_auth_config:e.Func([],[e.Opt(j)],[]),get_config:e.Func([],[w],[]),get_db_config:e.Func([],[e.Opt(z)],[]),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(X)],[]),get_rule:e.Func([b,e.Text],[e.Opt(C)],[]),get_storage_config:e.Func([],[ne],[]),http_request:e.Func([_],[le],[]),http_request_streaming_callback:e.Func([I],[D],[]),init_asset_upload:e.Func([u],[p],[]),init_proposal:e.Func([K],[e.Nat,X],[]),init_proposal_asset_upload:e.Func([u,e.Nat],[p],[]),list_assets:e.Func([e.Text,c],[y],[]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,h))],[]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,U))],[]),list_docs:e.Func([e.Text,c],[v],[]),list_proposals:e.Func([x],[$],[]),list_rules:e.Func([b,Q],[te],[]),memory_size:e.Func([],[de],[]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([ge],[j],[]),set_controllers:e.Func([Fe],[e.Vec(e.Tuple(e.Principal,h))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([_e],[z],[]),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,$e],[C],[]),set_storage_config:e.Func([Kt],[ne],[]),submit_proposal:e.Func([e.Nat],[e.Nat,X],[]),upload_asset_chunk:e.Func([Ft],[Ct],[]),upload_proposal_asset_chunk:e.Func([Ft],[Ct],[])})};var dt=({satellite:e,options:{certified:t}})=>ly({idlFactory:t?Qd:Xd,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}=Jd({satelliteId:e});(0,cy.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Zd({container:t});return await Xi.getInstance().getActor({satelliteId:n,container:i,...r})};var dy=async({collection:e,key:t,...r})=>{let{get_doc:n}=await dt(r),i=(0,Nr.fromNullable)(await n(e,t));if(!(0,Nr.isNullish)(i))return Ds({doc:i,key:t})},fy=async({docs:e,...t})=>{let{get_many_docs:r}=await dt(t),n=e.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=(0,Nr.fromNullable)(a);s.push((0,Nr.nonNullish)(c)?await Ds({key:o,doc:c}):void 0)}return s},hy=async({collection:e,doc:t,...r})=>{let{set_doc:n}=await dt(r),{key:i}=t,s=await zd(t),o=await n(e,i,s);return await Ds({key:i,doc:o})},py=async({docs:e,...t})=>{let{set_many_docs:r}=await dt(t),n=[];for(let{collection:o,doc:a}of e){let{key:c}=a;n.push([o,c,await zd(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await Ds({key:o,doc:a}));return s},_y=async({collection:e,doc:t,...r})=>{let{del_doc:n}=await dt(r),{key:i}=t;return n(e,i,Wd(t))},yy=async({docs:e,...t})=>{let{del_many_docs:r}=await dt(t),n=e.map(({collection:i,doc:s})=>[i,s.key,Wd(s)]);await r(n)},my=async({collection:e,filter:t,...r})=>{let{del_filtered_docs:n}=await dt(r);return n(e,jn(t))},gy=async({collection:e,filter:t,...r})=>{let{list_docs:n}=await dt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(e,jn(t)),d=[];for(let[f,h]of i){let{data:m,owner:b,description:l,version:S,...N}=h;d.push({key:f,description:(0,Nr.fromNullable)(l),owner:b.toText(),data:await iy({data:m}),version:(0,Nr.fromNullable)(S),...N})}return{items:d,items_length:o,items_page:(0,Nr.fromNullable)(s),matches_length:a,matches_pages:(0,Nr.fromNullable)(c)}},by=async({collection:e,filter:t,...r})=>{let{count_docs:n}=await dt(r);return n(e,jn(t))};var Qr={certified:!1};var wy=We(tr(),1),Ey=We(nt(),1);var et=e=>(0,Ey.nonNullish)(e)?e:xc()??new wy.AnonymousIdentity;var xy=async({satellite:e,options:t,...r})=>{let n=et(e?.identity);return await dy({...r,satellite:{...e,identity:n},options:t??Qr})},Gv=async({satellite:e,options:t,...r})=>{let n=et(e?.identity);return await fy({...r,satellite:{...e,identity:n},options:t??Qr})},Ty=async({satellite:e,...t})=>{let r=et(e?.identity);return await hy({...t,satellite:{...e,identity:r},options:{certified:!0}})},Yv=async({satellite:e,...t})=>{let r=et(e?.identity);return await py({...t,satellite:{...e,identity:r},options:{certified:!0}})},zv=async({satellite:e,...t})=>{let r=et(e?.identity);return await _y({...t,satellite:{...e,identity:r},options:{certified:!0}})},Wv=async({satellite:e,...t})=>{let r=et(e?.identity);return await yy({...t,satellite:{...e,identity:r},options:{certified:!0}})},Jv=async({satellite:e,filter:t,...r})=>{let n=et(e?.identity);return await my({...r,filter:t??{},satellite:{...e,identity:n},options:{certified:!0}})},Zv=async({satellite:e,options:t,filter:r,...n})=>{let i=et(e?.identity);return await gy({...n,filter:r??{},satellite:{...e,identity:i},options:t??Qr})},Xv=async({satellite:e,options:t,filter:r,...n})=>{let i=et(e?.identity);return await by({...n,filter:r??{},satellite:{...e,identity:i},options:t??Qr})};var Oy=async e=>{let t=xc();if((0,Ls.isNullish)(t))throw new gc("No identity to initialize the user. Have you initialized Juno?");let r=t.getPrincipal().toText(),n=()=>xy({collection:"#user",key:r}),i=await n();if((0,Ls.nonNullish)(i))return i;try{return await AT({userId:r,provider:e})}catch(s){if(Yd({error:s,type:ny})){let o=await n();if((0,Ls.nonNullish)(o))return o}throw s}},AT=({userId:e,...t})=>Ty({collection:"#user",doc:{key:e,data:t}});var hr,Dd=async e=>{if(hr=hr??await wc(),!(await hr?.isAuthenticated()??!1))return;let r=await Oy(e);Jr.getInstance().set(r)},ST=e=>new Promise(async(t,r)=>{if((0,Id.isNullish)(hr)){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 hr.login({onSuccess:async()=>{await Dd(n.id),t()},onError:i=>{if(i===vy.ERROR_USER_INTERRUPT){r(new mc(i));return}r(new _c(i))},maxTimeToLive:e?.maxTimeToLive??z_,allowPinAuthentication:e?.allowPin??W_,...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...n.signInOptions({windowed:e?.windowed})})}),Ld=async()=>{await RT(),hr=await wc()},RT=async()=>{await hr?.logout(),hr=null,Jr.getInstance().reset(),Xi.getInstance().reset(),Zi.getInstance().reset()},xc=()=>hr?.getIdentity(),BT=async()=>(hr??await wc()).getIdentity(),PT=async()=>{let e=Jr.getInstance().get();return(0,Id.isNullish)(e)||!(await hr?.isAuthenticated()??!1)?null:hr?.getIdentity()??null};var Ay=e=>{let t=e===!0?"./workers/auth.worker.js":e,r=new Worker(t),n=async()=>{ld({message:"junoSignOutAuthTimer"}),await Ld()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":ld({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},Jr.getInstance().subscribe(i=>{if((0,Ny.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Sy=()=>{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()},Ry=()=>{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 g6=async({idlFactory:e,satellite:t})=>{let r=et(t?.identity);return await uy({idlFactory:e,...t,identity:r})};var ro=We(nt(),1);var to=We(nt(),1);var eo=We(nt(),1);var By=async({asset:{data:e,headers:t,...r},actor:n})=>{let{init_asset_upload:i,upload_asset_chunk:s,commit_asset_upload:o}=n,{batch_id:a}=await i(UT(r)),{chunkIds:c}=await CT({data:e,uploadFn:s,batchId:a});await FT({commitFn:o,batchId:a,data:e,headers:t,chunkIds:c})};var UT=({filename:e,collection:t,token:r,fullPath:n,encoding:i,description:s})=>({collection:t,full_path:n,name:e,token:(0,eo.toNullable)(r),encoding_type:(0,eo.toNullable)(i),description:(0,eo.toNullable)(s)}),FT=async({commitFn:e,batchId:t,chunkIds:r,headers:n,data:i})=>{let s=n.find(([o,a])=>o.toLowerCase()==="content-type")===void 0&&i.type!==void 0&&i.type!==""?[["Content-Type",i.type]]:void 0;await e({batch_id:t,chunk_ids:r.map(({chunk_id:o})=>o),headers:[...n,...s??[]]})},CT=async({data:e,uploadFn:t,batchId:r})=>{let n=[],i=dc()?new Blob([await e.arrayBuffer()]):e,s=0n;for(let a=0;a<i.size;a+=19e5){let c=i.slice(a,a+19e5);n.push({batchId:r,chunk:c,uploadFn:t,orderId:s}),s++}let o=[];for await(let a of MT({uploadChunks:n}))o=[...o,...a];return{chunkIds:o}};async function*MT({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=>qT(i)))}}var qT=async({batchId:e,chunk:t,uploadFn:r,orderId:n})=>r({batch_id:e,content:new Uint8Array(await t.arrayBuffer()),order_id:(0,eo.toNullable)(n)});var Py=async({asset:e,...t})=>{let r=await dt(t);await By({actor:r,asset:e})},Uy=async({collection:e,filter:t,...r})=>{let{list_assets:n}=await dt(r),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(e,jn(t));return{items:i.map(([d,f])=>f),items_length:s,items_page:(0,to.fromNullable)(o),matches_length:a,matches_pages:(0,to.fromNullable)(c)}},Fy=async({collection:e,filter:t,...r})=>{let{count_assets:n}=await dt(r);return n(e,jn(t))},Cy=async({collection:e,fullPath:t,...r})=>(await dt(r)).del_asset(e,t),My=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)},qy=async({collection:e,filter:t,...r})=>{let{del_filtered_assets:n}=await dt(r);return n(e,jn(t))},jy=async({collection:e,fullPath:t,...r})=>{let{get_asset:n}=await dt(r);return(0,to.fromNullable)(await n(e,t))},ky=async({assets:e,...t})=>{let{get_many_assets:r}=await dt(t),n=e.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>(0,to.fromNullable)(o))};var Vy=e=>btoa([...e].map(t=>String.fromCharCode(t)).join(""));var U6=e=>Hy(e),F6=e=>Hy({filename:e.data.name,...e}),Hy=async({filename:e,data:t,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let d=et(o?.identity),f=decodeURI(e),h=i??`/${r}/${f}`,m={...o,identity:d};return await Py({asset:{data:t,filename:f,collection:r,token:s,headers:n,fullPath:h,encoding:a,description:c},satellite:m,options:{certified:!0}}),{downloadUrl:Ky({satellite:m,assetKey:{fullPath:h,token:s}}),fullPath:h,name:f}},C6=async({collection:e,filter:t,satellite:r,options:n})=>{let i={...r,identity:et(r?.identity)},{items:s,...o}=await Uy({collection:e,filter:t??{},satellite:i,options:n??Qr}),a=s.map(({key:{full_path:c,token:d,name:f,owner:h,description:m},headers:b,encodings:l,created_at:S,updated_at:N})=>{let F=(0,ro.fromNullable)(d);return{fullPath:c,description:(0,ro.fromNullable)(m),name:f,downloadUrl:Ky({satellite:i,assetKey:{fullPath:c,token:F}}),token:F,headers:b,encodings:l.reduce((q,[O,{modified:G,sha256:E,total_length:j}])=>({...q,[O]:{modified:G,sha256:Vy(E),total_length:j}}),{}),owner:h.toText(),created_at:S,updated_at:N}});return{items:a,assets:a,...o}},M6=async({collection:e,filter:t,satellite:r,options:n})=>{let i={...r,identity:et(r?.identity)};return await Fy({collection:e,satellite:i,filter:t??{},options:n??Qr})},q6=({collection:e,fullPath:t,satellite:r})=>Cy({collection:e,fullPath:t,satellite:{...r,identity:et(r?.identity)},options:{certified:!0}}),j6=({assets:e,satellite:t})=>My({assets:e,satellite:{...t,identity:et(t?.identity)},options:{certified:!0}}),k6=async({collection:e,satellite:t,filter:r})=>{let n={...t,identity:et(t?.identity)};return await qy({collection:e,satellite:n,filter:r??{},options:{certified:!0}})},V6=async({satellite:e,options:t,...r})=>{let n=et(e?.identity);return await jy({...r,satellite:{...e,identity:n},options:t??Qr})},H6=async({satellite:e,options:t,...r})=>{let n=et(e?.identity);return await ky({...r,satellite:{...e,identity:n},options:t??Qr})},Ky=({assetKey:{fullPath:e,token:t},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${ay(n)}${e}${(0,ro.nonNullish)(t)?`?token=${t}`:""}`};var jT=e=>{let t=e?.satelliteId??Sy();(0,$y.assertNonNullish)(t,"Satellite ID is not configured. Juno cannot be initialized.");let r=e?.container??Ry();return{satelliteId:t,internetIdentityId:e?.internetIdentityId,workers:e?.workers,container:r}},J6=e=>kT(e),kT=async e=>{let t=jT(e);Xr.getInstance().set(t),await Dd();let r=t.workers?.auth!==void 0?Ay(t.workers.auth):void 0;return[...r?[r]:[]]},Z6=e=>Jr.getInstance().subscribe(e);export{gc as InitError,fc as InternetIdentityProvider,bc as ListError,D_ as NFIDProvider,_c as SignInError,yc as SignInInitError,mc as SignInUserInterruptError,Z6 as authSubscribe,M6 as countAssets,Xv as countDocs,q6 as deleteAsset,zv as deleteDoc,k6 as deleteFilteredAssets,Jv as deleteFilteredDocs,j6 as deleteManyAssets,Wv as deleteManyDocs,Ky as downloadUrl,V6 as getAsset,xy as getDoc,PT as getIdentityOnce,H6 as getManyAssets,Gv as getManyDocs,g6 as getSatelliteExtendedActor,J6 as initJuno,kT as initSatellite,C6 as listAssets,Zv as listDocs,Ty as setDoc,Yv as setManyDocs,ST as signIn,Ld as signOut,BT as unsafeIdentity,U6 as uploadBlob,F6 as uploadFile};
58
58
  /*! Bundled license information:
59
59
 
60
60
  ieee754/index.js: