@junobuild/core-standalone 1.2.1-next-2025-09-03.1 → 2.0.0

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,7 +1,7 @@
1
1
  import { createRequire as topLevelCreateRequire } from 'module';
2
2
  const require = topLevelCreateRequire(import.meta.url);
3
- var Gm=Object.create;var ga=Object.defineProperty;var $m=Object.getOwnPropertyDescriptor;var Wm=Object.getOwnPropertyNames;var zm=Object.getPrototypeOf,Ym=Object.prototype.hasOwnProperty;var fi=(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 xf=(e,t)=>()=>(e&&(t=e(e=0)),t);var ee=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Jm=(e,t)=>{for(var r in t)ga(e,r,{get:t[r],enumerable:!0})},Tf=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Wm(t))!Ym.call(e,i)&&i!==r&&ga(e,i,{get:()=>t[i],enumerable:!(n=$m(t,i))||n.enumerable});return e};var be=(e,t,r)=>(r=e!=null?Gm(zm(e)):{},Tf(t||!e||!e.__esModule?ga(r,"default",{value:e,enumerable:!0}):r,e)),Zm=e=>Tf(ga({},"__esModule",{value:!0}),e);var Of=ee(ba=>{"use strict";ba.byteLength=Qm;ba.toByteArray=tg;ba.fromByteArray=ig;var Ir=[],ar=[],Xm=typeof Uint8Array<"u"?Uint8Array:Array,Yc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ln=0,Nf=Yc.length;Ln<Nf;++Ln)Ir[Ln]=Yc[Ln],ar[Yc.charCodeAt(Ln)]=Ln;var Ln,Nf;ar[45]=62;ar[95]=63;function Ef(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 Qm(e){var t=Ef(e),r=t[0],n=t[1];return(r+n)*3/4-n}function eg(e,t,r){return(t+r)*3/4-r}function tg(e){var t,r=Ef(e),n=r[0],i=r[1],s=new Xm(eg(e,n,i)),a=0,o=i>0?n-4:n,c;for(c=0;c<o;c+=4)t=ar[e.charCodeAt(c)]<<18|ar[e.charCodeAt(c+1)]<<12|ar[e.charCodeAt(c+2)]<<6|ar[e.charCodeAt(c+3)],s[a++]=t>>16&255,s[a++]=t>>8&255,s[a++]=t&255;return i===2&&(t=ar[e.charCodeAt(c)]<<2|ar[e.charCodeAt(c+1)]>>4,s[a++]=t&255),i===1&&(t=ar[e.charCodeAt(c)]<<10|ar[e.charCodeAt(c+1)]<<4|ar[e.charCodeAt(c+2)]>>2,s[a++]=t>>8&255,s[a++]=t&255),s}function rg(e){return Ir[e>>18&63]+Ir[e>>12&63]+Ir[e>>6&63]+Ir[e&63]}function ng(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(rg(n));return i.join("")}function ig(e){for(var t,r=e.length,n=r%3,i=[],s=16383,a=0,o=r-n;a<o;a+=s)i.push(ng(e,a,a+s>o?o:a+s));return n===1?(t=e[r-1],i.push(Ir[t>>2]+Ir[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Ir[t>>10]+Ir[t>>4&63]+Ir[t<<2&63]+"=")),i.join("")}});var Zc=ee(Jc=>{Jc.read=function(e,t,r,n,i){var s,a,o=i*8-n-1,c=(1<<o)-1,d=c>>1,f=-7,p=r?i-1:0,m=r?-1:1,b=e[t+p];for(p+=m,s=b&(1<<-f)-1,b>>=-f,f+=o;f>0;s=s*256+e[t+p],p+=m,f-=8);for(a=s&(1<<-f)-1,s>>=-f,f+=n;f>0;a=a*256+e[t+p],p+=m,f-=8);if(s===0)s=1-d;else{if(s===c)return a?NaN:(b?-1:1)*(1/0);a=a+Math.pow(2,n),s=s-d}return(b?-1:1)*a*Math.pow(2,s-n)};Jc.write=function(e,t,r,n,i,s){var a,o,c,d=s*8-i-1,f=(1<<d)-1,p=f>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:s-1,l=n?1:-1,A=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-a))<1&&(a--,c*=2),a+p>=1?t+=m/c:t+=m*Math.pow(2,1-p),t*c>=2&&(a++,c/=2),a+p>=f?(o=0,a=f):a+p>=1?(o=(t*c-1)*Math.pow(2,i),a=a+p):(o=t*Math.pow(2,p-1)*Math.pow(2,i),a=0));i>=8;e[r+b]=o&255,b+=l,o/=256,i-=8);for(a=a<<i|o,d+=i;d>0;e[r+b]=a&255,b+=l,a/=256,d-=8);e[r+b-l]|=A*128}});var Lf=ee(yi=>{"use strict";var Xc=Of(),hi=Zc(),vf=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;yi.Buffer=$;yi.SlowBuffer=lg;yi.INSPECT_MAX_BYTES=50;var wa=2147483647;yi.kMaxLength=wa;$.TYPED_ARRAY_SUPPORT=sg();!$.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 sg(){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($.prototype,"parent",{enumerable:!0,get:function(){if($.isBuffer(this))return this.buffer}});Object.defineProperty($.prototype,"offset",{enumerable:!0,get:function(){if($.isBuffer(this))return this.byteOffset}});function en(e){if(e>wa)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,$.prototype),t}function $(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 ru(e)}return If(e,t,r)}$.poolSize=8192;function If(e,t,r){if(typeof e=="string")return og(e,t);if(ArrayBuffer.isView(e))return cg(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(Br(e,ArrayBuffer)||e&&Br(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Br(e,SharedArrayBuffer)||e&&Br(e.buffer,SharedArrayBuffer)))return eu(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 $.from(n,t,r);let i=ug(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return $.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)}$.from=function(e,t,r){return If(e,t,r)};Object.setPrototypeOf($.prototype,Uint8Array.prototype);Object.setPrototypeOf($,Uint8Array);function Bf(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 ag(e,t,r){return Bf(e),e<=0?en(e):t!==void 0?typeof r=="string"?en(e).fill(t,r):en(e).fill(t):en(e)}$.alloc=function(e,t,r){return ag(e,t,r)};function ru(e){return Bf(e),en(e<0?0:nu(e)|0)}$.allocUnsafe=function(e){return ru(e)};$.allocUnsafeSlow=function(e){return ru(e)};function og(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!$.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=Pf(e,t)|0,n=en(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Qc(e){let t=e.length<0?0:nu(e.length)|0,r=en(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function cg(e){if(Br(e,Uint8Array)){let t=new Uint8Array(e);return eu(t.buffer,t.byteOffset,t.byteLength)}return Qc(e)}function eu(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,$.prototype),n}function ug(e){if($.isBuffer(e)){let t=nu(e.length)|0,r=en(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||su(e.length)?en(0):Qc(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Qc(e.data)}function nu(e){if(e>=wa)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+wa.toString(16)+" bytes");return e|0}function lg(e){return+e!=e&&(e=0),$.alloc(+e)}$.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==$.prototype};$.compare=function(t,r){if(Br(t,Uint8Array)&&(t=$.from(t,t.offset,t.byteLength)),Br(r,Uint8Array)&&(r=$.from(r,r.offset,r.byteLength)),!$.isBuffer(t)||!$.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let s=0,a=Math.min(n,i);s<a;++s)if(t[s]!==r[s]){n=t[s],i=r[s];break}return n<i?-1:i<n?1:0};$.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}};$.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return $.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=$.allocUnsafe(r),s=0;for(n=0;n<t.length;++n){let a=t[n];if(Br(a,Uint8Array))s+a.length>i.length?($.isBuffer(a)||(a=$.from(a)),a.copy(i,s)):Uint8Array.prototype.set.call(i,a,s);else if($.isBuffer(a))a.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=a.length}return i};function Pf(e,t){if($.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Br(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 tu(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return jf(e).length;default:if(i)return n?-1:tu(e).length;t=(""+t).toLowerCase(),i=!0}}$.byteLength=Pf;function dg(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 xg(this,t,r);case"utf8":case"utf-8":return Uf(this,t,r);case"ascii":return bg(this,t,r);case"latin1":case"binary":return wg(this,t,r);case"base64":return mg(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Tg(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}$.prototype._isBuffer=!0;function Hn(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}$.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)Hn(this,r,r+1);return this};$.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)Hn(this,r,r+3),Hn(this,r+1,r+2);return this};$.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)Hn(this,r,r+7),Hn(this,r+1,r+6),Hn(this,r+2,r+5),Hn(this,r+3,r+4);return this};$.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Uf(this,0,t):dg.apply(this,arguments)};$.prototype.toLocaleString=$.prototype.toString;$.prototype.equals=function(t){if(!$.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:$.compare(this,t)===0};$.prototype.inspect=function(){let t="",r=yi.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};vf&&($.prototype[vf]=$.prototype.inspect);$.prototype.compare=function(t,r,n,i,s){if(Br(t,Uint8Array)&&(t=$.from(t,t.offset,t.byteLength)),!$.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;let a=s-i,o=n-r,c=Math.min(a,o),d=this.slice(i,s),f=t.slice(r,n);for(let p=0;p<c;++p)if(d[p]!==f[p]){a=d[p],o=f[p];break}return a<o?-1:o<a?1:0};function Ff(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,su(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=$.from(t,n)),$.isBuffer(t))return t.length===0?-1:Rf(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):Rf(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Rf(e,t,r,n,i){let s=1,a=e.length,o=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;s=2,a/=2,o/=2,r/=2}function c(f,p){return s===1?f[p]:f.readUInt16BE(p*s)}let d;if(i){let f=-1;for(d=r;d<a;d++)if(c(e,d)===c(t,f===-1?0:d-f)){if(f===-1&&(f=d),d-f+1===o)return f*s}else f!==-1&&(d-=d-f),f=-1}else for(r+o>a&&(r=a-o),d=r;d>=0;d--){let f=!0;for(let p=0;p<o;p++)if(c(e,d+p)!==c(t,p)){f=!1;break}if(f)return d}return-1}$.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};$.prototype.indexOf=function(t,r,n){return Ff(this,t,r,n,!0)};$.prototype.lastIndexOf=function(t,r,n){return Ff(this,t,r,n,!1)};function fg(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=t.length;n>s/2&&(n=s/2);let a;for(a=0;a<n;++a){let o=parseInt(t.substr(a*2,2),16);if(su(o))return a;e[r+a]=o}return a}function pg(e,t,r,n){return xa(tu(t,e.length-r),e,r,n)}function hg(e,t,r,n){return xa(vg(t),e,r,n)}function _g(e,t,r,n){return xa(jf(t),e,r,n)}function yg(e,t,r,n){return xa(Rg(t,e.length-r),e,r,n)}$.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let a=!1;for(;;)switch(i){case"hex":return fg(this,t,r,n);case"utf8":case"utf-8":return pg(this,t,r,n);case"ascii":case"latin1":case"binary":return hg(this,t,r,n);case"base64":return _g(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yg(this,t,r,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}};$.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function mg(e,t,r){return t===0&&r===e.length?Xc.fromByteArray(e):Xc.fromByteArray(e.slice(t,r))}function Uf(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let s=e[i],a=null,o=s>239?4:s>223?3:s>191?2:1;if(i+o<=r){let c,d,f,p;switch(o){case 1:s<128&&(a=s);break;case 2:c=e[i+1],(c&192)===128&&(p=(s&31)<<6|c&63,p>127&&(a=p));break;case 3:c=e[i+1],d=e[i+2],(c&192)===128&&(d&192)===128&&(p=(s&15)<<12|(c&63)<<6|d&63,p>2047&&(p<55296||p>57343)&&(a=p));break;case 4:c=e[i+1],d=e[i+2],f=e[i+3],(c&192)===128&&(d&192)===128&&(f&192)===128&&(p=(s&15)<<18|(c&63)<<12|(d&63)<<6|f&63,p>65535&&p<1114112&&(a=p))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),i+=o}return gg(n)}var Af=4096;function gg(e){let t=e.length;if(t<=Af)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Af));return r}function bg(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 wg(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 xg(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+=Ag[e[s]];return i}function Tg(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}$.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,$.prototype),i};function pt(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}$.prototype.readUintLE=$.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=this[t],s=1,a=0;for(;++a<r&&(s*=256);)i+=this[t+a]*s;return i};$.prototype.readUintBE=$.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=this[t+--r],s=1;for(;r>0&&(s*=256);)i+=this[t+--r]*s;return i};$.prototype.readUint8=$.prototype.readUInt8=function(t,r){return t=t>>>0,r||pt(t,1,this.length),this[t]};$.prototype.readUint16LE=$.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||pt(t,2,this.length),this[t]|this[t+1]<<8};$.prototype.readUint16BE=$.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||pt(t,2,this.length),this[t]<<8|this[t+1]};$.prototype.readUint32LE=$.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};$.prototype.readUint32BE=$.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};$.prototype.readBigUInt64LE=fn(function(t){t=t>>>0,_i(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&cs(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))});$.prototype.readBigUInt64BE=fn(function(t){t=t>>>0,_i(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&cs(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)});$.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=this[t],s=1,a=0;for(;++a<r&&(s*=256);)i+=this[t+a]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};$.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=r,s=1,a=this[t+--i];for(;i>0&&(s*=256);)a+=this[t+--i]*s;return s*=128,a>=s&&(a-=Math.pow(2,8*r)),a};$.prototype.readInt8=function(t,r){return t=t>>>0,r||pt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};$.prototype.readInt16LE=function(t,r){t=t>>>0,r||pt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};$.prototype.readInt16BE=function(t,r){t=t>>>0,r||pt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};$.prototype.readInt32LE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};$.prototype.readInt32BE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};$.prototype.readBigInt64LE=fn(function(t){t=t>>>0,_i(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&cs(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)});$.prototype.readBigInt64BE=fn(function(t){t=t>>>0,_i(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&cs(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)});$.prototype.readFloatLE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),hi.read(this,t,!0,23,4)};$.prototype.readFloatBE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),hi.read(this,t,!1,23,4)};$.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||pt(t,8,this.length),hi.read(this,t,!0,52,8)};$.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||pt(t,8,this.length),hi.read(this,t,!1,52,8)};function Gt(e,t,r,n,i,s){if(!$.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")}$.prototype.writeUintLE=$.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let o=Math.pow(2,8*n)-1;Gt(this,t,r,n,o,0)}let s=1,a=0;for(this[r]=t&255;++a<n&&(s*=256);)this[r+a]=t/s&255;return r+n};$.prototype.writeUintBE=$.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let o=Math.pow(2,8*n)-1;Gt(this,t,r,n,o,0)}let s=n-1,a=1;for(this[r+s]=t&255;--s>=0&&(a*=256);)this[r+s]=t/a&255;return r+n};$.prototype.writeUint8=$.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};$.prototype.writeUint16LE=$.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};$.prototype.writeUint16BE=$.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};$.prototype.writeUint32LE=$.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};$.prototype.writeUint32BE=$.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 Vf(e,t,r,n,i){Mf(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a,r}function Cf(e,t,r,n,i){Mf(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r+7]=s,s=s>>8,e[r+6]=s,s=s>>8,e[r+5]=s,s=s>>8,e[r+4]=s;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=a,a=a>>8,e[r+2]=a,a=a>>8,e[r+1]=a,a=a>>8,e[r]=a,r+8}$.prototype.writeBigUInt64LE=fn(function(t,r=0){return Vf(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});$.prototype.writeBigUInt64BE=fn(function(t,r=0){return Cf(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});$.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,a=1,o=0;for(this[r]=t&255;++s<n&&(a*=256);)t<0&&o===0&&this[r+s-1]!==0&&(o=1),this[r+s]=(t/a>>0)-o&255;return r+n};$.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,a=1,o=0;for(this[r+s]=t&255;--s>=0&&(a*=256);)t<0&&o===0&&this[r+s+1]!==0&&(o=1),this[r+s]=(t/a>>0)-o&255;return r+n};$.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};$.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};$.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};$.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};$.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};$.prototype.writeBigInt64LE=fn(function(t,r=0){return Vf(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});$.prototype.writeBigInt64BE=fn(function(t,r=0){return Cf(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function qf(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 Df(e,t,r,n,i){return t=+t,r=r>>>0,i||qf(e,t,r,4,34028234663852886e22,-34028234663852886e22),hi.write(e,t,r,n,23,4),r+4}$.prototype.writeFloatLE=function(t,r,n){return Df(this,t,r,!0,n)};$.prototype.writeFloatBE=function(t,r,n){return Df(this,t,r,!1,n)};function kf(e,t,r,n,i){return t=+t,r=r>>>0,i||qf(e,t,r,8,17976931348623157e292,-17976931348623157e292),hi.write(e,t,r,n,52,8),r+8}$.prototype.writeDoubleLE=function(t,r,n){return kf(this,t,r,!0,n)};$.prototype.writeDoubleBE=function(t,r,n){return kf(this,t,r,!1,n)};$.prototype.copy=function(t,r,n,i){if(!$.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};$.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"&&!$.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let a=t.charCodeAt(0);(i==="utf8"&&a<128||i==="latin1")&&(t=a)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let s;if(typeof t=="number")for(s=r;s<n;++s)this[s]=t;else{let a=$.isBuffer(t)?t:$.from(t,i),o=a.length;if(o===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=a[s%o]}return this};var pi={};function iu(e,t,r){pi[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}`}}}iu("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);iu("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);iu("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=Sf(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Sf(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function Sf(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 Ng(e,t,r){_i(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&cs(t,e.length-(r+1))}function Mf(e,t,r,n,i,s){if(e>r||e<t){let a=typeof t=="bigint"?"n":"",o;throw s>3?t===0||t===BigInt(0)?o=`>= 0${a} and < 2${a} ** ${(s+1)*8}${a}`:o=`>= -(2${a} ** ${(s+1)*8-1}${a}) and < 2 ** ${(s+1)*8-1}${a}`:o=`>= ${t}${a} and <= ${r}${a}`,new pi.ERR_OUT_OF_RANGE("value",o,e)}Ng(n,i,s)}function _i(e,t){if(typeof e!="number")throw new pi.ERR_INVALID_ARG_TYPE(t,"number",e)}function cs(e,t,r){throw Math.floor(e)!==e?(_i(e,r),new pi.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new pi.ERR_BUFFER_OUT_OF_BOUNDS:new pi.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var Eg=/[^+/0-9A-Za-z-_]/g;function Og(e){if(e=e.split("=")[0],e=e.trim().replace(Eg,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function tu(e,t){t=t||1/0;let r,n=e.length,i=null,s=[];for(let a=0;a<n;++a){if(r=e.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(a+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function vg(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Rg(e,t){let r,n,i,s=[];for(let a=0;a<e.length&&!((t-=2)<0);++a)r=e.charCodeAt(a),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function jf(e){return Xc.toByteArray(Og(e))}function xa(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 Br(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function su(e){return e!==e}var Ag=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 fn(e){return typeof BigInt>"u"?Sg:e}function Sg(){throw new Error("BigInt not supported")}});var au=ee(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.ReplicaRejectCode=void 0;var Ig;(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"})(Ig=us.ReplicaRejectCode||(us.ReplicaRejectCode={}))});var Hf=ee(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.decode=gi.encode=void 0;var Ta="abcdefghijklmnopqrstuvwxyz234567",mi=Object.create(null);for(let e=0;e<Ta.length;e++)mi[Ta[e]]=e;mi[0]=mi.o;mi[1]=mi.i;function Bg(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+=Ta[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?Ta[r>>3]:"")}gi.encode=Bg;function Pg(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0;function s(a){let o=mi[a.toLowerCase()];if(o===void 0)throw new Error(`Invalid character: ${JSON.stringify(a)}`);o<<=3,r|=o>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=o<<5-t&255:r=0)}for(let a of e)s(a);return n.slice(0,i)}gi.decode=Pg});var Kf=ee(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});Na.getCrc32=void 0;var Fg=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 Ug(e){let t=new Uint8Array(e),r=-1;for(let n=0;n<t.length;n++){let s=(t[n]^r)&255;r=Fg[s]^r>>>8}return(r^-1)>>>0}Na.getCrc32=Ug});var cu=ee(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Pr.isBytes=$f;Pr.number=Ea;Pr.bool=Gf;Pr.bytes=ou;Pr.hash=Wf;Pr.exists=zf;Pr.output=Yf;function Ea(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Gf(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function $f(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function ou(e,...t){if(!$f(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 Wf(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ea(e.outputLen),Ea(e.blockLen)}function zf(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 Yf(e,t){ou(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Vg={number:Ea,bool:Gf,bytes:ou,hash:Wf,exists:zf,output:Yf};Pr.default=Vg});var Jf=ee(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});Oa.crypto=void 0;var pn=fi("node:crypto");Oa.crypto=pn&&typeof pn=="object"&&"webcrypto"in pn?pn.webcrypto:pn&&typeof pn=="object"&&"randomBytes"in pn?pn:void 0});var Kn=ee(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.Hash=xe.nextTick=xe.byteSwapIfBE=xe.byteSwap=xe.isLE=xe.rotl=xe.rotr=xe.createView=xe.u32=xe.u8=void 0;xe.isBytes=Cg;xe.byteSwap32=Hg;xe.bytesToHex=Gg;xe.hexToBytes=$g;xe.asyncLoop=zg;xe.utf8ToBytes=Xf;xe.toBytes=va;xe.concatBytes=Yg;xe.checkOpts=Zg;xe.wrapConstructor=Xg;xe.wrapConstructorWithOpts=Qg;xe.wrapXOFConstructorWithOpts=eb;xe.randomBytes=tb;var bi=Jf(),lu=cu();function Cg(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}var qg=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);xe.u8=qg;var Dg=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));xe.u32=Dg;var kg=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);xe.createView=kg;var Mg=(e,t)=>e<<32-t|e>>>t;xe.rotr=Mg;var jg=(e,t)=>e<<t|e>>>32-t>>>0;xe.rotl=jg;xe.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Lg=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;xe.byteSwap=Lg;xe.byteSwapIfBE=xe.isLE?e=>e:e=>(0,xe.byteSwap)(e);function Hg(e){for(let t=0;t<e.length;t++)e[t]=(0,xe.byteSwap)(e[t])}var Kg=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Gg(e){(0,lu.bytes)(e);let t="";for(let r=0;r<e.length;r++)t+=Kg[e[r]];return t}var tn={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Zf(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 $g(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let a=Zf(e.charCodeAt(s)),o=Zf(e.charCodeAt(s+1));if(a===void 0||o===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=a*16+o}return n}var Wg=async()=>{};xe.nextTick=Wg;async function zg(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,xe.nextTick)(),n+=s)}}function Xf(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function va(e){return typeof e=="string"&&(e=Xf(e)),(0,lu.bytes)(e),e}function Yg(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];(0,lu.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 uu=class{clone(){return this._cloneInto()}};xe.Hash=uu;var Jg={}.toString;function Zg(e,t){if(t!==void 0&&Jg.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(e,t)}function Xg(e){let t=n=>e().update(va(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Qg(e){let t=(n,i)=>e(i).update(va(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function eb(e){let t=(n,i)=>e(i).update(va(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function tb(e=32){if(bi.crypto&&typeof bi.crypto.getRandomValues=="function")return bi.crypto.getRandomValues(new Uint8Array(e));if(bi.crypto&&typeof bi.crypto.randomBytes=="function")return bi.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}});var pu=ee(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.HashMD=hn.Maj=hn.Chi=void 0;var du=cu(),ls=Kn();function rb(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let i=BigInt(32),s=BigInt(4294967295),a=Number(r>>i&s),o=Number(r&s),c=n?4:0,d=n?0:4;e.setUint32(t+c,a,n),e.setUint32(t+d,o,n)}var nb=(e,t,r)=>e&t^~e&r;hn.Chi=nb;var ib=(e,t,r)=>e&t^e&r^t&r;hn.Maj=ib;var fu=class extends ls.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,ls.createView)(this.buffer)}update(t){(0,du.exists)(this);let{view:r,buffer:n,blockLen:i}=this;t=(0,ls.toBytes)(t);let s=t.length;for(let a=0;a<s;){let o=Math.min(i-this.pos,s-a);if(o===i){let c=(0,ls.createView)(t);for(;i<=s-a;a+=i)this.process(c,a);continue}n.set(t.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,du.exists)(this),(0,du.output)(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:a}=this;r[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>i-a&&(this.process(n,0),a=0);for(let p=a;p<i;p++)r[p]=0;rb(n,i-8,BigInt(this.length*8),s),this.process(n,0);let o=(0,ls.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<d;p++)o.setUint32(4*p,f[p],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:a,pos:o}=this;return t.length=i,t.pos=o,t.finished=s,t.destroyed=a,i%r&&t.buffer.set(n),t}};hn.HashMD=fu});var Ra=ee(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});mn.sha224=mn.sha256=mn.SHA256=void 0;var hu=pu(),or=Kn(),sb=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]),_n=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),yn=new Uint32Array(64),ds=class extends hu.HashMD{constructor(){super(64,32,8,!1),this.A=_n[0]|0,this.B=_n[1]|0,this.C=_n[2]|0,this.D=_n[3]|0,this.E=_n[4]|0,this.F=_n[5]|0,this.G=_n[6]|0,this.H=_n[7]|0}get(){let{A:t,B:r,C:n,D:i,E:s,F:a,G:o,H:c}=this;return[t,r,n,i,s,a,o,c]}set(t,r,n,i,s,a,o,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=a|0,this.G=o|0,this.H=c|0}process(t,r){for(let p=0;p<16;p++,r+=4)yn[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let m=yn[p-15],b=yn[p-2],l=(0,or.rotr)(m,7)^(0,or.rotr)(m,18)^m>>>3,A=(0,or.rotr)(b,17)^(0,or.rotr)(b,19)^b>>>10;yn[p]=A+yn[p-7]+l+yn[p-16]|0}let{A:n,B:i,C:s,D:a,E:o,F:c,G:d,H:f}=this;for(let p=0;p<64;p++){let m=(0,or.rotr)(o,6)^(0,or.rotr)(o,11)^(0,or.rotr)(o,25),b=f+m+(0,hu.Chi)(o,c,d)+sb[p]+yn[p]|0,A=((0,or.rotr)(n,2)^(0,or.rotr)(n,13)^(0,or.rotr)(n,22))+(0,hu.Maj)(n,i,s)|0;f=d,d=c,c=o,o=a+b|0,a=s,s=i,i=n,n=b+A|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,a=a+this.D|0,o=o+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,i,s,a,o,c,d,f)}roundClean(){yn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};mn.SHA256=ds;var _u=class extends ds{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}};mn.sha256=(0,or.wrapConstructor)(()=>new ds);mn.sha224=(0,or.wrapConstructor)(()=>new _u)});var Qf=ee(Aa=>{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.sha224=void 0;var ab=Ra();function ob(e){return ab.sha224.create().update(new Uint8Array(e)).digest()}Aa.sha224=ob});var Ct=ee(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.Principal=Fr.JSON_KEY_PRINCIPAL=void 0;var ep=Hf(),cb=Kf(),ub=Qf();Fr.JSON_KEY_PRINCIPAL="__principal__";var lb=2,tp=4,db="aaaaa-aa",fb=e=>{var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))},pb=e=>e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""),yu=class e{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([tp]))}static managementCanister(){return this.fromHex(db)}static selfAuthenticating(t){let r=(0,ub.sha224)(t);return new this(new Uint8Array([...r,lb]))}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(fb(t))}static fromText(t){let r=t;if(t.includes(Fr.JSON_KEY_PRINCIPAL)){let a=JSON.parse(t);Fr.JSON_KEY_PRINCIPAL in a&&(r=a[Fr.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,ep.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]===tp}toUint8Array(){return this._arr}toHex(){return pb(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,(0,cb.getCrc32)(this._arr));let n=new Uint8Array(t),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),o=(0,ep.encode)(s).match(/.{1,5}/g);if(!o)throw new Error;return o.join("-")}toString(){return this.toText()}toJSON(){return{[Fr.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"}};Fr.Principal=yu});var $t=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 hb(...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=hb;function _b(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}vt.toHex=_b;var yb=new RegExp(/^[0-9a-fA-F]+$/);function mb(e){if(!yb.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=mb;function rp(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=rp;function gb(e,t){return rp(e,t)===0}vt.bufEquals=gb;function Sa(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}vt.uint8ToBuf=Sa;function np(e){return e instanceof Uint8Array?Sa(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Sa(new Uint8Array(e)):"buffer"in e?np(e.buffer):Sa(new Uint8Array(e))}vt.bufFromBufLike=np});var wi=ee(Ur=>{"use strict";Object.defineProperty(Ur,"__esModule",{value:!0});Ur.UpdateCallRejectedError=Ur.QueryCallRejectedError=Ur.ActorCallError=Ur.AgentError=void 0;var bu=Ct(),bb=au(),wb=$t(),Ia=class e extends Error{constructor(t){super(t),this.message=t,this.name="AgentError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Ur.AgentError=Ia;var fs=class e extends Ia{constructor(t,r,n,i){let s=bu.Principal.from(t);super(["Call failed:",` Canister: ${s.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(a=>` "${a}": ${JSON.stringify(i[a])}`)].join(`
4
- `)),this.canisterId=t,this.methodName=r,this.type=n,this.props=i,this.name="ActorCallError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Ur.ActorCallError=fs;var mu=class e extends fs{constructor(t,r,n){var i;let s=bu.Principal.from(t);super(s,r,"query",{Status:n.status,Code:(i=bb.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)}};Ur.QueryCallRejectedError=mu;var gu=class e extends fs{constructor(t,r,n,i){let s=bu.Principal.from(t);super(s,r,"update",Object.assign({"Request ID":(0,wb.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)}};Ur.UpdateCallRejectedError=gu});var Fa=ee(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.bufFromBufLike=Wt.uint8ToBuf=Wt.PipeArrayBuffer=Wt.fromHexString=Wt.toHexString=Wt.concat=void 0;function xb(...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}Wt.concat=xb;function Tb(e){return new Uint8Array(e).reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}Wt.toHexString=Tb;function Nb(e){var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))}Wt.fromHexString=Nb;var wu=class{constructor(t,r=t?.byteLength||0){this._buffer=Pa(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Pa(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}};Wt.PipeArrayBuffer=wu;function Ba(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}Wt.uint8ToBuf=Ba;function Pa(e){return e instanceof Uint8Array?Ba(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Ba(new Uint8Array(e)):"buffer"in e?Pa(e.buffer):Ba(new Uint8Array(e))}Wt.bufFromBufLike=Pa});var xu=ee(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.idlLabelToId=void 0;function Eb(e){let r=new TextEncoder().encode(e),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Ob(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 Eb(e)}Ua.idlLabelToId=Ob});var Nu=ee(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.readIntLE=Xe.readUIntLE=Xe.writeIntLE=Xe.writeUIntLE=Xe.slebDecode=Xe.slebEncode=Xe.lebDecode=Xe.lebEncode=Xe.safeReadUint8=Xe.safeRead=void 0;var Tu=Fa();function ip(){throw new Error("unexpected end of buffer")}function sp(e,t){return e.byteLength<t&&ip(),e.read(t)}Xe.safeRead=sp;function Va(e){let t=e.readUint8();return t===void 0&&ip(),t}Xe.safeReadUint8=Va;function vb(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 Tu.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}Xe.lebEncode=vb;function ap(e){let t=BigInt(1),r=BigInt(0),n;do n=Va(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}Xe.lebDecode=ap;function Rb(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 Tu.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let s=i(e);if(e/=BigInt(128),t&&e===BigInt(0)&&(s&64)!==0||!t&&e===BigInt(0)&&(s&64)===0){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let a=s%BigInt(128);return Number(t?BigInt(128)-a-BigInt(1):a)}return n.buffer}Xe.slebEncode=Rb;function Ab(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if((t[r]&64)===0)return ap(e);break}let n=new Uint8Array(sp(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)}Xe.slebDecode=Ab;function Sb(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return op(e,t)}Xe.writeUIntLE=Sb;function op(e,t){e=BigInt(e);let r=new Tu.PipeArrayBuffer(new ArrayBuffer(Math.min(1,t)),0),n=0,i=BigInt(256),s=BigInt(0),a=Number(e%i);for(r.write(new Uint8Array([a]));++n<t;)e<0&&s===BigInt(0)&&a!==0&&(s=BigInt(1)),a=Number((e/i-s)%BigInt(256)),r.write(new Uint8Array([a])),i*=BigInt(256);return r.buffer}Xe.writeIntLE=op;function cp(e,t){let r=BigInt(Va(e)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(Va(e));r=r+n*s}return r}Xe.readUIntLE=cp;function Ib(e,t){let r=cp(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Xe.readIntLE=Ib});var up=ee(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.iexp2=xi.ilog2=void 0;function Bb(e){let t=BigInt(e);if(e<=0)throw new RangeError("Input must be positive");return t.toString(2).length-1}xi.ilog2=Bb;function Pb(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}xi.iexp2=Pb});var Au=ee(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.Variant=W.Record=W.Opt=W.Vec=W.Tuple=W.Principal=W.Nat64=W.Nat32=W.Nat16=W.Nat8=W.Int64=W.Int32=W.Int16=W.Int8=W.Float64=W.Float32=W.Nat=W.Int=W.Text=W.Null=W.Bool=W.Unknown=W.Reserved=W.Empty=W.decode=W.encode=W.ServiceClass=W.FuncClass=W.PrincipalClass=W.RecClass=W.VariantClass=W.TupleClass=W.RecordClass=W.OptClass=W.VecClass=W.FixedNatClass=W.FixedIntClass=W.FloatClass=W.NatClass=W.IntClass=W.TextClass=W.ReservedClass=W.NullClass=W.BoolClass=W.UnknownClass=W.EmptyClass=W.ConstructType=W.PrimitiveType=W.Type=W.Visitor=void 0;W.Service=W.Func=W.Rec=void 0;var Fb=Ct(),Fe=Fa(),Vr=xu(),ce=Nu(),Eu=up(),Ca="DIDL",lp=400;function ps(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,Fe.concat)(...this._typs);return(0,Fe.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)}},vu=class{visitType(t,r){throw new Error("Not implemented")}visitPrimitive(t,r){return this.visitType(t,r)}visitEmpty(t,r){return this.visitPrimitive(t,r)}visitBool(t,r){return this.visitPrimitive(t,r)}visitNull(t,r){return this.visitPrimitive(t,r)}visitReserved(t,r){return this.visitPrimitive(t,r)}visitText(t,r){return this.visitPrimitive(t,r)}visitNumber(t,r){return this.visitPrimitive(t,r)}visitInt(t,r){return this.visitNumber(t,r)}visitNat(t,r){return this.visitNumber(t,r)}visitFloat(t,r){return this.visitPrimitive(t,r)}visitFixedInt(t,r){return this.visitNumber(t,r)}visitFixedNat(t,r){return this.visitNumber(t,r)}visitPrincipal(t,r){return this.visitPrimitive(t,r)}visitConstruct(t,r){return this.visitType(t,r)}visitVec(t,r,n){return this.visitConstruct(t,n)}visitOpt(t,r,n){return this.visitConstruct(t,n)}visitRecord(t,r,n){return this.visitConstruct(t,n)}visitTuple(t,r,n){let i=r.map((s,a)=>[`_${a}_`,s]);return this.visitRecord(t,i,n)}visitVariant(t,r,n){return this.visitConstruct(t,n)}visitRec(t,r,n){return this.visitConstruct(r,n)}visitFunc(t,r){return this.visitConstruct(t,r)}visitService(t,r){return this.visitConstruct(t,r)}};W.Visitor=vu;var Ti=class{display(){return this.name}valueToString(t){return rt(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}};W.Type=Ti;var zt=class extends Ti{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){}};W.PrimitiveType=zt;var qr=class extends Ti{checkType(t){if(t instanceof gn){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)}};W.ConstructType=qr;var qa=class extends zt{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,ce.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};W.EmptyClass=qa;var Da=class extends Ti{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,r){throw t.visitType(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof gn?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"}};W.UnknownClass=Da;var ka=class extends zt{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return(0,ce.slebEncode)(-2)}decodeValue(t,r){switch(this.checkType(r),(0,ce.safeReadUint8)(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};W.BoolClass=ka;var Ma=class extends zt{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ce.slebEncode)(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}};W.NullClass=Ma;var Ni=class extends zt{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ce.slebEncode)(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}};W.ReservedClass=Ni;var ja=class extends zt{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=(0,ce.lebEncode)(r.byteLength);return(0,Fe.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+'"'}};W.TextClass=ja;var La=class extends zt{accept(t,r){return t.visitInt(this,r)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return(0,ce.slebEncode)(t)}encodeType(){return(0,ce.slebEncode)(-4)}decodeValue(t,r){return this.checkType(r),(0,ce.slebDecode)(t)}get name(){return"int"}valueToString(t){return t.toString()}};W.IntClass=La;var Ha=class extends zt{accept(t,r){return t.visitNat(this,r)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return(0,ce.lebEncode)(t)}encodeType(){return(0,ce.slebEncode)(-3)}decodeValue(t,r){return this.checkType(r),(0,ce.lebDecode)(t)}get name(){return"nat"}valueToString(t){return t.toString()}};W.NatClass=Ha;var hs=class extends zt{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,r){return t.visitFloat(this,r)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),r}encodeType(){let t=this._bits===32?-13:-14;return(0,ce.slebEncode)(t)}decodeValue(t,r){this.checkType(r);let n=(0,ce.safeRead)(t,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}};W.FloatClass=hs;var rn=class extends zt{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=(0,Eu.iexp2)(this._bits-1)*BigInt(-1),n=(0,Eu.iexp2)(this._bits-1)-BigInt(1),i=!1;if(typeof t=="bigint")i=t>=r&&t<=n;else if(Number.isInteger(t)){let s=BigInt(t);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return(0,ce.writeIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,ce.slebEncode)(-9-t)}decodeValue(t,r){this.checkType(r);let n=(0,ce.readIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}};W.FixedIntClass=rn;var Cr=class extends zt{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=(0,Eu.iexp2)(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<r:Number.isInteger(t)&&t>=0?n=BigInt(t)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return(0,ce.writeUIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,ce.slebEncode)(-5-t)}decodeValue(t,r){this.checkType(r);let n=(0,ce.readUIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}};W.FixedNatClass=Cr;var Ka=class e extends qr{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof Cr&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof Cr?this._type._bits:this._type instanceof rn?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 $m=Object.create;var ga=Object.defineProperty;var Wm=Object.getOwnPropertyDescriptor;var zm=Object.getOwnPropertyNames;var Ym=Object.getPrototypeOf,Jm=Object.prototype.hasOwnProperty;var fi=(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 Tf=(e,t)=>()=>(e&&(t=e(e=0)),t);var ee=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Zm=(e,t)=>{for(var r in t)ga(e,r,{get:t[r],enumerable:!0})},Nf=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of zm(t))!Jm.call(e,i)&&i!==r&&ga(e,i,{get:()=>t[i],enumerable:!(n=Wm(t,i))||n.enumerable});return e};var be=(e,t,r)=>(r=e!=null?$m(Ym(e)):{},Nf(t||!e||!e.__esModule?ga(r,"default",{value:e,enumerable:!0}):r,e)),Xm=e=>Nf(ga({},"__esModule",{value:!0}),e);var vf=ee(ba=>{"use strict";ba.byteLength=eg;ba.toByteArray=rg;ba.fromByteArray=sg;var Ir=[],ar=[],Qm=typeof Uint8Array<"u"?Uint8Array:Array,Jc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ln=0,Ef=Jc.length;Ln<Ef;++Ln)Ir[Ln]=Jc[Ln],ar[Jc.charCodeAt(Ln)]=Ln;var Ln,Ef;ar[45]=62;ar[95]=63;function Of(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 eg(e){var t=Of(e),r=t[0],n=t[1];return(r+n)*3/4-n}function tg(e,t,r){return(t+r)*3/4-r}function rg(e){var t,r=Of(e),n=r[0],i=r[1],s=new Qm(tg(e,n,i)),a=0,o=i>0?n-4:n,c;for(c=0;c<o;c+=4)t=ar[e.charCodeAt(c)]<<18|ar[e.charCodeAt(c+1)]<<12|ar[e.charCodeAt(c+2)]<<6|ar[e.charCodeAt(c+3)],s[a++]=t>>16&255,s[a++]=t>>8&255,s[a++]=t&255;return i===2&&(t=ar[e.charCodeAt(c)]<<2|ar[e.charCodeAt(c+1)]>>4,s[a++]=t&255),i===1&&(t=ar[e.charCodeAt(c)]<<10|ar[e.charCodeAt(c+1)]<<4|ar[e.charCodeAt(c+2)]>>2,s[a++]=t>>8&255,s[a++]=t&255),s}function ng(e){return Ir[e>>18&63]+Ir[e>>12&63]+Ir[e>>6&63]+Ir[e&63]}function ig(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(ng(n));return i.join("")}function sg(e){for(var t,r=e.length,n=r%3,i=[],s=16383,a=0,o=r-n;a<o;a+=s)i.push(ig(e,a,a+s>o?o:a+s));return n===1?(t=e[r-1],i.push(Ir[t>>2]+Ir[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Ir[t>>10]+Ir[t>>4&63]+Ir[t<<2&63]+"=")),i.join("")}});var Xc=ee(Zc=>{Zc.read=function(e,t,r,n,i){var s,a,o=i*8-n-1,c=(1<<o)-1,d=c>>1,f=-7,p=r?i-1:0,m=r?-1:1,b=e[t+p];for(p+=m,s=b&(1<<-f)-1,b>>=-f,f+=o;f>0;s=s*256+e[t+p],p+=m,f-=8);for(a=s&(1<<-f)-1,s>>=-f,f+=n;f>0;a=a*256+e[t+p],p+=m,f-=8);if(s===0)s=1-d;else{if(s===c)return a?NaN:(b?-1:1)*(1/0);a=a+Math.pow(2,n),s=s-d}return(b?-1:1)*a*Math.pow(2,s-n)};Zc.write=function(e,t,r,n,i,s){var a,o,c,d=s*8-i-1,f=(1<<d)-1,p=f>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:s-1,l=n?1:-1,A=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-a))<1&&(a--,c*=2),a+p>=1?t+=m/c:t+=m*Math.pow(2,1-p),t*c>=2&&(a++,c/=2),a+p>=f?(o=0,a=f):a+p>=1?(o=(t*c-1)*Math.pow(2,i),a=a+p):(o=t*Math.pow(2,p-1)*Math.pow(2,i),a=0));i>=8;e[r+b]=o&255,b+=l,o/=256,i-=8);for(a=a<<i|o,d+=i;d>0;e[r+b]=a&255,b+=l,a/=256,d-=8);e[r+b-l]|=A*128}});var Hf=ee(yi=>{"use strict";var Qc=vf(),hi=Xc(),Rf=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;yi.Buffer=$;yi.SlowBuffer=dg;yi.INSPECT_MAX_BYTES=50;var wa=2147483647;yi.kMaxLength=wa;$.TYPED_ARRAY_SUPPORT=ag();!$.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 ag(){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($.prototype,"parent",{enumerable:!0,get:function(){if($.isBuffer(this))return this.buffer}});Object.defineProperty($.prototype,"offset",{enumerable:!0,get:function(){if($.isBuffer(this))return this.byteOffset}});function en(e){if(e>wa)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,$.prototype),t}function $(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 nu(e)}return Bf(e,t,r)}$.poolSize=8192;function Bf(e,t,r){if(typeof e=="string")return cg(e,t);if(ArrayBuffer.isView(e))return ug(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(Br(e,ArrayBuffer)||e&&Br(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Br(e,SharedArrayBuffer)||e&&Br(e.buffer,SharedArrayBuffer)))return tu(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 $.from(n,t,r);let i=lg(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return $.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)}$.from=function(e,t,r){return Bf(e,t,r)};Object.setPrototypeOf($.prototype,Uint8Array.prototype);Object.setPrototypeOf($,Uint8Array);function Pf(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 og(e,t,r){return Pf(e),e<=0?en(e):t!==void 0?typeof r=="string"?en(e).fill(t,r):en(e).fill(t):en(e)}$.alloc=function(e,t,r){return og(e,t,r)};function nu(e){return Pf(e),en(e<0?0:iu(e)|0)}$.allocUnsafe=function(e){return nu(e)};$.allocUnsafeSlow=function(e){return nu(e)};function cg(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!$.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=Ff(e,t)|0,n=en(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function eu(e){let t=e.length<0?0:iu(e.length)|0,r=en(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function ug(e){if(Br(e,Uint8Array)){let t=new Uint8Array(e);return tu(t.buffer,t.byteOffset,t.byteLength)}return eu(e)}function tu(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,$.prototype),n}function lg(e){if($.isBuffer(e)){let t=iu(e.length)|0,r=en(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||au(e.length)?en(0):eu(e);if(e.type==="Buffer"&&Array.isArray(e.data))return eu(e.data)}function iu(e){if(e>=wa)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+wa.toString(16)+" bytes");return e|0}function dg(e){return+e!=e&&(e=0),$.alloc(+e)}$.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==$.prototype};$.compare=function(t,r){if(Br(t,Uint8Array)&&(t=$.from(t,t.offset,t.byteLength)),Br(r,Uint8Array)&&(r=$.from(r,r.offset,r.byteLength)),!$.isBuffer(t)||!$.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let s=0,a=Math.min(n,i);s<a;++s)if(t[s]!==r[s]){n=t[s],i=r[s];break}return n<i?-1:i<n?1:0};$.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}};$.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return $.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=$.allocUnsafe(r),s=0;for(n=0;n<t.length;++n){let a=t[n];if(Br(a,Uint8Array))s+a.length>i.length?($.isBuffer(a)||(a=$.from(a)),a.copy(i,s)):Uint8Array.prototype.set.call(i,a,s);else if($.isBuffer(a))a.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=a.length}return i};function Ff(e,t){if($.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Br(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 ru(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Lf(e).length;default:if(i)return n?-1:ru(e).length;t=(""+t).toLowerCase(),i=!0}}$.byteLength=Ff;function fg(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 Tg(this,t,r);case"utf8":case"utf-8":return Vf(this,t,r);case"ascii":return wg(this,t,r);case"latin1":case"binary":return xg(this,t,r);case"base64":return gg(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ng(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}$.prototype._isBuffer=!0;function Hn(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}$.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)Hn(this,r,r+1);return this};$.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)Hn(this,r,r+3),Hn(this,r+1,r+2);return this};$.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)Hn(this,r,r+7),Hn(this,r+1,r+6),Hn(this,r+2,r+5),Hn(this,r+3,r+4);return this};$.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Vf(this,0,t):fg.apply(this,arguments)};$.prototype.toLocaleString=$.prototype.toString;$.prototype.equals=function(t){if(!$.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:$.compare(this,t)===0};$.prototype.inspect=function(){let t="",r=yi.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};Rf&&($.prototype[Rf]=$.prototype.inspect);$.prototype.compare=function(t,r,n,i,s){if(Br(t,Uint8Array)&&(t=$.from(t,t.offset,t.byteLength)),!$.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;let a=s-i,o=n-r,c=Math.min(a,o),d=this.slice(i,s),f=t.slice(r,n);for(let p=0;p<c;++p)if(d[p]!==f[p]){a=d[p],o=f[p];break}return a<o?-1:o<a?1:0};function Uf(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,au(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=$.from(t,n)),$.isBuffer(t))return t.length===0?-1:Af(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Af(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Af(e,t,r,n,i){let s=1,a=e.length,o=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;s=2,a/=2,o/=2,r/=2}function c(f,p){return s===1?f[p]:f.readUInt16BE(p*s)}let d;if(i){let f=-1;for(d=r;d<a;d++)if(c(e,d)===c(t,f===-1?0:d-f)){if(f===-1&&(f=d),d-f+1===o)return f*s}else f!==-1&&(d-=d-f),f=-1}else for(r+o>a&&(r=a-o),d=r;d>=0;d--){let f=!0;for(let p=0;p<o;p++)if(c(e,d+p)!==c(t,p)){f=!1;break}if(f)return d}return-1}$.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};$.prototype.indexOf=function(t,r,n){return Uf(this,t,r,n,!0)};$.prototype.lastIndexOf=function(t,r,n){return Uf(this,t,r,n,!1)};function pg(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=t.length;n>s/2&&(n=s/2);let a;for(a=0;a<n;++a){let o=parseInt(t.substr(a*2,2),16);if(au(o))return a;e[r+a]=o}return a}function hg(e,t,r,n){return xa(ru(t,e.length-r),e,r,n)}function _g(e,t,r,n){return xa(Rg(t),e,r,n)}function yg(e,t,r,n){return xa(Lf(t),e,r,n)}function mg(e,t,r,n){return xa(Ag(t,e.length-r),e,r,n)}$.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let a=!1;for(;;)switch(i){case"hex":return pg(this,t,r,n);case"utf8":case"utf-8":return hg(this,t,r,n);case"ascii":case"latin1":case"binary":return _g(this,t,r,n);case"base64":return yg(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mg(this,t,r,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}};$.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function gg(e,t,r){return t===0&&r===e.length?Qc.fromByteArray(e):Qc.fromByteArray(e.slice(t,r))}function Vf(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let s=e[i],a=null,o=s>239?4:s>223?3:s>191?2:1;if(i+o<=r){let c,d,f,p;switch(o){case 1:s<128&&(a=s);break;case 2:c=e[i+1],(c&192)===128&&(p=(s&31)<<6|c&63,p>127&&(a=p));break;case 3:c=e[i+1],d=e[i+2],(c&192)===128&&(d&192)===128&&(p=(s&15)<<12|(c&63)<<6|d&63,p>2047&&(p<55296||p>57343)&&(a=p));break;case 4:c=e[i+1],d=e[i+2],f=e[i+3],(c&192)===128&&(d&192)===128&&(f&192)===128&&(p=(s&15)<<18|(c&63)<<12|(d&63)<<6|f&63,p>65535&&p<1114112&&(a=p))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),i+=o}return bg(n)}var Sf=4096;function bg(e){let t=e.length;if(t<=Sf)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Sf));return r}function wg(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 xg(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 Tg(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+=Sg[e[s]];return i}function Ng(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}$.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,$.prototype),i};function pt(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}$.prototype.readUintLE=$.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=this[t],s=1,a=0;for(;++a<r&&(s*=256);)i+=this[t+a]*s;return i};$.prototype.readUintBE=$.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=this[t+--r],s=1;for(;r>0&&(s*=256);)i+=this[t+--r]*s;return i};$.prototype.readUint8=$.prototype.readUInt8=function(t,r){return t=t>>>0,r||pt(t,1,this.length),this[t]};$.prototype.readUint16LE=$.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||pt(t,2,this.length),this[t]|this[t+1]<<8};$.prototype.readUint16BE=$.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||pt(t,2,this.length),this[t]<<8|this[t+1]};$.prototype.readUint32LE=$.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};$.prototype.readUint32BE=$.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};$.prototype.readBigUInt64LE=fn(function(t){t=t>>>0,_i(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&cs(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))});$.prototype.readBigUInt64BE=fn(function(t){t=t>>>0,_i(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&cs(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)});$.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=this[t],s=1,a=0;for(;++a<r&&(s*=256);)i+=this[t+a]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};$.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||pt(t,r,this.length);let i=r,s=1,a=this[t+--i];for(;i>0&&(s*=256);)a+=this[t+--i]*s;return s*=128,a>=s&&(a-=Math.pow(2,8*r)),a};$.prototype.readInt8=function(t,r){return t=t>>>0,r||pt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};$.prototype.readInt16LE=function(t,r){t=t>>>0,r||pt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};$.prototype.readInt16BE=function(t,r){t=t>>>0,r||pt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};$.prototype.readInt32LE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};$.prototype.readInt32BE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};$.prototype.readBigInt64LE=fn(function(t){t=t>>>0,_i(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&cs(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)});$.prototype.readBigInt64BE=fn(function(t){t=t>>>0,_i(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&cs(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)});$.prototype.readFloatLE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),hi.read(this,t,!0,23,4)};$.prototype.readFloatBE=function(t,r){return t=t>>>0,r||pt(t,4,this.length),hi.read(this,t,!1,23,4)};$.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||pt(t,8,this.length),hi.read(this,t,!0,52,8)};$.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||pt(t,8,this.length),hi.read(this,t,!1,52,8)};function Gt(e,t,r,n,i,s){if(!$.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")}$.prototype.writeUintLE=$.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let o=Math.pow(2,8*n)-1;Gt(this,t,r,n,o,0)}let s=1,a=0;for(this[r]=t&255;++a<n&&(s*=256);)this[r+a]=t/s&255;return r+n};$.prototype.writeUintBE=$.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let o=Math.pow(2,8*n)-1;Gt(this,t,r,n,o,0)}let s=n-1,a=1;for(this[r+s]=t&255;--s>=0&&(a*=256);)this[r+s]=t/a&255;return r+n};$.prototype.writeUint8=$.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};$.prototype.writeUint16LE=$.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};$.prototype.writeUint16BE=$.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};$.prototype.writeUint32LE=$.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};$.prototype.writeUint32BE=$.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 Cf(e,t,r,n,i){jf(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a,r}function qf(e,t,r,n,i){jf(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r+7]=s,s=s>>8,e[r+6]=s,s=s>>8,e[r+5]=s,s=s>>8,e[r+4]=s;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=a,a=a>>8,e[r+2]=a,a=a>>8,e[r+1]=a,a=a>>8,e[r]=a,r+8}$.prototype.writeBigUInt64LE=fn(function(t,r=0){return Cf(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});$.prototype.writeBigUInt64BE=fn(function(t,r=0){return qf(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});$.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,a=1,o=0;for(this[r]=t&255;++s<n&&(a*=256);)t<0&&o===0&&this[r+s-1]!==0&&(o=1),this[r+s]=(t/a>>0)-o&255;return r+n};$.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,a=1,o=0;for(this[r+s]=t&255;--s>=0&&(a*=256);)t<0&&o===0&&this[r+s+1]!==0&&(o=1),this[r+s]=(t/a>>0)-o&255;return r+n};$.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};$.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};$.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};$.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};$.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};$.prototype.writeBigInt64LE=fn(function(t,r=0){return Cf(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});$.prototype.writeBigInt64BE=fn(function(t,r=0){return qf(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Df(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 kf(e,t,r,n,i){return t=+t,r=r>>>0,i||Df(e,t,r,4,34028234663852886e22,-34028234663852886e22),hi.write(e,t,r,n,23,4),r+4}$.prototype.writeFloatLE=function(t,r,n){return kf(this,t,r,!0,n)};$.prototype.writeFloatBE=function(t,r,n){return kf(this,t,r,!1,n)};function Mf(e,t,r,n,i){return t=+t,r=r>>>0,i||Df(e,t,r,8,17976931348623157e292,-17976931348623157e292),hi.write(e,t,r,n,52,8),r+8}$.prototype.writeDoubleLE=function(t,r,n){return Mf(this,t,r,!0,n)};$.prototype.writeDoubleBE=function(t,r,n){return Mf(this,t,r,!1,n)};$.prototype.copy=function(t,r,n,i){if(!$.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};$.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"&&!$.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let a=t.charCodeAt(0);(i==="utf8"&&a<128||i==="latin1")&&(t=a)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let s;if(typeof t=="number")for(s=r;s<n;++s)this[s]=t;else{let a=$.isBuffer(t)?t:$.from(t,i),o=a.length;if(o===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=a[s%o]}return this};var pi={};function su(e,t,r){pi[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}`}}}su("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);su("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);su("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=If(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=If(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function If(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 Eg(e,t,r){_i(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&cs(t,e.length-(r+1))}function jf(e,t,r,n,i,s){if(e>r||e<t){let a=typeof t=="bigint"?"n":"",o;throw s>3?t===0||t===BigInt(0)?o=`>= 0${a} and < 2${a} ** ${(s+1)*8}${a}`:o=`>= -(2${a} ** ${(s+1)*8-1}${a}) and < 2 ** ${(s+1)*8-1}${a}`:o=`>= ${t}${a} and <= ${r}${a}`,new pi.ERR_OUT_OF_RANGE("value",o,e)}Eg(n,i,s)}function _i(e,t){if(typeof e!="number")throw new pi.ERR_INVALID_ARG_TYPE(t,"number",e)}function cs(e,t,r){throw Math.floor(e)!==e?(_i(e,r),new pi.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new pi.ERR_BUFFER_OUT_OF_BOUNDS:new pi.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var Og=/[^+/0-9A-Za-z-_]/g;function vg(e){if(e=e.split("=")[0],e=e.trim().replace(Og,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function ru(e,t){t=t||1/0;let r,n=e.length,i=null,s=[];for(let a=0;a<n;++a){if(r=e.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(a+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function Rg(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Ag(e,t){let r,n,i,s=[];for(let a=0;a<e.length&&!((t-=2)<0);++a)r=e.charCodeAt(a),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function Lf(e){return Qc.toByteArray(vg(e))}function xa(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 Br(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function au(e){return e!==e}var Sg=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 fn(e){return typeof BigInt>"u"?Ig:e}function Ig(){throw new Error("BigInt not supported")}});var ou=ee(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.ReplicaRejectCode=void 0;var Bg;(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"})(Bg=us.ReplicaRejectCode||(us.ReplicaRejectCode={}))});var Kf=ee(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.decode=gi.encode=void 0;var Ta="abcdefghijklmnopqrstuvwxyz234567",mi=Object.create(null);for(let e=0;e<Ta.length;e++)mi[Ta[e]]=e;mi[0]=mi.o;mi[1]=mi.i;function Pg(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+=Ta[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?Ta[r>>3]:"")}gi.encode=Pg;function Fg(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0;function s(a){let o=mi[a.toLowerCase()];if(o===void 0)throw new Error(`Invalid character: ${JSON.stringify(a)}`);o<<=3,r|=o>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=o<<5-t&255:r=0)}for(let a of e)s(a);return n.slice(0,i)}gi.decode=Fg});var Gf=ee(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});Na.getCrc32=void 0;var Ug=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 Vg(e){let t=new Uint8Array(e),r=-1;for(let n=0;n<t.length;n++){let s=(t[n]^r)&255;r=Ug[s]^r>>>8}return(r^-1)>>>0}Na.getCrc32=Vg});var uu=ee(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Pr.isBytes=Wf;Pr.number=Ea;Pr.bool=$f;Pr.bytes=cu;Pr.hash=zf;Pr.exists=Yf;Pr.output=Jf;function Ea(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function $f(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function Wf(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function cu(e,...t){if(!Wf(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 zf(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ea(e.outputLen),Ea(e.blockLen)}function Yf(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 Jf(e,t){cu(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Cg={number:Ea,bool:$f,bytes:cu,hash:zf,exists:Yf,output:Jf};Pr.default=Cg});var Zf=ee(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});Oa.crypto=void 0;var pn=fi("node:crypto");Oa.crypto=pn&&typeof pn=="object"&&"webcrypto"in pn?pn.webcrypto:pn&&typeof pn=="object"&&"randomBytes"in pn?pn:void 0});var Kn=ee(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.Hash=xe.nextTick=xe.byteSwapIfBE=xe.byteSwap=xe.isLE=xe.rotl=xe.rotr=xe.createView=xe.u32=xe.u8=void 0;xe.isBytes=qg;xe.byteSwap32=Kg;xe.bytesToHex=$g;xe.hexToBytes=Wg;xe.asyncLoop=Yg;xe.utf8ToBytes=Qf;xe.toBytes=va;xe.concatBytes=Jg;xe.checkOpts=Xg;xe.wrapConstructor=Qg;xe.wrapConstructorWithOpts=eb;xe.wrapXOFConstructorWithOpts=tb;xe.randomBytes=rb;var bi=Zf(),du=uu();function qg(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}var Dg=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);xe.u8=Dg;var kg=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));xe.u32=kg;var Mg=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);xe.createView=Mg;var jg=(e,t)=>e<<32-t|e>>>t;xe.rotr=jg;var Lg=(e,t)=>e<<t|e>>>32-t>>>0;xe.rotl=Lg;xe.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Hg=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;xe.byteSwap=Hg;xe.byteSwapIfBE=xe.isLE?e=>e:e=>(0,xe.byteSwap)(e);function Kg(e){for(let t=0;t<e.length;t++)e[t]=(0,xe.byteSwap)(e[t])}var Gg=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function $g(e){(0,du.bytes)(e);let t="";for(let r=0;r<e.length;r++)t+=Gg[e[r]];return t}var tn={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Xf(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 Wg(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let a=Xf(e.charCodeAt(s)),o=Xf(e.charCodeAt(s+1));if(a===void 0||o===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=a*16+o}return n}var zg=async()=>{};xe.nextTick=zg;async function Yg(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,xe.nextTick)(),n+=s)}}function Qf(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function va(e){return typeof e=="string"&&(e=Qf(e)),(0,du.bytes)(e),e}function Jg(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];(0,du.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 lu=class{clone(){return this._cloneInto()}};xe.Hash=lu;var Zg={}.toString;function Xg(e,t){if(t!==void 0&&Zg.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(e,t)}function Qg(e){let t=n=>e().update(va(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function eb(e){let t=(n,i)=>e(i).update(va(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function tb(e){let t=(n,i)=>e(i).update(va(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function rb(e=32){if(bi.crypto&&typeof bi.crypto.getRandomValues=="function")return bi.crypto.getRandomValues(new Uint8Array(e));if(bi.crypto&&typeof bi.crypto.randomBytes=="function")return bi.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}});var hu=ee(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.HashMD=hn.Maj=hn.Chi=void 0;var fu=uu(),ls=Kn();function nb(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let i=BigInt(32),s=BigInt(4294967295),a=Number(r>>i&s),o=Number(r&s),c=n?4:0,d=n?0:4;e.setUint32(t+c,a,n),e.setUint32(t+d,o,n)}var ib=(e,t,r)=>e&t^~e&r;hn.Chi=ib;var sb=(e,t,r)=>e&t^e&r^t&r;hn.Maj=sb;var pu=class extends ls.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,ls.createView)(this.buffer)}update(t){(0,fu.exists)(this);let{view:r,buffer:n,blockLen:i}=this;t=(0,ls.toBytes)(t);let s=t.length;for(let a=0;a<s;){let o=Math.min(i-this.pos,s-a);if(o===i){let c=(0,ls.createView)(t);for(;i<=s-a;a+=i)this.process(c,a);continue}n.set(t.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,fu.exists)(this),(0,fu.output)(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:a}=this;r[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>i-a&&(this.process(n,0),a=0);for(let p=a;p<i;p++)r[p]=0;nb(n,i-8,BigInt(this.length*8),s),this.process(n,0);let o=(0,ls.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<d;p++)o.setUint32(4*p,f[p],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:a,pos:o}=this;return t.length=i,t.pos=o,t.finished=s,t.destroyed=a,i%r&&t.buffer.set(n),t}};hn.HashMD=pu});var Ra=ee(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});mn.sha224=mn.sha256=mn.SHA256=void 0;var _u=hu(),or=Kn(),ab=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]),_n=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),yn=new Uint32Array(64),ds=class extends _u.HashMD{constructor(){super(64,32,8,!1),this.A=_n[0]|0,this.B=_n[1]|0,this.C=_n[2]|0,this.D=_n[3]|0,this.E=_n[4]|0,this.F=_n[5]|0,this.G=_n[6]|0,this.H=_n[7]|0}get(){let{A:t,B:r,C:n,D:i,E:s,F:a,G:o,H:c}=this;return[t,r,n,i,s,a,o,c]}set(t,r,n,i,s,a,o,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=a|0,this.G=o|0,this.H=c|0}process(t,r){for(let p=0;p<16;p++,r+=4)yn[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let m=yn[p-15],b=yn[p-2],l=(0,or.rotr)(m,7)^(0,or.rotr)(m,18)^m>>>3,A=(0,or.rotr)(b,17)^(0,or.rotr)(b,19)^b>>>10;yn[p]=A+yn[p-7]+l+yn[p-16]|0}let{A:n,B:i,C:s,D:a,E:o,F:c,G:d,H:f}=this;for(let p=0;p<64;p++){let m=(0,or.rotr)(o,6)^(0,or.rotr)(o,11)^(0,or.rotr)(o,25),b=f+m+(0,_u.Chi)(o,c,d)+ab[p]+yn[p]|0,A=((0,or.rotr)(n,2)^(0,or.rotr)(n,13)^(0,or.rotr)(n,22))+(0,_u.Maj)(n,i,s)|0;f=d,d=c,c=o,o=a+b|0,a=s,s=i,i=n,n=b+A|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,a=a+this.D|0,o=o+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,i,s,a,o,c,d,f)}roundClean(){yn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};mn.SHA256=ds;var yu=class extends ds{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}};mn.sha256=(0,or.wrapConstructor)(()=>new ds);mn.sha224=(0,or.wrapConstructor)(()=>new yu)});var ep=ee(Aa=>{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.sha224=void 0;var ob=Ra();function cb(e){return ob.sha224.create().update(new Uint8Array(e)).digest()}Aa.sha224=cb});var Ct=ee(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.Principal=Fr.JSON_KEY_PRINCIPAL=void 0;var tp=Kf(),ub=Gf(),lb=ep();Fr.JSON_KEY_PRINCIPAL="__principal__";var db=2,rp=4,fb="aaaaa-aa",pb=e=>{var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))},hb=e=>e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""),mu=class e{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([rp]))}static managementCanister(){return this.fromHex(fb)}static selfAuthenticating(t){let r=(0,lb.sha224)(t);return new this(new Uint8Array([...r,db]))}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(pb(t))}static fromText(t){let r=t;if(t.includes(Fr.JSON_KEY_PRINCIPAL)){let a=JSON.parse(t);Fr.JSON_KEY_PRINCIPAL in a&&(r=a[Fr.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,tp.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]===rp}toUint8Array(){return this._arr}toHex(){return hb(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,(0,ub.getCrc32)(this._arr));let n=new Uint8Array(t),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),o=(0,tp.encode)(s).match(/.{1,5}/g);if(!o)throw new Error;return o.join("-")}toString(){return this.toText()}toJSON(){return{[Fr.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"}};Fr.Principal=mu});var $t=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 _b(...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=_b;function yb(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}vt.toHex=yb;var mb=new RegExp(/^[0-9a-fA-F]+$/);function gb(e){if(!mb.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=gb;function np(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=np;function bb(e,t){return np(e,t)===0}vt.bufEquals=bb;function Sa(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}vt.uint8ToBuf=Sa;function ip(e){return e instanceof Uint8Array?Sa(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Sa(new Uint8Array(e)):"buffer"in e?ip(e.buffer):Sa(new Uint8Array(e))}vt.bufFromBufLike=ip});var wi=ee(Ur=>{"use strict";Object.defineProperty(Ur,"__esModule",{value:!0});Ur.UpdateCallRejectedError=Ur.QueryCallRejectedError=Ur.ActorCallError=Ur.AgentError=void 0;var wu=Ct(),wb=ou(),xb=$t(),Ia=class e extends Error{constructor(t){super(t),this.message=t,this.name="AgentError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Ur.AgentError=Ia;var fs=class e extends Ia{constructor(t,r,n,i){let s=wu.Principal.from(t);super(["Call failed:",` Canister: ${s.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(a=>` "${a}": ${JSON.stringify(i[a])}`)].join(`
4
+ `)),this.canisterId=t,this.methodName=r,this.type=n,this.props=i,this.name="ActorCallError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}};Ur.ActorCallError=fs;var gu=class e extends fs{constructor(t,r,n){var i;let s=wu.Principal.from(t);super(s,r,"query",{Status:n.status,Code:(i=wb.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)}};Ur.QueryCallRejectedError=gu;var bu=class e extends fs{constructor(t,r,n,i){let s=wu.Principal.from(t);super(s,r,"update",Object.assign({"Request ID":(0,xb.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)}};Ur.UpdateCallRejectedError=bu});var Fa=ee(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.bufFromBufLike=Wt.uint8ToBuf=Wt.PipeArrayBuffer=Wt.fromHexString=Wt.toHexString=Wt.concat=void 0;function Tb(...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}Wt.concat=Tb;function Nb(e){return new Uint8Array(e).reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}Wt.toHexString=Nb;function Eb(e){var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))}Wt.fromHexString=Eb;var xu=class{constructor(t,r=t?.byteLength||0){this._buffer=Pa(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Pa(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}};Wt.PipeArrayBuffer=xu;function Ba(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}Wt.uint8ToBuf=Ba;function Pa(e){return e instanceof Uint8Array?Ba(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Ba(new Uint8Array(e)):"buffer"in e?Pa(e.buffer):Ba(new Uint8Array(e))}Wt.bufFromBufLike=Pa});var Tu=ee(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.idlLabelToId=void 0;function Ob(e){let r=new TextEncoder().encode(e),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function vb(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 Ob(e)}Ua.idlLabelToId=vb});var Eu=ee(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.readIntLE=Xe.readUIntLE=Xe.writeIntLE=Xe.writeUIntLE=Xe.slebDecode=Xe.slebEncode=Xe.lebDecode=Xe.lebEncode=Xe.safeReadUint8=Xe.safeRead=void 0;var Nu=Fa();function sp(){throw new Error("unexpected end of buffer")}function ap(e,t){return e.byteLength<t&&sp(),e.read(t)}Xe.safeRead=ap;function Va(e){let t=e.readUint8();return t===void 0&&sp(),t}Xe.safeReadUint8=Va;function Rb(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}Xe.lebEncode=Rb;function op(e){let t=BigInt(1),r=BigInt(0),n;do n=Va(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}Xe.lebDecode=op;function Ab(e){typeof e=="number"&&(e=BigInt(e));let t=e<BigInt(0);t&&(e=-e-BigInt(1));let r=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,n=new Nu.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let s=i(e);if(e/=BigInt(128),t&&e===BigInt(0)&&(s&64)!==0||!t&&e===BigInt(0)&&(s&64)===0){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let a=s%BigInt(128);return Number(t?BigInt(128)-a-BigInt(1):a)}return n.buffer}Xe.slebEncode=Ab;function Sb(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if((t[r]&64)===0)return op(e);break}let n=new Uint8Array(ap(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)}Xe.slebDecode=Sb;function Ib(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return cp(e,t)}Xe.writeUIntLE=Ib;function cp(e,t){e=BigInt(e);let r=new Nu.PipeArrayBuffer(new ArrayBuffer(Math.min(1,t)),0),n=0,i=BigInt(256),s=BigInt(0),a=Number(e%i);for(r.write(new Uint8Array([a]));++n<t;)e<0&&s===BigInt(0)&&a!==0&&(s=BigInt(1)),a=Number((e/i-s)%BigInt(256)),r.write(new Uint8Array([a])),i*=BigInt(256);return r.buffer}Xe.writeIntLE=cp;function up(e,t){let r=BigInt(Va(e)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(Va(e));r=r+n*s}return r}Xe.readUIntLE=up;function Bb(e,t){let r=up(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Xe.readIntLE=Bb});var lp=ee(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.iexp2=xi.ilog2=void 0;function Pb(e){let t=BigInt(e);if(e<=0)throw new RangeError("Input must be positive");return t.toString(2).length-1}xi.ilog2=Pb;function Fb(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}xi.iexp2=Fb});var Su=ee(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.Variant=W.Record=W.Opt=W.Vec=W.Tuple=W.Principal=W.Nat64=W.Nat32=W.Nat16=W.Nat8=W.Int64=W.Int32=W.Int16=W.Int8=W.Float64=W.Float32=W.Nat=W.Int=W.Text=W.Null=W.Bool=W.Unknown=W.Reserved=W.Empty=W.decode=W.encode=W.ServiceClass=W.FuncClass=W.PrincipalClass=W.RecClass=W.VariantClass=W.TupleClass=W.RecordClass=W.OptClass=W.VecClass=W.FixedNatClass=W.FixedIntClass=W.FloatClass=W.NatClass=W.IntClass=W.TextClass=W.ReservedClass=W.NullClass=W.BoolClass=W.UnknownClass=W.EmptyClass=W.ConstructType=W.PrimitiveType=W.Type=W.Visitor=void 0;W.Service=W.Func=W.Rec=void 0;var Ub=Ct(),Fe=Fa(),Vr=Tu(),ce=Eu(),Ou=lp(),Ca="DIDL",dp=400;function ps(e,t,r){return e.map((n,i)=>r(n,t[i]))}var vu=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,Fe.concat)(...this._typs);return(0,Fe.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)}},Ru=class{visitType(t,r){throw new Error("Not implemented")}visitPrimitive(t,r){return this.visitType(t,r)}visitEmpty(t,r){return this.visitPrimitive(t,r)}visitBool(t,r){return this.visitPrimitive(t,r)}visitNull(t,r){return this.visitPrimitive(t,r)}visitReserved(t,r){return this.visitPrimitive(t,r)}visitText(t,r){return this.visitPrimitive(t,r)}visitNumber(t,r){return this.visitPrimitive(t,r)}visitInt(t,r){return this.visitNumber(t,r)}visitNat(t,r){return this.visitNumber(t,r)}visitFloat(t,r){return this.visitPrimitive(t,r)}visitFixedInt(t,r){return this.visitNumber(t,r)}visitFixedNat(t,r){return this.visitNumber(t,r)}visitPrincipal(t,r){return this.visitPrimitive(t,r)}visitConstruct(t,r){return this.visitType(t,r)}visitVec(t,r,n){return this.visitConstruct(t,n)}visitOpt(t,r,n){return this.visitConstruct(t,n)}visitRecord(t,r,n){return this.visitConstruct(t,n)}visitTuple(t,r,n){let i=r.map((s,a)=>[`_${a}_`,s]);return this.visitRecord(t,i,n)}visitVariant(t,r,n){return this.visitConstruct(t,n)}visitRec(t,r,n){return this.visitConstruct(r,n)}visitFunc(t,r){return this.visitConstruct(t,r)}visitService(t,r){return this.visitConstruct(t,r)}};W.Visitor=Ru;var Ti=class{display(){return this.name}valueToString(t){return rt(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}};W.Type=Ti;var zt=class extends Ti{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){}};W.PrimitiveType=zt;var qr=class extends Ti{checkType(t){if(t instanceof gn){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)}};W.ConstructType=qr;var qa=class extends zt{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,ce.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};W.EmptyClass=qa;var Da=class extends Ti{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,r){throw t.visitType(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof gn?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"}};W.UnknownClass=Da;var ka=class extends zt{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return(0,ce.slebEncode)(-2)}decodeValue(t,r){switch(this.checkType(r),(0,ce.safeReadUint8)(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};W.BoolClass=ka;var Ma=class extends zt{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ce.slebEncode)(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}};W.NullClass=Ma;var Ni=class extends zt{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ce.slebEncode)(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}};W.ReservedClass=Ni;var ja=class extends zt{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=(0,ce.lebEncode)(r.byteLength);return(0,Fe.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+'"'}};W.TextClass=ja;var La=class extends zt{accept(t,r){return t.visitInt(this,r)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return(0,ce.slebEncode)(t)}encodeType(){return(0,ce.slebEncode)(-4)}decodeValue(t,r){return this.checkType(r),(0,ce.slebDecode)(t)}get name(){return"int"}valueToString(t){return t.toString()}};W.IntClass=La;var Ha=class extends zt{accept(t,r){return t.visitNat(this,r)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return(0,ce.lebEncode)(t)}encodeType(){return(0,ce.slebEncode)(-3)}decodeValue(t,r){return this.checkType(r),(0,ce.lebDecode)(t)}get name(){return"nat"}valueToString(t){return t.toString()}};W.NatClass=Ha;var hs=class extends zt{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,r){return t.visitFloat(this,r)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),r}encodeType(){let t=this._bits===32?-13:-14;return(0,ce.slebEncode)(t)}decodeValue(t,r){this.checkType(r);let n=(0,ce.safeRead)(t,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}};W.FloatClass=hs;var rn=class extends zt{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=(0,Ou.iexp2)(this._bits-1)*BigInt(-1),n=(0,Ou.iexp2)(this._bits-1)-BigInt(1),i=!1;if(typeof t=="bigint")i=t>=r&&t<=n;else if(Number.isInteger(t)){let s=BigInt(t);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return(0,ce.writeIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,ce.slebEncode)(-9-t)}decodeValue(t,r){this.checkType(r);let n=(0,ce.readIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}};W.FixedIntClass=rn;var Cr=class extends zt{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=(0,Ou.iexp2)(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<r:Number.isInteger(t)&&t>=0?n=BigInt(t)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){return(0,ce.writeUIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,ce.slebEncode)(-5-t)}decodeValue(t,r){this.checkType(r);let n=(0,ce.readUIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}};W.FixedNatClass=Cr;var Ka=class e extends qr{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof Cr&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof Cr?this._type._bits:this._type instanceof rn?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
6
  index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=(0,ce.lebEncode)(t.length);if(this._blobOptimization)return(0,Fe.concat)(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return(0,Fe.concat)(r,new Uint8Array(t.buffer));let n=new Fe.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,Fe.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 Cr){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 rn){if(this._type._bits==8)return new Int8Array(t.read(i));if(this._type._bits==16)return new Int16Array(t.read(i*2));if(this._type._bits==32)return new Int32Array(t.read(i*4));if(this._type._bits==64)return new BigInt64Array(t.read(i*8))}let s=[];for(let a=0;a<i;a++)s.push(this._type.decodeValue(t,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(t){return"vec {"+t.map(n=>this._type.valueToString(n)).join("; ")+"}"}};W.VecClass=Ka;var Ei=class e extends qr{constructor(t){super(),this._type=t}accept(t,r){return t.visitOpt(this,this._type,r)}covariant(t){try{if(Array.isArray(t)&&(t.length===0||t.length===1&&this._type.covariant(t[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${rt(t)}
7
7
 
@@ -11,10 +11,10 @@ field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display
11
11
 
12
12
  index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=ps(this._components,t,(n,i)=>n.encodeValue(i));return(0,Fe.concat)(...r)}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,a]of n._components.entries())s>=this._components.length?a.decodeValue(t,a):i.push(this._components[s].decodeValue(t,a));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${ps(this._components,t,(n,i)=>n.valueToString(i)).join("; ")}}`}};W.TupleClass=Ga;var $a=class e extends qr{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,Vr.idlLabelToId)(r[0])-(0,Vr.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: ${rt(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(t.hasOwnProperty(n)){let s=(0,ce.lebEncode)(r),a=i.encodeValue(t[n]);return(0,Fe.concat)(s,a)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,s])=>{s.buildTypeTable(t)});let r=(0,ce.slebEncode)(-21),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,a])=>(0,Fe.concat)((0,ce.lebEncode)((0,Vr.idlLabelToId)(s)),a.encodeType(t)));t.add(this,(0,Fe.concat)(r,n,...i))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a variant type");let i=Number((0,ce.lebDecode)(t));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,a]=n._fields[i];for(let[o,c]of this._fields)if((0,Vr.idlLabelToId)(s)===(0,Vr.idlLabelToId)(o)){let d=c.decodeValue(t,a);return{[o]:d}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(t){for(let[r,n]of this._fields)if(t.hasOwnProperty(r)){let i=n.valueToString(t[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+t)}};W.VariantClass=$a;var gn=class e extends qr{constructor(){super(...arguments),this._id=e._counter++,this._type=void 0}accept(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,r)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};W.RecClass=gn;gn._counter=0;function Ru(e){if((0,ce.safeReadUint8)(e)!==1)throw new Error("Cannot decode principal");let r=Number((0,ce.lebDecode)(e));return Fb.Principal.fromUint8Array(new Uint8Array((0,ce.safeRead)(e,r)))}var Wa=class extends zt{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,ce.lebEncode)(r.byteLength);return(0,Fe.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,ce.slebEncode)(-24)}decodeValue(t,r){return this.checkType(r),Ru(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};W.PrincipalClass=Wa;var ys=class extends qr{constructor(t,r,n=[]){super(),this.argTypes=t,this.retTypes=r,this.annotations=n}static argsToString(t,r){if(t.length!==r.length)throw new Error("arity mismatch");return"("+t.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(t,r){return t.visitFunc(this,r)}covariant(t){if(Array.isArray(t)&&t.length===2&&t[0]&&t[0]._isPrincipal&&typeof t[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),i=(0,ce.lebEncode)(n.byteLength),s=(0,Fe.concat)(new Uint8Array([1]),i,n),a=new TextEncoder().encode(r),o=(0,ce.lebEncode)(a.byteLength);return(0,Fe.concat)(new Uint8Array([1]),s,o,a)}_buildTypeTableImpl(t){this.argTypes.forEach(d=>d.buildTypeTable(t)),this.retTypes.forEach(d=>d.buildTypeTable(t));let r=(0,ce.slebEncode)(-22),n=(0,ce.lebEncode)(this.argTypes.length),i=(0,Fe.concat)(...this.argTypes.map(d=>d.encodeType(t))),s=(0,ce.lebEncode)(this.retTypes.length),a=(0,Fe.concat)(...this.retTypes.map(d=>d.encodeType(t))),o=(0,ce.lebEncode)(this.annotations.length),c=(0,Fe.concat)(...this.annotations.map(d=>this.encodeAnnotation(d)));t.add(this,(0,Fe.concat)(r,n,i,s,a,o,c))}decodeValue(t){if((0,ce.safeReadUint8)(t)!==1)throw new Error("Cannot decode function reference");let n=Ru(t),i=Number((0,ce.lebDecode)(t)),s=(0,ce.safeRead)(t,i),o=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,o]}get name(){let t=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${t}) -> (${r})${n}`}valueToString([t,r]){return`func "${t.toText()}".${r}`}display(){let t=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${t}) \u2192 (${r})${n}`}encodeAnnotation(t){if(t==="query")return new Uint8Array([1]);if(t==="oneway")return new Uint8Array([2]);if(t==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};W.FuncClass=ys;var za=class extends qr{constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,ce.lebEncode)(r.length);return(0,Fe.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([s,a])=>a.buildTypeTable(t));let r=(0,ce.slebEncode)(-23),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,a])=>{let o=new TextEncoder().encode(s),c=(0,ce.lebEncode)(o.length);return(0,Fe.concat)(c,o,a.encodeType(t))});t.add(this,(0,Fe.concat)(r,n,...i))}decodeValue(t){return Ru(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};W.ServiceClass=za;function rt(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>lp?t.substring(0,lp-3)+"...":t}function Ub(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(Ca),i=r.encode(),s=(0,ce.lebEncode)(t.length),a=(0,Fe.concat)(...e.map(c=>c.encodeType(r))),o=(0,Fe.concat)(...ps(e,t,(c,d)=>{try{c.covariant(d)}catch(f){throw new Error(f.message+`
14
+ variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(t.hasOwnProperty(n)){let s=(0,ce.lebEncode)(r),a=i.encodeValue(t[n]);return(0,Fe.concat)(s,a)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,s])=>{s.buildTypeTable(t)});let r=(0,ce.slebEncode)(-21),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,a])=>(0,Fe.concat)((0,ce.lebEncode)((0,Vr.idlLabelToId)(s)),a.encodeType(t)));t.add(this,(0,Fe.concat)(r,n,...i))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a variant type");let i=Number((0,ce.lebDecode)(t));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,a]=n._fields[i];for(let[o,c]of this._fields)if((0,Vr.idlLabelToId)(s)===(0,Vr.idlLabelToId)(o)){let d=c.decodeValue(t,a);return{[o]:d}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(t){for(let[r,n]of this._fields)if(t.hasOwnProperty(r)){let i=n.valueToString(t[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+t)}};W.VariantClass=$a;var gn=class e extends qr{constructor(){super(...arguments),this._id=e._counter++,this._type=void 0}accept(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,r)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};W.RecClass=gn;gn._counter=0;function Au(e){if((0,ce.safeReadUint8)(e)!==1)throw new Error("Cannot decode principal");let r=Number((0,ce.lebDecode)(e));return Ub.Principal.fromUint8Array(new Uint8Array((0,ce.safeRead)(e,r)))}var Wa=class extends zt{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,ce.lebEncode)(r.byteLength);return(0,Fe.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,ce.slebEncode)(-24)}decodeValue(t,r){return this.checkType(r),Au(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};W.PrincipalClass=Wa;var ys=class extends qr{constructor(t,r,n=[]){super(),this.argTypes=t,this.retTypes=r,this.annotations=n}static argsToString(t,r){if(t.length!==r.length)throw new Error("arity mismatch");return"("+t.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(t,r){return t.visitFunc(this,r)}covariant(t){if(Array.isArray(t)&&t.length===2&&t[0]&&t[0]._isPrincipal&&typeof t[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),i=(0,ce.lebEncode)(n.byteLength),s=(0,Fe.concat)(new Uint8Array([1]),i,n),a=new TextEncoder().encode(r),o=(0,ce.lebEncode)(a.byteLength);return(0,Fe.concat)(new Uint8Array([1]),s,o,a)}_buildTypeTableImpl(t){this.argTypes.forEach(d=>d.buildTypeTable(t)),this.retTypes.forEach(d=>d.buildTypeTable(t));let r=(0,ce.slebEncode)(-22),n=(0,ce.lebEncode)(this.argTypes.length),i=(0,Fe.concat)(...this.argTypes.map(d=>d.encodeType(t))),s=(0,ce.lebEncode)(this.retTypes.length),a=(0,Fe.concat)(...this.retTypes.map(d=>d.encodeType(t))),o=(0,ce.lebEncode)(this.annotations.length),c=(0,Fe.concat)(...this.annotations.map(d=>this.encodeAnnotation(d)));t.add(this,(0,Fe.concat)(r,n,i,s,a,o,c))}decodeValue(t){if((0,ce.safeReadUint8)(t)!==1)throw new Error("Cannot decode function reference");let n=Au(t),i=Number((0,ce.lebDecode)(t)),s=(0,ce.safeRead)(t,i),o=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,o]}get name(){let t=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${t}) -> (${r})${n}`}valueToString([t,r]){return`func "${t.toText()}".${r}`}display(){let t=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${t}) \u2192 (${r})${n}`}encodeAnnotation(t){if(t==="query")return new Uint8Array([1]);if(t==="oneway")return new Uint8Array([2]);if(t==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};W.FuncClass=ys;var za=class extends qr{constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${rt(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,ce.lebEncode)(r.length);return(0,Fe.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([s,a])=>a.buildTypeTable(t));let r=(0,ce.slebEncode)(-23),n=(0,ce.lebEncode)(this._fields.length),i=this._fields.map(([s,a])=>{let o=new TextEncoder().encode(s),c=(0,ce.lebEncode)(o.length);return(0,Fe.concat)(c,o,a.encodeType(t))});t.add(this,(0,Fe.concat)(r,n,...i))}decodeValue(t){return Au(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};W.ServiceClass=za;function rt(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>dp?t.substring(0,dp-3)+"...":t}function Vb(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new vu;e.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(Ca),i=r.encode(),s=(0,ce.lebEncode)(t.length),a=(0,Fe.concat)(...e.map(c=>c.encodeType(r))),o=(0,Fe.concat)(...ps(e,t,(c,d)=>{try{c.covariant(d)}catch(f){throw new Error(f.message+`
15
15
 
16
- `)}return c.encodeValue(d)}));return(0,Fe.concat)(n,i,s,a,o)}W.encode=Ub;function Vb(e,t){let r=new Fe.PipeArrayBuffer(t);if(t.byteLength<Ca.length)throw new Error("Message length smaller than magic number");let n=(0,ce.safeRead)(r,Ca.length),i=new TextDecoder().decode(n);if(i!==Ca)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(b){let l=[],A=Number((0,ce.lebDecode)(b));for(let C=0;C<A;C++){let E=Number((0,ce.slebDecode)(b));switch(E){case-18:case-19:{let H=Number((0,ce.slebDecode)(b));l.push([E,H]);break}case-20:case-21:{let H=[],x=Number((0,ce.lebDecode)(b)),q;for(;x--;){let K=Number((0,ce.lebDecode)(b));if(K>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof q=="number"&&q>=K)throw new Error("field id collision or not sorted");q=K;let G=Number((0,ce.slebDecode)(b));H.push([K,G])}l.push([E,H]);break}case-22:{let H=[],x=Number((0,ce.lebDecode)(b));for(;x--;)H.push(Number((0,ce.slebDecode)(b)));let q=[],K=Number((0,ce.lebDecode)(b));for(;K--;)q.push(Number((0,ce.slebDecode)(b)));let G=[],D=Number((0,ce.lebDecode)(b));for(;D--;)switch(Number((0,ce.lebDecode)(b))){case 1:{G.push("query");break}case 2:{G.push("oneway");break}case 3:{G.push("composite_query");break}default:throw new Error("unknown annotation")}l.push([E,[H,q,G]]);break}case-23:{let H=Number((0,ce.lebDecode)(b)),x=[];for(;H--;){let q=Number((0,ce.lebDecode)(b)),K=new TextDecoder().decode((0,ce.safeRead)(b,q)),G=(0,ce.slebDecode)(b);x.push([K,G])}l.push([E,x]);break}default:throw new Error("Illegal op_code: "+E)}}let v=[],F=Number((0,ce.lebDecode)(b));for(let C=0;C<F;C++)v.push(Number((0,ce.slebDecode)(b)));return[l,v]}let[a,o]=s(r);if(o.length<e.length)throw new Error("Wrong number of return values");let c=a.map(b=>yp());function d(b){if(b<-24)throw new Error("future value not supported");if(b<0)switch(b){case-1:return W.Null;case-2:return W.Bool;case-3:return W.Nat;case-4:return W.Int;case-5:return W.Nat8;case-6:return W.Nat16;case-7:return W.Nat32;case-8:return W.Nat64;case-9:return W.Int8;case-10:return W.Int16;case-11:return W.Int32;case-12:return W.Int64;case-13:return W.Float32;case-14:return W.Float64;case-15:return W.Text;case-16:return W.Reserved;case-17:return W.Empty;case-24:return W.Principal;default:throw new Error("Illegal op_code: "+b)}if(b>=a.length)throw new Error("type index out of range");return c[b]}function f(b){switch(b[0]){case-19:{let l=d(b[1]);return fp(l)}case-18:{let l=d(b[1]);return pp(l)}case-20:{let l={};for(let[F,C]of b[1]){let E=`_${F}_`;l[E]=d(C)}let A=hp(l),v=A.tryAsTuple();return Array.isArray(v)?dp(...v):A}case-21:{let l={};for(let[A,v]of b[1]){let F=`_${A}_`;l[F]=d(v)}return _p(l)}case-22:{let[l,A,v]=b[1];return mp(l.map(F=>d(F)),A.map(F=>d(F)),v)}case-23:{let l={},A=b[1];for(let[v,F]of A){let C=d(F);if(C instanceof gn&&(C=C.getType()),!(C instanceof ys))throw new Error("Illegal service definition: services can only contain functions");l[v]=C}return gp(l)}default:throw new Error("Illegal op_code: "+b[0])}}a.forEach((b,l)=>{if(b[0]===-22){let A=f(b);c[l].fill(A)}}),a.forEach((b,l)=>{if(b[0]!==-22){let A=f(b);c[l].fill(A)}});let p=o.map(b=>d(b)),m=e.map((b,l)=>b.decodeValue(r,p[l]));for(let b=e.length;b<p.length;b++)p[b].decodeValue(r,p[b]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return m}W.decode=Vb;W.Empty=new qa;W.Reserved=new Ni;W.Unknown=new Da;W.Bool=new ka;W.Null=new Ma;W.Text=new ja;W.Int=new La;W.Nat=new Ha;W.Float32=new hs(32);W.Float64=new hs(64);W.Int8=new rn(8);W.Int16=new rn(16);W.Int32=new rn(32);W.Int64=new rn(64);W.Nat8=new Cr(8);W.Nat16=new Cr(16);W.Nat32=new Cr(32);W.Nat64=new Cr(64);W.Principal=new Wa;function dp(...e){return new Ga(e)}W.Tuple=dp;function fp(e){return new Ka(e)}W.Vec=fp;function pp(e){return new Ei(e)}W.Opt=pp;function hp(e){return new _s(e)}W.Record=hp;function _p(e){return new $a(e)}W.Variant=_p;function yp(){return new gn}W.Rec=yp;function mp(e,t,r=[]){return new ys(e,t,r)}W.Func=mp;function gp(e){return new za(e)}W.Service=gp});var Vu=ee(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.VecForm=Rt.OptionForm=Rt.VariantForm=Rt.TupleForm=Rt.RecordForm=Rt.InputForm=Rt.InputBox=void 0;var Su=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)}};Rt.InputBox=Su;var bn=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)}};Rt.InputForm=bn;var Iu=class extends bn{constructor(t,r){super(r),this.fields=t,this.ui=r}generateForm(){this.form=this.fields.map(([t,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(t)?n.label=this.ui.labelMap[t]+" ":n.label=t+" ",n})}parse(t){let r={};if(this.fields.forEach(([n,i],s)=>{let a=this.form[s].parse(t);r[n]=a}),!this.form.some(n=>n.isRejected()))return r}};Rt.RecordForm=Iu;var Bu=class extends bn{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}};Rt.TupleForm=Bu;var Pu=class extends bn{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}};Rt.VariantForm=Pu;var Fu=class extends bn{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]}}};Rt.OptionForm=Fu;var Uu=class extends bn{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}};Rt.VecForm=Uu});var wp=ee(Te=>{"use strict";var Cb=Te&&Te.__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]}),qb=Te&&Te.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),bp=Te&&Te.__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)&&Cb(t,e,r);return qb(t,e),t};Object.defineProperty(Te,"__esModule",{value:!0});Te.renderValue=Te.renderInput=Te.Render=Te.vecForm=Te.optForm=Te.variantForm=Te.tupleForm=Te.recordForm=Te.inputBox=void 0;var Ja=bp(Au()),Cu=Ct(),Oi=bp(Vu()),Db={parse:Gb},ms={render:Mu},kb=(e,t)=>new Oi.InputBox(e,Object.assign(Object.assign({},Db),t));Te.inputBox=kb;var Mb=(e,t)=>new Oi.RecordForm(e,Object.assign(Object.assign({},ms),t));Te.recordForm=Mb;var jb=(e,t)=>new Oi.TupleForm(e,Object.assign(Object.assign({},ms),t));Te.tupleForm=jb;var Lb=(e,t)=>new Oi.VariantForm(e,Object.assign(Object.assign({},ms),t));Te.variantForm=Lb;var Hb=(e,t)=>new Oi.OptionForm(e,Object.assign(Object.assign({},ms),t));Te.optForm=Hb;var Kb=(e,t)=>new Oi.VecForm(e,Object.assign(Object.assign({},ms),t));Te.vecForm=Kb;var Ya=class extends Ja.Visitor{visitType(t,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=t.display(),(0,Te.inputBox)(t,{input:n})}visitNull(t,r){return(0,Te.inputBox)(t,{})}visitRecord(t,r,n){let i={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),i={container:a}}let s=(0,Te.recordForm)(r,i);return(0,Te.inputBox)(t,{form:s})}visitTuple(t,r,n){let i={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),i={container:a}}let s=(0,Te.tupleForm)(r,i);return(0,Te.inputBox)(t,{form:s})}visitVariant(t,r,n){let i=document.createElement("select");for(let[o,c]of r){let d=new Option(o);i.add(d)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},a=(0,Te.variantForm)(r,s);return(0,Te.inputBox)(t,{form:a})}visitOpt(t,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Te.optForm)(r,{open:i,event:"change"});return(0,Te.inputBox)(t,{form:s})}visitVec(t,r,n){let i=document.createElement("input");i.type="number",i.min="0",i.max="100",i.style.width="8rem",i.placeholder="len",i.classList.add("open");let s=document.createElement("div");s.classList.add("popup-form");let a=(0,Te.vecForm)(r,{open:i,event:"change",container:s});return(0,Te.inputBox)(t,{form:a})}visitRec(t,r,n){return Mu(r)}};Te.Render=Ya;var qu=class extends Ja.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 Cu.Principal.fromText(r)}visitService(t,r){return Cu.Principal.fromText(r)}visitFunc(t,r){let n=r.split(".",2);return[Cu.Principal.fromText(n[0]),n[1]]}},Du=class extends Ja.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 Gb(e,t,r){return t.random&&r===""?e.accept(new Du,r):e.accept(new qu,r)}function Mu(e){return e.accept(new Ya,null)}Te.renderInput=Mu;function Gn(e,t,r){return e.accept(new ku,{input:t,value:r})}Te.renderValue=Gn;var ku=class extends Ja.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){Gn(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)),Gn(r,i.form[0],n.value[0])}}visitRecord(t,r,n){let i=n.input.ui.form;r.forEach(([s,a],o)=>{Gn(a,i.form[o],n.value[s])})}visitTuple(t,r,n){let i=n.input.ui.form;r.forEach((s,a)=>{Gn(s,i.form[a],n.value[a])})}visitVariant(t,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([a,o],c)=>{if(a===s[0]){let d=i.ui.open;d.selectedIndex=c,d.dispatchEvent(new Event(i.ui.event)),Gn(o,i.form[0],s[1])}})}visitVec(t,r,n){let i=n.input.ui.form,s=n.value.length,a=i.ui.open;a.value=s,a.dispatchEvent(new Event(i.ui.event)),n.value.forEach((o,c)=>{Gn(r,i.form[c],o)})}}});var Tp=ee(xp=>{"use strict";Object.defineProperty(xp,"__esModule",{value:!0})});var Ri=ee(ht=>{"use strict";var Np=ht&&ht.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),$b=ht&&ht.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),vi=ht&&ht.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Np(t,e,r)},Wb=ht&&ht.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&Np(t,e,r);return $b(t,e),t};Object.defineProperty(ht,"__esModule",{value:!0});ht.IDL=void 0;vi(wp(),ht);vi(Vu(),ht);ht.IDL=Wb(Au());vi(xu(),ht);vi(Nu(),ht);vi(Fa(),ht);vi(Tp(),ht)});var gs=ee((Ep,Za)=>{(function(e){"use strict";var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",a=s+"Number primitive has more than 15 significant digits: ",o=1e14,c=14,d=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,m=1e9;function b(x){var q,K,G,D=U.prototype={constructor:U,toString:null,valueOf:null},ae=new U(1),Q=20,ne=4,w=-7,g=21,S=-1e7,R=1e7,I=!1,j=1,Y=0,oe={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},se="0123456789abcdefghijklmnopqrstuvwxyz",z=!0;function U(u,h){var y,P,O,B,M,T,V,L,k=this;if(!(k instanceof U))return new U(u,h);if(h==null){if(u&&u._isBigNumber===!0){k.s=u.s,!u.c||u.e>R?k.c=k.e=null:u.e<S?k.c=[k.e=0]:(k.e=u.e,k.c=u.c.slice());return}if((T=typeof u=="number")&&u*0==0){if(k.s=1/u<0?(u=-u,-1):1,u===~~u){for(B=0,M=u;M>=10;M/=10,B++);B>R?k.c=k.e=null:(k.e=B,k.c=[u]);return}L=String(u)}else{if(!r.test(L=String(u)))return G(k,L,T);k.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(B=L.indexOf("."))>-1&&(L=L.replace(".","")),(M=L.search(/e/i))>0?(B<0&&(B=M),B+=+L.slice(M+1),L=L.substring(0,M)):B<0&&(B=L.length)}else{if(F(h,2,se.length,"Base"),h==10&&z)return k=new U(u),le(k,Q+k.e+1,ne);if(L=String(u),T=typeof u=="number"){if(u*0!=0)return G(k,L,T,h);if(k.s=1/u<0?(L=L.slice(1),-1):1,U.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(a+u)}else k.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(y=se.slice(0,h),B=M=0,V=L.length;M<V;M++)if(y.indexOf(P=L.charAt(M))<0){if(P=="."){if(M>B){B=V;continue}}else if(!O&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){O=!0,M=-1,B=0;continue}return G(k,String(u),T,h)}T=!1,L=K(L,h,10,k.s),(B=L.indexOf("."))>-1?L=L.replace(".",""):B=L.length}for(M=0;L.charCodeAt(M)===48;M++);for(V=L.length;L.charCodeAt(--V)===48;);if(L=L.slice(M,++V)){if(V-=M,T&&U.DEBUG&&V>15&&(u>d||u!==i(u)))throw Error(a+k.s*u);if((B=B-M-1)>R)k.c=k.e=null;else if(B<S)k.c=[k.e=0];else{if(k.e=B,k.c=[],M=(B+1)%c,B<0&&(M+=c),M<V){for(M&&k.c.push(+L.slice(0,M)),V-=c;M<V;)k.c.push(+L.slice(M,M+=c));M=c-(L=L.slice(M)).length}else M-=V;for(;M--;L+="0");k.c.push(+L)}}else k.c=[k.e=0]}U.clone=b,U.ROUND_UP=0,U.ROUND_DOWN=1,U.ROUND_CEIL=2,U.ROUND_FLOOR=3,U.ROUND_HALF_UP=4,U.ROUND_HALF_DOWN=5,U.ROUND_HALF_EVEN=6,U.ROUND_HALF_CEIL=7,U.ROUND_HALF_FLOOR=8,U.EUCLID=9,U.config=U.set=function(u){var h,y;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(h="DECIMAL_PLACES")&&(y=u[h],F(y,0,m,h),Q=y),u.hasOwnProperty(h="ROUNDING_MODE")&&(y=u[h],F(y,0,8,h),ne=y),u.hasOwnProperty(h="EXPONENTIAL_AT")&&(y=u[h],y&&y.pop?(F(y[0],-m,0,h),F(y[1],0,m,h),w=y[0],g=y[1]):(F(y,-m,m,h),w=-(g=y<0?-y:y))),u.hasOwnProperty(h="RANGE"))if(y=u[h],y&&y.pop)F(y[0],-m,-1,h),F(y[1],1,m,h),S=y[0],R=y[1];else if(F(y,-m,m,h),y)S=-(R=y<0?-y:y);else throw Error(s+h+" cannot be zero: "+y);if(u.hasOwnProperty(h="CRYPTO"))if(y=u[h],y===!!y)if(y)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))I=y;else throw I=!y,Error(s+"crypto unavailable");else I=y;else throw Error(s+h+" not true or false: "+y);if(u.hasOwnProperty(h="MODULO_MODE")&&(y=u[h],F(y,0,9,h),j=y),u.hasOwnProperty(h="POW_PRECISION")&&(y=u[h],F(y,0,m,h),Y=y),u.hasOwnProperty(h="FORMAT"))if(y=u[h],typeof y=="object")oe=y;else throw Error(s+h+" not an object: "+y);if(u.hasOwnProperty(h="ALPHABET"))if(y=u[h],typeof y=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(y))z=y.slice(0,10)=="0123456789",se=y;else throw Error(s+h+" invalid: "+y)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:Q,ROUNDING_MODE:ne,EXPONENTIAL_AT:[w,g],RANGE:[S,R],CRYPTO:I,MODULO_MODE:j,POW_PRECISION:Y,FORMAT:oe,ALPHABET:se}},U.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!U.DEBUG)return!0;var h,y,P=u.c,O=u.e,B=u.s;e:if({}.toString.call(P)=="[object Array]"){if((B===1||B===-1)&&O>=-m&&O<=m&&O===i(O)){if(P[0]===0){if(O===0&&P.length===1)return!0;break e}if(h=(O+1)%c,h<1&&(h+=c),String(P[0]).length==h){for(h=0;h<P.length;h++)if(y=P[h],y<0||y>=o||y!==i(y))break e;if(y!==0)return!0}}}else if(P===null&&O===null&&(B===null||B===1||B===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},U.maximum=U.max=function(){return Z(arguments,-1)},U.minimum=U.min=function(){return Z(arguments,1)},U.random=function(){var u=9007199254740992,h=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(y){var P,O,B,M,T,V=0,L=[],k=new U(ae);if(y==null?y=Q:F(y,0,m),M=n(y/c),I)if(crypto.getRandomValues){for(P=crypto.getRandomValues(new Uint32Array(M*=2));V<M;)T=P[V]*131072+(P[V+1]>>>11),T>=9e15?(O=crypto.getRandomValues(new Uint32Array(2)),P[V]=O[0],P[V+1]=O[1]):(L.push(T%1e14),V+=2);V=M/2}else if(crypto.randomBytes){for(P=crypto.randomBytes(M*=7);V<M;)T=(P[V]&31)*281474976710656+P[V+1]*1099511627776+P[V+2]*4294967296+P[V+3]*16777216+(P[V+4]<<16)+(P[V+5]<<8)+P[V+6],T>=9e15?crypto.randomBytes(7).copy(P,V):(L.push(T%1e14),V+=7);V=M/7}else throw I=!1,Error(s+"crypto unavailable");if(!I)for(;V<M;)T=h(),T<9e15&&(L[V++]=T%1e14);for(M=L[--V],y%=c,M&&y&&(T=f[c-y],L[V]=i(M/T)*T);L[V]===0;L.pop(),V--);if(V<0)L=[B=0];else{for(B=-1;L[0]===0;L.splice(0,1),B-=c);for(V=1,T=L[0];T>=10;T/=10,V++);V<c&&(B-=c-V)}return k.e=B,k.c=L,k}}(),U.sum=function(){for(var u=1,h=arguments,y=new U(h[0]);u<h.length;)y=y.plus(h[u++]);return y},K=function(){var u="0123456789";function h(y,P,O,B){for(var M,T=[0],V,L=0,k=y.length;L<k;){for(V=T.length;V--;T[V]*=P);for(T[0]+=B.indexOf(y.charAt(L++)),M=0;M<T.length;M++)T[M]>O-1&&(T[M+1]==null&&(T[M+1]=0),T[M+1]+=T[M]/O|0,T[M]%=O)}return T.reverse()}return function(y,P,O,B,M){var T,V,L,k,J,te,de,ge,Ie=y.indexOf("."),Ue=Q,_e=ne;for(Ie>=0&&(k=Y,Y=0,y=y.replace(".",""),ge=new U(P),te=ge.pow(y.length-Ie),Y=k,ge.c=h(H(A(te.c),te.e,"0"),10,O,u),ge.e=ge.c.length),de=h(y,P,O,M?(T=se,u):(T=u,se)),L=k=de.length;de[--k]==0;de.pop());if(!de[0])return T.charAt(0);if(Ie<0?--L:(te.c=de,te.e=L,te.s=B,te=q(te,ge,Ue,_e,O),de=te.c,J=te.r,L=te.e),V=L+Ue+1,Ie=de[V],k=O/2,J=J||V<0||de[V+1]!=null,J=_e<4?(Ie!=null||J)&&(_e==0||_e==(te.s<0?3:2)):Ie>k||Ie==k&&(_e==4||J||_e==6&&de[V-1]&1||_e==(te.s<0?8:7)),V<1||!de[0])y=J?H(T.charAt(1),-Ue,T.charAt(0)):T.charAt(0);else{if(de.length=V,J)for(--O;++de[--V]>O;)de[V]=0,V||(++L,de=[1].concat(de));for(k=de.length;!de[--k];);for(Ie=0,y="";Ie<=k;y+=T.charAt(de[Ie++]));y=H(y,L,T.charAt(0))}return y}}(),q=function(){function u(P,O,B){var M,T,V,L,k=0,J=P.length,te=O%p,de=O/p|0;for(P=P.slice();J--;)V=P[J]%p,L=P[J]/p|0,M=de*V+L*te,T=te*V+M%p*p+k,k=(T/B|0)+(M/p|0)+de*L,P[J]=T%B;return k&&(P=[k].concat(P)),P}function h(P,O,B,M){var T,V;if(B!=M)V=B>M?1:-1;else for(T=V=0;T<B;T++)if(P[T]!=O[T]){V=P[T]>O[T]?1:-1;break}return V}function y(P,O,B,M){for(var T=0;B--;)P[B]-=T,T=P[B]<O[B]?1:0,P[B]=T*M+P[B]-O[B];for(;!P[0]&&P.length>1;P.splice(0,1));}return function(P,O,B,M,T){var V,L,k,J,te,de,ge,Ie,Ue,_e,fe,Ke,Ht,Ut,Vt,Kt,Be,Ot=P.s==O.s?1:-1,at=P.c,Ge=O.c;if(!at||!at[0]||!Ge||!Ge[0])return new U(!P.s||!O.s||(at?Ge&&at[0]==Ge[0]:!Ge)?NaN:at&&at[0]==0||!Ge?Ot*0:Ot/0);for(Ie=new U(Ot),Ue=Ie.c=[],L=P.e-O.e,Ot=B+L+1,T||(T=o,L=l(P.e/c)-l(O.e/c),Ot=Ot/c|0),k=0;Ge[k]==(at[k]||0);k++);if(Ge[k]>(at[k]||0)&&L--,Ot<0)Ue.push(1),J=!0;else{for(Ut=at.length,Kt=Ge.length,k=0,Ot+=2,te=i(T/(Ge[0]+1)),te>1&&(Ge=u(Ge,te,T),at=u(at,te,T),Kt=Ge.length,Ut=at.length),Ht=Kt,_e=at.slice(0,Kt),fe=_e.length;fe<Kt;_e[fe++]=0);Be=Ge.slice(),Be=[0].concat(Be),Vt=Ge[0],Ge[1]>=T/2&&Vt++;do{if(te=0,V=h(Ge,_e,Kt,fe),V<0){if(Ke=_e[0],Kt!=fe&&(Ke=Ke*T+(_e[1]||0)),te=i(Ke/Vt),te>1)for(te>=T&&(te=T-1),de=u(Ge,te,T),ge=de.length,fe=_e.length;h(de,_e,ge,fe)==1;)te--,y(de,Kt<ge?Be:Ge,ge,T),ge=de.length,V=1;else te==0&&(V=te=1),de=Ge.slice(),ge=de.length;if(ge<fe&&(de=[0].concat(de)),y(_e,de,fe,T),fe=_e.length,V==-1)for(;h(Ge,_e,Kt,fe)<1;)te++,y(_e,Kt<fe?Be:Ge,fe,T),fe=_e.length}else V===0&&(te++,_e=[0]);Ue[k++]=te,_e[0]?_e[fe++]=at[Ht]||0:(_e=[at[Ht]],fe=1)}while((Ht++<Ut||_e[0]!=null)&&Ot--);J=_e[0]!=null,Ue[0]||Ue.splice(0,1)}if(T==o){for(k=1,Ot=Ue[0];Ot>=10;Ot/=10,k++);le(Ie,B+(Ie.e=k+L*c-1)+1,M,J)}else Ie.e=L,Ie.r=+J;return Ie}}();function _(u,h,y,P){var O,B,M,T,V;if(y==null?y=ne:F(y,0,8),!u.c)return u.toString();if(O=u.c[0],M=u.e,h==null)V=A(u.c),V=P==1||P==2&&(M<=w||M>=g)?E(V,M):H(V,M,"0");else if(u=le(new U(u),h,y),B=u.e,V=A(u.c),T=V.length,P==1||P==2&&(h<=B||B<=w)){for(;T<h;V+="0",T++);V=E(V,B)}else if(h-=M,V=H(V,B,"0"),B+1>T){if(--h>0)for(V+=".";h--;V+="0");}else if(h+=B-T,h>0)for(B+1==T&&(V+=".");h--;V+="0");return u.s<0&&O?"-"+V:V}function Z(u,h){for(var y,P,O=1,B=new U(u[0]);O<u.length;O++)P=new U(u[O]),(!P.s||(y=v(B,P))===h||y===0&&B.s===h)&&(B=P);return B}function re(u,h,y){for(var P=1,O=h.length;!h[--O];h.pop());for(O=h[0];O>=10;O/=10,P++);return(y=P+y*c-1)>R?u.c=u.e=null:y<S?u.c=[u.e=0]:(u.e=y,u.c=h),u}G=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,h=/^([^.]+)\.$/,y=/^\.([^.]+)$/,P=/^-?(Infinity|NaN)$/,O=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(B,M,T,V){var L,k=T?M:M.replace(O,"");if(P.test(k))B.s=isNaN(k)?null:k<0?-1:1;else{if(!T&&(k=k.replace(u,function(J,te,de){return L=(de=de.toLowerCase())=="x"?16:de=="b"?2:8,!V||V==L?te:J}),V&&(L=V,k=k.replace(h,"$1").replace(y,"0.$1")),M!=k))return new U(k,L);if(U.DEBUG)throw Error(s+"Not a"+(V?" base "+V:"")+" number: "+M);B.s=null}B.c=B.e=null}}();function le(u,h,y,P){var O,B,M,T,V,L,k,J=u.c,te=f;if(J){e:{for(O=1,T=J[0];T>=10;T/=10,O++);if(B=h-O,B<0)B+=c,M=h,V=J[L=0],k=i(V/te[O-M-1]%10);else if(L=n((B+1)/c),L>=J.length)if(P){for(;J.length<=L;J.push(0));V=k=0,O=1,B%=c,M=B-c+1}else break e;else{for(V=T=J[L],O=1;T>=10;T/=10,O++);B%=c,M=B-c+O,k=M<0?0:i(V/te[O-M-1]%10)}if(P=P||h<0||J[L+1]!=null||(M<0?V:V%te[O-M-1]),P=y<4?(k||P)&&(y==0||y==(u.s<0?3:2)):k>5||k==5&&(y==4||P||y==6&&(B>0?M>0?V/te[O-M]:0:J[L-1])%10&1||y==(u.s<0?8:7)),h<1||!J[0])return J.length=0,P?(h-=u.e+1,J[0]=te[(c-h%c)%c],u.e=-h||0):J[0]=u.e=0,u;if(B==0?(J.length=L,T=1,L--):(J.length=L+1,T=te[c-B],J[L]=M>0?i(V/te[O-M]%te[M])*T:0),P)for(;;)if(L==0){for(B=1,M=J[0];M>=10;M/=10,B++);for(M=J[0]+=T,T=1;M>=10;M/=10,T++);B!=T&&(u.e++,J[0]==o&&(J[0]=1));break}else{if(J[L]+=T,J[L]!=o)break;J[L--]=0,T=1}for(B=J.length;J[--B]===0;J.pop());}u.e>R?u.c=u.e=null:u.e<S&&(u.c=[u.e=0])}return u}function X(u){var h,y=u.e;return y===null?u.toString():(h=A(u.c),h=y<=w||y>=g?E(h,y):H(h,y,"0"),u.s<0?"-"+h:h)}return D.absoluteValue=D.abs=function(){var u=new U(this);return u.s<0&&(u.s=1),u},D.comparedTo=function(u,h){return v(this,new U(u,h))},D.decimalPlaces=D.dp=function(u,h){var y,P,O,B=this;if(u!=null)return F(u,0,m),h==null?h=ne:F(h,0,8),le(new U(B),u+B.e+1,h);if(!(y=B.c))return null;if(P=((O=y.length-1)-l(this.e/c))*c,O=y[O])for(;O%10==0;O/=10,P--);return P<0&&(P=0),P},D.dividedBy=D.div=function(u,h){return q(this,new U(u,h),Q,ne)},D.dividedToIntegerBy=D.idiv=function(u,h){return q(this,new U(u,h),0,1)},D.exponentiatedBy=D.pow=function(u,h){var y,P,O,B,M,T,V,L,k,J=this;if(u=new U(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+X(u));if(h!=null&&(h=new U(h)),T=u.e>14,!J.c||!J.c[0]||J.c[0]==1&&!J.e&&J.c.length==1||!u.c||!u.c[0])return k=new U(Math.pow(+X(J),T?u.s*(2-C(u)):+X(u))),h?k.mod(h):k;if(V=u.s<0,h){if(h.c?!h.c[0]:!h.s)return new U(NaN);P=!V&&J.isInteger()&&h.isInteger(),P&&(J=J.mod(h))}else{if(u.e>9&&(J.e>0||J.e<-1||(J.e==0?J.c[0]>1||T&&J.c[1]>=24e7:J.c[0]<8e13||T&&J.c[0]<=9999975e7)))return B=J.s<0&&C(u)?-0:0,J.e>-1&&(B=1/B),new U(V?1/B:B);Y&&(B=n(Y/c+2))}for(T?(y=new U(.5),V&&(u.s=1),L=C(u)):(O=Math.abs(+X(u)),L=O%2),k=new U(ae);;){if(L){if(k=k.times(J),!k.c)break;B?k.c.length>B&&(k.c.length=B):P&&(k=k.mod(h))}if(O){if(O=i(O/2),O===0)break;L=O%2}else if(u=u.times(y),le(u,u.e+1,1),u.e>14)L=C(u);else{if(O=+X(u),O===0)break;L=O%2}J=J.times(J),B?J.c&&J.c.length>B&&(J.c.length=B):P&&(J=J.mod(h))}return P?k:(V&&(k=ae.div(k)),h?k.mod(h):B?le(k,Y,ne,M):k)},D.integerValue=function(u){var h=new U(this);return u==null?u=ne:F(u,0,8),le(h,h.e+1,u)},D.isEqualTo=D.eq=function(u,h){return v(this,new U(u,h))===0},D.isFinite=function(){return!!this.c},D.isGreaterThan=D.gt=function(u,h){return v(this,new U(u,h))>0},D.isGreaterThanOrEqualTo=D.gte=function(u,h){return(h=v(this,new U(u,h)))===1||h===0},D.isInteger=function(){return!!this.c&&l(this.e/c)>this.c.length-2},D.isLessThan=D.lt=function(u,h){return v(this,new U(u,h))<0},D.isLessThanOrEqualTo=D.lte=function(u,h){return(h=v(this,new U(u,h)))===-1||h===0},D.isNaN=function(){return!this.s},D.isNegative=function(){return this.s<0},D.isPositive=function(){return this.s>0},D.isZero=function(){return!!this.c&&this.c[0]==0},D.minus=function(u,h){var y,P,O,B,M=this,T=M.s;if(u=new U(u,h),h=u.s,!T||!h)return new U(NaN);if(T!=h)return u.s=-h,M.plus(u);var V=M.e/c,L=u.e/c,k=M.c,J=u.c;if(!V||!L){if(!k||!J)return k?(u.s=-h,u):new U(J?M:NaN);if(!k[0]||!J[0])return J[0]?(u.s=-h,u):new U(k[0]?M:ne==3?-0:0)}if(V=l(V),L=l(L),k=k.slice(),T=V-L){for((B=T<0)?(T=-T,O=k):(L=V,O=J),O.reverse(),h=T;h--;O.push(0));O.reverse()}else for(P=(B=(T=k.length)<(h=J.length))?T:h,T=h=0;h<P;h++)if(k[h]!=J[h]){B=k[h]<J[h];break}if(B&&(O=k,k=J,J=O,u.s=-u.s),h=(P=J.length)-(y=k.length),h>0)for(;h--;k[y++]=0);for(h=o-1;P>T;){if(k[--P]<J[P]){for(y=P;y&&!k[--y];k[y]=h);--k[y],k[P]+=o}k[P]-=J[P]}for(;k[0]==0;k.splice(0,1),--L);return k[0]?re(u,k,L):(u.s=ne==3?-1:1,u.c=[u.e=0],u)},D.modulo=D.mod=function(u,h){var y,P,O=this;return u=new U(u,h),!O.c||!u.s||u.c&&!u.c[0]?new U(NaN):!u.c||O.c&&!O.c[0]?new U(O):(j==9?(P=u.s,u.s=1,y=q(O,u,0,3),u.s=P,y.s*=P):y=q(O,u,0,j),u=O.minus(y.times(u)),!u.c[0]&&j==1&&(u.s=O.s),u)},D.multipliedBy=D.times=function(u,h){var y,P,O,B,M,T,V,L,k,J,te,de,ge,Ie,Ue,_e=this,fe=_e.c,Ke=(u=new U(u,h)).c;if(!fe||!Ke||!fe[0]||!Ke[0])return!_e.s||!u.s||fe&&!fe[0]&&!Ke||Ke&&!Ke[0]&&!fe?u.c=u.e=u.s=null:(u.s*=_e.s,!fe||!Ke?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(P=l(_e.e/c)+l(u.e/c),u.s*=_e.s,V=fe.length,J=Ke.length,V<J&&(ge=fe,fe=Ke,Ke=ge,O=V,V=J,J=O),O=V+J,ge=[];O--;ge.push(0));for(Ie=o,Ue=p,O=J;--O>=0;){for(y=0,te=Ke[O]%Ue,de=Ke[O]/Ue|0,M=V,B=O+M;B>O;)L=fe[--M]%Ue,k=fe[M]/Ue|0,T=de*L+k*te,L=te*L+T%Ue*Ue+ge[B]+y,y=(L/Ie|0)+(T/Ue|0)+de*k,ge[B--]=L%Ie;ge[B]=y}return y?++P:ge.splice(0,1),re(u,ge,P)},D.negated=function(){var u=new U(this);return u.s=-u.s||null,u},D.plus=function(u,h){var y,P=this,O=P.s;if(u=new U(u,h),h=u.s,!O||!h)return new U(NaN);if(O!=h)return u.s=-h,P.minus(u);var B=P.e/c,M=u.e/c,T=P.c,V=u.c;if(!B||!M){if(!T||!V)return new U(O/0);if(!T[0]||!V[0])return V[0]?u:new U(T[0]?P:O*0)}if(B=l(B),M=l(M),T=T.slice(),O=B-M){for(O>0?(M=B,y=V):(O=-O,y=T),y.reverse();O--;y.push(0));y.reverse()}for(O=T.length,h=V.length,O-h<0&&(y=V,V=T,T=y,h=O),O=0;h;)O=(T[--h]=T[h]+V[h]+O)/o|0,T[h]=o===T[h]?0:T[h]%o;return O&&(T=[O].concat(T),++M),re(u,T,M)},D.precision=D.sd=function(u,h){var y,P,O,B=this;if(u!=null&&u!==!!u)return F(u,1,m),h==null?h=ne:F(h,0,8),le(new U(B),u,h);if(!(y=B.c))return null;if(O=y.length-1,P=O*c+1,O=y[O]){for(;O%10==0;O/=10,P--);for(O=y[0];O>=10;O/=10,P++);}return u&&B.e+1>P&&(P=B.e+1),P},D.shiftedBy=function(u){return F(u,-d,d),this.times("1e"+u)},D.squareRoot=D.sqrt=function(){var u,h,y,P,O,B=this,M=B.c,T=B.s,V=B.e,L=Q+4,k=new U("0.5");if(T!==1||!M||!M[0])return new U(!T||T<0&&(!M||M[0])?NaN:M?B:1/0);if(T=Math.sqrt(+X(B)),T==0||T==1/0?(h=A(M),(h.length+V)%2==0&&(h+="0"),T=Math.sqrt(+h),V=l((V+1)/2)-(V<0||V%2),T==1/0?h="5e"+V:(h=T.toExponential(),h=h.slice(0,h.indexOf("e")+1)+V),y=new U(h)):y=new U(T+""),y.c[0]){for(V=y.e,T=V+L,T<3&&(T=0);;)if(O=y,y=k.times(O.plus(q(B,O,L,1))),A(O.c).slice(0,T)===(h=A(y.c)).slice(0,T))if(y.e<V&&--T,h=h.slice(T-3,T+1),h=="9999"||!P&&h=="4999"){if(!P&&(le(O,O.e+Q+2,0),O.times(O).eq(B))){y=O;break}L+=4,T+=4,P=1}else{(!+h||!+h.slice(1)&&h.charAt(0)=="5")&&(le(y,y.e+Q+2,1),u=!y.times(y).eq(B));break}}return le(y,y.e+Q+1,ne,u)},D.toExponential=function(u,h){return u!=null&&(F(u,0,m),u++),_(this,u,h,1)},D.toFixed=function(u,h){return u!=null&&(F(u,0,m),u=u+this.e+1),_(this,u,h)},D.toFormat=function(u,h,y){var P,O=this;if(y==null)u!=null&&h&&typeof h=="object"?(y=h,h=null):u&&typeof u=="object"?(y=u,u=h=null):y=oe;else if(typeof y!="object")throw Error(s+"Argument not an object: "+y);if(P=O.toFixed(u,h),O.c){var B,M=P.split("."),T=+y.groupSize,V=+y.secondaryGroupSize,L=y.groupSeparator||"",k=M[0],J=M[1],te=O.s<0,de=te?k.slice(1):k,ge=de.length;if(V&&(B=T,T=V,V=B,ge-=B),T>0&&ge>0){for(B=ge%T||T,k=de.substr(0,B);B<ge;B+=T)k+=L+de.substr(B,T);V>0&&(k+=L+de.slice(B)),te&&(k="-"+k)}P=J?k+(y.decimalSeparator||"")+((V=+y.fractionGroupSize)?J.replace(new RegExp("\\d{"+V+"}\\B","g"),"$&"+(y.fractionGroupSeparator||"")):J):k}return(y.prefix||"")+P+(y.suffix||"")},D.toFraction=function(u){var h,y,P,O,B,M,T,V,L,k,J,te,de=this,ge=de.c;if(u!=null&&(T=new U(u),!T.isInteger()&&(T.c||T.s!==1)||T.lt(ae)))throw Error(s+"Argument "+(T.isInteger()?"out of range: ":"not an integer: ")+X(T));if(!ge)return new U(de);for(h=new U(ae),L=y=new U(ae),P=V=new U(ae),te=A(ge),B=h.e=te.length-de.e-1,h.c[0]=f[(M=B%c)<0?c+M:M],u=!u||T.comparedTo(h)>0?B>0?h:L:T,M=R,R=1/0,T=new U(te),V.c[0]=0;k=q(T,h,0,1),O=y.plus(k.times(P)),O.comparedTo(u)!=1;)y=P,P=O,L=V.plus(k.times(O=L)),V=O,h=T.minus(k.times(O=h)),T=O;return O=q(u.minus(y),P,0,1),V=V.plus(O.times(L)),y=y.plus(O.times(P)),V.s=L.s=de.s,B=B*2,J=q(L,P,B,ne).minus(de).abs().comparedTo(q(V,y,B,ne).minus(de).abs())<1?[L,P]:[V,y],R=M,J},D.toNumber=function(){return+X(this)},D.toPrecision=function(u,h){return u!=null&&F(u,1,m),_(this,u,h,2)},D.toString=function(u){var h,y=this,P=y.s,O=y.e;return O===null?P?(h="Infinity",P<0&&(h="-"+h)):h="NaN":(u==null?h=O<=w||O>=g?E(A(y.c),O):H(A(y.c),O,"0"):u===10&&z?(y=le(new U(y),Q+O+1,ne),h=H(A(y.c),y.e,"0")):(F(u,2,se.length,"Base"),h=K(H(A(y.c),O,"0"),10,u,P,!0)),P<0&&y.c[0]&&(h="-"+h)),h},D.valueOf=D.toJSON=function(){return X(this)},D._isBigNumber=!0,x!=null&&U.set(x),U}function l(x){var q=x|0;return x>0||x===q?q:q-1}function A(x){for(var q,K,G=1,D=x.length,ae=x[0]+"";G<D;){for(q=x[G++]+"",K=c-q.length;K--;q="0"+q);ae+=q}for(D=ae.length;ae.charCodeAt(--D)===48;);return ae.slice(0,D+1||1)}function v(x,q){var K,G,D=x.c,ae=q.c,Q=x.s,ne=q.s,w=x.e,g=q.e;if(!Q||!ne)return null;if(K=D&&!D[0],G=ae&&!ae[0],K||G)return K?G?0:-ne:Q;if(Q!=ne)return Q;if(K=Q<0,G=w==g,!D||!ae)return G?0:!D^K?1:-1;if(!G)return w>g^K?1:-1;for(ne=(w=D.length)<(g=ae.length)?w:g,Q=0;Q<ne;Q++)if(D[Q]!=ae[Q])return D[Q]>ae[Q]^K?1:-1;return w==g?0:w>g^K?1:-1}function F(x,q,K,G){if(x<q||x>K||x!==i(x))throw Error(s+(G||"Argument")+(typeof x=="number"?x<q||x>K?" out of range: ":" not an integer: ":" not a primitive number: ")+String(x))}function C(x){var q=x.c.length-1;return l(x.e/c)==q&&x.c[q]%2!=0}function E(x,q){return(x.length>1?x.charAt(0)+"."+x.slice(1):x)+(q<0?"e":"e+")+q}function H(x,q,K){var G,D;if(q<0){for(D=K+".";++q;D+=K);x=D+x}else if(G=x.length,++q>G){for(D=K,q-=G;--q;D+=K);x+=D}else q<G&&(x=x.slice(0,q)+"."+x.slice(q));return x}t=b(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof Za<"u"&&Za.exports?Za.exports=t:(e||(e=typeof self<"u"&&self?self:window),e.BigNumber=t)})(Ep)});var vp=ee((KO,Op)=>{Op.exports=function(t,r,n){var i=new t.Uint8Array(n),s=r.pushInt,a=r.pushInt32,o=r.pushInt32Neg,c=r.pushInt64,d=r.pushInt64Neg,f=r.pushFloat,p=r.pushFloatSingle,m=r.pushFloatDouble,b=r.pushTrue,l=r.pushFalse,A=r.pushUndefined,v=r.pushNull,F=r.pushInfinity,C=r.pushInfinityNeg,E=r.pushNaN,H=r.pushNaNNeg,x=r.pushArrayStart,q=r.pushArrayStartFixed,K=r.pushArrayStartFixed32,G=r.pushArrayStartFixed64,D=r.pushObjectStart,ae=r.pushObjectStartFixed,Q=r.pushObjectStartFixed32,ne=r.pushObjectStartFixed64,w=r.pushByteString,g=r.pushByteStringStart,S=r.pushUtf8String,R=r.pushUtf8StringStart,I=r.pushSimpleUnassigned,j=r.pushTagStart,Y=r.pushTagStart4,oe=r.pushTagStart8,se=r.pushTagUnassigned,z=r.pushBreak,U=t.Math.pow,_=0,Z=0,re=0;function le(N){for(N=N|0,_=0,Z=N;(_|0)<(Z|0)&&(re=Km[i[_]&255](i[_]|0)|0,!((re|0)>0)););return re|0}function X(N){return N=N|0,((_|0)+(N|0)|0)<(Z|0)?0:1}function u(N){return N=N|0,i[N|0]<<8|i[N+1|0]|0}function h(N){return N=N|0,i[N|0]<<24|i[N+1|0]<<16|i[N+2|0]<<8|i[N+3|0]|0}function y(N){return N=N|0,s(N|0),_=_+1|0,0}function P(N){return N=N|0,X(1)|0?1:(s(i[_+1|0]|0),_=_+2|0,0)}function O(N){return N=N|0,X(2)|0?1:(s(u(_+1|0)|0),_=_+3|0,0)}function B(N){return N=N|0,X(4)|0?1:(a(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function M(N){return N=N|0,X(8)|0?1:(c(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function T(N){return N=N|0,s(-1-(N-32|0)|0),_=_+1|0,0}function V(N){return N=N|0,X(1)|0?1:(s(-1-(i[_+1|0]|0)|0),_=_+2|0,0)}function L(N){N=N|0;var ve=0;return X(2)|0?1:(ve=u(_+1|0)|0,s(-1-(ve|0)|0),_=_+3|0,0)}function k(N){return N=N|0,X(4)|0?1:(o(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function J(N){return N=N|0,X(8)|0?1:(d(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function te(N){N=N|0;var ve=0,Se=0,Ne=0;return Ne=N-64|0,X(Ne|0)|0?1:(ve=_+1|0,Se=(_+1|0)+(Ne|0)|0,w(ve|0,Se|0),_=Se|0,0)}function de(N){N=N|0;var ve=0,Se=0,Ne=0;return X(1)|0||(Ne=i[_+1|0]|0,ve=_+2|0,Se=(_+2|0)+(Ne|0)|0,X(Ne+1|0)|0)?1:(w(ve|0,Se|0),_=Se|0,0)}function ge(N){N=N|0;var ve=0,Se=0,Ne=0;return X(2)|0||(Ne=u(_+1|0)|0,ve=_+3|0,Se=(_+3|0)+(Ne|0)|0,X(Ne+2|0)|0)?1:(w(ve|0,Se|0),_=Se|0,0)}function Ie(N){N=N|0;var ve=0,Se=0,Ne=0;return X(4)|0||(Ne=h(_+1|0)|0,ve=_+5|0,Se=(_+5|0)+(Ne|0)|0,X(Ne+4|0)|0)?1:(w(ve|0,Se|0),_=Se|0,0)}function Ue(N){return N=N|0,1}function _e(N){return N=N|0,g(),_=_+1|0,0}function fe(N){N=N|0;var ve=0,Se=0,Ne=0;return Ne=N-96|0,X(Ne|0)|0?1:(ve=_+1|0,Se=(_+1|0)+(Ne|0)|0,S(ve|0,Se|0),_=Se|0,0)}function Ke(N){N=N|0;var ve=0,Se=0,Ne=0;return X(1)|0||(Ne=i[_+1|0]|0,ve=_+2|0,Se=(_+2|0)+(Ne|0)|0,X(Ne+1|0)|0)?1:(S(ve|0,Se|0),_=Se|0,0)}function Ht(N){N=N|0;var ve=0,Se=0,Ne=0;return X(2)|0||(Ne=u(_+1|0)|0,ve=_+3|0,Se=(_+3|0)+(Ne|0)|0,X(Ne+2|0)|0)?1:(S(ve|0,Se|0),_=Se|0,0)}function Ut(N){N=N|0;var ve=0,Se=0,Ne=0;return X(4)|0||(Ne=h(_+1|0)|0,ve=_+5|0,Se=(_+5|0)+(Ne|0)|0,X(Ne+4|0)|0)?1:(S(ve|0,Se|0),_=Se|0,0)}function Vt(N){return N=N|0,1}function Kt(N){return N=N|0,R(),_=_+1|0,0}function Be(N){return N=N|0,q(N-128|0),_=_+1|0,0}function Ot(N){return N=N|0,X(1)|0?1:(q(i[_+1|0]|0),_=_+2|0,0)}function at(N){return N=N|0,X(2)|0?1:(q(u(_+1|0)|0),_=_+3|0,0)}function Ge(N){return N=N|0,X(4)|0?1:(K(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Lc(N){return N=N|0,X(8)|0?1:(G(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function Hc(N){return N=N|0,x(),_=_+1|0,0}function $e(N){N=N|0;var ve=0;return ve=N-160|0,X(ve|0)|0?1:(ae(ve|0),_=_+1|0,0)}function Kc(N){return N=N|0,X(1)|0?1:(ae(i[_+1|0]|0),_=_+2|0,0)}function Gc(N){return N=N|0,X(2)|0?1:(ae(u(_+1|0)|0),_=_+3|0,0)}function $c(N){return N=N|0,X(4)|0?1:(Q(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Wc(N){return N=N|0,X(8)|0?1:(ne(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function zc(N){return N=N|0,D(),_=_+1|0,0}function dn(N){return N=N|0,j(N-192|0|0),_=_+1|0,0}function lO(N){return N=N|0,j(N|0),_=_+1|0,0}function dO(N){return N=N|0,j(N|0),_=_+1|0,0}function fO(N){return N=N|0,j(N|0),_=_+1|0,0}function pO(N){return N=N|0,j(N|0),_=_+1|0,0}function ft(N){return N=N|0,j(N-192|0|0),_=_+1|0,0}function hO(N){return N=N|0,j(N|0),_=_+1|0,0}function _O(N){return N=N|0,j(N|0),_=_+1|0,0}function yO(N){return N=N|0,j(N|0),_=_+1|0,0}function Bm(N){return N=N|0,X(1)|0?1:(j(i[_+1|0]|0),_=_+2|0,0)}function Pm(N){return N=N|0,X(2)|0?1:(j(u(_+1|0)|0),_=_+3|0,0)}function Fm(N){return N=N|0,X(4)|0?1:(Y(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Um(N){return N=N|0,X(8)|0?1:(oe(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function nt(N){return N=N|0,I((N|0)-224|0),_=_+1|0,0}function Vm(N){return N=N|0,l(),_=_+1|0,0}function Cm(N){return N=N|0,b(),_=_+1|0,0}function qm(N){return N=N|0,v(),_=_+1|0,0}function Dm(N){return N=N|0,A(),_=_+1|0,0}function km(N){return N=N|0,X(1)|0?1:(I(i[_+1|0]|0),_=_+2|0,0)}function Mm(N){N=N|0;var ve=0,Se=0,Ne=1,ma=0,os=0,mO=0;return X(2)|0?1:(ve=i[_+1|0]|0,Se=i[_+2|0]|0,(ve|0)&128&&(Ne=-1),ma=+(((ve|0)&124)>>2),os=+(((ve|0)&3)<<8|Se),+ma==0?f(+(+Ne*5960464477539063e-23*+os)):+ma==31?+Ne==1?+os>0?E():F():+os>0?H():C():f(+(+Ne*U(2,+(+ma-25))*+(1024+os))),_=_+3|0,0)}function jm(N){return N=N|0,X(4)|0?1:(p(i[_+1|0]|0,i[_+2|0]|0,i[_+3|0]|0,i[_+4|0]|0),_=_+5|0,0)}function Lm(N){return N=N|0,X(8)|0?1:(m(i[_+1|0]|0,i[_+2|0]|0,i[_+3|0]|0,i[_+4|0]|0,i[_+5|0]|0,i[_+6|0]|0,i[_+7|0]|0,i[_+8|0]|0),_=_+9|0,0)}function Le(N){return N=N|0,1}function Hm(N){return N=N|0,z(),_=_+1|0,0}var Km=[y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,P,O,B,M,Le,Le,Le,Le,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,V,L,k,J,Le,Le,Le,Le,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,Ie,Ue,Le,Le,Le,_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,Ke,Ht,Ut,Vt,Le,Le,Le,Kt,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Ot,at,Ge,Lc,Le,Le,Le,Hc,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,Kc,Gc,$c,Wc,Le,Le,Le,zc,dn,dn,dn,dn,dn,dn,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,Bm,Pm,Fm,Um,Le,Le,Le,Le,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,Vm,Cm,qm,Dm,km,Mm,jm,Lm,Le,Le,Le,Hm];return{parse:le}}});var bs=ee(Xt=>{"use strict";var ju=gs().BigNumber;Xt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Xt.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};Xt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Xt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Xt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Xt.SHIFT32=Math.pow(2,32);Xt.SHIFT16=Math.pow(2,16);Xt.MAX_SAFE_HIGH=2097151;Xt.NEG_ONE=new ju(-1);Xt.TEN=new ju(10);Xt.TWO=new ju(2);Xt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Xa=ee(cr=>{"use strict";var{Buffer:zb}=fi("buffer"),Ap=gs().BigNumber,Sp=bs(),Rp=Sp.SHIFT32,Yb=Sp.SHIFT16,Jb=2097151;cr.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 Zb(e){return e<16?"0"+e.toString(16):e.toString(16)}cr.arrayBufferToBignumber=function(e){let t=e.byteLength,r="";for(let n=0;n<t;n++)r+=Zb(e[n]);return new Ap(r,16)};cr.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};cr.buildInt32=(e,t)=>e*Yb+t;cr.buildInt64=(e,t,r,n)=>{let i=cr.buildInt32(e,t),s=cr.buildInt32(r,n);return i>Jb?new Ap(i).times(Rp).plus(s):i*Rp+s};cr.writeHalf=function(t,r){let n=zb.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if((i&8191)!==0)return!1;var s=i>>16&32768;let a=i>>23&255,o=i&8388607;if(a>=113&&a<=142)s+=(a-112<<10)+(o>>13);else if(a>=103&&a<113){if(o&(1<<126-a)-1)return!1;s+=o+8388608>>126-a}else return!1;return t.writeUInt16BE(s,0),!0};cr.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])};cr.isNegativeZero=e=>e===0&&1/e<0;cr.nextPowerOf2=e=>{let t=0;if(e&&!(e&e-1))return e;for(;e!==0;)e>>=1,t+=1;return 1<<t}});var Gu=ee((WO,Ip)=>{"use strict";var Ku=bs(),Xb=Ku.MT,Qa=Ku.SIMPLE,Lu=Ku.SYMS,Hu=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,Xb.SIMPLE_FLOAT)}static isSimple(t){return t instanceof e}static decode(t,r){switch(r==null&&(r=!0),t){case Qa.FALSE:return!1;case Qa.TRUE:return!0;case Qa.NULL:return r?null:Lu.NULL;case Qa.UNDEFINED:return r?void 0:Lu.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Lu.BREAK;default:return new e(t)}}};Ip.exports=Hu});var Wu=ee((zO,Bp)=>{"use strict";var $u=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}}};Bp.exports=$u});var Yu=ee((YO,Fp)=>{"use strict";var{URL:Qb,URLSearchParams:ew,format:tw}=fi("url"),Pp="http://localhost",zu=class extends Qb{constructor(t="",r=Pp){super(t,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}format(){return this.toString()}};Fp.exports={URLWithLegacySupport:zu,URLSearchParams:ew,format:tw,defaultBase:Pp}});var Cp=ee((JO,Vp)=>{"use strict";var{URLWithLegacySupport:Up,format:rw}=Yu();Vp.exports=(e,t={},r={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new Up(e)}catch{s={}}let a=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new Up(e,rw(a)).toString()}});var Ju=ee((ZO,qp)=>{"use strict";var{URLWithLegacySupport:nw,format:iw,URLSearchParams:sw,defaultBase:aw}=Yu(),ow=Cp();qp.exports={URL:nw,URLSearchParams:sw,format:iw,relative:ow,defaultBase:aw}});var Zu=ee((XO,kp)=>{"use strict";var{Buffer:Ai}=fi("buffer"),Dp=Zc(),cw=gs().BigNumber,uw=vp(),qt=Xa(),ke=bs(),lw=Gu(),dw=Wu(),{URL:fw}=Ju(),ws=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=Ai.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=>ke.NEG_ONE.minus(qt.arrayBufferToBignumber(r)),4:r=>ke.TEN.pow(r[0]).times(r[1]),5:r=>ke.TWO.pow(r[0]).times(r[1]),32:r=>new fw(r),35:r=>new RegExp(r)},t.tags),this.parser=uw(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 ke.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case ke.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case ke.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case ke.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 ke.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 ke.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===ke.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 ke.PARENT.ARRAY:case ke.PARENT.BYTE_STRING:case ke.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case ke.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=ke.PARENT.MAP,n.ref=qt.buildMap(n.ref)));break;case ke.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case ke.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:ke.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,r){let n=this._knownTags[t];return n?n(r):new dw(t,r)}createMap(t,r){return t}createObject(t,r){return t}createArray(t,r){return t}createByteString(t,r){return Ai.concat(t)}createByteStringFromHeap(t,r){return t===r?Ai.alloc(0):Ai.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 Dp.read([t,r,n,i],0,!1,23,4)}createFloatDouble(t,r,n,i,s,a,o,c){return Dp.read([t,r,n,i,s,a,o,c],0,!1,52,8)}createInt32Neg(t,r){return-1-qt.buildInt32(t,r)}createInt64Neg(t,r,n,i){let s=qt.buildInt32(t,r),a=qt.buildInt32(n,i);return s>ke.MAX_SAFE_HIGH?ke.NEG_ONE.minus(new cw(s).times(ke.SHIFT32).plus(a)):-1-(s*ke.SHIFT32+a)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(t,r){return t.join("")}createUtf8StringFromHeap(t,r){return t===r?"":this._buffer.toString("utf8",t,r)}createSimpleUnassigned(t){return new lw(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,r){this._push(this.createInt32(t,r))}pushInt64(t,r,n,i){this._push(this.createInt64(t,r,n,i))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,r,n,i){this._push(this.createFloatSingle(t,r,n,i))}pushFloatDouble(t,r,n,i,s,a,o,c){this._push(this.createFloatDouble(t,r,n,i,s,a,o,c))}pushInt32Neg(t,r){this._push(this.createInt32Neg(t,r))}pushInt64Neg(t,r,n,i){this._push(this.createInt64Neg(t,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],ke.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:ke.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:ke.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:ke.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({},ke.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),ke.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=Ai.from(t,r||"hex")),new e({size:t.length}).decodeFirst(t)}static decodeAll(t,r){return typeof t=="string"&&(t=Ai.from(t,r||"hex")),new e({size:t.length}).decodeAll(t)}};ws.decodeFirst=ws.decode;kp.exports=ws});var Lp=ee((QO,jp)=>{"use strict";var{Buffer:Xu}=fi("buffer"),pw=Zu(),hw=Xa(),Qu=class e extends pw{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 hw.isNegativeZero(t)?"-0_1":`${r}_1`}createFloatSingle(t,r,n,i){return`${super.createFloatSingle(t,r,n,i)}_2`}createFloatDouble(t,r,n,i,s,a,o,c){return`${super.createFloatDouble(t,r,n,i,s,a,o,c)}_3`}createByteString(t,r){let n=t.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(t,r){return`h'${Xu.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(Mp(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(t,r){let n=super.createObject(t),i=Object.keys(n).reduce(Mp(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(t,r){let n=t.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(t,r){return`"${Xu.from(super.createUtf8StringFromHeap(t,r)).toString("utf8")}"`}static diagnose(t,r){return typeof t=="string"&&(t=Xu.from(t,r||"hex")),new e().decodeFirst(t)}};jp.exports=Qu;function Mp(e){return(t,r)=>t?`${t}, ${r}: ${e[r]}`:`${r}: ${e[r]}`}});var Wp=ee((e6,$p)=>{"use strict";var{Buffer:Dr}=fi("buffer"),{URL:_w}=Ju(),tl=gs().BigNumber,el=Xa(),ot=bs(),mr=ot.MT,eo=ot.NUMBYTES,Hp=ot.SHIFT32,Kp=ot.SYMS,Si=ot.TAG,yw=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.TWO,mw=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.FOUR,gw=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.EIGHT,bw=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.TRUE,ww=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.FALSE,xw=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.UNDEFINED,Gp=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.NULL,Tw=new tl("0x20000000000000"),Nw=Dr.from("f97e00","hex"),Ew=Dr.from("f9fc00","hex"),Ow=Dr.from("f97c00","hex");function vw(e){return{}.toString.call(e).slice(8,-1)}var rl=class e{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[_w,this._pushUrl],[tl,this._pushBigNumber]];let r=t.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(t,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===t){let a=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,a}return this.semanticTypes.push([t,r]),null}push(t){return t&&(this.result[this.offset]=t,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=t.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(t,r,n){return this.result[this.offset]=t,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(t){return this.pushWrite(t,1,1)}_pushUInt16BE(t){return this.pushWrite(t,2,2)}_pushUInt32BE(t){return this.pushWrite(t,3,4)}_pushDoubleBE(t){return this.pushWrite(t,4,8)}_pushNaN(){return this.push(Nw)}_pushInfinity(t){let r=t<0?Ew:Ow;return this.push(r)}_pushFloat(t){let r=Dr.allocUnsafe(2);if(el.writeHalf(r,t)&&el.parseHalf(r)===t)return this._pushUInt8(yw)&&this.push(r);let n=Dr.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(mw)&&this.push(n):this._pushUInt8(gw)&&this._pushDoubleBE(t)}_pushInt(t,r,n){let i=r<<5;return t<24?this._pushUInt8(i|t):t<=255?this._pushUInt8(i|eo.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|eo.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|eo.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|eo.EIGHT)&&this._pushUInt32BE(Math.floor(t/Hp))&&this._pushUInt32BE(t%Hp):r===mr.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,mr.NEG_INT,t):this._pushInt(t,mr.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=Dr.byteLength(t,"utf8");return this._pushInt(r,mr.UTF8_STRING)&&this.pushWrite(t,5,r)}_pushBoolean(t){return this._pushUInt8(t?bw:ww)}_pushUndefined(t){return this._pushUInt8(xw)}_pushArray(t,r){let n=r.length;if(!t._pushInt(n,mr.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,mr.TAG)}_pushDate(t,r){return t._pushTag(Si.DATE_EPOCH)&&t.pushAny(Math.round(r/1e3))}_pushBuffer(t,r){return t._pushInt(r.length,mr.BYTE_STRING)&&t.push(r)}_pushNoFilter(t,r){return t._pushBuffer(t,r.slice())}_pushRegexp(t,r){return t._pushTag(Si.REGEXP)&&t.pushAny(r.source)}_pushSet(t,r){if(!t._pushInt(r.size,mr.ARRAY))return!1;for(let n of r)if(!t.pushAny(n))return!1;return!0}_pushUrl(t,r){return t._pushTag(Si.URI)&&t.pushAny(r.format())}_pushBigint(t){let r=Si.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),r=Si.NEG_BIGINT);let n=t.toString(16);n.length%2&&(n="0"+n);let i=Dr.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(Si.DECIMAL_FRAC)&&t._pushInt(2,mr.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new tl(10).pow(n));return t._pushIntNum(-n)?i.abs().isLessThan(Tw)?t._pushIntNum(i.toNumber()):t._pushBigint(i):!1}_pushMap(t,r){return t._pushInt(r.size,mr.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(t){if(!t)return this._pushUInt8(Gp);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(t instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(t,this,t);var i=t.encodeCBOR;if(typeof i=="function")return i.call(t,this);var s=Object.keys(t),a=s.length;return this._pushInt(a,mr.MAP)?this._pushRawMap(a,s.map(o=>[o,t[o]])):!1}_pushRawMap(t,r){r=r.map(function(i){return i[0]=e.encode(i[0]),i}).sort(el.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=vw(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,Dr.isBuffer(t)?t:Dr.from(t));case"Null":return this._pushUInt8(Gp);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 Kp.NULL:return this._pushObject(null);case Kp.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+t.toString())}default:throw new Error("Unknown type: "+typeof t+", "+(t?t.toString():""))}}finalize(){if(this.offset===0)return null;for(var t=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,a=0;a<i;a++)s+=r[a];var o=Dr.allocUnsafe(s),c=0,d=0;for(a=0;a<i;a++){switch(d=r[a],n[a]){case 0:t[a].copy(o,c);break;case 1:o.writeUInt8(t[a],c,!0);break;case 2:o.writeUInt16BE(t[a],c,!0);break;case 3:o.writeUInt32BE(t[a],c,!0);break;case 4:o.writeDoubleBE(t[a],c,!0);break;case 5:o.write(t[a],c,d,"utf8");break;default:throw new Error("unkown method")}c+=d}var f=o;return this._reset(),f}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(t){let r=new e;if(!r.pushAny(t))throw new Error("Failed to encode input");return r.finalize()}};$p.exports=rl});var to=ee(ct=>{"use strict";ct.Diagnose=Lp();ct.Decoder=Zu();ct.Encoder=Wp();ct.Simple=Gu();ct.Tagged=Wu();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 Ns=ee(ur=>{"use strict";var Rw=ur&&ur.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ur,"__esModule",{value:!0});ur.hashOfMap=ur.requestIdOf=ur.hashValue=ur.hash=void 0;var zp=Ri(),Aw=Rw(to()),Sw=Ra(),xs=$t();function wn(e){return(0,xs.uint8ToBuf)(Sw.sha256.create().update(new Uint8Array(e)).digest())}ur.hash=wn;function Ts(e){if(e instanceof Aw.default.Tagged)return Ts(e.value);if(typeof e=="string")return Yp(e);if(typeof e=="number")return wn((0,zp.lebEncode)(e));if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return wn(e);if(Array.isArray(e)){let t=e.map(Ts);return wn((0,xs.concat)(...t))}else{if(e&&typeof e=="object"&&e._isPrincipal)return wn(e.toUint8Array());if(typeof e=="object"&&e!==null&&typeof e.toHash=="function")return Ts(e.toHash());if(typeof e=="object")return nl(e);if(typeof e=="bigint")return wn((0,zp.lebEncode)(e))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${e}`),{value:e})}ur.hashValue=Ts;var Yp=e=>{let t=new TextEncoder().encode(e);return wn(t)};function Iw(e){return nl(e)}ur.requestIdOf=Iw;function nl(e){let n=Object.entries(e).filter(([,a])=>a!==void 0).map(([a,o])=>{let c=Yp(a),d=Ts(o);return[c,d]}).sort(([a],[o])=>(0,xs.compare)(a,o)),i=(0,xs.concat)(...n.map(a=>(0,xs.concat)(...a)));return wn(i)}ur.hashOfMap=nl});var al=ee(kr=>{"use strict";var Bw=kr&&kr.__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(kr,"__esModule",{value:!0});kr.createIdentityDescriptor=kr.AnonymousIdentity=kr.SignIdentity=void 0;var Jp=Ct(),Pw=Ns(),Zp=$t(),Fw=new TextEncoder().encode(`
17
- ic-request`),il=class{getPrincipal(){return this._principal||(this._principal=Jp.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:r}=t,n=Bw(t,["body"]),i=(0,Pw.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,Zp.concat)(Fw,i))}})}};kr.SignIdentity=il;var sl=class{getPrincipal(){return Jp.Principal.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}};kr.AnonymousIdentity=sl;function Uw(e){return"getPublicKey"in e?{type:"PublicKeyIdentity",publicKey:(0,Zp.toHex)(e.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}kr.createIdentityDescriptor=Uw});var ul=ee(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});var Vw=9007199254740992;function nn(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 gr(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 ro(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 gr(e,r,t.toString(16))}}function Xp(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 nn(new Uint8Array(ro(3,e.length)),new Uint8Array(t))}function Cw(e,t){if(e==14277111)return nn(new Uint8Array([217,217,247]),t);if(e<24)return nn(new Uint8Array([192+e]),t);{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27,n=2**(r-24),i=e.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(a=>parseInt(a,16)));return new Uint8Array(s).buffer}}We.tagged=Cw;function Es(e){return new Uint8Array(e).buffer}We.raw=Es;function ol(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}We.uSmall=ol;function Qp(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),gr(0,24,e)}We.u8=Qp;function e0(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),gr(0,25,e)}We.u16=e0;function t0(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),gr(0,26,e)}We.u32=t0;function cl(e,t){if(typeof e=="string"&&t==16){if(e.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return gr(0,27,e)}if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),Vw),e=e.toString(16),gr(0,27,e)}We.u64=cl;function r0(e){if(isNaN(e))throw new RangeError("Invalid number.");if(e===0)return ol(0);e=Math.min(Math.max(0,-e),24)-1;let t=[32+e];return new Uint8Array(t).buffer}We.iSmall=r0;function n0(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),gr(1,24,e)}We.i8=n0;function i0(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),gr(1,25,e)}We.i16=i0;function s0(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),gr(1,26,e)}We.i32=s0;function a0(e,t){if(typeof e=="string"&&t==16){if(e.startsWith("-")?e=e.slice(1):e="0",e.match(/[^0-9a-fA-F]/)||e.length>16)throw new RangeError("Invalid number.");let r=!1,n=e.split("").reduceRight((i,s)=>{if(r)return s+i;let a=parseInt(s,16)-1;return a>=0?(r=!0,a.toString(16)+i):"f"+i},"");return r?gr(1,27,n):cl(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),gr(1,27,e)}We.i64=a0;function qw(e){return e>=0?e<24?ol(e):e<=255?Qp(e):e<=65535?e0(e):e<=4294967295?t0(e):cl(e):e>=-24?r0(e):e>=-255?n0(e):e>=-65535?i0(e):e>=-4294967295?s0(e):a0(e)}We.number=qw;function Dw(e){return nn(ro(2,e.byteLength),e)}We.bytes=Dw;function kw(e){return Xp(e)}We.string=kw;function Mw(e){return nn(ro(4,e.length),...e)}We.array=Mw;function jw(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))),nn(ro(5,e.size),...r.map(([n,i])=>nn(Xp(n),i)))}We.map=jw;function Lw(e){let t=new Float32Array([e]);return nn(new Uint8Array([250]),new Uint8Array(t.buffer))}We.singleFloat=Lw;function Hw(e){let t=new Float64Array([e]);return nn(new Uint8Array([251]),new Uint8Array(t.buffer))}We.doubleFloat=Hw;function Kw(e){return e?o0():c0()}We.bool=Kw;function o0(){return Es(new Uint8Array([245]))}We.true_=o0;function c0(){return Es(new Uint8Array([244]))}We.false_=c0;function Gw(){return Es(new Uint8Array([246]))}We.null_=Gw;function $w(){return Es(new Uint8Array([247]))}We.undefined_=$w});var u0=ee(xn=>{"use strict";var Ww=xn&&xn.__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(xn,"__esModule",{value:!0});var br=Ww(ul()),zw=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],no=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 br.undefined_();case"boolean":return br.bool(t);case"number":return Math.floor(t)===t?br.number(t):br.doubleFloat(t);case"string":return br.string(t);case"object":if(t===null)return br.null_();if(Array.isArray(t))return br.array(t.map(r=>this._serializer.serializeValue(r)));if(zw.find(r=>t instanceof r))return br.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 br.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 br.map(r,this._stable)}default:throw new Error("Invalid value.")}}};xn.JsonDefaultCborEncoder=no;var io=class{constructor(){this.name="cborEncoder",this.priority=-90}match(t){return typeof t=="object"&&typeof t.toCBOR=="function"}encode(t){return t.toCBOR()}};xn.ToCborEncoder=io;var so=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let r=new this;return r.addEncoder(new no(r,t)),r.addEncoder(new io),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)}};xn.CborSerializer=so;var ll=class extends so{serialize(t){return br.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};xn.SelfDescribeCborSerializer=ll});var Os=ee($n=>{"use strict";function Yw(e){for(var t in e)$n.hasOwnProperty(t)||($n[t]=e[t])}var Jw=$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});Yw(u0());var Zw=Jw(ul());$n.value=Zw});var vs=ee(bt=>{"use strict";var Xw=bt&&bt.__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]}),Qw=bt&&bt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),e1=bt&&bt.__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)&&Xw(t,e,r);return Qw(t,e),t},t1=bt&&bt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(bt,"__esModule",{value:!0});bt.decode=bt.encode=bt.CborTag=void 0;var r1=t1(to()),Ii=e1(Os()),n1=Os(),ao=$t(),dl=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return Ii.value.bytes(t.toUint8Array())}},fl=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return Ii.value.bytes(new Uint8Array(t))}},pl=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?Ii.value.tagged(2,Ii.value.bytes((0,ao.fromHex)(t.toString(16)))):Ii.value.tagged(3,Ii.value.bytes((0,ao.fromHex)((BigInt("-1")*t).toString(16))))}},oo=n1.SelfDescribeCborSerializer.withDefaultEncoders(!0);oo.addEncoder(new dl);oo.addEncoder(new fl);oo.addEncoder(new pl);var d0;(function(e){e[e.Uint64LittleEndian=71]="Uint64LittleEndian",e[e.Semantic=55799]="Semantic"})(d0=bt.CborTag||(bt.CborTag={}));function i1(e){return oo.serialize(e)}bt.encode=i1;function l0(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 hl=class extends r1.default.Decoder{createByteString(t){return(0,ao.concat)(...t)}createByteStringFromHeap(t,r){return t===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(t,r))}};function s1(e){let t=new Uint8Array(e),r=new hl({size:t.byteLength,tags:{2:n=>l0(n),3:n=>-l0(n),[d0.Semantic]:n=>n}});try{return r.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,ao.toHex)(t)}`)}}bt.decode=s1});var _l=ee(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.randomNumber=void 0;var a1=()=>{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)};co.randomNumber=a1});var Rs=ee(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.makeNonce=Wn.SubmitRequestType=void 0;var uo=_l(),o1;(function(e){e.Call="call"})(o1=Wn.SubmitRequestType||(Wn.SubmitRequestType={}));function c1(){let e=new ArrayBuffer(16),t=new DataView(e),r=(0,uo.randomNumber)(),n=(0,uo.randomNumber)(),i=(0,uo.randomNumber)(),s=(0,uo.randomNumber)();return t.setUint32(0,r),t.setUint32(4,n),t.setUint32(8,i),t.setUint32(12,s),e}Wn.makeNonce=c1});var fo=ee(At=>{"use strict";var u1=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]}),l1=At&&At.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),d1=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)&&u1(t,e,r);return l1(t,e),t};Object.defineProperty(At,"__esModule",{value:!0});At.httpHeadersTransform=At.makeExpiryTransform=At.makeNonceTransform=At.Expiry=void 0;var f1=Ri(),p1=d1(Os()),h1=Rs(),f0=BigInt(1e6),_1=60*1e3,lo=class{constructor(t){if(t<90*1e3){let o=BigInt(Date.now()+t)*f0/BigInt(1e9);this._value=o*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+t-_1))*f0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return p1.value.u64(this._value.toString(16),16)}toHash(){return(0,f1.lebEncode)(this._value)}};At.Expiry=lo;function y1(e=h1.makeNonce){return async t=>{let r=t.request.headers;t.request.headers=r,t.endpoint==="call"&&(t.body.nonce=e())}}At.makeNonceTransform=y1;function m1(e){return async t=>{t.body.ingress_expiry=new lo(e)}}At.makeExpiryTransform=m1;function g1(e){let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t}At.httpHeadersTransform=g1});var ho=ee(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.AgentReadStateError=Mr.AgentQueryError=Mr.AgentCallError=Mr.AgentHTTPResponseError=void 0;var po=wi(),yl=class extends po.AgentError{constructor(t,r){super(t),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Mr.AgentHTTPResponseError=yl;var ml=class extends po.AgentError{constructor(t,r,n,i,s,a){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=a,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}};Mr.AgentCallError=ml;var gl=class extends po.AgentError{constructor(t,r,n,i,s,a){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=a,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}};Mr.AgentQueryError=gl;var bl=class extends po.AgentError{constructor(t,r,n,i,s,a){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=a,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};Mr.AgentReadStateError=bl});var Qt=ee(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.notImplemented=Ve.bitMask=void 0;Ve.isBytes=yo;Ve.abytes=mo;Ve.abool=w1;Ve.bytesToHex=Nl;Ve.numberToHexUnpadded=_0;Ve.hexToNumber=El;Ve.hexToBytes=go;Ve.bytesToNumberBE=T1;Ve.bytesToNumberLE=N1;Ve.numberToBytesBE=y0;Ve.numberToBytesLE=E1;Ve.numberToVarBytesBE=O1;Ve.ensureBytes=v1;Ve.concatBytes=m0;Ve.equalBytes=R1;Ve.utf8ToBytes=A1;Ve.inRange=g0;Ve.aInRange=S1;Ve.bitLen=I1;Ve.bitGet=B1;Ve.bitSet=P1;Ve.createHmacDrbg=U1;Ve.validateObject=C1;Ve.memoized=D1;var Tl=BigInt(0),_o=BigInt(1),b1=BigInt(2);function yo(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function mo(e){if(!yo(e))throw new Error("Uint8Array expected")}function w1(e,t){if(typeof t!="boolean")throw new Error(`${e} must be valid boolean, got "${t}".`)}var x1=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Nl(e){mo(e);let t="";for(let r=0;r<e.length;r++)t+=x1[e[r]];return t}function _0(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function El(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}var sn={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function p0(e){if(e>=sn._0&&e<=sn._9)return e-sn._0;if(e>=sn._A&&e<=sn._F)return e-(sn._A-10);if(e>=sn._a&&e<=sn._f)return e-(sn._a-10)}function go(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let a=p0(e.charCodeAt(s)),o=p0(e.charCodeAt(s+1));if(a===void 0||o===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=a*16+o}return n}function T1(e){return El(Nl(e))}function N1(e){return mo(e),El(Nl(Uint8Array.from(e).reverse()))}function y0(e,t){return go(e.toString(16).padStart(t*2,"0"))}function E1(e,t){return y0(e,t).reverse()}function O1(e){return go(_0(e))}function v1(e,t,r){let n;if(typeof t=="string")try{n=go(t)}catch(s){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`)}else if(yo(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 m0(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];mo(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 R1(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 A1(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}var wl=e=>typeof e=="bigint"&&Tl<=e;function g0(e,t,r){return wl(e)&&wl(t)&&wl(r)&&t<=e&&e<r}function S1(e,t,r,n){if(!g0(t,r,n))throw new Error(`expected valid ${e}: ${r} <= n < ${n}, got ${typeof t} ${t}`)}function I1(e){let t;for(t=0;e>Tl;e>>=_o,t+=1);return t}function B1(e,t){return e>>BigInt(t)&_o}function P1(e,t,r){return e|(r?_o:Tl)<<BigInt(t)}var F1=e=>(b1<<BigInt(e-1))-_o;Ve.bitMask=F1;var xl=e=>new Uint8Array(e),h0=e=>Uint8Array.from(e);function U1(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=xl(e),i=xl(e),s=0,a=()=>{n.fill(1),i.fill(0),s=0},o=(...p)=>r(i,n,...p),c=(p=xl())=>{i=o(h0([0]),p),n=o(),p.length!==0&&(i=o(h0([1]),p),n=o())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let p=0,m=[];for(;p<t;){n=o();let b=n.slice();m.push(b),p+=n.length}return m0(...m)};return(p,m)=>{a(),c(p);let b;for(;!(b=m(d()));)c();return a(),b}}var V1={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"||yo(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 C1(e,t,r={}){let n=(i,s,a)=>{let o=V1[s];if(typeof o!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=e[i];if(!(a&&c===void 0)&&!o(c,e))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(t))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return e}var q1=()=>{throw new Error("not implemented")};Ve.notImplemented=q1;function D1(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 jr=ee(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.isNegativeLE=void 0;Je.mod=er;Je.pow=x0;Je.pow2=L1;Je.invert=bo;Je.tonelliShanks=T0;Je.FpSqrt=N0;Je.validateField=G1;Je.FpPow=E0;Je.FpInvertBatch=O0;Je.FpDiv=$1;Je.FpLegendre=v0;Je.FpIsSquare=W1;Je.nLength=vl;Je.Field=z1;Je.FpSqrtOdd=Y1;Je.FpSqrtEven=J1;Je.hashToPrivateScalar=Z1;Je.getFieldBytesLength=Rl;Je.getMinHashLength=R0;Je.mapHashToField=X1;var tr=Qt(),ut=BigInt(0),He=BigInt(1),Tn=BigInt(2),k1=BigInt(3),Ol=BigInt(4),b0=BigInt(5),w0=BigInt(8),M1=BigInt(9),j1=BigInt(16);function er(e,t){let r=e%t;return r>=ut?r:t+r}function x0(e,t,r){if(r<=ut||t<ut)throw new Error("Expected power/modulo > 0");if(r===He)return ut;let n=He;for(;t>ut;)t&He&&(n=n*e%r),e=e*e%r,t>>=He;return n}function L1(e,t,r){let n=e;for(;t-- >ut;)n*=n,n%=r;return n}function bo(e,t){if(e===ut||t<=ut)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=er(e,t),n=t,i=ut,s=He,a=He,o=ut;for(;r!==ut;){let d=n/r,f=n%r,p=i-a*d,m=s-o*d;n=r,r=f,i=a,s=o,a=p,o=m}if(n!==He)throw new Error("invert: does not exist");return er(i,t)}function T0(e){let t=(e-He)/Tn,r,n,i;for(r=e-He,n=0;r%Tn===ut;r/=Tn,n++);for(i=Tn;i<e&&x0(i,t,e)!==e-He;i++);if(n===1){let a=(e+He)/Ol;return function(c,d){let f=c.pow(d,a);if(!c.eql(c.sqr(f),d))throw new Error("Cannot find square root");return f}}let s=(r+He)/Tn;return function(o,c){if(o.pow(c,t)===o.neg(o.ONE))throw new Error("Cannot find square root");let d=n,f=o.pow(o.mul(o.ONE,i),r),p=o.pow(c,s),m=o.pow(c,r);for(;!o.eql(m,o.ONE);){if(o.eql(m,o.ZERO))return o.ZERO;let b=1;for(let A=o.sqr(m);b<d&&!o.eql(A,o.ONE);b++)A=o.sqr(A);let l=o.pow(f,He<<BigInt(d-b-1));f=o.sqr(l),p=o.mul(p,l),m=o.mul(m,f),d=b}return p}}function N0(e){if(e%Ol===k1){let t=(e+He)/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%w0===b0){let t=(e-b0)/w0;return function(n,i){let s=n.mul(i,Tn),a=n.pow(s,t),o=n.mul(i,a),c=n.mul(n.mul(o,Tn),a),d=n.mul(o,n.sub(c,n.ONE));if(!n.eql(n.sqr(d),i))throw new Error("Cannot find square root");return d}}return e%j1,T0(e)}var H1=(e,t)=>(er(e,t)&He)===He;Je.isNegativeLE=H1;var K1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function G1(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=K1.reduce((n,i)=>(n[i]="function",n),t);return(0,tr.validateObject)(e,r)}function E0(e,t,r){if(r<ut)throw new Error("Expected power > 0");if(r===ut)return e.ONE;if(r===He)return t;let n=e.ONE,i=t;for(;r>ut;)r&He&&(n=e.mul(n,i)),i=e.sqr(i),r>>=He;return n}function O0(e,t){let r=new Array(t.length),n=t.reduce((s,a,o)=>e.is0(a)?s:(r[o]=s,e.mul(s,a)),e.ONE),i=e.inv(n);return t.reduceRight((s,a,o)=>e.is0(a)?s:(r[o]=e.mul(s,r[o]),e.mul(s,a)),i),r}function $1(e,t,r){return e.mul(t,typeof r=="bigint"?bo(r,e.ORDER):e.inv(r))}function v0(e){let t=(e-He)/Tn;return(r,n)=>r.pow(n,t)}function W1(e){let t=v0(e.ORDER);return r=>{let n=t(e,r);return e.eql(n,e.ZERO)||e.eql(n,e.ONE)}}function vl(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function z1(e,t,r=!1,n={}){if(e<=ut)throw new Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:s}=vl(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let a=N0(e),o=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:(0,tr.bitMask)(i),ZERO:ut,ONE:He,create:c=>er(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&He)===He,neg:c=>er(-c,e),eql:(c,d)=>c===d,sqr:c=>er(c*c,e),add:(c,d)=>er(c+d,e),sub:(c,d)=>er(c-d,e),mul:(c,d)=>er(c*d,e),pow:(c,d)=>E0(o,c,d),div:(c,d)=>er(c*bo(d,e),e),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>bo(c,e),sqrt:n.sqrt||(c=>a(o,c)),invertBatch:c=>O0(o,c),cmov:(c,d,f)=>f?d:c,toBytes:c=>r?(0,tr.numberToBytesLE)(c,s):(0,tr.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,tr.bytesToNumberLE)(c):(0,tr.bytesToNumberBE)(c)}});return Object.freeze(o)}function Y1(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 J1(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 Z1(e,t,r=!1){e=(0,tr.ensureBytes)("privateHash",e);let n=e.length,i=vl(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,tr.bytesToNumberLE)(e):(0,tr.bytesToNumberBE)(e);return er(s,t-He)+He}function Rl(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 R0(e){let t=Rl(e);return t+Math.ceil(t/2)}function X1(e,t,r=!1){let n=e.length,i=Rl(t),s=R0(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let a=r?(0,tr.bytesToNumberBE)(e):(0,tr.bytesToNumberLE)(e),o=er(a,t-He)+He;return r?(0,tr.numberToBytesLE)(o,i):(0,tr.numberToBytesBE)(o,i)}});var wo=ee(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.expand_message_xmd=A0;zn.expand_message_xof=S0;zn.hash_to_field=Al;zn.isogenyMap=rx;zn.createHasher=nx;var Q1=jr(),St=Qt(),ex=St.bytesToNumberBE;function Nn(e,t){if(As(e),As(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 tx(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 As(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function A0(e,t,r,n){(0,St.abytes)(e),(0,St.abytes)(t),As(r),t.length>255&&(t=n((0,St.concatBytes)((0,St.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:s}=n,a=Math.ceil(r/i);if(r>65535||a>255)throw new Error("expand_message_xmd: invalid lenInBytes");let o=(0,St.concatBytes)(t,Nn(t.length,1)),c=Nn(0,s),d=Nn(r,2),f=new Array(a),p=n((0,St.concatBytes)(c,e,d,Nn(0,1),o));f[0]=n((0,St.concatBytes)(p,Nn(1,1),o));for(let b=1;b<=a;b++){let l=[tx(p,f[b-1]),Nn(b+1,1),o];f[b]=n((0,St.concatBytes)(...l))}return(0,St.concatBytes)(...f).slice(0,r)}function S0(e,t,r,n,i){if((0,St.abytes)(e),(0,St.abytes)(t),As(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(Nn(r,2)).update(t).update(Nn(t.length,1)).digest()}function Al(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:a,expand:o,DST:c}=r;(0,St.abytes)(e),As(t);let d=typeof c=="string"?(0,St.utf8ToBytes)(c):c,f=n.toString(2).length,p=Math.ceil((f+i)/8),m=t*s*p,b;if(o==="xmd")b=A0(e,d,m,a);else if(o==="xof")b=S0(e,d,m,i,a);else if(o==="_internal_pass")b=e;else throw new Error('expand must be "xmd" or "xof"');let l=new Array(t);for(let A=0;A<t;A++){let v=new Array(s);for(let F=0;F<s;F++){let C=p*(F+A*s),E=b.subarray(C,C+p);v[F]=(0,Q1.mod)(ex(E),n)}l[A]=v}return l}function rx(e,t){let r=t.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,a,o,c]=r.map(d=>d.reduce((f,p)=>e.add(e.mul(f,n),p)));return n=e.div(s,a),i=e.mul(i,e.div(o,c)),{x:n,y:i}}}function nx(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=Al(n,2,{...r,DST:r.DST,...i}),a=e.fromAffine(t(s[0])),o=e.fromAffine(t(s[1])),c=a.add(o).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=Al(n,1,{...r,DST:r.encodeDST,...i}),a=e.fromAffine(t(s[0])).clearCofactor();return a.assertValidity(),a},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=e.fromAffine(t(n)).clearCofactor();return i.assertValidity(),i}}}});var Bl=ee(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.wNAF=sx;Ss.pippenger=ax;Ss.validateBasic=ox;var I0=jr(),P0=Qt(),ix=BigInt(0),Sl=BigInt(1),Il=new WeakMap,B0=new WeakMap;function sx(e,t){let r=(s,a)=>{let o=a.negate();return s?o:a},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},i=s=>{n(s);let a=Math.ceil(t/s)+1,o=2**(s-1);return{windows:a,windowSize:o}};return{constTimeNegate:r,unsafeLadder(s,a){let o=e.ZERO,c=s;for(;a>ix;)a&Sl&&(o=o.add(c)),c=c.double(),a>>=Sl;return o},precomputeWindow(s,a){let{windows:o,windowSize:c}=i(a),d=[],f=s,p=f;for(let m=0;m<o;m++){p=f,d.push(p);for(let b=1;b<c;b++)p=p.add(f),d.push(p);f=p.double()}return d},wNAF(s,a,o){let{windows:c,windowSize:d}=i(s),f=e.ZERO,p=e.BASE,m=BigInt(2**s-1),b=2**s,l=BigInt(s);for(let A=0;A<c;A++){let v=A*d,F=Number(o&m);o>>=l,F>d&&(F-=b,o+=Sl);let C=v,E=v+Math.abs(F)-1,H=A%2!==0,x=F<0;F===0?p=p.add(r(H,a[C])):f=f.add(r(x,a[E]))}return{p:f,f:p}},wNAFCached(s,a,o){let c=B0.get(s)||1,d=Il.get(s);return d||(d=this.precomputeWindow(s,c),c!==1&&Il.set(s,o(d))),this.wNAF(c,d,a)},setWindowSize(s,a){n(a),B0.set(s,a),Il.delete(s)}}}function ax(e,t,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((f,p)=>{if(!t.isValid(f))throw new Error(`wrong scalar at index ${p}`)}),r.forEach((f,p)=>{if(!(f instanceof e))throw new Error(`wrong point at index ${p}`)});let i=(0,P0.bitLen)(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<<s)-1,o=new Array(a+1).fill(e.ZERO),c=Math.floor((t.BITS-1)/s)*s,d=e.ZERO;for(let f=c;f>=0;f-=s){o.fill(e.ZERO);for(let m=0;m<n.length;m++){let b=n[m],l=Number(b>>BigInt(f)&BigInt(a));o[l]=o[l].add(r[m])}let p=e.ZERO;for(let m=o.length-1,b=e.ZERO;m>0;m--)b=b.add(o[m]),p=p.add(b);if(d=d.add(p),f!==0)for(let m=0;m<s;m++)d=d.double()}return d}function ox(e){return(0,I0.validateField)(e.Fp),(0,P0.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,I0.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}});var Pl=ee(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.DER=void 0;xt.weierstrassPoints=V0;xt.weierstrass=fx;xt.SWUFpSqrtRatio=C0;xt.mapToCurveSimpleSWU=px;var xo=Bl(),Yn=jr(),Re=Qt(),wt=Qt();function F0(e){e.lowS!==void 0&&(0,wt.abool)("lowS",e.lowS),e.prehash!==void 0&&(0,wt.abool)("prehash",e.prehash)}function cx(e){let t=(0,xo.validateBasic)(e);Re.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:ux,hexToBytes:lx}=Re;xt.DER={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(e,t)=>{let{Err:r}=xt.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=Re.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Re.numberToHexUnpadded(i.length/2|128):"";return`${Re.numberToHexUnpadded(e)}${s}${i}${t}`},decode(e,t){let{Err:r}=xt.DER,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],s=!!(i&128),a=0;if(!s)a=i;else{let c=i&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let d=t.subarray(n,n+c);if(d.length!==c)throw new r("tlv.decode: length bytes not complete");if(d[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of d)a=a<<8|f;if(n+=c,a<128)throw new r("tlv.decode(long): not minimal encoding")}let o=t.subarray(n,n+a);if(o.length!==a)throw new r("tlv.decode: wrong value length");return{v:o,l:t.subarray(n+a)}}},_int:{encode(e){let{Err:t}=xt.DER;if(e<wr)throw new t("integer: negative integers are not allowed");let r=Re.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}=xt.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 ux(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=xt.DER,i=typeof e=="string"?lx(e):e;Re.abytes(i);let{v:s,l:a}=n.decode(48,i);if(a.length)throw new t("Invalid signature: left bytes after parsing");let{v:o,l:c}=n.decode(2,s),{v:d,l:f}=n.decode(2,c);if(f.length)throw new t("Invalid signature: left bytes after parsing");return{r:r.decode(o),s:r.decode(d)}},hexFromSig(e){let{_tlv:t,_int:r}=xt.DER,n=`${t.encode(2,r.encode(e.r))}${t.encode(2,r.encode(e.s))}`;return t.encode(48,n)}};var wr=BigInt(0),Me=BigInt(1),En=BigInt(2),To=BigInt(3),U0=BigInt(4);function V0(e){let t=cx(e),{Fp:r}=t,n=Yn.Field(t.n,t.nBitLength),i=t.toBytes||((A,v,F)=>{let C=v.toAffine();return Re.concatBytes(Uint8Array.from([4]),r.toBytes(C.x),r.toBytes(C.y))}),s=t.fromBytes||(A=>{let v=A.subarray(1),F=r.fromBytes(v.subarray(0,r.BYTES)),C=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x:F,y:C}});function a(A){let{a:v,b:F}=t,C=r.sqr(A),E=r.mul(C,A);return r.add(r.add(E,r.mul(A,v)),F)}if(!r.eql(r.sqr(t.Gy),a(t.Gx)))throw new Error("bad generator point: equation left != right");function o(A){return Re.inRange(A,Me,t.n)}function c(A){let{allowedPrivateKeyLengths:v,nByteLength:F,wrapPrivateKey:C,n:E}=t;if(v&&typeof A!="bigint"){if(Re.isBytes(A)&&(A=Re.bytesToHex(A)),typeof A!="string"||!v.includes(A.length))throw new Error("Invalid key");A=A.padStart(F*2,"0")}let H;try{H=typeof A=="bigint"?A:Re.bytesToNumberBE((0,wt.ensureBytes)("private key",A,F))}catch{throw new Error(`private key must be ${F} bytes, hex or bigint, not ${typeof A}`)}return C&&(H=Yn.mod(H,E)),Re.aInRange("private key",H,Me,E),H}function d(A){if(!(A instanceof m))throw new Error("ProjectivePoint expected")}let f=(0,wt.memoized)((A,v)=>{let{px:F,py:C,pz:E}=A;if(r.eql(E,r.ONE))return{x:F,y:C};let H=A.is0();v==null&&(v=H?r.ONE:r.inv(E));let x=r.mul(F,v),q=r.mul(C,v),K=r.mul(E,v);if(H)return{x:r.ZERO,y:r.ZERO};if(!r.eql(K,r.ONE))throw new Error("invZ was invalid");return{x,y:q}}),p=(0,wt.memoized)(A=>{if(A.is0()){if(t.allowInfinityPoint&&!r.is0(A.py))return;throw new Error("bad point: ZERO")}let{x:v,y:F}=A.toAffine();if(!r.isValid(v)||!r.isValid(F))throw new Error("bad point: x or y not FE");let C=r.sqr(F),E=a(v);if(!r.eql(C,E))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(v,F,C){if(this.px=v,this.py=F,this.pz=C,v==null||!r.isValid(v))throw new Error("x required");if(F==null||!r.isValid(F))throw new Error("y required");if(C==null||!r.isValid(C))throw new Error("z required");Object.freeze(this)}static fromAffine(v){let{x:F,y:C}=v||{};if(!v||!r.isValid(F)||!r.isValid(C))throw new Error("invalid affine point");if(v instanceof m)throw new Error("projective point not allowed");let E=H=>r.eql(H,r.ZERO);return E(F)&&E(C)?m.ZERO:new m(F,C,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){let F=r.invertBatch(v.map(C=>C.pz));return v.map((C,E)=>C.toAffine(F[E])).map(m.fromAffine)}static fromHex(v){let F=m.fromAffine(s((0,wt.ensureBytes)("pointHex",v)));return F.assertValidity(),F}static fromPrivateKey(v){return m.BASE.multiply(c(v))}static msm(v,F){return(0,xo.pippenger)(m,n,v,F)}_setWindowSize(v){l.setWindowSize(this,v)}assertValidity(){p(this)}hasEvenY(){let{y:v}=this.toAffine();if(r.isOdd)return!r.isOdd(v);throw new Error("Field doesn't support isOdd")}equals(v){d(v);let{px:F,py:C,pz:E}=this,{px:H,py:x,pz:q}=v,K=r.eql(r.mul(F,q),r.mul(H,E)),G=r.eql(r.mul(C,q),r.mul(x,E));return K&&G}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:v,b:F}=t,C=r.mul(F,To),{px:E,py:H,pz:x}=this,q=r.ZERO,K=r.ZERO,G=r.ZERO,D=r.mul(E,E),ae=r.mul(H,H),Q=r.mul(x,x),ne=r.mul(E,H);return ne=r.add(ne,ne),G=r.mul(E,x),G=r.add(G,G),q=r.mul(v,G),K=r.mul(C,Q),K=r.add(q,K),q=r.sub(ae,K),K=r.add(ae,K),K=r.mul(q,K),q=r.mul(ne,q),G=r.mul(C,G),Q=r.mul(v,Q),ne=r.sub(D,Q),ne=r.mul(v,ne),ne=r.add(ne,G),G=r.add(D,D),D=r.add(G,D),D=r.add(D,Q),D=r.mul(D,ne),K=r.add(K,D),Q=r.mul(H,x),Q=r.add(Q,Q),D=r.mul(Q,ne),q=r.sub(q,D),G=r.mul(Q,ae),G=r.add(G,G),G=r.add(G,G),new m(q,K,G)}add(v){d(v);let{px:F,py:C,pz:E}=this,{px:H,py:x,pz:q}=v,K=r.ZERO,G=r.ZERO,D=r.ZERO,ae=t.a,Q=r.mul(t.b,To),ne=r.mul(F,H),w=r.mul(C,x),g=r.mul(E,q),S=r.add(F,C),R=r.add(H,x);S=r.mul(S,R),R=r.add(ne,w),S=r.sub(S,R),R=r.add(F,E);let I=r.add(H,q);return R=r.mul(R,I),I=r.add(ne,g),R=r.sub(R,I),I=r.add(C,E),K=r.add(x,q),I=r.mul(I,K),K=r.add(w,g),I=r.sub(I,K),D=r.mul(ae,R),K=r.mul(Q,g),D=r.add(K,D),K=r.sub(w,D),D=r.add(w,D),G=r.mul(K,D),w=r.add(ne,ne),w=r.add(w,ne),g=r.mul(ae,g),R=r.mul(Q,R),w=r.add(w,g),g=r.sub(ne,g),g=r.mul(ae,g),R=r.add(R,g),ne=r.mul(w,R),G=r.add(G,ne),ne=r.mul(I,R),K=r.mul(S,K),K=r.sub(K,ne),ne=r.mul(S,w),D=r.mul(I,D),D=r.add(D,ne),new m(K,G,D)}subtract(v){return this.add(v.negate())}is0(){return this.equals(m.ZERO)}wNAF(v){return l.wNAFCached(this,v,m.normalizeZ)}multiplyUnsafe(v){Re.aInRange("scalar",v,wr,t.n);let F=m.ZERO;if(v===wr)return F;if(v===Me)return this;let{endo:C}=t;if(!C)return l.unsafeLadder(this,v);let{k1neg:E,k1:H,k2neg:x,k2:q}=C.splitScalar(v),K=F,G=F,D=this;for(;H>wr||q>wr;)H&Me&&(K=K.add(D)),q&Me&&(G=G.add(D)),D=D.double(),H>>=Me,q>>=Me;return E&&(K=K.negate()),x&&(G=G.negate()),G=new m(r.mul(G.px,C.beta),G.py,G.pz),K.add(G)}multiply(v){let{endo:F,n:C}=t;Re.aInRange("scalar",v,Me,C);let E,H;if(F){let{k1neg:x,k1:q,k2neg:K,k2:G}=F.splitScalar(v),{p:D,f:ae}=this.wNAF(q),{p:Q,f:ne}=this.wNAF(G);D=l.constTimeNegate(x,D),Q=l.constTimeNegate(K,Q),Q=new m(r.mul(Q.px,F.beta),Q.py,Q.pz),E=D.add(Q),H=ae.add(ne)}else{let{p:x,f:q}=this.wNAF(v);E=x,H=q}return m.normalizeZ([E,H])[0]}multiplyAndAddUnsafe(v,F,C){let E=m.BASE,H=(q,K)=>K===wr||K===Me||!q.equals(E)?q.multiplyUnsafe(K):q.multiply(K),x=H(this,F).add(H(v,C));return x.is0()?void 0:x}toAffine(v){return f(this,v)}isTorsionFree(){let{h:v,isTorsionFree:F}=t;if(v===Me)return!0;if(F)return F(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:v,clearCofactor:F}=t;return v===Me?this:F?F(m,this):this.multiplyUnsafe(t.h)}toRawBytes(v=!0){return(0,wt.abool)("isCompressed",v),this.assertValidity(),i(m,this,v)}toHex(v=!0){return(0,wt.abool)("isCompressed",v),Re.bytesToHex(this.toRawBytes(v))}}m.BASE=new m(t.Gx,t.Gy,r.ONE),m.ZERO=new m(r.ZERO,r.ONE,r.ZERO);let b=t.nBitLength,l=(0,xo.wNAF)(m,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:o}}function dx(e){let t=(0,xo.validateBasic)(e);return Re.validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function fx(e){let t=dx(e),{Fp:r,n}=t,i=r.BYTES+1,s=2*r.BYTES+1;function a(g){return Yn.mod(g,n)}function o(g){return Yn.invert(g,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:p}=V0({...t,toBytes(g,S,R){let I=S.toAffine(),j=r.toBytes(I.x),Y=Re.concatBytes;return(0,wt.abool)("isCompressed",R),R?Y(Uint8Array.from([S.hasEvenY()?2:3]),j):Y(Uint8Array.from([4]),j,r.toBytes(I.y))},fromBytes(g){let S=g.length,R=g[0],I=g.subarray(1);if(S===i&&(R===2||R===3)){let j=Re.bytesToNumberBE(I);if(!Re.inRange(j,Me,r.ORDER))throw new Error("Point is not on curve");let Y=f(j),oe;try{oe=r.sqrt(Y)}catch(U){let _=U instanceof Error?": "+U.message:"";throw new Error("Point is not on curve"+_)}let se=(oe&Me)===Me;return(R&1)===1!==se&&(oe=r.neg(oe)),{x:j,y:oe}}else if(S===s&&R===4){let j=r.fromBytes(I.subarray(0,r.BYTES)),Y=r.fromBytes(I.subarray(r.BYTES,2*r.BYTES));return{x:j,y:Y}}else throw new Error(`Point of length ${S} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=g=>Re.bytesToHex(Re.numberToBytesBE(g,t.nByteLength));function b(g){let S=n>>Me;return g>S}function l(g){return b(g)?a(-g):g}let A=(g,S,R)=>Re.bytesToNumberBE(g.slice(S,R));class v{constructor(S,R,I){this.r=S,this.s=R,this.recovery=I,this.assertValidity()}static fromCompact(S){let R=t.nByteLength;return S=(0,wt.ensureBytes)("compactSignature",S,R*2),new v(A(S,0,R),A(S,R,2*R))}static fromDER(S){let{r:R,s:I}=xt.DER.toSig((0,wt.ensureBytes)("DER",S));return new v(R,I)}assertValidity(){Re.aInRange("r",this.r,Me,n),Re.aInRange("s",this.s,Me,n)}addRecoveryBit(S){return new v(this.r,this.s,S)}recoverPublicKey(S){let{r:R,s:I,recovery:j}=this,Y=q((0,wt.ensureBytes)("msgHash",S));if(j==null||![0,1,2,3].includes(j))throw new Error("recovery id invalid");let oe=j===2||j===3?R+t.n:R;if(oe>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let se=(j&1)===0?"02":"03",z=c.fromHex(se+m(oe)),U=o(oe),_=a(-Y*U),Z=a(I*U),re=c.BASE.multiplyAndAddUnsafe(z,_,Z);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new v(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Re.hexToBytes(this.toDERHex())}toDERHex(){return xt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Re.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=Yn.getMinHashLength(t.n);return Yn.mapHashToField(t.randomBytes(g),t.n)},precompute(g=8,S=c.BASE){return S._setWindowSize(g),S.multiply(BigInt(3)),S}};function C(g,S=!0){return c.fromPrivateKey(g).toRawBytes(S)}function E(g){let S=Re.isBytes(g),R=typeof g=="string",I=(S||R)&&g.length;return S?I===i||I===s:R?I===2*i||I===2*s:g instanceof c}function H(g,S,R=!0){if(E(g))throw new Error("first arg must be private key");if(!E(S))throw new Error("second arg must be public key");return c.fromHex(S).multiply(d(g)).toRawBytes(R)}let x=t.bits2int||function(g){let S=Re.bytesToNumberBE(g),R=g.length*8-t.nBitLength;return R>0?S>>BigInt(R):S},q=t.bits2int_modN||function(g){return a(x(g))},K=Re.bitMask(t.nBitLength);function G(g){return Re.aInRange(`num < 2^${t.nBitLength}`,g,wr,K),Re.numberToBytesBE(g,t.nByteLength)}function D(g,S,R=ae){if(["recovered","canonical"].some(X=>X in R))throw new Error("sign() legacy options not supported");let{hash:I,randomBytes:j}=t,{lowS:Y,prehash:oe,extraEntropy:se}=R;Y==null&&(Y=!0),g=(0,wt.ensureBytes)("msgHash",g),F0(R),oe&&(g=(0,wt.ensureBytes)("prehashed msgHash",I(g)));let z=q(g),U=d(S),_=[G(U),G(z)];if(se!=null&&se!==!1){let X=se===!0?j(r.BYTES):se;_.push((0,wt.ensureBytes)("extraEntropy",X))}let Z=Re.concatBytes(..._),re=z;function le(X){let u=x(X);if(!p(u))return;let h=o(u),y=c.BASE.multiply(u).toAffine(),P=a(y.x);if(P===wr)return;let O=a(h*a(re+P*U));if(O===wr)return;let B=(y.x===P?0:2)|Number(y.y&Me),M=O;return Y&&b(O)&&(M=l(O),B^=1),new v(P,M,B)}return{seed:Z,k2sig:le}}let ae={lowS:t.lowS,prehash:!1},Q={lowS:t.lowS,prehash:!1};function ne(g,S,R=ae){let{seed:I,k2sig:j}=D(g,S,R),Y=t;return Re.createHmacDrbg(Y.hash.outputLen,Y.nByteLength,Y.hmac)(I,j)}c.BASE._setWindowSize(8);function w(g,S,R,I=Q){let j=g;if(S=(0,wt.ensureBytes)("msgHash",S),R=(0,wt.ensureBytes)("publicKey",R),"strict"in I)throw new Error("options.strict was renamed to lowS");F0(I);let{lowS:Y,prehash:oe}=I,se,z;try{if(typeof j=="string"||Re.isBytes(j))try{se=v.fromDER(j)}catch(y){if(!(y instanceof xt.DER.Err))throw y;se=v.fromCompact(j)}else if(typeof j=="object"&&typeof j.r=="bigint"&&typeof j.s=="bigint"){let{r:y,s:P}=j;se=new v(y,P)}else throw new Error("PARSE");z=c.fromHex(R)}catch(y){if(y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Y&&se.hasHighS())return!1;oe&&(S=t.hash(S));let{r:U,s:_}=se,Z=q(S),re=o(_),le=a(Z*re),X=a(U*re),u=c.BASE.multiplyAndAddUnsafe(z,le,X)?.toAffine();return u?a(u.x)===U:!1}return{CURVE:t,getPublicKey:C,getSharedSecret:H,sign:ne,verify:w,ProjectivePoint:c,Signature:v,utils:F}}function C0(e,t){let r=e.ORDER,n=wr;for(let l=r-Me;l%En===wr;l/=En)n+=Me;let i=n,s=En<<i-Me-Me,a=s*En,o=(r-Me)/a,c=(o-Me)/En,d=a-Me,f=s,p=e.pow(t,o),m=e.pow(t,(o+Me)/En),b=(l,A)=>{let v=p,F=e.pow(A,d),C=e.sqr(F);C=e.mul(C,A);let E=e.mul(l,C);E=e.pow(E,c),E=e.mul(E,F),F=e.mul(E,A),C=e.mul(E,l);let H=e.mul(C,F);E=e.pow(H,f);let x=e.eql(E,e.ONE);F=e.mul(C,m),E=e.mul(H,v),C=e.cmov(F,C,x),H=e.cmov(E,H,x);for(let q=i;q>Me;q--){let K=q-En;K=En<<K-Me;let G=e.pow(H,K),D=e.eql(G,e.ONE);F=e.mul(C,v),v=e.mul(v,v),G=e.mul(H,v),C=e.cmov(F,C,D),H=e.cmov(G,H,D)}return{isValid:x,value:C}};if(e.ORDER%U0===To){let l=(e.ORDER-To)/U0,A=e.sqrt(e.neg(t));b=(v,F)=>{let C=e.sqr(F),E=e.mul(v,F);C=e.mul(C,E);let H=e.pow(C,l);H=e.mul(H,E);let x=e.mul(H,A),q=e.mul(e.sqr(H),F),K=e.eql(q,v),G=e.cmov(x,H,K);return{isValid:K,value:G}}}return b}function px(e,t){if(Yn.validateField(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=C0(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,a,o,c,d,f,p;i=e.sqr(n),i=e.mul(i,t.Z),s=e.sqr(i),s=e.add(s,i),a=e.add(s,e.ONE),a=e.mul(a,t.B),o=e.cmov(t.Z,e.neg(s),!e.eql(s,e.ZERO)),o=e.mul(o,t.A),s=e.sqr(a),d=e.sqr(o),c=e.mul(d,t.A),s=e.add(s,c),s=e.mul(s,a),d=e.mul(d,o),c=e.mul(d,t.B),s=e.add(s,c),f=e.mul(i,a);let{isValid:m,value:b}=r(s,d);p=e.mul(i,n),p=e.mul(p,b),f=e.cmov(f,a,m),p=e.cmov(p,b,m);let l=e.isOdd(n)===e.isOdd(p);return p=e.cmov(e.neg(p),p,l),f=e.div(f,o),{x:f,y:p}}}});var j0=ee(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});Ul.bls=yx;var q0=jr(),Fl=Qt(),D0=wo(),k0=Pl(),hx=BigInt(0),No=BigInt(1),M0=BigInt(2),Bi=BigInt(3);function _x(e){let t=[];for(;e>No;e>>=No)(e&No)===hx?t.unshift(0):(e&Bi)===Bi?(t.unshift(-1),e+=No):t.unshift(1);return t}function yx(e){let{Fp:t,Fr:r,Fp2:n,Fp6:i,Fp12:s}=e.fields,a=e.params.xNegative,o=e.params.twistType,c=(0,k0.weierstrassPoints)({n:r.ORDER,...e.G1}),d=Object.assign(c,(0,D0.createHasher)(c.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),f=(0,k0.weierstrassPoints)({n:r.ORDER,...e.G2}),p=Object.assign(f,(0,D0.createHasher)(f.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults})),m;if(o==="multiplicative")m=(z,U,_,Z,re,le)=>s.mul014(Z,z,n.mul(U,re),n.mul(_,le));else if(o==="divisive")m=(z,U,_,Z,re,le)=>s.mul034(Z,n.mul(_,le),n.mul(U,re),z);else throw new Error("bls: unknown twist type");let b=n.div(n.ONE,n.mul(n.ONE,M0));function l(z,U,_,Z){let re=n.sqr(_),le=n.sqr(Z),X=n.mulByB(n.mul(le,Bi)),u=n.mul(X,Bi),h=n.sub(n.sub(n.sqr(n.add(_,Z)),le),re),y=n.sub(X,re),P=n.mul(n.sqr(U),Bi),O=n.neg(h);return z.push([y,P,O]),U=n.mul(n.mul(n.mul(n.sub(re,u),U),_),b),_=n.sub(n.sqr(n.mul(n.add(re,u),b)),n.mul(n.sqr(X),Bi)),Z=n.mul(re,h),{Rx:U,Ry:_,Rz:Z}}function A(z,U,_,Z,re,le){let X=n.sub(_,n.mul(le,Z)),u=n.sub(U,n.mul(re,Z)),h=n.sub(n.mul(X,re),n.mul(u,le)),y=n.neg(X),P=u;z.push([h,y,P]);let O=n.sqr(u),B=n.mul(O,u),M=n.mul(O,U),T=n.add(n.sub(B,n.mul(M,M0)),n.mul(n.sqr(X),Z));return U=n.mul(u,T),_=n.sub(n.mul(n.sub(M,T),X),n.mul(B,_)),Z=n.mul(Z,B),{Rx:U,Ry:_,Rz:Z}}let v=_x(e.params.ateLoopSize),F=(0,Fl.memoized)(z=>{let U=z,{x:_,y:Z}=U.toAffine(),re=_,le=Z,X=n.neg(Z),u=re,h=le,y=n.ONE,P=[];for(let O of v){let B=[];({Rx:u,Ry:h,Rz:y}=l(B,u,h,y)),O&&({Rx:u,Ry:h,Rz:y}=A(B,u,h,y,re,O===-1?X:le)),P.push(B)}if(e.postPrecompute){let O=P[P.length-1];e.postPrecompute(u,h,y,re,le,A.bind(null,O))}return P});function C(z,U=!1){let _=s.ONE;if(z.length){let Z=z[0][0].length;for(let re=0;re<Z;re++){_=s.sqr(_);for(let[le,X,u]of z)for(let[h,y,P]of le[re])_=m(h,y,P,_,X,u)}}return a&&(_=s.conjugate(_)),U?s.finalExponentiate(_):_}function E(z,U=!0){let _=[];d.ProjectivePoint.normalizeZ(z.map(({g1:Z})=>Z)),p.ProjectivePoint.normalizeZ(z.map(({g2:Z})=>Z));for(let{g1:Z,g2:re}of z){if(Z.equals(d.ProjectivePoint.ZERO)||re.equals(p.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");Z.assertValidity(),re.assertValidity();let le=Z.toAffine();_.push([F(re),le.x,le.y])}return C(_,U)}function H(z,U,_=!0){return E([{g1:z,g2:U}],_)}let x={randomPrivateKey:()=>{let z=(0,q0.getMinHashLength)(r.ORDER);return(0,q0.mapHashToField)(e.randomBytes(z),r.ORDER)},calcPairingPrecomputes:F},{ShortSignature:q}=e.G1,{Signature:K}=e.G2;function G(z){return z instanceof d.ProjectivePoint?z:d.ProjectivePoint.fromHex(z)}function D(z,U){return z instanceof d.ProjectivePoint?z:d.hashToCurve((0,Fl.ensureBytes)("point",z),U)}function ae(z){return z instanceof p.ProjectivePoint?z:K.fromHex(z)}function Q(z,U){return z instanceof p.ProjectivePoint?z:p.hashToCurve((0,Fl.ensureBytes)("point",z),U)}function ne(z){return d.ProjectivePoint.fromPrivateKey(z).toRawBytes(!0)}function w(z){return p.ProjectivePoint.fromPrivateKey(z).toRawBytes(!0)}function g(z,U,_){let Z=Q(z,_);Z.assertValidity();let re=Z.multiply(d.normPrivateKeyToScalar(U));return z instanceof p.ProjectivePoint?re:K.toRawBytes(re)}function S(z,U,_){let Z=D(z,_);Z.assertValidity();let re=Z.multiply(d.normPrivateKeyToScalar(U));return z instanceof d.ProjectivePoint?re:q.toRawBytes(re)}function R(z,U,_,Z){let re=G(_),le=Q(U,Z),X=d.ProjectivePoint.BASE,u=ae(z),h=E([{g1:re.negate(),g2:le},{g1:X,g2:u}]);return s.eql(h,s.ONE)}function I(z,U,_,Z){let re=ae(_),le=D(U,Z),X=p.ProjectivePoint.BASE,u=G(z),h=E([{g1:le,g2:re},{g1:u,g2:X.negate()}]);return s.eql(h,s.ONE)}function j(z){if(!z.length)throw new Error("Expected non-empty array");let _=z.map(G).reduce((Z,re)=>Z.add(re),d.ProjectivePoint.ZERO);return z[0]instanceof d.ProjectivePoint?(_.assertValidity(),_):_.toRawBytes(!0)}function Y(z){if(!z.length)throw new Error("Expected non-empty array");let _=z.map(ae).reduce((Z,re)=>Z.add(re),p.ProjectivePoint.ZERO);return z[0]instanceof p.ProjectivePoint?(_.assertValidity(),_):K.toRawBytes(_)}function oe(z){if(!z.length)throw new Error("Expected non-empty array");let _=z.map(G).reduce((Z,re)=>Z.add(re),d.ProjectivePoint.ZERO);return z[0]instanceof d.ProjectivePoint?(_.assertValidity(),_):q.toRawBytes(_)}function se(z,U,_,Z){if(!U.length)throw new Error("Expected non-empty messages array");if(_.length!==U.length)throw new Error("Pubkey count should equal msg count");let re=ae(z),le=U.map(y=>Q(y,Z)),X=_.map(G),u=new Map;for(let y=0;y<X.length;y++){let P=X[y],O=le[y],B=u.get(O);B===void 0&&(B=[],u.set(O,B)),B.push(P)}let h=[];try{for(let[y,P]of u){let O=P.reduce((B,M)=>B.add(M));h.push({g1:O,g2:y})}return h.push({g1:d.ProjectivePoint.BASE.negate(),g2:re}),s.eql(E(h),s.ONE)}catch{return!1}}return d.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ne,getPublicKeyForShortSignatures:w,sign:g,signShortSignature:S,verify:R,verifyBatch:se,verifyShortSignature:I,aggregatePublicKeys:j,aggregateSignatures:Y,aggregateShortSignatures:oe,millerLoopBatch:C,pairing:H,pairingBatch:E,G1:d,G2:p,Signature:K,ShortSignature:q,fields:{Fr:r,Fp:t,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:e.params.ateLoopSize,r:e.params.r,G1b:e.G1.b,G2b:e.G2.b},utils:x}}});var H0=ee(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.psiFrobenius=gx;Eo.tower12=bx;var On=jr(),xr=Qt(),mx=BigInt(0),Pi=BigInt(1),an=BigInt(2),L0=BigInt(3);function Vl(e,t,r,n,i=1,s){let a=BigInt(s===void 0?n:s),o=r**BigInt(n),c=[];for(let d=0;d<i;d++){let f=BigInt(d+1),p=[];for(let m=0,b=Pi;m<n;m++){let l=(f*b-f)/a%o;p.push(e.pow(t,l)),b*=r}c.push(p)}return c}function gx(e,t,r){let n=t.pow(r,(e.ORDER-Pi)/L0),i=t.pow(r,(e.ORDER-Pi)/an);function s(m,b){let l=t.mul(t.frobeniusMap(m,1),n),A=t.mul(t.frobeniusMap(b,1),i);return[l,A]}let a=t.pow(r,(e.ORDER**an-Pi)/L0),o=t.pow(r,(e.ORDER**an-Pi)/an);if(!t.eql(o,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(m,b){return[t.mul(m,a),t.neg(b)]}let d=m=>(b,l)=>{let A=l.toAffine(),v=m(A.x,A.y);return b.fromAffine({x:v[0],y:v[1]})},f=d(s),p=d(c);return{psi:s,psi2:c,G2psi:f,G2psi2:p,PSI_X:n,PSI_Y:i,PSI2_X:a,PSI2_Y:o}}function bx(e){let{ORDER:t}=e,r=On.Field(t),n=r.create(e.NONRESIDUE||BigInt(-1)),i=On.FpLegendre(t),s=r.div(r.ONE,an),a=Vl(r,n,r.ORDER,2)[0],o=({c0:w,c1:g},{c0:S,c1:R})=>({c0:r.add(w,S),c1:r.add(g,R)}),c=({c0:w,c1:g},{c0:S,c1:R})=>({c0:r.sub(w,S),c1:r.sub(g,R)}),d=({c0:w,c1:g},S)=>{if(typeof S=="bigint")return{c0:r.mul(w,S),c1:r.mul(g,S)};let{c0:R,c1:I}=S,j=r.mul(w,R),Y=r.mul(g,I),oe=r.sub(j,Y),se=r.sub(r.mul(r.add(w,g),r.add(R,I)),r.add(j,Y));return{c0:oe,c1:se}},f=({c0:w,c1:g})=>{let S=r.add(w,g),R=r.sub(w,g),I=r.add(w,w);return{c0:r.mul(S,R),c1:r.mul(I,g)}},p=w=>{if(w.length!==2)throw new Error("Invalid tuple");let g=w.map(S=>r.create(S));return{c0:g[0],c1:g[1]}},m=t*t,b=p(e.FP2_NONRESIDUE),l={ORDER:m,NONRESIDUE:b,BITS:(0,xr.bitLen)(m),BYTES:Math.ceil((0,xr.bitLen)(m)/8),MASK:(0,xr.bitMask)((0,xr.bitLen)(m)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:w=>w,isValid:({c0:w,c1:g})=>typeof w=="bigint"&&typeof g=="bigint",is0:({c0:w,c1:g})=>r.is0(w)&&r.is0(g),eql:({c0:w,c1:g},{c0:S,c1:R})=>r.eql(w,S)&&r.eql(g,R),neg:({c0:w,c1:g})=>({c0:r.neg(w),c1:r.neg(g)}),pow:(w,g)=>On.FpPow(l,w,g),invertBatch:w=>On.FpInvertBatch(l,w),add:o,sub:c,mul:d,sqr:f,addN:o,subN:c,mulN:d,sqrN:f,div:(w,g)=>l.mul(w,typeof g=="bigint"?r.inv(r.create(g)):l.inv(g)),inv:({c0:w,c1:g})=>{let S=r.inv(r.create(w*w+g*g));return{c0:r.mul(S,r.create(w)),c1:r.mul(S,r.create(-g))}},sqrt:w=>{if(e.Fp2sqrt)return e.Fp2sqrt(w);let{c0:g,c1:S}=w;if(r.is0(S))return r.eql(i(r,g),r.ONE)?l.create({c0:r.sqrt(g),c1:r.ZERO}):l.create({c0:r.ZERO,c1:r.sqrt(r.div(g,n))});let R=r.sqrt(r.sub(r.sqr(g),r.mul(r.sqr(S),n))),I=r.mul(r.add(R,g),s),j=i(r,I);!r.is0(j)&&!r.eql(j,r.ONE)&&(I=r.sub(I,R));let Y=r.sqrt(I),oe=l.create({c0:Y,c1:r.div(r.mul(S,s),Y)});if(!l.eql(l.sqr(oe),w))throw new Error("Cannot find square root");let se=oe,z=l.neg(se),{re:U,im:_}=l.reim(se),{re:Z,im:re}=l.reim(z);return _>re||_===re&&U>Z?se:z},isOdd:w=>{let{re:g,im:S}=l.reim(w),R=g%an,I=g===mx,j=S%an;return BigInt(R||I&&j)==Pi},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,xr.concatBytes)(r.toBytes(w),r.toBytes(g)),cmov:({c0:w,c1:g},{c0:S,c1:R},I)=>({c0:r.cmov(w,S,I),c1:r.cmov(g,R,I)}),reim:({c0:w,c1:g})=>({re:w,im:g}),mulByNonresidue:({c0:w,c1:g})=>l.mul({c0:w,c1:g},b),mulByB:e.Fp2mulByB,fromBigTuple:p,frobeniusMap:({c0:w,c1:g},S)=>({c0:w,c1:r.mul(g,a[S%2])})},A=({c0:w,c1:g,c2:S},{c0:R,c1:I,c2:j})=>({c0:l.add(w,R),c1:l.add(g,I),c2:l.add(S,j)}),v=({c0:w,c1:g,c2:S},{c0:R,c1:I,c2:j})=>({c0:l.sub(w,R),c1:l.sub(g,I),c2:l.sub(S,j)}),F=({c0:w,c1:g,c2:S},R)=>{if(typeof R=="bigint")return{c0:l.mul(w,R),c1:l.mul(g,R),c2:l.mul(S,R)};let{c0:I,c1:j,c2:Y}=R,oe=l.mul(w,I),se=l.mul(g,j),z=l.mul(S,Y);return{c0:l.add(oe,l.mulByNonresidue(l.sub(l.mul(l.add(g,S),l.add(j,Y)),l.add(se,z)))),c1:l.add(l.sub(l.mul(l.add(w,g),l.add(I,j)),l.add(oe,se)),l.mulByNonresidue(z)),c2:l.sub(l.add(se,l.mul(l.add(w,S),l.add(I,Y))),l.add(oe,z))}},C=({c0:w,c1:g,c2:S})=>{let R=l.sqr(w),I=l.mul(l.mul(w,g),an),j=l.mul(l.mul(g,S),an),Y=l.sqr(S);return{c0:l.add(l.mulByNonresidue(j),R),c1:l.add(l.mulByNonresidue(Y),I),c2:l.sub(l.sub(l.add(l.add(I,l.sqr(l.add(l.sub(w,g),S))),j),R),Y)}},[E,H]=Vl(l,b,r.ORDER,6,2,3),x={ORDER:l.ORDER,BITS:3*l.BITS,BYTES:3*l.BYTES,MASK:(0,xr.bitMask)(3*l.BITS),ZERO:{c0:l.ZERO,c1:l.ZERO,c2:l.ZERO},ONE:{c0:l.ONE,c1:l.ZERO,c2:l.ZERO},create:w=>w,isValid:({c0:w,c1:g,c2:S})=>l.isValid(w)&&l.isValid(g)&&l.isValid(S),is0:({c0:w,c1:g,c2:S})=>l.is0(w)&&l.is0(g)&&l.is0(S),neg:({c0:w,c1:g,c2:S})=>({c0:l.neg(w),c1:l.neg(g),c2:l.neg(S)}),eql:({c0:w,c1:g,c2:S},{c0:R,c1:I,c2:j})=>l.eql(w,R)&&l.eql(g,I)&&l.eql(S,j),sqrt:xr.notImplemented,div:(w,g)=>x.mul(w,typeof g=="bigint"?r.inv(r.create(g)):x.inv(g)),pow:(w,g)=>On.FpPow(x,w,g),invertBatch:w=>On.FpInvertBatch(x,w),add:A,sub:v,mul:F,sqr:C,addN:A,subN:v,mulN:F,sqrN:C,inv:({c0:w,c1:g,c2:S})=>{let R=l.sub(l.sqr(w),l.mulByNonresidue(l.mul(S,g))),I=l.sub(l.mulByNonresidue(l.sqr(S)),l.mul(w,g)),j=l.sub(l.sqr(g),l.mul(w,S)),Y=l.inv(l.add(l.mulByNonresidue(l.add(l.mul(S,I),l.mul(g,j))),l.mul(w,R)));return{c0:l.mul(Y,R),c1:l.mul(Y,I),c2:l.mul(Y,j)}},fromBytes:w=>{if(w.length!==x.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:l.fromBytes(w.subarray(0,l.BYTES)),c1:l.fromBytes(w.subarray(l.BYTES,2*l.BYTES)),c2:l.fromBytes(w.subarray(2*l.BYTES))}},toBytes:({c0:w,c1:g,c2:S})=>(0,xr.concatBytes)(l.toBytes(w),l.toBytes(g),l.toBytes(S)),cmov:({c0:w,c1:g,c2:S},{c0:R,c1:I,c2:j},Y)=>({c0:l.cmov(w,R,Y),c1:l.cmov(g,I,Y),c2:l.cmov(S,j,Y)}),fromBigSix:w=>{if(!Array.isArray(w)||w.length!==6)throw new Error("Invalid Fp6 usage");return{c0:l.fromBigTuple(w.slice(0,2)),c1:l.fromBigTuple(w.slice(2,4)),c2:l.fromBigTuple(w.slice(4,6))}},frobeniusMap:({c0:w,c1:g,c2:S},R)=>({c0:l.frobeniusMap(w,R),c1:l.mul(l.frobeniusMap(g,R),E[R%6]),c2:l.mul(l.frobeniusMap(S,R),H[R%6])}),mulByFp2:({c0:w,c1:g,c2:S},R)=>({c0:l.mul(w,R),c1:l.mul(g,R),c2:l.mul(S,R)}),mulByNonresidue:({c0:w,c1:g,c2:S})=>({c0:l.mulByNonresidue(S),c1:w,c2:g}),mul1:({c0:w,c1:g,c2:S},R)=>({c0:l.mulByNonresidue(l.mul(S,R)),c1:l.mul(w,R),c2:l.mul(g,R)}),mul01({c0:w,c1:g,c2:S},R,I){let j=l.mul(w,R),Y=l.mul(g,I);return{c0:l.add(l.mulByNonresidue(l.sub(l.mul(l.add(g,S),I),Y)),j),c1:l.sub(l.sub(l.mul(l.add(R,I),l.add(w,g)),j),Y),c2:l.add(l.sub(l.mul(l.add(w,S),R),j),Y)}}},q=Vl(l,b,r.ORDER,12,1,6)[0],K=({c0:w,c1:g},{c0:S,c1:R})=>({c0:x.add(w,S),c1:x.add(g,R)}),G=({c0:w,c1:g},{c0:S,c1:R})=>({c0:x.sub(w,S),c1:x.sub(g,R)}),D=({c0:w,c1:g},S)=>{if(typeof S=="bigint")return{c0:x.mul(w,S),c1:x.mul(g,S)};let{c0:R,c1:I}=S,j=x.mul(w,R),Y=x.mul(g,I);return{c0:x.add(j,x.mulByNonresidue(Y)),c1:x.sub(x.mul(x.add(w,g),x.add(R,I)),x.add(j,Y))}},ae=({c0:w,c1:g})=>{let S=x.mul(w,g);return{c0:x.sub(x.sub(x.mul(x.add(x.mulByNonresidue(g),w),x.add(w,g)),S),x.mulByNonresidue(S)),c1:x.add(S,S)}};function Q(w,g){let S=l.sqr(w),R=l.sqr(g);return{first:l.add(l.mulByNonresidue(R),S),second:l.sub(l.sub(l.sqr(l.add(w,g)),S),R)}}let ne={ORDER:l.ORDER,BITS:2*l.BITS,BYTES:2*l.BYTES,MASK:(0,xr.bitMask)(2*l.BITS),ZERO:{c0:x.ZERO,c1:x.ZERO},ONE:{c0:x.ONE,c1:x.ZERO},create:w=>w,isValid:({c0:w,c1:g})=>x.isValid(w)&&x.isValid(g),is0:({c0:w,c1:g})=>x.is0(w)&&x.is0(g),neg:({c0:w,c1:g})=>({c0:x.neg(w),c1:x.neg(g)}),eql:({c0:w,c1:g},{c0:S,c1:R})=>x.eql(w,S)&&x.eql(g,R),sqrt:xr.notImplemented,inv:({c0:w,c1:g})=>{let S=x.inv(x.sub(x.sqr(w),x.mulByNonresidue(x.sqr(g))));return{c0:x.mul(w,S),c1:x.neg(x.mul(g,S))}},div:(w,g)=>ne.mul(w,typeof g=="bigint"?r.inv(r.create(g)):ne.inv(g)),pow:(w,g)=>On.FpPow(ne,w,g),invertBatch:w=>On.FpInvertBatch(ne,w),add:K,sub:G,mul:D,sqr:ae,addN:K,subN:G,mulN:D,sqrN:ae,fromBytes:w=>{if(w.length!==ne.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:x.fromBytes(w.subarray(0,x.BYTES)),c1:x.fromBytes(w.subarray(x.BYTES))}},toBytes:({c0:w,c1:g})=>(0,xr.concatBytes)(x.toBytes(w),x.toBytes(g)),cmov:({c0:w,c1:g},{c0:S,c1:R},I)=>({c0:x.cmov(w,S,I),c1:x.cmov(g,R,I)}),fromBigTwelve:w=>({c0:x.fromBigSix(w.slice(0,6)),c1:x.fromBigSix(w.slice(6,12))}),frobeniusMap(w,g){let{c0:S,c1:R,c2:I}=x.frobeniusMap(w.c1,g),j=q[g%12];return{c0:x.frobeniusMap(w.c0,g),c1:x.create({c0:l.mul(S,j),c1:l.mul(R,j),c2:l.mul(I,j)})}},mulByFp2:({c0:w,c1:g},S)=>({c0:x.mulByFp2(w,S),c1:x.mulByFp2(g,S)}),conjugate:({c0:w,c1:g})=>({c0:w,c1:x.neg(g)}),mul014:({c0:w,c1:g},S,R,I)=>{let j=x.mul01(w,S,R),Y=x.mul1(g,I);return{c0:x.add(x.mulByNonresidue(Y),j),c1:x.sub(x.sub(x.mul01(x.add(g,w),S,l.add(R,I)),j),Y)}},mul034:({c0:w,c1:g},S,R,I)=>{let j=x.create({c0:l.mul(w.c0,S),c1:l.mul(w.c1,S),c2:l.mul(w.c2,S)}),Y=x.mul01(g,R,I),oe=x.mul01(x.add(w,g),l.add(S,R),I);return{c0:x.add(x.mulByNonresidue(Y),j),c1:x.sub(oe,x.add(j,Y))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:r,Fp2:l,Fp6:x,Fp4Square:Q,Fp12:ne}}});var X0=ee(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.bls12_381=void 0;var z0=Ra(),wx=Kn(),xx=j0(),Tx=jr(),Ae=Qt(),Y0=wo(),J0=Pl(),Z0=H0(),Dt=BigInt(0),Ro=BigInt(1),_t=BigInt(2),Oo=BigInt(3),Is=BigInt(4),vn=BigInt("0xd201000000010000"),Nx=(0,Ae.bitLen)(vn),{Fp:pe,Fp2:he,Fp6:Dl,Fp4Square:Cl,Fp12:Ee}=(0,Z0.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[Ro,Ro],Fp2mulByB:({c0:e,c1:t})=>{let r=pe.mul(e,Is),n=pe.mul(t,Is);return{c0:pe.sub(r,n),c1:pe.add(r,n)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{let{c0:r,c1:n,c2:i}=e,{c0:s,c1:a,c2:o}=t,{first:c,second:d}=Cl(r,a),{first:f,second:p}=Cl(s,i),{first:m,second:b}=Cl(n,o),l=he.mulByNonresidue(b);return{c0:Dl.create({c0:he.add(he.mul(he.sub(c,r),_t),c),c1:he.add(he.mul(he.sub(f,n),_t),f),c2:he.add(he.mul(he.sub(m,i),_t),m)}),c1:Dl.create({c0:he.add(he.mul(he.add(l,s),_t),l),c1:he.add(he.mul(he.add(d,a),_t),d),c2:he.add(he.mul(he.add(p,o),_t),p)})}},Fp12cyclotomicExp(e,t){let r=Ee.ONE;for(let n=Nx-1;n>=0;n--)r=Ee._cyclotomicSquare(r),(0,Ae.bitGet)(t,n)&&(r=Ee.mul(r,e));return r},Fp12finalExponentiate:e=>{let t=vn,r=Ee.div(Ee.frobeniusMap(e,6),e),n=Ee.mul(Ee.frobeniusMap(r,2),r),i=Ee.conjugate(Ee._cyclotomicExp(n,t)),s=Ee.mul(Ee.conjugate(Ee._cyclotomicSquare(n)),i),a=Ee.conjugate(Ee._cyclotomicExp(s,t)),o=Ee.conjugate(Ee._cyclotomicExp(a,t)),c=Ee.mul(Ee.conjugate(Ee._cyclotomicExp(o,t)),Ee._cyclotomicSquare(i)),d=Ee.conjugate(Ee._cyclotomicExp(c,t)),f=Ee.frobeniusMap(Ee.mul(i,o),2),p=Ee.frobeniusMap(Ee.mul(a,n),3),m=Ee.frobeniusMap(Ee.mul(c,Ee.conjugate(n)),1),b=Ee.mul(Ee.mul(d,Ee.conjugate(s)),n);return Ee.mul(Ee.mul(Ee.mul(f,p),m),b)}}),K0=Tx.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Ex=(0,Y0.isogenyMap)(he,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(e=>e.map(t=>he.fromBigTuple(t.map(BigInt))))),Ox=(0,Y0.isogenyMap)(pe,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),vx=(0,J0.mapToCurveSimpleSWU)(he,{A:he.create({c0:pe.create(Dt),c1:pe.create(BigInt(240))}),B:he.create({c0:pe.create(BigInt(1012)),c1:pe.create(BigInt(1012))}),Z:he.create({c0:pe.create(BigInt(-2)),c1:pe.create(BigInt(-1))})}),Rx=(0,J0.mapToCurveSimpleSWU)(pe,{A:pe.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:pe.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:pe.create(BigInt(11))}),{G2psi:G0,G2psi2:Ax}=(0,Z0.psiFrobenius)(pe,he,he.div(he.ONE,he.NONRESIDUE)),ql=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:pe.ORDER,m:2,k:128,expand:"xmd",hash:z0.sha256}),Ao=Bs(pe.toBytes(Dt),{infinity:!0,compressed:!0});function vo(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 Bs(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 $0(e){e.assertValidity();let t=e.equals(kt.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=e.toAffine();if(t)return Ao.slice();let i=pe.ORDER,s=!!(n*_t/i);return Bs((0,Ae.numberToBytesBE)(r,pe.BYTES),{compressed:!0,sort:s})}function W0(e){e.assertValidity();let t=pe.BYTES;if(e.equals(kt.bls12_381.G2.ProjectivePoint.ZERO))return(0,Ae.concatBytes)(Ao,(0,Ae.numberToBytesBE)(Dt,t));let{x:r,y:n}=e.toAffine(),{re:i,im:s}=he.reim(r),{re:a,im:o}=he.reim(n),d=!!((o>Dt?o*_t:a*_t)/pe.ORDER&Ro),f=i;return(0,Ae.concatBytes)(Bs((0,Ae.numberToBytesBE)(s,t),{sort:d,compressed:!0}),(0,Ae.numberToBytesBE)(f,t))}kt.bls12_381=(0,xx.bls)({fields:{Fp:pe,Fp2:he,Fp6:Dl,Fp12:Ee,Fr:K0},G1:{Fp:pe,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:pe.ZERO,b:Is,htfDefaults:{...ql,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(e,t)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new e(pe.mul(t.px,r),t.py,t.pz);return t.multiplyUnsafe(vn).negate().multiplyUnsafe(vn).equals(n)},clearCofactor:(e,t)=>t.multiplyUnsafe(vn).add(t),mapToCurve:e=>{let{x:t,y:r}=Rx(pe.create(e[0]));return Ox(t,r)},fromBytes:e=>{let{compressed:t,infinity:r,sort:n,value:i}=vo(e);if(i.length===48&&t){let s=pe.ORDER,a=(0,Ae.bytesToNumberBE)(i),o=pe.create(a&pe.MASK);if(r){if(o!==Dt)throw new Error("G1: non-empty compressed point at infinity");return{x:Dt,y:Dt}}let c=pe.add(pe.pow(o,Oo),pe.create(kt.bls12_381.params.G1b)),d=pe.sqrt(c);if(!d)throw new Error("Invalid compressed G1 point");return d*_t/s!==BigInt(n)&&(d=pe.neg(d)),{x:pe.create(o),y:pe.create(d)}}else if(i.length===96&&!t){let s=(0,Ae.bytesToNumberBE)(i.subarray(0,pe.BYTES)),a=(0,Ae.bytesToNumberBE)(i.subarray(pe.BYTES));if(r){if(s!==Dt||a!==Dt)throw new Error("G1: non-empty point at infinity");return kt.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:pe.create(s),y:pe.create(a)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(e,t,r)=>{let n=t.equals(e.ZERO),{x:i,y:s}=t.toAffine();if(r){if(n)return Ao.slice();let a=pe.ORDER,o=!!(s*_t/a);return Bs((0,Ae.numberToBytesBE)(i,pe.BYTES),{compressed:!0,sort:o})}else return n?(0,Ae.concatBytes)(new Uint8Array([64]),new Uint8Array(2*pe.BYTES-1)):(0,Ae.concatBytes)((0,Ae.numberToBytesBE)(i,pe.BYTES),(0,Ae.numberToBytesBE)(s,pe.BYTES))},ShortSignature:{fromHex(e){let{infinity:t,sort:r,value:n}=vo((0,Ae.ensureBytes)("signatureHex",e,48)),i=pe.ORDER,s=(0,Ae.bytesToNumberBE)(n);if(t)return kt.bls12_381.G1.ProjectivePoint.ZERO;let a=pe.create(s&pe.MASK),o=pe.add(pe.pow(a,Oo),pe.create(kt.bls12_381.params.G1b)),c=pe.sqrt(o);if(!c)throw new Error("Invalid compressed G1 point");let d=BigInt(r);c*_t/i!==d&&(c=pe.neg(c));let f=kt.bls12_381.G1.ProjectivePoint.fromAffine({x:a,y:c});return f.assertValidity(),f},toRawBytes(e){return $0(e)},toHex(e){return(0,Ae.bytesToHex)($0(e))}}},G2:{Fp:he,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:he.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:he.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:he.ZERO,b:he.fromBigTuple([Is,Is]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...ql},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{let{x:t,y:r}=vx(he.fromBigTuple(e));return Ex(t,r)},isTorsionFree:(e,t)=>t.multiplyUnsafe(vn).negate().equals(G0(e,t)),clearCofactor:(e,t)=>{let r=vn,n=t.multiplyUnsafe(r).negate(),i=G0(e,t),s=t.double();return s=Ax(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}=vo(e);if(!t&&!r&&n||!t&&r&&n||n&&r&&t)throw new Error("Invalid encoding flag: "+(e[0]&224));let s=pe.BYTES,a=(o,c,d)=>(0,Ae.bytesToNumberBE)(o.slice(c,d));if(i.length===96&&t){let o=kt.bls12_381.params.G2b,c=pe.ORDER;if(r){if(i.reduce((A,v)=>A!==0?v+1:v,0)>0)throw new Error("Invalid compressed G2 point");return{x:he.ZERO,y:he.ZERO}}let d=a(i,0,s),f=a(i,s,2*s),p=he.create({c0:pe.create(f),c1:pe.create(d)}),m=he.add(he.pow(p,Oo),o),b=he.sqrt(m),l=b.c1===Dt?b.c0*_t/c:b.c1*_t/c?Ro:Dt;return b=n&&l>0?b:he.neg(b),{x:p,y:b}}else if(i.length===192&&!t){if(r){if(i.reduce((p,m)=>p!==0?m+1:m,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:he.ZERO,y:he.ZERO}}let o=a(i,0,s),c=a(i,s,2*s),d=a(i,2*s,3*s),f=a(i,3*s,4*s);return{x:he.fromBigTuple([c,o]),y:he.fromBigTuple([f,d])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(e,t,r)=>{let{BYTES:n,ORDER:i}=pe,s=t.equals(e.ZERO),{x:a,y:o}=t.toAffine();if(r){if(s)return(0,Ae.concatBytes)(Ao,(0,Ae.numberToBytesBE)(Dt,n));let c=!!(o.c1===Dt?o.c0*_t/i:o.c1*_t/i);return(0,Ae.concatBytes)(Bs((0,Ae.numberToBytesBE)(a.c1,n),{compressed:!0,sort:c}),(0,Ae.numberToBytesBE)(a.c0,n))}else{if(s)return(0,Ae.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:d}=he.reim(a),{re:f,im:p}=he.reim(o);return(0,Ae.concatBytes)((0,Ae.numberToBytesBE)(d,n),(0,Ae.numberToBytesBE)(c,n),(0,Ae.numberToBytesBE)(p,n),(0,Ae.numberToBytesBE)(f,n))}},Signature:{fromHex(e){let{infinity:t,sort:r,value:n}=vo((0,Ae.ensureBytes)("signatureHex",e)),i=pe.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let a=(0,Ae.bytesToNumberBE)(n.slice(0,s)),o=(0,Ae.bytesToNumberBE)(n.slice(s));if(t)return kt.bls12_381.G2.ProjectivePoint.ZERO;let c=pe.create(a&pe.MASK),d=pe.create(o),f=he.create({c0:d,c1:c}),p=he.add(he.pow(f,Oo),kt.bls12_381.params.G2b),m=he.sqrt(p);if(!m)throw new Error("Failed to find a square root");let{re:b,im:l}=he.reim(m),A=BigInt(r),v=l>Dt&&l*_t/i!==A,F=l===Dt&&b*_t/i!==A;(v||F)&&(m=he.neg(m));let C=kt.bls12_381.G2.ProjectivePoint.fromAffine({x:f,y:m});return C.assertValidity(),C},toRawBytes(e){return W0(e)},toHex(e){return(0,Ae.bytesToHex)(W0(e))}}},params:{ateLoopSize:vn,r:K0.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:ql,hash:z0.sha256,randomBytes:wx.randomBytes})});var Ml=ee(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.blsVerify=Ps.verify=void 0;var Sx=X0(),kl=$t();function Ix(e,t,r){let n=typeof e=="string"?e:(0,kl.toHex)(e),i=typeof t=="string"?t:(0,kl.toHex)(t),s=typeof r=="string"?r:(0,kl.toHex)(r);return Sx.bls12_381.verifyShortSignature(i,s,n)}Ps.blsVerify=Ix});var So=ee(Jn=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});Jn.decodeTime=Jn.decodeLeb128=void 0;var Q0=Ri(),Bx=e=>(0,Q0.lebDecode)(new Q0.PipeArrayBuffer(e));Jn.decodeLeb128=Bx;var Px=e=>{let t=(0,Jn.decodeLeb128)(e);return new Date(Number(t)/1e6)};Jn.decodeTime=Px});var Fi=ee(Oe=>{"use strict";var Fx=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]}),Ux=Oe&&Oe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),eh=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)&&Fx(t,e,r);return Ux(t,e),t},Vx=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},Cx=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)},Bo;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 th=eh(vs()),qx=wi(),Io=Ns(),Tr=$t(),jl=Ct(),Dx=eh(Ml()),kx=So(),Mx=qs(),on=class extends qx.AgentError{constructor(t){super(`Invalid certificate: ${t}`)}};Oe.CertificateVerificationError=on;var Tt;(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"})(Tt=Oe.NodeType||(Oe.NodeType={}));function Po(e){let t=n=>n.split(`
16
+ `)}return c.encodeValue(d)}));return(0,Fe.concat)(n,i,s,a,o)}W.encode=Vb;function Cb(e,t){let r=new Fe.PipeArrayBuffer(t);if(t.byteLength<Ca.length)throw new Error("Message length smaller than magic number");let n=(0,ce.safeRead)(r,Ca.length),i=new TextDecoder().decode(n);if(i!==Ca)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(b){let l=[],A=Number((0,ce.lebDecode)(b));for(let C=0;C<A;C++){let E=Number((0,ce.slebDecode)(b));switch(E){case-18:case-19:{let H=Number((0,ce.slebDecode)(b));l.push([E,H]);break}case-20:case-21:{let H=[],x=Number((0,ce.lebDecode)(b)),q;for(;x--;){let K=Number((0,ce.lebDecode)(b));if(K>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof q=="number"&&q>=K)throw new Error("field id collision or not sorted");q=K;let G=Number((0,ce.slebDecode)(b));H.push([K,G])}l.push([E,H]);break}case-22:{let H=[],x=Number((0,ce.lebDecode)(b));for(;x--;)H.push(Number((0,ce.slebDecode)(b)));let q=[],K=Number((0,ce.lebDecode)(b));for(;K--;)q.push(Number((0,ce.slebDecode)(b)));let G=[],D=Number((0,ce.lebDecode)(b));for(;D--;)switch(Number((0,ce.lebDecode)(b))){case 1:{G.push("query");break}case 2:{G.push("oneway");break}case 3:{G.push("composite_query");break}default:throw new Error("unknown annotation")}l.push([E,[H,q,G]]);break}case-23:{let H=Number((0,ce.lebDecode)(b)),x=[];for(;H--;){let q=Number((0,ce.lebDecode)(b)),K=new TextDecoder().decode((0,ce.safeRead)(b,q)),G=(0,ce.slebDecode)(b);x.push([K,G])}l.push([E,x]);break}default:throw new Error("Illegal op_code: "+E)}}let v=[],F=Number((0,ce.lebDecode)(b));for(let C=0;C<F;C++)v.push(Number((0,ce.slebDecode)(b)));return[l,v]}let[a,o]=s(r);if(o.length<e.length)throw new Error("Wrong number of return values");let c=a.map(b=>mp());function d(b){if(b<-24)throw new Error("future value not supported");if(b<0)switch(b){case-1:return W.Null;case-2:return W.Bool;case-3:return W.Nat;case-4:return W.Int;case-5:return W.Nat8;case-6:return W.Nat16;case-7:return W.Nat32;case-8:return W.Nat64;case-9:return W.Int8;case-10:return W.Int16;case-11:return W.Int32;case-12:return W.Int64;case-13:return W.Float32;case-14:return W.Float64;case-15:return W.Text;case-16:return W.Reserved;case-17:return W.Empty;case-24:return W.Principal;default:throw new Error("Illegal op_code: "+b)}if(b>=a.length)throw new Error("type index out of range");return c[b]}function f(b){switch(b[0]){case-19:{let l=d(b[1]);return pp(l)}case-18:{let l=d(b[1]);return hp(l)}case-20:{let l={};for(let[F,C]of b[1]){let E=`_${F}_`;l[E]=d(C)}let A=_p(l),v=A.tryAsTuple();return Array.isArray(v)?fp(...v):A}case-21:{let l={};for(let[A,v]of b[1]){let F=`_${A}_`;l[F]=d(v)}return yp(l)}case-22:{let[l,A,v]=b[1];return gp(l.map(F=>d(F)),A.map(F=>d(F)),v)}case-23:{let l={},A=b[1];for(let[v,F]of A){let C=d(F);if(C instanceof gn&&(C=C.getType()),!(C instanceof ys))throw new Error("Illegal service definition: services can only contain functions");l[v]=C}return bp(l)}default:throw new Error("Illegal op_code: "+b[0])}}a.forEach((b,l)=>{if(b[0]===-22){let A=f(b);c[l].fill(A)}}),a.forEach((b,l)=>{if(b[0]!==-22){let A=f(b);c[l].fill(A)}});let p=o.map(b=>d(b)),m=e.map((b,l)=>b.decodeValue(r,p[l]));for(let b=e.length;b<p.length;b++)p[b].decodeValue(r,p[b]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return m}W.decode=Cb;W.Empty=new qa;W.Reserved=new Ni;W.Unknown=new Da;W.Bool=new ka;W.Null=new Ma;W.Text=new ja;W.Int=new La;W.Nat=new Ha;W.Float32=new hs(32);W.Float64=new hs(64);W.Int8=new rn(8);W.Int16=new rn(16);W.Int32=new rn(32);W.Int64=new rn(64);W.Nat8=new Cr(8);W.Nat16=new Cr(16);W.Nat32=new Cr(32);W.Nat64=new Cr(64);W.Principal=new Wa;function fp(...e){return new Ga(e)}W.Tuple=fp;function pp(e){return new Ka(e)}W.Vec=pp;function hp(e){return new Ei(e)}W.Opt=hp;function _p(e){return new _s(e)}W.Record=_p;function yp(e){return new $a(e)}W.Variant=yp;function mp(){return new gn}W.Rec=mp;function gp(e,t,r=[]){return new ys(e,t,r)}W.Func=gp;function bp(e){return new za(e)}W.Service=bp});var Cu=ee(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.VecForm=Rt.OptionForm=Rt.VariantForm=Rt.TupleForm=Rt.RecordForm=Rt.InputForm=Rt.InputBox=void 0;var Iu=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)}};Rt.InputBox=Iu;var bn=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)}};Rt.InputForm=bn;var Bu=class extends bn{constructor(t,r){super(r),this.fields=t,this.ui=r}generateForm(){this.form=this.fields.map(([t,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(t)?n.label=this.ui.labelMap[t]+" ":n.label=t+" ",n})}parse(t){let r={};if(this.fields.forEach(([n,i],s)=>{let a=this.form[s].parse(t);r[n]=a}),!this.form.some(n=>n.isRejected()))return r}};Rt.RecordForm=Bu;var Pu=class extends bn{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}};Rt.TupleForm=Pu;var Fu=class extends bn{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}};Rt.VariantForm=Fu;var Uu=class extends bn{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]}}};Rt.OptionForm=Uu;var Vu=class extends bn{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}};Rt.VecForm=Vu});var xp=ee(Te=>{"use strict";var qb=Te&&Te.__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]}),Db=Te&&Te.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),wp=Te&&Te.__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)&&qb(t,e,r);return Db(t,e),t};Object.defineProperty(Te,"__esModule",{value:!0});Te.renderValue=Te.renderInput=Te.Render=Te.vecForm=Te.optForm=Te.variantForm=Te.tupleForm=Te.recordForm=Te.inputBox=void 0;var Ja=wp(Su()),qu=Ct(),Oi=wp(Cu()),kb={parse:$b},ms={render:ju},Mb=(e,t)=>new Oi.InputBox(e,Object.assign(Object.assign({},kb),t));Te.inputBox=Mb;var jb=(e,t)=>new Oi.RecordForm(e,Object.assign(Object.assign({},ms),t));Te.recordForm=jb;var Lb=(e,t)=>new Oi.TupleForm(e,Object.assign(Object.assign({},ms),t));Te.tupleForm=Lb;var Hb=(e,t)=>new Oi.VariantForm(e,Object.assign(Object.assign({},ms),t));Te.variantForm=Hb;var Kb=(e,t)=>new Oi.OptionForm(e,Object.assign(Object.assign({},ms),t));Te.optForm=Kb;var Gb=(e,t)=>new Oi.VecForm(e,Object.assign(Object.assign({},ms),t));Te.vecForm=Gb;var Ya=class extends Ja.Visitor{visitType(t,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=t.display(),(0,Te.inputBox)(t,{input:n})}visitNull(t,r){return(0,Te.inputBox)(t,{})}visitRecord(t,r,n){let i={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),i={container:a}}let s=(0,Te.recordForm)(r,i);return(0,Te.inputBox)(t,{form:s})}visitTuple(t,r,n){let i={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),i={container:a}}let s=(0,Te.tupleForm)(r,i);return(0,Te.inputBox)(t,{form:s})}visitVariant(t,r,n){let i=document.createElement("select");for(let[o,c]of r){let d=new Option(o);i.add(d)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},a=(0,Te.variantForm)(r,s);return(0,Te.inputBox)(t,{form:a})}visitOpt(t,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Te.optForm)(r,{open:i,event:"change"});return(0,Te.inputBox)(t,{form:s})}visitVec(t,r,n){let i=document.createElement("input");i.type="number",i.min="0",i.max="100",i.style.width="8rem",i.placeholder="len",i.classList.add("open");let s=document.createElement("div");s.classList.add("popup-form");let a=(0,Te.vecForm)(r,{open:i,event:"change",container:s});return(0,Te.inputBox)(t,{form:a})}visitRec(t,r,n){return ju(r)}};Te.Render=Ya;var Du=class extends Ja.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 qu.Principal.fromText(r)}visitService(t,r){return qu.Principal.fromText(r)}visitFunc(t,r){let n=r.split(".",2);return[qu.Principal.fromText(n[0]),n[1]]}},ku=class extends Ja.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 $b(e,t,r){return t.random&&r===""?e.accept(new ku,r):e.accept(new Du,r)}function ju(e){return e.accept(new Ya,null)}Te.renderInput=ju;function Gn(e,t,r){return e.accept(new Mu,{input:t,value:r})}Te.renderValue=Gn;var Mu=class extends Ja.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){Gn(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)),Gn(r,i.form[0],n.value[0])}}visitRecord(t,r,n){let i=n.input.ui.form;r.forEach(([s,a],o)=>{Gn(a,i.form[o],n.value[s])})}visitTuple(t,r,n){let i=n.input.ui.form;r.forEach((s,a)=>{Gn(s,i.form[a],n.value[a])})}visitVariant(t,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([a,o],c)=>{if(a===s[0]){let d=i.ui.open;d.selectedIndex=c,d.dispatchEvent(new Event(i.ui.event)),Gn(o,i.form[0],s[1])}})}visitVec(t,r,n){let i=n.input.ui.form,s=n.value.length,a=i.ui.open;a.value=s,a.dispatchEvent(new Event(i.ui.event)),n.value.forEach((o,c)=>{Gn(r,i.form[c],o)})}}});var Np=ee(Tp=>{"use strict";Object.defineProperty(Tp,"__esModule",{value:!0})});var Ri=ee(ht=>{"use strict";var Ep=ht&&ht.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Wb=ht&&ht.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),vi=ht&&ht.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Ep(t,e,r)},zb=ht&&ht.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&Ep(t,e,r);return Wb(t,e),t};Object.defineProperty(ht,"__esModule",{value:!0});ht.IDL=void 0;vi(xp(),ht);vi(Cu(),ht);ht.IDL=zb(Su());vi(Tu(),ht);vi(Eu(),ht);vi(Fa(),ht);vi(Np(),ht)});var gs=ee((Op,Za)=>{(function(e){"use strict";var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",a=s+"Number primitive has more than 15 significant digits: ",o=1e14,c=14,d=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,m=1e9;function b(x){var q,K,G,D=U.prototype={constructor:U,toString:null,valueOf:null},ae=new U(1),Q=20,ne=4,w=-7,g=21,S=-1e7,R=1e7,I=!1,j=1,Y=0,oe={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},se="0123456789abcdefghijklmnopqrstuvwxyz",z=!0;function U(u,h){var y,P,O,B,M,T,V,L,k=this;if(!(k instanceof U))return new U(u,h);if(h==null){if(u&&u._isBigNumber===!0){k.s=u.s,!u.c||u.e>R?k.c=k.e=null:u.e<S?k.c=[k.e=0]:(k.e=u.e,k.c=u.c.slice());return}if((T=typeof u=="number")&&u*0==0){if(k.s=1/u<0?(u=-u,-1):1,u===~~u){for(B=0,M=u;M>=10;M/=10,B++);B>R?k.c=k.e=null:(k.e=B,k.c=[u]);return}L=String(u)}else{if(!r.test(L=String(u)))return G(k,L,T);k.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(B=L.indexOf("."))>-1&&(L=L.replace(".","")),(M=L.search(/e/i))>0?(B<0&&(B=M),B+=+L.slice(M+1),L=L.substring(0,M)):B<0&&(B=L.length)}else{if(F(h,2,se.length,"Base"),h==10&&z)return k=new U(u),le(k,Q+k.e+1,ne);if(L=String(u),T=typeof u=="number"){if(u*0!=0)return G(k,L,T,h);if(k.s=1/u<0?(L=L.slice(1),-1):1,U.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(a+u)}else k.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(y=se.slice(0,h),B=M=0,V=L.length;M<V;M++)if(y.indexOf(P=L.charAt(M))<0){if(P=="."){if(M>B){B=V;continue}}else if(!O&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){O=!0,M=-1,B=0;continue}return G(k,String(u),T,h)}T=!1,L=K(L,h,10,k.s),(B=L.indexOf("."))>-1?L=L.replace(".",""):B=L.length}for(M=0;L.charCodeAt(M)===48;M++);for(V=L.length;L.charCodeAt(--V)===48;);if(L=L.slice(M,++V)){if(V-=M,T&&U.DEBUG&&V>15&&(u>d||u!==i(u)))throw Error(a+k.s*u);if((B=B-M-1)>R)k.c=k.e=null;else if(B<S)k.c=[k.e=0];else{if(k.e=B,k.c=[],M=(B+1)%c,B<0&&(M+=c),M<V){for(M&&k.c.push(+L.slice(0,M)),V-=c;M<V;)k.c.push(+L.slice(M,M+=c));M=c-(L=L.slice(M)).length}else M-=V;for(;M--;L+="0");k.c.push(+L)}}else k.c=[k.e=0]}U.clone=b,U.ROUND_UP=0,U.ROUND_DOWN=1,U.ROUND_CEIL=2,U.ROUND_FLOOR=3,U.ROUND_HALF_UP=4,U.ROUND_HALF_DOWN=5,U.ROUND_HALF_EVEN=6,U.ROUND_HALF_CEIL=7,U.ROUND_HALF_FLOOR=8,U.EUCLID=9,U.config=U.set=function(u){var h,y;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(h="DECIMAL_PLACES")&&(y=u[h],F(y,0,m,h),Q=y),u.hasOwnProperty(h="ROUNDING_MODE")&&(y=u[h],F(y,0,8,h),ne=y),u.hasOwnProperty(h="EXPONENTIAL_AT")&&(y=u[h],y&&y.pop?(F(y[0],-m,0,h),F(y[1],0,m,h),w=y[0],g=y[1]):(F(y,-m,m,h),w=-(g=y<0?-y:y))),u.hasOwnProperty(h="RANGE"))if(y=u[h],y&&y.pop)F(y[0],-m,-1,h),F(y[1],1,m,h),S=y[0],R=y[1];else if(F(y,-m,m,h),y)S=-(R=y<0?-y:y);else throw Error(s+h+" cannot be zero: "+y);if(u.hasOwnProperty(h="CRYPTO"))if(y=u[h],y===!!y)if(y)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))I=y;else throw I=!y,Error(s+"crypto unavailable");else I=y;else throw Error(s+h+" not true or false: "+y);if(u.hasOwnProperty(h="MODULO_MODE")&&(y=u[h],F(y,0,9,h),j=y),u.hasOwnProperty(h="POW_PRECISION")&&(y=u[h],F(y,0,m,h),Y=y),u.hasOwnProperty(h="FORMAT"))if(y=u[h],typeof y=="object")oe=y;else throw Error(s+h+" not an object: "+y);if(u.hasOwnProperty(h="ALPHABET"))if(y=u[h],typeof y=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(y))z=y.slice(0,10)=="0123456789",se=y;else throw Error(s+h+" invalid: "+y)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:Q,ROUNDING_MODE:ne,EXPONENTIAL_AT:[w,g],RANGE:[S,R],CRYPTO:I,MODULO_MODE:j,POW_PRECISION:Y,FORMAT:oe,ALPHABET:se}},U.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!U.DEBUG)return!0;var h,y,P=u.c,O=u.e,B=u.s;e:if({}.toString.call(P)=="[object Array]"){if((B===1||B===-1)&&O>=-m&&O<=m&&O===i(O)){if(P[0]===0){if(O===0&&P.length===1)return!0;break e}if(h=(O+1)%c,h<1&&(h+=c),String(P[0]).length==h){for(h=0;h<P.length;h++)if(y=P[h],y<0||y>=o||y!==i(y))break e;if(y!==0)return!0}}}else if(P===null&&O===null&&(B===null||B===1||B===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},U.maximum=U.max=function(){return Z(arguments,-1)},U.minimum=U.min=function(){return Z(arguments,1)},U.random=function(){var u=9007199254740992,h=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(y){var P,O,B,M,T,V=0,L=[],k=new U(ae);if(y==null?y=Q:F(y,0,m),M=n(y/c),I)if(crypto.getRandomValues){for(P=crypto.getRandomValues(new Uint32Array(M*=2));V<M;)T=P[V]*131072+(P[V+1]>>>11),T>=9e15?(O=crypto.getRandomValues(new Uint32Array(2)),P[V]=O[0],P[V+1]=O[1]):(L.push(T%1e14),V+=2);V=M/2}else if(crypto.randomBytes){for(P=crypto.randomBytes(M*=7);V<M;)T=(P[V]&31)*281474976710656+P[V+1]*1099511627776+P[V+2]*4294967296+P[V+3]*16777216+(P[V+4]<<16)+(P[V+5]<<8)+P[V+6],T>=9e15?crypto.randomBytes(7).copy(P,V):(L.push(T%1e14),V+=7);V=M/7}else throw I=!1,Error(s+"crypto unavailable");if(!I)for(;V<M;)T=h(),T<9e15&&(L[V++]=T%1e14);for(M=L[--V],y%=c,M&&y&&(T=f[c-y],L[V]=i(M/T)*T);L[V]===0;L.pop(),V--);if(V<0)L=[B=0];else{for(B=-1;L[0]===0;L.splice(0,1),B-=c);for(V=1,T=L[0];T>=10;T/=10,V++);V<c&&(B-=c-V)}return k.e=B,k.c=L,k}}(),U.sum=function(){for(var u=1,h=arguments,y=new U(h[0]);u<h.length;)y=y.plus(h[u++]);return y},K=function(){var u="0123456789";function h(y,P,O,B){for(var M,T=[0],V,L=0,k=y.length;L<k;){for(V=T.length;V--;T[V]*=P);for(T[0]+=B.indexOf(y.charAt(L++)),M=0;M<T.length;M++)T[M]>O-1&&(T[M+1]==null&&(T[M+1]=0),T[M+1]+=T[M]/O|0,T[M]%=O)}return T.reverse()}return function(y,P,O,B,M){var T,V,L,k,J,te,de,ge,Ie=y.indexOf("."),Ue=Q,_e=ne;for(Ie>=0&&(k=Y,Y=0,y=y.replace(".",""),ge=new U(P),te=ge.pow(y.length-Ie),Y=k,ge.c=h(H(A(te.c),te.e,"0"),10,O,u),ge.e=ge.c.length),de=h(y,P,O,M?(T=se,u):(T=u,se)),L=k=de.length;de[--k]==0;de.pop());if(!de[0])return T.charAt(0);if(Ie<0?--L:(te.c=de,te.e=L,te.s=B,te=q(te,ge,Ue,_e,O),de=te.c,J=te.r,L=te.e),V=L+Ue+1,Ie=de[V],k=O/2,J=J||V<0||de[V+1]!=null,J=_e<4?(Ie!=null||J)&&(_e==0||_e==(te.s<0?3:2)):Ie>k||Ie==k&&(_e==4||J||_e==6&&de[V-1]&1||_e==(te.s<0?8:7)),V<1||!de[0])y=J?H(T.charAt(1),-Ue,T.charAt(0)):T.charAt(0);else{if(de.length=V,J)for(--O;++de[--V]>O;)de[V]=0,V||(++L,de=[1].concat(de));for(k=de.length;!de[--k];);for(Ie=0,y="";Ie<=k;y+=T.charAt(de[Ie++]));y=H(y,L,T.charAt(0))}return y}}(),q=function(){function u(P,O,B){var M,T,V,L,k=0,J=P.length,te=O%p,de=O/p|0;for(P=P.slice();J--;)V=P[J]%p,L=P[J]/p|0,M=de*V+L*te,T=te*V+M%p*p+k,k=(T/B|0)+(M/p|0)+de*L,P[J]=T%B;return k&&(P=[k].concat(P)),P}function h(P,O,B,M){var T,V;if(B!=M)V=B>M?1:-1;else for(T=V=0;T<B;T++)if(P[T]!=O[T]){V=P[T]>O[T]?1:-1;break}return V}function y(P,O,B,M){for(var T=0;B--;)P[B]-=T,T=P[B]<O[B]?1:0,P[B]=T*M+P[B]-O[B];for(;!P[0]&&P.length>1;P.splice(0,1));}return function(P,O,B,M,T){var V,L,k,J,te,de,ge,Ie,Ue,_e,fe,Ke,Ht,Ut,Vt,Kt,Be,Ot=P.s==O.s?1:-1,at=P.c,Ge=O.c;if(!at||!at[0]||!Ge||!Ge[0])return new U(!P.s||!O.s||(at?Ge&&at[0]==Ge[0]:!Ge)?NaN:at&&at[0]==0||!Ge?Ot*0:Ot/0);for(Ie=new U(Ot),Ue=Ie.c=[],L=P.e-O.e,Ot=B+L+1,T||(T=o,L=l(P.e/c)-l(O.e/c),Ot=Ot/c|0),k=0;Ge[k]==(at[k]||0);k++);if(Ge[k]>(at[k]||0)&&L--,Ot<0)Ue.push(1),J=!0;else{for(Ut=at.length,Kt=Ge.length,k=0,Ot+=2,te=i(T/(Ge[0]+1)),te>1&&(Ge=u(Ge,te,T),at=u(at,te,T),Kt=Ge.length,Ut=at.length),Ht=Kt,_e=at.slice(0,Kt),fe=_e.length;fe<Kt;_e[fe++]=0);Be=Ge.slice(),Be=[0].concat(Be),Vt=Ge[0],Ge[1]>=T/2&&Vt++;do{if(te=0,V=h(Ge,_e,Kt,fe),V<0){if(Ke=_e[0],Kt!=fe&&(Ke=Ke*T+(_e[1]||0)),te=i(Ke/Vt),te>1)for(te>=T&&(te=T-1),de=u(Ge,te,T),ge=de.length,fe=_e.length;h(de,_e,ge,fe)==1;)te--,y(de,Kt<ge?Be:Ge,ge,T),ge=de.length,V=1;else te==0&&(V=te=1),de=Ge.slice(),ge=de.length;if(ge<fe&&(de=[0].concat(de)),y(_e,de,fe,T),fe=_e.length,V==-1)for(;h(Ge,_e,Kt,fe)<1;)te++,y(_e,Kt<fe?Be:Ge,fe,T),fe=_e.length}else V===0&&(te++,_e=[0]);Ue[k++]=te,_e[0]?_e[fe++]=at[Ht]||0:(_e=[at[Ht]],fe=1)}while((Ht++<Ut||_e[0]!=null)&&Ot--);J=_e[0]!=null,Ue[0]||Ue.splice(0,1)}if(T==o){for(k=1,Ot=Ue[0];Ot>=10;Ot/=10,k++);le(Ie,B+(Ie.e=k+L*c-1)+1,M,J)}else Ie.e=L,Ie.r=+J;return Ie}}();function _(u,h,y,P){var O,B,M,T,V;if(y==null?y=ne:F(y,0,8),!u.c)return u.toString();if(O=u.c[0],M=u.e,h==null)V=A(u.c),V=P==1||P==2&&(M<=w||M>=g)?E(V,M):H(V,M,"0");else if(u=le(new U(u),h,y),B=u.e,V=A(u.c),T=V.length,P==1||P==2&&(h<=B||B<=w)){for(;T<h;V+="0",T++);V=E(V,B)}else if(h-=M,V=H(V,B,"0"),B+1>T){if(--h>0)for(V+=".";h--;V+="0");}else if(h+=B-T,h>0)for(B+1==T&&(V+=".");h--;V+="0");return u.s<0&&O?"-"+V:V}function Z(u,h){for(var y,P,O=1,B=new U(u[0]);O<u.length;O++)P=new U(u[O]),(!P.s||(y=v(B,P))===h||y===0&&B.s===h)&&(B=P);return B}function re(u,h,y){for(var P=1,O=h.length;!h[--O];h.pop());for(O=h[0];O>=10;O/=10,P++);return(y=P+y*c-1)>R?u.c=u.e=null:y<S?u.c=[u.e=0]:(u.e=y,u.c=h),u}G=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,h=/^([^.]+)\.$/,y=/^\.([^.]+)$/,P=/^-?(Infinity|NaN)$/,O=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(B,M,T,V){var L,k=T?M:M.replace(O,"");if(P.test(k))B.s=isNaN(k)?null:k<0?-1:1;else{if(!T&&(k=k.replace(u,function(J,te,de){return L=(de=de.toLowerCase())=="x"?16:de=="b"?2:8,!V||V==L?te:J}),V&&(L=V,k=k.replace(h,"$1").replace(y,"0.$1")),M!=k))return new U(k,L);if(U.DEBUG)throw Error(s+"Not a"+(V?" base "+V:"")+" number: "+M);B.s=null}B.c=B.e=null}}();function le(u,h,y,P){var O,B,M,T,V,L,k,J=u.c,te=f;if(J){e:{for(O=1,T=J[0];T>=10;T/=10,O++);if(B=h-O,B<0)B+=c,M=h,V=J[L=0],k=i(V/te[O-M-1]%10);else if(L=n((B+1)/c),L>=J.length)if(P){for(;J.length<=L;J.push(0));V=k=0,O=1,B%=c,M=B-c+1}else break e;else{for(V=T=J[L],O=1;T>=10;T/=10,O++);B%=c,M=B-c+O,k=M<0?0:i(V/te[O-M-1]%10)}if(P=P||h<0||J[L+1]!=null||(M<0?V:V%te[O-M-1]),P=y<4?(k||P)&&(y==0||y==(u.s<0?3:2)):k>5||k==5&&(y==4||P||y==6&&(B>0?M>0?V/te[O-M]:0:J[L-1])%10&1||y==(u.s<0?8:7)),h<1||!J[0])return J.length=0,P?(h-=u.e+1,J[0]=te[(c-h%c)%c],u.e=-h||0):J[0]=u.e=0,u;if(B==0?(J.length=L,T=1,L--):(J.length=L+1,T=te[c-B],J[L]=M>0?i(V/te[O-M]%te[M])*T:0),P)for(;;)if(L==0){for(B=1,M=J[0];M>=10;M/=10,B++);for(M=J[0]+=T,T=1;M>=10;M/=10,T++);B!=T&&(u.e++,J[0]==o&&(J[0]=1));break}else{if(J[L]+=T,J[L]!=o)break;J[L--]=0,T=1}for(B=J.length;J[--B]===0;J.pop());}u.e>R?u.c=u.e=null:u.e<S&&(u.c=[u.e=0])}return u}function X(u){var h,y=u.e;return y===null?u.toString():(h=A(u.c),h=y<=w||y>=g?E(h,y):H(h,y,"0"),u.s<0?"-"+h:h)}return D.absoluteValue=D.abs=function(){var u=new U(this);return u.s<0&&(u.s=1),u},D.comparedTo=function(u,h){return v(this,new U(u,h))},D.decimalPlaces=D.dp=function(u,h){var y,P,O,B=this;if(u!=null)return F(u,0,m),h==null?h=ne:F(h,0,8),le(new U(B),u+B.e+1,h);if(!(y=B.c))return null;if(P=((O=y.length-1)-l(this.e/c))*c,O=y[O])for(;O%10==0;O/=10,P--);return P<0&&(P=0),P},D.dividedBy=D.div=function(u,h){return q(this,new U(u,h),Q,ne)},D.dividedToIntegerBy=D.idiv=function(u,h){return q(this,new U(u,h),0,1)},D.exponentiatedBy=D.pow=function(u,h){var y,P,O,B,M,T,V,L,k,J=this;if(u=new U(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+X(u));if(h!=null&&(h=new U(h)),T=u.e>14,!J.c||!J.c[0]||J.c[0]==1&&!J.e&&J.c.length==1||!u.c||!u.c[0])return k=new U(Math.pow(+X(J),T?u.s*(2-C(u)):+X(u))),h?k.mod(h):k;if(V=u.s<0,h){if(h.c?!h.c[0]:!h.s)return new U(NaN);P=!V&&J.isInteger()&&h.isInteger(),P&&(J=J.mod(h))}else{if(u.e>9&&(J.e>0||J.e<-1||(J.e==0?J.c[0]>1||T&&J.c[1]>=24e7:J.c[0]<8e13||T&&J.c[0]<=9999975e7)))return B=J.s<0&&C(u)?-0:0,J.e>-1&&(B=1/B),new U(V?1/B:B);Y&&(B=n(Y/c+2))}for(T?(y=new U(.5),V&&(u.s=1),L=C(u)):(O=Math.abs(+X(u)),L=O%2),k=new U(ae);;){if(L){if(k=k.times(J),!k.c)break;B?k.c.length>B&&(k.c.length=B):P&&(k=k.mod(h))}if(O){if(O=i(O/2),O===0)break;L=O%2}else if(u=u.times(y),le(u,u.e+1,1),u.e>14)L=C(u);else{if(O=+X(u),O===0)break;L=O%2}J=J.times(J),B?J.c&&J.c.length>B&&(J.c.length=B):P&&(J=J.mod(h))}return P?k:(V&&(k=ae.div(k)),h?k.mod(h):B?le(k,Y,ne,M):k)},D.integerValue=function(u){var h=new U(this);return u==null?u=ne:F(u,0,8),le(h,h.e+1,u)},D.isEqualTo=D.eq=function(u,h){return v(this,new U(u,h))===0},D.isFinite=function(){return!!this.c},D.isGreaterThan=D.gt=function(u,h){return v(this,new U(u,h))>0},D.isGreaterThanOrEqualTo=D.gte=function(u,h){return(h=v(this,new U(u,h)))===1||h===0},D.isInteger=function(){return!!this.c&&l(this.e/c)>this.c.length-2},D.isLessThan=D.lt=function(u,h){return v(this,new U(u,h))<0},D.isLessThanOrEqualTo=D.lte=function(u,h){return(h=v(this,new U(u,h)))===-1||h===0},D.isNaN=function(){return!this.s},D.isNegative=function(){return this.s<0},D.isPositive=function(){return this.s>0},D.isZero=function(){return!!this.c&&this.c[0]==0},D.minus=function(u,h){var y,P,O,B,M=this,T=M.s;if(u=new U(u,h),h=u.s,!T||!h)return new U(NaN);if(T!=h)return u.s=-h,M.plus(u);var V=M.e/c,L=u.e/c,k=M.c,J=u.c;if(!V||!L){if(!k||!J)return k?(u.s=-h,u):new U(J?M:NaN);if(!k[0]||!J[0])return J[0]?(u.s=-h,u):new U(k[0]?M:ne==3?-0:0)}if(V=l(V),L=l(L),k=k.slice(),T=V-L){for((B=T<0)?(T=-T,O=k):(L=V,O=J),O.reverse(),h=T;h--;O.push(0));O.reverse()}else for(P=(B=(T=k.length)<(h=J.length))?T:h,T=h=0;h<P;h++)if(k[h]!=J[h]){B=k[h]<J[h];break}if(B&&(O=k,k=J,J=O,u.s=-u.s),h=(P=J.length)-(y=k.length),h>0)for(;h--;k[y++]=0);for(h=o-1;P>T;){if(k[--P]<J[P]){for(y=P;y&&!k[--y];k[y]=h);--k[y],k[P]+=o}k[P]-=J[P]}for(;k[0]==0;k.splice(0,1),--L);return k[0]?re(u,k,L):(u.s=ne==3?-1:1,u.c=[u.e=0],u)},D.modulo=D.mod=function(u,h){var y,P,O=this;return u=new U(u,h),!O.c||!u.s||u.c&&!u.c[0]?new U(NaN):!u.c||O.c&&!O.c[0]?new U(O):(j==9?(P=u.s,u.s=1,y=q(O,u,0,3),u.s=P,y.s*=P):y=q(O,u,0,j),u=O.minus(y.times(u)),!u.c[0]&&j==1&&(u.s=O.s),u)},D.multipliedBy=D.times=function(u,h){var y,P,O,B,M,T,V,L,k,J,te,de,ge,Ie,Ue,_e=this,fe=_e.c,Ke=(u=new U(u,h)).c;if(!fe||!Ke||!fe[0]||!Ke[0])return!_e.s||!u.s||fe&&!fe[0]&&!Ke||Ke&&!Ke[0]&&!fe?u.c=u.e=u.s=null:(u.s*=_e.s,!fe||!Ke?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(P=l(_e.e/c)+l(u.e/c),u.s*=_e.s,V=fe.length,J=Ke.length,V<J&&(ge=fe,fe=Ke,Ke=ge,O=V,V=J,J=O),O=V+J,ge=[];O--;ge.push(0));for(Ie=o,Ue=p,O=J;--O>=0;){for(y=0,te=Ke[O]%Ue,de=Ke[O]/Ue|0,M=V,B=O+M;B>O;)L=fe[--M]%Ue,k=fe[M]/Ue|0,T=de*L+k*te,L=te*L+T%Ue*Ue+ge[B]+y,y=(L/Ie|0)+(T/Ue|0)+de*k,ge[B--]=L%Ie;ge[B]=y}return y?++P:ge.splice(0,1),re(u,ge,P)},D.negated=function(){var u=new U(this);return u.s=-u.s||null,u},D.plus=function(u,h){var y,P=this,O=P.s;if(u=new U(u,h),h=u.s,!O||!h)return new U(NaN);if(O!=h)return u.s=-h,P.minus(u);var B=P.e/c,M=u.e/c,T=P.c,V=u.c;if(!B||!M){if(!T||!V)return new U(O/0);if(!T[0]||!V[0])return V[0]?u:new U(T[0]?P:O*0)}if(B=l(B),M=l(M),T=T.slice(),O=B-M){for(O>0?(M=B,y=V):(O=-O,y=T),y.reverse();O--;y.push(0));y.reverse()}for(O=T.length,h=V.length,O-h<0&&(y=V,V=T,T=y,h=O),O=0;h;)O=(T[--h]=T[h]+V[h]+O)/o|0,T[h]=o===T[h]?0:T[h]%o;return O&&(T=[O].concat(T),++M),re(u,T,M)},D.precision=D.sd=function(u,h){var y,P,O,B=this;if(u!=null&&u!==!!u)return F(u,1,m),h==null?h=ne:F(h,0,8),le(new U(B),u,h);if(!(y=B.c))return null;if(O=y.length-1,P=O*c+1,O=y[O]){for(;O%10==0;O/=10,P--);for(O=y[0];O>=10;O/=10,P++);}return u&&B.e+1>P&&(P=B.e+1),P},D.shiftedBy=function(u){return F(u,-d,d),this.times("1e"+u)},D.squareRoot=D.sqrt=function(){var u,h,y,P,O,B=this,M=B.c,T=B.s,V=B.e,L=Q+4,k=new U("0.5");if(T!==1||!M||!M[0])return new U(!T||T<0&&(!M||M[0])?NaN:M?B:1/0);if(T=Math.sqrt(+X(B)),T==0||T==1/0?(h=A(M),(h.length+V)%2==0&&(h+="0"),T=Math.sqrt(+h),V=l((V+1)/2)-(V<0||V%2),T==1/0?h="5e"+V:(h=T.toExponential(),h=h.slice(0,h.indexOf("e")+1)+V),y=new U(h)):y=new U(T+""),y.c[0]){for(V=y.e,T=V+L,T<3&&(T=0);;)if(O=y,y=k.times(O.plus(q(B,O,L,1))),A(O.c).slice(0,T)===(h=A(y.c)).slice(0,T))if(y.e<V&&--T,h=h.slice(T-3,T+1),h=="9999"||!P&&h=="4999"){if(!P&&(le(O,O.e+Q+2,0),O.times(O).eq(B))){y=O;break}L+=4,T+=4,P=1}else{(!+h||!+h.slice(1)&&h.charAt(0)=="5")&&(le(y,y.e+Q+2,1),u=!y.times(y).eq(B));break}}return le(y,y.e+Q+1,ne,u)},D.toExponential=function(u,h){return u!=null&&(F(u,0,m),u++),_(this,u,h,1)},D.toFixed=function(u,h){return u!=null&&(F(u,0,m),u=u+this.e+1),_(this,u,h)},D.toFormat=function(u,h,y){var P,O=this;if(y==null)u!=null&&h&&typeof h=="object"?(y=h,h=null):u&&typeof u=="object"?(y=u,u=h=null):y=oe;else if(typeof y!="object")throw Error(s+"Argument not an object: "+y);if(P=O.toFixed(u,h),O.c){var B,M=P.split("."),T=+y.groupSize,V=+y.secondaryGroupSize,L=y.groupSeparator||"",k=M[0],J=M[1],te=O.s<0,de=te?k.slice(1):k,ge=de.length;if(V&&(B=T,T=V,V=B,ge-=B),T>0&&ge>0){for(B=ge%T||T,k=de.substr(0,B);B<ge;B+=T)k+=L+de.substr(B,T);V>0&&(k+=L+de.slice(B)),te&&(k="-"+k)}P=J?k+(y.decimalSeparator||"")+((V=+y.fractionGroupSize)?J.replace(new RegExp("\\d{"+V+"}\\B","g"),"$&"+(y.fractionGroupSeparator||"")):J):k}return(y.prefix||"")+P+(y.suffix||"")},D.toFraction=function(u){var h,y,P,O,B,M,T,V,L,k,J,te,de=this,ge=de.c;if(u!=null&&(T=new U(u),!T.isInteger()&&(T.c||T.s!==1)||T.lt(ae)))throw Error(s+"Argument "+(T.isInteger()?"out of range: ":"not an integer: ")+X(T));if(!ge)return new U(de);for(h=new U(ae),L=y=new U(ae),P=V=new U(ae),te=A(ge),B=h.e=te.length-de.e-1,h.c[0]=f[(M=B%c)<0?c+M:M],u=!u||T.comparedTo(h)>0?B>0?h:L:T,M=R,R=1/0,T=new U(te),V.c[0]=0;k=q(T,h,0,1),O=y.plus(k.times(P)),O.comparedTo(u)!=1;)y=P,P=O,L=V.plus(k.times(O=L)),V=O,h=T.minus(k.times(O=h)),T=O;return O=q(u.minus(y),P,0,1),V=V.plus(O.times(L)),y=y.plus(O.times(P)),V.s=L.s=de.s,B=B*2,J=q(L,P,B,ne).minus(de).abs().comparedTo(q(V,y,B,ne).minus(de).abs())<1?[L,P]:[V,y],R=M,J},D.toNumber=function(){return+X(this)},D.toPrecision=function(u,h){return u!=null&&F(u,1,m),_(this,u,h,2)},D.toString=function(u){var h,y=this,P=y.s,O=y.e;return O===null?P?(h="Infinity",P<0&&(h="-"+h)):h="NaN":(u==null?h=O<=w||O>=g?E(A(y.c),O):H(A(y.c),O,"0"):u===10&&z?(y=le(new U(y),Q+O+1,ne),h=H(A(y.c),y.e,"0")):(F(u,2,se.length,"Base"),h=K(H(A(y.c),O,"0"),10,u,P,!0)),P<0&&y.c[0]&&(h="-"+h)),h},D.valueOf=D.toJSON=function(){return X(this)},D._isBigNumber=!0,x!=null&&U.set(x),U}function l(x){var q=x|0;return x>0||x===q?q:q-1}function A(x){for(var q,K,G=1,D=x.length,ae=x[0]+"";G<D;){for(q=x[G++]+"",K=c-q.length;K--;q="0"+q);ae+=q}for(D=ae.length;ae.charCodeAt(--D)===48;);return ae.slice(0,D+1||1)}function v(x,q){var K,G,D=x.c,ae=q.c,Q=x.s,ne=q.s,w=x.e,g=q.e;if(!Q||!ne)return null;if(K=D&&!D[0],G=ae&&!ae[0],K||G)return K?G?0:-ne:Q;if(Q!=ne)return Q;if(K=Q<0,G=w==g,!D||!ae)return G?0:!D^K?1:-1;if(!G)return w>g^K?1:-1;for(ne=(w=D.length)<(g=ae.length)?w:g,Q=0;Q<ne;Q++)if(D[Q]!=ae[Q])return D[Q]>ae[Q]^K?1:-1;return w==g?0:w>g^K?1:-1}function F(x,q,K,G){if(x<q||x>K||x!==i(x))throw Error(s+(G||"Argument")+(typeof x=="number"?x<q||x>K?" out of range: ":" not an integer: ":" not a primitive number: ")+String(x))}function C(x){var q=x.c.length-1;return l(x.e/c)==q&&x.c[q]%2!=0}function E(x,q){return(x.length>1?x.charAt(0)+"."+x.slice(1):x)+(q<0?"e":"e+")+q}function H(x,q,K){var G,D;if(q<0){for(D=K+".";++q;D+=K);x=D+x}else if(G=x.length,++q>G){for(D=K,q-=G;--q;D+=K);x+=D}else q<G&&(x=x.slice(0,q)+"."+x.slice(q));return x}t=b(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof Za<"u"&&Za.exports?Za.exports=t:(e||(e=typeof self<"u"&&self?self:window),e.BigNumber=t)})(Op)});var Rp=ee((GO,vp)=>{vp.exports=function(t,r,n){var i=new t.Uint8Array(n),s=r.pushInt,a=r.pushInt32,o=r.pushInt32Neg,c=r.pushInt64,d=r.pushInt64Neg,f=r.pushFloat,p=r.pushFloatSingle,m=r.pushFloatDouble,b=r.pushTrue,l=r.pushFalse,A=r.pushUndefined,v=r.pushNull,F=r.pushInfinity,C=r.pushInfinityNeg,E=r.pushNaN,H=r.pushNaNNeg,x=r.pushArrayStart,q=r.pushArrayStartFixed,K=r.pushArrayStartFixed32,G=r.pushArrayStartFixed64,D=r.pushObjectStart,ae=r.pushObjectStartFixed,Q=r.pushObjectStartFixed32,ne=r.pushObjectStartFixed64,w=r.pushByteString,g=r.pushByteStringStart,S=r.pushUtf8String,R=r.pushUtf8StringStart,I=r.pushSimpleUnassigned,j=r.pushTagStart,Y=r.pushTagStart4,oe=r.pushTagStart8,se=r.pushTagUnassigned,z=r.pushBreak,U=t.Math.pow,_=0,Z=0,re=0;function le(N){for(N=N|0,_=0,Z=N;(_|0)<(Z|0)&&(re=Gm[i[_]&255](i[_]|0)|0,!((re|0)>0)););return re|0}function X(N){return N=N|0,((_|0)+(N|0)|0)<(Z|0)?0:1}function u(N){return N=N|0,i[N|0]<<8|i[N+1|0]|0}function h(N){return N=N|0,i[N|0]<<24|i[N+1|0]<<16|i[N+2|0]<<8|i[N+3|0]|0}function y(N){return N=N|0,s(N|0),_=_+1|0,0}function P(N){return N=N|0,X(1)|0?1:(s(i[_+1|0]|0),_=_+2|0,0)}function O(N){return N=N|0,X(2)|0?1:(s(u(_+1|0)|0),_=_+3|0,0)}function B(N){return N=N|0,X(4)|0?1:(a(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function M(N){return N=N|0,X(8)|0?1:(c(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function T(N){return N=N|0,s(-1-(N-32|0)|0),_=_+1|0,0}function V(N){return N=N|0,X(1)|0?1:(s(-1-(i[_+1|0]|0)|0),_=_+2|0,0)}function L(N){N=N|0;var ve=0;return X(2)|0?1:(ve=u(_+1|0)|0,s(-1-(ve|0)|0),_=_+3|0,0)}function k(N){return N=N|0,X(4)|0?1:(o(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function J(N){return N=N|0,X(8)|0?1:(d(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function te(N){N=N|0;var ve=0,Se=0,Ne=0;return Ne=N-64|0,X(Ne|0)|0?1:(ve=_+1|0,Se=(_+1|0)+(Ne|0)|0,w(ve|0,Se|0),_=Se|0,0)}function de(N){N=N|0;var ve=0,Se=0,Ne=0;return X(1)|0||(Ne=i[_+1|0]|0,ve=_+2|0,Se=(_+2|0)+(Ne|0)|0,X(Ne+1|0)|0)?1:(w(ve|0,Se|0),_=Se|0,0)}function ge(N){N=N|0;var ve=0,Se=0,Ne=0;return X(2)|0||(Ne=u(_+1|0)|0,ve=_+3|0,Se=(_+3|0)+(Ne|0)|0,X(Ne+2|0)|0)?1:(w(ve|0,Se|0),_=Se|0,0)}function Ie(N){N=N|0;var ve=0,Se=0,Ne=0;return X(4)|0||(Ne=h(_+1|0)|0,ve=_+5|0,Se=(_+5|0)+(Ne|0)|0,X(Ne+4|0)|0)?1:(w(ve|0,Se|0),_=Se|0,0)}function Ue(N){return N=N|0,1}function _e(N){return N=N|0,g(),_=_+1|0,0}function fe(N){N=N|0;var ve=0,Se=0,Ne=0;return Ne=N-96|0,X(Ne|0)|0?1:(ve=_+1|0,Se=(_+1|0)+(Ne|0)|0,S(ve|0,Se|0),_=Se|0,0)}function Ke(N){N=N|0;var ve=0,Se=0,Ne=0;return X(1)|0||(Ne=i[_+1|0]|0,ve=_+2|0,Se=(_+2|0)+(Ne|0)|0,X(Ne+1|0)|0)?1:(S(ve|0,Se|0),_=Se|0,0)}function Ht(N){N=N|0;var ve=0,Se=0,Ne=0;return X(2)|0||(Ne=u(_+1|0)|0,ve=_+3|0,Se=(_+3|0)+(Ne|0)|0,X(Ne+2|0)|0)?1:(S(ve|0,Se|0),_=Se|0,0)}function Ut(N){N=N|0;var ve=0,Se=0,Ne=0;return X(4)|0||(Ne=h(_+1|0)|0,ve=_+5|0,Se=(_+5|0)+(Ne|0)|0,X(Ne+4|0)|0)?1:(S(ve|0,Se|0),_=Se|0,0)}function Vt(N){return N=N|0,1}function Kt(N){return N=N|0,R(),_=_+1|0,0}function Be(N){return N=N|0,q(N-128|0),_=_+1|0,0}function Ot(N){return N=N|0,X(1)|0?1:(q(i[_+1|0]|0),_=_+2|0,0)}function at(N){return N=N|0,X(2)|0?1:(q(u(_+1|0)|0),_=_+3|0,0)}function Ge(N){return N=N|0,X(4)|0?1:(K(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Hc(N){return N=N|0,X(8)|0?1:(G(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function Kc(N){return N=N|0,x(),_=_+1|0,0}function $e(N){N=N|0;var ve=0;return ve=N-160|0,X(ve|0)|0?1:(ae(ve|0),_=_+1|0,0)}function Gc(N){return N=N|0,X(1)|0?1:(ae(i[_+1|0]|0),_=_+2|0,0)}function $c(N){return N=N|0,X(2)|0?1:(ae(u(_+1|0)|0),_=_+3|0,0)}function Wc(N){return N=N|0,X(4)|0?1:(Q(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function zc(N){return N=N|0,X(8)|0?1:(ne(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function Yc(N){return N=N|0,D(),_=_+1|0,0}function dn(N){return N=N|0,j(N-192|0|0),_=_+1|0,0}function dO(N){return N=N|0,j(N|0),_=_+1|0,0}function fO(N){return N=N|0,j(N|0),_=_+1|0,0}function pO(N){return N=N|0,j(N|0),_=_+1|0,0}function hO(N){return N=N|0,j(N|0),_=_+1|0,0}function ft(N){return N=N|0,j(N-192|0|0),_=_+1|0,0}function _O(N){return N=N|0,j(N|0),_=_+1|0,0}function yO(N){return N=N|0,j(N|0),_=_+1|0,0}function mO(N){return N=N|0,j(N|0),_=_+1|0,0}function Pm(N){return N=N|0,X(1)|0?1:(j(i[_+1|0]|0),_=_+2|0,0)}function Fm(N){return N=N|0,X(2)|0?1:(j(u(_+1|0)|0),_=_+3|0,0)}function Um(N){return N=N|0,X(4)|0?1:(Y(u(_+1|0)|0,u(_+3|0)|0),_=_+5|0,0)}function Vm(N){return N=N|0,X(8)|0?1:(oe(u(_+1|0)|0,u(_+3|0)|0,u(_+5|0)|0,u(_+7|0)|0),_=_+9|0,0)}function nt(N){return N=N|0,I((N|0)-224|0),_=_+1|0,0}function Cm(N){return N=N|0,l(),_=_+1|0,0}function qm(N){return N=N|0,b(),_=_+1|0,0}function Dm(N){return N=N|0,v(),_=_+1|0,0}function km(N){return N=N|0,A(),_=_+1|0,0}function Mm(N){return N=N|0,X(1)|0?1:(I(i[_+1|0]|0),_=_+2|0,0)}function jm(N){N=N|0;var ve=0,Se=0,Ne=1,ma=0,os=0,gO=0;return X(2)|0?1:(ve=i[_+1|0]|0,Se=i[_+2|0]|0,(ve|0)&128&&(Ne=-1),ma=+(((ve|0)&124)>>2),os=+(((ve|0)&3)<<8|Se),+ma==0?f(+(+Ne*5960464477539063e-23*+os)):+ma==31?+Ne==1?+os>0?E():F():+os>0?H():C():f(+(+Ne*U(2,+(+ma-25))*+(1024+os))),_=_+3|0,0)}function Lm(N){return N=N|0,X(4)|0?1:(p(i[_+1|0]|0,i[_+2|0]|0,i[_+3|0]|0,i[_+4|0]|0),_=_+5|0,0)}function Hm(N){return N=N|0,X(8)|0?1:(m(i[_+1|0]|0,i[_+2|0]|0,i[_+3|0]|0,i[_+4|0]|0,i[_+5|0]|0,i[_+6|0]|0,i[_+7|0]|0,i[_+8|0]|0),_=_+9|0,0)}function Le(N){return N=N|0,1}function Km(N){return N=N|0,z(),_=_+1|0,0}var Gm=[y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,P,O,B,M,Le,Le,Le,Le,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,V,L,k,J,Le,Le,Le,Le,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,Ie,Ue,Le,Le,Le,_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,Ke,Ht,Ut,Vt,Le,Le,Le,Kt,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Ot,at,Ge,Hc,Le,Le,Le,Kc,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,Gc,$c,Wc,zc,Le,Le,Le,Yc,dn,dn,dn,dn,dn,dn,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,Pm,Fm,Um,Vm,Le,Le,Le,Le,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,nt,Cm,qm,Dm,km,Mm,jm,Lm,Hm,Le,Le,Le,Km];return{parse:le}}});var bs=ee(Xt=>{"use strict";var Lu=gs().BigNumber;Xt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Xt.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};Xt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Xt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Xt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Xt.SHIFT32=Math.pow(2,32);Xt.SHIFT16=Math.pow(2,16);Xt.MAX_SAFE_HIGH=2097151;Xt.NEG_ONE=new Lu(-1);Xt.TEN=new Lu(10);Xt.TWO=new Lu(2);Xt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Xa=ee(cr=>{"use strict";var{Buffer:Yb}=fi("buffer"),Sp=gs().BigNumber,Ip=bs(),Ap=Ip.SHIFT32,Jb=Ip.SHIFT16,Zb=2097151;cr.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 Xb(e){return e<16?"0"+e.toString(16):e.toString(16)}cr.arrayBufferToBignumber=function(e){let t=e.byteLength,r="";for(let n=0;n<t;n++)r+=Xb(e[n]);return new Sp(r,16)};cr.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};cr.buildInt32=(e,t)=>e*Jb+t;cr.buildInt64=(e,t,r,n)=>{let i=cr.buildInt32(e,t),s=cr.buildInt32(r,n);return i>Zb?new Sp(i).times(Ap).plus(s):i*Ap+s};cr.writeHalf=function(t,r){let n=Yb.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if((i&8191)!==0)return!1;var s=i>>16&32768;let a=i>>23&255,o=i&8388607;if(a>=113&&a<=142)s+=(a-112<<10)+(o>>13);else if(a>=103&&a<113){if(o&(1<<126-a)-1)return!1;s+=o+8388608>>126-a}else return!1;return t.writeUInt16BE(s,0),!0};cr.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])};cr.isNegativeZero=e=>e===0&&1/e<0;cr.nextPowerOf2=e=>{let t=0;if(e&&!(e&e-1))return e;for(;e!==0;)e>>=1,t+=1;return 1<<t}});var $u=ee((zO,Bp)=>{"use strict";var Gu=bs(),Qb=Gu.MT,Qa=Gu.SIMPLE,Hu=Gu.SYMS,Ku=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,Qb.SIMPLE_FLOAT)}static isSimple(t){return t instanceof e}static decode(t,r){switch(r==null&&(r=!0),t){case Qa.FALSE:return!1;case Qa.TRUE:return!0;case Qa.NULL:return r?null:Hu.NULL;case Qa.UNDEFINED:return r?void 0:Hu.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Hu.BREAK;default:return new e(t)}}};Bp.exports=Ku});var zu=ee((YO,Pp)=>{"use strict";var Wu=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}}};Pp.exports=Wu});var Ju=ee((JO,Up)=>{"use strict";var{URL:ew,URLSearchParams:tw,format:rw}=fi("url"),Fp="http://localhost",Yu=class extends ew{constructor(t="",r=Fp){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()}};Up.exports={URLWithLegacySupport:Yu,URLSearchParams:tw,format:rw,defaultBase:Fp}});var qp=ee((ZO,Cp)=>{"use strict";var{URLWithLegacySupport:Vp,format:nw}=Ju();Cp.exports=(e,t={},r={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new Vp(e)}catch{s={}}let a=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new Vp(e,nw(a)).toString()}});var Zu=ee((XO,Dp)=>{"use strict";var{URLWithLegacySupport:iw,format:sw,URLSearchParams:aw,defaultBase:ow}=Ju(),cw=qp();Dp.exports={URL:iw,URLSearchParams:aw,format:sw,relative:cw,defaultBase:ow}});var Xu=ee((QO,Mp)=>{"use strict";var{Buffer:Ai}=fi("buffer"),kp=Xc(),uw=gs().BigNumber,lw=Rp(),qt=Xa(),ke=bs(),dw=$u(),fw=zu(),{URL:pw}=Zu(),ws=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=Ai.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=>ke.NEG_ONE.minus(qt.arrayBufferToBignumber(r)),4:r=>ke.TEN.pow(r[0]).times(r[1]),5:r=>ke.TWO.pow(r[0]).times(r[1]),32:r=>new pw(r),35:r=>new RegExp(r)},t.tags),this.parser=lw(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 ke.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case ke.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case ke.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case ke.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 ke.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 ke.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===ke.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 ke.PARENT.ARRAY:case ke.PARENT.BYTE_STRING:case ke.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case ke.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=ke.PARENT.MAP,n.ref=qt.buildMap(n.ref)));break;case ke.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case ke.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:ke.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,r){let n=this._knownTags[t];return n?n(r):new fw(t,r)}createMap(t,r){return t}createObject(t,r){return t}createArray(t,r){return t}createByteString(t,r){return Ai.concat(t)}createByteStringFromHeap(t,r){return t===r?Ai.alloc(0):Ai.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 kp.read([t,r,n,i],0,!1,23,4)}createFloatDouble(t,r,n,i,s,a,o,c){return kp.read([t,r,n,i,s,a,o,c],0,!1,52,8)}createInt32Neg(t,r){return-1-qt.buildInt32(t,r)}createInt64Neg(t,r,n,i){let s=qt.buildInt32(t,r),a=qt.buildInt32(n,i);return s>ke.MAX_SAFE_HIGH?ke.NEG_ONE.minus(new uw(s).times(ke.SHIFT32).plus(a)):-1-(s*ke.SHIFT32+a)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(t,r){return t.join("")}createUtf8StringFromHeap(t,r){return t===r?"":this._buffer.toString("utf8",t,r)}createSimpleUnassigned(t){return new dw(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,r){this._push(this.createInt32(t,r))}pushInt64(t,r,n,i){this._push(this.createInt64(t,r,n,i))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,r,n,i){this._push(this.createFloatSingle(t,r,n,i))}pushFloatDouble(t,r,n,i,s,a,o,c){this._push(this.createFloatDouble(t,r,n,i,s,a,o,c))}pushInt32Neg(t,r){this._push(this.createInt32Neg(t,r))}pushInt64Neg(t,r,n,i){this._push(this.createInt64Neg(t,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],ke.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:ke.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:ke.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:ke.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({},ke.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),ke.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=Ai.from(t,r||"hex")),new e({size:t.length}).decodeFirst(t)}static decodeAll(t,r){return typeof t=="string"&&(t=Ai.from(t,r||"hex")),new e({size:t.length}).decodeAll(t)}};ws.decodeFirst=ws.decode;Mp.exports=ws});var Hp=ee((e6,Lp)=>{"use strict";var{Buffer:Qu}=fi("buffer"),hw=Xu(),_w=Xa(),el=class e extends hw{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 _w.isNegativeZero(t)?"-0_1":`${r}_1`}createFloatSingle(t,r,n,i){return`${super.createFloatSingle(t,r,n,i)}_2`}createFloatDouble(t,r,n,i,s,a,o,c){return`${super.createFloatDouble(t,r,n,i,s,a,o,c)}_3`}createByteString(t,r){let n=t.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(t,r){return`h'${Qu.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(jp(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(t,r){let n=super.createObject(t),i=Object.keys(n).reduce(jp(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(t,r){let n=t.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(t,r){return`"${Qu.from(super.createUtf8StringFromHeap(t,r)).toString("utf8")}"`}static diagnose(t,r){return typeof t=="string"&&(t=Qu.from(t,r||"hex")),new e().decodeFirst(t)}};Lp.exports=el;function jp(e){return(t,r)=>t?`${t}, ${r}: ${e[r]}`:`${r}: ${e[r]}`}});var zp=ee((t6,Wp)=>{"use strict";var{Buffer:Dr}=fi("buffer"),{URL:yw}=Zu(),rl=gs().BigNumber,tl=Xa(),ot=bs(),mr=ot.MT,eo=ot.NUMBYTES,Kp=ot.SHIFT32,Gp=ot.SYMS,Si=ot.TAG,mw=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.TWO,gw=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.FOUR,bw=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.EIGHT,ww=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.TRUE,xw=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.FALSE,Tw=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.UNDEFINED,$p=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.NULL,Nw=new rl("0x20000000000000"),Ew=Dr.from("f97e00","hex"),Ow=Dr.from("f9fc00","hex"),vw=Dr.from("f97c00","hex");function Rw(e){return{}.toString.call(e).slice(8,-1)}var nl=class e{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[yw,this._pushUrl],[rl,this._pushBigNumber]];let r=t.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(t,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===t){let a=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,a}return this.semanticTypes.push([t,r]),null}push(t){return t&&(this.result[this.offset]=t,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=t.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(t,r,n){return this.result[this.offset]=t,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(t){return this.pushWrite(t,1,1)}_pushUInt16BE(t){return this.pushWrite(t,2,2)}_pushUInt32BE(t){return this.pushWrite(t,3,4)}_pushDoubleBE(t){return this.pushWrite(t,4,8)}_pushNaN(){return this.push(Ew)}_pushInfinity(t){let r=t<0?Ow:vw;return this.push(r)}_pushFloat(t){let r=Dr.allocUnsafe(2);if(tl.writeHalf(r,t)&&tl.parseHalf(r)===t)return this._pushUInt8(mw)&&this.push(r);let n=Dr.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(gw)&&this.push(n):this._pushUInt8(bw)&&this._pushDoubleBE(t)}_pushInt(t,r,n){let i=r<<5;return t<24?this._pushUInt8(i|t):t<=255?this._pushUInt8(i|eo.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|eo.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|eo.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|eo.EIGHT)&&this._pushUInt32BE(Math.floor(t/Kp))&&this._pushUInt32BE(t%Kp):r===mr.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,mr.NEG_INT,t):this._pushInt(t,mr.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=Dr.byteLength(t,"utf8");return this._pushInt(r,mr.UTF8_STRING)&&this.pushWrite(t,5,r)}_pushBoolean(t){return this._pushUInt8(t?ww:xw)}_pushUndefined(t){return this._pushUInt8(Tw)}_pushArray(t,r){let n=r.length;if(!t._pushInt(n,mr.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,mr.TAG)}_pushDate(t,r){return t._pushTag(Si.DATE_EPOCH)&&t.pushAny(Math.round(r/1e3))}_pushBuffer(t,r){return t._pushInt(r.length,mr.BYTE_STRING)&&t.push(r)}_pushNoFilter(t,r){return t._pushBuffer(t,r.slice())}_pushRegexp(t,r){return t._pushTag(Si.REGEXP)&&t.pushAny(r.source)}_pushSet(t,r){if(!t._pushInt(r.size,mr.ARRAY))return!1;for(let n of r)if(!t.pushAny(n))return!1;return!0}_pushUrl(t,r){return t._pushTag(Si.URI)&&t.pushAny(r.format())}_pushBigint(t){let r=Si.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),r=Si.NEG_BIGINT);let n=t.toString(16);n.length%2&&(n="0"+n);let i=Dr.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(Si.DECIMAL_FRAC)&&t._pushInt(2,mr.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new rl(10).pow(n));return t._pushIntNum(-n)?i.abs().isLessThan(Nw)?t._pushIntNum(i.toNumber()):t._pushBigint(i):!1}_pushMap(t,r){return t._pushInt(r.size,mr.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(t){if(!t)return this._pushUInt8($p);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(t instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(t,this,t);var i=t.encodeCBOR;if(typeof i=="function")return i.call(t,this);var s=Object.keys(t),a=s.length;return this._pushInt(a,mr.MAP)?this._pushRawMap(a,s.map(o=>[o,t[o]])):!1}_pushRawMap(t,r){r=r.map(function(i){return i[0]=e.encode(i[0]),i}).sort(tl.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=Rw(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,Dr.isBuffer(t)?t:Dr.from(t));case"Null":return this._pushUInt8($p);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 Gp.NULL:return this._pushObject(null);case Gp.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+t.toString())}default:throw new Error("Unknown type: "+typeof t+", "+(t?t.toString():""))}}finalize(){if(this.offset===0)return null;for(var t=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,a=0;a<i;a++)s+=r[a];var o=Dr.allocUnsafe(s),c=0,d=0;for(a=0;a<i;a++){switch(d=r[a],n[a]){case 0:t[a].copy(o,c);break;case 1:o.writeUInt8(t[a],c,!0);break;case 2:o.writeUInt16BE(t[a],c,!0);break;case 3:o.writeUInt32BE(t[a],c,!0);break;case 4:o.writeDoubleBE(t[a],c,!0);break;case 5:o.write(t[a],c,d,"utf8");break;default:throw new Error("unkown method")}c+=d}var f=o;return this._reset(),f}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(t){let r=new e;if(!r.pushAny(t))throw new Error("Failed to encode input");return r.finalize()}};Wp.exports=nl});var to=ee(ct=>{"use strict";ct.Diagnose=Hp();ct.Decoder=Xu();ct.Encoder=zp();ct.Simple=$u();ct.Tagged=zu();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 Ns=ee(ur=>{"use strict";var Aw=ur&&ur.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ur,"__esModule",{value:!0});ur.hashOfMap=ur.requestIdOf=ur.hashValue=ur.hash=void 0;var Yp=Ri(),Sw=Aw(to()),Iw=Ra(),xs=$t();function wn(e){return(0,xs.uint8ToBuf)(Iw.sha256.create().update(new Uint8Array(e)).digest())}ur.hash=wn;function Ts(e){if(e instanceof Sw.default.Tagged)return Ts(e.value);if(typeof e=="string")return Jp(e);if(typeof e=="number")return wn((0,Yp.lebEncode)(e));if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return wn(e);if(Array.isArray(e)){let t=e.map(Ts);return wn((0,xs.concat)(...t))}else{if(e&&typeof e=="object"&&e._isPrincipal)return wn(e.toUint8Array());if(typeof e=="object"&&e!==null&&typeof e.toHash=="function")return Ts(e.toHash());if(typeof e=="object")return il(e);if(typeof e=="bigint")return wn((0,Yp.lebEncode)(e))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${e}`),{value:e})}ur.hashValue=Ts;var Jp=e=>{let t=new TextEncoder().encode(e);return wn(t)};function Bw(e){return il(e)}ur.requestIdOf=Bw;function il(e){let n=Object.entries(e).filter(([,a])=>a!==void 0).map(([a,o])=>{let c=Jp(a),d=Ts(o);return[c,d]}).sort(([a],[o])=>(0,xs.compare)(a,o)),i=(0,xs.concat)(...n.map(a=>(0,xs.concat)(...a)));return wn(i)}ur.hashOfMap=il});var ol=ee(kr=>{"use strict";var Pw=kr&&kr.__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(kr,"__esModule",{value:!0});kr.createIdentityDescriptor=kr.AnonymousIdentity=kr.SignIdentity=void 0;var Zp=Ct(),Fw=Ns(),Xp=$t(),Uw=new TextEncoder().encode(`
17
+ ic-request`),sl=class{getPrincipal(){return this._principal||(this._principal=Zp.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:r}=t,n=Pw(t,["body"]),i=(0,Fw.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,Xp.concat)(Uw,i))}})}};kr.SignIdentity=sl;var al=class{getPrincipal(){return Zp.Principal.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}};kr.AnonymousIdentity=al;function Vw(e){return"getPublicKey"in e?{type:"PublicKeyIdentity",publicKey:(0,Xp.toHex)(e.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}kr.createIdentityDescriptor=Vw});var ll=ee(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});var Cw=9007199254740992;function nn(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 gr(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 ro(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 gr(e,r,t.toString(16))}}function Qp(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 nn(new Uint8Array(ro(3,e.length)),new Uint8Array(t))}function qw(e,t){if(e==14277111)return nn(new Uint8Array([217,217,247]),t);if(e<24)return nn(new Uint8Array([192+e]),t);{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27,n=2**(r-24),i=e.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(a=>parseInt(a,16)));return new Uint8Array(s).buffer}}We.tagged=qw;function Es(e){return new Uint8Array(e).buffer}We.raw=Es;function cl(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}We.uSmall=cl;function e0(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),gr(0,24,e)}We.u8=e0;function t0(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),gr(0,25,e)}We.u16=t0;function r0(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),gr(0,26,e)}We.u32=r0;function ul(e,t){if(typeof e=="string"&&t==16){if(e.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return gr(0,27,e)}if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),Cw),e=e.toString(16),gr(0,27,e)}We.u64=ul;function n0(e){if(isNaN(e))throw new RangeError("Invalid number.");if(e===0)return cl(0);e=Math.min(Math.max(0,-e),24)-1;let t=[32+e];return new Uint8Array(t).buffer}We.iSmall=n0;function i0(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),gr(1,24,e)}We.i8=i0;function s0(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),gr(1,25,e)}We.i16=s0;function a0(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),gr(1,26,e)}We.i32=a0;function o0(e,t){if(typeof e=="string"&&t==16){if(e.startsWith("-")?e=e.slice(1):e="0",e.match(/[^0-9a-fA-F]/)||e.length>16)throw new RangeError("Invalid number.");let r=!1,n=e.split("").reduceRight((i,s)=>{if(r)return s+i;let a=parseInt(s,16)-1;return a>=0?(r=!0,a.toString(16)+i):"f"+i},"");return r?gr(1,27,n):ul(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),gr(1,27,e)}We.i64=o0;function Dw(e){return e>=0?e<24?cl(e):e<=255?e0(e):e<=65535?t0(e):e<=4294967295?r0(e):ul(e):e>=-24?n0(e):e>=-255?i0(e):e>=-65535?s0(e):e>=-4294967295?a0(e):o0(e)}We.number=Dw;function kw(e){return nn(ro(2,e.byteLength),e)}We.bytes=kw;function Mw(e){return Qp(e)}We.string=Mw;function jw(e){return nn(ro(4,e.length),...e)}We.array=jw;function Lw(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))),nn(ro(5,e.size),...r.map(([n,i])=>nn(Qp(n),i)))}We.map=Lw;function Hw(e){let t=new Float32Array([e]);return nn(new Uint8Array([250]),new Uint8Array(t.buffer))}We.singleFloat=Hw;function Kw(e){let t=new Float64Array([e]);return nn(new Uint8Array([251]),new Uint8Array(t.buffer))}We.doubleFloat=Kw;function Gw(e){return e?c0():u0()}We.bool=Gw;function c0(){return Es(new Uint8Array([245]))}We.true_=c0;function u0(){return Es(new Uint8Array([244]))}We.false_=u0;function $w(){return Es(new Uint8Array([246]))}We.null_=$w;function Ww(){return Es(new Uint8Array([247]))}We.undefined_=Ww});var l0=ee(xn=>{"use strict";var zw=xn&&xn.__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(xn,"__esModule",{value:!0});var br=zw(ll()),Yw=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],no=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 br.undefined_();case"boolean":return br.bool(t);case"number":return Math.floor(t)===t?br.number(t):br.doubleFloat(t);case"string":return br.string(t);case"object":if(t===null)return br.null_();if(Array.isArray(t))return br.array(t.map(r=>this._serializer.serializeValue(r)));if(Yw.find(r=>t instanceof r))return br.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 br.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 br.map(r,this._stable)}default:throw new Error("Invalid value.")}}};xn.JsonDefaultCborEncoder=no;var io=class{constructor(){this.name="cborEncoder",this.priority=-90}match(t){return typeof t=="object"&&typeof t.toCBOR=="function"}encode(t){return t.toCBOR()}};xn.ToCborEncoder=io;var so=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let r=new this;return r.addEncoder(new no(r,t)),r.addEncoder(new io),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)}};xn.CborSerializer=so;var dl=class extends so{serialize(t){return br.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};xn.SelfDescribeCborSerializer=dl});var Os=ee($n=>{"use strict";function Jw(e){for(var t in e)$n.hasOwnProperty(t)||($n[t]=e[t])}var Zw=$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});Jw(l0());var Xw=Zw(ll());$n.value=Xw});var vs=ee(bt=>{"use strict";var Qw=bt&&bt.__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]}),e1=bt&&bt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),t1=bt&&bt.__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)&&Qw(t,e,r);return e1(t,e),t},r1=bt&&bt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(bt,"__esModule",{value:!0});bt.decode=bt.encode=bt.CborTag=void 0;var n1=r1(to()),Ii=t1(Os()),i1=Os(),ao=$t(),fl=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return Ii.value.bytes(t.toUint8Array())}},pl=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return Ii.value.bytes(new Uint8Array(t))}},hl=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?Ii.value.tagged(2,Ii.value.bytes((0,ao.fromHex)(t.toString(16)))):Ii.value.tagged(3,Ii.value.bytes((0,ao.fromHex)((BigInt("-1")*t).toString(16))))}},oo=i1.SelfDescribeCborSerializer.withDefaultEncoders(!0);oo.addEncoder(new fl);oo.addEncoder(new pl);oo.addEncoder(new hl);var f0;(function(e){e[e.Uint64LittleEndian=71]="Uint64LittleEndian",e[e.Semantic=55799]="Semantic"})(f0=bt.CborTag||(bt.CborTag={}));function s1(e){return oo.serialize(e)}bt.encode=s1;function d0(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 _l=class extends n1.default.Decoder{createByteString(t){return(0,ao.concat)(...t)}createByteStringFromHeap(t,r){return t===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(t,r))}};function a1(e){let t=new Uint8Array(e),r=new _l({size:t.byteLength,tags:{2:n=>d0(n),3:n=>-d0(n),[f0.Semantic]:n=>n}});try{return r.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,ao.toHex)(t)}`)}}bt.decode=a1});var yl=ee(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.randomNumber=void 0;var o1=()=>{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)};co.randomNumber=o1});var Rs=ee(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.makeNonce=Wn.SubmitRequestType=void 0;var uo=yl(),c1;(function(e){e.Call="call"})(c1=Wn.SubmitRequestType||(Wn.SubmitRequestType={}));function u1(){let e=new ArrayBuffer(16),t=new DataView(e),r=(0,uo.randomNumber)(),n=(0,uo.randomNumber)(),i=(0,uo.randomNumber)(),s=(0,uo.randomNumber)();return t.setUint32(0,r),t.setUint32(4,n),t.setUint32(8,i),t.setUint32(12,s),e}Wn.makeNonce=u1});var fo=ee(At=>{"use strict";var l1=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]}),d1=At&&At.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),f1=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)&&l1(t,e,r);return d1(t,e),t};Object.defineProperty(At,"__esModule",{value:!0});At.httpHeadersTransform=At.makeExpiryTransform=At.makeNonceTransform=At.Expiry=void 0;var p1=Ri(),h1=f1(Os()),_1=Rs(),p0=BigInt(1e6),y1=60*1e3,lo=class{constructor(t){if(t<90*1e3){let o=BigInt(Date.now()+t)*p0/BigInt(1e9);this._value=o*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+t-y1))*p0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return h1.value.u64(this._value.toString(16),16)}toHash(){return(0,p1.lebEncode)(this._value)}};At.Expiry=lo;function m1(e=_1.makeNonce){return async t=>{let r=t.request.headers;t.request.headers=r,t.endpoint==="call"&&(t.body.nonce=e())}}At.makeNonceTransform=m1;function g1(e){return async t=>{t.body.ingress_expiry=new lo(e)}}At.makeExpiryTransform=g1;function b1(e){let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t}At.httpHeadersTransform=b1});var ho=ee(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.AgentReadStateError=Mr.AgentQueryError=Mr.AgentCallError=Mr.AgentHTTPResponseError=void 0;var po=wi(),ml=class extends po.AgentError{constructor(t,r){super(t),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Mr.AgentHTTPResponseError=ml;var gl=class extends po.AgentError{constructor(t,r,n,i,s,a){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=a,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}};Mr.AgentCallError=gl;var bl=class extends po.AgentError{constructor(t,r,n,i,s,a){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=a,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}};Mr.AgentQueryError=bl;var wl=class extends po.AgentError{constructor(t,r,n,i,s,a){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=a,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};Mr.AgentReadStateError=wl});var Qt=ee(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.notImplemented=Ve.bitMask=void 0;Ve.isBytes=yo;Ve.abytes=mo;Ve.abool=x1;Ve.bytesToHex=El;Ve.numberToHexUnpadded=y0;Ve.hexToNumber=Ol;Ve.hexToBytes=go;Ve.bytesToNumberBE=N1;Ve.bytesToNumberLE=E1;Ve.numberToBytesBE=m0;Ve.numberToBytesLE=O1;Ve.numberToVarBytesBE=v1;Ve.ensureBytes=R1;Ve.concatBytes=g0;Ve.equalBytes=A1;Ve.utf8ToBytes=S1;Ve.inRange=b0;Ve.aInRange=I1;Ve.bitLen=B1;Ve.bitGet=P1;Ve.bitSet=F1;Ve.createHmacDrbg=V1;Ve.validateObject=q1;Ve.memoized=k1;var Nl=BigInt(0),_o=BigInt(1),w1=BigInt(2);function yo(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function mo(e){if(!yo(e))throw new Error("Uint8Array expected")}function x1(e,t){if(typeof t!="boolean")throw new Error(`${e} must be valid boolean, got "${t}".`)}var T1=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function El(e){mo(e);let t="";for(let r=0;r<e.length;r++)t+=T1[e[r]];return t}function y0(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function Ol(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}var sn={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function h0(e){if(e>=sn._0&&e<=sn._9)return e-sn._0;if(e>=sn._A&&e<=sn._F)return e-(sn._A-10);if(e>=sn._a&&e<=sn._f)return e-(sn._a-10)}function go(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let a=h0(e.charCodeAt(s)),o=h0(e.charCodeAt(s+1));if(a===void 0||o===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=a*16+o}return n}function N1(e){return Ol(El(e))}function E1(e){return mo(e),Ol(El(Uint8Array.from(e).reverse()))}function m0(e,t){return go(e.toString(16).padStart(t*2,"0"))}function O1(e,t){return m0(e,t).reverse()}function v1(e){return go(y0(e))}function R1(e,t,r){let n;if(typeof t=="string")try{n=go(t)}catch(s){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`)}else if(yo(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 g0(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];mo(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 A1(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 S1(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}var xl=e=>typeof e=="bigint"&&Nl<=e;function b0(e,t,r){return xl(e)&&xl(t)&&xl(r)&&t<=e&&e<r}function I1(e,t,r,n){if(!b0(t,r,n))throw new Error(`expected valid ${e}: ${r} <= n < ${n}, got ${typeof t} ${t}`)}function B1(e){let t;for(t=0;e>Nl;e>>=_o,t+=1);return t}function P1(e,t){return e>>BigInt(t)&_o}function F1(e,t,r){return e|(r?_o:Nl)<<BigInt(t)}var U1=e=>(w1<<BigInt(e-1))-_o;Ve.bitMask=U1;var Tl=e=>new Uint8Array(e),_0=e=>Uint8Array.from(e);function V1(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=Tl(e),i=Tl(e),s=0,a=()=>{n.fill(1),i.fill(0),s=0},o=(...p)=>r(i,n,...p),c=(p=Tl())=>{i=o(_0([0]),p),n=o(),p.length!==0&&(i=o(_0([1]),p),n=o())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let p=0,m=[];for(;p<t;){n=o();let b=n.slice();m.push(b),p+=n.length}return g0(...m)};return(p,m)=>{a(),c(p);let b;for(;!(b=m(d()));)c();return a(),b}}var C1={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"||yo(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 q1(e,t,r={}){let n=(i,s,a)=>{let o=C1[s];if(typeof o!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=e[i];if(!(a&&c===void 0)&&!o(c,e))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(t))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return e}var D1=()=>{throw new Error("not implemented")};Ve.notImplemented=D1;function k1(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 jr=ee(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.isNegativeLE=void 0;Je.mod=er;Je.pow=T0;Je.pow2=H1;Je.invert=bo;Je.tonelliShanks=N0;Je.FpSqrt=E0;Je.validateField=$1;Je.FpPow=O0;Je.FpInvertBatch=v0;Je.FpDiv=W1;Je.FpLegendre=R0;Je.FpIsSquare=z1;Je.nLength=Rl;Je.Field=Y1;Je.FpSqrtOdd=J1;Je.FpSqrtEven=Z1;Je.hashToPrivateScalar=X1;Je.getFieldBytesLength=Al;Je.getMinHashLength=A0;Je.mapHashToField=Q1;var tr=Qt(),ut=BigInt(0),He=BigInt(1),Tn=BigInt(2),M1=BigInt(3),vl=BigInt(4),w0=BigInt(5),x0=BigInt(8),j1=BigInt(9),L1=BigInt(16);function er(e,t){let r=e%t;return r>=ut?r:t+r}function T0(e,t,r){if(r<=ut||t<ut)throw new Error("Expected power/modulo > 0");if(r===He)return ut;let n=He;for(;t>ut;)t&He&&(n=n*e%r),e=e*e%r,t>>=He;return n}function H1(e,t,r){let n=e;for(;t-- >ut;)n*=n,n%=r;return n}function bo(e,t){if(e===ut||t<=ut)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=er(e,t),n=t,i=ut,s=He,a=He,o=ut;for(;r!==ut;){let d=n/r,f=n%r,p=i-a*d,m=s-o*d;n=r,r=f,i=a,s=o,a=p,o=m}if(n!==He)throw new Error("invert: does not exist");return er(i,t)}function N0(e){let t=(e-He)/Tn,r,n,i;for(r=e-He,n=0;r%Tn===ut;r/=Tn,n++);for(i=Tn;i<e&&T0(i,t,e)!==e-He;i++);if(n===1){let a=(e+He)/vl;return function(c,d){let f=c.pow(d,a);if(!c.eql(c.sqr(f),d))throw new Error("Cannot find square root");return f}}let s=(r+He)/Tn;return function(o,c){if(o.pow(c,t)===o.neg(o.ONE))throw new Error("Cannot find square root");let d=n,f=o.pow(o.mul(o.ONE,i),r),p=o.pow(c,s),m=o.pow(c,r);for(;!o.eql(m,o.ONE);){if(o.eql(m,o.ZERO))return o.ZERO;let b=1;for(let A=o.sqr(m);b<d&&!o.eql(A,o.ONE);b++)A=o.sqr(A);let l=o.pow(f,He<<BigInt(d-b-1));f=o.sqr(l),p=o.mul(p,l),m=o.mul(m,f),d=b}return p}}function E0(e){if(e%vl===M1){let t=(e+He)/vl;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%x0===w0){let t=(e-w0)/x0;return function(n,i){let s=n.mul(i,Tn),a=n.pow(s,t),o=n.mul(i,a),c=n.mul(n.mul(o,Tn),a),d=n.mul(o,n.sub(c,n.ONE));if(!n.eql(n.sqr(d),i))throw new Error("Cannot find square root");return d}}return e%L1,N0(e)}var K1=(e,t)=>(er(e,t)&He)===He;Je.isNegativeLE=K1;var G1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function $1(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=G1.reduce((n,i)=>(n[i]="function",n),t);return(0,tr.validateObject)(e,r)}function O0(e,t,r){if(r<ut)throw new Error("Expected power > 0");if(r===ut)return e.ONE;if(r===He)return t;let n=e.ONE,i=t;for(;r>ut;)r&He&&(n=e.mul(n,i)),i=e.sqr(i),r>>=He;return n}function v0(e,t){let r=new Array(t.length),n=t.reduce((s,a,o)=>e.is0(a)?s:(r[o]=s,e.mul(s,a)),e.ONE),i=e.inv(n);return t.reduceRight((s,a,o)=>e.is0(a)?s:(r[o]=e.mul(s,r[o]),e.mul(s,a)),i),r}function W1(e,t,r){return e.mul(t,typeof r=="bigint"?bo(r,e.ORDER):e.inv(r))}function R0(e){let t=(e-He)/Tn;return(r,n)=>r.pow(n,t)}function z1(e){let t=R0(e.ORDER);return r=>{let n=t(e,r);return e.eql(n,e.ZERO)||e.eql(n,e.ONE)}}function Rl(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Y1(e,t,r=!1,n={}){if(e<=ut)throw new Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:s}=Rl(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let a=E0(e),o=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:(0,tr.bitMask)(i),ZERO:ut,ONE:He,create:c=>er(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&He)===He,neg:c=>er(-c,e),eql:(c,d)=>c===d,sqr:c=>er(c*c,e),add:(c,d)=>er(c+d,e),sub:(c,d)=>er(c-d,e),mul:(c,d)=>er(c*d,e),pow:(c,d)=>O0(o,c,d),div:(c,d)=>er(c*bo(d,e),e),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>bo(c,e),sqrt:n.sqrt||(c=>a(o,c)),invertBatch:c=>v0(o,c),cmov:(c,d,f)=>f?d:c,toBytes:c=>r?(0,tr.numberToBytesLE)(c,s):(0,tr.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,tr.bytesToNumberLE)(c):(0,tr.bytesToNumberBE)(c)}});return Object.freeze(o)}function J1(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 Z1(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 X1(e,t,r=!1){e=(0,tr.ensureBytes)("privateHash",e);let n=e.length,i=Rl(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,tr.bytesToNumberLE)(e):(0,tr.bytesToNumberBE)(e);return er(s,t-He)+He}function Al(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function A0(e){let t=Al(e);return t+Math.ceil(t/2)}function Q1(e,t,r=!1){let n=e.length,i=Al(t),s=A0(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let a=r?(0,tr.bytesToNumberBE)(e):(0,tr.bytesToNumberLE)(e),o=er(a,t-He)+He;return r?(0,tr.numberToBytesLE)(o,i):(0,tr.numberToBytesBE)(o,i)}});var wo=ee(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.expand_message_xmd=S0;zn.expand_message_xof=I0;zn.hash_to_field=Sl;zn.isogenyMap=nx;zn.createHasher=ix;var ex=jr(),St=Qt(),tx=St.bytesToNumberBE;function Nn(e,t){if(As(e),As(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 rx(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 As(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function S0(e,t,r,n){(0,St.abytes)(e),(0,St.abytes)(t),As(r),t.length>255&&(t=n((0,St.concatBytes)((0,St.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:s}=n,a=Math.ceil(r/i);if(r>65535||a>255)throw new Error("expand_message_xmd: invalid lenInBytes");let o=(0,St.concatBytes)(t,Nn(t.length,1)),c=Nn(0,s),d=Nn(r,2),f=new Array(a),p=n((0,St.concatBytes)(c,e,d,Nn(0,1),o));f[0]=n((0,St.concatBytes)(p,Nn(1,1),o));for(let b=1;b<=a;b++){let l=[rx(p,f[b-1]),Nn(b+1,1),o];f[b]=n((0,St.concatBytes)(...l))}return(0,St.concatBytes)(...f).slice(0,r)}function I0(e,t,r,n,i){if((0,St.abytes)(e),(0,St.abytes)(t),As(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(Nn(r,2)).update(t).update(Nn(t.length,1)).digest()}function Sl(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:a,expand:o,DST:c}=r;(0,St.abytes)(e),As(t);let d=typeof c=="string"?(0,St.utf8ToBytes)(c):c,f=n.toString(2).length,p=Math.ceil((f+i)/8),m=t*s*p,b;if(o==="xmd")b=S0(e,d,m,a);else if(o==="xof")b=I0(e,d,m,i,a);else if(o==="_internal_pass")b=e;else throw new Error('expand must be "xmd" or "xof"');let l=new Array(t);for(let A=0;A<t;A++){let v=new Array(s);for(let F=0;F<s;F++){let C=p*(F+A*s),E=b.subarray(C,C+p);v[F]=(0,ex.mod)(tx(E),n)}l[A]=v}return l}function nx(e,t){let r=t.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,a,o,c]=r.map(d=>d.reduce((f,p)=>e.add(e.mul(f,n),p)));return n=e.div(s,a),i=e.mul(i,e.div(o,c)),{x:n,y:i}}}function ix(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=Sl(n,2,{...r,DST:r.DST,...i}),a=e.fromAffine(t(s[0])),o=e.fromAffine(t(s[1])),c=a.add(o).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=Sl(n,1,{...r,DST:r.encodeDST,...i}),a=e.fromAffine(t(s[0])).clearCofactor();return a.assertValidity(),a},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=e.fromAffine(t(n)).clearCofactor();return i.assertValidity(),i}}}});var Pl=ee(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.wNAF=ax;Ss.pippenger=ox;Ss.validateBasic=cx;var B0=jr(),F0=Qt(),sx=BigInt(0),Il=BigInt(1),Bl=new WeakMap,P0=new WeakMap;function ax(e,t){let r=(s,a)=>{let o=a.negate();return s?o:a},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},i=s=>{n(s);let a=Math.ceil(t/s)+1,o=2**(s-1);return{windows:a,windowSize:o}};return{constTimeNegate:r,unsafeLadder(s,a){let o=e.ZERO,c=s;for(;a>sx;)a&Il&&(o=o.add(c)),c=c.double(),a>>=Il;return o},precomputeWindow(s,a){let{windows:o,windowSize:c}=i(a),d=[],f=s,p=f;for(let m=0;m<o;m++){p=f,d.push(p);for(let b=1;b<c;b++)p=p.add(f),d.push(p);f=p.double()}return d},wNAF(s,a,o){let{windows:c,windowSize:d}=i(s),f=e.ZERO,p=e.BASE,m=BigInt(2**s-1),b=2**s,l=BigInt(s);for(let A=0;A<c;A++){let v=A*d,F=Number(o&m);o>>=l,F>d&&(F-=b,o+=Il);let C=v,E=v+Math.abs(F)-1,H=A%2!==0,x=F<0;F===0?p=p.add(r(H,a[C])):f=f.add(r(x,a[E]))}return{p:f,f:p}},wNAFCached(s,a,o){let c=P0.get(s)||1,d=Bl.get(s);return d||(d=this.precomputeWindow(s,c),c!==1&&Bl.set(s,o(d))),this.wNAF(c,d,a)},setWindowSize(s,a){n(a),P0.set(s,a),Bl.delete(s)}}}function ox(e,t,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((f,p)=>{if(!t.isValid(f))throw new Error(`wrong scalar at index ${p}`)}),r.forEach((f,p)=>{if(!(f instanceof e))throw new Error(`wrong point at index ${p}`)});let i=(0,F0.bitLen)(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<<s)-1,o=new Array(a+1).fill(e.ZERO),c=Math.floor((t.BITS-1)/s)*s,d=e.ZERO;for(let f=c;f>=0;f-=s){o.fill(e.ZERO);for(let m=0;m<n.length;m++){let b=n[m],l=Number(b>>BigInt(f)&BigInt(a));o[l]=o[l].add(r[m])}let p=e.ZERO;for(let m=o.length-1,b=e.ZERO;m>0;m--)b=b.add(o[m]),p=p.add(b);if(d=d.add(p),f!==0)for(let m=0;m<s;m++)d=d.double()}return d}function cx(e){return(0,B0.validateField)(e.Fp),(0,F0.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,B0.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}});var Fl=ee(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.DER=void 0;xt.weierstrassPoints=C0;xt.weierstrass=px;xt.SWUFpSqrtRatio=q0;xt.mapToCurveSimpleSWU=hx;var xo=Pl(),Yn=jr(),Re=Qt(),wt=Qt();function U0(e){e.lowS!==void 0&&(0,wt.abool)("lowS",e.lowS),e.prehash!==void 0&&(0,wt.abool)("prehash",e.prehash)}function ux(e){let t=(0,xo.validateBasic)(e);Re.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:lx,hexToBytes:dx}=Re;xt.DER={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(e,t)=>{let{Err:r}=xt.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=Re.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Re.numberToHexUnpadded(i.length/2|128):"";return`${Re.numberToHexUnpadded(e)}${s}${i}${t}`},decode(e,t){let{Err:r}=xt.DER,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],s=!!(i&128),a=0;if(!s)a=i;else{let c=i&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let d=t.subarray(n,n+c);if(d.length!==c)throw new r("tlv.decode: length bytes not complete");if(d[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of d)a=a<<8|f;if(n+=c,a<128)throw new r("tlv.decode(long): not minimal encoding")}let o=t.subarray(n,n+a);if(o.length!==a)throw new r("tlv.decode: wrong value length");return{v:o,l:t.subarray(n+a)}}},_int:{encode(e){let{Err:t}=xt.DER;if(e<wr)throw new t("integer: negative integers are not allowed");let r=Re.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}=xt.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 lx(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=xt.DER,i=typeof e=="string"?dx(e):e;Re.abytes(i);let{v:s,l:a}=n.decode(48,i);if(a.length)throw new t("Invalid signature: left bytes after parsing");let{v:o,l:c}=n.decode(2,s),{v:d,l:f}=n.decode(2,c);if(f.length)throw new t("Invalid signature: left bytes after parsing");return{r:r.decode(o),s:r.decode(d)}},hexFromSig(e){let{_tlv:t,_int:r}=xt.DER,n=`${t.encode(2,r.encode(e.r))}${t.encode(2,r.encode(e.s))}`;return t.encode(48,n)}};var wr=BigInt(0),Me=BigInt(1),En=BigInt(2),To=BigInt(3),V0=BigInt(4);function C0(e){let t=ux(e),{Fp:r}=t,n=Yn.Field(t.n,t.nBitLength),i=t.toBytes||((A,v,F)=>{let C=v.toAffine();return Re.concatBytes(Uint8Array.from([4]),r.toBytes(C.x),r.toBytes(C.y))}),s=t.fromBytes||(A=>{let v=A.subarray(1),F=r.fromBytes(v.subarray(0,r.BYTES)),C=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x:F,y:C}});function a(A){let{a:v,b:F}=t,C=r.sqr(A),E=r.mul(C,A);return r.add(r.add(E,r.mul(A,v)),F)}if(!r.eql(r.sqr(t.Gy),a(t.Gx)))throw new Error("bad generator point: equation left != right");function o(A){return Re.inRange(A,Me,t.n)}function c(A){let{allowedPrivateKeyLengths:v,nByteLength:F,wrapPrivateKey:C,n:E}=t;if(v&&typeof A!="bigint"){if(Re.isBytes(A)&&(A=Re.bytesToHex(A)),typeof A!="string"||!v.includes(A.length))throw new Error("Invalid key");A=A.padStart(F*2,"0")}let H;try{H=typeof A=="bigint"?A:Re.bytesToNumberBE((0,wt.ensureBytes)("private key",A,F))}catch{throw new Error(`private key must be ${F} bytes, hex or bigint, not ${typeof A}`)}return C&&(H=Yn.mod(H,E)),Re.aInRange("private key",H,Me,E),H}function d(A){if(!(A instanceof m))throw new Error("ProjectivePoint expected")}let f=(0,wt.memoized)((A,v)=>{let{px:F,py:C,pz:E}=A;if(r.eql(E,r.ONE))return{x:F,y:C};let H=A.is0();v==null&&(v=H?r.ONE:r.inv(E));let x=r.mul(F,v),q=r.mul(C,v),K=r.mul(E,v);if(H)return{x:r.ZERO,y:r.ZERO};if(!r.eql(K,r.ONE))throw new Error("invZ was invalid");return{x,y:q}}),p=(0,wt.memoized)(A=>{if(A.is0()){if(t.allowInfinityPoint&&!r.is0(A.py))return;throw new Error("bad point: ZERO")}let{x:v,y:F}=A.toAffine();if(!r.isValid(v)||!r.isValid(F))throw new Error("bad point: x or y not FE");let C=r.sqr(F),E=a(v);if(!r.eql(C,E))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(v,F,C){if(this.px=v,this.py=F,this.pz=C,v==null||!r.isValid(v))throw new Error("x required");if(F==null||!r.isValid(F))throw new Error("y required");if(C==null||!r.isValid(C))throw new Error("z required");Object.freeze(this)}static fromAffine(v){let{x:F,y:C}=v||{};if(!v||!r.isValid(F)||!r.isValid(C))throw new Error("invalid affine point");if(v instanceof m)throw new Error("projective point not allowed");let E=H=>r.eql(H,r.ZERO);return E(F)&&E(C)?m.ZERO:new m(F,C,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){let F=r.invertBatch(v.map(C=>C.pz));return v.map((C,E)=>C.toAffine(F[E])).map(m.fromAffine)}static fromHex(v){let F=m.fromAffine(s((0,wt.ensureBytes)("pointHex",v)));return F.assertValidity(),F}static fromPrivateKey(v){return m.BASE.multiply(c(v))}static msm(v,F){return(0,xo.pippenger)(m,n,v,F)}_setWindowSize(v){l.setWindowSize(this,v)}assertValidity(){p(this)}hasEvenY(){let{y:v}=this.toAffine();if(r.isOdd)return!r.isOdd(v);throw new Error("Field doesn't support isOdd")}equals(v){d(v);let{px:F,py:C,pz:E}=this,{px:H,py:x,pz:q}=v,K=r.eql(r.mul(F,q),r.mul(H,E)),G=r.eql(r.mul(C,q),r.mul(x,E));return K&&G}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:v,b:F}=t,C=r.mul(F,To),{px:E,py:H,pz:x}=this,q=r.ZERO,K=r.ZERO,G=r.ZERO,D=r.mul(E,E),ae=r.mul(H,H),Q=r.mul(x,x),ne=r.mul(E,H);return ne=r.add(ne,ne),G=r.mul(E,x),G=r.add(G,G),q=r.mul(v,G),K=r.mul(C,Q),K=r.add(q,K),q=r.sub(ae,K),K=r.add(ae,K),K=r.mul(q,K),q=r.mul(ne,q),G=r.mul(C,G),Q=r.mul(v,Q),ne=r.sub(D,Q),ne=r.mul(v,ne),ne=r.add(ne,G),G=r.add(D,D),D=r.add(G,D),D=r.add(D,Q),D=r.mul(D,ne),K=r.add(K,D),Q=r.mul(H,x),Q=r.add(Q,Q),D=r.mul(Q,ne),q=r.sub(q,D),G=r.mul(Q,ae),G=r.add(G,G),G=r.add(G,G),new m(q,K,G)}add(v){d(v);let{px:F,py:C,pz:E}=this,{px:H,py:x,pz:q}=v,K=r.ZERO,G=r.ZERO,D=r.ZERO,ae=t.a,Q=r.mul(t.b,To),ne=r.mul(F,H),w=r.mul(C,x),g=r.mul(E,q),S=r.add(F,C),R=r.add(H,x);S=r.mul(S,R),R=r.add(ne,w),S=r.sub(S,R),R=r.add(F,E);let I=r.add(H,q);return R=r.mul(R,I),I=r.add(ne,g),R=r.sub(R,I),I=r.add(C,E),K=r.add(x,q),I=r.mul(I,K),K=r.add(w,g),I=r.sub(I,K),D=r.mul(ae,R),K=r.mul(Q,g),D=r.add(K,D),K=r.sub(w,D),D=r.add(w,D),G=r.mul(K,D),w=r.add(ne,ne),w=r.add(w,ne),g=r.mul(ae,g),R=r.mul(Q,R),w=r.add(w,g),g=r.sub(ne,g),g=r.mul(ae,g),R=r.add(R,g),ne=r.mul(w,R),G=r.add(G,ne),ne=r.mul(I,R),K=r.mul(S,K),K=r.sub(K,ne),ne=r.mul(S,w),D=r.mul(I,D),D=r.add(D,ne),new m(K,G,D)}subtract(v){return this.add(v.negate())}is0(){return this.equals(m.ZERO)}wNAF(v){return l.wNAFCached(this,v,m.normalizeZ)}multiplyUnsafe(v){Re.aInRange("scalar",v,wr,t.n);let F=m.ZERO;if(v===wr)return F;if(v===Me)return this;let{endo:C}=t;if(!C)return l.unsafeLadder(this,v);let{k1neg:E,k1:H,k2neg:x,k2:q}=C.splitScalar(v),K=F,G=F,D=this;for(;H>wr||q>wr;)H&Me&&(K=K.add(D)),q&Me&&(G=G.add(D)),D=D.double(),H>>=Me,q>>=Me;return E&&(K=K.negate()),x&&(G=G.negate()),G=new m(r.mul(G.px,C.beta),G.py,G.pz),K.add(G)}multiply(v){let{endo:F,n:C}=t;Re.aInRange("scalar",v,Me,C);let E,H;if(F){let{k1neg:x,k1:q,k2neg:K,k2:G}=F.splitScalar(v),{p:D,f:ae}=this.wNAF(q),{p:Q,f:ne}=this.wNAF(G);D=l.constTimeNegate(x,D),Q=l.constTimeNegate(K,Q),Q=new m(r.mul(Q.px,F.beta),Q.py,Q.pz),E=D.add(Q),H=ae.add(ne)}else{let{p:x,f:q}=this.wNAF(v);E=x,H=q}return m.normalizeZ([E,H])[0]}multiplyAndAddUnsafe(v,F,C){let E=m.BASE,H=(q,K)=>K===wr||K===Me||!q.equals(E)?q.multiplyUnsafe(K):q.multiply(K),x=H(this,F).add(H(v,C));return x.is0()?void 0:x}toAffine(v){return f(this,v)}isTorsionFree(){let{h:v,isTorsionFree:F}=t;if(v===Me)return!0;if(F)return F(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:v,clearCofactor:F}=t;return v===Me?this:F?F(m,this):this.multiplyUnsafe(t.h)}toRawBytes(v=!0){return(0,wt.abool)("isCompressed",v),this.assertValidity(),i(m,this,v)}toHex(v=!0){return(0,wt.abool)("isCompressed",v),Re.bytesToHex(this.toRawBytes(v))}}m.BASE=new m(t.Gx,t.Gy,r.ONE),m.ZERO=new m(r.ZERO,r.ONE,r.ZERO);let b=t.nBitLength,l=(0,xo.wNAF)(m,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:o}}function fx(e){let t=(0,xo.validateBasic)(e);return Re.validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function px(e){let t=fx(e),{Fp:r,n}=t,i=r.BYTES+1,s=2*r.BYTES+1;function a(g){return Yn.mod(g,n)}function o(g){return Yn.invert(g,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:p}=C0({...t,toBytes(g,S,R){let I=S.toAffine(),j=r.toBytes(I.x),Y=Re.concatBytes;return(0,wt.abool)("isCompressed",R),R?Y(Uint8Array.from([S.hasEvenY()?2:3]),j):Y(Uint8Array.from([4]),j,r.toBytes(I.y))},fromBytes(g){let S=g.length,R=g[0],I=g.subarray(1);if(S===i&&(R===2||R===3)){let j=Re.bytesToNumberBE(I);if(!Re.inRange(j,Me,r.ORDER))throw new Error("Point is not on curve");let Y=f(j),oe;try{oe=r.sqrt(Y)}catch(U){let _=U instanceof Error?": "+U.message:"";throw new Error("Point is not on curve"+_)}let se=(oe&Me)===Me;return(R&1)===1!==se&&(oe=r.neg(oe)),{x:j,y:oe}}else if(S===s&&R===4){let j=r.fromBytes(I.subarray(0,r.BYTES)),Y=r.fromBytes(I.subarray(r.BYTES,2*r.BYTES));return{x:j,y:Y}}else throw new Error(`Point of length ${S} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=g=>Re.bytesToHex(Re.numberToBytesBE(g,t.nByteLength));function b(g){let S=n>>Me;return g>S}function l(g){return b(g)?a(-g):g}let A=(g,S,R)=>Re.bytesToNumberBE(g.slice(S,R));class v{constructor(S,R,I){this.r=S,this.s=R,this.recovery=I,this.assertValidity()}static fromCompact(S){let R=t.nByteLength;return S=(0,wt.ensureBytes)("compactSignature",S,R*2),new v(A(S,0,R),A(S,R,2*R))}static fromDER(S){let{r:R,s:I}=xt.DER.toSig((0,wt.ensureBytes)("DER",S));return new v(R,I)}assertValidity(){Re.aInRange("r",this.r,Me,n),Re.aInRange("s",this.s,Me,n)}addRecoveryBit(S){return new v(this.r,this.s,S)}recoverPublicKey(S){let{r:R,s:I,recovery:j}=this,Y=q((0,wt.ensureBytes)("msgHash",S));if(j==null||![0,1,2,3].includes(j))throw new Error("recovery id invalid");let oe=j===2||j===3?R+t.n:R;if(oe>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let se=(j&1)===0?"02":"03",z=c.fromHex(se+m(oe)),U=o(oe),_=a(-Y*U),Z=a(I*U),re=c.BASE.multiplyAndAddUnsafe(z,_,Z);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new v(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Re.hexToBytes(this.toDERHex())}toDERHex(){return xt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Re.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=Yn.getMinHashLength(t.n);return Yn.mapHashToField(t.randomBytes(g),t.n)},precompute(g=8,S=c.BASE){return S._setWindowSize(g),S.multiply(BigInt(3)),S}};function C(g,S=!0){return c.fromPrivateKey(g).toRawBytes(S)}function E(g){let S=Re.isBytes(g),R=typeof g=="string",I=(S||R)&&g.length;return S?I===i||I===s:R?I===2*i||I===2*s:g instanceof c}function H(g,S,R=!0){if(E(g))throw new Error("first arg must be private key");if(!E(S))throw new Error("second arg must be public key");return c.fromHex(S).multiply(d(g)).toRawBytes(R)}let x=t.bits2int||function(g){let S=Re.bytesToNumberBE(g),R=g.length*8-t.nBitLength;return R>0?S>>BigInt(R):S},q=t.bits2int_modN||function(g){return a(x(g))},K=Re.bitMask(t.nBitLength);function G(g){return Re.aInRange(`num < 2^${t.nBitLength}`,g,wr,K),Re.numberToBytesBE(g,t.nByteLength)}function D(g,S,R=ae){if(["recovered","canonical"].some(X=>X in R))throw new Error("sign() legacy options not supported");let{hash:I,randomBytes:j}=t,{lowS:Y,prehash:oe,extraEntropy:se}=R;Y==null&&(Y=!0),g=(0,wt.ensureBytes)("msgHash",g),U0(R),oe&&(g=(0,wt.ensureBytes)("prehashed msgHash",I(g)));let z=q(g),U=d(S),_=[G(U),G(z)];if(se!=null&&se!==!1){let X=se===!0?j(r.BYTES):se;_.push((0,wt.ensureBytes)("extraEntropy",X))}let Z=Re.concatBytes(..._),re=z;function le(X){let u=x(X);if(!p(u))return;let h=o(u),y=c.BASE.multiply(u).toAffine(),P=a(y.x);if(P===wr)return;let O=a(h*a(re+P*U));if(O===wr)return;let B=(y.x===P?0:2)|Number(y.y&Me),M=O;return Y&&b(O)&&(M=l(O),B^=1),new v(P,M,B)}return{seed:Z,k2sig:le}}let ae={lowS:t.lowS,prehash:!1},Q={lowS:t.lowS,prehash:!1};function ne(g,S,R=ae){let{seed:I,k2sig:j}=D(g,S,R),Y=t;return Re.createHmacDrbg(Y.hash.outputLen,Y.nByteLength,Y.hmac)(I,j)}c.BASE._setWindowSize(8);function w(g,S,R,I=Q){let j=g;if(S=(0,wt.ensureBytes)("msgHash",S),R=(0,wt.ensureBytes)("publicKey",R),"strict"in I)throw new Error("options.strict was renamed to lowS");U0(I);let{lowS:Y,prehash:oe}=I,se,z;try{if(typeof j=="string"||Re.isBytes(j))try{se=v.fromDER(j)}catch(y){if(!(y instanceof xt.DER.Err))throw y;se=v.fromCompact(j)}else if(typeof j=="object"&&typeof j.r=="bigint"&&typeof j.s=="bigint"){let{r:y,s:P}=j;se=new v(y,P)}else throw new Error("PARSE");z=c.fromHex(R)}catch(y){if(y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Y&&se.hasHighS())return!1;oe&&(S=t.hash(S));let{r:U,s:_}=se,Z=q(S),re=o(_),le=a(Z*re),X=a(U*re),u=c.BASE.multiplyAndAddUnsafe(z,le,X)?.toAffine();return u?a(u.x)===U:!1}return{CURVE:t,getPublicKey:C,getSharedSecret:H,sign:ne,verify:w,ProjectivePoint:c,Signature:v,utils:F}}function q0(e,t){let r=e.ORDER,n=wr;for(let l=r-Me;l%En===wr;l/=En)n+=Me;let i=n,s=En<<i-Me-Me,a=s*En,o=(r-Me)/a,c=(o-Me)/En,d=a-Me,f=s,p=e.pow(t,o),m=e.pow(t,(o+Me)/En),b=(l,A)=>{let v=p,F=e.pow(A,d),C=e.sqr(F);C=e.mul(C,A);let E=e.mul(l,C);E=e.pow(E,c),E=e.mul(E,F),F=e.mul(E,A),C=e.mul(E,l);let H=e.mul(C,F);E=e.pow(H,f);let x=e.eql(E,e.ONE);F=e.mul(C,m),E=e.mul(H,v),C=e.cmov(F,C,x),H=e.cmov(E,H,x);for(let q=i;q>Me;q--){let K=q-En;K=En<<K-Me;let G=e.pow(H,K),D=e.eql(G,e.ONE);F=e.mul(C,v),v=e.mul(v,v),G=e.mul(H,v),C=e.cmov(F,C,D),H=e.cmov(G,H,D)}return{isValid:x,value:C}};if(e.ORDER%V0===To){let l=(e.ORDER-To)/V0,A=e.sqrt(e.neg(t));b=(v,F)=>{let C=e.sqr(F),E=e.mul(v,F);C=e.mul(C,E);let H=e.pow(C,l);H=e.mul(H,E);let x=e.mul(H,A),q=e.mul(e.sqr(H),F),K=e.eql(q,v),G=e.cmov(x,H,K);return{isValid:K,value:G}}}return b}function hx(e,t){if(Yn.validateField(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=q0(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,a,o,c,d,f,p;i=e.sqr(n),i=e.mul(i,t.Z),s=e.sqr(i),s=e.add(s,i),a=e.add(s,e.ONE),a=e.mul(a,t.B),o=e.cmov(t.Z,e.neg(s),!e.eql(s,e.ZERO)),o=e.mul(o,t.A),s=e.sqr(a),d=e.sqr(o),c=e.mul(d,t.A),s=e.add(s,c),s=e.mul(s,a),d=e.mul(d,o),c=e.mul(d,t.B),s=e.add(s,c),f=e.mul(i,a);let{isValid:m,value:b}=r(s,d);p=e.mul(i,n),p=e.mul(p,b),f=e.cmov(f,a,m),p=e.cmov(p,b,m);let l=e.isOdd(n)===e.isOdd(p);return p=e.cmov(e.neg(p),p,l),f=e.div(f,o),{x:f,y:p}}}});var L0=ee(Vl=>{"use strict";Object.defineProperty(Vl,"__esModule",{value:!0});Vl.bls=mx;var D0=jr(),Ul=Qt(),k0=wo(),M0=Fl(),_x=BigInt(0),No=BigInt(1),j0=BigInt(2),Bi=BigInt(3);function yx(e){let t=[];for(;e>No;e>>=No)(e&No)===_x?t.unshift(0):(e&Bi)===Bi?(t.unshift(-1),e+=No):t.unshift(1);return t}function mx(e){let{Fp:t,Fr:r,Fp2:n,Fp6:i,Fp12:s}=e.fields,a=e.params.xNegative,o=e.params.twistType,c=(0,M0.weierstrassPoints)({n:r.ORDER,...e.G1}),d=Object.assign(c,(0,k0.createHasher)(c.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),f=(0,M0.weierstrassPoints)({n:r.ORDER,...e.G2}),p=Object.assign(f,(0,k0.createHasher)(f.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults})),m;if(o==="multiplicative")m=(z,U,_,Z,re,le)=>s.mul014(Z,z,n.mul(U,re),n.mul(_,le));else if(o==="divisive")m=(z,U,_,Z,re,le)=>s.mul034(Z,n.mul(_,le),n.mul(U,re),z);else throw new Error("bls: unknown twist type");let b=n.div(n.ONE,n.mul(n.ONE,j0));function l(z,U,_,Z){let re=n.sqr(_),le=n.sqr(Z),X=n.mulByB(n.mul(le,Bi)),u=n.mul(X,Bi),h=n.sub(n.sub(n.sqr(n.add(_,Z)),le),re),y=n.sub(X,re),P=n.mul(n.sqr(U),Bi),O=n.neg(h);return z.push([y,P,O]),U=n.mul(n.mul(n.mul(n.sub(re,u),U),_),b),_=n.sub(n.sqr(n.mul(n.add(re,u),b)),n.mul(n.sqr(X),Bi)),Z=n.mul(re,h),{Rx:U,Ry:_,Rz:Z}}function A(z,U,_,Z,re,le){let X=n.sub(_,n.mul(le,Z)),u=n.sub(U,n.mul(re,Z)),h=n.sub(n.mul(X,re),n.mul(u,le)),y=n.neg(X),P=u;z.push([h,y,P]);let O=n.sqr(u),B=n.mul(O,u),M=n.mul(O,U),T=n.add(n.sub(B,n.mul(M,j0)),n.mul(n.sqr(X),Z));return U=n.mul(u,T),_=n.sub(n.mul(n.sub(M,T),X),n.mul(B,_)),Z=n.mul(Z,B),{Rx:U,Ry:_,Rz:Z}}let v=yx(e.params.ateLoopSize),F=(0,Ul.memoized)(z=>{let U=z,{x:_,y:Z}=U.toAffine(),re=_,le=Z,X=n.neg(Z),u=re,h=le,y=n.ONE,P=[];for(let O of v){let B=[];({Rx:u,Ry:h,Rz:y}=l(B,u,h,y)),O&&({Rx:u,Ry:h,Rz:y}=A(B,u,h,y,re,O===-1?X:le)),P.push(B)}if(e.postPrecompute){let O=P[P.length-1];e.postPrecompute(u,h,y,re,le,A.bind(null,O))}return P});function C(z,U=!1){let _=s.ONE;if(z.length){let Z=z[0][0].length;for(let re=0;re<Z;re++){_=s.sqr(_);for(let[le,X,u]of z)for(let[h,y,P]of le[re])_=m(h,y,P,_,X,u)}}return a&&(_=s.conjugate(_)),U?s.finalExponentiate(_):_}function E(z,U=!0){let _=[];d.ProjectivePoint.normalizeZ(z.map(({g1:Z})=>Z)),p.ProjectivePoint.normalizeZ(z.map(({g2:Z})=>Z));for(let{g1:Z,g2:re}of z){if(Z.equals(d.ProjectivePoint.ZERO)||re.equals(p.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");Z.assertValidity(),re.assertValidity();let le=Z.toAffine();_.push([F(re),le.x,le.y])}return C(_,U)}function H(z,U,_=!0){return E([{g1:z,g2:U}],_)}let x={randomPrivateKey:()=>{let z=(0,D0.getMinHashLength)(r.ORDER);return(0,D0.mapHashToField)(e.randomBytes(z),r.ORDER)},calcPairingPrecomputes:F},{ShortSignature:q}=e.G1,{Signature:K}=e.G2;function G(z){return z instanceof d.ProjectivePoint?z:d.ProjectivePoint.fromHex(z)}function D(z,U){return z instanceof d.ProjectivePoint?z:d.hashToCurve((0,Ul.ensureBytes)("point",z),U)}function ae(z){return z instanceof p.ProjectivePoint?z:K.fromHex(z)}function Q(z,U){return z instanceof p.ProjectivePoint?z:p.hashToCurve((0,Ul.ensureBytes)("point",z),U)}function ne(z){return d.ProjectivePoint.fromPrivateKey(z).toRawBytes(!0)}function w(z){return p.ProjectivePoint.fromPrivateKey(z).toRawBytes(!0)}function g(z,U,_){let Z=Q(z,_);Z.assertValidity();let re=Z.multiply(d.normPrivateKeyToScalar(U));return z instanceof p.ProjectivePoint?re:K.toRawBytes(re)}function S(z,U,_){let Z=D(z,_);Z.assertValidity();let re=Z.multiply(d.normPrivateKeyToScalar(U));return z instanceof d.ProjectivePoint?re:q.toRawBytes(re)}function R(z,U,_,Z){let re=G(_),le=Q(U,Z),X=d.ProjectivePoint.BASE,u=ae(z),h=E([{g1:re.negate(),g2:le},{g1:X,g2:u}]);return s.eql(h,s.ONE)}function I(z,U,_,Z){let re=ae(_),le=D(U,Z),X=p.ProjectivePoint.BASE,u=G(z),h=E([{g1:le,g2:re},{g1:u,g2:X.negate()}]);return s.eql(h,s.ONE)}function j(z){if(!z.length)throw new Error("Expected non-empty array");let _=z.map(G).reduce((Z,re)=>Z.add(re),d.ProjectivePoint.ZERO);return z[0]instanceof d.ProjectivePoint?(_.assertValidity(),_):_.toRawBytes(!0)}function Y(z){if(!z.length)throw new Error("Expected non-empty array");let _=z.map(ae).reduce((Z,re)=>Z.add(re),p.ProjectivePoint.ZERO);return z[0]instanceof p.ProjectivePoint?(_.assertValidity(),_):K.toRawBytes(_)}function oe(z){if(!z.length)throw new Error("Expected non-empty array");let _=z.map(G).reduce((Z,re)=>Z.add(re),d.ProjectivePoint.ZERO);return z[0]instanceof d.ProjectivePoint?(_.assertValidity(),_):q.toRawBytes(_)}function se(z,U,_,Z){if(!U.length)throw new Error("Expected non-empty messages array");if(_.length!==U.length)throw new Error("Pubkey count should equal msg count");let re=ae(z),le=U.map(y=>Q(y,Z)),X=_.map(G),u=new Map;for(let y=0;y<X.length;y++){let P=X[y],O=le[y],B=u.get(O);B===void 0&&(B=[],u.set(O,B)),B.push(P)}let h=[];try{for(let[y,P]of u){let O=P.reduce((B,M)=>B.add(M));h.push({g1:O,g2:y})}return h.push({g1:d.ProjectivePoint.BASE.negate(),g2:re}),s.eql(E(h),s.ONE)}catch{return!1}}return d.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ne,getPublicKeyForShortSignatures:w,sign:g,signShortSignature:S,verify:R,verifyBatch:se,verifyShortSignature:I,aggregatePublicKeys:j,aggregateSignatures:Y,aggregateShortSignatures:oe,millerLoopBatch:C,pairing:H,pairingBatch:E,G1:d,G2:p,Signature:K,ShortSignature:q,fields:{Fr:r,Fp:t,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:e.params.ateLoopSize,r:e.params.r,G1b:e.G1.b,G2b:e.G2.b},utils:x}}});var K0=ee(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.psiFrobenius=bx;Eo.tower12=wx;var On=jr(),xr=Qt(),gx=BigInt(0),Pi=BigInt(1),an=BigInt(2),H0=BigInt(3);function Cl(e,t,r,n,i=1,s){let a=BigInt(s===void 0?n:s),o=r**BigInt(n),c=[];for(let d=0;d<i;d++){let f=BigInt(d+1),p=[];for(let m=0,b=Pi;m<n;m++){let l=(f*b-f)/a%o;p.push(e.pow(t,l)),b*=r}c.push(p)}return c}function bx(e,t,r){let n=t.pow(r,(e.ORDER-Pi)/H0),i=t.pow(r,(e.ORDER-Pi)/an);function s(m,b){let l=t.mul(t.frobeniusMap(m,1),n),A=t.mul(t.frobeniusMap(b,1),i);return[l,A]}let a=t.pow(r,(e.ORDER**an-Pi)/H0),o=t.pow(r,(e.ORDER**an-Pi)/an);if(!t.eql(o,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(m,b){return[t.mul(m,a),t.neg(b)]}let d=m=>(b,l)=>{let A=l.toAffine(),v=m(A.x,A.y);return b.fromAffine({x:v[0],y:v[1]})},f=d(s),p=d(c);return{psi:s,psi2:c,G2psi:f,G2psi2:p,PSI_X:n,PSI_Y:i,PSI2_X:a,PSI2_Y:o}}function wx(e){let{ORDER:t}=e,r=On.Field(t),n=r.create(e.NONRESIDUE||BigInt(-1)),i=On.FpLegendre(t),s=r.div(r.ONE,an),a=Cl(r,n,r.ORDER,2)[0],o=({c0:w,c1:g},{c0:S,c1:R})=>({c0:r.add(w,S),c1:r.add(g,R)}),c=({c0:w,c1:g},{c0:S,c1:R})=>({c0:r.sub(w,S),c1:r.sub(g,R)}),d=({c0:w,c1:g},S)=>{if(typeof S=="bigint")return{c0:r.mul(w,S),c1:r.mul(g,S)};let{c0:R,c1:I}=S,j=r.mul(w,R),Y=r.mul(g,I),oe=r.sub(j,Y),se=r.sub(r.mul(r.add(w,g),r.add(R,I)),r.add(j,Y));return{c0:oe,c1:se}},f=({c0:w,c1:g})=>{let S=r.add(w,g),R=r.sub(w,g),I=r.add(w,w);return{c0:r.mul(S,R),c1:r.mul(I,g)}},p=w=>{if(w.length!==2)throw new Error("Invalid tuple");let g=w.map(S=>r.create(S));return{c0:g[0],c1:g[1]}},m=t*t,b=p(e.FP2_NONRESIDUE),l={ORDER:m,NONRESIDUE:b,BITS:(0,xr.bitLen)(m),BYTES:Math.ceil((0,xr.bitLen)(m)/8),MASK:(0,xr.bitMask)((0,xr.bitLen)(m)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:w=>w,isValid:({c0:w,c1:g})=>typeof w=="bigint"&&typeof g=="bigint",is0:({c0:w,c1:g})=>r.is0(w)&&r.is0(g),eql:({c0:w,c1:g},{c0:S,c1:R})=>r.eql(w,S)&&r.eql(g,R),neg:({c0:w,c1:g})=>({c0:r.neg(w),c1:r.neg(g)}),pow:(w,g)=>On.FpPow(l,w,g),invertBatch:w=>On.FpInvertBatch(l,w),add:o,sub:c,mul:d,sqr:f,addN:o,subN:c,mulN:d,sqrN:f,div:(w,g)=>l.mul(w,typeof g=="bigint"?r.inv(r.create(g)):l.inv(g)),inv:({c0:w,c1:g})=>{let S=r.inv(r.create(w*w+g*g));return{c0:r.mul(S,r.create(w)),c1:r.mul(S,r.create(-g))}},sqrt:w=>{if(e.Fp2sqrt)return e.Fp2sqrt(w);let{c0:g,c1:S}=w;if(r.is0(S))return r.eql(i(r,g),r.ONE)?l.create({c0:r.sqrt(g),c1:r.ZERO}):l.create({c0:r.ZERO,c1:r.sqrt(r.div(g,n))});let R=r.sqrt(r.sub(r.sqr(g),r.mul(r.sqr(S),n))),I=r.mul(r.add(R,g),s),j=i(r,I);!r.is0(j)&&!r.eql(j,r.ONE)&&(I=r.sub(I,R));let Y=r.sqrt(I),oe=l.create({c0:Y,c1:r.div(r.mul(S,s),Y)});if(!l.eql(l.sqr(oe),w))throw new Error("Cannot find square root");let se=oe,z=l.neg(se),{re:U,im:_}=l.reim(se),{re:Z,im:re}=l.reim(z);return _>re||_===re&&U>Z?se:z},isOdd:w=>{let{re:g,im:S}=l.reim(w),R=g%an,I=g===gx,j=S%an;return BigInt(R||I&&j)==Pi},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,xr.concatBytes)(r.toBytes(w),r.toBytes(g)),cmov:({c0:w,c1:g},{c0:S,c1:R},I)=>({c0:r.cmov(w,S,I),c1:r.cmov(g,R,I)}),reim:({c0:w,c1:g})=>({re:w,im:g}),mulByNonresidue:({c0:w,c1:g})=>l.mul({c0:w,c1:g},b),mulByB:e.Fp2mulByB,fromBigTuple:p,frobeniusMap:({c0:w,c1:g},S)=>({c0:w,c1:r.mul(g,a[S%2])})},A=({c0:w,c1:g,c2:S},{c0:R,c1:I,c2:j})=>({c0:l.add(w,R),c1:l.add(g,I),c2:l.add(S,j)}),v=({c0:w,c1:g,c2:S},{c0:R,c1:I,c2:j})=>({c0:l.sub(w,R),c1:l.sub(g,I),c2:l.sub(S,j)}),F=({c0:w,c1:g,c2:S},R)=>{if(typeof R=="bigint")return{c0:l.mul(w,R),c1:l.mul(g,R),c2:l.mul(S,R)};let{c0:I,c1:j,c2:Y}=R,oe=l.mul(w,I),se=l.mul(g,j),z=l.mul(S,Y);return{c0:l.add(oe,l.mulByNonresidue(l.sub(l.mul(l.add(g,S),l.add(j,Y)),l.add(se,z)))),c1:l.add(l.sub(l.mul(l.add(w,g),l.add(I,j)),l.add(oe,se)),l.mulByNonresidue(z)),c2:l.sub(l.add(se,l.mul(l.add(w,S),l.add(I,Y))),l.add(oe,z))}},C=({c0:w,c1:g,c2:S})=>{let R=l.sqr(w),I=l.mul(l.mul(w,g),an),j=l.mul(l.mul(g,S),an),Y=l.sqr(S);return{c0:l.add(l.mulByNonresidue(j),R),c1:l.add(l.mulByNonresidue(Y),I),c2:l.sub(l.sub(l.add(l.add(I,l.sqr(l.add(l.sub(w,g),S))),j),R),Y)}},[E,H]=Cl(l,b,r.ORDER,6,2,3),x={ORDER:l.ORDER,BITS:3*l.BITS,BYTES:3*l.BYTES,MASK:(0,xr.bitMask)(3*l.BITS),ZERO:{c0:l.ZERO,c1:l.ZERO,c2:l.ZERO},ONE:{c0:l.ONE,c1:l.ZERO,c2:l.ZERO},create:w=>w,isValid:({c0:w,c1:g,c2:S})=>l.isValid(w)&&l.isValid(g)&&l.isValid(S),is0:({c0:w,c1:g,c2:S})=>l.is0(w)&&l.is0(g)&&l.is0(S),neg:({c0:w,c1:g,c2:S})=>({c0:l.neg(w),c1:l.neg(g),c2:l.neg(S)}),eql:({c0:w,c1:g,c2:S},{c0:R,c1:I,c2:j})=>l.eql(w,R)&&l.eql(g,I)&&l.eql(S,j),sqrt:xr.notImplemented,div:(w,g)=>x.mul(w,typeof g=="bigint"?r.inv(r.create(g)):x.inv(g)),pow:(w,g)=>On.FpPow(x,w,g),invertBatch:w=>On.FpInvertBatch(x,w),add:A,sub:v,mul:F,sqr:C,addN:A,subN:v,mulN:F,sqrN:C,inv:({c0:w,c1:g,c2:S})=>{let R=l.sub(l.sqr(w),l.mulByNonresidue(l.mul(S,g))),I=l.sub(l.mulByNonresidue(l.sqr(S)),l.mul(w,g)),j=l.sub(l.sqr(g),l.mul(w,S)),Y=l.inv(l.add(l.mulByNonresidue(l.add(l.mul(S,I),l.mul(g,j))),l.mul(w,R)));return{c0:l.mul(Y,R),c1:l.mul(Y,I),c2:l.mul(Y,j)}},fromBytes:w=>{if(w.length!==x.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:l.fromBytes(w.subarray(0,l.BYTES)),c1:l.fromBytes(w.subarray(l.BYTES,2*l.BYTES)),c2:l.fromBytes(w.subarray(2*l.BYTES))}},toBytes:({c0:w,c1:g,c2:S})=>(0,xr.concatBytes)(l.toBytes(w),l.toBytes(g),l.toBytes(S)),cmov:({c0:w,c1:g,c2:S},{c0:R,c1:I,c2:j},Y)=>({c0:l.cmov(w,R,Y),c1:l.cmov(g,I,Y),c2:l.cmov(S,j,Y)}),fromBigSix:w=>{if(!Array.isArray(w)||w.length!==6)throw new Error("Invalid Fp6 usage");return{c0:l.fromBigTuple(w.slice(0,2)),c1:l.fromBigTuple(w.slice(2,4)),c2:l.fromBigTuple(w.slice(4,6))}},frobeniusMap:({c0:w,c1:g,c2:S},R)=>({c0:l.frobeniusMap(w,R),c1:l.mul(l.frobeniusMap(g,R),E[R%6]),c2:l.mul(l.frobeniusMap(S,R),H[R%6])}),mulByFp2:({c0:w,c1:g,c2:S},R)=>({c0:l.mul(w,R),c1:l.mul(g,R),c2:l.mul(S,R)}),mulByNonresidue:({c0:w,c1:g,c2:S})=>({c0:l.mulByNonresidue(S),c1:w,c2:g}),mul1:({c0:w,c1:g,c2:S},R)=>({c0:l.mulByNonresidue(l.mul(S,R)),c1:l.mul(w,R),c2:l.mul(g,R)}),mul01({c0:w,c1:g,c2:S},R,I){let j=l.mul(w,R),Y=l.mul(g,I);return{c0:l.add(l.mulByNonresidue(l.sub(l.mul(l.add(g,S),I),Y)),j),c1:l.sub(l.sub(l.mul(l.add(R,I),l.add(w,g)),j),Y),c2:l.add(l.sub(l.mul(l.add(w,S),R),j),Y)}}},q=Cl(l,b,r.ORDER,12,1,6)[0],K=({c0:w,c1:g},{c0:S,c1:R})=>({c0:x.add(w,S),c1:x.add(g,R)}),G=({c0:w,c1:g},{c0:S,c1:R})=>({c0:x.sub(w,S),c1:x.sub(g,R)}),D=({c0:w,c1:g},S)=>{if(typeof S=="bigint")return{c0:x.mul(w,S),c1:x.mul(g,S)};let{c0:R,c1:I}=S,j=x.mul(w,R),Y=x.mul(g,I);return{c0:x.add(j,x.mulByNonresidue(Y)),c1:x.sub(x.mul(x.add(w,g),x.add(R,I)),x.add(j,Y))}},ae=({c0:w,c1:g})=>{let S=x.mul(w,g);return{c0:x.sub(x.sub(x.mul(x.add(x.mulByNonresidue(g),w),x.add(w,g)),S),x.mulByNonresidue(S)),c1:x.add(S,S)}};function Q(w,g){let S=l.sqr(w),R=l.sqr(g);return{first:l.add(l.mulByNonresidue(R),S),second:l.sub(l.sub(l.sqr(l.add(w,g)),S),R)}}let ne={ORDER:l.ORDER,BITS:2*l.BITS,BYTES:2*l.BYTES,MASK:(0,xr.bitMask)(2*l.BITS),ZERO:{c0:x.ZERO,c1:x.ZERO},ONE:{c0:x.ONE,c1:x.ZERO},create:w=>w,isValid:({c0:w,c1:g})=>x.isValid(w)&&x.isValid(g),is0:({c0:w,c1:g})=>x.is0(w)&&x.is0(g),neg:({c0:w,c1:g})=>({c0:x.neg(w),c1:x.neg(g)}),eql:({c0:w,c1:g},{c0:S,c1:R})=>x.eql(w,S)&&x.eql(g,R),sqrt:xr.notImplemented,inv:({c0:w,c1:g})=>{let S=x.inv(x.sub(x.sqr(w),x.mulByNonresidue(x.sqr(g))));return{c0:x.mul(w,S),c1:x.neg(x.mul(g,S))}},div:(w,g)=>ne.mul(w,typeof g=="bigint"?r.inv(r.create(g)):ne.inv(g)),pow:(w,g)=>On.FpPow(ne,w,g),invertBatch:w=>On.FpInvertBatch(ne,w),add:K,sub:G,mul:D,sqr:ae,addN:K,subN:G,mulN:D,sqrN:ae,fromBytes:w=>{if(w.length!==ne.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:x.fromBytes(w.subarray(0,x.BYTES)),c1:x.fromBytes(w.subarray(x.BYTES))}},toBytes:({c0:w,c1:g})=>(0,xr.concatBytes)(x.toBytes(w),x.toBytes(g)),cmov:({c0:w,c1:g},{c0:S,c1:R},I)=>({c0:x.cmov(w,S,I),c1:x.cmov(g,R,I)}),fromBigTwelve:w=>({c0:x.fromBigSix(w.slice(0,6)),c1:x.fromBigSix(w.slice(6,12))}),frobeniusMap(w,g){let{c0:S,c1:R,c2:I}=x.frobeniusMap(w.c1,g),j=q[g%12];return{c0:x.frobeniusMap(w.c0,g),c1:x.create({c0:l.mul(S,j),c1:l.mul(R,j),c2:l.mul(I,j)})}},mulByFp2:({c0:w,c1:g},S)=>({c0:x.mulByFp2(w,S),c1:x.mulByFp2(g,S)}),conjugate:({c0:w,c1:g})=>({c0:w,c1:x.neg(g)}),mul014:({c0:w,c1:g},S,R,I)=>{let j=x.mul01(w,S,R),Y=x.mul1(g,I);return{c0:x.add(x.mulByNonresidue(Y),j),c1:x.sub(x.sub(x.mul01(x.add(g,w),S,l.add(R,I)),j),Y)}},mul034:({c0:w,c1:g},S,R,I)=>{let j=x.create({c0:l.mul(w.c0,S),c1:l.mul(w.c1,S),c2:l.mul(w.c2,S)}),Y=x.mul01(g,R,I),oe=x.mul01(x.add(w,g),l.add(S,R),I);return{c0:x.add(x.mulByNonresidue(Y),j),c1:x.sub(oe,x.add(j,Y))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:r,Fp2:l,Fp6:x,Fp4Square:Q,Fp12:ne}}});var Q0=ee(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.bls12_381=void 0;var Y0=Ra(),xx=Kn(),Tx=L0(),Nx=jr(),Ae=Qt(),J0=wo(),Z0=Fl(),X0=K0(),Dt=BigInt(0),Ro=BigInt(1),_t=BigInt(2),Oo=BigInt(3),Is=BigInt(4),vn=BigInt("0xd201000000010000"),Ex=(0,Ae.bitLen)(vn),{Fp:pe,Fp2:he,Fp6:kl,Fp4Square:ql,Fp12:Ee}=(0,X0.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[Ro,Ro],Fp2mulByB:({c0:e,c1:t})=>{let r=pe.mul(e,Is),n=pe.mul(t,Is);return{c0:pe.sub(r,n),c1:pe.add(r,n)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{let{c0:r,c1:n,c2:i}=e,{c0:s,c1:a,c2:o}=t,{first:c,second:d}=ql(r,a),{first:f,second:p}=ql(s,i),{first:m,second:b}=ql(n,o),l=he.mulByNonresidue(b);return{c0:kl.create({c0:he.add(he.mul(he.sub(c,r),_t),c),c1:he.add(he.mul(he.sub(f,n),_t),f),c2:he.add(he.mul(he.sub(m,i),_t),m)}),c1:kl.create({c0:he.add(he.mul(he.add(l,s),_t),l),c1:he.add(he.mul(he.add(d,a),_t),d),c2:he.add(he.mul(he.add(p,o),_t),p)})}},Fp12cyclotomicExp(e,t){let r=Ee.ONE;for(let n=Ex-1;n>=0;n--)r=Ee._cyclotomicSquare(r),(0,Ae.bitGet)(t,n)&&(r=Ee.mul(r,e));return r},Fp12finalExponentiate:e=>{let t=vn,r=Ee.div(Ee.frobeniusMap(e,6),e),n=Ee.mul(Ee.frobeniusMap(r,2),r),i=Ee.conjugate(Ee._cyclotomicExp(n,t)),s=Ee.mul(Ee.conjugate(Ee._cyclotomicSquare(n)),i),a=Ee.conjugate(Ee._cyclotomicExp(s,t)),o=Ee.conjugate(Ee._cyclotomicExp(a,t)),c=Ee.mul(Ee.conjugate(Ee._cyclotomicExp(o,t)),Ee._cyclotomicSquare(i)),d=Ee.conjugate(Ee._cyclotomicExp(c,t)),f=Ee.frobeniusMap(Ee.mul(i,o),2),p=Ee.frobeniusMap(Ee.mul(a,n),3),m=Ee.frobeniusMap(Ee.mul(c,Ee.conjugate(n)),1),b=Ee.mul(Ee.mul(d,Ee.conjugate(s)),n);return Ee.mul(Ee.mul(Ee.mul(f,p),m),b)}}),G0=Nx.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Ox=(0,J0.isogenyMap)(he,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(e=>e.map(t=>he.fromBigTuple(t.map(BigInt))))),vx=(0,J0.isogenyMap)(pe,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),Rx=(0,Z0.mapToCurveSimpleSWU)(he,{A:he.create({c0:pe.create(Dt),c1:pe.create(BigInt(240))}),B:he.create({c0:pe.create(BigInt(1012)),c1:pe.create(BigInt(1012))}),Z:he.create({c0:pe.create(BigInt(-2)),c1:pe.create(BigInt(-1))})}),Ax=(0,Z0.mapToCurveSimpleSWU)(pe,{A:pe.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:pe.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:pe.create(BigInt(11))}),{G2psi:$0,G2psi2:Sx}=(0,X0.psiFrobenius)(pe,he,he.div(he.ONE,he.NONRESIDUE)),Dl=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:pe.ORDER,m:2,k:128,expand:"xmd",hash:Y0.sha256}),Ao=Bs(pe.toBytes(Dt),{infinity:!0,compressed:!0});function vo(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 Bs(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 W0(e){e.assertValidity();let t=e.equals(kt.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=e.toAffine();if(t)return Ao.slice();let i=pe.ORDER,s=!!(n*_t/i);return Bs((0,Ae.numberToBytesBE)(r,pe.BYTES),{compressed:!0,sort:s})}function z0(e){e.assertValidity();let t=pe.BYTES;if(e.equals(kt.bls12_381.G2.ProjectivePoint.ZERO))return(0,Ae.concatBytes)(Ao,(0,Ae.numberToBytesBE)(Dt,t));let{x:r,y:n}=e.toAffine(),{re:i,im:s}=he.reim(r),{re:a,im:o}=he.reim(n),d=!!((o>Dt?o*_t:a*_t)/pe.ORDER&Ro),f=i;return(0,Ae.concatBytes)(Bs((0,Ae.numberToBytesBE)(s,t),{sort:d,compressed:!0}),(0,Ae.numberToBytesBE)(f,t))}kt.bls12_381=(0,Tx.bls)({fields:{Fp:pe,Fp2:he,Fp6:kl,Fp12:Ee,Fr:G0},G1:{Fp:pe,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:pe.ZERO,b:Is,htfDefaults:{...Dl,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(e,t)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new e(pe.mul(t.px,r),t.py,t.pz);return t.multiplyUnsafe(vn).negate().multiplyUnsafe(vn).equals(n)},clearCofactor:(e,t)=>t.multiplyUnsafe(vn).add(t),mapToCurve:e=>{let{x:t,y:r}=Ax(pe.create(e[0]));return vx(t,r)},fromBytes:e=>{let{compressed:t,infinity:r,sort:n,value:i}=vo(e);if(i.length===48&&t){let s=pe.ORDER,a=(0,Ae.bytesToNumberBE)(i),o=pe.create(a&pe.MASK);if(r){if(o!==Dt)throw new Error("G1: non-empty compressed point at infinity");return{x:Dt,y:Dt}}let c=pe.add(pe.pow(o,Oo),pe.create(kt.bls12_381.params.G1b)),d=pe.sqrt(c);if(!d)throw new Error("Invalid compressed G1 point");return d*_t/s!==BigInt(n)&&(d=pe.neg(d)),{x:pe.create(o),y:pe.create(d)}}else if(i.length===96&&!t){let s=(0,Ae.bytesToNumberBE)(i.subarray(0,pe.BYTES)),a=(0,Ae.bytesToNumberBE)(i.subarray(pe.BYTES));if(r){if(s!==Dt||a!==Dt)throw new Error("G1: non-empty point at infinity");return kt.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:pe.create(s),y:pe.create(a)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(e,t,r)=>{let n=t.equals(e.ZERO),{x:i,y:s}=t.toAffine();if(r){if(n)return Ao.slice();let a=pe.ORDER,o=!!(s*_t/a);return Bs((0,Ae.numberToBytesBE)(i,pe.BYTES),{compressed:!0,sort:o})}else return n?(0,Ae.concatBytes)(new Uint8Array([64]),new Uint8Array(2*pe.BYTES-1)):(0,Ae.concatBytes)((0,Ae.numberToBytesBE)(i,pe.BYTES),(0,Ae.numberToBytesBE)(s,pe.BYTES))},ShortSignature:{fromHex(e){let{infinity:t,sort:r,value:n}=vo((0,Ae.ensureBytes)("signatureHex",e,48)),i=pe.ORDER,s=(0,Ae.bytesToNumberBE)(n);if(t)return kt.bls12_381.G1.ProjectivePoint.ZERO;let a=pe.create(s&pe.MASK),o=pe.add(pe.pow(a,Oo),pe.create(kt.bls12_381.params.G1b)),c=pe.sqrt(o);if(!c)throw new Error("Invalid compressed G1 point");let d=BigInt(r);c*_t/i!==d&&(c=pe.neg(c));let f=kt.bls12_381.G1.ProjectivePoint.fromAffine({x:a,y:c});return f.assertValidity(),f},toRawBytes(e){return W0(e)},toHex(e){return(0,Ae.bytesToHex)(W0(e))}}},G2:{Fp:he,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:he.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:he.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:he.ZERO,b:he.fromBigTuple([Is,Is]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...Dl},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{let{x:t,y:r}=Rx(he.fromBigTuple(e));return Ox(t,r)},isTorsionFree:(e,t)=>t.multiplyUnsafe(vn).negate().equals($0(e,t)),clearCofactor:(e,t)=>{let r=vn,n=t.multiplyUnsafe(r).negate(),i=$0(e,t),s=t.double();return s=Sx(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}=vo(e);if(!t&&!r&&n||!t&&r&&n||n&&r&&t)throw new Error("Invalid encoding flag: "+(e[0]&224));let s=pe.BYTES,a=(o,c,d)=>(0,Ae.bytesToNumberBE)(o.slice(c,d));if(i.length===96&&t){let o=kt.bls12_381.params.G2b,c=pe.ORDER;if(r){if(i.reduce((A,v)=>A!==0?v+1:v,0)>0)throw new Error("Invalid compressed G2 point");return{x:he.ZERO,y:he.ZERO}}let d=a(i,0,s),f=a(i,s,2*s),p=he.create({c0:pe.create(f),c1:pe.create(d)}),m=he.add(he.pow(p,Oo),o),b=he.sqrt(m),l=b.c1===Dt?b.c0*_t/c:b.c1*_t/c?Ro:Dt;return b=n&&l>0?b:he.neg(b),{x:p,y:b}}else if(i.length===192&&!t){if(r){if(i.reduce((p,m)=>p!==0?m+1:m,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:he.ZERO,y:he.ZERO}}let o=a(i,0,s),c=a(i,s,2*s),d=a(i,2*s,3*s),f=a(i,3*s,4*s);return{x:he.fromBigTuple([c,o]),y:he.fromBigTuple([f,d])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(e,t,r)=>{let{BYTES:n,ORDER:i}=pe,s=t.equals(e.ZERO),{x:a,y:o}=t.toAffine();if(r){if(s)return(0,Ae.concatBytes)(Ao,(0,Ae.numberToBytesBE)(Dt,n));let c=!!(o.c1===Dt?o.c0*_t/i:o.c1*_t/i);return(0,Ae.concatBytes)(Bs((0,Ae.numberToBytesBE)(a.c1,n),{compressed:!0,sort:c}),(0,Ae.numberToBytesBE)(a.c0,n))}else{if(s)return(0,Ae.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:d}=he.reim(a),{re:f,im:p}=he.reim(o);return(0,Ae.concatBytes)((0,Ae.numberToBytesBE)(d,n),(0,Ae.numberToBytesBE)(c,n),(0,Ae.numberToBytesBE)(p,n),(0,Ae.numberToBytesBE)(f,n))}},Signature:{fromHex(e){let{infinity:t,sort:r,value:n}=vo((0,Ae.ensureBytes)("signatureHex",e)),i=pe.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let a=(0,Ae.bytesToNumberBE)(n.slice(0,s)),o=(0,Ae.bytesToNumberBE)(n.slice(s));if(t)return kt.bls12_381.G2.ProjectivePoint.ZERO;let c=pe.create(a&pe.MASK),d=pe.create(o),f=he.create({c0:d,c1:c}),p=he.add(he.pow(f,Oo),kt.bls12_381.params.G2b),m=he.sqrt(p);if(!m)throw new Error("Failed to find a square root");let{re:b,im:l}=he.reim(m),A=BigInt(r),v=l>Dt&&l*_t/i!==A,F=l===Dt&&b*_t/i!==A;(v||F)&&(m=he.neg(m));let C=kt.bls12_381.G2.ProjectivePoint.fromAffine({x:f,y:m});return C.assertValidity(),C},toRawBytes(e){return z0(e)},toHex(e){return(0,Ae.bytesToHex)(z0(e))}}},params:{ateLoopSize:vn,r:G0.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:Dl,hash:Y0.sha256,randomBytes:xx.randomBytes})});var jl=ee(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.blsVerify=Ps.verify=void 0;var Ix=Q0(),Ml=$t();function Bx(e,t,r){let n=typeof e=="string"?e:(0,Ml.toHex)(e),i=typeof t=="string"?t:(0,Ml.toHex)(t),s=typeof r=="string"?r:(0,Ml.toHex)(r);return Ix.bls12_381.verifyShortSignature(i,s,n)}Ps.blsVerify=Bx});var So=ee(Jn=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});Jn.decodeTime=Jn.decodeLeb128=void 0;var eh=Ri(),Px=e=>(0,eh.lebDecode)(new eh.PipeArrayBuffer(e));Jn.decodeLeb128=Px;var Fx=e=>{let t=(0,Jn.decodeLeb128)(e);return new Date(Number(t)/1e6)};Jn.decodeTime=Fx});var Fi=ee(Oe=>{"use strict";var Ux=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]}),Vx=Oe&&Oe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),th=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)&&Ux(t,e,r);return Vx(t,e),t},Cx=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},qx=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)},Bo;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 rh=th(vs()),Dx=wi(),Io=Ns(),Tr=$t(),Ll=Ct(),kx=th(jl()),Mx=So(),jx=qs(),on=class extends Dx.AgentError{constructor(t){super(`Invalid certificate: ${t}`)}};Oe.CertificateVerificationError=on;var Tt;(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"})(Tt=Oe.NodeType||(Oe.NodeType={}));function Po(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 Tt.Empty:return"()";case Tt.Fork:if(e[1]instanceof Array&&e[2]instanceof ArrayBuffer){let n=Po(e[1]),i=Po(e[2]);return`sub(
20
20
  left:
@@ -27,10 +27,10 @@ ${t(i)}
27
27
  ${t(n)}
28
28
  sub:
29
29
  ${t(i)}
30
- )`}else throw new Error("Invalid tree structure for labeled");case Tt.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 Tt.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,Tr.toHex)(new Uint8Array(e[1]))}`}default:return`unknown(${JSON.stringify(e[0])})`}}Oe.hashTreeToString=Po;function jx(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 Ll=class e{constructor(t,r,n,i,s=5,a=!1){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,Bo.set(this,!1),Vx(this,Bo,a,"f"),this.cert=th.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=Dx.blsVerify),new e(t.certificate,t.rootKey,t.canisterId,r,t.maxAgeInMinutes,t.disableTimeVerification)}lookup(t){return Fo(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=Hx(r),s=(0,Tr.concat)(Us("ic-state-root"),t),a=!1,o=Hl(this.lookup(["time"]));if(!o)throw new on("Certificate does not contain a time");if(!Cx(this,Bo,"f")){let d=this._maxAgeInMinutes*60*1e3,f=Date.now(),p=f-d,m=f+3e5,b=(0,kx.decodeTime)(o);if(b.getTime()<p)throw new on(`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 on("Certificate is signed more than 5 minutes in the future. Certificate time: "+b.toISOString()+" Current time: "+new Date(f).toISOString())}try{a=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{a=!1}if(!a)throw new on("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 on("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==Mx.MANAGEMENT_CANISTER_ID&&!rh({canisterId:this._canisterId,subnetId:jl.Principal.fromUint8Array(new Uint8Array(t.subnet_id)),tree:r.cert.tree}))throw new on(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,Tr.toHex)(t.subnet_id)}`);let n=Hl(r.lookup(["subnet",t.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,Tr.toHex)(t.subnet_id)}`);return n}};Oe.Certificate=Ll;Bo=new WeakMap;var Fs=(0,Tr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Lx=96;function Hx(e){let t=Fs.byteLength+Lx;if(e.byteLength!==t)throw new TypeError(`BLS DER-encoded public key must be ${t} bytes long`);let r=e.slice(0,Fs.byteLength);if(!(0,Tr.bufEquals)(r,Fs))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Fs}, but get ${r}`);return e.slice(Fs.byteLength)}function Hl(e){if(e.status===Mt.Found){if(e.value instanceof ArrayBuffer)return e.value;if(e.value instanceof Uint8Array)return e.value.buffer}}Oe.lookupResultToBuffer=Hl;async function Vs(e){switch(e[0]){case Tt.Empty:return(0,Io.hash)(Us("ic-hashtree-empty"));case Tt.Pruned:return e[1];case Tt.Leaf:return(0,Io.hash)((0,Tr.concat)(Us("ic-hashtree-leaf"),e[1]));case Tt.Labeled:return(0,Io.hash)((0,Tr.concat)(Us("ic-hashtree-labeled"),e[1],await Vs(e[2])));case Tt.Fork:return(0,Io.hash)((0,Tr.concat)(Us("ic-hashtree-fork"),await Vs(e[1]),await Vs(e[2])));default:throw new Error("unreachable")}}Oe.reconstruct=Vs;function Us(e){let t=new Uint8Array([e.length]),r=new TextEncoder().encode(e);return(0,Tr.concat)(t,r)}var Mt;(function(e){e.Unknown="unknown",e.Absent="absent",e.Found="found"})(Mt=Oe.LookupStatus||(Oe.LookupStatus={}));var cn;(function(e){e.Less="less",e.Greater="greater"})(cn||(cn={}));function Fo(e,t){if(e.length===0)switch(t[0]){case Tt.Leaf:{if(!t[1])throw new Error("Invalid tree structure for leaf");return t[1]instanceof ArrayBuffer?{status:Mt.Found,value:t[1]}:t[1]instanceof Uint8Array?{status:Mt.Found,value:t[1].buffer}:{status:Mt.Found,value:t[1]}}default:return{status:Mt.Found,value:t}}let r=typeof e[0]=="string"?new TextEncoder().encode(e[0]):e[0],n=Cs(r,t);switch(n.status){case Mt.Found:return Fo(e.slice(1),n.value);case cn.Greater:case cn.Less:return{status:Mt.Absent};default:return n}}Oe.lookup_path=Fo;function Kl(e){switch(e[0]){case Tt.Empty:return[];case Tt.Fork:return Kl(e[1]).concat(Kl(e[2]));default:return[e]}}Oe.flatten_forks=Kl;function Cs(e,t){switch(t[0]){case Tt.Labeled:return jx(e,t[1])?{status:cn.Greater}:(0,Tr.bufEquals)(e,t[1])?{status:Mt.Found,value:t[2]}:{status:cn.Less};case Tt.Fork:let r=Cs(e,t[1]);switch(r.status){case cn.Greater:{let n=Cs(e,t[2]);return n.status===cn.Less?{status:Mt.Absent}:n}case Mt.Unknown:{let n=Cs(e,t[2]);return n.status===cn.Less?{status:Mt.Unknown}:n}default:return r}case Tt.Pruned:return{status:Mt.Unknown};default:return{status:Mt.Absent}}}Oe.find_label=Cs;function rh(e){let{canisterId:t,subnetId:r,tree:n}=e,i=Fo(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Mt.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return th.decode(i.value).map(c=>[jl.Principal.fromUint8Array(c[0]),jl.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(t)&&c[1].gtEq(t))}Oe.check_canister_ranges=rh});var Ds=ee(lt=>{"use strict";var Kx=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]}),Gx=lt&&lt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),$x=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)&&Kx(t,e,r);return Gx(t,e),t};Object.defineProperty(lt,"__esModule",{value:!0});lt.encodePath=lt.fetchNodeKeys=lt.request=lt.CustomPath=void 0;var Rn=Ct(),Wx=wi(),An=Fi(),zx=$t(),sh=$x(vs()),nh=So(),Gl=class{constructor(t,r,n){this.key=t,this.path=r,this.decodeStrategy=n}};lt.CustomPath=Gl;var Yx=async e=>{let{agent:t,paths:r}=e,n=Rn.Principal.from(e.canisterId),i=[...new Set(r)],s=i.map(c=>(0,lt.encodePath)(c,n)),a=new Map,o=i.map((c,d)=>(async()=>{var f;try{let p=await t.readState(n,{paths:[s[d]]});if(t.rootKey==null)throw new Error("Agent is missing root key");let m=await An.Certificate.create({certificate:p.certificate,rootKey:t.rootKey,canisterId:n,disableTimeVerification:!0}),b=(v,F)=>{if(F==="subnet"){if(t.rootKey==null)throw new Error("Agent is missing root key");let C=(0,lt.fetchNodeKeys)(p.certificate,n,t.rootKey);return{path:F,data:C}}else return{path:F,data:(0,An.lookupResultToBuffer)(v.lookup((0,lt.encodePath)(F,n)))}},{path:l,data:A}=b(m,i[d]);if(!A)console.warn(`Expected to find result for path ${l}, but instead found nothing.`),typeof l=="string"?a.set(l,null):a.set(l.key,null);else switch(l){case"time":{a.set(l,(0,nh.decodeTime)(A));break}case"controllers":{a.set(l,Qx(A));break}case"module_hash":{a.set(l,ih(A));break}case"subnet":{a.set(l,A);break}case"candid":{a.set(l,new TextDecoder().decode(A));break}default:if(typeof l!="string"&&"key"in l&&"path"in l)switch(l.decodeStrategy){case"raw":a.set(l.key,A);break;case"leb128":{a.set(l.key,(0,nh.decodeLeb128)(A));break}case"cbor":{a.set(l.key,ah(A));break}case"hex":{a.set(l.key,ih(A));break}case"utf-8":a.set(l.key,Xx(A))}}}catch(p){if(!((f=p?.message)===null||f===void 0)&&f.includes("Invalid certificate"))throw new Wx.AgentError(p.message);typeof c!="string"&&"key"in c&&"path"in c?a.set(c.key,null):a.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(p),console.groupEnd()}})());return await Promise.all(o),a};lt.request=Yx;var Jx=(e,t,r)=>{if(!t._isPrincipal)throw new Error("Invalid canisterId");let n=sh.decode(new Uint8Array(e)),i=n.tree,s=n.delegation,a;if(s&&s.subnet_id?a=Rn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(a=Rn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:a.toUint8Array(),certificate:new ArrayBuffer(0)}):(a=Rn.Principal.selfAuthenticating(Rn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:a.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,An.check_canister_ranges)({canisterId:t,subnetId:a,tree:i}))throw new Error("Canister not in range");let c=(0,An.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==An.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let d=(0,An.flatten_forks)(c.value),f=new Map;return d.forEach(p=>{let m=Rn.Principal.from(new Uint8Array(p[1])).toText(),b=(0,An.lookup_path)(["public_key"],p[2]);if(b.status!==An.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:Rn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:f}};lt.fetchNodeKeys=Jx;var Zx=(e,t)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(t.toUint8Array().buffer).buffer;switch(e){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in e&&"path"in e)if(typeof e.path=="string"||e.path instanceof ArrayBuffer){let s=e.path,a=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),a]}else return e.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${e} was formatted correctly.`)};lt.encodePath=Zx;var ih=e=>(0,zx.toHex)(e),ah=e=>sh.decode(e),Xx=e=>new TextDecoder().decode(e),Qx=e=>ah(e).map(r=>Rn.Principal.fromUint8Array(new Uint8Array(r)))});var Ah=ee(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.add5L=ye.add5H=ye.add4H=ye.add4L=ye.add3H=ye.add3L=ye.rotlBL=ye.rotlBH=ye.rotlSL=ye.rotlSH=ye.rotr32L=ye.rotr32H=ye.rotrBL=ye.rotrBH=ye.rotrSL=ye.rotrSH=ye.shrSL=ye.shrSH=ye.toBig=void 0;ye.fromBig=Wl;ye.split=oh;ye.add=xh;var Uo=BigInt(2**32-1),$l=BigInt(32);function Wl(e,t=!1){return t?{h:Number(e&Uo),l:Number(e>>$l&Uo)}:{h:Number(e>>$l&Uo)|0,l:Number(e&Uo)|0}}function oh(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:s,l:a}=Wl(e[i],t);[r[i],n[i]]=[s,a]}return[r,n]}var ch=(e,t)=>BigInt(e>>>0)<<$l|BigInt(t>>>0);ye.toBig=ch;var uh=(e,t,r)=>e>>>r;ye.shrSH=uh;var lh=(e,t,r)=>e<<32-r|t>>>r;ye.shrSL=lh;var dh=(e,t,r)=>e>>>r|t<<32-r;ye.rotrSH=dh;var fh=(e,t,r)=>e<<32-r|t>>>r;ye.rotrSL=fh;var ph=(e,t,r)=>e<<64-r|t>>>r-32;ye.rotrBH=ph;var hh=(e,t,r)=>e>>>r-32|t<<64-r;ye.rotrBL=hh;var _h=(e,t)=>t;ye.rotr32H=_h;var yh=(e,t)=>e;ye.rotr32L=yh;var mh=(e,t,r)=>e<<r|t>>>32-r;ye.rotlSH=mh;var gh=(e,t,r)=>t<<r|e>>>32-r;ye.rotlSL=gh;var bh=(e,t,r)=>t<<r-32|e>>>64-r;ye.rotlBH=bh;var wh=(e,t,r)=>e<<r-32|t>>>64-r;ye.rotlBL=wh;function xh(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var Th=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);ye.add3L=Th;var Nh=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;ye.add3H=Nh;var Eh=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);ye.add4L=Eh;var Oh=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0;ye.add4H=Oh;var vh=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0);ye.add5L=vh;var Rh=(e,t,r,n,i,s)=>t+r+n+i+s+(e/2**32|0)|0;ye.add5H=Rh;var eT={fromBig:Wl,split:oh,toBig:ch,shrSH:uh,shrSL:lh,rotrSH:dh,rotrSL:fh,rotrBH:ph,rotrBL:hh,rotr32H:_h,rotr32L:yh,rotlSH:mh,rotlSL:gh,rotlBH:bh,rotlBL:wh,add:xh,add3L:Th,add3H:Nh,add4L:Eh,add4H:Oh,add5H:Rh,add5L:vh};ye.default=eT});var Sh=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 tT=pu(),we=Ah(),Do=Kn(),[rT,nT]=we.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))),Sn=new Uint32Array(80),In=new Uint32Array(80),Zn=class extends tT.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:s,Cl:a,Dh:o,Dl:c,Eh:d,El:f,Fh:p,Fl:m,Gh:b,Gl:l,Hh:A,Hl:v}=this;return[t,r,n,i,s,a,o,c,d,f,p,m,b,l,A,v]}set(t,r,n,i,s,a,o,c,d,f,p,m,b,l,A,v){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=a|0,this.Dh=o|0,this.Dl=c|0,this.Eh=d|0,this.El=f|0,this.Fh=p|0,this.Fl=m|0,this.Gh=b|0,this.Gl=l|0,this.Hh=A|0,this.Hl=v|0}process(t,r){for(let E=0;E<16;E++,r+=4)Sn[E]=t.getUint32(r),In[E]=t.getUint32(r+=4);for(let E=16;E<80;E++){let H=Sn[E-15]|0,x=In[E-15]|0,q=we.default.rotrSH(H,x,1)^we.default.rotrSH(H,x,8)^we.default.shrSH(H,x,7),K=we.default.rotrSL(H,x,1)^we.default.rotrSL(H,x,8)^we.default.shrSL(H,x,7),G=Sn[E-2]|0,D=In[E-2]|0,ae=we.default.rotrSH(G,D,19)^we.default.rotrBH(G,D,61)^we.default.shrSH(G,D,6),Q=we.default.rotrSL(G,D,19)^we.default.rotrBL(G,D,61)^we.default.shrSL(G,D,6),ne=we.default.add4L(K,Q,In[E-7],In[E-16]),w=we.default.add4H(ne,q,ae,Sn[E-7],Sn[E-16]);Sn[E]=w|0,In[E]=ne|0}let{Ah:n,Al:i,Bh:s,Bl:a,Ch:o,Cl:c,Dh:d,Dl:f,Eh:p,El:m,Fh:b,Fl:l,Gh:A,Gl:v,Hh:F,Hl:C}=this;for(let E=0;E<80;E++){let H=we.default.rotrSH(p,m,14)^we.default.rotrSH(p,m,18)^we.default.rotrBH(p,m,41),x=we.default.rotrSL(p,m,14)^we.default.rotrSL(p,m,18)^we.default.rotrBL(p,m,41),q=p&b^~p&A,K=m&l^~m&v,G=we.default.add5L(C,x,K,nT[E],In[E]),D=we.default.add5H(G,F,H,q,rT[E],Sn[E]),ae=G|0,Q=we.default.rotrSH(n,i,28)^we.default.rotrBH(n,i,34)^we.default.rotrBH(n,i,39),ne=we.default.rotrSL(n,i,28)^we.default.rotrBL(n,i,34)^we.default.rotrBL(n,i,39),w=n&s^n&o^s&o,g=i&a^i&c^a&c;F=A|0,C=v|0,A=b|0,v=l|0,b=p|0,l=m|0,{h:p,l:m}=we.default.add(d|0,f|0,D|0,ae|0),d=o|0,f=c|0,o=s|0,c=a|0,s=n|0,a=i|0;let S=we.default.add3L(ae,ne,g);n=we.default.add3H(S,D,Q,w),i=S|0}({h:n,l:i}=we.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:a}=we.default.add(this.Bh|0,this.Bl|0,s|0,a|0),{h:o,l:c}=we.default.add(this.Ch|0,this.Cl|0,o|0,c|0),{h:d,l:f}=we.default.add(this.Dh|0,this.Dl|0,d|0,f|0),{h:p,l:m}=we.default.add(this.Eh|0,this.El|0,p|0,m|0),{h:b,l}=we.default.add(this.Fh|0,this.Fl|0,b|0,l|0),{h:A,l:v}=we.default.add(this.Gh|0,this.Gl|0,A|0,v|0),{h:F,l:C}=we.default.add(this.Hh|0,this.Hl|0,F|0,C|0),this.set(n,i,s,a,o,c,d,f,p,m,b,l,A,v,F,C)}roundClean(){Sn.fill(0),In.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};yt.SHA512=Zn;var Vo=class extends Zn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}};yt.SHA512_224=Vo;var Co=class extends Zn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}};yt.SHA512_256=Co;var qo=class extends Zn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};yt.SHA384=qo;yt.sha512=(0,Do.wrapConstructor)(()=>new Zn);yt.sha512_224=(0,Do.wrapConstructor)(()=>new Vo);yt.sha512_256=(0,Do.wrapConstructor)(()=>new Co);yt.sha384=(0,Do.wrapConstructor)(()=>new qo)});var Bh=ee(Yl=>{"use strict";Object.defineProperty(Yl,"__esModule",{value:!0});Yl.twistedEdwards=oT;var zl=Bl(),Ih=jr(),Jt=Qt(),rr=Qt(),Nr=BigInt(0),Yt=BigInt(1),ko=BigInt(2),iT=BigInt(8),sT={zip215:!0};function aT(e){let t=(0,zl.validateBasic)(e);return Jt.validateObject(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function oT(e){let t=aT(e),{Fp:r,n,prehash:i,hash:s,randomBytes:a,nByteLength:o,h:c}=t,d=ko<<BigInt(o*8)-Yt,f=r.create,p=(0,Ih.Field)(t.n,t.nBitLength),m=t.uvRatio||((R,I)=>{try{return{isValid:!0,value:r.sqrt(R*r.inv(I))}}catch{return{isValid:!1,value:Nr}}}),b=t.adjustScalarBytes||(R=>R),l=t.domain||((R,I,j)=>{if((0,rr.abool)("phflag",j),I.length||j)throw new Error("Contexts/pre-hash are not supported");return R});function A(R,I){Jt.aInRange("coordinate "+R,I,Nr,d)}function v(R){if(!(R instanceof E))throw new Error("ExtendedPoint expected")}let F=(0,rr.memoized)((R,I)=>{let{ex:j,ey:Y,ez:oe}=R,se=R.is0();I==null&&(I=se?iT:r.inv(oe));let z=f(j*I),U=f(Y*I),_=f(oe*I);if(se)return{x:Nr,y:Yt};if(_!==Yt)throw new Error("invZ was invalid");return{x:z,y:U}}),C=(0,rr.memoized)(R=>{let{a:I,d:j}=t;if(R.is0())throw new Error("bad point: ZERO");let{ex:Y,ey:oe,ez:se,et:z}=R,U=f(Y*Y),_=f(oe*oe),Z=f(se*se),re=f(Z*Z),le=f(U*I),X=f(Z*f(le+_)),u=f(re+f(j*f(U*_)));if(X!==u)throw new Error("bad point: equation left != right (1)");let h=f(Y*oe),y=f(se*z);if(h!==y)throw new Error("bad point: equation left != right (2)");return!0});class E{constructor(I,j,Y,oe){this.ex=I,this.ey=j,this.ez=Y,this.et=oe,A("x",I),A("y",j),A("z",Y),A("t",oe),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(I){if(I instanceof E)throw new Error("extended point not allowed");let{x:j,y:Y}=I||{};return A("x",j),A("y",Y),new E(j,Y,Yt,f(j*Y))}static normalizeZ(I){let j=r.invertBatch(I.map(Y=>Y.ez));return I.map((Y,oe)=>Y.toAffine(j[oe])).map(E.fromAffine)}static msm(I,j){return(0,zl.pippenger)(E,p,I,j)}_setWindowSize(I){q.setWindowSize(this,I)}assertValidity(){C(this)}equals(I){v(I);let{ex:j,ey:Y,ez:oe}=this,{ex:se,ey:z,ez:U}=I,_=f(j*U),Z=f(se*oe),re=f(Y*U),le=f(z*oe);return _===Z&&re===le}is0(){return this.equals(E.ZERO)}negate(){return new E(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:I}=t,{ex:j,ey:Y,ez:oe}=this,se=f(j*j),z=f(Y*Y),U=f(ko*f(oe*oe)),_=f(I*se),Z=j+Y,re=f(f(Z*Z)-se-z),le=_+z,X=le-U,u=_-z,h=f(re*X),y=f(le*u),P=f(re*u),O=f(X*le);return new E(h,y,O,P)}add(I){v(I);let{a:j,d:Y}=t,{ex:oe,ey:se,ez:z,et:U}=this,{ex:_,ey:Z,ez:re,et:le}=I;if(j===BigInt(-1)){let J=f((se-oe)*(Z+_)),te=f((se+oe)*(Z-_)),de=f(te-J);if(de===Nr)return this.double();let ge=f(z*ko*le),Ie=f(U*ko*re),Ue=Ie+ge,_e=te+J,fe=Ie-ge,Ke=f(Ue*de),Ht=f(_e*fe),Ut=f(Ue*fe),Vt=f(de*_e);return new E(Ke,Ht,Vt,Ut)}let X=f(oe*_),u=f(se*Z),h=f(U*Y*le),y=f(z*re),P=f((oe+se)*(_+Z)-X-u),O=y-h,B=y+h,M=f(u-j*X),T=f(P*O),V=f(B*M),L=f(P*M),k=f(O*B);return new E(T,V,k,L)}subtract(I){return this.add(I.negate())}wNAF(I){return q.wNAFCached(this,I,E.normalizeZ)}multiply(I){let j=I;Jt.aInRange("scalar",j,Yt,n);let{p:Y,f:oe}=this.wNAF(j);return E.normalizeZ([Y,oe])[0]}multiplyUnsafe(I){let j=I;return Jt.aInRange("scalar",j,Nr,n),j===Nr?x:this.equals(x)||j===Yt?this:this.equals(H)?this.wNAF(j).p:q.unsafeLadder(this,j)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return q.unsafeLadder(this,n).is0()}toAffine(I){return F(this,I)}clearCofactor(){let{h:I}=t;return I===Yt?this:this.multiplyUnsafe(I)}static fromHex(I,j=!1){let{d:Y,a:oe}=t,se=r.BYTES;I=(0,rr.ensureBytes)("pointHex",I,se),(0,rr.abool)("zip215",j);let z=I.slice(),U=I[se-1];z[se-1]=U&-129;let _=Jt.bytesToNumberLE(z),Z=j?d:r.ORDER;Jt.aInRange("pointHex.y",_,Nr,Z);let re=f(_*_),le=f(re-Yt),X=f(Y*re-oe),{isValid:u,value:h}=m(le,X);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let y=(h&Yt)===Yt,P=(U&128)!==0;if(!j&&h===Nr&&P)throw new Error("Point.fromHex: x=0 and x_0=1");return P!==y&&(h=f(-h)),E.fromAffine({x:h,y:_})}static fromPrivateKey(I){return D(I).point}toRawBytes(){let{x:I,y:j}=this.toAffine(),Y=Jt.numberToBytesLE(j,r.BYTES);return Y[Y.length-1]|=I&Yt?128:0,Y}toHex(){return Jt.bytesToHex(this.toRawBytes())}}E.BASE=new E(t.Gx,t.Gy,Yt,f(t.Gx*t.Gy)),E.ZERO=new E(Nr,Yt,Yt,Nr);let{BASE:H,ZERO:x}=E,q=(0,zl.wNAF)(E,o*8);function K(R){return(0,Ih.mod)(R,n)}function G(R){return K(Jt.bytesToNumberLE(R))}function D(R){let I=o;R=(0,rr.ensureBytes)("private key",R,I);let j=(0,rr.ensureBytes)("hashed private key",s(R),2*I),Y=b(j.slice(0,I)),oe=j.slice(I,2*I),se=G(Y),z=H.multiply(se),U=z.toRawBytes();return{head:Y,prefix:oe,scalar:se,point:z,pointBytes:U}}function ae(R){return D(R).pointBytes}function Q(R=new Uint8Array,...I){let j=Jt.concatBytes(...I);return G(s(l(j,(0,rr.ensureBytes)("context",R),!!i)))}function ne(R,I,j={}){R=(0,rr.ensureBytes)("message",R),i&&(R=i(R));let{prefix:Y,scalar:oe,pointBytes:se}=D(I),z=Q(j.context,Y,R),U=H.multiply(z).toRawBytes(),_=Q(j.context,U,se,R),Z=K(z+_*oe);Jt.aInRange("signature.s",Z,Nr,n);let re=Jt.concatBytes(U,Jt.numberToBytesLE(Z,r.BYTES));return(0,rr.ensureBytes)("result",re,o*2)}let w=sT;function g(R,I,j,Y=w){let{context:oe,zip215:se}=Y,z=r.BYTES;R=(0,rr.ensureBytes)("signature",R,2*z),I=(0,rr.ensureBytes)("message",I),se!==void 0&&(0,rr.abool)("zip215",se),i&&(I=i(I));let U=Jt.bytesToNumberLE(R.slice(z,2*z)),_,Z,re;try{_=E.fromHex(j,se),Z=E.fromHex(R.slice(0,z),se),re=H.multiplyUnsafe(U)}catch{return!1}if(!se&&_.isSmallOrder())return!1;let le=Q(oe,Z.toRawBytes(),_.toRawBytes(),I);return Z.add(_.multiplyUnsafe(le)).subtract(re).clearCofactor().equals(E.ZERO)}return H._setWindowSize(8),{CURVE:t,getPublicKey:ae,sign:ne,verify:g,ExtendedPoint:E,utils:{getExtendedPublicKey:D,randomPrivateKey:()=>a(r.BYTES),precompute(R=8,I=E.BASE){return I._setWindowSize(R),I.multiply(BigInt(3)),I}}}}});var Fh=ee(Zl=>{"use strict";Object.defineProperty(Zl,"__esModule",{value:!0});Zl.montgomery=uT;var Ph=jr(),Bn=Qt(),Ui=BigInt(0),Jl=BigInt(1);function cT(e){return(0,Bn.validateObject)(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}function uT(e){let t=cT(e),{P:r}=t,n=C=>(0,Ph.mod)(C,r),i=t.montgomeryBits,s=Math.ceil(i/8),a=t.nByteLength,o=t.adjustScalarBytes||(C=>C),c=t.powPminus2||(C=>(0,Ph.pow)(C,r-BigInt(2),r));function d(C,E,H){let x=n(C*(E-H));return E=n(E-x),H=n(H+x),[E,H]}let f=(t.a-BigInt(2))/BigInt(4);function p(C,E){(0,Bn.aInRange)("u",C,Ui,r),(0,Bn.aInRange)("scalar",E,Ui,r);let H=E,x=C,q=Jl,K=Ui,G=C,D=Jl,ae=Ui,Q;for(let w=BigInt(i-1);w>=Ui;w--){let g=H>>w&Jl;ae^=g,Q=d(ae,q,G),q=Q[0],G=Q[1],Q=d(ae,K,D),K=Q[0],D=Q[1],ae=g;let S=q+K,R=n(S*S),I=q-K,j=n(I*I),Y=R-j,oe=G+D,se=G-D,z=n(se*S),U=n(oe*I),_=z+U,Z=z-U;G=n(_*_),D=n(x*n(Z*Z)),q=n(R*j),K=n(Y*(R+n(f*Y)))}Q=d(ae,q,G),q=Q[0],G=Q[1],Q=d(ae,K,D),K=Q[0],D=Q[1];let ne=c(K);return n(q*ne)}function m(C){return(0,Bn.numberToBytesLE)(n(C),s)}function b(C){let E=(0,Bn.ensureBytes)("u coordinate",C,s);return a===32&&(E[31]&=127),(0,Bn.bytesToNumberLE)(E)}function l(C){let E=(0,Bn.ensureBytes)("scalar",C),H=E.length;if(H!==s&&H!==a)throw new Error(`Expected ${s} or ${a} bytes, got ${H}`);return(0,Bn.bytesToNumberLE)(o(E))}function A(C,E){let H=b(E),x=l(C),q=p(H,x);if(q===Ui)throw new Error("Invalid private or public key received");return m(q)}let v=m(t.Gu);function F(C){return A(C,v)}return{scalarMult:A,scalarMultBase:F,getSharedSecret:(C,E)=>A(C,E),getPublicKey:C=>F(C),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:v}}});var sd=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=Hh;me.edwardsToMontgomeryPriv=fT;var jo=Sh(),ks=Kn(),rd=Bh(),qh=wo(),Ce=jr(),lT=Fh(),Xn=Qt(),Ms=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ed=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),dT=BigInt(0),Lr=BigInt(1),Mo=BigInt(2),Dh=BigInt(3),kh=BigInt(5),nd=BigInt(8);function Mh(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=Ms,o=e*e%s*e%s,c=(0,Ce.pow2)(o,Mo,s)*o%s,d=(0,Ce.pow2)(c,Lr,s)*e%s,f=(0,Ce.pow2)(d,kh,s)*d%s,p=(0,Ce.pow2)(f,t,s)*f%s,m=(0,Ce.pow2)(p,r,s)*p%s,b=(0,Ce.pow2)(m,n,s)*m%s,l=(0,Ce.pow2)(b,i,s)*b%s,A=(0,Ce.pow2)(l,i,s)*b%s,v=(0,Ce.pow2)(A,t,s)*f%s;return{pow_p_5_8:(0,Ce.pow2)(v,Mo,s)*e%s,b2:o}}function jh(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function id(e,t){let r=Ms,n=(0,Ce.mod)(t*t*t,r),i=(0,Ce.mod)(n*n*t,r),s=Mh(e*i).pow_p_5_8,a=(0,Ce.mod)(e*n*s,r),o=(0,Ce.mod)(t*a*a,r),c=a,d=(0,Ce.mod)(a*ed,r),f=o===e,p=o===(0,Ce.mod)(-e,r),m=o===(0,Ce.mod)(-e*ed,r);return f&&(a=c),(p||m)&&(a=d),(0,Ce.isNegativeLE)(a,r)&&(a=(0,Ce.mod)(-a,r)),{isValid:f||p,value:a}}me.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var ue=(0,Ce.Field)(Ms,void 0,!0),js={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ue,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:nd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:jo.sha512,randomBytes:ks.randomBytes,adjustScalarBytes:jh,uvRatio:id};me.ed25519=(0,rd.twistedEdwards)(js);function Lh(e,t,r){if(t.length>255)throw new Error("Context is too big");return(0,ks.concatBytes)((0,ks.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}me.ed25519ctx=(0,rd.twistedEdwards)({...js,domain:Lh});me.ed25519ph=(0,rd.twistedEdwards)(Object.assign({},js,{domain:Lh,prehash:jo.sha512}));me.x25519=(0,lT.montgomery)({P:Ms,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{let t=Ms,{pow_p_5_8:r,b2:n}=Mh(e);return(0,Ce.mod)((0,Ce.pow2)(r,Dh,t)*n,t)},adjustScalarBytes:jh,randomBytes:ks.randomBytes});function Hh(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=Hh;function fT(e){let t=js.hash(e.subarray(0,32));return js.adjustScalarBytes(t).subarray(0,32)}var pT=(ue.ORDER+Dh)/nd,hT=ue.pow(Mo,pT),Uh=ue.sqrt(ue.neg(ue.ONE));function _T(e){let t=(ue.ORDER-kh)/nd,r=BigInt(486662),n=ue.sqr(e);n=ue.mul(n,Mo);let i=ue.add(n,ue.ONE),s=ue.neg(r),a=ue.sqr(i),o=ue.mul(a,i),c=ue.mul(n,r);c=ue.mul(c,s),c=ue.add(c,a),c=ue.mul(c,s);let d=ue.sqr(o);a=ue.sqr(d),d=ue.mul(d,o),d=ue.mul(d,c),a=ue.mul(a,d);let f=ue.pow(a,t);f=ue.mul(f,d);let p=ue.mul(f,Uh);a=ue.sqr(f),a=ue.mul(a,o);let m=ue.eql(a,c),b=ue.cmov(p,f,m),l=ue.mul(s,n),A=ue.mul(f,e);A=ue.mul(A,hT);let v=ue.mul(A,Uh),F=ue.mul(c,n);a=ue.sqr(A),a=ue.mul(a,o);let C=ue.eql(a,F),E=ue.cmov(v,A,C);a=ue.sqr(b),a=ue.mul(a,o);let H=ue.eql(a,c),x=ue.cmov(l,s,H),q=ue.cmov(E,b,H),K=ue.isOdd(q);return q=ue.cmov(q,ue.neg(q),H!==K),{xMn:x,xMd:i,yMn:q,yMd:Lr}}var yT=(0,Ce.FpSqrtEven)(ue,ue.neg(BigInt(486664)));function mT(e){let{xMn:t,xMd:r,yMn:n,yMd:i}=_T(e),s=ue.mul(t,i);s=ue.mul(s,yT);let a=ue.mul(r,n),o=ue.sub(t,r),c=ue.add(t,r),d=ue.mul(a,c),f=ue.eql(d,ue.ZERO);s=ue.cmov(s,ue.ZERO,f),a=ue.cmov(a,ue.ONE,f),o=ue.cmov(o,ue.ONE,f),c=ue.cmov(c,ue.ONE,f);let p=ue.invertBatch([a,c]);return{x:ue.mul(s,p[0]),y:ue.mul(o,p[1])}}var Kh=(0,qh.createHasher)(me.ed25519.ExtendedPoint,e=>mT(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:jo.sha512});me.hashToCurve=Kh.hashToCurve;me.encodeToCurve=Kh.encodeToCurve;function Xl(e){if(!(e instanceof Er))throw new Error("RistrettoPoint expected")}var td=ed,gT=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),bT=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),wT=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),xT=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Vh=e=>id(Lr,e),TT=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Ql=e=>me.ed25519.CURVE.Fp.create((0,Xn.bytesToNumberLE)(e)&TT);function Ch(e){let{d:t}=me.ed25519.CURVE,r=me.ed25519.CURVE.Fp.ORDER,n=me.ed25519.CURVE.Fp.create,i=n(td*e*e),s=n((i+Lr)*wT),a=BigInt(-1),o=n((a-t*i)*n(i+t)),{isValid:c,value:d}=id(s,o),f=n(d*e);(0,Ce.isNegativeLE)(f,r)||(f=n(-f)),c||(d=f),c||(a=i);let p=n(a*(i-Lr)*xT-o),m=d*d,b=n((d+d)*o),l=n(p*gT),A=n(Lr-m),v=n(Lr+m);return new me.ed25519.ExtendedPoint(n(b*v),n(A*l),n(l*v),n(b*A))}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,Xn.ensureBytes)("ristrettoHash",t,64);let r=Ql(t.slice(0,32)),n=Ch(r),i=Ql(t.slice(32,64)),s=Ch(i);return new e(n.add(s))}static fromHex(t){t=(0,Xn.ensureBytes)("ristrettoHex",t,32);let{a:r,d:n}=me.ed25519.CURVE,i=me.ed25519.CURVE.Fp.ORDER,s=me.ed25519.CURVE.Fp.create,a="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",o=Ql(t);if(!(0,Xn.equalBytes)((0,Xn.numberToBytesLE)(o,32),t)||(0,Ce.isNegativeLE)(o,i))throw new Error(a);let c=s(o*o),d=s(Lr+r*c),f=s(Lr-r*c),p=s(d*d),m=s(f*f),b=s(r*n*p-m),{isValid:l,value:A}=Vh(s(b*m)),v=s(A*f),F=s(A*v*b),C=s((o+o)*v);(0,Ce.isNegativeLE)(C,i)&&(C=s(-C));let E=s(d*F),H=s(C*E);if(!l||(0,Ce.isNegativeLE)(H,i)||E===dT)throw new Error(a);return new e(new me.ed25519.ExtendedPoint(C,E,Lr,H))}toRawBytes(){let{ex:t,ey:r,ez:n,et:i}=this.ep,s=me.ed25519.CURVE.Fp.ORDER,a=me.ed25519.CURVE.Fp.create,o=a(a(n+r)*a(n-r)),c=a(t*r),d=a(c*c),{value:f}=Vh(a(o*d)),p=a(f*o),m=a(f*c),b=a(p*m*i),l;if((0,Ce.isNegativeLE)(i*b,s)){let v=a(r*td),F=a(t*td);t=v,r=F,l=a(p*bT)}else l=m;(0,Ce.isNegativeLE)(t*b,s)&&(r=a(-r));let A=a((n-r)*l);return(0,Ce.isNegativeLE)(A,s)&&(A=a(-A)),(0,Xn.numberToBytesLE)(A,32)}toHex(){return(0,Xn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(t){Xl(t);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=t.ep,a=me.ed25519.CURVE.Fp.create,o=a(r*s)===a(n*i),c=a(n*s)===a(r*i);return o||c}add(t){return Xl(t),new e(this.ep.add(t.ep))}subtract(t){return Xl(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 NT=(e,t)=>{let r=t.DST,n=typeof r=="string"?(0,ks.utf8ToBytes)(r):r,i=(0,qh.expand_message_xmd)(e,n,64,jo.sha512);return Er.hashToCurve(i)};me.hashToRistretto255=NT;me.hash_to_ristretto255=me.hashToRistretto255});var zh=ee(Pn=>{"use strict";var Gh=Pn&&Pn.__classPrivateFieldSet||function(e,t,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},jt=Pn&&Pn.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},It,Ls,$h,Wh;Object.defineProperty(Pn,"__esModule",{value:!0});Pn.ExpirableMap=void 0;var ad=class{constructor(t={}){It.set(this,void 0),Ls.set(this,void 0),this[$h]=this.entries.bind(this),this[Wh]="ExpirableMap";let{source:r=[],expirationTime:n=600*1e3}=t,i=Date.now();Gh(this,It,new Map([...r].map(([s,a])=>[s,{value:a,timestamp:i}])),"f"),Gh(this,Ls,n,"f")}prune(){let t=Date.now();for(let[r,n]of jt(this,It,"f").entries())t-n.timestamp>jt(this,Ls,"f")&&jt(this,It,"f").delete(r);return this}set(t,r){this.prune();let n={value:r,timestamp:Date.now()};return jt(this,It,"f").set(t,n),this}get(t){let r=jt(this,It,"f").get(t);if(r!==void 0){if(Date.now()-r.timestamp>jt(this,Ls,"f")){jt(this,It,"f").delete(t);return}return r.value}}clear(){jt(this,It,"f").clear()}entries(){let t=jt(this,It,"f").entries();return function*(){for(let[n,i]of t)yield[n,i.value]}()}values(){let t=jt(this,It,"f").values();return function*(){for(let n of t)yield n.value}()}keys(){return jt(this,It,"f").keys()}forEach(t,r){for(let[n,i]of jt(this,It,"f").entries())t.call(r,i.value,n,this)}has(t){return jt(this,It,"f").has(t)}delete(t){return jt(this,It,"f").delete(t)}get size(){return jt(this,It,"f").size}};Pn.ExpirableMap=ad;It=new WeakMap,Ls=new WeakMap,$h=Symbol.iterator,Wh=Symbol.toStringTag});var od=ee(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.unwrapDER=je.wrapDER=je.SECP256K1_OID=je.ED25519_OID=je.DER_COSE_OID=je.decodeLen=je.decodeLenBytes=je.encodeLen=je.encodeLenBytes=void 0;var ET=$t(),OT=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)")};je.encodeLenBytes=OT;var vT=(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)")};je.encodeLen=vT;var RT=(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)")};je.decodeLenBytes=RT;var AT=(e,t)=>{let r=(0,je.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)")};je.decodeLen=AT;je.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);je.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);je.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function ST(e,t){let r=2+(0,je.encodeLenBytes)(e.byteLength+1),n=t.byteLength+r+e.byteLength,i=0,s=new Uint8Array(1+(0,je.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,je.encodeLen)(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=(0,je.encodeLen)(s,i,e.byteLength+1),s[i++]=0,s.set(new Uint8Array(e),i),s}je.wrapDER=ST;var IT=(e,t)=>{let r=0,n=(o,c)=>{if(i[r++]!==o)throw new Error("Expected: "+c)},i=new Uint8Array(e);if(n(48,"sequence"),r+=(0,je.decodeLenBytes)(i,r),!(0,ET.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,je.decodeLen)(i,r)-1;r+=(0,je.decodeLenBytes)(i,r),n(0,"0 padding");let a=i.slice(r);if(s!==a.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${a.length}`);return a};je.unwrapDER=IT});var cd=ee(Fn=>{"use strict";var Yh=Fn&&Fn.__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},Jh=Fn&&Fn.__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)},Ho,Ko;Object.defineProperty(Fn,"__esModule",{value:!0});Fn.Ed25519PublicKey=void 0;var Lo=od(),Go=class e{constructor(t){if(Ho.set(this,void 0),Ko.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Yh(this,Ho,t,"f"),Yh(this,Ko,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,Lo.wrapDER)(t,Lo.ED25519_OID).buffer}static derDecode(t){let r=(0,Lo.unwrapDER)(t,Lo.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 Jh(this,Ho,"f")}get derKey(){return Jh(this,Ko,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Fn.Ed25519PublicKey=Go;Ho=new WeakMap,Ko=new WeakMap;Go.RAW_KEY_LENGTH=32});var ld=ee(Vi=>{"use strict";Object.defineProperty(Vi,"__esModule",{value:!0});Vi.ObservableLog=Vi.Observable=void 0;var $o=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))}};Vi.Observable=$o;var ud=class extends $o{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)}};Vi.ObservableLog=ud});var n_=ee(Gr=>{"use strict";var Hr=Gr&&Gr.__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=Gr&&Gr.__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,Wo,zo,Yo,Jo,Zo,Xo,Qo,Ci;Object.defineProperty(Gr,"__esModule",{value:!0});Gr.exponentialBackoff=Gr.ExponentialBackoff=void 0;var Zh=.5,Xh=1.5,Qh=500,e_=6e4,t_=9e5,r_=10,qi=class e{constructor(t=e.default){Kr.set(this,void 0),Wo.set(this,void 0),zo.set(this,void 0),Yo.set(this,void 0),Jo.set(this,void 0),Zo.set(this,void 0),Xo.set(this,void 0),Qo.set(this,void 0),Ci.set(this,0);let{initialInterval:r=Qh,randomizationFactor:n=Zh,multiplier:i=Xh,maxInterval:s=e_,maxElapsedTime:a=t_,maxIterations:o=r_,date:c=Date}=t;Hr(this,Kr,r,"f"),Hr(this,Wo,n,"f"),Hr(this,zo,i,"f"),Hr(this,Yo,s,"f"),Hr(this,Qo,c,"f"),Hr(this,Jo,c.now(),"f"),Hr(this,Zo,a,"f"),Hr(this,Xo,o,"f")}get ellapsedTimeInMsec(){return Bt(this,Qo,"f").now()-Bt(this,Jo,"f")}get currentInterval(){return Bt(this,Kr,"f")}get count(){return Bt(this,Ci,"f")}get randomValueFromInterval(){let t=Bt(this,Wo,"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,zo,"f"),Bt(this,Yo,"f")),"f"),Hr(this,Ci,(t=Bt(this,Ci,"f"),t++,t),"f"),Bt(this,Kr,"f")}next(){return this.ellapsedTimeInMsec>=Bt(this,Zo,"f")||Bt(this,Ci,"f")>=Bt(this,Xo,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Gr.ExponentialBackoff=qi;Kr=new WeakMap,Wo=new WeakMap,zo=new WeakMap,Yo=new WeakMap,Jo=new WeakMap,Zo=new WeakMap,Xo=new WeakMap,Qo=new WeakMap,Ci=new WeakMap;qi.default={initialInterval:Qh,randomizationFactor:Zh,multiplier:Xh,maxInterval:e_,maxElapsedTime:t_,maxIterations:r_,date:Date};function*BT(e=qi.default){let t=new qi(e),r=t.next();for(;r;)yield r,r=t.next()}Gr.exponentialBackoff=BT});var pd=ee(qe=>{"use strict";var s_=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]}),PT=qe&&qe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a_=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)&&s_(t,e,r);return PT(t,e),t},o_=qe&&qe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&s_(t,e,r)},Nt=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,Qn,Hi,$r,un,Li,Hs,ki,vr,Rr,ei,ti,Ks,Mi,ji,ri,ii,c_,rc,nc,ni;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 lr=Ct(),Wr=wi(),i_=al(),Un=a_(vs()),ec=Ns(),Or=$t(),Ar=fo(),dd=Rs(),Ki=ho(),FT=Ds(),Di=Fi(),UT=sd(),VT=zh(),CT=cd(),qT=So(),DT=ld(),kT=n_();o_(fo(),qe);o_(ho(),qe);var MT=Rs();Object.defineProperty(qe,"makeNonce",{enumerable:!0,get:function(){return MT.makeNonce}});var jT;(function(e){e.Received="received",e.Processing="processing",e.Replied="replied",e.Rejected="rejected",e.Unknown="unknown",e.Done="done"})(jT=qe.RequestStatusResponseStatus||(qe.RequestStatusResponseStatus={}));var tc=60*1e3;qe.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";qe.MANAGEMENT_CANISTER_ID="aaaaa-aa";var LT="ic0.app",HT=".ic0.app",KT="icp0.io",GT=".icp0.io",$T="icp-api.io",WT=".icp-api.io",Gs=class extends Wr.AgentError{constructor(t){super(t),this.message=t}},si=class extends Wr.AgentError{constructor(t){super(t),this.message=t}};qe.IdentityInvalidError=si;function zT(){let e;if(typeof window<"u")if(window.fetch)e=window.fetch.bind(window);else throw new Gs("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 Gs("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 Gs("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function YT(e){let t;if(e!==void 0)!e.match(/^[a-z]+:/)&&typeof window<"u"?t=new URL(window.location.protocol+"//"+e):t=new URL(e);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,a;s&&typeof s=="string"&&(n.some(o=>s.endsWith(o))?a=s:a=r.find(o=>s.endsWith(o))),i&&a?t=new URL(`${i.protocol}//${a}${i.port?":"+i.port:""}`):t=new URL("https://icp-api.io")}return t.toString()}var fd=class e{constructor(t={}){var r,n;Pt.add(this),Qn.set(this,null),Hi.set(this,!1),$r.set(this,void 0),un.set(this,void 0),Li.set(this,void 0),Hs.set(this,void 0),ki.set(this,0),vr.set(this,void 0),Rr.set(this,void 0),ei.set(this,void 0),ti.set(this,void 0),this._isAgent=!0,this.config={},Ks.set(this,0),this.log=new DT.ObservableLog,Mi.set(this,[]),ji.set(this,[]),ri.set(this,new VT.ExpirableMap({expirationTime:300*1e3})),ii.set(this,!0),nc.set(this,(a,o)=>{if(ie(this,ii,"f")===!1)return a;if(!o)throw new Di.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:c,signatures:d=[],requestId:f}=a,p=new TextEncoder().encode("\vic-response");for(let m of d){let{timestamp:b,identity:l}=m,A=lr.Principal.fromUint8Array(l).toText(),v;if(c==="replied"){let{reply:x}=a;v=(0,ec.hashOfMap)({status:c,reply:x,timestamp:BigInt(b),request_id:f})}else if(c==="rejected"){let{reject_code:x,reject_message:q,error_code:K}=a;v=(0,ec.hashOfMap)({status:c,reject_code:x,reject_message:q,error_code:K,timestamp:BigInt(b),request_id:f})}else throw new Error(`Unknown status: ${c}`);let F=(0,Or.concat)(p,new Uint8Array(v)),C=o?.nodeKeys.get(A);if(!C)throw new Di.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let E=CT.Ed25519PublicKey.fromDer(C).rawKey;if(UT.ed25519.verify(m.signature,new Uint8Array(F),new Uint8Array(E)))return a;throw new Di.CertificateVerificationError(`Invalid signature from replica ${A} signed query.`)}return a}),this.config=t,Nt(this,un,t.fetch||zT()||fetch.bind(global),"f"),Nt(this,Li,t.fetchOptions,"f"),Nt(this,Hs,t.callOptions,"f"),Nt(this,Hi,(r=t.shouldFetchRootKey)!==null&&r!==void 0?r:!1,"f"),t.rootKey?this.rootKey=t.rootKey:ie(this,Hi,"f")?this.rootKey=null:this.rootKey=(0,Or.fromHex)(qe.IC_ROOT_KEY);let i=YT(t.host);this.host=new URL(i),t.verifyQuerySignatures!==void 0&&Nt(this,ii,t.verifyQuerySignatures,"f"),Nt(this,Rr,(n=t.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new kT.ExponentialBackoff({maxIterations:ie(this,Rr,"f")});if(Nt(this,ei,t.backoffStrategy||s,"f"),this.host.hostname.endsWith(HT)?this.host.hostname=LT:this.host.hostname.endsWith(GT)?this.host.hostname=KT:this.host.hostname.endsWith(WT)&&(this.host.hostname=$T),t.credentials){let{name:a,password:o}=t.credentials;Nt(this,vr,`${a}${o?":"+o:""}`,"f")}if(Nt(this,$r,Promise.resolve(t.identity||new i_.AnonymousIdentity),"f"),t.ingressExpiryInMinutes&&t.ingressExpiryInMinutes>5)throw new Wr.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 Wr.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${t.ingressExpiryInMinutes} minutes.`);Nt(this,ti,t.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,Ar.makeNonceTransform)(dd.makeNonce)),t.useQueryNonces&&this.addTransform("query",(0,Ar.makeNonceTransform)(dd.makeNonce)),t.logToConsole&&this.log.subscribe(a=>{a.level==="error"?console.error(a.message):a.level==="warn"?console.warn(a.message):console.log(a.message)})}get waterMark(){return ie(this,Ks,"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 Wr.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,ji,"f").findIndex(s=>(s.priority||0)<n);ie(this,ji,"f").splice(i>=0?i:ie(this,ji,"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,$r,"f"))throw new si("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ie(this,$r,"f")).getPrincipal()}async call(t,r,n){var i,s;await ie(this,Pt,"m",ni).call(this);let a=(i=r.callSync)!==null&&i!==void 0?i:!0,o=await(n!==void 0?await n:await ie(this,$r,"f"));if(!o)throw new si("This identity has expired due this application's security policy. Please refresh your authentication.");let c=lr.Principal.from(t),d=r.effectiveCanisterId?lr.Principal.from(r.effectiveCanisterId):c,f=o.getPrincipal()||lr.Principal.anonymous(),p=new Ar.Expiry(ie(this,ti,"f")*tc);Math.abs(ie(this,ki,"f"))>1e3*30&&(p=new Ar.Expiry(ie(this,ti,"f")*tc+ie(this,ki,"f")));let m={request_type:dd.SubmitRequestType.Call,canister_id:c,method_name:r.methodName,arg:r.arg,sender:f,ingress_expiry:p},b=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,vr,"f")?{Authorization:"Basic "+btoa(ie(this,vr,"f"))}:{})},endpoint:"call",body:m}),l=b.body.nonce?A(b.body.nonce):void 0;m.nonce=l;function A(E){return new Uint8Array(E)}b=await o.transformRequest(b);let v=Un.encode(b.body),F=ie(this,ei,"f").call(this),C=(0,ec.requestIdOf)(m);try{let E=()=>(this.log.print(`fetching "/api/v3/canister/${d.toText()}/call" with request:`,b),ie(this,un,"f").call(this,""+new URL(`/api/v3/canister/${d.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Hs,"f")),b.request),{body:v}))),H=()=>(this.log.print(`fetching "/api/v2/canister/${d.toText()}/call" with request:`,b),ie(this,un,"f").call(this,""+new URL(`/api/v2/canister/${d.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Hs,"f")),b.request),{body:v}))),q=await ie(this,Pt,"m",rc).call(this,{request:a?E:H,backoff:F,tries:0}),K=await q.arrayBuffer(),G=q.status===200&&K.byteLength>0?Un.decode(K):null;if(G&&"certificate"in G){let D=await this.parseTimeFromResponse({certificate:G.certificate});Nt(this,Ks,D,"f")}return{requestId:C,response:{ok:q.ok,status:q.status,statusText:q.statusText,body:G,headers:(0,Ar.httpHeadersTransform)(q.headers)},requestDetails:m}}catch(E){if(E.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(t,Object.assign(Object.assign({},r),{callSync:!1}),n);let H=`Error while making call: ${(s=E.message)!==null&&s!==void 0?s:String(E)}`,x=new Ki.AgentCallError(H,E,(0,Or.toHex)(C),(0,Or.toHex)(b.body.sender_pubkey),(0,Or.toHex)(b.body.sender_sig),String(b.body.content.ingress_expiry._value));throw this.log.error(H,x),x}}async query(t,r,n){var i,s,a,o;await ie(this,Pt,"m",ni).call(this);let c=ie(this,ei,"f").call(this),d=r.effectiveCanisterId?lr.Principal.from(r.effectiveCanisterId):lr.Principal.from(t);this.log.print(`ecid ${d.toString()}`),this.log.print(`canisterId ${t.toString()}`);let f,p,m=await(n!==void 0?n:ie(this,$r,"f"));if(!m)throw new si("This identity has expired due this application's security policy. Please refresh your authentication.");let b=lr.Principal.from(t),l=m?.getPrincipal()||lr.Principal.anonymous(),A={request_type:"query",canister_id:b,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:new Ar.Expiry(ie(this,ti,"f")*tc)},v=(0,ec.requestIdOf)(A);f=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,vr,"f")?{Authorization:"Basic "+btoa(ie(this,vr,"f"))}:{})},endpoint:"read",body:A}),f=await m?.transformRequest(f);let F=Un.encode(f.body),C={canister:b.toText(),ecid:d,transformedRequest:f,body:F,requestId:v,backoff:c,tries:0},E=async()=>({requestDetails:A,query:await ie(this,Pt,"m",c_).call(this,C)}),H=async()=>{if(!ie(this,ii,"f"))return;let x=ie(this,ri,"f").get(d.toString());return x||(await this.fetchSubnetKeys(d.toString()),ie(this,ri,"f").get(d.toString()))};try{let[x,q]=await Promise.all([E(),H()]);p=x;let{requestDetails:K,query:G}=p,D=Object.assign(Object.assign({},G),{requestDetails:K});if(this.log.print("Query response:",D),!ie(this,ii,"f"))return D;try{return ie(this,nc,"f").call(this,D,q)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ie(this,ri,"f").delete(t.toString()),await this.fetchSubnetKeys(d.toString());let Q=ie(this,ri,"f").get(t.toString());if(!Q)throw new Di.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ie(this,nc,"f").call(this,D,Q)}}catch(x){let q=`Error while making call: ${(i=x.message)!==null&&i!==void 0?i:String(x)}`,K=new Ki.AgentQueryError(q,x,String(v),(0,Or.toHex)((s=f?.body)===null||s===void 0?void 0:s.sender_pubkey),(0,Or.toHex)((a=f?.body)===null||a===void 0?void 0:a.sender_sig),String((o=f?.body)===null||o===void 0?void 0:o.content.ingress_expiry._value));throw this.log.error(q,K),K}}async createReadStateRequest(t,r){await ie(this,Pt,"m",ni).call(this);let n=await(r!==void 0?await r:await ie(this,$r,"f"));if(!n)throw new si("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||lr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,vr,"f")?{Authorization:"Basic "+btoa(ie(this,vr,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:t.paths,sender:i,ingress_expiry:new Ar.Expiry(ie(this,ti,"f")*tc)}});return n?.transformRequest(s)}async readState(t,r,n,i){var s,a,o,c;function d(A){for(let v of A.paths){let[F,C]=v,E=new TextEncoder().encode("request_status");if((0,Or.bufEquals)(F,E))return C}}let f=d(r);await ie(this,Pt,"m",ni).call(this);let p=typeof t=="string"?lr.Principal.fromText(t):t,m=i??await this.createReadStateRequest(r,n),b=Un.encode(m.body);this.log.print(`fetching "/api/v2/canister/${p}/read_state" with request:`,m);let l=ie(this,ei,"f").call(this);try{let A=await ie(this,Pt,"m",rc).call(this,{request:()=>ie(this,un,"f").call(this,""+new URL(`/api/v2/canister/${p.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Li,"f")),m.request),{body:b})),backoff:l,tries:0});if(!A.ok)throw new Error(`Server returned an error:
30
+ )`}else throw new Error("Invalid tree structure for labeled");case Tt.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 Tt.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,Tr.toHex)(new Uint8Array(e[1]))}`}default:return`unknown(${JSON.stringify(e[0])})`}}Oe.hashTreeToString=Po;function Lx(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 Hl=class e{constructor(t,r,n,i,s=5,a=!1){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,Bo.set(this,!1),Cx(this,Bo,a,"f"),this.cert=rh.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=kx.blsVerify),new e(t.certificate,t.rootKey,t.canisterId,r,t.maxAgeInMinutes,t.disableTimeVerification)}lookup(t){return Fo(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=Kx(r),s=(0,Tr.concat)(Us("ic-state-root"),t),a=!1,o=Kl(this.lookup(["time"]));if(!o)throw new on("Certificate does not contain a time");if(!qx(this,Bo,"f")){let d=this._maxAgeInMinutes*60*1e3,f=Date.now(),p=f-d,m=f+3e5,b=(0,Mx.decodeTime)(o);if(b.getTime()<p)throw new on(`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 on("Certificate is signed more than 5 minutes in the future. Certificate time: "+b.toISOString()+" Current time: "+new Date(f).toISOString())}try{a=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{a=!1}if(!a)throw new on("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 on("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==jx.MANAGEMENT_CANISTER_ID&&!nh({canisterId:this._canisterId,subnetId:Ll.Principal.fromUint8Array(new Uint8Array(t.subnet_id)),tree:r.cert.tree}))throw new on(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,Tr.toHex)(t.subnet_id)}`);let n=Kl(r.lookup(["subnet",t.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,Tr.toHex)(t.subnet_id)}`);return n}};Oe.Certificate=Hl;Bo=new WeakMap;var Fs=(0,Tr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Hx=96;function Kx(e){let t=Fs.byteLength+Hx;if(e.byteLength!==t)throw new TypeError(`BLS DER-encoded public key must be ${t} bytes long`);let r=e.slice(0,Fs.byteLength);if(!(0,Tr.bufEquals)(r,Fs))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Fs}, but get ${r}`);return e.slice(Fs.byteLength)}function Kl(e){if(e.status===Mt.Found){if(e.value instanceof ArrayBuffer)return e.value;if(e.value instanceof Uint8Array)return e.value.buffer}}Oe.lookupResultToBuffer=Kl;async function Vs(e){switch(e[0]){case Tt.Empty:return(0,Io.hash)(Us("ic-hashtree-empty"));case Tt.Pruned:return e[1];case Tt.Leaf:return(0,Io.hash)((0,Tr.concat)(Us("ic-hashtree-leaf"),e[1]));case Tt.Labeled:return(0,Io.hash)((0,Tr.concat)(Us("ic-hashtree-labeled"),e[1],await Vs(e[2])));case Tt.Fork:return(0,Io.hash)((0,Tr.concat)(Us("ic-hashtree-fork"),await Vs(e[1]),await Vs(e[2])));default:throw new Error("unreachable")}}Oe.reconstruct=Vs;function Us(e){let t=new Uint8Array([e.length]),r=new TextEncoder().encode(e);return(0,Tr.concat)(t,r)}var Mt;(function(e){e.Unknown="unknown",e.Absent="absent",e.Found="found"})(Mt=Oe.LookupStatus||(Oe.LookupStatus={}));var cn;(function(e){e.Less="less",e.Greater="greater"})(cn||(cn={}));function Fo(e,t){if(e.length===0)switch(t[0]){case Tt.Leaf:{if(!t[1])throw new Error("Invalid tree structure for leaf");return t[1]instanceof ArrayBuffer?{status:Mt.Found,value:t[1]}:t[1]instanceof Uint8Array?{status:Mt.Found,value:t[1].buffer}:{status:Mt.Found,value:t[1]}}default:return{status:Mt.Found,value:t}}let r=typeof e[0]=="string"?new TextEncoder().encode(e[0]):e[0],n=Cs(r,t);switch(n.status){case Mt.Found:return Fo(e.slice(1),n.value);case cn.Greater:case cn.Less:return{status:Mt.Absent};default:return n}}Oe.lookup_path=Fo;function Gl(e){switch(e[0]){case Tt.Empty:return[];case Tt.Fork:return Gl(e[1]).concat(Gl(e[2]));default:return[e]}}Oe.flatten_forks=Gl;function Cs(e,t){switch(t[0]){case Tt.Labeled:return Lx(e,t[1])?{status:cn.Greater}:(0,Tr.bufEquals)(e,t[1])?{status:Mt.Found,value:t[2]}:{status:cn.Less};case Tt.Fork:let r=Cs(e,t[1]);switch(r.status){case cn.Greater:{let n=Cs(e,t[2]);return n.status===cn.Less?{status:Mt.Absent}:n}case Mt.Unknown:{let n=Cs(e,t[2]);return n.status===cn.Less?{status:Mt.Unknown}:n}default:return r}case Tt.Pruned:return{status:Mt.Unknown};default:return{status:Mt.Absent}}}Oe.find_label=Cs;function nh(e){let{canisterId:t,subnetId:r,tree:n}=e,i=Fo(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Mt.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return rh.decode(i.value).map(c=>[Ll.Principal.fromUint8Array(c[0]),Ll.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(t)&&c[1].gtEq(t))}Oe.check_canister_ranges=nh});var Ds=ee(lt=>{"use strict";var Gx=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]}),$x=lt&&lt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Wx=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)&&Gx(t,e,r);return $x(t,e),t};Object.defineProperty(lt,"__esModule",{value:!0});lt.encodePath=lt.fetchNodeKeys=lt.request=lt.CustomPath=void 0;var Rn=Ct(),zx=wi(),An=Fi(),Yx=$t(),ah=Wx(vs()),ih=So(),$l=class{constructor(t,r,n){this.key=t,this.path=r,this.decodeStrategy=n}};lt.CustomPath=$l;var Jx=async e=>{let{agent:t,paths:r}=e,n=Rn.Principal.from(e.canisterId),i=[...new Set(r)],s=i.map(c=>(0,lt.encodePath)(c,n)),a=new Map,o=i.map((c,d)=>(async()=>{var f;try{let p=await t.readState(n,{paths:[s[d]]});if(t.rootKey==null)throw new Error("Agent is missing root key");let m=await An.Certificate.create({certificate:p.certificate,rootKey:t.rootKey,canisterId:n,disableTimeVerification:!0}),b=(v,F)=>{if(F==="subnet"){if(t.rootKey==null)throw new Error("Agent is missing root key");let C=(0,lt.fetchNodeKeys)(p.certificate,n,t.rootKey);return{path:F,data:C}}else return{path:F,data:(0,An.lookupResultToBuffer)(v.lookup((0,lt.encodePath)(F,n)))}},{path:l,data:A}=b(m,i[d]);if(!A)console.warn(`Expected to find result for path ${l}, but instead found nothing.`),typeof l=="string"?a.set(l,null):a.set(l.key,null);else switch(l){case"time":{a.set(l,(0,ih.decodeTime)(A));break}case"controllers":{a.set(l,eT(A));break}case"module_hash":{a.set(l,sh(A));break}case"subnet":{a.set(l,A);break}case"candid":{a.set(l,new TextDecoder().decode(A));break}default:if(typeof l!="string"&&"key"in l&&"path"in l)switch(l.decodeStrategy){case"raw":a.set(l.key,A);break;case"leb128":{a.set(l.key,(0,ih.decodeLeb128)(A));break}case"cbor":{a.set(l.key,oh(A));break}case"hex":{a.set(l.key,sh(A));break}case"utf-8":a.set(l.key,Qx(A))}}}catch(p){if(!((f=p?.message)===null||f===void 0)&&f.includes("Invalid certificate"))throw new zx.AgentError(p.message);typeof c!="string"&&"key"in c&&"path"in c?a.set(c.key,null):a.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(p),console.groupEnd()}})());return await Promise.all(o),a};lt.request=Jx;var Zx=(e,t,r)=>{if(!t._isPrincipal)throw new Error("Invalid canisterId");let n=ah.decode(new Uint8Array(e)),i=n.tree,s=n.delegation,a;if(s&&s.subnet_id?a=Rn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(a=Rn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:a.toUint8Array(),certificate:new ArrayBuffer(0)}):(a=Rn.Principal.selfAuthenticating(Rn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:a.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,An.check_canister_ranges)({canisterId:t,subnetId:a,tree:i}))throw new Error("Canister not in range");let c=(0,An.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==An.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let d=(0,An.flatten_forks)(c.value),f=new Map;return d.forEach(p=>{let m=Rn.Principal.from(new Uint8Array(p[1])).toText(),b=(0,An.lookup_path)(["public_key"],p[2]);if(b.status!==An.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:Rn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:f}};lt.fetchNodeKeys=Zx;var Xx=(e,t)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(t.toUint8Array().buffer).buffer;switch(e){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in e&&"path"in e)if(typeof e.path=="string"||e.path instanceof ArrayBuffer){let s=e.path,a=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),a]}else return e.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${e} was formatted correctly.`)};lt.encodePath=Xx;var sh=e=>(0,Yx.toHex)(e),oh=e=>ah.decode(e),Qx=e=>new TextDecoder().decode(e),eT=e=>oh(e).map(r=>Rn.Principal.fromUint8Array(new Uint8Array(r)))});var Sh=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=zl;ye.split=ch;ye.add=Th;var Uo=BigInt(2**32-1),Wl=BigInt(32);function zl(e,t=!1){return t?{h:Number(e&Uo),l:Number(e>>Wl&Uo)}:{h:Number(e>>Wl&Uo)|0,l:Number(e&Uo)|0}}function ch(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:s,l:a}=zl(e[i],t);[r[i],n[i]]=[s,a]}return[r,n]}var uh=(e,t)=>BigInt(e>>>0)<<Wl|BigInt(t>>>0);ye.toBig=uh;var lh=(e,t,r)=>e>>>r;ye.shrSH=lh;var dh=(e,t,r)=>e<<32-r|t>>>r;ye.shrSL=dh;var fh=(e,t,r)=>e>>>r|t<<32-r;ye.rotrSH=fh;var ph=(e,t,r)=>e<<32-r|t>>>r;ye.rotrSL=ph;var hh=(e,t,r)=>e<<64-r|t>>>r-32;ye.rotrBH=hh;var _h=(e,t,r)=>e>>>r-32|t<<64-r;ye.rotrBL=_h;var yh=(e,t)=>t;ye.rotr32H=yh;var mh=(e,t)=>e;ye.rotr32L=mh;var gh=(e,t,r)=>e<<r|t>>>32-r;ye.rotlSH=gh;var bh=(e,t,r)=>t<<r|e>>>32-r;ye.rotlSL=bh;var wh=(e,t,r)=>t<<r-32|e>>>64-r;ye.rotlBH=wh;var xh=(e,t,r)=>e<<r-32|t>>>64-r;ye.rotlBL=xh;function Th(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var Nh=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);ye.add3L=Nh;var Eh=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;ye.add3H=Eh;var Oh=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);ye.add4L=Oh;var vh=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0;ye.add4H=vh;var Rh=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0);ye.add5L=Rh;var Ah=(e,t,r,n,i,s)=>t+r+n+i+s+(e/2**32|0)|0;ye.add5H=Ah;var tT={fromBig:zl,split:ch,toBig:uh,shrSH:lh,shrSL:dh,rotrSH:fh,rotrSL:ph,rotrBH:hh,rotrBL:_h,rotr32H:yh,rotr32L:mh,rotlSH:gh,rotlSL:bh,rotlBH:wh,rotlBL:xh,add:Th,add3L:Nh,add3H:Eh,add4L:Oh,add4H:vh,add5H:Ah,add5L:Rh};ye.default=tT});var Ih=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 rT=hu(),we=Sh(),Do=Kn(),[nT,iT]=we.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))),Sn=new Uint32Array(80),In=new Uint32Array(80),Zn=class extends rT.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:s,Cl:a,Dh:o,Dl:c,Eh:d,El:f,Fh:p,Fl:m,Gh:b,Gl:l,Hh:A,Hl:v}=this;return[t,r,n,i,s,a,o,c,d,f,p,m,b,l,A,v]}set(t,r,n,i,s,a,o,c,d,f,p,m,b,l,A,v){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=a|0,this.Dh=o|0,this.Dl=c|0,this.Eh=d|0,this.El=f|0,this.Fh=p|0,this.Fl=m|0,this.Gh=b|0,this.Gl=l|0,this.Hh=A|0,this.Hl=v|0}process(t,r){for(let E=0;E<16;E++,r+=4)Sn[E]=t.getUint32(r),In[E]=t.getUint32(r+=4);for(let E=16;E<80;E++){let H=Sn[E-15]|0,x=In[E-15]|0,q=we.default.rotrSH(H,x,1)^we.default.rotrSH(H,x,8)^we.default.shrSH(H,x,7),K=we.default.rotrSL(H,x,1)^we.default.rotrSL(H,x,8)^we.default.shrSL(H,x,7),G=Sn[E-2]|0,D=In[E-2]|0,ae=we.default.rotrSH(G,D,19)^we.default.rotrBH(G,D,61)^we.default.shrSH(G,D,6),Q=we.default.rotrSL(G,D,19)^we.default.rotrBL(G,D,61)^we.default.shrSL(G,D,6),ne=we.default.add4L(K,Q,In[E-7],In[E-16]),w=we.default.add4H(ne,q,ae,Sn[E-7],Sn[E-16]);Sn[E]=w|0,In[E]=ne|0}let{Ah:n,Al:i,Bh:s,Bl:a,Ch:o,Cl:c,Dh:d,Dl:f,Eh:p,El:m,Fh:b,Fl:l,Gh:A,Gl:v,Hh:F,Hl:C}=this;for(let E=0;E<80;E++){let H=we.default.rotrSH(p,m,14)^we.default.rotrSH(p,m,18)^we.default.rotrBH(p,m,41),x=we.default.rotrSL(p,m,14)^we.default.rotrSL(p,m,18)^we.default.rotrBL(p,m,41),q=p&b^~p&A,K=m&l^~m&v,G=we.default.add5L(C,x,K,iT[E],In[E]),D=we.default.add5H(G,F,H,q,nT[E],Sn[E]),ae=G|0,Q=we.default.rotrSH(n,i,28)^we.default.rotrBH(n,i,34)^we.default.rotrBH(n,i,39),ne=we.default.rotrSL(n,i,28)^we.default.rotrBL(n,i,34)^we.default.rotrBL(n,i,39),w=n&s^n&o^s&o,g=i&a^i&c^a&c;F=A|0,C=v|0,A=b|0,v=l|0,b=p|0,l=m|0,{h:p,l:m}=we.default.add(d|0,f|0,D|0,ae|0),d=o|0,f=c|0,o=s|0,c=a|0,s=n|0,a=i|0;let S=we.default.add3L(ae,ne,g);n=we.default.add3H(S,D,Q,w),i=S|0}({h:n,l:i}=we.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:a}=we.default.add(this.Bh|0,this.Bl|0,s|0,a|0),{h:o,l:c}=we.default.add(this.Ch|0,this.Cl|0,o|0,c|0),{h:d,l:f}=we.default.add(this.Dh|0,this.Dl|0,d|0,f|0),{h:p,l:m}=we.default.add(this.Eh|0,this.El|0,p|0,m|0),{h:b,l}=we.default.add(this.Fh|0,this.Fl|0,b|0,l|0),{h:A,l:v}=we.default.add(this.Gh|0,this.Gl|0,A|0,v|0),{h:F,l:C}=we.default.add(this.Hh|0,this.Hl|0,F|0,C|0),this.set(n,i,s,a,o,c,d,f,p,m,b,l,A,v,F,C)}roundClean(){Sn.fill(0),In.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};yt.SHA512=Zn;var Vo=class extends Zn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}};yt.SHA512_224=Vo;var Co=class extends Zn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}};yt.SHA512_256=Co;var qo=class extends Zn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};yt.SHA384=qo;yt.sha512=(0,Do.wrapConstructor)(()=>new Zn);yt.sha512_224=(0,Do.wrapConstructor)(()=>new Vo);yt.sha512_256=(0,Do.wrapConstructor)(()=>new Co);yt.sha384=(0,Do.wrapConstructor)(()=>new qo)});var Ph=ee(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});Jl.twistedEdwards=cT;var Yl=Pl(),Bh=jr(),Jt=Qt(),rr=Qt(),Nr=BigInt(0),Yt=BigInt(1),ko=BigInt(2),sT=BigInt(8),aT={zip215:!0};function oT(e){let t=(0,Yl.validateBasic)(e);return Jt.validateObject(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function cT(e){let t=oT(e),{Fp:r,n,prehash:i,hash:s,randomBytes:a,nByteLength:o,h:c}=t,d=ko<<BigInt(o*8)-Yt,f=r.create,p=(0,Bh.Field)(t.n,t.nBitLength),m=t.uvRatio||((R,I)=>{try{return{isValid:!0,value:r.sqrt(R*r.inv(I))}}catch{return{isValid:!1,value:Nr}}}),b=t.adjustScalarBytes||(R=>R),l=t.domain||((R,I,j)=>{if((0,rr.abool)("phflag",j),I.length||j)throw new Error("Contexts/pre-hash are not supported");return R});function A(R,I){Jt.aInRange("coordinate "+R,I,Nr,d)}function v(R){if(!(R instanceof E))throw new Error("ExtendedPoint expected")}let F=(0,rr.memoized)((R,I)=>{let{ex:j,ey:Y,ez:oe}=R,se=R.is0();I==null&&(I=se?sT:r.inv(oe));let z=f(j*I),U=f(Y*I),_=f(oe*I);if(se)return{x:Nr,y:Yt};if(_!==Yt)throw new Error("invZ was invalid");return{x:z,y:U}}),C=(0,rr.memoized)(R=>{let{a:I,d:j}=t;if(R.is0())throw new Error("bad point: ZERO");let{ex:Y,ey:oe,ez:se,et:z}=R,U=f(Y*Y),_=f(oe*oe),Z=f(se*se),re=f(Z*Z),le=f(U*I),X=f(Z*f(le+_)),u=f(re+f(j*f(U*_)));if(X!==u)throw new Error("bad point: equation left != right (1)");let h=f(Y*oe),y=f(se*z);if(h!==y)throw new Error("bad point: equation left != right (2)");return!0});class E{constructor(I,j,Y,oe){this.ex=I,this.ey=j,this.ez=Y,this.et=oe,A("x",I),A("y",j),A("z",Y),A("t",oe),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(I){if(I instanceof E)throw new Error("extended point not allowed");let{x:j,y:Y}=I||{};return A("x",j),A("y",Y),new E(j,Y,Yt,f(j*Y))}static normalizeZ(I){let j=r.invertBatch(I.map(Y=>Y.ez));return I.map((Y,oe)=>Y.toAffine(j[oe])).map(E.fromAffine)}static msm(I,j){return(0,Yl.pippenger)(E,p,I,j)}_setWindowSize(I){q.setWindowSize(this,I)}assertValidity(){C(this)}equals(I){v(I);let{ex:j,ey:Y,ez:oe}=this,{ex:se,ey:z,ez:U}=I,_=f(j*U),Z=f(se*oe),re=f(Y*U),le=f(z*oe);return _===Z&&re===le}is0(){return this.equals(E.ZERO)}negate(){return new E(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:I}=t,{ex:j,ey:Y,ez:oe}=this,se=f(j*j),z=f(Y*Y),U=f(ko*f(oe*oe)),_=f(I*se),Z=j+Y,re=f(f(Z*Z)-se-z),le=_+z,X=le-U,u=_-z,h=f(re*X),y=f(le*u),P=f(re*u),O=f(X*le);return new E(h,y,O,P)}add(I){v(I);let{a:j,d:Y}=t,{ex:oe,ey:se,ez:z,et:U}=this,{ex:_,ey:Z,ez:re,et:le}=I;if(j===BigInt(-1)){let J=f((se-oe)*(Z+_)),te=f((se+oe)*(Z-_)),de=f(te-J);if(de===Nr)return this.double();let ge=f(z*ko*le),Ie=f(U*ko*re),Ue=Ie+ge,_e=te+J,fe=Ie-ge,Ke=f(Ue*de),Ht=f(_e*fe),Ut=f(Ue*fe),Vt=f(de*_e);return new E(Ke,Ht,Vt,Ut)}let X=f(oe*_),u=f(se*Z),h=f(U*Y*le),y=f(z*re),P=f((oe+se)*(_+Z)-X-u),O=y-h,B=y+h,M=f(u-j*X),T=f(P*O),V=f(B*M),L=f(P*M),k=f(O*B);return new E(T,V,k,L)}subtract(I){return this.add(I.negate())}wNAF(I){return q.wNAFCached(this,I,E.normalizeZ)}multiply(I){let j=I;Jt.aInRange("scalar",j,Yt,n);let{p:Y,f:oe}=this.wNAF(j);return E.normalizeZ([Y,oe])[0]}multiplyUnsafe(I){let j=I;return Jt.aInRange("scalar",j,Nr,n),j===Nr?x:this.equals(x)||j===Yt?this:this.equals(H)?this.wNAF(j).p:q.unsafeLadder(this,j)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return q.unsafeLadder(this,n).is0()}toAffine(I){return F(this,I)}clearCofactor(){let{h:I}=t;return I===Yt?this:this.multiplyUnsafe(I)}static fromHex(I,j=!1){let{d:Y,a:oe}=t,se=r.BYTES;I=(0,rr.ensureBytes)("pointHex",I,se),(0,rr.abool)("zip215",j);let z=I.slice(),U=I[se-1];z[se-1]=U&-129;let _=Jt.bytesToNumberLE(z),Z=j?d:r.ORDER;Jt.aInRange("pointHex.y",_,Nr,Z);let re=f(_*_),le=f(re-Yt),X=f(Y*re-oe),{isValid:u,value:h}=m(le,X);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let y=(h&Yt)===Yt,P=(U&128)!==0;if(!j&&h===Nr&&P)throw new Error("Point.fromHex: x=0 and x_0=1");return P!==y&&(h=f(-h)),E.fromAffine({x:h,y:_})}static fromPrivateKey(I){return D(I).point}toRawBytes(){let{x:I,y:j}=this.toAffine(),Y=Jt.numberToBytesLE(j,r.BYTES);return Y[Y.length-1]|=I&Yt?128:0,Y}toHex(){return Jt.bytesToHex(this.toRawBytes())}}E.BASE=new E(t.Gx,t.Gy,Yt,f(t.Gx*t.Gy)),E.ZERO=new E(Nr,Yt,Yt,Nr);let{BASE:H,ZERO:x}=E,q=(0,Yl.wNAF)(E,o*8);function K(R){return(0,Bh.mod)(R,n)}function G(R){return K(Jt.bytesToNumberLE(R))}function D(R){let I=o;R=(0,rr.ensureBytes)("private key",R,I);let j=(0,rr.ensureBytes)("hashed private key",s(R),2*I),Y=b(j.slice(0,I)),oe=j.slice(I,2*I),se=G(Y),z=H.multiply(se),U=z.toRawBytes();return{head:Y,prefix:oe,scalar:se,point:z,pointBytes:U}}function ae(R){return D(R).pointBytes}function Q(R=new Uint8Array,...I){let j=Jt.concatBytes(...I);return G(s(l(j,(0,rr.ensureBytes)("context",R),!!i)))}function ne(R,I,j={}){R=(0,rr.ensureBytes)("message",R),i&&(R=i(R));let{prefix:Y,scalar:oe,pointBytes:se}=D(I),z=Q(j.context,Y,R),U=H.multiply(z).toRawBytes(),_=Q(j.context,U,se,R),Z=K(z+_*oe);Jt.aInRange("signature.s",Z,Nr,n);let re=Jt.concatBytes(U,Jt.numberToBytesLE(Z,r.BYTES));return(0,rr.ensureBytes)("result",re,o*2)}let w=aT;function g(R,I,j,Y=w){let{context:oe,zip215:se}=Y,z=r.BYTES;R=(0,rr.ensureBytes)("signature",R,2*z),I=(0,rr.ensureBytes)("message",I),se!==void 0&&(0,rr.abool)("zip215",se),i&&(I=i(I));let U=Jt.bytesToNumberLE(R.slice(z,2*z)),_,Z,re;try{_=E.fromHex(j,se),Z=E.fromHex(R.slice(0,z),se),re=H.multiplyUnsafe(U)}catch{return!1}if(!se&&_.isSmallOrder())return!1;let le=Q(oe,Z.toRawBytes(),_.toRawBytes(),I);return Z.add(_.multiplyUnsafe(le)).subtract(re).clearCofactor().equals(E.ZERO)}return H._setWindowSize(8),{CURVE:t,getPublicKey:ae,sign:ne,verify:g,ExtendedPoint:E,utils:{getExtendedPublicKey:D,randomPrivateKey:()=>a(r.BYTES),precompute(R=8,I=E.BASE){return I._setWindowSize(R),I.multiply(BigInt(3)),I}}}}});var Uh=ee(Xl=>{"use strict";Object.defineProperty(Xl,"__esModule",{value:!0});Xl.montgomery=lT;var Fh=jr(),Bn=Qt(),Ui=BigInt(0),Zl=BigInt(1);function uT(e){return(0,Bn.validateObject)(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}function lT(e){let t=uT(e),{P:r}=t,n=C=>(0,Fh.mod)(C,r),i=t.montgomeryBits,s=Math.ceil(i/8),a=t.nByteLength,o=t.adjustScalarBytes||(C=>C),c=t.powPminus2||(C=>(0,Fh.pow)(C,r-BigInt(2),r));function d(C,E,H){let x=n(C*(E-H));return E=n(E-x),H=n(H+x),[E,H]}let f=(t.a-BigInt(2))/BigInt(4);function p(C,E){(0,Bn.aInRange)("u",C,Ui,r),(0,Bn.aInRange)("scalar",E,Ui,r);let H=E,x=C,q=Zl,K=Ui,G=C,D=Zl,ae=Ui,Q;for(let w=BigInt(i-1);w>=Ui;w--){let g=H>>w&Zl;ae^=g,Q=d(ae,q,G),q=Q[0],G=Q[1],Q=d(ae,K,D),K=Q[0],D=Q[1],ae=g;let S=q+K,R=n(S*S),I=q-K,j=n(I*I),Y=R-j,oe=G+D,se=G-D,z=n(se*S),U=n(oe*I),_=z+U,Z=z-U;G=n(_*_),D=n(x*n(Z*Z)),q=n(R*j),K=n(Y*(R+n(f*Y)))}Q=d(ae,q,G),q=Q[0],G=Q[1],Q=d(ae,K,D),K=Q[0],D=Q[1];let ne=c(K);return n(q*ne)}function m(C){return(0,Bn.numberToBytesLE)(n(C),s)}function b(C){let E=(0,Bn.ensureBytes)("u coordinate",C,s);return a===32&&(E[31]&=127),(0,Bn.bytesToNumberLE)(E)}function l(C){let E=(0,Bn.ensureBytes)("scalar",C),H=E.length;if(H!==s&&H!==a)throw new Error(`Expected ${s} or ${a} bytes, got ${H}`);return(0,Bn.bytesToNumberLE)(o(E))}function A(C,E){let H=b(E),x=l(C),q=p(H,x);if(q===Ui)throw new Error("Invalid private or public key received");return m(q)}let v=m(t.Gu);function F(C){return A(C,v)}return{scalarMult:A,scalarMultBase:F,getSharedSecret:(C,E)=>A(C,E),getPublicKey:C=>F(C),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:v}}});var ad=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=Kh;me.edwardsToMontgomeryPriv=pT;var jo=Ih(),ks=Kn(),nd=Ph(),Dh=wo(),Ce=jr(),dT=Uh(),Xn=Qt(),Ms=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),td=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),fT=BigInt(0),Lr=BigInt(1),Mo=BigInt(2),kh=BigInt(3),Mh=BigInt(5),id=BigInt(8);function jh(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=Ms,o=e*e%s*e%s,c=(0,Ce.pow2)(o,Mo,s)*o%s,d=(0,Ce.pow2)(c,Lr,s)*e%s,f=(0,Ce.pow2)(d,Mh,s)*d%s,p=(0,Ce.pow2)(f,t,s)*f%s,m=(0,Ce.pow2)(p,r,s)*p%s,b=(0,Ce.pow2)(m,n,s)*m%s,l=(0,Ce.pow2)(b,i,s)*b%s,A=(0,Ce.pow2)(l,i,s)*b%s,v=(0,Ce.pow2)(A,t,s)*f%s;return{pow_p_5_8:(0,Ce.pow2)(v,Mo,s)*e%s,b2:o}}function Lh(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function sd(e,t){let r=Ms,n=(0,Ce.mod)(t*t*t,r),i=(0,Ce.mod)(n*n*t,r),s=jh(e*i).pow_p_5_8,a=(0,Ce.mod)(e*n*s,r),o=(0,Ce.mod)(t*a*a,r),c=a,d=(0,Ce.mod)(a*td,r),f=o===e,p=o===(0,Ce.mod)(-e,r),m=o===(0,Ce.mod)(-e*td,r);return f&&(a=c),(p||m)&&(a=d),(0,Ce.isNegativeLE)(a,r)&&(a=(0,Ce.mod)(-a,r)),{isValid:f||p,value:a}}me.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var ue=(0,Ce.Field)(Ms,void 0,!0),js={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ue,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:id,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:jo.sha512,randomBytes:ks.randomBytes,adjustScalarBytes:Lh,uvRatio:sd};me.ed25519=(0,nd.twistedEdwards)(js);function Hh(e,t,r){if(t.length>255)throw new Error("Context is too big");return(0,ks.concatBytes)((0,ks.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}me.ed25519ctx=(0,nd.twistedEdwards)({...js,domain:Hh});me.ed25519ph=(0,nd.twistedEdwards)(Object.assign({},js,{domain:Hh,prehash:jo.sha512}));me.x25519=(0,dT.montgomery)({P:Ms,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{let t=Ms,{pow_p_5_8:r,b2:n}=jh(e);return(0,Ce.mod)((0,Ce.pow2)(r,kh,t)*n,t)},adjustScalarBytes:Lh,randomBytes:ks.randomBytes});function Kh(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=Kh;function pT(e){let t=js.hash(e.subarray(0,32));return js.adjustScalarBytes(t).subarray(0,32)}var hT=(ue.ORDER+kh)/id,_T=ue.pow(Mo,hT),Vh=ue.sqrt(ue.neg(ue.ONE));function yT(e){let t=(ue.ORDER-Mh)/id,r=BigInt(486662),n=ue.sqr(e);n=ue.mul(n,Mo);let i=ue.add(n,ue.ONE),s=ue.neg(r),a=ue.sqr(i),o=ue.mul(a,i),c=ue.mul(n,r);c=ue.mul(c,s),c=ue.add(c,a),c=ue.mul(c,s);let d=ue.sqr(o);a=ue.sqr(d),d=ue.mul(d,o),d=ue.mul(d,c),a=ue.mul(a,d);let f=ue.pow(a,t);f=ue.mul(f,d);let p=ue.mul(f,Vh);a=ue.sqr(f),a=ue.mul(a,o);let m=ue.eql(a,c),b=ue.cmov(p,f,m),l=ue.mul(s,n),A=ue.mul(f,e);A=ue.mul(A,_T);let v=ue.mul(A,Vh),F=ue.mul(c,n);a=ue.sqr(A),a=ue.mul(a,o);let C=ue.eql(a,F),E=ue.cmov(v,A,C);a=ue.sqr(b),a=ue.mul(a,o);let H=ue.eql(a,c),x=ue.cmov(l,s,H),q=ue.cmov(E,b,H),K=ue.isOdd(q);return q=ue.cmov(q,ue.neg(q),H!==K),{xMn:x,xMd:i,yMn:q,yMd:Lr}}var mT=(0,Ce.FpSqrtEven)(ue,ue.neg(BigInt(486664)));function gT(e){let{xMn:t,xMd:r,yMn:n,yMd:i}=yT(e),s=ue.mul(t,i);s=ue.mul(s,mT);let a=ue.mul(r,n),o=ue.sub(t,r),c=ue.add(t,r),d=ue.mul(a,c),f=ue.eql(d,ue.ZERO);s=ue.cmov(s,ue.ZERO,f),a=ue.cmov(a,ue.ONE,f),o=ue.cmov(o,ue.ONE,f),c=ue.cmov(c,ue.ONE,f);let p=ue.invertBatch([a,c]);return{x:ue.mul(s,p[0]),y:ue.mul(o,p[1])}}var Gh=(0,Dh.createHasher)(me.ed25519.ExtendedPoint,e=>gT(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:jo.sha512});me.hashToCurve=Gh.hashToCurve;me.encodeToCurve=Gh.encodeToCurve;function Ql(e){if(!(e instanceof Er))throw new Error("RistrettoPoint expected")}var rd=td,bT=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),wT=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),xT=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),TT=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Ch=e=>sd(Lr,e),NT=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),ed=e=>me.ed25519.CURVE.Fp.create((0,Xn.bytesToNumberLE)(e)&NT);function qh(e){let{d:t}=me.ed25519.CURVE,r=me.ed25519.CURVE.Fp.ORDER,n=me.ed25519.CURVE.Fp.create,i=n(rd*e*e),s=n((i+Lr)*xT),a=BigInt(-1),o=n((a-t*i)*n(i+t)),{isValid:c,value:d}=sd(s,o),f=n(d*e);(0,Ce.isNegativeLE)(f,r)||(f=n(-f)),c||(d=f),c||(a=i);let p=n(a*(i-Lr)*TT-o),m=d*d,b=n((d+d)*o),l=n(p*bT),A=n(Lr-m),v=n(Lr+m);return new me.ed25519.ExtendedPoint(n(b*v),n(A*l),n(l*v),n(b*A))}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,Xn.ensureBytes)("ristrettoHash",t,64);let r=ed(t.slice(0,32)),n=qh(r),i=ed(t.slice(32,64)),s=qh(i);return new e(n.add(s))}static fromHex(t){t=(0,Xn.ensureBytes)("ristrettoHex",t,32);let{a:r,d:n}=me.ed25519.CURVE,i=me.ed25519.CURVE.Fp.ORDER,s=me.ed25519.CURVE.Fp.create,a="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",o=ed(t);if(!(0,Xn.equalBytes)((0,Xn.numberToBytesLE)(o,32),t)||(0,Ce.isNegativeLE)(o,i))throw new Error(a);let c=s(o*o),d=s(Lr+r*c),f=s(Lr-r*c),p=s(d*d),m=s(f*f),b=s(r*n*p-m),{isValid:l,value:A}=Ch(s(b*m)),v=s(A*f),F=s(A*v*b),C=s((o+o)*v);(0,Ce.isNegativeLE)(C,i)&&(C=s(-C));let E=s(d*F),H=s(C*E);if(!l||(0,Ce.isNegativeLE)(H,i)||E===fT)throw new Error(a);return new e(new me.ed25519.ExtendedPoint(C,E,Lr,H))}toRawBytes(){let{ex:t,ey:r,ez:n,et:i}=this.ep,s=me.ed25519.CURVE.Fp.ORDER,a=me.ed25519.CURVE.Fp.create,o=a(a(n+r)*a(n-r)),c=a(t*r),d=a(c*c),{value:f}=Ch(a(o*d)),p=a(f*o),m=a(f*c),b=a(p*m*i),l;if((0,Ce.isNegativeLE)(i*b,s)){let v=a(r*rd),F=a(t*rd);t=v,r=F,l=a(p*wT)}else l=m;(0,Ce.isNegativeLE)(t*b,s)&&(r=a(-r));let A=a((n-r)*l);return(0,Ce.isNegativeLE)(A,s)&&(A=a(-A)),(0,Xn.numberToBytesLE)(A,32)}toHex(){return(0,Xn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(t){Ql(t);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=t.ep,a=me.ed25519.CURVE.Fp.create,o=a(r*s)===a(n*i),c=a(n*s)===a(r*i);return o||c}add(t){return Ql(t),new e(this.ep.add(t.ep))}subtract(t){return Ql(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 ET=(e,t)=>{let r=t.DST,n=typeof r=="string"?(0,ks.utf8ToBytes)(r):r,i=(0,Dh.expand_message_xmd)(e,n,64,jo.sha512);return Er.hashToCurve(i)};me.hashToRistretto255=ET;me.hash_to_ristretto255=me.hashToRistretto255});var Yh=ee(Pn=>{"use strict";var $h=Pn&&Pn.__classPrivateFieldSet||function(e,t,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},jt=Pn&&Pn.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},It,Ls,Wh,zh;Object.defineProperty(Pn,"__esModule",{value:!0});Pn.ExpirableMap=void 0;var od=class{constructor(t={}){It.set(this,void 0),Ls.set(this,void 0),this[Wh]=this.entries.bind(this),this[zh]="ExpirableMap";let{source:r=[],expirationTime:n=600*1e3}=t,i=Date.now();$h(this,It,new Map([...r].map(([s,a])=>[s,{value:a,timestamp:i}])),"f"),$h(this,Ls,n,"f")}prune(){let t=Date.now();for(let[r,n]of jt(this,It,"f").entries())t-n.timestamp>jt(this,Ls,"f")&&jt(this,It,"f").delete(r);return this}set(t,r){this.prune();let n={value:r,timestamp:Date.now()};return jt(this,It,"f").set(t,n),this}get(t){let r=jt(this,It,"f").get(t);if(r!==void 0){if(Date.now()-r.timestamp>jt(this,Ls,"f")){jt(this,It,"f").delete(t);return}return r.value}}clear(){jt(this,It,"f").clear()}entries(){let t=jt(this,It,"f").entries();return function*(){for(let[n,i]of t)yield[n,i.value]}()}values(){let t=jt(this,It,"f").values();return function*(){for(let n of t)yield n.value}()}keys(){return jt(this,It,"f").keys()}forEach(t,r){for(let[n,i]of jt(this,It,"f").entries())t.call(r,i.value,n,this)}has(t){return jt(this,It,"f").has(t)}delete(t){return jt(this,It,"f").delete(t)}get size(){return jt(this,It,"f").size}};Pn.ExpirableMap=od;It=new WeakMap,Ls=new WeakMap,Wh=Symbol.iterator,zh=Symbol.toStringTag});var cd=ee(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.unwrapDER=je.wrapDER=je.SECP256K1_OID=je.ED25519_OID=je.DER_COSE_OID=je.decodeLen=je.decodeLenBytes=je.encodeLen=je.encodeLenBytes=void 0;var OT=$t(),vT=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)")};je.encodeLenBytes=vT;var RT=(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)")};je.encodeLen=RT;var AT=(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)")};je.decodeLenBytes=AT;var ST=(e,t)=>{let r=(0,je.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)")};je.decodeLen=ST;je.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);je.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);je.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function IT(e,t){let r=2+(0,je.encodeLenBytes)(e.byteLength+1),n=t.byteLength+r+e.byteLength,i=0,s=new Uint8Array(1+(0,je.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,je.encodeLen)(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=(0,je.encodeLen)(s,i,e.byteLength+1),s[i++]=0,s.set(new Uint8Array(e),i),s}je.wrapDER=IT;var BT=(e,t)=>{let r=0,n=(o,c)=>{if(i[r++]!==o)throw new Error("Expected: "+c)},i=new Uint8Array(e);if(n(48,"sequence"),r+=(0,je.decodeLenBytes)(i,r),!(0,OT.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,je.decodeLen)(i,r)-1;r+=(0,je.decodeLenBytes)(i,r),n(0,"0 padding");let a=i.slice(r);if(s!==a.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${a.length}`);return a};je.unwrapDER=BT});var ud=ee(Fn=>{"use strict";var Jh=Fn&&Fn.__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},Zh=Fn&&Fn.__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)},Ho,Ko;Object.defineProperty(Fn,"__esModule",{value:!0});Fn.Ed25519PublicKey=void 0;var Lo=cd(),Go=class e{constructor(t){if(Ho.set(this,void 0),Ko.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Jh(this,Ho,t,"f"),Jh(this,Ko,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,Lo.wrapDER)(t,Lo.ED25519_OID).buffer}static derDecode(t){let r=(0,Lo.unwrapDER)(t,Lo.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 Zh(this,Ho,"f")}get derKey(){return Zh(this,Ko,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Fn.Ed25519PublicKey=Go;Ho=new WeakMap,Ko=new WeakMap;Go.RAW_KEY_LENGTH=32});var dd=ee(Vi=>{"use strict";Object.defineProperty(Vi,"__esModule",{value:!0});Vi.ObservableLog=Vi.Observable=void 0;var $o=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))}};Vi.Observable=$o;var ld=class extends $o{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)}};Vi.ObservableLog=ld});var i_=ee(Gr=>{"use strict";var Hr=Gr&&Gr.__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=Gr&&Gr.__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,Wo,zo,Yo,Jo,Zo,Xo,Qo,Ci;Object.defineProperty(Gr,"__esModule",{value:!0});Gr.exponentialBackoff=Gr.ExponentialBackoff=void 0;var Xh=.5,Qh=1.5,e_=500,t_=6e4,r_=9e5,n_=10,qi=class e{constructor(t=e.default){Kr.set(this,void 0),Wo.set(this,void 0),zo.set(this,void 0),Yo.set(this,void 0),Jo.set(this,void 0),Zo.set(this,void 0),Xo.set(this,void 0),Qo.set(this,void 0),Ci.set(this,0);let{initialInterval:r=e_,randomizationFactor:n=Xh,multiplier:i=Qh,maxInterval:s=t_,maxElapsedTime:a=r_,maxIterations:o=n_,date:c=Date}=t;Hr(this,Kr,r,"f"),Hr(this,Wo,n,"f"),Hr(this,zo,i,"f"),Hr(this,Yo,s,"f"),Hr(this,Qo,c,"f"),Hr(this,Jo,c.now(),"f"),Hr(this,Zo,a,"f"),Hr(this,Xo,o,"f")}get ellapsedTimeInMsec(){return Bt(this,Qo,"f").now()-Bt(this,Jo,"f")}get currentInterval(){return Bt(this,Kr,"f")}get count(){return Bt(this,Ci,"f")}get randomValueFromInterval(){let t=Bt(this,Wo,"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,zo,"f"),Bt(this,Yo,"f")),"f"),Hr(this,Ci,(t=Bt(this,Ci,"f"),t++,t),"f"),Bt(this,Kr,"f")}next(){return this.ellapsedTimeInMsec>=Bt(this,Zo,"f")||Bt(this,Ci,"f")>=Bt(this,Xo,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Gr.ExponentialBackoff=qi;Kr=new WeakMap,Wo=new WeakMap,zo=new WeakMap,Yo=new WeakMap,Jo=new WeakMap,Zo=new WeakMap,Xo=new WeakMap,Qo=new WeakMap,Ci=new WeakMap;qi.default={initialInterval:e_,randomizationFactor:Xh,multiplier:Qh,maxInterval:t_,maxElapsedTime:r_,maxIterations:n_,date:Date};function*PT(e=qi.default){let t=new qi(e),r=t.next();for(;r;)yield r,r=t.next()}Gr.exponentialBackoff=PT});var hd=ee(qe=>{"use strict";var a_=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]}),FT=qe&&qe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o_=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)&&a_(t,e,r);return FT(t,e),t},c_=qe&&qe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&a_(t,e,r)},Nt=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,Qn,Hi,$r,un,Li,Hs,ki,vr,Rr,ei,ti,Ks,Mi,ji,ri,ii,u_,rc,nc,ni;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 lr=Ct(),Wr=wi(),s_=ol(),Un=o_(vs()),ec=Ns(),Or=$t(),Ar=fo(),fd=Rs(),Ki=ho(),UT=Ds(),Di=Fi(),VT=ad(),CT=Yh(),qT=ud(),DT=So(),kT=dd(),MT=i_();c_(fo(),qe);c_(ho(),qe);var jT=Rs();Object.defineProperty(qe,"makeNonce",{enumerable:!0,get:function(){return jT.makeNonce}});var LT;(function(e){e.Received="received",e.Processing="processing",e.Replied="replied",e.Rejected="rejected",e.Unknown="unknown",e.Done="done"})(LT=qe.RequestStatusResponseStatus||(qe.RequestStatusResponseStatus={}));var tc=60*1e3;qe.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";qe.MANAGEMENT_CANISTER_ID="aaaaa-aa";var HT="ic0.app",KT=".ic0.app",GT="icp0.io",$T=".icp0.io",WT="icp-api.io",zT=".icp-api.io",Gs=class extends Wr.AgentError{constructor(t){super(t),this.message=t}},si=class extends Wr.AgentError{constructor(t){super(t),this.message=t}};qe.IdentityInvalidError=si;function YT(){let e;if(typeof window<"u")if(window.fetch)e=window.fetch.bind(window);else throw new Gs("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 Gs("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 Gs("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function JT(e){let t;if(e!==void 0)!e.match(/^[a-z]+:/)&&typeof window<"u"?t=new URL(window.location.protocol+"//"+e):t=new URL(e);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,a;s&&typeof s=="string"&&(n.some(o=>s.endsWith(o))?a=s:a=r.find(o=>s.endsWith(o))),i&&a?t=new URL(`${i.protocol}//${a}${i.port?":"+i.port:""}`):t=new URL("https://icp-api.io")}return t.toString()}var pd=class e{constructor(t={}){var r,n;Pt.add(this),Qn.set(this,null),Hi.set(this,!1),$r.set(this,void 0),un.set(this,void 0),Li.set(this,void 0),Hs.set(this,void 0),ki.set(this,0),vr.set(this,void 0),Rr.set(this,void 0),ei.set(this,void 0),ti.set(this,void 0),this._isAgent=!0,this.config={},Ks.set(this,0),this.log=new kT.ObservableLog,Mi.set(this,[]),ji.set(this,[]),ri.set(this,new CT.ExpirableMap({expirationTime:300*1e3})),ii.set(this,!0),nc.set(this,(a,o)=>{if(ie(this,ii,"f")===!1)return a;if(!o)throw new Di.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:c,signatures:d=[],requestId:f}=a,p=new TextEncoder().encode("\vic-response");for(let m of d){let{timestamp:b,identity:l}=m,A=lr.Principal.fromUint8Array(l).toText(),v;if(c==="replied"){let{reply:x}=a;v=(0,ec.hashOfMap)({status:c,reply:x,timestamp:BigInt(b),request_id:f})}else if(c==="rejected"){let{reject_code:x,reject_message:q,error_code:K}=a;v=(0,ec.hashOfMap)({status:c,reject_code:x,reject_message:q,error_code:K,timestamp:BigInt(b),request_id:f})}else throw new Error(`Unknown status: ${c}`);let F=(0,Or.concat)(p,new Uint8Array(v)),C=o?.nodeKeys.get(A);if(!C)throw new Di.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let E=qT.Ed25519PublicKey.fromDer(C).rawKey;if(VT.ed25519.verify(m.signature,new Uint8Array(F),new Uint8Array(E)))return a;throw new Di.CertificateVerificationError(`Invalid signature from replica ${A} signed query.`)}return a}),this.config=t,Nt(this,un,t.fetch||YT()||fetch.bind(global),"f"),Nt(this,Li,t.fetchOptions,"f"),Nt(this,Hs,t.callOptions,"f"),Nt(this,Hi,(r=t.shouldFetchRootKey)!==null&&r!==void 0?r:!1,"f"),t.rootKey?this.rootKey=t.rootKey:ie(this,Hi,"f")?this.rootKey=null:this.rootKey=(0,Or.fromHex)(qe.IC_ROOT_KEY);let i=JT(t.host);this.host=new URL(i),t.verifyQuerySignatures!==void 0&&Nt(this,ii,t.verifyQuerySignatures,"f"),Nt(this,Rr,(n=t.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new MT.ExponentialBackoff({maxIterations:ie(this,Rr,"f")});if(Nt(this,ei,t.backoffStrategy||s,"f"),this.host.hostname.endsWith(KT)?this.host.hostname=HT:this.host.hostname.endsWith($T)?this.host.hostname=GT:this.host.hostname.endsWith(zT)&&(this.host.hostname=WT),t.credentials){let{name:a,password:o}=t.credentials;Nt(this,vr,`${a}${o?":"+o:""}`,"f")}if(Nt(this,$r,Promise.resolve(t.identity||new s_.AnonymousIdentity),"f"),t.ingressExpiryInMinutes&&t.ingressExpiryInMinutes>5)throw new Wr.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 Wr.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${t.ingressExpiryInMinutes} minutes.`);Nt(this,ti,t.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,Ar.makeNonceTransform)(fd.makeNonce)),t.useQueryNonces&&this.addTransform("query",(0,Ar.makeNonceTransform)(fd.makeNonce)),t.logToConsole&&this.log.subscribe(a=>{a.level==="error"?console.error(a.message):a.level==="warn"?console.warn(a.message):console.log(a.message)})}get waterMark(){return ie(this,Ks,"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 Wr.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,ji,"f").findIndex(s=>(s.priority||0)<n);ie(this,ji,"f").splice(i>=0?i:ie(this,ji,"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,$r,"f"))throw new si("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ie(this,$r,"f")).getPrincipal()}async call(t,r,n){var i,s;await ie(this,Pt,"m",ni).call(this);let a=(i=r.callSync)!==null&&i!==void 0?i:!0,o=await(n!==void 0?await n:await ie(this,$r,"f"));if(!o)throw new si("This identity has expired due this application's security policy. Please refresh your authentication.");let c=lr.Principal.from(t),d=r.effectiveCanisterId?lr.Principal.from(r.effectiveCanisterId):c,f=o.getPrincipal()||lr.Principal.anonymous(),p=new Ar.Expiry(ie(this,ti,"f")*tc);Math.abs(ie(this,ki,"f"))>1e3*30&&(p=new Ar.Expiry(ie(this,ti,"f")*tc+ie(this,ki,"f")));let m={request_type:fd.SubmitRequestType.Call,canister_id:c,method_name:r.methodName,arg:r.arg,sender:f,ingress_expiry:p},b=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,vr,"f")?{Authorization:"Basic "+btoa(ie(this,vr,"f"))}:{})},endpoint:"call",body:m}),l=b.body.nonce?A(b.body.nonce):void 0;m.nonce=l;function A(E){return new Uint8Array(E)}b=await o.transformRequest(b);let v=Un.encode(b.body),F=ie(this,ei,"f").call(this),C=(0,ec.requestIdOf)(m);try{let E=()=>(this.log.print(`fetching "/api/v3/canister/${d.toText()}/call" with request:`,b),ie(this,un,"f").call(this,""+new URL(`/api/v3/canister/${d.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Hs,"f")),b.request),{body:v}))),H=()=>(this.log.print(`fetching "/api/v2/canister/${d.toText()}/call" with request:`,b),ie(this,un,"f").call(this,""+new URL(`/api/v2/canister/${d.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Hs,"f")),b.request),{body:v}))),q=await ie(this,Pt,"m",rc).call(this,{request:a?E:H,backoff:F,tries:0}),K=await q.arrayBuffer(),G=q.status===200&&K.byteLength>0?Un.decode(K):null;if(G&&"certificate"in G){let D=await this.parseTimeFromResponse({certificate:G.certificate});Nt(this,Ks,D,"f")}return{requestId:C,response:{ok:q.ok,status:q.status,statusText:q.statusText,body:G,headers:(0,Ar.httpHeadersTransform)(q.headers)},requestDetails:m}}catch(E){if(E.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(t,Object.assign(Object.assign({},r),{callSync:!1}),n);let H=`Error while making call: ${(s=E.message)!==null&&s!==void 0?s:String(E)}`,x=new Ki.AgentCallError(H,E,(0,Or.toHex)(C),(0,Or.toHex)(b.body.sender_pubkey),(0,Or.toHex)(b.body.sender_sig),String(b.body.content.ingress_expiry._value));throw this.log.error(H,x),x}}async query(t,r,n){var i,s,a,o;await ie(this,Pt,"m",ni).call(this);let c=ie(this,ei,"f").call(this),d=r.effectiveCanisterId?lr.Principal.from(r.effectiveCanisterId):lr.Principal.from(t);this.log.print(`ecid ${d.toString()}`),this.log.print(`canisterId ${t.toString()}`);let f,p,m=await(n!==void 0?n:ie(this,$r,"f"));if(!m)throw new si("This identity has expired due this application's security policy. Please refresh your authentication.");let b=lr.Principal.from(t),l=m?.getPrincipal()||lr.Principal.anonymous(),A={request_type:"query",canister_id:b,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:new Ar.Expiry(ie(this,ti,"f")*tc)},v=(0,ec.requestIdOf)(A);f=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,vr,"f")?{Authorization:"Basic "+btoa(ie(this,vr,"f"))}:{})},endpoint:"read",body:A}),f=await m?.transformRequest(f);let F=Un.encode(f.body),C={canister:b.toText(),ecid:d,transformedRequest:f,body:F,requestId:v,backoff:c,tries:0},E=async()=>({requestDetails:A,query:await ie(this,Pt,"m",u_).call(this,C)}),H=async()=>{if(!ie(this,ii,"f"))return;let x=ie(this,ri,"f").get(d.toString());return x||(await this.fetchSubnetKeys(d.toString()),ie(this,ri,"f").get(d.toString()))};try{let[x,q]=await Promise.all([E(),H()]);p=x;let{requestDetails:K,query:G}=p,D=Object.assign(Object.assign({},G),{requestDetails:K});if(this.log.print("Query response:",D),!ie(this,ii,"f"))return D;try{return ie(this,nc,"f").call(this,D,q)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ie(this,ri,"f").delete(t.toString()),await this.fetchSubnetKeys(d.toString());let Q=ie(this,ri,"f").get(t.toString());if(!Q)throw new Di.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ie(this,nc,"f").call(this,D,Q)}}catch(x){let q=`Error while making call: ${(i=x.message)!==null&&i!==void 0?i:String(x)}`,K=new Ki.AgentQueryError(q,x,String(v),(0,Or.toHex)((s=f?.body)===null||s===void 0?void 0:s.sender_pubkey),(0,Or.toHex)((a=f?.body)===null||a===void 0?void 0:a.sender_sig),String((o=f?.body)===null||o===void 0?void 0:o.content.ingress_expiry._value));throw this.log.error(q,K),K}}async createReadStateRequest(t,r){await ie(this,Pt,"m",ni).call(this);let n=await(r!==void 0?await r:await ie(this,$r,"f"));if(!n)throw new si("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||lr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ie(this,vr,"f")?{Authorization:"Basic "+btoa(ie(this,vr,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:t.paths,sender:i,ingress_expiry:new Ar.Expiry(ie(this,ti,"f")*tc)}});return n?.transformRequest(s)}async readState(t,r,n,i){var s,a,o,c;function d(A){for(let v of A.paths){let[F,C]=v,E=new TextEncoder().encode("request_status");if((0,Or.bufEquals)(F,E))return C}}let f=d(r);await ie(this,Pt,"m",ni).call(this);let p=typeof t=="string"?lr.Principal.fromText(t):t,m=i??await this.createReadStateRequest(r,n),b=Un.encode(m.body);this.log.print(`fetching "/api/v2/canister/${p}/read_state" with request:`,m);let l=ie(this,ei,"f").call(this);try{let A=await ie(this,Pt,"m",rc).call(this,{request:()=>ie(this,un,"f").call(this,""+new URL(`/api/v2/canister/${p.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Li,"f")),m.request),{body:b})),backoff:l,tries:0});if(!A.ok)throw new Error(`Server returned an error:
31
31
  Code: ${A.status} (${A.statusText})
32
32
  Body: ${await A.text()}
33
- `);let v=Un.decode(await A.arrayBuffer());this.log.print("Read state response:",v);let F=await this.parseTimeFromResponse(v);return F>0&&(this.log.print("Read state response time:",F),Nt(this,Ks,F,"f")),v}catch(A){let v=`Caught exception while attempting to read state: ${(s=A.message)!==null&&s!==void 0?s:String(A)}`,F=new Ki.AgentReadStateError(v,A,String(f),(0,Or.toHex)((a=m?.body)===null||a===void 0?void 0:a.sender_pubkey),(0,Or.toHex)((o=m?.body)===null||o===void 0?void 0:o.sender_sig),String((c=m?.body)===null||c===void 0?void 0:c.content.ingress_expiry._value));throw this.log.error(v,F),F}}async parseTimeFromResponse(t){let r;if(t.certificate){let n=Un.decode(t.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,Di.lookup_path)(["time"],r);if(i.status!==Di.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,qT.decodeTime)((0,Or.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",ni).call(this);let r=await Promise.resolve().then(()=>a_(Ds())),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 i_.AnonymousIdentity,host:this.host.toString(),fetch:ie(this,un,"f"),retryTimes:0}),a=(await r.request({canisterId:t??lr.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:i,paths:["time"]})).get("time");a&&(Nt(this,ki,Number(a)-Number(n),"f"),this.log.notify({message:`Syncing time: offset of ${ie(this,ki,"f")}`,level:"info"}))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let t=ie(this,vr,"f")?{Authorization:"Basic "+btoa(ie(this,vr,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ie(this,ei,"f").call(this),n=await ie(this,Pt,"m",rc).call(this,{backoff:r,request:()=>ie(this,un,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:t},ie(this,Li,"f"))),tries:0});return Un.decode(await n.arrayBuffer())}async fetchRootKey(){let t;return ie(this,Qn,"f")?t=await ie(this,Qn,"f"):(Nt(this,Qn,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,Qn,"f")),Nt(this,Qn,null,"f"),t}invalidateIdentity(){Nt(this,$r,null,"f")}replaceIdentity(t){Nt(this,$r,Promise.resolve(t),"f")}async fetchSubnetKeys(t){await ie(this,Pt,"m",ni).call(this);let r=lr.Principal.from(t),i=(await(0,FT.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ie(this,ri,"f").set(r.toText(),i),i}_transform(t){let r=Promise.resolve(t);if(t.endpoint==="call")for(let n of ie(this,ji,"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=fd;Qn=new WeakMap,Hi=new WeakMap,$r=new WeakMap,un=new WeakMap,Li=new WeakMap,Hs=new WeakMap,ki=new WeakMap,vr=new WeakMap,Rr=new WeakMap,ei=new WeakMap,ti=new WeakMap,Ks=new WeakMap,Mi=new WeakMap,ji=new WeakMap,ri=new WeakMap,ii=new WeakMap,nc=new WeakMap,Pt=new WeakSet,c_=async function e(t){var r,n;let{ecid:i,transformedRequest:s,body:a,requestId:o,backoff:c,tries:d}=t,f=d===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:d,backoff:c,delay:f}),f===null)throw new Wr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ie(this,Rr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);f>0&&await new Promise(l=>setTimeout(l,f));let p;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let l=await ie(this,un,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Li,"f")),s.request),{body:a}));if(l.status===200){let A=Un.decode(await l.arrayBuffer());p=Object.assign(Object.assign({},A),{httpDetails:{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,Ar.httpHeadersTransform)(l.headers)},requestId:o})}else throw new Ki.AgentHTTPResponseError(`Gateway returned an error:
33
+ `);let v=Un.decode(await A.arrayBuffer());this.log.print("Read state response:",v);let F=await this.parseTimeFromResponse(v);return F>0&&(this.log.print("Read state response time:",F),Nt(this,Ks,F,"f")),v}catch(A){let v=`Caught exception while attempting to read state: ${(s=A.message)!==null&&s!==void 0?s:String(A)}`,F=new Ki.AgentReadStateError(v,A,String(f),(0,Or.toHex)((a=m?.body)===null||a===void 0?void 0:a.sender_pubkey),(0,Or.toHex)((o=m?.body)===null||o===void 0?void 0:o.sender_sig),String((c=m?.body)===null||c===void 0?void 0:c.content.ingress_expiry._value));throw this.log.error(v,F),F}}async parseTimeFromResponse(t){let r;if(t.certificate){let n=Un.decode(t.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,Di.lookup_path)(["time"],r);if(i.status!==Di.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,DT.decodeTime)((0,Or.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",ni).call(this);let r=await Promise.resolve().then(()=>o_(Ds())),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 s_.AnonymousIdentity,host:this.host.toString(),fetch:ie(this,un,"f"),retryTimes:0}),a=(await r.request({canisterId:t??lr.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:i,paths:["time"]})).get("time");a&&(Nt(this,ki,Number(a)-Number(n),"f"),this.log.notify({message:`Syncing time: offset of ${ie(this,ki,"f")}`,level:"info"}))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let t=ie(this,vr,"f")?{Authorization:"Basic "+btoa(ie(this,vr,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ie(this,ei,"f").call(this),n=await ie(this,Pt,"m",rc).call(this,{backoff:r,request:()=>ie(this,un,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:t},ie(this,Li,"f"))),tries:0});return Un.decode(await n.arrayBuffer())}async fetchRootKey(){let t;return ie(this,Qn,"f")?t=await ie(this,Qn,"f"):(Nt(this,Qn,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,Qn,"f")),Nt(this,Qn,null,"f"),t}invalidateIdentity(){Nt(this,$r,null,"f")}replaceIdentity(t){Nt(this,$r,Promise.resolve(t),"f")}async fetchSubnetKeys(t){await ie(this,Pt,"m",ni).call(this);let r=lr.Principal.from(t),i=(await(0,UT.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ie(this,ri,"f").set(r.toText(),i),i}_transform(t){let r=Promise.resolve(t);if(t.endpoint==="call")for(let n of ie(this,ji,"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=pd;Qn=new WeakMap,Hi=new WeakMap,$r=new WeakMap,un=new WeakMap,Li=new WeakMap,Hs=new WeakMap,ki=new WeakMap,vr=new WeakMap,Rr=new WeakMap,ei=new WeakMap,ti=new WeakMap,Ks=new WeakMap,Mi=new WeakMap,ji=new WeakMap,ri=new WeakMap,ii=new WeakMap,nc=new WeakMap,Pt=new WeakSet,u_=async function e(t){var r,n;let{ecid:i,transformedRequest:s,body:a,requestId:o,backoff:c,tries:d}=t,f=d===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:d,backoff:c,delay:f}),f===null)throw new Wr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ie(this,Rr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);f>0&&await new Promise(l=>setTimeout(l,f));let p;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let l=await ie(this,un,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ie(this,Li,"f")),s.request),{body:a}));if(l.status===200){let A=Un.decode(await l.arrayBuffer());p=Object.assign(Object.assign({},A),{httpDetails:{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,Ar.httpHeadersTransform)(l.headers)},requestId:o})}else throw new Ki.AgentHTTPResponseError(`Gateway returned an error:
34
34
  Code: ${l.status} (${l.statusText})
35
35
  Body: ${await l.text()}
36
36
  `,{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,Ar.httpHeadersTransform)(l.headers)})}catch(l){if(d<ie(this,Rr,"f"))return this.log.warn(`Caught exception while attempting to make query:
@@ -40,21 +40,21 @@ ${t(i)}
40
40
  Retrying request.`),await ie(this,Pt,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw d}if(a.ok)return a;let o=await a.clone().text(),c=`Server returned an error:
41
41
  Code: ${a.status} (${a.statusText})
42
42
  Body: ${o}
43
- `;if(a.status===404&&a.url.includes("api/v3"))throw new Ki.AgentHTTPResponseError("v3 api not supported. Fall back to v2",{ok:a.ok,status:a.status,statusText:a.statusText,headers:(0,Ar.httpHeadersTransform)(a.headers)});if(i<ie(this,Rr,"f"))return await ie(this,Pt,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw new Ki.AgentHTTPResponseError(c,{ok:a.ok,status:a.status,statusText:a.statusText,headers:(0,Ar.httpHeadersTransform)(a.headers)})},ni=async function(){if(!this.rootKey)if(this.rootKey===null&&ie(this,Hi,"f"))await this.fetchRootKey();else throw new Wr.AgentError(`Invalid root key detected. The root key for this agent is ${this.rootKey} and the shouldFetchRootKey value is set to ${ie(this,Hi,"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 u_=ee(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.ProxyAgent=ln.ProxyStubAgent=ln.ProxyMessageKind=void 0;var JT=Ct(),Qe;(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"})(Qe=ln.ProxyMessageKind||(ln.ProxyMessageKind={}));var hd=class{constructor(t,r){this._frontend=t,this._agent=r}onmessage(t){switch(t.type){case Qe.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:t.id,type:Qe.GetPrincipalResponse,response:r.toText()})});break;case Qe.Query:this._agent.query(...t.args).then(r=>{this._frontend({id:t.id,type:Qe.QueryResponse,response:r})});break;case Qe.Call:this._agent.call(...t.args).then(r=>{this._frontend({id:t.id,type:Qe.CallResponse,response:r})});break;case Qe.ReadState:this._agent.readState(...t.args).then(r=>{this._frontend({id:t.id,type:Qe.ReadStateResponse,response:r})});break;case Qe.Status:this._agent.status().then(r=>{this._frontend({id:t.id,type:Qe.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(t)}`)}}};ln.ProxyStubAgent=hd;var _d=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 Qe.Error:return s(t.error);case Qe.GetPrincipalResponse:case Qe.CallResponse:case Qe.QueryResponse:case Qe.ReadStateResponse:case Qe.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:Qe.GetPrincipal}).then(t=>{if(typeof t!="string")throw new Error("Invalid principal received.");return JT.Principal.fromText(t)})}readState(t,r){return this._sendAndWait({id:this._nextId++,type:Qe.ReadState,args:[t.toString(),r]})}call(t,r){return this._sendAndWait({id:this._nextId++,type:Qe.Call,args:[t.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:Qe.Status})}query(t,r){return this._sendAndWait({id:this._nextId++,type:Qe.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}};ln.ProxyAgent=_d});var qs=ee(dr=>{"use strict";var ZT=dr&&dr.__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]}),ic=dr&&dr.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&ZT(t,e,r)};Object.defineProperty(dr,"__esModule",{value:!0});dr.getDefaultAgent=void 0;ic(au(),dr);ic(pd(),dr);ic(ho(),dr);ic(u_(),dr);function XT(){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}dr.getDefaultAgent=XT});var sc=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 l_=$t(),QT=300*1e3;function eN(){return __(f_(d_(),1e3),h_(1e3,1.2),p_(QT))}mt.defaultStrategy=eN;function d_(){let e=!0;return async()=>e?(e=!1,!0):!1}mt.once=d_;function f_(e,t){return async(r,n,i)=>{if(await e(r,n,i))return new Promise(s=>setTimeout(s,t))}}mt.conditionalDelay=f_;function tN(e){let t=e;return async(r,n,i)=>{if(--t<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
44
- Request ID: ${(0,l_.toHex)(n)}
43
+ `;if(a.status===404&&a.url.includes("api/v3"))throw new Ki.AgentHTTPResponseError("v3 api not supported. Fall back to v2",{ok:a.ok,status:a.status,statusText:a.statusText,headers:(0,Ar.httpHeadersTransform)(a.headers)});if(i<ie(this,Rr,"f"))return await ie(this,Pt,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw new Ki.AgentHTTPResponseError(c,{ok:a.ok,status:a.status,statusText:a.statusText,headers:(0,Ar.httpHeadersTransform)(a.headers)})},ni=async function(){if(!this.rootKey)if(this.rootKey===null&&ie(this,Hi,"f"))await this.fetchRootKey();else throw new Wr.AgentError(`Invalid root key detected. The root key for this agent is ${this.rootKey} and the shouldFetchRootKey value is set to ${ie(this,Hi,"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 l_=ee(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.ProxyAgent=ln.ProxyStubAgent=ln.ProxyMessageKind=void 0;var ZT=Ct(),Qe;(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"})(Qe=ln.ProxyMessageKind||(ln.ProxyMessageKind={}));var _d=class{constructor(t,r){this._frontend=t,this._agent=r}onmessage(t){switch(t.type){case Qe.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:t.id,type:Qe.GetPrincipalResponse,response:r.toText()})});break;case Qe.Query:this._agent.query(...t.args).then(r=>{this._frontend({id:t.id,type:Qe.QueryResponse,response:r})});break;case Qe.Call:this._agent.call(...t.args).then(r=>{this._frontend({id:t.id,type:Qe.CallResponse,response:r})});break;case Qe.ReadState:this._agent.readState(...t.args).then(r=>{this._frontend({id:t.id,type:Qe.ReadStateResponse,response:r})});break;case Qe.Status:this._agent.status().then(r=>{this._frontend({id:t.id,type:Qe.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(t)}`)}}};ln.ProxyStubAgent=_d;var yd=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 Qe.Error:return s(t.error);case Qe.GetPrincipalResponse:case Qe.CallResponse:case Qe.QueryResponse:case Qe.ReadStateResponse:case Qe.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:Qe.GetPrincipal}).then(t=>{if(typeof t!="string")throw new Error("Invalid principal received.");return ZT.Principal.fromText(t)})}readState(t,r){return this._sendAndWait({id:this._nextId++,type:Qe.ReadState,args:[t.toString(),r]})}call(t,r){return this._sendAndWait({id:this._nextId++,type:Qe.Call,args:[t.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:Qe.Status})}query(t,r){return this._sendAndWait({id:this._nextId++,type:Qe.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}};ln.ProxyAgent=yd});var qs=ee(dr=>{"use strict";var XT=dr&&dr.__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]}),ic=dr&&dr.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&XT(t,e,r)};Object.defineProperty(dr,"__esModule",{value:!0});dr.getDefaultAgent=void 0;ic(ou(),dr);ic(hd(),dr);ic(ho(),dr);ic(l_(),dr);function QT(){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}dr.getDefaultAgent=QT});var sc=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 d_=$t(),eN=300*1e3;function tN(){return y_(p_(f_(),1e3),__(1e3,1.2),h_(eN))}mt.defaultStrategy=tN;function f_(){let e=!0;return async()=>e?(e=!1,!0):!1}mt.once=f_;function p_(e,t){return async(r,n,i)=>{if(await e(r,n,i))return new Promise(s=>setTimeout(s,t))}}mt.conditionalDelay=p_;function rN(e){let t=e;return async(r,n,i)=>{if(--t<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
44
+ Request ID: ${(0,d_.toHex)(n)}
45
45
  Request status: ${i}
46
- `)}}mt.maxAttempts=tN;function rN(e){return()=>new Promise(t=>setTimeout(t,e))}mt.throttle=rN;function p_(e){let t=Date.now()+e;return async(r,n,i)=>{if(Date.now()>t)throw new Error(`Request timed out after ${e} msec:
47
- Request ID: ${(0,l_.toHex)(n)}
46
+ `)}}mt.maxAttempts=rN;function nN(e){return()=>new Promise(t=>setTimeout(t,e))}mt.throttle=nN;function h_(e){let t=Date.now()+e;return async(r,n,i)=>{if(Date.now()>t)throw new Error(`Request timed out after ${e} msec:
47
+ Request ID: ${(0,d_.toHex)(n)}
48
48
  Request status: ${i}
49
- `)}}mt.timeout=p_;function h_(e,t){let r=e;return()=>new Promise(n=>setTimeout(()=>{r*=t,n()},r))}mt.backoff=h_;function __(...e){return async(t,r,n)=>{for(let i of e)await i(t,r,n)}}mt.chain=__});var ac=ee(Zt=>{"use strict";var nN=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]}),iN=Zt&&Zt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),sN=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)&&nN(t,e,r);return iN(t,e),t};Object.defineProperty(Zt,"__esModule",{value:!0});Zt.pollForResponse=Zt.defaultStrategy=Zt.strategy=void 0;var ai=qs(),$s=Fi(),y_=$t();Zt.strategy=sN(sc());var aN=sc(),oN=sc();Object.defineProperty(Zt,"defaultStrategy",{enumerable:!0,get:function(){return oN.defaultStrategy}});async function m_(e,t,r,n=(0,aN.defaultStrategy)(),i,s){var a;let o=[new TextEncoder().encode("request_status"),r],c=i??await((a=e.createReadStateRequest)===null||a===void 0?void 0:a.call(e,{paths:[o]})),d=await e.readState(t,{paths:[o]},void 0,c);if(e.rootKey==null)throw new Error("Agent root key not initialized before polling");let f=await $s.Certificate.create({certificate:d.certificate,rootKey:e.rootKey,canisterId:t,blsVerify:s}),p=(0,$s.lookupResultToBuffer)(f.lookup([...o,new TextEncoder().encode("status")])),m;switch(typeof p>"u"?m=ai.RequestStatusResponseStatus.Unknown:m=new TextDecoder().decode(p),m){case ai.RequestStatusResponseStatus.Replied:return{reply:(0,$s.lookupResultToBuffer)(f.lookup([...o,"reply"])),certificate:f};case ai.RequestStatusResponseStatus.Received:case ai.RequestStatusResponseStatus.Unknown:case ai.RequestStatusResponseStatus.Processing:return await n(t,r,m),m_(e,t,r,n,c,s);case ai.RequestStatusResponseStatus.Rejected:{let b=new Uint8Array((0,$s.lookupResultToBuffer)(f.lookup([...o,"reject_code"])))[0],l=new TextDecoder().decode((0,$s.lookupResultToBuffer)(f.lookup([...o,"reject_message"])));throw new Error(`Call was rejected:
50
- Request ID: ${(0,y_.toHex)(r)}
49
+ `)}}mt.timeout=h_;function __(e,t){let r=e;return()=>new Promise(n=>setTimeout(()=>{r*=t,n()},r))}mt.backoff=__;function y_(...e){return async(t,r,n)=>{for(let i of e)await i(t,r,n)}}mt.chain=y_});var ac=ee(Zt=>{"use strict";var iN=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]}),sN=Zt&&Zt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),aN=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)&&iN(t,e,r);return sN(t,e),t};Object.defineProperty(Zt,"__esModule",{value:!0});Zt.pollForResponse=Zt.defaultStrategy=Zt.strategy=void 0;var ai=qs(),$s=Fi(),m_=$t();Zt.strategy=aN(sc());var oN=sc(),cN=sc();Object.defineProperty(Zt,"defaultStrategy",{enumerable:!0,get:function(){return cN.defaultStrategy}});async function g_(e,t,r,n=(0,oN.defaultStrategy)(),i,s){var a;let o=[new TextEncoder().encode("request_status"),r],c=i??await((a=e.createReadStateRequest)===null||a===void 0?void 0:a.call(e,{paths:[o]})),d=await e.readState(t,{paths:[o]},void 0,c);if(e.rootKey==null)throw new Error("Agent root key not initialized before polling");let f=await $s.Certificate.create({certificate:d.certificate,rootKey:e.rootKey,canisterId:t,blsVerify:s}),p=(0,$s.lookupResultToBuffer)(f.lookup([...o,new TextEncoder().encode("status")])),m;switch(typeof p>"u"?m=ai.RequestStatusResponseStatus.Unknown:m=new TextDecoder().decode(p),m){case ai.RequestStatusResponseStatus.Replied:return{reply:(0,$s.lookupResultToBuffer)(f.lookup([...o,"reply"])),certificate:f};case ai.RequestStatusResponseStatus.Received:case ai.RequestStatusResponseStatus.Unknown:case ai.RequestStatusResponseStatus.Processing:return await n(t,r,m),g_(e,t,r,n,c,s);case ai.RequestStatusResponseStatus.Rejected:{let b=new Uint8Array((0,$s.lookupResultToBuffer)(f.lookup([...o,"reject_code"])))[0],l=new TextDecoder().decode((0,$s.lookupResultToBuffer)(f.lookup([...o,"reject_message"])));throw new Error(`Call was rejected:
50
+ Request ID: ${(0,m_.toHex)(r)}
51
51
  Reject code: ${b}
52
52
  Reject text: ${l}
53
53
  `)}case ai.RequestStatusResponseStatus.Done:throw new Error(`Call was marked as done but we never saw the reply:
54
- Request ID: ${(0,y_.toHex)(r)}
55
- `)}throw new Error("unreachable")}Zt.pollForResponse=m_});var g_=ee(yd=>{"use strict";Object.defineProperty(yd,"__esModule",{value:!0});yd.default=({IDL:e})=>{let t=e.Variant({mainnet:e.Null,testnet:e.Null}),r=e.Text,n=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),i=e.Nat64,s=i,a=e.Nat32,o=e.Record({start_height:a,end_height:e.Opt(a),network:t}),c=e.Vec(e.Nat8),d=e.Record({tip_height:a,block_headers:e.Vec(c)}),f=e.Record({network:t}),p=e.Nat64,m=e.Vec(p),b=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),l=e.Vec(e.Nat8),A=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),v=e.Record({height:e.Nat32,value:i,outpoint:A}),F=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:a,tip_block_hash:l,utxos:e.Vec(v)}),C=e.Record({transaction:e.Vec(e.Nat8),network:t}),E=e.Principal,H=e.Record({canister_id:E,num_requested_changes:e.Opt(e.Nat64)}),x=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),q=e.Vec(e.Nat8),K=e.Variant({creation:e.Record({controllers:e.Vec(e.Principal)}),code_deployment:e.Record({mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),module_hash:e.Vec(e.Nat8)}),load_snapshot:e.Record({canister_version:e.Nat64,taken_at_timestamp:e.Nat64,snapshot_id:q}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),G=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:x,details:K}),D=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(G),total_num_changes:e.Nat64}),ae=e.Record({canister_id:E}),Q=e.Variant({controllers:e.Null,public:e.Null,allowed_viewers:e.Vec(e.Principal)}),ne=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:Q,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),w=e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:ne,query_stats:e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),g=e.Record({canister_id:E}),S=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),reserved_cycles_limit:e.Opt(e.Nat),log_visibility:e.Opt(Q),wasm_memory_limit:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),R=e.Record({settings:e.Opt(S),sender_canister_version:e.Opt(e.Nat64)}),I=e.Record({canister_id:E}),j=e.Record({canister_id:E}),Y=e.Record({canister_id:E,snapshot_id:q}),oe=e.Record({canister_id:E}),se=e.Variant({secp256k1:e.Null}),z=e.Record({key_id:e.Record({name:e.Text,curve:se}),canister_id:e.Opt(E),derivation_path:e.Vec(e.Vec(e.Nat8))}),U=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),_=e.Record({canister_id:E}),Z=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),re=e.Record({canister_log_records:e.Vec(Z)}),le=e.Record({value:e.Text,name:e.Text}),X=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(le)}),u=e.Record({url:e.Text,method:e.Variant({get:e.Null,head:e.Null,post:e.Null}),max_response_bytes:e.Opt(e.Nat64),body:e.Opt(e.Vec(e.Nat8)),transform:e.Opt(e.Record({function:e.Func([e.Record({context:e.Vec(e.Nat8),response:X})],[X],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(le)}),h=e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({wasm_memory_persistence:e.Opt(e.Variant({keep:e.Null,replace:e.Null})),skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),y=e.Record({hash:e.Vec(e.Nat8)}),P=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:h,chunk_hashes_list:e.Vec(y),target_canister:E,store_canister:e.Opt(E),sender_canister_version:e.Opt(e.Nat64)}),O=e.Vec(e.Nat8),B=e.Record({arg:e.Vec(e.Nat8),wasm_module:O,mode:h,canister_id:E,sender_canister_version:e.Opt(e.Nat64)}),M=e.Record({canister_id:E}),T=e.Record({id:q,total_size:e.Nat64,taken_at_timestamp:e.Nat64}),V=e.Vec(T),L=e.Record({canister_id:E,sender_canister_version:e.Opt(e.Nat64),snapshot_id:q}),k=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),J=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_proposed_total:e.Nat64}),te=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec(J)})),de=e.Record({settings:e.Opt(S),specified_id:e.Opt(E),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),ge=e.Record({canister_id:E}),Ie=e.Record({canister_id:E,amount:e.Nat}),Ue=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(E),derivation_path:e.Vec(e.Vec(e.Nat8))}),Ke=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),Ht=e.Record({key_id:e.Record({name:e.Text,curve:se}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),Ut=e.Record({signature:e.Vec(e.Nat8)}),Vt=e.Variant({bip341:e.Record({merkle_root_hash:e.Vec(e.Nat8)})}),Kt=e.Record({aux:e.Opt(Vt),key_id:e.Record({algorithm:_e,name:e.Text}),derivation_path:e.Vec(e.Vec(e.Nat8)),message:e.Vec(e.Nat8)}),Be=e.Record({signature:e.Vec(e.Nat8)}),Ot=e.Record({canister_id:E}),at=e.Record({canister_id:E}),Ge=e.Record({canister_id:E}),Lc=e.Vec(y),Hc=e.Record({subnet_id:e.Principal}),$e=e.Record({replica_version:e.Text}),Kc=e.Record({replace_snapshot:e.Opt(q),canister_id:E}),Gc=T,$c=e.Record({canister_id:E,sender_canister_version:e.Opt(e.Nat64)}),Wc=e.Record({canister_id:e.Principal,settings:S,sender_canister_version:e.Opt(e.Nat64)}),zc=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),dn=y;return e.Service({bitcoin_get_balance:e.Func([n],[s],[]),bitcoin_get_block_headers:e.Func([o],[d],[]),bitcoin_get_current_fee_percentiles:e.Func([f],[m],[]),bitcoin_get_utxos:e.Func([b],[F],[]),bitcoin_send_transaction:e.Func([C],[],[]),canister_info:e.Func([H],[D],[]),canister_status:e.Func([ae],[w],[]),clear_chunk_store:e.Func([g],[],[]),create_canister:e.Func([R],[I],[]),delete_canister:e.Func([j],[],[]),delete_canister_snapshot:e.Func([Y],[],[]),deposit_cycles:e.Func([oe],[],[]),ecdsa_public_key:e.Func([z],[U],[]),fetch_canister_logs:e.Func([_],[re],["query"]),http_request:e.Func([u],[X],[]),install_chunked_code:e.Func([P],[],[]),install_code:e.Func([B],[],[]),list_canister_snapshots:e.Func([M],[V],[]),load_canister_snapshot:e.Func([L],[],[]),node_metrics_history:e.Func([k],[te],[]),provisional_create_canister_with_cycles:e.Func([de],[ge],[]),provisional_top_up_canister:e.Func([Ie],[],[]),raw_rand:e.Func([],[Ue],[]),schnorr_public_key:e.Func([fe],[Ke],[]),sign_with_ecdsa:e.Func([Ht],[Ut],[]),sign_with_schnorr:e.Func([Kt],[Be],[]),start_canister:e.Func([Ot],[],[]),stop_canister:e.Func([at],[],[]),stored_chunks:e.Func([Ge],[Lc],[]),subnet_info:e.Func([Hc],[$e],[]),take_canister_snapshot:e.Func([Kc],[Gc],[]),uninstall_code:e.Func([$c],[],[]),update_settings:e.Func([Wc],[],[]),upload_chunk:e.Func([zc],[dn],[])})}});var cc=ee(ze=>{"use strict";var cN=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 uN=Lf(),md=qs(),gd=wi(),Ws=Ri(),b_=ac(),pr=Ct(),lN=$t(),Gi=Fi(),dN=cN(g_()),zs=class extends gd.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=zs;var oc=class extends zs{constructor(t,r,n){var i;super(t,r,"query",{Status:n.status,Code:(i=md.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};ze.QueryCallRejectedError=oc;var Ys=class extends zs{constructor(t,r,n,i,s,a,o){super(t,r,"update",Object.assign({"Request ID":(0,lN.toHex)(n)},i.body?Object.assign(Object.assign({},o?{"Error code":o}:{}),{"Reject code":String(s),"Reject message":a}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=a,this.error_code=o}};ze.UpdateCallRejectedError=Ys;var fr=Symbol.for("ic-agent-metadata"),Js=class e{constructor(t){this[fr]=Object.freeze(t)}static agentOf(t){return t[fr].config.agent}static interfaceOf(t){return t[fr].service}static canisterIdOf(t){return pr.Principal.from(t[fr].config.canisterId)}static async install(t,r){let n=t.mode===void 0?{install:null}:t.mode,i=t.arg?[...new Uint8Array(t.arg)]:[],s=[...new Uint8Array(t.module)],a=typeof r.canisterId=="string"?pr.Principal.fromText(r.canisterId):r.canisterId;await bd(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:a,sender_canister_version:[]})}static async createCanister(t,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await bd(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:Ws.IDL});class i extends e{constructor(a){if(!a.canisterId)throw new gd.AgentError(`Canister ID is required, but received ${typeof a.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let o=typeof a.canisterId=="string"?pr.Principal.fromText(a.canisterId):a.canisterId;super({config:Object.assign(Object.assign(Object.assign({},w_),a),{canisterId:o}),service:n});for(let[c,d]of n._fields)r?.httpDetails&&d.annotations.push(ze.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&d.annotations.push(ze.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=fN(this,c,d,a.blsVerify)}}return i}static createActor(t,r){if(!r.canisterId)throw new gd.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=Js;function $i(e,t){let r=Ws.IDL.decode(e,uN.Buffer.from(t));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var w_={pollingStrategyFactory:b_.strategy.defaultStrategy};ze.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";ze.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function fN(e,t,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(a,...o)=>{var c,d;a=Object.assign(Object.assign({},a),(d=(c=e[fr].config).queryTransform)===null||d===void 0?void 0:d.call(c,t,o,Object.assign(Object.assign({},e[fr].config),a)));let f=a.agent||e[fr].config.agent||(0,md.getDefaultAgent)(),p=pr.Principal.from(a.canisterId||e[fr].config.canisterId),m=Ws.IDL.encode(r.argTypes,o),b=await f.query(p,{methodName:t,arg:m,effectiveCanisterId:a.effectiveCanisterId}),l=Object.assign(Object.assign({},b.httpDetails),{requestDetails:b.requestDetails});switch(b.status){case"rejected":throw new oc(p,t,b);case"replied":return r.annotations.includes(ze.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:l,result:$i(r.retTypes,b.reply.arg)}:$i(r.retTypes,b.reply.arg)}}:i=async(a,...o)=>{var c,d;a=Object.assign(Object.assign({},a),(d=(c=e[fr].config).callTransform)===null||d===void 0?void 0:d.call(c,t,o,Object.assign(Object.assign({},e[fr].config),a)));let f=a.agent||e[fr].config.agent||(0,md.getDefaultAgent)(),{canisterId:p,effectiveCanisterId:m,pollingStrategyFactory:b}=Object.assign(Object.assign(Object.assign({},w_),e[fr].config),a),l=pr.Principal.from(p),A=m!==void 0?pr.Principal.from(m):l,v=Ws.IDL.encode(r.argTypes,o),{requestId:F,response:C,requestDetails:E}=await f.call(l,{methodName:t,arg:v,effectiveCanisterId:A}),H,x;if(C.body&&C.body.certificate){if(f.rootKey==null)throw new Error("Agent is missing root key");let D=C.body.certificate;x=await Gi.Certificate.create({certificate:(0,Ws.bufFromBufLike)(D),rootKey:f.rootKey,canisterId:pr.Principal.from(p),blsVerify:n});let ae=[new TextEncoder().encode("request_status"),F];switch(new TextDecoder().decode((0,Gi.lookupResultToBuffer)(x.lookup([...ae,"status"])))){case"replied":H=(0,Gi.lookupResultToBuffer)(x.lookup([...ae,"reply"]));break;case"rejected":{let ne=new Uint8Array((0,Gi.lookupResultToBuffer)(x.lookup([...ae,"reject_code"])))[0],w=new TextDecoder().decode((0,Gi.lookupResultToBuffer)(x.lookup([...ae,"reject_message"]))),g=(0,Gi.lookupResultToBuffer)(x.lookup([...ae,"error_code"])),S=g?new TextDecoder().decode(g):void 0;throw new Ys(l,t,F,C,ne,w,S)}}}else if(C.body&&"reject_message"in C.body){let{reject_code:D,reject_message:ae,error_code:Q}=C.body;throw new Ys(l,t,F,C,D,ae,Q)}if(C.status===202){let D=b(),ae=await(0,b_.pollForResponse)(f,A,F,D,n);x=ae.certificate,H=ae.reply}let q=r.annotations.includes(ze.ACTOR_METHOD_WITH_HTTP_DETAILS),K=r.annotations.includes(ze.ACTOR_METHOD_WITH_CERTIFICATE),G=Object.assign(Object.assign({},C),{requestDetails:E});if(H!==void 0)return q&&K?{httpDetails:G,certificate:x,result:$i(r.retTypes,H)}:K?{certificate:x,result:$i(r.retTypes,H)}:q?{httpDetails:G,result:$i(r.retTypes,H)}:$i(r.retTypes,H);if(r.retTypes.length===0)return q?{httpDetails:C,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...a)=>i({},...a);return s.withOptions=a=>(...o)=>i(a,...o),s}function bd(e){function t(r,n){if(e.effectiveCanisterId)return{effectiveCanisterId:pr.Principal.from(e.effectiveCanisterId)};let i=n[0],s=pr.Principal.fromHex("");return i&&typeof i=="object"&&i.target_canister&&r==="install_chunked_code"&&(s=pr.Principal.from(i.target_canister)),i&&typeof i=="object"&&i.canister_id&&(s=pr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return Js.createActor(dN.default,Object.assign(Object.assign(Object.assign({},e),{canisterId:pr.Principal.fromHex("")}),{callTransform:t,queryTransform:t}))}ze.getManagementCanister=bd;var wd=class extends Js{constructor(t){super(t)}};ze.AdvancedActor=wd});var x_=ee(xd=>{"use strict";Object.defineProperty(xd,"__esModule",{value:!0});xd.default=({IDL:e})=>e.Service({retrieve:e.Func([e.Text],[e.Vec(e.Nat8)],["query"]),store:e.Func([e.Text,e.Vec(e.Nat8)],[],[])})});var T_=ee(Wi=>{"use strict";var pN=Wi&&Wi.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Wi,"__esModule",{value:!0});Wi.createAssetCanisterActor=void 0;var hN=cc(),_N=pN(x_());function yN(e){return hN.Actor.createActor(_N.default,e)}Wi.createAssetCanisterActor=yN});var N_=ee(zr=>{"use strict";var mN=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]}),gN=zr&&zr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),bN=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)&&mN(t,e,r);return gN(t,e),t};Object.defineProperty(zr,"__esModule",{value:!0});zr.fetchCandid=void 0;var wN=Ct(),xN=bN(Ds()),TN=pd(),NN=cc();async function EN(e,t){t||(t=await TN.HttpAgent.create());let n=(await xN.request({agent:t,canisterId:wN.Principal.fromText(e),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:a})=>a.Service({__get_candid_interface_tmp_hack:a.Func([],[a.Text],["query"])});return await NN.Actor.createActor(i,{agent:t,canisterId:e}).__get_candid_interface_tmp_hack()}zr.fetchCandid=EN});var gt=ee(Pe=>{"use strict";var E_=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]}),ON=Pe&&Pe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ft=Pe&&Pe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&E_(t,e,r)},Td=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)&&E_(t,e,r);return ON(t,e),t};Object.defineProperty(Pe,"__esModule",{value:!0});Pe.Cbor=Pe.CanisterStatus=Pe.polling=void 0;Ft(cc(),Pe);Ft(qs(),Pe);Ft(fo(),Pe);Ft(Rs(),Pe);Ft(al(),Pe);Ft(T_(),Pe);Ft(Fi(),Pe);Ft(od(),Pe);Ft(N_(),Pe);Ft(ld(),Pe);Ft(cd(),Pe);Ft(Ns(),Pe);Ft(Ml(),Pe);Ft($t(),Pe);Ft(_l(),Pe);Pe.polling=Td(ac());Pe.CanisterStatus=Td(Ds());Pe.Cbor=Td(vs());Ft(ac(),Pe)});var De=ee(($6,H_)=>{"use strict";var Rd=Object.defineProperty,vN=Object.getOwnPropertyDescriptor,RN=Object.getOwnPropertyNames,AN=Object.prototype.hasOwnProperty,SN=(e,t)=>{for(var r in t)Rd(e,r,{get:t[r],enumerable:!0})},IN=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of RN(t))!AN.call(e,i)&&i!==r&&Rd(e,i,{get:()=>t[i],enumerable:!(n=vN(t,i))||n.enumerable});return e},BN=e=>IN(Rd({},"__esModule",{value:!0}),e),A_={};SN(A_,{AgentManager:()=>jN,Canister:()=>DN,FromStringToTokenError:()=>S_,ICPToken:()=>VN,InvalidPercentageError:()=>V_,NullishError:()=>C_,TokenAmount:()=>CN,TokenAmountV2:()=>qN,arrayBufferToUint8Array:()=>zN,arrayOfNumberToUint8Array:()=>JN,asNonNullish:()=>HN,asciiStringToByteArray:()=>ZN,assertNonNullish:()=>ta,assertPercentageNumber:()=>KN,base64ToUint8Array:()=>i2,bigEndianCrc32:()=>o2,bigIntToUint8Array:()=>$N,candidNumberArrayToBigInt:()=>e2,convertStringToE8s:()=>I_,createAgent:()=>F_,createServices:()=>LN,debounce:()=>_2,decodeBase32:()=>r2,defaultAgent:()=>P_,encodeBase32:()=>t2,fromDefinedNullable:()=>m2,fromNullable:()=>Ad,fromNullishNullable:()=>g2,hashObject:()=>u2,hashText:()=>M_,hexStringToUint8Array:()=>XN,isEmptyString:()=>kN,isNullish:()=>ea,jsonReplacer:()=>k_,jsonReviver:()=>c2,nonNullish:()=>Yr,notEmptyString:()=>B_,nowInBigIntNanoSeconds:()=>p2,numberToUint8Array:()=>WN,principalToSubAccount:()=>b2,queryAndUpdate:()=>MN,secondsToDuration:()=>d2,smallerVersion:()=>w2,toBigIntNanoSeconds:()=>h2,toNullable:()=>y2,uint8ArrayToArrayOfNumber:()=>YN,uint8ArrayToBase64:()=>n2,uint8ArrayToBigInt:()=>GN,uint8ArrayToHexString:()=>q_,uint8ArraysEqual:()=>QN});H_.exports=BN(A_);var S_=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(S_||{}),PN=BigInt(1e8),FN=8,I_=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)*PN}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},UN=({amount:e,decimals:t})=>{e=e.trim().replace(/[,']/g,"");let r=e.match(/\d*(\.\d*)?/);if(!r||r[0]!==e)return 1;let[n,i]=e.split("."),s=0n,a=10n**BigInt(t);if(n)try{s+=BigInt(n)*a}catch{return 1}if(i){if(i.length>t)return 2;try{s+=BigInt(i.padEnd(t,"0"))}catch{return 1}}return s},VN={symbol:"ICP",name:"Internet Computer",decimals:8},CN=class Xs{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 Xs(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=I_(t);return typeof n=="bigint"?new Xs(n,r):n}static fromNumber({amount:t,token:r}){let n=Xs.fromString({amount:t.toString(),token:r});if(n instanceof Xs)return n;throw n===0?new Error(`Number ${t} has more than 8 decimals`):new Error(`Invalid number ${t}`)}toE8s(){return this.e8s}},qN=class Qs{constructor(t,r){this.ulps=t,this.token=r}static fromUlps({amount:t,token:r}){return new Qs(t,r)}static fromString({amount:t,token:r}){let n=UN({amount:t,decimals:r.decimals});return typeof n=="bigint"?new Qs(n,r):n}static fromNumber({amount:t,token:r}){let n=Qs.fromString({amount:t.toFixed(Math.min(FN,r.decimals)),token:r});if(n instanceof Qs)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)}},DN=class{constructor(e,t,r){this.id=e,this.service=t,this.certifiedService=r}get canisterId(){return this.id}caller=({certified:e=!0})=>e?this.certifiedService:this.service},ea=e=>e==null,Yr=e=>!ea(e),B_=e=>Yr(e)&&e!=="",kN=e=>!B_(e),MN=async({request:e,onLoad:t,onQueryError:r,onUpdateError:n,strategy:i="query_and_update",identity:s,resolution:a="race"})=>{let o=!1,c=f=>e({certified:f,identity:s}).then(p=>{o||t({certified:f,response:p})}).catch(p=>{f||r==null||r({error:p,identity:s}),!o&&(ea(n)||(console.error(p),f&&n({error:p,identity:s})))}).finally(()=>o=o||f),d=i==="query"?[c(!1)]:i==="update"?[c(!0)]:[c(!1),c(!0)];await(a==="all_settled"?Promise.allSettled(d):Promise.race(d))},O_=gt(),Nd=gt(),P_=()=>Nd.HttpAgent.createSync({host:"https://icp-api.io",identity:new Nd.AnonymousIdentity}),F_=async({identity:e,host:t,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await Nd.HttpAgent.create({identity:e,...Yr(t)&&{host:t},verifyQuerySignatures:n,...Yr(i)&&{retryTimes:i},shouldFetchRootKey:r}),jN=class U_{constructor(t){this.config=t}agents=void 0;static create(t){return new U_(t)}getAgent=async({identity:t})=>{let r=t.getPrincipal().toText();if(ea(this.agents)||ea(this.agents[r])){let n=await F_({identity:t,fetchRootKey:this.config.fetchRootKey,host:this.config.host,verifyQuerySignatures:!0});return this.agents={...this.agents??{},[r]:n},n}return this.agents[r]};clearAgents=()=>{this.agents=null}},LN=({options:{canisterId:e,serviceOverride:t,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:a,certifiedIdlFactory:o})=>{let c=n??P_(),d=t??O_.Actor.createActor(a,{agent:c,canisterId:e,callTransform:i,queryTransform:s}),f=r??O_.Actor.createActor(o,{agent:c,canisterId:e,callTransform:i,queryTransform:s});return{service:d,certifiedService:f,agent:c,canisterId:e}},V_=class extends Error{},C_=class extends Error{},ta=(e,t)=>{if(e==null)throw new C_(t)},HN=(e,t)=>(ta(e,t),e),KN=e=>{if(e<0||e>100)throw new V_(`${e} is not a valid percentage number.`)},GN=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},$N=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)},WN=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)},zN=e=>new Uint8Array(e),YN=e=>Array.from(e),JN=e=>new Uint8Array(e),ZN=e=>Array.from(e).map(t=>t.charCodeAt(0)),XN=e=>{let t=e.match(/.{1,2}/g);return ta(t,"Invalid hex string."),Uint8Array.from(t.map(r=>parseInt(r,16)))},QN=({a:e,b:t})=>e.length===t.length&&e.every((r,n)=>r===t[n]),q_=e=>(e instanceof Uint8Array||(e=Uint8Array.from(e)),e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")),e2=e=>{let t=0n;for(let r=e.length-1;r>=0;r--)t=(t<<32n)+BigInt(e[r]);return t},uc="abcdefghijklmnopqrstuvwxyz234567",zi=Object.create(null);for(let e=0;e<uc.length;e++)zi[uc[e]]=e;zi[0]=zi.o;zi[1]=zi.i;var t2=e=>{let t=0,r=0,n="",i=s=>(t<0?r|=s>>-t:r=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=uc[r>>3],t+=5),0));for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?uc[r>>3]:"")},r2=e=>{let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0,s=a=>{let o=zi[a.toLowerCase()];ta(o,`Invalid character: ${JSON.stringify(a)}`),o<<=3,r|=o>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=o<<5-t&255:r=0)};for(let a of e)s(a);return n.slice(0,i)},n2=e=>btoa(String.fromCharCode(...new Uint8Array(e))),i2=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)),s2=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]),a2=e=>{let t=-1;for(let r=0;r<e.length;r++){let n=(e[r]^t)&255;t=s2[n]^t>>>8}return(t^-1)>>>0},o2=e=>{let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,a2(e),!1),new Uint8Array(t)},D_=Ct(),Ed="__bigint__",Od="__principal__",vd="__uint8array__",k_=(e,t)=>typeof t=="bigint"?{[Ed]:`${t}`}:Yr(t)&&t instanceof D_.Principal?{[Od]:t.toText()}:Yr(t)&&t instanceof Uint8Array?{[vd]:Array.from(t)}:t,c2=(e,t)=>{let r=n=>t[n];return Yr(t)&&typeof t=="object"&&Ed in t?BigInt(r(Ed)):Yr(t)&&typeof t=="object"&&Od in t?D_.Principal.fromText(r(Od)):Yr(t)&&typeof t=="object"&&vd in t?Uint8Array.from(r(vd)):t},u2=async e=>{let t=JSON.stringify(e,k_);return await M_(t)},M_=async e=>{let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return q_(new Uint8Array(r))},l2={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"},d2=({seconds:e,i18n:t=l2})=>{let r=e/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=f2(i);return i-=j_(s),[Zs({labelKey:"year",amount:s}),Zs({labelKey:"day",amount:i}),Zs({labelKey:"hour",amount:n}),Zs({labelKey:"minute",amount:r}),...e>BigInt(0)&&e<BigInt(60)?[Zs({labelKey:"second",amount:e})]:[]].filter(({amount:a})=>a>0).slice(0,2).map(a=>`${a.amount} ${a.amount===1?t[a.labelKey]:t[`${a.labelKey}_plural`]}`).join(", ")},f2=e=>{let t=e/BigInt(365);for(;j_(t)>e;)t--;return t},j_=e=>{let t=e/BigInt(4);return e*BigInt(365)+t},Zs=({labelKey:e,amount:t})=>({labelKey:e,amount:Number(t)}),L_=1000000n,p2=()=>BigInt(Date.now())*L_,h2=e=>BigInt(e.getTime())*L_,_2=(e,t)=>{let r;return(...n)=>{let i=()=>e(...n);r&&clearTimeout(r),r=setTimeout(i,t!==void 0&&t>0?t:300)}},y2=e=>Yr(e)?[e]:[],Ad=e=>e?.[0],m2=e=>{let t=Ad(e);return ta(t),t},g2=e=>Ad(e??[]),b2=e=>{let t=e.toUint8Array(),r=new Uint8Array(32);return r[0]=t.length,r.set(t,1),r},v_=({nums:e,amountZeros:t})=>t>e.length?[...e,...[...Array(t-e.length).keys()].map(()=>0)]:e,R_=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)},w2=({minVersion:e,currentVersion:t})=>{let r=v_({nums:e.split(".").map(R_),amountZeros:3}).join(".");return v_({nums:t.split(".").map(R_),amountZeros:3}).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var hy=ee(Jr=>{"use strict";var bc=Jr&&Jr.__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},Cn=Jr&&Jr.__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)},mc,gc,Qi,es;Object.defineProperty(Jr,"__esModule",{value:!0});Jr.Ed25519KeyIdentity=Jr.Ed25519PublicKey=void 0;var $2=gt(),ir=gt(),ia=sd();function py(e){return e!==null&&typeof e=="object"}var oi=class e{constructor(t){if(mc.set(this,void 0),gc.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");bc(this,mc,t,"f"),bc(this,gc,e.derEncode(t),"f")}static from(t){if(typeof t=="string"){let r=(0,ir.fromHex)(t);return this.fromRaw(r)}else if(py(t)){let r=t;if(py(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,ir.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,ir.wrapDER)(t,ir.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(t){let r=(0,ir.unwrapDER)(t,ir.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 Cn(this,mc,"f")}get derKey(){return Cn(this,gc,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Jr.Ed25519PublicKey=oi;mc=new WeakMap,gc=new WeakMap;oi.RAW_KEY_LENGTH=32;var Vd=class e extends ir.SignIdentity{constructor(t,r){super(),Qi.set(this,void 0),es.set(this,void 0),bc(this,Qi,oi.from(t),"f"),bc(this,es,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=ia.ed25519.utils.randomPrivateKey()),(0,$2.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=ia.ed25519.getPublicKey(r);return e.fromKeyPair(n,r)}static fromParsedJson(t){let[r,n]=t;return new e(oi.fromDer((0,ir.fromHex)(r)),(0,ir.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(oi.fromRaw(t),r)}static fromSecretKey(t){let r=ia.ed25519.getPublicKey(new Uint8Array(t));return e.fromKeyPair(r,t)}toJSON(){return[(0,ir.toHex)(Cn(this,Qi,"f").toDer()),(0,ir.toHex)(Cn(this,es,"f"))]}getKeyPair(){return{secretKey:Cn(this,es,"f"),publicKey:Cn(this,Qi,"f")}}getPublicKey(){return Cn(this,Qi,"f")}async sign(t){let r=new Uint8Array(t),n=(0,ir.uint8ToBuf)(ia.ed25519.sign(r,Cn(this,es,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(t,r,n){let[i,s,a]=[t,r,n].map(o=>(typeof o=="string"&&(o=(0,ir.fromHex)(o)),o instanceof Uint8Array&&(o=o.buffer),new Uint8Array(o)));return ia.ed25519.verify(s,i,a)}};Jr.Ed25519KeyIdentity=Vd;Qi=new WeakMap,es=new WeakMap});var yy=ee(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});ci.ECDSAKeyIdentity=ci.CryptoError=void 0;var W2=gt(),wc=class e extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,e.prototype)}};ci.CryptoError=wc;function _y(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 wc("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 xc=class e extends W2.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=_y(i),a=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),o=await s.exportKey("spki",a.publicKey);return new this(a,o,s)}static async fromKeyPair(t,r){let n=_y(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)}};ci.ECDSAKeyIdentity=xc;ci.default=xc});var qd=ee(Dn=>{"use strict";var z2=Dn&&Dn.__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},sa=Dn&&Dn.__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)},qn;Object.defineProperty(Dn,"__esModule",{value:!0});Dn.PartialIdentity=void 0;var Y2=Ct(),Cd=class{constructor(t){qn.set(this,void 0),z2(this,qn,t,"f")}get rawKey(){return sa(this,qn,"f").rawKey}get derKey(){return sa(this,qn,"f").derKey}toDer(){return sa(this,qn,"f").toDer()}getPublicKey(){return sa(this,qn,"f")}getPrincipal(){return Y2.Principal.from(sa(this,qn,"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.")}};Dn.PartialIdentity=Cd;qn=new WeakMap});var my=ee(Ze=>{"use strict";var J2=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]}),Z2=Ze&&Ze.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),X2=Ze&&Ze.__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)&&J2(t,e,r);return Z2(t,e),t},Q2=Ze&&Ze.__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},eE=Ze&&Ze.__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)},tE=Ze&&Ze.__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(Ze,"__esModule",{value:!0});Ze.isDelegationValid=Ze.PartialDelegationIdentity=Ze.DelegationIdentity=Ze.DelegationChain=Ze.Delegation=void 0;var kn=gt(),kd=Ct(),aa=X2(Os()),rE=qd(),nE=new TextEncoder().encode("ic-request-auth-delegation"),iE=new TextEncoder().encode(`
57
- ic-request`);function Dd(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return(0,kn.fromHex)(e)}var oa=class{constructor(t,r,n){this.pubkey=t,this.expiration=r,this.targets=n}toCBOR(){return aa.value.map(Object.assign({pubkey:aa.value.bytes(this.pubkey),expiration:aa.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:aa.value.array(this.targets.map(t=>aa.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,kn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};Ze.Delegation=oa;async function sE(e,t,r,n){let i=new oa(t.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...nE,...new Uint8Array((0,kn.requestIdOf)(Object.assign({},i)))]),a=await e.sign(s);return{delegation:i,signature:a}}var Md=class e{constructor(t,r){this.delegations=t,this.publicKey=r}static async create(t,r,n=new Date(Date.now()+900*1e3),i={}){var s,a;let o=await sE(t,r,n,i.targets);return new e([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],o],((a=i.previous)===null||a===void 0?void 0:a.publicKey)||t.getPublicKey().toDer())}static fromJSON(t){let{publicKey:r,delegations:n}=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:a,signature:o}=s,{pubkey:c,expiration:d,targets:f}=a;if(f!==void 0&&!Array.isArray(f))throw new Error("Invalid targets.");return{delegation:new oa(Dd(c),BigInt("0x"+d),f&&f.map(p=>{if(typeof p!="string")throw new Error("Invalid target.");return kd.Principal.fromHex(p)})),signature:Dd(o)}});return new this(i,Dd(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,kn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,kn.toHex)(n)}}),publicKey:(0,kn.toHex)(this.publicKey)}}};Ze.DelegationChain=Md;var jd=class extends kn.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=tE(t,["body"]),i=await(0,kn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...iE,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};Ze.DelegationIdentity=jd;var Ld=class e extends rE.PartialIdentity{constructor(t,r){super(t),Tc.set(this,void 0),Q2(this,Tc,r,"f")}get delegation(){return eE(this,Tc,"f")}static fromDelegation(t,r){return new e(t,r)}};Ze.PartialDelegationIdentity=Ld;Tc=new WeakMap;function aE(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"?kd.Principal.fromText(i):i)):r.push(typeof n=="string"?kd.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:a}of e.delegations){if(a.targets===void 0)continue;let o=!0;for(let c of a.targets)if(c.toText()===s){o=!1;break}if(o)return!1}}return!0}Ze.isDelegationValid=aE});var gy=ee(Mn=>{"use strict";var oE=Mn&&Mn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Mn,"__esModule",{value:!0});Mn.WebAuthnIdentity=Mn.CosePublicKey=void 0;var ui=gt(),Hd=oE(to()),cE=Kn(),uE=Ri();function lE(e){return(0,ui.wrapDER)(e,ui.DER_COSE_OID).buffer}function dE(e){let t=new DataView(new ArrayBuffer(2)),r=e.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>t.setUint8(s,i));let n=t.getUint16(0);return e.slice(55+n)}var Nc=class{constructor(t){this._cose=t,this._encodedKey=lE(t)}toDer(){return this._encodedKey}getCose(){return this._cose}};Mn.CosePublicKey=Nc;function fE(e="<ic0.app>"){return typeof e=="string"?Uint8Array.from(e,t=>t.charCodeAt(0)):e}async function pE(e){let t=await navigator.credentials.create(e??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:fE(),pubKeyCredParams:[{type:"public-key",alg:Kd.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,cE.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,uE.bufFromBufLike)(t.rawId)}}var Kd;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Kd||(Kd={}));var Gd=class extends ui.SignIdentity{constructor(t,r,n){super(),this.rawId=t,this.authenticatorAttachment=n,this._publicKey=new Nc(r)}static fromJSON(t){let{publicKey:r,rawId:n}=JSON.parse(t);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,ui.fromHex)(n),(0,ui.fromHex)(r),void 0)}static async create(t){var r;let n=await pE(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=Hd.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,dE(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=Hd.default.encode(new Hd.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,ui.toHex)(this._publicKey.getCose()),rawId:(0,ui.toHex)(this.rawId)}}};Mn.WebAuthnIdentity=Gd});var zd=ee(Ye=>{"use strict";var hE=Ye&&Ye.__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]}),Wd=Ye&&Ye.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&hE(t,e,r)};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.Secp256k1KeyIdentity=Ye.ED25519_OID=Ye.DER_COSE_OID=Ye.unwrapDER=Ye.wrapDER=Ye.WebAuthnIdentity=Ye.Ed25519PublicKey=Ye.Ed25519KeyIdentity=void 0;var by=hy();Object.defineProperty(Ye,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return by.Ed25519KeyIdentity}});Object.defineProperty(Ye,"Ed25519PublicKey",{enumerable:!0,get:function(){return by.Ed25519PublicKey}});Wd(yy(),Ye);Wd(my(),Ye);Wd(qd(),Ye);var _E=gy();Object.defineProperty(Ye,"WebAuthnIdentity",{enumerable:!0,get:function(){return _E.WebAuthnIdentity}});var Ec=gt();Object.defineProperty(Ye,"wrapDER",{enumerable:!0,get:function(){return Ec.wrapDER}});Object.defineProperty(Ye,"unwrapDER",{enumerable:!0,get:function(){return Ec.unwrapDER}});Object.defineProperty(Ye,"DER_COSE_OID",{enumerable:!0,get:function(){return Ec.DER_COSE_OID}});Object.defineProperty(Ye,"ED25519_OID",{enumerable:!0,get:function(){return Ec.ED25519_OID}});var $d=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};Ye.Secp256k1KeyIdentity=$d});var Jd=ee(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});Oc.IdleManager=void 0;var wy=["mousedown","mousemove","keydown","touchstart","wheel"],Yd=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),wy.forEach(function(o){document.addEventListener(o,s,!0)});let a=(o,c)=>{let d;return(...f)=>{let p=this,m=function(){d=void 0,o.apply(p,f)};clearTimeout(d),d=window.setTimeout(m,c)}};if(t?.captureScroll){let o=a(s,(r=t?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",o,!0)}s()}static create(t={}){return new this(t)}registerCallback(t){this.callbacks.push(t)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let t=this._resetTimer.bind(this);wy.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)}};Oc.IdleManager=Yd});function mE(){return xy||(xy=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function gE(){return Ty||(Ty=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function bE(e){let t=new Promise((r,n)=>{let i=()=>{e.removeEventListener("success",s),e.removeEventListener("error",a)},s=()=>{r(_r(e.result)),i()},a=()=>{n(e.error),i()};e.addEventListener("success",s),e.addEventListener("error",a)});return t.then(r=>{r instanceof IDBCursor&&Ny.set(r,e)}).catch(()=>{}),ef.set(t,e),t}function wE(e){if(Xd.has(e))return;let t=new Promise((r,n)=>{let i=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",a),e.removeEventListener("abort",a)},s=()=>{r(),i()},a=()=>{n(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",s),e.addEventListener("error",a),e.addEventListener("abort",a)});Xd.set(e,t)}function Oy(e){Qd=e(Qd)}function xE(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...r){let n=e.call(ca(this),t,...r);return Ey.set(n,t.sort?t.sort():[t]),_r(n)}:gE().includes(e)?function(...t){return e.apply(ca(this),t),_r(Ny.get(this))}:function(...t){return _r(e.apply(ca(this),t))}}function TE(e){return typeof e=="function"?xE(e):(e instanceof IDBTransaction&&wE(e),yE(e,mE())?new Proxy(e,Qd):e)}function _r(e){if(e instanceof IDBRequest)return bE(e);if(Zd.has(e))return Zd.get(e);let t=TE(e);return t!==e&&(Zd.set(e,t),ef.set(t,e)),t}var yE,xy,Ty,Ny,Xd,Ey,Zd,ef,Qd,ca,tf=xf(()=>{yE=(e,t)=>t.some(r=>e instanceof r);Ny=new WeakMap,Xd=new WeakMap,Ey=new WeakMap,Zd=new WeakMap,ef=new WeakMap;Qd={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return Xd.get(e);if(t==="objectStoreNames")return e.objectStoreNames||Ey.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return _r(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}};ca=e=>ef.get(e)});var Ry={};Jm(Ry,{deleteDB:()=>EE,openDB:()=>NE,unwrap:()=>ca,wrap:()=>_r});function NE(e,t,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let a=indexedDB.open(e,t),o=_r(a);return n&&a.addEventListener("upgradeneeded",c=>{n(_r(a.result),c.oldVersion,c.newVersion,_r(a.transaction),c)}),r&&a.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),o.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",d=>i(d.oldVersion,d.newVersion,d))}).catch(()=>{}),o}function EE(e,{blocked:t}={}){let r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),_r(r).then(()=>{})}function vy(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(rf.get(t))return rf.get(t);let r=t.replace(/FromIndex$/,""),n=t!==r,i=vE.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||OE.includes(r)))return;let s=async function(a,...o){let c=this.transaction(a,i?"readwrite":"readonly"),d=c.store;return n&&(d=d.index(o.shift())),(await Promise.all([d[r](...o),i&&c.done]))[0]};return rf.set(t,s),s}var OE,vE,rf,Ay=xf(()=>{tf();tf();OE=["get","getKey","getAll","getAllKeys","count"],vE=["put","add","delete","clear"],rf=new Map;Oy(e=>({...e,get:(t,r,n)=>vy(t,r)||e.get(t,r,n),has:(t,r)=>!!vy(t,r)||e.has(t,r)}))});var sf=ee(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});vc.IdbKeyVal=void 0;var RE=(Ay(),Zm(Ry)),ua=Rc(),Sy="auth-client-db",Iy="ic-keyval",AE=async(e=Sy,t=Iy,r)=>(ua.isBrowser&&(localStorage!=null&&localStorage.getItem(ua.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(ua.KEY_STORAGE_DELEGATION),localStorage.removeItem(ua.KEY_STORAGE_KEY)),await(0,RE.openDB)(e,r,{upgrade:n=>{n.objectStoreNames.contains(t)&&n.clear(t),n.createObjectStore(t)}}));async function SE(e,t,r){return await e.get(t,r)}async function IE(e,t,r,n){return await e.put(t,n,r)}async function BE(e,t,r){return await e.delete(t,r)}var nf=class e{constructor(t,r){this._db=t,this._storeName=r}static async create(t){let{dbName:r=Sy,storeName:n=Iy,version:i=ua.DB_VERSION}=t??{},s=await AE(r,n,i);return new e(s,n)}async set(t,r){return await IE(this._db,this._storeName,t,r)}async get(t){var r;return(r=await SE(this._db,this._storeName,t))!==null&&r!==void 0?r:null}async remove(t){return await BE(this._db,this._storeName,t)}};vc.IdbKeyVal=nf});var Rc=ee(it=>{"use strict";var PE=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},FE=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 UE=sf();it.KEY_STORAGE_KEY="identity";it.KEY_STORAGE_DELEGATION="delegation";it.KEY_VECTOR="iv";it.DB_VERSION=1;it.isBrowser=typeof window<"u";var af=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=af;var of=class{constructor(t){Ac.set(this,void 0),PE(this,Ac,t??{},"f")}get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}UE.IdbKeyVal.create(FE(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=of;Ac=new WeakMap});var Ic=ee(et=>{"use strict";var VE=et&&et.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),CE=et&&et.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&VE(t,e,r)};Object.defineProperty(et,"__esModule",{value:!0});et.AuthClient=et.ERROR_USER_INTERRUPT=et.IdbKeyVal=et.KEY_STORAGE_KEY=et.KEY_STORAGE_DELEGATION=et.LocalStorage=et.IdbStorage=void 0;var By=gt(),sr=zd(),Py=Jd(),Et=Rc(),Sc=Rc();Object.defineProperty(et,"IdbStorage",{enumerable:!0,get:function(){return Sc.IdbStorage}});Object.defineProperty(et,"LocalStorage",{enumerable:!0,get:function(){return Sc.LocalStorage}});Object.defineProperty(et,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return Sc.KEY_STORAGE_DELEGATION}});Object.defineProperty(et,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return Sc.KEY_STORAGE_KEY}});var qE=sf();Object.defineProperty(et,"IdbKeyVal",{enumerable:!0,get:function(){return qE.IdbKeyVal}});var DE="https://identity.ic0.app",kE="#authorize",cf="ECDSA",uf="Ed25519",ME=500;et.ERROR_USER_INTERRUPT="UserInterrupt";CE(Jd(),et);var df=class{constructor(t,r,n,i,s,a,o,c){this._identity=t,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=a,this._idpWindow=o,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(t={}){var r,n,i;let s=(r=t.storage)!==null&&r!==void 0?r:new Et.IdbStorage,a=(n=t.keyType)!==null&&n!==void 0?n:cf,o=null;if(t.identity)o=t.identity;else{let p=await s.get(Et.KEY_STORAGE_KEY);if(!p&&Et.isBrowser)try{let m=new Et.LocalStorage,b=await m.get(Et.KEY_STORAGE_DELEGATION),l=await m.get(Et.KEY_STORAGE_KEY);b&&l&&a===cf&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Et.KEY_STORAGE_DELEGATION,b),await s.set(Et.KEY_STORAGE_KEY,l),p=b,await m.remove(Et.KEY_STORAGE_DELEGATION),await m.remove(Et.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(p)try{typeof p=="object"?a===uf&&typeof p=="string"?o=await sr.Ed25519KeyIdentity.fromJSON(p):o=await sr.ECDSAKeyIdentity.fromKeyPair(p):typeof p=="string"&&(o=sr.Ed25519KeyIdentity.fromJSON(p))}catch{}}let c=new By.AnonymousIdentity,d=null;if(o)try{let p=await s.get(Et.KEY_STORAGE_DELEGATION);if(typeof p=="object"&&p!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?c=t.identity:p&&(d=sr.DelegationChain.fromJSON(p),(0,sr.isDelegationValid)(d)?"toDer"in o?c=sr.PartialDelegationIdentity.fromDelegation(o,d):c=sr.DelegationIdentity.fromDelegation(o,d):(await lf(s),o=null))}catch(p){console.error(p),await lf(s),o=null}let f;return!((i=t.idleOptions)===null||i===void 0)&&i.disableIdle?f=void 0:(d||t.identity)&&(f=Py.IdleManager.create(t.idleOptions)),o||(a===uf?(o=await sr.Ed25519KeyIdentity.generate(),await s.set(Et.KEY_STORAGE_KEY,JSON.stringify(o.toJSON()))):(t.storage&&a===cf&&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 '${uf}' as the key type, as it can serialize to a string`),o=await sr.ECDSAKeyIdentity.generate(),await s.set(Et.KEY_STORAGE_KEY,o.getKeyPair()))),new this(c,o,d,s,f,t)}_registerDefaultIdleCallback(){var t,r;let n=(t=this._createOptions)===null||t===void 0?void 0:t.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(t,r){var n,i;let s=t.delegations.map(d=>({delegation:new sr.Delegation(d.delegation.pubkey,d.delegation.expiration,d.delegation.targets),signature:d.signature.buffer})),a=sr.DelegationChain.fromDelegations(s,t.userPublicKey.buffer),o=this._key;if(!o)return;this._chain=a,"toDer"in o?this._identity=sr.PartialDelegationIdentity.fromDelegation(o,this._chain):this._identity=sr.DelegationIdentity.fromDelegation(o,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=Py.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Et.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(t)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(t){var r,n,i,s;let a=BigInt(8)*BigInt(36e11),o=new URL(((r=t?.identityProvider)===null||r===void 0?void 0:r.toString())||DE);o.hash=kE,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(o,Object.assign({maxTimeToLive:(i=t?.maxTimeToLive)!==null&&i!==void 0?i:a},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(o.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(et.ERROR_USER_INTERRUPT,t?.onError):setTimeout(c,ME))};c()}_getEventHandler(t,r){return async n=>{var i,s,a;if(n.origin!==t.origin)return;let o=n.data;switch(o.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(a=this._idpWindow)===null||a===void 0||a.postMessage(c,t.origin);break}case"authorize-client-success":try{await this._handleSuccess(o,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(o.text,r?.onError);break;default:break}}}_handleFailure(t,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(t),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(t={}){if(await lf(this._storage),this._identity=new By.AnonymousIdentity,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};et.AuthClient=df;async function lf(e){await e.remove(Et.KEY_STORAGE_KEY),await e.remove(Et.KEY_STORAGE_DELEGATION),await e.remove(Et.KEY_VECTOR)}});var Im=be(De(),1);var z_=be(De(),1),lc=be(gt(),1),Y_=be(De(),1),na=be(gt(),1),Lt=be(De(),1),Z_=be(De(),1),ty=be(De(),1),x2=({authData:e})=>{if(e.byteLength<37)return{invalidAuthData:null};if(e.byteLength<53)return{invalidAuthData:null};let t=e.slice(37,53),r=T2({bytes:t});return"aaguid"in r?{aaguidBytes:t,aaguidText:r.aaguid}:{unknownProvider:null}},T2=({bytes:e})=>{if(e.length!==16)return{invalidBytes:null};let t=(e instanceof Uint8Array?(0,z_.uint8ArrayToArrayOfNumber)(e):e).map(r=>r.toString(16).padStart(2,"0")).join("").replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5");return t==="00000000-0000-0000-0000-000000000000"?{unknownProvider:null}:{aaguid:t}};function N2(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)}function E2(e){return(0,lc.wrapDER)(e.buffer,lc.DER_COSE_OID).buffer}var O2=class{constructor(e){this._cose=e,this._encodedKey=E2(e)}_encodedKey;toDer(){return this._encodedKey}},J_=class{#e;#t;constructor({rawId:e,cose:t}){this.#e=e,this.#t=new O2(t)}getPublicKey(){return this.#t}getCredentialId(){return this.#e}getCredentialIdText(){return(0,Y_.uint8ArrayToBase64)(this.#e)}},v2=class extends J_{#e;#t;constructor({authData:e,...t}){super(t);let r=x2({authData:e});this.#e="aaguidText"in r?r.aaguidText:void 0,this.#t="aaguidBytes"in r?r.aaguidBytes:void 0}getAAGUID(){return this.#t}getAAGUIDText(){return this.#e}},R2=class extends J_{},A2=class extends Error{},S2=class extends Error{},I2=class extends Error{},B2=class extends Error{},P2=class extends Error{},F2=class extends Error{},U2=class extends Error{},K_=class extends Error{};var V2={ECDSA_WITH_SHA256:-7,RSA_WITH_SHA256:-257},C2=6e4,X_=()=>window.crypto.getRandomValues(new Uint8Array(16)),q2=()=>X_(),D2=()=>X_(),k2=()=>{let{location:{href:e}}=window,t=URL.parse(e);if((0,Z_.isNullish)(t))throw new A2;let{hostname:r}=t;return r},Q_=({appId:e})=>e?.id??k2(),M2=({appId:e,user:t}={})=>{let{document:{title:r}}=window,n=()=>({rp:{name:e?.name??r,id:Q_({appId:e})}}),i=()=>({user:{id:D2(),name:t?.name??t?.displayName??r,displayName:t?.displayName??r}});return{attestation:"direct",challenge:q2(),...n(),...i(),pubKeyCredParams:Object.values(V2).map(s=>({type:"public-key",alg:s})),excludeCredentials:[],authenticatorSelection:{authenticatorAttachment:"platform",userVerification:"preferred",residentKey:"required",requireResidentKey:!0}}},j2=(e={})=>({rpId:Q_(e),allowCredentials:[],userVerification:"required"}),Sd=async({fn:e,step:t,onProgress:r})=>{r?.({step:t,state:"in_progress"});try{let n=await e();return r?.({step:t,state:"success"}),n}catch(n){throw r?.({step:t,state:"error"}),n}},Vn=(e=>(e[e.RequestingUserCredential=0]="RequestingUserCredential",e[e.FinalizingCredential=1]="FinalizingCredential",e[e.Signing=2]="Signing",e))(Vn||{}),ey=({timeout:e})=>AbortSignal.timeout(e??C2),L2=async({challenge:e,credentialIds:t,passkeyOptions:r,timeout:n})=>await navigator.credentials.get({publicKey:{...j2(r),challenge:e.buffer,allowCredentials:(t??[]).map(i=>({id:i.buffer,type:"public-key"}))},signal:ey({timeout:n})}),G_=e=>{if(e.status!=="initialized")throw new S2},$_=e=>{if((0,Lt.isNullish)(e))throw new I2},W_=({type:e})=>{if(e!=="public-key")throw new B2},Id=class ra extends na.SignIdentity{#e;#t;constructor({onProgress:t,...r}){if(super(),this.#e=t,"retrievePublicKey"in r){let{retrievePublicKey:n}=r;this.#t={status:"pending",retrievePublicKey:n};return}this.#t=ra.#r({credential:new v2(r)})}static#r({credential:t}){return{status:"initialized",credential:t}}static async createWithNewCredential({passkeyOptions:t,timeout:r,...n}={}){let i=await navigator.credentials.create({publicKey:M2(t),signal:ey({timeout:r})});$_(i),W_(i);let{response:{attestationObject:s},rawId:a}=i;if((0,Lt.isNullish)(s))throw new P2;let{authData:o}=na.Cbor.decode(s),c=N2(o);return new ra({...n,rawId:(0,Lt.arrayBufferToUint8Array)(a),cose:c,authData:o})}static async createWithExistingCredential(t){return new ra(t)}getPublicKey(){G_(this.#t);let{credential:t}=this.#t;return t.getPublicKey()}getCredential(){G_(this.#t);let{credential:t}=this.#t;return t}async sign(t){let r=await Sd({fn:async()=>{let n=await L2({challenge:(0,Lt.arrayBufferToUint8Array)(t),...this.#t.status==="initialized"&&{credentialIds:[this.#t.credential.getCredentialId()]}});return $_(n),W_(n),n},step:0,onProgress:this.#e});return await Sd({fn:async()=>{let{rawId:n}=r;if(this.#t.status==="initialized"){if(!(0,Lt.uint8ArraysEqual)({a:this.#t.credential.getCredentialId(),b:(0,Lt.arrayBufferToUint8Array)(n)}))throw new F2;return}let{retrievePublicKey:i}=this.#t,s=await i({credentialId:(0,Lt.arrayBufferToUint8Array)(n)});this.#t=ra.#r({credential:new R2({rawId:(0,Lt.arrayBufferToUint8Array)(n),cose:s})})},step:1,onProgress:this.#e}),await Sd({fn:async()=>{let{response:n}=r,{clientDataJSON:i}=n,{authenticatorData:s,signature:a}="authenticatorData"in n&&"signature"in n?n:{};if((0,Lt.isNullish)(s))throw new K_;if((0,Lt.isNullish)(a))throw new K_;let o=na.Cbor.encode({authenticator_data:s,client_data_json:new TextDecoder().decode(i),signature:(0,Lt.arrayBufferToUint8Array)(a)});if((0,Lt.isNullish)(o))throw new U2;return Object.assign(o,{__signature__:void 0}),o},step:2,onProgress:this.#e})}},H2=async()=>(0,ty.nonNullish)(window.PublicKeyCredential)&&"isUserVerifyingPlatformAuthenticatorAvailable"in PublicKeyCredential?await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():!1;var hm=be(De(),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 hr=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 Bd=({message:e,detail:t})=>{let r=new CustomEvent(e,{detail:t,bubbles:!0});document.dispatchEvent(r)};var pm=be(De(),1);var sy=be(gt(),1),fc=be(De(),1);var dc=be(De(),1);var ny=be(gt(),1),Pd=be(De(),1);var Ji="http://127.0.0.1:5987",ry="rdmx6-jaaaa-aaaaa-aaadq-cai";var iy=async({identity:e,container:t})=>{let n=(0,Pd.nonNullish)(t)&&t!==!1?t===!0?Ji:t:"https://icp-api.io",i=(0,Pd.nonNullish)(t);return await ny.HttpAgent.create({identity:e,shouldFetchRootKey:i,host:n})};var Zi=class e{static instance;#e=void 0;constructor(){}static getInstance(){return(0,dc.isNullish)(e.instance)&&(e.instance=new e),e.instance}async getAgent({identity:t,...r}){let n=t.getPrincipal().toText();if((0,dc.isNullish)(this.#e)||(0,dc.isNullish)(this.#e[n])){let i=await iy({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,fc.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,fc.isNullish)(this.#e)||(0,fc.isNullish)(this.#e[s])){let a=await this.createActor({satelliteId:t,identity:r,...i});return this.#e={...this.#e??{},[s]:a},a}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:t,satelliteId:r,...n}){let i=await Zi.getInstance().getAgent(n);return sy.Actor.createActor(t,{agent:i,canisterId:r})}};var ay=e=>(e.preventDefault(),e.returnValue="Are you sure you want to exit?"),K2=()=>{window.addEventListener("beforeunload",ay,{capture:!0})},G2=()=>{window.removeEventListener("beforeunload",ay,{capture:!0})},Fd=async({fn:e})=>{try{return K2(),await e()}finally{G2()}};var la=be(De(),1);var nr=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 oy=BigInt(144e11),cy=!1,uy={width:576,height:576},ly={width:505,height:705},dy="internetcomputer.org";var Ud=be(De(),1);var pc=be(De(),1),fy=async e=>{let t=new Blob([JSON.stringify(e,pc.jsonReplacer)],{type:"application/json; charset=utf-8"});return new Uint8Array(await t.arrayBuffer())},hc=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(),pc.jsonReviver)},_c=()=>typeof window<"u";var yc=({width:e,height:t})=>{if(!_c()||(0,Ud.isNullish)(window)||(0,Ud.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 Uy=be(Ic(),1),Vy=be(De(),1);var Zr=async({fn:e,step:t,onProgress:r})=>{r?.({step:t,state:"in_progress"});try{let n=await e();return r?.({step:t,state:"success"}),n}catch(n){throw r?.({step:t,state:"error"}),n}};var Fy=(r=>(r[r.AuthorizingWithProvider=0]="AuthorizingWithProvider",r[r.CreatingOrRetrievingUser=1]="CreatingOrRetrievingUser",r))(Fy||{});var Bc=class extends Error{},li=class extends Error{},Pc=class extends Error{},Fc=class extends Error{},Uc=class extends Error{},Vc=class extends Error{},Cc=class extends Error{};var ts=class{async signIn({options:t,authClient:r,initAuth:n}){await Zr({fn:async()=>await this.#e({options:t,authClient:r}),step:0,onProgress:t?.onProgress}),await Zr({fn:async()=>await n({provider:this.id}),step:1,onProgress:t?.onProgress})}#e({options:t,authClient:r}){return new Promise(async(n,i)=>{if((0,Vy.isNullish)(r)){i(new li("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}await r.login({onSuccess:n,onError:s=>{if(s===Uy.ERROR_USER_INTERRUPT){i(new Pc(s));return}i(new Bc(s))},maxTimeToLive:t?.maxTimeToLiveInNanoseconds??oy,allowPinAuthentication:t?.allowPin??cy,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...this.signInOptions({windowed:t?.windowed})})})}};var qc=class extends ts{#e;constructor({domain:t}={}){super(),this.#e=t}get id(){return"internet_identity"}signInOptions({windowed:t}){let r=()=>{let n=nr.getInstance().get()?.container;if((0,la.isNullish)(n)||n===!1)return`https://identity.${this.#e??dy}`;let i=nr.getInstance().get(),s=(0,la.nonNullish)(i)&&(0,la.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:ry,{host:a,protocol:o}=new URL(n===!0?Ji:n);return/apple/i.test(navigator?.vendor)?`${o}//${a}?canisterId=${s}`:`${o}//${s}.${a.replace("127.0.0.1","localhost")}`};return{...t!==!1&&{windowOpenerFeatures:yc(uy)},identityProvider:r()}}};var Dc=class extends ts{#e;#t;constructor({appName:t,logoUrl:r}){super(),this.#e=t,this.#t=r}get id(){return"nfid"}signInOptions({windowed:t}){return{...t!==!1&&{windowOpenerFeatures:yc(ly)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var om=be(gt(),1),is=be(Ic(),1),Qr=be(zd(),1),ns=be(De(),1);var Xr={certified:!1};var Cy=be(gt(),1),qy=be(De(),1);var tt=e=>(0,qy.nonNullish)(e)?e:kc()??new Cy.AnonymousIdentity;var Sr=be(De(),1);var jy=be(De(),1);var jE=be(gt(),1),LE=be(De(),1),HE=be(De(),1),KE=be(gt(),1);var Dy=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),n=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),i=e.Record({field:n,desc:e.Bool}),s=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),a=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(s),description:e.Opt(e.Text),created_at:e.Opt(s)}),o=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),c=e.Record({order:e.Opt(i),owner:e.Opt(e.Principal),matcher:e.Opt(a),paginate:e.Opt(o)}),d=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),p=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:f,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),b=e.Variant({Db:e.Null,Storage:e.Null}),l=e.Record({version:e.Opt(e.Nat64)}),A=e.Record({proposal_ids:e.Vec(e.Nat)}),v=e.Record({cycles:e.Nat,destination_id:e.Principal}),F=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),C=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),E=e.Record({key:F,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,C)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),H=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),x=e.Record({allowed_callers:e.Vec(e.Principal)}),q=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),K=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),G=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),D=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),ae=e.Variant({Deny:e.Null,Allow:e.Null}),Q=e.Record({status_code:e.Nat16,location:e.Text}),ne=e.Record({iframe:e.Opt(D),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),w=e.Record({db:e.Opt(G),authentication:e.Opt(q),storage:ne}),g=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),S=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),R=e.Record({clear_existing_assets:e.Opt(e.Bool)}),I=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),j=e.Variant({AssetsUpgrade:R,SegmentsDeployment:I}),Y=e.Record({status:S,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:j}),oe=e.Variant({Heap:e.Null,Stable:e.Null}),se=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),z=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),U=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:se,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(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)}),Z=e.Record({memory:oe,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),re=e.Variant({Callback:e.Record({token:Z,callback:e.Func([],[],["query"])})}),le=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(re),status_code:e.Nat16}),X=e.Record({token:e.Opt(Z),body:e.Vec(e.Nat8)}),u=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),h=e.Record({batch_id:e.Nat}),y=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,E)),items_length:e.Nat64}),P=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),O=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}),B=e.Record({desc:e.Bool}),M=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),T=e.Record({order:e.Opt(B),paginate:e.Opt(M)}),V=e.Record({proposal_id:e.Nat}),L=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(V,Y)),items_length:e.Nat64}),k=e.Record({include_system:e.Bool}),J=e.Record({matcher:e.Opt(k)}),te=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,U)),items_length:e.Nat64}),de=e.Record({stable:e.Nat64,heap:e.Nat64}),ge=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),Ie=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:f,expires_at:e.Opt(e.Nat64)}),Ue=e.Record({controller:Ie,controllers:e.Vec(e.Principal)}),_e=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),fe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Ke=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),max_size:e.Opt(e.Nat),read:se,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(z),write:se,max_changes_per_user:e.Opt(e.Nat32)}),Ht=e.Record({iframe:e.Opt(D),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),Ut=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Vt=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),commit_proposal:e.Func([r],[e.Null],[]),commit_proposal_asset_upload:e.Func([t],[],[]),commit_proposal_many_assets_upload:e.Func([e.Vec(t)],[],[]),count_assets:e.Func([e.Text,c],[e.Nat64],["query"]),count_collection_assets:e.Func([e.Text],[e.Nat64],["query"]),count_collection_docs:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text,c],[e.Nat64],["query"]),count_proposals:e.Func([],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([d],[e.Vec(e.Tuple(e.Principal,p))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,c],[],[]),del_filtered_docs:e.Func([e.Text,c],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,m))],[],[]),del_rule:e.Func([b,e.Text,l],[],[]),delete_proposal_assets:e.Func([A],[],[]),deposit_cycles:e.Func([v],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(E)],["query"]),get_auth_config:e.Func([],[e.Opt(q)],["query"]),get_config:e.Func([],[w],[]),get_db_config:e.Func([],[e.Opt(G)],["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(E)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(g)))],["query"]),get_proposal:e.Func([e.Nat],[e.Opt(Y)],["query"]),get_rule:e.Func([b,e.Text],[e.Opt(U)],["query"]),get_storage_config:e.Func([],[ne],["query"]),http_request:e.Func([_],[le],["query"]),http_request_streaming_callback:e.Func([Z],[X],["query"]),init_asset_upload:e.Func([u],[h],[]),init_proposal:e.Func([j],[e.Nat,Y],[]),init_proposal_asset_upload:e.Func([u,e.Nat],[h],[]),init_proposal_many_assets_upload:e.Func([e.Vec(u),e.Nat],[e.Vec(e.Tuple(e.Text,h))],[]),list_assets:e.Func([e.Text,c],[y],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,p))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,P))],["query"]),list_docs:e.Func([e.Text,c],[O],["query"]),list_proposals:e.Func([T],[L],["query"]),list_rules:e.Func([b,J],[te],["query"]),memory_size:e.Func([],[de],["query"]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([ge],[q],[]),set_controllers:e.Func([Ue],[e.Vec(e.Tuple(e.Principal,p))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([_e],[G],[]),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,Ke],[U],[]),set_storage_config:e.Func([Ht],[ne],[]),submit_proposal:e.Func([e.Nat],[e.Nat,Y],[]),upload_asset_chunk:e.Func([Ut],[Vt],[]),upload_proposal_asset_chunk:e.Func([Ut],[Vt],[])})},ky=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),n=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),i=e.Record({field:n,desc:e.Bool}),s=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),a=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(s),description:e.Opt(e.Text),created_at:e.Opt(s)}),o=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),c=e.Record({order:e.Opt(i),owner:e.Opt(e.Principal),matcher:e.Opt(a),paginate:e.Opt(o)}),d=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),p=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:f,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),b=e.Variant({Db:e.Null,Storage:e.Null}),l=e.Record({version:e.Opt(e.Nat64)}),A=e.Record({proposal_ids:e.Vec(e.Nat)}),v=e.Record({cycles:e.Nat,destination_id:e.Principal}),F=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),C=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),E=e.Record({key:F,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,C)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),H=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),x=e.Record({allowed_callers:e.Vec(e.Principal)}),q=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),K=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),G=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),D=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),ae=e.Variant({Deny:e.Null,Allow:e.Null}),Q=e.Record({status_code:e.Nat16,location:e.Text}),ne=e.Record({iframe:e.Opt(D),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),w=e.Record({db:e.Opt(G),authentication:e.Opt(q),storage:ne}),g=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),S=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),R=e.Record({clear_existing_assets:e.Opt(e.Bool)}),I=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),j=e.Variant({AssetsUpgrade:R,SegmentsDeployment:I}),Y=e.Record({status:S,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:j}),oe=e.Variant({Heap:e.Null,Stable:e.Null}),se=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),z=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),U=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:se,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(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)}),Z=e.Record({memory:oe,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),re=e.Variant({Callback:e.Record({token:Z,callback:e.Func([],[],[])})}),le=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(re),status_code:e.Nat16}),X=e.Record({token:e.Opt(Z),body:e.Vec(e.Nat8)}),u=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),h=e.Record({batch_id:e.Nat}),y=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,E)),items_length:e.Nat64}),P=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),O=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}),B=e.Record({desc:e.Bool}),M=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),T=e.Record({order:e.Opt(B),paginate:e.Opt(M)}),V=e.Record({proposal_id:e.Nat}),L=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(V,Y)),items_length:e.Nat64}),k=e.Record({include_system:e.Bool}),J=e.Record({matcher:e.Opt(k)}),te=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,U)),items_length:e.Nat64}),de=e.Record({stable:e.Nat64,heap:e.Nat64}),ge=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),Ie=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:f,expires_at:e.Opt(e.Nat64)}),Ue=e.Record({controller:Ie,controllers:e.Vec(e.Principal)}),_e=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),fe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Ke=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),max_size:e.Opt(e.Nat),read:se,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(z),write:se,max_changes_per_user:e.Opt(e.Nat32)}),Ht=e.Record({iframe:e.Opt(D),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),Ut=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Vt=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),commit_proposal:e.Func([r],[e.Null],[]),commit_proposal_asset_upload:e.Func([t],[],[]),commit_proposal_many_assets_upload:e.Func([e.Vec(t)],[],[]),count_assets:e.Func([e.Text,c],[e.Nat64],[]),count_collection_assets:e.Func([e.Text],[e.Nat64],[]),count_collection_docs:e.Func([e.Text],[e.Nat64],[]),count_docs:e.Func([e.Text,c],[e.Nat64],[]),count_proposals:e.Func([],[e.Nat64],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([d],[e.Vec(e.Tuple(e.Principal,p))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,c],[],[]),del_filtered_docs:e.Func([e.Text,c],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,m))],[],[]),del_rule:e.Func([b,e.Text,l],[],[]),delete_proposal_assets:e.Func([A],[],[]),deposit_cycles:e.Func([v],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(E)],[]),get_auth_config:e.Func([],[e.Opt(q)],[]),get_config:e.Func([],[w],[]),get_db_config:e.Func([],[e.Opt(G)],[]),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(E)))],[]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(g)))],[]),get_proposal:e.Func([e.Nat],[e.Opt(Y)],[]),get_rule:e.Func([b,e.Text],[e.Opt(U)],[]),get_storage_config:e.Func([],[ne],[]),http_request:e.Func([_],[le],[]),http_request_streaming_callback:e.Func([Z],[X],[]),init_asset_upload:e.Func([u],[h],[]),init_proposal:e.Func([j],[e.Nat,Y],[]),init_proposal_asset_upload:e.Func([u,e.Nat],[h],[]),init_proposal_many_assets_upload:e.Func([e.Vec(u),e.Nat],[e.Vec(e.Tuple(e.Text,h))],[]),list_assets:e.Func([e.Text,c],[y],[]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,p))],[]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,P))],[]),list_docs:e.Func([e.Text,c],[O],[]),list_proposals:e.Func([T],[L],[]),list_rules:e.Func([b,J],[te],[]),memory_size:e.Func([],[de],[]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([ge],[q],[]),set_controllers:e.Func([Ue],[e.Vec(e.Tuple(e.Principal,p))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([_e],[G],[]),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,Ke],[U],[]),set_storage_config:e.Func([Ht],[ne],[]),submit_proposal:e.Func([e.Nat],[e.Nat,Y],[]),upload_asset_chunk:e.Func([Ut],[Vt],[]),upload_proposal_asset_chunk:e.Func([Ut],[Vt],[])})};var Mc=be(De(),1);var My=({satelliteId:e,container:t})=>{let{satelliteId:r}=ff({satelliteId:e}),{container:n}=pf({container:t});if((0,Mc.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`},ff=({satelliteId:e})=>(0,Mc.nonNullish)(e)?{satelliteId:e}:nr.getInstance().get()??{satelliteId:void 0},pf=({container:e})=>(0,Mc.nonNullish)(e)?{container:e}:nr.getInstance().get()??{container:void 0};var dt=({satellite:e,options:{certified:t}})=>Hy({idlFactory:t?ky:Dy,actorKey:`stock#${t?"update":"query"}`,...e}),Ly=({idlFactory:e,...t})=>Hy({idlFactory:e,actorKey:"extended#query",...t}),Hy=async({satelliteId:e,container:t,...r})=>{let{satelliteId:n}=ff({satelliteId:e});(0,jy.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=pf({container:t});return await Xi.getInstance().getActor({satelliteId:n,container:i,...r})};var Gy=be(Ct(),1),st=be(De(),1);var Ky=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 Cc("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:Ky(e.createdAt),updated_at:Ky(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"?Gy.Principal.fromText(n):n)});var $y=async({data:e})=>{try{return await hc(e)}catch(t){console.error("The data parsing has failed, mapping to undefined as a fallback.",t);return}};var di=be(De(),1);var hf=async e=>{let{data:t,version:r,description:n}=e;return{description:(0,di.toNullable)(n),data:await fy(t),version:(0,di.toNullable)(r)}},_f=e=>{let{version:t}=e;return{version:(0,di.toNullable)(t)}},da=async({doc:e,key:t})=>{let{owner:r,version:n,description:i,data:s,...a}=e;return{key:t,description:(0,di.fromNullable)(i),owner:r.toText(),data:await hc(s),version:(0,di.fromNullable)(n),...a}};var Wy=async({collection:e,key:t,...r})=>{let{get_doc:n}=await dt(r),i=(0,Sr.fromNullable)(await n(e,t));if(!(0,Sr.isNullish)(i))return da({doc:i,key:t})},zy=async({docs:e,...t})=>{let{get_many_docs:r}=await dt(t),n=e.map(({collection:a,key:o})=>[a,o]),i=await r(n),s=[];for(let[a,o]of i){let c=(0,Sr.fromNullable)(o);s.push((0,Sr.nonNullish)(c)?await da({key:a,doc:c}):void 0)}return s},Yy=async({collection:e,doc:t,...r})=>{let{set_doc:n}=await dt(r),{key:i}=t,s=await hf(t),a=await n(e,i,s);return await da({key:i,doc:a})},Jy=async({docs:e,...t})=>{let{set_many_docs:r}=await dt(t),n=[];for(let{collection:a,doc:o}of e){let{key:c}=o;n.push([a,c,await hf(o)])}let i=await r(n),s=[];for(let[a,o]of i)s.push(await da({key:a,doc:o}));return s},Zy=async({collection:e,doc:t,...r})=>{let{del_doc:n}=await dt(r),{key:i}=t;return n(e,i,_f(t))},Xy=async({docs:e,...t})=>{let{del_many_docs:r}=await dt(t),n=e.map(({collection:i,doc:s})=>[i,s.key,_f(s)]);await r(n)},Qy=async({collection:e,filter:t,...r})=>{let{del_filtered_docs:n}=await dt(r);return n(e,jn(t))},em=async({collection:e,filter:t,...r})=>{let{list_docs:n}=await dt(r),{items:i,items_page:s,items_length:a,matches_length:o,matches_pages:c}=await n(e,jn(t)),d=[];for(let[f,p]of i){let{data:m,owner:b,description:l,version:A,...v}=p;d.push({key:f,description:(0,Sr.fromNullable)(l),owner:b.toText(),data:await $y({data:m}),version:(0,Sr.fromNullable)(A),...v})}return{items:d,items_length:a,items_page:(0,Sr.fromNullable)(s),matches_length:o,matches_pages:(0,Sr.fromNullable)(c)}},tm=async({collection:e,filter:t,...r})=>{let{count_docs:n}=await dt(r);return n(e,jn(t))};var jc=async({satellite:e,options:t,...r})=>{let n=tt(e?.identity);return await Wy({...r,satellite:{...e,identity:n},options:t??Xr})},S4=async({satellite:e,options:t,...r})=>{let n=tt(e?.identity);return await zy({...r,satellite:{...e,identity:n},options:t??Xr})},rm=async({satellite:e,...t})=>{let r=tt(e?.identity);return await Yy({...t,satellite:{...e,identity:r},options:{certified:!0}})},nm=async({satellite:e,...t})=>{let r=tt(e?.identity);return await Jy({...t,satellite:{...e,identity:r},options:{certified:!0}})},I4=async({satellite:e,...t})=>{let r=tt(e?.identity);return await Zy({...t,satellite:{...e,identity:r},options:{certified:!0}})},B4=async({satellite:e,...t})=>{let r=tt(e?.identity);return await Xy({...t,satellite:{...e,identity:r},options:{certified:!0}})},P4=async({satellite:e,filter:t,...r})=>{let n=tt(e?.identity);return await Qy({...r,filter:t??{},satellite:{...e,identity:n},options:{certified:!0}})},F4=async({satellite:e,options:t,filter:r,...n})=>{let i=tt(e?.identity);return await em({...n,filter:r??{},satellite:{...e,identity:i},options:t??Xr})},U4=async({satellite:e,options:t,filter:r,...n})=>{let i=tt(e?.identity);return await tm({...n,filter:r??{},satellite:{...e,identity:i},options:t??Xr})};var rs=be(De(),1);var im=async({delegationIdentity:e,passkeyIdentity:t,satelliteId:r})=>{let n=t.getCredential().getAAGUID(),[i,s]=await nm({docs:[{collection:"#user",doc:{key:e.getPrincipal().toText(),data:{provider:"webauthn",providerData:{webauthn:{...(0,rs.nonNullish)(n)&&{aaguid:(0,rs.uint8ArrayToArrayOfNumber)(n)}}}}}},{collection:"#user-webauthn",doc:{key:t.getCredential().getCredentialIdText(),data:{publicKey:(0,rs.arrayBufferToUint8Array)(t.getPublicKey().toDer())}}}],satellite:{identity:e,satelliteId:r}});return i};var sm=(s=>(s[s.RequestingUserCredential=0]="RequestingUserCredential",s[s.FinalizingCredential=1]="FinalizingCredential",s[s.Signing=2]="Signing",s[s.FinalizingSession=3]="FinalizingSession",s[s.RetrievingUser=4]="RetrievingUser",s))(sm||{}),am=(a=>(a[a.CreatingUserCredential=0]="CreatingUserCredential",a[a.ValidatingUserCredential=1]="ValidatingUserCredential",a[a.FinalizingCredential=2]="FinalizingCredential",a[a.Signing=3]="Signing",a[a.FinalizingSession=4]="FinalizingSession",a[a.RegisteringUser=5]="RegisteringUser",a))(am||{});var fa=class{get id(){return"webauthn"}async signUp({options:{onProgress:t,maxTimeToLiveInMilliseconds:r,passkey:n}={},loadAuthWithUser:i}){let{satelliteId:s}=nr.getInstance().get()??{satelliteId:void 0};if((0,ns.isNullish)(s))throw new li("Satellite ID not set. Have you initialized the Satellite?");let a=({step:A,state:v})=>{switch(A){case Vn.RequestingUserCredential:t?.({step:1,state:v});break;case Vn.FinalizingCredential:t?.({step:2,state:v});break;case Vn.Signing:t?.({step:3,state:v});break}},c=await Zr({fn:async()=>await Id.createWithNewCredential({onProgress:a,passkeyOptions:n}),step:0,onProgress:t}),{delegationIdentity:d,sessionKey:f}=await this.#e({identity:c,maxTimeToLiveInMilliseconds:r}),m=await Zr({fn:async()=>await im({delegationIdentity:d,passkeyIdentity:c,satelliteId:s}),step:5,onProgress:t});await Zr({fn:async()=>await this.#t({delegationIdentity:d,sessionKey:f}),step:4,onProgress:t}),await Zr({fn:async()=>await i({user:m}),step:5,onProgress:t})}async signIn({options:{onProgress:t,maxTimeToLiveInMilliseconds:r}={},loadAuth:n}){let{satelliteId:i}=nr.getInstance().get()??{satelliteId:void 0};if((0,ns.isNullish)(i))throw new li("Satellite ID not set. Have you initialized the Satellite?");let s=async({credentialId:p})=>{let m=await jc({collection:"#user-webauthn",key:(0,ns.uint8ArrayToBase64)(p),options:{certified:!0},satellite:{identity:new om.AnonymousIdentity,satelliteId:i}});if((0,ns.isNullish)(m))throw new Fc("No public key found for the selected passkey.");let{data:b}=m,{publicKey:l}=b;return(0,Qr.unwrapDER)(l.buffer,Qr.DER_COSE_OID)},a=({step:p,state:m})=>{switch(p){case Vn.RequestingUserCredential:t?.({step:0,state:m});break;case Vn.FinalizingCredential:t?.({step:1,state:m});break;case Vn.Signing:t?.({step:2,state:m});break}},o=await Id.createWithExistingCredential({retrievePublicKey:s,onProgress:a}),{delegationIdentity:c,sessionKey:d}=await this.#e({identity:o,maxTimeToLiveInMilliseconds:r});await Zr({fn:async()=>await this.#t({delegationIdentity:c,sessionKey:d}),step:3,onProgress:t}),await Zr({fn:n,step:4,onProgress:t})}async#e({identity:t,maxTimeToLiveInMilliseconds:r}){let n=await Qr.ECDSAKeyIdentity.generate({extractable:!1}),i=r??144e5,s=await Qr.DelegationChain.create(t,n.getPublicKey(),new Date(Date.now()+i));return{delegationIdentity:Qr.DelegationIdentity.fromDelegation(n,s),sessionKey:n}}async#t({sessionKey:t,delegationIdentity:r}){let n=new is.IdbStorage;await Promise.all([n.set(is.KEY_STORAGE_KEY,t.getKeyPair()),n.set(is.KEY_STORAGE_DELEGATION,JSON.stringify(r.getDelegation().toJSON()))])}};var ss=be(Ic(),1),pa=()=>ss.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}}),cm=async()=>(await new ss.IdbStorage().remove(ss.KEY_STORAGE_KEY),await pa());var ha=be(De(),1);var yf=({error:e,type:t})=>typeof e=="string"?e.includes(t):e instanceof Error?e.message.includes(t):!1;var um="juno.datastore.error.user.cannot_update";var lm=async({provider:e})=>{let{user:t,userId:r}=await mf();if((0,ha.nonNullish)(t))return t;try{return await $E({userId:r,provider:e})}catch(n){if(yf({error:n,type:um})){let i=await dm({userId:r});if((0,ha.nonNullish)(i))return i}throw n}},mf=async()=>{let e=kc();if((0,ha.isNullish)(e))throw new Vc("No identity to initialize the user. Have you initialized Juno?");let t=e.getPrincipal().toText(),r=await dm({userId:t});return{userId:t,user:r}},dm=({userId:e})=>jc({collection:"#user",key:e}),$E=({userId:e,...t})=>rm({collection:"#user",doc:{key:e,data:t}});var yr,gf=async()=>{await bf({fn:async()=>{let{user:t}=await mf();hr.getInstance().set(t??null)}})},WE=async({user:e})=>{await bf({fn:async()=>{hr.getInstance().set(e)}})},fm=async({provider:e})=>{await bf({fn:async()=>{let r=await lm({provider:e});hr.getInstance().set(r)}})},bf=async({fn:e})=>{if(yr=await pa(),!await yr.isAuthenticated()){yr=await cm();return}await e()},zE=async e=>{let t=e??{internet_identity:{}},r=async()=>await JE(t);if(Object.values(t)?.[0].context?.windowGuard===!1){await r();return}await Fd({fn:r})},YE=async e=>{let t=async()=>await ZE(e);if(Object.values(e)?.[0].context?.windowGuard===!1){await t();return}await Fd({fn:t})},JE=async e=>{if("webauthn"in e){let{webauthn:{options:n}}=e;await new fa().signIn({options:n,loadAuth:gf});return}if("nfid"in e){let{nfid:{config:n,options:i}}=e;await new Dc(n).signIn({options:i,authClient:yr,initAuth:fm});return}let{internet_identity:{config:t,options:r}}=e;await new qc(t).signIn({options:r,authClient:yr,initAuth:fm})},ZE=async e=>{if("webauthn"in e){let{webauthn:{options:t}}=e;await new fa().signUp({options:t,loadAuthWithUser:WE});return}throw new Uc("An unknown or unsupported provider was provided for sign-up. Try signing in instead.")},wf=async()=>{await XE(),yr=await pa()},XE=async()=>{await yr?.logout(),yr=null,hr.getInstance().reset(),Xi.getInstance().reset(),Zi.getInstance().reset()},kc=()=>yr?.getIdentity(),QE=async()=>(yr??await pa()).getIdentity(),eO=async()=>{let e=hr.getInstance().get();return(0,pm.isNullish)(e)||!(await yr?.isAuthenticated()??!1)?null:yr?.getIdentity()??null};var _m=e=>{let t=e===!0?"./workers/auth.worker.js":e,r=new Worker(t),n=async()=>{Bd({message:"junoSignOutAuthTimer"}),await wf()};return r.onmessage=async({data:i})=>{let{msg:s,data:a}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Bd({message:"junoDelegationRemainingTime",detail:a?.authRemainingTime});return}},hr.getInstance().subscribe(i=>{if((0,hm.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var ym=()=>{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()},mm=()=>{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 xR=async({idlFactory:e,satellite:t})=>{let r=tt(t?.identity);return await Ly({idlFactory:e,...t,identity:r})};var ya=be(De(),1);var _a=be(De(),1);var as=be(De(),1);var gm=async({asset:{data:e,headers:t,...r},actor:n,progress:i})=>{let{init_asset_upload:s,upload_asset_chunk:a,commit_asset_upload:o}=n,{batch_id:c}=await s(tO(r));i?.onInitiatedBatch();let{chunkIds:d}=await iO({data:e,uploadFn:a,batchId:c});i?.onUploadedFileChunks(r.fullPath),await nO({commitFn:o,batchId:c,data:e,headers:t,chunkIds:d}),i?.onCommittedBatch()};var tO=({filename:e,collection:t,token:r,fullPath:n,encoding:i,description:s})=>({collection:t,full_path:n,name:e,token:(0,as.toNullable)(r),encoding_type:(0,as.toNullable)(i),description:(0,as.toNullable)(s)}),rO=({batchId:e,chunkIds:t,headers:r,data:n})=>{let i=r.find(([s,a])=>s.toLowerCase()==="content-type")===void 0&&n.type!==void 0&&n.type!==""?[["Content-Type",n.type]]:void 0;return{batch_id:e,chunk_ids:t.map(({chunk_id:s})=>s),headers:[...r,...i??[]]}},nO=async({commitFn:e,...t})=>{let r=rO(t);await e(r)},iO=async({data:e,uploadFn:t,batchId:r})=>{let n=[],i=_c()?new Blob([await e.arrayBuffer()]):e,s=0n;for(let o=0;o<i.size;o+=19e5){let c=i.slice(o,o+19e5);n.push({batchId:r,chunk:c,uploadFn:t,orderId:s}),s++}let a=[];for await(let o of sO({uploadChunks:n}))a=[...a,...o];return{chunkIds:a}};async function*sO({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=>aO(i)))}}var aO=async({batchId:e,chunk:t,uploadFn:r,orderId:n})=>r({batch_id:e,content:new Uint8Array(await t.arrayBuffer()),order_id:(0,as.toNullable)(n)});var bm=async({asset:e,...t})=>{let r=await dt(t);await gm({actor:r,asset:e})},wm=async({collection:e,filter:t,...r})=>{let{list_assets:n}=await dt(r),{items:i,items_length:s,items_page:a,matches_length:o,matches_pages:c}=await n(e,jn(t));return{items:i.map(([d,f])=>f),items_length:s,items_page:(0,_a.fromNullable)(a),matches_length:o,matches_pages:(0,_a.fromNullable)(c)}},xm=async({collection:e,filter:t,...r})=>{let{count_assets:n}=await dt(r);return n(e,jn(t))},Tm=async({collection:e,fullPath:t,...r})=>(await dt(r)).del_asset(e,t),Nm=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)},Em=async({collection:e,filter:t,...r})=>{let{del_filtered_assets:n}=await dt(r);return n(e,jn(t))},Om=async({collection:e,fullPath:t,...r})=>{let{get_asset:n}=await dt(r);return(0,_a.fromNullable)(await n(e,t))},vm=async({assets:e,...t})=>{let{get_many_assets:r}=await dt(t),n=e.map(({collection:s,fullPath:a})=>[s,a]);return(await r(n)).map(([s,a])=>(0,_a.fromNullable)(a))};var Rm=e=>btoa([...e].map(t=>String.fromCharCode(t)).join(""));var VR=e=>Am(e),CR=e=>Am({filename:e.data.name,...e}),Am=async({filename:e,data:t,collection:r,headers:n=[],fullPath:i,token:s,satellite:a,encoding:o,description:c})=>{let d=tt(a?.identity),f=decodeURI(e),p=i??`/${r}/${f}`,m={...a,identity:d};return await bm({asset:{data:t,filename:f,collection:r,token:s,headers:n,fullPath:p,encoding:o,description:c},satellite:m,options:{certified:!0}}),{downloadUrl:Sm({satellite:m,assetKey:{fullPath:p,token:s}}),fullPath:p,name:f}},qR=async({collection:e,filter:t,satellite:r,options:n})=>{let i={...r,identity:tt(r?.identity)},{items:s,...a}=await wm({collection:e,filter:t??{},satellite:i,options:n??Xr}),o=s.map(({key:{full_path:c,token:d,name:f,owner:p,description:m},headers:b,encodings:l,created_at:A,updated_at:v})=>{let F=(0,ya.fromNullable)(d);return{fullPath:c,description:(0,ya.fromNullable)(m),name:f,downloadUrl:Sm({satellite:i,assetKey:{fullPath:c,token:F}}),token:F,headers:b,encodings:l.reduce((C,[E,{modified:H,sha256:x,total_length:q}])=>({...C,[E]:{modified:H,sha256:Rm(x),total_length:q}}),{}),owner:p.toText(),created_at:A,updated_at:v}});return{items:o,assets:o,...a}},DR=async({collection:e,filter:t,satellite:r,options:n})=>{let i={...r,identity:tt(r?.identity)};return await xm({collection:e,satellite:i,filter:t??{},options:n??Xr})},kR=({collection:e,fullPath:t,satellite:r})=>Tm({collection:e,fullPath:t,satellite:{...r,identity:tt(r?.identity)},options:{certified:!0}}),MR=({assets:e,satellite:t})=>Nm({assets:e,satellite:{...t,identity:tt(t?.identity)},options:{certified:!0}}),jR=async({collection:e,satellite:t,filter:r})=>{let n={...t,identity:tt(t?.identity)};return await Em({collection:e,satellite:n,filter:r??{},options:{certified:!0}})},LR=async({satellite:e,options:t,...r})=>{let n=tt(e?.identity);return await Om({...r,satellite:{...e,identity:n},options:t??Xr})},HR=async({satellite:e,options:t,...r})=>{let n=tt(e?.identity);return await vm({...r,satellite:{...e,identity:n},options:t??Xr})},Sm=({assetKey:{fullPath:e,token:t},satellite:r})=>{let n={...r,identity:tt(r?.identity)};return`${My(n)}${e}${(0,ya.nonNullish)(t)?`?token=${t}`:""}`};var oO=e=>{let t=e?.satelliteId??ym();(0,Im.assertNonNullish)(t,"Satellite ID is not configured. Juno cannot be initialized.");let r=e?.container??mm();return{satelliteId:t,internetIdentityId:e?.internetIdentityId,workers:e?.workers,container:r}},ZR=e=>cO(e),cO=async e=>{let t=oO(e);nr.getInstance().set(t),await gf();let r=t.workers?.auth!==void 0?_m(t.workers.auth):void 0;return[...r?[r]:[]]},uO=e=>hr.getInstance().subscribe(e),XR=uO;export{Fy as AuthClientSignInProgressStep,Vc as InitError,qc as InternetIdentityProvider,Cc as ListError,Dc as NFIDProvider,Bc as SignInError,li as SignInInitError,Pc as SignInUserInterruptError,Uc as SignUpProviderNotSupportedError,sm as WebAuthnSignInProgressStep,Fc as WebAuthnSignInRetrievePublicKeyError,am as WebAuthnSignUpProgressStep,XR as authSubscribe,DR as countAssets,U4 as countDocs,kR as deleteAsset,I4 as deleteDoc,jR as deleteFilteredAssets,P4 as deleteFilteredDocs,MR as deleteManyAssets,B4 as deleteManyDocs,Sm as downloadUrl,LR as getAsset,jc as getDoc,eO as getIdentityOnce,HR as getManyAssets,S4 as getManyDocs,xR as getSatelliteExtendedActor,ZR as initJuno,cO as initSatellite,H2 as isWebAuthnAvailable,qR as listAssets,F4 as listDocs,uO as onAuthStateChange,rm as setDoc,nm as setManyDocs,zE as signIn,wf as signOut,YE as signUp,QE as unsafeIdentity,VR as uploadBlob,CR as uploadFile};
54
+ Request ID: ${(0,m_.toHex)(r)}
55
+ `)}throw new Error("unreachable")}Zt.pollForResponse=g_});var b_=ee(md=>{"use strict";Object.defineProperty(md,"__esModule",{value:!0});md.default=({IDL:e})=>{let t=e.Variant({mainnet:e.Null,testnet:e.Null}),r=e.Text,n=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),i=e.Nat64,s=i,a=e.Nat32,o=e.Record({start_height:a,end_height:e.Opt(a),network:t}),c=e.Vec(e.Nat8),d=e.Record({tip_height:a,block_headers:e.Vec(c)}),f=e.Record({network:t}),p=e.Nat64,m=e.Vec(p),b=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),l=e.Vec(e.Nat8),A=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),v=e.Record({height:e.Nat32,value:i,outpoint:A}),F=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:a,tip_block_hash:l,utxos:e.Vec(v)}),C=e.Record({transaction:e.Vec(e.Nat8),network:t}),E=e.Principal,H=e.Record({canister_id:E,num_requested_changes:e.Opt(e.Nat64)}),x=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),q=e.Vec(e.Nat8),K=e.Variant({creation:e.Record({controllers:e.Vec(e.Principal)}),code_deployment:e.Record({mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),module_hash:e.Vec(e.Nat8)}),load_snapshot:e.Record({canister_version:e.Nat64,taken_at_timestamp:e.Nat64,snapshot_id:q}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),G=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:x,details:K}),D=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(G),total_num_changes:e.Nat64}),ae=e.Record({canister_id:E}),Q=e.Variant({controllers:e.Null,public:e.Null,allowed_viewers:e.Vec(e.Principal)}),ne=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:Q,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),w=e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:ne,query_stats:e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),g=e.Record({canister_id:E}),S=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),reserved_cycles_limit:e.Opt(e.Nat),log_visibility:e.Opt(Q),wasm_memory_limit:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),R=e.Record({settings:e.Opt(S),sender_canister_version:e.Opt(e.Nat64)}),I=e.Record({canister_id:E}),j=e.Record({canister_id:E}),Y=e.Record({canister_id:E,snapshot_id:q}),oe=e.Record({canister_id:E}),se=e.Variant({secp256k1:e.Null}),z=e.Record({key_id:e.Record({name:e.Text,curve:se}),canister_id:e.Opt(E),derivation_path:e.Vec(e.Vec(e.Nat8))}),U=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),_=e.Record({canister_id:E}),Z=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),re=e.Record({canister_log_records:e.Vec(Z)}),le=e.Record({value:e.Text,name:e.Text}),X=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(le)}),u=e.Record({url:e.Text,method:e.Variant({get:e.Null,head:e.Null,post:e.Null}),max_response_bytes:e.Opt(e.Nat64),body:e.Opt(e.Vec(e.Nat8)),transform:e.Opt(e.Record({function:e.Func([e.Record({context:e.Vec(e.Nat8),response:X})],[X],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(le)}),h=e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({wasm_memory_persistence:e.Opt(e.Variant({keep:e.Null,replace:e.Null})),skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),y=e.Record({hash:e.Vec(e.Nat8)}),P=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:h,chunk_hashes_list:e.Vec(y),target_canister:E,store_canister:e.Opt(E),sender_canister_version:e.Opt(e.Nat64)}),O=e.Vec(e.Nat8),B=e.Record({arg:e.Vec(e.Nat8),wasm_module:O,mode:h,canister_id:E,sender_canister_version:e.Opt(e.Nat64)}),M=e.Record({canister_id:E}),T=e.Record({id:q,total_size:e.Nat64,taken_at_timestamp:e.Nat64}),V=e.Vec(T),L=e.Record({canister_id:E,sender_canister_version:e.Opt(e.Nat64),snapshot_id:q}),k=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),J=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_proposed_total:e.Nat64}),te=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec(J)})),de=e.Record({settings:e.Opt(S),specified_id:e.Opt(E),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),ge=e.Record({canister_id:E}),Ie=e.Record({canister_id:E,amount:e.Nat}),Ue=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(E),derivation_path:e.Vec(e.Vec(e.Nat8))}),Ke=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),Ht=e.Record({key_id:e.Record({name:e.Text,curve:se}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),Ut=e.Record({signature:e.Vec(e.Nat8)}),Vt=e.Variant({bip341:e.Record({merkle_root_hash:e.Vec(e.Nat8)})}),Kt=e.Record({aux:e.Opt(Vt),key_id:e.Record({algorithm:_e,name:e.Text}),derivation_path:e.Vec(e.Vec(e.Nat8)),message:e.Vec(e.Nat8)}),Be=e.Record({signature:e.Vec(e.Nat8)}),Ot=e.Record({canister_id:E}),at=e.Record({canister_id:E}),Ge=e.Record({canister_id:E}),Hc=e.Vec(y),Kc=e.Record({subnet_id:e.Principal}),$e=e.Record({replica_version:e.Text}),Gc=e.Record({replace_snapshot:e.Opt(q),canister_id:E}),$c=T,Wc=e.Record({canister_id:E,sender_canister_version:e.Opt(e.Nat64)}),zc=e.Record({canister_id:e.Principal,settings:S,sender_canister_version:e.Opt(e.Nat64)}),Yc=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),dn=y;return e.Service({bitcoin_get_balance:e.Func([n],[s],[]),bitcoin_get_block_headers:e.Func([o],[d],[]),bitcoin_get_current_fee_percentiles:e.Func([f],[m],[]),bitcoin_get_utxos:e.Func([b],[F],[]),bitcoin_send_transaction:e.Func([C],[],[]),canister_info:e.Func([H],[D],[]),canister_status:e.Func([ae],[w],[]),clear_chunk_store:e.Func([g],[],[]),create_canister:e.Func([R],[I],[]),delete_canister:e.Func([j],[],[]),delete_canister_snapshot:e.Func([Y],[],[]),deposit_cycles:e.Func([oe],[],[]),ecdsa_public_key:e.Func([z],[U],[]),fetch_canister_logs:e.Func([_],[re],["query"]),http_request:e.Func([u],[X],[]),install_chunked_code:e.Func([P],[],[]),install_code:e.Func([B],[],[]),list_canister_snapshots:e.Func([M],[V],[]),load_canister_snapshot:e.Func([L],[],[]),node_metrics_history:e.Func([k],[te],[]),provisional_create_canister_with_cycles:e.Func([de],[ge],[]),provisional_top_up_canister:e.Func([Ie],[],[]),raw_rand:e.Func([],[Ue],[]),schnorr_public_key:e.Func([fe],[Ke],[]),sign_with_ecdsa:e.Func([Ht],[Ut],[]),sign_with_schnorr:e.Func([Kt],[Be],[]),start_canister:e.Func([Ot],[],[]),stop_canister:e.Func([at],[],[]),stored_chunks:e.Func([Ge],[Hc],[]),subnet_info:e.Func([Kc],[$e],[]),take_canister_snapshot:e.Func([Gc],[$c],[]),uninstall_code:e.Func([Wc],[],[]),update_settings:e.Func([zc],[],[]),upload_chunk:e.Func([Yc],[dn],[])})}});var cc=ee(ze=>{"use strict";var uN=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 lN=Hf(),gd=qs(),bd=wi(),Ws=Ri(),w_=ac(),pr=Ct(),dN=$t(),Gi=Fi(),fN=uN(b_()),zs=class extends bd.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=zs;var oc=class extends zs{constructor(t,r,n){var i;super(t,r,"query",{Status:n.status,Code:(i=gd.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};ze.QueryCallRejectedError=oc;var Ys=class extends zs{constructor(t,r,n,i,s,a,o){super(t,r,"update",Object.assign({"Request ID":(0,dN.toHex)(n)},i.body?Object.assign(Object.assign({},o?{"Error code":o}:{}),{"Reject code":String(s),"Reject message":a}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=a,this.error_code=o}};ze.UpdateCallRejectedError=Ys;var fr=Symbol.for("ic-agent-metadata"),Js=class e{constructor(t){this[fr]=Object.freeze(t)}static agentOf(t){return t[fr].config.agent}static interfaceOf(t){return t[fr].service}static canisterIdOf(t){return pr.Principal.from(t[fr].config.canisterId)}static async install(t,r){let n=t.mode===void 0?{install:null}:t.mode,i=t.arg?[...new Uint8Array(t.arg)]:[],s=[...new Uint8Array(t.module)],a=typeof r.canisterId=="string"?pr.Principal.fromText(r.canisterId):r.canisterId;await wd(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:a,sender_canister_version:[]})}static async createCanister(t,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await wd(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:Ws.IDL});class i extends e{constructor(a){if(!a.canisterId)throw new bd.AgentError(`Canister ID is required, but received ${typeof a.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let o=typeof a.canisterId=="string"?pr.Principal.fromText(a.canisterId):a.canisterId;super({config:Object.assign(Object.assign(Object.assign({},x_),a),{canisterId:o}),service:n});for(let[c,d]of n._fields)r?.httpDetails&&d.annotations.push(ze.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&d.annotations.push(ze.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=pN(this,c,d,a.blsVerify)}}return i}static createActor(t,r){if(!r.canisterId)throw new bd.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=Js;function $i(e,t){let r=Ws.IDL.decode(e,lN.Buffer.from(t));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var x_={pollingStrategyFactory:w_.strategy.defaultStrategy};ze.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";ze.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function pN(e,t,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(a,...o)=>{var c,d;a=Object.assign(Object.assign({},a),(d=(c=e[fr].config).queryTransform)===null||d===void 0?void 0:d.call(c,t,o,Object.assign(Object.assign({},e[fr].config),a)));let f=a.agent||e[fr].config.agent||(0,gd.getDefaultAgent)(),p=pr.Principal.from(a.canisterId||e[fr].config.canisterId),m=Ws.IDL.encode(r.argTypes,o),b=await f.query(p,{methodName:t,arg:m,effectiveCanisterId:a.effectiveCanisterId}),l=Object.assign(Object.assign({},b.httpDetails),{requestDetails:b.requestDetails});switch(b.status){case"rejected":throw new oc(p,t,b);case"replied":return r.annotations.includes(ze.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:l,result:$i(r.retTypes,b.reply.arg)}:$i(r.retTypes,b.reply.arg)}}:i=async(a,...o)=>{var c,d;a=Object.assign(Object.assign({},a),(d=(c=e[fr].config).callTransform)===null||d===void 0?void 0:d.call(c,t,o,Object.assign(Object.assign({},e[fr].config),a)));let f=a.agent||e[fr].config.agent||(0,gd.getDefaultAgent)(),{canisterId:p,effectiveCanisterId:m,pollingStrategyFactory:b}=Object.assign(Object.assign(Object.assign({},x_),e[fr].config),a),l=pr.Principal.from(p),A=m!==void 0?pr.Principal.from(m):l,v=Ws.IDL.encode(r.argTypes,o),{requestId:F,response:C,requestDetails:E}=await f.call(l,{methodName:t,arg:v,effectiveCanisterId:A}),H,x;if(C.body&&C.body.certificate){if(f.rootKey==null)throw new Error("Agent is missing root key");let D=C.body.certificate;x=await Gi.Certificate.create({certificate:(0,Ws.bufFromBufLike)(D),rootKey:f.rootKey,canisterId:pr.Principal.from(p),blsVerify:n});let ae=[new TextEncoder().encode("request_status"),F];switch(new TextDecoder().decode((0,Gi.lookupResultToBuffer)(x.lookup([...ae,"status"])))){case"replied":H=(0,Gi.lookupResultToBuffer)(x.lookup([...ae,"reply"]));break;case"rejected":{let ne=new Uint8Array((0,Gi.lookupResultToBuffer)(x.lookup([...ae,"reject_code"])))[0],w=new TextDecoder().decode((0,Gi.lookupResultToBuffer)(x.lookup([...ae,"reject_message"]))),g=(0,Gi.lookupResultToBuffer)(x.lookup([...ae,"error_code"])),S=g?new TextDecoder().decode(g):void 0;throw new Ys(l,t,F,C,ne,w,S)}}}else if(C.body&&"reject_message"in C.body){let{reject_code:D,reject_message:ae,error_code:Q}=C.body;throw new Ys(l,t,F,C,D,ae,Q)}if(C.status===202){let D=b(),ae=await(0,w_.pollForResponse)(f,A,F,D,n);x=ae.certificate,H=ae.reply}let q=r.annotations.includes(ze.ACTOR_METHOD_WITH_HTTP_DETAILS),K=r.annotations.includes(ze.ACTOR_METHOD_WITH_CERTIFICATE),G=Object.assign(Object.assign({},C),{requestDetails:E});if(H!==void 0)return q&&K?{httpDetails:G,certificate:x,result:$i(r.retTypes,H)}:K?{certificate:x,result:$i(r.retTypes,H)}:q?{httpDetails:G,result:$i(r.retTypes,H)}:$i(r.retTypes,H);if(r.retTypes.length===0)return q?{httpDetails:C,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...a)=>i({},...a);return s.withOptions=a=>(...o)=>i(a,...o),s}function wd(e){function t(r,n){if(e.effectiveCanisterId)return{effectiveCanisterId:pr.Principal.from(e.effectiveCanisterId)};let i=n[0],s=pr.Principal.fromHex("");return i&&typeof i=="object"&&i.target_canister&&r==="install_chunked_code"&&(s=pr.Principal.from(i.target_canister)),i&&typeof i=="object"&&i.canister_id&&(s=pr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return Js.createActor(fN.default,Object.assign(Object.assign(Object.assign({},e),{canisterId:pr.Principal.fromHex("")}),{callTransform:t,queryTransform:t}))}ze.getManagementCanister=wd;var xd=class extends Js{constructor(t){super(t)}};ze.AdvancedActor=xd});var T_=ee(Td=>{"use strict";Object.defineProperty(Td,"__esModule",{value:!0});Td.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 N_=ee(Wi=>{"use strict";var hN=Wi&&Wi.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Wi,"__esModule",{value:!0});Wi.createAssetCanisterActor=void 0;var _N=cc(),yN=hN(T_());function mN(e){return _N.Actor.createActor(yN.default,e)}Wi.createAssetCanisterActor=mN});var E_=ee(zr=>{"use strict";var gN=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]}),bN=zr&&zr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),wN=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)&&gN(t,e,r);return bN(t,e),t};Object.defineProperty(zr,"__esModule",{value:!0});zr.fetchCandid=void 0;var xN=Ct(),TN=wN(Ds()),NN=hd(),EN=cc();async function ON(e,t){t||(t=await NN.HttpAgent.create());let n=(await TN.request({agent:t,canisterId:xN.Principal.fromText(e),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:a})=>a.Service({__get_candid_interface_tmp_hack:a.Func([],[a.Text],["query"])});return await EN.Actor.createActor(i,{agent:t,canisterId:e}).__get_candid_interface_tmp_hack()}zr.fetchCandid=ON});var gt=ee(Pe=>{"use strict";var O_=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]}),vN=Pe&&Pe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ft=Pe&&Pe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&O_(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)&&O_(t,e,r);return vN(t,e),t};Object.defineProperty(Pe,"__esModule",{value:!0});Pe.Cbor=Pe.CanisterStatus=Pe.polling=void 0;Ft(cc(),Pe);Ft(qs(),Pe);Ft(fo(),Pe);Ft(Rs(),Pe);Ft(ol(),Pe);Ft(N_(),Pe);Ft(Fi(),Pe);Ft(cd(),Pe);Ft(E_(),Pe);Ft(dd(),Pe);Ft(ud(),Pe);Ft(Ns(),Pe);Ft(jl(),Pe);Ft($t(),Pe);Ft(yl(),Pe);Pe.polling=Nd(ac());Pe.CanisterStatus=Nd(Ds());Pe.Cbor=Nd(vs());Ft(ac(),Pe)});var De=ee((W6,K_)=>{"use strict";var Ad=Object.defineProperty,RN=Object.getOwnPropertyDescriptor,AN=Object.getOwnPropertyNames,SN=Object.prototype.hasOwnProperty,IN=(e,t)=>{for(var r in t)Ad(e,r,{get:t[r],enumerable:!0})},BN=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of AN(t))!SN.call(e,i)&&i!==r&&Ad(e,i,{get:()=>t[i],enumerable:!(n=RN(t,i))||n.enumerable});return e},PN=e=>BN(Ad({},"__esModule",{value:!0}),e),S_={};IN(S_,{AgentManager:()=>LN,Canister:()=>kN,FromStringToTokenError:()=>I_,ICPToken:()=>CN,InvalidPercentageError:()=>C_,NullishError:()=>q_,TokenAmount:()=>qN,TokenAmountV2:()=>DN,arrayBufferToUint8Array:()=>YN,arrayOfNumberToUint8Array:()=>ZN,asNonNullish:()=>KN,asciiStringToByteArray:()=>XN,assertNonNullish:()=>ta,assertPercentageNumber:()=>GN,base64ToUint8Array:()=>s2,bigEndianCrc32:()=>c2,bigIntToUint8Array:()=>WN,candidNumberArrayToBigInt:()=>t2,convertStringToE8s:()=>B_,createAgent:()=>U_,createServices:()=>HN,debounce:()=>y2,decodeBase32:()=>n2,defaultAgent:()=>F_,encodeBase32:()=>r2,fromDefinedNullable:()=>g2,fromNullable:()=>Sd,fromNullishNullable:()=>b2,hashObject:()=>l2,hashText:()=>j_,hexStringToUint8Array:()=>QN,isEmptyString:()=>MN,isNullish:()=>ea,jsonReplacer:()=>M_,jsonReviver:()=>u2,nonNullish:()=>Yr,notEmptyString:()=>P_,nowInBigIntNanoSeconds:()=>h2,numberToUint8Array:()=>zN,principalToSubAccount:()=>w2,queryAndUpdate:()=>jN,secondsToDuration:()=>f2,smallerVersion:()=>x2,toBigIntNanoSeconds:()=>_2,toNullable:()=>m2,uint8ArrayToArrayOfNumber:()=>JN,uint8ArrayToBase64:()=>i2,uint8ArrayToBigInt:()=>$N,uint8ArrayToHexString:()=>D_,uint8ArraysEqual:()=>e2});K_.exports=PN(S_);var I_=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(I_||{}),FN=BigInt(1e8),UN=8,B_=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)*FN}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},VN=({amount:e,decimals:t})=>{e=e.trim().replace(/[,']/g,"");let r=e.match(/\d*(\.\d*)?/);if(!r||r[0]!==e)return 1;let[n,i]=e.split("."),s=0n,a=10n**BigInt(t);if(n)try{s+=BigInt(n)*a}catch{return 1}if(i){if(i.length>t)return 2;try{s+=BigInt(i.padEnd(t,"0"))}catch{return 1}}return s},CN={symbol:"ICP",name:"Internet Computer",decimals:8},qN=class Xs{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 Xs(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=B_(t);return typeof n=="bigint"?new Xs(n,r):n}static fromNumber({amount:t,token:r}){let n=Xs.fromString({amount:t.toString(),token:r});if(n instanceof Xs)return n;throw n===0?new Error(`Number ${t} has more than 8 decimals`):new Error(`Invalid number ${t}`)}toE8s(){return this.e8s}},DN=class Qs{constructor(t,r){this.ulps=t,this.token=r}static fromUlps({amount:t,token:r}){return new Qs(t,r)}static fromString({amount:t,token:r}){let n=VN({amount:t,decimals:r.decimals});return typeof n=="bigint"?new Qs(n,r):n}static fromNumber({amount:t,token:r}){let n=Qs.fromString({amount:t.toFixed(Math.min(UN,r.decimals)),token:r});if(n instanceof Qs)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)}},kN=class{constructor(e,t,r){this.id=e,this.service=t,this.certifiedService=r}get canisterId(){return this.id}caller=({certified:e=!0})=>e?this.certifiedService:this.service},ea=e=>e==null,Yr=e=>!ea(e),P_=e=>Yr(e)&&e!=="",MN=e=>!P_(e),jN=async({request:e,onLoad:t,onQueryError:r,onUpdateError:n,strategy:i="query_and_update",identity:s,resolution:a="race"})=>{let o=!1,c=f=>e({certified:f,identity:s}).then(p=>{o||t({certified:f,response:p})}).catch(p=>{f||r==null||r({error:p,identity:s}),!o&&(ea(n)||(console.error(p),f&&n({error:p,identity:s})))}).finally(()=>o=o||f),d=i==="query"?[c(!1)]:i==="update"?[c(!0)]:[c(!1),c(!0)];await(a==="all_settled"?Promise.allSettled(d):Promise.race(d))},v_=gt(),Ed=gt(),F_=()=>Ed.HttpAgent.createSync({host:"https://icp-api.io",identity:new Ed.AnonymousIdentity}),U_=async({identity:e,host:t,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await Ed.HttpAgent.create({identity:e,...Yr(t)&&{host:t},verifyQuerySignatures:n,...Yr(i)&&{retryTimes:i},shouldFetchRootKey:r}),LN=class V_{constructor(t){this.config=t}agents=void 0;static create(t){return new V_(t)}getAgent=async({identity:t})=>{let r=t.getPrincipal().toText();if(ea(this.agents)||ea(this.agents[r])){let n=await U_({identity:t,fetchRootKey:this.config.fetchRootKey,host:this.config.host,verifyQuerySignatures:!0});return this.agents={...this.agents??{},[r]:n},n}return this.agents[r]};clearAgents=()=>{this.agents=null}},HN=({options:{canisterId:e,serviceOverride:t,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:a,certifiedIdlFactory:o})=>{let c=n??F_(),d=t??v_.Actor.createActor(a,{agent:c,canisterId:e,callTransform:i,queryTransform:s}),f=r??v_.Actor.createActor(o,{agent:c,canisterId:e,callTransform:i,queryTransform:s});return{service:d,certifiedService:f,agent:c,canisterId:e}},C_=class extends Error{},q_=class extends Error{},ta=(e,t)=>{if(e==null)throw new q_(t)},KN=(e,t)=>(ta(e,t),e),GN=e=>{if(e<0||e>100)throw new C_(`${e} is not a valid percentage number.`)},$N=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},WN=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)},zN=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)},YN=e=>new Uint8Array(e),JN=e=>Array.from(e),ZN=e=>new Uint8Array(e),XN=e=>Array.from(e).map(t=>t.charCodeAt(0)),QN=e=>{let t=e.match(/.{1,2}/g);return ta(t,"Invalid hex string."),Uint8Array.from(t.map(r=>parseInt(r,16)))},e2=({a:e,b:t})=>e.length===t.length&&e.every((r,n)=>r===t[n]),D_=e=>(e instanceof Uint8Array||(e=Uint8Array.from(e)),e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")),t2=e=>{let t=0n;for(let r=e.length-1;r>=0;r--)t=(t<<32n)+BigInt(e[r]);return t},uc="abcdefghijklmnopqrstuvwxyz234567",zi=Object.create(null);for(let e=0;e<uc.length;e++)zi[uc[e]]=e;zi[0]=zi.o;zi[1]=zi.i;var r2=e=>{let t=0,r=0,n="",i=s=>(t<0?r|=s>>-t:r=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=uc[r>>3],t+=5),0));for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?uc[r>>3]:"")},n2=e=>{let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0,s=a=>{let o=zi[a.toLowerCase()];ta(o,`Invalid character: ${JSON.stringify(a)}`),o<<=3,r|=o>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=o<<5-t&255:r=0)};for(let a of e)s(a);return n.slice(0,i)},i2=e=>btoa(String.fromCharCode(...new Uint8Array(e))),s2=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)),a2=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]),o2=e=>{let t=-1;for(let r=0;r<e.length;r++){let n=(e[r]^t)&255;t=a2[n]^t>>>8}return(t^-1)>>>0},c2=e=>{let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,o2(e),!1),new Uint8Array(t)},k_=Ct(),Od="__bigint__",vd="__principal__",Rd="__uint8array__",M_=(e,t)=>typeof t=="bigint"?{[Od]:`${t}`}:Yr(t)&&t instanceof k_.Principal?{[vd]:t.toText()}:Yr(t)&&t instanceof Uint8Array?{[Rd]:Array.from(t)}:t,u2=(e,t)=>{let r=n=>t[n];return Yr(t)&&typeof t=="object"&&Od in t?BigInt(r(Od)):Yr(t)&&typeof t=="object"&&vd in t?k_.Principal.fromText(r(vd)):Yr(t)&&typeof t=="object"&&Rd in t?Uint8Array.from(r(Rd)):t},l2=async e=>{let t=JSON.stringify(e,M_);return await j_(t)},j_=async e=>{let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return D_(new Uint8Array(r))},d2={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"},f2=({seconds:e,i18n:t=d2})=>{let r=e/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=p2(i);return i-=L_(s),[Zs({labelKey:"year",amount:s}),Zs({labelKey:"day",amount:i}),Zs({labelKey:"hour",amount:n}),Zs({labelKey:"minute",amount:r}),...e>BigInt(0)&&e<BigInt(60)?[Zs({labelKey:"second",amount:e})]:[]].filter(({amount:a})=>a>0).slice(0,2).map(a=>`${a.amount} ${a.amount===1?t[a.labelKey]:t[`${a.labelKey}_plural`]}`).join(", ")},p2=e=>{let t=e/BigInt(365);for(;L_(t)>e;)t--;return t},L_=e=>{let t=e/BigInt(4);return e*BigInt(365)+t},Zs=({labelKey:e,amount:t})=>({labelKey:e,amount:Number(t)}),H_=1000000n,h2=()=>BigInt(Date.now())*H_,_2=e=>BigInt(e.getTime())*H_,y2=(e,t)=>{let r;return(...n)=>{let i=()=>e(...n);r&&clearTimeout(r),r=setTimeout(i,t!==void 0&&t>0?t:300)}},m2=e=>Yr(e)?[e]:[],Sd=e=>e?.[0],g2=e=>{let t=Sd(e);return ta(t),t},b2=e=>Sd(e??[]),w2=e=>{let t=e.toUint8Array(),r=new Uint8Array(32);return r[0]=t.length,r.set(t,1),r},R_=({nums:e,amountZeros: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)},x2=({minVersion:e,currentVersion:t})=>{let r=R_({nums:e.split(".").map(A_),amountZeros:3}).join(".");return R_({nums:t.split(".").map(A_),amountZeros:3}).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var _y=ee(Jr=>{"use strict";var bc=Jr&&Jr.__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},Cn=Jr&&Jr.__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)},mc,gc,Qi,es;Object.defineProperty(Jr,"__esModule",{value:!0});Jr.Ed25519KeyIdentity=Jr.Ed25519PublicKey=void 0;var W2=gt(),ir=gt(),ia=ad();function hy(e){return e!==null&&typeof e=="object"}var oi=class e{constructor(t){if(mc.set(this,void 0),gc.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");bc(this,mc,t,"f"),bc(this,gc,e.derEncode(t),"f")}static from(t){if(typeof t=="string"){let r=(0,ir.fromHex)(t);return this.fromRaw(r)}else if(hy(t)){let r=t;if(hy(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,ir.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,ir.wrapDER)(t,ir.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(t){let r=(0,ir.unwrapDER)(t,ir.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 Cn(this,mc,"f")}get derKey(){return Cn(this,gc,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Jr.Ed25519PublicKey=oi;mc=new WeakMap,gc=new WeakMap;oi.RAW_KEY_LENGTH=32;var Cd=class e extends ir.SignIdentity{constructor(t,r){super(),Qi.set(this,void 0),es.set(this,void 0),bc(this,Qi,oi.from(t),"f"),bc(this,es,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=ia.ed25519.utils.randomPrivateKey()),(0,W2.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=ia.ed25519.getPublicKey(r);return e.fromKeyPair(n,r)}static fromParsedJson(t){let[r,n]=t;return new e(oi.fromDer((0,ir.fromHex)(r)),(0,ir.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(oi.fromRaw(t),r)}static fromSecretKey(t){let r=ia.ed25519.getPublicKey(new Uint8Array(t));return e.fromKeyPair(r,t)}toJSON(){return[(0,ir.toHex)(Cn(this,Qi,"f").toDer()),(0,ir.toHex)(Cn(this,es,"f"))]}getKeyPair(){return{secretKey:Cn(this,es,"f"),publicKey:Cn(this,Qi,"f")}}getPublicKey(){return Cn(this,Qi,"f")}async sign(t){let r=new Uint8Array(t),n=(0,ir.uint8ToBuf)(ia.ed25519.sign(r,Cn(this,es,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(t,r,n){let[i,s,a]=[t,r,n].map(o=>(typeof o=="string"&&(o=(0,ir.fromHex)(o)),o instanceof Uint8Array&&(o=o.buffer),new Uint8Array(o)));return ia.ed25519.verify(s,i,a)}};Jr.Ed25519KeyIdentity=Cd;Qi=new WeakMap,es=new WeakMap});var my=ee(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});ci.ECDSAKeyIdentity=ci.CryptoError=void 0;var z2=gt(),wc=class e extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,e.prototype)}};ci.CryptoError=wc;function yy(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 wc("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 xc=class e extends z2.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=yy(i),a=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),o=await s.exportKey("spki",a.publicKey);return new this(a,o,s)}static async fromKeyPair(t,r){let n=yy(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)}};ci.ECDSAKeyIdentity=xc;ci.default=xc});var Dd=ee(Dn=>{"use strict";var Y2=Dn&&Dn.__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},sa=Dn&&Dn.__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)},qn;Object.defineProperty(Dn,"__esModule",{value:!0});Dn.PartialIdentity=void 0;var J2=Ct(),qd=class{constructor(t){qn.set(this,void 0),Y2(this,qn,t,"f")}get rawKey(){return sa(this,qn,"f").rawKey}get derKey(){return sa(this,qn,"f").derKey}toDer(){return sa(this,qn,"f").toDer()}getPublicKey(){return sa(this,qn,"f")}getPrincipal(){return J2.Principal.from(sa(this,qn,"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.")}};Dn.PartialIdentity=qd;qn=new WeakMap});var gy=ee(Ze=>{"use strict";var Z2=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]}),X2=Ze&&Ze.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Q2=Ze&&Ze.__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)&&Z2(t,e,r);return X2(t,e),t},eE=Ze&&Ze.__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},tE=Ze&&Ze.__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)},rE=Ze&&Ze.__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(Ze,"__esModule",{value:!0});Ze.isDelegationValid=Ze.PartialDelegationIdentity=Ze.DelegationIdentity=Ze.DelegationChain=Ze.Delegation=void 0;var kn=gt(),Md=Ct(),aa=Q2(Os()),nE=Dd(),iE=new TextEncoder().encode("ic-request-auth-delegation"),sE=new TextEncoder().encode(`
57
+ ic-request`);function kd(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return(0,kn.fromHex)(e)}var oa=class{constructor(t,r,n){this.pubkey=t,this.expiration=r,this.targets=n}toCBOR(){return aa.value.map(Object.assign({pubkey:aa.value.bytes(this.pubkey),expiration:aa.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:aa.value.array(this.targets.map(t=>aa.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,kn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};Ze.Delegation=oa;async function aE(e,t,r,n){let i=new oa(t.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...iE,...new Uint8Array((0,kn.requestIdOf)(Object.assign({},i)))]),a=await e.sign(s);return{delegation:i,signature:a}}var jd=class e{constructor(t,r){this.delegations=t,this.publicKey=r}static async create(t,r,n=new Date(Date.now()+900*1e3),i={}){var s,a;let o=await aE(t,r,n,i.targets);return new e([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],o],((a=i.previous)===null||a===void 0?void 0:a.publicKey)||t.getPublicKey().toDer())}static fromJSON(t){let{publicKey:r,delegations:n}=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:a,signature:o}=s,{pubkey:c,expiration:d,targets:f}=a;if(f!==void 0&&!Array.isArray(f))throw new Error("Invalid targets.");return{delegation:new oa(kd(c),BigInt("0x"+d),f&&f.map(p=>{if(typeof p!="string")throw new Error("Invalid target.");return Md.Principal.fromHex(p)})),signature:kd(o)}});return new this(i,kd(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,kn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,kn.toHex)(n)}}),publicKey:(0,kn.toHex)(this.publicKey)}}};Ze.DelegationChain=jd;var Ld=class extends kn.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=rE(t,["body"]),i=await(0,kn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...sE,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};Ze.DelegationIdentity=Ld;var Hd=class e extends nE.PartialIdentity{constructor(t,r){super(t),Tc.set(this,void 0),eE(this,Tc,r,"f")}get delegation(){return tE(this,Tc,"f")}static fromDelegation(t,r){return new e(t,r)}};Ze.PartialDelegationIdentity=Hd;Tc=new WeakMap;function oE(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"?Md.Principal.fromText(i):i)):r.push(typeof n=="string"?Md.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:a}of e.delegations){if(a.targets===void 0)continue;let o=!0;for(let c of a.targets)if(c.toText()===s){o=!1;break}if(o)return!1}}return!0}Ze.isDelegationValid=oE});var by=ee(Mn=>{"use strict";var cE=Mn&&Mn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Mn,"__esModule",{value:!0});Mn.WebAuthnIdentity=Mn.CosePublicKey=void 0;var ui=gt(),Kd=cE(to()),uE=Kn(),lE=Ri();function dE(e){return(0,ui.wrapDER)(e,ui.DER_COSE_OID).buffer}function fE(e){let t=new DataView(new ArrayBuffer(2)),r=e.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>t.setUint8(s,i));let n=t.getUint16(0);return e.slice(55+n)}var Nc=class{constructor(t){this._cose=t,this._encodedKey=dE(t)}toDer(){return this._encodedKey}getCose(){return this._cose}};Mn.CosePublicKey=Nc;function pE(e="<ic0.app>"){return typeof e=="string"?Uint8Array.from(e,t=>t.charCodeAt(0)):e}async function hE(e){let t=await navigator.credentials.create(e??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:pE(),pubKeyCredParams:[{type:"public-key",alg:Gd.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,uE.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,lE.bufFromBufLike)(t.rawId)}}var Gd;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Gd||(Gd={}));var $d=class extends ui.SignIdentity{constructor(t,r,n){super(),this.rawId=t,this.authenticatorAttachment=n,this._publicKey=new Nc(r)}static fromJSON(t){let{publicKey:r,rawId:n}=JSON.parse(t);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,ui.fromHex)(n),(0,ui.fromHex)(r),void 0)}static async create(t){var r;let n=await hE(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=Kd.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,fE(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=Kd.default.encode(new Kd.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,ui.toHex)(this._publicKey.getCose()),rawId:(0,ui.toHex)(this.rawId)}}};Mn.WebAuthnIdentity=$d});var Yd=ee(Ye=>{"use strict";var _E=Ye&&Ye.__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]}),zd=Ye&&Ye.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&_E(t,e,r)};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.Secp256k1KeyIdentity=Ye.ED25519_OID=Ye.DER_COSE_OID=Ye.unwrapDER=Ye.wrapDER=Ye.WebAuthnIdentity=Ye.Ed25519PublicKey=Ye.Ed25519KeyIdentity=void 0;var wy=_y();Object.defineProperty(Ye,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return wy.Ed25519KeyIdentity}});Object.defineProperty(Ye,"Ed25519PublicKey",{enumerable:!0,get:function(){return wy.Ed25519PublicKey}});zd(my(),Ye);zd(gy(),Ye);zd(Dd(),Ye);var yE=by();Object.defineProperty(Ye,"WebAuthnIdentity",{enumerable:!0,get:function(){return yE.WebAuthnIdentity}});var Ec=gt();Object.defineProperty(Ye,"wrapDER",{enumerable:!0,get:function(){return Ec.wrapDER}});Object.defineProperty(Ye,"unwrapDER",{enumerable:!0,get:function(){return Ec.unwrapDER}});Object.defineProperty(Ye,"DER_COSE_OID",{enumerable:!0,get:function(){return Ec.DER_COSE_OID}});Object.defineProperty(Ye,"ED25519_OID",{enumerable:!0,get:function(){return Ec.ED25519_OID}});var Wd=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};Ye.Secp256k1KeyIdentity=Wd});var Zd=ee(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});Oc.IdleManager=void 0;var xy=["mousedown","mousemove","keydown","touchstart","wheel"],Jd=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),xy.forEach(function(o){document.addEventListener(o,s,!0)});let a=(o,c)=>{let d;return(...f)=>{let p=this,m=function(){d=void 0,o.apply(p,f)};clearTimeout(d),d=window.setTimeout(m,c)}};if(t?.captureScroll){let o=a(s,(r=t?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",o,!0)}s()}static create(t={}){return new this(t)}registerCallback(t){this.callbacks.push(t)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let t=this._resetTimer.bind(this);xy.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)}};Oc.IdleManager=Jd});function gE(){return Ty||(Ty=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function bE(){return Ny||(Ny=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function wE(e){let t=new Promise((r,n)=>{let i=()=>{e.removeEventListener("success",s),e.removeEventListener("error",a)},s=()=>{r(_r(e.result)),i()},a=()=>{n(e.error),i()};e.addEventListener("success",s),e.addEventListener("error",a)});return t.then(r=>{r instanceof IDBCursor&&Ey.set(r,e)}).catch(()=>{}),tf.set(t,e),t}function xE(e){if(Qd.has(e))return;let t=new Promise((r,n)=>{let i=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",a),e.removeEventListener("abort",a)},s=()=>{r(),i()},a=()=>{n(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",s),e.addEventListener("error",a),e.addEventListener("abort",a)});Qd.set(e,t)}function vy(e){ef=e(ef)}function TE(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...r){let n=e.call(ca(this),t,...r);return Oy.set(n,t.sort?t.sort():[t]),_r(n)}:bE().includes(e)?function(...t){return e.apply(ca(this),t),_r(Ey.get(this))}:function(...t){return _r(e.apply(ca(this),t))}}function NE(e){return typeof e=="function"?TE(e):(e instanceof IDBTransaction&&xE(e),mE(e,gE())?new Proxy(e,ef):e)}function _r(e){if(e instanceof IDBRequest)return wE(e);if(Xd.has(e))return Xd.get(e);let t=NE(e);return t!==e&&(Xd.set(e,t),tf.set(t,e)),t}var mE,Ty,Ny,Ey,Qd,Oy,Xd,tf,ef,ca,rf=Tf(()=>{mE=(e,t)=>t.some(r=>e instanceof r);Ey=new WeakMap,Qd=new WeakMap,Oy=new WeakMap,Xd=new WeakMap,tf=new WeakMap;ef={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return Qd.get(e);if(t==="objectStoreNames")return e.objectStoreNames||Oy.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return _r(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}};ca=e=>tf.get(e)});var Ay={};Zm(Ay,{deleteDB:()=>OE,openDB:()=>EE,unwrap:()=>ca,wrap:()=>_r});function EE(e,t,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let a=indexedDB.open(e,t),o=_r(a);return n&&a.addEventListener("upgradeneeded",c=>{n(_r(a.result),c.oldVersion,c.newVersion,_r(a.transaction),c)}),r&&a.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),o.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",d=>i(d.oldVersion,d.newVersion,d))}).catch(()=>{}),o}function OE(e,{blocked:t}={}){let r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),_r(r).then(()=>{})}function Ry(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(nf.get(t))return nf.get(t);let r=t.replace(/FromIndex$/,""),n=t!==r,i=RE.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||vE.includes(r)))return;let s=async function(a,...o){let c=this.transaction(a,i?"readwrite":"readonly"),d=c.store;return n&&(d=d.index(o.shift())),(await Promise.all([d[r](...o),i&&c.done]))[0]};return nf.set(t,s),s}var vE,RE,nf,Sy=Tf(()=>{rf();rf();vE=["get","getKey","getAll","getAllKeys","count"],RE=["put","add","delete","clear"],nf=new Map;vy(e=>({...e,get:(t,r,n)=>Ry(t,r)||e.get(t,r,n),has:(t,r)=>!!Ry(t,r)||e.has(t,r)}))});var af=ee(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});vc.IdbKeyVal=void 0;var AE=(Sy(),Xm(Ay)),ua=Rc(),Iy="auth-client-db",By="ic-keyval",SE=async(e=Iy,t=By,r)=>(ua.isBrowser&&(localStorage!=null&&localStorage.getItem(ua.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(ua.KEY_STORAGE_DELEGATION),localStorage.removeItem(ua.KEY_STORAGE_KEY)),await(0,AE.openDB)(e,r,{upgrade:n=>{n.objectStoreNames.contains(t)&&n.clear(t),n.createObjectStore(t)}}));async function IE(e,t,r){return await e.get(t,r)}async function BE(e,t,r,n){return await e.put(t,n,r)}async function PE(e,t,r){return await e.delete(t,r)}var sf=class e{constructor(t,r){this._db=t,this._storeName=r}static async create(t){let{dbName:r=Iy,storeName:n=By,version:i=ua.DB_VERSION}=t??{},s=await SE(r,n,i);return new e(s,n)}async set(t,r){return await BE(this._db,this._storeName,t,r)}async get(t){var r;return(r=await IE(this._db,this._storeName,t))!==null&&r!==void 0?r:null}async remove(t){return await PE(this._db,this._storeName,t)}};vc.IdbKeyVal=sf});var Rc=ee(it=>{"use strict";var FE=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},UE=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 VE=af();it.KEY_STORAGE_KEY="identity";it.KEY_STORAGE_DELEGATION="delegation";it.KEY_VECTOR="iv";it.DB_VERSION=1;it.isBrowser=typeof window<"u";var of=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=of;var cf=class{constructor(t){Ac.set(this,void 0),FE(this,Ac,t??{},"f")}get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}VE.IdbKeyVal.create(UE(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=cf;Ac=new WeakMap});var Ic=ee(et=>{"use strict";var CE=et&&et.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),qE=et&&et.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&CE(t,e,r)};Object.defineProperty(et,"__esModule",{value:!0});et.AuthClient=et.ERROR_USER_INTERRUPT=et.IdbKeyVal=et.KEY_STORAGE_KEY=et.KEY_STORAGE_DELEGATION=et.LocalStorage=et.IdbStorage=void 0;var Py=gt(),sr=Yd(),Fy=Zd(),Et=Rc(),Sc=Rc();Object.defineProperty(et,"IdbStorage",{enumerable:!0,get:function(){return Sc.IdbStorage}});Object.defineProperty(et,"LocalStorage",{enumerable:!0,get:function(){return Sc.LocalStorage}});Object.defineProperty(et,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return Sc.KEY_STORAGE_DELEGATION}});Object.defineProperty(et,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return Sc.KEY_STORAGE_KEY}});var DE=af();Object.defineProperty(et,"IdbKeyVal",{enumerable:!0,get:function(){return DE.IdbKeyVal}});var kE="https://identity.ic0.app",ME="#authorize",uf="ECDSA",lf="Ed25519",jE=500;et.ERROR_USER_INTERRUPT="UserInterrupt";qE(Zd(),et);var ff=class{constructor(t,r,n,i,s,a,o,c){this._identity=t,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=a,this._idpWindow=o,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(t={}){var r,n,i;let s=(r=t.storage)!==null&&r!==void 0?r:new Et.IdbStorage,a=(n=t.keyType)!==null&&n!==void 0?n:uf,o=null;if(t.identity)o=t.identity;else{let p=await s.get(Et.KEY_STORAGE_KEY);if(!p&&Et.isBrowser)try{let m=new Et.LocalStorage,b=await m.get(Et.KEY_STORAGE_DELEGATION),l=await m.get(Et.KEY_STORAGE_KEY);b&&l&&a===uf&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Et.KEY_STORAGE_DELEGATION,b),await s.set(Et.KEY_STORAGE_KEY,l),p=b,await m.remove(Et.KEY_STORAGE_DELEGATION),await m.remove(Et.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(p)try{typeof p=="object"?a===lf&&typeof p=="string"?o=await sr.Ed25519KeyIdentity.fromJSON(p):o=await sr.ECDSAKeyIdentity.fromKeyPair(p):typeof p=="string"&&(o=sr.Ed25519KeyIdentity.fromJSON(p))}catch{}}let c=new Py.AnonymousIdentity,d=null;if(o)try{let p=await s.get(Et.KEY_STORAGE_DELEGATION);if(typeof p=="object"&&p!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?c=t.identity:p&&(d=sr.DelegationChain.fromJSON(p),(0,sr.isDelegationValid)(d)?"toDer"in o?c=sr.PartialDelegationIdentity.fromDelegation(o,d):c=sr.DelegationIdentity.fromDelegation(o,d):(await df(s),o=null))}catch(p){console.error(p),await df(s),o=null}let f;return!((i=t.idleOptions)===null||i===void 0)&&i.disableIdle?f=void 0:(d||t.identity)&&(f=Fy.IdleManager.create(t.idleOptions)),o||(a===lf?(o=await sr.Ed25519KeyIdentity.generate(),await s.set(Et.KEY_STORAGE_KEY,JSON.stringify(o.toJSON()))):(t.storage&&a===uf&&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 '${lf}' as the key type, as it can serialize to a string`),o=await sr.ECDSAKeyIdentity.generate(),await s.set(Et.KEY_STORAGE_KEY,o.getKeyPair()))),new this(c,o,d,s,f,t)}_registerDefaultIdleCallback(){var t,r;let n=(t=this._createOptions)===null||t===void 0?void 0:t.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(t,r){var n,i;let s=t.delegations.map(d=>({delegation:new sr.Delegation(d.delegation.pubkey,d.delegation.expiration,d.delegation.targets),signature:d.signature.buffer})),a=sr.DelegationChain.fromDelegations(s,t.userPublicKey.buffer),o=this._key;if(!o)return;this._chain=a,"toDer"in o?this._identity=sr.PartialDelegationIdentity.fromDelegation(o,this._chain):this._identity=sr.DelegationIdentity.fromDelegation(o,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=Fy.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Et.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(t)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(t){var r,n,i,s;let a=BigInt(8)*BigInt(36e11),o=new URL(((r=t?.identityProvider)===null||r===void 0?void 0:r.toString())||kE);o.hash=ME,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(o,Object.assign({maxTimeToLive:(i=t?.maxTimeToLive)!==null&&i!==void 0?i:a},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(o.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(et.ERROR_USER_INTERRUPT,t?.onError):setTimeout(c,jE))};c()}_getEventHandler(t,r){return async n=>{var i,s,a;if(n.origin!==t.origin)return;let o=n.data;switch(o.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(a=this._idpWindow)===null||a===void 0||a.postMessage(c,t.origin);break}case"authorize-client-success":try{await this._handleSuccess(o,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(o.text,r?.onError);break;default:break}}}_handleFailure(t,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(t),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(t={}){if(await df(this._storage),this._identity=new Py.AnonymousIdentity,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};et.AuthClient=ff;async function df(e){await e.remove(Et.KEY_STORAGE_KEY),await e.remove(Et.KEY_STORAGE_DELEGATION),await e.remove(Et.KEY_VECTOR)}});var Bm=be(De(),1);var Y_=be(De(),1),lc=be(gt(),1),J_=be(De(),1),na=be(gt(),1),Lt=be(De(),1),X_=be(De(),1),ry=be(De(),1),T2=({authData:e})=>{if(e.byteLength<37)return{invalidAuthData:null};if(e.byteLength<53)return{invalidAuthData:null};let t=e.slice(37,53),r=N2({bytes:t});return"aaguid"in r?{aaguidBytes:t,aaguidText:r.aaguid}:{unknownProvider:null}},N2=({bytes:e})=>{if(e.length!==16)return{invalidBytes:null};let t=(e instanceof Uint8Array?(0,Y_.uint8ArrayToArrayOfNumber)(e):e).map(r=>r.toString(16).padStart(2,"0")).join("").replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5");return t==="00000000-0000-0000-0000-000000000000"?{unknownProvider:null}:{aaguid:t}};function E2(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)}function O2(e){return(0,lc.wrapDER)(e.buffer,lc.DER_COSE_OID).buffer}var v2=class{constructor(e){this._cose=e,this._encodedKey=O2(e)}_encodedKey;toDer(){return this._encodedKey}},Z_=class{#e;#t;constructor({rawId:e,cose:t}){this.#e=e,this.#t=new v2(t)}getPublicKey(){return this.#t}getCredentialId(){return this.#e}getCredentialIdText(){return(0,J_.uint8ArrayToBase64)(this.#e)}},R2=class extends Z_{#e;#t;constructor({authData:e,...t}){super(t);let r=T2({authData:e});this.#e="aaguidText"in r?r.aaguidText:void 0,this.#t="aaguidBytes"in r?r.aaguidBytes:void 0}getAAGUID(){return this.#t}getAAGUIDText(){return this.#e}},A2=class extends Z_{},S2=class extends Error{},I2=class extends Error{},B2=class extends Error{},P2=class extends Error{},F2=class extends Error{},U2=class extends Error{},V2=class extends Error{},G_=class extends Error{};var C2={ECDSA_WITH_SHA256:-7,RSA_WITH_SHA256:-257},q2=6e4,Q_=()=>window.crypto.getRandomValues(new Uint8Array(16)),D2=()=>Q_(),k2=()=>Q_(),M2=()=>{let{location:{href:e}}=window,t=URL.parse(e);if((0,X_.isNullish)(t))throw new S2;let{hostname:r}=t;return r},ey=({appId:e})=>e?.id??M2(),j2=({appId:e,user:t}={})=>{let{document:{title:r}}=window,n=()=>({rp:{name:e?.name??r,id:ey({appId:e})}}),i=()=>({user:{id:k2(),name:t?.name??t?.displayName??r,displayName:t?.displayName??r}});return{attestation:"direct",challenge:D2(),...n(),...i(),pubKeyCredParams:Object.values(C2).map(s=>({type:"public-key",alg:s})),excludeCredentials:[],authenticatorSelection:{authenticatorAttachment:"platform",userVerification:"preferred",residentKey:"required",requireResidentKey:!0}}},L2=(e={})=>({rpId:ey(e),allowCredentials:[],userVerification:"required"}),Id=async({fn:e,step:t,onProgress:r})=>{r?.({step:t,state:"in_progress"});try{let n=await e();return r?.({step:t,state:"success"}),n}catch(n){throw r?.({step:t,state:"error"}),n}},Vn=(e=>(e[e.RequestingUserCredential=0]="RequestingUserCredential",e[e.FinalizingCredential=1]="FinalizingCredential",e[e.Signing=2]="Signing",e))(Vn||{}),ty=({timeout:e})=>AbortSignal.timeout(e??q2),H2=async({challenge:e,credentialIds:t,passkeyOptions:r,timeout:n})=>await navigator.credentials.get({publicKey:{...L2(r),challenge:e.buffer,allowCredentials:(t??[]).map(i=>({id:i.buffer,type:"public-key"}))},signal:ty({timeout:n})}),$_=e=>{if(e.status!=="initialized")throw new I2},W_=e=>{if((0,Lt.isNullish)(e))throw new B2},z_=({type:e})=>{if(e!=="public-key")throw new P2},Bd=class ra extends na.SignIdentity{#e;#t;constructor({onProgress:t,...r}){if(super(),this.#e=t,"retrievePublicKey"in r){let{retrievePublicKey:n}=r;this.#t={status:"pending",retrievePublicKey:n};return}this.#t=ra.#r({credential:new R2(r)})}static#r({credential:t}){return{status:"initialized",credential:t}}static async createWithNewCredential({passkeyOptions:t,timeout:r,...n}={}){let i=await navigator.credentials.create({publicKey:j2(t),signal:ty({timeout:r})});W_(i),z_(i);let{response:{attestationObject:s},rawId:a}=i;if((0,Lt.isNullish)(s))throw new F2;let{authData:o}=na.Cbor.decode(s),c=E2(o);return new ra({...n,rawId:(0,Lt.arrayBufferToUint8Array)(a),cose:c,authData:o})}static async createWithExistingCredential(t){return new ra(t)}getPublicKey(){$_(this.#t);let{credential:t}=this.#t;return t.getPublicKey()}getCredential(){$_(this.#t);let{credential:t}=this.#t;return t}async sign(t){let r=await Id({fn:async()=>{let n=await H2({challenge:(0,Lt.arrayBufferToUint8Array)(t),...this.#t.status==="initialized"&&{credentialIds:[this.#t.credential.getCredentialId()]}});return W_(n),z_(n),n},step:0,onProgress:this.#e});return await Id({fn:async()=>{let{rawId:n}=r;if(this.#t.status==="initialized"){if(!(0,Lt.uint8ArraysEqual)({a:this.#t.credential.getCredentialId(),b:(0,Lt.arrayBufferToUint8Array)(n)}))throw new U2;return}let{retrievePublicKey:i}=this.#t,s=await i({credentialId:(0,Lt.arrayBufferToUint8Array)(n)});this.#t=ra.#r({credential:new A2({rawId:(0,Lt.arrayBufferToUint8Array)(n),cose:s})})},step:1,onProgress:this.#e}),await Id({fn:async()=>{let{response:n}=r,{clientDataJSON:i}=n,{authenticatorData:s,signature:a}="authenticatorData"in n&&"signature"in n?n:{};if((0,Lt.isNullish)(s))throw new G_;if((0,Lt.isNullish)(a))throw new G_;let o=na.Cbor.encode({authenticator_data:s,client_data_json:new TextDecoder().decode(i),signature:(0,Lt.arrayBufferToUint8Array)(a)});if((0,Lt.isNullish)(o))throw new V2;return Object.assign(o,{__signature__:void 0}),o},step:2,onProgress:this.#e})}},K2=async()=>(0,ry.nonNullish)(window.PublicKeyCredential)&&"isUserVerifyingPlatformAuthenticatorAvailable"in PublicKeyCredential?await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():!1;var _m=be(De(),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 hr=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 Pd=({message:e,detail:t})=>{let r=new CustomEvent(e,{detail:t,bubbles:!0});document.dispatchEvent(r)};var hm=be(De(),1);var ay=be(gt(),1),fc=be(De(),1);var dc=be(De(),1);var iy=be(gt(),1),Fd=be(De(),1);var Ji="http://127.0.0.1:5987",ny="rdmx6-jaaaa-aaaaa-aaadq-cai";var sy=async({identity:e,container:t})=>{let n=(0,Fd.nonNullish)(t)&&t!==!1?t===!0?Ji:t:"https://icp-api.io",i=(0,Fd.nonNullish)(t);return await iy.HttpAgent.create({identity:e,shouldFetchRootKey:i,host:n})};var Zi=class e{static instance;#e=void 0;constructor(){}static getInstance(){return(0,dc.isNullish)(e.instance)&&(e.instance=new e),e.instance}async getAgent({identity:t,...r}){let n=t.getPrincipal().toText();if((0,dc.isNullish)(this.#e)||(0,dc.isNullish)(this.#e[n])){let i=await sy({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,fc.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,fc.isNullish)(this.#e)||(0,fc.isNullish)(this.#e[s])){let a=await this.createActor({satelliteId:t,identity:r,...i});return this.#e={...this.#e??{},[s]:a},a}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:t,satelliteId:r,...n}){let i=await Zi.getInstance().getAgent(n);return ay.Actor.createActor(t,{agent:i,canisterId:r})}};var oy=e=>(e.preventDefault(),e.returnValue="Are you sure you want to exit?"),G2=()=>{window.addEventListener("beforeunload",oy,{capture:!0})},$2=()=>{window.removeEventListener("beforeunload",oy,{capture:!0})},Ud=async({fn:e})=>{try{return G2(),await e()}finally{$2()}};var la=be(De(),1);var nr=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 cy=BigInt(144e11),uy=!1,ly={width:576,height:576},dy={width:505,height:705},fy="internetcomputer.org";var Vd=be(De(),1);var pc=be(De(),1),py=async e=>{let t=new Blob([JSON.stringify(e,pc.jsonReplacer)],{type:"application/json; charset=utf-8"});return new Uint8Array(await t.arrayBuffer())},hc=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(),pc.jsonReviver)},_c=()=>typeof window<"u";var yc=({width:e,height:t})=>{if(!_c()||(0,Vd.isNullish)(window)||(0,Vd.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 Vy=be(Ic(),1),Cy=be(De(),1);var Zr=async({fn:e,step:t,onProgress:r})=>{r?.({step:t,state:"in_progress"});try{let n=await e();return r?.({step:t,state:"success"}),n}catch(n){throw r?.({step:t,state:"error"}),n}};var Uy=(r=>(r[r.AuthorizingWithProvider=0]="AuthorizingWithProvider",r[r.CreatingOrRetrievingUser=1]="CreatingOrRetrievingUser",r))(Uy||{});var Bc=class extends Error{},li=class extends Error{},Pc=class extends Error{},Fc=class extends Error{},Uc=class extends Error{},Vc=class extends Error{},Cc=class extends Error{},qc=class extends Error{};var ts=class{async signIn({options:t,authClient:r,initAuth:n}){await Zr({fn:async()=>await this.#e({options:t,authClient:r}),step:0,onProgress:t?.onProgress}),await Zr({fn:async()=>await n({provider:this.id}),step:1,onProgress:t?.onProgress})}#e({options:t,authClient:r}){return new Promise(async(n,i)=>{if((0,Cy.isNullish)(r)){i(new li("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}await r.login({onSuccess:n,onError:s=>{if(s===Vy.ERROR_USER_INTERRUPT){i(new Pc(s));return}i(new Bc(s))},maxTimeToLive:t?.maxTimeToLiveInNanoseconds??cy,allowPinAuthentication:t?.allowPin??uy,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...this.signInOptions({windowed:t?.windowed})})})}};var Dc=class extends ts{#e;constructor({domain:t}){super(),this.#e=t}get id(){return"internet_identity"}signInOptions({windowed:t}){let r=()=>{let n=nr.getInstance().get()?.container;if((0,la.isNullish)(n)||n===!1)return`https://identity.${this.#e??fy}`;let i=nr.getInstance().get(),s=(0,la.nonNullish)(i)&&(0,la.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:ny,{host:a,protocol:o}=new URL(n===!0?Ji:n);return/apple/i.test(navigator?.vendor)?`${o}//${a}?canisterId=${s}`:`${o}//${s}.${a.replace("127.0.0.1","localhost")}`};return{...t!==!1&&{windowOpenerFeatures:yc(ly)},identityProvider:r()}}};var kc=class extends ts{#e;#t;constructor({appName:t,logoUrl:r}){super(),this.#e=t,this.#t=r}get id(){return"nfid"}signInOptions({windowed:t}){return{...t!==!1&&{windowOpenerFeatures:yc(dy)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var cm=be(gt(),1),is=be(Ic(),1),Qr=be(Yd(),1),ns=be(De(),1);var Xr={certified:!1};var qy=be(gt(),1),Dy=be(De(),1);var tt=e=>(0,Dy.nonNullish)(e)?e:Mc()??new qy.AnonymousIdentity;var Sr=be(De(),1);var Ly=be(De(),1);var LE=be(gt(),1),HE=be(De(),1),KE=be(De(),1),GE=be(gt(),1);var ky=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),n=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),i=e.Record({field:n,desc:e.Bool}),s=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),a=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(s),description:e.Opt(e.Text),created_at:e.Opt(s)}),o=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),c=e.Record({order:e.Opt(i),owner:e.Opt(e.Principal),matcher:e.Opt(a),paginate:e.Opt(o)}),d=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),p=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:f,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),b=e.Variant({Db:e.Null,Storage:e.Null}),l=e.Record({version:e.Opt(e.Nat64)}),A=e.Record({proposal_ids:e.Vec(e.Nat)}),v=e.Record({cycles:e.Nat,destination_id:e.Principal}),F=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),C=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),E=e.Record({key:F,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,C)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),H=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),x=e.Record({allowed_callers:e.Vec(e.Principal)}),q=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),K=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),G=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),D=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),ae=e.Variant({Deny:e.Null,Allow:e.Null}),Q=e.Record({status_code:e.Nat16,location:e.Text}),ne=e.Record({iframe:e.Opt(D),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),w=e.Record({db:e.Opt(G),authentication:e.Opt(q),storage:ne}),g=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),S=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),R=e.Record({clear_existing_assets:e.Opt(e.Bool)}),I=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),j=e.Variant({AssetsUpgrade:R,SegmentsDeployment:I}),Y=e.Record({status:S,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:j}),oe=e.Variant({Heap:e.Null,Stable:e.Null}),se=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),z=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),U=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:se,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(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)}),Z=e.Record({memory:oe,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),re=e.Variant({Callback:e.Record({token:Z,callback:e.Func([],[],["query"])})}),le=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(re),status_code:e.Nat16}),X=e.Record({token:e.Opt(Z),body:e.Vec(e.Nat8)}),u=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),h=e.Record({batch_id:e.Nat}),y=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,E)),items_length:e.Nat64}),P=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),O=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}),B=e.Record({desc:e.Bool}),M=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),T=e.Record({order:e.Opt(B),paginate:e.Opt(M)}),V=e.Record({proposal_id:e.Nat}),L=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(V,Y)),items_length:e.Nat64}),k=e.Record({include_system:e.Bool}),J=e.Record({matcher:e.Opt(k)}),te=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,U)),items_length:e.Nat64}),de=e.Record({stable:e.Nat64,heap:e.Nat64}),ge=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),Ie=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:f,expires_at:e.Opt(e.Nat64)}),Ue=e.Record({controller:Ie,controllers:e.Vec(e.Principal)}),_e=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),fe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Ke=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),max_size:e.Opt(e.Nat),read:se,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(z),write:se,max_changes_per_user:e.Opt(e.Nat32)}),Ht=e.Record({iframe:e.Opt(D),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),Ut=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Vt=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),commit_proposal:e.Func([r],[e.Null],[]),commit_proposal_asset_upload:e.Func([t],[],[]),commit_proposal_many_assets_upload:e.Func([e.Vec(t)],[],[]),count_assets:e.Func([e.Text,c],[e.Nat64],["query"]),count_collection_assets:e.Func([e.Text],[e.Nat64],["query"]),count_collection_docs:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text,c],[e.Nat64],["query"]),count_proposals:e.Func([],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([d],[e.Vec(e.Tuple(e.Principal,p))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,c],[],[]),del_filtered_docs:e.Func([e.Text,c],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,m))],[],[]),del_rule:e.Func([b,e.Text,l],[],[]),delete_proposal_assets:e.Func([A],[],[]),deposit_cycles:e.Func([v],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(E)],["query"]),get_auth_config:e.Func([],[e.Opt(q)],["query"]),get_config:e.Func([],[w],[]),get_db_config:e.Func([],[e.Opt(G)],["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(E)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(g)))],["query"]),get_proposal:e.Func([e.Nat],[e.Opt(Y)],["query"]),get_rule:e.Func([b,e.Text],[e.Opt(U)],["query"]),get_storage_config:e.Func([],[ne],["query"]),http_request:e.Func([_],[le],["query"]),http_request_streaming_callback:e.Func([Z],[X],["query"]),init_asset_upload:e.Func([u],[h],[]),init_proposal:e.Func([j],[e.Nat,Y],[]),init_proposal_asset_upload:e.Func([u,e.Nat],[h],[]),init_proposal_many_assets_upload:e.Func([e.Vec(u),e.Nat],[e.Vec(e.Tuple(e.Text,h))],[]),list_assets:e.Func([e.Text,c],[y],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,p))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,P))],["query"]),list_docs:e.Func([e.Text,c],[O],["query"]),list_proposals:e.Func([T],[L],["query"]),list_rules:e.Func([b,J],[te],["query"]),memory_size:e.Func([],[de],["query"]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([ge],[q],[]),set_controllers:e.Func([Ue],[e.Vec(e.Tuple(e.Principal,p))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([_e],[G],[]),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,Ke],[U],[]),set_storage_config:e.Func([Ht],[ne],[]),submit_proposal:e.Func([e.Nat],[e.Nat,Y],[]),upload_asset_chunk:e.Func([Ut],[Vt],[]),upload_proposal_asset_chunk:e.Func([Ut],[Vt],[])})},My=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),n=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),i=e.Record({field:n,desc:e.Bool}),s=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),a=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(s),description:e.Opt(e.Text),created_at:e.Opt(s)}),o=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),c=e.Record({order:e.Opt(i),owner:e.Opt(e.Principal),matcher:e.Opt(a),paginate:e.Opt(o)}),d=e.Record({controllers:e.Vec(e.Principal)}),f=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),p=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:f,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),b=e.Variant({Db:e.Null,Storage:e.Null}),l=e.Record({version:e.Opt(e.Nat64)}),A=e.Record({proposal_ids:e.Vec(e.Nat)}),v=e.Record({cycles:e.Nat,destination_id:e.Principal}),F=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),C=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),E=e.Record({key:F,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,C)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),H=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),x=e.Record({allowed_callers:e.Vec(e.Principal)}),q=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),K=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),G=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),D=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),ae=e.Variant({Deny:e.Null,Allow:e.Null}),Q=e.Record({status_code:e.Nat16,location:e.Text}),ne=e.Record({iframe:e.Opt(D),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),w=e.Record({db:e.Opt(G),authentication:e.Opt(q),storage:ne}),g=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),S=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),R=e.Record({clear_existing_assets:e.Opt(e.Bool)}),I=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),j=e.Variant({AssetsUpgrade:R,SegmentsDeployment:I}),Y=e.Record({status:S,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:j}),oe=e.Variant({Heap:e.Null,Stable:e.Null}),se=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),z=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),U=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:se,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(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)}),Z=e.Record({memory:oe,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),re=e.Variant({Callback:e.Record({token:Z,callback:e.Func([],[],[])})}),le=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(re),status_code:e.Nat16}),X=e.Record({token:e.Opt(Z),body:e.Vec(e.Nat8)}),u=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),h=e.Record({batch_id:e.Nat}),y=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,E)),items_length:e.Nat64}),P=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),O=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}),B=e.Record({desc:e.Bool}),M=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),T=e.Record({order:e.Opt(B),paginate:e.Opt(M)}),V=e.Record({proposal_id:e.Nat}),L=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(V,Y)),items_length:e.Nat64}),k=e.Record({include_system:e.Bool}),J=e.Record({matcher:e.Opt(k)}),te=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,U)),items_length:e.Nat64}),de=e.Record({stable:e.Nat64,heap:e.Nat64}),ge=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(H),rules:e.Opt(x)}),Ie=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:f,expires_at:e.Opt(e.Nat64)}),Ue=e.Record({controller:Ie,controllers:e.Vec(e.Principal)}),_e=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(K)}),fe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Ke=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(oe),max_size:e.Opt(e.Nat),read:se,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(z),write:se,max_changes_per_user:e.Opt(e.Nat32)}),Ht=e.Record({iframe:e.Opt(D),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(K),raw_access:e.Opt(ae),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Q)))}),Ut=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Vt=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),commit_proposal:e.Func([r],[e.Null],[]),commit_proposal_asset_upload:e.Func([t],[],[]),commit_proposal_many_assets_upload:e.Func([e.Vec(t)],[],[]),count_assets:e.Func([e.Text,c],[e.Nat64],[]),count_collection_assets:e.Func([e.Text],[e.Nat64],[]),count_collection_docs:e.Func([e.Text],[e.Nat64],[]),count_docs:e.Func([e.Text,c],[e.Nat64],[]),count_proposals:e.Func([],[e.Nat64],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([d],[e.Vec(e.Tuple(e.Principal,p))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,c],[],[]),del_filtered_docs:e.Func([e.Text,c],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,m))],[],[]),del_rule:e.Func([b,e.Text,l],[],[]),delete_proposal_assets:e.Func([A],[],[]),deposit_cycles:e.Func([v],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(E)],[]),get_auth_config:e.Func([],[e.Opt(q)],[]),get_config:e.Func([],[w],[]),get_db_config:e.Func([],[e.Opt(G)],[]),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(E)))],[]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(g)))],[]),get_proposal:e.Func([e.Nat],[e.Opt(Y)],[]),get_rule:e.Func([b,e.Text],[e.Opt(U)],[]),get_storage_config:e.Func([],[ne],[]),http_request:e.Func([_],[le],[]),http_request_streaming_callback:e.Func([Z],[X],[]),init_asset_upload:e.Func([u],[h],[]),init_proposal:e.Func([j],[e.Nat,Y],[]),init_proposal_asset_upload:e.Func([u,e.Nat],[h],[]),init_proposal_many_assets_upload:e.Func([e.Vec(u),e.Nat],[e.Vec(e.Tuple(e.Text,h))],[]),list_assets:e.Func([e.Text,c],[y],[]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,p))],[]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,P))],[]),list_docs:e.Func([e.Text,c],[O],[]),list_proposals:e.Func([T],[L],[]),list_rules:e.Func([b,J],[te],[]),memory_size:e.Func([],[de],[]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([ge],[q],[]),set_controllers:e.Func([Ue],[e.Vec(e.Tuple(e.Principal,p))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([_e],[G],[]),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,Ke],[U],[]),set_storage_config:e.Func([Ht],[ne],[]),submit_proposal:e.Func([e.Nat],[e.Nat,Y],[]),upload_asset_chunk:e.Func([Ut],[Vt],[]),upload_proposal_asset_chunk:e.Func([Ut],[Vt],[])})};var jc=be(De(),1);var jy=({satelliteId:e,container:t})=>{let{satelliteId:r}=pf({satelliteId:e}),{container:n}=hf({container:t});if((0,jc.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`},pf=({satelliteId:e})=>(0,jc.nonNullish)(e)?{satelliteId:e}:nr.getInstance().get()??{satelliteId:void 0},hf=({container:e})=>(0,jc.nonNullish)(e)?{container:e}:nr.getInstance().get()??{container:void 0};var dt=({satellite:e,options:{certified:t}})=>Ky({idlFactory:t?My:ky,actorKey:`stock#${t?"update":"query"}`,...e}),Hy=({idlFactory:e,...t})=>Ky({idlFactory:e,actorKey:"extended#query",...t}),Ky=async({satelliteId:e,container:t,...r})=>{let{satelliteId:n}=pf({satelliteId:e});(0,Ly.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=hf({container:t});return await Xi.getInstance().getActor({satelliteId:n,container:i,...r})};var $y=be(Ct(),1),st=be(De(),1);var Gy=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 qc("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:Gy(e.createdAt),updated_at:Gy(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"?$y.Principal.fromText(n):n)});var Wy=async({data:e})=>{try{return await hc(e)}catch(t){console.error("The data parsing has failed, mapping to undefined as a fallback.",t);return}};var di=be(De(),1);var _f=async e=>{let{data:t,version:r,description:n}=e;return{description:(0,di.toNullable)(n),data:await py(t),version:(0,di.toNullable)(r)}},yf=e=>{let{version:t}=e;return{version:(0,di.toNullable)(t)}},da=async({doc:e,key:t})=>{let{owner:r,version:n,description:i,data:s,...a}=e;return{key:t,description:(0,di.fromNullable)(i),owner:r.toText(),data:await hc(s),version:(0,di.fromNullable)(n),...a}};var zy=async({collection:e,key:t,...r})=>{let{get_doc:n}=await dt(r),i=(0,Sr.fromNullable)(await n(e,t));if(!(0,Sr.isNullish)(i))return da({doc:i,key:t})},Yy=async({docs:e,...t})=>{let{get_many_docs:r}=await dt(t),n=e.map(({collection:a,key:o})=>[a,o]),i=await r(n),s=[];for(let[a,o]of i){let c=(0,Sr.fromNullable)(o);s.push((0,Sr.nonNullish)(c)?await da({key:a,doc:c}):void 0)}return s},Jy=async({collection:e,doc:t,...r})=>{let{set_doc:n}=await dt(r),{key:i}=t,s=await _f(t),a=await n(e,i,s);return await da({key:i,doc:a})},Zy=async({docs:e,...t})=>{let{set_many_docs:r}=await dt(t),n=[];for(let{collection:a,doc:o}of e){let{key:c}=o;n.push([a,c,await _f(o)])}let i=await r(n),s=[];for(let[a,o]of i)s.push(await da({key:a,doc:o}));return s},Xy=async({collection:e,doc:t,...r})=>{let{del_doc:n}=await dt(r),{key:i}=t;return n(e,i,yf(t))},Qy=async({docs:e,...t})=>{let{del_many_docs:r}=await dt(t),n=e.map(({collection:i,doc:s})=>[i,s.key,yf(s)]);await r(n)},em=async({collection:e,filter:t,...r})=>{let{del_filtered_docs:n}=await dt(r);return n(e,jn(t))},tm=async({collection:e,filter:t,...r})=>{let{list_docs:n}=await dt(r),{items:i,items_page:s,items_length:a,matches_length:o,matches_pages:c}=await n(e,jn(t)),d=[];for(let[f,p]of i){let{data:m,owner:b,description:l,version:A,...v}=p;d.push({key:f,description:(0,Sr.fromNullable)(l),owner:b.toText(),data:await Wy({data:m}),version:(0,Sr.fromNullable)(A),...v})}return{items:d,items_length:a,items_page:(0,Sr.fromNullable)(s),matches_length:o,matches_pages:(0,Sr.fromNullable)(c)}},rm=async({collection:e,filter:t,...r})=>{let{count_docs:n}=await dt(r);return n(e,jn(t))};var Lc=async({satellite:e,options:t,...r})=>{let n=tt(e?.identity);return await zy({...r,satellite:{...e,identity:n},options:t??Xr})},I4=async({satellite:e,options:t,...r})=>{let n=tt(e?.identity);return await Yy({...r,satellite:{...e,identity:n},options:t??Xr})},nm=async({satellite:e,...t})=>{let r=tt(e?.identity);return await Jy({...t,satellite:{...e,identity:r},options:{certified:!0}})},im=async({satellite:e,...t})=>{let r=tt(e?.identity);return await Zy({...t,satellite:{...e,identity:r},options:{certified:!0}})},B4=async({satellite:e,...t})=>{let r=tt(e?.identity);return await Xy({...t,satellite:{...e,identity:r},options:{certified:!0}})},P4=async({satellite:e,...t})=>{let r=tt(e?.identity);return await Qy({...t,satellite:{...e,identity:r},options:{certified:!0}})},F4=async({satellite:e,filter:t,...r})=>{let n=tt(e?.identity);return await em({...r,filter:t??{},satellite:{...e,identity:n},options:{certified:!0}})},U4=async({satellite:e,options:t,filter:r,...n})=>{let i=tt(e?.identity);return await tm({...n,filter:r??{},satellite:{...e,identity:i},options:t??Xr})},V4=async({satellite:e,options:t,filter:r,...n})=>{let i=tt(e?.identity);return await rm({...n,filter:r??{},satellite:{...e,identity:i},options:t??Xr})};var rs=be(De(),1);var sm=async({delegationIdentity:e,passkeyIdentity:t,satelliteId:r})=>{let n=t.getCredential().getAAGUID(),[i,s]=await im({docs:[{collection:"#user",doc:{key:e.getPrincipal().toText(),data:{provider:"webauthn",providerData:{webauthn:{...(0,rs.nonNullish)(n)&&{aaguid:(0,rs.uint8ArrayToArrayOfNumber)(n)}}}}}},{collection:"#user-webauthn",doc:{key:t.getCredential().getCredentialIdText(),data:{publicKey:(0,rs.arrayBufferToUint8Array)(t.getPublicKey().toDer())}}}],satellite:{identity:e,satelliteId:r}});return i};var am=(s=>(s[s.RequestingUserCredential=0]="RequestingUserCredential",s[s.FinalizingCredential=1]="FinalizingCredential",s[s.Signing=2]="Signing",s[s.FinalizingSession=3]="FinalizingSession",s[s.RetrievingUser=4]="RetrievingUser",s))(am||{}),om=(a=>(a[a.CreatingUserCredential=0]="CreatingUserCredential",a[a.ValidatingUserCredential=1]="ValidatingUserCredential",a[a.FinalizingCredential=2]="FinalizingCredential",a[a.Signing=3]="Signing",a[a.FinalizingSession=4]="FinalizingSession",a[a.RegisteringUser=5]="RegisteringUser",a))(om||{});var fa=class{get id(){return"webauthn"}async signUp({options:{onProgress:t,maxTimeToLiveInMilliseconds:r,passkey:n}={},loadAuthWithUser:i}){let{satelliteId:s}=nr.getInstance().get()??{satelliteId:void 0};if((0,ns.isNullish)(s))throw new li("Satellite ID not set. Have you initialized the Satellite?");let a=({step:A,state:v})=>{switch(A){case Vn.RequestingUserCredential:t?.({step:1,state:v});break;case Vn.FinalizingCredential:t?.({step:2,state:v});break;case Vn.Signing:t?.({step:3,state:v});break}},c=await Zr({fn:async()=>await Bd.createWithNewCredential({onProgress:a,passkeyOptions:n}),step:0,onProgress:t}),{delegationIdentity:d,sessionKey:f}=await this.#e({identity:c,maxTimeToLiveInMilliseconds:r}),m=await Zr({fn:async()=>await sm({delegationIdentity:d,passkeyIdentity:c,satelliteId:s}),step:5,onProgress:t});await Zr({fn:async()=>await this.#t({delegationIdentity:d,sessionKey:f}),step:4,onProgress:t}),await Zr({fn:async()=>await i({user:m}),step:5,onProgress:t})}async signIn({options:{onProgress:t,maxTimeToLiveInMilliseconds:r}={},loadAuth:n}){let{satelliteId:i}=nr.getInstance().get()??{satelliteId:void 0};if((0,ns.isNullish)(i))throw new li("Satellite ID not set. Have you initialized the Satellite?");let s=async({credentialId:p})=>{let m=await Lc({collection:"#user-webauthn",key:(0,ns.uint8ArrayToBase64)(p),options:{certified:!0},satellite:{identity:new cm.AnonymousIdentity,satelliteId:i}});if((0,ns.isNullish)(m))throw new Uc("No public key found for the selected passkey.");let{data:b}=m,{publicKey:l}=b;return(0,Qr.unwrapDER)(l.buffer,Qr.DER_COSE_OID)},a=({step:p,state:m})=>{switch(p){case Vn.RequestingUserCredential:t?.({step:0,state:m});break;case Vn.FinalizingCredential:t?.({step:1,state:m});break;case Vn.Signing:t?.({step:2,state:m});break}},o=await Bd.createWithExistingCredential({retrievePublicKey:s,onProgress:a}),{delegationIdentity:c,sessionKey:d}=await this.#e({identity:o,maxTimeToLiveInMilliseconds:r});await Zr({fn:async()=>await this.#t({delegationIdentity:c,sessionKey:d}),step:3,onProgress:t}),await Zr({fn:n,step:4,onProgress:t})}async#e({identity:t,maxTimeToLiveInMilliseconds:r}){let n=await Qr.ECDSAKeyIdentity.generate({extractable:!1}),i=r??144e5,s=await Qr.DelegationChain.create(t,n.getPublicKey(),new Date(Date.now()+i));return{delegationIdentity:Qr.DelegationIdentity.fromDelegation(n,s),sessionKey:n}}async#t({sessionKey:t,delegationIdentity:r}){let n=new is.IdbStorage;await Promise.all([n.set(is.KEY_STORAGE_KEY,t.getKeyPair()),n.set(is.KEY_STORAGE_DELEGATION,JSON.stringify(r.getDelegation().toJSON()))])}};var ss=be(Ic(),1),pa=()=>ss.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}}),um=async()=>(await new ss.IdbStorage().remove(ss.KEY_STORAGE_KEY),await pa());var ha=be(De(),1);var mf=({error:e,type:t})=>typeof e=="string"?e.includes(t):e instanceof Error?e.message.includes(t):!1;var lm="juno.datastore.error.user.cannot_update";var dm=async({provider:e})=>{let{user:t,userId:r}=await gf();if((0,ha.nonNullish)(t))return t;try{return await WE({userId:r,provider:e})}catch(n){if(mf({error:n,type:lm})){let i=await fm({userId:r});if((0,ha.nonNullish)(i))return i}throw n}},gf=async()=>{let e=Mc();if((0,ha.isNullish)(e))throw new Cc("No identity to initialize the user. Have you initialized Juno?");let t=e.getPrincipal().toText(),r=await fm({userId:t});return{userId:t,user:r}},fm=({userId:e})=>Lc({collection:"#user",key:e}),WE=({userId:e,...t})=>nm({collection:"#user",doc:{key:e,data:t}});var yr,bf=async()=>{await wf({fn:async()=>{let{user:t}=await gf();hr.getInstance().set(t??null)}})},zE=async({user:e})=>{await wf({fn:async()=>{hr.getInstance().set(e)}})},pm=async({provider:e})=>{await wf({fn:async()=>{let r=await dm({provider:e});hr.getInstance().set(r)}})},wf=async({fn:e})=>{if(yr=await pa(),!await yr.isAuthenticated()){yr=await um();return}await e()},YE=async e=>{let t=async()=>await ZE(e);if(Object.values(e)[0].context?.windowGuard===!1){await t();return}await Ud({fn:t})},JE=async e=>{let t=async()=>await XE(e);if(Object.values(e)?.[0].context?.windowGuard===!1){await t();return}await Ud({fn:t})},ZE=async e=>{if("webauthn"in e){let{webauthn:{options:t}}=e;await new fa().signIn({options:t,loadAuth:bf});return}if("nfid"in e){let{nfid:{options:t}}=e,{appName:r,logoUrl:n,...i}=t??{};await new kc({appName:r,logoUrl:n}).signIn({options:i,authClient:yr,initAuth:pm});return}if("internet_identity"in e){let{internet_identity:{options:t}}=e,{domain:r,...n}=t??{};await new Dc({domain:r}).signIn({options:n,authClient:yr,initAuth:pm});return}throw new Fc("An unknown or unsupported provider was provided for sign-in.")},XE=async e=>{if("webauthn"in e){let{webauthn:{options:t}}=e;await new fa().signUp({options:t,loadAuthWithUser:zE});return}throw new Vc("An unknown or unsupported provider was provided for sign-up.")},xf=async e=>{await QE(),yr=await pa(),e?.windowReload!==!1&&window.location.reload()},QE=async()=>{await yr?.logout(),yr=null,hr.getInstance().reset(),Xi.getInstance().reset(),Zi.getInstance().reset()},Mc=()=>yr?.getIdentity(),eO=async()=>(yr??await pa()).getIdentity(),tO=async()=>{let e=hr.getInstance().get();return(0,hm.isNullish)(e)||!(await yr?.isAuthenticated()??!1)?null:yr?.getIdentity()??null};var ym=e=>{let t=e===!0?"./workers/auth.worker.js":e,r=new Worker(t),n=async()=>{Pd({message:"junoSignOutAuthTimer"}),await xf()};return r.onmessage=async({data:i})=>{let{msg:s,data:a}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Pd({message:"junoDelegationRemainingTime",detail:a?.authRemainingTime});return}},hr.getInstance().subscribe(i=>{if((0,_m.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var mm=()=>{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()},gm=()=>{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 TR=async({idlFactory:e,satellite:t})=>{let r=tt(t?.identity);return await Hy({idlFactory:e,...t,identity:r})};var ya=be(De(),1);var _a=be(De(),1);var as=be(De(),1);var bm=async({asset:{data:e,headers:t,...r},actor:n,progress:i})=>{let{init_asset_upload:s,upload_asset_chunk:a,commit_asset_upload:o}=n,{batch_id:c}=await s(rO(r));i?.onInitiatedBatch();let{chunkIds:d}=await sO({data:e,uploadFn:a,batchId:c});i?.onUploadedFileChunks(r.fullPath),await iO({commitFn:o,batchId:c,data:e,headers:t,chunkIds:d}),i?.onCommittedBatch()};var rO=({filename:e,collection:t,token:r,fullPath:n,encoding:i,description:s})=>({collection:t,full_path:n,name:e,token:(0,as.toNullable)(r),encoding_type:(0,as.toNullable)(i),description:(0,as.toNullable)(s)}),nO=({batchId:e,chunkIds:t,headers:r,data:n})=>{let i=r.find(([s,a])=>s.toLowerCase()==="content-type")===void 0&&n.type!==void 0&&n.type!==""?[["Content-Type",n.type]]:void 0;return{batch_id:e,chunk_ids:t.map(({chunk_id:s})=>s),headers:[...r,...i??[]]}},iO=async({commitFn:e,...t})=>{let r=nO(t);await e(r)},sO=async({data:e,uploadFn:t,batchId:r})=>{let n=[],i=_c()?new Blob([await e.arrayBuffer()]):e,s=0n;for(let o=0;o<i.size;o+=19e5){let c=i.slice(o,o+19e5);n.push({batchId:r,chunk:c,uploadFn:t,orderId:s}),s++}let a=[];for await(let o of aO({uploadChunks:n}))a=[...a,...o];return{chunkIds:a}};async function*aO({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=>oO(i)))}}var oO=async({batchId:e,chunk:t,uploadFn:r,orderId:n})=>r({batch_id:e,content:new Uint8Array(await t.arrayBuffer()),order_id:(0,as.toNullable)(n)});var wm=async({asset:e,...t})=>{let r=await dt(t);await bm({actor:r,asset:e})},xm=async({collection:e,filter:t,...r})=>{let{list_assets:n}=await dt(r),{items:i,items_length:s,items_page:a,matches_length:o,matches_pages:c}=await n(e,jn(t));return{items:i.map(([d,f])=>f),items_length:s,items_page:(0,_a.fromNullable)(a),matches_length:o,matches_pages:(0,_a.fromNullable)(c)}},Tm=async({collection:e,filter:t,...r})=>{let{count_assets:n}=await dt(r);return n(e,jn(t))},Nm=async({collection:e,fullPath:t,...r})=>(await dt(r)).del_asset(e,t),Em=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)},Om=async({collection:e,filter:t,...r})=>{let{del_filtered_assets:n}=await dt(r);return n(e,jn(t))},vm=async({collection:e,fullPath:t,...r})=>{let{get_asset:n}=await dt(r);return(0,_a.fromNullable)(await n(e,t))},Rm=async({assets:e,...t})=>{let{get_many_assets:r}=await dt(t),n=e.map(({collection:s,fullPath:a})=>[s,a]);return(await r(n)).map(([s,a])=>(0,_a.fromNullable)(a))};var Am=e=>btoa([...e].map(t=>String.fromCharCode(t)).join(""));var CR=e=>Sm(e),qR=e=>Sm({filename:e.data.name,...e}),Sm=async({filename:e,data:t,collection:r,headers:n=[],fullPath:i,token:s,satellite:a,encoding:o,description:c})=>{let d=tt(a?.identity),f=decodeURI(e),p=i??`/${r}/${f}`,m={...a,identity:d};return await wm({asset:{data:t,filename:f,collection:r,token:s,headers:n,fullPath:p,encoding:o,description:c},satellite:m,options:{certified:!0}}),{downloadUrl:Im({satellite:m,assetKey:{fullPath:p,token:s}}),fullPath:p,name:f}},DR=async({collection:e,filter:t,satellite:r,options:n})=>{let i={...r,identity:tt(r?.identity)},{items:s,...a}=await xm({collection:e,filter:t??{},satellite:i,options:n??Xr}),o=s.map(({key:{full_path:c,token:d,name:f,owner:p,description:m},headers:b,encodings:l,created_at:A,updated_at:v})=>{let F=(0,ya.fromNullable)(d);return{fullPath:c,description:(0,ya.fromNullable)(m),name:f,downloadUrl:Im({satellite:i,assetKey:{fullPath:c,token:F}}),token:F,headers:b,encodings:l.reduce((C,[E,{modified:H,sha256:x,total_length:q}])=>({...C,[E]:{modified:H,sha256:Am(x),total_length:q}}),{}),owner:p.toText(),created_at:A,updated_at:v}});return{items:o,assets:o,...a}},kR=async({collection:e,filter:t,satellite:r,options:n})=>{let i={...r,identity:tt(r?.identity)};return await Tm({collection:e,satellite:i,filter:t??{},options:n??Xr})},MR=({collection:e,fullPath:t,satellite:r})=>Nm({collection:e,fullPath:t,satellite:{...r,identity:tt(r?.identity)},options:{certified:!0}}),jR=({assets:e,satellite:t})=>Em({assets:e,satellite:{...t,identity:tt(t?.identity)},options:{certified:!0}}),LR=async({collection:e,satellite:t,filter:r})=>{let n={...t,identity:tt(t?.identity)};return await Om({collection:e,satellite:n,filter:r??{},options:{certified:!0}})},HR=async({satellite:e,options:t,...r})=>{let n=tt(e?.identity);return await vm({...r,satellite:{...e,identity:n},options:t??Xr})},KR=async({satellite:e,options:t,...r})=>{let n=tt(e?.identity);return await Rm({...r,satellite:{...e,identity:n},options:t??Xr})},Im=({assetKey:{fullPath:e,token:t},satellite:r})=>{let n={...r,identity:tt(r?.identity)};return`${jy(n)}${e}${(0,ya.nonNullish)(t)?`?token=${t}`:""}`};var cO=e=>{let t=e?.satelliteId??mm();(0,Bm.assertNonNullish)(t,"Satellite ID is not configured. Juno cannot be initialized.");let r=e?.container??gm();return{satelliteId:t,internetIdentityId:e?.internetIdentityId,workers:e?.workers,container:r}},XR=e=>uO(e),uO=async e=>{let t=cO(e);nr.getInstance().set(t),await bf();let r=t.workers?.auth!==void 0?ym(t.workers.auth):void 0;return[...r?[r]:[]]},lO=e=>hr.getInstance().subscribe(e),QR=lO;export{Uy as AuthClientSignInProgressStep,Cc as InitError,Dc as InternetIdentityProvider,qc as ListError,kc as NFIDProvider,Bc as SignInError,li as SignInInitError,Fc as SignInProviderNotSupportedError,Pc as SignInUserInterruptError,Vc as SignUpProviderNotSupportedError,am as WebAuthnSignInProgressStep,Uc as WebAuthnSignInRetrievePublicKeyError,om as WebAuthnSignUpProgressStep,QR as authSubscribe,kR as countAssets,V4 as countDocs,MR as deleteAsset,B4 as deleteDoc,LR as deleteFilteredAssets,F4 as deleteFilteredDocs,jR as deleteManyAssets,P4 as deleteManyDocs,Im as downloadUrl,HR as getAsset,Lc as getDoc,tO as getIdentityOnce,KR as getManyAssets,I4 as getManyDocs,TR as getSatelliteExtendedActor,XR as initJuno,uO as initSatellite,K2 as isWebAuthnAvailable,DR as listAssets,U4 as listDocs,lO as onAuthStateChange,nm as setDoc,im as setManyDocs,YE as signIn,xf as signOut,JE as signUp,eO as unsafeIdentity,CR as uploadBlob,qR as uploadFile};
58
58
  /*! Bundled license information:
59
59
 
60
60
  ieee754/index.js: