@junobuild/core-standalone 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
var Cg=Object.create;var Js=Object.defineProperty;var qg=Object.getOwnPropertyDescriptor;var jg=Object.getOwnPropertyNames;var kg=Object.getPrototypeOf,Hg=Object.prototype.hasOwnProperty;var ni=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Uf=(t,e)=>()=>(t&&(e=t(t=0)),e);var L=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Vg=(t,e)=>{for(var r in e)Js(t,r,{get:e[r],enumerable:!0})},Ff=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of jg(e))!Hg.call(t,i)&&i!==r&&Js(t,i,{get:()=>e[i],enumerable:!(n=qg(e,i))||n.enumerable});return t};var Xe=(t,e,r)=>(r=t!=null?Cg(kg(t)):{},Ff(e||!t||!t.__esModule?Js(r,"default",{value:t,enumerable:!0}):r,t)),$g=t=>Ff(Js({},"__esModule",{value:!0}),t);var qf=L(Qs=>{"use strict";Qs.byteLength=Gg;Qs.toByteArray=zg;Qs.fromByteArray=Zg;var xr=[],er=[],Kg=typeof Uint8Array<"u"?Uint8Array:Array,hc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Mn=0,Mf=hc.length;Mn<Mf;++Mn)xr[Mn]=hc[Mn],er[hc.charCodeAt(Mn)]=Mn;var Mn,Mf;er[45]=62;er[95]=63;function Cf(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Gg(t){var e=Cf(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Yg(t,e,r){return(e+r)*3/4-r}function zg(t){var e,r=Cf(t),n=r[0],i=r[1],s=new Kg(Yg(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=er[t.charCodeAt(c)]<<18|er[t.charCodeAt(c+1)]<<12|er[t.charCodeAt(c+2)]<<6|er[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=er[t.charCodeAt(c)]<<2|er[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=er[t.charCodeAt(c)]<<10|er[t.charCodeAt(c+1)]<<4|er[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Wg(t){return xr[t>>18&63]+xr[t>>12&63]+xr[t>>6&63]+xr[t&63]}function Dg(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(Wg(n));return i.join("")}function Zg(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(Dg(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(xr[e>>2]+xr[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(xr[e>>10]+xr[e>>4&63]+xr[e<<2&63]+"=")),i.join("")}});var yc=L(pc=>{pc.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,f=c>>1,d=-7,h=r?i-1:0,m=r?-1:1,_=t[e+h];for(h+=m,s=_&(1<<-d)-1,_>>=-d,d+=a;d>0;s=s*256+t[e+h],h+=m,d-=8);for(o=s&(1<<-d)-1,s>>=-d,d+=n;d>0;o=o*256+t[e+h],h+=m,d-=8);if(s===0)s=1-f;else{if(s===c)return o?NaN:(_?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-f}return(_?-1:1)*o*Math.pow(2,s-n)};pc.write=function(t,e,r,n,i,s){var o,a,c,f=s*8-i-1,d=(1<<f)-1,h=d>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=n?0:s-1,u=n?1:-1,T=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=d):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?e+=m/c:e+=m*Math.pow(2,1-h),e*c>=2&&(o++,c/=2),o+h>=d?(a=0,o=d):o+h>=1?(a=(e*c-1)*Math.pow(2,i),o=o+h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+_]=a&255,_+=u,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;t[r+_]=o&255,_+=u,o/=256,f-=8);t[r+_-u]|=T*128}});var ed=L(ai=>{"use strict";var gc=qf(),si=yc(),jf=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ai.Buffer=G;ai.SlowBuffer=tm;ai.INSPECT_MAX_BYTES=50;var Ls=2147483647;ai.kMaxLength=Ls;G.TYPED_ARRAY_SUPPORT=Xg();!G.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Xg(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(G.prototype,"parent",{enumerable:!0,get:function(){if(G.isBuffer(this))return this.buffer}});Object.defineProperty(G.prototype,"offset",{enumerable:!0,get:function(){if(G.isBuffer(this))return this.byteOffset}});function Gr(t){if(t>Ls)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,G.prototype),e}function G(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return wc(t)}return $f(t,e,r)}G.poolSize=8192;function $f(t,e,r){if(typeof t=="string")return Qg(t,e);if(ArrayBuffer.isView(t))return Lg(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(vr(t,ArrayBuffer)||t&&vr(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(vr(t,SharedArrayBuffer)||t&&vr(t.buffer,SharedArrayBuffer)))return bc(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return G.from(n,e,r);let i=em(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return G.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}G.from=function(t,e,r){return $f(t,e,r)};Object.setPrototypeOf(G.prototype,Uint8Array.prototype);Object.setPrototypeOf(G,Uint8Array);function Kf(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function Jg(t,e,r){return Kf(t),t<=0?Gr(t):e!==void 0?typeof r=="string"?Gr(t).fill(e,r):Gr(t).fill(e):Gr(t)}G.alloc=function(t,e,r){return Jg(t,e,r)};function wc(t){return Kf(t),Gr(t<0?0:Ec(t)|0)}G.allocUnsafe=function(t){return wc(t)};G.allocUnsafeSlow=function(t){return wc(t)};function Qg(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!G.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Gf(t,e)|0,n=Gr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function mc(t){let e=t.length<0?0:Ec(t.length)|0,r=Gr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Lg(t){if(vr(t,Uint8Array)){let e=new Uint8Array(t);return bc(e.buffer,e.byteOffset,e.byteLength)}return mc(t)}function bc(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,G.prototype),n}function em(t){if(G.isBuffer(t)){let e=Ec(t.length)|0,r=Gr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||vc(t.length)?Gr(0):mc(t);if(t.type==="Buffer"&&Array.isArray(t.data))return mc(t.data)}function Ec(t){if(t>=Ls)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ls.toString(16)+" bytes");return t|0}function tm(t){return+t!=t&&(t=0),G.alloc(+t)}G.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==G.prototype};G.compare=function(e,r){if(vr(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),vr(r,Uint8Array)&&(r=G.from(r,r.offset,r.byteLength)),!G.isBuffer(e)||!G.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};G.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};G.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return G.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=G.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(vr(o,Uint8Array))s+o.length>i.length?(G.isBuffer(o)||(o=G.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(G.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Gf(t,e){if(G.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||vr(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return _c(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Lf(t).length;default:if(i)return n?-1:_c(t).length;e=(""+e).toLowerCase(),i=!0}}G.byteLength=Gf;function rm(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return dm(this,e,r);case"utf8":case"utf-8":return zf(this,e,r);case"ascii":return lm(this,e,r);case"latin1":case"binary":return fm(this,e,r);case"base64":return cm(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hm(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}G.prototype._isBuffer=!0;function Cn(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}G.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)Cn(this,r,r+1);return this};G.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)Cn(this,r,r+3),Cn(this,r+1,r+2);return this};G.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)Cn(this,r,r+7),Cn(this,r+1,r+6),Cn(this,r+2,r+5),Cn(this,r+3,r+4);return this};G.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?zf(this,0,e):rm.apply(this,arguments)};G.prototype.toLocaleString=G.prototype.toString;G.prototype.equals=function(e){if(!G.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:G.compare(this,e)===0};G.prototype.inspect=function(){let e="",r=ai.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};jf&&(G.prototype[jf]=G.prototype.inspect);G.prototype.compare=function(e,r,n,i,s){if(vr(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),!G.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.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===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),f=this.slice(i,s),d=e.slice(r,n);for(let h=0;h<c;++h)if(f[h]!==d[h]){o=f[h],a=d[h];break}return o<a?-1:a<o?1:0};function Yf(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,vc(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=G.from(e,n)),G.isBuffer(e))return e.length===0?-1:kf(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):kf(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function kf(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(d,h){return s===1?d[h]:d.readUInt16BE(h*s)}let f;if(i){let d=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,d===-1?0:f-d)){if(d===-1&&(d=f),f-d+1===a)return d*s}else d!==-1&&(f-=f-d),d=-1}else for(r+a>o&&(r=o-a),f=r;f>=0;f--){let d=!0;for(let h=0;h<a;h++)if(c(t,f+h)!==c(e,h)){d=!1;break}if(d)return f}return-1}G.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};G.prototype.indexOf=function(e,r,n){return Yf(this,e,r,n,!0)};G.prototype.lastIndexOf=function(e,r,n){return Yf(this,e,r,n,!1)};function nm(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(vc(a))return o;t[r+o]=a}return o}function im(t,e,r,n){return eo(_c(e,t.length-r),t,r,n)}function sm(t,e,r,n){return eo(mm(e),t,r,n)}function om(t,e,r,n){return eo(Lf(e),t,r,n)}function am(t,e,r,n){return eo(bm(e,t.length-r),t,r,n)}G.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return nm(this,e,r,n);case"utf8":case"utf-8":return im(this,e,r,n);case"ascii":case"latin1":case"binary":return sm(this,e,r,n);case"base64":return om(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return am(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};G.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function cm(t,e,r){return e===0&&r===t.length?gc.fromByteArray(t):gc.fromByteArray(t.slice(e,r))}function zf(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,f,d,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(h=(s&15)<<12|(c&63)<<6|f&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=t[i+1],f=t[i+2],d=t[i+3],(c&192)===128&&(f&192)===128&&(d&192)===128&&(h=(s&15)<<18|(c&63)<<12|(f&63)<<6|d&63,h>65535&&h<1114112&&(o=h))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return um(n)}var Hf=4096;function um(t){let e=t.length;if(e<=Hf)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Hf));return r}function lm(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function fm(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function dm(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=_m[t[s]];return i}function hm(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}G.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,G.prototype),i};function ft(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}G.prototype.readUintLE=G.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};G.prototype.readUintBE=G.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};G.prototype.readUint8=G.prototype.readUInt8=function(e,r){return e=e>>>0,r||ft(e,1,this.length),this[e]};G.prototype.readUint16LE=G.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||ft(e,2,this.length),this[e]|this[e+1]<<8};G.prototype.readUint16BE=G.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||ft(e,2,this.length),this[e]<<8|this[e+1]};G.prototype.readUint32LE=G.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};G.prototype.readUint32BE=G.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};G.prototype.readBigUInt64LE=rn(function(e){e=e>>>0,oi(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Gi(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});G.prototype.readBigUInt64BE=rn(function(e){e=e>>>0,oi(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Gi(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});G.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};G.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};G.prototype.readInt8=function(e,r){return e=e>>>0,r||ft(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};G.prototype.readInt16LE=function(e,r){e=e>>>0,r||ft(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};G.prototype.readInt16BE=function(e,r){e=e>>>0,r||ft(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};G.prototype.readInt32LE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};G.prototype.readInt32BE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};G.prototype.readBigInt64LE=rn(function(e){e=e>>>0,oi(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Gi(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});G.prototype.readBigInt64BE=rn(function(e){e=e>>>0,oi(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Gi(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});G.prototype.readFloatLE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),si.read(this,e,!0,23,4)};G.prototype.readFloatBE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),si.read(this,e,!1,23,4)};G.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||ft(e,8,this.length),si.read(this,e,!0,52,8)};G.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||ft(e,8,this.length),si.read(this,e,!1,52,8)};function jt(t,e,r,n,i,s){if(!G.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}G.prototype.writeUintLE=G.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;jt(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};G.prototype.writeUintBE=G.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;jt(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};G.prototype.writeUint8=G.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,1,255,0),this[r]=e&255,r+1};G.prototype.writeUint16LE=G.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};G.prototype.writeUint16BE=G.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};G.prototype.writeUint32LE=G.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};G.prototype.writeUint32BE=G.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Wf(t,e,r,n,i){Qf(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function Df(t,e,r,n,i){Qf(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}G.prototype.writeBigUInt64LE=rn(function(e,r=0){return Wf(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeBigUInt64BE=rn(function(e,r=0){return Df(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);jt(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};G.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);jt(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};G.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};G.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};G.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};G.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};G.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};G.prototype.writeBigInt64LE=rn(function(e,r=0){return Wf(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});G.prototype.writeBigInt64BE=rn(function(e,r=0){return Df(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Zf(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Xf(t,e,r,n,i){return e=+e,r=r>>>0,i||Zf(t,e,r,4,34028234663852886e22,-34028234663852886e22),si.write(t,e,r,n,23,4),r+4}G.prototype.writeFloatLE=function(e,r,n){return Xf(this,e,r,!0,n)};G.prototype.writeFloatBE=function(e,r,n){return Xf(this,e,r,!1,n)};function Jf(t,e,r,n,i){return e=+e,r=r>>>0,i||Zf(t,e,r,8,17976931348623157e292,-17976931348623157e292),si.write(t,e,r,n,52,8),r+8}G.prototype.writeDoubleLE=function(e,r,n){return Jf(this,e,r,!0,n)};G.prototype.writeDoubleBE=function(e,r,n){return Jf(this,e,r,!1,n)};G.prototype.copy=function(e,r,n,i){if(!G.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};G.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!G.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=G.isBuffer(e)?e:G.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var ii={};function xc(t,e,r){ii[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}xc("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);xc("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);xc("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Vf(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Vf(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Vf(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function pm(t,e,r){oi(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Gi(e,t.length-(r+1))}function Qf(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new ii.ERR_OUT_OF_RANGE("value",a,t)}pm(n,i,s)}function oi(t,e){if(typeof t!="number")throw new ii.ERR_INVALID_ARG_TYPE(e,"number",t)}function Gi(t,e,r){throw Math.floor(t)!==t?(oi(t,r),new ii.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ii.ERR_BUFFER_OUT_OF_BOUNDS:new ii.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var ym=/[^+/0-9A-Za-z-_]/g;function gm(t){if(t=t.split("=")[0],t=t.trim().replace(ym,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function _c(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function mm(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function bm(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function Lf(t){return gc.toByteArray(gm(t))}function eo(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function vr(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function vc(t){return t!==t}var _m=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function rn(t){return typeof BigInt>"u"?wm:t}function wm(){throw new Error("BigInt not supported")}});var Tc=L(Yi=>{"use strict";Object.defineProperty(Yi,"__esModule",{value:!0});Yi.ReplicaRejectCode=void 0;var Em;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(Em=Yi.ReplicaRejectCode||(Yi.ReplicaRejectCode={}))});var td=L(ui=>{"use strict";Object.defineProperty(ui,"__esModule",{value:!0});ui.decode=ui.encode=void 0;var to="abcdefghijklmnopqrstuvwxyz234567",ci=Object.create(null);for(let t=0;t<to.length;t++)ci[to[t]]=t;ci[0]=ci.o;ci[1]=ci.i;function xm(t){let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=to[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?to[r>>3]:"")}ui.encode=xm;function vm(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=ci[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}ui.decode=vm});var rd=L(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.getCrc32=void 0;var Tm=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 Am(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=Tm[s]^r>>>8}return(r^-1)>>>0}ro.getCrc32=Am});var Sc=L(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.isBytes=id;Tr.number=no;Tr.bool=nd;Tr.bytes=Ac;Tr.hash=sd;Tr.exists=od;Tr.output=ad;function no(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function nd(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function id(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ac(t,...e){if(!id(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function sd(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");no(t.outputLen),no(t.blockLen)}function od(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ad(t,e){Ac(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Sm={number:no,bool:nd,bytes:Ac,hash:sd,exists:od,output:ad};Tr.default=Sm});var cd=L(io=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});io.crypto=void 0;var nn=ni("node:crypto");io.crypto=nn&&typeof nn=="object"&&"webcrypto"in nn?nn.webcrypto:nn&&typeof nn=="object"&&"randomBytes"in nn?nn:void 0});var qn=L(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.Hash=we.nextTick=we.byteSwapIfBE=we.byteSwap=we.isLE=we.rotl=we.rotr=we.createView=we.u32=we.u8=void 0;we.isBytes=Bm;we.byteSwap32=Fm;we.bytesToHex=Cm;we.hexToBytes=qm;we.asyncLoop=km;we.utf8ToBytes=ld;we.toBytes=so;we.concatBytes=Hm;we.checkOpts=$m;we.wrapConstructor=Km;we.wrapConstructorWithOpts=Gm;we.wrapXOFConstructorWithOpts=Ym;we.randomBytes=zm;var li=cd(),Oc=Sc();function Bm(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Om=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);we.u8=Om;var Nm=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));we.u32=Nm;var Rm=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);we.createView=Rm;var Pm=(t,e)=>t<<32-e|t>>>e;we.rotr=Pm;var Im=(t,e)=>t<<e|t>>>32-e>>>0;we.rotl=Im;we.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Um=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;we.byteSwap=Um;we.byteSwapIfBE=we.isLE?t=>t:t=>(0,we.byteSwap)(t);function Fm(t){for(let e=0;e<t.length;e++)t[e]=(0,we.byteSwap)(t[e])}var Mm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Cm(t){(0,Oc.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=Mm[t[r]];return e}var Yr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function ud(t){if(t>=Yr._0&&t<=Yr._9)return t-Yr._0;if(t>=Yr._A&&t<=Yr._F)return t-(Yr._A-10);if(t>=Yr._a&&t<=Yr._f)return t-(Yr._a-10)}function qm(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=ud(t.charCodeAt(s)),a=ud(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}var jm=async()=>{};we.nextTick=jm;async function km(t,e,r){let n=Date.now();for(let i=0;i<t;i++){r(i);let s=Date.now()-n;s>=0&&s<e||(await(0,we.nextTick)(),n+=s)}}function ld(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function so(t){return typeof t=="string"&&(t=ld(t)),(0,Oc.bytes)(t),t}function Hm(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,Oc.bytes)(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}var Bc=class{clone(){return this._cloneInto()}};we.Hash=Bc;var Vm={}.toString;function $m(t,e){if(e!==void 0&&Vm.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function Km(t){let e=n=>t().update(so(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Gm(t){let e=(n,i)=>t(i).update(so(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function Ym(t){let e=(n,i)=>t(i).update(so(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function zm(t=32){if(li.crypto&&typeof li.crypto.getRandomValues=="function")return li.crypto.getRandomValues(new Uint8Array(t));if(li.crypto&&typeof li.crypto.randomBytes=="function")return li.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}});var Pc=L(sn=>{"use strict";Object.defineProperty(sn,"__esModule",{value:!0});sn.HashMD=sn.Maj=sn.Chi=void 0;var Nc=Sc(),zi=qn();function Wm(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,f=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+f,a,n)}var Dm=(t,e,r)=>t&e^~t&r;sn.Chi=Dm;var Zm=(t,e,r)=>t&e^t&r^e&r;sn.Maj=Zm;var Rc=class extends zi.Hash{constructor(e,r,n,i){super(),this.blockLen=e,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(e),this.view=(0,zi.createView)(this.buffer)}update(e){(0,Nc.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,zi.toBytes)(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=(0,zi.createView)(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,Nc.exists)(this),(0,Nc.output)(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let h=o;h<i;h++)r[h]=0;Wm(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,zi.createView)(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,d=this.get();if(f>d.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)a.setUint32(4*h,d[h],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};sn.HashMD=Rc});var oo=L(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.sha224=cn.sha256=cn.SHA256=void 0;var Ic=Pc(),tr=qn(),Xm=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]),on=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),an=new Uint32Array(64),Wi=class extends Ic.HashMD{constructor(){super(64,32,8,!1),this.A=on[0]|0,this.B=on[1]|0,this.C=on[2]|0,this.D=on[3]|0,this.E=on[4]|0,this.F=on[5]|0,this.G=on[6]|0,this.H=on[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let h=0;h<16;h++,r+=4)an[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){let m=an[h-15],_=an[h-2],u=(0,tr.rotr)(m,7)^(0,tr.rotr)(m,18)^m>>>3,T=(0,tr.rotr)(_,17)^(0,tr.rotr)(_,19)^_>>>10;an[h]=T+an[h-7]+u+an[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:f,H:d}=this;for(let h=0;h<64;h++){let m=(0,tr.rotr)(a,6)^(0,tr.rotr)(a,11)^(0,tr.rotr)(a,25),_=d+m+(0,Ic.Chi)(a,c,f)+Xm[h]+an[h]|0,T=((0,tr.rotr)(n,2)^(0,tr.rotr)(n,13)^(0,tr.rotr)(n,22))+(0,Ic.Maj)(n,i,s)|0;d=f,f=c,c=a,a=o+_|0,o=s,s=i,i=n,n=_+T|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(n,i,s,o,a,c,f,d)}roundClean(){an.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};cn.SHA256=Wi;var Uc=class extends Wi{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}};cn.sha256=(0,tr.wrapConstructor)(()=>new Wi);cn.sha224=(0,tr.wrapConstructor)(()=>new Uc)});var fd=L(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.sha224=void 0;var Jm=oo();function Qm(t){return Jm.sha224.create().update(new Uint8Array(t)).digest()}ao.sha224=Qm});var Nt=L(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.Principal=Ar.JSON_KEY_PRINCIPAL=void 0;var dd=td(),Lm=rd(),eb=fd();Ar.JSON_KEY_PRINCIPAL="__principal__";var tb=2,hd=4,rb="aaaaa-aa",nb=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},ib=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),Fc=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([hd]))}static managementCanister(){return this.fromHex(rb)}static selfAuthenticating(e){let r=(0,eb.sha224)(e);return new this(new Uint8Array([...r,tb]))}static from(e){if(typeof e=="string")return t.fromText(e);if(Object.getPrototypeOf(e)===Uint8Array.prototype)return new t(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new t(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(nb(e))}static fromText(e){let r=e;if(e.includes(Ar.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);Ar.JSON_KEY_PRINCIPAL in o&&(r=o[Ar.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,dd.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(e){return new this(e)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===hd}toUint8Array(){return this._arr}toHex(){return ib(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,Lm.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=(0,dd.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[Ar.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(e){for(let r=0;r<Math.min(this._arr.length,e._arr.length);r++){if(this._arr[r]<e._arr[r])return"lt";if(this._arr[r]>e._arr[r])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let r=this.compareTo(e);return r=="lt"||r=="eq"}gtEq(e){let r=this.compareTo(e);return r=="gt"||r=="eq"}};Ar.Principal=Fc});var kt=L(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 sb(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e.buffer}vt.concat=sb;function ob(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}vt.toHex=ob;var ab=new RegExp(/^[0-9a-fA-F]+$/);function cb(t){if(!ab.test(t))throw new Error("Invalid hexadecimal string.");let e=[...t].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(e).buffer}vt.fromHex=cb;function pd(t,e){if(t.byteLength!==e.byteLength)return t.byteLength-e.byteLength;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}vt.compare=pd;function ub(t,e){return pd(t,e)===0}vt.bufEquals=ub;function co(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}vt.uint8ToBuf=co;function yd(t){return t instanceof Uint8Array?co(t):t instanceof ArrayBuffer?t:Array.isArray(t)?co(new Uint8Array(t)):"buffer"in t?yd(t.buffer):co(new Uint8Array(t))}vt.bufFromBufLike=yd});var fi=L(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.UpdateCallRejectedError=Sr.QueryCallRejectedError=Sr.ActorCallError=Sr.AgentError=void 0;var qc=Nt(),lb=Tc(),fb=kt(),uo=class t extends Error{constructor(e){super(e),this.message=e,this.name="AgentError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Sr.AgentError=uo;var Di=class t extends uo{constructor(e,r,n,i){let s=qc.Principal.from(e);super(["Call failed:",` Canister: ${s.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(o=>` "${o}": ${JSON.stringify(i[o])}`)].join(`
|
|
4
|
-
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i,this.name="ActorCallError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Sr.ActorCallError=Di;var Mc=class t extends Di{constructor(e,r,n){var i;let s=qc.Principal.from(e);super(s,r,"query",{Status:n.status,Code:(i=lb.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__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Sr.QueryCallRejectedError=Mc;var Cc=class t extends Di{constructor(e,r,n,i){let s=qc.Principal.from(e);super(s,r,"update",Object.assign({"Request ID":(0,fb.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__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Sr.UpdateCallRejectedError=Cc});var ho=L(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.bufFromBufLike=Ht.uint8ToBuf=Ht.PipeArrayBuffer=Ht.fromHexString=Ht.toHexString=Ht.concat=void 0;function db(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e}Ht.concat=db;function hb(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}Ht.toHexString=hb;function pb(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}Ht.fromHexString=pb;var jc=class{constructor(e,r=e?.byteLength||0){this._buffer=fo(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return fo(this._view.slice())}get byteLength(){return this._view.byteLength}read(e){let r=this._view.subarray(0,e);return this._view=this._view.subarray(e),r.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let r=new Uint8Array(e),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(e){let r=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+e);n.set(this._view),this._buffer=r,this._view=n}};Ht.PipeArrayBuffer=jc;function lo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}Ht.uint8ToBuf=lo;function fo(t){return t instanceof Uint8Array?lo(t):t instanceof ArrayBuffer?t:Array.isArray(t)?lo(new Uint8Array(t)):"buffer"in t?fo(t.buffer):lo(new Uint8Array(t))}Ht.bufFromBufLike=fo});var kc=L(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.idlLabelToId=void 0;function yb(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function gb(t){if(/^_\d+_$/.test(t)||/^_0x[0-9a-fA-F]+_$/.test(t)){let e=+t.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return yb(t)}po.idlLabelToId=gb});var Vc=L(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.readIntLE=Je.readUIntLE=Je.writeIntLE=Je.writeUIntLE=Je.slebDecode=Je.slebEncode=Je.lebDecode=Je.lebEncode=Je.safeReadUint8=Je.safeRead=void 0;var Hc=ho();function gd(){throw new Error("unexpected end of buffer")}function md(t,e){return t.byteLength<e&&gd(),t.read(e)}Je.safeRead=md;function yo(t){let e=t.readUint8();return e===void 0&&gd(),e}Je.safeReadUint8=yo;function mb(t){if(typeof t=="number"&&(t=BigInt(t)),t<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,r=new Hc.PipeArrayBuffer(new ArrayBuffer(e),0);for(;;){let n=Number(t&BigInt(127));if(t/=BigInt(128),t===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}Je.lebEncode=mb;function bd(t){let e=BigInt(1),r=BigInt(0),n;do n=yo(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}Je.lebDecode=bd;function bb(t){typeof t=="number"&&(t=BigInt(t));let e=t<BigInt(0);e&&(t=-t-BigInt(1));let r=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,n=new Hc.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let s=i(t);if(t/=BigInt(128),e&&t===BigInt(0)&&s&64||!e&&t===BigInt(0)&&!(s&64)){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}Je.slebEncode=bb;function _b(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return bd(t);break}let n=new Uint8Array(md(t,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)}Je.slebDecode=_b;function wb(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return _d(t,e)}Je.writeUIntLE=wb;function _d(t,e){t=BigInt(t);let r=new Hc.PipeArrayBuffer(new ArrayBuffer(Math.min(1,e)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(t%i);for(r.write(new Uint8Array([o]));++n<e;)t<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((t/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}Je.writeIntLE=_d;function wd(t,e){let r=BigInt(yo(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(yo(t));r=r+n*s}return r}Je.readUIntLE=wd;function Eb(t,e){let r=wd(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Je.readIntLE=Eb});var Ed=L(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0});di.iexp2=di.ilog2=void 0;function xb(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}di.ilog2=xb;function vb(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}di.iexp2=vb});var zc=L(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.Variant=Y.Record=Y.Opt=Y.Vec=Y.Tuple=Y.Principal=Y.Nat64=Y.Nat32=Y.Nat16=Y.Nat8=Y.Int64=Y.Int32=Y.Int16=Y.Int8=Y.Float64=Y.Float32=Y.Nat=Y.Int=Y.Text=Y.Null=Y.Bool=Y.Unknown=Y.Reserved=Y.Empty=Y.decode=Y.encode=Y.ServiceClass=Y.FuncClass=Y.PrincipalClass=Y.RecClass=Y.VariantClass=Y.TupleClass=Y.RecordClass=Y.OptClass=Y.VecClass=Y.FixedNatClass=Y.FixedIntClass=Y.FloatClass=Y.NatClass=Y.IntClass=Y.TextClass=Y.ReservedClass=Y.NullClass=Y.BoolClass=Y.UnknownClass=Y.EmptyClass=Y.ConstructType=Y.PrimitiveType=Y.Type=Y.Visitor=void 0;Y.Service=Y.Func=Y.Rec=void 0;var Tb=Nt(),Ne=ho(),Br=kc(),se=Vc(),$c=Ed(),go="DIDL",xd=400;function Zi(t,e,r){return t.map((n,i)=>r(n,e[i]))}var Kc=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,r){let n=this._typs.length;this._idx.set(e.name,n),this._typs.push(r)}merge(e,r){let n=this._idx.get(e.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+e);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 e=(0,se.lebEncode)(this._typs.length),r=(0,Ne.concat)(...this._typs);return(0,Ne.concat)(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return(0,se.slebEncode)(this._idx.get(e)||0)}},Gc=class{visitType(e,r){throw new Error("Not implemented")}visitPrimitive(e,r){return this.visitType(e,r)}visitEmpty(e,r){return this.visitPrimitive(e,r)}visitBool(e,r){return this.visitPrimitive(e,r)}visitNull(e,r){return this.visitPrimitive(e,r)}visitReserved(e,r){return this.visitPrimitive(e,r)}visitText(e,r){return this.visitPrimitive(e,r)}visitNumber(e,r){return this.visitPrimitive(e,r)}visitInt(e,r){return this.visitNumber(e,r)}visitNat(e,r){return this.visitNumber(e,r)}visitFloat(e,r){return this.visitPrimitive(e,r)}visitFixedInt(e,r){return this.visitNumber(e,r)}visitFixedNat(e,r){return this.visitNumber(e,r)}visitPrincipal(e,r){return this.visitPrimitive(e,r)}visitConstruct(e,r){return this.visitType(e,r)}visitVec(e,r,n){return this.visitConstruct(e,n)}visitOpt(e,r,n){return this.visitConstruct(e,n)}visitRecord(e,r,n){return this.visitConstruct(e,n)}visitTuple(e,r,n){let i=r.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(e,i,n)}visitVariant(e,r,n){return this.visitConstruct(e,n)}visitRec(e,r,n){return this.visitConstruct(r,n)}visitFunc(e,r){return this.visitConstruct(e,r)}visitService(e,r){return this.visitConstruct(e,r)}};Y.Visitor=Gc;var hi=class{display(){return this.name}valueToString(e){return tt(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};Y.Type=hi;var Vt=class extends hi{checkType(e){if(this.name!==e.name)throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);return e}_buildTypeTableImpl(e){}};Y.PrimitiveType=Vt;var Nr=class extends hi{checkType(e){if(e instanceof un){let r=e.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}};Y.ConstructType=Nr;var mo=class extends Vt{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,se.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};Y.EmptyClass=mo;var bo=class extends hi{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,r){throw e.visitType(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}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(e,r){let n=r.decodeValue(e,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof un?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"}};Y.UnknownClass=bo;var _o=class extends Vt{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return(0,se.slebEncode)(-2)}decodeValue(e,r){switch(this.checkType(r),(0,se.safeReadUint8)(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};Y.BoolClass=_o;var wo=class extends Vt{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,se.slebEncode)(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}};Y.NullClass=wo;var pi=class extends Vt{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,se.slebEncode)(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}};Y.ReservedClass=pi;var Eo=class extends Vt{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=(0,se.lebEncode)(r.byteLength);return(0,Ne.concat)(n,r)}encodeType(){return(0,se.slebEncode)(-15)}decodeValue(e,r){this.checkType(r);let n=(0,se.lebDecode)(e),i=(0,se.safeRead)(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}};Y.TextClass=Eo;var xo=class extends Vt{accept(e,r){return e.visitInt(this,r)}covariant(e){if(typeof e=="bigint"||Number.isInteger(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.slebEncode)(e)}encodeType(){return(0,se.slebEncode)(-4)}decodeValue(e,r){return this.checkType(r),(0,se.slebDecode)(e)}get name(){return"int"}valueToString(e){return e.toString()}};Y.IntClass=xo;var vo=class extends Vt{accept(e,r){return e.visitNat(this,r)}covariant(e){if(typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.lebEncode)(e)}encodeType(){return(0,se.slebEncode)(-3)}decodeValue(e,r){return this.checkType(r),(0,se.lebDecode)(e)}get name(){return"nat"}valueToString(e){return e.toString()}};Y.NatClass=vo;var Xi=class extends Vt{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,r){return e.visitFloat(this,r)}covariant(e){if(typeof e=="number"||e instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,e,!0):n.setFloat64(0,e,!0),r}encodeType(){let e=this._bits===32?-13:-14;return(0,se.slebEncode)(e)}decodeValue(e,r){this.checkType(r);let n=(0,se.safeRead)(e,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(e){return e.toString()}};Y.FloatClass=Xi;var zr=class extends Vt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,$c.iexp2)(this._bits-1)*BigInt(-1),n=(0,$c.iexp2)(this._bits-1)-BigInt(1),i=!1;if(typeof e=="bigint")i=e>=r&&e<=n;else if(Number.isInteger(e)){let s=BigInt(e);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.writeIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,se.slebEncode)(-9-e)}decodeValue(e,r){this.checkType(r);let n=(0,se.readIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}};Y.FixedIntClass=zr;var Or=class extends Vt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,$c.iexp2)(this._bits),n=!1;if(typeof e=="bigint"&&e>=BigInt(0)?n=e<r:Number.isInteger(e)&&e>=0?n=BigInt(e)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.writeUIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,se.slebEncode)(-5-e)}decodeValue(e,r){this.checkType(r);let n=(0,se.readUIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};Y.FixedNatClass=Or;var To=class t extends Nr{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Or&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof Or?this._type._bits:this._type instanceof zr?this._type._bits:0;if(ArrayBuffer.isView(e)&&r==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
|
|
3
|
+
var jg=Object.create;var Js=Object.defineProperty;var kg=Object.getOwnPropertyDescriptor;var Hg=Object.getOwnPropertyNames;var Vg=Object.getPrototypeOf,$g=Object.prototype.hasOwnProperty;var ni=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Mf=(t,e)=>()=>(t&&(e=t(t=0)),e);var L=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Kg=(t,e)=>{for(var r in e)Js(t,r,{get:e[r],enumerable:!0})},Cf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Hg(e))!$g.call(t,i)&&i!==r&&Js(t,i,{get:()=>e[i],enumerable:!(n=kg(e,i))||n.enumerable});return t};var Ze=(t,e,r)=>(r=t!=null?jg(Vg(t)):{},Cf(e||!t||!t.__esModule?Js(r,"default",{value:t,enumerable:!0}):r,t)),Gg=t=>Cf(Js({},"__esModule",{value:!0}),t);var kf=L(Qs=>{"use strict";Qs.byteLength=zg;Qs.toByteArray=Dg;Qs.fromByteArray=Jg;var xr=[],er=[],Yg=typeof Uint8Array<"u"?Uint8Array:Array,yc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Mn=0,qf=yc.length;Mn<qf;++Mn)xr[Mn]=yc[Mn],er[yc.charCodeAt(Mn)]=Mn;var Mn,qf;er[45]=62;er[95]=63;function jf(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function zg(t){var e=jf(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Wg(t,e,r){return(e+r)*3/4-r}function Dg(t){var e,r=jf(t),n=r[0],i=r[1],s=new Yg(Wg(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=er[t.charCodeAt(c)]<<18|er[t.charCodeAt(c+1)]<<12|er[t.charCodeAt(c+2)]<<6|er[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=er[t.charCodeAt(c)]<<2|er[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=er[t.charCodeAt(c)]<<10|er[t.charCodeAt(c+1)]<<4|er[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Zg(t){return xr[t>>18&63]+xr[t>>12&63]+xr[t>>6&63]+xr[t&63]}function Xg(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(Zg(n));return i.join("")}function Jg(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(Xg(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(xr[e>>2]+xr[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(xr[e>>10]+xr[e>>4&63]+xr[e<<2&63]+"=")),i.join("")}});var mc=L(gc=>{gc.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,f=c>>1,d=-7,h=r?i-1:0,m=r?-1:1,_=t[e+h];for(h+=m,s=_&(1<<-d)-1,_>>=-d,d+=a;d>0;s=s*256+t[e+h],h+=m,d-=8);for(o=s&(1<<-d)-1,s>>=-d,d+=n;d>0;o=o*256+t[e+h],h+=m,d-=8);if(s===0)s=1-f;else{if(s===c)return o?NaN:(_?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-f}return(_?-1:1)*o*Math.pow(2,s-n)};gc.write=function(t,e,r,n,i,s){var o,a,c,f=s*8-i-1,d=(1<<f)-1,h=d>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=n?0:s-1,u=n?1:-1,T=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=d):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?e+=m/c:e+=m*Math.pow(2,1-h),e*c>=2&&(o++,c/=2),o+h>=d?(a=0,o=d):o+h>=1?(a=(e*c-1)*Math.pow(2,i),o=o+h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+_]=a&255,_+=u,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;t[r+_]=o&255,_+=u,o/=256,f-=8);t[r+_-u]|=T*128}});var rd=L(ai=>{"use strict";var bc=kf(),si=mc(),Hf=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ai.Buffer=G;ai.SlowBuffer=nm;ai.INSPECT_MAX_BYTES=50;var Ls=2147483647;ai.kMaxLength=Ls;G.TYPED_ARRAY_SUPPORT=Qg();!G.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Qg(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(G.prototype,"parent",{enumerable:!0,get:function(){if(G.isBuffer(this))return this.buffer}});Object.defineProperty(G.prototype,"offset",{enumerable:!0,get:function(){if(G.isBuffer(this))return this.byteOffset}});function Yr(t){if(t>Ls)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,G.prototype),e}function G(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return xc(t)}return Gf(t,e,r)}G.poolSize=8192;function Gf(t,e,r){if(typeof t=="string")return em(t,e);if(ArrayBuffer.isView(t))return tm(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(vr(t,ArrayBuffer)||t&&vr(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(vr(t,SharedArrayBuffer)||t&&vr(t.buffer,SharedArrayBuffer)))return wc(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return G.from(n,e,r);let i=rm(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return G.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}G.from=function(t,e,r){return Gf(t,e,r)};Object.setPrototypeOf(G.prototype,Uint8Array.prototype);Object.setPrototypeOf(G,Uint8Array);function Yf(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function Lg(t,e,r){return Yf(t),t<=0?Yr(t):e!==void 0?typeof r=="string"?Yr(t).fill(e,r):Yr(t).fill(e):Yr(t)}G.alloc=function(t,e,r){return Lg(t,e,r)};function xc(t){return Yf(t),Yr(t<0?0:vc(t)|0)}G.allocUnsafe=function(t){return xc(t)};G.allocUnsafeSlow=function(t){return xc(t)};function em(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!G.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=zf(t,e)|0,n=Yr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function _c(t){let e=t.length<0?0:vc(t.length)|0,r=Yr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function tm(t){if(vr(t,Uint8Array)){let e=new Uint8Array(t);return wc(e.buffer,e.byteOffset,e.byteLength)}return _c(t)}function wc(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,G.prototype),n}function rm(t){if(G.isBuffer(t)){let e=vc(t.length)|0,r=Yr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Ac(t.length)?Yr(0):_c(t);if(t.type==="Buffer"&&Array.isArray(t.data))return _c(t.data)}function vc(t){if(t>=Ls)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ls.toString(16)+" bytes");return t|0}function nm(t){return+t!=t&&(t=0),G.alloc(+t)}G.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==G.prototype};G.compare=function(e,r){if(vr(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),vr(r,Uint8Array)&&(r=G.from(r,r.offset,r.byteLength)),!G.isBuffer(e)||!G.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};G.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};G.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return G.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=G.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(vr(o,Uint8Array))s+o.length>i.length?(G.isBuffer(o)||(o=G.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(G.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function zf(t,e){if(G.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||vr(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Ec(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return td(t).length;default:if(i)return n?-1:Ec(t).length;e=(""+e).toLowerCase(),i=!0}}G.byteLength=zf;function im(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return pm(this,e,r);case"utf8":case"utf-8":return Df(this,e,r);case"ascii":return dm(this,e,r);case"latin1":case"binary":return hm(this,e,r);case"base64":return lm(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ym(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}G.prototype._isBuffer=!0;function Cn(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}G.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)Cn(this,r,r+1);return this};G.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)Cn(this,r,r+3),Cn(this,r+1,r+2);return this};G.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)Cn(this,r,r+7),Cn(this,r+1,r+6),Cn(this,r+2,r+5),Cn(this,r+3,r+4);return this};G.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Df(this,0,e):im.apply(this,arguments)};G.prototype.toLocaleString=G.prototype.toString;G.prototype.equals=function(e){if(!G.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:G.compare(this,e)===0};G.prototype.inspect=function(){let e="",r=ai.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Hf&&(G.prototype[Hf]=G.prototype.inspect);G.prototype.compare=function(e,r,n,i,s){if(vr(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),!G.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.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===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),f=this.slice(i,s),d=e.slice(r,n);for(let h=0;h<c;++h)if(f[h]!==d[h]){o=f[h],a=d[h];break}return o<a?-1:a<o?1:0};function Wf(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Ac(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=G.from(e,n)),G.isBuffer(e))return e.length===0?-1:Vf(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Vf(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Vf(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(d,h){return s===1?d[h]:d.readUInt16BE(h*s)}let f;if(i){let d=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,d===-1?0:f-d)){if(d===-1&&(d=f),f-d+1===a)return d*s}else d!==-1&&(f-=f-d),d=-1}else for(r+a>o&&(r=o-a),f=r;f>=0;f--){let d=!0;for(let h=0;h<a;h++)if(c(t,f+h)!==c(e,h)){d=!1;break}if(d)return f}return-1}G.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};G.prototype.indexOf=function(e,r,n){return Wf(this,e,r,n,!0)};G.prototype.lastIndexOf=function(e,r,n){return Wf(this,e,r,n,!1)};function sm(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(Ac(a))return o;t[r+o]=a}return o}function om(t,e,r,n){return eo(Ec(e,t.length-r),t,r,n)}function am(t,e,r,n){return eo(_m(e),t,r,n)}function cm(t,e,r,n){return eo(td(e),t,r,n)}function um(t,e,r,n){return eo(wm(e,t.length-r),t,r,n)}G.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return sm(this,e,r,n);case"utf8":case"utf-8":return om(this,e,r,n);case"ascii":case"latin1":case"binary":return am(this,e,r,n);case"base64":return cm(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return um(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};G.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function lm(t,e,r){return e===0&&r===t.length?bc.fromByteArray(t):bc.fromByteArray(t.slice(e,r))}function Df(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,f,d,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(h=(s&15)<<12|(c&63)<<6|f&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=t[i+1],f=t[i+2],d=t[i+3],(c&192)===128&&(f&192)===128&&(d&192)===128&&(h=(s&15)<<18|(c&63)<<12|(f&63)<<6|d&63,h>65535&&h<1114112&&(o=h))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return fm(n)}var $f=4096;function fm(t){let e=t.length;if(e<=$f)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=$f));return r}function dm(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function hm(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function pm(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=Em[t[s]];return i}function ym(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}G.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,G.prototype),i};function ft(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}G.prototype.readUintLE=G.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};G.prototype.readUintBE=G.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};G.prototype.readUint8=G.prototype.readUInt8=function(e,r){return e=e>>>0,r||ft(e,1,this.length),this[e]};G.prototype.readUint16LE=G.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||ft(e,2,this.length),this[e]|this[e+1]<<8};G.prototype.readUint16BE=G.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||ft(e,2,this.length),this[e]<<8|this[e+1]};G.prototype.readUint32LE=G.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};G.prototype.readUint32BE=G.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};G.prototype.readBigUInt64LE=rn(function(e){e=e>>>0,oi(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Gi(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});G.prototype.readBigUInt64BE=rn(function(e){e=e>>>0,oi(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Gi(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});G.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};G.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};G.prototype.readInt8=function(e,r){return e=e>>>0,r||ft(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};G.prototype.readInt16LE=function(e,r){e=e>>>0,r||ft(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};G.prototype.readInt16BE=function(e,r){e=e>>>0,r||ft(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};G.prototype.readInt32LE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};G.prototype.readInt32BE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};G.prototype.readBigInt64LE=rn(function(e){e=e>>>0,oi(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Gi(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});G.prototype.readBigInt64BE=rn(function(e){e=e>>>0,oi(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Gi(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});G.prototype.readFloatLE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),si.read(this,e,!0,23,4)};G.prototype.readFloatBE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),si.read(this,e,!1,23,4)};G.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||ft(e,8,this.length),si.read(this,e,!0,52,8)};G.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||ft(e,8,this.length),si.read(this,e,!1,52,8)};function jt(t,e,r,n,i,s){if(!G.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}G.prototype.writeUintLE=G.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;jt(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};G.prototype.writeUintBE=G.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;jt(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};G.prototype.writeUint8=G.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,1,255,0),this[r]=e&255,r+1};G.prototype.writeUint16LE=G.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};G.prototype.writeUint16BE=G.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};G.prototype.writeUint32LE=G.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};G.prototype.writeUint32BE=G.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Zf(t,e,r,n,i){ed(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function Xf(t,e,r,n,i){ed(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}G.prototype.writeBigUInt64LE=rn(function(e,r=0){return Zf(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeBigUInt64BE=rn(function(e,r=0){return Xf(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);jt(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};G.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);jt(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};G.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};G.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};G.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};G.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};G.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};G.prototype.writeBigInt64LE=rn(function(e,r=0){return Zf(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});G.prototype.writeBigInt64BE=rn(function(e,r=0){return Xf(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Jf(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Qf(t,e,r,n,i){return e=+e,r=r>>>0,i||Jf(t,e,r,4,34028234663852886e22,-34028234663852886e22),si.write(t,e,r,n,23,4),r+4}G.prototype.writeFloatLE=function(e,r,n){return Qf(this,e,r,!0,n)};G.prototype.writeFloatBE=function(e,r,n){return Qf(this,e,r,!1,n)};function Lf(t,e,r,n,i){return e=+e,r=r>>>0,i||Jf(t,e,r,8,17976931348623157e292,-17976931348623157e292),si.write(t,e,r,n,52,8),r+8}G.prototype.writeDoubleLE=function(e,r,n){return Lf(this,e,r,!0,n)};G.prototype.writeDoubleBE=function(e,r,n){return Lf(this,e,r,!1,n)};G.prototype.copy=function(e,r,n,i){if(!G.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};G.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!G.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=G.isBuffer(e)?e:G.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var ii={};function Tc(t,e,r){ii[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Tc("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Tc("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Tc("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Kf(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Kf(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Kf(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function gm(t,e,r){oi(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Gi(e,t.length-(r+1))}function ed(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new ii.ERR_OUT_OF_RANGE("value",a,t)}gm(n,i,s)}function oi(t,e){if(typeof t!="number")throw new ii.ERR_INVALID_ARG_TYPE(e,"number",t)}function Gi(t,e,r){throw Math.floor(t)!==t?(oi(t,r),new ii.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ii.ERR_BUFFER_OUT_OF_BOUNDS:new ii.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var mm=/[^+/0-9A-Za-z-_]/g;function bm(t){if(t=t.split("=")[0],t=t.trim().replace(mm,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Ec(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=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 _m(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function wm(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function td(t){return bc.toByteArray(bm(t))}function eo(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function vr(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Ac(t){return t!==t}var Em=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function rn(t){return typeof BigInt>"u"?xm:t}function xm(){throw new Error("BigInt not supported")}});var Sc=L(Yi=>{"use strict";Object.defineProperty(Yi,"__esModule",{value:!0});Yi.ReplicaRejectCode=void 0;var vm;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(vm=Yi.ReplicaRejectCode||(Yi.ReplicaRejectCode={}))});var nd=L(ui=>{"use strict";Object.defineProperty(ui,"__esModule",{value:!0});ui.decode=ui.encode=void 0;var to="abcdefghijklmnopqrstuvwxyz234567",ci=Object.create(null);for(let t=0;t<to.length;t++)ci[to[t]]=t;ci[0]=ci.o;ci[1]=ci.i;function Tm(t){let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=to[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?to[r>>3]:"")}ui.encode=Tm;function Am(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=ci[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}ui.decode=Am});var id=L(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.getCrc32=void 0;var Sm=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 Bm(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=Sm[s]^r>>>8}return(r^-1)>>>0}ro.getCrc32=Bm});var Oc=L(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.isBytes=od;Tr.number=no;Tr.bool=sd;Tr.bytes=Bc;Tr.hash=ad;Tr.exists=cd;Tr.output=ud;function no(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function sd(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function od(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Bc(t,...e){if(!od(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function ad(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");no(t.outputLen),no(t.blockLen)}function cd(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ud(t,e){Bc(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Om={number:no,bool:sd,bytes:Bc,hash:ad,exists:cd,output:ud};Tr.default=Om});var ld=L(io=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});io.crypto=void 0;var nn=ni("node:crypto");io.crypto=nn&&typeof nn=="object"&&"webcrypto"in nn?nn.webcrypto:nn&&typeof nn=="object"&&"randomBytes"in nn?nn:void 0});var qn=L(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.Hash=we.nextTick=we.byteSwapIfBE=we.byteSwap=we.isLE=we.rotl=we.rotr=we.createView=we.u32=we.u8=void 0;we.isBytes=Nm;we.byteSwap32=Cm;we.bytesToHex=jm;we.hexToBytes=km;we.asyncLoop=Vm;we.utf8ToBytes=dd;we.toBytes=so;we.concatBytes=$m;we.checkOpts=Gm;we.wrapConstructor=Ym;we.wrapConstructorWithOpts=zm;we.wrapXOFConstructorWithOpts=Wm;we.randomBytes=Dm;var li=ld(),Rc=Oc();function Nm(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Rm=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);we.u8=Rm;var Pm=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));we.u32=Pm;var Im=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);we.createView=Im;var Um=(t,e)=>t<<32-e|t>>>e;we.rotr=Um;var Fm=(t,e)=>t<<e|t>>>32-e>>>0;we.rotl=Fm;we.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Mm=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;we.byteSwap=Mm;we.byteSwapIfBE=we.isLE?t=>t:t=>(0,we.byteSwap)(t);function Cm(t){for(let e=0;e<t.length;e++)t[e]=(0,we.byteSwap)(t[e])}var qm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function jm(t){(0,Rc.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=qm[t[r]];return e}var zr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function fd(t){if(t>=zr._0&&t<=zr._9)return t-zr._0;if(t>=zr._A&&t<=zr._F)return t-(zr._A-10);if(t>=zr._a&&t<=zr._f)return t-(zr._a-10)}function km(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=fd(t.charCodeAt(s)),a=fd(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}var Hm=async()=>{};we.nextTick=Hm;async function Vm(t,e,r){let n=Date.now();for(let i=0;i<t;i++){r(i);let s=Date.now()-n;s>=0&&s<e||(await(0,we.nextTick)(),n+=s)}}function dd(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function so(t){return typeof t=="string"&&(t=dd(t)),(0,Rc.bytes)(t),t}function $m(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,Rc.bytes)(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}var Nc=class{clone(){return this._cloneInto()}};we.Hash=Nc;var Km={}.toString;function Gm(t,e){if(e!==void 0&&Km.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function Ym(t){let e=n=>t().update(so(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function zm(t){let e=(n,i)=>t(i).update(so(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function Wm(t){let e=(n,i)=>t(i).update(so(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function Dm(t=32){if(li.crypto&&typeof li.crypto.getRandomValues=="function")return li.crypto.getRandomValues(new Uint8Array(t));if(li.crypto&&typeof li.crypto.randomBytes=="function")return li.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}});var Uc=L(sn=>{"use strict";Object.defineProperty(sn,"__esModule",{value:!0});sn.HashMD=sn.Maj=sn.Chi=void 0;var Pc=Oc(),zi=qn();function Zm(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,f=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+f,a,n)}var Xm=(t,e,r)=>t&e^~t&r;sn.Chi=Xm;var Jm=(t,e,r)=>t&e^t&r^e&r;sn.Maj=Jm;var Ic=class extends zi.Hash{constructor(e,r,n,i){super(),this.blockLen=e,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(e),this.view=(0,zi.createView)(this.buffer)}update(e){(0,Pc.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,zi.toBytes)(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=(0,zi.createView)(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,Pc.exists)(this),(0,Pc.output)(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let h=o;h<i;h++)r[h]=0;Zm(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,zi.createView)(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,d=this.get();if(f>d.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)a.setUint32(4*h,d[h],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};sn.HashMD=Ic});var oo=L(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.sha224=cn.sha256=cn.SHA256=void 0;var Fc=Uc(),tr=qn(),Qm=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]),on=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),an=new Uint32Array(64),Wi=class extends Fc.HashMD{constructor(){super(64,32,8,!1),this.A=on[0]|0,this.B=on[1]|0,this.C=on[2]|0,this.D=on[3]|0,this.E=on[4]|0,this.F=on[5]|0,this.G=on[6]|0,this.H=on[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let h=0;h<16;h++,r+=4)an[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){let m=an[h-15],_=an[h-2],u=(0,tr.rotr)(m,7)^(0,tr.rotr)(m,18)^m>>>3,T=(0,tr.rotr)(_,17)^(0,tr.rotr)(_,19)^_>>>10;an[h]=T+an[h-7]+u+an[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:f,H:d}=this;for(let h=0;h<64;h++){let m=(0,tr.rotr)(a,6)^(0,tr.rotr)(a,11)^(0,tr.rotr)(a,25),_=d+m+(0,Fc.Chi)(a,c,f)+Qm[h]+an[h]|0,T=((0,tr.rotr)(n,2)^(0,tr.rotr)(n,13)^(0,tr.rotr)(n,22))+(0,Fc.Maj)(n,i,s)|0;d=f,f=c,c=a,a=o+_|0,o=s,s=i,i=n,n=_+T|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(n,i,s,o,a,c,f,d)}roundClean(){an.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};cn.SHA256=Wi;var Mc=class extends Wi{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}};cn.sha256=(0,tr.wrapConstructor)(()=>new Wi);cn.sha224=(0,tr.wrapConstructor)(()=>new Mc)});var hd=L(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.sha224=void 0;var Lm=oo();function eb(t){return Lm.sha224.create().update(new Uint8Array(t)).digest()}ao.sha224=eb});var Nt=L(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.Principal=Ar.JSON_KEY_PRINCIPAL=void 0;var pd=nd(),tb=id(),rb=hd();Ar.JSON_KEY_PRINCIPAL="__principal__";var nb=2,yd=4,ib="aaaaa-aa",sb=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},ob=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),Cc=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([yd]))}static managementCanister(){return this.fromHex(ib)}static selfAuthenticating(e){let r=(0,rb.sha224)(e);return new this(new Uint8Array([...r,nb]))}static from(e){if(typeof e=="string")return t.fromText(e);if(Object.getPrototypeOf(e)===Uint8Array.prototype)return new t(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new t(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(sb(e))}static fromText(e){let r=e;if(e.includes(Ar.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);Ar.JSON_KEY_PRINCIPAL in o&&(r=o[Ar.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,pd.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(e){return new this(e)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===yd}toUint8Array(){return this._arr}toHex(){return ob(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,tb.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=(0,pd.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[Ar.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(e){for(let r=0;r<Math.min(this._arr.length,e._arr.length);r++){if(this._arr[r]<e._arr[r])return"lt";if(this._arr[r]>e._arr[r])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let r=this.compareTo(e);return r=="lt"||r=="eq"}gtEq(e){let r=this.compareTo(e);return r=="gt"||r=="eq"}};Ar.Principal=Cc});var kt=L(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 ab(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e.buffer}vt.concat=ab;function cb(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}vt.toHex=cb;var ub=new RegExp(/^[0-9a-fA-F]+$/);function lb(t){if(!ub.test(t))throw new Error("Invalid hexadecimal string.");let e=[...t].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(e).buffer}vt.fromHex=lb;function gd(t,e){if(t.byteLength!==e.byteLength)return t.byteLength-e.byteLength;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}vt.compare=gd;function fb(t,e){return gd(t,e)===0}vt.bufEquals=fb;function co(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}vt.uint8ToBuf=co;function md(t){return t instanceof Uint8Array?co(t):t instanceof ArrayBuffer?t:Array.isArray(t)?co(new Uint8Array(t)):"buffer"in t?md(t.buffer):co(new Uint8Array(t))}vt.bufFromBufLike=md});var fi=L(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.UpdateCallRejectedError=Sr.QueryCallRejectedError=Sr.ActorCallError=Sr.AgentError=void 0;var kc=Nt(),db=Sc(),hb=kt(),uo=class t extends Error{constructor(e){super(e),this.message=e,this.name="AgentError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Sr.AgentError=uo;var Di=class t extends uo{constructor(e,r,n,i){let s=kc.Principal.from(e);super(["Call failed:",` Canister: ${s.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(o=>` "${o}": ${JSON.stringify(i[o])}`)].join(`
|
|
4
|
+
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i,this.name="ActorCallError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Sr.ActorCallError=Di;var qc=class t extends Di{constructor(e,r,n){var i;let s=kc.Principal.from(e);super(s,r,"query",{Status:n.status,Code:(i=db.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__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Sr.QueryCallRejectedError=qc;var jc=class t extends Di{constructor(e,r,n,i){let s=kc.Principal.from(e);super(s,r,"update",Object.assign({"Request ID":(0,hb.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__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Sr.UpdateCallRejectedError=jc});var ho=L(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.bufFromBufLike=Ht.uint8ToBuf=Ht.PipeArrayBuffer=Ht.fromHexString=Ht.toHexString=Ht.concat=void 0;function pb(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e}Ht.concat=pb;function yb(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}Ht.toHexString=yb;function gb(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}Ht.fromHexString=gb;var Hc=class{constructor(e,r=e?.byteLength||0){this._buffer=fo(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return fo(this._view.slice())}get byteLength(){return this._view.byteLength}read(e){let r=this._view.subarray(0,e);return this._view=this._view.subarray(e),r.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let r=new Uint8Array(e),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(e){let r=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+e);n.set(this._view),this._buffer=r,this._view=n}};Ht.PipeArrayBuffer=Hc;function lo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}Ht.uint8ToBuf=lo;function fo(t){return t instanceof Uint8Array?lo(t):t instanceof ArrayBuffer?t:Array.isArray(t)?lo(new Uint8Array(t)):"buffer"in t?fo(t.buffer):lo(new Uint8Array(t))}Ht.bufFromBufLike=fo});var Vc=L(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.idlLabelToId=void 0;function mb(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function bb(t){if(/^_\d+_$/.test(t)||/^_0x[0-9a-fA-F]+_$/.test(t)){let e=+t.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return mb(t)}po.idlLabelToId=bb});var Kc=L(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.readIntLE=Je.readUIntLE=Je.writeIntLE=Je.writeUIntLE=Je.slebDecode=Je.slebEncode=Je.lebDecode=Je.lebEncode=Je.safeReadUint8=Je.safeRead=void 0;var $c=ho();function bd(){throw new Error("unexpected end of buffer")}function _d(t,e){return t.byteLength<e&&bd(),t.read(e)}Je.safeRead=_d;function yo(t){let e=t.readUint8();return e===void 0&&bd(),e}Je.safeReadUint8=yo;function _b(t){if(typeof t=="number"&&(t=BigInt(t)),t<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,r=new $c.PipeArrayBuffer(new ArrayBuffer(e),0);for(;;){let n=Number(t&BigInt(127));if(t/=BigInt(128),t===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}Je.lebEncode=_b;function wd(t){let e=BigInt(1),r=BigInt(0),n;do n=yo(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}Je.lebDecode=wd;function wb(t){typeof t=="number"&&(t=BigInt(t));let e=t<BigInt(0);e&&(t=-t-BigInt(1));let r=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,n=new $c.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let s=i(t);if(t/=BigInt(128),e&&t===BigInt(0)&&s&64||!e&&t===BigInt(0)&&!(s&64)){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}Je.slebEncode=wb;function Eb(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return wd(t);break}let n=new Uint8Array(_d(t,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)}Je.slebDecode=Eb;function xb(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return Ed(t,e)}Je.writeUIntLE=xb;function Ed(t,e){t=BigInt(t);let r=new $c.PipeArrayBuffer(new ArrayBuffer(Math.min(1,e)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(t%i);for(r.write(new Uint8Array([o]));++n<e;)t<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((t/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}Je.writeIntLE=Ed;function xd(t,e){let r=BigInt(yo(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(yo(t));r=r+n*s}return r}Je.readUIntLE=xd;function vb(t,e){let r=xd(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Je.readIntLE=vb});var vd=L(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0});di.iexp2=di.ilog2=void 0;function Tb(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}di.ilog2=Tb;function Ab(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}di.iexp2=Ab});var Dc=L(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.Variant=Y.Record=Y.Opt=Y.Vec=Y.Tuple=Y.Principal=Y.Nat64=Y.Nat32=Y.Nat16=Y.Nat8=Y.Int64=Y.Int32=Y.Int16=Y.Int8=Y.Float64=Y.Float32=Y.Nat=Y.Int=Y.Text=Y.Null=Y.Bool=Y.Unknown=Y.Reserved=Y.Empty=Y.decode=Y.encode=Y.ServiceClass=Y.FuncClass=Y.PrincipalClass=Y.RecClass=Y.VariantClass=Y.TupleClass=Y.RecordClass=Y.OptClass=Y.VecClass=Y.FixedNatClass=Y.FixedIntClass=Y.FloatClass=Y.NatClass=Y.IntClass=Y.TextClass=Y.ReservedClass=Y.NullClass=Y.BoolClass=Y.UnknownClass=Y.EmptyClass=Y.ConstructType=Y.PrimitiveType=Y.Type=Y.Visitor=void 0;Y.Service=Y.Func=Y.Rec=void 0;var Sb=Nt(),Ne=ho(),Br=Vc(),se=Kc(),Gc=vd(),go="DIDL",Td=400;function Zi(t,e,r){return t.map((n,i)=>r(n,e[i]))}var Yc=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,r){let n=this._typs.length;this._idx.set(e.name,n),this._typs.push(r)}merge(e,r){let n=this._idx.get(e.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+e);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 e=(0,se.lebEncode)(this._typs.length),r=(0,Ne.concat)(...this._typs);return(0,Ne.concat)(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return(0,se.slebEncode)(this._idx.get(e)||0)}},zc=class{visitType(e,r){throw new Error("Not implemented")}visitPrimitive(e,r){return this.visitType(e,r)}visitEmpty(e,r){return this.visitPrimitive(e,r)}visitBool(e,r){return this.visitPrimitive(e,r)}visitNull(e,r){return this.visitPrimitive(e,r)}visitReserved(e,r){return this.visitPrimitive(e,r)}visitText(e,r){return this.visitPrimitive(e,r)}visitNumber(e,r){return this.visitPrimitive(e,r)}visitInt(e,r){return this.visitNumber(e,r)}visitNat(e,r){return this.visitNumber(e,r)}visitFloat(e,r){return this.visitPrimitive(e,r)}visitFixedInt(e,r){return this.visitNumber(e,r)}visitFixedNat(e,r){return this.visitNumber(e,r)}visitPrincipal(e,r){return this.visitPrimitive(e,r)}visitConstruct(e,r){return this.visitType(e,r)}visitVec(e,r,n){return this.visitConstruct(e,n)}visitOpt(e,r,n){return this.visitConstruct(e,n)}visitRecord(e,r,n){return this.visitConstruct(e,n)}visitTuple(e,r,n){let i=r.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(e,i,n)}visitVariant(e,r,n){return this.visitConstruct(e,n)}visitRec(e,r,n){return this.visitConstruct(r,n)}visitFunc(e,r){return this.visitConstruct(e,r)}visitService(e,r){return this.visitConstruct(e,r)}};Y.Visitor=zc;var hi=class{display(){return this.name}valueToString(e){return tt(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};Y.Type=hi;var Vt=class extends hi{checkType(e){if(this.name!==e.name)throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);return e}_buildTypeTableImpl(e){}};Y.PrimitiveType=Vt;var Nr=class extends hi{checkType(e){if(e instanceof un){let r=e.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}};Y.ConstructType=Nr;var mo=class extends Vt{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,se.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};Y.EmptyClass=mo;var bo=class extends hi{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,r){throw e.visitType(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}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(e,r){let n=r.decodeValue(e,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof un?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"}};Y.UnknownClass=bo;var _o=class extends Vt{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return(0,se.slebEncode)(-2)}decodeValue(e,r){switch(this.checkType(r),(0,se.safeReadUint8)(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};Y.BoolClass=_o;var wo=class extends Vt{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,se.slebEncode)(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}};Y.NullClass=wo;var pi=class extends Vt{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,se.slebEncode)(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}};Y.ReservedClass=pi;var Eo=class extends Vt{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=(0,se.lebEncode)(r.byteLength);return(0,Ne.concat)(n,r)}encodeType(){return(0,se.slebEncode)(-15)}decodeValue(e,r){this.checkType(r);let n=(0,se.lebDecode)(e),i=(0,se.safeRead)(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}};Y.TextClass=Eo;var xo=class extends Vt{accept(e,r){return e.visitInt(this,r)}covariant(e){if(typeof e=="bigint"||Number.isInteger(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.slebEncode)(e)}encodeType(){return(0,se.slebEncode)(-4)}decodeValue(e,r){return this.checkType(r),(0,se.slebDecode)(e)}get name(){return"int"}valueToString(e){return e.toString()}};Y.IntClass=xo;var vo=class extends Vt{accept(e,r){return e.visitNat(this,r)}covariant(e){if(typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.lebEncode)(e)}encodeType(){return(0,se.slebEncode)(-3)}decodeValue(e,r){return this.checkType(r),(0,se.lebDecode)(e)}get name(){return"nat"}valueToString(e){return e.toString()}};Y.NatClass=vo;var Xi=class extends Vt{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,r){return e.visitFloat(this,r)}covariant(e){if(typeof e=="number"||e instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,e,!0):n.setFloat64(0,e,!0),r}encodeType(){let e=this._bits===32?-13:-14;return(0,se.slebEncode)(e)}decodeValue(e,r){this.checkType(r);let n=(0,se.safeRead)(e,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(e){return e.toString()}};Y.FloatClass=Xi;var Wr=class extends Vt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,Gc.iexp2)(this._bits-1)*BigInt(-1),n=(0,Gc.iexp2)(this._bits-1)-BigInt(1),i=!1;if(typeof e=="bigint")i=e>=r&&e<=n;else if(Number.isInteger(e)){let s=BigInt(e);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.writeIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,se.slebEncode)(-9-e)}decodeValue(e,r){this.checkType(r);let n=(0,se.readIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}};Y.FixedIntClass=Wr;var Or=class extends Vt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,Gc.iexp2)(this._bits),n=!1;if(typeof e=="bigint"&&e>=BigInt(0)?n=e<r:Number.isInteger(e)&&e>=0?n=BigInt(e)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.writeUIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,se.slebEncode)(-5-e)}decodeValue(e,r){this.checkType(r);let n=(0,se.readUIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};Y.FixedNatClass=Or;var To=class t extends Nr{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Or&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof Or?this._type._bits:this._type instanceof Wr?this._type._bits:0;if(ArrayBuffer.isView(e)&&r==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
|
|
5
5
|
|
|
6
|
-
index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=(0,se.lebEncode)(e.length);if(this._blobOptimization)return(0,Ne.concat)(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,Ne.concat)(r,new Uint8Array(e.buffer));let n=new Ne.PipeArrayBuffer(new ArrayBuffer(r.byteLength+e.length),0);n.write(r);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,se.slebEncode)(-19),n=this._type.encodeType(e);e.add(this,(0,Ne.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a vector type");let i=Number((0,se.lebDecode)(e));if(this._type instanceof Or){if(this._type._bits==8)return new Uint8Array(e.read(i));if(this._type._bits==16)return new Uint16Array(e.read(i*2));if(this._type._bits==32)return new Uint32Array(e.read(i*4));if(this._type._bits==64)return new BigUint64Array(e.read(i*8))}if(this._type instanceof
|
|
6
|
+
index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=(0,se.lebEncode)(e.length);if(this._blobOptimization)return(0,Ne.concat)(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,Ne.concat)(r,new Uint8Array(e.buffer));let n=new Ne.PipeArrayBuffer(new ArrayBuffer(r.byteLength+e.length),0);n.write(r);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,se.slebEncode)(-19),n=this._type.encodeType(e);e.add(this,(0,Ne.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a vector type");let i=Number((0,se.lebDecode)(e));if(this._type instanceof Or){if(this._type._bits==8)return new Uint8Array(e.read(i));if(this._type._bits==16)return new Uint16Array(e.read(i*2));if(this._type._bits==32)return new Uint32Array(e.read(i*4));if(this._type._bits==64)return new BigUint64Array(e.read(i*8))}if(this._type instanceof Wr){if(this._type._bits==8)return new Int8Array(e.read(i));if(this._type._bits==16)return new Int16Array(e.read(i*2));if(this._type._bits==32)return new Int32Array(e.read(i*4));if(this._type._bits==64)return new BigInt64Array(e.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(e,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(e){return"vec {"+e.map(n=>this._type.valueToString(n)).join("; ")+"}"}};Y.VecClass=To;var yi=class t extends Nr{constructor(e){super(),this._type=e}accept(e,r){return e.visitOpt(this,this._type,r)}covariant(e){try{if(Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}
|
|
7
7
|
|
|
8
8
|
-> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):(0,Ne.concat)(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,se.slebEncode)(-18),n=this._type.encodeType(e);e.add(this,(0,Ne.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch((0,se.safeReadUint8)(e)){case 0:return[];case 1:return[this._type.decodeValue(e,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}};Y.OptClass=yi;var Ji=class t extends Nr{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,Br.idlLabelToId)(r[0])-(0,Br.idlLabelToId)(n[0]))}accept(e,r){return e.visitRecord(this,this._fields,r)}tryAsTuple(){let e=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;e.push(i)}return e}covariant(e){if(typeof e=="object"&&this._fields.every(([r,n])=>{if(!e.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
9
9
|
|
|
@@ -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: ${tt(e)}`)}encodeValue(e){let r=Zi(this._components,e,(n,i)=>n.encodeValue(i));return(0,Ne.concat)(...r)}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,o]of n._components.entries())s>=this._components.length?o.decodeValue(e,o):i.push(this._components[s].decodeValue(e,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(e){return`record {${Zi(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}};Y.TupleClass=Ao;var So=class t extends Nr{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,Br.idlLabelToId)(r[0])-(0,Br.idlLabelToId)(n[0]))}accept(e,r){return e.visitVariant(this,this._fields,r)}covariant(e){if(typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([r,n])=>{try{return!e.hasOwnProperty(r)||n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
13
13
|
|
|
14
|
-
variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(e.hasOwnProperty(n)){let s=(0,se.lebEncode)(r),o=i.encodeValue(e[n]);return(0,Ne.concat)(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=(0,se.slebEncode)(-21),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Ne.concat)((0,se.lebEncode)((0,Br.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Ne.concat)(r,n,...i))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a variant type");let i=Number((0,se.lebDecode)(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[a,c]of this._fields)if((0,Br.idlLabelToId)(s)===(0,Br.idlLabelToId)(a)){let f=c.decodeValue(e,o);return{[a]:f}}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(e){for(let[r,n]of this._fields)if(e.hasOwnProperty(r)){let i=n.valueToString(e[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+e)}};Y.VariantClass=So;var un=class t extends Nr{constructor(){super(...arguments),this._id=t._counter++,this._type=void 0}accept(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,r)}fill(e){this._type=e}getType(){return this._type}covariant(e){if(this._type&&this._type.covariant(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(e)}_buildTypeTableImpl(e){if(!this._type)throw Error("Recursive type uninitialized.");e.add(this,new Uint8Array([])),this._type.buildTypeTable(e),e.merge(this,this._type.name)}decodeValue(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(e)}};Y.RecClass=un;un._counter=0;function
|
|
14
|
+
variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(e.hasOwnProperty(n)){let s=(0,se.lebEncode)(r),o=i.encodeValue(e[n]);return(0,Ne.concat)(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=(0,se.slebEncode)(-21),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Ne.concat)((0,se.lebEncode)((0,Br.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Ne.concat)(r,n,...i))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a variant type");let i=Number((0,se.lebDecode)(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[a,c]of this._fields)if((0,Br.idlLabelToId)(s)===(0,Br.idlLabelToId)(a)){let f=c.decodeValue(e,o);return{[a]:f}}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(e){for(let[r,n]of this._fields)if(e.hasOwnProperty(r)){let i=n.valueToString(e[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+e)}};Y.VariantClass=So;var un=class t extends Nr{constructor(){super(...arguments),this._id=t._counter++,this._type=void 0}accept(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,r)}fill(e){this._type=e}getType(){return this._type}covariant(e){if(this._type&&this._type.covariant(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(e)}_buildTypeTableImpl(e){if(!this._type)throw Error("Recursive type uninitialized.");e.add(this,new Uint8Array([])),this._type.buildTypeTable(e),e.merge(this,this._type.name)}decodeValue(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(e)}};Y.RecClass=un;un._counter=0;function Wc(t){if((0,se.safeReadUint8)(t)!==1)throw new Error("Cannot decode principal");let r=Number((0,se.lebDecode)(t));return Sb.Principal.fromUint8Array(new Uint8Array((0,se.safeRead)(t,r)))}var Bo=class extends Vt{accept(e,r){return e.visitPrincipal(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,se.lebEncode)(r.byteLength);return(0,Ne.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,se.slebEncode)(-24)}decodeValue(e,r){return this.checkType(r),Wc(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}};Y.PrincipalClass=Bo;var Qi=class extends Nr{constructor(e,r,n=[]){super(),this.argTypes=e,this.retTypes=r,this.annotations=n}static argsToString(e,r){if(e.length!==r.length)throw new Error("arity mismatch");return"("+e.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(e,r){return e.visitFunc(this,r)}covariant(e){if(Array.isArray(e)&&e.length===2&&e[0]&&e[0]._isPrincipal&&typeof e[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue([e,r]){let n=e.toUint8Array(),i=(0,se.lebEncode)(n.byteLength),s=(0,Ne.concat)(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=(0,se.lebEncode)(o.byteLength);return(0,Ne.concat)(new Uint8Array([1]),s,a,o)}_buildTypeTableImpl(e){this.argTypes.forEach(f=>f.buildTypeTable(e)),this.retTypes.forEach(f=>f.buildTypeTable(e));let r=(0,se.slebEncode)(-22),n=(0,se.lebEncode)(this.argTypes.length),i=(0,Ne.concat)(...this.argTypes.map(f=>f.encodeType(e))),s=(0,se.lebEncode)(this.retTypes.length),o=(0,Ne.concat)(...this.retTypes.map(f=>f.encodeType(e))),a=(0,se.lebEncode)(this.annotations.length),c=(0,Ne.concat)(...this.annotations.map(f=>this.encodeAnnotation(f)));e.add(this,(0,Ne.concat)(r,n,i,s,o,a,c))}decodeValue(e){if((0,se.safeReadUint8)(e)!==1)throw new Error("Cannot decode function reference");let n=Wc(e),i=Number((0,se.lebDecode)(e)),s=(0,se.safeRead)(e,i),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${r})${n}`}valueToString([e,r]){return`func "${e.toText()}".${r}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${r})${n}`}encodeAnnotation(e){if(e==="query")return new Uint8Array([1]);if(e==="oneway")return new Uint8Array([2]);if(e==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};Y.FuncClass=Qi;var Oo=class extends Nr{constructor(e){super(),this._fields=Object.entries(e).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(e,r){return e.visitService(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,se.lebEncode)(r.length);return(0,Ne.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,se.slebEncode)(-23),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=(0,se.lebEncode)(a.length);return(0,Ne.concat)(c,a,o.encodeType(e))});e.add(this,(0,Ne.concat)(r,n,...i))}decodeValue(e){return Wc(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};Y.ServiceClass=Oo;function tt(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>Td?e.substring(0,Td-3)+"...":e}function Bb(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new Yc;t.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(go),i=r.encode(),s=(0,se.lebEncode)(e.length),o=(0,Ne.concat)(...t.map(c=>c.encodeType(r))),a=(0,Ne.concat)(...Zi(t,e,(c,f)=>{try{c.covariant(f)}catch(d){throw new Error(d.message+`
|
|
15
15
|
|
|
16
|
-
`)}return c.encodeValue(f)}));return(0,Ne.concat)(n,i,s,o,a)}Y.encode=Ab;function Sb(t,e){let r=new Ne.PipeArrayBuffer(e);if(e.byteLength<go.length)throw new Error("Message length smaller than magic number");let n=(0,se.safeRead)(r,go.length),i=new TextDecoder().decode(n);if(i!==go)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(_){let u=[],T=Number((0,se.lebDecode)(_));for(let F=0;F<T;F++){let M=Number((0,se.slebDecode)(_));switch(M){case-18:case-19:{let K=Number((0,se.slebDecode)(_));u.push([M,K]);break}case-20:case-21:{let K=[],x=Number((0,se.lebDecode)(_)),$;for(;x--;){let z=Number((0,se.lebDecode)(_));if(z>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof $=="number"&&$>=z)throw new Error("field id collision or not sorted");$=z;let D=Number((0,se.slebDecode)(_));K.push([z,D])}u.push([M,K]);break}case-22:{let K=[],x=Number((0,se.lebDecode)(_));for(;x--;)K.push(Number((0,se.slebDecode)(_)));let $=[],z=Number((0,se.lebDecode)(_));for(;z--;)$.push(Number((0,se.slebDecode)(_)));let D=[],j=Number((0,se.lebDecode)(_));for(;j--;)switch(Number((0,se.lebDecode)(_))){case 1:{D.push("query");break}case 2:{D.push("oneway");break}case 3:{D.push("composite_query");break}default:throw new Error("unknown annotation")}u.push([M,[K,$,D]]);break}case-23:{let K=Number((0,se.lebDecode)(_)),x=[];for(;K--;){let $=Number((0,se.lebDecode)(_)),z=new TextDecoder().decode((0,se.safeRead)(_,$)),D=(0,se.slebDecode)(_);x.push([z,D])}u.push([M,x]);break}default:throw new Error("Illegal op_code: "+M)}}let O=[],R=Number((0,se.lebDecode)(_));for(let F=0;F<R;F++)O.push(Number((0,se.slebDecode)(_)));return[u,O]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(_=>Od());function f(_){if(_<-24)throw new Error("future value not supported");if(_<0)switch(_){case-1:return Y.Null;case-2:return Y.Bool;case-3:return Y.Nat;case-4:return Y.Int;case-5:return Y.Nat8;case-6:return Y.Nat16;case-7:return Y.Nat32;case-8:return Y.Nat64;case-9:return Y.Int8;case-10:return Y.Int16;case-11:return Y.Int32;case-12:return Y.Int64;case-13:return Y.Float32;case-14:return Y.Float64;case-15:return Y.Text;case-16:return Y.Reserved;case-17:return Y.Empty;case-24:return Y.Principal;default:throw new Error("Illegal op_code: "+_)}if(_>=o.length)throw new Error("type index out of range");return c[_]}function d(_){switch(_[0]){case-19:{let u=f(_[1]);return Td(u)}case-18:{let u=f(_[1]);return Ad(u)}case-20:{let u={};for(let[R,F]of _[1]){let M=`_${R}_`;u[M]=f(F)}let T=Sd(u),O=T.tryAsTuple();return Array.isArray(O)?vd(...O):T}case-21:{let u={};for(let[T,O]of _[1]){let R=`_${T}_`;u[R]=f(O)}return Bd(u)}case-22:{let[u,T,O]=_[1];return Nd(u.map(R=>f(R)),T.map(R=>f(R)),O)}case-23:{let u={},T=_[1];for(let[O,R]of T){let F=f(R);if(F instanceof un&&(F=F.getType()),!(F instanceof Qi))throw new Error("Illegal service definition: services can only contain functions");u[O]=F}return Rd(u)}default:throw new Error("Illegal op_code: "+_[0])}}o.forEach((_,u)=>{if(_[0]===-22){let T=d(_);c[u].fill(T)}}),o.forEach((_,u)=>{if(_[0]!==-22){let T=d(_);c[u].fill(T)}});let h=a.map(_=>f(_)),m=t.map((_,u)=>_.decodeValue(r,h[u]));for(let _=t.length;_<h.length;_++)h[_].decodeValue(r,h[_]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return m}Y.decode=Sb;Y.Empty=new mo;Y.Reserved=new pi;Y.Unknown=new bo;Y.Bool=new _o;Y.Null=new wo;Y.Text=new Eo;Y.Int=new xo;Y.Nat=new vo;Y.Float32=new Xi(32);Y.Float64=new Xi(64);Y.Int8=new zr(8);Y.Int16=new zr(16);Y.Int32=new zr(32);Y.Int64=new zr(64);Y.Nat8=new Or(8);Y.Nat16=new Or(16);Y.Nat32=new Or(32);Y.Nat64=new Or(64);Y.Principal=new Bo;function vd(...t){return new Ao(t)}Y.Tuple=vd;function Td(t){return new To(t)}Y.Vec=Td;function Ad(t){return new yi(t)}Y.Opt=Ad;function Sd(t){return new Ji(t)}Y.Record=Sd;function Bd(t){return new So(t)}Y.Variant=Bd;function Od(){return new un}Y.Rec=Od;function Nd(t,e,r=[]){return new Qi(t,e,r)}Y.Func=Nd;function Rd(t){return new Oo(t)}Y.Service=Rd});var Lc=L(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.VecForm=Tt.OptionForm=Tt.VariantForm=Tt.TupleForm=Tt.RecordForm=Tt.InputForm=Tt.InputBox=void 0;var Wc=class{constructor(e,r){this.idl=e,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(e={}){if(this.ui.form){let r=this.ui.form.parse(e);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,e,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(e){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),e.appendChild(r)}};Tt.InputBox=Wc;var ln=class{constructor(e){this.ui=e,this.form=[]}renderForm(e){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),e.appendChild(this.ui.container)):this.form.forEach(r=>r.render(e))}render(e){if(this.ui.open&&this.ui.event){e.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(e)})}else this.generateForm(),this.renderForm(e)}};Tt.InputForm=ln;var Dc=class extends ln{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){this.form=this.fields.map(([e,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(e)?n.label=this.ui.labelMap[e]+" ":n.label=e+" ",n})}parse(e){let r={};if(this.fields.forEach(([n,i],s)=>{let o=this.form[s].parse(e);r[n]=o}),!this.form.some(n=>n.isRejected()))return r}};Tt.RecordForm=Dc;var Zc=class extends ln{constructor(e,r){super(r),this.components=e,this.ui=r}generateForm(){this.form=this.components.map(e=>this.ui.render(e))}parse(e){let r=[];if(this.components.forEach((n,i)=>{let s=this.form[i].parse(e);r.push(s)}),!this.form.some(n=>n.isRejected()))return r}};Tt.TupleForm=Zc;var Xc=class extends ln{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){let e=this.ui.open.selectedIndex,[r,n]=this.fields[e],i=this.ui.render(n);this.form=[i]}parse(e){let r=this.ui.open,n=r.options[r.selectedIndex].value,i=this.form[0].parse(e);if(i===void 0)return;let s={};return s[n]=i,s}};Tt.VariantForm=Xc;var Jc=class extends ln{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){if(this.ui.open.checked){let e=this.ui.render(this.ty);this.form=[e]}else this.form=[]}parse(e){if(this.form.length===0)return[];{let r=this.form[0].parse(e);return r===void 0?void 0:[r]}}};Tt.OptionForm=Jc;var Qc=class extends ln{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){let e=+this.ui.open.value;this.form=[];for(let r=0;r<e;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(e){let r=this.form.map(n=>n.parse(e));if(!this.form.some(n=>n.isRejected()))return r}};Tt.VecForm=Qc});var Id=L(Ee=>{"use strict";var Bb=Ee&&Ee.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Ob=Ee&&Ee.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Pd=Ee&&Ee.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Bb(e,t,r);return Ob(e,t),e};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.renderValue=Ee.renderInput=Ee.Render=Ee.vecForm=Ee.optForm=Ee.variantForm=Ee.tupleForm=Ee.recordForm=Ee.inputBox=void 0;var Ro=Pd(zc()),eu=Nt(),gi=Pd(Lc()),Nb={parse:Cb},Li={render:iu},Rb=(t,e)=>new gi.InputBox(t,Object.assign(Object.assign({},Nb),e));Ee.inputBox=Rb;var Pb=(t,e)=>new gi.RecordForm(t,Object.assign(Object.assign({},Li),e));Ee.recordForm=Pb;var Ib=(t,e)=>new gi.TupleForm(t,Object.assign(Object.assign({},Li),e));Ee.tupleForm=Ib;var Ub=(t,e)=>new gi.VariantForm(t,Object.assign(Object.assign({},Li),e));Ee.variantForm=Ub;var Fb=(t,e)=>new gi.OptionForm(t,Object.assign(Object.assign({},Li),e));Ee.optForm=Fb;var Mb=(t,e)=>new gi.VecForm(t,Object.assign(Object.assign({},Li),e));Ee.vecForm=Mb;var No=class extends Ro.Visitor{visitType(e,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=e.display(),(0,Ee.inputBox)(e,{input:n})}visitNull(e,r){return(0,Ee.inputBox)(e,{})}visitRecord(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.recordForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitTuple(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.tupleForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitVariant(e,r,n){let i=document.createElement("select");for(let[a,c]of r){let f=new Option(a);i.add(f)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},o=(0,Ee.variantForm)(r,s);return(0,Ee.inputBox)(e,{form:o})}visitOpt(e,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Ee.optForm)(r,{open:i,event:"change"});return(0,Ee.inputBox)(e,{form:s})}visitVec(e,r,n){let i=document.createElement("input");i.type="number",i.min="0",i.max="100",i.style.width="8rem",i.placeholder="len",i.classList.add("open");let s=document.createElement("div");s.classList.add("popup-form");let o=(0,Ee.vecForm)(r,{open:i,event:"change",container:s});return(0,Ee.inputBox)(e,{form:o})}visitRec(e,r,n){return iu(r)}};Ee.Render=No;var tu=class extends Ro.Visitor{visitNull(e,r){return null}visitBool(e,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(e,r){return r}visitFloat(e,r){return parseFloat(r)}visitFixedInt(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(e,r){return BigInt(r)}visitPrincipal(e,r){return eu.Principal.fromText(r)}visitService(e,r){return eu.Principal.fromText(r)}visitFunc(e,r){let n=r.split(".",2);return[eu.Principal.fromText(n[0]),n[1]]}},ru=class extends Ro.Visitor{visitNull(e,r){return null}visitBool(e,r){return Math.random()<.5}visitText(e,r){return Math.random().toString(36).substring(6)}visitFloat(e,r){return Math.random()}visitInt(e,r){return BigInt(this.generateNumber(!0))}visitNat(e,r){return BigInt(this.generateNumber(!1))}visitFixedInt(e,r){let n=this.generateNumber(!0);return e._bits<=32?n:BigInt(r)}visitFixedNat(e,r){let n=this.generateNumber(!1);return e._bits<=32?n:BigInt(r)}generateNumber(e){let r=Math.floor(Math.random()*100);return e&&Math.random()<.5?-r:r}};function Cb(t,e,r){return e.random&&r===""?t.accept(new ru,r):t.accept(new tu,r)}function iu(t){return t.accept(new No,null)}Ee.renderInput=iu;function jn(t,e,r){return t.accept(new nu,{input:e,value:r})}Ee.renderValue=jn;var nu=class extends Ro.Visitor{visitType(e,r){r.input.ui.input.value=e.valueToString(r.value)}visitNull(e,r){}visitText(e,r){r.input.ui.input.value=r.value}visitRec(e,r,n){jn(r,n.input,n.value)}visitOpt(e,r,n){if(n.value.length!==0){let i=n.input.ui.form,s=i.ui.open;s.checked=!0,s.dispatchEvent(new Event(i.ui.event)),jn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{jn(o,i.form[a],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{jn(s,i.form[o],n.value[o])})}visitVariant(e,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([o,a],c)=>{if(o===s[0]){let f=i.ui.open;f.selectedIndex=c,f.dispatchEvent(new Event(i.ui.event)),jn(a,i.form[0],s[1])}})}visitVec(e,r,n){let i=n.input.ui.form,s=n.value.length,o=i.ui.open;o.value=s,o.dispatchEvent(new Event(i.ui.event)),n.value.forEach((a,c)=>{jn(r,i.form[c],a)})}}});var Fd=L(Ud=>{"use strict";Object.defineProperty(Ud,"__esModule",{value:!0})});var bi=L(dt=>{"use strict";var Md=dt&&dt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),qb=dt&&dt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),mi=dt&&dt.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Md(e,t,r)},jb=dt&&dt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Md(e,t,r);return qb(e,t),e};Object.defineProperty(dt,"__esModule",{value:!0});dt.IDL=void 0;mi(Id(),dt);mi(Lc(),dt);dt.IDL=jb(zc());mi(kc(),dt);mi(Vc(),dt);mi(ho(),dt);mi(Fd(),dt)});var es=L((Cd,Po)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,f=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,m=1e9;function _(x){var $,z,D,j=U.prototype={constructor:U,toString:null,valueOf:null},ie=new U(1),ee=20,ne=4,w=-7,b=21,B=-1e7,S=1e7,N=!1,H=1,Z=0,ae={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},oe="0123456789abcdefghijklmnopqrstuvwxyz",W=!0;function U(l,y){var g,P,A,I,k,E,C,V,q=this;if(!(q instanceof U))return new U(l,y);if(y==null){if(l&&l._isBigNumber===!0){q.s=l.s,!l.c||l.e>S?q.c=q.e=null:l.e<B?q.c=[q.e=0]:(q.e=l.e,q.c=l.c.slice());return}if((E=typeof l=="number")&&l*0==0){if(q.s=1/l<0?(l=-l,-1):1,l===~~l){for(I=0,k=l;k>=10;k/=10,I++);I>S?q.c=q.e=null:(q.e=I,q.c=[l]);return}V=String(l)}else{if(!r.test(V=String(l)))return D(q,V,E);q.s=V.charCodeAt(0)==45?(V=V.slice(1),-1):1}(I=V.indexOf("."))>-1&&(V=V.replace(".","")),(k=V.search(/e/i))>0?(I<0&&(I=k),I+=+V.slice(k+1),V=V.substring(0,k)):I<0&&(I=V.length)}else{if(R(y,2,oe.length,"Base"),y==10&&W)return q=new U(l),fe(q,ee+q.e+1,ne);if(V=String(l),E=typeof l=="number"){if(l*0!=0)return D(q,V,E,y);if(q.s=1/l<0?(V=V.slice(1),-1):1,U.DEBUG&&V.replace(/^0\.0*|\./,"").length>15)throw Error(o+l)}else q.s=V.charCodeAt(0)===45?(V=V.slice(1),-1):1;for(g=oe.slice(0,y),I=k=0,C=V.length;k<C;k++)if(g.indexOf(P=V.charAt(k))<0){if(P=="."){if(k>I){I=C;continue}}else if(!A&&(V==V.toUpperCase()&&(V=V.toLowerCase())||V==V.toLowerCase()&&(V=V.toUpperCase()))){A=!0,k=-1,I=0;continue}return D(q,String(l),E,y)}E=!1,V=z(V,y,10,q.s),(I=V.indexOf("."))>-1?V=V.replace(".",""):I=V.length}for(k=0;V.charCodeAt(k)===48;k++);for(C=V.length;V.charCodeAt(--C)===48;);if(V=V.slice(k,++C)){if(C-=k,E&&U.DEBUG&&C>15&&(l>f||l!==i(l)))throw Error(o+q.s*l);if((I=I-k-1)>S)q.c=q.e=null;else if(I<B)q.c=[q.e=0];else{if(q.e=I,q.c=[],k=(I+1)%c,I<0&&(k+=c),k<C){for(k&&q.c.push(+V.slice(0,k)),C-=c;k<C;)q.c.push(+V.slice(k,k+=c));k=c-(V=V.slice(k)).length}else k-=C;for(;k--;V+="0");q.c.push(+V)}}else q.c=[q.e=0]}U.clone=_,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(l){var y,g;if(l!=null)if(typeof l=="object"){if(l.hasOwnProperty(y="DECIMAL_PLACES")&&(g=l[y],R(g,0,m,y),ee=g),l.hasOwnProperty(y="ROUNDING_MODE")&&(g=l[y],R(g,0,8,y),ne=g),l.hasOwnProperty(y="EXPONENTIAL_AT")&&(g=l[y],g&&g.pop?(R(g[0],-m,0,y),R(g[1],0,m,y),w=g[0],b=g[1]):(R(g,-m,m,y),w=-(b=g<0?-g:g))),l.hasOwnProperty(y="RANGE"))if(g=l[y],g&&g.pop)R(g[0],-m,-1,y),R(g[1],1,m,y),B=g[0],S=g[1];else if(R(g,-m,m,y),g)B=-(S=g<0?-g:g);else throw Error(s+y+" cannot be zero: "+g);if(l.hasOwnProperty(y="CRYPTO"))if(g=l[y],g===!!g)if(g)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))N=g;else throw N=!g,Error(s+"crypto unavailable");else N=g;else throw Error(s+y+" not true or false: "+g);if(l.hasOwnProperty(y="MODULO_MODE")&&(g=l[y],R(g,0,9,y),H=g),l.hasOwnProperty(y="POW_PRECISION")&&(g=l[y],R(g,0,m,y),Z=g),l.hasOwnProperty(y="FORMAT"))if(g=l[y],typeof g=="object")ae=g;else throw Error(s+y+" not an object: "+g);if(l.hasOwnProperty(y="ALPHABET"))if(g=l[y],typeof g=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(g))W=g.slice(0,10)=="0123456789",oe=g;else throw Error(s+y+" invalid: "+g)}else throw Error(s+"Object expected: "+l);return{DECIMAL_PLACES:ee,ROUNDING_MODE:ne,EXPONENTIAL_AT:[w,b],RANGE:[B,S],CRYPTO:N,MODULO_MODE:H,POW_PRECISION:Z,FORMAT:ae,ALPHABET:oe}},U.isBigNumber=function(l){if(!l||l._isBigNumber!==!0)return!1;if(!U.DEBUG)return!0;var y,g,P=l.c,A=l.e,I=l.s;e:if({}.toString.call(P)=="[object Array]"){if((I===1||I===-1)&&A>=-m&&A<=m&&A===i(A)){if(P[0]===0){if(A===0&&P.length===1)return!0;break e}if(y=(A+1)%c,y<1&&(y+=c),String(P[0]).length==y){for(y=0;y<P.length;y++)if(g=P[y],g<0||g>=a||g!==i(g))break e;if(g!==0)return!0}}}else if(P===null&&A===null&&(I===null||I===1||I===-1))return!0;throw Error(s+"Invalid BigNumber: "+l)},U.maximum=U.max=function(){return J(arguments,-1)},U.minimum=U.min=function(){return J(arguments,1)},U.random=function(){var l=9007199254740992,y=Math.random()*l&2097151?function(){return i(Math.random()*l)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(g){var P,A,I,k,E,C=0,V=[],q=new U(ie);if(g==null?g=ee:R(g,0,m),k=n(g/c),N)if(crypto.getRandomValues){for(P=crypto.getRandomValues(new Uint32Array(k*=2));C<k;)E=P[C]*131072+(P[C+1]>>>11),E>=9e15?(A=crypto.getRandomValues(new Uint32Array(2)),P[C]=A[0],P[C+1]=A[1]):(V.push(E%1e14),C+=2);C=k/2}else if(crypto.randomBytes){for(P=crypto.randomBytes(k*=7);C<k;)E=(P[C]&31)*281474976710656+P[C+1]*1099511627776+P[C+2]*4294967296+P[C+3]*16777216+(P[C+4]<<16)+(P[C+5]<<8)+P[C+6],E>=9e15?crypto.randomBytes(7).copy(P,C):(V.push(E%1e14),C+=7);C=k/7}else throw N=!1,Error(s+"crypto unavailable");if(!N)for(;C<k;)E=y(),E<9e15&&(V[C++]=E%1e14);for(k=V[--C],g%=c,k&&g&&(E=d[c-g],V[C]=i(k/E)*E);V[C]===0;V.pop(),C--);if(C<0)V=[I=0];else{for(I=-1;V[0]===0;V.splice(0,1),I-=c);for(C=1,E=V[0];E>=10;E/=10,C++);C<c&&(I-=c-C)}return q.e=I,q.c=V,q}}(),U.sum=function(){for(var l=1,y=arguments,g=new U(y[0]);l<y.length;)g=g.plus(y[l++]);return g},z=function(){var l="0123456789";function y(g,P,A,I){for(var k,E=[0],C,V=0,q=g.length;V<q;){for(C=E.length;C--;E[C]*=P);for(E[0]+=I.indexOf(g.charAt(V++)),k=0;k<E.length;k++)E[k]>A-1&&(E[k+1]==null&&(E[k+1]=0),E[k+1]+=E[k]/A|0,E[k]%=A)}return E.reverse()}return function(g,P,A,I,k){var E,C,V,q,X,te,de,_e,Fe=g.indexOf("."),Ve=ee,me=ne;for(Fe>=0&&(q=Z,Z=0,g=g.replace(".",""),_e=new U(P),te=_e.pow(g.length-Fe),Z=q,_e.c=y(K(T(te.c),te.e,"0"),10,A,l),_e.e=_e.c.length),de=y(g,P,A,k?(E=oe,l):(E=l,oe)),V=q=de.length;de[--q]==0;de.pop());if(!de[0])return E.charAt(0);if(Fe<0?--V:(te.c=de,te.e=V,te.s=I,te=$(te,_e,Ve,me,A),de=te.c,X=te.r,V=te.e),C=V+Ve+1,Fe=de[C],q=A/2,X=X||C<0||de[C+1]!=null,X=me<4?(Fe!=null||X)&&(me==0||me==(te.s<0?3:2)):Fe>q||Fe==q&&(me==4||X||me==6&&de[C-1]&1||me==(te.s<0?8:7)),C<1||!de[0])g=X?K(E.charAt(1),-Ve,E.charAt(0)):E.charAt(0);else{if(de.length=C,X)for(--A;++de[--C]>A;)de[C]=0,C||(++V,de=[1].concat(de));for(q=de.length;!de[--q];);for(Fe=0,g="";Fe<=q;g+=E.charAt(de[Fe++]));g=K(g,V,E.charAt(0))}return g}}(),$=function(){function l(P,A,I){var k,E,C,V,q=0,X=P.length,te=A%h,de=A/h|0;for(P=P.slice();X--;)C=P[X]%h,V=P[X]/h|0,k=de*C+V*te,E=te*C+k%h*h+q,q=(E/I|0)+(k/h|0)+de*V,P[X]=E%I;return q&&(P=[q].concat(P)),P}function y(P,A,I,k){var E,C;if(I!=k)C=I>k?1:-1;else for(E=C=0;E<I;E++)if(P[E]!=A[E]){C=P[E]>A[E]?1:-1;break}return C}function g(P,A,I,k){for(var E=0;I--;)P[I]-=E,E=P[I]<A[I]?1:0,P[I]=E*k+P[I]-A[I];for(;!P[0]&&P.length>1;P.splice(0,1));}return function(P,A,I,k,E){var C,V,q,X,te,de,_e,Fe,Ve,me,he,Ze,Er,Kr,Fn,Lt,Pe,qt=P.s==A.s?1:-1,mt=P.c,Ye=A.c;if(!mt||!mt[0]||!Ye||!Ye[0])return new U(!P.s||!A.s||(mt?Ye&&mt[0]==Ye[0]:!Ye)?NaN:mt&&mt[0]==0||!Ye?qt*0:qt/0);for(Fe=new U(qt),Ve=Fe.c=[],V=P.e-A.e,qt=I+V+1,E||(E=a,V=u(P.e/c)-u(A.e/c),qt=qt/c|0),q=0;Ye[q]==(mt[q]||0);q++);if(Ye[q]>(mt[q]||0)&&V--,qt<0)Ve.push(1),X=!0;else{for(Kr=mt.length,Lt=Ye.length,q=0,qt+=2,te=i(E/(Ye[0]+1)),te>1&&(Ye=l(Ye,te,E),mt=l(mt,te,E),Lt=Ye.length,Kr=mt.length),Er=Lt,me=mt.slice(0,Lt),he=me.length;he<Lt;me[he++]=0);Pe=Ye.slice(),Pe=[0].concat(Pe),Fn=Ye[0],Ye[1]>=E/2&&Fn++;do{if(te=0,C=y(Ye,me,Lt,he),C<0){if(Ze=me[0],Lt!=he&&(Ze=Ze*E+(me[1]||0)),te=i(Ze/Fn),te>1)for(te>=E&&(te=E-1),de=l(Ye,te,E),_e=de.length,he=me.length;y(de,me,_e,he)==1;)te--,g(de,Lt<_e?Pe:Ye,_e,E),_e=de.length,C=1;else te==0&&(C=te=1),de=Ye.slice(),_e=de.length;if(_e<he&&(de=[0].concat(de)),g(me,de,he,E),he=me.length,C==-1)for(;y(Ye,me,Lt,he)<1;)te++,g(me,Lt<he?Pe:Ye,he,E),he=me.length}else C===0&&(te++,me=[0]);Ve[q++]=te,me[0]?me[he++]=mt[Er]||0:(me=[mt[Er]],he=1)}while((Er++<Kr||me[0]!=null)&&qt--);X=me[0]!=null,Ve[0]||Ve.splice(0,1)}if(E==a){for(q=1,qt=Ve[0];qt>=10;qt/=10,q++);fe(Fe,I+(Fe.e=q+V*c-1)+1,k,X)}else Fe.e=V,Fe.r=+X;return Fe}}();function p(l,y,g,P){var A,I,k,E,C;if(g==null?g=ne:R(g,0,8),!l.c)return l.toString();if(A=l.c[0],k=l.e,y==null)C=T(l.c),C=P==1||P==2&&(k<=w||k>=b)?M(C,k):K(C,k,"0");else if(l=fe(new U(l),y,g),I=l.e,C=T(l.c),E=C.length,P==1||P==2&&(y<=I||I<=w)){for(;E<y;C+="0",E++);C=M(C,I)}else if(y-=k,C=K(C,I,"0"),I+1>E){if(--y>0)for(C+=".";y--;C+="0");}else if(y+=I-E,y>0)for(I+1==E&&(C+=".");y--;C+="0");return l.s<0&&A?"-"+C:C}function J(l,y){for(var g,P,A=1,I=new U(l[0]);A<l.length;A++)P=new U(l[A]),(!P.s||(g=O(I,P))===y||g===0&&I.s===y)&&(I=P);return I}function re(l,y,g){for(var P=1,A=y.length;!y[--A];y.pop());for(A=y[0];A>=10;A/=10,P++);return(g=P+g*c-1)>S?l.c=l.e=null:g<B?l.c=[l.e=0]:(l.e=g,l.c=y),l}D=function(){var l=/^(-?)0([xbo])(?=\w[\w.]*$)/i,y=/^([^.]+)\.$/,g=/^\.([^.]+)$/,P=/^-?(Infinity|NaN)$/,A=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(I,k,E,C){var V,q=E?k:k.replace(A,"");if(P.test(q))I.s=isNaN(q)?null:q<0?-1:1;else{if(!E&&(q=q.replace(l,function(X,te,de){return V=(de=de.toLowerCase())=="x"?16:de=="b"?2:8,!C||C==V?te:X}),C&&(V=C,q=q.replace(y,"$1").replace(g,"0.$1")),k!=q))return new U(q,V);if(U.DEBUG)throw Error(s+"Not a"+(C?" base "+C:"")+" number: "+k);I.s=null}I.c=I.e=null}}();function fe(l,y,g,P){var A,I,k,E,C,V,q,X=l.c,te=d;if(X){e:{for(A=1,E=X[0];E>=10;E/=10,A++);if(I=y-A,I<0)I+=c,k=y,C=X[V=0],q=i(C/te[A-k-1]%10);else if(V=n((I+1)/c),V>=X.length)if(P){for(;X.length<=V;X.push(0));C=q=0,A=1,I%=c,k=I-c+1}else break e;else{for(C=E=X[V],A=1;E>=10;E/=10,A++);I%=c,k=I-c+A,q=k<0?0:i(C/te[A-k-1]%10)}if(P=P||y<0||X[V+1]!=null||(k<0?C:C%te[A-k-1]),P=g<4?(q||P)&&(g==0||g==(l.s<0?3:2)):q>5||q==5&&(g==4||P||g==6&&(I>0?k>0?C/te[A-k]:0:X[V-1])%10&1||g==(l.s<0?8:7)),y<1||!X[0])return X.length=0,P?(y-=l.e+1,X[0]=te[(c-y%c)%c],l.e=-y||0):X[0]=l.e=0,l;if(I==0?(X.length=V,E=1,V--):(X.length=V+1,E=te[c-I],X[V]=k>0?i(C/te[A-k]%te[k])*E:0),P)for(;;)if(V==0){for(I=1,k=X[0];k>=10;k/=10,I++);for(k=X[0]+=E,E=1;k>=10;k/=10,E++);I!=E&&(l.e++,X[0]==a&&(X[0]=1));break}else{if(X[V]+=E,X[V]!=a)break;X[V--]=0,E=1}for(I=X.length;X[--I]===0;X.pop());}l.e>S?l.c=l.e=null:l.e<B&&(l.c=[l.e=0])}return l}function Q(l){var y,g=l.e;return g===null?l.toString():(y=T(l.c),y=g<=w||g>=b?M(y,g):K(y,g,"0"),l.s<0?"-"+y:y)}return j.absoluteValue=j.abs=function(){var l=new U(this);return l.s<0&&(l.s=1),l},j.comparedTo=function(l,y){return O(this,new U(l,y))},j.decimalPlaces=j.dp=function(l,y){var g,P,A,I=this;if(l!=null)return R(l,0,m),y==null?y=ne:R(y,0,8),fe(new U(I),l+I.e+1,y);if(!(g=I.c))return null;if(P=((A=g.length-1)-u(this.e/c))*c,A=g[A])for(;A%10==0;A/=10,P--);return P<0&&(P=0),P},j.dividedBy=j.div=function(l,y){return $(this,new U(l,y),ee,ne)},j.dividedToIntegerBy=j.idiv=function(l,y){return $(this,new U(l,y),0,1)},j.exponentiatedBy=j.pow=function(l,y){var g,P,A,I,k,E,C,V,q,X=this;if(l=new U(l),l.c&&!l.isInteger())throw Error(s+"Exponent not an integer: "+Q(l));if(y!=null&&(y=new U(y)),E=l.e>14,!X.c||!X.c[0]||X.c[0]==1&&!X.e&&X.c.length==1||!l.c||!l.c[0])return q=new U(Math.pow(+Q(X),E?l.s*(2-F(l)):+Q(l))),y?q.mod(y):q;if(C=l.s<0,y){if(y.c?!y.c[0]:!y.s)return new U(NaN);P=!C&&X.isInteger()&&y.isInteger(),P&&(X=X.mod(y))}else{if(l.e>9&&(X.e>0||X.e<-1||(X.e==0?X.c[0]>1||E&&X.c[1]>=24e7:X.c[0]<8e13||E&&X.c[0]<=9999975e7)))return I=X.s<0&&F(l)?-0:0,X.e>-1&&(I=1/I),new U(C?1/I:I);Z&&(I=n(Z/c+2))}for(E?(g=new U(.5),C&&(l.s=1),V=F(l)):(A=Math.abs(+Q(l)),V=A%2),q=new U(ie);;){if(V){if(q=q.times(X),!q.c)break;I?q.c.length>I&&(q.c.length=I):P&&(q=q.mod(y))}if(A){if(A=i(A/2),A===0)break;V=A%2}else if(l=l.times(g),fe(l,l.e+1,1),l.e>14)V=F(l);else{if(A=+Q(l),A===0)break;V=A%2}X=X.times(X),I?X.c&&X.c.length>I&&(X.c.length=I):P&&(X=X.mod(y))}return P?q:(C&&(q=ie.div(q)),y?q.mod(y):I?fe(q,Z,ne,k):q)},j.integerValue=function(l){var y=new U(this);return l==null?l=ne:R(l,0,8),fe(y,y.e+1,l)},j.isEqualTo=j.eq=function(l,y){return O(this,new U(l,y))===0},j.isFinite=function(){return!!this.c},j.isGreaterThan=j.gt=function(l,y){return O(this,new U(l,y))>0},j.isGreaterThanOrEqualTo=j.gte=function(l,y){return(y=O(this,new U(l,y)))===1||y===0},j.isInteger=function(){return!!this.c&&u(this.e/c)>this.c.length-2},j.isLessThan=j.lt=function(l,y){return O(this,new U(l,y))<0},j.isLessThanOrEqualTo=j.lte=function(l,y){return(y=O(this,new U(l,y)))===-1||y===0},j.isNaN=function(){return!this.s},j.isNegative=function(){return this.s<0},j.isPositive=function(){return this.s>0},j.isZero=function(){return!!this.c&&this.c[0]==0},j.minus=function(l,y){var g,P,A,I,k=this,E=k.s;if(l=new U(l,y),y=l.s,!E||!y)return new U(NaN);if(E!=y)return l.s=-y,k.plus(l);var C=k.e/c,V=l.e/c,q=k.c,X=l.c;if(!C||!V){if(!q||!X)return q?(l.s=-y,l):new U(X?k:NaN);if(!q[0]||!X[0])return X[0]?(l.s=-y,l):new U(q[0]?k:ne==3?-0:0)}if(C=u(C),V=u(V),q=q.slice(),E=C-V){for((I=E<0)?(E=-E,A=q):(V=C,A=X),A.reverse(),y=E;y--;A.push(0));A.reverse()}else for(P=(I=(E=q.length)<(y=X.length))?E:y,E=y=0;y<P;y++)if(q[y]!=X[y]){I=q[y]<X[y];break}if(I&&(A=q,q=X,X=A,l.s=-l.s),y=(P=X.length)-(g=q.length),y>0)for(;y--;q[g++]=0);for(y=a-1;P>E;){if(q[--P]<X[P]){for(g=P;g&&!q[--g];q[g]=y);--q[g],q[P]+=a}q[P]-=X[P]}for(;q[0]==0;q.splice(0,1),--V);return q[0]?re(l,q,V):(l.s=ne==3?-1:1,l.c=[l.e=0],l)},j.modulo=j.mod=function(l,y){var g,P,A=this;return l=new U(l,y),!A.c||!l.s||l.c&&!l.c[0]?new U(NaN):!l.c||A.c&&!A.c[0]?new U(A):(H==9?(P=l.s,l.s=1,g=$(A,l,0,3),l.s=P,g.s*=P):g=$(A,l,0,H),l=A.minus(g.times(l)),!l.c[0]&&H==1&&(l.s=A.s),l)},j.multipliedBy=j.times=function(l,y){var g,P,A,I,k,E,C,V,q,X,te,de,_e,Fe,Ve,me=this,he=me.c,Ze=(l=new U(l,y)).c;if(!he||!Ze||!he[0]||!Ze[0])return!me.s||!l.s||he&&!he[0]&&!Ze||Ze&&!Ze[0]&&!he?l.c=l.e=l.s=null:(l.s*=me.s,!he||!Ze?l.c=l.e=null:(l.c=[0],l.e=0)),l;for(P=u(me.e/c)+u(l.e/c),l.s*=me.s,C=he.length,X=Ze.length,C<X&&(_e=he,he=Ze,Ze=_e,A=C,C=X,X=A),A=C+X,_e=[];A--;_e.push(0));for(Fe=a,Ve=h,A=X;--A>=0;){for(g=0,te=Ze[A]%Ve,de=Ze[A]/Ve|0,k=C,I=A+k;I>A;)V=he[--k]%Ve,q=he[k]/Ve|0,E=de*V+q*te,V=te*V+E%Ve*Ve+_e[I]+g,g=(V/Fe|0)+(E/Ve|0)+de*q,_e[I--]=V%Fe;_e[I]=g}return g?++P:_e.splice(0,1),re(l,_e,P)},j.negated=function(){var l=new U(this);return l.s=-l.s||null,l},j.plus=function(l,y){var g,P=this,A=P.s;if(l=new U(l,y),y=l.s,!A||!y)return new U(NaN);if(A!=y)return l.s=-y,P.minus(l);var I=P.e/c,k=l.e/c,E=P.c,C=l.c;if(!I||!k){if(!E||!C)return new U(A/0);if(!E[0]||!C[0])return C[0]?l:new U(E[0]?P:A*0)}if(I=u(I),k=u(k),E=E.slice(),A=I-k){for(A>0?(k=I,g=C):(A=-A,g=E),g.reverse();A--;g.push(0));g.reverse()}for(A=E.length,y=C.length,A-y<0&&(g=C,C=E,E=g,y=A),A=0;y;)A=(E[--y]=E[y]+C[y]+A)/a|0,E[y]=a===E[y]?0:E[y]%a;return A&&(E=[A].concat(E),++k),re(l,E,k)},j.precision=j.sd=function(l,y){var g,P,A,I=this;if(l!=null&&l!==!!l)return R(l,1,m),y==null?y=ne:R(y,0,8),fe(new U(I),l,y);if(!(g=I.c))return null;if(A=g.length-1,P=A*c+1,A=g[A]){for(;A%10==0;A/=10,P--);for(A=g[0];A>=10;A/=10,P++);}return l&&I.e+1>P&&(P=I.e+1),P},j.shiftedBy=function(l){return R(l,-f,f),this.times("1e"+l)},j.squareRoot=j.sqrt=function(){var l,y,g,P,A,I=this,k=I.c,E=I.s,C=I.e,V=ee+4,q=new U("0.5");if(E!==1||!k||!k[0])return new U(!E||E<0&&(!k||k[0])?NaN:k?I:1/0);if(E=Math.sqrt(+Q(I)),E==0||E==1/0?(y=T(k),(y.length+C)%2==0&&(y+="0"),E=Math.sqrt(+y),C=u((C+1)/2)-(C<0||C%2),E==1/0?y="5e"+C:(y=E.toExponential(),y=y.slice(0,y.indexOf("e")+1)+C),g=new U(y)):g=new U(E+""),g.c[0]){for(C=g.e,E=C+V,E<3&&(E=0);;)if(A=g,g=q.times(A.plus($(I,A,V,1))),T(A.c).slice(0,E)===(y=T(g.c)).slice(0,E))if(g.e<C&&--E,y=y.slice(E-3,E+1),y=="9999"||!P&&y=="4999"){if(!P&&(fe(A,A.e+ee+2,0),A.times(A).eq(I))){g=A;break}V+=4,E+=4,P=1}else{(!+y||!+y.slice(1)&&y.charAt(0)=="5")&&(fe(g,g.e+ee+2,1),l=!g.times(g).eq(I));break}}return fe(g,g.e+ee+1,ne,l)},j.toExponential=function(l,y){return l!=null&&(R(l,0,m),l++),p(this,l,y,1)},j.toFixed=function(l,y){return l!=null&&(R(l,0,m),l=l+this.e+1),p(this,l,y)},j.toFormat=function(l,y,g){var P,A=this;if(g==null)l!=null&&y&&typeof y=="object"?(g=y,y=null):l&&typeof l=="object"?(g=l,l=y=null):g=ae;else if(typeof g!="object")throw Error(s+"Argument not an object: "+g);if(P=A.toFixed(l,y),A.c){var I,k=P.split("."),E=+g.groupSize,C=+g.secondaryGroupSize,V=g.groupSeparator||"",q=k[0],X=k[1],te=A.s<0,de=te?q.slice(1):q,_e=de.length;if(C&&(I=E,E=C,C=I,_e-=I),E>0&&_e>0){for(I=_e%E||E,q=de.substr(0,I);I<_e;I+=E)q+=V+de.substr(I,E);C>0&&(q+=V+de.slice(I)),te&&(q="-"+q)}P=X?q+(g.decimalSeparator||"")+((C=+g.fractionGroupSize)?X.replace(new RegExp("\\d{"+C+"}\\B","g"),"$&"+(g.fractionGroupSeparator||"")):X):q}return(g.prefix||"")+P+(g.suffix||"")},j.toFraction=function(l){var y,g,P,A,I,k,E,C,V,q,X,te,de=this,_e=de.c;if(l!=null&&(E=new U(l),!E.isInteger()&&(E.c||E.s!==1)||E.lt(ie)))throw Error(s+"Argument "+(E.isInteger()?"out of range: ":"not an integer: ")+Q(E));if(!_e)return new U(de);for(y=new U(ie),V=g=new U(ie),P=C=new U(ie),te=T(_e),I=y.e=te.length-de.e-1,y.c[0]=d[(k=I%c)<0?c+k:k],l=!l||E.comparedTo(y)>0?I>0?y:V:E,k=S,S=1/0,E=new U(te),C.c[0]=0;q=$(E,y,0,1),A=g.plus(q.times(P)),A.comparedTo(l)!=1;)g=P,P=A,V=C.plus(q.times(A=V)),C=A,y=E.minus(q.times(A=y)),E=A;return A=$(l.minus(g),P,0,1),C=C.plus(A.times(V)),g=g.plus(A.times(P)),C.s=V.s=de.s,I=I*2,X=$(V,P,I,ne).minus(de).abs().comparedTo($(C,g,I,ne).minus(de).abs())<1?[V,P]:[C,g],S=k,X},j.toNumber=function(){return+Q(this)},j.toPrecision=function(l,y){return l!=null&&R(l,1,m),p(this,l,y,2)},j.toString=function(l){var y,g=this,P=g.s,A=g.e;return A===null?P?(y="Infinity",P<0&&(y="-"+y)):y="NaN":(l==null?y=A<=w||A>=b?M(T(g.c),A):K(T(g.c),A,"0"):l===10&&W?(g=fe(new U(g),ee+A+1,ne),y=K(T(g.c),g.e,"0")):(R(l,2,oe.length,"Base"),y=z(K(T(g.c),A,"0"),10,l,P,!0)),P<0&&g.c[0]&&(y="-"+y)),y},j.valueOf=j.toJSON=function(){return Q(this)},j._isBigNumber=!0,x!=null&&U.set(x),U}function u(x){var $=x|0;return x>0||x===$?$:$-1}function T(x){for(var $,z,D=1,j=x.length,ie=x[0]+"";D<j;){for($=x[D++]+"",z=c-$.length;z--;$="0"+$);ie+=$}for(j=ie.length;ie.charCodeAt(--j)===48;);return ie.slice(0,j+1||1)}function O(x,$){var z,D,j=x.c,ie=$.c,ee=x.s,ne=$.s,w=x.e,b=$.e;if(!ee||!ne)return null;if(z=j&&!j[0],D=ie&&!ie[0],z||D)return z?D?0:-ne:ee;if(ee!=ne)return ee;if(z=ee<0,D=w==b,!j||!ie)return D?0:!j^z?1:-1;if(!D)return w>b^z?1:-1;for(ne=(w=j.length)<(b=ie.length)?w:b,ee=0;ee<ne;ee++)if(j[ee]!=ie[ee])return j[ee]>ie[ee]^z?1:-1;return w==b?0:w>b^z?1:-1}function R(x,$,z,D){if(x<$||x>z||x!==i(x))throw Error(s+(D||"Argument")+(typeof x=="number"?x<$||x>z?" out of range: ":" not an integer: ":" not a primitive number: ")+String(x))}function F(x){var $=x.c.length-1;return u(x.e/c)==$&&x.c[$]%2!=0}function M(x,$){return(x.length>1?x.charAt(0)+"."+x.slice(1):x)+($<0?"e":"e+")+$}function K(x,$,z){var D,j;if($<0){for(j=z+".";++$;j+=z);x=j+x}else if(D=x.length,++$>D){for(j=z,$-=D;--$;j+=z);x+=j}else $<D&&(x=x.slice(0,$)+"."+x.slice($));return x}e=_(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof Po<"u"&&Po.exports?Po.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(Cd)});var jd=L((W8,qd)=>{qd.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,f=r.pushInt64Neg,d=r.pushFloat,h=r.pushFloatSingle,m=r.pushFloatDouble,_=r.pushTrue,u=r.pushFalse,T=r.pushUndefined,O=r.pushNull,R=r.pushInfinity,F=r.pushInfinityNeg,M=r.pushNaN,K=r.pushNaNNeg,x=r.pushArrayStart,$=r.pushArrayStartFixed,z=r.pushArrayStartFixed32,D=r.pushArrayStartFixed64,j=r.pushObjectStart,ie=r.pushObjectStartFixed,ee=r.pushObjectStartFixed32,ne=r.pushObjectStartFixed64,w=r.pushByteString,b=r.pushByteStringStart,B=r.pushUtf8String,S=r.pushUtf8StringStart,N=r.pushSimpleUnassigned,H=r.pushTagStart,Z=r.pushTagStart4,ae=r.pushTagStart8,oe=r.pushTagUnassigned,W=r.pushBreak,U=e.Math.pow,p=0,J=0,re=0;function fe(v){for(v=v|0,p=0,J=v;(p|0)<(J|0)&&(re=Mg[i[p]&255](i[p]|0)|0,!((re|0)>0)););return re|0}function Q(v){return v=v|0,((p|0)+(v|0)|0)<(J|0)?0:1}function l(v){return v=v|0,i[v|0]<<8|i[v+1|0]|0}function y(v){return v=v|0,i[v|0]<<24|i[v+1|0]<<16|i[v+2|0]<<8|i[v+3|0]|0}function g(v){return v=v|0,s(v|0),p=p+1|0,0}function P(v){return v=v|0,Q(1)|0?1:(s(i[p+1|0]|0),p=p+2|0,0)}function A(v){return v=v|0,Q(2)|0?1:(s(l(p+1|0)|0),p=p+3|0,0)}function I(v){return v=v|0,Q(4)|0?1:(o(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function k(v){return v=v|0,Q(8)|0?1:(c(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function E(v){return v=v|0,s(-1-(v-32|0)|0),p=p+1|0,0}function C(v){return v=v|0,Q(1)|0?1:(s(-1-(i[p+1|0]|0)|0),p=p+2|0,0)}function V(v){v=v|0;var Te=0;return Q(2)|0?1:(Te=l(p+1|0)|0,s(-1-(Te|0)|0),p=p+3|0,0)}function q(v){return v=v|0,Q(4)|0?1:(a(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function X(v){return v=v|0,Q(8)|0?1:(f(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function te(v){v=v|0;var Te=0,Be=0,xe=0;return xe=v-64|0,Q(xe|0)|0?1:(Te=p+1|0,Be=(p+1|0)+(xe|0)|0,w(Te|0,Be|0),p=Be|0,0)}function de(v){v=v|0;var Te=0,Be=0,xe=0;return Q(1)|0||(xe=i[p+1|0]|0,Te=p+2|0,Be=(p+2|0)+(xe|0)|0,Q(xe+1|0)|0)?1:(w(Te|0,Be|0),p=Be|0,0)}function _e(v){v=v|0;var Te=0,Be=0,xe=0;return Q(2)|0||(xe=l(p+1|0)|0,Te=p+3|0,Be=(p+3|0)+(xe|0)|0,Q(xe+2|0)|0)?1:(w(Te|0,Be|0),p=Be|0,0)}function Fe(v){v=v|0;var Te=0,Be=0,xe=0;return Q(4)|0||(xe=y(p+1|0)|0,Te=p+5|0,Be=(p+5|0)+(xe|0)|0,Q(xe+4|0)|0)?1:(w(Te|0,Be|0),p=Be|0,0)}function Ve(v){return v=v|0,1}function me(v){return v=v|0,b(),p=p+1|0,0}function he(v){v=v|0;var Te=0,Be=0,xe=0;return xe=v-96|0,Q(xe|0)|0?1:(Te=p+1|0,Be=(p+1|0)+(xe|0)|0,B(Te|0,Be|0),p=Be|0,0)}function Ze(v){v=v|0;var Te=0,Be=0,xe=0;return Q(1)|0||(xe=i[p+1|0]|0,Te=p+2|0,Be=(p+2|0)+(xe|0)|0,Q(xe+1|0)|0)?1:(B(Te|0,Be|0),p=Be|0,0)}function Er(v){v=v|0;var Te=0,Be=0,xe=0;return Q(2)|0||(xe=l(p+1|0)|0,Te=p+3|0,Be=(p+3|0)+(xe|0)|0,Q(xe+2|0)|0)?1:(B(Te|0,Be|0),p=Be|0,0)}function Kr(v){v=v|0;var Te=0,Be=0,xe=0;return Q(4)|0||(xe=y(p+1|0)|0,Te=p+5|0,Be=(p+5|0)+(xe|0)|0,Q(xe+4|0)|0)?1:(B(Te|0,Be|0),p=Be|0,0)}function Fn(v){return v=v|0,1}function Lt(v){return v=v|0,S(),p=p+1|0,0}function Pe(v){return v=v|0,$(v-128|0),p=p+1|0,0}function qt(v){return v=v|0,Q(1)|0?1:($(i[p+1|0]|0),p=p+2|0,0)}function mt(v){return v=v|0,Q(2)|0?1:($(l(p+1|0)|0),p=p+3|0,0)}function Ye(v){return v=v|0,Q(4)|0?1:(z(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function yg(v){return v=v|0,Q(8)|0?1:(D(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function gg(v){return v=v|0,x(),p=p+1|0,0}function ze(v){v=v|0;var Te=0;return Te=v-160|0,Q(Te|0)|0?1:(ie(Te|0),p=p+1|0,0)}function mg(v){return v=v|0,Q(1)|0?1:(ie(i[p+1|0]|0),p=p+2|0,0)}function bg(v){return v=v|0,Q(2)|0?1:(ie(l(p+1|0)|0),p=p+3|0,0)}function _g(v){return v=v|0,Q(4)|0?1:(ee(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function wg(v){return v=v|0,Q(8)|0?1:(ne(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function Eg(v){return v=v|0,j(),p=p+1|0,0}function ri(v){return v=v|0,H(v-192|0|0),p=p+1|0,0}function h8(v){return v=v|0,H(v|0),p=p+1|0,0}function p8(v){return v=v|0,H(v|0),p=p+1|0,0}function y8(v){return v=v|0,H(v|0),p=p+1|0,0}function g8(v){return v=v|0,H(v|0),p=p+1|0,0}function lt(v){return v=v|0,H(v-192|0|0),p=p+1|0,0}function m8(v){return v=v|0,H(v|0),p=p+1|0,0}function b8(v){return v=v|0,H(v|0),p=p+1|0,0}function _8(v){return v=v|0,H(v|0),p=p+1|0,0}function xg(v){return v=v|0,Q(1)|0?1:(H(i[p+1|0]|0),p=p+2|0,0)}function vg(v){return v=v|0,Q(2)|0?1:(H(l(p+1|0)|0),p=p+3|0,0)}function Tg(v){return v=v|0,Q(4)|0?1:(Z(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function Ag(v){return v=v|0,Q(8)|0?1:(ae(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function rt(v){return v=v|0,N((v|0)-224|0),p=p+1|0,0}function Sg(v){return v=v|0,u(),p=p+1|0,0}function Bg(v){return v=v|0,_(),p=p+1|0,0}function Og(v){return v=v|0,O(),p=p+1|0,0}function Ng(v){return v=v|0,T(),p=p+1|0,0}function Rg(v){return v=v|0,Q(1)|0?1:(N(i[p+1|0]|0),p=p+2|0,0)}function Pg(v){v=v|0;var Te=0,Be=0,xe=1,Xs=0,Ki=0,w8=0;return Q(2)|0?1:(Te=i[p+1|0]|0,Be=i[p+2|0]|0,(Te|0)&128&&(xe=-1),Xs=+(((Te|0)&124)>>2),Ki=+(((Te|0)&3)<<8|Be),+Xs==0?d(+(+xe*5960464477539063e-23*+Ki)):+Xs==31?+xe==1?+Ki>0?M():R():+Ki>0?K():F():d(+(+xe*U(2,+(+Xs-25))*+(1024+Ki))),p=p+3|0,0)}function Ig(v){return v=v|0,Q(4)|0?1:(h(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0),p=p+5|0,0)}function Ug(v){return v=v|0,Q(8)|0?1:(m(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0,i[p+5|0]|0,i[p+6|0]|0,i[p+7|0]|0,i[p+8|0]|0),p=p+9|0,0)}function ke(v){return v=v|0,1}function Fg(v){return v=v|0,W(),p=p+1|0,0}var Mg=[g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,P,A,I,k,ke,ke,ke,ke,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,C,V,q,X,ke,ke,ke,ke,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,_e,Fe,Ve,ke,ke,ke,me,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,Ze,Er,Kr,Fn,ke,ke,ke,Lt,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,qt,mt,Ye,yg,ke,ke,ke,gg,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,mg,bg,_g,wg,ke,ke,ke,Eg,ri,ri,ri,ri,ri,ri,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,xg,vg,Tg,Ag,ke,ke,ke,ke,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,Sg,Bg,Og,Ng,Rg,Pg,Ig,Ug,ke,ke,ke,Fg];return{parse:fe}}});var ts=L(Yt=>{"use strict";var su=es().BigNumber;Yt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Yt.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};Yt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Yt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Yt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Yt.SHIFT32=Math.pow(2,32);Yt.SHIFT16=Math.pow(2,16);Yt.MAX_SAFE_HIGH=2097151;Yt.NEG_ONE=new su(-1);Yt.TEN=new su(10);Yt.TWO=new su(2);Yt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Io=L(rr=>{"use strict";var{Buffer:kb}=ni("buffer"),Hd=es().BigNumber,Vd=ts(),kd=Vd.SHIFT32,Hb=Vd.SHIFT16,Vb=2097151;rr.parseHalf=function(e){var r,n,i;return i=e[0]&128?-1:1,r=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function $b(t){return t<16?"0"+t.toString(16):t.toString(16)}rr.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=$b(t[n]);return new Hd(r,16)};rr.buildMap=t=>{let e=new Map,r=Object.keys(t),n=r.length;for(let i=0;i<n;i++)e.set(r[i],t[r[i]]);return e};rr.buildInt32=(t,e)=>t*Hb+e;rr.buildInt64=(t,e,r,n)=>{let i=rr.buildInt32(t,e),s=rr.buildInt32(r,n);return i>Vb?new Hd(i).times(kd).plus(s):i*kd+s};rr.writeHalf=function(e,r){let n=kb.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};rr.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])};rr.isNegativeZero=t=>t===0&&1/t<0;rr.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var uu=L((X8,$d)=>{"use strict";var cu=ts(),Kb=cu.MT,Uo=cu.SIMPLE,ou=cu.SYMS,au=class t{constructor(e){if(typeof e!="number")throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(e|0)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,Kb.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case Uo.FALSE:return!1;case Uo.TRUE:return!0;case Uo.NULL:return r?null:ou.NULL;case Uo.UNDEFINED:return r?void 0:ou.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return ou.BREAK;default:return new t(e)}}};$d.exports=au});var fu=L((J8,Kd)=>{"use strict";var lu=class t{constructor(e,r,n){if(this.tag=e,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(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var r,n;if(n=e?.[this.tag],typeof n!="function"&&(n=t["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(t,this.value)}catch(i){return r=i,this.err=r,this}}};Kd.exports=lu});var hu=L((Q8,Yd)=>{"use strict";var{URL:Gb,URLSearchParams:Yb,format:zb}=ni("url"),Gd="http://localhost",du=class extends Gb{constructor(e="",r=Gd){super(e,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()}};Yd.exports={URLWithLegacySupport:du,URLSearchParams:Yb,format:zb,defaultBase:Gd}});var Dd=L((L8,Wd)=>{"use strict";var{URLWithLegacySupport:zd,format:Wb}=hu();Wd.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new zd(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new zd(t,Wb(o)).toString()}});var pu=L((ev,Zd)=>{"use strict";var{URLWithLegacySupport:Db,format:Zb,URLSearchParams:Xb,defaultBase:Jb}=hu(),Qb=Dd();Zd.exports={URL:Db,URLSearchParams:Xb,format:Zb,relative:Qb,defaultBase:Jb}});var yu=L((tv,Jd)=>{"use strict";var{Buffer:_i}=ni("buffer"),Xd=yc(),Lb=es().BigNumber,e1=jd(),Rt=Io(),Ce=ts(),t1=uu(),r1=fu(),{URL:n1}=pu(),rs=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=Rt.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=_i.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>Rt.arrayBufferToBignumber(r),3:r=>Ce.NEG_ONE.minus(Rt.arrayBufferToBignumber(r)),4:r=>Ce.TEN.pow(r[0]).times(r[1]),5:r=>Ce.TWO.pow(r[0]).times(r[1]),32:r=>new n1(r),35:r=>new RegExp(r)},e.tags),this.parser=e1(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 e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case Ce.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case Ce.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case Ce.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case Ce.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case Ce.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case Ce.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===Ce.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,r){let n=this._currentParent;switch(n.values++,n.type){case Ce.PARENT.ARRAY:case Ce.PARENT.BYTE_STRING:case Ce.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case Ce.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=Ce.PARENT.MAP,n.ref=Rt.buildMap(n.ref)));break;case Ce.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case Ce.PARENT.TAG:this._ref.push(e),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,r,n){this._parents[this._depth]={type:r,length:n,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:Ce.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new r1(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return _i.concat(e)}createByteStringFromHeap(e,r){return e===r?_i.alloc(0):_i.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return Rt.buildInt32(e,r)}createInt64(e,r,n,i){return Rt.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return Xd.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return Xd.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-Rt.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=Rt.buildInt32(e,r),o=Rt.buildInt32(n,i);return s>Ce.MAX_SAFE_HIGH?Ce.NEG_ONE.minus(new Lb(s).times(Ce.SHIFT32).plus(o)):-1-(s*Ce.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,r){return e.join("")}createUtf8StringFromHeap(e,r){return e===r?"":this._buffer.toString("utf8",e,r)}createSimpleUnassigned(e){return new t1(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,r){this._push(this.createInt32(e,r))}pushInt64(e,r,n,i){this._push(this.createInt64(e,r,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,r,n,i){this._push(this.createFloatSingle(e,r,n,i))}pushFloatDouble(e,r,n,i,s,o,a,c){this._push(this.createFloatDouble(e,r,n,i,s,o,a,c))}pushInt32Neg(e,r){this._push(this.createInt32Neg(e,r))}pushInt64Neg(e,r,n,i){this._push(this.createInt64Neg(e,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([],Ce.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=Rt.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=Rt.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=Rt.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=Rt.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:Ce.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,r){this._push(this.createByteStringFromHeap(e,r))}pushUtf8StringStart(){this._parents[this._depth]={type:Ce.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,r){this._push(this.createUtf8StringFromHeap(e,r))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:Ce.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(Rt.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(Rt.buildInt64(e,r,n,i))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){if(e===0){this._push(this.createObject({}));return}this._createParent({},Ce.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),Ce.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let r=this.parser.parse(e.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(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,r){return typeof e=="string"&&(e=_i.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=_i.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};rs.decodeFirst=rs.decode;Jd.exports=rs});var e0=L((rv,Ld)=>{"use strict";var{Buffer:gu}=ni("buffer"),i1=yu(),s1=Io(),mu=class t extends i1{createTag(e,r){return`${e}(${r})`}createInt(e){return super.createInt(e).toString()}createInt32(e,r){return super.createInt32(e,r).toString()}createInt64(e,r,n,i){return super.createInt64(e,r,n,i).toString()}createInt32Neg(e,r){return super.createInt32Neg(e,r).toString()}createInt64Neg(e,r,n,i){return super.createInt64Neg(e,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let r=super.createFloat(e);return s1.isNegativeZero(e)?"-0_1":`${r}_1`}createFloatSingle(e,r,n,i){return`${super.createFloatSingle(e,r,n,i)}_2`}createFloatDouble(e,r,n,i,s,o,a,c){return`${super.createFloatDouble(e,r,n,i,s,o,a,c)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${gu.from(super.createByteStringFromHeap(e,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(e){return`simple(${e})`}createArray(e,r){let n=super.createArray(e,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(e,r){let n=super.createMap(e),i=Array.from(n.keys()).reduce(Qd(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(Qd(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${gu.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=gu.from(e,r||"hex")),new t().decodeFirst(e)}};Ld.exports=mu;function Qd(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var s0=L((nv,i0)=>{"use strict";var{Buffer:Rr}=ni("buffer"),{URL:o1}=pu(),_u=es().BigNumber,bu=Io(),st=ts(),ur=st.MT,Fo=st.NUMBYTES,t0=st.SHIFT32,r0=st.SYMS,wi=st.TAG,a1=st.MT.SIMPLE_FLOAT<<5|st.NUMBYTES.TWO,c1=st.MT.SIMPLE_FLOAT<<5|st.NUMBYTES.FOUR,u1=st.MT.SIMPLE_FLOAT<<5|st.NUMBYTES.EIGHT,l1=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.TRUE,f1=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.FALSE,d1=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.UNDEFINED,n0=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.NULL,h1=new _u("0x20000000000000"),p1=Rr.from("f97e00","hex"),y1=Rr.from("f9fc00","hex"),g1=Rr.from("f97c00","hex");function m1(t){return{}.toString.call(t).slice(8,-1)}var wu=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[o1,this._pushUrl],[_u,this._pushBigNumber]];let r=e.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(e,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===e){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}return this.semanticTypes.push([e,r]),null}push(e){return e&&(this.result[this.offset]=e,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=e.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(e,r,n){return this.result[this.offset]=e,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(e){return this.pushWrite(e,1,1)}_pushUInt16BE(e){return this.pushWrite(e,2,2)}_pushUInt32BE(e){return this.pushWrite(e,3,4)}_pushDoubleBE(e){return this.pushWrite(e,4,8)}_pushNaN(){return this.push(p1)}_pushInfinity(e){let r=e<0?y1:g1;return this.push(r)}_pushFloat(e){let r=Rr.allocUnsafe(2);if(bu.writeHalf(r,e)&&bu.parseHalf(r)===e)return this._pushUInt8(a1)&&this.push(r);let n=Rr.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(c1)&&this.push(n):this._pushUInt8(u1)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|Fo.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|Fo.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|Fo.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Fo.EIGHT)&&this._pushUInt32BE(Math.floor(e/t0))&&this._pushUInt32BE(e%t0):r===ur.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,ur.NEG_INT,e):this._pushInt(e,ur.POS_INT)}_pushNumber(e){switch(!1){case e===e:return this._pushNaN(e);case isFinite(e):return this._pushInfinity(e);case e%1!==0:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){let r=Rr.byteLength(e,"utf8");return this._pushInt(r,ur.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?l1:f1)}_pushUndefined(e){return this._pushUInt8(d1)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,ur.ARRAY))return!1;for(let i=0;i<n;i++)if(!e.pushAny(r[i]))return!1;return!0}_pushTag(e){return this._pushInt(e,ur.TAG)}_pushDate(e,r){return e._pushTag(wi.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,ur.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(wi.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,ur.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(wi.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=wi.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=wi.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Rr.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(e,r){if(r.isNaN())return e._pushNaN();if(!r.isFinite())return e._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return e._pushBigint(r);if(!(e._pushTag(wi.DECIMAL_FRAC)&&e._pushInt(2,ur.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new _u(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(h1)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,ur.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(n0);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(e instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(e,this,e);var i=e.encodeCBOR;if(typeof i=="function")return i.call(e,this);var s=Object.keys(e),o=s.length;return this._pushInt(o,ur.MAP)?this._pushRawMap(o,s.map(a=>[a,e[a]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(bu.keySorter);for(var n=0;n<e;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var r=m1(e);switch(r){case"Number":return this._pushNumber(e);case"String":return this._pushString(e);case"Boolean":return this._pushBoolean(e);case"Object":return this._pushObject(e);case"Array":return this._pushArray(this,e);case"Uint8Array":return this._pushBuffer(this,Rr.isBuffer(e)?e:Rr.from(e));case"Null":return this._pushUInt8(n0);case"Undefined":return this._pushUndefined(e);case"Map":return this._pushMap(this,e);case"Set":return this._pushSet(this,e);case"URL":return this._pushUrl(this,e);case"BigNumber":return this._pushBigNumber(this,e);case"Date":return this._pushDate(this,e);case"RegExp":return this._pushRegexp(this,e);case"Symbol":switch(e){case r0.NULL:return this._pushObject(null);case r0.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=Rr.allocUnsafe(s),c=0,f=0;for(o=0;o<i;o++){switch(f=r[o],n[o]){case 0:e[o].copy(a,c);break;case 1:a.writeUInt8(e[o],c,!0);break;case 2:a.writeUInt16BE(e[o],c,!0);break;case 3:a.writeUInt32BE(e[o],c,!0);break;case 4:a.writeDoubleBE(e[o],c,!0);break;case 5:a.write(e[o],c,f,"utf8");break;default:throw new Error("unkown method")}c+=f}var d=a;return this._reset(),d}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let r=new t;if(!r.pushAny(e))throw new Error("Failed to encode input");return r.finalize()}};i0.exports=wu});var Mo=L(ot=>{"use strict";ot.Diagnose=e0();ot.Decoder=yu();ot.Encoder=s0();ot.Simple=uu();ot.Tagged=fu();ot.decodeAll=ot.Decoder.decodeAll;ot.decodeFirst=ot.Decoder.decodeFirst;ot.diagnose=ot.Diagnose.diagnose;ot.encode=ot.Encoder.encode;ot.decode=ot.Decoder.decode;ot.leveldb={decode:ot.Decoder.decodeAll,encode:ot.Encoder.encode,buffer:!0,name:"cbor"}});var ss=L(nr=>{"use strict";var b1=nr&&nr.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(nr,"__esModule",{value:!0});nr.hashOfMap=nr.requestIdOf=nr.hashValue=nr.hash=void 0;var o0=bi(),_1=b1(Mo()),w1=oo(),ns=kt();function fn(t){return(0,ns.uint8ToBuf)(w1.sha256.create().update(new Uint8Array(t)).digest())}nr.hash=fn;function is(t){if(t instanceof _1.default.Tagged)return is(t.value);if(typeof t=="string")return a0(t);if(typeof t=="number")return fn((0,o0.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return fn(t);if(Array.isArray(t)){let e=t.map(is);return fn((0,ns.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return fn(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return is(t.toHash());if(typeof t=="object")return Eu(t);if(typeof t=="bigint")return fn((0,o0.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}nr.hashValue=is;var a0=t=>{let e=new TextEncoder().encode(t);return fn(e)};function E1(t){return Eu(t)}nr.requestIdOf=E1;function Eu(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=a0(o),f=is(a);return[c,f]}).sort(([o],[a])=>(0,ns.compare)(o,a)),i=(0,ns.concat)(...n.map(o=>(0,ns.concat)(...o)));return fn(i)}nr.hashOfMap=Eu});var Tu=L(Pr=>{"use strict";var x1=Pr&&Pr.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(Pr,"__esModule",{value:!0});Pr.createIdentityDescriptor=Pr.AnonymousIdentity=Pr.SignIdentity=void 0;var c0=Nt(),v1=ss(),u0=kt(),T1=new TextEncoder().encode(`
|
|
17
|
-
ic-request`),xu=class{getPrincipal(){return this._principal||(this._principal=c0.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=x1(e,["body"]),i=await(0,v1.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,u0.concat)(T1,i))}})}};Pr.SignIdentity=xu;var vu=class{getPrincipal(){return c0.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};Pr.AnonymousIdentity=vu;function A1(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,u0.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Pr.createIdentityDescriptor=A1});var Bu=L($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});var S1=9007199254740992;function Wr(t,...e){let r=new Uint8Array(t.byteLength+e.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(t),0);let n=t.byteLength;for(let i of e)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function lr(t,e,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(t<<5)+e].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function Co(t,e){if(e<24)return new Uint8Array([(t<<5)+e]).buffer;{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27;return lr(t,r,e.toString(16))}}function l0(t){let e=[];for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|t.charCodeAt(r)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Wr(new Uint8Array(Co(3,t.length)),new Uint8Array(e))}function B1(t,e){if(t==14277111)return Wr(new Uint8Array([217,217,247]),e);if(t<24)return Wr(new Uint8Array([192+t]),e);{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27,n=2**(r-24),i=t.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}$e.tagged=B1;function os(t){return new Uint8Array(t).buffer}$e.raw=os;function Au(t){if(isNaN(t))throw new RangeError("Invalid number.");t=Math.min(Math.max(0,t),23);let e=[0+t];return new Uint8Array(e).buffer}$e.uSmall=Au;function f0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),255),t=t.toString(16),lr(0,24,t)}$e.u8=f0;function d0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),65535),t=t.toString(16),lr(0,25,t)}$e.u16=d0;function h0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),4294967295),t=t.toString(16),lr(0,26,t)}$e.u32=h0;function Su(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return lr(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),S1),t=t.toString(16),lr(0,27,t)}$e.u64=Su;function p0(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Au(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}$e.iSmall=p0;function y0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),255),t=t.toString(16),lr(1,24,t)}$e.i8=y0;function g0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),65535),t=t.toString(16),lr(1,25,t)}$e.i16=g0;function m0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),4294967295),t=t.toString(16),lr(1,26,t)}$e.i32=m0;function b0(t,e){if(typeof t=="string"&&e==16){if(t.startsWith("-")?t=t.slice(1):t="0",t.match(/[^0-9a-fA-F]/)||t.length>16)throw new RangeError("Invalid number.");let r=!1,n=t.split("").reduceRight((i,s)=>{if(r)return s+i;let o=parseInt(s,16)-1;return o>=0?(r=!0,o.toString(16)+i):"f"+i},"");return r?lr(1,27,n):Su(0)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),9007199254740992),t=t.toString(16),lr(1,27,t)}$e.i64=b0;function O1(t){return t>=0?t<24?Au(t):t<=255?f0(t):t<=65535?d0(t):t<=4294967295?h0(t):Su(t):t>=-24?p0(t):t>=-255?y0(t):t>=-65535?g0(t):t>=-4294967295?m0(t):b0(t)}$e.number=O1;function N1(t){return Wr(Co(2,t.byteLength),t)}$e.bytes=N1;function R1(t){return l0(t)}$e.string=R1;function P1(t){return Wr(Co(4,t.length),...t)}$e.array=P1;function I1(t,e=!1){t instanceof Map||(t=new Map(Object.entries(t)));let r=Array.from(t.entries());return e&&(r=r.sort(([n],[i])=>n.localeCompare(i))),Wr(Co(5,t.size),...r.map(([n,i])=>Wr(l0(n),i)))}$e.map=I1;function U1(t){let e=new Float32Array([t]);return Wr(new Uint8Array([250]),new Uint8Array(e.buffer))}$e.singleFloat=U1;function F1(t){let e=new Float64Array([t]);return Wr(new Uint8Array([251]),new Uint8Array(e.buffer))}$e.doubleFloat=F1;function M1(t){return t?_0():w0()}$e.bool=M1;function _0(){return os(new Uint8Array([245]))}$e.true_=_0;function w0(){return os(new Uint8Array([244]))}$e.false_=w0;function C1(){return os(new Uint8Array([246]))}$e.null_=C1;function q1(){return os(new Uint8Array([247]))}$e.undefined_=q1});var E0=L(dn=>{"use strict";var j1=dn&&dn.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(dn,"__esModule",{value:!0});var fr=j1(Bu()),k1=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],qo=class{constructor(e,r=!1){this._serializer=e,this._stable=r,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return fr.undefined_();case"boolean":return fr.bool(e);case"number":return Math.floor(e)===e?fr.number(e):fr.doubleFloat(e);case"string":return fr.string(e);case"object":if(e===null)return fr.null_();if(Array.isArray(e))return fr.array(e.map(r=>this._serializer.serializeValue(r)));if(k1.find(r=>e instanceof r))return fr.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let r=new Map;for(let[n,i]of e.entries())r.set(n,this._serializer.serializeValue(i));return fr.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(e))r.set(n,this._serializer.serializeValue(i));return fr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};dn.JsonDefaultCborEncoder=qo;var jo=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};dn.ToCborEncoder=jo;var ko=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new qo(r,e)),r.addEncoder(new jo),r}removeEncoder(e){for(let r of this._encoders.values())r.name==e&&this._encoders.delete(r)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(e)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};dn.CborSerializer=ko;var Ou=class extends ko{serialize(e){return fr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};dn.SelfDescribeCborSerializer=Ou});var as=L(kn=>{"use strict";function H1(t){for(var e in t)kn.hasOwnProperty(e)||(kn[e]=t[e])}var V1=kn&&kn.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(kn,"__esModule",{value:!0});H1(E0());var $1=V1(Bu());kn.value=$1});var cs=L(bt=>{"use strict";var K1=bt&&bt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),G1=bt&&bt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Y1=bt&&bt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&K1(e,t,r);return G1(e,t),e},z1=bt&&bt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bt,"__esModule",{value:!0});bt.decode=bt.encode=bt.CborTag=void 0;var W1=z1(Mo()),Ei=Y1(as()),D1=as(),Ho=kt(),Nu=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Ei.value.bytes(e.toUint8Array())}},Ru=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Ei.value.bytes(new Uint8Array(e))}},Pu=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Ei.value.tagged(2,Ei.value.bytes((0,Ho.fromHex)(e.toString(16)))):Ei.value.tagged(3,Ei.value.bytes((0,Ho.fromHex)((BigInt("-1")*e).toString(16))))}},Vo=D1.SelfDescribeCborSerializer.withDefaultEncoders(!0);Vo.addEncoder(new Nu);Vo.addEncoder(new Ru);Vo.addEncoder(new Pu);var v0;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(v0=bt.CborTag||(bt.CborTag={}));function Z1(t){return Vo.serialize(t)}bt.encode=Z1;function x0(t){let e=t.byteLength,r=BigInt(0);for(let n=0;n<e;n++)r=r*BigInt(256)+BigInt(t[n]);return r}var Iu=class extends W1.default.Decoder{createByteString(e){return(0,Ho.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function X1(t){let e=new Uint8Array(t),r=new Iu({size:e.byteLength,tags:{2:n=>x0(n),3:n=>-x0(n),[v0.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,Ho.toHex)(e)}`)}}bt.decode=X1});var Uu=L($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.randomNumber=void 0;var J1=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};$o.randomNumber=J1});var us=L(Hn=>{"use strict";Object.defineProperty(Hn,"__esModule",{value:!0});Hn.makeNonce=Hn.SubmitRequestType=void 0;var Ko=Uu(),Q1;(function(t){t.Call="call"})(Q1=Hn.SubmitRequestType||(Hn.SubmitRequestType={}));function L1(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,Ko.randomNumber)(),n=(0,Ko.randomNumber)(),i=(0,Ko.randomNumber)(),s=(0,Ko.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}Hn.makeNonce=L1});var Yo=L(At=>{"use strict";var e_=At&&At.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),t_=At&&At.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r_=At&&At.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&e_(e,t,r);return t_(e,t),e};Object.defineProperty(At,"__esModule",{value:!0});At.httpHeadersTransform=At.makeExpiryTransform=At.makeNonceTransform=At.Expiry=void 0;var n_=bi(),i_=r_(as()),s_=us(),T0=BigInt(1e6),o_=60*1e3,Go=class{constructor(e){if(e<90*1e3){let a=BigInt(Date.now()+e)*T0/BigInt(1e9);this._value=a*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-o_))*T0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return i_.value.u64(this._value.toString(16),16)}toHash(){return(0,n_.lebEncode)(this._value)}};At.Expiry=Go;function a_(t=s_.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}At.makeNonceTransform=a_;function c_(t){return async e=>{e.body.ingress_expiry=new Go(t)}}At.makeExpiryTransform=c_;function u_(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}At.httpHeadersTransform=u_});var Mu=L(zo=>{"use strict";Object.defineProperty(zo,"__esModule",{value:!0});zo.AgentHTTPResponseError=void 0;var l_=fi(),Fu=class extends l_.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};zo.AgentHTTPResponseError=Fu});var zt=L(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.notImplemented=Ie.bitMask=void 0;Ie.isBytes=Do;Ie.abytes=Zo;Ie.abool=d_;Ie.bytesToHex=ku;Ie.numberToHexUnpadded=B0;Ie.hexToNumber=Hu;Ie.hexToBytes=Xo;Ie.bytesToNumberBE=p_;Ie.bytesToNumberLE=y_;Ie.numberToBytesBE=O0;Ie.numberToBytesLE=g_;Ie.numberToVarBytesBE=m_;Ie.ensureBytes=b_;Ie.concatBytes=N0;Ie.equalBytes=__;Ie.utf8ToBytes=w_;Ie.inRange=R0;Ie.aInRange=E_;Ie.bitLen=x_;Ie.bitGet=v_;Ie.bitSet=T_;Ie.createHmacDrbg=S_;Ie.validateObject=O_;Ie.memoized=R_;var ju=BigInt(0),Wo=BigInt(1),f_=BigInt(2);function Do(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Zo(t){if(!Do(t))throw new Error("Uint8Array expected")}function d_(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}var h_=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ku(t){Zo(t);let e="";for(let r=0;r<t.length;r++)e+=h_[t[r]];return e}function B0(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function Hu(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Dr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function A0(t){if(t>=Dr._0&&t<=Dr._9)return t-Dr._0;if(t>=Dr._A&&t<=Dr._F)return t-(Dr._A-10);if(t>=Dr._a&&t<=Dr._f)return t-(Dr._a-10)}function Xo(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=A0(t.charCodeAt(s)),a=A0(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function p_(t){return Hu(ku(t))}function y_(t){return Zo(t),Hu(ku(Uint8Array.from(t).reverse()))}function O0(t,e){return Xo(t.toString(16).padStart(e*2,"0"))}function g_(t,e){return O0(t,e).reverse()}function m_(t){return Xo(B0(t))}function b_(t,e,r){let n;if(typeof e=="string")try{n=Xo(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(Do(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function N0(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];Zo(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function __(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function w_(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}var Cu=t=>typeof t=="bigint"&&ju<=t;function R0(t,e,r){return Cu(t)&&Cu(e)&&Cu(r)&&e<=t&&t<r}function E_(t,e,r,n){if(!R0(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function x_(t){let e;for(e=0;t>ju;t>>=Wo,e+=1);return e}function v_(t,e){return t>>BigInt(e)&Wo}function T_(t,e,r){return t|(r?Wo:ju)<<BigInt(e)}var A_=t=>(f_<<BigInt(t-1))-Wo;Ie.bitMask=A_;var qu=t=>new Uint8Array(t),S0=t=>Uint8Array.from(t);function S_(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=qu(t),i=qu(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...h)=>r(i,n,...h),c=(h=qu())=>{i=a(S0([0]),h),n=a(),h.length!==0&&(i=a(S0([1]),h),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,m=[];for(;h<e;){n=a();let _=n.slice();m.push(_),h+=n.length}return N0(...m)};return(h,m)=>{o(),c(h);let _;for(;!(_=m(f()));)c();return o(),_}}var B_={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Do(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function O_(t,e,r={}){let n=(i,s,o)=>{let a=B_[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return t}var N_=()=>{throw new Error("not implemented")};Ie.notImplemented=N_;function R_(t){let e=new WeakMap;return(r,...n)=>{let i=e.get(r);if(i!==void 0)return i;let s=t(r,...n);return e.set(r,s),s}}});var Ir=L(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.isNegativeLE=void 0;We.mod=Wt;We.pow=U0;We.pow2=F_;We.invert=Jo;We.tonelliShanks=F0;We.FpSqrt=M0;We.validateField=q_;We.FpPow=C0;We.FpInvertBatch=q0;We.FpDiv=j_;We.FpLegendre=j0;We.FpIsSquare=k_;We.nLength=$u;We.Field=H_;We.FpSqrtOdd=V_;We.FpSqrtEven=$_;We.hashToPrivateScalar=K_;We.getFieldBytesLength=Ku;We.getMinHashLength=k0;We.mapHashToField=G_;var Dt=zt(),at=BigInt(0),He=BigInt(1),hn=BigInt(2),P_=BigInt(3),Vu=BigInt(4),P0=BigInt(5),I0=BigInt(8),I_=BigInt(9),U_=BigInt(16);function Wt(t,e){let r=t%e;return r>=at?r:e+r}function U0(t,e,r){if(r<=at||e<at)throw new Error("Expected power/modulo > 0");if(r===He)return at;let n=He;for(;e>at;)e&He&&(n=n*t%r),t=t*t%r,e>>=He;return n}function F_(t,e,r){let n=t;for(;e-- >at;)n*=n,n%=r;return n}function Jo(t,e){if(t===at||e<=at)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Wt(t,e),n=e,i=at,s=He,o=He,a=at;for(;r!==at;){let f=n/r,d=n%r,h=i-o*f,m=s-a*f;n=r,r=d,i=o,s=a,o=h,a=m}if(n!==He)throw new Error("invert: does not exist");return Wt(i,e)}function F0(t){let e=(t-He)/hn,r,n,i;for(r=t-He,n=0;r%hn===at;r/=hn,n++);for(i=hn;i<t&&U0(i,e,t)!==t-He;i++);if(n===1){let o=(t+He)/Vu;return function(c,f){let d=c.pow(f,o);if(!c.eql(c.sqr(d),f))throw new Error("Cannot find square root");return d}}let s=(r+He)/hn;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,d=a.pow(a.mul(a.ONE,i),r),h=a.pow(c,s),m=a.pow(c,r);for(;!a.eql(m,a.ONE);){if(a.eql(m,a.ZERO))return a.ZERO;let _=1;for(let T=a.sqr(m);_<f&&!a.eql(T,a.ONE);_++)T=a.sqr(T);let u=a.pow(d,He<<BigInt(f-_-1));d=a.sqr(u),h=a.mul(h,u),m=a.mul(m,d),f=_}return h}}function M0(t){if(t%Vu===P_){let e=(t+He)/Vu;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%I0===P0){let e=(t-P0)/I0;return function(n,i){let s=n.mul(i,hn),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,hn),o),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%U_,F0(t)}var M_=(t,e)=>(Wt(t,e)&He)===He;We.isNegativeLE=M_;var C_=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function q_(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=C_.reduce((n,i)=>(n[i]="function",n),e);return(0,Dt.validateObject)(t,r)}function C0(t,e,r){if(r<at)throw new Error("Expected power > 0");if(r===at)return t.ONE;if(r===He)return e;let n=t.ONE,i=e;for(;r>at;)r&He&&(n=t.mul(n,i)),i=t.sqr(i),r>>=He;return n}function q0(t,e){let r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function j_(t,e,r){return t.mul(e,typeof r=="bigint"?Jo(r,t.ORDER):t.inv(r))}function j0(t){let e=(t-He)/hn;return(r,n)=>r.pow(n,e)}function k_(t){let e=j0(t.ORDER);return r=>{let n=e(t,r);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}function $u(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function H_(t,e,r=!1,n={}){if(t<=at)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=$u(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=M0(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Dt.bitMask)(i),ZERO:at,ONE:He,create:c=>Wt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return at<=c&&c<t},is0:c=>c===at,isOdd:c=>(c&He)===He,neg:c=>Wt(-c,t),eql:(c,f)=>c===f,sqr:c=>Wt(c*c,t),add:(c,f)=>Wt(c+f,t),sub:(c,f)=>Wt(c-f,t),mul:(c,f)=>Wt(c*f,t),pow:(c,f)=>C0(a,c,f),div:(c,f)=>Wt(c*Jo(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Jo(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>q0(a,c),cmov:(c,f,d)=>d?f:c,toBytes:c=>r?(0,Dt.numberToBytesLE)(c,s):(0,Dt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Dt.bytesToNumberLE)(c):(0,Dt.bytesToNumberBE)(c)}});return Object.freeze(a)}function V_(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)}function $_(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function K_(t,e,r=!1){t=(0,Dt.ensureBytes)("privateHash",t);let n=t.length,i=$u(e).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,Dt.bytesToNumberLE)(t):(0,Dt.bytesToNumberBE)(t);return Wt(s,e-He)+He}function Ku(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function k0(t){let e=Ku(t);return e+Math.ceil(e/2)}function G_(t,e,r=!1){let n=t.length,i=Ku(e),s=k0(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Dt.bytesToNumberBE)(t):(0,Dt.bytesToNumberLE)(t),a=Wt(o,e-He)+He;return r?(0,Dt.numberToBytesLE)(a,i):(0,Dt.numberToBytesBE)(a,i)}});var Qo=L(Vn=>{"use strict";Object.defineProperty(Vn,"__esModule",{value:!0});Vn.expand_message_xmd=H0;Vn.expand_message_xof=V0;Vn.hash_to_field=Gu;Vn.isogenyMap=D_;Vn.createHasher=Z_;var Y_=Ir(),St=zt(),z_=St.bytesToNumberBE;function pn(t,e){if(ls(t),ls(e),t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function W_(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function ls(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function H0(t,e,r,n){(0,St.abytes)(t),(0,St.abytes)(e),ls(r),e.length>255&&(e=n((0,St.concatBytes)((0,St.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=(0,St.concatBytes)(e,pn(e.length,1)),c=pn(0,s),f=pn(r,2),d=new Array(o),h=n((0,St.concatBytes)(c,t,f,pn(0,1),a));d[0]=n((0,St.concatBytes)(h,pn(1,1),a));for(let _=1;_<=o;_++){let u=[W_(h,d[_-1]),pn(_+1,1),a];d[_]=n((0,St.concatBytes)(...u))}return(0,St.concatBytes)(...d).slice(0,r)}function V0(t,e,r,n,i){if((0,St.abytes)(t),(0,St.abytes)(e),ls(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update((0,St.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(pn(r,2)).update(e).update(pn(e.length,1)).digest()}function Gu(t,e,r){(0,St.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:a,DST:c}=r;(0,St.abytes)(t),ls(e);let f=typeof c=="string"?(0,St.utf8ToBytes)(c):c,d=n.toString(2).length,h=Math.ceil((d+i)/8),m=e*s*h,_;if(a==="xmd")_=H0(t,f,m,o);else if(a==="xof")_=V0(t,f,m,i,o);else if(a==="_internal_pass")_=t;else throw new Error('expand must be "xmd" or "xof"');let u=new Array(e);for(let T=0;T<e;T++){let O=new Array(s);for(let R=0;R<s;R++){let F=h*(R+T*s),M=_.subarray(F,F+h);O[R]=(0,Y_.mod)(z_(M),n)}u[T]=O}return u}function D_(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(f=>f.reduce((d,h)=>t.add(t.mul(d,n),h)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}function Z_(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=Gu(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=Gu(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=t.fromAffine(e(n)).clearCofactor();return i.assertValidity(),i}}}});var Wu=L(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0});fs.wNAF=J_;fs.pippenger=Q_;fs.validateBasic=L_;var $0=Ir(),G0=zt(),X_=BigInt(0),Yu=BigInt(1),zu=new WeakMap,K0=new WeakMap;function J_(t,e){let r=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=t.ZERO,c=s;for(;o>X_;)o&Yu&&(a=a.add(c)),c=c.double(),o>>=Yu;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),f=[],d=s,h=d;for(let m=0;m<a;m++){h=d,f.push(h);for(let _=1;_<c;_++)h=h.add(d),f.push(h);d=h.double()}return f},wNAF(s,o,a){let{windows:c,windowSize:f}=i(s),d=t.ZERO,h=t.BASE,m=BigInt(2**s-1),_=2**s,u=BigInt(s);for(let T=0;T<c;T++){let O=T*f,R=Number(a&m);a>>=u,R>f&&(R-=_,a+=Yu);let F=O,M=O+Math.abs(R)-1,K=T%2!==0,x=R<0;R===0?h=h.add(r(K,o[F])):d=d.add(r(x,o[M]))}return{p:d,f:h}},wNAFCached(s,o,a){let c=K0.get(s)||1,f=zu.get(s);return f||(f=this.precomputeWindow(s,c),c!==1&&zu.set(s,a(f))),this.wNAF(c,f,o)},setWindowSize(s,o){n(o),K0.set(s,o),zu.delete(s)}}}function Q_(t,e,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((d,h)=>{if(!e.isValid(d))throw new Error(`wrong scalar at index ${h}`)}),r.forEach((d,h)=>{if(!(d instanceof t))throw new Error(`wrong point at index ${h}`)});let i=(0,G0.bitLen)(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,a=new Array(o+1).fill(t.ZERO),c=Math.floor((e.BITS-1)/s)*s,f=t.ZERO;for(let d=c;d>=0;d-=s){a.fill(t.ZERO);for(let m=0;m<n.length;m++){let _=n[m],u=Number(_>>BigInt(d)&BigInt(o));a[u]=a[u].add(r[m])}let h=t.ZERO;for(let m=a.length-1,_=t.ZERO;m>0;m--)_=_.add(a[m]),h=h.add(_);if(f=f.add(h),d!==0)for(let m=0;m<s;m++)f=f.double()}return f}function L_(t){return(0,$0.validateField)(t.Fp),(0,G0.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,$0.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}});var Du=L(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.DER=void 0;wt.weierstrassPoints=W0;wt.weierstrass=iw;wt.SWUFpSqrtRatio=D0;wt.mapToCurveSimpleSWU=sw;var Lo=Wu(),$n=Ir(),Ae=zt(),_t=zt();function Y0(t){t.lowS!==void 0&&(0,_t.abool)("lowS",t.lowS),t.prehash!==void 0&&(0,_t.abool)("prehash",t.prehash)}function ew(t){let e=(0,Lo.validateBasic)(t);Ae.validateObject(e,{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}=e;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({...e})}var{bytesToNumberBE:tw,hexToBytes:rw}=Ae;wt.DER={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,e)=>{let{Err:r}=wt.DER;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,i=Ae.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Ae.numberToHexUnpadded(i.length/2|128):"";return`${Ae.numberToHexUnpadded(t)}${s}${i}${e}`},decode(t,e){let{Err:r}=wt.DER,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let i=e[n++],s=!!(i&128),o=0;if(!s)o=i;else{let c=i&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of f)o=o<<8|d;if(n+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){let{Err:e}=wt.DER;if(t<dr)throw new e("integer: negative integers are not allowed");let r=Ae.numberToHexUnpadded(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected assertion");return r},decode(t){let{Err:e}=wt.DER;if(t[0]&128)throw new e("Invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return tw(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=wt.DER,i=typeof t=="string"?rw(t):t;Ae.abytes(i);let{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:f,l:d}=n.decode(2,c);if(d.length)throw new e("Invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(t){let{_tlv:e,_int:r}=wt.DER,n=`${e.encode(2,r.encode(t.r))}${e.encode(2,r.encode(t.s))}`;return e.encode(48,n)}};var dr=BigInt(0),qe=BigInt(1),yn=BigInt(2),ea=BigInt(3),z0=BigInt(4);function W0(t){let e=ew(t),{Fp:r}=e,n=$n.Field(e.n,e.nBitLength),i=e.toBytes||((T,O,R)=>{let F=O.toAffine();return Ae.concatBytes(Uint8Array.from([4]),r.toBytes(F.x),r.toBytes(F.y))}),s=e.fromBytes||(T=>{let O=T.subarray(1),R=r.fromBytes(O.subarray(0,r.BYTES)),F=r.fromBytes(O.subarray(r.BYTES,2*r.BYTES));return{x:R,y:F}});function o(T){let{a:O,b:R}=e,F=r.sqr(T),M=r.mul(F,T);return r.add(r.add(M,r.mul(T,O)),R)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(T){return Ae.inRange(T,qe,e.n)}function c(T){let{allowedPrivateKeyLengths:O,nByteLength:R,wrapPrivateKey:F,n:M}=e;if(O&&typeof T!="bigint"){if(Ae.isBytes(T)&&(T=Ae.bytesToHex(T)),typeof T!="string"||!O.includes(T.length))throw new Error("Invalid key");T=T.padStart(R*2,"0")}let K;try{K=typeof T=="bigint"?T:Ae.bytesToNumberBE((0,_t.ensureBytes)("private key",T,R))}catch{throw new Error(`private key must be ${R} bytes, hex or bigint, not ${typeof T}`)}return F&&(K=$n.mod(K,M)),Ae.aInRange("private key",K,qe,M),K}function f(T){if(!(T instanceof m))throw new Error("ProjectivePoint expected")}let d=(0,_t.memoized)((T,O)=>{let{px:R,py:F,pz:M}=T;if(r.eql(M,r.ONE))return{x:R,y:F};let K=T.is0();O==null&&(O=K?r.ONE:r.inv(M));let x=r.mul(R,O),$=r.mul(F,O),z=r.mul(M,O);if(K)return{x:r.ZERO,y:r.ZERO};if(!r.eql(z,r.ONE))throw new Error("invZ was invalid");return{x,y:$}}),h=(0,_t.memoized)(T=>{if(T.is0()){if(e.allowInfinityPoint&&!r.is0(T.py))return;throw new Error("bad point: ZERO")}let{x:O,y:R}=T.toAffine();if(!r.isValid(O)||!r.isValid(R))throw new Error("bad point: x or y not FE");let F=r.sqr(R),M=o(O);if(!r.eql(F,M))throw new Error("bad point: equation left != right");if(!T.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(O,R,F){if(this.px=O,this.py=R,this.pz=F,O==null||!r.isValid(O))throw new Error("x required");if(R==null||!r.isValid(R))throw new Error("y required");if(F==null||!r.isValid(F))throw new Error("z required");Object.freeze(this)}static fromAffine(O){let{x:R,y:F}=O||{};if(!O||!r.isValid(R)||!r.isValid(F))throw new Error("invalid affine point");if(O instanceof m)throw new Error("projective point not allowed");let M=K=>r.eql(K,r.ZERO);return M(R)&&M(F)?m.ZERO:new m(R,F,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(O){let R=r.invertBatch(O.map(F=>F.pz));return O.map((F,M)=>F.toAffine(R[M])).map(m.fromAffine)}static fromHex(O){let R=m.fromAffine(s((0,_t.ensureBytes)("pointHex",O)));return R.assertValidity(),R}static fromPrivateKey(O){return m.BASE.multiply(c(O))}static msm(O,R){return(0,Lo.pippenger)(m,n,O,R)}_setWindowSize(O){u.setWindowSize(this,O)}assertValidity(){h(this)}hasEvenY(){let{y:O}=this.toAffine();if(r.isOdd)return!r.isOdd(O);throw new Error("Field doesn't support isOdd")}equals(O){f(O);let{px:R,py:F,pz:M}=this,{px:K,py:x,pz:$}=O,z=r.eql(r.mul(R,$),r.mul(K,M)),D=r.eql(r.mul(F,$),r.mul(x,M));return z&&D}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:O,b:R}=e,F=r.mul(R,ea),{px:M,py:K,pz:x}=this,$=r.ZERO,z=r.ZERO,D=r.ZERO,j=r.mul(M,M),ie=r.mul(K,K),ee=r.mul(x,x),ne=r.mul(M,K);return ne=r.add(ne,ne),D=r.mul(M,x),D=r.add(D,D),$=r.mul(O,D),z=r.mul(F,ee),z=r.add($,z),$=r.sub(ie,z),z=r.add(ie,z),z=r.mul($,z),$=r.mul(ne,$),D=r.mul(F,D),ee=r.mul(O,ee),ne=r.sub(j,ee),ne=r.mul(O,ne),ne=r.add(ne,D),D=r.add(j,j),j=r.add(D,j),j=r.add(j,ee),j=r.mul(j,ne),z=r.add(z,j),ee=r.mul(K,x),ee=r.add(ee,ee),j=r.mul(ee,ne),$=r.sub($,j),D=r.mul(ee,ie),D=r.add(D,D),D=r.add(D,D),new m($,z,D)}add(O){f(O);let{px:R,py:F,pz:M}=this,{px:K,py:x,pz:$}=O,z=r.ZERO,D=r.ZERO,j=r.ZERO,ie=e.a,ee=r.mul(e.b,ea),ne=r.mul(R,K),w=r.mul(F,x),b=r.mul(M,$),B=r.add(R,F),S=r.add(K,x);B=r.mul(B,S),S=r.add(ne,w),B=r.sub(B,S),S=r.add(R,M);let N=r.add(K,$);return S=r.mul(S,N),N=r.add(ne,b),S=r.sub(S,N),N=r.add(F,M),z=r.add(x,$),N=r.mul(N,z),z=r.add(w,b),N=r.sub(N,z),j=r.mul(ie,S),z=r.mul(ee,b),j=r.add(z,j),z=r.sub(w,j),j=r.add(w,j),D=r.mul(z,j),w=r.add(ne,ne),w=r.add(w,ne),b=r.mul(ie,b),S=r.mul(ee,S),w=r.add(w,b),b=r.sub(ne,b),b=r.mul(ie,b),S=r.add(S,b),ne=r.mul(w,S),D=r.add(D,ne),ne=r.mul(N,S),z=r.mul(B,z),z=r.sub(z,ne),ne=r.mul(B,w),j=r.mul(N,j),j=r.add(j,ne),new m(z,D,j)}subtract(O){return this.add(O.negate())}is0(){return this.equals(m.ZERO)}wNAF(O){return u.wNAFCached(this,O,m.normalizeZ)}multiplyUnsafe(O){Ae.aInRange("scalar",O,dr,e.n);let R=m.ZERO;if(O===dr)return R;if(O===qe)return this;let{endo:F}=e;if(!F)return u.unsafeLadder(this,O);let{k1neg:M,k1:K,k2neg:x,k2:$}=F.splitScalar(O),z=R,D=R,j=this;for(;K>dr||$>dr;)K&qe&&(z=z.add(j)),$&qe&&(D=D.add(j)),j=j.double(),K>>=qe,$>>=qe;return M&&(z=z.negate()),x&&(D=D.negate()),D=new m(r.mul(D.px,F.beta),D.py,D.pz),z.add(D)}multiply(O){let{endo:R,n:F}=e;Ae.aInRange("scalar",O,qe,F);let M,K;if(R){let{k1neg:x,k1:$,k2neg:z,k2:D}=R.splitScalar(O),{p:j,f:ie}=this.wNAF($),{p:ee,f:ne}=this.wNAF(D);j=u.constTimeNegate(x,j),ee=u.constTimeNegate(z,ee),ee=new m(r.mul(ee.px,R.beta),ee.py,ee.pz),M=j.add(ee),K=ie.add(ne)}else{let{p:x,f:$}=this.wNAF(O);M=x,K=$}return m.normalizeZ([M,K])[0]}multiplyAndAddUnsafe(O,R,F){let M=m.BASE,K=($,z)=>z===dr||z===qe||!$.equals(M)?$.multiplyUnsafe(z):$.multiply(z),x=K(this,R).add(K(O,F));return x.is0()?void 0:x}toAffine(O){return d(this,O)}isTorsionFree(){let{h:O,isTorsionFree:R}=e;if(O===qe)return!0;if(R)return R(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:O,clearCofactor:R}=e;return O===qe?this:R?R(m,this):this.multiplyUnsafe(e.h)}toRawBytes(O=!0){return(0,_t.abool)("isCompressed",O),this.assertValidity(),i(m,this,O)}toHex(O=!0){return(0,_t.abool)("isCompressed",O),Ae.bytesToHex(this.toRawBytes(O))}}m.BASE=new m(e.Gx,e.Gy,r.ONE),m.ZERO=new m(r.ZERO,r.ONE,r.ZERO);let _=e.nBitLength,u=(0,Lo.wNAF)(m,e.endo?Math.ceil(_/2):_);return{CURVE:e,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function nw(t){let e=(0,Lo.validateBasic)(t);return Ae.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function iw(t){let e=nw(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(b){return $n.mod(b,n)}function a(b){return $n.invert(b,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:d,isWithinCurveOrder:h}=W0({...e,toBytes(b,B,S){let N=B.toAffine(),H=r.toBytes(N.x),Z=Ae.concatBytes;return(0,_t.abool)("isCompressed",S),S?Z(Uint8Array.from([B.hasEvenY()?2:3]),H):Z(Uint8Array.from([4]),H,r.toBytes(N.y))},fromBytes(b){let B=b.length,S=b[0],N=b.subarray(1);if(B===i&&(S===2||S===3)){let H=Ae.bytesToNumberBE(N);if(!Ae.inRange(H,qe,r.ORDER))throw new Error("Point is not on curve");let Z=d(H),ae;try{ae=r.sqrt(Z)}catch(U){let p=U instanceof Error?": "+U.message:"";throw new Error("Point is not on curve"+p)}let oe=(ae&qe)===qe;return(S&1)===1!==oe&&(ae=r.neg(ae)),{x:H,y:ae}}else if(B===s&&S===4){let H=r.fromBytes(N.subarray(0,r.BYTES)),Z=r.fromBytes(N.subarray(r.BYTES,2*r.BYTES));return{x:H,y:Z}}else throw new Error(`Point of length ${B} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=b=>Ae.bytesToHex(Ae.numberToBytesBE(b,e.nByteLength));function _(b){let B=n>>qe;return b>B}function u(b){return _(b)?o(-b):b}let T=(b,B,S)=>Ae.bytesToNumberBE(b.slice(B,S));class O{constructor(B,S,N){this.r=B,this.s=S,this.recovery=N,this.assertValidity()}static fromCompact(B){let S=e.nByteLength;return B=(0,_t.ensureBytes)("compactSignature",B,S*2),new O(T(B,0,S),T(B,S,2*S))}static fromDER(B){let{r:S,s:N}=wt.DER.toSig((0,_t.ensureBytes)("DER",B));return new O(S,N)}assertValidity(){Ae.aInRange("r",this.r,qe,n),Ae.aInRange("s",this.s,qe,n)}addRecoveryBit(B){return new O(this.r,this.s,B)}recoverPublicKey(B){let{r:S,s:N,recovery:H}=this,Z=$((0,_t.ensureBytes)("msgHash",B));if(H==null||![0,1,2,3].includes(H))throw new Error("recovery id invalid");let ae=H===2||H===3?S+e.n:S;if(ae>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let oe=H&1?"03":"02",W=c.fromHex(oe+m(ae)),U=a(ae),p=o(-Z*U),J=o(N*U),re=c.BASE.multiplyAndAddUnsafe(W,p,J);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new O(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ae.hexToBytes(this.toDERHex())}toDERHex(){return wt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ae.hexToBytes(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let R={isValidPrivateKey(b){try{return f(b),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let b=$n.getMinHashLength(e.n);return $n.mapHashToField(e.randomBytes(b),e.n)},precompute(b=8,B=c.BASE){return B._setWindowSize(b),B.multiply(BigInt(3)),B}};function F(b,B=!0){return c.fromPrivateKey(b).toRawBytes(B)}function M(b){let B=Ae.isBytes(b),S=typeof b=="string",N=(B||S)&&b.length;return B?N===i||N===s:S?N===2*i||N===2*s:b instanceof c}function K(b,B,S=!0){if(M(b))throw new Error("first arg must be private key");if(!M(B))throw new Error("second arg must be public key");return c.fromHex(B).multiply(f(b)).toRawBytes(S)}let x=e.bits2int||function(b){let B=Ae.bytesToNumberBE(b),S=b.length*8-e.nBitLength;return S>0?B>>BigInt(S):B},$=e.bits2int_modN||function(b){return o(x(b))},z=Ae.bitMask(e.nBitLength);function D(b){return Ae.aInRange(`num < 2^${e.nBitLength}`,b,dr,z),Ae.numberToBytesBE(b,e.nByteLength)}function j(b,B,S=ie){if(["recovered","canonical"].some(Q=>Q in S))throw new Error("sign() legacy options not supported");let{hash:N,randomBytes:H}=e,{lowS:Z,prehash:ae,extraEntropy:oe}=S;Z==null&&(Z=!0),b=(0,_t.ensureBytes)("msgHash",b),Y0(S),ae&&(b=(0,_t.ensureBytes)("prehashed msgHash",N(b)));let W=$(b),U=f(B),p=[D(U),D(W)];if(oe!=null&&oe!==!1){let Q=oe===!0?H(r.BYTES):oe;p.push((0,_t.ensureBytes)("extraEntropy",Q))}let J=Ae.concatBytes(...p),re=W;function fe(Q){let l=x(Q);if(!h(l))return;let y=a(l),g=c.BASE.multiply(l).toAffine(),P=o(g.x);if(P===dr)return;let A=o(y*o(re+P*U));if(A===dr)return;let I=(g.x===P?0:2)|Number(g.y&qe),k=A;return Z&&_(A)&&(k=u(A),I^=1),new O(P,k,I)}return{seed:J,k2sig:fe}}let ie={lowS:e.lowS,prehash:!1},ee={lowS:e.lowS,prehash:!1};function ne(b,B,S=ie){let{seed:N,k2sig:H}=j(b,B,S),Z=e;return Ae.createHmacDrbg(Z.hash.outputLen,Z.nByteLength,Z.hmac)(N,H)}c.BASE._setWindowSize(8);function w(b,B,S,N=ee){let H=b;if(B=(0,_t.ensureBytes)("msgHash",B),S=(0,_t.ensureBytes)("publicKey",S),"strict"in N)throw new Error("options.strict was renamed to lowS");Y0(N);let{lowS:Z,prehash:ae}=N,oe,W;try{if(typeof H=="string"||Ae.isBytes(H))try{oe=O.fromDER(H)}catch(g){if(!(g instanceof wt.DER.Err))throw g;oe=O.fromCompact(H)}else if(typeof H=="object"&&typeof H.r=="bigint"&&typeof H.s=="bigint"){let{r:g,s:P}=H;oe=new O(g,P)}else throw new Error("PARSE");W=c.fromHex(S)}catch(g){if(g.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Z&&oe.hasHighS())return!1;ae&&(B=e.hash(B));let{r:U,s:p}=oe,J=$(B),re=a(p),fe=o(J*re),Q=o(U*re),l=c.BASE.multiplyAndAddUnsafe(W,fe,Q)?.toAffine();return l?o(l.x)===U:!1}return{CURVE:e,getPublicKey:F,getSharedSecret:K,sign:ne,verify:w,ProjectivePoint:c,Signature:O,utils:R}}function D0(t,e){let r=t.ORDER,n=dr;for(let u=r-qe;u%yn===dr;u/=yn)n+=qe;let i=n,s=yn<<i-qe-qe,o=s*yn,a=(r-qe)/o,c=(a-qe)/yn,f=o-qe,d=s,h=t.pow(e,a),m=t.pow(e,(a+qe)/yn),_=(u,T)=>{let O=h,R=t.pow(T,f),F=t.sqr(R);F=t.mul(F,T);let M=t.mul(u,F);M=t.pow(M,c),M=t.mul(M,R),R=t.mul(M,T),F=t.mul(M,u);let K=t.mul(F,R);M=t.pow(K,d);let x=t.eql(M,t.ONE);R=t.mul(F,m),M=t.mul(K,O),F=t.cmov(R,F,x),K=t.cmov(M,K,x);for(let $=i;$>qe;$--){let z=$-yn;z=yn<<z-qe;let D=t.pow(K,z),j=t.eql(D,t.ONE);R=t.mul(F,O),O=t.mul(O,O),D=t.mul(K,O),F=t.cmov(R,F,j),K=t.cmov(D,K,j)}return{isValid:x,value:F}};if(t.ORDER%z0===ea){let u=(t.ORDER-ea)/z0,T=t.sqrt(t.neg(e));_=(O,R)=>{let F=t.sqr(R),M=t.mul(O,R);F=t.mul(F,M);let K=t.pow(F,u);K=t.mul(K,M);let x=t.mul(K,T),$=t.mul(t.sqr(K),R),z=t.eql($,O),D=t.cmov(x,K,z);return{isValid:z,value:D}}}return _}function sw(t,e){if($n.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=D0(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,f,d,h;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),f=t.sqr(a),c=t.mul(f,e.A),s=t.add(s,c),s=t.mul(s,o),f=t.mul(f,a),c=t.mul(f,e.B),s=t.add(s,c),d=t.mul(i,o);let{isValid:m,value:_}=r(s,f);h=t.mul(i,n),h=t.mul(h,_),d=t.cmov(d,o,m),h=t.cmov(h,_,m);let u=t.isOdd(n)===t.isOdd(h);return h=t.cmov(t.neg(h),h,u),d=t.div(d,a),{x:d,y:h}}}});var L0=L(Xu=>{"use strict";Object.defineProperty(Xu,"__esModule",{value:!0});Xu.bls=cw;var Z0=Ir(),Zu=zt(),X0=Qo(),J0=Du(),ow=BigInt(0),ta=BigInt(1),Q0=BigInt(2),xi=BigInt(3);function aw(t){let e=[];for(;t>ta;t>>=ta)(t&ta)===ow?e.unshift(0):(t&xi)===xi?(e.unshift(-1),t+=ta):e.unshift(1);return e}function cw(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=t.params.xNegative,a=t.params.twistType,c=(0,J0.weierstrassPoints)({n:r.ORDER,...t.G1}),f=Object.assign(c,(0,X0.createHasher)(c.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),d=(0,J0.weierstrassPoints)({n:r.ORDER,...t.G2}),h=Object.assign(d,(0,X0.createHasher)(d.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),m;if(a==="multiplicative")m=(W,U,p,J,re,fe)=>s.mul014(J,W,n.mul(U,re),n.mul(p,fe));else if(a==="divisive")m=(W,U,p,J,re,fe)=>s.mul034(J,n.mul(p,fe),n.mul(U,re),W);else throw new Error("bls: unknown twist type");let _=n.div(n.ONE,n.mul(n.ONE,Q0));function u(W,U,p,J){let re=n.sqr(p),fe=n.sqr(J),Q=n.mulByB(n.mul(fe,xi)),l=n.mul(Q,xi),y=n.sub(n.sub(n.sqr(n.add(p,J)),fe),re),g=n.sub(Q,re),P=n.mul(n.sqr(U),xi),A=n.neg(y);return W.push([g,P,A]),U=n.mul(n.mul(n.mul(n.sub(re,l),U),p),_),p=n.sub(n.sqr(n.mul(n.add(re,l),_)),n.mul(n.sqr(Q),xi)),J=n.mul(re,y),{Rx:U,Ry:p,Rz:J}}function T(W,U,p,J,re,fe){let Q=n.sub(p,n.mul(fe,J)),l=n.sub(U,n.mul(re,J)),y=n.sub(n.mul(Q,re),n.mul(l,fe)),g=n.neg(Q),P=l;W.push([y,g,P]);let A=n.sqr(l),I=n.mul(A,l),k=n.mul(A,U),E=n.add(n.sub(I,n.mul(k,Q0)),n.mul(n.sqr(Q),J));return U=n.mul(l,E),p=n.sub(n.mul(n.sub(k,E),Q),n.mul(I,p)),J=n.mul(J,I),{Rx:U,Ry:p,Rz:J}}let O=aw(t.params.ateLoopSize),R=(0,Zu.memoized)(W=>{let U=W,{x:p,y:J}=U.toAffine(),re=p,fe=J,Q=n.neg(J),l=re,y=fe,g=n.ONE,P=[];for(let A of O){let I=[];({Rx:l,Ry:y,Rz:g}=u(I,l,y,g)),A&&({Rx:l,Ry:y,Rz:g}=T(I,l,y,g,re,A===-1?Q:fe)),P.push(I)}if(t.postPrecompute){let A=P[P.length-1];t.postPrecompute(l,y,g,re,fe,T.bind(null,A))}return P});function F(W,U=!1){let p=s.ONE;if(W.length){let J=W[0][0].length;for(let re=0;re<J;re++){p=s.sqr(p);for(let[fe,Q,l]of W)for(let[y,g,P]of fe[re])p=m(y,g,P,p,Q,l)}}return o&&(p=s.conjugate(p)),U?s.finalExponentiate(p):p}function M(W,U=!0){let p=[];f.ProjectivePoint.normalizeZ(W.map(({g1:J})=>J)),h.ProjectivePoint.normalizeZ(W.map(({g2:J})=>J));for(let{g1:J,g2:re}of W){if(J.equals(f.ProjectivePoint.ZERO)||re.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");J.assertValidity(),re.assertValidity();let fe=J.toAffine();p.push([R(re),fe.x,fe.y])}return F(p,U)}function K(W,U,p=!0){return M([{g1:W,g2:U}],p)}let x={randomPrivateKey:()=>{let W=(0,Z0.getMinHashLength)(r.ORDER);return(0,Z0.mapHashToField)(t.randomBytes(W),r.ORDER)},calcPairingPrecomputes:R},{ShortSignature:$}=t.G1,{Signature:z}=t.G2;function D(W){return W instanceof f.ProjectivePoint?W:f.ProjectivePoint.fromHex(W)}function j(W,U){return W instanceof f.ProjectivePoint?W:f.hashToCurve((0,Zu.ensureBytes)("point",W),U)}function ie(W){return W instanceof h.ProjectivePoint?W:z.fromHex(W)}function ee(W,U){return W instanceof h.ProjectivePoint?W:h.hashToCurve((0,Zu.ensureBytes)("point",W),U)}function ne(W){return f.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function w(W){return h.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function b(W,U,p){let J=ee(W,p);J.assertValidity();let re=J.multiply(f.normPrivateKeyToScalar(U));return W instanceof h.ProjectivePoint?re:z.toRawBytes(re)}function B(W,U,p){let J=j(W,p);J.assertValidity();let re=J.multiply(f.normPrivateKeyToScalar(U));return W instanceof f.ProjectivePoint?re:$.toRawBytes(re)}function S(W,U,p,J){let re=D(p),fe=ee(U,J),Q=f.ProjectivePoint.BASE,l=ie(W),y=M([{g1:re.negate(),g2:fe},{g1:Q,g2:l}]);return s.eql(y,s.ONE)}function N(W,U,p,J){let re=ie(p),fe=j(U,J),Q=h.ProjectivePoint.BASE,l=D(W),y=M([{g1:fe,g2:re},{g1:l,g2:Q.negate()}]);return s.eql(y,s.ONE)}function H(W){if(!W.length)throw new Error("Expected non-empty array");let p=W.map(D).reduce((J,re)=>J.add(re),f.ProjectivePoint.ZERO);return W[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):p.toRawBytes(!0)}function Z(W){if(!W.length)throw new Error("Expected non-empty array");let p=W.map(ie).reduce((J,re)=>J.add(re),h.ProjectivePoint.ZERO);return W[0]instanceof h.ProjectivePoint?(p.assertValidity(),p):z.toRawBytes(p)}function ae(W){if(!W.length)throw new Error("Expected non-empty array");let p=W.map(D).reduce((J,re)=>J.add(re),f.ProjectivePoint.ZERO);return W[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):$.toRawBytes(p)}function oe(W,U,p,J){if(!U.length)throw new Error("Expected non-empty messages array");if(p.length!==U.length)throw new Error("Pubkey count should equal msg count");let re=ie(W),fe=U.map(g=>ee(g,J)),Q=p.map(D),l=new Map;for(let g=0;g<Q.length;g++){let P=Q[g],A=fe[g],I=l.get(A);I===void 0&&(I=[],l.set(A,I)),I.push(P)}let y=[];try{for(let[g,P]of l){let A=P.reduce((I,k)=>I.add(k));y.push({g1:A,g2:g})}return y.push({g1:f.ProjectivePoint.BASE.negate(),g2:re}),s.eql(M(y),s.ONE)}catch{return!1}}return f.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ne,getPublicKeyForShortSignatures:w,sign:b,signShortSignature:B,verify:S,verifyBatch:oe,verifyShortSignature:N,aggregatePublicKeys:H,aggregateSignatures:Z,aggregateShortSignatures:ae,millerLoopBatch:F,pairing:K,pairingBatch:M,G1:f,G2:h,Signature:z,ShortSignature:$,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:t.params.ateLoopSize,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:x}}});var th=L(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.psiFrobenius=lw;ra.tower12=fw;var gn=Ir(),hr=zt(),uw=BigInt(0),vi=BigInt(1),Zr=BigInt(2),eh=BigInt(3);function Ju(t,e,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let f=0;f<i;f++){let d=BigInt(f+1),h=[];for(let m=0,_=vi;m<n;m++){let u=(d*_-d)/o%a;h.push(t.pow(e,u)),_*=r}c.push(h)}return c}function lw(t,e,r){let n=e.pow(r,(t.ORDER-vi)/eh),i=e.pow(r,(t.ORDER-vi)/Zr);function s(m,_){let u=e.mul(e.frobeniusMap(m,1),n),T=e.mul(e.frobeniusMap(_,1),i);return[u,T]}let o=e.pow(r,(t.ORDER**Zr-vi)/eh),a=e.pow(r,(t.ORDER**Zr-vi)/Zr);if(!e.eql(a,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(m,_){return[e.mul(m,o),e.neg(_)]}let f=m=>(_,u)=>{let T=u.toAffine(),O=m(T.x,T.y);return _.fromAffine({x:O[0],y:O[1]})},d=f(s),h=f(c);return{psi:s,psi2:c,G2psi:d,G2psi2:h,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function fw(t){let{ORDER:e}=t,r=gn.Field(e),n=r.create(t.NONRESIDUE||BigInt(-1)),i=gn.FpLegendre(e),s=r.div(r.ONE,Zr),o=Ju(r,n,r.ORDER,2)[0],a=({c0:w,c1:b},{c0:B,c1:S})=>({c0:r.add(w,B),c1:r.add(b,S)}),c=({c0:w,c1:b},{c0:B,c1:S})=>({c0:r.sub(w,B),c1:r.sub(b,S)}),f=({c0:w,c1:b},B)=>{if(typeof B=="bigint")return{c0:r.mul(w,B),c1:r.mul(b,B)};let{c0:S,c1:N}=B,H=r.mul(w,S),Z=r.mul(b,N),ae=r.sub(H,Z),oe=r.sub(r.mul(r.add(w,b),r.add(S,N)),r.add(H,Z));return{c0:ae,c1:oe}},d=({c0:w,c1:b})=>{let B=r.add(w,b),S=r.sub(w,b),N=r.add(w,w);return{c0:r.mul(B,S),c1:r.mul(N,b)}},h=w=>{if(w.length!==2)throw new Error("Invalid tuple");let b=w.map(B=>r.create(B));return{c0:b[0],c1:b[1]}},m=e*e,_=h(t.FP2_NONRESIDUE),u={ORDER:m,NONRESIDUE:_,BITS:(0,hr.bitLen)(m),BYTES:Math.ceil((0,hr.bitLen)(m)/8),MASK:(0,hr.bitMask)((0,hr.bitLen)(m)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:w=>w,isValid:({c0:w,c1:b})=>typeof w=="bigint"&&typeof b=="bigint",is0:({c0:w,c1:b})=>r.is0(w)&&r.is0(b),eql:({c0:w,c1:b},{c0:B,c1:S})=>r.eql(w,B)&&r.eql(b,S),neg:({c0:w,c1:b})=>({c0:r.neg(w),c1:r.neg(b)}),pow:(w,b)=>gn.FpPow(u,w,b),invertBatch:w=>gn.FpInvertBatch(u,w),add:a,sub:c,mul:f,sqr:d,addN:a,subN:c,mulN:f,sqrN:d,div:(w,b)=>u.mul(w,typeof b=="bigint"?r.inv(r.create(b)):u.inv(b)),inv:({c0:w,c1:b})=>{let B=r.inv(r.create(w*w+b*b));return{c0:r.mul(B,r.create(w)),c1:r.mul(B,r.create(-b))}},sqrt:w=>{if(t.Fp2sqrt)return t.Fp2sqrt(w);let{c0:b,c1:B}=w;if(r.is0(B))return r.eql(i(r,b),r.ONE)?u.create({c0:r.sqrt(b),c1:r.ZERO}):u.create({c0:r.ZERO,c1:r.sqrt(r.div(b,n))});let S=r.sqrt(r.sub(r.sqr(b),r.mul(r.sqr(B),n))),N=r.mul(r.add(S,b),s),H=i(r,N);!r.is0(H)&&!r.eql(H,r.ONE)&&(N=r.sub(N,S));let Z=r.sqrt(N),ae=u.create({c0:Z,c1:r.div(r.mul(B,s),Z)});if(!u.eql(u.sqr(ae),w))throw new Error("Cannot find square root");let oe=ae,W=u.neg(oe),{re:U,im:p}=u.reim(oe),{re:J,im:re}=u.reim(W);return p>re||p===re&&U>J?oe:W},isOdd:w=>{let{re:b,im:B}=u.reim(w),S=b%Zr,N=b===uw,H=B%Zr;return BigInt(S||N&&H)==vi},fromBytes(w){if(w.length!==u.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:b})=>(0,hr.concatBytes)(r.toBytes(w),r.toBytes(b)),cmov:({c0:w,c1:b},{c0:B,c1:S},N)=>({c0:r.cmov(w,B,N),c1:r.cmov(b,S,N)}),reim:({c0:w,c1:b})=>({re:w,im:b}),mulByNonresidue:({c0:w,c1:b})=>u.mul({c0:w,c1:b},_),mulByB:t.Fp2mulByB,fromBigTuple:h,frobeniusMap:({c0:w,c1:b},B)=>({c0:w,c1:r.mul(b,o[B%2])})},T=({c0:w,c1:b,c2:B},{c0:S,c1:N,c2:H})=>({c0:u.add(w,S),c1:u.add(b,N),c2:u.add(B,H)}),O=({c0:w,c1:b,c2:B},{c0:S,c1:N,c2:H})=>({c0:u.sub(w,S),c1:u.sub(b,N),c2:u.sub(B,H)}),R=({c0:w,c1:b,c2:B},S)=>{if(typeof S=="bigint")return{c0:u.mul(w,S),c1:u.mul(b,S),c2:u.mul(B,S)};let{c0:N,c1:H,c2:Z}=S,ae=u.mul(w,N),oe=u.mul(b,H),W=u.mul(B,Z);return{c0:u.add(ae,u.mulByNonresidue(u.sub(u.mul(u.add(b,B),u.add(H,Z)),u.add(oe,W)))),c1:u.add(u.sub(u.mul(u.add(w,b),u.add(N,H)),u.add(ae,oe)),u.mulByNonresidue(W)),c2:u.sub(u.add(oe,u.mul(u.add(w,B),u.add(N,Z))),u.add(ae,W))}},F=({c0:w,c1:b,c2:B})=>{let S=u.sqr(w),N=u.mul(u.mul(w,b),Zr),H=u.mul(u.mul(b,B),Zr),Z=u.sqr(B);return{c0:u.add(u.mulByNonresidue(H),S),c1:u.add(u.mulByNonresidue(Z),N),c2:u.sub(u.sub(u.add(u.add(N,u.sqr(u.add(u.sub(w,b),B))),H),S),Z)}},[M,K]=Ju(u,_,r.ORDER,6,2,3),x={ORDER:u.ORDER,BITS:3*u.BITS,BYTES:3*u.BYTES,MASK:(0,hr.bitMask)(3*u.BITS),ZERO:{c0:u.ZERO,c1:u.ZERO,c2:u.ZERO},ONE:{c0:u.ONE,c1:u.ZERO,c2:u.ZERO},create:w=>w,isValid:({c0:w,c1:b,c2:B})=>u.isValid(w)&&u.isValid(b)&&u.isValid(B),is0:({c0:w,c1:b,c2:B})=>u.is0(w)&&u.is0(b)&&u.is0(B),neg:({c0:w,c1:b,c2:B})=>({c0:u.neg(w),c1:u.neg(b),c2:u.neg(B)}),eql:({c0:w,c1:b,c2:B},{c0:S,c1:N,c2:H})=>u.eql(w,S)&&u.eql(b,N)&&u.eql(B,H),sqrt:hr.notImplemented,div:(w,b)=>x.mul(w,typeof b=="bigint"?r.inv(r.create(b)):x.inv(b)),pow:(w,b)=>gn.FpPow(x,w,b),invertBatch:w=>gn.FpInvertBatch(x,w),add:T,sub:O,mul:R,sqr:F,addN:T,subN:O,mulN:R,sqrN:F,inv:({c0:w,c1:b,c2:B})=>{let S=u.sub(u.sqr(w),u.mulByNonresidue(u.mul(B,b))),N=u.sub(u.mulByNonresidue(u.sqr(B)),u.mul(w,b)),H=u.sub(u.sqr(b),u.mul(w,B)),Z=u.inv(u.add(u.mulByNonresidue(u.add(u.mul(B,N),u.mul(b,H))),u.mul(w,S)));return{c0:u.mul(Z,S),c1:u.mul(Z,N),c2:u.mul(Z,H)}},fromBytes:w=>{if(w.length!==x.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:u.fromBytes(w.subarray(0,u.BYTES)),c1:u.fromBytes(w.subarray(u.BYTES,2*u.BYTES)),c2:u.fromBytes(w.subarray(2*u.BYTES))}},toBytes:({c0:w,c1:b,c2:B})=>(0,hr.concatBytes)(u.toBytes(w),u.toBytes(b),u.toBytes(B)),cmov:({c0:w,c1:b,c2:B},{c0:S,c1:N,c2:H},Z)=>({c0:u.cmov(w,S,Z),c1:u.cmov(b,N,Z),c2:u.cmov(B,H,Z)}),fromBigSix:w=>{if(!Array.isArray(w)||w.length!==6)throw new Error("Invalid Fp6 usage");return{c0:u.fromBigTuple(w.slice(0,2)),c1:u.fromBigTuple(w.slice(2,4)),c2:u.fromBigTuple(w.slice(4,6))}},frobeniusMap:({c0:w,c1:b,c2:B},S)=>({c0:u.frobeniusMap(w,S),c1:u.mul(u.frobeniusMap(b,S),M[S%6]),c2:u.mul(u.frobeniusMap(B,S),K[S%6])}),mulByFp2:({c0:w,c1:b,c2:B},S)=>({c0:u.mul(w,S),c1:u.mul(b,S),c2:u.mul(B,S)}),mulByNonresidue:({c0:w,c1:b,c2:B})=>({c0:u.mulByNonresidue(B),c1:w,c2:b}),mul1:({c0:w,c1:b,c2:B},S)=>({c0:u.mulByNonresidue(u.mul(B,S)),c1:u.mul(w,S),c2:u.mul(b,S)}),mul01({c0:w,c1:b,c2:B},S,N){let H=u.mul(w,S),Z=u.mul(b,N);return{c0:u.add(u.mulByNonresidue(u.sub(u.mul(u.add(b,B),N),Z)),H),c1:u.sub(u.sub(u.mul(u.add(S,N),u.add(w,b)),H),Z),c2:u.add(u.sub(u.mul(u.add(w,B),S),H),Z)}}},$=Ju(u,_,r.ORDER,12,1,6)[0],z=({c0:w,c1:b},{c0:B,c1:S})=>({c0:x.add(w,B),c1:x.add(b,S)}),D=({c0:w,c1:b},{c0:B,c1:S})=>({c0:x.sub(w,B),c1:x.sub(b,S)}),j=({c0:w,c1:b},B)=>{if(typeof B=="bigint")return{c0:x.mul(w,B),c1:x.mul(b,B)};let{c0:S,c1:N}=B,H=x.mul(w,S),Z=x.mul(b,N);return{c0:x.add(H,x.mulByNonresidue(Z)),c1:x.sub(x.mul(x.add(w,b),x.add(S,N)),x.add(H,Z))}},ie=({c0:w,c1:b})=>{let B=x.mul(w,b);return{c0:x.sub(x.sub(x.mul(x.add(x.mulByNonresidue(b),w),x.add(w,b)),B),x.mulByNonresidue(B)),c1:x.add(B,B)}};function ee(w,b){let B=u.sqr(w),S=u.sqr(b);return{first:u.add(u.mulByNonresidue(S),B),second:u.sub(u.sub(u.sqr(u.add(w,b)),B),S)}}let ne={ORDER:u.ORDER,BITS:2*u.BITS,BYTES:2*u.BYTES,MASK:(0,hr.bitMask)(2*u.BITS),ZERO:{c0:x.ZERO,c1:x.ZERO},ONE:{c0:x.ONE,c1:x.ZERO},create:w=>w,isValid:({c0:w,c1:b})=>x.isValid(w)&&x.isValid(b),is0:({c0:w,c1:b})=>x.is0(w)&&x.is0(b),neg:({c0:w,c1:b})=>({c0:x.neg(w),c1:x.neg(b)}),eql:({c0:w,c1:b},{c0:B,c1:S})=>x.eql(w,B)&&x.eql(b,S),sqrt:hr.notImplemented,inv:({c0:w,c1:b})=>{let B=x.inv(x.sub(x.sqr(w),x.mulByNonresidue(x.sqr(b))));return{c0:x.mul(w,B),c1:x.neg(x.mul(b,B))}},div:(w,b)=>ne.mul(w,typeof b=="bigint"?r.inv(r.create(b)):ne.inv(b)),pow:(w,b)=>gn.FpPow(ne,w,b),invertBatch:w=>gn.FpInvertBatch(ne,w),add:z,sub:D,mul:j,sqr:ie,addN:z,subN:D,mulN:j,sqrN:ie,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:b})=>(0,hr.concatBytes)(x.toBytes(w),x.toBytes(b)),cmov:({c0:w,c1:b},{c0:B,c1:S},N)=>({c0:x.cmov(w,B,N),c1:x.cmov(b,S,N)}),fromBigTwelve:w=>({c0:x.fromBigSix(w.slice(0,6)),c1:x.fromBigSix(w.slice(6,12))}),frobeniusMap(w,b){let{c0:B,c1:S,c2:N}=x.frobeniusMap(w.c1,b),H=$[b%12];return{c0:x.frobeniusMap(w.c0,b),c1:x.create({c0:u.mul(B,H),c1:u.mul(S,H),c2:u.mul(N,H)})}},mulByFp2:({c0:w,c1:b},B)=>({c0:x.mulByFp2(w,B),c1:x.mulByFp2(b,B)}),conjugate:({c0:w,c1:b})=>({c0:w,c1:x.neg(b)}),mul014:({c0:w,c1:b},B,S,N)=>{let H=x.mul01(w,B,S),Z=x.mul1(b,N);return{c0:x.add(x.mulByNonresidue(Z),H),c1:x.sub(x.sub(x.mul01(x.add(b,w),B,u.add(S,N)),H),Z)}},mul034:({c0:w,c1:b},B,S,N)=>{let H=x.create({c0:u.mul(w.c0,B),c1:u.mul(w.c1,B),c2:u.mul(w.c2,B)}),Z=x.mul01(b,S,N),ae=x.mul01(x.add(w,b),u.add(B,S),N);return{c0:x.add(x.mulByNonresidue(Z),H),c1:x.sub(ae,x.add(H,Z))}},_cyclotomicSquare:t.Fp12cyclotomicSquare,_cyclotomicExp:t.Fp12cyclotomicExp,finalExponentiate:t.Fp12finalExponentiate};return{Fp:r,Fp2:u,Fp6:x,Fp4Square:ee,Fp12:ne}}});var lh=L(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.bls12_381=void 0;var oh=oo(),dw=qn(),hw=L0(),pw=Ir(),Se=zt(),ah=Qo(),ch=Du(),uh=th(),Pt=BigInt(0),sa=BigInt(1),ht=BigInt(2),na=BigInt(3),ds=BigInt(4),mn=BigInt("0xd201000000010000"),yw=(0,Se.bitLen)(mn),{Fp:le,Fp2:pe,Fp6:el,Fp4Square:Qu,Fp12:ve}=(0,uh.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[sa,sa],Fp2mulByB:({c0:t,c1:e})=>{let r=le.mul(t,ds),n=le.mul(e,ds);return{c0:le.sub(r,n),c1:le.add(r,n)}},Fp12cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:f}=Qu(r,o),{first:d,second:h}=Qu(s,i),{first:m,second:_}=Qu(n,a),u=pe.mulByNonresidue(_);return{c0:el.create({c0:pe.add(pe.mul(pe.sub(c,r),ht),c),c1:pe.add(pe.mul(pe.sub(d,n),ht),d),c2:pe.add(pe.mul(pe.sub(m,i),ht),m)}),c1:el.create({c0:pe.add(pe.mul(pe.add(u,s),ht),u),c1:pe.add(pe.mul(pe.add(f,o),ht),f),c2:pe.add(pe.mul(pe.add(h,a),ht),h)})}},Fp12cyclotomicExp(t,e){let r=ve.ONE;for(let n=yw-1;n>=0;n--)r=ve._cyclotomicSquare(r),(0,Se.bitGet)(e,n)&&(r=ve.mul(r,t));return r},Fp12finalExponentiate:t=>{let e=mn,r=ve.div(ve.frobeniusMap(t,6),t),n=ve.mul(ve.frobeniusMap(r,2),r),i=ve.conjugate(ve._cyclotomicExp(n,e)),s=ve.mul(ve.conjugate(ve._cyclotomicSquare(n)),i),o=ve.conjugate(ve._cyclotomicExp(s,e)),a=ve.conjugate(ve._cyclotomicExp(o,e)),c=ve.mul(ve.conjugate(ve._cyclotomicExp(a,e)),ve._cyclotomicSquare(i)),f=ve.conjugate(ve._cyclotomicExp(c,e)),d=ve.frobeniusMap(ve.mul(i,a),2),h=ve.frobeniusMap(ve.mul(o,n),3),m=ve.frobeniusMap(ve.mul(c,ve.conjugate(n)),1),_=ve.mul(ve.mul(f,ve.conjugate(s)),n);return ve.mul(ve.mul(ve.mul(d,h),m),_)}}),rh=pw.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),gw=(0,ah.isogenyMap)(pe,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(t=>t.map(e=>pe.fromBigTuple(e.map(BigInt))))),mw=(0,ah.isogenyMap)(le,[["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(t=>t.map(e=>BigInt(e)))),bw=(0,ch.mapToCurveSimpleSWU)(pe,{A:pe.create({c0:le.create(Pt),c1:le.create(BigInt(240))}),B:pe.create({c0:le.create(BigInt(1012)),c1:le.create(BigInt(1012))}),Z:pe.create({c0:le.create(BigInt(-2)),c1:le.create(BigInt(-1))})}),_w=(0,ch.mapToCurveSimpleSWU)(le,{A:le.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:le.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:le.create(BigInt(11))}),{G2psi:nh,G2psi2:ww}=(0,uh.psiFrobenius)(le,pe,pe.div(pe.ONE,pe.NONRESIDUE)),Lu=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:le.ORDER,m:2,k:128,expand:"xmd",hash:oh.sha256}),oa=hs(le.toBytes(Pt),{infinity:!0,compressed:!0});function ia(t){t=t.slice();let e=t[0]&224,r=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return t[0]&=31,{compressed:r,infinity:n,sort:i,value:t}}function hs(t,e){if(t[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(t[0]|=128),e.infinity&&(t[0]|=64),e.sort&&(t[0]|=32),t}function ih(t){t.assertValidity();let e=t.equals(It.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return oa.slice();let i=le.ORDER,s=!!(n*ht/i);return hs((0,Se.numberToBytesBE)(r,le.BYTES),{compressed:!0,sort:s})}function sh(t){t.assertValidity();let e=le.BYTES;if(t.equals(It.bls12_381.G2.ProjectivePoint.ZERO))return(0,Se.concatBytes)(oa,(0,Se.numberToBytesBE)(Pt,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=pe.reim(r),{re:o,im:a}=pe.reim(n),f=!!((a>Pt?a*ht:o*ht)/le.ORDER&sa),d=i;return(0,Se.concatBytes)(hs((0,Se.numberToBytesBE)(s,e),{sort:f,compressed:!0}),(0,Se.numberToBytesBE)(d,e))}It.bls12_381=(0,hw.bls)({fields:{Fp:le,Fp2:pe,Fp6:el,Fp12:ve,Fr:rh},G1:{Fp:le,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:le.ZERO,b:ds,htfDefaults:{...Lu,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(t,e)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new t(le.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(mn).negate().multiplyUnsafe(mn).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(mn).add(e),mapToCurve:t=>{let{x:e,y:r}=_w(le.create(t[0]));return mw(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=ia(t);if(i.length===48&&e){let s=le.ORDER,o=(0,Se.bytesToNumberBE)(i),a=le.create(o&le.MASK);if(r){if(a!==Pt)throw new Error("G1: non-empty compressed point at infinity");return{x:Pt,y:Pt}}let c=le.add(le.pow(a,na),le.create(It.bls12_381.params.G1b)),f=le.sqrt(c);if(!f)throw new Error("Invalid compressed G1 point");return f*ht/s!==BigInt(n)&&(f=le.neg(f)),{x:le.create(a),y:le.create(f)}}else if(i.length===96&&!e){let s=(0,Se.bytesToNumberBE)(i.subarray(0,le.BYTES)),o=(0,Se.bytesToNumberBE)(i.subarray(le.BYTES));if(r){if(s!==Pt||o!==Pt)throw new Error("G1: non-empty point at infinity");return It.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:le.create(s),y:le.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(t,e,r)=>{let n=e.equals(t.ZERO),{x:i,y:s}=e.toAffine();if(r){if(n)return oa.slice();let o=le.ORDER,a=!!(s*ht/o);return hs((0,Se.numberToBytesBE)(i,le.BYTES),{compressed:!0,sort:a})}else return n?(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(2*le.BYTES-1)):(0,Se.concatBytes)((0,Se.numberToBytesBE)(i,le.BYTES),(0,Se.numberToBytesBE)(s,le.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=ia((0,Se.ensureBytes)("signatureHex",t,48)),i=le.ORDER,s=(0,Se.bytesToNumberBE)(n);if(e)return It.bls12_381.G1.ProjectivePoint.ZERO;let o=le.create(s&le.MASK),a=le.add(le.pow(o,na),le.create(It.bls12_381.params.G1b)),c=le.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let f=BigInt(r);c*ht/i!==f&&(c=le.neg(c));let d=It.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return d.assertValidity(),d},toRawBytes(t){return ih(t)},toHex(t){return(0,Se.bytesToHex)(ih(t))}}},G2:{Fp:pe,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:pe.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:pe.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:pe.ZERO,b:pe.fromBigTuple([ds,ds]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...Lu},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=bw(pe.fromBigTuple(t));return gw(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(mn).negate().equals(nh(t,e)),clearCofactor:(t,e)=>{let r=mn,n=e.multiplyUnsafe(r).negate(),i=nh(t,e),s=e.double();return s=ww(t,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=ia(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=le.BYTES,o=(a,c,f)=>(0,Se.bytesToNumberBE)(a.slice(c,f));if(i.length===96&&e){let a=It.bls12_381.params.G2b,c=le.ORDER;if(r){if(i.reduce((T,O)=>T!==0?O+1:O,0)>0)throw new Error("Invalid compressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let f=o(i,0,s),d=o(i,s,2*s),h=pe.create({c0:le.create(d),c1:le.create(f)}),m=pe.add(pe.pow(h,na),a),_=pe.sqrt(m),u=_.c1===Pt?_.c0*ht/c:_.c1*ht/c?sa:Pt;return _=n&&u>0?_:pe.neg(_),{x:h,y:_}}else if(i.length===192&&!e){if(r){if(i.reduce((h,m)=>h!==0?m+1:m,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),f=o(i,2*s,3*s),d=o(i,3*s,4*s);return{x:pe.fromBigTuple([c,a]),y:pe.fromBigTuple([d,f])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=le,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return(0,Se.concatBytes)(oa,(0,Se.numberToBytesBE)(Pt,n));let c=!!(a.c1===Pt?a.c0*ht/i:a.c1*ht/i);return(0,Se.concatBytes)(hs((0,Se.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,Se.numberToBytesBE)(o.c0,n))}else{if(s)return(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:f}=pe.reim(o),{re:d,im:h}=pe.reim(a);return(0,Se.concatBytes)((0,Se.numberToBytesBE)(f,n),(0,Se.numberToBytesBE)(c,n),(0,Se.numberToBytesBE)(h,n),(0,Se.numberToBytesBE)(d,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=ia((0,Se.ensureBytes)("signatureHex",t)),i=le.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=(0,Se.bytesToNumberBE)(n.slice(0,s)),a=(0,Se.bytesToNumberBE)(n.slice(s));if(e)return It.bls12_381.G2.ProjectivePoint.ZERO;let c=le.create(o&le.MASK),f=le.create(a),d=pe.create({c0:f,c1:c}),h=pe.add(pe.pow(d,na),It.bls12_381.params.G2b),m=pe.sqrt(h);if(!m)throw new Error("Failed to find a square root");let{re:_,im:u}=pe.reim(m),T=BigInt(r),O=u>Pt&&u*ht/i!==T,R=u===Pt&&_*ht/i!==T;(O||R)&&(m=pe.neg(m));let F=It.bls12_381.G2.ProjectivePoint.fromAffine({x:d,y:m});return F.assertValidity(),F},toRawBytes(t){return sh(t)},toHex(t){return(0,Se.bytesToHex)(sh(t))}}},params:{ateLoopSize:mn,r:rh.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:Lu,hash:oh.sha256,randomBytes:dw.randomBytes})});var rl=L(ps=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});ps.blsVerify=ps.verify=void 0;var Ew=lh(),tl=kt();function xw(t,e,r){let n=typeof t=="string"?t:(0,tl.toHex)(t),i=typeof e=="string"?e:(0,tl.toHex)(e),s=typeof r=="string"?r:(0,tl.toHex)(r);return Ew.bls12_381.verifyShortSignature(i,s,n)}ps.blsVerify=xw});var aa=L(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.decodeTime=Kn.decodeLeb128=void 0;var fh=bi(),vw=t=>(0,fh.lebDecode)(new fh.PipeArrayBuffer(t));Kn.decodeLeb128=vw;var Tw=t=>{let e=(0,Kn.decodeLeb128)(t);return new Date(Number(e)/1e6)};Kn.decodeTime=Tw});var Ti=L(Oe=>{"use strict";var Aw=Oe&&Oe.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Sw=Oe&&Oe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),dh=Oe&&Oe.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Aw(e,t,r);return Sw(e,t),e};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 hh=dh(cs()),Bw=fi(),ca=ss(),pr=kt(),nl=Nt(),Ow=dh(rl()),Nw=aa(),Rw=_s(),Xr=class extends Bw.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};Oe.CertificateVerificationError=Xr;var Et;(function(t){t[t.Empty=0]="Empty",t[t.Fork=1]="Fork",t[t.Labeled=2]="Labeled",t[t.Leaf=3]="Leaf",t[t.Pruned=4]="Pruned"})(Et=Oe.NodeType||(Oe.NodeType={}));function ua(t){let e=n=>n.split(`
|
|
16
|
+
`)}return c.encodeValue(f)}));return(0,Ne.concat)(n,i,s,o,a)}Y.encode=Bb;function Ob(t,e){let r=new Ne.PipeArrayBuffer(e);if(e.byteLength<go.length)throw new Error("Message length smaller than magic number");let n=(0,se.safeRead)(r,go.length),i=new TextDecoder().decode(n);if(i!==go)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(_){let u=[],T=Number((0,se.lebDecode)(_));for(let F=0;F<T;F++){let M=Number((0,se.slebDecode)(_));switch(M){case-18:case-19:{let K=Number((0,se.slebDecode)(_));u.push([M,K]);break}case-20:case-21:{let K=[],x=Number((0,se.lebDecode)(_)),$;for(;x--;){let z=Number((0,se.lebDecode)(_));if(z>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof $=="number"&&$>=z)throw new Error("field id collision or not sorted");$=z;let D=Number((0,se.slebDecode)(_));K.push([z,D])}u.push([M,K]);break}case-22:{let K=[],x=Number((0,se.lebDecode)(_));for(;x--;)K.push(Number((0,se.slebDecode)(_)));let $=[],z=Number((0,se.lebDecode)(_));for(;z--;)$.push(Number((0,se.slebDecode)(_)));let D=[],j=Number((0,se.lebDecode)(_));for(;j--;)switch(Number((0,se.lebDecode)(_))){case 1:{D.push("query");break}case 2:{D.push("oneway");break}case 3:{D.push("composite_query");break}default:throw new Error("unknown annotation")}u.push([M,[K,$,D]]);break}case-23:{let K=Number((0,se.lebDecode)(_)),x=[];for(;K--;){let $=Number((0,se.lebDecode)(_)),z=new TextDecoder().decode((0,se.safeRead)(_,$)),D=(0,se.slebDecode)(_);x.push([z,D])}u.push([M,x]);break}default:throw new Error("Illegal op_code: "+M)}}let O=[],R=Number((0,se.lebDecode)(_));for(let F=0;F<R;F++)O.push(Number((0,se.slebDecode)(_)));return[u,O]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(_=>Rd());function f(_){if(_<-24)throw new Error("future value not supported");if(_<0)switch(_){case-1:return Y.Null;case-2:return Y.Bool;case-3:return Y.Nat;case-4:return Y.Int;case-5:return Y.Nat8;case-6:return Y.Nat16;case-7:return Y.Nat32;case-8:return Y.Nat64;case-9:return Y.Int8;case-10:return Y.Int16;case-11:return Y.Int32;case-12:return Y.Int64;case-13:return Y.Float32;case-14:return Y.Float64;case-15:return Y.Text;case-16:return Y.Reserved;case-17:return Y.Empty;case-24:return Y.Principal;default:throw new Error("Illegal op_code: "+_)}if(_>=o.length)throw new Error("type index out of range");return c[_]}function d(_){switch(_[0]){case-19:{let u=f(_[1]);return Sd(u)}case-18:{let u=f(_[1]);return Bd(u)}case-20:{let u={};for(let[R,F]of _[1]){let M=`_${R}_`;u[M]=f(F)}let T=Od(u),O=T.tryAsTuple();return Array.isArray(O)?Ad(...O):T}case-21:{let u={};for(let[T,O]of _[1]){let R=`_${T}_`;u[R]=f(O)}return Nd(u)}case-22:{let[u,T,O]=_[1];return Pd(u.map(R=>f(R)),T.map(R=>f(R)),O)}case-23:{let u={},T=_[1];for(let[O,R]of T){let F=f(R);if(F instanceof un&&(F=F.getType()),!(F instanceof Qi))throw new Error("Illegal service definition: services can only contain functions");u[O]=F}return Id(u)}default:throw new Error("Illegal op_code: "+_[0])}}o.forEach((_,u)=>{if(_[0]===-22){let T=d(_);c[u].fill(T)}}),o.forEach((_,u)=>{if(_[0]!==-22){let T=d(_);c[u].fill(T)}});let h=a.map(_=>f(_)),m=t.map((_,u)=>_.decodeValue(r,h[u]));for(let _=t.length;_<h.length;_++)h[_].decodeValue(r,h[_]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return m}Y.decode=Ob;Y.Empty=new mo;Y.Reserved=new pi;Y.Unknown=new bo;Y.Bool=new _o;Y.Null=new wo;Y.Text=new Eo;Y.Int=new xo;Y.Nat=new vo;Y.Float32=new Xi(32);Y.Float64=new Xi(64);Y.Int8=new Wr(8);Y.Int16=new Wr(16);Y.Int32=new Wr(32);Y.Int64=new Wr(64);Y.Nat8=new Or(8);Y.Nat16=new Or(16);Y.Nat32=new Or(32);Y.Nat64=new Or(64);Y.Principal=new Bo;function Ad(...t){return new Ao(t)}Y.Tuple=Ad;function Sd(t){return new To(t)}Y.Vec=Sd;function Bd(t){return new yi(t)}Y.Opt=Bd;function Od(t){return new Ji(t)}Y.Record=Od;function Nd(t){return new So(t)}Y.Variant=Nd;function Rd(){return new un}Y.Rec=Rd;function Pd(t,e,r=[]){return new Qi(t,e,r)}Y.Func=Pd;function Id(t){return new Oo(t)}Y.Service=Id});var tu=L(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.VecForm=Tt.OptionForm=Tt.VariantForm=Tt.TupleForm=Tt.RecordForm=Tt.InputForm=Tt.InputBox=void 0;var Zc=class{constructor(e,r){this.idl=e,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(e={}){if(this.ui.form){let r=this.ui.form.parse(e);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,e,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(e){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),e.appendChild(r)}};Tt.InputBox=Zc;var ln=class{constructor(e){this.ui=e,this.form=[]}renderForm(e){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),e.appendChild(this.ui.container)):this.form.forEach(r=>r.render(e))}render(e){if(this.ui.open&&this.ui.event){e.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(e)})}else this.generateForm(),this.renderForm(e)}};Tt.InputForm=ln;var Xc=class extends ln{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){this.form=this.fields.map(([e,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(e)?n.label=this.ui.labelMap[e]+" ":n.label=e+" ",n})}parse(e){let r={};if(this.fields.forEach(([n,i],s)=>{let o=this.form[s].parse(e);r[n]=o}),!this.form.some(n=>n.isRejected()))return r}};Tt.RecordForm=Xc;var Jc=class extends ln{constructor(e,r){super(r),this.components=e,this.ui=r}generateForm(){this.form=this.components.map(e=>this.ui.render(e))}parse(e){let r=[];if(this.components.forEach((n,i)=>{let s=this.form[i].parse(e);r.push(s)}),!this.form.some(n=>n.isRejected()))return r}};Tt.TupleForm=Jc;var Qc=class extends ln{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){let e=this.ui.open.selectedIndex,[r,n]=this.fields[e],i=this.ui.render(n);this.form=[i]}parse(e){let r=this.ui.open,n=r.options[r.selectedIndex].value,i=this.form[0].parse(e);if(i===void 0)return;let s={};return s[n]=i,s}};Tt.VariantForm=Qc;var Lc=class extends ln{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){if(this.ui.open.checked){let e=this.ui.render(this.ty);this.form=[e]}else this.form=[]}parse(e){if(this.form.length===0)return[];{let r=this.form[0].parse(e);return r===void 0?void 0:[r]}}};Tt.OptionForm=Lc;var eu=class extends ln{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){let e=+this.ui.open.value;this.form=[];for(let r=0;r<e;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(e){let r=this.form.map(n=>n.parse(e));if(!this.form.some(n=>n.isRejected()))return r}};Tt.VecForm=eu});var Fd=L(Ee=>{"use strict";var Nb=Ee&&Ee.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Rb=Ee&&Ee.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ud=Ee&&Ee.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Nb(e,t,r);return Rb(e,t),e};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.renderValue=Ee.renderInput=Ee.Render=Ee.vecForm=Ee.optForm=Ee.variantForm=Ee.tupleForm=Ee.recordForm=Ee.inputBox=void 0;var Ro=Ud(Dc()),ru=Nt(),gi=Ud(tu()),Pb={parse:jb},Li={render:ou},Ib=(t,e)=>new gi.InputBox(t,Object.assign(Object.assign({},Pb),e));Ee.inputBox=Ib;var Ub=(t,e)=>new gi.RecordForm(t,Object.assign(Object.assign({},Li),e));Ee.recordForm=Ub;var Fb=(t,e)=>new gi.TupleForm(t,Object.assign(Object.assign({},Li),e));Ee.tupleForm=Fb;var Mb=(t,e)=>new gi.VariantForm(t,Object.assign(Object.assign({},Li),e));Ee.variantForm=Mb;var Cb=(t,e)=>new gi.OptionForm(t,Object.assign(Object.assign({},Li),e));Ee.optForm=Cb;var qb=(t,e)=>new gi.VecForm(t,Object.assign(Object.assign({},Li),e));Ee.vecForm=qb;var No=class extends Ro.Visitor{visitType(e,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=e.display(),(0,Ee.inputBox)(e,{input:n})}visitNull(e,r){return(0,Ee.inputBox)(e,{})}visitRecord(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.recordForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitTuple(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.tupleForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitVariant(e,r,n){let i=document.createElement("select");for(let[a,c]of r){let f=new Option(a);i.add(f)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},o=(0,Ee.variantForm)(r,s);return(0,Ee.inputBox)(e,{form:o})}visitOpt(e,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Ee.optForm)(r,{open:i,event:"change"});return(0,Ee.inputBox)(e,{form:s})}visitVec(e,r,n){let i=document.createElement("input");i.type="number",i.min="0",i.max="100",i.style.width="8rem",i.placeholder="len",i.classList.add("open");let s=document.createElement("div");s.classList.add("popup-form");let o=(0,Ee.vecForm)(r,{open:i,event:"change",container:s});return(0,Ee.inputBox)(e,{form:o})}visitRec(e,r,n){return ou(r)}};Ee.Render=No;var nu=class extends Ro.Visitor{visitNull(e,r){return null}visitBool(e,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(e,r){return r}visitFloat(e,r){return parseFloat(r)}visitFixedInt(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(e,r){return BigInt(r)}visitPrincipal(e,r){return ru.Principal.fromText(r)}visitService(e,r){return ru.Principal.fromText(r)}visitFunc(e,r){let n=r.split(".",2);return[ru.Principal.fromText(n[0]),n[1]]}},iu=class extends Ro.Visitor{visitNull(e,r){return null}visitBool(e,r){return Math.random()<.5}visitText(e,r){return Math.random().toString(36).substring(6)}visitFloat(e,r){return Math.random()}visitInt(e,r){return BigInt(this.generateNumber(!0))}visitNat(e,r){return BigInt(this.generateNumber(!1))}visitFixedInt(e,r){let n=this.generateNumber(!0);return e._bits<=32?n:BigInt(r)}visitFixedNat(e,r){let n=this.generateNumber(!1);return e._bits<=32?n:BigInt(r)}generateNumber(e){let r=Math.floor(Math.random()*100);return e&&Math.random()<.5?-r:r}};function jb(t,e,r){return e.random&&r===""?t.accept(new iu,r):t.accept(new nu,r)}function ou(t){return t.accept(new No,null)}Ee.renderInput=ou;function jn(t,e,r){return t.accept(new su,{input:e,value:r})}Ee.renderValue=jn;var su=class extends Ro.Visitor{visitType(e,r){r.input.ui.input.value=e.valueToString(r.value)}visitNull(e,r){}visitText(e,r){r.input.ui.input.value=r.value}visitRec(e,r,n){jn(r,n.input,n.value)}visitOpt(e,r,n){if(n.value.length!==0){let i=n.input.ui.form,s=i.ui.open;s.checked=!0,s.dispatchEvent(new Event(i.ui.event)),jn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{jn(o,i.form[a],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{jn(s,i.form[o],n.value[o])})}visitVariant(e,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([o,a],c)=>{if(o===s[0]){let f=i.ui.open;f.selectedIndex=c,f.dispatchEvent(new Event(i.ui.event)),jn(a,i.form[0],s[1])}})}visitVec(e,r,n){let i=n.input.ui.form,s=n.value.length,o=i.ui.open;o.value=s,o.dispatchEvent(new Event(i.ui.event)),n.value.forEach((a,c)=>{jn(r,i.form[c],a)})}}});var Cd=L(Md=>{"use strict";Object.defineProperty(Md,"__esModule",{value:!0})});var bi=L(dt=>{"use strict";var qd=dt&&dt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),kb=dt&&dt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),mi=dt&&dt.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&qd(e,t,r)},Hb=dt&&dt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&qd(e,t,r);return kb(e,t),e};Object.defineProperty(dt,"__esModule",{value:!0});dt.IDL=void 0;mi(Fd(),dt);mi(tu(),dt);dt.IDL=Hb(Dc());mi(Vc(),dt);mi(Kc(),dt);mi(ho(),dt);mi(Cd(),dt)});var es=L((jd,Po)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,f=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,m=1e9;function _(x){var $,z,D,j=U.prototype={constructor:U,toString:null,valueOf:null},ie=new U(1),ee=20,ne=4,w=-7,b=21,B=-1e7,S=1e7,N=!1,H=1,Z=0,ae={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},oe="0123456789abcdefghijklmnopqrstuvwxyz",W=!0;function U(l,y){var g,P,A,I,k,E,C,V,q=this;if(!(q instanceof U))return new U(l,y);if(y==null){if(l&&l._isBigNumber===!0){q.s=l.s,!l.c||l.e>S?q.c=q.e=null:l.e<B?q.c=[q.e=0]:(q.e=l.e,q.c=l.c.slice());return}if((E=typeof l=="number")&&l*0==0){if(q.s=1/l<0?(l=-l,-1):1,l===~~l){for(I=0,k=l;k>=10;k/=10,I++);I>S?q.c=q.e=null:(q.e=I,q.c=[l]);return}V=String(l)}else{if(!r.test(V=String(l)))return D(q,V,E);q.s=V.charCodeAt(0)==45?(V=V.slice(1),-1):1}(I=V.indexOf("."))>-1&&(V=V.replace(".","")),(k=V.search(/e/i))>0?(I<0&&(I=k),I+=+V.slice(k+1),V=V.substring(0,k)):I<0&&(I=V.length)}else{if(R(y,2,oe.length,"Base"),y==10&&W)return q=new U(l),fe(q,ee+q.e+1,ne);if(V=String(l),E=typeof l=="number"){if(l*0!=0)return D(q,V,E,y);if(q.s=1/l<0?(V=V.slice(1),-1):1,U.DEBUG&&V.replace(/^0\.0*|\./,"").length>15)throw Error(o+l)}else q.s=V.charCodeAt(0)===45?(V=V.slice(1),-1):1;for(g=oe.slice(0,y),I=k=0,C=V.length;k<C;k++)if(g.indexOf(P=V.charAt(k))<0){if(P=="."){if(k>I){I=C;continue}}else if(!A&&(V==V.toUpperCase()&&(V=V.toLowerCase())||V==V.toLowerCase()&&(V=V.toUpperCase()))){A=!0,k=-1,I=0;continue}return D(q,String(l),E,y)}E=!1,V=z(V,y,10,q.s),(I=V.indexOf("."))>-1?V=V.replace(".",""):I=V.length}for(k=0;V.charCodeAt(k)===48;k++);for(C=V.length;V.charCodeAt(--C)===48;);if(V=V.slice(k,++C)){if(C-=k,E&&U.DEBUG&&C>15&&(l>f||l!==i(l)))throw Error(o+q.s*l);if((I=I-k-1)>S)q.c=q.e=null;else if(I<B)q.c=[q.e=0];else{if(q.e=I,q.c=[],k=(I+1)%c,I<0&&(k+=c),k<C){for(k&&q.c.push(+V.slice(0,k)),C-=c;k<C;)q.c.push(+V.slice(k,k+=c));k=c-(V=V.slice(k)).length}else k-=C;for(;k--;V+="0");q.c.push(+V)}}else q.c=[q.e=0]}U.clone=_,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(l){var y,g;if(l!=null)if(typeof l=="object"){if(l.hasOwnProperty(y="DECIMAL_PLACES")&&(g=l[y],R(g,0,m,y),ee=g),l.hasOwnProperty(y="ROUNDING_MODE")&&(g=l[y],R(g,0,8,y),ne=g),l.hasOwnProperty(y="EXPONENTIAL_AT")&&(g=l[y],g&&g.pop?(R(g[0],-m,0,y),R(g[1],0,m,y),w=g[0],b=g[1]):(R(g,-m,m,y),w=-(b=g<0?-g:g))),l.hasOwnProperty(y="RANGE"))if(g=l[y],g&&g.pop)R(g[0],-m,-1,y),R(g[1],1,m,y),B=g[0],S=g[1];else if(R(g,-m,m,y),g)B=-(S=g<0?-g:g);else throw Error(s+y+" cannot be zero: "+g);if(l.hasOwnProperty(y="CRYPTO"))if(g=l[y],g===!!g)if(g)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))N=g;else throw N=!g,Error(s+"crypto unavailable");else N=g;else throw Error(s+y+" not true or false: "+g);if(l.hasOwnProperty(y="MODULO_MODE")&&(g=l[y],R(g,0,9,y),H=g),l.hasOwnProperty(y="POW_PRECISION")&&(g=l[y],R(g,0,m,y),Z=g),l.hasOwnProperty(y="FORMAT"))if(g=l[y],typeof g=="object")ae=g;else throw Error(s+y+" not an object: "+g);if(l.hasOwnProperty(y="ALPHABET"))if(g=l[y],typeof g=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(g))W=g.slice(0,10)=="0123456789",oe=g;else throw Error(s+y+" invalid: "+g)}else throw Error(s+"Object expected: "+l);return{DECIMAL_PLACES:ee,ROUNDING_MODE:ne,EXPONENTIAL_AT:[w,b],RANGE:[B,S],CRYPTO:N,MODULO_MODE:H,POW_PRECISION:Z,FORMAT:ae,ALPHABET:oe}},U.isBigNumber=function(l){if(!l||l._isBigNumber!==!0)return!1;if(!U.DEBUG)return!0;var y,g,P=l.c,A=l.e,I=l.s;e:if({}.toString.call(P)=="[object Array]"){if((I===1||I===-1)&&A>=-m&&A<=m&&A===i(A)){if(P[0]===0){if(A===0&&P.length===1)return!0;break e}if(y=(A+1)%c,y<1&&(y+=c),String(P[0]).length==y){for(y=0;y<P.length;y++)if(g=P[y],g<0||g>=a||g!==i(g))break e;if(g!==0)return!0}}}else if(P===null&&A===null&&(I===null||I===1||I===-1))return!0;throw Error(s+"Invalid BigNumber: "+l)},U.maximum=U.max=function(){return J(arguments,-1)},U.minimum=U.min=function(){return J(arguments,1)},U.random=function(){var l=9007199254740992,y=Math.random()*l&2097151?function(){return i(Math.random()*l)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(g){var P,A,I,k,E,C=0,V=[],q=new U(ie);if(g==null?g=ee:R(g,0,m),k=n(g/c),N)if(crypto.getRandomValues){for(P=crypto.getRandomValues(new Uint32Array(k*=2));C<k;)E=P[C]*131072+(P[C+1]>>>11),E>=9e15?(A=crypto.getRandomValues(new Uint32Array(2)),P[C]=A[0],P[C+1]=A[1]):(V.push(E%1e14),C+=2);C=k/2}else if(crypto.randomBytes){for(P=crypto.randomBytes(k*=7);C<k;)E=(P[C]&31)*281474976710656+P[C+1]*1099511627776+P[C+2]*4294967296+P[C+3]*16777216+(P[C+4]<<16)+(P[C+5]<<8)+P[C+6],E>=9e15?crypto.randomBytes(7).copy(P,C):(V.push(E%1e14),C+=7);C=k/7}else throw N=!1,Error(s+"crypto unavailable");if(!N)for(;C<k;)E=y(),E<9e15&&(V[C++]=E%1e14);for(k=V[--C],g%=c,k&&g&&(E=d[c-g],V[C]=i(k/E)*E);V[C]===0;V.pop(),C--);if(C<0)V=[I=0];else{for(I=-1;V[0]===0;V.splice(0,1),I-=c);for(C=1,E=V[0];E>=10;E/=10,C++);C<c&&(I-=c-C)}return q.e=I,q.c=V,q}}(),U.sum=function(){for(var l=1,y=arguments,g=new U(y[0]);l<y.length;)g=g.plus(y[l++]);return g},z=function(){var l="0123456789";function y(g,P,A,I){for(var k,E=[0],C,V=0,q=g.length;V<q;){for(C=E.length;C--;E[C]*=P);for(E[0]+=I.indexOf(g.charAt(V++)),k=0;k<E.length;k++)E[k]>A-1&&(E[k+1]==null&&(E[k+1]=0),E[k+1]+=E[k]/A|0,E[k]%=A)}return E.reverse()}return function(g,P,A,I,k){var E,C,V,q,X,te,de,_e,Fe=g.indexOf("."),Ve=ee,me=ne;for(Fe>=0&&(q=Z,Z=0,g=g.replace(".",""),_e=new U(P),te=_e.pow(g.length-Fe),Z=q,_e.c=y(K(T(te.c),te.e,"0"),10,A,l),_e.e=_e.c.length),de=y(g,P,A,k?(E=oe,l):(E=l,oe)),V=q=de.length;de[--q]==0;de.pop());if(!de[0])return E.charAt(0);if(Fe<0?--V:(te.c=de,te.e=V,te.s=I,te=$(te,_e,Ve,me,A),de=te.c,X=te.r,V=te.e),C=V+Ve+1,Fe=de[C],q=A/2,X=X||C<0||de[C+1]!=null,X=me<4?(Fe!=null||X)&&(me==0||me==(te.s<0?3:2)):Fe>q||Fe==q&&(me==4||X||me==6&&de[C-1]&1||me==(te.s<0?8:7)),C<1||!de[0])g=X?K(E.charAt(1),-Ve,E.charAt(0)):E.charAt(0);else{if(de.length=C,X)for(--A;++de[--C]>A;)de[C]=0,C||(++V,de=[1].concat(de));for(q=de.length;!de[--q];);for(Fe=0,g="";Fe<=q;g+=E.charAt(de[Fe++]));g=K(g,V,E.charAt(0))}return g}}(),$=function(){function l(P,A,I){var k,E,C,V,q=0,X=P.length,te=A%h,de=A/h|0;for(P=P.slice();X--;)C=P[X]%h,V=P[X]/h|0,k=de*C+V*te,E=te*C+k%h*h+q,q=(E/I|0)+(k/h|0)+de*V,P[X]=E%I;return q&&(P=[q].concat(P)),P}function y(P,A,I,k){var E,C;if(I!=k)C=I>k?1:-1;else for(E=C=0;E<I;E++)if(P[E]!=A[E]){C=P[E]>A[E]?1:-1;break}return C}function g(P,A,I,k){for(var E=0;I--;)P[I]-=E,E=P[I]<A[I]?1:0,P[I]=E*k+P[I]-A[I];for(;!P[0]&&P.length>1;P.splice(0,1));}return function(P,A,I,k,E){var C,V,q,X,te,de,_e,Fe,Ve,me,he,Xe,Er,Gr,Fn,Lt,Pe,qt=P.s==A.s?1:-1,mt=P.c,Ye=A.c;if(!mt||!mt[0]||!Ye||!Ye[0])return new U(!P.s||!A.s||(mt?Ye&&mt[0]==Ye[0]:!Ye)?NaN:mt&&mt[0]==0||!Ye?qt*0:qt/0);for(Fe=new U(qt),Ve=Fe.c=[],V=P.e-A.e,qt=I+V+1,E||(E=a,V=u(P.e/c)-u(A.e/c),qt=qt/c|0),q=0;Ye[q]==(mt[q]||0);q++);if(Ye[q]>(mt[q]||0)&&V--,qt<0)Ve.push(1),X=!0;else{for(Gr=mt.length,Lt=Ye.length,q=0,qt+=2,te=i(E/(Ye[0]+1)),te>1&&(Ye=l(Ye,te,E),mt=l(mt,te,E),Lt=Ye.length,Gr=mt.length),Er=Lt,me=mt.slice(0,Lt),he=me.length;he<Lt;me[he++]=0);Pe=Ye.slice(),Pe=[0].concat(Pe),Fn=Ye[0],Ye[1]>=E/2&&Fn++;do{if(te=0,C=y(Ye,me,Lt,he),C<0){if(Xe=me[0],Lt!=he&&(Xe=Xe*E+(me[1]||0)),te=i(Xe/Fn),te>1)for(te>=E&&(te=E-1),de=l(Ye,te,E),_e=de.length,he=me.length;y(de,me,_e,he)==1;)te--,g(de,Lt<_e?Pe:Ye,_e,E),_e=de.length,C=1;else te==0&&(C=te=1),de=Ye.slice(),_e=de.length;if(_e<he&&(de=[0].concat(de)),g(me,de,he,E),he=me.length,C==-1)for(;y(Ye,me,Lt,he)<1;)te++,g(me,Lt<he?Pe:Ye,he,E),he=me.length}else C===0&&(te++,me=[0]);Ve[q++]=te,me[0]?me[he++]=mt[Er]||0:(me=[mt[Er]],he=1)}while((Er++<Gr||me[0]!=null)&&qt--);X=me[0]!=null,Ve[0]||Ve.splice(0,1)}if(E==a){for(q=1,qt=Ve[0];qt>=10;qt/=10,q++);fe(Fe,I+(Fe.e=q+V*c-1)+1,k,X)}else Fe.e=V,Fe.r=+X;return Fe}}();function p(l,y,g,P){var A,I,k,E,C;if(g==null?g=ne:R(g,0,8),!l.c)return l.toString();if(A=l.c[0],k=l.e,y==null)C=T(l.c),C=P==1||P==2&&(k<=w||k>=b)?M(C,k):K(C,k,"0");else if(l=fe(new U(l),y,g),I=l.e,C=T(l.c),E=C.length,P==1||P==2&&(y<=I||I<=w)){for(;E<y;C+="0",E++);C=M(C,I)}else if(y-=k,C=K(C,I,"0"),I+1>E){if(--y>0)for(C+=".";y--;C+="0");}else if(y+=I-E,y>0)for(I+1==E&&(C+=".");y--;C+="0");return l.s<0&&A?"-"+C:C}function J(l,y){for(var g,P,A=1,I=new U(l[0]);A<l.length;A++)P=new U(l[A]),(!P.s||(g=O(I,P))===y||g===0&&I.s===y)&&(I=P);return I}function re(l,y,g){for(var P=1,A=y.length;!y[--A];y.pop());for(A=y[0];A>=10;A/=10,P++);return(g=P+g*c-1)>S?l.c=l.e=null:g<B?l.c=[l.e=0]:(l.e=g,l.c=y),l}D=function(){var l=/^(-?)0([xbo])(?=\w[\w.]*$)/i,y=/^([^.]+)\.$/,g=/^\.([^.]+)$/,P=/^-?(Infinity|NaN)$/,A=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(I,k,E,C){var V,q=E?k:k.replace(A,"");if(P.test(q))I.s=isNaN(q)?null:q<0?-1:1;else{if(!E&&(q=q.replace(l,function(X,te,de){return V=(de=de.toLowerCase())=="x"?16:de=="b"?2:8,!C||C==V?te:X}),C&&(V=C,q=q.replace(y,"$1").replace(g,"0.$1")),k!=q))return new U(q,V);if(U.DEBUG)throw Error(s+"Not a"+(C?" base "+C:"")+" number: "+k);I.s=null}I.c=I.e=null}}();function fe(l,y,g,P){var A,I,k,E,C,V,q,X=l.c,te=d;if(X){e:{for(A=1,E=X[0];E>=10;E/=10,A++);if(I=y-A,I<0)I+=c,k=y,C=X[V=0],q=i(C/te[A-k-1]%10);else if(V=n((I+1)/c),V>=X.length)if(P){for(;X.length<=V;X.push(0));C=q=0,A=1,I%=c,k=I-c+1}else break e;else{for(C=E=X[V],A=1;E>=10;E/=10,A++);I%=c,k=I-c+A,q=k<0?0:i(C/te[A-k-1]%10)}if(P=P||y<0||X[V+1]!=null||(k<0?C:C%te[A-k-1]),P=g<4?(q||P)&&(g==0||g==(l.s<0?3:2)):q>5||q==5&&(g==4||P||g==6&&(I>0?k>0?C/te[A-k]:0:X[V-1])%10&1||g==(l.s<0?8:7)),y<1||!X[0])return X.length=0,P?(y-=l.e+1,X[0]=te[(c-y%c)%c],l.e=-y||0):X[0]=l.e=0,l;if(I==0?(X.length=V,E=1,V--):(X.length=V+1,E=te[c-I],X[V]=k>0?i(C/te[A-k]%te[k])*E:0),P)for(;;)if(V==0){for(I=1,k=X[0];k>=10;k/=10,I++);for(k=X[0]+=E,E=1;k>=10;k/=10,E++);I!=E&&(l.e++,X[0]==a&&(X[0]=1));break}else{if(X[V]+=E,X[V]!=a)break;X[V--]=0,E=1}for(I=X.length;X[--I]===0;X.pop());}l.e>S?l.c=l.e=null:l.e<B&&(l.c=[l.e=0])}return l}function Q(l){var y,g=l.e;return g===null?l.toString():(y=T(l.c),y=g<=w||g>=b?M(y,g):K(y,g,"0"),l.s<0?"-"+y:y)}return j.absoluteValue=j.abs=function(){var l=new U(this);return l.s<0&&(l.s=1),l},j.comparedTo=function(l,y){return O(this,new U(l,y))},j.decimalPlaces=j.dp=function(l,y){var g,P,A,I=this;if(l!=null)return R(l,0,m),y==null?y=ne:R(y,0,8),fe(new U(I),l+I.e+1,y);if(!(g=I.c))return null;if(P=((A=g.length-1)-u(this.e/c))*c,A=g[A])for(;A%10==0;A/=10,P--);return P<0&&(P=0),P},j.dividedBy=j.div=function(l,y){return $(this,new U(l,y),ee,ne)},j.dividedToIntegerBy=j.idiv=function(l,y){return $(this,new U(l,y),0,1)},j.exponentiatedBy=j.pow=function(l,y){var g,P,A,I,k,E,C,V,q,X=this;if(l=new U(l),l.c&&!l.isInteger())throw Error(s+"Exponent not an integer: "+Q(l));if(y!=null&&(y=new U(y)),E=l.e>14,!X.c||!X.c[0]||X.c[0]==1&&!X.e&&X.c.length==1||!l.c||!l.c[0])return q=new U(Math.pow(+Q(X),E?l.s*(2-F(l)):+Q(l))),y?q.mod(y):q;if(C=l.s<0,y){if(y.c?!y.c[0]:!y.s)return new U(NaN);P=!C&&X.isInteger()&&y.isInteger(),P&&(X=X.mod(y))}else{if(l.e>9&&(X.e>0||X.e<-1||(X.e==0?X.c[0]>1||E&&X.c[1]>=24e7:X.c[0]<8e13||E&&X.c[0]<=9999975e7)))return I=X.s<0&&F(l)?-0:0,X.e>-1&&(I=1/I),new U(C?1/I:I);Z&&(I=n(Z/c+2))}for(E?(g=new U(.5),C&&(l.s=1),V=F(l)):(A=Math.abs(+Q(l)),V=A%2),q=new U(ie);;){if(V){if(q=q.times(X),!q.c)break;I?q.c.length>I&&(q.c.length=I):P&&(q=q.mod(y))}if(A){if(A=i(A/2),A===0)break;V=A%2}else if(l=l.times(g),fe(l,l.e+1,1),l.e>14)V=F(l);else{if(A=+Q(l),A===0)break;V=A%2}X=X.times(X),I?X.c&&X.c.length>I&&(X.c.length=I):P&&(X=X.mod(y))}return P?q:(C&&(q=ie.div(q)),y?q.mod(y):I?fe(q,Z,ne,k):q)},j.integerValue=function(l){var y=new U(this);return l==null?l=ne:R(l,0,8),fe(y,y.e+1,l)},j.isEqualTo=j.eq=function(l,y){return O(this,new U(l,y))===0},j.isFinite=function(){return!!this.c},j.isGreaterThan=j.gt=function(l,y){return O(this,new U(l,y))>0},j.isGreaterThanOrEqualTo=j.gte=function(l,y){return(y=O(this,new U(l,y)))===1||y===0},j.isInteger=function(){return!!this.c&&u(this.e/c)>this.c.length-2},j.isLessThan=j.lt=function(l,y){return O(this,new U(l,y))<0},j.isLessThanOrEqualTo=j.lte=function(l,y){return(y=O(this,new U(l,y)))===-1||y===0},j.isNaN=function(){return!this.s},j.isNegative=function(){return this.s<0},j.isPositive=function(){return this.s>0},j.isZero=function(){return!!this.c&&this.c[0]==0},j.minus=function(l,y){var g,P,A,I,k=this,E=k.s;if(l=new U(l,y),y=l.s,!E||!y)return new U(NaN);if(E!=y)return l.s=-y,k.plus(l);var C=k.e/c,V=l.e/c,q=k.c,X=l.c;if(!C||!V){if(!q||!X)return q?(l.s=-y,l):new U(X?k:NaN);if(!q[0]||!X[0])return X[0]?(l.s=-y,l):new U(q[0]?k:ne==3?-0:0)}if(C=u(C),V=u(V),q=q.slice(),E=C-V){for((I=E<0)?(E=-E,A=q):(V=C,A=X),A.reverse(),y=E;y--;A.push(0));A.reverse()}else for(P=(I=(E=q.length)<(y=X.length))?E:y,E=y=0;y<P;y++)if(q[y]!=X[y]){I=q[y]<X[y];break}if(I&&(A=q,q=X,X=A,l.s=-l.s),y=(P=X.length)-(g=q.length),y>0)for(;y--;q[g++]=0);for(y=a-1;P>E;){if(q[--P]<X[P]){for(g=P;g&&!q[--g];q[g]=y);--q[g],q[P]+=a}q[P]-=X[P]}for(;q[0]==0;q.splice(0,1),--V);return q[0]?re(l,q,V):(l.s=ne==3?-1:1,l.c=[l.e=0],l)},j.modulo=j.mod=function(l,y){var g,P,A=this;return l=new U(l,y),!A.c||!l.s||l.c&&!l.c[0]?new U(NaN):!l.c||A.c&&!A.c[0]?new U(A):(H==9?(P=l.s,l.s=1,g=$(A,l,0,3),l.s=P,g.s*=P):g=$(A,l,0,H),l=A.minus(g.times(l)),!l.c[0]&&H==1&&(l.s=A.s),l)},j.multipliedBy=j.times=function(l,y){var g,P,A,I,k,E,C,V,q,X,te,de,_e,Fe,Ve,me=this,he=me.c,Xe=(l=new U(l,y)).c;if(!he||!Xe||!he[0]||!Xe[0])return!me.s||!l.s||he&&!he[0]&&!Xe||Xe&&!Xe[0]&&!he?l.c=l.e=l.s=null:(l.s*=me.s,!he||!Xe?l.c=l.e=null:(l.c=[0],l.e=0)),l;for(P=u(me.e/c)+u(l.e/c),l.s*=me.s,C=he.length,X=Xe.length,C<X&&(_e=he,he=Xe,Xe=_e,A=C,C=X,X=A),A=C+X,_e=[];A--;_e.push(0));for(Fe=a,Ve=h,A=X;--A>=0;){for(g=0,te=Xe[A]%Ve,de=Xe[A]/Ve|0,k=C,I=A+k;I>A;)V=he[--k]%Ve,q=he[k]/Ve|0,E=de*V+q*te,V=te*V+E%Ve*Ve+_e[I]+g,g=(V/Fe|0)+(E/Ve|0)+de*q,_e[I--]=V%Fe;_e[I]=g}return g?++P:_e.splice(0,1),re(l,_e,P)},j.negated=function(){var l=new U(this);return l.s=-l.s||null,l},j.plus=function(l,y){var g,P=this,A=P.s;if(l=new U(l,y),y=l.s,!A||!y)return new U(NaN);if(A!=y)return l.s=-y,P.minus(l);var I=P.e/c,k=l.e/c,E=P.c,C=l.c;if(!I||!k){if(!E||!C)return new U(A/0);if(!E[0]||!C[0])return C[0]?l:new U(E[0]?P:A*0)}if(I=u(I),k=u(k),E=E.slice(),A=I-k){for(A>0?(k=I,g=C):(A=-A,g=E),g.reverse();A--;g.push(0));g.reverse()}for(A=E.length,y=C.length,A-y<0&&(g=C,C=E,E=g,y=A),A=0;y;)A=(E[--y]=E[y]+C[y]+A)/a|0,E[y]=a===E[y]?0:E[y]%a;return A&&(E=[A].concat(E),++k),re(l,E,k)},j.precision=j.sd=function(l,y){var g,P,A,I=this;if(l!=null&&l!==!!l)return R(l,1,m),y==null?y=ne:R(y,0,8),fe(new U(I),l,y);if(!(g=I.c))return null;if(A=g.length-1,P=A*c+1,A=g[A]){for(;A%10==0;A/=10,P--);for(A=g[0];A>=10;A/=10,P++);}return l&&I.e+1>P&&(P=I.e+1),P},j.shiftedBy=function(l){return R(l,-f,f),this.times("1e"+l)},j.squareRoot=j.sqrt=function(){var l,y,g,P,A,I=this,k=I.c,E=I.s,C=I.e,V=ee+4,q=new U("0.5");if(E!==1||!k||!k[0])return new U(!E||E<0&&(!k||k[0])?NaN:k?I:1/0);if(E=Math.sqrt(+Q(I)),E==0||E==1/0?(y=T(k),(y.length+C)%2==0&&(y+="0"),E=Math.sqrt(+y),C=u((C+1)/2)-(C<0||C%2),E==1/0?y="5e"+C:(y=E.toExponential(),y=y.slice(0,y.indexOf("e")+1)+C),g=new U(y)):g=new U(E+""),g.c[0]){for(C=g.e,E=C+V,E<3&&(E=0);;)if(A=g,g=q.times(A.plus($(I,A,V,1))),T(A.c).slice(0,E)===(y=T(g.c)).slice(0,E))if(g.e<C&&--E,y=y.slice(E-3,E+1),y=="9999"||!P&&y=="4999"){if(!P&&(fe(A,A.e+ee+2,0),A.times(A).eq(I))){g=A;break}V+=4,E+=4,P=1}else{(!+y||!+y.slice(1)&&y.charAt(0)=="5")&&(fe(g,g.e+ee+2,1),l=!g.times(g).eq(I));break}}return fe(g,g.e+ee+1,ne,l)},j.toExponential=function(l,y){return l!=null&&(R(l,0,m),l++),p(this,l,y,1)},j.toFixed=function(l,y){return l!=null&&(R(l,0,m),l=l+this.e+1),p(this,l,y)},j.toFormat=function(l,y,g){var P,A=this;if(g==null)l!=null&&y&&typeof y=="object"?(g=y,y=null):l&&typeof l=="object"?(g=l,l=y=null):g=ae;else if(typeof g!="object")throw Error(s+"Argument not an object: "+g);if(P=A.toFixed(l,y),A.c){var I,k=P.split("."),E=+g.groupSize,C=+g.secondaryGroupSize,V=g.groupSeparator||"",q=k[0],X=k[1],te=A.s<0,de=te?q.slice(1):q,_e=de.length;if(C&&(I=E,E=C,C=I,_e-=I),E>0&&_e>0){for(I=_e%E||E,q=de.substr(0,I);I<_e;I+=E)q+=V+de.substr(I,E);C>0&&(q+=V+de.slice(I)),te&&(q="-"+q)}P=X?q+(g.decimalSeparator||"")+((C=+g.fractionGroupSize)?X.replace(new RegExp("\\d{"+C+"}\\B","g"),"$&"+(g.fractionGroupSeparator||"")):X):q}return(g.prefix||"")+P+(g.suffix||"")},j.toFraction=function(l){var y,g,P,A,I,k,E,C,V,q,X,te,de=this,_e=de.c;if(l!=null&&(E=new U(l),!E.isInteger()&&(E.c||E.s!==1)||E.lt(ie)))throw Error(s+"Argument "+(E.isInteger()?"out of range: ":"not an integer: ")+Q(E));if(!_e)return new U(de);for(y=new U(ie),V=g=new U(ie),P=C=new U(ie),te=T(_e),I=y.e=te.length-de.e-1,y.c[0]=d[(k=I%c)<0?c+k:k],l=!l||E.comparedTo(y)>0?I>0?y:V:E,k=S,S=1/0,E=new U(te),C.c[0]=0;q=$(E,y,0,1),A=g.plus(q.times(P)),A.comparedTo(l)!=1;)g=P,P=A,V=C.plus(q.times(A=V)),C=A,y=E.minus(q.times(A=y)),E=A;return A=$(l.minus(g),P,0,1),C=C.plus(A.times(V)),g=g.plus(A.times(P)),C.s=V.s=de.s,I=I*2,X=$(V,P,I,ne).minus(de).abs().comparedTo($(C,g,I,ne).minus(de).abs())<1?[V,P]:[C,g],S=k,X},j.toNumber=function(){return+Q(this)},j.toPrecision=function(l,y){return l!=null&&R(l,1,m),p(this,l,y,2)},j.toString=function(l){var y,g=this,P=g.s,A=g.e;return A===null?P?(y="Infinity",P<0&&(y="-"+y)):y="NaN":(l==null?y=A<=w||A>=b?M(T(g.c),A):K(T(g.c),A,"0"):l===10&&W?(g=fe(new U(g),ee+A+1,ne),y=K(T(g.c),g.e,"0")):(R(l,2,oe.length,"Base"),y=z(K(T(g.c),A,"0"),10,l,P,!0)),P<0&&g.c[0]&&(y="-"+y)),y},j.valueOf=j.toJSON=function(){return Q(this)},j._isBigNumber=!0,x!=null&&U.set(x),U}function u(x){var $=x|0;return x>0||x===$?$:$-1}function T(x){for(var $,z,D=1,j=x.length,ie=x[0]+"";D<j;){for($=x[D++]+"",z=c-$.length;z--;$="0"+$);ie+=$}for(j=ie.length;ie.charCodeAt(--j)===48;);return ie.slice(0,j+1||1)}function O(x,$){var z,D,j=x.c,ie=$.c,ee=x.s,ne=$.s,w=x.e,b=$.e;if(!ee||!ne)return null;if(z=j&&!j[0],D=ie&&!ie[0],z||D)return z?D?0:-ne:ee;if(ee!=ne)return ee;if(z=ee<0,D=w==b,!j||!ie)return D?0:!j^z?1:-1;if(!D)return w>b^z?1:-1;for(ne=(w=j.length)<(b=ie.length)?w:b,ee=0;ee<ne;ee++)if(j[ee]!=ie[ee])return j[ee]>ie[ee]^z?1:-1;return w==b?0:w>b^z?1:-1}function R(x,$,z,D){if(x<$||x>z||x!==i(x))throw Error(s+(D||"Argument")+(typeof x=="number"?x<$||x>z?" out of range: ":" not an integer: ":" not a primitive number: ")+String(x))}function F(x){var $=x.c.length-1;return u(x.e/c)==$&&x.c[$]%2!=0}function M(x,$){return(x.length>1?x.charAt(0)+"."+x.slice(1):x)+($<0?"e":"e+")+$}function K(x,$,z){var D,j;if($<0){for(j=z+".";++$;j+=z);x=j+x}else if(D=x.length,++$>D){for(j=z,$-=D;--$;j+=z);x+=j}else $<D&&(x=x.slice(0,$)+"."+x.slice($));return x}e=_(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof Po<"u"&&Po.exports?Po.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(jd)});var Hd=L((Z8,kd)=>{kd.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,f=r.pushInt64Neg,d=r.pushFloat,h=r.pushFloatSingle,m=r.pushFloatDouble,_=r.pushTrue,u=r.pushFalse,T=r.pushUndefined,O=r.pushNull,R=r.pushInfinity,F=r.pushInfinityNeg,M=r.pushNaN,K=r.pushNaNNeg,x=r.pushArrayStart,$=r.pushArrayStartFixed,z=r.pushArrayStartFixed32,D=r.pushArrayStartFixed64,j=r.pushObjectStart,ie=r.pushObjectStartFixed,ee=r.pushObjectStartFixed32,ne=r.pushObjectStartFixed64,w=r.pushByteString,b=r.pushByteStringStart,B=r.pushUtf8String,S=r.pushUtf8StringStart,N=r.pushSimpleUnassigned,H=r.pushTagStart,Z=r.pushTagStart4,ae=r.pushTagStart8,oe=r.pushTagUnassigned,W=r.pushBreak,U=e.Math.pow,p=0,J=0,re=0;function fe(v){for(v=v|0,p=0,J=v;(p|0)<(J|0)&&(re=qg[i[p]&255](i[p]|0)|0,!((re|0)>0)););return re|0}function Q(v){return v=v|0,((p|0)+(v|0)|0)<(J|0)?0:1}function l(v){return v=v|0,i[v|0]<<8|i[v+1|0]|0}function y(v){return v=v|0,i[v|0]<<24|i[v+1|0]<<16|i[v+2|0]<<8|i[v+3|0]|0}function g(v){return v=v|0,s(v|0),p=p+1|0,0}function P(v){return v=v|0,Q(1)|0?1:(s(i[p+1|0]|0),p=p+2|0,0)}function A(v){return v=v|0,Q(2)|0?1:(s(l(p+1|0)|0),p=p+3|0,0)}function I(v){return v=v|0,Q(4)|0?1:(o(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function k(v){return v=v|0,Q(8)|0?1:(c(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function E(v){return v=v|0,s(-1-(v-32|0)|0),p=p+1|0,0}function C(v){return v=v|0,Q(1)|0?1:(s(-1-(i[p+1|0]|0)|0),p=p+2|0,0)}function V(v){v=v|0;var Te=0;return Q(2)|0?1:(Te=l(p+1|0)|0,s(-1-(Te|0)|0),p=p+3|0,0)}function q(v){return v=v|0,Q(4)|0?1:(a(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function X(v){return v=v|0,Q(8)|0?1:(f(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function te(v){v=v|0;var Te=0,Be=0,xe=0;return xe=v-64|0,Q(xe|0)|0?1:(Te=p+1|0,Be=(p+1|0)+(xe|0)|0,w(Te|0,Be|0),p=Be|0,0)}function de(v){v=v|0;var Te=0,Be=0,xe=0;return Q(1)|0||(xe=i[p+1|0]|0,Te=p+2|0,Be=(p+2|0)+(xe|0)|0,Q(xe+1|0)|0)?1:(w(Te|0,Be|0),p=Be|0,0)}function _e(v){v=v|0;var Te=0,Be=0,xe=0;return Q(2)|0||(xe=l(p+1|0)|0,Te=p+3|0,Be=(p+3|0)+(xe|0)|0,Q(xe+2|0)|0)?1:(w(Te|0,Be|0),p=Be|0,0)}function Fe(v){v=v|0;var Te=0,Be=0,xe=0;return Q(4)|0||(xe=y(p+1|0)|0,Te=p+5|0,Be=(p+5|0)+(xe|0)|0,Q(xe+4|0)|0)?1:(w(Te|0,Be|0),p=Be|0,0)}function Ve(v){return v=v|0,1}function me(v){return v=v|0,b(),p=p+1|0,0}function he(v){v=v|0;var Te=0,Be=0,xe=0;return xe=v-96|0,Q(xe|0)|0?1:(Te=p+1|0,Be=(p+1|0)+(xe|0)|0,B(Te|0,Be|0),p=Be|0,0)}function Xe(v){v=v|0;var Te=0,Be=0,xe=0;return Q(1)|0||(xe=i[p+1|0]|0,Te=p+2|0,Be=(p+2|0)+(xe|0)|0,Q(xe+1|0)|0)?1:(B(Te|0,Be|0),p=Be|0,0)}function Er(v){v=v|0;var Te=0,Be=0,xe=0;return Q(2)|0||(xe=l(p+1|0)|0,Te=p+3|0,Be=(p+3|0)+(xe|0)|0,Q(xe+2|0)|0)?1:(B(Te|0,Be|0),p=Be|0,0)}function Gr(v){v=v|0;var Te=0,Be=0,xe=0;return Q(4)|0||(xe=y(p+1|0)|0,Te=p+5|0,Be=(p+5|0)+(xe|0)|0,Q(xe+4|0)|0)?1:(B(Te|0,Be|0),p=Be|0,0)}function Fn(v){return v=v|0,1}function Lt(v){return v=v|0,S(),p=p+1|0,0}function Pe(v){return v=v|0,$(v-128|0),p=p+1|0,0}function qt(v){return v=v|0,Q(1)|0?1:($(i[p+1|0]|0),p=p+2|0,0)}function mt(v){return v=v|0,Q(2)|0?1:($(l(p+1|0)|0),p=p+3|0,0)}function Ye(v){return v=v|0,Q(4)|0?1:(z(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function mg(v){return v=v|0,Q(8)|0?1:(D(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function bg(v){return v=v|0,x(),p=p+1|0,0}function ze(v){v=v|0;var Te=0;return Te=v-160|0,Q(Te|0)|0?1:(ie(Te|0),p=p+1|0,0)}function _g(v){return v=v|0,Q(1)|0?1:(ie(i[p+1|0]|0),p=p+2|0,0)}function wg(v){return v=v|0,Q(2)|0?1:(ie(l(p+1|0)|0),p=p+3|0,0)}function Eg(v){return v=v|0,Q(4)|0?1:(ee(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function xg(v){return v=v|0,Q(8)|0?1:(ne(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function vg(v){return v=v|0,j(),p=p+1|0,0}function ri(v){return v=v|0,H(v-192|0|0),p=p+1|0,0}function y8(v){return v=v|0,H(v|0),p=p+1|0,0}function g8(v){return v=v|0,H(v|0),p=p+1|0,0}function m8(v){return v=v|0,H(v|0),p=p+1|0,0}function b8(v){return v=v|0,H(v|0),p=p+1|0,0}function lt(v){return v=v|0,H(v-192|0|0),p=p+1|0,0}function _8(v){return v=v|0,H(v|0),p=p+1|0,0}function w8(v){return v=v|0,H(v|0),p=p+1|0,0}function E8(v){return v=v|0,H(v|0),p=p+1|0,0}function Tg(v){return v=v|0,Q(1)|0?1:(H(i[p+1|0]|0),p=p+2|0,0)}function Ag(v){return v=v|0,Q(2)|0?1:(H(l(p+1|0)|0),p=p+3|0,0)}function Sg(v){return v=v|0,Q(4)|0?1:(Z(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function Bg(v){return v=v|0,Q(8)|0?1:(ae(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function rt(v){return v=v|0,N((v|0)-224|0),p=p+1|0,0}function Og(v){return v=v|0,u(),p=p+1|0,0}function Ng(v){return v=v|0,_(),p=p+1|0,0}function Rg(v){return v=v|0,O(),p=p+1|0,0}function Pg(v){return v=v|0,T(),p=p+1|0,0}function Ig(v){return v=v|0,Q(1)|0?1:(N(i[p+1|0]|0),p=p+2|0,0)}function Ug(v){v=v|0;var Te=0,Be=0,xe=1,Xs=0,Ki=0,x8=0;return Q(2)|0?1:(Te=i[p+1|0]|0,Be=i[p+2|0]|0,(Te|0)&128&&(xe=-1),Xs=+(((Te|0)&124)>>2),Ki=+(((Te|0)&3)<<8|Be),+Xs==0?d(+(+xe*5960464477539063e-23*+Ki)):+Xs==31?+xe==1?+Ki>0?M():R():+Ki>0?K():F():d(+(+xe*U(2,+(+Xs-25))*+(1024+Ki))),p=p+3|0,0)}function Fg(v){return v=v|0,Q(4)|0?1:(h(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0),p=p+5|0,0)}function Mg(v){return v=v|0,Q(8)|0?1:(m(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0,i[p+5|0]|0,i[p+6|0]|0,i[p+7|0]|0,i[p+8|0]|0),p=p+9|0,0)}function ke(v){return v=v|0,1}function Cg(v){return v=v|0,W(),p=p+1|0,0}var qg=[g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,P,A,I,k,ke,ke,ke,ke,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,C,V,q,X,ke,ke,ke,ke,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,_e,Fe,Ve,ke,ke,ke,me,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,Xe,Er,Gr,Fn,ke,ke,ke,Lt,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,qt,mt,Ye,mg,ke,ke,ke,bg,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,_g,wg,Eg,xg,ke,ke,ke,vg,ri,ri,ri,ri,ri,ri,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,lt,Tg,Ag,Sg,Bg,ke,ke,ke,ke,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,Og,Ng,Rg,Pg,Ig,Ug,Fg,Mg,ke,ke,ke,Cg];return{parse:fe}}});var ts=L(Yt=>{"use strict";var au=es().BigNumber;Yt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Yt.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};Yt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Yt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Yt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Yt.SHIFT32=Math.pow(2,32);Yt.SHIFT16=Math.pow(2,16);Yt.MAX_SAFE_HIGH=2097151;Yt.NEG_ONE=new au(-1);Yt.TEN=new au(10);Yt.TWO=new au(2);Yt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Io=L(rr=>{"use strict";var{Buffer:Vb}=ni("buffer"),$d=es().BigNumber,Kd=ts(),Vd=Kd.SHIFT32,$b=Kd.SHIFT16,Kb=2097151;rr.parseHalf=function(e){var r,n,i;return i=e[0]&128?-1:1,r=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function Gb(t){return t<16?"0"+t.toString(16):t.toString(16)}rr.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=Gb(t[n]);return new $d(r,16)};rr.buildMap=t=>{let e=new Map,r=Object.keys(t),n=r.length;for(let i=0;i<n;i++)e.set(r[i],t[r[i]]);return e};rr.buildInt32=(t,e)=>t*$b+e;rr.buildInt64=(t,e,r,n)=>{let i=rr.buildInt32(t,e),s=rr.buildInt32(r,n);return i>Kb?new $d(i).times(Vd).plus(s):i*Vd+s};rr.writeHalf=function(e,r){let n=Vb.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};rr.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])};rr.isNegativeZero=t=>t===0&&1/t<0;rr.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var fu=L((Q8,Gd)=>{"use strict";var lu=ts(),Yb=lu.MT,Uo=lu.SIMPLE,cu=lu.SYMS,uu=class t{constructor(e){if(typeof e!="number")throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(e|0)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,Yb.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case Uo.FALSE:return!1;case Uo.TRUE:return!0;case Uo.NULL:return r?null:cu.NULL;case Uo.UNDEFINED:return r?void 0:cu.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return cu.BREAK;default:return new t(e)}}};Gd.exports=uu});var hu=L((L8,Yd)=>{"use strict";var du=class t{constructor(e,r,n){if(this.tag=e,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(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var r,n;if(n=e?.[this.tag],typeof n!="function"&&(n=t["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(t,this.value)}catch(i){return r=i,this.err=r,this}}};Yd.exports=du});var yu=L((ev,Wd)=>{"use strict";var{URL:zb,URLSearchParams:Wb,format:Db}=ni("url"),zd="http://localhost",pu=class extends zb{constructor(e="",r=zd){super(e,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()}};Wd.exports={URLWithLegacySupport:pu,URLSearchParams:Wb,format:Db,defaultBase:zd}});var Xd=L((tv,Zd)=>{"use strict";var{URLWithLegacySupport:Dd,format:Zb}=yu();Zd.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new Dd(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new Dd(t,Zb(o)).toString()}});var gu=L((rv,Jd)=>{"use strict";var{URLWithLegacySupport:Xb,format:Jb,URLSearchParams:Qb,defaultBase:Lb}=yu(),e1=Xd();Jd.exports={URL:Xb,URLSearchParams:Qb,format:Jb,relative:e1,defaultBase:Lb}});var mu=L((nv,Ld)=>{"use strict";var{Buffer:_i}=ni("buffer"),Qd=mc(),t1=es().BigNumber,r1=Hd(),Rt=Io(),Ce=ts(),n1=fu(),i1=hu(),{URL:s1}=gu(),rs=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=Rt.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=_i.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>Rt.arrayBufferToBignumber(r),3:r=>Ce.NEG_ONE.minus(Rt.arrayBufferToBignumber(r)),4:r=>Ce.TEN.pow(r[0]).times(r[1]),5:r=>Ce.TWO.pow(r[0]).times(r[1]),32:r=>new s1(r),35:r=>new RegExp(r)},e.tags),this.parser=r1(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 e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case Ce.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case Ce.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case Ce.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case Ce.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case Ce.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case Ce.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===Ce.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,r){let n=this._currentParent;switch(n.values++,n.type){case Ce.PARENT.ARRAY:case Ce.PARENT.BYTE_STRING:case Ce.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case Ce.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=Ce.PARENT.MAP,n.ref=Rt.buildMap(n.ref)));break;case Ce.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case Ce.PARENT.TAG:this._ref.push(e),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,r,n){this._parents[this._depth]={type:r,length:n,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:Ce.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new i1(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return _i.concat(e)}createByteStringFromHeap(e,r){return e===r?_i.alloc(0):_i.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return Rt.buildInt32(e,r)}createInt64(e,r,n,i){return Rt.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return Qd.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return Qd.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-Rt.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=Rt.buildInt32(e,r),o=Rt.buildInt32(n,i);return s>Ce.MAX_SAFE_HIGH?Ce.NEG_ONE.minus(new t1(s).times(Ce.SHIFT32).plus(o)):-1-(s*Ce.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,r){return e.join("")}createUtf8StringFromHeap(e,r){return e===r?"":this._buffer.toString("utf8",e,r)}createSimpleUnassigned(e){return new n1(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,r){this._push(this.createInt32(e,r))}pushInt64(e,r,n,i){this._push(this.createInt64(e,r,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,r,n,i){this._push(this.createFloatSingle(e,r,n,i))}pushFloatDouble(e,r,n,i,s,o,a,c){this._push(this.createFloatDouble(e,r,n,i,s,o,a,c))}pushInt32Neg(e,r){this._push(this.createInt32Neg(e,r))}pushInt64Neg(e,r,n,i){this._push(this.createInt64Neg(e,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([],Ce.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=Rt.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=Rt.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=Rt.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=Rt.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:Ce.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,r){this._push(this.createByteStringFromHeap(e,r))}pushUtf8StringStart(){this._parents[this._depth]={type:Ce.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,r){this._push(this.createUtf8StringFromHeap(e,r))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:Ce.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(Rt.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(Rt.buildInt64(e,r,n,i))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){if(e===0){this._push(this.createObject({}));return}this._createParent({},Ce.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),Ce.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let r=this.parser.parse(e.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(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,r){return typeof e=="string"&&(e=_i.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=_i.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};rs.decodeFirst=rs.decode;Ld.exports=rs});var r0=L((iv,t0)=>{"use strict";var{Buffer:bu}=ni("buffer"),o1=mu(),a1=Io(),_u=class t extends o1{createTag(e,r){return`${e}(${r})`}createInt(e){return super.createInt(e).toString()}createInt32(e,r){return super.createInt32(e,r).toString()}createInt64(e,r,n,i){return super.createInt64(e,r,n,i).toString()}createInt32Neg(e,r){return super.createInt32Neg(e,r).toString()}createInt64Neg(e,r,n,i){return super.createInt64Neg(e,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let r=super.createFloat(e);return a1.isNegativeZero(e)?"-0_1":`${r}_1`}createFloatSingle(e,r,n,i){return`${super.createFloatSingle(e,r,n,i)}_2`}createFloatDouble(e,r,n,i,s,o,a,c){return`${super.createFloatDouble(e,r,n,i,s,o,a,c)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${bu.from(super.createByteStringFromHeap(e,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(e){return`simple(${e})`}createArray(e,r){let n=super.createArray(e,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(e,r){let n=super.createMap(e),i=Array.from(n.keys()).reduce(e0(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(e0(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${bu.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=bu.from(e,r||"hex")),new t().decodeFirst(e)}};t0.exports=_u;function e0(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var a0=L((sv,o0)=>{"use strict";var{Buffer:Rr}=ni("buffer"),{URL:c1}=gu(),Eu=es().BigNumber,wu=Io(),st=ts(),ur=st.MT,Fo=st.NUMBYTES,n0=st.SHIFT32,i0=st.SYMS,wi=st.TAG,u1=st.MT.SIMPLE_FLOAT<<5|st.NUMBYTES.TWO,l1=st.MT.SIMPLE_FLOAT<<5|st.NUMBYTES.FOUR,f1=st.MT.SIMPLE_FLOAT<<5|st.NUMBYTES.EIGHT,d1=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.TRUE,h1=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.FALSE,p1=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.UNDEFINED,s0=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.NULL,y1=new Eu("0x20000000000000"),g1=Rr.from("f97e00","hex"),m1=Rr.from("f9fc00","hex"),b1=Rr.from("f97c00","hex");function _1(t){return{}.toString.call(t).slice(8,-1)}var xu=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[c1,this._pushUrl],[Eu,this._pushBigNumber]];let r=e.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(e,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===e){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}return this.semanticTypes.push([e,r]),null}push(e){return e&&(this.result[this.offset]=e,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=e.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(e,r,n){return this.result[this.offset]=e,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(e){return this.pushWrite(e,1,1)}_pushUInt16BE(e){return this.pushWrite(e,2,2)}_pushUInt32BE(e){return this.pushWrite(e,3,4)}_pushDoubleBE(e){return this.pushWrite(e,4,8)}_pushNaN(){return this.push(g1)}_pushInfinity(e){let r=e<0?m1:b1;return this.push(r)}_pushFloat(e){let r=Rr.allocUnsafe(2);if(wu.writeHalf(r,e)&&wu.parseHalf(r)===e)return this._pushUInt8(u1)&&this.push(r);let n=Rr.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(l1)&&this.push(n):this._pushUInt8(f1)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|Fo.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|Fo.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|Fo.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Fo.EIGHT)&&this._pushUInt32BE(Math.floor(e/n0))&&this._pushUInt32BE(e%n0):r===ur.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,ur.NEG_INT,e):this._pushInt(e,ur.POS_INT)}_pushNumber(e){switch(!1){case e===e:return this._pushNaN(e);case isFinite(e):return this._pushInfinity(e);case e%1!==0:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){let r=Rr.byteLength(e,"utf8");return this._pushInt(r,ur.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?d1:h1)}_pushUndefined(e){return this._pushUInt8(p1)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,ur.ARRAY))return!1;for(let i=0;i<n;i++)if(!e.pushAny(r[i]))return!1;return!0}_pushTag(e){return this._pushInt(e,ur.TAG)}_pushDate(e,r){return e._pushTag(wi.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,ur.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(wi.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,ur.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(wi.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=wi.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=wi.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Rr.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(e,r){if(r.isNaN())return e._pushNaN();if(!r.isFinite())return e._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return e._pushBigint(r);if(!(e._pushTag(wi.DECIMAL_FRAC)&&e._pushInt(2,ur.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new Eu(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(y1)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,ur.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(s0);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(e instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(e,this,e);var i=e.encodeCBOR;if(typeof i=="function")return i.call(e,this);var s=Object.keys(e),o=s.length;return this._pushInt(o,ur.MAP)?this._pushRawMap(o,s.map(a=>[a,e[a]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(wu.keySorter);for(var n=0;n<e;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var r=_1(e);switch(r){case"Number":return this._pushNumber(e);case"String":return this._pushString(e);case"Boolean":return this._pushBoolean(e);case"Object":return this._pushObject(e);case"Array":return this._pushArray(this,e);case"Uint8Array":return this._pushBuffer(this,Rr.isBuffer(e)?e:Rr.from(e));case"Null":return this._pushUInt8(s0);case"Undefined":return this._pushUndefined(e);case"Map":return this._pushMap(this,e);case"Set":return this._pushSet(this,e);case"URL":return this._pushUrl(this,e);case"BigNumber":return this._pushBigNumber(this,e);case"Date":return this._pushDate(this,e);case"RegExp":return this._pushRegexp(this,e);case"Symbol":switch(e){case i0.NULL:return this._pushObject(null);case i0.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=Rr.allocUnsafe(s),c=0,f=0;for(o=0;o<i;o++){switch(f=r[o],n[o]){case 0:e[o].copy(a,c);break;case 1:a.writeUInt8(e[o],c,!0);break;case 2:a.writeUInt16BE(e[o],c,!0);break;case 3:a.writeUInt32BE(e[o],c,!0);break;case 4:a.writeDoubleBE(e[o],c,!0);break;case 5:a.write(e[o],c,f,"utf8");break;default:throw new Error("unkown method")}c+=f}var d=a;return this._reset(),d}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let r=new t;if(!r.pushAny(e))throw new Error("Failed to encode input");return r.finalize()}};o0.exports=xu});var Mo=L(ot=>{"use strict";ot.Diagnose=r0();ot.Decoder=mu();ot.Encoder=a0();ot.Simple=fu();ot.Tagged=hu();ot.decodeAll=ot.Decoder.decodeAll;ot.decodeFirst=ot.Decoder.decodeFirst;ot.diagnose=ot.Diagnose.diagnose;ot.encode=ot.Encoder.encode;ot.decode=ot.Decoder.decode;ot.leveldb={decode:ot.Decoder.decodeAll,encode:ot.Encoder.encode,buffer:!0,name:"cbor"}});var ss=L(nr=>{"use strict";var w1=nr&&nr.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(nr,"__esModule",{value:!0});nr.hashOfMap=nr.requestIdOf=nr.hashValue=nr.hash=void 0;var c0=bi(),E1=w1(Mo()),x1=oo(),ns=kt();function fn(t){return(0,ns.uint8ToBuf)(x1.sha256.create().update(new Uint8Array(t)).digest())}nr.hash=fn;function is(t){if(t instanceof E1.default.Tagged)return is(t.value);if(typeof t=="string")return u0(t);if(typeof t=="number")return fn((0,c0.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return fn(t);if(Array.isArray(t)){let e=t.map(is);return fn((0,ns.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return fn(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return is(t.toHash());if(typeof t=="object")return vu(t);if(typeof t=="bigint")return fn((0,c0.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}nr.hashValue=is;var u0=t=>{let e=new TextEncoder().encode(t);return fn(e)};function v1(t){return vu(t)}nr.requestIdOf=v1;function vu(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=u0(o),f=is(a);return[c,f]}).sort(([o],[a])=>(0,ns.compare)(o,a)),i=(0,ns.concat)(...n.map(o=>(0,ns.concat)(...o)));return fn(i)}nr.hashOfMap=vu});var Su=L(Pr=>{"use strict";var T1=Pr&&Pr.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(Pr,"__esModule",{value:!0});Pr.createIdentityDescriptor=Pr.AnonymousIdentity=Pr.SignIdentity=void 0;var l0=Nt(),A1=ss(),f0=kt(),S1=new TextEncoder().encode(`
|
|
17
|
+
ic-request`),Tu=class{getPrincipal(){return this._principal||(this._principal=l0.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=T1(e,["body"]),i=await(0,A1.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,f0.concat)(S1,i))}})}};Pr.SignIdentity=Tu;var Au=class{getPrincipal(){return l0.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};Pr.AnonymousIdentity=Au;function B1(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,f0.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Pr.createIdentityDescriptor=B1});var Nu=L($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});var O1=9007199254740992;function Dr(t,...e){let r=new Uint8Array(t.byteLength+e.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(t),0);let n=t.byteLength;for(let i of e)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function lr(t,e,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(t<<5)+e].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function Co(t,e){if(e<24)return new Uint8Array([(t<<5)+e]).buffer;{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27;return lr(t,r,e.toString(16))}}function d0(t){let e=[];for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|t.charCodeAt(r)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Dr(new Uint8Array(Co(3,t.length)),new Uint8Array(e))}function N1(t,e){if(t==14277111)return Dr(new Uint8Array([217,217,247]),e);if(t<24)return Dr(new Uint8Array([192+t]),e);{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27,n=2**(r-24),i=t.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}$e.tagged=N1;function os(t){return new Uint8Array(t).buffer}$e.raw=os;function Bu(t){if(isNaN(t))throw new RangeError("Invalid number.");t=Math.min(Math.max(0,t),23);let e=[0+t];return new Uint8Array(e).buffer}$e.uSmall=Bu;function h0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),255),t=t.toString(16),lr(0,24,t)}$e.u8=h0;function p0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),65535),t=t.toString(16),lr(0,25,t)}$e.u16=p0;function y0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),4294967295),t=t.toString(16),lr(0,26,t)}$e.u32=y0;function Ou(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return lr(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),O1),t=t.toString(16),lr(0,27,t)}$e.u64=Ou;function g0(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Bu(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}$e.iSmall=g0;function m0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),255),t=t.toString(16),lr(1,24,t)}$e.i8=m0;function b0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),65535),t=t.toString(16),lr(1,25,t)}$e.i16=b0;function _0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),4294967295),t=t.toString(16),lr(1,26,t)}$e.i32=_0;function w0(t,e){if(typeof t=="string"&&e==16){if(t.startsWith("-")?t=t.slice(1):t="0",t.match(/[^0-9a-fA-F]/)||t.length>16)throw new RangeError("Invalid number.");let r=!1,n=t.split("").reduceRight((i,s)=>{if(r)return s+i;let o=parseInt(s,16)-1;return o>=0?(r=!0,o.toString(16)+i):"f"+i},"");return r?lr(1,27,n):Ou(0)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),9007199254740992),t=t.toString(16),lr(1,27,t)}$e.i64=w0;function R1(t){return t>=0?t<24?Bu(t):t<=255?h0(t):t<=65535?p0(t):t<=4294967295?y0(t):Ou(t):t>=-24?g0(t):t>=-255?m0(t):t>=-65535?b0(t):t>=-4294967295?_0(t):w0(t)}$e.number=R1;function P1(t){return Dr(Co(2,t.byteLength),t)}$e.bytes=P1;function I1(t){return d0(t)}$e.string=I1;function U1(t){return Dr(Co(4,t.length),...t)}$e.array=U1;function F1(t,e=!1){t instanceof Map||(t=new Map(Object.entries(t)));let r=Array.from(t.entries());return e&&(r=r.sort(([n],[i])=>n.localeCompare(i))),Dr(Co(5,t.size),...r.map(([n,i])=>Dr(d0(n),i)))}$e.map=F1;function M1(t){let e=new Float32Array([t]);return Dr(new Uint8Array([250]),new Uint8Array(e.buffer))}$e.singleFloat=M1;function C1(t){let e=new Float64Array([t]);return Dr(new Uint8Array([251]),new Uint8Array(e.buffer))}$e.doubleFloat=C1;function q1(t){return t?E0():x0()}$e.bool=q1;function E0(){return os(new Uint8Array([245]))}$e.true_=E0;function x0(){return os(new Uint8Array([244]))}$e.false_=x0;function j1(){return os(new Uint8Array([246]))}$e.null_=j1;function k1(){return os(new Uint8Array([247]))}$e.undefined_=k1});var v0=L(dn=>{"use strict";var H1=dn&&dn.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(dn,"__esModule",{value:!0});var fr=H1(Nu()),V1=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],qo=class{constructor(e,r=!1){this._serializer=e,this._stable=r,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return fr.undefined_();case"boolean":return fr.bool(e);case"number":return Math.floor(e)===e?fr.number(e):fr.doubleFloat(e);case"string":return fr.string(e);case"object":if(e===null)return fr.null_();if(Array.isArray(e))return fr.array(e.map(r=>this._serializer.serializeValue(r)));if(V1.find(r=>e instanceof r))return fr.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let r=new Map;for(let[n,i]of e.entries())r.set(n,this._serializer.serializeValue(i));return fr.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(e))r.set(n,this._serializer.serializeValue(i));return fr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};dn.JsonDefaultCborEncoder=qo;var jo=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};dn.ToCborEncoder=jo;var ko=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new qo(r,e)),r.addEncoder(new jo),r}removeEncoder(e){for(let r of this._encoders.values())r.name==e&&this._encoders.delete(r)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(e)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};dn.CborSerializer=ko;var Ru=class extends ko{serialize(e){return fr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};dn.SelfDescribeCborSerializer=Ru});var as=L(kn=>{"use strict";function $1(t){for(var e in t)kn.hasOwnProperty(e)||(kn[e]=t[e])}var K1=kn&&kn.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(kn,"__esModule",{value:!0});$1(v0());var G1=K1(Nu());kn.value=G1});var cs=L(bt=>{"use strict";var Y1=bt&&bt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),z1=bt&&bt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),W1=bt&&bt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Y1(e,t,r);return z1(e,t),e},D1=bt&&bt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bt,"__esModule",{value:!0});bt.decode=bt.encode=bt.CborTag=void 0;var Z1=D1(Mo()),Ei=W1(as()),X1=as(),Ho=kt(),Pu=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Ei.value.bytes(e.toUint8Array())}},Iu=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Ei.value.bytes(new Uint8Array(e))}},Uu=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Ei.value.tagged(2,Ei.value.bytes((0,Ho.fromHex)(e.toString(16)))):Ei.value.tagged(3,Ei.value.bytes((0,Ho.fromHex)((BigInt("-1")*e).toString(16))))}},Vo=X1.SelfDescribeCborSerializer.withDefaultEncoders(!0);Vo.addEncoder(new Pu);Vo.addEncoder(new Iu);Vo.addEncoder(new Uu);var A0;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(A0=bt.CborTag||(bt.CborTag={}));function J1(t){return Vo.serialize(t)}bt.encode=J1;function T0(t){let e=t.byteLength,r=BigInt(0);for(let n=0;n<e;n++)r=r*BigInt(256)+BigInt(t[n]);return r}var Fu=class extends Z1.default.Decoder{createByteString(e){return(0,Ho.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function Q1(t){let e=new Uint8Array(t),r=new Fu({size:e.byteLength,tags:{2:n=>T0(n),3:n=>-T0(n),[A0.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,Ho.toHex)(e)}`)}}bt.decode=Q1});var Mu=L($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.randomNumber=void 0;var L1=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};$o.randomNumber=L1});var us=L(Hn=>{"use strict";Object.defineProperty(Hn,"__esModule",{value:!0});Hn.makeNonce=Hn.SubmitRequestType=void 0;var Ko=Mu(),e_;(function(t){t.Call="call"})(e_=Hn.SubmitRequestType||(Hn.SubmitRequestType={}));function t_(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,Ko.randomNumber)(),n=(0,Ko.randomNumber)(),i=(0,Ko.randomNumber)(),s=(0,Ko.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}Hn.makeNonce=t_});var Yo=L(At=>{"use strict";var r_=At&&At.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),n_=At&&At.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i_=At&&At.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&r_(e,t,r);return n_(e,t),e};Object.defineProperty(At,"__esModule",{value:!0});At.httpHeadersTransform=At.makeExpiryTransform=At.makeNonceTransform=At.Expiry=void 0;var s_=bi(),o_=i_(as()),a_=us(),S0=BigInt(1e6),c_=60*1e3,Go=class{constructor(e){if(e<90*1e3){let a=BigInt(Date.now()+e)*S0/BigInt(1e9);this._value=a*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-c_))*S0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return o_.value.u64(this._value.toString(16),16)}toHash(){return(0,s_.lebEncode)(this._value)}};At.Expiry=Go;function u_(t=a_.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}At.makeNonceTransform=u_;function l_(t){return async e=>{e.body.ingress_expiry=new Go(t)}}At.makeExpiryTransform=l_;function f_(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}At.httpHeadersTransform=f_});var qu=L(zo=>{"use strict";Object.defineProperty(zo,"__esModule",{value:!0});zo.AgentHTTPResponseError=void 0;var d_=fi(),Cu=class extends d_.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};zo.AgentHTTPResponseError=Cu});var zt=L(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.notImplemented=Ie.bitMask=void 0;Ie.isBytes=Do;Ie.abytes=Zo;Ie.abool=p_;Ie.bytesToHex=Vu;Ie.numberToHexUnpadded=N0;Ie.hexToNumber=$u;Ie.hexToBytes=Xo;Ie.bytesToNumberBE=g_;Ie.bytesToNumberLE=m_;Ie.numberToBytesBE=R0;Ie.numberToBytesLE=b_;Ie.numberToVarBytesBE=__;Ie.ensureBytes=w_;Ie.concatBytes=P0;Ie.equalBytes=E_;Ie.utf8ToBytes=x_;Ie.inRange=I0;Ie.aInRange=v_;Ie.bitLen=T_;Ie.bitGet=A_;Ie.bitSet=S_;Ie.createHmacDrbg=O_;Ie.validateObject=R_;Ie.memoized=I_;var Hu=BigInt(0),Wo=BigInt(1),h_=BigInt(2);function Do(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Zo(t){if(!Do(t))throw new Error("Uint8Array expected")}function p_(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}var y_=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Vu(t){Zo(t);let e="";for(let r=0;r<t.length;r++)e+=y_[t[r]];return e}function N0(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function $u(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Zr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function B0(t){if(t>=Zr._0&&t<=Zr._9)return t-Zr._0;if(t>=Zr._A&&t<=Zr._F)return t-(Zr._A-10);if(t>=Zr._a&&t<=Zr._f)return t-(Zr._a-10)}function Xo(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=B0(t.charCodeAt(s)),a=B0(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function g_(t){return $u(Vu(t))}function m_(t){return Zo(t),$u(Vu(Uint8Array.from(t).reverse()))}function R0(t,e){return Xo(t.toString(16).padStart(e*2,"0"))}function b_(t,e){return R0(t,e).reverse()}function __(t){return Xo(N0(t))}function w_(t,e,r){let n;if(typeof e=="string")try{n=Xo(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(Do(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function P0(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];Zo(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function E_(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function x_(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}var ju=t=>typeof t=="bigint"&&Hu<=t;function I0(t,e,r){return ju(t)&&ju(e)&&ju(r)&&e<=t&&t<r}function v_(t,e,r,n){if(!I0(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function T_(t){let e;for(e=0;t>Hu;t>>=Wo,e+=1);return e}function A_(t,e){return t>>BigInt(e)&Wo}function S_(t,e,r){return t|(r?Wo:Hu)<<BigInt(e)}var B_=t=>(h_<<BigInt(t-1))-Wo;Ie.bitMask=B_;var ku=t=>new Uint8Array(t),O0=t=>Uint8Array.from(t);function O_(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=ku(t),i=ku(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...h)=>r(i,n,...h),c=(h=ku())=>{i=a(O0([0]),h),n=a(),h.length!==0&&(i=a(O0([1]),h),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,m=[];for(;h<e;){n=a();let _=n.slice();m.push(_),h+=n.length}return P0(...m)};return(h,m)=>{o(),c(h);let _;for(;!(_=m(f()));)c();return o(),_}}var N_={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Do(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function R_(t,e,r={}){let n=(i,s,o)=>{let a=N_[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return t}var P_=()=>{throw new Error("not implemented")};Ie.notImplemented=P_;function I_(t){let e=new WeakMap;return(r,...n)=>{let i=e.get(r);if(i!==void 0)return i;let s=t(r,...n);return e.set(r,s),s}}});var Ir=L(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.isNegativeLE=void 0;We.mod=Wt;We.pow=M0;We.pow2=C_;We.invert=Jo;We.tonelliShanks=C0;We.FpSqrt=q0;We.validateField=k_;We.FpPow=j0;We.FpInvertBatch=k0;We.FpDiv=H_;We.FpLegendre=H0;We.FpIsSquare=V_;We.nLength=Gu;We.Field=$_;We.FpSqrtOdd=K_;We.FpSqrtEven=G_;We.hashToPrivateScalar=Y_;We.getFieldBytesLength=Yu;We.getMinHashLength=V0;We.mapHashToField=z_;var Dt=zt(),at=BigInt(0),He=BigInt(1),hn=BigInt(2),U_=BigInt(3),Ku=BigInt(4),U0=BigInt(5),F0=BigInt(8),F_=BigInt(9),M_=BigInt(16);function Wt(t,e){let r=t%e;return r>=at?r:e+r}function M0(t,e,r){if(r<=at||e<at)throw new Error("Expected power/modulo > 0");if(r===He)return at;let n=He;for(;e>at;)e&He&&(n=n*t%r),t=t*t%r,e>>=He;return n}function C_(t,e,r){let n=t;for(;e-- >at;)n*=n,n%=r;return n}function Jo(t,e){if(t===at||e<=at)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Wt(t,e),n=e,i=at,s=He,o=He,a=at;for(;r!==at;){let f=n/r,d=n%r,h=i-o*f,m=s-a*f;n=r,r=d,i=o,s=a,o=h,a=m}if(n!==He)throw new Error("invert: does not exist");return Wt(i,e)}function C0(t){let e=(t-He)/hn,r,n,i;for(r=t-He,n=0;r%hn===at;r/=hn,n++);for(i=hn;i<t&&M0(i,e,t)!==t-He;i++);if(n===1){let o=(t+He)/Ku;return function(c,f){let d=c.pow(f,o);if(!c.eql(c.sqr(d),f))throw new Error("Cannot find square root");return d}}let s=(r+He)/hn;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,d=a.pow(a.mul(a.ONE,i),r),h=a.pow(c,s),m=a.pow(c,r);for(;!a.eql(m,a.ONE);){if(a.eql(m,a.ZERO))return a.ZERO;let _=1;for(let T=a.sqr(m);_<f&&!a.eql(T,a.ONE);_++)T=a.sqr(T);let u=a.pow(d,He<<BigInt(f-_-1));d=a.sqr(u),h=a.mul(h,u),m=a.mul(m,d),f=_}return h}}function q0(t){if(t%Ku===U_){let e=(t+He)/Ku;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%F0===U0){let e=(t-U0)/F0;return function(n,i){let s=n.mul(i,hn),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,hn),o),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%M_,C0(t)}var q_=(t,e)=>(Wt(t,e)&He)===He;We.isNegativeLE=q_;var j_=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function k_(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=j_.reduce((n,i)=>(n[i]="function",n),e);return(0,Dt.validateObject)(t,r)}function j0(t,e,r){if(r<at)throw new Error("Expected power > 0");if(r===at)return t.ONE;if(r===He)return e;let n=t.ONE,i=e;for(;r>at;)r&He&&(n=t.mul(n,i)),i=t.sqr(i),r>>=He;return n}function k0(t,e){let r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function H_(t,e,r){return t.mul(e,typeof r=="bigint"?Jo(r,t.ORDER):t.inv(r))}function H0(t){let e=(t-He)/hn;return(r,n)=>r.pow(n,e)}function V_(t){let e=H0(t.ORDER);return r=>{let n=e(t,r);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}function Gu(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function $_(t,e,r=!1,n={}){if(t<=at)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=Gu(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=q0(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Dt.bitMask)(i),ZERO:at,ONE:He,create:c=>Wt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return at<=c&&c<t},is0:c=>c===at,isOdd:c=>(c&He)===He,neg:c=>Wt(-c,t),eql:(c,f)=>c===f,sqr:c=>Wt(c*c,t),add:(c,f)=>Wt(c+f,t),sub:(c,f)=>Wt(c-f,t),mul:(c,f)=>Wt(c*f,t),pow:(c,f)=>j0(a,c,f),div:(c,f)=>Wt(c*Jo(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Jo(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>k0(a,c),cmov:(c,f,d)=>d?f:c,toBytes:c=>r?(0,Dt.numberToBytesLE)(c,s):(0,Dt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Dt.bytesToNumberLE)(c):(0,Dt.bytesToNumberBE)(c)}});return Object.freeze(a)}function K_(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)}function G_(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function Y_(t,e,r=!1){t=(0,Dt.ensureBytes)("privateHash",t);let n=t.length,i=Gu(e).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,Dt.bytesToNumberLE)(t):(0,Dt.bytesToNumberBE)(t);return Wt(s,e-He)+He}function Yu(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function V0(t){let e=Yu(t);return e+Math.ceil(e/2)}function z_(t,e,r=!1){let n=t.length,i=Yu(e),s=V0(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Dt.bytesToNumberBE)(t):(0,Dt.bytesToNumberLE)(t),a=Wt(o,e-He)+He;return r?(0,Dt.numberToBytesLE)(a,i):(0,Dt.numberToBytesBE)(a,i)}});var Qo=L(Vn=>{"use strict";Object.defineProperty(Vn,"__esModule",{value:!0});Vn.expand_message_xmd=$0;Vn.expand_message_xof=K0;Vn.hash_to_field=zu;Vn.isogenyMap=X_;Vn.createHasher=J_;var W_=Ir(),St=zt(),D_=St.bytesToNumberBE;function pn(t,e){if(ls(t),ls(e),t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function Z_(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function ls(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function $0(t,e,r,n){(0,St.abytes)(t),(0,St.abytes)(e),ls(r),e.length>255&&(e=n((0,St.concatBytes)((0,St.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=(0,St.concatBytes)(e,pn(e.length,1)),c=pn(0,s),f=pn(r,2),d=new Array(o),h=n((0,St.concatBytes)(c,t,f,pn(0,1),a));d[0]=n((0,St.concatBytes)(h,pn(1,1),a));for(let _=1;_<=o;_++){let u=[Z_(h,d[_-1]),pn(_+1,1),a];d[_]=n((0,St.concatBytes)(...u))}return(0,St.concatBytes)(...d).slice(0,r)}function K0(t,e,r,n,i){if((0,St.abytes)(t),(0,St.abytes)(e),ls(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update((0,St.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(pn(r,2)).update(e).update(pn(e.length,1)).digest()}function zu(t,e,r){(0,St.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:a,DST:c}=r;(0,St.abytes)(t),ls(e);let f=typeof c=="string"?(0,St.utf8ToBytes)(c):c,d=n.toString(2).length,h=Math.ceil((d+i)/8),m=e*s*h,_;if(a==="xmd")_=$0(t,f,m,o);else if(a==="xof")_=K0(t,f,m,i,o);else if(a==="_internal_pass")_=t;else throw new Error('expand must be "xmd" or "xof"');let u=new Array(e);for(let T=0;T<e;T++){let O=new Array(s);for(let R=0;R<s;R++){let F=h*(R+T*s),M=_.subarray(F,F+h);O[R]=(0,W_.mod)(D_(M),n)}u[T]=O}return u}function X_(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(f=>f.reduce((d,h)=>t.add(t.mul(d,n),h)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}function J_(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=zu(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=zu(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=t.fromAffine(e(n)).clearCofactor();return i.assertValidity(),i}}}});var Zu=L(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0});fs.wNAF=L_;fs.pippenger=ew;fs.validateBasic=tw;var G0=Ir(),z0=zt(),Q_=BigInt(0),Wu=BigInt(1),Du=new WeakMap,Y0=new WeakMap;function L_(t,e){let r=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=t.ZERO,c=s;for(;o>Q_;)o&Wu&&(a=a.add(c)),c=c.double(),o>>=Wu;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),f=[],d=s,h=d;for(let m=0;m<a;m++){h=d,f.push(h);for(let _=1;_<c;_++)h=h.add(d),f.push(h);d=h.double()}return f},wNAF(s,o,a){let{windows:c,windowSize:f}=i(s),d=t.ZERO,h=t.BASE,m=BigInt(2**s-1),_=2**s,u=BigInt(s);for(let T=0;T<c;T++){let O=T*f,R=Number(a&m);a>>=u,R>f&&(R-=_,a+=Wu);let F=O,M=O+Math.abs(R)-1,K=T%2!==0,x=R<0;R===0?h=h.add(r(K,o[F])):d=d.add(r(x,o[M]))}return{p:d,f:h}},wNAFCached(s,o,a){let c=Y0.get(s)||1,f=Du.get(s);return f||(f=this.precomputeWindow(s,c),c!==1&&Du.set(s,a(f))),this.wNAF(c,f,o)},setWindowSize(s,o){n(o),Y0.set(s,o),Du.delete(s)}}}function ew(t,e,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((d,h)=>{if(!e.isValid(d))throw new Error(`wrong scalar at index ${h}`)}),r.forEach((d,h)=>{if(!(d instanceof t))throw new Error(`wrong point at index ${h}`)});let i=(0,z0.bitLen)(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,a=new Array(o+1).fill(t.ZERO),c=Math.floor((e.BITS-1)/s)*s,f=t.ZERO;for(let d=c;d>=0;d-=s){a.fill(t.ZERO);for(let m=0;m<n.length;m++){let _=n[m],u=Number(_>>BigInt(d)&BigInt(o));a[u]=a[u].add(r[m])}let h=t.ZERO;for(let m=a.length-1,_=t.ZERO;m>0;m--)_=_.add(a[m]),h=h.add(_);if(f=f.add(h),d!==0)for(let m=0;m<s;m++)f=f.double()}return f}function tw(t){return(0,G0.validateField)(t.Fp),(0,z0.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,G0.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}});var Xu=L(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.DER=void 0;wt.weierstrassPoints=Z0;wt.weierstrass=ow;wt.SWUFpSqrtRatio=X0;wt.mapToCurveSimpleSWU=aw;var Lo=Zu(),$n=Ir(),Ae=zt(),_t=zt();function W0(t){t.lowS!==void 0&&(0,_t.abool)("lowS",t.lowS),t.prehash!==void 0&&(0,_t.abool)("prehash",t.prehash)}function rw(t){let e=(0,Lo.validateBasic)(t);Ae.validateObject(e,{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}=e;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({...e})}var{bytesToNumberBE:nw,hexToBytes:iw}=Ae;wt.DER={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,e)=>{let{Err:r}=wt.DER;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,i=Ae.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Ae.numberToHexUnpadded(i.length/2|128):"";return`${Ae.numberToHexUnpadded(t)}${s}${i}${e}`},decode(t,e){let{Err:r}=wt.DER,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let i=e[n++],s=!!(i&128),o=0;if(!s)o=i;else{let c=i&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of f)o=o<<8|d;if(n+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){let{Err:e}=wt.DER;if(t<dr)throw new e("integer: negative integers are not allowed");let r=Ae.numberToHexUnpadded(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected assertion");return r},decode(t){let{Err:e}=wt.DER;if(t[0]&128)throw new e("Invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return nw(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=wt.DER,i=typeof t=="string"?iw(t):t;Ae.abytes(i);let{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:f,l:d}=n.decode(2,c);if(d.length)throw new e("Invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(t){let{_tlv:e,_int:r}=wt.DER,n=`${e.encode(2,r.encode(t.r))}${e.encode(2,r.encode(t.s))}`;return e.encode(48,n)}};var dr=BigInt(0),qe=BigInt(1),yn=BigInt(2),ea=BigInt(3),D0=BigInt(4);function Z0(t){let e=rw(t),{Fp:r}=e,n=$n.Field(e.n,e.nBitLength),i=e.toBytes||((T,O,R)=>{let F=O.toAffine();return Ae.concatBytes(Uint8Array.from([4]),r.toBytes(F.x),r.toBytes(F.y))}),s=e.fromBytes||(T=>{let O=T.subarray(1),R=r.fromBytes(O.subarray(0,r.BYTES)),F=r.fromBytes(O.subarray(r.BYTES,2*r.BYTES));return{x:R,y:F}});function o(T){let{a:O,b:R}=e,F=r.sqr(T),M=r.mul(F,T);return r.add(r.add(M,r.mul(T,O)),R)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(T){return Ae.inRange(T,qe,e.n)}function c(T){let{allowedPrivateKeyLengths:O,nByteLength:R,wrapPrivateKey:F,n:M}=e;if(O&&typeof T!="bigint"){if(Ae.isBytes(T)&&(T=Ae.bytesToHex(T)),typeof T!="string"||!O.includes(T.length))throw new Error("Invalid key");T=T.padStart(R*2,"0")}let K;try{K=typeof T=="bigint"?T:Ae.bytesToNumberBE((0,_t.ensureBytes)("private key",T,R))}catch{throw new Error(`private key must be ${R} bytes, hex or bigint, not ${typeof T}`)}return F&&(K=$n.mod(K,M)),Ae.aInRange("private key",K,qe,M),K}function f(T){if(!(T instanceof m))throw new Error("ProjectivePoint expected")}let d=(0,_t.memoized)((T,O)=>{let{px:R,py:F,pz:M}=T;if(r.eql(M,r.ONE))return{x:R,y:F};let K=T.is0();O==null&&(O=K?r.ONE:r.inv(M));let x=r.mul(R,O),$=r.mul(F,O),z=r.mul(M,O);if(K)return{x:r.ZERO,y:r.ZERO};if(!r.eql(z,r.ONE))throw new Error("invZ was invalid");return{x,y:$}}),h=(0,_t.memoized)(T=>{if(T.is0()){if(e.allowInfinityPoint&&!r.is0(T.py))return;throw new Error("bad point: ZERO")}let{x:O,y:R}=T.toAffine();if(!r.isValid(O)||!r.isValid(R))throw new Error("bad point: x or y not FE");let F=r.sqr(R),M=o(O);if(!r.eql(F,M))throw new Error("bad point: equation left != right");if(!T.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(O,R,F){if(this.px=O,this.py=R,this.pz=F,O==null||!r.isValid(O))throw new Error("x required");if(R==null||!r.isValid(R))throw new Error("y required");if(F==null||!r.isValid(F))throw new Error("z required");Object.freeze(this)}static fromAffine(O){let{x:R,y:F}=O||{};if(!O||!r.isValid(R)||!r.isValid(F))throw new Error("invalid affine point");if(O instanceof m)throw new Error("projective point not allowed");let M=K=>r.eql(K,r.ZERO);return M(R)&&M(F)?m.ZERO:new m(R,F,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(O){let R=r.invertBatch(O.map(F=>F.pz));return O.map((F,M)=>F.toAffine(R[M])).map(m.fromAffine)}static fromHex(O){let R=m.fromAffine(s((0,_t.ensureBytes)("pointHex",O)));return R.assertValidity(),R}static fromPrivateKey(O){return m.BASE.multiply(c(O))}static msm(O,R){return(0,Lo.pippenger)(m,n,O,R)}_setWindowSize(O){u.setWindowSize(this,O)}assertValidity(){h(this)}hasEvenY(){let{y:O}=this.toAffine();if(r.isOdd)return!r.isOdd(O);throw new Error("Field doesn't support isOdd")}equals(O){f(O);let{px:R,py:F,pz:M}=this,{px:K,py:x,pz:$}=O,z=r.eql(r.mul(R,$),r.mul(K,M)),D=r.eql(r.mul(F,$),r.mul(x,M));return z&&D}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:O,b:R}=e,F=r.mul(R,ea),{px:M,py:K,pz:x}=this,$=r.ZERO,z=r.ZERO,D=r.ZERO,j=r.mul(M,M),ie=r.mul(K,K),ee=r.mul(x,x),ne=r.mul(M,K);return ne=r.add(ne,ne),D=r.mul(M,x),D=r.add(D,D),$=r.mul(O,D),z=r.mul(F,ee),z=r.add($,z),$=r.sub(ie,z),z=r.add(ie,z),z=r.mul($,z),$=r.mul(ne,$),D=r.mul(F,D),ee=r.mul(O,ee),ne=r.sub(j,ee),ne=r.mul(O,ne),ne=r.add(ne,D),D=r.add(j,j),j=r.add(D,j),j=r.add(j,ee),j=r.mul(j,ne),z=r.add(z,j),ee=r.mul(K,x),ee=r.add(ee,ee),j=r.mul(ee,ne),$=r.sub($,j),D=r.mul(ee,ie),D=r.add(D,D),D=r.add(D,D),new m($,z,D)}add(O){f(O);let{px:R,py:F,pz:M}=this,{px:K,py:x,pz:$}=O,z=r.ZERO,D=r.ZERO,j=r.ZERO,ie=e.a,ee=r.mul(e.b,ea),ne=r.mul(R,K),w=r.mul(F,x),b=r.mul(M,$),B=r.add(R,F),S=r.add(K,x);B=r.mul(B,S),S=r.add(ne,w),B=r.sub(B,S),S=r.add(R,M);let N=r.add(K,$);return S=r.mul(S,N),N=r.add(ne,b),S=r.sub(S,N),N=r.add(F,M),z=r.add(x,$),N=r.mul(N,z),z=r.add(w,b),N=r.sub(N,z),j=r.mul(ie,S),z=r.mul(ee,b),j=r.add(z,j),z=r.sub(w,j),j=r.add(w,j),D=r.mul(z,j),w=r.add(ne,ne),w=r.add(w,ne),b=r.mul(ie,b),S=r.mul(ee,S),w=r.add(w,b),b=r.sub(ne,b),b=r.mul(ie,b),S=r.add(S,b),ne=r.mul(w,S),D=r.add(D,ne),ne=r.mul(N,S),z=r.mul(B,z),z=r.sub(z,ne),ne=r.mul(B,w),j=r.mul(N,j),j=r.add(j,ne),new m(z,D,j)}subtract(O){return this.add(O.negate())}is0(){return this.equals(m.ZERO)}wNAF(O){return u.wNAFCached(this,O,m.normalizeZ)}multiplyUnsafe(O){Ae.aInRange("scalar",O,dr,e.n);let R=m.ZERO;if(O===dr)return R;if(O===qe)return this;let{endo:F}=e;if(!F)return u.unsafeLadder(this,O);let{k1neg:M,k1:K,k2neg:x,k2:$}=F.splitScalar(O),z=R,D=R,j=this;for(;K>dr||$>dr;)K&qe&&(z=z.add(j)),$&qe&&(D=D.add(j)),j=j.double(),K>>=qe,$>>=qe;return M&&(z=z.negate()),x&&(D=D.negate()),D=new m(r.mul(D.px,F.beta),D.py,D.pz),z.add(D)}multiply(O){let{endo:R,n:F}=e;Ae.aInRange("scalar",O,qe,F);let M,K;if(R){let{k1neg:x,k1:$,k2neg:z,k2:D}=R.splitScalar(O),{p:j,f:ie}=this.wNAF($),{p:ee,f:ne}=this.wNAF(D);j=u.constTimeNegate(x,j),ee=u.constTimeNegate(z,ee),ee=new m(r.mul(ee.px,R.beta),ee.py,ee.pz),M=j.add(ee),K=ie.add(ne)}else{let{p:x,f:$}=this.wNAF(O);M=x,K=$}return m.normalizeZ([M,K])[0]}multiplyAndAddUnsafe(O,R,F){let M=m.BASE,K=($,z)=>z===dr||z===qe||!$.equals(M)?$.multiplyUnsafe(z):$.multiply(z),x=K(this,R).add(K(O,F));return x.is0()?void 0:x}toAffine(O){return d(this,O)}isTorsionFree(){let{h:O,isTorsionFree:R}=e;if(O===qe)return!0;if(R)return R(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:O,clearCofactor:R}=e;return O===qe?this:R?R(m,this):this.multiplyUnsafe(e.h)}toRawBytes(O=!0){return(0,_t.abool)("isCompressed",O),this.assertValidity(),i(m,this,O)}toHex(O=!0){return(0,_t.abool)("isCompressed",O),Ae.bytesToHex(this.toRawBytes(O))}}m.BASE=new m(e.Gx,e.Gy,r.ONE),m.ZERO=new m(r.ZERO,r.ONE,r.ZERO);let _=e.nBitLength,u=(0,Lo.wNAF)(m,e.endo?Math.ceil(_/2):_);return{CURVE:e,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function sw(t){let e=(0,Lo.validateBasic)(t);return Ae.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function ow(t){let e=sw(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(b){return $n.mod(b,n)}function a(b){return $n.invert(b,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:d,isWithinCurveOrder:h}=Z0({...e,toBytes(b,B,S){let N=B.toAffine(),H=r.toBytes(N.x),Z=Ae.concatBytes;return(0,_t.abool)("isCompressed",S),S?Z(Uint8Array.from([B.hasEvenY()?2:3]),H):Z(Uint8Array.from([4]),H,r.toBytes(N.y))},fromBytes(b){let B=b.length,S=b[0],N=b.subarray(1);if(B===i&&(S===2||S===3)){let H=Ae.bytesToNumberBE(N);if(!Ae.inRange(H,qe,r.ORDER))throw new Error("Point is not on curve");let Z=d(H),ae;try{ae=r.sqrt(Z)}catch(U){let p=U instanceof Error?": "+U.message:"";throw new Error("Point is not on curve"+p)}let oe=(ae&qe)===qe;return(S&1)===1!==oe&&(ae=r.neg(ae)),{x:H,y:ae}}else if(B===s&&S===4){let H=r.fromBytes(N.subarray(0,r.BYTES)),Z=r.fromBytes(N.subarray(r.BYTES,2*r.BYTES));return{x:H,y:Z}}else throw new Error(`Point of length ${B} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=b=>Ae.bytesToHex(Ae.numberToBytesBE(b,e.nByteLength));function _(b){let B=n>>qe;return b>B}function u(b){return _(b)?o(-b):b}let T=(b,B,S)=>Ae.bytesToNumberBE(b.slice(B,S));class O{constructor(B,S,N){this.r=B,this.s=S,this.recovery=N,this.assertValidity()}static fromCompact(B){let S=e.nByteLength;return B=(0,_t.ensureBytes)("compactSignature",B,S*2),new O(T(B,0,S),T(B,S,2*S))}static fromDER(B){let{r:S,s:N}=wt.DER.toSig((0,_t.ensureBytes)("DER",B));return new O(S,N)}assertValidity(){Ae.aInRange("r",this.r,qe,n),Ae.aInRange("s",this.s,qe,n)}addRecoveryBit(B){return new O(this.r,this.s,B)}recoverPublicKey(B){let{r:S,s:N,recovery:H}=this,Z=$((0,_t.ensureBytes)("msgHash",B));if(H==null||![0,1,2,3].includes(H))throw new Error("recovery id invalid");let ae=H===2||H===3?S+e.n:S;if(ae>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let oe=H&1?"03":"02",W=c.fromHex(oe+m(ae)),U=a(ae),p=o(-Z*U),J=o(N*U),re=c.BASE.multiplyAndAddUnsafe(W,p,J);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new O(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ae.hexToBytes(this.toDERHex())}toDERHex(){return wt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ae.hexToBytes(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let R={isValidPrivateKey(b){try{return f(b),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let b=$n.getMinHashLength(e.n);return $n.mapHashToField(e.randomBytes(b),e.n)},precompute(b=8,B=c.BASE){return B._setWindowSize(b),B.multiply(BigInt(3)),B}};function F(b,B=!0){return c.fromPrivateKey(b).toRawBytes(B)}function M(b){let B=Ae.isBytes(b),S=typeof b=="string",N=(B||S)&&b.length;return B?N===i||N===s:S?N===2*i||N===2*s:b instanceof c}function K(b,B,S=!0){if(M(b))throw new Error("first arg must be private key");if(!M(B))throw new Error("second arg must be public key");return c.fromHex(B).multiply(f(b)).toRawBytes(S)}let x=e.bits2int||function(b){let B=Ae.bytesToNumberBE(b),S=b.length*8-e.nBitLength;return S>0?B>>BigInt(S):B},$=e.bits2int_modN||function(b){return o(x(b))},z=Ae.bitMask(e.nBitLength);function D(b){return Ae.aInRange(`num < 2^${e.nBitLength}`,b,dr,z),Ae.numberToBytesBE(b,e.nByteLength)}function j(b,B,S=ie){if(["recovered","canonical"].some(Q=>Q in S))throw new Error("sign() legacy options not supported");let{hash:N,randomBytes:H}=e,{lowS:Z,prehash:ae,extraEntropy:oe}=S;Z==null&&(Z=!0),b=(0,_t.ensureBytes)("msgHash",b),W0(S),ae&&(b=(0,_t.ensureBytes)("prehashed msgHash",N(b)));let W=$(b),U=f(B),p=[D(U),D(W)];if(oe!=null&&oe!==!1){let Q=oe===!0?H(r.BYTES):oe;p.push((0,_t.ensureBytes)("extraEntropy",Q))}let J=Ae.concatBytes(...p),re=W;function fe(Q){let l=x(Q);if(!h(l))return;let y=a(l),g=c.BASE.multiply(l).toAffine(),P=o(g.x);if(P===dr)return;let A=o(y*o(re+P*U));if(A===dr)return;let I=(g.x===P?0:2)|Number(g.y&qe),k=A;return Z&&_(A)&&(k=u(A),I^=1),new O(P,k,I)}return{seed:J,k2sig:fe}}let ie={lowS:e.lowS,prehash:!1},ee={lowS:e.lowS,prehash:!1};function ne(b,B,S=ie){let{seed:N,k2sig:H}=j(b,B,S),Z=e;return Ae.createHmacDrbg(Z.hash.outputLen,Z.nByteLength,Z.hmac)(N,H)}c.BASE._setWindowSize(8);function w(b,B,S,N=ee){let H=b;if(B=(0,_t.ensureBytes)("msgHash",B),S=(0,_t.ensureBytes)("publicKey",S),"strict"in N)throw new Error("options.strict was renamed to lowS");W0(N);let{lowS:Z,prehash:ae}=N,oe,W;try{if(typeof H=="string"||Ae.isBytes(H))try{oe=O.fromDER(H)}catch(g){if(!(g instanceof wt.DER.Err))throw g;oe=O.fromCompact(H)}else if(typeof H=="object"&&typeof H.r=="bigint"&&typeof H.s=="bigint"){let{r:g,s:P}=H;oe=new O(g,P)}else throw new Error("PARSE");W=c.fromHex(S)}catch(g){if(g.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Z&&oe.hasHighS())return!1;ae&&(B=e.hash(B));let{r:U,s:p}=oe,J=$(B),re=a(p),fe=o(J*re),Q=o(U*re),l=c.BASE.multiplyAndAddUnsafe(W,fe,Q)?.toAffine();return l?o(l.x)===U:!1}return{CURVE:e,getPublicKey:F,getSharedSecret:K,sign:ne,verify:w,ProjectivePoint:c,Signature:O,utils:R}}function X0(t,e){let r=t.ORDER,n=dr;for(let u=r-qe;u%yn===dr;u/=yn)n+=qe;let i=n,s=yn<<i-qe-qe,o=s*yn,a=(r-qe)/o,c=(a-qe)/yn,f=o-qe,d=s,h=t.pow(e,a),m=t.pow(e,(a+qe)/yn),_=(u,T)=>{let O=h,R=t.pow(T,f),F=t.sqr(R);F=t.mul(F,T);let M=t.mul(u,F);M=t.pow(M,c),M=t.mul(M,R),R=t.mul(M,T),F=t.mul(M,u);let K=t.mul(F,R);M=t.pow(K,d);let x=t.eql(M,t.ONE);R=t.mul(F,m),M=t.mul(K,O),F=t.cmov(R,F,x),K=t.cmov(M,K,x);for(let $=i;$>qe;$--){let z=$-yn;z=yn<<z-qe;let D=t.pow(K,z),j=t.eql(D,t.ONE);R=t.mul(F,O),O=t.mul(O,O),D=t.mul(K,O),F=t.cmov(R,F,j),K=t.cmov(D,K,j)}return{isValid:x,value:F}};if(t.ORDER%D0===ea){let u=(t.ORDER-ea)/D0,T=t.sqrt(t.neg(e));_=(O,R)=>{let F=t.sqr(R),M=t.mul(O,R);F=t.mul(F,M);let K=t.pow(F,u);K=t.mul(K,M);let x=t.mul(K,T),$=t.mul(t.sqr(K),R),z=t.eql($,O),D=t.cmov(x,K,z);return{isValid:z,value:D}}}return _}function aw(t,e){if($n.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=X0(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,f,d,h;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),f=t.sqr(a),c=t.mul(f,e.A),s=t.add(s,c),s=t.mul(s,o),f=t.mul(f,a),c=t.mul(f,e.B),s=t.add(s,c),d=t.mul(i,o);let{isValid:m,value:_}=r(s,f);h=t.mul(i,n),h=t.mul(h,_),d=t.cmov(d,o,m),h=t.cmov(h,_,m);let u=t.isOdd(n)===t.isOdd(h);return h=t.cmov(t.neg(h),h,u),d=t.div(d,a),{x:d,y:h}}}});var th=L(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});Qu.bls=lw;var J0=Ir(),Ju=zt(),Q0=Qo(),L0=Xu(),cw=BigInt(0),ta=BigInt(1),eh=BigInt(2),xi=BigInt(3);function uw(t){let e=[];for(;t>ta;t>>=ta)(t&ta)===cw?e.unshift(0):(t&xi)===xi?(e.unshift(-1),t+=ta):e.unshift(1);return e}function lw(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=t.params.xNegative,a=t.params.twistType,c=(0,L0.weierstrassPoints)({n:r.ORDER,...t.G1}),f=Object.assign(c,(0,Q0.createHasher)(c.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),d=(0,L0.weierstrassPoints)({n:r.ORDER,...t.G2}),h=Object.assign(d,(0,Q0.createHasher)(d.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),m;if(a==="multiplicative")m=(W,U,p,J,re,fe)=>s.mul014(J,W,n.mul(U,re),n.mul(p,fe));else if(a==="divisive")m=(W,U,p,J,re,fe)=>s.mul034(J,n.mul(p,fe),n.mul(U,re),W);else throw new Error("bls: unknown twist type");let _=n.div(n.ONE,n.mul(n.ONE,eh));function u(W,U,p,J){let re=n.sqr(p),fe=n.sqr(J),Q=n.mulByB(n.mul(fe,xi)),l=n.mul(Q,xi),y=n.sub(n.sub(n.sqr(n.add(p,J)),fe),re),g=n.sub(Q,re),P=n.mul(n.sqr(U),xi),A=n.neg(y);return W.push([g,P,A]),U=n.mul(n.mul(n.mul(n.sub(re,l),U),p),_),p=n.sub(n.sqr(n.mul(n.add(re,l),_)),n.mul(n.sqr(Q),xi)),J=n.mul(re,y),{Rx:U,Ry:p,Rz:J}}function T(W,U,p,J,re,fe){let Q=n.sub(p,n.mul(fe,J)),l=n.sub(U,n.mul(re,J)),y=n.sub(n.mul(Q,re),n.mul(l,fe)),g=n.neg(Q),P=l;W.push([y,g,P]);let A=n.sqr(l),I=n.mul(A,l),k=n.mul(A,U),E=n.add(n.sub(I,n.mul(k,eh)),n.mul(n.sqr(Q),J));return U=n.mul(l,E),p=n.sub(n.mul(n.sub(k,E),Q),n.mul(I,p)),J=n.mul(J,I),{Rx:U,Ry:p,Rz:J}}let O=uw(t.params.ateLoopSize),R=(0,Ju.memoized)(W=>{let U=W,{x:p,y:J}=U.toAffine(),re=p,fe=J,Q=n.neg(J),l=re,y=fe,g=n.ONE,P=[];for(let A of O){let I=[];({Rx:l,Ry:y,Rz:g}=u(I,l,y,g)),A&&({Rx:l,Ry:y,Rz:g}=T(I,l,y,g,re,A===-1?Q:fe)),P.push(I)}if(t.postPrecompute){let A=P[P.length-1];t.postPrecompute(l,y,g,re,fe,T.bind(null,A))}return P});function F(W,U=!1){let p=s.ONE;if(W.length){let J=W[0][0].length;for(let re=0;re<J;re++){p=s.sqr(p);for(let[fe,Q,l]of W)for(let[y,g,P]of fe[re])p=m(y,g,P,p,Q,l)}}return o&&(p=s.conjugate(p)),U?s.finalExponentiate(p):p}function M(W,U=!0){let p=[];f.ProjectivePoint.normalizeZ(W.map(({g1:J})=>J)),h.ProjectivePoint.normalizeZ(W.map(({g2:J})=>J));for(let{g1:J,g2:re}of W){if(J.equals(f.ProjectivePoint.ZERO)||re.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");J.assertValidity(),re.assertValidity();let fe=J.toAffine();p.push([R(re),fe.x,fe.y])}return F(p,U)}function K(W,U,p=!0){return M([{g1:W,g2:U}],p)}let x={randomPrivateKey:()=>{let W=(0,J0.getMinHashLength)(r.ORDER);return(0,J0.mapHashToField)(t.randomBytes(W),r.ORDER)},calcPairingPrecomputes:R},{ShortSignature:$}=t.G1,{Signature:z}=t.G2;function D(W){return W instanceof f.ProjectivePoint?W:f.ProjectivePoint.fromHex(W)}function j(W,U){return W instanceof f.ProjectivePoint?W:f.hashToCurve((0,Ju.ensureBytes)("point",W),U)}function ie(W){return W instanceof h.ProjectivePoint?W:z.fromHex(W)}function ee(W,U){return W instanceof h.ProjectivePoint?W:h.hashToCurve((0,Ju.ensureBytes)("point",W),U)}function ne(W){return f.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function w(W){return h.ProjectivePoint.fromPrivateKey(W).toRawBytes(!0)}function b(W,U,p){let J=ee(W,p);J.assertValidity();let re=J.multiply(f.normPrivateKeyToScalar(U));return W instanceof h.ProjectivePoint?re:z.toRawBytes(re)}function B(W,U,p){let J=j(W,p);J.assertValidity();let re=J.multiply(f.normPrivateKeyToScalar(U));return W instanceof f.ProjectivePoint?re:$.toRawBytes(re)}function S(W,U,p,J){let re=D(p),fe=ee(U,J),Q=f.ProjectivePoint.BASE,l=ie(W),y=M([{g1:re.negate(),g2:fe},{g1:Q,g2:l}]);return s.eql(y,s.ONE)}function N(W,U,p,J){let re=ie(p),fe=j(U,J),Q=h.ProjectivePoint.BASE,l=D(W),y=M([{g1:fe,g2:re},{g1:l,g2:Q.negate()}]);return s.eql(y,s.ONE)}function H(W){if(!W.length)throw new Error("Expected non-empty array");let p=W.map(D).reduce((J,re)=>J.add(re),f.ProjectivePoint.ZERO);return W[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):p.toRawBytes(!0)}function Z(W){if(!W.length)throw new Error("Expected non-empty array");let p=W.map(ie).reduce((J,re)=>J.add(re),h.ProjectivePoint.ZERO);return W[0]instanceof h.ProjectivePoint?(p.assertValidity(),p):z.toRawBytes(p)}function ae(W){if(!W.length)throw new Error("Expected non-empty array");let p=W.map(D).reduce((J,re)=>J.add(re),f.ProjectivePoint.ZERO);return W[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):$.toRawBytes(p)}function oe(W,U,p,J){if(!U.length)throw new Error("Expected non-empty messages array");if(p.length!==U.length)throw new Error("Pubkey count should equal msg count");let re=ie(W),fe=U.map(g=>ee(g,J)),Q=p.map(D),l=new Map;for(let g=0;g<Q.length;g++){let P=Q[g],A=fe[g],I=l.get(A);I===void 0&&(I=[],l.set(A,I)),I.push(P)}let y=[];try{for(let[g,P]of l){let A=P.reduce((I,k)=>I.add(k));y.push({g1:A,g2:g})}return y.push({g1:f.ProjectivePoint.BASE.negate(),g2:re}),s.eql(M(y),s.ONE)}catch{return!1}}return f.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ne,getPublicKeyForShortSignatures:w,sign:b,signShortSignature:B,verify:S,verifyBatch:oe,verifyShortSignature:N,aggregatePublicKeys:H,aggregateSignatures:Z,aggregateShortSignatures:ae,millerLoopBatch:F,pairing:K,pairingBatch:M,G1:f,G2:h,Signature:z,ShortSignature:$,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:t.params.ateLoopSize,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:x}}});var nh=L(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.psiFrobenius=dw;ra.tower12=hw;var gn=Ir(),hr=zt(),fw=BigInt(0),vi=BigInt(1),Xr=BigInt(2),rh=BigInt(3);function Lu(t,e,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let f=0;f<i;f++){let d=BigInt(f+1),h=[];for(let m=0,_=vi;m<n;m++){let u=(d*_-d)/o%a;h.push(t.pow(e,u)),_*=r}c.push(h)}return c}function dw(t,e,r){let n=e.pow(r,(t.ORDER-vi)/rh),i=e.pow(r,(t.ORDER-vi)/Xr);function s(m,_){let u=e.mul(e.frobeniusMap(m,1),n),T=e.mul(e.frobeniusMap(_,1),i);return[u,T]}let o=e.pow(r,(t.ORDER**Xr-vi)/rh),a=e.pow(r,(t.ORDER**Xr-vi)/Xr);if(!e.eql(a,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(m,_){return[e.mul(m,o),e.neg(_)]}let f=m=>(_,u)=>{let T=u.toAffine(),O=m(T.x,T.y);return _.fromAffine({x:O[0],y:O[1]})},d=f(s),h=f(c);return{psi:s,psi2:c,G2psi:d,G2psi2:h,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function hw(t){let{ORDER:e}=t,r=gn.Field(e),n=r.create(t.NONRESIDUE||BigInt(-1)),i=gn.FpLegendre(e),s=r.div(r.ONE,Xr),o=Lu(r,n,r.ORDER,2)[0],a=({c0:w,c1:b},{c0:B,c1:S})=>({c0:r.add(w,B),c1:r.add(b,S)}),c=({c0:w,c1:b},{c0:B,c1:S})=>({c0:r.sub(w,B),c1:r.sub(b,S)}),f=({c0:w,c1:b},B)=>{if(typeof B=="bigint")return{c0:r.mul(w,B),c1:r.mul(b,B)};let{c0:S,c1:N}=B,H=r.mul(w,S),Z=r.mul(b,N),ae=r.sub(H,Z),oe=r.sub(r.mul(r.add(w,b),r.add(S,N)),r.add(H,Z));return{c0:ae,c1:oe}},d=({c0:w,c1:b})=>{let B=r.add(w,b),S=r.sub(w,b),N=r.add(w,w);return{c0:r.mul(B,S),c1:r.mul(N,b)}},h=w=>{if(w.length!==2)throw new Error("Invalid tuple");let b=w.map(B=>r.create(B));return{c0:b[0],c1:b[1]}},m=e*e,_=h(t.FP2_NONRESIDUE),u={ORDER:m,NONRESIDUE:_,BITS:(0,hr.bitLen)(m),BYTES:Math.ceil((0,hr.bitLen)(m)/8),MASK:(0,hr.bitMask)((0,hr.bitLen)(m)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:w=>w,isValid:({c0:w,c1:b})=>typeof w=="bigint"&&typeof b=="bigint",is0:({c0:w,c1:b})=>r.is0(w)&&r.is0(b),eql:({c0:w,c1:b},{c0:B,c1:S})=>r.eql(w,B)&&r.eql(b,S),neg:({c0:w,c1:b})=>({c0:r.neg(w),c1:r.neg(b)}),pow:(w,b)=>gn.FpPow(u,w,b),invertBatch:w=>gn.FpInvertBatch(u,w),add:a,sub:c,mul:f,sqr:d,addN:a,subN:c,mulN:f,sqrN:d,div:(w,b)=>u.mul(w,typeof b=="bigint"?r.inv(r.create(b)):u.inv(b)),inv:({c0:w,c1:b})=>{let B=r.inv(r.create(w*w+b*b));return{c0:r.mul(B,r.create(w)),c1:r.mul(B,r.create(-b))}},sqrt:w=>{if(t.Fp2sqrt)return t.Fp2sqrt(w);let{c0:b,c1:B}=w;if(r.is0(B))return r.eql(i(r,b),r.ONE)?u.create({c0:r.sqrt(b),c1:r.ZERO}):u.create({c0:r.ZERO,c1:r.sqrt(r.div(b,n))});let S=r.sqrt(r.sub(r.sqr(b),r.mul(r.sqr(B),n))),N=r.mul(r.add(S,b),s),H=i(r,N);!r.is0(H)&&!r.eql(H,r.ONE)&&(N=r.sub(N,S));let Z=r.sqrt(N),ae=u.create({c0:Z,c1:r.div(r.mul(B,s),Z)});if(!u.eql(u.sqr(ae),w))throw new Error("Cannot find square root");let oe=ae,W=u.neg(oe),{re:U,im:p}=u.reim(oe),{re:J,im:re}=u.reim(W);return p>re||p===re&&U>J?oe:W},isOdd:w=>{let{re:b,im:B}=u.reim(w),S=b%Xr,N=b===fw,H=B%Xr;return BigInt(S||N&&H)==vi},fromBytes(w){if(w.length!==u.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:b})=>(0,hr.concatBytes)(r.toBytes(w),r.toBytes(b)),cmov:({c0:w,c1:b},{c0:B,c1:S},N)=>({c0:r.cmov(w,B,N),c1:r.cmov(b,S,N)}),reim:({c0:w,c1:b})=>({re:w,im:b}),mulByNonresidue:({c0:w,c1:b})=>u.mul({c0:w,c1:b},_),mulByB:t.Fp2mulByB,fromBigTuple:h,frobeniusMap:({c0:w,c1:b},B)=>({c0:w,c1:r.mul(b,o[B%2])})},T=({c0:w,c1:b,c2:B},{c0:S,c1:N,c2:H})=>({c0:u.add(w,S),c1:u.add(b,N),c2:u.add(B,H)}),O=({c0:w,c1:b,c2:B},{c0:S,c1:N,c2:H})=>({c0:u.sub(w,S),c1:u.sub(b,N),c2:u.sub(B,H)}),R=({c0:w,c1:b,c2:B},S)=>{if(typeof S=="bigint")return{c0:u.mul(w,S),c1:u.mul(b,S),c2:u.mul(B,S)};let{c0:N,c1:H,c2:Z}=S,ae=u.mul(w,N),oe=u.mul(b,H),W=u.mul(B,Z);return{c0:u.add(ae,u.mulByNonresidue(u.sub(u.mul(u.add(b,B),u.add(H,Z)),u.add(oe,W)))),c1:u.add(u.sub(u.mul(u.add(w,b),u.add(N,H)),u.add(ae,oe)),u.mulByNonresidue(W)),c2:u.sub(u.add(oe,u.mul(u.add(w,B),u.add(N,Z))),u.add(ae,W))}},F=({c0:w,c1:b,c2:B})=>{let S=u.sqr(w),N=u.mul(u.mul(w,b),Xr),H=u.mul(u.mul(b,B),Xr),Z=u.sqr(B);return{c0:u.add(u.mulByNonresidue(H),S),c1:u.add(u.mulByNonresidue(Z),N),c2:u.sub(u.sub(u.add(u.add(N,u.sqr(u.add(u.sub(w,b),B))),H),S),Z)}},[M,K]=Lu(u,_,r.ORDER,6,2,3),x={ORDER:u.ORDER,BITS:3*u.BITS,BYTES:3*u.BYTES,MASK:(0,hr.bitMask)(3*u.BITS),ZERO:{c0:u.ZERO,c1:u.ZERO,c2:u.ZERO},ONE:{c0:u.ONE,c1:u.ZERO,c2:u.ZERO},create:w=>w,isValid:({c0:w,c1:b,c2:B})=>u.isValid(w)&&u.isValid(b)&&u.isValid(B),is0:({c0:w,c1:b,c2:B})=>u.is0(w)&&u.is0(b)&&u.is0(B),neg:({c0:w,c1:b,c2:B})=>({c0:u.neg(w),c1:u.neg(b),c2:u.neg(B)}),eql:({c0:w,c1:b,c2:B},{c0:S,c1:N,c2:H})=>u.eql(w,S)&&u.eql(b,N)&&u.eql(B,H),sqrt:hr.notImplemented,div:(w,b)=>x.mul(w,typeof b=="bigint"?r.inv(r.create(b)):x.inv(b)),pow:(w,b)=>gn.FpPow(x,w,b),invertBatch:w=>gn.FpInvertBatch(x,w),add:T,sub:O,mul:R,sqr:F,addN:T,subN:O,mulN:R,sqrN:F,inv:({c0:w,c1:b,c2:B})=>{let S=u.sub(u.sqr(w),u.mulByNonresidue(u.mul(B,b))),N=u.sub(u.mulByNonresidue(u.sqr(B)),u.mul(w,b)),H=u.sub(u.sqr(b),u.mul(w,B)),Z=u.inv(u.add(u.mulByNonresidue(u.add(u.mul(B,N),u.mul(b,H))),u.mul(w,S)));return{c0:u.mul(Z,S),c1:u.mul(Z,N),c2:u.mul(Z,H)}},fromBytes:w=>{if(w.length!==x.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:u.fromBytes(w.subarray(0,u.BYTES)),c1:u.fromBytes(w.subarray(u.BYTES,2*u.BYTES)),c2:u.fromBytes(w.subarray(2*u.BYTES))}},toBytes:({c0:w,c1:b,c2:B})=>(0,hr.concatBytes)(u.toBytes(w),u.toBytes(b),u.toBytes(B)),cmov:({c0:w,c1:b,c2:B},{c0:S,c1:N,c2:H},Z)=>({c0:u.cmov(w,S,Z),c1:u.cmov(b,N,Z),c2:u.cmov(B,H,Z)}),fromBigSix:w=>{if(!Array.isArray(w)||w.length!==6)throw new Error("Invalid Fp6 usage");return{c0:u.fromBigTuple(w.slice(0,2)),c1:u.fromBigTuple(w.slice(2,4)),c2:u.fromBigTuple(w.slice(4,6))}},frobeniusMap:({c0:w,c1:b,c2:B},S)=>({c0:u.frobeniusMap(w,S),c1:u.mul(u.frobeniusMap(b,S),M[S%6]),c2:u.mul(u.frobeniusMap(B,S),K[S%6])}),mulByFp2:({c0:w,c1:b,c2:B},S)=>({c0:u.mul(w,S),c1:u.mul(b,S),c2:u.mul(B,S)}),mulByNonresidue:({c0:w,c1:b,c2:B})=>({c0:u.mulByNonresidue(B),c1:w,c2:b}),mul1:({c0:w,c1:b,c2:B},S)=>({c0:u.mulByNonresidue(u.mul(B,S)),c1:u.mul(w,S),c2:u.mul(b,S)}),mul01({c0:w,c1:b,c2:B},S,N){let H=u.mul(w,S),Z=u.mul(b,N);return{c0:u.add(u.mulByNonresidue(u.sub(u.mul(u.add(b,B),N),Z)),H),c1:u.sub(u.sub(u.mul(u.add(S,N),u.add(w,b)),H),Z),c2:u.add(u.sub(u.mul(u.add(w,B),S),H),Z)}}},$=Lu(u,_,r.ORDER,12,1,6)[0],z=({c0:w,c1:b},{c0:B,c1:S})=>({c0:x.add(w,B),c1:x.add(b,S)}),D=({c0:w,c1:b},{c0:B,c1:S})=>({c0:x.sub(w,B),c1:x.sub(b,S)}),j=({c0:w,c1:b},B)=>{if(typeof B=="bigint")return{c0:x.mul(w,B),c1:x.mul(b,B)};let{c0:S,c1:N}=B,H=x.mul(w,S),Z=x.mul(b,N);return{c0:x.add(H,x.mulByNonresidue(Z)),c1:x.sub(x.mul(x.add(w,b),x.add(S,N)),x.add(H,Z))}},ie=({c0:w,c1:b})=>{let B=x.mul(w,b);return{c0:x.sub(x.sub(x.mul(x.add(x.mulByNonresidue(b),w),x.add(w,b)),B),x.mulByNonresidue(B)),c1:x.add(B,B)}};function ee(w,b){let B=u.sqr(w),S=u.sqr(b);return{first:u.add(u.mulByNonresidue(S),B),second:u.sub(u.sub(u.sqr(u.add(w,b)),B),S)}}let ne={ORDER:u.ORDER,BITS:2*u.BITS,BYTES:2*u.BYTES,MASK:(0,hr.bitMask)(2*u.BITS),ZERO:{c0:x.ZERO,c1:x.ZERO},ONE:{c0:x.ONE,c1:x.ZERO},create:w=>w,isValid:({c0:w,c1:b})=>x.isValid(w)&&x.isValid(b),is0:({c0:w,c1:b})=>x.is0(w)&&x.is0(b),neg:({c0:w,c1:b})=>({c0:x.neg(w),c1:x.neg(b)}),eql:({c0:w,c1:b},{c0:B,c1:S})=>x.eql(w,B)&&x.eql(b,S),sqrt:hr.notImplemented,inv:({c0:w,c1:b})=>{let B=x.inv(x.sub(x.sqr(w),x.mulByNonresidue(x.sqr(b))));return{c0:x.mul(w,B),c1:x.neg(x.mul(b,B))}},div:(w,b)=>ne.mul(w,typeof b=="bigint"?r.inv(r.create(b)):ne.inv(b)),pow:(w,b)=>gn.FpPow(ne,w,b),invertBatch:w=>gn.FpInvertBatch(ne,w),add:z,sub:D,mul:j,sqr:ie,addN:z,subN:D,mulN:j,sqrN:ie,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:b})=>(0,hr.concatBytes)(x.toBytes(w),x.toBytes(b)),cmov:({c0:w,c1:b},{c0:B,c1:S},N)=>({c0:x.cmov(w,B,N),c1:x.cmov(b,S,N)}),fromBigTwelve:w=>({c0:x.fromBigSix(w.slice(0,6)),c1:x.fromBigSix(w.slice(6,12))}),frobeniusMap(w,b){let{c0:B,c1:S,c2:N}=x.frobeniusMap(w.c1,b),H=$[b%12];return{c0:x.frobeniusMap(w.c0,b),c1:x.create({c0:u.mul(B,H),c1:u.mul(S,H),c2:u.mul(N,H)})}},mulByFp2:({c0:w,c1:b},B)=>({c0:x.mulByFp2(w,B),c1:x.mulByFp2(b,B)}),conjugate:({c0:w,c1:b})=>({c0:w,c1:x.neg(b)}),mul014:({c0:w,c1:b},B,S,N)=>{let H=x.mul01(w,B,S),Z=x.mul1(b,N);return{c0:x.add(x.mulByNonresidue(Z),H),c1:x.sub(x.sub(x.mul01(x.add(b,w),B,u.add(S,N)),H),Z)}},mul034:({c0:w,c1:b},B,S,N)=>{let H=x.create({c0:u.mul(w.c0,B),c1:u.mul(w.c1,B),c2:u.mul(w.c2,B)}),Z=x.mul01(b,S,N),ae=x.mul01(x.add(w,b),u.add(B,S),N);return{c0:x.add(x.mulByNonresidue(Z),H),c1:x.sub(ae,x.add(H,Z))}},_cyclotomicSquare:t.Fp12cyclotomicSquare,_cyclotomicExp:t.Fp12cyclotomicExp,finalExponentiate:t.Fp12finalExponentiate};return{Fp:r,Fp2:u,Fp6:x,Fp4Square:ee,Fp12:ne}}});var dh=L(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.bls12_381=void 0;var ch=oo(),pw=qn(),yw=th(),gw=Ir(),Se=zt(),uh=Qo(),lh=Xu(),fh=nh(),Pt=BigInt(0),sa=BigInt(1),ht=BigInt(2),na=BigInt(3),ds=BigInt(4),mn=BigInt("0xd201000000010000"),mw=(0,Se.bitLen)(mn),{Fp:le,Fp2:pe,Fp6:rl,Fp4Square:el,Fp12:ve}=(0,fh.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[sa,sa],Fp2mulByB:({c0:t,c1:e})=>{let r=le.mul(t,ds),n=le.mul(e,ds);return{c0:le.sub(r,n),c1:le.add(r,n)}},Fp12cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:f}=el(r,o),{first:d,second:h}=el(s,i),{first:m,second:_}=el(n,a),u=pe.mulByNonresidue(_);return{c0:rl.create({c0:pe.add(pe.mul(pe.sub(c,r),ht),c),c1:pe.add(pe.mul(pe.sub(d,n),ht),d),c2:pe.add(pe.mul(pe.sub(m,i),ht),m)}),c1:rl.create({c0:pe.add(pe.mul(pe.add(u,s),ht),u),c1:pe.add(pe.mul(pe.add(f,o),ht),f),c2:pe.add(pe.mul(pe.add(h,a),ht),h)})}},Fp12cyclotomicExp(t,e){let r=ve.ONE;for(let n=mw-1;n>=0;n--)r=ve._cyclotomicSquare(r),(0,Se.bitGet)(e,n)&&(r=ve.mul(r,t));return r},Fp12finalExponentiate:t=>{let e=mn,r=ve.div(ve.frobeniusMap(t,6),t),n=ve.mul(ve.frobeniusMap(r,2),r),i=ve.conjugate(ve._cyclotomicExp(n,e)),s=ve.mul(ve.conjugate(ve._cyclotomicSquare(n)),i),o=ve.conjugate(ve._cyclotomicExp(s,e)),a=ve.conjugate(ve._cyclotomicExp(o,e)),c=ve.mul(ve.conjugate(ve._cyclotomicExp(a,e)),ve._cyclotomicSquare(i)),f=ve.conjugate(ve._cyclotomicExp(c,e)),d=ve.frobeniusMap(ve.mul(i,a),2),h=ve.frobeniusMap(ve.mul(o,n),3),m=ve.frobeniusMap(ve.mul(c,ve.conjugate(n)),1),_=ve.mul(ve.mul(f,ve.conjugate(s)),n);return ve.mul(ve.mul(ve.mul(d,h),m),_)}}),ih=gw.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),bw=(0,uh.isogenyMap)(pe,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(t=>t.map(e=>pe.fromBigTuple(e.map(BigInt))))),_w=(0,uh.isogenyMap)(le,[["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(t=>t.map(e=>BigInt(e)))),ww=(0,lh.mapToCurveSimpleSWU)(pe,{A:pe.create({c0:le.create(Pt),c1:le.create(BigInt(240))}),B:pe.create({c0:le.create(BigInt(1012)),c1:le.create(BigInt(1012))}),Z:pe.create({c0:le.create(BigInt(-2)),c1:le.create(BigInt(-1))})}),Ew=(0,lh.mapToCurveSimpleSWU)(le,{A:le.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:le.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:le.create(BigInt(11))}),{G2psi:sh,G2psi2:xw}=(0,fh.psiFrobenius)(le,pe,pe.div(pe.ONE,pe.NONRESIDUE)),tl=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:le.ORDER,m:2,k:128,expand:"xmd",hash:ch.sha256}),oa=hs(le.toBytes(Pt),{infinity:!0,compressed:!0});function ia(t){t=t.slice();let e=t[0]&224,r=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return t[0]&=31,{compressed:r,infinity:n,sort:i,value:t}}function hs(t,e){if(t[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(t[0]|=128),e.infinity&&(t[0]|=64),e.sort&&(t[0]|=32),t}function oh(t){t.assertValidity();let e=t.equals(It.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return oa.slice();let i=le.ORDER,s=!!(n*ht/i);return hs((0,Se.numberToBytesBE)(r,le.BYTES),{compressed:!0,sort:s})}function ah(t){t.assertValidity();let e=le.BYTES;if(t.equals(It.bls12_381.G2.ProjectivePoint.ZERO))return(0,Se.concatBytes)(oa,(0,Se.numberToBytesBE)(Pt,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=pe.reim(r),{re:o,im:a}=pe.reim(n),f=!!((a>Pt?a*ht:o*ht)/le.ORDER&sa),d=i;return(0,Se.concatBytes)(hs((0,Se.numberToBytesBE)(s,e),{sort:f,compressed:!0}),(0,Se.numberToBytesBE)(d,e))}It.bls12_381=(0,yw.bls)({fields:{Fp:le,Fp2:pe,Fp6:rl,Fp12:ve,Fr:ih},G1:{Fp:le,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:le.ZERO,b:ds,htfDefaults:{...tl,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(t,e)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new t(le.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(mn).negate().multiplyUnsafe(mn).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(mn).add(e),mapToCurve:t=>{let{x:e,y:r}=Ew(le.create(t[0]));return _w(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=ia(t);if(i.length===48&&e){let s=le.ORDER,o=(0,Se.bytesToNumberBE)(i),a=le.create(o&le.MASK);if(r){if(a!==Pt)throw new Error("G1: non-empty compressed point at infinity");return{x:Pt,y:Pt}}let c=le.add(le.pow(a,na),le.create(It.bls12_381.params.G1b)),f=le.sqrt(c);if(!f)throw new Error("Invalid compressed G1 point");return f*ht/s!==BigInt(n)&&(f=le.neg(f)),{x:le.create(a),y:le.create(f)}}else if(i.length===96&&!e){let s=(0,Se.bytesToNumberBE)(i.subarray(0,le.BYTES)),o=(0,Se.bytesToNumberBE)(i.subarray(le.BYTES));if(r){if(s!==Pt||o!==Pt)throw new Error("G1: non-empty point at infinity");return It.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:le.create(s),y:le.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(t,e,r)=>{let n=e.equals(t.ZERO),{x:i,y:s}=e.toAffine();if(r){if(n)return oa.slice();let o=le.ORDER,a=!!(s*ht/o);return hs((0,Se.numberToBytesBE)(i,le.BYTES),{compressed:!0,sort:a})}else return n?(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(2*le.BYTES-1)):(0,Se.concatBytes)((0,Se.numberToBytesBE)(i,le.BYTES),(0,Se.numberToBytesBE)(s,le.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=ia((0,Se.ensureBytes)("signatureHex",t,48)),i=le.ORDER,s=(0,Se.bytesToNumberBE)(n);if(e)return It.bls12_381.G1.ProjectivePoint.ZERO;let o=le.create(s&le.MASK),a=le.add(le.pow(o,na),le.create(It.bls12_381.params.G1b)),c=le.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let f=BigInt(r);c*ht/i!==f&&(c=le.neg(c));let d=It.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return d.assertValidity(),d},toRawBytes(t){return oh(t)},toHex(t){return(0,Se.bytesToHex)(oh(t))}}},G2:{Fp:pe,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:pe.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:pe.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:pe.ZERO,b:pe.fromBigTuple([ds,ds]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...tl},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=ww(pe.fromBigTuple(t));return bw(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(mn).negate().equals(sh(t,e)),clearCofactor:(t,e)=>{let r=mn,n=e.multiplyUnsafe(r).negate(),i=sh(t,e),s=e.double();return s=xw(t,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=ia(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=le.BYTES,o=(a,c,f)=>(0,Se.bytesToNumberBE)(a.slice(c,f));if(i.length===96&&e){let a=It.bls12_381.params.G2b,c=le.ORDER;if(r){if(i.reduce((T,O)=>T!==0?O+1:O,0)>0)throw new Error("Invalid compressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let f=o(i,0,s),d=o(i,s,2*s),h=pe.create({c0:le.create(d),c1:le.create(f)}),m=pe.add(pe.pow(h,na),a),_=pe.sqrt(m),u=_.c1===Pt?_.c0*ht/c:_.c1*ht/c?sa:Pt;return _=n&&u>0?_:pe.neg(_),{x:h,y:_}}else if(i.length===192&&!e){if(r){if(i.reduce((h,m)=>h!==0?m+1:m,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),f=o(i,2*s,3*s),d=o(i,3*s,4*s);return{x:pe.fromBigTuple([c,a]),y:pe.fromBigTuple([d,f])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=le,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return(0,Se.concatBytes)(oa,(0,Se.numberToBytesBE)(Pt,n));let c=!!(a.c1===Pt?a.c0*ht/i:a.c1*ht/i);return(0,Se.concatBytes)(hs((0,Se.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,Se.numberToBytesBE)(o.c0,n))}else{if(s)return(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:f}=pe.reim(o),{re:d,im:h}=pe.reim(a);return(0,Se.concatBytes)((0,Se.numberToBytesBE)(f,n),(0,Se.numberToBytesBE)(c,n),(0,Se.numberToBytesBE)(h,n),(0,Se.numberToBytesBE)(d,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=ia((0,Se.ensureBytes)("signatureHex",t)),i=le.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=(0,Se.bytesToNumberBE)(n.slice(0,s)),a=(0,Se.bytesToNumberBE)(n.slice(s));if(e)return It.bls12_381.G2.ProjectivePoint.ZERO;let c=le.create(o&le.MASK),f=le.create(a),d=pe.create({c0:f,c1:c}),h=pe.add(pe.pow(d,na),It.bls12_381.params.G2b),m=pe.sqrt(h);if(!m)throw new Error("Failed to find a square root");let{re:_,im:u}=pe.reim(m),T=BigInt(r),O=u>Pt&&u*ht/i!==T,R=u===Pt&&_*ht/i!==T;(O||R)&&(m=pe.neg(m));let F=It.bls12_381.G2.ProjectivePoint.fromAffine({x:d,y:m});return F.assertValidity(),F},toRawBytes(t){return ah(t)},toHex(t){return(0,Se.bytesToHex)(ah(t))}}},params:{ateLoopSize:mn,r:ih.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:tl,hash:ch.sha256,randomBytes:pw.randomBytes})});var il=L(ps=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});ps.blsVerify=ps.verify=void 0;var vw=dh(),nl=kt();function Tw(t,e,r){let n=typeof t=="string"?t:(0,nl.toHex)(t),i=typeof e=="string"?e:(0,nl.toHex)(e),s=typeof r=="string"?r:(0,nl.toHex)(r);return vw.bls12_381.verifyShortSignature(i,s,n)}ps.blsVerify=Tw});var aa=L(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.decodeTime=Kn.decodeLeb128=void 0;var hh=bi(),Aw=t=>(0,hh.lebDecode)(new hh.PipeArrayBuffer(t));Kn.decodeLeb128=Aw;var Sw=t=>{let e=(0,Kn.decodeLeb128)(t);return new Date(Number(e)/1e6)};Kn.decodeTime=Sw});var Ti=L(Oe=>{"use strict";var Bw=Oe&&Oe.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Ow=Oe&&Oe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),ph=Oe&&Oe.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Bw(e,t,r);return Ow(e,t),e};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 yh=ph(cs()),Nw=fi(),ca=ss(),pr=kt(),sl=Nt(),Rw=ph(il()),Pw=aa(),Iw=_s(),Jr=class extends Nw.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};Oe.CertificateVerificationError=Jr;var Et;(function(t){t[t.Empty=0]="Empty",t[t.Fork=1]="Fork",t[t.Labeled=2]="Labeled",t[t.Leaf=3]="Leaf",t[t.Pruned=4]="Pruned"})(Et=Oe.NodeType||(Oe.NodeType={}));function ua(t){let e=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(t[0]){case Et.Empty:return"()";case Et.Fork:if(t[1]instanceof Array&&t[2]instanceof ArrayBuffer){let n=ua(t[1]),i=ua(t[2]);return`sub(
|
|
20
20
|
left:
|
|
@@ -27,34 +27,34 @@ ${e(i)}
|
|
|
27
27
|
${e(n)}
|
|
28
28
|
sub:
|
|
29
29
|
${e(i)}
|
|
30
|
-
)`}else throw new Error("Invalid tree structure for labeled");case Et.Leaf:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for leaf");return`leaf(...${t[1].byteLength} bytes)`}case Et.Pruned:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for pruned");return`pruned(${(0,pr.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}Oe.hashTreeToString=ua;function Pw(t,e){let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}var il=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=hh.decode(new Uint8Array(e))}static async create(e){let r=t.createUnverified(e);return await r.verify(),r}static createUnverified(e){let r=e.blsVerify;return r||(r=Ow.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return la(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await ms(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Uw(r),s=(0,pr.concat)(gs("ic-state-root"),e),o=!1,a=sl(this.lookup(["time"]));if(!a)throw new Xr("Certificate does not contain a time");let c=5*60*1e3,f=this._maxAgeInMinutes*60*1e3,d=Date.now(),h=d-f,m=d+c,_=(0,Nw.decodeTime)(a);if(_.getTime()<h)throw new Xr(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+_.toISOString()+" Current time: "+new Date(d).toISOString());if(_.getTime()>m)throw new Xr("Certificate is signed more than 5 minutes in the future. Certificate time: "+_.toISOString()+" Current time: "+new Date(d).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new Xr("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let r=await t.createUnverified({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new Xr("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==Rw.MANAGEMENT_CANISTER_ID&&!ph({canisterId:this._canisterId,subnetId:nl.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new Xr(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,pr.toHex)(e.subnet_id)}`);let n=sl(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,pr.toHex)(e.subnet_id)}`);return n}};Oe.Certificate=il;var ys=(0,pr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Iw=96;function Uw(t){let e=ys.byteLength+Iw;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,ys.byteLength);if(!(0,pr.bufEquals)(r,ys))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${ys}, but get ${r}`);return t.slice(ys.byteLength)}function sl(t){if(t.status===Ut.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}Oe.lookupResultToBuffer=sl;async function ms(t){switch(t[0]){case Et.Empty:return(0,ca.hash)(gs("ic-hashtree-empty"));case Et.Pruned:return t[1];case Et.Leaf:return(0,ca.hash)((0,pr.concat)(gs("ic-hashtree-leaf"),t[1]));case Et.Labeled:return(0,ca.hash)((0,pr.concat)(gs("ic-hashtree-labeled"),t[1],await ms(t[2])));case Et.Fork:return(0,ca.hash)((0,pr.concat)(gs("ic-hashtree-fork"),await ms(t[1]),await ms(t[2])));default:throw new Error("unreachable")}}Oe.reconstruct=ms;function gs(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,pr.concat)(e,r)}var Ut;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(Ut=Oe.LookupStatus||(Oe.LookupStatus={}));var Jr;(function(t){t.Less="less",t.Greater="greater"})(Jr||(Jr={}));function la(t,e){if(t.length===0)switch(e[0]){case Et.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:Ut.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:Ut.Found,value:e[1].buffer}:{status:Ut.Found,value:e[1]}}default:return{status:Ut.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=bs(r,e);switch(n.status){case Ut.Found:return la(t.slice(1),n.value);case Jr.Greater:case Jr.Less:return{status:Ut.Absent};default:return n}}Oe.lookup_path=la;function ol(t){switch(t[0]){case Et.Empty:return[];case Et.Fork:return ol(t[1]).concat(ol(t[2]));default:return[t]}}Oe.flatten_forks=ol;function bs(t,e){switch(e[0]){case Et.Labeled:return Pw(t,e[1])?{status:Jr.Greater}:(0,pr.bufEquals)(t,e[1])?{status:Ut.Found,value:e[2]}:{status:Jr.Less};case Et.Fork:let r=bs(t,e[1]);switch(r.status){case Jr.Greater:{let n=bs(t,e[2]);return n.status===Jr.Less?{status:Ut.Absent}:n}case Ut.Unknown:{let n=bs(t,e[2]);return n.status===Jr.Less?{status:Ut.Unknown}:n}default:return r}case Et.Pruned:return{status:Ut.Unknown};default:return{status:Ut.Absent}}}Oe.find_label=bs;function ph(t){let{canisterId:e,subnetId:r,tree:n}=t,i=la(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Ut.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return hh.decode(i.value).map(c=>[nl.Principal.fromUint8Array(c[0]),nl.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}Oe.check_canister_ranges=ph});var ws=L(ct=>{"use strict";var Fw=ct&&ct.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Mw=ct&&ct.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Cw=ct&&ct.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Fw(e,t,r);return Mw(e,t),e};Object.defineProperty(ct,"__esModule",{value:!0});ct.encodePath=ct.fetchNodeKeys=ct.request=ct.CustomPath=void 0;var bn=Nt(),qw=fi(),_n=Ti(),jw=kt(),mh=Cw(cs()),yh=aa(),al=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};ct.CustomPath=al;var kw=async t=>{let{agent:e,paths:r}=t,n=bn.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>(0,ct.encodePath)(c,n)),o=new Map,a=i.map((c,f)=>(async()=>{var d;try{let h=await e.readState(n,{paths:[s[f]]}),m=await _n.Certificate.create({certificate:h.certificate,rootKey:e.rootKey,canisterId:n}),_=(O,R)=>{if(R==="subnet"){let F=(0,ct.fetchNodeKeys)(h.certificate,n,e.rootKey);return{path:R,data:F}}else return{path:R,data:(0,_n.lookupResultToBuffer)(O.lookup((0,ct.encodePath)(R,n)))}},{path:u,data:T}=_(m,i[f]);if(!T)console.warn(`Expected to find result for path ${u}, but instead found nothing.`),typeof u=="string"?o.set(u,null):o.set(u.key,null);else switch(u){case"time":{o.set(u,(0,yh.decodeTime)(T));break}case"controllers":{o.set(u,Kw(T));break}case"module_hash":{o.set(u,gh(T));break}case"subnet":{o.set(u,T);break}case"candid":{o.set(u,new TextDecoder().decode(T));break}default:if(typeof u!="string"&&"key"in u&&"path"in u)switch(u.decodeStrategy){case"raw":o.set(u.key,T);break;case"leb128":{o.set(u.key,(0,yh.decodeLeb128)(T));break}case"cbor":{o.set(u.key,bh(T));break}case"hex":{o.set(u.key,gh(T));break}case"utf-8":o.set(u.key,$w(T))}}}catch(h){if(!((d=h?.message)===null||d===void 0)&&d.includes("Invalid certificate"))throw new qw.AgentError(h.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(h),console.groupEnd()}})());return await Promise.all(a),o};ct.request=kw;var Hw=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=mh.decode(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=bn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=bn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=bn.Principal.selfAuthenticating(bn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,_n.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,_n.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==_n.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let f=(0,_n.flatten_forks)(c.value),d=new Map;return f.forEach(h=>{let m=bn.Principal.from(new Uint8Array(h[1])).toText(),_=(0,_n.lookup_path)(["public_key"],h[2]);if(_.status!==_n.LookupStatus.Found)throw new Error("Public key not found");let u=_.value;if(u.byteLength!==44)throw new Error("Invalid public key length");d.set(m,u)}),{subnetId:bn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:d}};ct.fetchNodeKeys=Hw;var Vw=(t,e)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(e.toUint8Array().buffer).buffer;switch(t){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 t&&"path"in t)if(typeof t.path=="string"||t.path instanceof ArrayBuffer){let s=t.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return t.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${t} was formatted correctly.`)};ct.encodePath=Vw;var gh=t=>(0,jw.toHex)(t),bh=t=>mh.decode(t),$w=t=>new TextDecoder().decode(t),Kw=t=>bh(t).map(r=>bn.Principal.fromUint8Array(new Uint8Array(r)))});var Hh=L(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=ul;ye.split=_h;ye.add=Uh;var fa=BigInt(2**32-1),cl=BigInt(32);function ul(t,e=!1){return e?{h:Number(t&fa),l:Number(t>>cl&fa)}:{h:Number(t>>cl&fa)|0,l:Number(t&fa)|0}}function _h(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:s,l:o}=ul(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}var wh=(t,e)=>BigInt(t>>>0)<<cl|BigInt(e>>>0);ye.toBig=wh;var Eh=(t,e,r)=>t>>>r;ye.shrSH=Eh;var xh=(t,e,r)=>t<<32-r|e>>>r;ye.shrSL=xh;var vh=(t,e,r)=>t>>>r|e<<32-r;ye.rotrSH=vh;var Th=(t,e,r)=>t<<32-r|e>>>r;ye.rotrSL=Th;var Ah=(t,e,r)=>t<<64-r|e>>>r-32;ye.rotrBH=Ah;var Sh=(t,e,r)=>t>>>r-32|e<<64-r;ye.rotrBL=Sh;var Bh=(t,e)=>e;ye.rotr32H=Bh;var Oh=(t,e)=>t;ye.rotr32L=Oh;var Nh=(t,e,r)=>t<<r|e>>>32-r;ye.rotlSH=Nh;var Rh=(t,e,r)=>e<<r|t>>>32-r;ye.rotlSL=Rh;var Ph=(t,e,r)=>e<<r-32|t>>>64-r;ye.rotlBH=Ph;var Ih=(t,e,r)=>t<<r-32|e>>>64-r;ye.rotlBL=Ih;function Uh(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Fh=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);ye.add3L=Fh;var Mh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;ye.add3H=Mh;var Ch=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);ye.add4L=Ch;var qh=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;ye.add4H=qh;var jh=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);ye.add5L=jh;var kh=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;ye.add5H=kh;var Gw={fromBig:ul,split:_h,toBig:wh,shrSH:Eh,shrSL:xh,rotrSH:vh,rotrSL:Th,rotrBH:Ah,rotrBL:Sh,rotr32H:Bh,rotr32L:Oh,rotlSH:Nh,rotlSL:Rh,rotlBH:Ph,rotlBL:Ih,add:Uh,add3L:Fh,add3H:Mh,add4L:Ch,add4H:qh,add5H:kh,add5L:jh};ye.default=Gw});var Vh=L(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.sha384=pt.sha512_256=pt.sha512_224=pt.sha512=pt.SHA384=pt.SHA512_256=pt.SHA512_224=pt.SHA512=void 0;var Yw=Pc(),be=Hh(),ya=qn(),[zw,Ww]=be.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),wn=new Uint32Array(80),En=new Uint32Array(80),Gn=class extends Yw.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:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:f,El:d,Fh:h,Fl:m,Gh:_,Gl:u,Hh:T,Hl:O}=this;return[e,r,n,i,s,o,a,c,f,d,h,m,_,u,T,O]}set(e,r,n,i,s,o,a,c,f,d,h,m,_,u,T,O){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=d|0,this.Fh=h|0,this.Fl=m|0,this.Gh=_|0,this.Gl=u|0,this.Hh=T|0,this.Hl=O|0}process(e,r){for(let M=0;M<16;M++,r+=4)wn[M]=e.getUint32(r),En[M]=e.getUint32(r+=4);for(let M=16;M<80;M++){let K=wn[M-15]|0,x=En[M-15]|0,$=be.default.rotrSH(K,x,1)^be.default.rotrSH(K,x,8)^be.default.shrSH(K,x,7),z=be.default.rotrSL(K,x,1)^be.default.rotrSL(K,x,8)^be.default.shrSL(K,x,7),D=wn[M-2]|0,j=En[M-2]|0,ie=be.default.rotrSH(D,j,19)^be.default.rotrBH(D,j,61)^be.default.shrSH(D,j,6),ee=be.default.rotrSL(D,j,19)^be.default.rotrBL(D,j,61)^be.default.shrSL(D,j,6),ne=be.default.add4L(z,ee,En[M-7],En[M-16]),w=be.default.add4H(ne,$,ie,wn[M-7],wn[M-16]);wn[M]=w|0,En[M]=ne|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:d,Eh:h,El:m,Fh:_,Fl:u,Gh:T,Gl:O,Hh:R,Hl:F}=this;for(let M=0;M<80;M++){let K=be.default.rotrSH(h,m,14)^be.default.rotrSH(h,m,18)^be.default.rotrBH(h,m,41),x=be.default.rotrSL(h,m,14)^be.default.rotrSL(h,m,18)^be.default.rotrBL(h,m,41),$=h&_^~h&T,z=m&u^~m&O,D=be.default.add5L(F,x,z,Ww[M],En[M]),j=be.default.add5H(D,R,K,$,zw[M],wn[M]),ie=D|0,ee=be.default.rotrSH(n,i,28)^be.default.rotrBH(n,i,34)^be.default.rotrBH(n,i,39),ne=be.default.rotrSL(n,i,28)^be.default.rotrBL(n,i,34)^be.default.rotrBL(n,i,39),w=n&s^n&a^s&a,b=i&o^i&c^o&c;R=T|0,F=O|0,T=_|0,O=u|0,_=h|0,u=m|0,{h,l:m}=be.default.add(f|0,d|0,j|0,ie|0),f=a|0,d=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let B=be.default.add3L(ie,ne,b);n=be.default.add3H(B,j,ee,w),i=B|0}({h:n,l:i}=be.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=be.default.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=be.default.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:d}=be.default.add(this.Dh|0,this.Dl|0,f|0,d|0),{h,l:m}=be.default.add(this.Eh|0,this.El|0,h|0,m|0),{h:_,l:u}=be.default.add(this.Fh|0,this.Fl|0,_|0,u|0),{h:T,l:O}=be.default.add(this.Gh|0,this.Gl|0,T|0,O|0),{h:R,l:F}=be.default.add(this.Hh|0,this.Hl|0,R|0,F|0),this.set(n,i,s,o,a,c,f,d,h,m,_,u,T,O,R,F)}roundClean(){wn.fill(0),En.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)}};pt.SHA512=Gn;var da=class extends Gn{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}};pt.SHA512_224=da;var ha=class extends Gn{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}};pt.SHA512_256=ha;var pa=class extends Gn{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}};pt.SHA384=pa;pt.sha512=(0,ya.wrapConstructor)(()=>new Gn);pt.sha512_224=(0,ya.wrapConstructor)(()=>new da);pt.sha512_256=(0,ya.wrapConstructor)(()=>new ha);pt.sha384=(0,ya.wrapConstructor)(()=>new pa)});var Kh=L(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});fl.twistedEdwards=Jw;var ll=Wu(),$h=Ir(),Kt=zt(),Zt=zt(),yr=BigInt(0),$t=BigInt(1),ga=BigInt(2),Dw=BigInt(8),Zw={zip215:!0};function Xw(t){let e=(0,ll.validateBasic)(t);return Kt.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Jw(t){let e=Xw(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=ga<<BigInt(a*8)-$t,d=r.create,h=(0,$h.Field)(e.n,e.nBitLength),m=e.uvRatio||((S,N)=>{try{return{isValid:!0,value:r.sqrt(S*r.inv(N))}}catch{return{isValid:!1,value:yr}}}),_=e.adjustScalarBytes||(S=>S),u=e.domain||((S,N,H)=>{if((0,Zt.abool)("phflag",H),N.length||H)throw new Error("Contexts/pre-hash are not supported");return S});function T(S,N){Kt.aInRange("coordinate "+S,N,yr,f)}function O(S){if(!(S instanceof M))throw new Error("ExtendedPoint expected")}let R=(0,Zt.memoized)((S,N)=>{let{ex:H,ey:Z,ez:ae}=S,oe=S.is0();N==null&&(N=oe?Dw:r.inv(ae));let W=d(H*N),U=d(Z*N),p=d(ae*N);if(oe)return{x:yr,y:$t};if(p!==$t)throw new Error("invZ was invalid");return{x:W,y:U}}),F=(0,Zt.memoized)(S=>{let{a:N,d:H}=e;if(S.is0())throw new Error("bad point: ZERO");let{ex:Z,ey:ae,ez:oe,et:W}=S,U=d(Z*Z),p=d(ae*ae),J=d(oe*oe),re=d(J*J),fe=d(U*N),Q=d(J*d(fe+p)),l=d(re+d(H*d(U*p)));if(Q!==l)throw new Error("bad point: equation left != right (1)");let y=d(Z*ae),g=d(oe*W);if(y!==g)throw new Error("bad point: equation left != right (2)");return!0});class M{constructor(N,H,Z,ae){this.ex=N,this.ey=H,this.ez=Z,this.et=ae,T("x",N),T("y",H),T("z",Z),T("t",ae),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(N){if(N instanceof M)throw new Error("extended point not allowed");let{x:H,y:Z}=N||{};return T("x",H),T("y",Z),new M(H,Z,$t,d(H*Z))}static normalizeZ(N){let H=r.invertBatch(N.map(Z=>Z.ez));return N.map((Z,ae)=>Z.toAffine(H[ae])).map(M.fromAffine)}static msm(N,H){return(0,ll.pippenger)(M,h,N,H)}_setWindowSize(N){$.setWindowSize(this,N)}assertValidity(){F(this)}equals(N){O(N);let{ex:H,ey:Z,ez:ae}=this,{ex:oe,ey:W,ez:U}=N,p=d(H*U),J=d(oe*ae),re=d(Z*U),fe=d(W*ae);return p===J&&re===fe}is0(){return this.equals(M.ZERO)}negate(){return new M(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:N}=e,{ex:H,ey:Z,ez:ae}=this,oe=d(H*H),W=d(Z*Z),U=d(ga*d(ae*ae)),p=d(N*oe),J=H+Z,re=d(d(J*J)-oe-W),fe=p+W,Q=fe-U,l=p-W,y=d(re*Q),g=d(fe*l),P=d(re*l),A=d(Q*fe);return new M(y,g,A,P)}add(N){O(N);let{a:H,d:Z}=e,{ex:ae,ey:oe,ez:W,et:U}=this,{ex:p,ey:J,ez:re,et:fe}=N;if(H===BigInt(-1)){let X=d((oe-ae)*(J+p)),te=d((oe+ae)*(J-p)),de=d(te-X);if(de===yr)return this.double();let _e=d(W*ga*fe),Fe=d(U*ga*re),Ve=Fe+_e,me=te+X,he=Fe-_e,Ze=d(Ve*de),Er=d(me*he),Kr=d(Ve*he),Fn=d(de*me);return new M(Ze,Er,Fn,Kr)}let Q=d(ae*p),l=d(oe*J),y=d(U*Z*fe),g=d(W*re),P=d((ae+oe)*(p+J)-Q-l),A=g-y,I=g+y,k=d(l-H*Q),E=d(P*A),C=d(I*k),V=d(P*k),q=d(A*I);return new M(E,C,q,V)}subtract(N){return this.add(N.negate())}wNAF(N){return $.wNAFCached(this,N,M.normalizeZ)}multiply(N){let H=N;Kt.aInRange("scalar",H,$t,n);let{p:Z,f:ae}=this.wNAF(H);return M.normalizeZ([Z,ae])[0]}multiplyUnsafe(N){let H=N;return Kt.aInRange("scalar",H,yr,n),H===yr?x:this.equals(x)||H===$t?this:this.equals(K)?this.wNAF(H).p:$.unsafeLadder(this,H)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return $.unsafeLadder(this,n).is0()}toAffine(N){return R(this,N)}clearCofactor(){let{h:N}=e;return N===$t?this:this.multiplyUnsafe(N)}static fromHex(N,H=!1){let{d:Z,a:ae}=e,oe=r.BYTES;N=(0,Zt.ensureBytes)("pointHex",N,oe),(0,Zt.abool)("zip215",H);let W=N.slice(),U=N[oe-1];W[oe-1]=U&-129;let p=Kt.bytesToNumberLE(W),J=H?f:r.ORDER;Kt.aInRange("pointHex.y",p,yr,J);let re=d(p*p),fe=d(re-$t),Q=d(Z*re-ae),{isValid:l,value:y}=m(fe,Q);if(!l)throw new Error("Point.fromHex: invalid y coordinate");let g=(y&$t)===$t,P=(U&128)!==0;if(!H&&y===yr&&P)throw new Error("Point.fromHex: x=0 and x_0=1");return P!==g&&(y=d(-y)),M.fromAffine({x:y,y:p})}static fromPrivateKey(N){return j(N).point}toRawBytes(){let{x:N,y:H}=this.toAffine(),Z=Kt.numberToBytesLE(H,r.BYTES);return Z[Z.length-1]|=N&$t?128:0,Z}toHex(){return Kt.bytesToHex(this.toRawBytes())}}M.BASE=new M(e.Gx,e.Gy,$t,d(e.Gx*e.Gy)),M.ZERO=new M(yr,$t,$t,yr);let{BASE:K,ZERO:x}=M,$=(0,ll.wNAF)(M,a*8);function z(S){return(0,$h.mod)(S,n)}function D(S){return z(Kt.bytesToNumberLE(S))}function j(S){let N=a;S=(0,Zt.ensureBytes)("private key",S,N);let H=(0,Zt.ensureBytes)("hashed private key",s(S),2*N),Z=_(H.slice(0,N)),ae=H.slice(N,2*N),oe=D(Z),W=K.multiply(oe),U=W.toRawBytes();return{head:Z,prefix:ae,scalar:oe,point:W,pointBytes:U}}function ie(S){return j(S).pointBytes}function ee(S=new Uint8Array,...N){let H=Kt.concatBytes(...N);return D(s(u(H,(0,Zt.ensureBytes)("context",S),!!i)))}function ne(S,N,H={}){S=(0,Zt.ensureBytes)("message",S),i&&(S=i(S));let{prefix:Z,scalar:ae,pointBytes:oe}=j(N),W=ee(H.context,Z,S),U=K.multiply(W).toRawBytes(),p=ee(H.context,U,oe,S),J=z(W+p*ae);Kt.aInRange("signature.s",J,yr,n);let re=Kt.concatBytes(U,Kt.numberToBytesLE(J,r.BYTES));return(0,Zt.ensureBytes)("result",re,a*2)}let w=Zw;function b(S,N,H,Z=w){let{context:ae,zip215:oe}=Z,W=r.BYTES;S=(0,Zt.ensureBytes)("signature",S,2*W),N=(0,Zt.ensureBytes)("message",N),oe!==void 0&&(0,Zt.abool)("zip215",oe),i&&(N=i(N));let U=Kt.bytesToNumberLE(S.slice(W,2*W)),p,J,re;try{p=M.fromHex(H,oe),J=M.fromHex(S.slice(0,W),oe),re=K.multiplyUnsafe(U)}catch{return!1}if(!oe&&p.isSmallOrder())return!1;let fe=ee(ae,J.toRawBytes(),p.toRawBytes(),N);return J.add(p.multiplyUnsafe(fe)).subtract(re).clearCofactor().equals(M.ZERO)}return K._setWindowSize(8),{CURVE:e,getPublicKey:ie,sign:ne,verify:b,ExtendedPoint:M,utils:{getExtendedPublicKey:j,randomPrivateKey:()=>o(r.BYTES),precompute(S=8,N=M.BASE){return N._setWindowSize(S),N.multiply(BigInt(3)),N}}}}});var Yh=L(hl=>{"use strict";Object.defineProperty(hl,"__esModule",{value:!0});hl.montgomery=Lw;var Gh=Ir(),xn=zt(),Ai=BigInt(0),dl=BigInt(1);function Qw(t){return(0,xn.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function Lw(t){let e=Qw(t),{P:r}=e,n=F=>(0,Gh.mod)(F,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(F=>F),c=e.powPminus2||(F=>(0,Gh.pow)(F,r-BigInt(2),r));function f(F,M,K){let x=n(F*(M-K));return M=n(M-x),K=n(K+x),[M,K]}let d=(e.a-BigInt(2))/BigInt(4);function h(F,M){(0,xn.aInRange)("u",F,Ai,r),(0,xn.aInRange)("scalar",M,Ai,r);let K=M,x=F,$=dl,z=Ai,D=F,j=dl,ie=Ai,ee;for(let w=BigInt(i-1);w>=Ai;w--){let b=K>>w&dl;ie^=b,ee=f(ie,$,D),$=ee[0],D=ee[1],ee=f(ie,z,j),z=ee[0],j=ee[1],ie=b;let B=$+z,S=n(B*B),N=$-z,H=n(N*N),Z=S-H,ae=D+j,oe=D-j,W=n(oe*B),U=n(ae*N),p=W+U,J=W-U;D=n(p*p),j=n(x*n(J*J)),$=n(S*H),z=n(Z*(S+n(d*Z)))}ee=f(ie,$,D),$=ee[0],D=ee[1],ee=f(ie,z,j),z=ee[0],j=ee[1];let ne=c(z);return n($*ne)}function m(F){return(0,xn.numberToBytesLE)(n(F),s)}function _(F){let M=(0,xn.ensureBytes)("u coordinate",F,s);return o===32&&(M[31]&=127),(0,xn.bytesToNumberLE)(M)}function u(F){let M=(0,xn.ensureBytes)("scalar",F),K=M.length;if(K!==s&&K!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${K}`);return(0,xn.bytesToNumberLE)(a(M))}function T(F,M){let K=_(M),x=u(F),$=h(K,x);if($===Ai)throw new Error("Invalid private or public key received");return m($)}let O=m(e.Gu);function R(F){return T(F,O)}return{scalarMult:T,scalarMultBase:R,getSharedSecret:(F,M)=>T(F,M),getPublicKey:F=>R(F),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:O}}});var El=L(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.hash_to_ristretto255=ge.hashToRistretto255=ge.RistrettoPoint=ge.encodeToCurve=ge.hashToCurve=ge.edwardsToMontgomery=ge.x25519=ge.ed25519ph=ge.ed25519ctx=ge.ed25519=ge.ED25519_TORSION_SUBGROUP=void 0;ge.edwardsToMontgomeryPub=tp;ge.edwardsToMontgomeryPriv=r2;var ba=Vh(),Es=qn(),bl=Kh(),Zh=Qo(),Ue=Ir(),e2=Yh(),Yn=zt(),xs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),gl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),t2=BigInt(0),Ur=BigInt(1),ma=BigInt(2),Xh=BigInt(3),Jh=BigInt(5),_l=BigInt(8);function Qh(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=xs,a=t*t%s*t%s,c=(0,Ue.pow2)(a,ma,s)*a%s,f=(0,Ue.pow2)(c,Ur,s)*t%s,d=(0,Ue.pow2)(f,Jh,s)*f%s,h=(0,Ue.pow2)(d,e,s)*d%s,m=(0,Ue.pow2)(h,r,s)*h%s,_=(0,Ue.pow2)(m,n,s)*m%s,u=(0,Ue.pow2)(_,i,s)*_%s,T=(0,Ue.pow2)(u,i,s)*_%s,O=(0,Ue.pow2)(T,e,s)*d%s;return{pow_p_5_8:(0,Ue.pow2)(O,ma,s)*t%s,b2:a}}function Lh(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function wl(t,e){let r=xs,n=(0,Ue.mod)(e*e*e,r),i=(0,Ue.mod)(n*n*e,r),s=Qh(t*i).pow_p_5_8,o=(0,Ue.mod)(t*n*s,r),a=(0,Ue.mod)(e*o*o,r),c=o,f=(0,Ue.mod)(o*gl,r),d=a===t,h=a===(0,Ue.mod)(-t,r),m=a===(0,Ue.mod)(-t*gl,r);return d&&(o=c),(h||m)&&(o=f),(0,Ue.isNegativeLE)(o,r)&&(o=(0,Ue.mod)(-o,r)),{isValid:d||h,value:o}}ge.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var ce=(0,Ue.Field)(xs,void 0,!0),vs={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ce,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:_l,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ba.sha512,randomBytes:Es.randomBytes,adjustScalarBytes:Lh,uvRatio:wl};ge.ed25519=(0,bl.twistedEdwards)(vs);function ep(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,Es.concatBytes)((0,Es.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}ge.ed25519ctx=(0,bl.twistedEdwards)({...vs,domain:ep});ge.ed25519ph=(0,bl.twistedEdwards)(Object.assign({},vs,{domain:ep,prehash:ba.sha512}));ge.x25519=(0,e2.montgomery)({P:xs,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=xs,{pow_p_5_8:r,b2:n}=Qh(t);return(0,Ue.mod)((0,Ue.pow2)(r,Xh,e)*n,e)},adjustScalarBytes:Lh,randomBytes:Es.randomBytes});function tp(t){let{y:e}=ge.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return ce.toBytes(ce.create((r+e)*ce.inv(r-e)))}ge.edwardsToMontgomery=tp;function r2(t){let e=vs.hash(t.subarray(0,32));return vs.adjustScalarBytes(e).subarray(0,32)}var n2=(ce.ORDER+Xh)/_l,i2=ce.pow(ma,n2),zh=ce.sqrt(ce.neg(ce.ONE));function s2(t){let e=(ce.ORDER-Jh)/_l,r=BigInt(486662),n=ce.sqr(t);n=ce.mul(n,ma);let i=ce.add(n,ce.ONE),s=ce.neg(r),o=ce.sqr(i),a=ce.mul(o,i),c=ce.mul(n,r);c=ce.mul(c,s),c=ce.add(c,o),c=ce.mul(c,s);let f=ce.sqr(a);o=ce.sqr(f),f=ce.mul(f,a),f=ce.mul(f,c),o=ce.mul(o,f);let d=ce.pow(o,e);d=ce.mul(d,f);let h=ce.mul(d,zh);o=ce.sqr(d),o=ce.mul(o,a);let m=ce.eql(o,c),_=ce.cmov(h,d,m),u=ce.mul(s,n),T=ce.mul(d,t);T=ce.mul(T,i2);let O=ce.mul(T,zh),R=ce.mul(c,n);o=ce.sqr(T),o=ce.mul(o,a);let F=ce.eql(o,R),M=ce.cmov(O,T,F);o=ce.sqr(_),o=ce.mul(o,a);let K=ce.eql(o,c),x=ce.cmov(u,s,K),$=ce.cmov(M,_,K),z=ce.isOdd($);return $=ce.cmov($,ce.neg($),K!==z),{xMn:x,xMd:i,yMn:$,yMd:Ur}}var o2=(0,Ue.FpSqrtEven)(ce,ce.neg(BigInt(486664)));function a2(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=s2(t),s=ce.mul(e,i);s=ce.mul(s,o2);let o=ce.mul(r,n),a=ce.sub(e,r),c=ce.add(e,r),f=ce.mul(o,c),d=ce.eql(f,ce.ZERO);s=ce.cmov(s,ce.ZERO,d),o=ce.cmov(o,ce.ONE,d),a=ce.cmov(a,ce.ONE,d),c=ce.cmov(c,ce.ONE,d);let h=ce.invertBatch([o,c]);return{x:ce.mul(s,h[0]),y:ce.mul(a,h[1])}}var rp=(0,Zh.createHasher)(ge.ed25519.ExtendedPoint,t=>a2(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:ce.ORDER,m:1,k:128,expand:"xmd",hash:ba.sha512});ge.hashToCurve=rp.hashToCurve;ge.encodeToCurve=rp.encodeToCurve;function pl(t){if(!(t instanceof gr))throw new Error("RistrettoPoint expected")}var ml=gl,c2=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),u2=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),l2=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),f2=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Wh=t=>wl(Ur,t),d2=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),yl=t=>ge.ed25519.CURVE.Fp.create((0,Yn.bytesToNumberLE)(t)&d2);function Dh(t){let{d:e}=ge.ed25519.CURVE,r=ge.ed25519.CURVE.Fp.ORDER,n=ge.ed25519.CURVE.Fp.create,i=n(ml*t*t),s=n((i+Ur)*l2),o=BigInt(-1),a=n((o-e*i)*n(i+e)),{isValid:c,value:f}=wl(s,a),d=n(f*t);(0,Ue.isNegativeLE)(d,r)||(d=n(-d)),c||(f=d),c||(o=i);let h=n(o*(i-Ur)*f2-a),m=f*f,_=n((f+f)*a),u=n(h*c2),T=n(Ur-m),O=n(Ur+m);return new ge.ed25519.ExtendedPoint(n(_*O),n(T*u),n(u*O),n(_*T))}var gr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(ge.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,Yn.ensureBytes)("ristrettoHash",e,64);let r=yl(e.slice(0,32)),n=Dh(r),i=yl(e.slice(32,64)),s=Dh(i);return new t(n.add(s))}static fromHex(e){e=(0,Yn.ensureBytes)("ristrettoHex",e,32);let{a:r,d:n}=ge.ed25519.CURVE,i=ge.ed25519.CURVE.Fp.ORDER,s=ge.ed25519.CURVE.Fp.create,o="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=yl(e);if(!(0,Yn.equalBytes)((0,Yn.numberToBytesLE)(a,32),e)||(0,Ue.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),f=s(Ur+r*c),d=s(Ur-r*c),h=s(f*f),m=s(d*d),_=s(r*n*h-m),{isValid:u,value:T}=Wh(s(_*m)),O=s(T*d),R=s(T*O*_),F=s((a+a)*O);(0,Ue.isNegativeLE)(F,i)&&(F=s(-F));let M=s(f*R),K=s(F*M);if(!u||(0,Ue.isNegativeLE)(K,i)||M===t2)throw new Error(o);return new t(new ge.ed25519.ExtendedPoint(F,M,Ur,K))}toRawBytes(){let{ex:e,ey:r,ez:n,et:i}=this.ep,s=ge.ed25519.CURVE.Fp.ORDER,o=ge.ed25519.CURVE.Fp.create,a=o(o(n+r)*o(n-r)),c=o(e*r),f=o(c*c),{value:d}=Wh(o(a*f)),h=o(d*a),m=o(d*c),_=o(h*m*i),u;if((0,Ue.isNegativeLE)(i*_,s)){let O=o(r*ml),R=o(e*ml);e=O,r=R,u=o(h*u2)}else u=m;(0,Ue.isNegativeLE)(e*_,s)&&(r=o(-r));let T=o((n-r)*u);return(0,Ue.isNegativeLE)(T,s)&&(T=o(-T)),(0,Yn.numberToBytesLE)(T,32)}toHex(){return(0,Yn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){pl(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=e.ep,o=ge.ed25519.CURVE.Fp.create,a=o(r*s)===o(n*i),c=o(n*s)===o(r*i);return a||c}add(e){return pl(e),new t(this.ep.add(e.ep))}subtract(e){return pl(e),new t(this.ep.subtract(e.ep))}multiply(e){return new t(this.ep.multiply(e))}multiplyUnsafe(e){return new t(this.ep.multiplyUnsafe(e))}double(){return new t(this.ep.double())}negate(){return new t(this.ep.negate())}};ge.RistrettoPoint=(gr.BASE||(gr.BASE=new gr(ge.ed25519.ExtendedPoint.BASE)),gr.ZERO||(gr.ZERO=new gr(ge.ed25519.ExtendedPoint.ZERO)),gr);var h2=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,Es.utf8ToBytes)(r):r,i=(0,Zh.expand_message_xmd)(t,n,64,ba.sha512);return gr.hashToCurve(i)};ge.hashToRistretto255=h2;ge.hash_to_ristretto255=ge.hashToRistretto255});var op=L(vn=>{"use strict";var np=vn&&vn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ft=vn&&vn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Bt,Ts,ip,sp;Object.defineProperty(vn,"__esModule",{value:!0});vn.ExpirableMap=void 0;var xl=class{constructor(e={}){Bt.set(this,void 0),Ts.set(this,void 0),this[ip]=this.entries.bind(this),this[sp]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();np(this,Bt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),np(this,Ts,n,"f")}prune(){let e=Date.now();for(let[r,n]of Ft(this,Bt,"f").entries())e-n.timestamp>Ft(this,Ts,"f")&&Ft(this,Bt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return Ft(this,Bt,"f").set(e,n),this}get(e){let r=Ft(this,Bt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>Ft(this,Ts,"f")){Ft(this,Bt,"f").delete(e);return}return r.value}}clear(){Ft(this,Bt,"f").clear()}entries(){let e=Ft(this,Bt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=Ft(this,Bt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return Ft(this,Bt,"f").keys()}forEach(e,r){for(let[n,i]of Ft(this,Bt,"f").entries())e.call(r,i.value,n,this)}has(e){return Ft(this,Bt,"f").has(e)}delete(e){return Ft(this,Bt,"f").delete(e)}get size(){return Ft(this,Bt,"f").size}};vn.ExpirableMap=xl;Bt=new WeakMap,Ts=new WeakMap,ip=Symbol.iterator,sp=Symbol.toStringTag});var vl=L(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 p2=kt(),y2=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")};je.encodeLenBytes=y2;var g2=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")};je.encodeLen=g2;var m2=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")};je.decodeLenBytes=m2;var b2=(t,e)=>{let r=(0,je.decodeLenBytes)(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")};je.decodeLen=b2;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 _2(t,e){let r=2+(0,je.encodeLenBytes)(t.byteLength+1),n=e.byteLength+r+t.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(e,i),i+=e.byteLength,s[i++]=3,i+=(0,je.encodeLen)(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}je.wrapDER=_2;var w2=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=(0,je.decodeLenBytes)(i,r),!(0,p2.bufEquals)(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=(0,je.decodeLen)(i,r)-1;r+=(0,je.decodeLenBytes)(i,r),n(0,"0 padding");let o=i.slice(r);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};je.unwrapDER=w2});var Tl=L(Tn=>{"use strict";var ap=Tn&&Tn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},cp=Tn&&Tn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},wa,Ea;Object.defineProperty(Tn,"__esModule",{value:!0});Tn.Ed25519PublicKey=void 0;var _a=vl(),xa=class t{constructor(e){if(wa.set(this,void 0),Ea.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");ap(this,wa,e,"f"),ap(this,Ea,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return(0,_a.wrapDER)(e,_a.ED25519_OID).buffer}static derDecode(e){let r=(0,_a.unwrapDER)(e,_a.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 cp(this,wa,"f")}get derKey(){return cp(this,Ea,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Tn.Ed25519PublicKey=xa;wa=new WeakMap,Ea=new WeakMap;xa.RAW_KEY_LENGTH=32});var up=L(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.ObservableLog=Si.Observable=void 0;var va=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}};Si.Observable=va;var Al=class extends va{constructor(){super()}print(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};Si.ObservableLog=Al});var gp=L(Cr=>{"use strict";var Fr=Cr&&Cr.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ot=Cr&&Cr.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Mr,Ta,Aa,Sa,Ba,Oa,Na,Ra,Bi;Object.defineProperty(Cr,"__esModule",{value:!0});Cr.exponentialBackoff=Cr.ExponentialBackoff=void 0;var lp=.5,fp=1.5,dp=500,hp=6e4,pp=9e5,yp=10,Oi=class t{constructor(e=t.default){Mr.set(this,void 0),Ta.set(this,void 0),Aa.set(this,void 0),Sa.set(this,void 0),Ba.set(this,void 0),Oa.set(this,void 0),Na.set(this,void 0),Ra.set(this,void 0),Bi.set(this,0);let{initialInterval:r=dp,randomizationFactor:n=lp,multiplier:i=fp,maxInterval:s=hp,maxElapsedTime:o=pp,maxIterations:a=yp,date:c=Date}=e;Fr(this,Mr,r,"f"),Fr(this,Ta,n,"f"),Fr(this,Aa,i,"f"),Fr(this,Sa,s,"f"),Fr(this,Ra,c,"f"),Fr(this,Ba,c.now(),"f"),Fr(this,Oa,o,"f"),Fr(this,Na,a,"f")}get ellapsedTimeInMsec(){return Ot(this,Ra,"f").now()-Ot(this,Ba,"f")}get currentInterval(){return Ot(this,Mr,"f")}get count(){return Ot(this,Bi,"f")}get randomValueFromInterval(){let e=Ot(this,Ta,"f")*Ot(this,Mr,"f"),r=Ot(this,Mr,"f")-e,n=Ot(this,Mr,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Fr(this,Mr,Math.min(Ot(this,Mr,"f")*Ot(this,Aa,"f"),Ot(this,Sa,"f")),"f"),Fr(this,Bi,(e=Ot(this,Bi,"f"),e++,e),"f"),Ot(this,Mr,"f")}next(){return this.ellapsedTimeInMsec>=Ot(this,Oa,"f")||Ot(this,Bi,"f")>=Ot(this,Na,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Cr.ExponentialBackoff=Oi;Mr=new WeakMap,Ta=new WeakMap,Aa=new WeakMap,Sa=new WeakMap,Ba=new WeakMap,Oa=new WeakMap,Na=new WeakMap,Ra=new WeakMap,Bi=new WeakMap;Oi.default={initialInterval:dp,randomizationFactor:lp,multiplier:fp,maxInterval:hp,maxElapsedTime:pp,maxIterations:yp,date:Date};function*E2(t=Oi.default){let e=new Oi(t),r=e.next();for(;r;)yield r,r=e.next()}Cr.exponentialBackoff=E2});var Sl=L(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS=void 0;Pa.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS=5*60*1e3});var Pl=L(Me=>{"use strict";var mp=Me&&Me.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),x2=Me&&Me.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),bp=Me&&Me.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&mp(e,t,r);return x2(e,t),e},v2=Me&&Me.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&mp(e,t,r)},Mt=Me&&Me.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ue=Me&&Me.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},jr,qr,Sn,Ii,As,Ss,mr,Fa,br,zn,Wn,Bs,Ri,Pi,Dn,Zn,_p,Ma,Ca;Object.defineProperty(Me,"__esModule",{value:!0});Me.HttpAgent=Me.IdentityInvalidError=Me.MANAGEMENT_CANISTER_ID=Me.IC_ROOT_KEY=Me.RequestStatusResponseStatus=Me.makeNonce=void 0;var ir=Nt(),Qr=fi(),T2=Tu(),An=bp(cs()),Ia=ss(),Bl=kt(),sr=Yo(),Ol=us(),Nl=Mu(),A2=ws(),Ni=Ti(),S2=El(),B2=op(),O2=Tl(),N2=aa(),R2=up(),P2=gp(),I2=Sl();v2(Yo(),Me);var U2=us();Object.defineProperty(Me,"makeNonce",{enumerable:!0,get:function(){return U2.makeNonce}});var F2;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(F2=Me.RequestStatusResponseStatus||(Me.RequestStatusResponseStatus={}));var Ua=60*1e3;Me.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Me.MANAGEMENT_CANISTER_ID="aaaaa-aa";var M2="ic0.app",C2=".ic0.app",q2="icp0.io",j2=".icp0.io",k2="icp-api.io",H2=".icp-api.io",Os=class extends Qr.AgentError{constructor(e){super(e),this.message=e}},Xn=class extends Qr.AgentError{constructor(e){super(e),this.message=e}};Me.IdentityInvalidError=Xn;function V2(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Os("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)t=global.fetch.bind(global);else throw new Os("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&&(t=self.fetch.bind(self));if(t)return t;throw new Os("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function $2(t){let e;if(t!==void 0)!t.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+t):e=new URL(t);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,o;s&&typeof s=="string"&&(n.some(a=>s.endsWith(a))?o=s:o=r.find(a=>s.endsWith(a))),i&&o?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var Rl=class t{constructor(e={}){var r;jr.add(this),qr.set(this,void 0),Sn.set(this,void 0),Ii.set(this,void 0),As.set(this,void 0),Ss.set(this,0),mr.set(this,void 0),Fa.set(this,!1),br.set(this,void 0),zn.set(this,void 0),Wn.set(this,void 0),this._isAgent=!0,this.config={},Bs.set(this,0),this.log=new R2.ObservableLog,Ri.set(this,[]),Pi.set(this,[]),Dn.set(this,new B2.ExpirableMap({expirationTime:5*60*1e3})),Zn.set(this,!0),Ca.set(this,(s,o)=>{if(ue(this,Zn,"f")===!1)return s;if(!o)throw new Ni.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:a,signatures:c=[],requestId:f}=s,d=new TextEncoder().encode("\vic-response");for(let h of c){let{timestamp:m,identity:_}=h,u=ir.Principal.fromUint8Array(_).toText(),T;if(a==="replied"){let{reply:K}=s;T=(0,Ia.hashOfMap)({status:a,reply:K,timestamp:BigInt(m),request_id:f})}else if(a==="rejected"){let{reject_code:K,reject_message:x,error_code:$}=s;T=(0,Ia.hashOfMap)({status:a,reject_code:K,reject_message:x,error_code:$,timestamp:BigInt(m),request_id:f})}else throw new Error(`Unknown status: ${a}`);let O=(0,Bl.concat)(d,new Uint8Array(T)),R=o?.nodeKeys.get(u);if(!R)throw new Ni.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let F=O2.Ed25519PublicKey.fromDer(R).rawKey;if(S2.ed25519.verify(h.signature,new Uint8Array(O),new Uint8Array(F)))return s;throw new Ni.CertificateVerificationError(`Invalid signature from replica ${u} signed query.`)}return s}),this.config=e,Mt(this,Sn,e.fetch||V2()||fetch.bind(global),"f"),Mt(this,Ii,e.fetchOptions,"f"),Mt(this,As,e.callOptions,"f"),this.rootKey=e.rootKey?e.rootKey:(0,Bl.fromHex)(Me.IC_ROOT_KEY);let n=$2(e.host);this.host=new URL(n),e.verifyQuerySignatures!==void 0&&Mt(this,Zn,e.verifyQuerySignatures,"f"),Mt(this,br,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let i=()=>new P2.ExponentialBackoff({maxIterations:ue(this,br,"f")});if(Mt(this,zn,e.backoffStrategy||i,"f"),this.host.hostname.endsWith(C2)?this.host.hostname=M2:this.host.hostname.endsWith(j2)?this.host.hostname=q2:this.host.hostname.endsWith(H2)&&(this.host.hostname=k2),e.credentials){let{name:s,password:o}=e.credentials;Mt(this,mr,`${s}${o?":"+o:""}`,"f")}if(Mt(this,qr,Promise.resolve(e.identity||new T2.AnonymousIdentity),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new Qr.AgentError(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);if(e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes<=0)throw new Qr.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);Mt(this,Wn,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,sr.makeNonceTransform)(Ol.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,sr.makeNonceTransform)(Ol.makeNonce)),e.logToConsole&&this.log.subscribe(s=>{s.level==="error"?console.error(s.message):s.level==="warn"?console.warn(s.message):console.log(s.message)})}get waterMark(){return ue(this,Bs,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let r=t.createSync(e),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(e){var r;try{return"config"in e?await t.create(e.config):await t.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(r=e._identity)!==null&&r!==void 0?r:void 0})}catch{throw new Qr.AgentError("Failed to create agent from provided agent")}}isLocal(){let e=this.host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=ue(this,Pi,"f").findIndex(s=>(s.priority||0)<n);ue(this,Pi,"f").splice(i>=0?i:ue(this,Pi,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ue(this,Ri,"f").findIndex(s=>(s.priority||0)<n);ue(this,Ri,"f").splice(i>=0?i:ue(this,Ri,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ue(this,qr,"f"))throw new Xn("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ue(this,qr,"f")).getPrincipal()}async call(e,r,n){var i;let s=(i=r.callSync)!==null&&i!==void 0?i:!0,o=await(n!==void 0?await n:await ue(this,qr,"f"));if(!o)throw new Xn("This identity has expired due this application's security policy. Please refresh your authentication.");let a=ir.Principal.from(e),c=r.effectiveCanisterId?ir.Principal.from(r.effectiveCanisterId):a,f=o.getPrincipal()||ir.Principal.anonymous(),d=new sr.Expiry(ue(this,Wn,"f")*Ua);Math.abs(ue(this,Ss,"f"))>1e3*30&&(d=new sr.Expiry(ue(this,Wn,"f")*Ua+ue(this,Ss,"f")));let h={request_type:Ol.SubmitRequestType.Call,canister_id:a,method_name:r.methodName,arg:r.arg,sender:f,ingress_expiry:d},m=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ue(this,mr,"f")?{Authorization:"Basic "+btoa(ue(this,mr,"f"))}:{})},endpoint:"call",body:h}),_=m.body.nonce?u(m.body.nonce):void 0;h.nonce=_;function u(R){return new Uint8Array(R)}m=await o.transformRequest(m);let T=An.encode(m.body),O=ue(this,zn,"f").call(this);try{let R=()=>(this.log.print(`fetching "/api/v3/canister/${c.toText()}/call" with request:`,m),ue(this,Sn,"f").call(this,""+new URL(`/api/v3/canister/${c.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,As,"f")),m.request),{body:T}))),F=()=>(this.log.print(`fetching "/api/v2/canister/${c.toText()}/call" with request:`,m),ue(this,Sn,"f").call(this,""+new URL(`/api/v2/canister/${c.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,As,"f")),m.request),{body:T}))),M=ue(this,jr,"m",Ma).call(this,{request:s?R:F,backoff:O,tries:0}),[K,x]=await Promise.all([M,(0,Ia.requestIdOf)(h)]),$=await K.arrayBuffer(),z=K.status===200&&$.byteLength>0?An.decode($):null;if(z&&"certificate"in z){let D=await this.parseTimeFromResponse({certificate:z.certificate});Mt(this,Bs,D,"f")}return{requestId:x,response:{ok:K.ok,status:K.status,statusText:K.statusText,body:z,headers:(0,sr.httpHeadersTransform)(K.headers)},requestDetails:h}}catch(R){if(R.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(e,Object.assign(Object.assign({},r),{callSync:!1}),n);throw this.log.error("Error while making call:",R),R}}async query(e,r,n){let i=ue(this,zn,"f").call(this),s=r.effectiveCanisterId?ir.Principal.from(r.effectiveCanisterId):ir.Principal.from(e);this.log.print(`ecid ${s.toString()}`),this.log.print(`canisterId ${e.toString()}`);let o=async()=>{let _=await(n!==void 0?n:ue(this,qr,"f"));if(!_)throw new Xn("This identity has expired due this application's security policy. Please refresh your authentication.");let u=ir.Principal.from(e),T=_?.getPrincipal()||ir.Principal.anonymous(),O={request_type:"query",canister_id:u,method_name:r.methodName,arg:r.arg,sender:T,ingress_expiry:new sr.Expiry(ue(this,Wn,"f")*Ua)},R=await(0,Ia.requestIdOf)(O),F=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ue(this,mr,"f")?{Authorization:"Basic "+btoa(ue(this,mr,"f"))}:{})},endpoint:"read",body:O});F=await _?.transformRequest(F);let M=An.encode(F.body),K={canister:u.toText(),ecid:s,transformedRequest:F,body:M,requestId:R,backoff:i,tries:0};return{requestDetails:O,query:await ue(this,jr,"m",_p).call(this,K)}},a=async()=>{if(!ue(this,Zn,"f"))return;let _=ue(this,Dn,"f").get(s.toString());return _||(await this.fetchSubnetKeys(s.toString()),ue(this,Dn,"f").get(s.toString()))},[c,f]=await Promise.all([o(),a()]),{requestDetails:d,query:h}=c,m=Object.assign(Object.assign({},h),{requestDetails:d});if(this.log.print("Query response:",m),!ue(this,Zn,"f"))return m;try{return ue(this,Ca,"f").call(this,m,f)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ue(this,Dn,"f").delete(e.toString()),await this.fetchSubnetKeys(s.toString());let u=ue(this,Dn,"f").get(e.toString());if(!u)throw new Ni.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ue(this,Ca,"f").call(this,m,u)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await ue(this,qr,"f"));if(!n)throw new Xn("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||ir.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ue(this,mr,"f")?{Authorization:"Basic "+btoa(ue(this,mr,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new sr.Expiry(ue(this,Wn,"f")*Ua)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?ir.Principal.fromText(e):e,o=i??await this.createReadStateRequest(r,n),a=Object.assign(Object.assign({},o.body),{ingress_expiry:new sr.Expiry(I2.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS)}),c=An.encode(a);this.log.print(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let f=ue(this,zn,"f").call(this);try{let d=await ue(this,jr,"m",Ma).call(this,{request:()=>ue(this,Sn,"f").call(this,""+new URL(`/api/v2/canister/${s.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,Ii,"f")),o.request),{body:c})),backoff:f,tries:0});if(!d.ok)throw new Error(`Server returned an error:
|
|
30
|
+
)`}else throw new Error("Invalid tree structure for labeled");case Et.Leaf:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for leaf");return`leaf(...${t[1].byteLength} bytes)`}case Et.Pruned:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for pruned");return`pruned(${(0,pr.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}Oe.hashTreeToString=ua;function Uw(t,e){let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}var ol=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=yh.decode(new Uint8Array(e))}static async create(e){let r=t.createUnverified(e);return await r.verify(),r}static createUnverified(e){let r=e.blsVerify;return r||(r=Rw.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return la(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await ms(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Mw(r),s=(0,pr.concat)(gs("ic-state-root"),e),o=!1,a=al(this.lookup(["time"]));if(!a)throw new Jr("Certificate does not contain a time");let c=5*60*1e3,f=this._maxAgeInMinutes*60*1e3,d=Date.now(),h=d-f,m=d+c,_=(0,Pw.decodeTime)(a);if(_.getTime()<h)throw new Jr(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+_.toISOString()+" Current time: "+new Date(d).toISOString());if(_.getTime()>m)throw new Jr("Certificate is signed more than 5 minutes in the future. Certificate time: "+_.toISOString()+" Current time: "+new Date(d).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new Jr("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let r=await t.createUnverified({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new Jr("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==Iw.MANAGEMENT_CANISTER_ID&&!gh({canisterId:this._canisterId,subnetId:sl.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new Jr(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,pr.toHex)(e.subnet_id)}`);let n=al(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,pr.toHex)(e.subnet_id)}`);return n}};Oe.Certificate=ol;var ys=(0,pr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Fw=96;function Mw(t){let e=ys.byteLength+Fw;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,ys.byteLength);if(!(0,pr.bufEquals)(r,ys))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${ys}, but get ${r}`);return t.slice(ys.byteLength)}function al(t){if(t.status===Ut.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}Oe.lookupResultToBuffer=al;async function ms(t){switch(t[0]){case Et.Empty:return(0,ca.hash)(gs("ic-hashtree-empty"));case Et.Pruned:return t[1];case Et.Leaf:return(0,ca.hash)((0,pr.concat)(gs("ic-hashtree-leaf"),t[1]));case Et.Labeled:return(0,ca.hash)((0,pr.concat)(gs("ic-hashtree-labeled"),t[1],await ms(t[2])));case Et.Fork:return(0,ca.hash)((0,pr.concat)(gs("ic-hashtree-fork"),await ms(t[1]),await ms(t[2])));default:throw new Error("unreachable")}}Oe.reconstruct=ms;function gs(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,pr.concat)(e,r)}var Ut;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(Ut=Oe.LookupStatus||(Oe.LookupStatus={}));var Qr;(function(t){t.Less="less",t.Greater="greater"})(Qr||(Qr={}));function la(t,e){if(t.length===0)switch(e[0]){case Et.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:Ut.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:Ut.Found,value:e[1].buffer}:{status:Ut.Found,value:e[1]}}default:return{status:Ut.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=bs(r,e);switch(n.status){case Ut.Found:return la(t.slice(1),n.value);case Qr.Greater:case Qr.Less:return{status:Ut.Absent};default:return n}}Oe.lookup_path=la;function cl(t){switch(t[0]){case Et.Empty:return[];case Et.Fork:return cl(t[1]).concat(cl(t[2]));default:return[t]}}Oe.flatten_forks=cl;function bs(t,e){switch(e[0]){case Et.Labeled:return Uw(t,e[1])?{status:Qr.Greater}:(0,pr.bufEquals)(t,e[1])?{status:Ut.Found,value:e[2]}:{status:Qr.Less};case Et.Fork:let r=bs(t,e[1]);switch(r.status){case Qr.Greater:{let n=bs(t,e[2]);return n.status===Qr.Less?{status:Ut.Absent}:n}case Ut.Unknown:{let n=bs(t,e[2]);return n.status===Qr.Less?{status:Ut.Unknown}:n}default:return r}case Et.Pruned:return{status:Ut.Unknown};default:return{status:Ut.Absent}}}Oe.find_label=bs;function gh(t){let{canisterId:e,subnetId:r,tree:n}=t,i=la(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Ut.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return yh.decode(i.value).map(c=>[sl.Principal.fromUint8Array(c[0]),sl.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}Oe.check_canister_ranges=gh});var ws=L(ct=>{"use strict";var Cw=ct&&ct.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),qw=ct&&ct.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),jw=ct&&ct.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Cw(e,t,r);return qw(e,t),e};Object.defineProperty(ct,"__esModule",{value:!0});ct.encodePath=ct.fetchNodeKeys=ct.request=ct.CustomPath=void 0;var bn=Nt(),kw=fi(),_n=Ti(),Hw=kt(),_h=jw(cs()),mh=aa(),ul=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};ct.CustomPath=ul;var Vw=async t=>{let{agent:e,paths:r}=t,n=bn.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>(0,ct.encodePath)(c,n)),o=new Map,a=i.map((c,f)=>(async()=>{var d;try{let h=await e.readState(n,{paths:[s[f]]}),m=await _n.Certificate.create({certificate:h.certificate,rootKey:e.rootKey,canisterId:n}),_=(O,R)=>{if(R==="subnet"){let F=(0,ct.fetchNodeKeys)(h.certificate,n,e.rootKey);return{path:R,data:F}}else return{path:R,data:(0,_n.lookupResultToBuffer)(O.lookup((0,ct.encodePath)(R,n)))}},{path:u,data:T}=_(m,i[f]);if(!T)console.warn(`Expected to find result for path ${u}, but instead found nothing.`),typeof u=="string"?o.set(u,null):o.set(u.key,null);else switch(u){case"time":{o.set(u,(0,mh.decodeTime)(T));break}case"controllers":{o.set(u,Yw(T));break}case"module_hash":{o.set(u,bh(T));break}case"subnet":{o.set(u,T);break}case"candid":{o.set(u,new TextDecoder().decode(T));break}default:if(typeof u!="string"&&"key"in u&&"path"in u)switch(u.decodeStrategy){case"raw":o.set(u.key,T);break;case"leb128":{o.set(u.key,(0,mh.decodeLeb128)(T));break}case"cbor":{o.set(u.key,wh(T));break}case"hex":{o.set(u.key,bh(T));break}case"utf-8":o.set(u.key,Gw(T))}}}catch(h){if(!((d=h?.message)===null||d===void 0)&&d.includes("Invalid certificate"))throw new kw.AgentError(h.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(h),console.groupEnd()}})());return await Promise.all(a),o};ct.request=Vw;var $w=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=_h.decode(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=bn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=bn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=bn.Principal.selfAuthenticating(bn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,_n.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,_n.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==_n.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let f=(0,_n.flatten_forks)(c.value),d=new Map;return f.forEach(h=>{let m=bn.Principal.from(new Uint8Array(h[1])).toText(),_=(0,_n.lookup_path)(["public_key"],h[2]);if(_.status!==_n.LookupStatus.Found)throw new Error("Public key not found");let u=_.value;if(u.byteLength!==44)throw new Error("Invalid public key length");d.set(m,u)}),{subnetId:bn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:d}};ct.fetchNodeKeys=$w;var Kw=(t,e)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(e.toUint8Array().buffer).buffer;switch(t){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 t&&"path"in t)if(typeof t.path=="string"||t.path instanceof ArrayBuffer){let s=t.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return t.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${t} was formatted correctly.`)};ct.encodePath=Kw;var bh=t=>(0,Hw.toHex)(t),wh=t=>_h.decode(t),Gw=t=>new TextDecoder().decode(t),Yw=t=>wh(t).map(r=>bn.Principal.fromUint8Array(new Uint8Array(r)))});var $h=L(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=fl;ye.split=Eh;ye.add=Mh;var fa=BigInt(2**32-1),ll=BigInt(32);function fl(t,e=!1){return e?{h:Number(t&fa),l:Number(t>>ll&fa)}:{h:Number(t>>ll&fa)|0,l:Number(t&fa)|0}}function Eh(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:s,l:o}=fl(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}var xh=(t,e)=>BigInt(t>>>0)<<ll|BigInt(e>>>0);ye.toBig=xh;var vh=(t,e,r)=>t>>>r;ye.shrSH=vh;var Th=(t,e,r)=>t<<32-r|e>>>r;ye.shrSL=Th;var Ah=(t,e,r)=>t>>>r|e<<32-r;ye.rotrSH=Ah;var Sh=(t,e,r)=>t<<32-r|e>>>r;ye.rotrSL=Sh;var Bh=(t,e,r)=>t<<64-r|e>>>r-32;ye.rotrBH=Bh;var Oh=(t,e,r)=>t>>>r-32|e<<64-r;ye.rotrBL=Oh;var Nh=(t,e)=>e;ye.rotr32H=Nh;var Rh=(t,e)=>t;ye.rotr32L=Rh;var Ph=(t,e,r)=>t<<r|e>>>32-r;ye.rotlSH=Ph;var Ih=(t,e,r)=>e<<r|t>>>32-r;ye.rotlSL=Ih;var Uh=(t,e,r)=>e<<r-32|t>>>64-r;ye.rotlBH=Uh;var Fh=(t,e,r)=>t<<r-32|e>>>64-r;ye.rotlBL=Fh;function Mh(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Ch=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);ye.add3L=Ch;var qh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;ye.add3H=qh;var jh=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);ye.add4L=jh;var kh=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;ye.add4H=kh;var Hh=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);ye.add5L=Hh;var Vh=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;ye.add5H=Vh;var zw={fromBig:fl,split:Eh,toBig:xh,shrSH:vh,shrSL:Th,rotrSH:Ah,rotrSL:Sh,rotrBH:Bh,rotrBL:Oh,rotr32H:Nh,rotr32L:Rh,rotlSH:Ph,rotlSL:Ih,rotlBH:Uh,rotlBL:Fh,add:Mh,add3L:Ch,add3H:qh,add4L:jh,add4H:kh,add5H:Vh,add5L:Hh};ye.default=zw});var Kh=L(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.sha384=pt.sha512_256=pt.sha512_224=pt.sha512=pt.SHA384=pt.SHA512_256=pt.SHA512_224=pt.SHA512=void 0;var Ww=Uc(),be=$h(),ya=qn(),[Dw,Zw]=be.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),wn=new Uint32Array(80),En=new Uint32Array(80),Gn=class extends Ww.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:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:f,El:d,Fh:h,Fl:m,Gh:_,Gl:u,Hh:T,Hl:O}=this;return[e,r,n,i,s,o,a,c,f,d,h,m,_,u,T,O]}set(e,r,n,i,s,o,a,c,f,d,h,m,_,u,T,O){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=d|0,this.Fh=h|0,this.Fl=m|0,this.Gh=_|0,this.Gl=u|0,this.Hh=T|0,this.Hl=O|0}process(e,r){for(let M=0;M<16;M++,r+=4)wn[M]=e.getUint32(r),En[M]=e.getUint32(r+=4);for(let M=16;M<80;M++){let K=wn[M-15]|0,x=En[M-15]|0,$=be.default.rotrSH(K,x,1)^be.default.rotrSH(K,x,8)^be.default.shrSH(K,x,7),z=be.default.rotrSL(K,x,1)^be.default.rotrSL(K,x,8)^be.default.shrSL(K,x,7),D=wn[M-2]|0,j=En[M-2]|0,ie=be.default.rotrSH(D,j,19)^be.default.rotrBH(D,j,61)^be.default.shrSH(D,j,6),ee=be.default.rotrSL(D,j,19)^be.default.rotrBL(D,j,61)^be.default.shrSL(D,j,6),ne=be.default.add4L(z,ee,En[M-7],En[M-16]),w=be.default.add4H(ne,$,ie,wn[M-7],wn[M-16]);wn[M]=w|0,En[M]=ne|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:d,Eh:h,El:m,Fh:_,Fl:u,Gh:T,Gl:O,Hh:R,Hl:F}=this;for(let M=0;M<80;M++){let K=be.default.rotrSH(h,m,14)^be.default.rotrSH(h,m,18)^be.default.rotrBH(h,m,41),x=be.default.rotrSL(h,m,14)^be.default.rotrSL(h,m,18)^be.default.rotrBL(h,m,41),$=h&_^~h&T,z=m&u^~m&O,D=be.default.add5L(F,x,z,Zw[M],En[M]),j=be.default.add5H(D,R,K,$,Dw[M],wn[M]),ie=D|0,ee=be.default.rotrSH(n,i,28)^be.default.rotrBH(n,i,34)^be.default.rotrBH(n,i,39),ne=be.default.rotrSL(n,i,28)^be.default.rotrBL(n,i,34)^be.default.rotrBL(n,i,39),w=n&s^n&a^s&a,b=i&o^i&c^o&c;R=T|0,F=O|0,T=_|0,O=u|0,_=h|0,u=m|0,{h,l:m}=be.default.add(f|0,d|0,j|0,ie|0),f=a|0,d=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let B=be.default.add3L(ie,ne,b);n=be.default.add3H(B,j,ee,w),i=B|0}({h:n,l:i}=be.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=be.default.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=be.default.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:d}=be.default.add(this.Dh|0,this.Dl|0,f|0,d|0),{h,l:m}=be.default.add(this.Eh|0,this.El|0,h|0,m|0),{h:_,l:u}=be.default.add(this.Fh|0,this.Fl|0,_|0,u|0),{h:T,l:O}=be.default.add(this.Gh|0,this.Gl|0,T|0,O|0),{h:R,l:F}=be.default.add(this.Hh|0,this.Hl|0,R|0,F|0),this.set(n,i,s,o,a,c,f,d,h,m,_,u,T,O,R,F)}roundClean(){wn.fill(0),En.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)}};pt.SHA512=Gn;var da=class extends Gn{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}};pt.SHA512_224=da;var ha=class extends Gn{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}};pt.SHA512_256=ha;var pa=class extends Gn{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}};pt.SHA384=pa;pt.sha512=(0,ya.wrapConstructor)(()=>new Gn);pt.sha512_224=(0,ya.wrapConstructor)(()=>new da);pt.sha512_256=(0,ya.wrapConstructor)(()=>new ha);pt.sha384=(0,ya.wrapConstructor)(()=>new pa)});var Yh=L(hl=>{"use strict";Object.defineProperty(hl,"__esModule",{value:!0});hl.twistedEdwards=Lw;var dl=Zu(),Gh=Ir(),Kt=zt(),Zt=zt(),yr=BigInt(0),$t=BigInt(1),ga=BigInt(2),Xw=BigInt(8),Jw={zip215:!0};function Qw(t){let e=(0,dl.validateBasic)(t);return Kt.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Lw(t){let e=Qw(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=ga<<BigInt(a*8)-$t,d=r.create,h=(0,Gh.Field)(e.n,e.nBitLength),m=e.uvRatio||((S,N)=>{try{return{isValid:!0,value:r.sqrt(S*r.inv(N))}}catch{return{isValid:!1,value:yr}}}),_=e.adjustScalarBytes||(S=>S),u=e.domain||((S,N,H)=>{if((0,Zt.abool)("phflag",H),N.length||H)throw new Error("Contexts/pre-hash are not supported");return S});function T(S,N){Kt.aInRange("coordinate "+S,N,yr,f)}function O(S){if(!(S instanceof M))throw new Error("ExtendedPoint expected")}let R=(0,Zt.memoized)((S,N)=>{let{ex:H,ey:Z,ez:ae}=S,oe=S.is0();N==null&&(N=oe?Xw:r.inv(ae));let W=d(H*N),U=d(Z*N),p=d(ae*N);if(oe)return{x:yr,y:$t};if(p!==$t)throw new Error("invZ was invalid");return{x:W,y:U}}),F=(0,Zt.memoized)(S=>{let{a:N,d:H}=e;if(S.is0())throw new Error("bad point: ZERO");let{ex:Z,ey:ae,ez:oe,et:W}=S,U=d(Z*Z),p=d(ae*ae),J=d(oe*oe),re=d(J*J),fe=d(U*N),Q=d(J*d(fe+p)),l=d(re+d(H*d(U*p)));if(Q!==l)throw new Error("bad point: equation left != right (1)");let y=d(Z*ae),g=d(oe*W);if(y!==g)throw new Error("bad point: equation left != right (2)");return!0});class M{constructor(N,H,Z,ae){this.ex=N,this.ey=H,this.ez=Z,this.et=ae,T("x",N),T("y",H),T("z",Z),T("t",ae),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(N){if(N instanceof M)throw new Error("extended point not allowed");let{x:H,y:Z}=N||{};return T("x",H),T("y",Z),new M(H,Z,$t,d(H*Z))}static normalizeZ(N){let H=r.invertBatch(N.map(Z=>Z.ez));return N.map((Z,ae)=>Z.toAffine(H[ae])).map(M.fromAffine)}static msm(N,H){return(0,dl.pippenger)(M,h,N,H)}_setWindowSize(N){$.setWindowSize(this,N)}assertValidity(){F(this)}equals(N){O(N);let{ex:H,ey:Z,ez:ae}=this,{ex:oe,ey:W,ez:U}=N,p=d(H*U),J=d(oe*ae),re=d(Z*U),fe=d(W*ae);return p===J&&re===fe}is0(){return this.equals(M.ZERO)}negate(){return new M(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:N}=e,{ex:H,ey:Z,ez:ae}=this,oe=d(H*H),W=d(Z*Z),U=d(ga*d(ae*ae)),p=d(N*oe),J=H+Z,re=d(d(J*J)-oe-W),fe=p+W,Q=fe-U,l=p-W,y=d(re*Q),g=d(fe*l),P=d(re*l),A=d(Q*fe);return new M(y,g,A,P)}add(N){O(N);let{a:H,d:Z}=e,{ex:ae,ey:oe,ez:W,et:U}=this,{ex:p,ey:J,ez:re,et:fe}=N;if(H===BigInt(-1)){let X=d((oe-ae)*(J+p)),te=d((oe+ae)*(J-p)),de=d(te-X);if(de===yr)return this.double();let _e=d(W*ga*fe),Fe=d(U*ga*re),Ve=Fe+_e,me=te+X,he=Fe-_e,Xe=d(Ve*de),Er=d(me*he),Gr=d(Ve*he),Fn=d(de*me);return new M(Xe,Er,Fn,Gr)}let Q=d(ae*p),l=d(oe*J),y=d(U*Z*fe),g=d(W*re),P=d((ae+oe)*(p+J)-Q-l),A=g-y,I=g+y,k=d(l-H*Q),E=d(P*A),C=d(I*k),V=d(P*k),q=d(A*I);return new M(E,C,q,V)}subtract(N){return this.add(N.negate())}wNAF(N){return $.wNAFCached(this,N,M.normalizeZ)}multiply(N){let H=N;Kt.aInRange("scalar",H,$t,n);let{p:Z,f:ae}=this.wNAF(H);return M.normalizeZ([Z,ae])[0]}multiplyUnsafe(N){let H=N;return Kt.aInRange("scalar",H,yr,n),H===yr?x:this.equals(x)||H===$t?this:this.equals(K)?this.wNAF(H).p:$.unsafeLadder(this,H)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return $.unsafeLadder(this,n).is0()}toAffine(N){return R(this,N)}clearCofactor(){let{h:N}=e;return N===$t?this:this.multiplyUnsafe(N)}static fromHex(N,H=!1){let{d:Z,a:ae}=e,oe=r.BYTES;N=(0,Zt.ensureBytes)("pointHex",N,oe),(0,Zt.abool)("zip215",H);let W=N.slice(),U=N[oe-1];W[oe-1]=U&-129;let p=Kt.bytesToNumberLE(W),J=H?f:r.ORDER;Kt.aInRange("pointHex.y",p,yr,J);let re=d(p*p),fe=d(re-$t),Q=d(Z*re-ae),{isValid:l,value:y}=m(fe,Q);if(!l)throw new Error("Point.fromHex: invalid y coordinate");let g=(y&$t)===$t,P=(U&128)!==0;if(!H&&y===yr&&P)throw new Error("Point.fromHex: x=0 and x_0=1");return P!==g&&(y=d(-y)),M.fromAffine({x:y,y:p})}static fromPrivateKey(N){return j(N).point}toRawBytes(){let{x:N,y:H}=this.toAffine(),Z=Kt.numberToBytesLE(H,r.BYTES);return Z[Z.length-1]|=N&$t?128:0,Z}toHex(){return Kt.bytesToHex(this.toRawBytes())}}M.BASE=new M(e.Gx,e.Gy,$t,d(e.Gx*e.Gy)),M.ZERO=new M(yr,$t,$t,yr);let{BASE:K,ZERO:x}=M,$=(0,dl.wNAF)(M,a*8);function z(S){return(0,Gh.mod)(S,n)}function D(S){return z(Kt.bytesToNumberLE(S))}function j(S){let N=a;S=(0,Zt.ensureBytes)("private key",S,N);let H=(0,Zt.ensureBytes)("hashed private key",s(S),2*N),Z=_(H.slice(0,N)),ae=H.slice(N,2*N),oe=D(Z),W=K.multiply(oe),U=W.toRawBytes();return{head:Z,prefix:ae,scalar:oe,point:W,pointBytes:U}}function ie(S){return j(S).pointBytes}function ee(S=new Uint8Array,...N){let H=Kt.concatBytes(...N);return D(s(u(H,(0,Zt.ensureBytes)("context",S),!!i)))}function ne(S,N,H={}){S=(0,Zt.ensureBytes)("message",S),i&&(S=i(S));let{prefix:Z,scalar:ae,pointBytes:oe}=j(N),W=ee(H.context,Z,S),U=K.multiply(W).toRawBytes(),p=ee(H.context,U,oe,S),J=z(W+p*ae);Kt.aInRange("signature.s",J,yr,n);let re=Kt.concatBytes(U,Kt.numberToBytesLE(J,r.BYTES));return(0,Zt.ensureBytes)("result",re,a*2)}let w=Jw;function b(S,N,H,Z=w){let{context:ae,zip215:oe}=Z,W=r.BYTES;S=(0,Zt.ensureBytes)("signature",S,2*W),N=(0,Zt.ensureBytes)("message",N),oe!==void 0&&(0,Zt.abool)("zip215",oe),i&&(N=i(N));let U=Kt.bytesToNumberLE(S.slice(W,2*W)),p,J,re;try{p=M.fromHex(H,oe),J=M.fromHex(S.slice(0,W),oe),re=K.multiplyUnsafe(U)}catch{return!1}if(!oe&&p.isSmallOrder())return!1;let fe=ee(ae,J.toRawBytes(),p.toRawBytes(),N);return J.add(p.multiplyUnsafe(fe)).subtract(re).clearCofactor().equals(M.ZERO)}return K._setWindowSize(8),{CURVE:e,getPublicKey:ie,sign:ne,verify:b,ExtendedPoint:M,utils:{getExtendedPublicKey:j,randomPrivateKey:()=>o(r.BYTES),precompute(S=8,N=M.BASE){return N._setWindowSize(S),N.multiply(BigInt(3)),N}}}}});var Wh=L(yl=>{"use strict";Object.defineProperty(yl,"__esModule",{value:!0});yl.montgomery=t2;var zh=Ir(),xn=zt(),Ai=BigInt(0),pl=BigInt(1);function e2(t){return(0,xn.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function t2(t){let e=e2(t),{P:r}=e,n=F=>(0,zh.mod)(F,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(F=>F),c=e.powPminus2||(F=>(0,zh.pow)(F,r-BigInt(2),r));function f(F,M,K){let x=n(F*(M-K));return M=n(M-x),K=n(K+x),[M,K]}let d=(e.a-BigInt(2))/BigInt(4);function h(F,M){(0,xn.aInRange)("u",F,Ai,r),(0,xn.aInRange)("scalar",M,Ai,r);let K=M,x=F,$=pl,z=Ai,D=F,j=pl,ie=Ai,ee;for(let w=BigInt(i-1);w>=Ai;w--){let b=K>>w&pl;ie^=b,ee=f(ie,$,D),$=ee[0],D=ee[1],ee=f(ie,z,j),z=ee[0],j=ee[1],ie=b;let B=$+z,S=n(B*B),N=$-z,H=n(N*N),Z=S-H,ae=D+j,oe=D-j,W=n(oe*B),U=n(ae*N),p=W+U,J=W-U;D=n(p*p),j=n(x*n(J*J)),$=n(S*H),z=n(Z*(S+n(d*Z)))}ee=f(ie,$,D),$=ee[0],D=ee[1],ee=f(ie,z,j),z=ee[0],j=ee[1];let ne=c(z);return n($*ne)}function m(F){return(0,xn.numberToBytesLE)(n(F),s)}function _(F){let M=(0,xn.ensureBytes)("u coordinate",F,s);return o===32&&(M[31]&=127),(0,xn.bytesToNumberLE)(M)}function u(F){let M=(0,xn.ensureBytes)("scalar",F),K=M.length;if(K!==s&&K!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${K}`);return(0,xn.bytesToNumberLE)(a(M))}function T(F,M){let K=_(M),x=u(F),$=h(K,x);if($===Ai)throw new Error("Invalid private or public key received");return m($)}let O=m(e.Gu);function R(F){return T(F,O)}return{scalarMult:T,scalarMultBase:R,getSharedSecret:(F,M)=>T(F,M),getPublicKey:F=>R(F),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:O}}});var vl=L(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.hash_to_ristretto255=ge.hashToRistretto255=ge.RistrettoPoint=ge.encodeToCurve=ge.hashToCurve=ge.edwardsToMontgomery=ge.x25519=ge.ed25519ph=ge.ed25519ctx=ge.ed25519=ge.ED25519_TORSION_SUBGROUP=void 0;ge.edwardsToMontgomeryPub=np;ge.edwardsToMontgomeryPriv=i2;var ba=Kh(),Es=qn(),wl=Yh(),Jh=Qo(),Ue=Ir(),r2=Wh(),Yn=zt(),xs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),bl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),n2=BigInt(0),Ur=BigInt(1),ma=BigInt(2),Qh=BigInt(3),Lh=BigInt(5),El=BigInt(8);function ep(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=xs,a=t*t%s*t%s,c=(0,Ue.pow2)(a,ma,s)*a%s,f=(0,Ue.pow2)(c,Ur,s)*t%s,d=(0,Ue.pow2)(f,Lh,s)*f%s,h=(0,Ue.pow2)(d,e,s)*d%s,m=(0,Ue.pow2)(h,r,s)*h%s,_=(0,Ue.pow2)(m,n,s)*m%s,u=(0,Ue.pow2)(_,i,s)*_%s,T=(0,Ue.pow2)(u,i,s)*_%s,O=(0,Ue.pow2)(T,e,s)*d%s;return{pow_p_5_8:(0,Ue.pow2)(O,ma,s)*t%s,b2:a}}function tp(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function xl(t,e){let r=xs,n=(0,Ue.mod)(e*e*e,r),i=(0,Ue.mod)(n*n*e,r),s=ep(t*i).pow_p_5_8,o=(0,Ue.mod)(t*n*s,r),a=(0,Ue.mod)(e*o*o,r),c=o,f=(0,Ue.mod)(o*bl,r),d=a===t,h=a===(0,Ue.mod)(-t,r),m=a===(0,Ue.mod)(-t*bl,r);return d&&(o=c),(h||m)&&(o=f),(0,Ue.isNegativeLE)(o,r)&&(o=(0,Ue.mod)(-o,r)),{isValid:d||h,value:o}}ge.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var ce=(0,Ue.Field)(xs,void 0,!0),vs={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ce,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:El,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ba.sha512,randomBytes:Es.randomBytes,adjustScalarBytes:tp,uvRatio:xl};ge.ed25519=(0,wl.twistedEdwards)(vs);function rp(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,Es.concatBytes)((0,Es.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}ge.ed25519ctx=(0,wl.twistedEdwards)({...vs,domain:rp});ge.ed25519ph=(0,wl.twistedEdwards)(Object.assign({},vs,{domain:rp,prehash:ba.sha512}));ge.x25519=(0,r2.montgomery)({P:xs,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=xs,{pow_p_5_8:r,b2:n}=ep(t);return(0,Ue.mod)((0,Ue.pow2)(r,Qh,e)*n,e)},adjustScalarBytes:tp,randomBytes:Es.randomBytes});function np(t){let{y:e}=ge.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return ce.toBytes(ce.create((r+e)*ce.inv(r-e)))}ge.edwardsToMontgomery=np;function i2(t){let e=vs.hash(t.subarray(0,32));return vs.adjustScalarBytes(e).subarray(0,32)}var s2=(ce.ORDER+Qh)/El,o2=ce.pow(ma,s2),Dh=ce.sqrt(ce.neg(ce.ONE));function a2(t){let e=(ce.ORDER-Lh)/El,r=BigInt(486662),n=ce.sqr(t);n=ce.mul(n,ma);let i=ce.add(n,ce.ONE),s=ce.neg(r),o=ce.sqr(i),a=ce.mul(o,i),c=ce.mul(n,r);c=ce.mul(c,s),c=ce.add(c,o),c=ce.mul(c,s);let f=ce.sqr(a);o=ce.sqr(f),f=ce.mul(f,a),f=ce.mul(f,c),o=ce.mul(o,f);let d=ce.pow(o,e);d=ce.mul(d,f);let h=ce.mul(d,Dh);o=ce.sqr(d),o=ce.mul(o,a);let m=ce.eql(o,c),_=ce.cmov(h,d,m),u=ce.mul(s,n),T=ce.mul(d,t);T=ce.mul(T,o2);let O=ce.mul(T,Dh),R=ce.mul(c,n);o=ce.sqr(T),o=ce.mul(o,a);let F=ce.eql(o,R),M=ce.cmov(O,T,F);o=ce.sqr(_),o=ce.mul(o,a);let K=ce.eql(o,c),x=ce.cmov(u,s,K),$=ce.cmov(M,_,K),z=ce.isOdd($);return $=ce.cmov($,ce.neg($),K!==z),{xMn:x,xMd:i,yMn:$,yMd:Ur}}var c2=(0,Ue.FpSqrtEven)(ce,ce.neg(BigInt(486664)));function u2(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=a2(t),s=ce.mul(e,i);s=ce.mul(s,c2);let o=ce.mul(r,n),a=ce.sub(e,r),c=ce.add(e,r),f=ce.mul(o,c),d=ce.eql(f,ce.ZERO);s=ce.cmov(s,ce.ZERO,d),o=ce.cmov(o,ce.ONE,d),a=ce.cmov(a,ce.ONE,d),c=ce.cmov(c,ce.ONE,d);let h=ce.invertBatch([o,c]);return{x:ce.mul(s,h[0]),y:ce.mul(a,h[1])}}var ip=(0,Jh.createHasher)(ge.ed25519.ExtendedPoint,t=>u2(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:ce.ORDER,m:1,k:128,expand:"xmd",hash:ba.sha512});ge.hashToCurve=ip.hashToCurve;ge.encodeToCurve=ip.encodeToCurve;function gl(t){if(!(t instanceof gr))throw new Error("RistrettoPoint expected")}var _l=bl,l2=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),f2=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),d2=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),h2=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Zh=t=>xl(Ur,t),p2=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),ml=t=>ge.ed25519.CURVE.Fp.create((0,Yn.bytesToNumberLE)(t)&p2);function Xh(t){let{d:e}=ge.ed25519.CURVE,r=ge.ed25519.CURVE.Fp.ORDER,n=ge.ed25519.CURVE.Fp.create,i=n(_l*t*t),s=n((i+Ur)*d2),o=BigInt(-1),a=n((o-e*i)*n(i+e)),{isValid:c,value:f}=xl(s,a),d=n(f*t);(0,Ue.isNegativeLE)(d,r)||(d=n(-d)),c||(f=d),c||(o=i);let h=n(o*(i-Ur)*h2-a),m=f*f,_=n((f+f)*a),u=n(h*l2),T=n(Ur-m),O=n(Ur+m);return new ge.ed25519.ExtendedPoint(n(_*O),n(T*u),n(u*O),n(_*T))}var gr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(ge.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,Yn.ensureBytes)("ristrettoHash",e,64);let r=ml(e.slice(0,32)),n=Xh(r),i=ml(e.slice(32,64)),s=Xh(i);return new t(n.add(s))}static fromHex(e){e=(0,Yn.ensureBytes)("ristrettoHex",e,32);let{a:r,d:n}=ge.ed25519.CURVE,i=ge.ed25519.CURVE.Fp.ORDER,s=ge.ed25519.CURVE.Fp.create,o="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=ml(e);if(!(0,Yn.equalBytes)((0,Yn.numberToBytesLE)(a,32),e)||(0,Ue.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),f=s(Ur+r*c),d=s(Ur-r*c),h=s(f*f),m=s(d*d),_=s(r*n*h-m),{isValid:u,value:T}=Zh(s(_*m)),O=s(T*d),R=s(T*O*_),F=s((a+a)*O);(0,Ue.isNegativeLE)(F,i)&&(F=s(-F));let M=s(f*R),K=s(F*M);if(!u||(0,Ue.isNegativeLE)(K,i)||M===n2)throw new Error(o);return new t(new ge.ed25519.ExtendedPoint(F,M,Ur,K))}toRawBytes(){let{ex:e,ey:r,ez:n,et:i}=this.ep,s=ge.ed25519.CURVE.Fp.ORDER,o=ge.ed25519.CURVE.Fp.create,a=o(o(n+r)*o(n-r)),c=o(e*r),f=o(c*c),{value:d}=Zh(o(a*f)),h=o(d*a),m=o(d*c),_=o(h*m*i),u;if((0,Ue.isNegativeLE)(i*_,s)){let O=o(r*_l),R=o(e*_l);e=O,r=R,u=o(h*f2)}else u=m;(0,Ue.isNegativeLE)(e*_,s)&&(r=o(-r));let T=o((n-r)*u);return(0,Ue.isNegativeLE)(T,s)&&(T=o(-T)),(0,Yn.numberToBytesLE)(T,32)}toHex(){return(0,Yn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){gl(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=e.ep,o=ge.ed25519.CURVE.Fp.create,a=o(r*s)===o(n*i),c=o(n*s)===o(r*i);return a||c}add(e){return gl(e),new t(this.ep.add(e.ep))}subtract(e){return gl(e),new t(this.ep.subtract(e.ep))}multiply(e){return new t(this.ep.multiply(e))}multiplyUnsafe(e){return new t(this.ep.multiplyUnsafe(e))}double(){return new t(this.ep.double())}negate(){return new t(this.ep.negate())}};ge.RistrettoPoint=(gr.BASE||(gr.BASE=new gr(ge.ed25519.ExtendedPoint.BASE)),gr.ZERO||(gr.ZERO=new gr(ge.ed25519.ExtendedPoint.ZERO)),gr);var y2=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,Es.utf8ToBytes)(r):r,i=(0,Jh.expand_message_xmd)(t,n,64,ba.sha512);return gr.hashToCurve(i)};ge.hashToRistretto255=y2;ge.hash_to_ristretto255=ge.hashToRistretto255});var cp=L(vn=>{"use strict";var sp=vn&&vn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ft=vn&&vn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Bt,Ts,op,ap;Object.defineProperty(vn,"__esModule",{value:!0});vn.ExpirableMap=void 0;var Tl=class{constructor(e={}){Bt.set(this,void 0),Ts.set(this,void 0),this[op]=this.entries.bind(this),this[ap]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();sp(this,Bt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),sp(this,Ts,n,"f")}prune(){let e=Date.now();for(let[r,n]of Ft(this,Bt,"f").entries())e-n.timestamp>Ft(this,Ts,"f")&&Ft(this,Bt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return Ft(this,Bt,"f").set(e,n),this}get(e){let r=Ft(this,Bt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>Ft(this,Ts,"f")){Ft(this,Bt,"f").delete(e);return}return r.value}}clear(){Ft(this,Bt,"f").clear()}entries(){let e=Ft(this,Bt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=Ft(this,Bt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return Ft(this,Bt,"f").keys()}forEach(e,r){for(let[n,i]of Ft(this,Bt,"f").entries())e.call(r,i.value,n,this)}has(e){return Ft(this,Bt,"f").has(e)}delete(e){return Ft(this,Bt,"f").delete(e)}get size(){return Ft(this,Bt,"f").size}};vn.ExpirableMap=Tl;Bt=new WeakMap,Ts=new WeakMap,op=Symbol.iterator,ap=Symbol.toStringTag});var Al=L(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 g2=kt(),m2=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")};je.encodeLenBytes=m2;var b2=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")};je.encodeLen=b2;var _2=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")};je.decodeLenBytes=_2;var w2=(t,e)=>{let r=(0,je.decodeLenBytes)(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")};je.decodeLen=w2;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 E2(t,e){let r=2+(0,je.encodeLenBytes)(t.byteLength+1),n=e.byteLength+r+t.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(e,i),i+=e.byteLength,s[i++]=3,i+=(0,je.encodeLen)(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}je.wrapDER=E2;var x2=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=(0,je.decodeLenBytes)(i,r),!(0,g2.bufEquals)(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=(0,je.decodeLen)(i,r)-1;r+=(0,je.decodeLenBytes)(i,r),n(0,"0 padding");let o=i.slice(r);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};je.unwrapDER=x2});var Sl=L(Tn=>{"use strict";var up=Tn&&Tn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},lp=Tn&&Tn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},wa,Ea;Object.defineProperty(Tn,"__esModule",{value:!0});Tn.Ed25519PublicKey=void 0;var _a=Al(),xa=class t{constructor(e){if(wa.set(this,void 0),Ea.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");up(this,wa,e,"f"),up(this,Ea,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return(0,_a.wrapDER)(e,_a.ED25519_OID).buffer}static derDecode(e){let r=(0,_a.unwrapDER)(e,_a.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 lp(this,wa,"f")}get derKey(){return lp(this,Ea,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Tn.Ed25519PublicKey=xa;wa=new WeakMap,Ea=new WeakMap;xa.RAW_KEY_LENGTH=32});var fp=L(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.ObservableLog=Si.Observable=void 0;var va=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}};Si.Observable=va;var Bl=class extends va{constructor(){super()}print(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};Si.ObservableLog=Bl});var bp=L(Cr=>{"use strict";var Fr=Cr&&Cr.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ot=Cr&&Cr.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Mr,Ta,Aa,Sa,Ba,Oa,Na,Ra,Bi;Object.defineProperty(Cr,"__esModule",{value:!0});Cr.exponentialBackoff=Cr.ExponentialBackoff=void 0;var dp=.5,hp=1.5,pp=500,yp=6e4,gp=9e5,mp=10,Oi=class t{constructor(e=t.default){Mr.set(this,void 0),Ta.set(this,void 0),Aa.set(this,void 0),Sa.set(this,void 0),Ba.set(this,void 0),Oa.set(this,void 0),Na.set(this,void 0),Ra.set(this,void 0),Bi.set(this,0);let{initialInterval:r=pp,randomizationFactor:n=dp,multiplier:i=hp,maxInterval:s=yp,maxElapsedTime:o=gp,maxIterations:a=mp,date:c=Date}=e;Fr(this,Mr,r,"f"),Fr(this,Ta,n,"f"),Fr(this,Aa,i,"f"),Fr(this,Sa,s,"f"),Fr(this,Ra,c,"f"),Fr(this,Ba,c.now(),"f"),Fr(this,Oa,o,"f"),Fr(this,Na,a,"f")}get ellapsedTimeInMsec(){return Ot(this,Ra,"f").now()-Ot(this,Ba,"f")}get currentInterval(){return Ot(this,Mr,"f")}get count(){return Ot(this,Bi,"f")}get randomValueFromInterval(){let e=Ot(this,Ta,"f")*Ot(this,Mr,"f"),r=Ot(this,Mr,"f")-e,n=Ot(this,Mr,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Fr(this,Mr,Math.min(Ot(this,Mr,"f")*Ot(this,Aa,"f"),Ot(this,Sa,"f")),"f"),Fr(this,Bi,(e=Ot(this,Bi,"f"),e++,e),"f"),Ot(this,Mr,"f")}next(){return this.ellapsedTimeInMsec>=Ot(this,Oa,"f")||Ot(this,Bi,"f")>=Ot(this,Na,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Cr.ExponentialBackoff=Oi;Mr=new WeakMap,Ta=new WeakMap,Aa=new WeakMap,Sa=new WeakMap,Ba=new WeakMap,Oa=new WeakMap,Na=new WeakMap,Ra=new WeakMap,Bi=new WeakMap;Oi.default={initialInterval:pp,randomizationFactor:dp,multiplier:hp,maxInterval:yp,maxElapsedTime:gp,maxIterations:mp,date:Date};function*v2(t=Oi.default){let e=new Oi(t),r=e.next();for(;r;)yield r,r=e.next()}Cr.exponentialBackoff=v2});var Ol=L(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS=void 0;Pa.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS=5*60*1e3});var Ul=L(Me=>{"use strict";var _p=Me&&Me.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),T2=Me&&Me.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),wp=Me&&Me.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&_p(e,t,r);return T2(e,t),e},A2=Me&&Me.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&_p(e,t,r)},Mt=Me&&Me.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ue=Me&&Me.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},jr,qr,Sn,Ii,As,Ss,mr,Fa,br,zn,Wn,Bs,Ri,Pi,Dn,Zn,Ep,Ma,Ca;Object.defineProperty(Me,"__esModule",{value:!0});Me.HttpAgent=Me.IdentityInvalidError=Me.MANAGEMENT_CANISTER_ID=Me.IC_ROOT_KEY=Me.RequestStatusResponseStatus=Me.makeNonce=void 0;var ir=Nt(),Lr=fi(),S2=Su(),An=wp(cs()),Ia=ss(),Nl=kt(),sr=Yo(),Rl=us(),Pl=qu(),B2=ws(),Ni=Ti(),O2=vl(),N2=cp(),R2=Sl(),P2=aa(),I2=fp(),U2=bp(),F2=Ol();A2(Yo(),Me);var M2=us();Object.defineProperty(Me,"makeNonce",{enumerable:!0,get:function(){return M2.makeNonce}});var C2;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(C2=Me.RequestStatusResponseStatus||(Me.RequestStatusResponseStatus={}));var Ua=60*1e3;Me.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Me.MANAGEMENT_CANISTER_ID="aaaaa-aa";var q2="ic0.app",j2=".ic0.app",k2="icp0.io",H2=".icp0.io",V2="icp-api.io",$2=".icp-api.io",Os=class extends Lr.AgentError{constructor(e){super(e),this.message=e}},Xn=class extends Lr.AgentError{constructor(e){super(e),this.message=e}};Me.IdentityInvalidError=Xn;function K2(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Os("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)t=global.fetch.bind(global);else throw new Os("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&&(t=self.fetch.bind(self));if(t)return t;throw new Os("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function G2(t){let e;if(t!==void 0)!t.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+t):e=new URL(t);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,o;s&&typeof s=="string"&&(n.some(a=>s.endsWith(a))?o=s:o=r.find(a=>s.endsWith(a))),i&&o?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var Il=class t{constructor(e={}){var r;jr.add(this),qr.set(this,void 0),Sn.set(this,void 0),Ii.set(this,void 0),As.set(this,void 0),Ss.set(this,0),mr.set(this,void 0),Fa.set(this,!1),br.set(this,void 0),zn.set(this,void 0),Wn.set(this,void 0),this._isAgent=!0,this.config={},Bs.set(this,0),this.log=new I2.ObservableLog,Ri.set(this,[]),Pi.set(this,[]),Dn.set(this,new N2.ExpirableMap({expirationTime:5*60*1e3})),Zn.set(this,!0),Ca.set(this,(s,o)=>{if(ue(this,Zn,"f")===!1)return s;if(!o)throw new Ni.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:a,signatures:c=[],requestId:f}=s,d=new TextEncoder().encode("\vic-response");for(let h of c){let{timestamp:m,identity:_}=h,u=ir.Principal.fromUint8Array(_).toText(),T;if(a==="replied"){let{reply:K}=s;T=(0,Ia.hashOfMap)({status:a,reply:K,timestamp:BigInt(m),request_id:f})}else if(a==="rejected"){let{reject_code:K,reject_message:x,error_code:$}=s;T=(0,Ia.hashOfMap)({status:a,reject_code:K,reject_message:x,error_code:$,timestamp:BigInt(m),request_id:f})}else throw new Error(`Unknown status: ${a}`);let O=(0,Nl.concat)(d,new Uint8Array(T)),R=o?.nodeKeys.get(u);if(!R)throw new Ni.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let F=R2.Ed25519PublicKey.fromDer(R).rawKey;if(O2.ed25519.verify(h.signature,new Uint8Array(O),new Uint8Array(F)))return s;throw new Ni.CertificateVerificationError(`Invalid signature from replica ${u} signed query.`)}return s}),this.config=e,Mt(this,Sn,e.fetch||K2()||fetch.bind(global),"f"),Mt(this,Ii,e.fetchOptions,"f"),Mt(this,As,e.callOptions,"f"),this.rootKey=e.rootKey?e.rootKey:(0,Nl.fromHex)(Me.IC_ROOT_KEY);let n=G2(e.host);this.host=new URL(n),e.verifyQuerySignatures!==void 0&&Mt(this,Zn,e.verifyQuerySignatures,"f"),Mt(this,br,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let i=()=>new U2.ExponentialBackoff({maxIterations:ue(this,br,"f")});if(Mt(this,zn,e.backoffStrategy||i,"f"),this.host.hostname.endsWith(j2)?this.host.hostname=q2:this.host.hostname.endsWith(H2)?this.host.hostname=k2:this.host.hostname.endsWith($2)&&(this.host.hostname=V2),e.credentials){let{name:s,password:o}=e.credentials;Mt(this,mr,`${s}${o?":"+o:""}`,"f")}if(Mt(this,qr,Promise.resolve(e.identity||new S2.AnonymousIdentity),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new Lr.AgentError(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);if(e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes<=0)throw new Lr.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);Mt(this,Wn,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,sr.makeNonceTransform)(Rl.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,sr.makeNonceTransform)(Rl.makeNonce)),e.logToConsole&&this.log.subscribe(s=>{s.level==="error"?console.error(s.message):s.level==="warn"?console.warn(s.message):console.log(s.message)})}get waterMark(){return ue(this,Bs,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let r=t.createSync(e),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(e){var r;try{return"config"in e?await t.create(e.config):await t.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(r=e._identity)!==null&&r!==void 0?r:void 0})}catch{throw new Lr.AgentError("Failed to create agent from provided agent")}}isLocal(){let e=this.host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=ue(this,Pi,"f").findIndex(s=>(s.priority||0)<n);ue(this,Pi,"f").splice(i>=0?i:ue(this,Pi,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ue(this,Ri,"f").findIndex(s=>(s.priority||0)<n);ue(this,Ri,"f").splice(i>=0?i:ue(this,Ri,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ue(this,qr,"f"))throw new Xn("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ue(this,qr,"f")).getPrincipal()}async call(e,r,n){var i;let s=(i=r.callSync)!==null&&i!==void 0?i:!0,o=await(n!==void 0?await n:await ue(this,qr,"f"));if(!o)throw new Xn("This identity has expired due this application's security policy. Please refresh your authentication.");let a=ir.Principal.from(e),c=r.effectiveCanisterId?ir.Principal.from(r.effectiveCanisterId):a,f=o.getPrincipal()||ir.Principal.anonymous(),d=new sr.Expiry(ue(this,Wn,"f")*Ua);Math.abs(ue(this,Ss,"f"))>1e3*30&&(d=new sr.Expiry(ue(this,Wn,"f")*Ua+ue(this,Ss,"f")));let h={request_type:Rl.SubmitRequestType.Call,canister_id:a,method_name:r.methodName,arg:r.arg,sender:f,ingress_expiry:d},m=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ue(this,mr,"f")?{Authorization:"Basic "+btoa(ue(this,mr,"f"))}:{})},endpoint:"call",body:h}),_=m.body.nonce?u(m.body.nonce):void 0;h.nonce=_;function u(R){return new Uint8Array(R)}m=await o.transformRequest(m);let T=An.encode(m.body),O=ue(this,zn,"f").call(this);try{let R=()=>(this.log.print(`fetching "/api/v3/canister/${c.toText()}/call" with request:`,m),ue(this,Sn,"f").call(this,""+new URL(`/api/v3/canister/${c.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,As,"f")),m.request),{body:T}))),F=()=>(this.log.print(`fetching "/api/v2/canister/${c.toText()}/call" with request:`,m),ue(this,Sn,"f").call(this,""+new URL(`/api/v2/canister/${c.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,As,"f")),m.request),{body:T}))),M=ue(this,jr,"m",Ma).call(this,{request:s?R:F,backoff:O,tries:0}),[K,x]=await Promise.all([M,(0,Ia.requestIdOf)(h)]),$=await K.arrayBuffer(),z=K.status===200&&$.byteLength>0?An.decode($):null;if(z&&"certificate"in z){let D=await this.parseTimeFromResponse({certificate:z.certificate});Mt(this,Bs,D,"f")}return{requestId:x,response:{ok:K.ok,status:K.status,statusText:K.statusText,body:z,headers:(0,sr.httpHeadersTransform)(K.headers)},requestDetails:h}}catch(R){if(R.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(e,Object.assign(Object.assign({},r),{callSync:!1}),n);throw this.log.error("Error while making call:",R),R}}async query(e,r,n){let i=ue(this,zn,"f").call(this),s=r.effectiveCanisterId?ir.Principal.from(r.effectiveCanisterId):ir.Principal.from(e);this.log.print(`ecid ${s.toString()}`),this.log.print(`canisterId ${e.toString()}`);let o=async()=>{let _=await(n!==void 0?n:ue(this,qr,"f"));if(!_)throw new Xn("This identity has expired due this application's security policy. Please refresh your authentication.");let u=ir.Principal.from(e),T=_?.getPrincipal()||ir.Principal.anonymous(),O={request_type:"query",canister_id:u,method_name:r.methodName,arg:r.arg,sender:T,ingress_expiry:new sr.Expiry(ue(this,Wn,"f")*Ua)},R=await(0,Ia.requestIdOf)(O),F=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ue(this,mr,"f")?{Authorization:"Basic "+btoa(ue(this,mr,"f"))}:{})},endpoint:"read",body:O});F=await _?.transformRequest(F);let M=An.encode(F.body),K={canister:u.toText(),ecid:s,transformedRequest:F,body:M,requestId:R,backoff:i,tries:0};return{requestDetails:O,query:await ue(this,jr,"m",Ep).call(this,K)}},a=async()=>{if(!ue(this,Zn,"f"))return;let _=ue(this,Dn,"f").get(s.toString());return _||(await this.fetchSubnetKeys(s.toString()),ue(this,Dn,"f").get(s.toString()))},[c,f]=await Promise.all([o(),a()]),{requestDetails:d,query:h}=c,m=Object.assign(Object.assign({},h),{requestDetails:d});if(this.log.print("Query response:",m),!ue(this,Zn,"f"))return m;try{return ue(this,Ca,"f").call(this,m,f)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ue(this,Dn,"f").delete(e.toString()),await this.fetchSubnetKeys(s.toString());let u=ue(this,Dn,"f").get(e.toString());if(!u)throw new Ni.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ue(this,Ca,"f").call(this,m,u)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await ue(this,qr,"f"));if(!n)throw new Xn("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||ir.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ue(this,mr,"f")?{Authorization:"Basic "+btoa(ue(this,mr,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new sr.Expiry(ue(this,Wn,"f")*Ua)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?ir.Principal.fromText(e):e,o=i??await this.createReadStateRequest(r,n),a=Object.assign(Object.assign({},o.body),{ingress_expiry:new sr.Expiry(F2.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS)}),c=An.encode(a);this.log.print(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let f=ue(this,zn,"f").call(this);try{let d=await ue(this,jr,"m",Ma).call(this,{request:()=>ue(this,Sn,"f").call(this,""+new URL(`/api/v2/canister/${s.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,Ii,"f")),o.request),{body:c})),backoff:f,tries:0});if(!d.ok)throw new Error(`Server returned an error:
|
|
31
31
|
Code: ${d.status} (${d.statusText})
|
|
32
32
|
Body: ${await d.text()}
|
|
33
|
-
`);let h=An.decode(await d.arrayBuffer());this.log.print("Read state response:",h);let m=await this.parseTimeFromResponse(h);return m>0&&(this.log.print("Read state response time:",m),Mt(this,Bs,m,"f")),h}catch(d){throw this.log.error("Caught exception while attempting to read state",d),d}}async parseTimeFromResponse(e){let r;if(e.certificate){let n=An.decode(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,Ni.lookup_path)(["time"],r);if(i.status!==Ni.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,
|
|
33
|
+
`);let h=An.decode(await d.arrayBuffer());this.log.print("Read state response:",h);let m=await this.parseTimeFromResponse(h);return m>0&&(this.log.print("Read state response time:",m),Mt(this,Bs,m,"f")),h}catch(d){throw this.log.error("Caught exception while attempting to read state",d),d}}async parseTimeFromResponse(e){let r;if(e.certificate){let n=An.decode(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,Ni.lookup_path)(["time"],r);if(i.status!==Ni.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,P2.decodeTime)((0,Nl.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(e){let r=await Promise.resolve().then(()=>wp(ws())),n=Date.now();try{e||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let s=(await r.request({canisterId:e??ir.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");s&&Mt(this,Ss,Number(s)-Number(n),"f")}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=ue(this,mr,"f")?{Authorization:"Basic "+btoa(ue(this,mr,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ue(this,zn,"f").call(this),n=await ue(this,jr,"m",Ma).call(this,{backoff:r,request:()=>ue(this,Sn,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:e},ue(this,Ii,"f"))),tries:0});return An.decode(await n.arrayBuffer())}async fetchRootKey(){if(!ue(this,Fa,"f")){let e=await this.status();this.rootKey=e.root_key,Mt(this,Fa,!0,"f")}return this.rootKey}invalidateIdentity(){Mt(this,qr,null,"f")}replaceIdentity(e){Mt(this,qr,Promise.resolve(e),"f")}async fetchSubnetKeys(e){let r=ir.Principal.from(e),i=(await(0,B2.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ue(this,Dn,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of ue(this,Pi,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ue(this,Ri,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Me.HttpAgent=Il;qr=new WeakMap,Sn=new WeakMap,Ii=new WeakMap,As=new WeakMap,Ss=new WeakMap,mr=new WeakMap,Fa=new WeakMap,br=new WeakMap,zn=new WeakMap,Wn=new WeakMap,Bs=new WeakMap,Ri=new WeakMap,Pi=new WeakMap,Dn=new WeakMap,Zn=new WeakMap,Ca=new WeakMap,jr=new WeakSet,Ep=async function t(e){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,backoff:c,tries:f}=e,d=f===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:f,backoff:c,delay:d}),d===null)throw new Lr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ue(this,br,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);d>0&&await new Promise(u=>setTimeout(u,d));let h;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let u=await ue(this,Sn,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,Ii,"f")),s.request),{body:o}));if(u.status===200){let T=An.decode(await u.arrayBuffer());h=Object.assign(Object.assign({},T),{httpDetails:{ok:u.ok,status:u.status,statusText:u.statusText,headers:(0,sr.httpHeadersTransform)(u.headers)},requestId:a})}else throw new Pl.AgentHTTPResponseError(`Gateway returned an error:
|
|
34
34
|
Code: ${u.status} (${u.statusText})
|
|
35
35
|
Body: ${await u.text()}
|
|
36
36
|
`,{ok:u.ok,status:u.status,statusText:u.statusText,headers:(0,sr.httpHeadersTransform)(u.headers)})}catch(u){if(f<ue(this,br,"f"))return this.log.warn(`Caught exception while attempting to make query:
|
|
37
37
|
${u}
|
|
38
|
-
Retrying query.`),await ue(this,jr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw u}let m=(n=(r=h.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ue(this,Zn,"f"))return h;if(!m)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let _=Number(BigInt(m)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:_}),Number(this.waterMark)>_){let u=new
|
|
38
|
+
Retrying query.`),await ue(this,jr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw u}let m=(n=(r=h.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ue(this,Zn,"f"))return h;if(!m)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let _=Number(BigInt(m)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:_}),Number(this.waterMark)>_){let u=new Lr.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",u,{timestamp:m,waterMark:this.waterMark}),f<ue(this,br,"f"))return await ue(this,jr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw new Lr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ue(this,br,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return h},Ma=async function t(e){let{request:r,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new Lr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ue(this,br,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(f=>setTimeout(f,s));let o;try{o=await r()}catch(f){if(ue(this,br,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
|
|
39
39
|
${f}
|
|
40
40
|
Retrying request.`),await ue(this,jr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw f}if(o.ok)return o;let a=await o.clone().text(),c=`Server returned an error:
|
|
41
41
|
Code: ${o.status} (${o.statusText})
|
|
42
42
|
Body: ${a}
|
|
43
|
-
`;if(o.status===404&&o.url.includes("api/v3"))throw new
|
|
44
|
-
Request ID: ${(0,
|
|
43
|
+
`;if(o.status===404&&o.url.includes("api/v3"))throw new Pl.AgentHTTPResponseError("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,sr.httpHeadersTransform)(o.headers)});if(i<ue(this,br,"f"))return await ue(this,jr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new Pl.AgentHTTPResponseError(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,sr.httpHeadersTransform)(o.headers)})}});var xp=L(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});en.ProxyAgent=en.ProxyStubAgent=en.ProxyMessageKind=void 0;var Y2=Nt(),Qe;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(Qe=en.ProxyMessageKind||(en.ProxyMessageKind={}));var Fl=class{constructor(e,r){this._frontend=e,this._agent=r}onmessage(e){switch(e.type){case Qe.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:e.id,type:Qe.GetPrincipalResponse,response:r.toText()})});break;case Qe.Query:this._agent.query(...e.args).then(r=>{this._frontend({id:e.id,type:Qe.QueryResponse,response:r})});break;case Qe.Call:this._agent.call(...e.args).then(r=>{this._frontend({id:e.id,type:Qe.CallResponse,response:r})});break;case Qe.ReadState:this._agent.readState(...e.args).then(r=>{this._frontend({id:e.id,type:Qe.ReadStateResponse,response:r})});break;case Qe.Status:this._agent.status().then(r=>{this._frontend({id:e.id,type:Qe.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(e)}`)}}};en.ProxyStubAgent=Fl;var Ml=class{constructor(e){this._backend=e,this._nextId=0,this._pendingCalls=new Map,this.rootKey=null}onmessage(e){let r=e.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(e.type){case Qe.Error:return s(e.error);case Qe.GetPrincipalResponse:case Qe.CallResponse:case Qe.QueryResponse:case Qe.ReadStateResponse:case Qe.StatusResponse:return i(e.response);default:throw new Error(`Invalid message being sent to ProxyAgent: ${JSON.stringify(e)}`)}}async getPrincipal(){return this._sendAndWait({id:this._nextId++,type:Qe.GetPrincipal}).then(e=>{if(typeof e!="string")throw new Error("Invalid principal received.");return Y2.Principal.fromText(e)})}readState(e,r){return this._sendAndWait({id:this._nextId++,type:Qe.ReadState,args:[e.toString(),r]})}call(e,r){return this._sendAndWait({id:this._nextId++,type:Qe.Call,args:[e.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:Qe.Status})}query(e,r){return this._sendAndWait({id:this._nextId++,type:Qe.Query,args:[e.toString(),r]})}async _sendAndWait(e){return new Promise((r,n)=>{this._pendingCalls.set(e.id,[r,n]),this._backend(e)})}async fetchRootKey(){let e=(await this.status()).root_key;return this.rootKey=e,e}};en.ProxyAgent=Ml});var _s=L(or=>{"use strict";var z2=or&&or.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),qa=or&&or.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&z2(e,t,r)};Object.defineProperty(or,"__esModule",{value:!0});or.getDefaultAgent=void 0;qa(Sc(),or);qa(Ul(),or);qa(qu(),or);qa(xp(),or);function W2(){let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.ic.agent:global.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}or.getDefaultAgent=W2});var ja=L(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.chain=yt.backoff=yt.timeout=yt.throttle=yt.maxAttempts=yt.conditionalDelay=yt.once=yt.defaultStrategy=void 0;var vp=kt(),D2=5*60*1e3;function Z2(){return Op(Ap(Tp(),1e3),Bp(1e3,1.2),Sp(D2))}yt.defaultStrategy=Z2;function Tp(){let t=!0;return async()=>t?(t=!1,!0):!1}yt.once=Tp;function Ap(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}yt.conditionalDelay=Ap;function X2(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
|
|
44
|
+
Request ID: ${(0,vp.toHex)(n)}
|
|
45
45
|
Request status: ${i}
|
|
46
|
-
`)}}yt.maxAttempts=
|
|
47
|
-
Request ID: ${(0,
|
|
46
|
+
`)}}yt.maxAttempts=X2;function J2(t){return()=>new Promise(e=>setTimeout(e,t))}yt.throttle=J2;function Sp(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
|
|
47
|
+
Request ID: ${(0,vp.toHex)(n)}
|
|
48
48
|
Request status: ${i}
|
|
49
|
-
`)}}yt.timeout=
|
|
50
|
-
Request ID: ${(0,
|
|
49
|
+
`)}}yt.timeout=Sp;function Bp(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}yt.backoff=Bp;function Op(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}yt.chain=Op});var ka=L(Gt=>{"use strict";var Q2=Gt&&Gt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),L2=Gt&&Gt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),eE=Gt&&Gt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Q2(e,t,r);return L2(e,t),e};Object.defineProperty(Gt,"__esModule",{value:!0});Gt.pollForResponse=Gt.defaultStrategy=Gt.strategy=void 0;var Bn=_s(),Ns=Ti(),Np=kt();Gt.strategy=eE(ja());var tE=ja(),rE=Ol(),nE=ja();Object.defineProperty(Gt,"defaultStrategy",{enumerable:!0,get:function(){return nE.defaultStrategy}});async function Rp(t,e,r,n=(0,tE.defaultStrategy)(),i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=t.createReadStateRequest)===null||o===void 0?void 0:o.call(t,{paths:[a]}));c.body.content.ingress_expiry=new Bn.Expiry(rE.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS);let f=await t.readState(e,{paths:[a]},void 0,c);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let d=await Ns.Certificate.create({certificate:f.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),h=(0,Ns.lookupResultToBuffer)(d.lookup([...a,new TextEncoder().encode("status")])),m;switch(typeof h>"u"?m=Bn.RequestStatusResponseStatus.Unknown:m=new TextDecoder().decode(h),m){case Bn.RequestStatusResponseStatus.Replied:return{reply:(0,Ns.lookupResultToBuffer)(d.lookup([...a,"reply"])),certificate:d};case Bn.RequestStatusResponseStatus.Received:case Bn.RequestStatusResponseStatus.Unknown:case Bn.RequestStatusResponseStatus.Processing:return await n(e,r,m),Rp(t,e,r,n,c,s);case Bn.RequestStatusResponseStatus.Rejected:{let _=new Uint8Array((0,Ns.lookupResultToBuffer)(d.lookup([...a,"reject_code"])))[0],u=new TextDecoder().decode((0,Ns.lookupResultToBuffer)(d.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
|
|
50
|
+
Request ID: ${(0,Np.toHex)(r)}
|
|
51
51
|
Reject code: ${_}
|
|
52
52
|
Reject text: ${u}
|
|
53
53
|
`)}case Bn.RequestStatusResponseStatus.Done:throw new Error(`Call was marked as done but we never saw the reply:
|
|
54
|
-
Request ID: ${(0,
|
|
55
|
-
`)}throw new Error("unreachable")}Gt.pollForResponse=
|
|
56
|
-
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}};Ke.ActorCallError=Ps;var Va=class extends Ps{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Ml.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};Ke.QueryCallRejectedError=Va;var Is=class extends Ps{constructor(e,r,n,i,s,o,a){super(e,r,"update",Object.assign({"Request ID":(0,iE.toHex)(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(s),"Reject message":o}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=o,this.error_code=a}};Ke.UpdateCallRejectedError=Is;var ar=Symbol.for("ic-agent-metadata"),Us=class t{constructor(e){this[ar]=Object.freeze(e)}static agentOf(e){return e[ar].config.agent}static interfaceOf(e){return e[ar].service}static canisterIdOf(e){return _r.Principal.from(e[ar].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?_r.Principal.fromText(r.canisterId):r.canisterId;await Cl(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,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 Cl(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:Rs.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new Ha.AgentError(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?_r.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Pp),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(Ke.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&f.annotations.push(Ke.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=oE(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Ha.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(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};Ke.Actor=Us;function Fi(t,e){let r=Rs.IDL.decode(t,nE.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Pp={pollingStrategyFactory:Rp.strategy.defaultStrategy};Ke.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";Ke.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function oE(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).queryTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,Ml.getDefaultAgent)(),h=_r.Principal.from(o.canisterId||t[ar].config.canisterId),m=Rs.IDL.encode(r.argTypes,a),_=await d.query(h,{methodName:e,arg:m,effectiveCanisterId:o.effectiveCanisterId}),u=Object.assign(Object.assign({},_.httpDetails),{requestDetails:_.requestDetails});switch(_.status){case"rejected":throw new Va(h,e,_);case"replied":return r.annotations.includes(Ke.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:u,result:Fi(r.retTypes,_.reply.arg)}:Fi(r.retTypes,_.reply.arg)}}:i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).callTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,Ml.getDefaultAgent)(),{canisterId:h,effectiveCanisterId:m,pollingStrategyFactory:_}=Object.assign(Object.assign(Object.assign({},Pp),t[ar].config),o),u=_r.Principal.from(h),T=m!==void 0?_r.Principal.from(m):u,O=Rs.IDL.encode(r.argTypes,a);if(d.rootKey==null)throw new Ha.AgentError("Agent root key not initialized before making call");let{requestId:R,response:F,requestDetails:M}=await d.call(u,{methodName:e,arg:O,effectiveCanisterId:T}),K,x;if(F.body&&F.body.certificate){let j=F.body.certificate;x=await Ui.Certificate.create({certificate:(0,Rs.bufFromBufLike)(j),rootKey:d.rootKey,canisterId:_r.Principal.from(h),blsVerify:n});let ie=[new TextEncoder().encode("request_status"),R];switch(new TextDecoder().decode((0,Ui.lookupResultToBuffer)(x.lookup([...ie,"status"])))){case"replied":K=(0,Ui.lookupResultToBuffer)(x.lookup([...ie,"reply"]));break;case"rejected":{let ne=new Uint8Array((0,Ui.lookupResultToBuffer)(x.lookup([...ie,"reject_code"])))[0],w=new TextDecoder().decode((0,Ui.lookupResultToBuffer)(x.lookup([...ie,"reject_message"]))),b=(0,Ui.lookupResultToBuffer)(x.lookup([...ie,"error_code"])),B=b?new TextDecoder().decode(b):void 0;throw new Is(u,e,R,F,ne,w,B)}}}else if(F.body&&"reject_message"in F.body){let{reject_code:j,reject_message:ie,error_code:ee}=F.body;throw new Is(u,e,R,F,j,ie,ee)}if(F.status===202){let j=_(),ie=await(0,Rp.pollForResponse)(d,T,R,j,n);x=ie.certificate,K=ie.reply}let $=r.annotations.includes(Ke.ACTOR_METHOD_WITH_HTTP_DETAILS),z=r.annotations.includes(Ke.ACTOR_METHOD_WITH_CERTIFICATE),D=Object.assign(Object.assign({},F),{requestDetails:M});if(K!==void 0)return $&&z?{httpDetails:D,certificate:x,result:Fi(r.retTypes,K)}:z?{certificate:x,result:Fi(r.retTypes,K)}:$?{httpDetails:D,result:Fi(r.retTypes,K)}:Fi(r.retTypes,K);if(r.retTypes.length===0)return $?{httpDetails:F,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),s}function Cl(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:_r.Principal.from(t.effectiveCanisterId)};let i=n[0],s=_r.Principal.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=_r.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return Us.createActor(sE.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:_r.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}Ke.getManagementCanister=Cl;var ql=class extends Us{constructor(e){super(e)}};Ke.AdvancedActor=ql});var Ip=L(jl=>{"use strict";Object.defineProperty(jl,"__esModule",{value:!0});jl.default=({IDL:t})=>t.Service({retrieve:t.Func([t.Text],[t.Vec(t.Nat8)],["query"]),store:t.Func([t.Text,t.Vec(t.Nat8)],[],[])})});var Up=L(Mi=>{"use strict";var aE=Mi&&Mi.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Mi,"__esModule",{value:!0});Mi.createAssetCanisterActor=void 0;var cE=$a(),uE=aE(Ip());function lE(t){return cE.Actor.createActor(uE.default,t)}Mi.createAssetCanisterActor=lE});var Fp=L(kr=>{"use strict";var fE=kr&&kr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),dE=kr&&kr.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),hE=kr&&kr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&fE(e,t,r);return dE(e,t),e};Object.defineProperty(kr,"__esModule",{value:!0});kr.fetchCandid=void 0;var pE=Nt(),yE=hE(ws()),gE=Pl(),mE=$a();async function bE(t,e){e||(e=await gE.HttpAgent.create());let n=(await yE.request({agent:e,canisterId:pE.Principal.fromText(t),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:o})=>o.Service({__get_candid_interface_tmp_hack:o.Func([],[o.Text],["query"])});return await mE.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}kr.fetchCandid=bE});var Xt=L(Re=>{"use strict";var Mp=Re&&Re.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),_E=Re&&Re.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ct=Re&&Re.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Mp(e,t,r)},kl=Re&&Re.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Mp(e,t,r);return _E(e,t),e};Object.defineProperty(Re,"__esModule",{value:!0});Re.Cbor=Re.CanisterStatus=Re.polling=void 0;Ct($a(),Re);Ct(_s(),Re);Ct(Yo(),Re);Ct(us(),Re);Ct(Tu(),Re);Ct(Up(),Re);Ct(Ti(),Re);Ct(vl(),Re);Ct(Fp(),Re);Ct(Tl(),Re);Ct(ss(),Re);Ct(rl(),Re);Ct(kt(),Re);Ct(Uu(),Re);Re.polling=kl(ka());Re.CanisterStatus=kl(ws());Re.Cbor=kl(cs());Ct(ka(),Re)});var gt=L((Xv,Xp)=>{"use strict";var Gl=Object.defineProperty,wE=Object.getOwnPropertyDescriptor,EE=Object.getOwnPropertyNames,xE=Object.prototype.hasOwnProperty,vE=(t,e)=>{for(var r in e)Gl(t,r,{get:e[r],enumerable:!0})},TE=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of EE(e))!xE.call(t,i)&&i!==r&&Gl(t,i,{get:()=>e[i],enumerable:!(n=wE(e,i))||n.enumerable});return t},AE=t=>TE(Gl({},"__esModule",{value:!0}),t),kp={};vE(kp,{AgentManager:()=>FE,Canister:()=>IE,FromStringToTokenError:()=>Hp,ICPToken:()=>NE,InvalidPercentageError:()=>zp,NullishError:()=>Wp,TokenAmount:()=>RE,TokenAmountV2:()=>PE,arrayBufferToUint8Array:()=>VE,arrayOfNumberToUint8Array:()=>KE,asNonNullish:()=>CE,asciiStringToByteArray:()=>GE,assertNonNullish:()=>qs,assertPercentageNumber:()=>qE,bigEndianCrc32:()=>QE,bigIntToUint8Array:()=>kE,candidNumberArrayToBigInt:()=>WE,convertStringToE8s:()=>Vp,createAgent:()=>Gp,createServices:()=>ME,debounce:()=>nx,decodeBase32:()=>ZE,defaultAgent:()=>Kp,encodeBase32:()=>DE,fromDefinedNullable:()=>sx,fromNullable:()=>Yl,fromNullishNullable:()=>ox,hexStringToUint8Array:()=>YE,isEmptyString:()=>UE,isNullish:()=>Ka,jsonReplacer:()=>ax,jsonReviver:()=>cx,nonNullish:()=>Hr,notEmptyString:()=>$p,nowInBigIntNanoSeconds:()=>rx,numberToUint8Array:()=>HE,principalToSubAccount:()=>ux,secondsToDuration:()=>ex,smallerVersion:()=>lx,toNullable:()=>ix,uint8ArrayToArrayOfNumber:()=>$E,uint8ArrayToBigInt:()=>jE,uint8ArrayToHexString:()=>zE});Xp.exports=AE(kp);var Hp=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(Hp||{}),SE=BigInt(1e8),BE=8,Vp=t=>{let e=t.includes("e")?Number(t).toLocaleString("en",{useGrouping:!1,maximumFractionDigits:20}):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=BigInt(0);if(n)try{s+=BigInt(n)*SE}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},OE=({amount:t,decimals: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=0n,o=10n**BigInt(e);if(n)try{s+=BigInt(n)*o}catch{return 1}if(i){if(i.length>e)return 2;try{s+=BigInt(i.padEnd(e,"0"))}catch{return 1}}return s},NE={symbol:"ICP",name:"Internet Computer",decimals:8},RE=class Ms{constructor(e,r){if(this.e8s=e,this.token=r,r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8")}static fromE8s({amount:e,token:r}){return new Ms(e,r)}static fromString({amount:e,token:r}){if(r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8");let n=Vp(e);return typeof n=="bigint"?new Ms(n,r):n}static fromNumber({amount:e,token:r}){let n=Ms.fromString({amount:e.toString(),token:r});if(n instanceof Ms)return n;throw n===0?new Error(`Number ${e} has more than 8 decimals`):new Error(`Invalid number ${e}`)}toE8s(){return this.e8s}},PE=class Cs{constructor(e,r){this.ulps=e,this.token=r}static fromUlps({amount:e,token:r}){return new Cs(e,r)}static fromString({amount:e,token:r}){let n=OE({amount:e,decimals:r.decimals});return typeof n=="bigint"?new Cs(n,r):n}static fromNumber({amount:e,token:r}){let n=Cs.fromString({amount:e.toFixed(Math.min(BE,r.decimals)),token:r});if(n instanceof Cs)return n;throw n===2?new Error(`Number ${e} has more than ${r.decimals} decimals`):new Error(`Invalid number ${e}`)}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)}},IE=class{constructor(t,e,r){this.id=t,this.service=e,this.certifiedService=r,this.caller=({certified:n=!0})=>n?this.certifiedService:this.service}get canisterId(){return this.id}},Cp=Xt(),Hl=Xt(),Ka=t=>t==null,Hr=t=>!Ka(t),$p=t=>Hr(t)&&t!=="",UE=t=>!$p(t),Kp=()=>Hl.HttpAgent.createSync({host:"https://icp-api.io",identity:new Hl.AnonymousIdentity}),Gp=async({identity:t,host:e,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await Hl.HttpAgent.create({identity:t,...Hr(e)&&{host:e},verifyQuerySignatures:n,...Hr(i)&&{retryTimes:i},shouldFetchRootKey:r}),FE=class Yp{constructor(e){this.config=e,this.agents=void 0}static create(e){return new Yp(e)}async getAgent({identity:e}){let r=e.getPrincipal().toText();if(Ka(this.agents)||Ka(this.agents[r])){let n=await Gp({identity:e,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}},ME=({options:{canisterId:t,serviceOverride:e,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:o,certifiedIdlFactory:a})=>{let c=n??Kp(),f=e??Cp.Actor.createActor(o,{agent:c,canisterId:t,callTransform:i,queryTransform:s}),d=r??Cp.Actor.createActor(a,{agent:c,canisterId:t,callTransform:i,queryTransform:s});return{service:f,certifiedService:d,agent:c,canisterId:t}},zp=class extends Error{},Wp=class extends Error{},qs=(t,e)=>{if(t==null)throw new Wp(e)},CE=(t,e)=>(qs(t,e),t),qE=t=>{if(t<0||t>100)throw new zp(`${t} is not a valid percentage number.`)},jE=t=>{let e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(typeof e.getBigUint64=="function")return e.getBigUint64(0);{let r=BigInt(e.getUint32(0)),n=BigInt(e.getUint32(4));return(r<<BigInt(32))+n}},kE=t=>{let e=new ArrayBuffer(8),r=new DataView(e);if(typeof r.setBigUint64=="function")r.setBigUint64(0,t);else{let n=Number(t>>BigInt(32)),i=Number(t&BigInt(4294967295));r.setUint32(0,n),r.setUint32(4,i)}return new Uint8Array(e)},HE=t=>{let e=new DataView(new ArrayBuffer(8));for(let r=7;r>=0;--r)e.setUint8(r,t%256),t=t>>8;return new Uint8Array(e.buffer)},VE=t=>new Uint8Array(t),$E=t=>Array.from(t),KE=t=>new Uint8Array(t),GE=t=>Array.from(t).map(e=>e.charCodeAt(0)),YE=t=>{let e=t.match(/.{1,2}/g);return qs(e,"Invalid hex string."),Uint8Array.from(e.map(r=>parseInt(r,16)))},zE=t=>(t instanceof Uint8Array||(t=Uint8Array.from(t)),t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")),WE=t=>{let e=0n;for(let r=t.length-1;r>=0;r--)e=(e<<32n)+BigInt(t[r]);return e},Ga="abcdefghijklmnopqrstuvwxyz234567",Ci=Object.create(null);for(let t=0;t<Ga.length;t++)Ci[Ga[t]]=t;Ci[0]=Ci.o;Ci[1]=Ci.i;var DE=t=>{let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=Ga[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Ga[r>>3]:"")};function ZE(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Ci[o.toLowerCase()];qs(a,`Invalid character: ${JSON.stringify(o)}`),a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}var XE=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]),JE=t=>{let e=-1;for(let r=0;r<t.length;r++){let n=(t[r]^e)&255;e=XE[n]^e>>>8}return(e^-1)>>>0},QE=t=>{let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,JE(t),!1),new Uint8Array(e)},LE={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"},ex=({seconds:t,i18n:e=LE})=>{let r=t/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=tx(i);return i-=Dp(s),[Fs("year",s),Fs("day",i),Fs("hour",n),Fs("minute",r),...t>BigInt(0)&&t<BigInt(60)?[Fs("second",t)]:[]].filter(({amount:o})=>o>0).slice(0,2).map(o=>`${o.amount} ${o.amount===1?e[o.labelKey]:e[`${o.labelKey}_plural`]}`).join(", ")},tx=t=>{let e=t/BigInt(365);for(;Dp(e)>t;)e--;return e},Dp=t=>{let e=t/BigInt(4);return t*BigInt(365)+e},Fs=(t,e)=>({labelKey:t,amount:Number(e)}),rx=()=>BigInt(Date.now())*BigInt(1e6),nx=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},ix=t=>Hr(t)?[t]:[],Yl=t=>t?.[0],sx=t=>{let e=Yl(t);return qs(e),e},ox=t=>Yl(t??[]),Zp=Nt(),Vl="__bigint__",$l="__principal__",Kl="__uint8array__",ax=(t,e)=>typeof e=="bigint"?{[Vl]:`${e}`}:Hr(e)&&e instanceof Zp.Principal?{[$l]:e.toText()}:Hr(e)&&e instanceof Uint8Array?{[Kl]:Array.from(e)}:e,cx=(t,e)=>{let r=n=>e[n];return Hr(e)&&typeof e=="object"&&Vl in e?BigInt(r(Vl)):Hr(e)&&typeof e=="object"&&$l in e?Zp.Principal.fromText(r($l)):Hr(e)&&typeof e=="object"&&Kl in e?Uint8Array.from(r(Kl)):e},ux=t=>{let e=t.toUint8Array(),r=new Uint8Array(32);return r[0]=e.length,r.set(e,1),r},qp=(t,e)=>e>t.length?[...t,...[...Array(e-t.length).keys()].map(()=>0)]:t,jp=t=>{if(!Number.isNaN(Number(t)))return Number(t);let e=t.split("").reduce((r,n)=>Number.isNaN(Number(n))?r:r+n,"");return Number(e)},lx=({minVersion:t,currentVersion:e})=>{let r=qp(t.split(".").map(jp),3).join(".");return qp(e.split(".").map(jp),3).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var cy=L($r=>{"use strict";var ec=$r&&$r.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},On=$r&&$r.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Qa,La,Vi,$i;Object.defineProperty($r,"__esModule",{value:!0});$r.Ed25519KeyIdentity=$r.Ed25519PublicKey=void 0;var fx=Xt(),Jt=Xt(),Hs=El();function ay(t){return t!==null&&typeof t=="object"}var Qn=class t{constructor(e){if(Qa.set(this,void 0),La.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");ec(this,Qa,e,"f"),ec(this,La,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,Jt.fromHex)(e);return this.fromRaw(r)}else if(ay(e)){let r=e;if(ay(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Jt.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(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=(0,Jt.wrapDER)(e,Jt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,Jt.unwrapDER)(e,Jt.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 On(this,Qa,"f")}get derKey(){return On(this,La,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};$r.Ed25519PublicKey=Qn;Qa=new WeakMap,La=new WeakMap;Qn.RAW_KEY_LENGTH=32;var Zl=class t extends Jt.SignIdentity{constructor(e,r){super(),Vi.set(this,void 0),$i.set(this,void 0),ec(this,Vi,Qn.from(e),"f"),ec(this,$i,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=Hs.ed25519.utils.randomPrivateKey()),(0,fx.bufEquals)(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=Hs.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(Qn.fromDer((0,Jt.fromHex)(r)),(0,Jt.fromHex)(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(Qn.fromRaw(e),r)}static fromSecretKey(e){let r=Hs.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,Jt.toHex)(On(this,Vi,"f").toDer()),(0,Jt.toHex)(On(this,$i,"f"))]}getKeyPair(){return{secretKey:On(this,$i,"f"),publicKey:On(this,Vi,"f")}}getPublicKey(){return On(this,Vi,"f")}async sign(e){let r=new Uint8Array(e),n=(0,Jt.uint8ToBuf)(Hs.ed25519.sign(r,On(this,$i,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,s,o]=[e,r,n].map(a=>(typeof a=="string"&&(a=(0,Jt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Hs.ed25519.verify(s,i,o)}};$r.Ed25519KeyIdentity=Zl;Vi=new WeakMap,$i=new WeakMap});var ly=L(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.ECDSAKeyIdentity=Ln.CryptoError=void 0;var dx=Xt(),tc=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};Ln.CryptoError=tc;function uy(t){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new tc("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 rc=class t extends dx.SignIdentity{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},s=uy(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await s.exportKey("spki",o.publicKey);return new this(o,a,s)}static async fromKeyPair(e,r){let n=uy(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};Ln.ECDSAKeyIdentity=rc;Ln.default=rc});var Jl=L(Rn=>{"use strict";var hx=Rn&&Rn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Vs=Rn&&Rn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Nn;Object.defineProperty(Rn,"__esModule",{value:!0});Rn.PartialIdentity=void 0;var px=Nt(),Xl=class{constructor(e){Nn.set(this,void 0),hx(this,Nn,e,"f")}get rawKey(){return Vs(this,Nn,"f").rawKey}get derKey(){return Vs(this,Nn,"f").derKey}toDer(){return Vs(this,Nn,"f").toDer()}getPublicKey(){return Vs(this,Nn,"f")}getPrincipal(){return px.Principal.from(Vs(this,Nn,"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.")}};Rn.PartialIdentity=Xl;Nn=new WeakMap});var fy=L(De=>{"use strict";var yx=De&&De.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),gx=De&&De.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),mx=De&&De.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&yx(e,t,r);return gx(e,t),e},bx=De&&De.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},_x=De&&De.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},wx=De&&De.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},nc;Object.defineProperty(De,"__esModule",{value:!0});De.isDelegationValid=De.PartialDelegationIdentity=De.DelegationIdentity=De.DelegationChain=De.Delegation=void 0;var Pn=Xt(),Ll=Nt(),$s=mx(as()),Ex=Jl(),xx=new TextEncoder().encode("ic-request-auth-delegation"),vx=new TextEncoder().encode(`
|
|
57
|
-
ic-request`);function Ql(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,Pn.fromHex)(t)}var Ks=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return $s.value.map(Object.assign({pubkey:$s.value.bytes(this.pubkey),expiration:$s.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:$s.value.array(this.targets.map(e=>$s.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Pn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};De.Delegation=Ks;async function Tx(t,e,r,n){let i=new Ks(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...xx,...new Uint8Array((0,Pn.requestIdOf)(i))]),o=await t.sign(s);return{delegation:i,signature:o}}var ef=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let a=await Tx(e,r,n,i.targets);return new t([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],a],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:a}=s,{pubkey:c,expiration:f,targets:d}=o;if(d!==void 0&&!Array.isArray(d))throw new Error("Invalid targets.");return{delegation:new Ks(Ql(c),BigInt("0x"+f),d&&d.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return Ll.Principal.fromHex(h)})),signature:Ql(a)}});return new this(i,Ql(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:(0,Pn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Pn.toHex)(n)}}),publicKey:(0,Pn.toHex)(this.publicKey)}}};De.DelegationChain=ef;var tf=class extends Pn.SignIdentity{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=wx(e,["body"]),i=await(0,Pn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...vx,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};De.DelegationIdentity=tf;var rf=class t extends Ex.PartialIdentity{constructor(e,r){super(e),nc.set(this,void 0),bx(this,nc,r,"f")}get delegation(){return _x(this,nc,"f")}static fromDelegation(e,r){return new t(e,r)}};De.PartialDelegationIdentity=rf;nc=new WeakMap;function Ax(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?Ll.Principal.fromText(i):i)):r.push(typeof n=="string"?Ll.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:o}of t.delegations){if(o.targets===void 0)continue;let a=!0;for(let c of o.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}De.isDelegationValid=Ax});var dy=L(In=>{"use strict";var Sx=In&&In.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(In,"__esModule",{value:!0});In.WebAuthnIdentity=In.CosePublicKey=void 0;var ei=Xt(),nf=Sx(Mo()),Bx=qn(),Ox=bi();function Nx(t){return(0,ei.wrapDER)(t,ei.DER_COSE_OID).buffer}function Rx(t){let e=new DataView(new ArrayBuffer(2)),r=t.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>e.setUint8(s,i));let n=e.getUint16(0);return t.slice(55+n)}var ic=class{constructor(e){this._cose=e,this._encodedKey=Nx(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};In.CosePublicKey=ic;function Px(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function Ix(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:Px(),pubKeyCredParams:[{type:"public-key",alg:sf.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Bx.randomBytes)(16),name:"Internet Identity",displayName:"Internet Identity"}}});return e===null?null:{id:e.id,response:e.response,type:e.type,authenticatorAttachment:e.authenticatorAttachment,getClientExtensionResults:e.getClientExtensionResults,rawId:(0,Ox.bufFromBufLike)(e.rawId)}}var sf;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(sf||(sf={}));var of=class extends ei.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new ic(r)}static fromJSON(e){let{publicKey:r,rawId:n}=JSON.parse(e);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,ei.fromHex)(n),(0,ei.fromHex)(r),void 0)}static async create(e){var r;let n=await Ix(e);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=nf.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,Rx(s.authData),(r=n.authenticatorAttachment)!==null&&r!==void 0?r:void 0)}getPublicKey(){return this._publicKey}getAuthenticatorAttachment(){return this.authenticatorAttachment}async sign(e){let r=await navigator.credentials.get({publicKey:{allowCredentials:[{type:"public-key",id:this.rawId}],challenge:e,userVerification:"preferred"}});r.authenticatorAttachment!==null&&(this.authenticatorAttachment=r.authenticatorAttachment);let n=r.response,i=nf.default.encode(new nf.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,ei.toHex)(this._publicKey.getCose()),rawId:(0,ei.toHex)(this.rawId)}}};In.WebAuthnIdentity=of});var py=L(Ge=>{"use strict";var Ux=Ge&&Ge.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),cf=Ge&&Ge.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Ux(e,t,r)};Object.defineProperty(Ge,"__esModule",{value:!0});Ge.Secp256k1KeyIdentity=Ge.ED25519_OID=Ge.DER_COSE_OID=Ge.unwrapDER=Ge.wrapDER=Ge.WebAuthnIdentity=Ge.Ed25519PublicKey=Ge.Ed25519KeyIdentity=void 0;var hy=cy();Object.defineProperty(Ge,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return hy.Ed25519KeyIdentity}});Object.defineProperty(Ge,"Ed25519PublicKey",{enumerable:!0,get:function(){return hy.Ed25519PublicKey}});cf(ly(),Ge);cf(fy(),Ge);cf(Jl(),Ge);var Fx=dy();Object.defineProperty(Ge,"WebAuthnIdentity",{enumerable:!0,get:function(){return Fx.WebAuthnIdentity}});var sc=Xt();Object.defineProperty(Ge,"wrapDER",{enumerable:!0,get:function(){return sc.wrapDER}});Object.defineProperty(Ge,"unwrapDER",{enumerable:!0,get:function(){return sc.unwrapDER}});Object.defineProperty(Ge,"DER_COSE_OID",{enumerable:!0,get:function(){return sc.DER_COSE_OID}});Object.defineProperty(Ge,"ED25519_OID",{enumerable:!0,get:function(){return sc.ED25519_OID}});var af=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};Ge.Secp256k1KeyIdentity=af});var lf=L(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});oc.IdleManager=void 0;var yy=["mousedown","mousemove","keydown","touchstart","wheel"],uf=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),yy.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let f;return(...d)=>{let h=this,m=function(){f=void 0,a.apply(h,d)};clearTimeout(f),f=window.setTimeout(m,c)}};if(e?.captureScroll){let a=o(s,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}s()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);yy.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};oc.IdleManager=uf});function Cx(){return gy||(gy=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function qx(){return my||(my=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function jx(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(cr(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&by.set(r,t)}).catch(()=>{}),pf.set(e,t),e}function kx(t){if(df.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{r(),i()},o=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});df.set(t,e)}function wy(t){hf=t(hf)}function Hx(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Gs(this),e,...r);return _y.set(n,e.sort?e.sort():[e]),cr(n)}:qx().includes(t)?function(...e){return t.apply(Gs(this),e),cr(by.get(this))}:function(...e){return cr(t.apply(Gs(this),e))}}function Vx(t){return typeof t=="function"?Hx(t):(t instanceof IDBTransaction&&kx(t),Mx(t,Cx())?new Proxy(t,hf):t)}function cr(t){if(t instanceof IDBRequest)return jx(t);if(ff.has(t))return ff.get(t);let e=Vx(t);return e!==t&&(ff.set(t,e),pf.set(e,t)),e}var Mx,gy,my,by,df,_y,ff,pf,hf,Gs,yf=Uf(()=>{Mx=(t,e)=>e.some(r=>t instanceof r);by=new WeakMap,df=new WeakMap,_y=new WeakMap,ff=new WeakMap,pf=new WeakMap;hf={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return df.get(t);if(e==="objectStoreNames")return t.objectStoreNames||_y.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return cr(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};Gs=t=>pf.get(t)});var xy={};Vg(xy,{deleteDB:()=>Kx,openDB:()=>$x,unwrap:()=>Gs,wrap:()=>cr});function $x(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=cr(o);return n&&o.addEventListener("upgradeneeded",c=>{n(cr(o.result),c.oldVersion,c.newVersion,cr(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),a}function Kx(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),cr(r).then(()=>{})}function Ey(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(gf.get(e))return gf.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=Yx.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||Gx.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),f=c.store;return n&&(f=f.index(a.shift())),(await Promise.all([f[r](...a),i&&c.done]))[0]};return gf.set(e,s),s}var Gx,Yx,gf,vy=Uf(()=>{yf();yf();Gx=["get","getKey","getAll","getAllKeys","count"],Yx=["put","add","delete","clear"],gf=new Map;wy(t=>({...t,get:(e,r,n)=>Ey(e,r)||t.get(e,r,n),has:(e,r)=>!!Ey(e,r)||t.has(e,r)}))});var bf=L(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});ac.IdbKeyVal=void 0;var zx=(vy(),$g(xy)),Ys=cc(),Ty="auth-client-db",Ay="ic-keyval",Wx=async(t=Ty,e=Ay,r)=>(Ys.isBrowser&&(localStorage!=null&&localStorage.getItem(Ys.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Ys.KEY_STORAGE_DELEGATION),localStorage.removeItem(Ys.KEY_STORAGE_KEY)),await(0,zx.openDB)(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function Dx(t,e,r){return await t.get(e,r)}async function Zx(t,e,r,n){return await t.put(e,n,r)}async function Xx(t,e,r){return await t.delete(e,r)}var mf=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=Ty,storeName:n=Ay,version:i=Ys.DB_VERSION}=e??{},s=await Wx(r,n,i);return new t(s,n)}async set(e,r){return await Zx(this._db,this._storeName,e,r)}async get(e){var r;return(r=await Dx(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await Xx(this._db,this._storeName,e)}};ac.IdbKeyVal=mf});var cc=L(nt=>{"use strict";var Jx=nt&&nt.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Qx=nt&&nt.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},uc;Object.defineProperty(nt,"__esModule",{value:!0});nt.IdbStorage=nt.LocalStorage=nt.isBrowser=nt.DB_VERSION=nt.KEY_VECTOR=nt.KEY_STORAGE_DELEGATION=nt.KEY_STORAGE_KEY=void 0;var Lx=bf();nt.KEY_STORAGE_KEY="identity";nt.KEY_STORAGE_DELEGATION="delegation";nt.KEY_VECTOR="iv";nt.DB_VERSION=1;nt.isBrowser=typeof window<"u";var _f=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}};nt.LocalStorage=_f;var wf=class{constructor(e){uc.set(this,void 0),Jx(this,uc,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}Lx.IdbKeyVal.create(Qx(this,uc,"f")).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};nt.IdbStorage=wf;uc=new WeakMap});var Oy=L(Le=>{"use strict";var e8=Le&&Le.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),t8=Le&&Le.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&e8(e,t,r)};Object.defineProperty(Le,"__esModule",{value:!0});Le.AuthClient=Le.ERROR_USER_INTERRUPT=Le.IdbKeyVal=Le.KEY_STORAGE_KEY=Le.KEY_STORAGE_DELEGATION=Le.LocalStorage=Le.IdbStorage=void 0;var Sy=Xt(),Qt=py(),By=lf(),xt=cc(),lc=cc();Object.defineProperty(Le,"IdbStorage",{enumerable:!0,get:function(){return lc.IdbStorage}});Object.defineProperty(Le,"LocalStorage",{enumerable:!0,get:function(){return lc.LocalStorage}});Object.defineProperty(Le,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return lc.KEY_STORAGE_DELEGATION}});Object.defineProperty(Le,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return lc.KEY_STORAGE_KEY}});var r8=bf();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return r8.IdbKeyVal}});var n8="https://identity.ic0.app",i8="#authorize",Ef="ECDSA",xf="Ed25519",s8=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";t8(lf(),Le);var Tf=class{constructor(e,r,n,i,s,o,a,c){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let s=(r=e.storage)!==null&&r!==void 0?r:new xt.IdbStorage,o=(n=e.keyType)!==null&&n!==void 0?n:Ef,a=null;if(e.identity)a=e.identity;else{let h=await s.get(xt.KEY_STORAGE_KEY);if(!h&&xt.isBrowser)try{let m=new xt.LocalStorage,_=await m.get(xt.KEY_STORAGE_DELEGATION),u=await m.get(xt.KEY_STORAGE_KEY);_&&u&&o===Ef&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(xt.KEY_STORAGE_DELEGATION,_),await s.set(xt.KEY_STORAGE_KEY,u),h=_,await m.remove(xt.KEY_STORAGE_DELEGATION),await m.remove(xt.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(h)try{typeof h=="object"?o===xf&&typeof h=="string"?a=await Qt.Ed25519KeyIdentity.fromJSON(h):a=await Qt.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=Qt.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new Sy.AnonymousIdentity,f=null;if(a)try{let h=await s.get(xt.KEY_STORAGE_DELEGATION);if(typeof h=="object"&&h!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:h&&(f=Qt.DelegationChain.fromJSON(h),(0,Qt.isDelegationValid)(f)?"toDer"in a?c=Qt.PartialDelegationIdentity.fromDelegation(a,f):c=Qt.DelegationIdentity.fromDelegation(a,f):(await vf(s),a=null))}catch(h){console.error(h),await vf(s),a=null}let d;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?d=void 0:(f||e.identity)&&(d=By.IdleManager.create(e.idleOptions)),a||(o===xf?(a=await Qt.Ed25519KeyIdentity.generate(),await s.set(xt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===Ef&&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 '${xf}' as the key type, as it can serialize to a string`),a=await Qt.ECDSAKeyIdentity.generate(),await s.set(xt.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,f,s,d,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let s=e.delegations.map(f=>({delegation:new Qt.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=Qt.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=Qt.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=Qt.DelegationIdentity.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=By.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(xt.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,s;let o=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||n8);a.hash=i8,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:o},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Le.ERROR_USER_INTERRUPT,e?.onError):setTimeout(c,s8))};c()}_getEventHandler(e,r){return async n=>{var i,s,o;if(n.origin!==e.origin){console.warn(`WARNING: expected origin '${e.origin}', got '${n.origin}' (ignoring)`);return}let a=n.data;switch(a.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await vf(this._storage),this._identity=new Sy.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Le.AuthClient=Tf;async function vf(t){await t.remove(xt.KEY_STORAGE_KEY),await t.remove(xt.KEY_STORAGE_DELEGATION),await t.remove(xt.KEY_VECTOR)}});var pg=Xe(gt(),1);var Qy=Xe(gt(),1);var qi=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var en=class t extends qi{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var zl=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var Jy=Xe(gt(),1);var Jp=BigInt(144e11),Qp=!1,Lp={width:576,height:576},ey={width:505,height:705},ty="internetcomputer.org";var js=Xe(gt(),1);var ji="http://127.0.0.1:5987",ry="rdmx6-jaaaa-aaaaa-aaadq-cai";var Vr=class t extends qi{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var Wl=Xe(gt(),1);var Ya=Xe(gt(),1),ny=async t=>{let e=new Blob([JSON.stringify(t,Ya.jsonReplacer)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},za=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),Ya.jsonReviver)},Wa=()=>typeof window<"u";var Dl=({width:t,height:e})=>{if(!Wa()||(0,Wl.isNullish)(window)||(0,Wl.isNullish)(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,s=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${s}`};var Da=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=Vr.getInstance().get()?.container;if((0,js.isNullish)(n)||n===!1)return`https://identity.${this.#e??ty}`;let i=Vr.getInstance().get(),s=(0,js.nonNullish)(i)&&(0,js.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:ry,{host:o,protocol:a}=new URL(n===!0?ji:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Dl(Lp)},identityProvider:r()}}},iy=class{#e;#t;constructor({appName:e,logoUrl:r}){this.#e=e,this.#t=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:Dl(ey)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var oy=Xe(Xt(),1),Za=Xe(gt(),1);var sy=Xe(Xt(),1),Jn=Xe(gt(),1);var ki=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,Jn.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...r}){let n=e.getPrincipal().toText();if((0,Jn.isNullish)(this.#e)||(0,Jn.isNullish)(this.#e[n])){let i=await this.createAgent({identity:e,...r});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}async createAgent({identity:e,fetch:r,container:n}){let s=(0,Jn.nonNullish)(n)&&n!==!1?n===!0?ji:n:"https://icp-api.io",o=(0,Jn.nonNullish)(n);return await sy.HttpAgent.create({identity:e,shouldFetchRootKey:o,host:s,...r&&{fetch:r}})}};var Hi=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,Za.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:r,buildType:n,...i}){let s=`${n}#${r.getPrincipal().toText()}#${e};`;if((0,Za.isNullish)(this.#e)||(0,Za.isNullish)(this.#e[s])){let o=await this.createActor({satelliteId:e,identity:r,...i});return this.#e={...this.#e??{},[s]:o},o}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:e,satelliteId:r,...n}){let i=await ki.getInstance().getAgent(n);return oy.Actor.createActor(e,{agent:i,canisterId:r})}};var ks=class extends Error{},Xa=class extends Error{},Ja=class extends Error{};var Ny=Xe(Oy(),1),Af=()=>Ny.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Rf=Xe(gt(),1);var wr=Xe(gt(),1);var Ry=async({data:t})=>{try{return await za(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var ti=Xe(gt(),1);var Sf=async t=>{let{data:e,version:r,description:n}=t;return{description:(0,ti.toNullable)(n),data:await ny(e),version:(0,ti.toNullable)(r)}},Bf=t=>{let{version:e}=t;return{version:(0,ti.toNullable)(e)}},zs=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:(0,ti.fromNullable)(i),owner:r.toText(),data:await za(s),version:(0,ti.fromNullable)(n),...o}};var Iy=Xe(Nt(),1),it=Xe(gt(),1);var Py=t=>{if((0,it.isNullish)(t))return(0,it.toNullable)();switch(t.matcher){case"equal":return(0,it.toNullable)({Equal:t.timestamp});case"greaterThan":return(0,it.toNullable)({GreaterThan:t.timestamp});case"lessThan":return(0,it.toNullable)({LessThan:t.timestamp});case"between":return(0,it.toNullable)({Between:[t.timestamps.start,t.timestamps.end]});default:throw new Ja("Invalid list matcher for timestamp",t)}},Un=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:(0,it.isNullish)(t)?[]:[{key:(0,it.toNullable)(t.key),description:(0,it.toNullable)(t.description),created_at:Py(t.createdAt),updated_at:Py(t.updatedAt)}],paginate:(0,it.toNullable)((0,it.isNullish)(e)?void 0:{start_after:(0,it.toNullable)(e.startAfter),limit:(0,it.toNullable)((0,it.isNullish)(e.limit)?void 0:BigInt(e.limit))}),order:(0,it.toNullable)((0,it.isNullish)(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:(0,it.toNullable)((0,it.isNullish)(n)?void 0:typeof n=="string"?Iy.Principal.fromText(n):n)});var My=Xe(gt(),1);var Uy=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:r,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),s=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),o=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),a=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(o)}),c=t.Record({controllers:t.Vec(t.Principal)}),f=t.Variant({Write:t.Null,Admin:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:f,expires_at:t.Opt(t.Nat64)}),h=t.Record({version:t.Opt(t.Nat64)}),m=t.Variant({Db:t.Null,Storage:t.Null}),_=t.Record({version:t.Opt(t.Nat64)}),u=t.Record({cycles:t.Nat,destination_id:t.Principal}),T=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),O=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),R=t.Record({key:T,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,O)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),F=t.Record({derivation_origin:t.Opt(t.Text)}),M=t.Record({internet_identity:t.Opt(F)}),K=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),x=t.Record({max_memory_size:t.Opt(K)}),$=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),z=t.Variant({Deny:t.Null,Allow:t.Null}),D=t.Record({status_code:t.Nat16,location:t.Text}),j=t.Record({iframe:t.Opt($),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(K),raw_access:t.Opt(z),redirects:t.Opt(t.Vec(t.Tuple(t.Text,D)))}),ie=t.Record({db:t.Opt(x),authentication:t.Opt(M),storage:j}),ee=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),ne=t.Variant({Heap:t.Null,Stable:t.Null}),w=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),b=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),B=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ne),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:w,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(b),write:w}),S=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),N=t.Record({memory:ne,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),H=t.Variant({Callback:t.Record({token:N,callback:t.Func([],[],["query"])})}),Z=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(H),status_code:t.Nat16}),ae=t.Record({token:t.Opt(N),body:t.Vec(t.Nat8)}),oe=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),W=t.Record({batch_id:t.Nat}),U=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,R)),items_length:t.Nat64}),p=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),J=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,ee)),items_length:t.Nat64}),re=t.Record({stable:t.Nat64,heap:t.Nat64}),fe=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:f,expires_at:t.Opt(t.Nat64)}),Q=t.Record({controller:fe,controllers:t.Vec(t.Principal)}),l=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),y=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ne),max_size:t.Opt(t.Nat),read:w,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(b),write:w}),g=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),P=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,a],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,a],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([c],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,h],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,a],[],[]),del_filtered_docs:t.Func([t.Text,a],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,h))],[],[]),del_rule:t.Func([m,t.Text,_],[],[]),deposit_cycles:t.Func([u],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(R)],["query"]),get_auth_config:t.Func([],[t.Opt(M)],["query"]),get_config:t.Func([],[ie],[]),get_db_config:t.Func([],[t.Opt(x)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(ee)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(R)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(ee)))],["query"]),get_rule:t.Func([m,t.Text],[t.Opt(B)],["query"]),get_storage_config:t.Func([],[j],["query"]),http_request:t.Func([S],[Z],["query"]),http_request_streaming_callback:t.Func([N],[ae],["query"]),init_asset_upload:t.Func([oe],[W],[]),list_assets:t.Func([t.Text,a],[U],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,p))],["query"]),list_docs:t.Func([t.Text,a],[J],["query"]),list_rules:t.Func([m],[t.Vec(t.Tuple(t.Text,B))],["query"]),memory_size:t.Func([],[re],["query"]),set_auth_config:t.Func([M],[],[]),set_controllers:t.Func([Q],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([x],[],[]),set_doc:t.Func([t.Text,t.Text,l],[ee],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,l))],[t.Vec(t.Tuple(t.Text,ee))],[]),set_rule:t.Func([m,t.Text,y],[B],[]),set_storage_config:t.Func([j],[],[]),upload_asset_chunk:t.Func([g],[P],[]),version:t.Func([],[t.Text],["query"])})};var fc=Xe(gt(),1);var Fy=({satelliteId:t,container:e})=>{let{satelliteId:r}=Of({satelliteId:t}),{container:n}=Nf({container:e});if((0,fc.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`},Of=({satelliteId:t})=>(0,fc.nonNullish)(t)?{satelliteId:t}:Vr.getInstance().get()??{satelliteId:void 0},Nf=({container:t})=>(0,fc.nonNullish)(t)?{container:t}:Vr.getInstance().get()??{container:void 0};var ut=t=>qy({idlFactory:Uy,buildType:"stock",...t}),Cy=({idlFactory:t,...e})=>qy({idlFactory:t,buildType:"extended",...e}),qy=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Of({satelliteId:t});(0,My.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Nf({container:e});return await Hi.getInstance().getActor({satelliteId:n,container:i,...r})};var jy=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await ut(r),i=(0,wr.fromNullable)(await n(t,e));if(!(0,wr.isNullish)(i))return zs({doc:i,key:e})},ky=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await ut(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=(0,wr.fromNullable)(a);s.push((0,wr.nonNullish)(c)?await zs({key:o,doc:c}):void 0)}return s},Hy=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await ut(r),{key:i}=e,s=await Sf(e),o=await n(t,i,s);return await zs({key:i,doc:o})},Vy=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await ut(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await Sf(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await zs({key:o,doc:a}));return s},$y=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await ut(r),{key:i}=e;return n(t,i,Bf(e))},Ky=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await ut(e),n=t.map(({collection:i,doc:s})=>[i,s.key,Bf(s)]);await r(n)},Gy=async({collection:t,filter:e,satellite:r})=>{let{del_filtered_docs:n}=await ut(r);return n(t,Un(e))},Yy=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await ut(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(t,Un(e)),f=[];for(let[d,h]of i){let{data:m,owner:_,description:u,version:T,...O}=h;f.push({key:d,description:(0,wr.fromNullable)(u),owner:_.toText(),data:await Ry({data:m}),version:(0,wr.fromNullable)(T),...O})}return{items:f,items_length:o,items_page:(0,wr.fromNullable)(s),matches_length:a,matches_pages:(0,wr.fromNullable)(c)}},zy=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await ut(r);return n(t,Un(e))};var Wy=Xe(Xt(),1);var et=t=>t!==void 0?t:dc()??new Wy.AnonymousIdentity;var Dy=async({satellite:t,...e})=>{let r=et(t?.identity);return await jy({...e,satellite:{...t,identity:r}})},i6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ky({...e,satellite:{...t,identity:r}})},Zy=async({satellite:t,...e})=>{let r=et(t?.identity);return await Hy({...e,satellite:{...t,identity:r}})},s6=async({satellite:t,...e})=>{let r=et(t?.identity);return await Vy({...e,satellite:{...t,identity:r}})},o6=async({satellite:t,...e})=>{let r=et(t?.identity);return await $y({...e,satellite:{...t,identity:r}})},a6=async({satellite:t,...e})=>{let r=et(t?.identity);return await Ky({...e,satellite:{...t,identity:r}})},c6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await Gy({...r,filter:e??{},satellite:{...t,identity:n}})},u6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await Yy({...r,filter:e??{},satellite:{...t,identity:n}})},l6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await zy({...r,filter:e??{},satellite:{...t,identity:n}})};var Xy=async t=>{let e=dc();if((0,Rf.isNullish)(e))throw new Xa("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await Dy({collection:"#user",key:r});return(0,Rf.isNullish)(n)?await o8({userId:r,provider:t}):n},o8=({userId:t,...e})=>Zy({collection:"#user",doc:{key:t,data:e}});var tn,Pf=async t=>{if(tn=tn??await Af(),!(await tn?.isAuthenticated()??!1))return;let r=await Xy(t);en.getInstance().set(r)},a8=t=>new Promise(async(e,r)=>{if((0,Jy.isNullish)(tn)){r(new ks("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=t?.provider??new Da({});await tn.login({onSuccess:async()=>{await Pf(n.id),e()},onError:i=>r(new ks(i)),maxTimeToLive:t?.maxTimeToLive??Jp,allowPinAuthentication:t?.allowPin??Qp,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),If=async()=>{await tn?.logout(),tn=void 0,en.getInstance().reset(),Hi.getInstance().reset(),ki.getInstance().reset()},dc=()=>tn?.getIdentity(),c8=async()=>(tn??await Af()).getIdentity();var Ly=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{zl({message:"junoSignOutAuthTimer"}),await If()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":zl({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},en.getInstance().subscribe(i=>{if((0,Qy.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var eg=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},tg=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var I6=async({idlFactory:t,satellite:e})=>{let r=et(e?.identity);return await Cy({idlFactory:t,...e,identity:r})};var Zs=Xe(gt(),1);var Ds=Xe(gt(),1);var Ws=Xe(gt(),1);var rg=async({asset:{data:t,filename:e,collection:r,headers:n,token:i,fullPath:s,encoding:o,description:a},actor:c,init_asset_upload:f})=>{let{batch_id:d}=await f({collection:r,full_path:s,name:e,token:(0,Ws.toNullable)(i),encoding_type:(0,Ws.toNullable)(o),description:(0,Ws.toNullable)(a)}),h=19e5,m=[],_=Wa()?new Blob([await t.arrayBuffer()]):t,u=0n;for(let R=0;R<_.size;R+=h){let F=_.slice(R,R+h);m.push({batchId:d,chunk:F,actor:c,orderId:u}),u++}let T=[];for await(let R of u8({uploadChunks:m}))T=[...T,...R];let O=n.find(([R,F])=>R.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await c.commit_asset_upload({batch_id:d,chunk_ids:T.map(({chunk_id:R})=>R),headers:[...n,...O||[]]})};async function*u8({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(i=>l8(i)))}}var l8=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:(0,Ws.toNullable)(n)});var ng=async({satellite:t,...e})=>{let r=await ut(t);await rg({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},ig=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await ut(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(t,Un(r));return{items:i.map(([f,d])=>d),items_length:s,items_page:(0,Ds.fromNullable)(o),matches_length:a,matches_pages:(0,Ds.fromNullable)(c)}},sg=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await ut(e);return n(t,Un(r))},og=async({collection:t,fullPath:e,satellite:r})=>(await ut(r)).del_asset(t,e),ag=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await ut(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},cg=async({collection:t,satellite:e,filter:r})=>{let{del_filtered_assets:n}=await ut(e);return n(t,Un(r))},ug=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await ut(r);return(0,Ds.fromNullable)(await n(t,e))},lg=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await ut(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>(0,Ds.fromNullable)(o))};var fg=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Y6=t=>dg(t),z6=t=>dg({filename:t.data.name,...t}),dg=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let f=et(o?.identity),d=decodeURI(t),h=i??`/${r}/${d}`,m={...o,identity:f};return await ng({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:m,description:c}),{downloadUrl:hg({satellite:m,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},W6=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)},{items:i,...s}=await ig({collection:t,satellite:n,filter:r??{}}),o=i.map(({key:{full_path:a,token:c,name:f,owner:d,description:h},headers:m,encodings:_,created_at:u,updated_at:T})=>{let O=(0,Zs.fromNullable)(c);return{fullPath:a,description:(0,Zs.fromNullable)(h),name:f,downloadUrl:hg({satellite:n,assetKey:{fullPath:a,token:O}}),token:O,headers:m,encodings:_.reduce((R,[F,{modified:M,sha256:K,total_length:x}])=>({...R,[F]:{modified:M,sha256:fg(K),total_length:x}}),{}),owner:d.toText(),created_at:u,updated_at:T}});return{items:o,assets:o,...s}},D6=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await sg({collection:t,satellite:n,filter:r??{}})},Z6=({collection:t,fullPath:e,satellite:r})=>og({collection:t,fullPath:e,satellite:{...r,identity:et(r?.identity)}}),X6=({assets:t,satellite:e})=>ag({assets:t,satellite:{...e,identity:et(e?.identity)}}),J6=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await cg({collection:t,satellite:n,filter:r??{}})},Q6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ug({...e,satellite:{...t,identity:r}})},L6=async({satellite:t,...e})=>{let r=et(t?.identity);return await lg({...e,satellite:{...t,identity:r}})},hg=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${Fy(n)}${t}${(0,Zs.nonNullish)(e)?`?token=${e}`:""}`};var f8=t=>{let e=t?.satelliteId??eg();(0,pg.assertNonNullish)(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??tg();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},o5=t=>d8(t),d8=async t=>{let e=f8(t);Vr.getInstance().set(e),await Pf();let r=e.workers?.auth!==void 0?Ly(e.workers.auth):void 0;return[...r?[r]:[]]},a5=t=>en.getInstance().subscribe(t);export{Xa as InitError,Da as InternetIdentityProvider,Ja as ListError,iy as NFIDProvider,ks as SignInError,a5 as authSubscribe,D6 as countAssets,l6 as countDocs,Z6 as deleteAsset,o6 as deleteDoc,J6 as deleteFilteredAssets,c6 as deleteFilteredDocs,X6 as deleteManyAssets,a6 as deleteManyDocs,hg as downloadUrl,Q6 as getAsset,Dy as getDoc,L6 as getManyAssets,i6 as getManyDocs,I6 as getSatelliteExtendedActor,o5 as initJuno,d8 as initSatellite,W6 as listAssets,u6 as listDocs,Zy as setDoc,s6 as setManyDocs,a8 as signIn,If as signOut,c8 as unsafeIdentity,Y6 as uploadBlob,z6 as uploadFile};
|
|
54
|
+
Request ID: ${(0,Np.toHex)(r)}
|
|
55
|
+
`)}throw new Error("unreachable")}Gt.pollForResponse=Rp});var Pp=L(Cl=>{"use strict";Object.defineProperty(Cl,"__esModule",{value:!0});Cl.default=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=i,o=t.Record({network:e}),a=t.Nat64,c=t.Vec(a),f=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),d=t.Vec(t.Nat8),h=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),m=t.Record({height:t.Nat32,value:i,outpoint:h}),_=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:d,utxos:t.Vec(m)}),u=t.Record({transaction:t.Vec(t.Nat8),network:e}),T=t.Principal,O=t.Record({canister_id:T,num_requested_changes:t.Opt(t.Nat64)}),R=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),F=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),M=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:R,details:F}),K=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(M),total_num_changes:t.Nat64}),x=t.Record({canister_id:T}),$=t.Variant({controllers:t.Null,public:t.Null}),z=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:$,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),D=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:z,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),j=t.Record({canister_id:T}),ie=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt($),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),ee=t.Record({settings:t.Opt(ie),sender_canister_version:t.Opt(t.Nat64)}),ne=t.Record({canister_id:T}),w=t.Record({canister_id:T}),b=t.Record({canister_id:T}),B=t.Variant({secp256k1:t.Null}),S=t.Record({key_id:t.Record({name:t.Text,curve:B}),canister_id:t.Opt(T),derivation_path:t.Vec(t.Vec(t.Nat8))}),N=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),H=t.Record({canister_id:T}),Z=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),ae=t.Record({canister_log_records:t.Vec(Z)}),oe=t.Record({value:t.Text,name:t.Text}),W=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(oe)}),U=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:W})],[W],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(oe)}),p=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),J=t.Record({hash:t.Vec(t.Nat8)}),re=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:p,chunk_hashes_list:t.Vec(J),target_canister:T,store_canister:t.Opt(T),sender_canister_version:t.Opt(t.Nat64)}),fe=t.Vec(t.Nat8),Q=t.Record({arg:t.Vec(t.Nat8),wasm_module:fe,mode:p,canister_id:T,sender_canister_version:t.Opt(t.Nat64)}),l=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),y=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),g=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(y)})),P=t.Record({settings:t.Opt(ie),specified_id:t.Opt(T),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),A=t.Record({canister_id:T}),I=t.Record({canister_id:T,amount:t.Nat}),k=t.Vec(t.Nat8),E=t.Variant({ed25519:t.Null,bip340secp256k1:t.Null}),C=t.Record({key_id:t.Record({algorithm:E,name:t.Text}),canister_id:t.Opt(T),derivation_path:t.Vec(t.Vec(t.Nat8))}),V=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),q=t.Record({key_id:t.Record({name:t.Text,curve:B}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),X=t.Record({signature:t.Vec(t.Nat8)}),te=t.Record({key_id:t.Record({algorithm:E,name:t.Text}),derivation_path:t.Vec(t.Vec(t.Nat8)),message:t.Vec(t.Nat8)}),de=t.Record({signature:t.Vec(t.Nat8)}),_e=t.Record({canister_id:T}),Fe=t.Record({canister_id:T}),Ve=t.Record({canister_id:T}),me=t.Vec(J),he=t.Record({canister_id:T,sender_canister_version:t.Opt(t.Nat64)}),Xe=t.Record({canister_id:t.Principal,settings:ie,sender_canister_version:t.Opt(t.Nat64)}),Er=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),Gr=J;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_current_fee_percentiles:t.Func([o],[c],[]),bitcoin_get_utxos:t.Func([f],[_],[]),bitcoin_send_transaction:t.Func([u],[],[]),canister_info:t.Func([O],[K],[]),canister_status:t.Func([x],[D],[]),clear_chunk_store:t.Func([j],[],[]),create_canister:t.Func([ee],[ne],[]),delete_canister:t.Func([w],[],[]),deposit_cycles:t.Func([b],[],[]),ecdsa_public_key:t.Func([S],[N],[]),fetch_canister_logs:t.Func([H],[ae],["query"]),http_request:t.Func([U],[W],[]),install_chunked_code:t.Func([re],[],[]),install_code:t.Func([Q],[],[]),node_metrics_history:t.Func([l],[g],[]),provisional_create_canister_with_cycles:t.Func([P],[A],[]),provisional_top_up_canister:t.Func([I],[],[]),raw_rand:t.Func([],[k],[]),schnorr_public_key:t.Func([C],[V],[]),sign_with_ecdsa:t.Func([q],[X],[]),sign_with_schnorr:t.Func([te],[de],[]),start_canister:t.Func([_e],[],[]),stop_canister:t.Func([Fe],[],[]),stored_chunks:t.Func([Ve],[me],[]),uninstall_code:t.Func([he],[],[]),update_settings:t.Func([Xe],[],[]),upload_chunk:t.Func([Er],[Gr],[])})}});var $a=L(Ke=>{"use strict";var iE=Ke&&Ke.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ke,"__esModule",{value:!0});Ke.AdvancedActor=Ke.getManagementCanister=Ke.ACTOR_METHOD_WITH_CERTIFICATE=Ke.ACTOR_METHOD_WITH_HTTP_DETAILS=Ke.Actor=Ke.UpdateCallRejectedError=Ke.QueryCallRejectedError=Ke.ActorCallError=void 0;var sE=rd(),ql=_s(),Ha=fi(),Rs=bi(),Ip=ka(),_r=Nt(),oE=kt(),Ui=Ti(),aE=iE(Pp()),Ps=class extends Ha.AgentError{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
|
|
56
|
+
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}};Ke.ActorCallError=Ps;var Va=class extends Ps{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=ql.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};Ke.QueryCallRejectedError=Va;var Is=class extends Ps{constructor(e,r,n,i,s,o,a){super(e,r,"update",Object.assign({"Request ID":(0,oE.toHex)(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(s),"Reject message":o}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=o,this.error_code=a}};Ke.UpdateCallRejectedError=Is;var ar=Symbol.for("ic-agent-metadata"),Us=class t{constructor(e){this[ar]=Object.freeze(e)}static agentOf(e){return e[ar].config.agent}static interfaceOf(e){return e[ar].service}static canisterIdOf(e){return _r.Principal.from(e[ar].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?_r.Principal.fromText(r.canisterId):r.canisterId;await jl(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,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 jl(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:Rs.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new Ha.AgentError(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?_r.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Up),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(Ke.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&f.annotations.push(Ke.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=cE(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Ha.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(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};Ke.Actor=Us;function Fi(t,e){let r=Rs.IDL.decode(t,sE.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Up={pollingStrategyFactory:Ip.strategy.defaultStrategy};Ke.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";Ke.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function cE(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).queryTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,ql.getDefaultAgent)(),h=_r.Principal.from(o.canisterId||t[ar].config.canisterId),m=Rs.IDL.encode(r.argTypes,a),_=await d.query(h,{methodName:e,arg:m,effectiveCanisterId:o.effectiveCanisterId}),u=Object.assign(Object.assign({},_.httpDetails),{requestDetails:_.requestDetails});switch(_.status){case"rejected":throw new Va(h,e,_);case"replied":return r.annotations.includes(Ke.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:u,result:Fi(r.retTypes,_.reply.arg)}:Fi(r.retTypes,_.reply.arg)}}:i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).callTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,ql.getDefaultAgent)(),{canisterId:h,effectiveCanisterId:m,pollingStrategyFactory:_}=Object.assign(Object.assign(Object.assign({},Up),t[ar].config),o),u=_r.Principal.from(h),T=m!==void 0?_r.Principal.from(m):u,O=Rs.IDL.encode(r.argTypes,a);if(d.rootKey==null)throw new Ha.AgentError("Agent root key not initialized before making call");let{requestId:R,response:F,requestDetails:M}=await d.call(u,{methodName:e,arg:O,effectiveCanisterId:T}),K,x;if(F.body&&F.body.certificate){let j=F.body.certificate;x=await Ui.Certificate.create({certificate:(0,Rs.bufFromBufLike)(j),rootKey:d.rootKey,canisterId:_r.Principal.from(h),blsVerify:n});let ie=[new TextEncoder().encode("request_status"),R];switch(new TextDecoder().decode((0,Ui.lookupResultToBuffer)(x.lookup([...ie,"status"])))){case"replied":K=(0,Ui.lookupResultToBuffer)(x.lookup([...ie,"reply"]));break;case"rejected":{let ne=new Uint8Array((0,Ui.lookupResultToBuffer)(x.lookup([...ie,"reject_code"])))[0],w=new TextDecoder().decode((0,Ui.lookupResultToBuffer)(x.lookup([...ie,"reject_message"]))),b=(0,Ui.lookupResultToBuffer)(x.lookup([...ie,"error_code"])),B=b?new TextDecoder().decode(b):void 0;throw new Is(u,e,R,F,ne,w,B)}}}else if(F.body&&"reject_message"in F.body){let{reject_code:j,reject_message:ie,error_code:ee}=F.body;throw new Is(u,e,R,F,j,ie,ee)}if(F.status===202){let j=_(),ie=await(0,Ip.pollForResponse)(d,T,R,j,n);x=ie.certificate,K=ie.reply}let $=r.annotations.includes(Ke.ACTOR_METHOD_WITH_HTTP_DETAILS),z=r.annotations.includes(Ke.ACTOR_METHOD_WITH_CERTIFICATE),D=Object.assign(Object.assign({},F),{requestDetails:M});if(K!==void 0)return $&&z?{httpDetails:D,certificate:x,result:Fi(r.retTypes,K)}:z?{certificate:x,result:Fi(r.retTypes,K)}:$?{httpDetails:D,result:Fi(r.retTypes,K)}:Fi(r.retTypes,K);if(r.retTypes.length===0)return $?{httpDetails:F,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),s}function jl(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:_r.Principal.from(t.effectiveCanisterId)};let i=n[0],s=_r.Principal.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=_r.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return Us.createActor(aE.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:_r.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}Ke.getManagementCanister=jl;var kl=class extends Us{constructor(e){super(e)}};Ke.AdvancedActor=kl});var Fp=L(Hl=>{"use strict";Object.defineProperty(Hl,"__esModule",{value:!0});Hl.default=({IDL:t})=>t.Service({retrieve:t.Func([t.Text],[t.Vec(t.Nat8)],["query"]),store:t.Func([t.Text,t.Vec(t.Nat8)],[],[])})});var Mp=L(Mi=>{"use strict";var uE=Mi&&Mi.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Mi,"__esModule",{value:!0});Mi.createAssetCanisterActor=void 0;var lE=$a(),fE=uE(Fp());function dE(t){return lE.Actor.createActor(fE.default,t)}Mi.createAssetCanisterActor=dE});var Cp=L(kr=>{"use strict";var hE=kr&&kr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),pE=kr&&kr.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),yE=kr&&kr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&hE(e,t,r);return pE(e,t),e};Object.defineProperty(kr,"__esModule",{value:!0});kr.fetchCandid=void 0;var gE=Nt(),mE=yE(ws()),bE=Ul(),_E=$a();async function wE(t,e){e||(e=await bE.HttpAgent.create());let n=(await mE.request({agent:e,canisterId:gE.Principal.fromText(t),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:o})=>o.Service({__get_candid_interface_tmp_hack:o.Func([],[o.Text],["query"])});return await _E.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}kr.fetchCandid=wE});var Xt=L(Re=>{"use strict";var qp=Re&&Re.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),EE=Re&&Re.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ct=Re&&Re.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&qp(e,t,r)},Vl=Re&&Re.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&qp(e,t,r);return EE(e,t),e};Object.defineProperty(Re,"__esModule",{value:!0});Re.Cbor=Re.CanisterStatus=Re.polling=void 0;Ct($a(),Re);Ct(_s(),Re);Ct(Yo(),Re);Ct(us(),Re);Ct(Su(),Re);Ct(Mp(),Re);Ct(Ti(),Re);Ct(Al(),Re);Ct(Cp(),Re);Ct(Sl(),Re);Ct(ss(),Re);Ct(il(),Re);Ct(kt(),Re);Ct(Mu(),Re);Re.polling=Vl(ka());Re.CanisterStatus=Vl(ws());Re.Cbor=Vl(cs());Ct(ka(),Re)});var gt=L((Qv,Qp)=>{"use strict";var zl=Object.defineProperty,xE=Object.getOwnPropertyDescriptor,vE=Object.getOwnPropertyNames,TE=Object.prototype.hasOwnProperty,AE=(t,e)=>{for(var r in e)zl(t,r,{get:e[r],enumerable:!0})},SE=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of vE(e))!TE.call(t,i)&&i!==r&&zl(t,i,{get:()=>e[i],enumerable:!(n=xE(e,i))||n.enumerable});return t},BE=t=>SE(zl({},"__esModule",{value:!0}),t),Vp={};AE(Vp,{AgentManager:()=>CE,Canister:()=>FE,FromStringToTokenError:()=>$p,ICPToken:()=>PE,InvalidPercentageError:()=>Dp,NullishError:()=>Zp,TokenAmount:()=>IE,TokenAmountV2:()=>UE,arrayBufferToUint8Array:()=>KE,arrayOfNumberToUint8Array:()=>YE,asNonNullish:()=>jE,asciiStringToByteArray:()=>zE,assertNonNullish:()=>qs,assertPercentageNumber:()=>kE,bigEndianCrc32:()=>ex,bigIntToUint8Array:()=>VE,candidNumberArrayToBigInt:()=>ZE,convertStringToE8s:()=>Kp,createAgent:()=>zp,createServices:()=>qE,debounce:()=>sx,decodeBase32:()=>JE,defaultAgent:()=>Yp,encodeBase32:()=>XE,fromDefinedNullable:()=>ax,fromNullable:()=>Wl,fromNullishNullable:()=>cx,hexStringToUint8Array:()=>WE,isEmptyString:()=>ME,isNullish:()=>Ka,jsonReplacer:()=>ux,jsonReviver:()=>lx,nonNullish:()=>Hr,notEmptyString:()=>Gp,nowInBigIntNanoSeconds:()=>ix,numberToUint8Array:()=>$E,principalToSubAccount:()=>fx,secondsToDuration:()=>rx,smallerVersion:()=>dx,toNullable:()=>ox,uint8ArrayToArrayOfNumber:()=>GE,uint8ArrayToBigInt:()=>HE,uint8ArrayToHexString:()=>DE});Qp.exports=BE(Vp);var $p=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))($p||{}),OE=BigInt(1e8),NE=8,Kp=t=>{let e=t.includes("e")?Number(t).toLocaleString("en",{useGrouping:!1,maximumFractionDigits:20}):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=BigInt(0);if(n)try{s+=BigInt(n)*OE}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},RE=({amount:t,decimals: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=0n,o=10n**BigInt(e);if(n)try{s+=BigInt(n)*o}catch{return 1}if(i){if(i.length>e)return 2;try{s+=BigInt(i.padEnd(e,"0"))}catch{return 1}}return s},PE={symbol:"ICP",name:"Internet Computer",decimals:8},IE=class Ms{constructor(e,r){if(this.e8s=e,this.token=r,r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8")}static fromE8s({amount:e,token:r}){return new Ms(e,r)}static fromString({amount:e,token:r}){if(r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8");let n=Kp(e);return typeof n=="bigint"?new Ms(n,r):n}static fromNumber({amount:e,token:r}){let n=Ms.fromString({amount:e.toString(),token:r});if(n instanceof Ms)return n;throw n===0?new Error(`Number ${e} has more than 8 decimals`):new Error(`Invalid number ${e}`)}toE8s(){return this.e8s}},UE=class Cs{constructor(e,r){this.ulps=e,this.token=r}static fromUlps({amount:e,token:r}){return new Cs(e,r)}static fromString({amount:e,token:r}){let n=RE({amount:e,decimals:r.decimals});return typeof n=="bigint"?new Cs(n,r):n}static fromNumber({amount:e,token:r}){let n=Cs.fromString({amount:e.toFixed(Math.min(NE,r.decimals)),token:r});if(n instanceof Cs)return n;throw n===2?new Error(`Number ${e} has more than ${r.decimals} decimals`):new Error(`Invalid number ${e}`)}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)}},FE=class{constructor(t,e,r){this.id=t,this.service=e,this.certifiedService=r,this.caller=({certified:n=!0})=>n?this.certifiedService:this.service}get canisterId(){return this.id}},jp=Xt(),$l=Xt(),Ka=t=>t==null,Hr=t=>!Ka(t),Gp=t=>Hr(t)&&t!=="",ME=t=>!Gp(t),Yp=()=>$l.HttpAgent.createSync({host:"https://icp-api.io",identity:new $l.AnonymousIdentity}),zp=async({identity:t,host:e,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await $l.HttpAgent.create({identity:t,...Hr(e)&&{host:e},verifyQuerySignatures:n,...Hr(i)&&{retryTimes:i},shouldFetchRootKey:r}),CE=class Wp{constructor(e){this.config=e,this.agents=void 0}static create(e){return new Wp(e)}async getAgent({identity:e}){let r=e.getPrincipal().toText();if(Ka(this.agents)||Ka(this.agents[r])){let n=await zp({identity:e,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}},qE=({options:{canisterId:t,serviceOverride:e,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:o,certifiedIdlFactory:a})=>{let c=n??Yp(),f=e??jp.Actor.createActor(o,{agent:c,canisterId:t,callTransform:i,queryTransform:s}),d=r??jp.Actor.createActor(a,{agent:c,canisterId:t,callTransform:i,queryTransform:s});return{service:f,certifiedService:d,agent:c,canisterId:t}},Dp=class extends Error{},Zp=class extends Error{},qs=(t,e)=>{if(t==null)throw new Zp(e)},jE=(t,e)=>(qs(t,e),t),kE=t=>{if(t<0||t>100)throw new Dp(`${t} is not a valid percentage number.`)},HE=t=>{let e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(typeof e.getBigUint64=="function")return e.getBigUint64(0);{let r=BigInt(e.getUint32(0)),n=BigInt(e.getUint32(4));return(r<<BigInt(32))+n}},VE=t=>{let e=new ArrayBuffer(8),r=new DataView(e);if(typeof r.setBigUint64=="function")r.setBigUint64(0,t);else{let n=Number(t>>BigInt(32)),i=Number(t&BigInt(4294967295));r.setUint32(0,n),r.setUint32(4,i)}return new Uint8Array(e)},$E=t=>{let e=new DataView(new ArrayBuffer(8));for(let r=7;r>=0;--r)e.setUint8(r,t%256),t=t>>8;return new Uint8Array(e.buffer)},KE=t=>new Uint8Array(t),GE=t=>Array.from(t),YE=t=>new Uint8Array(t),zE=t=>Array.from(t).map(e=>e.charCodeAt(0)),WE=t=>{let e=t.match(/.{1,2}/g);return qs(e,"Invalid hex string."),Uint8Array.from(e.map(r=>parseInt(r,16)))},DE=t=>(t instanceof Uint8Array||(t=Uint8Array.from(t)),t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")),ZE=t=>{let e=0n;for(let r=t.length-1;r>=0;r--)e=(e<<32n)+BigInt(t[r]);return e},Ga="abcdefghijklmnopqrstuvwxyz234567",Ci=Object.create(null);for(let t=0;t<Ga.length;t++)Ci[Ga[t]]=t;Ci[0]=Ci.o;Ci[1]=Ci.i;var XE=t=>{let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=Ga[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Ga[r>>3]:"")};function JE(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Ci[o.toLowerCase()];qs(a,`Invalid character: ${JSON.stringify(o)}`),a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}var QE=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]),LE=t=>{let e=-1;for(let r=0;r<t.length;r++){let n=(t[r]^e)&255;e=QE[n]^e>>>8}return(e^-1)>>>0},ex=t=>{let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,LE(t),!1),new Uint8Array(e)},tx={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"},rx=({seconds:t,i18n:e=tx})=>{let r=t/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=nx(i);return i-=Xp(s),[Fs("year",s),Fs("day",i),Fs("hour",n),Fs("minute",r),...t>BigInt(0)&&t<BigInt(60)?[Fs("second",t)]:[]].filter(({amount:o})=>o>0).slice(0,2).map(o=>`${o.amount} ${o.amount===1?e[o.labelKey]:e[`${o.labelKey}_plural`]}`).join(", ")},nx=t=>{let e=t/BigInt(365);for(;Xp(e)>t;)e--;return e},Xp=t=>{let e=t/BigInt(4);return t*BigInt(365)+e},Fs=(t,e)=>({labelKey:t,amount:Number(e)}),ix=()=>BigInt(Date.now())*BigInt(1e6),sx=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},ox=t=>Hr(t)?[t]:[],Wl=t=>t?.[0],ax=t=>{let e=Wl(t);return qs(e),e},cx=t=>Wl(t??[]),Jp=Nt(),Kl="__bigint__",Gl="__principal__",Yl="__uint8array__",ux=(t,e)=>typeof e=="bigint"?{[Kl]:`${e}`}:Hr(e)&&e instanceof Jp.Principal?{[Gl]:e.toText()}:Hr(e)&&e instanceof Uint8Array?{[Yl]:Array.from(e)}:e,lx=(t,e)=>{let r=n=>e[n];return Hr(e)&&typeof e=="object"&&Kl in e?BigInt(r(Kl)):Hr(e)&&typeof e=="object"&&Gl in e?Jp.Principal.fromText(r(Gl)):Hr(e)&&typeof e=="object"&&Yl in e?Uint8Array.from(r(Yl)):e},fx=t=>{let e=t.toUint8Array(),r=new Uint8Array(32);return r[0]=e.length,r.set(e,1),r},kp=(t,e)=>e>t.length?[...t,...[...Array(e-t.length).keys()].map(()=>0)]:t,Hp=t=>{if(!Number.isNaN(Number(t)))return Number(t);let e=t.split("").reduce((r,n)=>Number.isNaN(Number(n))?r:r+n,"");return Number(e)},dx=({minVersion:t,currentVersion:e})=>{let r=kp(t.split(".").map(Hp),3).join(".");return kp(e.split(".").map(Hp),3).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var ey=L(Vr=>{"use strict";var Wa=Vr&&Vr.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},On=Vr&&Vr.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ya,za,ji,ki;Object.defineProperty(Vr,"__esModule",{value:!0});Vr.Ed25519KeyIdentity=Vr.Ed25519PublicKey=void 0;var hx=Xt(),Jt=Xt(),js=vl();function Lp(t){return t!==null&&typeof t=="object"}var Jn=class t{constructor(e){if(Ya.set(this,void 0),za.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Wa(this,Ya,e,"f"),Wa(this,za,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,Jt.fromHex)(e);return this.fromRaw(r)}else if(Lp(e)){let r=e;if(Lp(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Jt.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(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=(0,Jt.wrapDER)(e,Jt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,Jt.unwrapDER)(e,Jt.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 On(this,Ya,"f")}get derKey(){return On(this,za,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Vr.Ed25519PublicKey=Jn;Ya=new WeakMap,za=new WeakMap;Jn.RAW_KEY_LENGTH=32;var Zl=class t extends Jt.SignIdentity{constructor(e,r){super(),ji.set(this,void 0),ki.set(this,void 0),Wa(this,ji,Jn.from(e),"f"),Wa(this,ki,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=js.ed25519.utils.randomPrivateKey()),(0,hx.bufEquals)(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=js.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(Jn.fromDer((0,Jt.fromHex)(r)),(0,Jt.fromHex)(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(Jn.fromRaw(e),r)}static fromSecretKey(e){let r=js.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,Jt.toHex)(On(this,ji,"f").toDer()),(0,Jt.toHex)(On(this,ki,"f"))]}getKeyPair(){return{secretKey:On(this,ki,"f"),publicKey:On(this,ji,"f")}}getPublicKey(){return On(this,ji,"f")}async sign(e){let r=new Uint8Array(e),n=(0,Jt.uint8ToBuf)(js.ed25519.sign(r,On(this,ki,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,s,o]=[e,r,n].map(a=>(typeof a=="string"&&(a=(0,Jt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return js.ed25519.verify(s,i,o)}};Vr.Ed25519KeyIdentity=Zl;ji=new WeakMap,ki=new WeakMap});var ry=L(Qn=>{"use strict";Object.defineProperty(Qn,"__esModule",{value:!0});Qn.ECDSAKeyIdentity=Qn.CryptoError=void 0;var px=Xt(),Da=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};Qn.CryptoError=Da;function ty(t){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new Da("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 Za=class t extends px.SignIdentity{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},s=ty(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await s.exportKey("spki",o.publicKey);return new this(o,a,s)}static async fromKeyPair(e,r){let n=ty(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};Qn.ECDSAKeyIdentity=Za;Qn.default=Za});var Jl=L(Rn=>{"use strict";var yx=Rn&&Rn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ks=Rn&&Rn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Nn;Object.defineProperty(Rn,"__esModule",{value:!0});Rn.PartialIdentity=void 0;var gx=Nt(),Xl=class{constructor(e){Nn.set(this,void 0),yx(this,Nn,e,"f")}get rawKey(){return ks(this,Nn,"f").rawKey}get derKey(){return ks(this,Nn,"f").derKey}toDer(){return ks(this,Nn,"f").toDer()}getPublicKey(){return ks(this,Nn,"f")}getPrincipal(){return gx.Principal.from(ks(this,Nn,"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.")}};Rn.PartialIdentity=Xl;Nn=new WeakMap});var ny=L(De=>{"use strict";var mx=De&&De.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),bx=De&&De.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),_x=De&&De.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&mx(e,t,r);return bx(e,t),e},wx=De&&De.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ex=De&&De.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},xx=De&&De.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Xa;Object.defineProperty(De,"__esModule",{value:!0});De.isDelegationValid=De.PartialDelegationIdentity=De.DelegationIdentity=De.DelegationChain=De.Delegation=void 0;var Pn=Xt(),Ll=Nt(),Hs=_x(as()),vx=Jl(),Tx=new TextEncoder().encode("ic-request-auth-delegation"),Ax=new TextEncoder().encode(`
|
|
57
|
+
ic-request`);function Ql(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,Pn.fromHex)(t)}var Vs=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return Hs.value.map(Object.assign({pubkey:Hs.value.bytes(this.pubkey),expiration:Hs.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Hs.value.array(this.targets.map(e=>Hs.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Pn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};De.Delegation=Vs;async function Sx(t,e,r,n){let i=new Vs(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...Tx,...new Uint8Array((0,Pn.requestIdOf)(i))]),o=await t.sign(s);return{delegation:i,signature:o}}var ef=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let a=await Sx(e,r,n,i.targets);return new t([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],a],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:a}=s,{pubkey:c,expiration:f,targets:d}=o;if(d!==void 0&&!Array.isArray(d))throw new Error("Invalid targets.");return{delegation:new Vs(Ql(c),BigInt("0x"+f),d&&d.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return Ll.Principal.fromHex(h)})),signature:Ql(a)}});return new this(i,Ql(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:(0,Pn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Pn.toHex)(n)}}),publicKey:(0,Pn.toHex)(this.publicKey)}}};De.DelegationChain=ef;var tf=class extends Pn.SignIdentity{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=xx(e,["body"]),i=await(0,Pn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Ax,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};De.DelegationIdentity=tf;var rf=class t extends vx.PartialIdentity{constructor(e,r){super(e),Xa.set(this,void 0),wx(this,Xa,r,"f")}get delegation(){return Ex(this,Xa,"f")}static fromDelegation(e,r){return new t(e,r)}};De.PartialDelegationIdentity=rf;Xa=new WeakMap;function Bx(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?Ll.Principal.fromText(i):i)):r.push(typeof n=="string"?Ll.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:o}of t.delegations){if(o.targets===void 0)continue;let a=!0;for(let c of o.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}De.isDelegationValid=Bx});var iy=L(In=>{"use strict";var Ox=In&&In.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(In,"__esModule",{value:!0});In.WebAuthnIdentity=In.CosePublicKey=void 0;var Ln=Xt(),nf=Ox(Mo()),Nx=qn(),Rx=bi();function Px(t){return(0,Ln.wrapDER)(t,Ln.DER_COSE_OID).buffer}function Ix(t){let e=new DataView(new ArrayBuffer(2)),r=t.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>e.setUint8(s,i));let n=e.getUint16(0);return t.slice(55+n)}var Ja=class{constructor(e){this._cose=e,this._encodedKey=Px(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};In.CosePublicKey=Ja;function Ux(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function Fx(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:Ux(),pubKeyCredParams:[{type:"public-key",alg:sf.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Nx.randomBytes)(16),name:"Internet Identity",displayName:"Internet Identity"}}});return e===null?null:{id:e.id,response:e.response,type:e.type,authenticatorAttachment:e.authenticatorAttachment,getClientExtensionResults:e.getClientExtensionResults,rawId:(0,Rx.bufFromBufLike)(e.rawId)}}var sf;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(sf||(sf={}));var of=class extends Ln.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new Ja(r)}static fromJSON(e){let{publicKey:r,rawId:n}=JSON.parse(e);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,Ln.fromHex)(n),(0,Ln.fromHex)(r),void 0)}static async create(e){var r;let n=await Fx(e);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=nf.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,Ix(s.authData),(r=n.authenticatorAttachment)!==null&&r!==void 0?r:void 0)}getPublicKey(){return this._publicKey}getAuthenticatorAttachment(){return this.authenticatorAttachment}async sign(e){let r=await navigator.credentials.get({publicKey:{allowCredentials:[{type:"public-key",id:this.rawId}],challenge:e,userVerification:"preferred"}});r.authenticatorAttachment!==null&&(this.authenticatorAttachment=r.authenticatorAttachment);let n=r.response,i=nf.default.encode(new nf.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,Ln.toHex)(this._publicKey.getCose()),rawId:(0,Ln.toHex)(this.rawId)}}};In.WebAuthnIdentity=of});var oy=L(Ge=>{"use strict";var Mx=Ge&&Ge.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),cf=Ge&&Ge.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Mx(e,t,r)};Object.defineProperty(Ge,"__esModule",{value:!0});Ge.Secp256k1KeyIdentity=Ge.ED25519_OID=Ge.DER_COSE_OID=Ge.unwrapDER=Ge.wrapDER=Ge.WebAuthnIdentity=Ge.Ed25519PublicKey=Ge.Ed25519KeyIdentity=void 0;var sy=ey();Object.defineProperty(Ge,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return sy.Ed25519KeyIdentity}});Object.defineProperty(Ge,"Ed25519PublicKey",{enumerable:!0,get:function(){return sy.Ed25519PublicKey}});cf(ry(),Ge);cf(ny(),Ge);cf(Jl(),Ge);var Cx=iy();Object.defineProperty(Ge,"WebAuthnIdentity",{enumerable:!0,get:function(){return Cx.WebAuthnIdentity}});var Qa=Xt();Object.defineProperty(Ge,"wrapDER",{enumerable:!0,get:function(){return Qa.wrapDER}});Object.defineProperty(Ge,"unwrapDER",{enumerable:!0,get:function(){return Qa.unwrapDER}});Object.defineProperty(Ge,"DER_COSE_OID",{enumerable:!0,get:function(){return Qa.DER_COSE_OID}});Object.defineProperty(Ge,"ED25519_OID",{enumerable:!0,get:function(){return Qa.ED25519_OID}});var af=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};Ge.Secp256k1KeyIdentity=af});var lf=L(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});La.IdleManager=void 0;var ay=["mousedown","mousemove","keydown","touchstart","wheel"],uf=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),ay.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let f;return(...d)=>{let h=this,m=function(){f=void 0,a.apply(h,d)};clearTimeout(f),f=window.setTimeout(m,c)}};if(e?.captureScroll){let a=o(s,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}s()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);ay.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};La.IdleManager=uf});function jx(){return cy||(cy=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function kx(){return uy||(uy=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function Hx(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(cr(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&ly.set(r,t)}).catch(()=>{}),pf.set(e,t),e}function Vx(t){if(df.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{r(),i()},o=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});df.set(t,e)}function dy(t){hf=t(hf)}function $x(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call($s(this),e,...r);return fy.set(n,e.sort?e.sort():[e]),cr(n)}:kx().includes(t)?function(...e){return t.apply($s(this),e),cr(ly.get(this))}:function(...e){return cr(t.apply($s(this),e))}}function Kx(t){return typeof t=="function"?$x(t):(t instanceof IDBTransaction&&Vx(t),qx(t,jx())?new Proxy(t,hf):t)}function cr(t){if(t instanceof IDBRequest)return Hx(t);if(ff.has(t))return ff.get(t);let e=Kx(t);return e!==t&&(ff.set(t,e),pf.set(e,t)),e}var qx,cy,uy,ly,df,fy,ff,pf,hf,$s,yf=Mf(()=>{qx=(t,e)=>e.some(r=>t instanceof r);ly=new WeakMap,df=new WeakMap,fy=new WeakMap,ff=new WeakMap,pf=new WeakMap;hf={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return df.get(t);if(e==="objectStoreNames")return t.objectStoreNames||fy.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return cr(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};$s=t=>pf.get(t)});var py={};Kg(py,{deleteDB:()=>Yx,openDB:()=>Gx,unwrap:()=>$s,wrap:()=>cr});function Gx(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=cr(o);return n&&o.addEventListener("upgradeneeded",c=>{n(cr(o.result),c.oldVersion,c.newVersion,cr(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),a}function Yx(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),cr(r).then(()=>{})}function hy(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(gf.get(e))return gf.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=Wx.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||zx.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),f=c.store;return n&&(f=f.index(a.shift())),(await Promise.all([f[r](...a),i&&c.done]))[0]};return gf.set(e,s),s}var zx,Wx,gf,yy=Mf(()=>{yf();yf();zx=["get","getKey","getAll","getAllKeys","count"],Wx=["put","add","delete","clear"],gf=new Map;dy(t=>({...t,get:(e,r,n)=>hy(e,r)||t.get(e,r,n),has:(e,r)=>!!hy(e,r)||t.has(e,r)}))});var bf=L(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.IdbKeyVal=void 0;var Dx=(yy(),Gg(py)),Ks=tc(),gy="auth-client-db",my="ic-keyval",Zx=async(t=gy,e=my,r)=>(Ks.isBrowser&&(localStorage!=null&&localStorage.getItem(Ks.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Ks.KEY_STORAGE_DELEGATION),localStorage.removeItem(Ks.KEY_STORAGE_KEY)),await(0,Dx.openDB)(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function Xx(t,e,r){return await t.get(e,r)}async function Jx(t,e,r,n){return await t.put(e,n,r)}async function Qx(t,e,r){return await t.delete(e,r)}var mf=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=gy,storeName:n=my,version:i=Ks.DB_VERSION}=e??{},s=await Zx(r,n,i);return new t(s,n)}async set(e,r){return await Jx(this._db,this._storeName,e,r)}async get(e){var r;return(r=await Xx(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await Qx(this._db,this._storeName,e)}};ec.IdbKeyVal=mf});var tc=L(nt=>{"use strict";var Lx=nt&&nt.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},e8=nt&&nt.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},rc;Object.defineProperty(nt,"__esModule",{value:!0});nt.IdbStorage=nt.LocalStorage=nt.isBrowser=nt.DB_VERSION=nt.KEY_VECTOR=nt.KEY_STORAGE_DELEGATION=nt.KEY_STORAGE_KEY=void 0;var t8=bf();nt.KEY_STORAGE_KEY="identity";nt.KEY_STORAGE_DELEGATION="delegation";nt.KEY_VECTOR="iv";nt.DB_VERSION=1;nt.isBrowser=typeof window<"u";var _f=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}};nt.LocalStorage=_f;var wf=class{constructor(e){rc.set(this,void 0),Lx(this,rc,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}t8.IdbKeyVal.create(e8(this,rc,"f")).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};nt.IdbStorage=wf;rc=new WeakMap});var Af=L(Le=>{"use strict";var r8=Le&&Le.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),n8=Le&&Le.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&r8(e,t,r)};Object.defineProperty(Le,"__esModule",{value:!0});Le.AuthClient=Le.ERROR_USER_INTERRUPT=Le.IdbKeyVal=Le.KEY_STORAGE_KEY=Le.KEY_STORAGE_DELEGATION=Le.LocalStorage=Le.IdbStorage=void 0;var by=Xt(),Qt=oy(),_y=lf(),xt=tc(),nc=tc();Object.defineProperty(Le,"IdbStorage",{enumerable:!0,get:function(){return nc.IdbStorage}});Object.defineProperty(Le,"LocalStorage",{enumerable:!0,get:function(){return nc.LocalStorage}});Object.defineProperty(Le,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return nc.KEY_STORAGE_DELEGATION}});Object.defineProperty(Le,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return nc.KEY_STORAGE_KEY}});var i8=bf();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return i8.IdbKeyVal}});var s8="https://identity.ic0.app",o8="#authorize",Ef="ECDSA",xf="Ed25519",a8=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";n8(lf(),Le);var Tf=class{constructor(e,r,n,i,s,o,a,c){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let s=(r=e.storage)!==null&&r!==void 0?r:new xt.IdbStorage,o=(n=e.keyType)!==null&&n!==void 0?n:Ef,a=null;if(e.identity)a=e.identity;else{let h=await s.get(xt.KEY_STORAGE_KEY);if(!h&&xt.isBrowser)try{let m=new xt.LocalStorage,_=await m.get(xt.KEY_STORAGE_DELEGATION),u=await m.get(xt.KEY_STORAGE_KEY);_&&u&&o===Ef&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(xt.KEY_STORAGE_DELEGATION,_),await s.set(xt.KEY_STORAGE_KEY,u),h=_,await m.remove(xt.KEY_STORAGE_DELEGATION),await m.remove(xt.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(h)try{typeof h=="object"?o===xf&&typeof h=="string"?a=await Qt.Ed25519KeyIdentity.fromJSON(h):a=await Qt.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=Qt.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new by.AnonymousIdentity,f=null;if(a)try{let h=await s.get(xt.KEY_STORAGE_DELEGATION);if(typeof h=="object"&&h!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:h&&(f=Qt.DelegationChain.fromJSON(h),(0,Qt.isDelegationValid)(f)?"toDer"in a?c=Qt.PartialDelegationIdentity.fromDelegation(a,f):c=Qt.DelegationIdentity.fromDelegation(a,f):(await vf(s),a=null))}catch(h){console.error(h),await vf(s),a=null}let d;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?d=void 0:(f||e.identity)&&(d=_y.IdleManager.create(e.idleOptions)),a||(o===xf?(a=await Qt.Ed25519KeyIdentity.generate(),await s.set(xt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===Ef&&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 '${xf}' as the key type, as it can serialize to a string`),a=await Qt.ECDSAKeyIdentity.generate(),await s.set(xt.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,f,s,d,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let s=e.delegations.map(f=>({delegation:new Qt.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=Qt.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=Qt.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=Qt.DelegationIdentity.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=_y.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(xt.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,s;let o=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||s8);a.hash=o8,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:o},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Le.ERROR_USER_INTERRUPT,e?.onError):setTimeout(c,a8))};c()}_getEventHandler(e,r){return async n=>{var i,s,o;if(n.origin!==e.origin){console.warn(`WARNING: expected origin '${e.origin}', got '${n.origin}' (ignoring)`);return}let a=n.data;switch(a.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await vf(this._storage),this._identity=new by.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Le.AuthClient=Tf;async function vf(t){await t.remove(xt.KEY_STORAGE_KEY),await t.remove(xt.KEY_STORAGE_DELEGATION),await t.remove(xt.KEY_VECTOR)}});var gg=Ze(gt(),1);var eg=Ze(gt(),1);var qi=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var tn=class t extends qi{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var Dl=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var Qy=Ze(Af(),1),Ly=Ze(gt(),1);var wy=BigInt(144e11),Ey=!1,xy={width:576,height:576},vy={width:505,height:705},Ty="internetcomputer.org";var Gs=Ze(gt(),1);var Hi="http://127.0.0.1:5987",Ay="rdmx6-jaaaa-aaaaa-aaadq-cai";var $r=class t extends qi{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var Sf=Ze(gt(),1);var ic=Ze(gt(),1),Sy=async t=>{let e=new Blob([JSON.stringify(t,ic.jsonReplacer)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},sc=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),ic.jsonReviver)},oc=()=>typeof window<"u";var Bf=({width:t,height:e})=>{if(!oc()||(0,Sf.isNullish)(window)||(0,Sf.isNullish)(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,s=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${s}`};var ac=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=$r.getInstance().get()?.container;if((0,Gs.isNullish)(n)||n===!1)return`https://identity.${this.#e??Ty}`;let i=$r.getInstance().get(),s=(0,Gs.nonNullish)(i)&&(0,Gs.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:Ay,{host:o,protocol:a}=new URL(n===!0?Hi:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Bf(xy)},identityProvider:r()}}},By=class{#e;#t;constructor({appName:e,logoUrl:r}){this.#e=e,this.#t=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:Bf(vy)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var Ny=Ze(Xt(),1),cc=Ze(gt(),1);var Oy=Ze(Xt(),1),ei=Ze(gt(),1);var Vi=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,ei.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...r}){let n=e.getPrincipal().toText();if((0,ei.isNullish)(this.#e)||(0,ei.isNullish)(this.#e[n])){let i=await this.createAgent({identity:e,...r});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}async createAgent({identity:e,fetch:r,container:n}){let s=(0,ei.nonNullish)(n)&&n!==!1?n===!0?Hi:n:"https://icp-api.io",o=(0,ei.nonNullish)(n);return await Oy.HttpAgent.create({identity:e,shouldFetchRootKey:o,host:s,...r&&{fetch:r}})}};var $i=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,cc.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:r,buildType:n,...i}){let s=`${n}#${r.getPrincipal().toText()}#${e};`;if((0,cc.isNullish)(this.#e)||(0,cc.isNullish)(this.#e[s])){let o=await this.createActor({satelliteId:e,identity:r,...i});return this.#e={...this.#e??{},[s]:o},o}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:e,satelliteId:r,...n}){let i=await Vi.getInstance().getAgent(n);return Ny.Actor.createActor(e,{agent:i,canisterId:r})}};var Ys=class extends Error{},uc=class extends Error{},lc=class extends Error{},fc=class extends Error{};var Ry=Ze(Af(),1),dc=()=>Ry.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var If=Ze(gt(),1);var wr=Ze(gt(),1);var Py=async({data:t})=>{try{return await sc(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var ti=Ze(gt(),1);var Of=async t=>{let{data:e,version:r,description:n}=t;return{description:(0,ti.toNullable)(n),data:await Sy(e),version:(0,ti.toNullable)(r)}},Nf=t=>{let{version:e}=t;return{version:(0,ti.toNullable)(e)}},zs=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:(0,ti.fromNullable)(i),owner:r.toText(),data:await sc(s),version:(0,ti.fromNullable)(n),...o}};var Uy=Ze(Nt(),1),it=Ze(gt(),1);var Iy=t=>{if((0,it.isNullish)(t))return(0,it.toNullable)();switch(t.matcher){case"equal":return(0,it.toNullable)({Equal:t.timestamp});case"greaterThan":return(0,it.toNullable)({GreaterThan:t.timestamp});case"lessThan":return(0,it.toNullable)({LessThan:t.timestamp});case"between":return(0,it.toNullable)({Between:[t.timestamps.start,t.timestamps.end]});default:throw new fc("Invalid list matcher for timestamp",t)}},Un=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:(0,it.isNullish)(t)?[]:[{key:(0,it.toNullable)(t.key),description:(0,it.toNullable)(t.description),created_at:Iy(t.createdAt),updated_at:Iy(t.updatedAt)}],paginate:(0,it.toNullable)((0,it.isNullish)(e)?void 0:{start_after:(0,it.toNullable)(e.startAfter),limit:(0,it.toNullable)((0,it.isNullish)(e.limit)?void 0:BigInt(e.limit))}),order:(0,it.toNullable)((0,it.isNullish)(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:(0,it.toNullable)((0,it.isNullish)(n)?void 0:typeof n=="string"?Uy.Principal.fromText(n):n)});var Cy=Ze(gt(),1);var Fy=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:r,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),s=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),o=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),a=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(o)}),c=t.Record({controllers:t.Vec(t.Principal)}),f=t.Variant({Write:t.Null,Admin:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:f,expires_at:t.Opt(t.Nat64)}),h=t.Record({version:t.Opt(t.Nat64)}),m=t.Variant({Db:t.Null,Storage:t.Null}),_=t.Record({version:t.Opt(t.Nat64)}),u=t.Record({cycles:t.Nat,destination_id:t.Principal}),T=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),O=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),R=t.Record({key:T,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,O)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),F=t.Record({derivation_origin:t.Opt(t.Text)}),M=t.Record({internet_identity:t.Opt(F)}),K=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),x=t.Record({max_memory_size:t.Opt(K)}),$=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),z=t.Variant({Deny:t.Null,Allow:t.Null}),D=t.Record({status_code:t.Nat16,location:t.Text}),j=t.Record({iframe:t.Opt($),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(K),raw_access:t.Opt(z),redirects:t.Opt(t.Vec(t.Tuple(t.Text,D)))}),ie=t.Record({db:t.Opt(x),authentication:t.Opt(M),storage:j}),ee=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),ne=t.Variant({Heap:t.Null,Stable:t.Null}),w=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),b=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),B=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ne),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:w,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(b),write:w}),S=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),N=t.Record({memory:ne,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),H=t.Variant({Callback:t.Record({token:N,callback:t.Func([],[],["query"])})}),Z=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(H),status_code:t.Nat16}),ae=t.Record({token:t.Opt(N),body:t.Vec(t.Nat8)}),oe=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),W=t.Record({batch_id:t.Nat}),U=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,R)),items_length:t.Nat64}),p=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),J=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,ee)),items_length:t.Nat64}),re=t.Record({stable:t.Nat64,heap:t.Nat64}),fe=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:f,expires_at:t.Opt(t.Nat64)}),Q=t.Record({controller:fe,controllers:t.Vec(t.Principal)}),l=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),y=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ne),max_size:t.Opt(t.Nat),read:w,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(b),write:w}),g=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),P=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,a],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,a],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([c],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,h],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,a],[],[]),del_filtered_docs:t.Func([t.Text,a],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,h))],[],[]),del_rule:t.Func([m,t.Text,_],[],[]),deposit_cycles:t.Func([u],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(R)],["query"]),get_auth_config:t.Func([],[t.Opt(M)],["query"]),get_config:t.Func([],[ie],[]),get_db_config:t.Func([],[t.Opt(x)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(ee)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(R)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(ee)))],["query"]),get_rule:t.Func([m,t.Text],[t.Opt(B)],["query"]),get_storage_config:t.Func([],[j],["query"]),http_request:t.Func([S],[Z],["query"]),http_request_streaming_callback:t.Func([N],[ae],["query"]),init_asset_upload:t.Func([oe],[W],[]),list_assets:t.Func([t.Text,a],[U],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,p))],["query"]),list_docs:t.Func([t.Text,a],[J],["query"]),list_rules:t.Func([m],[t.Vec(t.Tuple(t.Text,B))],["query"]),memory_size:t.Func([],[re],["query"]),set_auth_config:t.Func([M],[],[]),set_controllers:t.Func([Q],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([x],[],[]),set_doc:t.Func([t.Text,t.Text,l],[ee],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,l))],[t.Vec(t.Tuple(t.Text,ee))],[]),set_rule:t.Func([m,t.Text,y],[B],[]),set_storage_config:t.Func([j],[],[]),upload_asset_chunk:t.Func([g],[P],[]),version:t.Func([],[t.Text],["query"])})};var hc=Ze(gt(),1);var My=({satelliteId:t,container:e})=>{let{satelliteId:r}=Rf({satelliteId:t}),{container:n}=Pf({container:e});if((0,hc.nonNullish)(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?Hi:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Rf=({satelliteId:t})=>(0,hc.nonNullish)(t)?{satelliteId:t}:$r.getInstance().get()??{satelliteId:void 0},Pf=({container:t})=>(0,hc.nonNullish)(t)?{container:t}:$r.getInstance().get()??{container:void 0};var ut=t=>jy({idlFactory:Fy,buildType:"stock",...t}),qy=({idlFactory:t,...e})=>jy({idlFactory:t,buildType:"extended",...e}),jy=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Rf({satelliteId:t});(0,Cy.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Pf({container:e});return await $i.getInstance().getActor({satelliteId:n,container:i,...r})};var ky=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await ut(r),i=(0,wr.fromNullable)(await n(t,e));if(!(0,wr.isNullish)(i))return zs({doc:i,key:e})},Hy=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await ut(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=(0,wr.fromNullable)(a);s.push((0,wr.nonNullish)(c)?await zs({key:o,doc:c}):void 0)}return s},Vy=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await ut(r),{key:i}=e,s=await Of(e),o=await n(t,i,s);return await zs({key:i,doc:o})},$y=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await ut(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await Of(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await zs({key:o,doc:a}));return s},Ky=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await ut(r),{key:i}=e;return n(t,i,Nf(e))},Gy=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await ut(e),n=t.map(({collection:i,doc:s})=>[i,s.key,Nf(s)]);await r(n)},Yy=async({collection:t,filter:e,satellite:r})=>{let{del_filtered_docs:n}=await ut(r);return n(t,Un(e))},zy=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await ut(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(t,Un(e)),f=[];for(let[d,h]of i){let{data:m,owner:_,description:u,version:T,...O}=h;f.push({key:d,description:(0,wr.fromNullable)(u),owner:_.toText(),data:await Py({data:m}),version:(0,wr.fromNullable)(T),...O})}return{items:f,items_length:o,items_page:(0,wr.fromNullable)(s),matches_length:a,matches_pages:(0,wr.fromNullable)(c)}},Wy=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await ut(r);return n(t,Un(e))};var Dy=Ze(Xt(),1);var et=t=>t!==void 0?t:pc()??new Dy.AnonymousIdentity;var Zy=async({satellite:t,...e})=>{let r=et(t?.identity);return await ky({...e,satellite:{...t,identity:r}})},o6=async({satellite:t,...e})=>{let r=et(t?.identity);return await Hy({...e,satellite:{...t,identity:r}})},Xy=async({satellite:t,...e})=>{let r=et(t?.identity);return await Vy({...e,satellite:{...t,identity:r}})},a6=async({satellite:t,...e})=>{let r=et(t?.identity);return await $y({...e,satellite:{...t,identity:r}})},c6=async({satellite:t,...e})=>{let r=et(t?.identity);return await Ky({...e,satellite:{...t,identity:r}})},u6=async({satellite:t,...e})=>{let r=et(t?.identity);return await Gy({...e,satellite:{...t,identity:r}})},l6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await Yy({...r,filter:e??{},satellite:{...t,identity:n}})},f6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await zy({...r,filter:e??{},satellite:{...t,identity:n}})},d6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await Wy({...r,filter:e??{},satellite:{...t,identity:n}})};var Jy=async t=>{let e=pc();if((0,If.isNullish)(e))throw new lc("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await Zy({collection:"#user",key:r});return(0,If.isNullish)(n)?await c8({userId:r,provider:t}):n},c8=({userId:t,...e})=>Xy({collection:"#user",doc:{key:t,data:e}});var Kr,Uf=async t=>{if(Kr=Kr??await dc(),!(await Kr?.isAuthenticated()??!1))return;let r=await Jy(t);tn.getInstance().set(r)},u8=t=>new Promise(async(e,r)=>{if((0,Ly.isNullish)(Kr)){r(new Ys("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=t?.provider??new ac({});await Kr.login({onSuccess:async()=>{await Uf(n.id),e()},onError:i=>{if(i===Qy.ERROR_USER_INTERRUPT){r(new uc(i));return}r(new Ys(i))},maxTimeToLive:t?.maxTimeToLive??wy,allowPinAuthentication:t?.allowPin??Ey,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Ff=async()=>{await Kr?.logout(),Kr=null,tn.getInstance().reset(),$i.getInstance().reset(),Vi.getInstance().reset(),Kr=await dc()},pc=()=>Kr?.getIdentity(),l8=async()=>(Kr??await dc()).getIdentity();var tg=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{Dl({message:"junoSignOutAuthTimer"}),await Ff()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Dl({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},tn.getInstance().subscribe(i=>{if((0,eg.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var rg=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},ng=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var M6=async({idlFactory:t,satellite:e})=>{let r=et(e?.identity);return await qy({idlFactory:t,...e,identity:r})};var Zs=Ze(gt(),1);var Ds=Ze(gt(),1);var Ws=Ze(gt(),1);var ig=async({asset:{data:t,filename:e,collection:r,headers:n,token:i,fullPath:s,encoding:o,description:a},actor:c,init_asset_upload:f})=>{let{batch_id:d}=await f({collection:r,full_path:s,name:e,token:(0,Ws.toNullable)(i),encoding_type:(0,Ws.toNullable)(o),description:(0,Ws.toNullable)(a)}),h=19e5,m=[],_=oc()?new Blob([await t.arrayBuffer()]):t,u=0n;for(let R=0;R<_.size;R+=h){let F=_.slice(R,R+h);m.push({batchId:d,chunk:F,actor:c,orderId:u}),u++}let T=[];for await(let R of f8({uploadChunks:m}))T=[...T,...R];let O=n.find(([R,F])=>R.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await c.commit_asset_upload({batch_id:d,chunk_ids:T.map(({chunk_id:R})=>R),headers:[...n,...O||[]]})};async function*f8({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(i=>d8(i)))}}var d8=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:(0,Ws.toNullable)(n)});var sg=async({satellite:t,...e})=>{let r=await ut(t);await ig({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},og=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await ut(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(t,Un(r));return{items:i.map(([f,d])=>d),items_length:s,items_page:(0,Ds.fromNullable)(o),matches_length:a,matches_pages:(0,Ds.fromNullable)(c)}},ag=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await ut(e);return n(t,Un(r))},cg=async({collection:t,fullPath:e,satellite:r})=>(await ut(r)).del_asset(t,e),ug=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await ut(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},lg=async({collection:t,satellite:e,filter:r})=>{let{del_filtered_assets:n}=await ut(e);return n(t,Un(r))},fg=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await ut(r);return(0,Ds.fromNullable)(await n(t,e))},dg=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await ut(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>(0,Ds.fromNullable)(o))};var hg=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var D6=t=>pg(t),Z6=t=>pg({filename:t.data.name,...t}),pg=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let f=et(o?.identity),d=decodeURI(t),h=i??`/${r}/${d}`,m={...o,identity:f};return await sg({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:m,description:c}),{downloadUrl:yg({satellite:m,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},X6=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)},{items:i,...s}=await og({collection:t,satellite:n,filter:r??{}}),o=i.map(({key:{full_path:a,token:c,name:f,owner:d,description:h},headers:m,encodings:_,created_at:u,updated_at:T})=>{let O=(0,Zs.fromNullable)(c);return{fullPath:a,description:(0,Zs.fromNullable)(h),name:f,downloadUrl:yg({satellite:n,assetKey:{fullPath:a,token:O}}),token:O,headers:m,encodings:_.reduce((R,[F,{modified:M,sha256:K,total_length:x}])=>({...R,[F]:{modified:M,sha256:hg(K),total_length:x}}),{}),owner:d.toText(),created_at:u,updated_at:T}});return{items:o,assets:o,...s}},J6=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await ag({collection:t,satellite:n,filter:r??{}})},Q6=({collection:t,fullPath:e,satellite:r})=>cg({collection:t,fullPath:e,satellite:{...r,identity:et(r?.identity)}}),L6=({assets:t,satellite:e})=>ug({assets:t,satellite:{...e,identity:et(e?.identity)}}),e5=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await lg({collection:t,satellite:n,filter:r??{}})},t5=async({satellite:t,...e})=>{let r=et(t?.identity);return await fg({...e,satellite:{...t,identity:r}})},r5=async({satellite:t,...e})=>{let r=et(t?.identity);return await dg({...e,satellite:{...t,identity:r}})},yg=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${My(n)}${t}${(0,Zs.nonNullish)(e)?`?token=${e}`:""}`};var h8=t=>{let e=t?.satelliteId??rg();(0,gg.assertNonNullish)(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??ng();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},u5=t=>p8(t),p8=async t=>{let e=h8(t);$r.getInstance().set(e),await Uf();let r=e.workers?.auth!==void 0?tg(e.workers.auth):void 0;return[...r?[r]:[]]},l5=t=>tn.getInstance().subscribe(t);export{lc as InitError,ac as InternetIdentityProvider,fc as ListError,By as NFIDProvider,Ys as SignInError,uc as SignInUserInterruptError,l5 as authSubscribe,J6 as countAssets,d6 as countDocs,Q6 as deleteAsset,c6 as deleteDoc,e5 as deleteFilteredAssets,l6 as deleteFilteredDocs,L6 as deleteManyAssets,u6 as deleteManyDocs,yg as downloadUrl,t5 as getAsset,Zy as getDoc,r5 as getManyAssets,o6 as getManyDocs,M6 as getSatelliteExtendedActor,u5 as initJuno,p8 as initSatellite,X6 as listAssets,f6 as listDocs,Xy as setDoc,a6 as setManyDocs,u8 as signIn,Ff as signOut,l8 as unsafeIdentity,D6 as uploadBlob,Z6 as uploadFile};
|
|
58
58
|
/*! Bundled license information:
|
|
59
59
|
|
|
60
60
|
ieee754/index.js:
|