@junobuild/core-standalone 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/canisterStatus-227TLZKL.js +2 -0
- package/dist/browser/{chunk-Q5TR3LMW.js → chunk-S7FZSAC3.js} +3 -3
- package/dist/browser/{chunk-Q5TR3LMW.js.map → chunk-S7FZSAC3.js.map} +2 -2
- package/dist/browser/index.js +11 -11
- package/dist/browser/index.js.map +4 -4
- package/dist/declarations/satellite/satellite.did.d.ts +8 -5
- package/dist/declarations/satellite/satellite.factory.did.js +11 -8
- package/dist/declarations/satellite/satellite.factory.did.mjs +11 -8
- package/dist/node/index.mjs +23 -23
- package/dist/node/index.mjs.map +4 -4
- package/dist/workers/auth.worker.js +1 -1
- package/dist/workers/auth.worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/browser/canisterStatus-T6OA6ZHD.js +0 -2
- /package/dist/browser/{canisterStatus-T6OA6ZHD.js.map → canisterStatus-227TLZKL.js.map} +0 -0
package/dist/node/index.mjs
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
var Wg=Object.create;var ro=Object.defineProperty;var zg=Object.getOwnPropertyDescriptor;var Zg=Object.getOwnPropertyNames;var Dg=Object.getPrototypeOf,Xg=Object.prototype.hasOwnProperty;var ai=(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 Df=(t,e)=>()=>(t&&(e=t(t=0)),e);var ee=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Jg=(t,e)=>{for(var r in e)ro(t,r,{get:e[r],enumerable:!0})},Xf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Zg(e))!Xg.call(t,i)&&i!==r&&ro(t,i,{get:()=>e[i],enumerable:!(n=zg(e,i))||n.enumerable});return t};var De=(t,e,r)=>(r=t!=null?Wg(Dg(t)):{},Xf(e||!t||!t.__esModule?ro(r,"default",{value:t,enumerable:!0}):r,t)),Qg=t=>Xf(ro({},"__esModule",{value:!0}),t);var Lf=ee(no=>{"use strict";no.byteLength=em;no.toByteArray=rm;no.fromByteArray=sm;var Tr=[],tr=[],Lg=typeof Uint8Array<"u"?Uint8Array:Array,Oc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Cn=0,Jf=Oc.length;Cn<Jf;++Cn)Tr[Cn]=Oc[Cn],tr[Oc.charCodeAt(Cn)]=Cn;var Cn,Jf;tr[45]=62;tr[95]=63;function Qf(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 em(t){var e=Qf(t),r=e[0],n=e[1];return(r+n)*3/4-n}function tm(t,e,r){return(e+r)*3/4-r}function rm(t){var e,r=Qf(t),n=r[0],i=r[1],s=new Lg(tm(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=tr[t.charCodeAt(c)]<<18|tr[t.charCodeAt(c+1)]<<12|tr[t.charCodeAt(c+2)]<<6|tr[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=tr[t.charCodeAt(c)]<<2|tr[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=tr[t.charCodeAt(c)]<<10|tr[t.charCodeAt(c+1)]<<4|tr[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function nm(t){return Tr[t>>18&63]+Tr[t>>12&63]+Tr[t>>6&63]+Tr[t&63]}function im(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(nm(n));return i.join("")}function sm(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(im(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(Tr[e>>2]+Tr[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(Tr[e>>10]+Tr[e>>4&63]+Tr[e<<2&63]+"=")),i.join("")}});var Rc=ee(Nc=>{Nc.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)};Nc.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,O=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]|=O*128}});var gd=ee(fi=>{"use strict";var Pc=Lf(),ui=Rc(),ed=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;fi.Buffer=Y;fi.SlowBuffer=fm;fi.INSPECT_MAX_BYTES=50;var io=2147483647;fi.kMaxLength=io;Y.TYPED_ARRAY_SUPPORT=om();!Y.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 om(){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(Y.prototype,"parent",{enumerable:!0,get:function(){if(Y.isBuffer(this))return this.buffer}});Object.defineProperty(Y.prototype,"offset",{enumerable:!0,get:function(){if(Y.isBuffer(this))return this.byteOffset}});function Dr(t){if(t>io)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,Y.prototype),e}function Y(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 Mc(t)}return id(t,e,r)}Y.poolSize=8192;function id(t,e,r){if(typeof t=="string")return cm(t,e);if(ArrayBuffer.isView(t))return um(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(Ar(t,ArrayBuffer)||t&&Ar(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ar(t,SharedArrayBuffer)||t&&Ar(t.buffer,SharedArrayBuffer)))return Uc(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 Y.from(n,e,r);let i=lm(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return Y.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)}Y.from=function(t,e,r){return id(t,e,r)};Object.setPrototypeOf(Y.prototype,Uint8Array.prototype);Object.setPrototypeOf(Y,Uint8Array);function sd(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 am(t,e,r){return sd(t),t<=0?Dr(t):e!==void 0?typeof r=="string"?Dr(t).fill(e,r):Dr(t).fill(e):Dr(t)}Y.alloc=function(t,e,r){return am(t,e,r)};function Mc(t){return sd(t),Dr(t<0?0:qc(t)|0)}Y.allocUnsafe=function(t){return Mc(t)};Y.allocUnsafeSlow=function(t){return Mc(t)};function cm(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!Y.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=od(t,e)|0,n=Dr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ic(t){let e=t.length<0?0:qc(t.length)|0,r=Dr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function um(t){if(Ar(t,Uint8Array)){let e=new Uint8Array(t);return Uc(e.buffer,e.byteOffset,e.byteLength)}return Ic(t)}function Uc(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,Y.prototype),n}function lm(t){if(Y.isBuffer(t)){let e=qc(t.length)|0,r=Dr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||kc(t.length)?Dr(0):Ic(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ic(t.data)}function qc(t){if(t>=io)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+io.toString(16)+" bytes");return t|0}function fm(t){return+t!=t&&(t=0),Y.alloc(+t)}Y.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==Y.prototype};Y.compare=function(e,r){if(Ar(e,Uint8Array)&&(e=Y.from(e,e.offset,e.byteLength)),Ar(r,Uint8Array)&&(r=Y.from(r,r.offset,r.byteLength)),!Y.isBuffer(e)||!Y.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};Y.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}};Y.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return Y.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=Y.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(Ar(o,Uint8Array))s+o.length>i.length?(Y.isBuffer(o)||(o=Y.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(Y.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function od(t,e){if(Y.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Ar(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 Fc(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return yd(t).length;default:if(i)return n?-1:Fc(t).length;e=(""+e).toLowerCase(),i=!0}}Y.byteLength=od;function dm(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 xm(this,e,r);case"utf8":case"utf-8":return cd(this,e,r);case"ascii":return wm(this,e,r);case"latin1":case"binary":return Em(this,e,r);case"base64":return bm(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vm(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}Y.prototype._isBuffer=!0;function kn(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}Y.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)kn(this,r,r+1);return this};Y.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)kn(this,r,r+3),kn(this,r+1,r+2);return this};Y.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)kn(this,r,r+7),kn(this,r+1,r+6),kn(this,r+2,r+5),kn(this,r+3,r+4);return this};Y.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?cd(this,0,e):dm.apply(this,arguments)};Y.prototype.toLocaleString=Y.prototype.toString;Y.prototype.equals=function(e){if(!Y.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:Y.compare(this,e)===0};Y.prototype.inspect=function(){let e="",r=fi.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};ed&&(Y.prototype[ed]=Y.prototype.inspect);Y.prototype.compare=function(e,r,n,i,s){if(Ar(e,Uint8Array)&&(e=Y.from(e,e.offset,e.byteLength)),!Y.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 ad(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,kc(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=Y.from(e,n)),Y.isBuffer(e))return e.length===0?-1:td(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):td(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function td(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}Y.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};Y.prototype.indexOf=function(e,r,n){return ad(this,e,r,n,!0)};Y.prototype.lastIndexOf=function(e,r,n){return ad(this,e,r,n,!1)};function hm(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(kc(a))return o;t[r+o]=a}return o}function pm(t,e,r,n){return so(Fc(e,t.length-r),t,r,n)}function ym(t,e,r,n){return so(Bm(e),t,r,n)}function gm(t,e,r,n){return so(yd(e),t,r,n)}function mm(t,e,r,n){return so(Om(e,t.length-r),t,r,n)}Y.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 hm(this,e,r,n);case"utf8":case"utf-8":return pm(this,e,r,n);case"ascii":case"latin1":case"binary":return ym(this,e,r,n);case"base64":return gm(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mm(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function bm(t,e,r){return e===0&&r===t.length?Pc.fromByteArray(t):Pc.fromByteArray(t.slice(e,r))}function cd(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 _m(n)}var rd=4096;function _m(t){let e=t.length;if(e<=rd)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=rd));return r}function wm(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 Em(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 xm(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+=Nm[t[s]];return i}function vm(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}Y.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,Y.prototype),i};function dt(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")}Y.prototype.readUintLE=Y.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};Y.prototype.readUintBE=Y.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};Y.prototype.readUint8=Y.prototype.readUInt8=function(e,r){return e=e>>>0,r||dt(e,1,this.length),this[e]};Y.prototype.readUint16LE=Y.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||dt(e,2,this.length),this[e]|this[e+1]<<8};Y.prototype.readUint16BE=Y.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||dt(e,2,this.length),this[e]<<8|this[e+1]};Y.prototype.readUint32LE=Y.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};Y.prototype.readUint32BE=Y.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};Y.prototype.readBigUInt64LE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ji(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))});Y.prototype.readBigUInt64BE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ji(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)});Y.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(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};Y.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(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};Y.prototype.readInt8=function(e,r){return e=e>>>0,r||dt(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};Y.prototype.readInt16LE=function(e,r){e=e>>>0,r||dt(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};Y.prototype.readInt16BE=function(e,r){e=e>>>0,r||dt(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};Y.prototype.readInt32LE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};Y.prototype.readInt32BE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};Y.prototype.readBigInt64LE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ji(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)});Y.prototype.readBigInt64BE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ji(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)});Y.prototype.readFloatLE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),ui.read(this,e,!0,23,4)};Y.prototype.readFloatBE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),ui.read(this,e,!1,23,4)};Y.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||dt(e,8,this.length),ui.read(this,e,!0,52,8)};Y.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||dt(e,8,this.length),ui.read(this,e,!1,52,8)};function Ht(t,e,r,n,i,s){if(!Y.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")}Y.prototype.writeUintLE=Y.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;Ht(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};Y.prototype.writeUintBE=Y.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;Ht(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};Y.prototype.writeUint8=Y.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ht(this,e,r,1,255,0),this[r]=e&255,r+1};Y.prototype.writeUint16LE=Y.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};Y.prototype.writeUint16BE=Y.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};Y.prototype.writeUint32LE=Y.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(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};Y.prototype.writeUint32BE=Y.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(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 ud(t,e,r,n,i){pd(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 ld(t,e,r,n,i){pd(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}Y.prototype.writeBigUInt64LE=cn(function(e,r=0){return ud(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});Y.prototype.writeBigUInt64BE=cn(function(e,r=0){return ld(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});Y.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Ht(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};Y.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Ht(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};Y.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ht(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};Y.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};Y.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};Y.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(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};Y.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(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};Y.prototype.writeBigInt64LE=cn(function(e,r=0){return ud(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});Y.prototype.writeBigInt64BE=cn(function(e,r=0){return ld(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function fd(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 dd(t,e,r,n,i){return e=+e,r=r>>>0,i||fd(t,e,r,4,34028234663852886e22,-34028234663852886e22),ui.write(t,e,r,n,23,4),r+4}Y.prototype.writeFloatLE=function(e,r,n){return dd(this,e,r,!0,n)};Y.prototype.writeFloatBE=function(e,r,n){return dd(this,e,r,!1,n)};function hd(t,e,r,n,i){return e=+e,r=r>>>0,i||fd(t,e,r,8,17976931348623157e292,-17976931348623157e292),ui.write(t,e,r,n,52,8),r+8}Y.prototype.writeDoubleLE=function(e,r,n){return hd(this,e,r,!0,n)};Y.prototype.writeDoubleBE=function(e,r,n){return hd(this,e,r,!1,n)};Y.prototype.copy=function(e,r,n,i){if(!Y.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};Y.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"&&!Y.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=Y.isBuffer(e)?e:Y.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 ci={};function Cc(t,e,r){ci[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}`}}}Cc("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Cc("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Cc("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=nd(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=nd(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function nd(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 Tm(t,e,r){li(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Ji(e,t.length-(r+1))}function pd(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 ci.ERR_OUT_OF_RANGE("value",a,t)}Tm(n,i,s)}function li(t,e){if(typeof t!="number")throw new ci.ERR_INVALID_ARG_TYPE(e,"number",t)}function Ji(t,e,r){throw Math.floor(t)!==t?(li(t,r),new ci.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ci.ERR_BUFFER_OUT_OF_BOUNDS:new ci.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Am=/[^+/0-9A-Za-z-_]/g;function Sm(t){if(t=t.split("=")[0],t=t.trim().replace(Am,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Fc(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 Bm(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Om(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 yd(t){return Pc.toByteArray(Sm(t))}function so(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 Ar(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function kc(t){return t!==t}var Nm=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 cn(t){return typeof BigInt>"u"?Rm:t}function Rm(){throw new Error("BigInt not supported")}});var jc=ee(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.ReplicaRejectCode=void 0;var Pm;(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"})(Pm=Qi.ReplicaRejectCode||(Qi.ReplicaRejectCode={}))});var md=ee(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.decode=hi.encode=void 0;var oo="abcdefghijklmnopqrstuvwxyz234567",di=Object.create(null);for(let t=0;t<oo.length;t++)di[oo[t]]=t;di[0]=di.o;di[1]=di.i;function Im(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+=oo[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?oo[r>>3]:"")}hi.encode=Im;function Um(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=di[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)}hi.decode=Um});var bd=ee(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.getCrc32=void 0;var Fm=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 Mm(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=Fm[s]^r>>>8}return(r^-1)>>>0}ao.getCrc32=Mm});var Vc=ee(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.isBytes=wd;Sr.number=co;Sr.bool=_d;Sr.bytes=Hc;Sr.hash=Ed;Sr.exists=xd;Sr.output=vd;function co(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function _d(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function wd(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Hc(t,...e){if(!wd(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 Ed(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");co(t.outputLen),co(t.blockLen)}function xd(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 vd(t,e){Hc(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var qm={number:co,bool:_d,bytes:Hc,hash:Ed,exists:xd,output:vd};Sr.default=qm});var Td=ee(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.crypto=void 0;var un=ai("node:crypto");uo.crypto=un&&typeof un=="object"&&"webcrypto"in un?un.webcrypto:un&&typeof un=="object"&&"randomBytes"in un?un:void 0});var jn=ee(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.Hash=we.nextTick=we.byteSwapIfBE=we.byteSwap=we.isLE=we.rotl=we.rotr=we.createView=we.u32=we.u8=void 0;we.isBytes=Cm;we.byteSwap32=Gm;we.bytesToHex=Wm;we.hexToBytes=zm;we.asyncLoop=Dm;we.utf8ToBytes=Sd;we.toBytes=lo;we.concatBytes=Xm;we.checkOpts=Qm;we.wrapConstructor=Lm;we.wrapConstructorWithOpts=eb;we.wrapXOFConstructorWithOpts=tb;we.randomBytes=rb;var pi=Td(),Kc=Vc();function Cm(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var km=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);we.u8=km;var jm=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));we.u32=jm;var Hm=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);we.createView=Hm;var Vm=(t,e)=>t<<32-e|t>>>e;we.rotr=Vm;var $m=(t,e)=>t<<e|t>>>32-e>>>0;we.rotl=$m;we.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Km=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;we.byteSwap=Km;we.byteSwapIfBE=we.isLE?t=>t:t=>(0,we.byteSwap)(t);function Gm(t){for(let e=0;e<t.length;e++)t[e]=(0,we.byteSwap)(t[e])}var Ym=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Wm(t){(0,Kc.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=Ym[t[r]];return e}var Xr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Ad(t){if(t>=Xr._0&&t<=Xr._9)return t-Xr._0;if(t>=Xr._A&&t<=Xr._F)return t-(Xr._A-10);if(t>=Xr._a&&t<=Xr._f)return t-(Xr._a-10)}function zm(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=Ad(t.charCodeAt(s)),a=Ad(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 Zm=async()=>{};we.nextTick=Zm;async function Dm(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 Sd(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function lo(t){return typeof t=="string"&&(t=Sd(t)),(0,Kc.bytes)(t),t}function Xm(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,Kc.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 $c=class{clone(){return this._cloneInto()}};we.Hash=$c;var Jm={}.toString;function Qm(t,e){if(e!==void 0&&Jm.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function Lm(t){let e=n=>t().update(lo(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function eb(t){let e=(n,i)=>t(i).update(lo(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function tb(t){let e=(n,i)=>t(i).update(lo(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function rb(t=32){if(pi.crypto&&typeof pi.crypto.getRandomValues=="function")return pi.crypto.getRandomValues(new Uint8Array(t));if(pi.crypto&&typeof pi.crypto.randomBytes=="function")return pi.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}});var Wc=ee(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.HashMD=ln.Maj=ln.Chi=void 0;var Gc=Vc(),Li=jn();function nb(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 ib=(t,e,r)=>t&e^~t&r;ln.Chi=ib;var sb=(t,e,r)=>t&e^t&r^e&r;ln.Maj=sb;var Yc=class extends Li.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,Li.createView)(this.buffer)}update(e){(0,Gc.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,Li.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,Li.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,Gc.exists)(this),(0,Gc.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;nb(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,Li.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}};ln.HashMD=Yc});var fo=ee(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.sha224=hn.sha256=hn.SHA256=void 0;var zc=Wc(),rr=jn(),ob=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),fn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),dn=new Uint32Array(64),es=class extends zc.HashMD{constructor(){super(64,32,8,!1),this.A=fn[0]|0,this.B=fn[1]|0,this.C=fn[2]|0,this.D=fn[3]|0,this.E=fn[4]|0,this.F=fn[5]|0,this.G=fn[6]|0,this.H=fn[7]|0}get(){let{A: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)dn[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){let m=dn[h-15],_=dn[h-2],u=(0,rr.rotr)(m,7)^(0,rr.rotr)(m,18)^m>>>3,O=(0,rr.rotr)(_,17)^(0,rr.rotr)(_,19)^_>>>10;dn[h]=O+dn[h-7]+u+dn[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,rr.rotr)(a,6)^(0,rr.rotr)(a,11)^(0,rr.rotr)(a,25),_=d+m+(0,zc.Chi)(a,c,f)+ob[h]+dn[h]|0,O=((0,rr.rotr)(n,2)^(0,rr.rotr)(n,13)^(0,rr.rotr)(n,22))+(0,zc.Maj)(n,i,s)|0;d=f,f=c,c=a,a=o+_|0,o=s,s=i,i=n,n=_+O|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(){dn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};hn.SHA256=es;var Zc=class extends es{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};hn.sha256=(0,rr.wrapConstructor)(()=>new es);hn.sha224=(0,rr.wrapConstructor)(()=>new Zc)});var Bd=ee(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.sha224=void 0;var ab=fo();function cb(t){return ab.sha224.create().update(new Uint8Array(t)).digest()}ho.sha224=cb});var Ut=ee(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.Principal=Br.JSON_KEY_PRINCIPAL=void 0;var Od=md(),ub=bd(),lb=Bd();Br.JSON_KEY_PRINCIPAL="__principal__";var fb=2,Nd=4,db="aaaaa-aa",hb=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},pb=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),Dc=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Nd]))}static managementCanister(){return this.fromHex(db)}static selfAuthenticating(e){let r=(0,lb.sha224)(e);return new this(new Uint8Array([...r,fb]))}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(hb(e))}static fromText(e){let r=e;if(e.includes(Br.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);Br.JSON_KEY_PRINCIPAL in o&&(r=o[Br.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,Od.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]===Nd}toUint8Array(){return this._arr}toHex(){return pb(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,ub.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=(0,Od.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[Br.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(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"}};Br.Principal=Dc});var Vt=ee(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.bufFromBufLike=At.uint8ToBuf=At.bufEquals=At.compare=At.fromHex=At.toHex=At.concat=void 0;function yb(...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}At.concat=yb;function gb(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}At.toHex=gb;var mb=new RegExp(/^[0-9a-fA-F]+$/);function bb(t){if(!mb.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}At.fromHex=bb;function Rd(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}At.compare=Rd;function _b(t,e){return Rd(t,e)===0}At.bufEquals=_b;function po(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}At.uint8ToBuf=po;function Pd(t){return t instanceof Uint8Array?po(t):t instanceof ArrayBuffer?t:Array.isArray(t)?po(new Uint8Array(t)):"buffer"in t?Pd(t.buffer):po(new Uint8Array(t))}At.bufFromBufLike=Pd});var yi=ee(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.UpdateCallRejectedError=Or.QueryCallRejectedError=Or.ActorCallError=Or.AgentError=void 0;var Qc=Ut(),wb=jc(),Eb=Vt(),yo=class t extends Error{constructor(e){super(e),this.message=e,this.name="AgentError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Or.AgentError=yo;var ts=class t extends yo{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)}};Or.ActorCallError=ts;var Xc=class t extends ts{constructor(e,r,n){var i;let s=Qc.Principal.from(e);super(s,r,"query",{Status:n.status,Code:(i=wb.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n,this.name="QueryCallRejectedError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Or.QueryCallRejectedError=Xc;var Jc=class t extends ts{constructor(e,r,n,i){let s=Qc.Principal.from(e);super(s,r,"update",Object.assign({"Request ID":(0,Eb.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)}};Or.UpdateCallRejectedError=Jc});var bo=ee($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.bufFromBufLike=$t.uint8ToBuf=$t.PipeArrayBuffer=$t.fromHexString=$t.toHexString=$t.concat=void 0;function xb(...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}$t.concat=xb;function vb(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}$t.toHexString=vb;function Tb(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}$t.fromHexString=Tb;var Lc=class{constructor(e,r=e?.byteLength||0){this._buffer=mo(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return mo(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}};$t.PipeArrayBuffer=Lc;function go(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}$t.uint8ToBuf=go;function mo(t){return t instanceof Uint8Array?go(t):t instanceof ArrayBuffer?t:Array.isArray(t)?go(new Uint8Array(t)):"buffer"in t?mo(t.buffer):go(new Uint8Array(t))}$t.bufFromBufLike=mo});var eu=ee(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.idlLabelToId=void 0;function Ab(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Sb(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 Ab(t)}_o.idlLabelToId=Sb});var ru=ee(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 tu=bo();function Id(){throw new Error("unexpected end of buffer")}function Ud(t,e){return t.byteLength<e&&Id(),t.read(e)}Je.safeRead=Ud;function wo(t){let e=t.readUint8();return e===void 0&&Id(),e}Je.safeReadUint8=wo;function Bb(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 tu.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=Bb;function Fd(t){let e=BigInt(1),r=BigInt(0),n;do n=wo(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}Je.lebDecode=Fd;function Ob(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 tu.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=Ob;function Nb(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return Fd(t);break}let n=new Uint8Array(Ud(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=Nb;function Rb(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return Md(t,e)}Je.writeUIntLE=Rb;function Md(t,e){t=BigInt(t);let r=new tu.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=Md;function qd(t,e){let r=BigInt(wo(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(wo(t));r=r+n*s}return r}Je.readUIntLE=qd;function Pb(t,e){let r=qd(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Je.readIntLE=Pb});var Cd=ee(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.iexp2=gi.ilog2=void 0;function Ib(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}gi.ilog2=Ib;function Ub(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}gi.iexp2=Ub});var au=ee(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.Variant=W.Record=W.Opt=W.Vec=W.Tuple=W.Principal=W.Nat64=W.Nat32=W.Nat16=W.Nat8=W.Int64=W.Int32=W.Int16=W.Int8=W.Float64=W.Float32=W.Nat=W.Int=W.Text=W.Null=W.Bool=W.Unknown=W.Reserved=W.Empty=W.decode=W.encode=W.ServiceClass=W.FuncClass=W.PrincipalClass=W.RecClass=W.VariantClass=W.TupleClass=W.RecordClass=W.OptClass=W.VecClass=W.FixedNatClass=W.FixedIntClass=W.FloatClass=W.NatClass=W.IntClass=W.TextClass=W.ReservedClass=W.NullClass=W.BoolClass=W.UnknownClass=W.EmptyClass=W.ConstructType=W.PrimitiveType=W.Type=W.Visitor=void 0;W.Service=W.Func=W.Rec=void 0;var Fb=Ut(),Pe=bo(),Nr=eu(),se=ru(),nu=Cd(),Eo="DIDL",kd=400;function rs(t,e,r){return t.map((n,i)=>r(n,e[i]))}var iu=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,Pe.concat)(...this._typs);return(0,Pe.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)}},su=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)}};W.Visitor=su;var mi=class{display(){return this.name}valueToString(e){return tt(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};W.Type=mi;var Kt=class extends mi{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){}};W.PrimitiveType=Kt;var Pr=class extends mi{checkType(e){if(e instanceof pn){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)}};W.ConstructType=Pr;var xo=class extends Kt{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"}};W.EmptyClass=xo;var vo=class extends mi{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 pn?i=()=>r.getType():i=()=>r,Object.defineProperty(n,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}};W.UnknownClass=vo;var To=class extends Kt{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"}};W.BoolClass=To;var Ao=class extends Kt{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"}};W.NullClass=Ao;var bi=class extends Kt{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"}};W.ReservedClass=bi;var So=class extends Kt{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,Pe.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+'"'}};W.TextClass=So;var Bo=class extends Kt{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()}};W.IntClass=Bo;var Oo=class extends Kt{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()}};W.NatClass=Oo;var ns=class extends Kt{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()}};W.FloatClass=ns;var Jr=class extends Kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,nu.iexp2)(this._bits-1)*BigInt(-1),n=(0,nu.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()}};W.FixedIntClass=Jr;var Rr=class extends Kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,nu.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()}};W.FixedNatClass=Rr;var No=class t extends Pr{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Rr&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof Rr?this._type._bits:this._type instanceof Jr?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 Dg=Object.create;var no=Object.defineProperty;var Zg=Object.getOwnPropertyDescriptor;var Jg=Object.getOwnPropertyNames;var Xg=Object.getPrototypeOf,Qg=Object.prototype.hasOwnProperty;var ai=(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 Xf=(t,e)=>()=>(t&&(e=t(t=0)),e);var ee=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Lg=(t,e)=>{for(var r in e)no(t,r,{get:e[r],enumerable:!0})},Qf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Jg(e))!Qg.call(t,i)&&i!==r&&no(t,i,{get:()=>e[i],enumerable:!(n=Zg(e,i))||n.enumerable});return t};var Ze=(t,e,r)=>(r=t!=null?Dg(Xg(t)):{},Qf(e||!t||!t.__esModule?no(r,"default",{value:t,enumerable:!0}):r,t)),em=t=>Qf(no({},"__esModule",{value:!0}),t);var td=ee(io=>{"use strict";io.byteLength=rm;io.toByteArray=im;io.fromByteArray=am;var Tr=[],tr=[],tm=typeof Uint8Array<"u"?Uint8Array:Array,Nc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(qn=0,Lf=Nc.length;qn<Lf;++qn)Tr[qn]=Nc[qn],tr[Nc.charCodeAt(qn)]=qn;var qn,Lf;tr[45]=62;tr[95]=63;function ed(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 rm(t){var e=ed(t),r=e[0],n=e[1];return(r+n)*3/4-n}function nm(t,e,r){return(e+r)*3/4-r}function im(t){var e,r=ed(t),n=r[0],i=r[1],s=new tm(nm(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=tr[t.charCodeAt(c)]<<18|tr[t.charCodeAt(c+1)]<<12|tr[t.charCodeAt(c+2)]<<6|tr[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=tr[t.charCodeAt(c)]<<2|tr[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=tr[t.charCodeAt(c)]<<10|tr[t.charCodeAt(c+1)]<<4|tr[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function sm(t){return Tr[t>>18&63]+Tr[t>>12&63]+Tr[t>>6&63]+Tr[t&63]}function om(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(sm(n));return i.join("")}function am(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(om(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(Tr[e>>2]+Tr[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(Tr[e>>10]+Tr[e>>4&63]+Tr[e<<2&63]+"=")),i.join("")}});var Pc=ee(Rc=>{Rc.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)};Rc.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,O=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]|=O*128}});var bd=ee(fi=>{"use strict";var Ic=td(),ui=Pc(),rd=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;fi.Buffer=Y;fi.SlowBuffer=hm;fi.INSPECT_MAX_BYTES=50;var so=2147483647;fi.kMaxLength=so;Y.TYPED_ARRAY_SUPPORT=cm();!Y.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 cm(){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(Y.prototype,"parent",{enumerable:!0,get:function(){if(Y.isBuffer(this))return this.buffer}});Object.defineProperty(Y.prototype,"offset",{enumerable:!0,get:function(){if(Y.isBuffer(this))return this.byteOffset}});function Zr(t){if(t>so)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,Y.prototype),e}function Y(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 Cc(t)}return od(t,e,r)}Y.poolSize=8192;function od(t,e,r){if(typeof t=="string")return lm(t,e);if(ArrayBuffer.isView(t))return fm(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(Ar(t,ArrayBuffer)||t&&Ar(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ar(t,SharedArrayBuffer)||t&&Ar(t.buffer,SharedArrayBuffer)))return Fc(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 Y.from(n,e,r);let i=dm(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return Y.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)}Y.from=function(t,e,r){return od(t,e,r)};Object.setPrototypeOf(Y.prototype,Uint8Array.prototype);Object.setPrototypeOf(Y,Uint8Array);function ad(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 um(t,e,r){return ad(t),t<=0?Zr(t):e!==void 0?typeof r=="string"?Zr(t).fill(e,r):Zr(t).fill(e):Zr(t)}Y.alloc=function(t,e,r){return um(t,e,r)};function Cc(t){return ad(t),Zr(t<0?0:qc(t)|0)}Y.allocUnsafe=function(t){return Cc(t)};Y.allocUnsafeSlow=function(t){return Cc(t)};function lm(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!Y.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=cd(t,e)|0,n=Zr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Uc(t){let e=t.length<0?0:qc(t.length)|0,r=Zr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function fm(t){if(Ar(t,Uint8Array)){let e=new Uint8Array(t);return Fc(e.buffer,e.byteOffset,e.byteLength)}return Uc(t)}function Fc(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,Y.prototype),n}function dm(t){if(Y.isBuffer(t)){let e=qc(t.length)|0,r=Zr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||kc(t.length)?Zr(0):Uc(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Uc(t.data)}function qc(t){if(t>=so)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+so.toString(16)+" bytes");return t|0}function hm(t){return+t!=t&&(t=0),Y.alloc(+t)}Y.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==Y.prototype};Y.compare=function(e,r){if(Ar(e,Uint8Array)&&(e=Y.from(e,e.offset,e.byteLength)),Ar(r,Uint8Array)&&(r=Y.from(r,r.offset,r.byteLength)),!Y.isBuffer(e)||!Y.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};Y.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}};Y.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return Y.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=Y.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(Ar(o,Uint8Array))s+o.length>i.length?(Y.isBuffer(o)||(o=Y.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(Y.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function cd(t,e){if(Y.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Ar(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 Mc(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return md(t).length;default:if(i)return n?-1:Mc(t).length;e=(""+e).toLowerCase(),i=!0}}Y.byteLength=cd;function pm(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 Tm(this,e,r);case"utf8":case"utf-8":return ld(this,e,r);case"ascii":return xm(this,e,r);case"latin1":case"binary":return vm(this,e,r);case"base64":return wm(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Am(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}Y.prototype._isBuffer=!0;function jn(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}Y.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)jn(this,r,r+1);return this};Y.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)jn(this,r,r+3),jn(this,r+1,r+2);return this};Y.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)jn(this,r,r+7),jn(this,r+1,r+6),jn(this,r+2,r+5),jn(this,r+3,r+4);return this};Y.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?ld(this,0,e):pm.apply(this,arguments)};Y.prototype.toLocaleString=Y.prototype.toString;Y.prototype.equals=function(e){if(!Y.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:Y.compare(this,e)===0};Y.prototype.inspect=function(){let e="",r=fi.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};rd&&(Y.prototype[rd]=Y.prototype.inspect);Y.prototype.compare=function(e,r,n,i,s){if(Ar(e,Uint8Array)&&(e=Y.from(e,e.offset,e.byteLength)),!Y.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 ud(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,kc(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=Y.from(e,n)),Y.isBuffer(e))return e.length===0?-1:nd(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):nd(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function nd(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}Y.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};Y.prototype.indexOf=function(e,r,n){return ud(this,e,r,n,!0)};Y.prototype.lastIndexOf=function(e,r,n){return ud(this,e,r,n,!1)};function ym(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(kc(a))return o;t[r+o]=a}return o}function gm(t,e,r,n){return oo(Mc(e,t.length-r),t,r,n)}function mm(t,e,r,n){return oo(Nm(e),t,r,n)}function bm(t,e,r,n){return oo(md(e),t,r,n)}function _m(t,e,r,n){return oo(Rm(e,t.length-r),t,r,n)}Y.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 ym(this,e,r,n);case"utf8":case"utf-8":return gm(this,e,r,n);case"ascii":case"latin1":case"binary":return mm(this,e,r,n);case"base64":return bm(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _m(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function wm(t,e,r){return e===0&&r===t.length?Ic.fromByteArray(t):Ic.fromByteArray(t.slice(e,r))}function ld(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 Em(n)}var id=4096;function Em(t){let e=t.length;if(e<=id)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=id));return r}function xm(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 vm(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 Tm(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+=Pm[t[s]];return i}function Am(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}Y.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,Y.prototype),i};function dt(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")}Y.prototype.readUintLE=Y.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};Y.prototype.readUintBE=Y.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};Y.prototype.readUint8=Y.prototype.readUInt8=function(e,r){return e=e>>>0,r||dt(e,1,this.length),this[e]};Y.prototype.readUint16LE=Y.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||dt(e,2,this.length),this[e]|this[e+1]<<8};Y.prototype.readUint16BE=Y.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||dt(e,2,this.length),this[e]<<8|this[e+1]};Y.prototype.readUint32LE=Y.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};Y.prototype.readUint32BE=Y.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};Y.prototype.readBigUInt64LE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xi(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))});Y.prototype.readBigUInt64BE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xi(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)});Y.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(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};Y.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(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};Y.prototype.readInt8=function(e,r){return e=e>>>0,r||dt(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};Y.prototype.readInt16LE=function(e,r){e=e>>>0,r||dt(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};Y.prototype.readInt16BE=function(e,r){e=e>>>0,r||dt(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};Y.prototype.readInt32LE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};Y.prototype.readInt32BE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};Y.prototype.readBigInt64LE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xi(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)});Y.prototype.readBigInt64BE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xi(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)});Y.prototype.readFloatLE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),ui.read(this,e,!0,23,4)};Y.prototype.readFloatBE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),ui.read(this,e,!1,23,4)};Y.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||dt(e,8,this.length),ui.read(this,e,!0,52,8)};Y.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||dt(e,8,this.length),ui.read(this,e,!1,52,8)};function Ht(t,e,r,n,i,s){if(!Y.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")}Y.prototype.writeUintLE=Y.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;Ht(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};Y.prototype.writeUintBE=Y.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;Ht(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};Y.prototype.writeUint8=Y.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ht(this,e,r,1,255,0),this[r]=e&255,r+1};Y.prototype.writeUint16LE=Y.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};Y.prototype.writeUint16BE=Y.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};Y.prototype.writeUint32LE=Y.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(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};Y.prototype.writeUint32BE=Y.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(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 fd(t,e,r,n,i){gd(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 dd(t,e,r,n,i){gd(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}Y.prototype.writeBigUInt64LE=cn(function(e,r=0){return fd(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});Y.prototype.writeBigUInt64BE=cn(function(e,r=0){return dd(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});Y.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Ht(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};Y.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Ht(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};Y.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ht(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};Y.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};Y.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};Y.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(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};Y.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ht(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};Y.prototype.writeBigInt64LE=cn(function(e,r=0){return fd(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});Y.prototype.writeBigInt64BE=cn(function(e,r=0){return dd(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function hd(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 pd(t,e,r,n,i){return e=+e,r=r>>>0,i||hd(t,e,r,4,34028234663852886e22,-34028234663852886e22),ui.write(t,e,r,n,23,4),r+4}Y.prototype.writeFloatLE=function(e,r,n){return pd(this,e,r,!0,n)};Y.prototype.writeFloatBE=function(e,r,n){return pd(this,e,r,!1,n)};function yd(t,e,r,n,i){return e=+e,r=r>>>0,i||hd(t,e,r,8,17976931348623157e292,-17976931348623157e292),ui.write(t,e,r,n,52,8),r+8}Y.prototype.writeDoubleLE=function(e,r,n){return yd(this,e,r,!0,n)};Y.prototype.writeDoubleBE=function(e,r,n){return yd(this,e,r,!1,n)};Y.prototype.copy=function(e,r,n,i){if(!Y.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};Y.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"&&!Y.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=Y.isBuffer(e)?e:Y.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 ci={};function jc(t,e,r){ci[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}`}}}jc("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);jc("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);jc("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=sd(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=sd(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function sd(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 Sm(t,e,r){li(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Xi(e,t.length-(r+1))}function gd(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 ci.ERR_OUT_OF_RANGE("value",a,t)}Sm(n,i,s)}function li(t,e){if(typeof t!="number")throw new ci.ERR_INVALID_ARG_TYPE(e,"number",t)}function Xi(t,e,r){throw Math.floor(t)!==t?(li(t,r),new ci.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ci.ERR_BUFFER_OUT_OF_BOUNDS:new ci.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Bm=/[^+/0-9A-Za-z-_]/g;function Om(t){if(t=t.split("=")[0],t=t.trim().replace(Bm,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Mc(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 Nm(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Rm(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 md(t){return Ic.toByteArray(Om(t))}function oo(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 Ar(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function kc(t){return t!==t}var Pm=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 cn(t){return typeof BigInt>"u"?Im:t}function Im(){throw new Error("BigInt not supported")}});var Hc=ee(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.ReplicaRejectCode=void 0;var Um;(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"})(Um=Qi.ReplicaRejectCode||(Qi.ReplicaRejectCode={}))});var _d=ee(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.decode=hi.encode=void 0;var ao="abcdefghijklmnopqrstuvwxyz234567",di=Object.create(null);for(let t=0;t<ao.length;t++)di[ao[t]]=t;di[0]=di.o;di[1]=di.i;function Fm(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+=ao[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?ao[r>>3]:"")}hi.encode=Fm;function Mm(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=di[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)}hi.decode=Mm});var wd=ee(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.getCrc32=void 0;var Cm=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 qm(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=Cm[s]^r>>>8}return(r^-1)>>>0}co.getCrc32=qm});var $c=ee(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.isBytes=xd;Sr.number=uo;Sr.bool=Ed;Sr.bytes=Vc;Sr.hash=vd;Sr.exists=Td;Sr.output=Ad;function uo(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Ed(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function xd(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Vc(t,...e){if(!xd(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 vd(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");uo(t.outputLen),uo(t.blockLen)}function Td(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){Vc(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var jm={number:uo,bool:Ed,bytes:Vc,hash:vd,exists:Td,output:Ad};Sr.default=jm});var Sd=ee(lo=>{"use strict";Object.defineProperty(lo,"__esModule",{value:!0});lo.crypto=void 0;var un=ai("node:crypto");lo.crypto=un&&typeof un=="object"&&"webcrypto"in un?un.webcrypto:un&&typeof un=="object"&&"randomBytes"in un?un:void 0});var kn=ee(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.Hash=we.nextTick=we.byteSwapIfBE=we.byteSwap=we.isLE=we.rotl=we.rotr=we.createView=we.u32=we.u8=void 0;we.isBytes=km;we.byteSwap32=Wm;we.bytesToHex=Dm;we.hexToBytes=Zm;we.asyncLoop=Xm;we.utf8ToBytes=Od;we.toBytes=fo;we.concatBytes=Qm;we.checkOpts=eb;we.wrapConstructor=tb;we.wrapConstructorWithOpts=rb;we.wrapXOFConstructorWithOpts=nb;we.randomBytes=ib;var pi=Sd(),Gc=$c();function km(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Hm=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);we.u8=Hm;var Vm=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));we.u32=Vm;var $m=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);we.createView=$m;var Km=(t,e)=>t<<32-e|t>>>e;we.rotr=Km;var Gm=(t,e)=>t<<e|t>>>32-e>>>0;we.rotl=Gm;we.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Ym=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;we.byteSwap=Ym;we.byteSwapIfBE=we.isLE?t=>t:t=>(0,we.byteSwap)(t);function Wm(t){for(let e=0;e<t.length;e++)t[e]=(0,we.byteSwap)(t[e])}var zm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Dm(t){(0,Gc.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=zm[t[r]];return e}var Jr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Bd(t){if(t>=Jr._0&&t<=Jr._9)return t-Jr._0;if(t>=Jr._A&&t<=Jr._F)return t-(Jr._A-10);if(t>=Jr._a&&t<=Jr._f)return t-(Jr._a-10)}function Zm(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=Bd(t.charCodeAt(s)),a=Bd(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 Xm(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 Od(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function fo(t){return typeof t=="string"&&(t=Od(t)),(0,Gc.bytes)(t),t}function Qm(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,Gc.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 Kc=class{clone(){return this._cloneInto()}};we.Hash=Kc;var Lm={}.toString;function eb(t,e){if(e!==void 0&&Lm.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function tb(t){let e=n=>t().update(fo(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function rb(t){let e=(n,i)=>t(i).update(fo(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function nb(t){let e=(n,i)=>t(i).update(fo(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function ib(t=32){if(pi.crypto&&typeof pi.crypto.getRandomValues=="function")return pi.crypto.getRandomValues(new Uint8Array(t));if(pi.crypto&&typeof pi.crypto.randomBytes=="function")return pi.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}});var zc=ee(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.HashMD=ln.Maj=ln.Chi=void 0;var Yc=$c(),Li=kn();function sb(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 ob=(t,e,r)=>t&e^~t&r;ln.Chi=ob;var ab=(t,e,r)=>t&e^t&r^e&r;ln.Maj=ab;var Wc=class extends Li.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,Li.createView)(this.buffer)}update(e){(0,Yc.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,Li.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,Li.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,Yc.exists)(this),(0,Yc.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;sb(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,Li.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}};ln.HashMD=Wc});var ho=ee(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.sha224=hn.sha256=hn.SHA256=void 0;var Dc=zc(),rr=kn(),cb=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),fn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),dn=new Uint32Array(64),es=class extends Dc.HashMD{constructor(){super(64,32,8,!1),this.A=fn[0]|0,this.B=fn[1]|0,this.C=fn[2]|0,this.D=fn[3]|0,this.E=fn[4]|0,this.F=fn[5]|0,this.G=fn[6]|0,this.H=fn[7]|0}get(){let{A: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)dn[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){let m=dn[h-15],_=dn[h-2],u=(0,rr.rotr)(m,7)^(0,rr.rotr)(m,18)^m>>>3,O=(0,rr.rotr)(_,17)^(0,rr.rotr)(_,19)^_>>>10;dn[h]=O+dn[h-7]+u+dn[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,rr.rotr)(a,6)^(0,rr.rotr)(a,11)^(0,rr.rotr)(a,25),_=d+m+(0,Dc.Chi)(a,c,f)+cb[h]+dn[h]|0,O=((0,rr.rotr)(n,2)^(0,rr.rotr)(n,13)^(0,rr.rotr)(n,22))+(0,Dc.Maj)(n,i,s)|0;d=f,f=c,c=a,a=o+_|0,o=s,s=i,i=n,n=_+O|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(){dn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};hn.SHA256=es;var Zc=class extends es{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};hn.sha256=(0,rr.wrapConstructor)(()=>new es);hn.sha224=(0,rr.wrapConstructor)(()=>new Zc)});var Nd=ee(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.sha224=void 0;var ub=ho();function lb(t){return ub.sha224.create().update(new Uint8Array(t)).digest()}po.sha224=lb});var Ut=ee(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.Principal=Br.JSON_KEY_PRINCIPAL=void 0;var Rd=_d(),fb=wd(),db=Nd();Br.JSON_KEY_PRINCIPAL="__principal__";var hb=2,Pd=4,pb="aaaaa-aa",yb=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},gb=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),Jc=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Pd]))}static managementCanister(){return this.fromHex(pb)}static selfAuthenticating(e){let r=(0,db.sha224)(e);return new this(new Uint8Array([...r,hb]))}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(yb(e))}static fromText(e){let r=e;if(e.includes(Br.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);Br.JSON_KEY_PRINCIPAL in o&&(r=o[Br.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,Rd.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]===Pd}toUint8Array(){return this._arr}toHex(){return gb(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,fb.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=(0,Rd.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[Br.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(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"}};Br.Principal=Jc});var Vt=ee(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.bufFromBufLike=At.uint8ToBuf=At.bufEquals=At.compare=At.fromHex=At.toHex=At.concat=void 0;function mb(...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}At.concat=mb;function bb(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}At.toHex=bb;var _b=new RegExp(/^[0-9a-fA-F]+$/);function wb(t){if(!_b.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}At.fromHex=wb;function Id(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}At.compare=Id;function Eb(t,e){return Id(t,e)===0}At.bufEquals=Eb;function yo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}At.uint8ToBuf=yo;function Ud(t){return t instanceof Uint8Array?yo(t):t instanceof ArrayBuffer?t:Array.isArray(t)?yo(new Uint8Array(t)):"buffer"in t?Ud(t.buffer):yo(new Uint8Array(t))}At.bufFromBufLike=Ud});var yi=ee(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.UpdateCallRejectedError=Or.QueryCallRejectedError=Or.ActorCallError=Or.AgentError=void 0;var Lc=Ut(),xb=Hc(),vb=Vt(),go=class t extends Error{constructor(e){super(e),this.message=e,this.name="AgentError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Or.AgentError=go;var ts=class t extends go{constructor(e,r,n,i){let s=Lc.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)}};Or.ActorCallError=ts;var Xc=class t extends ts{constructor(e,r,n){var i;let s=Lc.Principal.from(e);super(s,r,"query",{Status:n.status,Code:(i=xb.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)}};Or.QueryCallRejectedError=Xc;var Qc=class t extends ts{constructor(e,r,n,i){let s=Lc.Principal.from(e);super(s,r,"update",Object.assign({"Request ID":(0,vb.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)}};Or.UpdateCallRejectedError=Qc});var _o=ee($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.bufFromBufLike=$t.uint8ToBuf=$t.PipeArrayBuffer=$t.fromHexString=$t.toHexString=$t.concat=void 0;function Tb(...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}$t.concat=Tb;function Ab(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}$t.toHexString=Ab;function Sb(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}$t.fromHexString=Sb;var eu=class{constructor(e,r=e?.byteLength||0){this._buffer=bo(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return bo(this._view.slice())}get byteLength(){return this._view.byteLength}read(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}};$t.PipeArrayBuffer=eu;function mo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}$t.uint8ToBuf=mo;function bo(t){return t instanceof Uint8Array?mo(t):t instanceof ArrayBuffer?t:Array.isArray(t)?mo(new Uint8Array(t)):"buffer"in t?bo(t.buffer):mo(new Uint8Array(t))}$t.bufFromBufLike=bo});var tu=ee(wo=>{"use strict";Object.defineProperty(wo,"__esModule",{value:!0});wo.idlLabelToId=void 0;function Bb(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Ob(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 Bb(t)}wo.idlLabelToId=Ob});var nu=ee(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.readIntLE=Xe.readUIntLE=Xe.writeIntLE=Xe.writeUIntLE=Xe.slebDecode=Xe.slebEncode=Xe.lebDecode=Xe.lebEncode=Xe.safeReadUint8=Xe.safeRead=void 0;var ru=_o();function Fd(){throw new Error("unexpected end of buffer")}function Md(t,e){return t.byteLength<e&&Fd(),t.read(e)}Xe.safeRead=Md;function Eo(t){let e=t.readUint8();return e===void 0&&Fd(),e}Xe.safeReadUint8=Eo;function Nb(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 ru.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}Xe.lebEncode=Nb;function Cd(t){let e=BigInt(1),r=BigInt(0),n;do n=Eo(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}Xe.lebDecode=Cd;function Rb(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 ru.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let s=i(t);if(t/=BigInt(128),e&&t===BigInt(0)&&(s&64)!==0||!e&&t===BigInt(0)&&(s&64)===0){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}Xe.slebEncode=Rb;function Pb(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if((e[r]&64)===0)return Cd(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)}Xe.slebDecode=Pb;function Ib(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return qd(t,e)}Xe.writeUIntLE=Ib;function qd(t,e){t=BigInt(t);let r=new ru.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}Xe.writeIntLE=qd;function jd(t,e){let r=BigInt(Eo(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(Eo(t));r=r+n*s}return r}Xe.readUIntLE=jd;function Ub(t,e){let r=jd(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Xe.readIntLE=Ub});var kd=ee(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.iexp2=gi.ilog2=void 0;function Fb(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}gi.ilog2=Fb;function Mb(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}gi.iexp2=Mb});var cu=ee(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.Variant=W.Record=W.Opt=W.Vec=W.Tuple=W.Principal=W.Nat64=W.Nat32=W.Nat16=W.Nat8=W.Int64=W.Int32=W.Int16=W.Int8=W.Float64=W.Float32=W.Nat=W.Int=W.Text=W.Null=W.Bool=W.Unknown=W.Reserved=W.Empty=W.decode=W.encode=W.ServiceClass=W.FuncClass=W.PrincipalClass=W.RecClass=W.VariantClass=W.TupleClass=W.RecordClass=W.OptClass=W.VecClass=W.FixedNatClass=W.FixedIntClass=W.FloatClass=W.NatClass=W.IntClass=W.TextClass=W.ReservedClass=W.NullClass=W.BoolClass=W.UnknownClass=W.EmptyClass=W.ConstructType=W.PrimitiveType=W.Type=W.Visitor=void 0;W.Service=W.Func=W.Rec=void 0;var Cb=Ut(),Pe=_o(),Nr=tu(),se=nu(),iu=kd(),xo="DIDL",Hd=400;function rs(t,e,r){return t.map((n,i)=>r(n,e[i]))}var su=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,Pe.concat)(...this._typs);return(0,Pe.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)}},ou=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)}};W.Visitor=ou;var mi=class{display(){return this.name}valueToString(e){return tt(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};W.Type=mi;var Kt=class extends mi{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){}};W.PrimitiveType=Kt;var Pr=class extends mi{checkType(e){if(e instanceof pn){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)}};W.ConstructType=Pr;var vo=class extends Kt{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"}};W.EmptyClass=vo;var To=class extends mi{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 pn?i=()=>r.getType():i=()=>r,Object.defineProperty(n,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}};W.UnknownClass=To;var Ao=class extends Kt{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"}};W.BoolClass=Ao;var So=class extends Kt{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"}};W.NullClass=So;var bi=class extends Kt{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"}};W.ReservedClass=bi;var Bo=class extends Kt{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,Pe.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+'"'}};W.TextClass=Bo;var Oo=class extends Kt{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()}};W.IntClass=Oo;var No=class extends Kt{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()}};W.NatClass=No;var ns=class extends Kt{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()}};W.FloatClass=ns;var Xr=class extends Kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,iu.iexp2)(this._bits-1)*BigInt(-1),n=(0,iu.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()}};W.FixedIntClass=Xr;var Rr=class extends Kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,iu.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()}};W.FixedNatClass=Rr;var Ro=class t extends Pr{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Rr&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof Rr?this._type._bits:this._type instanceof Xr?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,Pe.concat)(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,Pe.concat)(r,new Uint8Array(e.buffer));let n=new Pe.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,Pe.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 Rr){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,Pe.concat)(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,Pe.concat)(r,new Uint8Array(e.buffer));let n=new Pe.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,Pe.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 Rr){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 Xr){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("; ")+"}"}};W.VecClass=Ro;var _i=class t extends Pr{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,Pe.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,Pe.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])}`}};W.OptClass=_i;var is=class t extends Pr{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,Nr.idlLabelToId)(r[0])-(0,Nr.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
|
|
|
10
|
-
field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=rs(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Pe.concat)(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,se.slebEncode)(-20),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Pe.concat)((0,se.lebEncode)((0,Nr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Pe.concat)(r,n,(0,Pe.concat)(...i)))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(e,c),o++;continue}let[f,d]=this._fields[s],h=(0,Nr.idlLabelToId)(this._fields[s][0]),m=(0,Nr.idlLabelToId)(a);if(h===m)i[f]=d.decodeValue(e,c),s++,o++;else if(m>h)if(d instanceof _i||d instanceof bi)i[f]=[],s++;else throw new Error("Cannot find required field "+f);else c.decodeValue(e,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof _i||c instanceof bi)i[a]=[];else throw new Error("Cannot find required field "+a);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(e){let r=this._fields.map(([i])=>e[i]);return`record {${rs(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}};W.RecordClass=is;var
|
|
10
|
+
field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=rs(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Pe.concat)(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,se.slebEncode)(-20),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Pe.concat)((0,se.lebEncode)((0,Nr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Pe.concat)(r,n,(0,Pe.concat)(...i)))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(e,c),o++;continue}let[f,d]=this._fields[s],h=(0,Nr.idlLabelToId)(this._fields[s][0]),m=(0,Nr.idlLabelToId)(a);if(h===m)i[f]=d.decodeValue(e,c),s++,o++;else if(m>h)if(d instanceof _i||d instanceof bi)i[f]=[],s++;else throw new Error("Cannot find required field "+f);else c.decodeValue(e,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof _i||c instanceof bi)i[a]=[];else throw new Error("Cannot find required field "+a);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(e){let r=this._fields.map(([i])=>e[i]);return`record {${rs(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}};W.RecordClass=is;var Po=class t extends is{constructor(e){let r={};e.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=e}accept(e,r){return e.visitTuple(this,this._components,r)}covariant(e){if(Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(e[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
11
11
|
|
|
12
|
-
index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=rs(this._components,e,(n,i)=>n.encodeValue(i));return(0,Pe.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 {${rs(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}};W.TupleClass=
|
|
12
|
+
index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=rs(this._components,e,(n,i)=>n.encodeValue(i));return(0,Pe.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 {${rs(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}};W.TupleClass=Po;var Io=class t extends Pr{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,Nr.idlLabelToId)(r[0])-(0,Nr.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,Pe.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,Pe.concat)((0,se.lebEncode)((0,Nr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Pe.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,Nr.idlLabelToId)(s)===(0,Nr.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)}};W.VariantClass=
|
|
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,Pe.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,Pe.concat)((0,se.lebEncode)((0,Nr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Pe.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,Nr.idlLabelToId)(s)===(0,Nr.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)}};W.VariantClass=Io;var pn=class t extends Pr{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)}};W.RecClass=pn;pn._counter=0;function au(t){if((0,se.safeReadUint8)(t)!==1)throw new Error("Cannot decode principal");let r=Number((0,se.lebDecode)(t));return Cb.Principal.fromUint8Array(new Uint8Array((0,se.safeRead)(t,r)))}var Uo=class extends Kt{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,Pe.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,se.slebEncode)(-24)}decodeValue(e,r){return this.checkType(r),au(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}};W.PrincipalClass=Uo;var ss=class extends Pr{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,Pe.concat)(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=(0,se.lebEncode)(o.byteLength);return(0,Pe.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,Pe.concat)(...this.argTypes.map(f=>f.encodeType(e))),s=(0,se.lebEncode)(this.retTypes.length),o=(0,Pe.concat)(...this.retTypes.map(f=>f.encodeType(e))),a=(0,se.lebEncode)(this.annotations.length),c=(0,Pe.concat)(...this.annotations.map(f=>this.encodeAnnotation(f)));e.add(this,(0,Pe.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=au(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")}};W.FuncClass=ss;var Fo=class extends Pr{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,Pe.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,Pe.concat)(c,a,o.encodeType(e))});e.add(this,(0,Pe.concat)(r,n,...i))}decodeValue(e){return au(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};W.ServiceClass=Fo;function tt(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>Hd?e.substring(0,Hd-3)+"...":e}function qb(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new su;t.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(xo),i=r.encode(),s=(0,se.lebEncode)(e.length),o=(0,Pe.concat)(...t.map(c=>c.encodeType(r))),a=(0,Pe.concat)(...rs(t,e,(c,f)=>{try{c.covariant(f)}catch(d){throw new Error(d.message+`
|
|
15
15
|
|
|
16
|
-
`)}return c.encodeValue(f)}));return(0,Pe.concat)(n,i,s,o,a)}W.encode=Mb;function qb(t,e){let r=new Pe.PipeArrayBuffer(e);if(e.byteLength<Eo.length)throw new Error("Message length smaller than magic number");let n=(0,se.safeRead)(r,Eo.length),i=new TextDecoder().decode(n);if(i!==Eo)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(_){let u=[],O=Number((0,se.lebDecode)(_));for(let F=0;F<O;F++){let A=Number((0,se.slebDecode)(_));switch(A){case-18:case-19:{let K=Number((0,se.slebDecode)(_));u.push([A,K]);break}case-20:case-21:{let K=[],E=Number((0,se.lebDecode)(_)),k;for(;E--;){let G=Number((0,se.lebDecode)(_));if(G>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof k=="number"&&k>=G)throw new Error("field id collision or not sorted");k=G;let z=Number((0,se.slebDecode)(_));K.push([G,z])}u.push([A,K]);break}case-22:{let K=[],E=Number((0,se.lebDecode)(_));for(;E--;)K.push(Number((0,se.slebDecode)(_)));let k=[],G=Number((0,se.lebDecode)(_));for(;G--;)k.push(Number((0,se.slebDecode)(_)));let z=[],C=Number((0,se.lebDecode)(_));for(;C--;)switch(Number((0,se.lebDecode)(_))){case 1:{z.push("query");break}case 2:{z.push("oneway");break}case 3:{z.push("composite_query");break}default:throw new Error("unknown annotation")}u.push([A,[K,k,z]]);break}case-23:{let K=Number((0,se.lebDecode)(_)),E=[];for(;K--;){let k=Number((0,se.lebDecode)(_)),G=new TextDecoder().decode((0,se.safeRead)(_,k)),z=(0,se.slebDecode)(_);E.push([G,z])}u.push([A,E]);break}default:throw new Error("Illegal op_code: "+A)}}let T=[],P=Number((0,se.lebDecode)(_));for(let F=0;F<P;F++)T.push(Number((0,se.slebDecode)(_)));return[u,T]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(_=>Gd());function f(_){if(_<-24)throw new Error("future value not supported");if(_<0)switch(_){case-1:return W.Null;case-2:return W.Bool;case-3:return W.Nat;case-4:return W.Int;case-5:return W.Nat8;case-6:return W.Nat16;case-7:return W.Nat32;case-8:return W.Nat64;case-9:return W.Int8;case-10:return W.Int16;case-11:return W.Int32;case-12:return W.Int64;case-13:return W.Float32;case-14:return W.Float64;case-15:return W.Text;case-16:return W.Reserved;case-17:return W.Empty;case-24:return W.Principal;default:throw new Error("Illegal op_code: "+_)}if(_>=o.length)throw new Error("type index out of range");return c[_]}function d(_){switch(_[0]){case-19:{let u=f(_[1]);return Hd(u)}case-18:{let u=f(_[1]);return Vd(u)}case-20:{let u={};for(let[P,F]of _[1]){let A=`_${P}_`;u[A]=f(F)}let O=$d(u),T=O.tryAsTuple();return Array.isArray(T)?jd(...T):O}case-21:{let u={};for(let[O,T]of _[1]){let P=`_${O}_`;u[P]=f(T)}return Kd(u)}case-22:{let[u,O,T]=_[1];return Yd(u.map(P=>f(P)),O.map(P=>f(P)),T)}case-23:{let u={},O=_[1];for(let[T,P]of O){let F=f(P);if(F instanceof pn&&(F=F.getType()),!(F instanceof ss))throw new Error("Illegal service definition: services can only contain functions");u[T]=F}return Wd(u)}default:throw new Error("Illegal op_code: "+_[0])}}o.forEach((_,u)=>{if(_[0]===-22){let O=d(_);c[u].fill(O)}}),o.forEach((_,u)=>{if(_[0]!==-22){let O=d(_);c[u].fill(O)}});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}W.decode=qb;W.Empty=new xo;W.Reserved=new bi;W.Unknown=new vo;W.Bool=new To;W.Null=new Ao;W.Text=new So;W.Int=new Bo;W.Nat=new Oo;W.Float32=new ns(32);W.Float64=new ns(64);W.Int8=new Jr(8);W.Int16=new Jr(16);W.Int32=new Jr(32);W.Int64=new Jr(64);W.Nat8=new Rr(8);W.Nat16=new Rr(16);W.Nat32=new Rr(32);W.Nat64=new Rr(64);W.Principal=new Io;function jd(...t){return new Ro(t)}W.Tuple=jd;function Hd(t){return new No(t)}W.Vec=Hd;function Vd(t){return new _i(t)}W.Opt=Vd;function $d(t){return new is(t)}W.Record=$d;function Kd(t){return new Po(t)}W.Variant=Kd;function Gd(){return new pn}W.Rec=Gd;function Yd(t,e,r=[]){return new ss(t,e,r)}W.Func=Yd;function Wd(t){return new Uo(t)}W.Service=Wd});var pu=ee(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.VecForm=St.OptionForm=St.VariantForm=St.TupleForm=St.RecordForm=St.InputForm=St.InputBox=void 0;var cu=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)}};St.InputBox=cu;var yn=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)}};St.InputForm=yn;var uu=class extends yn{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}};St.RecordForm=uu;var lu=class extends yn{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}};St.TupleForm=lu;var fu=class extends yn{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}};St.VariantForm=fu;var du=class extends yn{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]}}};St.OptionForm=du;var hu=class extends yn{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}};St.VecForm=hu});var Zd=ee(Ee=>{"use strict";var Cb=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]}),kb=Ee&&Ee.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),zd=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)&&Cb(e,t,r);return kb(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 Mo=zd(au()),yu=Ut(),wi=zd(pu()),jb={parse:Wb},os={render:_u},Hb=(t,e)=>new wi.InputBox(t,Object.assign(Object.assign({},jb),e));Ee.inputBox=Hb;var Vb=(t,e)=>new wi.RecordForm(t,Object.assign(Object.assign({},os),e));Ee.recordForm=Vb;var $b=(t,e)=>new wi.TupleForm(t,Object.assign(Object.assign({},os),e));Ee.tupleForm=$b;var Kb=(t,e)=>new wi.VariantForm(t,Object.assign(Object.assign({},os),e));Ee.variantForm=Kb;var Gb=(t,e)=>new wi.OptionForm(t,Object.assign(Object.assign({},os),e));Ee.optForm=Gb;var Yb=(t,e)=>new wi.VecForm(t,Object.assign(Object.assign({},os),e));Ee.vecForm=Yb;var Fo=class extends Mo.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 _u(r)}};Ee.Render=Fo;var gu=class extends Mo.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 yu.Principal.fromText(r)}visitService(e,r){return yu.Principal.fromText(r)}visitFunc(e,r){let n=r.split(".",2);return[yu.Principal.fromText(n[0]),n[1]]}},mu=class extends Mo.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 Wb(t,e,r){return e.random&&r===""?t.accept(new mu,r):t.accept(new gu,r)}function _u(t){return t.accept(new Fo,null)}Ee.renderInput=_u;function Hn(t,e,r){return t.accept(new bu,{input:e,value:r})}Ee.renderValue=Hn;var bu=class extends Mo.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){Hn(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)),Hn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{Hn(o,i.form[a],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{Hn(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)),Hn(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)=>{Hn(r,i.form[c],a)})}}});var Xd=ee(Dd=>{"use strict";Object.defineProperty(Dd,"__esModule",{value:!0})});var xi=ee(ht=>{"use strict";var Jd=ht&&ht.__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]}),zb=ht&&ht.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ei=ht&&ht.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Jd(e,t,r)},Zb=ht&&ht.__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)&&Jd(e,t,r);return zb(e,t),e};Object.defineProperty(ht,"__esModule",{value:!0});ht.IDL=void 0;Ei(Zd(),ht);Ei(pu(),ht);ht.IDL=Zb(au());Ei(eu(),ht);Ei(ru(),ht);Ei(bo(),ht);Ei(Xd(),ht)});var as=ee((Qd,qo)=>{(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 _(E){var k,G,z,C=M.prototype={constructor:M,toString:null,valueOf:null},oe=new M(1),Q=20,ie=4,w=-7,b=21,N=-1e7,B=1e7,R=!1,V=1,D=0,ce={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ae="0123456789abcdefghijklmnopqrstuvwxyz",Z=!0;function M(l,p){var g,I,S,U,H,x,q,$,j=this;if(!(j instanceof M))return new M(l,p);if(p==null){if(l&&l._isBigNumber===!0){j.s=l.s,!l.c||l.e>B?j.c=j.e=null:l.e<N?j.c=[j.e=0]:(j.e=l.e,j.c=l.c.slice());return}if((x=typeof l=="number")&&l*0==0){if(j.s=1/l<0?(l=-l,-1):1,l===~~l){for(U=0,H=l;H>=10;H/=10,U++);U>B?j.c=j.e=null:(j.e=U,j.c=[l]);return}$=String(l)}else{if(!r.test($=String(l)))return z(j,$,x);j.s=$.charCodeAt(0)==45?($=$.slice(1),-1):1}(U=$.indexOf("."))>-1&&($=$.replace(".","")),(H=$.search(/e/i))>0?(U<0&&(U=H),U+=+$.slice(H+1),$=$.substring(0,H)):U<0&&(U=$.length)}else{if(P(p,2,ae.length,"Base"),p==10&&Z)return j=new M(l),le(j,Q+j.e+1,ie);if($=String(l),x=typeof l=="number"){if(l*0!=0)return z(j,$,x,p);if(j.s=1/l<0?($=$.slice(1),-1):1,M.DEBUG&&$.replace(/^0\.0*|\./,"").length>15)throw Error(o+l)}else j.s=$.charCodeAt(0)===45?($=$.slice(1),-1):1;for(g=ae.slice(0,p),U=H=0,q=$.length;H<q;H++)if(g.indexOf(I=$.charAt(H))<0){if(I=="."){if(H>U){U=q;continue}}else if(!S&&($==$.toUpperCase()&&($=$.toLowerCase())||$==$.toLowerCase()&&($=$.toUpperCase()))){S=!0,H=-1,U=0;continue}return z(j,String(l),x,p)}x=!1,$=G($,p,10,j.s),(U=$.indexOf("."))>-1?$=$.replace(".",""):U=$.length}for(H=0;$.charCodeAt(H)===48;H++);for(q=$.length;$.charCodeAt(--q)===48;);if($=$.slice(H,++q)){if(q-=H,x&&M.DEBUG&&q>15&&(l>f||l!==i(l)))throw Error(o+j.s*l);if((U=U-H-1)>B)j.c=j.e=null;else if(U<N)j.c=[j.e=0];else{if(j.e=U,j.c=[],H=(U+1)%c,U<0&&(H+=c),H<q){for(H&&j.c.push(+$.slice(0,H)),q-=c;H<q;)j.c.push(+$.slice(H,H+=c));H=c-($=$.slice(H)).length}else H-=q;for(;H--;$+="0");j.c.push(+$)}}else j.c=[j.e=0]}M.clone=_,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(l){var p,g;if(l!=null)if(typeof l=="object"){if(l.hasOwnProperty(p="DECIMAL_PLACES")&&(g=l[p],P(g,0,m,p),Q=g),l.hasOwnProperty(p="ROUNDING_MODE")&&(g=l[p],P(g,0,8,p),ie=g),l.hasOwnProperty(p="EXPONENTIAL_AT")&&(g=l[p],g&&g.pop?(P(g[0],-m,0,p),P(g[1],0,m,p),w=g[0],b=g[1]):(P(g,-m,m,p),w=-(b=g<0?-g:g))),l.hasOwnProperty(p="RANGE"))if(g=l[p],g&&g.pop)P(g[0],-m,-1,p),P(g[1],1,m,p),N=g[0],B=g[1];else if(P(g,-m,m,p),g)N=-(B=g<0?-g:g);else throw Error(s+p+" cannot be zero: "+g);if(l.hasOwnProperty(p="CRYPTO"))if(g=l[p],g===!!g)if(g)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))R=g;else throw R=!g,Error(s+"crypto unavailable");else R=g;else throw Error(s+p+" not true or false: "+g);if(l.hasOwnProperty(p="MODULO_MODE")&&(g=l[p],P(g,0,9,p),V=g),l.hasOwnProperty(p="POW_PRECISION")&&(g=l[p],P(g,0,m,p),D=g),l.hasOwnProperty(p="FORMAT"))if(g=l[p],typeof g=="object")ce=g;else throw Error(s+p+" not an object: "+g);if(l.hasOwnProperty(p="ALPHABET"))if(g=l[p],typeof g=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(g))Z=g.slice(0,10)=="0123456789",ae=g;else throw Error(s+p+" invalid: "+g)}else throw Error(s+"Object expected: "+l);return{DECIMAL_PLACES:Q,ROUNDING_MODE:ie,EXPONENTIAL_AT:[w,b],RANGE:[N,B],CRYPTO:R,MODULO_MODE:V,POW_PRECISION:D,FORMAT:ce,ALPHABET:ae}},M.isBigNumber=function(l){if(!l||l._isBigNumber!==!0)return!1;if(!M.DEBUG)return!0;var p,g,I=l.c,S=l.e,U=l.s;e:if({}.toString.call(I)=="[object Array]"){if((U===1||U===-1)&&S>=-m&&S<=m&&S===i(S)){if(I[0]===0){if(S===0&&I.length===1)return!0;break e}if(p=(S+1)%c,p<1&&(p+=c),String(I[0]).length==p){for(p=0;p<I.length;p++)if(g=I[p],g<0||g>=a||g!==i(g))break e;if(g!==0)return!0}}}else if(I===null&&S===null&&(U===null||U===1||U===-1))return!0;throw Error(s+"Invalid BigNumber: "+l)},M.maximum=M.max=function(){return L(arguments,-1)},M.minimum=M.min=function(){return L(arguments,1)},M.random=function(){var l=9007199254740992,p=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 I,S,U,H,x,q=0,$=[],j=new M(oe);if(g==null?g=Q:P(g,0,m),H=n(g/c),R)if(crypto.getRandomValues){for(I=crypto.getRandomValues(new Uint32Array(H*=2));q<H;)x=I[q]*131072+(I[q+1]>>>11),x>=9e15?(S=crypto.getRandomValues(new Uint32Array(2)),I[q]=S[0],I[q+1]=S[1]):($.push(x%1e14),q+=2);q=H/2}else if(crypto.randomBytes){for(I=crypto.randomBytes(H*=7);q<H;)x=(I[q]&31)*281474976710656+I[q+1]*1099511627776+I[q+2]*4294967296+I[q+3]*16777216+(I[q+4]<<16)+(I[q+5]<<8)+I[q+6],x>=9e15?crypto.randomBytes(7).copy(I,q):($.push(x%1e14),q+=7);q=H/7}else throw R=!1,Error(s+"crypto unavailable");if(!R)for(;q<H;)x=p(),x<9e15&&($[q++]=x%1e14);for(H=$[--q],g%=c,H&&g&&(x=d[c-g],$[q]=i(H/x)*x);$[q]===0;$.pop(),q--);if(q<0)$=[U=0];else{for(U=-1;$[0]===0;$.splice(0,1),U-=c);for(q=1,x=$[0];x>=10;x/=10,q++);q<c&&(U-=c-q)}return j.e=U,j.c=$,j}}(),M.sum=function(){for(var l=1,p=arguments,g=new M(p[0]);l<p.length;)g=g.plus(p[l++]);return g},G=function(){var l="0123456789";function p(g,I,S,U){for(var H,x=[0],q,$=0,j=g.length;$<j;){for(q=x.length;q--;x[q]*=I);for(x[0]+=U.indexOf(g.charAt($++)),H=0;H<x.length;H++)x[H]>S-1&&(x[H+1]==null&&(x[H+1]=0),x[H+1]+=x[H]/S|0,x[H]%=S)}return x.reverse()}return function(g,I,S,U,H){var x,q,$,j,X,te,de,_e,Me=g.indexOf("."),Ve=Q,me=ie;for(Me>=0&&(j=D,D=0,g=g.replace(".",""),_e=new M(I),te=_e.pow(g.length-Me),D=j,_e.c=p(K(O(te.c),te.e,"0"),10,S,l),_e.e=_e.c.length),de=p(g,I,S,H?(x=ae,l):(x=l,ae)),$=j=de.length;de[--j]==0;de.pop());if(!de[0])return x.charAt(0);if(Me<0?--$:(te.c=de,te.e=$,te.s=U,te=k(te,_e,Ve,me,S),de=te.c,X=te.r,$=te.e),q=$+Ve+1,Me=de[q],j=S/2,X=X||q<0||de[q+1]!=null,X=me<4?(Me!=null||X)&&(me==0||me==(te.s<0?3:2)):Me>j||Me==j&&(me==4||X||me==6&&de[q-1]&1||me==(te.s<0?8:7)),q<1||!de[0])g=X?K(x.charAt(1),-Ve,x.charAt(0)):x.charAt(0);else{if(de.length=q,X)for(--S;++de[--q]>S;)de[q]=0,q||(++$,de=[1].concat(de));for(j=de.length;!de[--j];);for(Me=0,g="";Me<=j;g+=x.charAt(de[Me++]));g=K(g,$,x.charAt(0))}return g}}(),k=function(){function l(I,S,U){var H,x,q,$,j=0,X=I.length,te=S%h,de=S/h|0;for(I=I.slice();X--;)q=I[X]%h,$=I[X]/h|0,H=de*q+$*te,x=te*q+H%h*h+j,j=(x/U|0)+(H/h|0)+de*$,I[X]=x%U;return j&&(I=[j].concat(I)),I}function p(I,S,U,H){var x,q;if(U!=H)q=U>H?1:-1;else for(x=q=0;x<U;x++)if(I[x]!=S[x]){q=I[x]>S[x]?1:-1;break}return q}function g(I,S,U,H){for(var x=0;U--;)I[U]-=x,x=I[U]<S[U]?1:0,I[U]=x*H+I[U]-S[U];for(;!I[0]&&I.length>1;I.splice(0,1));}return function(I,S,U,H,x){var q,$,j,X,te,de,_e,Me,Ve,me,he,Xe,vr,zr,Zr,jt,Ne,Tt=I.s==S.s?1:-1,st=I.c,$e=S.c;if(!st||!st[0]||!$e||!$e[0])return new M(!I.s||!S.s||(st?$e&&st[0]==$e[0]:!$e)?NaN:st&&st[0]==0||!$e?Tt*0:Tt/0);for(Me=new M(Tt),Ve=Me.c=[],$=I.e-S.e,Tt=U+$+1,x||(x=a,$=u(I.e/c)-u(S.e/c),Tt=Tt/c|0),j=0;$e[j]==(st[j]||0);j++);if($e[j]>(st[j]||0)&&$--,Tt<0)Ve.push(1),X=!0;else{for(zr=st.length,jt=$e.length,j=0,Tt+=2,te=i(x/($e[0]+1)),te>1&&($e=l($e,te,x),st=l(st,te,x),jt=$e.length,zr=st.length),vr=jt,me=st.slice(0,jt),he=me.length;he<jt;me[he++]=0);Ne=$e.slice(),Ne=[0].concat(Ne),Zr=$e[0],$e[1]>=x/2&&Zr++;do{if(te=0,q=p($e,me,jt,he),q<0){if(Xe=me[0],jt!=he&&(Xe=Xe*x+(me[1]||0)),te=i(Xe/Zr),te>1)for(te>=x&&(te=x-1),de=l($e,te,x),_e=de.length,he=me.length;p(de,me,_e,he)==1;)te--,g(de,jt<_e?Ne:$e,_e,x),_e=de.length,q=1;else te==0&&(q=te=1),de=$e.slice(),_e=de.length;if(_e<he&&(de=[0].concat(de)),g(me,de,he,x),he=me.length,q==-1)for(;p($e,me,jt,he)<1;)te++,g(me,jt<he?Ne:$e,he,x),he=me.length}else q===0&&(te++,me=[0]);Ve[j++]=te,me[0]?me[he++]=st[vr]||0:(me=[st[vr]],he=1)}while((vr++<zr||me[0]!=null)&&Tt--);X=me[0]!=null,Ve[0]||Ve.splice(0,1)}if(x==a){for(j=1,Tt=Ve[0];Tt>=10;Tt/=10,j++);le(Me,U+(Me.e=j+$*c-1)+1,H,X)}else Me.e=$,Me.r=+X;return Me}}();function y(l,p,g,I){var S,U,H,x,q;if(g==null?g=ie:P(g,0,8),!l.c)return l.toString();if(S=l.c[0],H=l.e,p==null)q=O(l.c),q=I==1||I==2&&(H<=w||H>=b)?A(q,H):K(q,H,"0");else if(l=le(new M(l),p,g),U=l.e,q=O(l.c),x=q.length,I==1||I==2&&(p<=U||U<=w)){for(;x<p;q+="0",x++);q=A(q,U)}else if(p-=H,q=K(q,U,"0"),U+1>x){if(--p>0)for(q+=".";p--;q+="0");}else if(p+=U-x,p>0)for(U+1==x&&(q+=".");p--;q+="0");return l.s<0&&S?"-"+q:q}function L(l,p){for(var g,I,S=1,U=new M(l[0]);S<l.length;S++)I=new M(l[S]),(!I.s||(g=T(U,I))===p||g===0&&U.s===p)&&(U=I);return U}function re(l,p,g){for(var I=1,S=p.length;!p[--S];p.pop());for(S=p[0];S>=10;S/=10,I++);return(g=I+g*c-1)>B?l.c=l.e=null:g<N?l.c=[l.e=0]:(l.e=g,l.c=p),l}z=function(){var l=/^(-?)0([xbo])(?=\w[\w.]*$)/i,p=/^([^.]+)\.$/,g=/^\.([^.]+)$/,I=/^-?(Infinity|NaN)$/,S=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(U,H,x,q){var $,j=x?H:H.replace(S,"");if(I.test(j))U.s=isNaN(j)?null:j<0?-1:1;else{if(!x&&(j=j.replace(l,function(X,te,de){return $=(de=de.toLowerCase())=="x"?16:de=="b"?2:8,!q||q==$?te:X}),q&&($=q,j=j.replace(p,"$1").replace(g,"0.$1")),H!=j))return new M(j,$);if(M.DEBUG)throw Error(s+"Not a"+(q?" base "+q:"")+" number: "+H);U.s=null}U.c=U.e=null}}();function le(l,p,g,I){var S,U,H,x,q,$,j,X=l.c,te=d;if(X){e:{for(S=1,x=X[0];x>=10;x/=10,S++);if(U=p-S,U<0)U+=c,H=p,q=X[$=0],j=i(q/te[S-H-1]%10);else if($=n((U+1)/c),$>=X.length)if(I){for(;X.length<=$;X.push(0));q=j=0,S=1,U%=c,H=U-c+1}else break e;else{for(q=x=X[$],S=1;x>=10;x/=10,S++);U%=c,H=U-c+S,j=H<0?0:i(q/te[S-H-1]%10)}if(I=I||p<0||X[$+1]!=null||(H<0?q:q%te[S-H-1]),I=g<4?(j||I)&&(g==0||g==(l.s<0?3:2)):j>5||j==5&&(g==4||I||g==6&&(U>0?H>0?q/te[S-H]:0:X[$-1])%10&1||g==(l.s<0?8:7)),p<1||!X[0])return X.length=0,I?(p-=l.e+1,X[0]=te[(c-p%c)%c],l.e=-p||0):X[0]=l.e=0,l;if(U==0?(X.length=$,x=1,$--):(X.length=$+1,x=te[c-U],X[$]=H>0?i(q/te[S-H]%te[H])*x:0),I)for(;;)if($==0){for(U=1,H=X[0];H>=10;H/=10,U++);for(H=X[0]+=x,x=1;H>=10;H/=10,x++);U!=x&&(l.e++,X[0]==a&&(X[0]=1));break}else{if(X[$]+=x,X[$]!=a)break;X[$--]=0,x=1}for(U=X.length;X[--U]===0;X.pop());}l.e>B?l.c=l.e=null:l.e<N&&(l.c=[l.e=0])}return l}function J(l){var p,g=l.e;return g===null?l.toString():(p=O(l.c),p=g<=w||g>=b?A(p,g):K(p,g,"0"),l.s<0?"-"+p:p)}return C.absoluteValue=C.abs=function(){var l=new M(this);return l.s<0&&(l.s=1),l},C.comparedTo=function(l,p){return T(this,new M(l,p))},C.decimalPlaces=C.dp=function(l,p){var g,I,S,U=this;if(l!=null)return P(l,0,m),p==null?p=ie:P(p,0,8),le(new M(U),l+U.e+1,p);if(!(g=U.c))return null;if(I=((S=g.length-1)-u(this.e/c))*c,S=g[S])for(;S%10==0;S/=10,I--);return I<0&&(I=0),I},C.dividedBy=C.div=function(l,p){return k(this,new M(l,p),Q,ie)},C.dividedToIntegerBy=C.idiv=function(l,p){return k(this,new M(l,p),0,1)},C.exponentiatedBy=C.pow=function(l,p){var g,I,S,U,H,x,q,$,j,X=this;if(l=new M(l),l.c&&!l.isInteger())throw Error(s+"Exponent not an integer: "+J(l));if(p!=null&&(p=new M(p)),x=l.e>14,!X.c||!X.c[0]||X.c[0]==1&&!X.e&&X.c.length==1||!l.c||!l.c[0])return j=new M(Math.pow(+J(X),x?l.s*(2-F(l)):+J(l))),p?j.mod(p):j;if(q=l.s<0,p){if(p.c?!p.c[0]:!p.s)return new M(NaN);I=!q&&X.isInteger()&&p.isInteger(),I&&(X=X.mod(p))}else{if(l.e>9&&(X.e>0||X.e<-1||(X.e==0?X.c[0]>1||x&&X.c[1]>=24e7:X.c[0]<8e13||x&&X.c[0]<=9999975e7)))return U=X.s<0&&F(l)?-0:0,X.e>-1&&(U=1/U),new M(q?1/U:U);D&&(U=n(D/c+2))}for(x?(g=new M(.5),q&&(l.s=1),$=F(l)):(S=Math.abs(+J(l)),$=S%2),j=new M(oe);;){if($){if(j=j.times(X),!j.c)break;U?j.c.length>U&&(j.c.length=U):I&&(j=j.mod(p))}if(S){if(S=i(S/2),S===0)break;$=S%2}else if(l=l.times(g),le(l,l.e+1,1),l.e>14)$=F(l);else{if(S=+J(l),S===0)break;$=S%2}X=X.times(X),U?X.c&&X.c.length>U&&(X.c.length=U):I&&(X=X.mod(p))}return I?j:(q&&(j=oe.div(j)),p?j.mod(p):U?le(j,D,ie,H):j)},C.integerValue=function(l){var p=new M(this);return l==null?l=ie:P(l,0,8),le(p,p.e+1,l)},C.isEqualTo=C.eq=function(l,p){return T(this,new M(l,p))===0},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(l,p){return T(this,new M(l,p))>0},C.isGreaterThanOrEqualTo=C.gte=function(l,p){return(p=T(this,new M(l,p)))===1||p===0},C.isInteger=function(){return!!this.c&&u(this.e/c)>this.c.length-2},C.isLessThan=C.lt=function(l,p){return T(this,new M(l,p))<0},C.isLessThanOrEqualTo=C.lte=function(l,p){return(p=T(this,new M(l,p)))===-1||p===0},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&this.c[0]==0},C.minus=function(l,p){var g,I,S,U,H=this,x=H.s;if(l=new M(l,p),p=l.s,!x||!p)return new M(NaN);if(x!=p)return l.s=-p,H.plus(l);var q=H.e/c,$=l.e/c,j=H.c,X=l.c;if(!q||!$){if(!j||!X)return j?(l.s=-p,l):new M(X?H:NaN);if(!j[0]||!X[0])return X[0]?(l.s=-p,l):new M(j[0]?H:ie==3?-0:0)}if(q=u(q),$=u($),j=j.slice(),x=q-$){for((U=x<0)?(x=-x,S=j):($=q,S=X),S.reverse(),p=x;p--;S.push(0));S.reverse()}else for(I=(U=(x=j.length)<(p=X.length))?x:p,x=p=0;p<I;p++)if(j[p]!=X[p]){U=j[p]<X[p];break}if(U&&(S=j,j=X,X=S,l.s=-l.s),p=(I=X.length)-(g=j.length),p>0)for(;p--;j[g++]=0);for(p=a-1;I>x;){if(j[--I]<X[I]){for(g=I;g&&!j[--g];j[g]=p);--j[g],j[I]+=a}j[I]-=X[I]}for(;j[0]==0;j.splice(0,1),--$);return j[0]?re(l,j,$):(l.s=ie==3?-1:1,l.c=[l.e=0],l)},C.modulo=C.mod=function(l,p){var g,I,S=this;return l=new M(l,p),!S.c||!l.s||l.c&&!l.c[0]?new M(NaN):!l.c||S.c&&!S.c[0]?new M(S):(V==9?(I=l.s,l.s=1,g=k(S,l,0,3),l.s=I,g.s*=I):g=k(S,l,0,V),l=S.minus(g.times(l)),!l.c[0]&&V==1&&(l.s=S.s),l)},C.multipliedBy=C.times=function(l,p){var g,I,S,U,H,x,q,$,j,X,te,de,_e,Me,Ve,me=this,he=me.c,Xe=(l=new M(l,p)).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(I=u(me.e/c)+u(l.e/c),l.s*=me.s,q=he.length,X=Xe.length,q<X&&(_e=he,he=Xe,Xe=_e,S=q,q=X,X=S),S=q+X,_e=[];S--;_e.push(0));for(Me=a,Ve=h,S=X;--S>=0;){for(g=0,te=Xe[S]%Ve,de=Xe[S]/Ve|0,H=q,U=S+H;U>S;)$=he[--H]%Ve,j=he[H]/Ve|0,x=de*$+j*te,$=te*$+x%Ve*Ve+_e[U]+g,g=($/Me|0)+(x/Ve|0)+de*j,_e[U--]=$%Me;_e[U]=g}return g?++I:_e.splice(0,1),re(l,_e,I)},C.negated=function(){var l=new M(this);return l.s=-l.s||null,l},C.plus=function(l,p){var g,I=this,S=I.s;if(l=new M(l,p),p=l.s,!S||!p)return new M(NaN);if(S!=p)return l.s=-p,I.minus(l);var U=I.e/c,H=l.e/c,x=I.c,q=l.c;if(!U||!H){if(!x||!q)return new M(S/0);if(!x[0]||!q[0])return q[0]?l:new M(x[0]?I:S*0)}if(U=u(U),H=u(H),x=x.slice(),S=U-H){for(S>0?(H=U,g=q):(S=-S,g=x),g.reverse();S--;g.push(0));g.reverse()}for(S=x.length,p=q.length,S-p<0&&(g=q,q=x,x=g,p=S),S=0;p;)S=(x[--p]=x[p]+q[p]+S)/a|0,x[p]=a===x[p]?0:x[p]%a;return S&&(x=[S].concat(x),++H),re(l,x,H)},C.precision=C.sd=function(l,p){var g,I,S,U=this;if(l!=null&&l!==!!l)return P(l,1,m),p==null?p=ie:P(p,0,8),le(new M(U),l,p);if(!(g=U.c))return null;if(S=g.length-1,I=S*c+1,S=g[S]){for(;S%10==0;S/=10,I--);for(S=g[0];S>=10;S/=10,I++);}return l&&U.e+1>I&&(I=U.e+1),I},C.shiftedBy=function(l){return P(l,-f,f),this.times("1e"+l)},C.squareRoot=C.sqrt=function(){var l,p,g,I,S,U=this,H=U.c,x=U.s,q=U.e,$=Q+4,j=new M("0.5");if(x!==1||!H||!H[0])return new M(!x||x<0&&(!H||H[0])?NaN:H?U:1/0);if(x=Math.sqrt(+J(U)),x==0||x==1/0?(p=O(H),(p.length+q)%2==0&&(p+="0"),x=Math.sqrt(+p),q=u((q+1)/2)-(q<0||q%2),x==1/0?p="5e"+q:(p=x.toExponential(),p=p.slice(0,p.indexOf("e")+1)+q),g=new M(p)):g=new M(x+""),g.c[0]){for(q=g.e,x=q+$,x<3&&(x=0);;)if(S=g,g=j.times(S.plus(k(U,S,$,1))),O(S.c).slice(0,x)===(p=O(g.c)).slice(0,x))if(g.e<q&&--x,p=p.slice(x-3,x+1),p=="9999"||!I&&p=="4999"){if(!I&&(le(S,S.e+Q+2,0),S.times(S).eq(U))){g=S;break}$+=4,x+=4,I=1}else{(!+p||!+p.slice(1)&&p.charAt(0)=="5")&&(le(g,g.e+Q+2,1),l=!g.times(g).eq(U));break}}return le(g,g.e+Q+1,ie,l)},C.toExponential=function(l,p){return l!=null&&(P(l,0,m),l++),y(this,l,p,1)},C.toFixed=function(l,p){return l!=null&&(P(l,0,m),l=l+this.e+1),y(this,l,p)},C.toFormat=function(l,p,g){var I,S=this;if(g==null)l!=null&&p&&typeof p=="object"?(g=p,p=null):l&&typeof l=="object"?(g=l,l=p=null):g=ce;else if(typeof g!="object")throw Error(s+"Argument not an object: "+g);if(I=S.toFixed(l,p),S.c){var U,H=I.split("."),x=+g.groupSize,q=+g.secondaryGroupSize,$=g.groupSeparator||"",j=H[0],X=H[1],te=S.s<0,de=te?j.slice(1):j,_e=de.length;if(q&&(U=x,x=q,q=U,_e-=U),x>0&&_e>0){for(U=_e%x||x,j=de.substr(0,U);U<_e;U+=x)j+=$+de.substr(U,x);q>0&&(j+=$+de.slice(U)),te&&(j="-"+j)}I=X?j+(g.decimalSeparator||"")+((q=+g.fractionGroupSize)?X.replace(new RegExp("\\d{"+q+"}\\B","g"),"$&"+(g.fractionGroupSeparator||"")):X):j}return(g.prefix||"")+I+(g.suffix||"")},C.toFraction=function(l){var p,g,I,S,U,H,x,q,$,j,X,te,de=this,_e=de.c;if(l!=null&&(x=new M(l),!x.isInteger()&&(x.c||x.s!==1)||x.lt(oe)))throw Error(s+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+J(x));if(!_e)return new M(de);for(p=new M(oe),$=g=new M(oe),I=q=new M(oe),te=O(_e),U=p.e=te.length-de.e-1,p.c[0]=d[(H=U%c)<0?c+H:H],l=!l||x.comparedTo(p)>0?U>0?p:$:x,H=B,B=1/0,x=new M(te),q.c[0]=0;j=k(x,p,0,1),S=g.plus(j.times(I)),S.comparedTo(l)!=1;)g=I,I=S,$=q.plus(j.times(S=$)),q=S,p=x.minus(j.times(S=p)),x=S;return S=k(l.minus(g),I,0,1),q=q.plus(S.times($)),g=g.plus(S.times(I)),q.s=$.s=de.s,U=U*2,X=k($,I,U,ie).minus(de).abs().comparedTo(k(q,g,U,ie).minus(de).abs())<1?[$,I]:[q,g],B=H,X},C.toNumber=function(){return+J(this)},C.toPrecision=function(l,p){return l!=null&&P(l,1,m),y(this,l,p,2)},C.toString=function(l){var p,g=this,I=g.s,S=g.e;return S===null?I?(p="Infinity",I<0&&(p="-"+p)):p="NaN":(l==null?p=S<=w||S>=b?A(O(g.c),S):K(O(g.c),S,"0"):l===10&&Z?(g=le(new M(g),Q+S+1,ie),p=K(O(g.c),g.e,"0")):(P(l,2,ae.length,"Base"),p=G(K(O(g.c),S,"0"),10,l,I,!0)),I<0&&g.c[0]&&(p="-"+p)),p},C.valueOf=C.toJSON=function(){return J(this)},C._isBigNumber=!0,E!=null&&M.set(E),M}function u(E){var k=E|0;return E>0||E===k?k:k-1}function O(E){for(var k,G,z=1,C=E.length,oe=E[0]+"";z<C;){for(k=E[z++]+"",G=c-k.length;G--;k="0"+k);oe+=k}for(C=oe.length;oe.charCodeAt(--C)===48;);return oe.slice(0,C+1||1)}function T(E,k){var G,z,C=E.c,oe=k.c,Q=E.s,ie=k.s,w=E.e,b=k.e;if(!Q||!ie)return null;if(G=C&&!C[0],z=oe&&!oe[0],G||z)return G?z?0:-ie:Q;if(Q!=ie)return Q;if(G=Q<0,z=w==b,!C||!oe)return z?0:!C^G?1:-1;if(!z)return w>b^G?1:-1;for(ie=(w=C.length)<(b=oe.length)?w:b,Q=0;Q<ie;Q++)if(C[Q]!=oe[Q])return C[Q]>oe[Q]^G?1:-1;return w==b?0:w>b^G?1:-1}function P(E,k,G,z){if(E<k||E>G||E!==i(E))throw Error(s+(z||"Argument")+(typeof E=="number"?E<k||E>G?" out of range: ":" not an integer: ":" not a primitive number: ")+String(E))}function F(E){var k=E.c.length-1;return u(E.e/c)==k&&E.c[k]%2!=0}function A(E,k){return(E.length>1?E.charAt(0)+"."+E.slice(1):E)+(k<0?"e":"e+")+k}function K(E,k,G){var z,C;if(k<0){for(C=G+".";++k;C+=G);E=C+E}else if(z=E.length,++k>z){for(C=G,k-=z;--k;C+=G);E+=C}else k<z&&(E=E.slice(0,k)+"."+E.slice(k));return E}e=_(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof qo<"u"&&qo.exports?qo.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(Qd)});var e0=ee((ev,Ld)=>{Ld.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,O=r.pushUndefined,T=r.pushNull,P=r.pushInfinity,F=r.pushInfinityNeg,A=r.pushNaN,K=r.pushNaNNeg,E=r.pushArrayStart,k=r.pushArrayStartFixed,G=r.pushArrayStartFixed32,z=r.pushArrayStartFixed64,C=r.pushObjectStart,oe=r.pushObjectStartFixed,Q=r.pushObjectStartFixed32,ie=r.pushObjectStartFixed64,w=r.pushByteString,b=r.pushByteStringStart,N=r.pushUtf8String,B=r.pushUtf8StringStart,R=r.pushSimpleUnassigned,V=r.pushTagStart,D=r.pushTagStart4,ce=r.pushTagStart8,ae=r.pushTagUnassigned,Z=r.pushBreak,M=e.Math.pow,y=0,L=0,re=0;function le(v){for(v=v|0,y=0,L=v;(y|0)<(L|0)&&(re=Yg[i[y]&255](i[y]|0)|0,!((re|0)>0)););return re|0}function J(v){return v=v|0,((y|0)+(v|0)|0)<(L|0)?0:1}function l(v){return v=v|0,i[v|0]<<8|i[v+1|0]|0}function p(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),y=y+1|0,0}function I(v){return v=v|0,J(1)|0?1:(s(i[y+1|0]|0),y=y+2|0,0)}function S(v){return v=v|0,J(2)|0?1:(s(l(y+1|0)|0),y=y+3|0,0)}function U(v){return v=v|0,J(4)|0?1:(o(l(y+1|0)|0,l(y+3|0)|0),y=y+5|0,0)}function H(v){return v=v|0,J(8)|0?1:(c(l(y+1|0)|0,l(y+3|0)|0,l(y+5|0)|0,l(y+7|0)|0),y=y+9|0,0)}function x(v){return v=v|0,s(-1-(v-32|0)|0),y=y+1|0,0}function q(v){return v=v|0,J(1)|0?1:(s(-1-(i[y+1|0]|0)|0),y=y+2|0,0)}function $(v){v=v|0;var Ae=0;return J(2)|0?1:(Ae=l(y+1|0)|0,s(-1-(Ae|0)|0),y=y+3|0,0)}function j(v){return v=v|0,J(4)|0?1:(a(l(y+1|0)|0,l(y+3|0)|0),y=y+5|0,0)}function X(v){return v=v|0,J(8)|0?1:(f(l(y+1|0)|0,l(y+3|0)|0,l(y+5|0)|0,l(y+7|0)|0),y=y+9|0,0)}function te(v){v=v|0;var Ae=0,Oe=0,xe=0;return xe=v-64|0,J(xe|0)|0?1:(Ae=y+1|0,Oe=(y+1|0)+(xe|0)|0,w(Ae|0,Oe|0),y=Oe|0,0)}function de(v){v=v|0;var Ae=0,Oe=0,xe=0;return J(1)|0||(xe=i[y+1|0]|0,Ae=y+2|0,Oe=(y+2|0)+(xe|0)|0,J(xe+1|0)|0)?1:(w(Ae|0,Oe|0),y=Oe|0,0)}function _e(v){v=v|0;var Ae=0,Oe=0,xe=0;return J(2)|0||(xe=l(y+1|0)|0,Ae=y+3|0,Oe=(y+3|0)+(xe|0)|0,J(xe+2|0)|0)?1:(w(Ae|0,Oe|0),y=Oe|0,0)}function Me(v){v=v|0;var Ae=0,Oe=0,xe=0;return J(4)|0||(xe=p(y+1|0)|0,Ae=y+5|0,Oe=(y+5|0)+(xe|0)|0,J(xe+4|0)|0)?1:(w(Ae|0,Oe|0),y=Oe|0,0)}function Ve(v){return v=v|0,1}function me(v){return v=v|0,b(),y=y+1|0,0}function he(v){v=v|0;var Ae=0,Oe=0,xe=0;return xe=v-96|0,J(xe|0)|0?1:(Ae=y+1|0,Oe=(y+1|0)+(xe|0)|0,N(Ae|0,Oe|0),y=Oe|0,0)}function Xe(v){v=v|0;var Ae=0,Oe=0,xe=0;return J(1)|0||(xe=i[y+1|0]|0,Ae=y+2|0,Oe=(y+2|0)+(xe|0)|0,J(xe+1|0)|0)?1:(N(Ae|0,Oe|0),y=Oe|0,0)}function vr(v){v=v|0;var Ae=0,Oe=0,xe=0;return J(2)|0||(xe=l(y+1|0)|0,Ae=y+3|0,Oe=(y+3|0)+(xe|0)|0,J(xe+2|0)|0)?1:(N(Ae|0,Oe|0),y=Oe|0,0)}function zr(v){v=v|0;var Ae=0,Oe=0,xe=0;return J(4)|0||(xe=p(y+1|0)|0,Ae=y+5|0,Oe=(y+5|0)+(xe|0)|0,J(xe+4|0)|0)?1:(N(Ae|0,Oe|0),y=Oe|0,0)}function Zr(v){return v=v|0,1}function jt(v){return v=v|0,B(),y=y+1|0,0}function Ne(v){return v=v|0,k(v-128|0),y=y+1|0,0}function Tt(v){return v=v|0,J(1)|0?1:(k(i[y+1|0]|0),y=y+2|0,0)}function st(v){return v=v|0,J(2)|0?1:(k(l(y+1|0)|0),y=y+3|0,0)}function $e(v){return v=v|0,J(4)|0?1:(G(l(y+1|0)|0,l(y+3|0)|0),y=y+5|0,0)}function Ec(v){return v=v|0,J(8)|0?1:(z(l(y+1|0)|0,l(y+3|0)|0,l(y+5|0)|0,l(y+7|0)|0),y=y+9|0,0)}function xc(v){return v=v|0,E(),y=y+1|0,0}function Ke(v){v=v|0;var Ae=0;return Ae=v-160|0,J(Ae|0)|0?1:(oe(Ae|0),y=y+1|0,0)}function vc(v){return v=v|0,J(1)|0?1:(oe(i[y+1|0]|0),y=y+2|0,0)}function Tc(v){return v=v|0,J(2)|0?1:(oe(l(y+1|0)|0),y=y+3|0,0)}function Ac(v){return v=v|0,J(4)|0?1:(Q(l(y+1|0)|0,l(y+3|0)|0),y=y+5|0,0)}function Sc(v){return v=v|0,J(8)|0?1:(ie(l(y+1|0)|0,l(y+3|0)|0,l(y+5|0)|0,l(y+7|0)|0),y=y+9|0,0)}function Bc(v){return v=v|0,C(),y=y+1|0,0}function an(v){return v=v|0,V(v-192|0|0),y=y+1|0,0}function w8(v){return v=v|0,V(v|0),y=y+1|0,0}function E8(v){return v=v|0,V(v|0),y=y+1|0,0}function x8(v){return v=v|0,V(v|0),y=y+1|0,0}function v8(v){return v=v|0,V(v|0),y=y+1|0,0}function ft(v){return v=v|0,V(v-192|0|0),y=y+1|0,0}function T8(v){return v=v|0,V(v|0),y=y+1|0,0}function A8(v){return v=v|0,V(v|0),y=y+1|0,0}function S8(v){return v=v|0,V(v|0),y=y+1|0,0}function Ig(v){return v=v|0,J(1)|0?1:(V(i[y+1|0]|0),y=y+2|0,0)}function Ug(v){return v=v|0,J(2)|0?1:(V(l(y+1|0)|0),y=y+3|0,0)}function Fg(v){return v=v|0,J(4)|0?1:(D(l(y+1|0)|0,l(y+3|0)|0),y=y+5|0,0)}function Mg(v){return v=v|0,J(8)|0?1:(ce(l(y+1|0)|0,l(y+3|0)|0,l(y+5|0)|0,l(y+7|0)|0),y=y+9|0,0)}function rt(v){return v=v|0,R((v|0)-224|0),y=y+1|0,0}function qg(v){return v=v|0,u(),y=y+1|0,0}function Cg(v){return v=v|0,_(),y=y+1|0,0}function kg(v){return v=v|0,T(),y=y+1|0,0}function jg(v){return v=v|0,O(),y=y+1|0,0}function Hg(v){return v=v|0,J(1)|0?1:(R(i[y+1|0]|0),y=y+2|0,0)}function Vg(v){v=v|0;var Ae=0,Oe=0,xe=1,to=0,Xi=0,B8=0;return J(2)|0?1:(Ae=i[y+1|0]|0,Oe=i[y+2|0]|0,(Ae|0)&128&&(xe=-1),to=+(((Ae|0)&124)>>2),Xi=+(((Ae|0)&3)<<8|Oe),+to==0?d(+(+xe*5960464477539063e-23*+Xi)):+to==31?+xe==1?+Xi>0?A():P():+Xi>0?K():F():d(+(+xe*M(2,+(+to-25))*+(1024+Xi))),y=y+3|0,0)}function $g(v){return v=v|0,J(4)|0?1:(h(i[y+1|0]|0,i[y+2|0]|0,i[y+3|0]|0,i[y+4|0]|0),y=y+5|0,0)}function Kg(v){return v=v|0,J(8)|0?1:(m(i[y+1|0]|0,i[y+2|0]|0,i[y+3|0]|0,i[y+4|0]|0,i[y+5|0]|0,i[y+6|0]|0,i[y+7|0]|0,i[y+8|0]|0),y=y+9|0,0)}function je(v){return v=v|0,1}function Gg(v){return v=v|0,Z(),y=y+1|0,0}var Yg=[g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,I,S,U,H,je,je,je,je,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,q,$,j,X,je,je,je,je,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,de,_e,Me,Ve,je,je,je,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,vr,zr,Zr,je,je,je,jt,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Tt,st,$e,Ec,je,je,je,xc,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,vc,Tc,Ac,Sc,je,je,je,Bc,an,an,an,an,an,an,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,Ig,Ug,Fg,Mg,je,je,je,je,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,qg,Cg,kg,jg,Hg,Vg,$g,Kg,je,je,je,Gg];return{parse:le}}});var cs=ee(zt=>{"use strict";var wu=as().BigNumber;zt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};zt.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};zt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};zt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};zt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};zt.SHIFT32=Math.pow(2,32);zt.SHIFT16=Math.pow(2,16);zt.MAX_SAFE_HIGH=2097151;zt.NEG_ONE=new wu(-1);zt.TEN=new wu(10);zt.TWO=new wu(2);zt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Co=ee(nr=>{"use strict";var{Buffer:Db}=ai("buffer"),r0=as().BigNumber,n0=cs(),t0=n0.SHIFT32,Xb=n0.SHIFT16,Jb=2097151;nr.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 Qb(t){return t<16?"0"+t.toString(16):t.toString(16)}nr.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=Qb(t[n]);return new r0(r,16)};nr.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};nr.buildInt32=(t,e)=>t*Xb+e;nr.buildInt64=(t,e,r,n)=>{let i=nr.buildInt32(t,e),s=nr.buildInt32(r,n);return i>Jb?new r0(i).times(t0).plus(s):i*t0+s};nr.writeHalf=function(e,r){let n=Db.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};nr.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])};nr.isNegativeZero=t=>t===0&&1/t<0;nr.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Tu=ee((nv,i0)=>{"use strict";var vu=cs(),Lb=vu.MT,ko=vu.SIMPLE,Eu=vu.SYMS,xu=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,Lb.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case ko.FALSE:return!1;case ko.TRUE:return!0;case ko.NULL:return r?null:Eu.NULL;case ko.UNDEFINED:return r?void 0:Eu.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Eu.BREAK;default:return new t(e)}}};i0.exports=xu});var Su=ee((iv,s0)=>{"use strict";var Au=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}}};s0.exports=Au});var Ou=ee((sv,a0)=>{"use strict";var{URL:e1,URLSearchParams:t1,format:r1}=ai("url"),o0="http://localhost",Bu=class extends e1{constructor(e="",r=o0){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()}};a0.exports={URLWithLegacySupport:Bu,URLSearchParams:t1,format:r1,defaultBase:o0}});var l0=ee((ov,u0)=>{"use strict";var{URLWithLegacySupport:c0,format:n1}=Ou();u0.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new c0(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new c0(t,n1(o)).toString()}});var Nu=ee((av,f0)=>{"use strict";var{URLWithLegacySupport:i1,format:s1,URLSearchParams:o1,defaultBase:a1}=Ou(),c1=l0();f0.exports={URL:i1,URLSearchParams:o1,format:s1,relative:c1,defaultBase:a1}});var Ru=ee((cv,h0)=>{"use strict";var{Buffer:vi}=ai("buffer"),d0=Rc(),u1=as().BigNumber,l1=e0(),Ft=Co(),qe=cs(),f1=Tu(),d1=Su(),{URL:h1}=Nu(),us=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=Ft.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=vi.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>Ft.arrayBufferToBignumber(r),3:r=>qe.NEG_ONE.minus(Ft.arrayBufferToBignumber(r)),4:r=>qe.TEN.pow(r[0]).times(r[1]),5:r=>qe.TWO.pow(r[0]).times(r[1]),32:r=>new h1(r),35:r=>new RegExp(r)},e.tags),this.parser=l1(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 qe.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case qe.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case qe.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case qe.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 qe.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 qe.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===qe.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 qe.PARENT.ARRAY:case qe.PARENT.BYTE_STRING:case qe.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case qe.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=qe.PARENT.MAP,n.ref=Ft.buildMap(n.ref)));break;case qe.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case qe.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:qe.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new d1(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return vi.concat(e)}createByteStringFromHeap(e,r){return e===r?vi.alloc(0):vi.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return Ft.buildInt32(e,r)}createInt64(e,r,n,i){return Ft.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return d0.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return d0.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-Ft.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=Ft.buildInt32(e,r),o=Ft.buildInt32(n,i);return s>qe.MAX_SAFE_HIGH?qe.NEG_ONE.minus(new u1(s).times(qe.SHIFT32).plus(o)):-1-(s*qe.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 f1(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([],qe.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=Ft.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=Ft.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=Ft.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=Ft.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:qe.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:qe.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:qe.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(Ft.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(Ft.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({},qe.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),qe.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=vi.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=vi.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};us.decodeFirst=us.decode;h0.exports=us});var g0=ee((uv,y0)=>{"use strict";var{Buffer:Pu}=ai("buffer"),p1=Ru(),y1=Co(),Iu=class t extends p1{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 y1.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'${Pu.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(p0(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(p0(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${Pu.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=Pu.from(e,r||"hex")),new t().decodeFirst(e)}};y0.exports=Iu;function p0(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var E0=ee((lv,w0)=>{"use strict";var{Buffer:Ir}=ai("buffer"),{URL:g1}=Nu(),Fu=as().BigNumber,Uu=Co(),ot=cs(),lr=ot.MT,jo=ot.NUMBYTES,m0=ot.SHIFT32,b0=ot.SYMS,Ti=ot.TAG,m1=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.TWO,b1=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.FOUR,_1=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.EIGHT,w1=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.TRUE,E1=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.FALSE,x1=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.UNDEFINED,_0=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.NULL,v1=new Fu("0x20000000000000"),T1=Ir.from("f97e00","hex"),A1=Ir.from("f9fc00","hex"),S1=Ir.from("f97c00","hex");function B1(t){return{}.toString.call(t).slice(8,-1)}var Mu=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[g1,this._pushUrl],[Fu,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(T1)}_pushInfinity(e){let r=e<0?A1:S1;return this.push(r)}_pushFloat(e){let r=Ir.allocUnsafe(2);if(Uu.writeHalf(r,e)&&Uu.parseHalf(r)===e)return this._pushUInt8(m1)&&this.push(r);let n=Ir.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(b1)&&this.push(n):this._pushUInt8(_1)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|jo.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|jo.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|jo.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|jo.EIGHT)&&this._pushUInt32BE(Math.floor(e/m0))&&this._pushUInt32BE(e%m0):r===lr.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,lr.NEG_INT,e):this._pushInt(e,lr.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=Ir.byteLength(e,"utf8");return this._pushInt(r,lr.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?w1:E1)}_pushUndefined(e){return this._pushUInt8(x1)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,lr.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,lr.TAG)}_pushDate(e,r){return e._pushTag(Ti.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,lr.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(Ti.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,lr.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(Ti.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=Ti.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=Ti.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Ir.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(Ti.DECIMAL_FRAC)&&e._pushInt(2,lr.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new Fu(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(v1)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,lr.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(_0);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,lr.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(Uu.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=B1(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,Ir.isBuffer(e)?e:Ir.from(e));case"Null":return this._pushUInt8(_0);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 b0.NULL:return this._pushObject(null);case b0.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=Ir.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()}};w0.exports=Mu});var Ho=ee(at=>{"use strict";at.Diagnose=g0();at.Decoder=Ru();at.Encoder=E0();at.Simple=Tu();at.Tagged=Su();at.decodeAll=at.Decoder.decodeAll;at.decodeFirst=at.Decoder.decodeFirst;at.diagnose=at.Diagnose.diagnose;at.encode=at.Encoder.encode;at.decode=at.Decoder.decode;at.leveldb={decode:at.Decoder.decodeAll,encode:at.Encoder.encode,buffer:!0,name:"cbor"}});var ds=ee(ir=>{"use strict";var O1=ir&&ir.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ir,"__esModule",{value:!0});ir.hashOfMap=ir.requestIdOf=ir.hashValue=ir.hash=void 0;var x0=xi(),N1=O1(Ho()),R1=fo(),ls=Vt();function gn(t){return(0,ls.uint8ToBuf)(R1.sha256.create().update(new Uint8Array(t)).digest())}ir.hash=gn;function fs(t){if(t instanceof N1.default.Tagged)return fs(t.value);if(typeof t=="string")return v0(t);if(typeof t=="number")return gn((0,x0.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return gn(t);if(Array.isArray(t)){let e=t.map(fs);return gn((0,ls.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return gn(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return fs(t.toHash());if(typeof t=="object")return qu(t);if(typeof t=="bigint")return gn((0,x0.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}ir.hashValue=fs;var v0=t=>{let e=new TextEncoder().encode(t);return gn(e)};function P1(t){return qu(t)}ir.requestIdOf=P1;function qu(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=v0(o),f=fs(a);return[c,f]}).sort(([o],[a])=>(0,ls.compare)(o,a)),i=(0,ls.concat)(...n.map(o=>(0,ls.concat)(...o)));return gn(i)}ir.hashOfMap=qu});var ju=ee(Ur=>{"use strict";var I1=Ur&&Ur.__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(Ur,"__esModule",{value:!0});Ur.createIdentityDescriptor=Ur.AnonymousIdentity=Ur.SignIdentity=void 0;var T0=Ut(),U1=ds(),A0=Vt(),F1=new TextEncoder().encode(`
|
|
17
|
-
ic-request`),Cu=class{getPrincipal(){return this._principal||(this._principal=T0.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=I1(e,["body"]),i=(0,U1.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,A0.concat)(F1,i))}})}};Ur.SignIdentity=Cu;var ku=class{getPrincipal(){return T0.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};Ur.AnonymousIdentity=ku;function M1(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,A0.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Ur.createIdentityDescriptor=M1});var $u=ee(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});var q1=9007199254740992;function Qr(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 fr(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 Vo(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 fr(t,r,e.toString(16))}}function S0(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 Qr(new Uint8Array(Vo(3,t.length)),new Uint8Array(e))}function C1(t,e){if(t==14277111)return Qr(new Uint8Array([217,217,247]),e);if(t<24)return Qr(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}}Ge.tagged=C1;function hs(t){return new Uint8Array(t).buffer}Ge.raw=hs;function Hu(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}Ge.uSmall=Hu;function B0(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),fr(0,24,t)}Ge.u8=B0;function O0(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),fr(0,25,t)}Ge.u16=O0;function N0(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),fr(0,26,t)}Ge.u32=N0;function Vu(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return fr(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),q1),t=t.toString(16),fr(0,27,t)}Ge.u64=Vu;function R0(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Hu(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ge.iSmall=R0;function P0(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),fr(1,24,t)}Ge.i8=P0;function I0(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),fr(1,25,t)}Ge.i16=I0;function U0(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),fr(1,26,t)}Ge.i32=U0;function F0(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?fr(1,27,n):Vu(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),fr(1,27,t)}Ge.i64=F0;function k1(t){return t>=0?t<24?Hu(t):t<=255?B0(t):t<=65535?O0(t):t<=4294967295?N0(t):Vu(t):t>=-24?R0(t):t>=-255?P0(t):t>=-65535?I0(t):t>=-4294967295?U0(t):F0(t)}Ge.number=k1;function j1(t){return Qr(Vo(2,t.byteLength),t)}Ge.bytes=j1;function H1(t){return S0(t)}Ge.string=H1;function V1(t){return Qr(Vo(4,t.length),...t)}Ge.array=V1;function $1(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))),Qr(Vo(5,t.size),...r.map(([n,i])=>Qr(S0(n),i)))}Ge.map=$1;function K1(t){let e=new Float32Array([t]);return Qr(new Uint8Array([250]),new Uint8Array(e.buffer))}Ge.singleFloat=K1;function G1(t){let e=new Float64Array([t]);return Qr(new Uint8Array([251]),new Uint8Array(e.buffer))}Ge.doubleFloat=G1;function Y1(t){return t?M0():q0()}Ge.bool=Y1;function M0(){return hs(new Uint8Array([245]))}Ge.true_=M0;function q0(){return hs(new Uint8Array([244]))}Ge.false_=q0;function W1(){return hs(new Uint8Array([246]))}Ge.null_=W1;function z1(){return hs(new Uint8Array([247]))}Ge.undefined_=z1});var C0=ee(mn=>{"use strict";var Z1=mn&&mn.__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(mn,"__esModule",{value:!0});var dr=Z1($u()),D1=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],$o=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 dr.undefined_();case"boolean":return dr.bool(e);case"number":return Math.floor(e)===e?dr.number(e):dr.doubleFloat(e);case"string":return dr.string(e);case"object":if(e===null)return dr.null_();if(Array.isArray(e))return dr.array(e.map(r=>this._serializer.serializeValue(r)));if(D1.find(r=>e instanceof r))return dr.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 dr.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 dr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};mn.JsonDefaultCborEncoder=$o;var Ko=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};mn.ToCborEncoder=Ko;var Go=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new $o(r,e)),r.addEncoder(new Ko),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)}};mn.CborSerializer=Go;var Ku=class extends Go{serialize(e){return dr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};mn.SelfDescribeCborSerializer=Ku});var ps=ee(Vn=>{"use strict";function X1(t){for(var e in t)Vn.hasOwnProperty(e)||(Vn[e]=t[e])}var J1=Vn&&Vn.__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(Vn,"__esModule",{value:!0});X1(C0());var Q1=J1($u());Vn.value=Q1});var ys=ee(bt=>{"use strict";var L1=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]}),e_=bt&&bt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),t_=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)&&L1(e,t,r);return e_(e,t),e},r_=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 n_=r_(Ho()),Ai=t_(ps()),i_=ps(),Yo=Vt(),Gu=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Ai.value.bytes(e.toUint8Array())}},Yu=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Ai.value.bytes(new Uint8Array(e))}},Wu=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Ai.value.tagged(2,Ai.value.bytes((0,Yo.fromHex)(e.toString(16)))):Ai.value.tagged(3,Ai.value.bytes((0,Yo.fromHex)((BigInt("-1")*e).toString(16))))}},Wo=i_.SelfDescribeCborSerializer.withDefaultEncoders(!0);Wo.addEncoder(new Gu);Wo.addEncoder(new Yu);Wo.addEncoder(new Wu);var j0;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(j0=bt.CborTag||(bt.CborTag={}));function s_(t){return Wo.serialize(t)}bt.encode=s_;function k0(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 zu=class extends n_.default.Decoder{createByteString(e){return(0,Yo.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function o_(t){let e=new Uint8Array(t),r=new zu({size:e.byteLength,tags:{2:n=>k0(n),3:n=>-k0(n),[j0.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,Yo.toHex)(e)}`)}}bt.decode=o_});var Zu=ee(zo=>{"use strict";Object.defineProperty(zo,"__esModule",{value:!0});zo.randomNumber=void 0;var a_=()=>{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)};zo.randomNumber=a_});var gs=ee($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.makeNonce=$n.SubmitRequestType=void 0;var Zo=Zu(),c_;(function(t){t.Call="call"})(c_=$n.SubmitRequestType||($n.SubmitRequestType={}));function u_(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,Zo.randomNumber)(),n=(0,Zo.randomNumber)(),i=(0,Zo.randomNumber)(),s=(0,Zo.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}$n.makeNonce=u_});var Xo=ee(Bt=>{"use strict";var l_=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]}),f_=Bt&&Bt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),d_=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)&&l_(e,t,r);return f_(e,t),e};Object.defineProperty(Bt,"__esModule",{value:!0});Bt.httpHeadersTransform=Bt.makeExpiryTransform=Bt.makeNonceTransform=Bt.Expiry=void 0;var h_=xi(),p_=d_(ps()),y_=gs(),H0=BigInt(1e6),g_=60*1e3,Do=class{constructor(e){if(e<90*1e3){let a=BigInt(Date.now()+e)*H0/BigInt(1e9);this._value=a*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-g_))*H0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return p_.value.u64(this._value.toString(16),16)}toHash(){return(0,h_.lebEncode)(this._value)}};Bt.Expiry=Do;function m_(t=y_.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}Bt.makeNonceTransform=m_;function b_(t){return async e=>{e.body.ingress_expiry=new Do(t)}}Bt.makeExpiryTransform=b_;function __(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}Bt.httpHeadersTransform=__});var Qo=ee(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.AgentReadStateError=Fr.AgentQueryError=Fr.AgentCallError=Fr.AgentHTTPResponseError=void 0;var Jo=yi(),Du=class extends Jo.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Fr.AgentHTTPResponseError=Du;var Xu=class extends Jo.AgentError{constructor(e,r,n,i,s,o){super(e),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}};Fr.AgentCallError=Xu;var Ju=class extends Jo.AgentError{constructor(e,r,n,i,s,o){super(e),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}};Fr.AgentQueryError=Ju;var Qu=class extends Jo.AgentError{constructor(e,r,n,i,s,o){super(e),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};Fr.AgentReadStateError=Qu});var Zt=ee(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.notImplemented=Ie.bitMask=void 0;Ie.isBytes=ea;Ie.abytes=ta;Ie.abool=E_;Ie.bytesToHex=rl;Ie.numberToHexUnpadded=K0;Ie.hexToNumber=nl;Ie.hexToBytes=ra;Ie.bytesToNumberBE=v_;Ie.bytesToNumberLE=T_;Ie.numberToBytesBE=G0;Ie.numberToBytesLE=A_;Ie.numberToVarBytesBE=S_;Ie.ensureBytes=B_;Ie.concatBytes=Y0;Ie.equalBytes=O_;Ie.utf8ToBytes=N_;Ie.inRange=W0;Ie.aInRange=R_;Ie.bitLen=P_;Ie.bitGet=I_;Ie.bitSet=U_;Ie.createHmacDrbg=M_;Ie.validateObject=C_;Ie.memoized=j_;var tl=BigInt(0),Lo=BigInt(1),w_=BigInt(2);function ea(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function ta(t){if(!ea(t))throw new Error("Uint8Array expected")}function E_(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}var x_=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function rl(t){ta(t);let e="";for(let r=0;r<t.length;r++)e+=x_[t[r]];return e}function K0(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function nl(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Lr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function V0(t){if(t>=Lr._0&&t<=Lr._9)return t-Lr._0;if(t>=Lr._A&&t<=Lr._F)return t-(Lr._A-10);if(t>=Lr._a&&t<=Lr._f)return t-(Lr._a-10)}function ra(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=V0(t.charCodeAt(s)),a=V0(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 v_(t){return nl(rl(t))}function T_(t){return ta(t),nl(rl(Uint8Array.from(t).reverse()))}function G0(t,e){return ra(t.toString(16).padStart(e*2,"0"))}function A_(t,e){return G0(t,e).reverse()}function S_(t){return ra(K0(t))}function B_(t,e,r){let n;if(typeof e=="string")try{n=ra(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(ea(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 Y0(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];ta(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 O_(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 N_(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}var Lu=t=>typeof t=="bigint"&&tl<=t;function W0(t,e,r){return Lu(t)&&Lu(e)&&Lu(r)&&e<=t&&t<r}function R_(t,e,r,n){if(!W0(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function P_(t){let e;for(e=0;t>tl;t>>=Lo,e+=1);return e}function I_(t,e){return t>>BigInt(e)&Lo}function U_(t,e,r){return t|(r?Lo:tl)<<BigInt(e)}var F_=t=>(w_<<BigInt(t-1))-Lo;Ie.bitMask=F_;var el=t=>new Uint8Array(t),$0=t=>Uint8Array.from(t);function M_(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=el(t),i=el(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...h)=>r(i,n,...h),c=(h=el())=>{i=a($0([0]),h),n=a(),h.length!==0&&(i=a($0([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 Y0(...m)};return(h,m)=>{o(),c(h);let _;for(;!(_=m(f()));)c();return o(),_}}var q_={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"||ea(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 C_(t,e,r={}){let n=(i,s,o)=>{let a=q_[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 k_=()=>{throw new Error("not implemented")};Ie.notImplemented=k_;function j_(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 Mr=ee(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.isNegativeLE=void 0;ze.mod=Dt;ze.pow=D0;ze.pow2=K_;ze.invert=na;ze.tonelliShanks=X0;ze.FpSqrt=J0;ze.validateField=W_;ze.FpPow=Q0;ze.FpInvertBatch=L0;ze.FpDiv=z_;ze.FpLegendre=eh;ze.FpIsSquare=Z_;ze.nLength=sl;ze.Field=D_;ze.FpSqrtOdd=X_;ze.FpSqrtEven=J_;ze.hashToPrivateScalar=Q_;ze.getFieldBytesLength=ol;ze.getMinHashLength=th;ze.mapHashToField=L_;var Xt=Zt(),ct=BigInt(0),He=BigInt(1),bn=BigInt(2),H_=BigInt(3),il=BigInt(4),z0=BigInt(5),Z0=BigInt(8),V_=BigInt(9),$_=BigInt(16);function Dt(t,e){let r=t%e;return r>=ct?r:e+r}function D0(t,e,r){if(r<=ct||e<ct)throw new Error("Expected power/modulo > 0");if(r===He)return ct;let n=He;for(;e>ct;)e&He&&(n=n*t%r),t=t*t%r,e>>=He;return n}function K_(t,e,r){let n=t;for(;e-- >ct;)n*=n,n%=r;return n}function na(t,e){if(t===ct||e<=ct)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Dt(t,e),n=e,i=ct,s=He,o=He,a=ct;for(;r!==ct;){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 Dt(i,e)}function X0(t){let e=(t-He)/bn,r,n,i;for(r=t-He,n=0;r%bn===ct;r/=bn,n++);for(i=bn;i<t&&D0(i,e,t)!==t-He;i++);if(n===1){let o=(t+He)/il;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)/bn;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 O=a.sqr(m);_<f&&!a.eql(O,a.ONE);_++)O=a.sqr(O);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 J0(t){if(t%il===H_){let e=(t+He)/il;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%Z0===z0){let e=(t-z0)/Z0;return function(n,i){let s=n.mul(i,bn),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,bn),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%$_,X0(t)}var G_=(t,e)=>(Dt(t,e)&He)===He;ze.isNegativeLE=G_;var Y_=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function W_(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Y_.reduce((n,i)=>(n[i]="function",n),e);return(0,Xt.validateObject)(t,r)}function Q0(t,e,r){if(r<ct)throw new Error("Expected power > 0");if(r===ct)return t.ONE;if(r===He)return e;let n=t.ONE,i=e;for(;r>ct;)r&He&&(n=t.mul(n,i)),i=t.sqr(i),r>>=He;return n}function L0(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 z_(t,e,r){return t.mul(e,typeof r=="bigint"?na(r,t.ORDER):t.inv(r))}function eh(t){let e=(t-He)/bn;return(r,n)=>r.pow(n,e)}function Z_(t){let e=eh(t.ORDER);return r=>{let n=e(t,r);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}function sl(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function D_(t,e,r=!1,n={}){if(t<=ct)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=sl(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=J0(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Xt.bitMask)(i),ZERO:ct,ONE:He,create:c=>Dt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ct<=c&&c<t},is0:c=>c===ct,isOdd:c=>(c&He)===He,neg:c=>Dt(-c,t),eql:(c,f)=>c===f,sqr:c=>Dt(c*c,t),add:(c,f)=>Dt(c+f,t),sub:(c,f)=>Dt(c-f,t),mul:(c,f)=>Dt(c*f,t),pow:(c,f)=>Q0(a,c,f),div:(c,f)=>Dt(c*na(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>na(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>L0(a,c),cmov:(c,f,d)=>d?f:c,toBytes:c=>r?(0,Xt.numberToBytesLE)(c,s):(0,Xt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Xt.bytesToNumberLE)(c):(0,Xt.bytesToNumberBE)(c)}});return Object.freeze(a)}function X_(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 J_(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 Q_(t,e,r=!1){t=(0,Xt.ensureBytes)("privateHash",t);let n=t.length,i=sl(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,Xt.bytesToNumberLE)(t):(0,Xt.bytesToNumberBE)(t);return Dt(s,e-He)+He}function ol(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 th(t){let e=ol(t);return e+Math.ceil(e/2)}function L_(t,e,r=!1){let n=t.length,i=ol(e),s=th(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Xt.bytesToNumberBE)(t):(0,Xt.bytesToNumberLE)(t),a=Dt(o,e-He)+He;return r?(0,Xt.numberToBytesLE)(a,i):(0,Xt.numberToBytesBE)(a,i)}});var ia=ee(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.expand_message_xmd=rh;Kn.expand_message_xof=nh;Kn.hash_to_field=al;Kn.isogenyMap=nw;Kn.createHasher=iw;var ew=Mr(),Ot=Zt(),tw=Ot.bytesToNumberBE;function _n(t,e){if(ms(t),ms(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 rw(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 ms(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function rh(t,e,r,n){(0,Ot.abytes)(t),(0,Ot.abytes)(e),ms(r),e.length>255&&(e=n((0,Ot.concatBytes)((0,Ot.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,Ot.concatBytes)(e,_n(e.length,1)),c=_n(0,s),f=_n(r,2),d=new Array(o),h=n((0,Ot.concatBytes)(c,t,f,_n(0,1),a));d[0]=n((0,Ot.concatBytes)(h,_n(1,1),a));for(let _=1;_<=o;_++){let u=[rw(h,d[_-1]),_n(_+1,1),a];d[_]=n((0,Ot.concatBytes)(...u))}return(0,Ot.concatBytes)(...d).slice(0,r)}function nh(t,e,r,n,i){if((0,Ot.abytes)(t),(0,Ot.abytes)(e),ms(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update((0,Ot.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(_n(r,2)).update(e).update(_n(e.length,1)).digest()}function al(t,e,r){(0,Ot.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,Ot.abytes)(t),ms(e);let f=typeof c=="string"?(0,Ot.utf8ToBytes)(c):c,d=n.toString(2).length,h=Math.ceil((d+i)/8),m=e*s*h,_;if(a==="xmd")_=rh(t,f,m,o);else if(a==="xof")_=nh(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 O=0;O<e;O++){let T=new Array(s);for(let P=0;P<s;P++){let F=h*(P+O*s),A=_.subarray(F,F+h);T[P]=(0,ew.mod)(tw(A),n)}u[O]=T}return u}function nw(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 iw(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=al(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=al(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 ll=ee(bs=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});bs.wNAF=ow;bs.pippenger=aw;bs.validateBasic=cw;var ih=Mr(),oh=Zt(),sw=BigInt(0),cl=BigInt(1),ul=new WeakMap,sh=new WeakMap;function ow(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>sw;)o&cl&&(a=a.add(c)),c=c.double(),o>>=cl;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 O=0;O<c;O++){let T=O*f,P=Number(a&m);a>>=u,P>f&&(P-=_,a+=cl);let F=T,A=T+Math.abs(P)-1,K=O%2!==0,E=P<0;P===0?h=h.add(r(K,o[F])):d=d.add(r(E,o[A]))}return{p:d,f:h}},wNAFCached(s,o,a){let c=sh.get(s)||1,f=ul.get(s);return f||(f=this.precomputeWindow(s,c),c!==1&&ul.set(s,a(f))),this.wNAF(c,f,o)},setWindowSize(s,o){n(o),sh.set(s,o),ul.delete(s)}}}function aw(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,oh.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 cw(t){return(0,ih.validateField)(t.Fp),(0,oh.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,ih.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}});var fl=ee(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.DER=void 0;wt.weierstrassPoints=uh;wt.weierstrass=hw;wt.SWUFpSqrtRatio=lh;wt.mapToCurveSimpleSWU=pw;var sa=ll(),Gn=Mr(),Se=Zt(),_t=Zt();function ah(t){t.lowS!==void 0&&(0,_t.abool)("lowS",t.lowS),t.prehash!==void 0&&(0,_t.abool)("prehash",t.prehash)}function uw(t){let e=(0,sa.validateBasic)(t);Se.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:lw,hexToBytes:fw}=Se;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=Se.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Se.numberToHexUnpadded(i.length/2|128):"";return`${Se.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<hr)throw new e("integer: negative integers are not allowed");let r=Se.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 lw(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=wt.DER,i=typeof t=="string"?fw(t):t;Se.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 hr=BigInt(0),Ce=BigInt(1),wn=BigInt(2),oa=BigInt(3),ch=BigInt(4);function uh(t){let e=uw(t),{Fp:r}=e,n=Gn.Field(e.n,e.nBitLength),i=e.toBytes||((O,T,P)=>{let F=T.toAffine();return Se.concatBytes(Uint8Array.from([4]),r.toBytes(F.x),r.toBytes(F.y))}),s=e.fromBytes||(O=>{let T=O.subarray(1),P=r.fromBytes(T.subarray(0,r.BYTES)),F=r.fromBytes(T.subarray(r.BYTES,2*r.BYTES));return{x:P,y:F}});function o(O){let{a:T,b:P}=e,F=r.sqr(O),A=r.mul(F,O);return r.add(r.add(A,r.mul(O,T)),P)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(O){return Se.inRange(O,Ce,e.n)}function c(O){let{allowedPrivateKeyLengths:T,nByteLength:P,wrapPrivateKey:F,n:A}=e;if(T&&typeof O!="bigint"){if(Se.isBytes(O)&&(O=Se.bytesToHex(O)),typeof O!="string"||!T.includes(O.length))throw new Error("Invalid key");O=O.padStart(P*2,"0")}let K;try{K=typeof O=="bigint"?O:Se.bytesToNumberBE((0,_t.ensureBytes)("private key",O,P))}catch{throw new Error(`private key must be ${P} bytes, hex or bigint, not ${typeof O}`)}return F&&(K=Gn.mod(K,A)),Se.aInRange("private key",K,Ce,A),K}function f(O){if(!(O instanceof m))throw new Error("ProjectivePoint expected")}let d=(0,_t.memoized)((O,T)=>{let{px:P,py:F,pz:A}=O;if(r.eql(A,r.ONE))return{x:P,y:F};let K=O.is0();T==null&&(T=K?r.ONE:r.inv(A));let E=r.mul(P,T),k=r.mul(F,T),G=r.mul(A,T);if(K)return{x:r.ZERO,y:r.ZERO};if(!r.eql(G,r.ONE))throw new Error("invZ was invalid");return{x:E,y:k}}),h=(0,_t.memoized)(O=>{if(O.is0()){if(e.allowInfinityPoint&&!r.is0(O.py))return;throw new Error("bad point: ZERO")}let{x:T,y:P}=O.toAffine();if(!r.isValid(T)||!r.isValid(P))throw new Error("bad point: x or y not FE");let F=r.sqr(P),A=o(T);if(!r.eql(F,A))throw new Error("bad point: equation left != right");if(!O.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(T,P,F){if(this.px=T,this.py=P,this.pz=F,T==null||!r.isValid(T))throw new Error("x required");if(P==null||!r.isValid(P))throw new Error("y required");if(F==null||!r.isValid(F))throw new Error("z required");Object.freeze(this)}static fromAffine(T){let{x:P,y:F}=T||{};if(!T||!r.isValid(P)||!r.isValid(F))throw new Error("invalid affine point");if(T instanceof m)throw new Error("projective point not allowed");let A=K=>r.eql(K,r.ZERO);return A(P)&&A(F)?m.ZERO:new m(P,F,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(T){let P=r.invertBatch(T.map(F=>F.pz));return T.map((F,A)=>F.toAffine(P[A])).map(m.fromAffine)}static fromHex(T){let P=m.fromAffine(s((0,_t.ensureBytes)("pointHex",T)));return P.assertValidity(),P}static fromPrivateKey(T){return m.BASE.multiply(c(T))}static msm(T,P){return(0,sa.pippenger)(m,n,T,P)}_setWindowSize(T){u.setWindowSize(this,T)}assertValidity(){h(this)}hasEvenY(){let{y:T}=this.toAffine();if(r.isOdd)return!r.isOdd(T);throw new Error("Field doesn't support isOdd")}equals(T){f(T);let{px:P,py:F,pz:A}=this,{px:K,py:E,pz:k}=T,G=r.eql(r.mul(P,k),r.mul(K,A)),z=r.eql(r.mul(F,k),r.mul(E,A));return G&&z}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:T,b:P}=e,F=r.mul(P,oa),{px:A,py:K,pz:E}=this,k=r.ZERO,G=r.ZERO,z=r.ZERO,C=r.mul(A,A),oe=r.mul(K,K),Q=r.mul(E,E),ie=r.mul(A,K);return ie=r.add(ie,ie),z=r.mul(A,E),z=r.add(z,z),k=r.mul(T,z),G=r.mul(F,Q),G=r.add(k,G),k=r.sub(oe,G),G=r.add(oe,G),G=r.mul(k,G),k=r.mul(ie,k),z=r.mul(F,z),Q=r.mul(T,Q),ie=r.sub(C,Q),ie=r.mul(T,ie),ie=r.add(ie,z),z=r.add(C,C),C=r.add(z,C),C=r.add(C,Q),C=r.mul(C,ie),G=r.add(G,C),Q=r.mul(K,E),Q=r.add(Q,Q),C=r.mul(Q,ie),k=r.sub(k,C),z=r.mul(Q,oe),z=r.add(z,z),z=r.add(z,z),new m(k,G,z)}add(T){f(T);let{px:P,py:F,pz:A}=this,{px:K,py:E,pz:k}=T,G=r.ZERO,z=r.ZERO,C=r.ZERO,oe=e.a,Q=r.mul(e.b,oa),ie=r.mul(P,K),w=r.mul(F,E),b=r.mul(A,k),N=r.add(P,F),B=r.add(K,E);N=r.mul(N,B),B=r.add(ie,w),N=r.sub(N,B),B=r.add(P,A);let R=r.add(K,k);return B=r.mul(B,R),R=r.add(ie,b),B=r.sub(B,R),R=r.add(F,A),G=r.add(E,k),R=r.mul(R,G),G=r.add(w,b),R=r.sub(R,G),C=r.mul(oe,B),G=r.mul(Q,b),C=r.add(G,C),G=r.sub(w,C),C=r.add(w,C),z=r.mul(G,C),w=r.add(ie,ie),w=r.add(w,ie),b=r.mul(oe,b),B=r.mul(Q,B),w=r.add(w,b),b=r.sub(ie,b),b=r.mul(oe,b),B=r.add(B,b),ie=r.mul(w,B),z=r.add(z,ie),ie=r.mul(R,B),G=r.mul(N,G),G=r.sub(G,ie),ie=r.mul(N,w),C=r.mul(R,C),C=r.add(C,ie),new m(G,z,C)}subtract(T){return this.add(T.negate())}is0(){return this.equals(m.ZERO)}wNAF(T){return u.wNAFCached(this,T,m.normalizeZ)}multiplyUnsafe(T){Se.aInRange("scalar",T,hr,e.n);let P=m.ZERO;if(T===hr)return P;if(T===Ce)return this;let{endo:F}=e;if(!F)return u.unsafeLadder(this,T);let{k1neg:A,k1:K,k2neg:E,k2:k}=F.splitScalar(T),G=P,z=P,C=this;for(;K>hr||k>hr;)K&Ce&&(G=G.add(C)),k&Ce&&(z=z.add(C)),C=C.double(),K>>=Ce,k>>=Ce;return A&&(G=G.negate()),E&&(z=z.negate()),z=new m(r.mul(z.px,F.beta),z.py,z.pz),G.add(z)}multiply(T){let{endo:P,n:F}=e;Se.aInRange("scalar",T,Ce,F);let A,K;if(P){let{k1neg:E,k1:k,k2neg:G,k2:z}=P.splitScalar(T),{p:C,f:oe}=this.wNAF(k),{p:Q,f:ie}=this.wNAF(z);C=u.constTimeNegate(E,C),Q=u.constTimeNegate(G,Q),Q=new m(r.mul(Q.px,P.beta),Q.py,Q.pz),A=C.add(Q),K=oe.add(ie)}else{let{p:E,f:k}=this.wNAF(T);A=E,K=k}return m.normalizeZ([A,K])[0]}multiplyAndAddUnsafe(T,P,F){let A=m.BASE,K=(k,G)=>G===hr||G===Ce||!k.equals(A)?k.multiplyUnsafe(G):k.multiply(G),E=K(this,P).add(K(T,F));return E.is0()?void 0:E}toAffine(T){return d(this,T)}isTorsionFree(){let{h:T,isTorsionFree:P}=e;if(T===Ce)return!0;if(P)return P(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:T,clearCofactor:P}=e;return T===Ce?this:P?P(m,this):this.multiplyUnsafe(e.h)}toRawBytes(T=!0){return(0,_t.abool)("isCompressed",T),this.assertValidity(),i(m,this,T)}toHex(T=!0){return(0,_t.abool)("isCompressed",T),Se.bytesToHex(this.toRawBytes(T))}}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,sa.wNAF)(m,e.endo?Math.ceil(_/2):_);return{CURVE:e,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function dw(t){let e=(0,sa.validateBasic)(t);return Se.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function hw(t){let e=dw(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(b){return Gn.mod(b,n)}function a(b){return Gn.invert(b,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:d,isWithinCurveOrder:h}=uh({...e,toBytes(b,N,B){let R=N.toAffine(),V=r.toBytes(R.x),D=Se.concatBytes;return(0,_t.abool)("isCompressed",B),B?D(Uint8Array.from([N.hasEvenY()?2:3]),V):D(Uint8Array.from([4]),V,r.toBytes(R.y))},fromBytes(b){let N=b.length,B=b[0],R=b.subarray(1);if(N===i&&(B===2||B===3)){let V=Se.bytesToNumberBE(R);if(!Se.inRange(V,Ce,r.ORDER))throw new Error("Point is not on curve");let D=d(V),ce;try{ce=r.sqrt(D)}catch(M){let y=M instanceof Error?": "+M.message:"";throw new Error("Point is not on curve"+y)}let ae=(ce&Ce)===Ce;return(B&1)===1!==ae&&(ce=r.neg(ce)),{x:V,y:ce}}else if(N===s&&B===4){let V=r.fromBytes(R.subarray(0,r.BYTES)),D=r.fromBytes(R.subarray(r.BYTES,2*r.BYTES));return{x:V,y:D}}else throw new Error(`Point of length ${N} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=b=>Se.bytesToHex(Se.numberToBytesBE(b,e.nByteLength));function _(b){let N=n>>Ce;return b>N}function u(b){return _(b)?o(-b):b}let O=(b,N,B)=>Se.bytesToNumberBE(b.slice(N,B));class T{constructor(N,B,R){this.r=N,this.s=B,this.recovery=R,this.assertValidity()}static fromCompact(N){let B=e.nByteLength;return N=(0,_t.ensureBytes)("compactSignature",N,B*2),new T(O(N,0,B),O(N,B,2*B))}static fromDER(N){let{r:B,s:R}=wt.DER.toSig((0,_t.ensureBytes)("DER",N));return new T(B,R)}assertValidity(){Se.aInRange("r",this.r,Ce,n),Se.aInRange("s",this.s,Ce,n)}addRecoveryBit(N){return new T(this.r,this.s,N)}recoverPublicKey(N){let{r:B,s:R,recovery:V}=this,D=k((0,_t.ensureBytes)("msgHash",N));if(V==null||![0,1,2,3].includes(V))throw new Error("recovery id invalid");let ce=V===2||V===3?B+e.n:B;if(ce>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let ae=V&1?"03":"02",Z=c.fromHex(ae+m(ce)),M=a(ce),y=o(-D*M),L=o(R*M),re=c.BASE.multiplyAndAddUnsafe(Z,y,L);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new T(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Se.hexToBytes(this.toDERHex())}toDERHex(){return wt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Se.hexToBytes(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let P={isValidPrivateKey(b){try{return f(b),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let b=Gn.getMinHashLength(e.n);return Gn.mapHashToField(e.randomBytes(b),e.n)},precompute(b=8,N=c.BASE){return N._setWindowSize(b),N.multiply(BigInt(3)),N}};function F(b,N=!0){return c.fromPrivateKey(b).toRawBytes(N)}function A(b){let N=Se.isBytes(b),B=typeof b=="string",R=(N||B)&&b.length;return N?R===i||R===s:B?R===2*i||R===2*s:b instanceof c}function K(b,N,B=!0){if(A(b))throw new Error("first arg must be private key");if(!A(N))throw new Error("second arg must be public key");return c.fromHex(N).multiply(f(b)).toRawBytes(B)}let E=e.bits2int||function(b){let N=Se.bytesToNumberBE(b),B=b.length*8-e.nBitLength;return B>0?N>>BigInt(B):N},k=e.bits2int_modN||function(b){return o(E(b))},G=Se.bitMask(e.nBitLength);function z(b){return Se.aInRange(`num < 2^${e.nBitLength}`,b,hr,G),Se.numberToBytesBE(b,e.nByteLength)}function C(b,N,B=oe){if(["recovered","canonical"].some(J=>J in B))throw new Error("sign() legacy options not supported");let{hash:R,randomBytes:V}=e,{lowS:D,prehash:ce,extraEntropy:ae}=B;D==null&&(D=!0),b=(0,_t.ensureBytes)("msgHash",b),ah(B),ce&&(b=(0,_t.ensureBytes)("prehashed msgHash",R(b)));let Z=k(b),M=f(N),y=[z(M),z(Z)];if(ae!=null&&ae!==!1){let J=ae===!0?V(r.BYTES):ae;y.push((0,_t.ensureBytes)("extraEntropy",J))}let L=Se.concatBytes(...y),re=Z;function le(J){let l=E(J);if(!h(l))return;let p=a(l),g=c.BASE.multiply(l).toAffine(),I=o(g.x);if(I===hr)return;let S=o(p*o(re+I*M));if(S===hr)return;let U=(g.x===I?0:2)|Number(g.y&Ce),H=S;return D&&_(S)&&(H=u(S),U^=1),new T(I,H,U)}return{seed:L,k2sig:le}}let oe={lowS:e.lowS,prehash:!1},Q={lowS:e.lowS,prehash:!1};function ie(b,N,B=oe){let{seed:R,k2sig:V}=C(b,N,B),D=e;return Se.createHmacDrbg(D.hash.outputLen,D.nByteLength,D.hmac)(R,V)}c.BASE._setWindowSize(8);function w(b,N,B,R=Q){let V=b;if(N=(0,_t.ensureBytes)("msgHash",N),B=(0,_t.ensureBytes)("publicKey",B),"strict"in R)throw new Error("options.strict was renamed to lowS");ah(R);let{lowS:D,prehash:ce}=R,ae,Z;try{if(typeof V=="string"||Se.isBytes(V))try{ae=T.fromDER(V)}catch(g){if(!(g instanceof wt.DER.Err))throw g;ae=T.fromCompact(V)}else if(typeof V=="object"&&typeof V.r=="bigint"&&typeof V.s=="bigint"){let{r:g,s:I}=V;ae=new T(g,I)}else throw new Error("PARSE");Z=c.fromHex(B)}catch(g){if(g.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(D&&ae.hasHighS())return!1;ce&&(N=e.hash(N));let{r:M,s:y}=ae,L=k(N),re=a(y),le=o(L*re),J=o(M*re),l=c.BASE.multiplyAndAddUnsafe(Z,le,J)?.toAffine();return l?o(l.x)===M:!1}return{CURVE:e,getPublicKey:F,getSharedSecret:K,sign:ie,verify:w,ProjectivePoint:c,Signature:T,utils:P}}function lh(t,e){let r=t.ORDER,n=hr;for(let u=r-Ce;u%wn===hr;u/=wn)n+=Ce;let i=n,s=wn<<i-Ce-Ce,o=s*wn,a=(r-Ce)/o,c=(a-Ce)/wn,f=o-Ce,d=s,h=t.pow(e,a),m=t.pow(e,(a+Ce)/wn),_=(u,O)=>{let T=h,P=t.pow(O,f),F=t.sqr(P);F=t.mul(F,O);let A=t.mul(u,F);A=t.pow(A,c),A=t.mul(A,P),P=t.mul(A,O),F=t.mul(A,u);let K=t.mul(F,P);A=t.pow(K,d);let E=t.eql(A,t.ONE);P=t.mul(F,m),A=t.mul(K,T),F=t.cmov(P,F,E),K=t.cmov(A,K,E);for(let k=i;k>Ce;k--){let G=k-wn;G=wn<<G-Ce;let z=t.pow(K,G),C=t.eql(z,t.ONE);P=t.mul(F,T),T=t.mul(T,T),z=t.mul(K,T),F=t.cmov(P,F,C),K=t.cmov(z,K,C)}return{isValid:E,value:F}};if(t.ORDER%ch===oa){let u=(t.ORDER-oa)/ch,O=t.sqrt(t.neg(e));_=(T,P)=>{let F=t.sqr(P),A=t.mul(T,P);F=t.mul(F,A);let K=t.pow(F,u);K=t.mul(K,A);let E=t.mul(K,O),k=t.mul(t.sqr(K),P),G=t.eql(k,T),z=t.cmov(E,K,G);return{isValid:G,value:z}}}return _}function pw(t,e){if(Gn.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=lh(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 yh=ee(hl=>{"use strict";Object.defineProperty(hl,"__esModule",{value:!0});hl.bls=mw;var fh=Mr(),dl=Zt(),dh=ia(),hh=fl(),yw=BigInt(0),aa=BigInt(1),ph=BigInt(2),Si=BigInt(3);function gw(t){let e=[];for(;t>aa;t>>=aa)(t&aa)===yw?e.unshift(0):(t&Si)===Si?(e.unshift(-1),t+=aa):e.unshift(1);return e}function mw(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=t.params.xNegative,a=t.params.twistType,c=(0,hh.weierstrassPoints)({n:r.ORDER,...t.G1}),f=Object.assign(c,(0,dh.createHasher)(c.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),d=(0,hh.weierstrassPoints)({n:r.ORDER,...t.G2}),h=Object.assign(d,(0,dh.createHasher)(d.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),m;if(a==="multiplicative")m=(Z,M,y,L,re,le)=>s.mul014(L,Z,n.mul(M,re),n.mul(y,le));else if(a==="divisive")m=(Z,M,y,L,re,le)=>s.mul034(L,n.mul(y,le),n.mul(M,re),Z);else throw new Error("bls: unknown twist type");let _=n.div(n.ONE,n.mul(n.ONE,ph));function u(Z,M,y,L){let re=n.sqr(y),le=n.sqr(L),J=n.mulByB(n.mul(le,Si)),l=n.mul(J,Si),p=n.sub(n.sub(n.sqr(n.add(y,L)),le),re),g=n.sub(J,re),I=n.mul(n.sqr(M),Si),S=n.neg(p);return Z.push([g,I,S]),M=n.mul(n.mul(n.mul(n.sub(re,l),M),y),_),y=n.sub(n.sqr(n.mul(n.add(re,l),_)),n.mul(n.sqr(J),Si)),L=n.mul(re,p),{Rx:M,Ry:y,Rz:L}}function O(Z,M,y,L,re,le){let J=n.sub(y,n.mul(le,L)),l=n.sub(M,n.mul(re,L)),p=n.sub(n.mul(J,re),n.mul(l,le)),g=n.neg(J),I=l;Z.push([p,g,I]);let S=n.sqr(l),U=n.mul(S,l),H=n.mul(S,M),x=n.add(n.sub(U,n.mul(H,ph)),n.mul(n.sqr(J),L));return M=n.mul(l,x),y=n.sub(n.mul(n.sub(H,x),J),n.mul(U,y)),L=n.mul(L,U),{Rx:M,Ry:y,Rz:L}}let T=gw(t.params.ateLoopSize),P=(0,dl.memoized)(Z=>{let M=Z,{x:y,y:L}=M.toAffine(),re=y,le=L,J=n.neg(L),l=re,p=le,g=n.ONE,I=[];for(let S of T){let U=[];({Rx:l,Ry:p,Rz:g}=u(U,l,p,g)),S&&({Rx:l,Ry:p,Rz:g}=O(U,l,p,g,re,S===-1?J:le)),I.push(U)}if(t.postPrecompute){let S=I[I.length-1];t.postPrecompute(l,p,g,re,le,O.bind(null,S))}return I});function F(Z,M=!1){let y=s.ONE;if(Z.length){let L=Z[0][0].length;for(let re=0;re<L;re++){y=s.sqr(y);for(let[le,J,l]of Z)for(let[p,g,I]of le[re])y=m(p,g,I,y,J,l)}}return o&&(y=s.conjugate(y)),M?s.finalExponentiate(y):y}function A(Z,M=!0){let y=[];f.ProjectivePoint.normalizeZ(Z.map(({g1:L})=>L)),h.ProjectivePoint.normalizeZ(Z.map(({g2:L})=>L));for(let{g1:L,g2:re}of Z){if(L.equals(f.ProjectivePoint.ZERO)||re.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");L.assertValidity(),re.assertValidity();let le=L.toAffine();y.push([P(re),le.x,le.y])}return F(y,M)}function K(Z,M,y=!0){return A([{g1:Z,g2:M}],y)}let E={randomPrivateKey:()=>{let Z=(0,fh.getMinHashLength)(r.ORDER);return(0,fh.mapHashToField)(t.randomBytes(Z),r.ORDER)},calcPairingPrecomputes:P},{ShortSignature:k}=t.G1,{Signature:G}=t.G2;function z(Z){return Z instanceof f.ProjectivePoint?Z:f.ProjectivePoint.fromHex(Z)}function C(Z,M){return Z instanceof f.ProjectivePoint?Z:f.hashToCurve((0,dl.ensureBytes)("point",Z),M)}function oe(Z){return Z instanceof h.ProjectivePoint?Z:G.fromHex(Z)}function Q(Z,M){return Z instanceof h.ProjectivePoint?Z:h.hashToCurve((0,dl.ensureBytes)("point",Z),M)}function ie(Z){return f.ProjectivePoint.fromPrivateKey(Z).toRawBytes(!0)}function w(Z){return h.ProjectivePoint.fromPrivateKey(Z).toRawBytes(!0)}function b(Z,M,y){let L=Q(Z,y);L.assertValidity();let re=L.multiply(f.normPrivateKeyToScalar(M));return Z instanceof h.ProjectivePoint?re:G.toRawBytes(re)}function N(Z,M,y){let L=C(Z,y);L.assertValidity();let re=L.multiply(f.normPrivateKeyToScalar(M));return Z instanceof f.ProjectivePoint?re:k.toRawBytes(re)}function B(Z,M,y,L){let re=z(y),le=Q(M,L),J=f.ProjectivePoint.BASE,l=oe(Z),p=A([{g1:re.negate(),g2:le},{g1:J,g2:l}]);return s.eql(p,s.ONE)}function R(Z,M,y,L){let re=oe(y),le=C(M,L),J=h.ProjectivePoint.BASE,l=z(Z),p=A([{g1:le,g2:re},{g1:l,g2:J.negate()}]);return s.eql(p,s.ONE)}function V(Z){if(!Z.length)throw new Error("Expected non-empty array");let y=Z.map(z).reduce((L,re)=>L.add(re),f.ProjectivePoint.ZERO);return Z[0]instanceof f.ProjectivePoint?(y.assertValidity(),y):y.toRawBytes(!0)}function D(Z){if(!Z.length)throw new Error("Expected non-empty array");let y=Z.map(oe).reduce((L,re)=>L.add(re),h.ProjectivePoint.ZERO);return Z[0]instanceof h.ProjectivePoint?(y.assertValidity(),y):G.toRawBytes(y)}function ce(Z){if(!Z.length)throw new Error("Expected non-empty array");let y=Z.map(z).reduce((L,re)=>L.add(re),f.ProjectivePoint.ZERO);return Z[0]instanceof f.ProjectivePoint?(y.assertValidity(),y):k.toRawBytes(y)}function ae(Z,M,y,L){if(!M.length)throw new Error("Expected non-empty messages array");if(y.length!==M.length)throw new Error("Pubkey count should equal msg count");let re=oe(Z),le=M.map(g=>Q(g,L)),J=y.map(z),l=new Map;for(let g=0;g<J.length;g++){let I=J[g],S=le[g],U=l.get(S);U===void 0&&(U=[],l.set(S,U)),U.push(I)}let p=[];try{for(let[g,I]of l){let S=I.reduce((U,H)=>U.add(H));p.push({g1:S,g2:g})}return p.push({g1:f.ProjectivePoint.BASE.negate(),g2:re}),s.eql(A(p),s.ONE)}catch{return!1}}return f.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ie,getPublicKeyForShortSignatures:w,sign:b,signShortSignature:N,verify:B,verifyBatch:ae,verifyShortSignature:R,aggregatePublicKeys:V,aggregateSignatures:D,aggregateShortSignatures:ce,millerLoopBatch:F,pairing:K,pairingBatch:A,G1:f,G2:h,Signature:G,ShortSignature:k,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:E}}});var mh=ee(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.psiFrobenius=_w;ca.tower12=ww;var En=Mr(),pr=Zt(),bw=BigInt(0),Bi=BigInt(1),en=BigInt(2),gh=BigInt(3);function pl(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,_=Bi;m<n;m++){let u=(d*_-d)/o%a;h.push(t.pow(e,u)),_*=r}c.push(h)}return c}function _w(t,e,r){let n=e.pow(r,(t.ORDER-Bi)/gh),i=e.pow(r,(t.ORDER-Bi)/en);function s(m,_){let u=e.mul(e.frobeniusMap(m,1),n),O=e.mul(e.frobeniusMap(_,1),i);return[u,O]}let o=e.pow(r,(t.ORDER**en-Bi)/gh),a=e.pow(r,(t.ORDER**en-Bi)/en);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 O=u.toAffine(),T=m(O.x,O.y);return _.fromAffine({x:T[0],y:T[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 ww(t){let{ORDER:e}=t,r=En.Field(e),n=r.create(t.NONRESIDUE||BigInt(-1)),i=En.FpLegendre(e),s=r.div(r.ONE,en),o=pl(r,n,r.ORDER,2)[0],a=({c0:w,c1:b},{c0:N,c1:B})=>({c0:r.add(w,N),c1:r.add(b,B)}),c=({c0:w,c1:b},{c0:N,c1:B})=>({c0:r.sub(w,N),c1:r.sub(b,B)}),f=({c0:w,c1:b},N)=>{if(typeof N=="bigint")return{c0:r.mul(w,N),c1:r.mul(b,N)};let{c0:B,c1:R}=N,V=r.mul(w,B),D=r.mul(b,R),ce=r.sub(V,D),ae=r.sub(r.mul(r.add(w,b),r.add(B,R)),r.add(V,D));return{c0:ce,c1:ae}},d=({c0:w,c1:b})=>{let N=r.add(w,b),B=r.sub(w,b),R=r.add(w,w);return{c0:r.mul(N,B),c1:r.mul(R,b)}},h=w=>{if(w.length!==2)throw new Error("Invalid tuple");let b=w.map(N=>r.create(N));return{c0:b[0],c1:b[1]}},m=e*e,_=h(t.FP2_NONRESIDUE),u={ORDER:m,NONRESIDUE:_,BITS:(0,pr.bitLen)(m),BYTES:Math.ceil((0,pr.bitLen)(m)/8),MASK:(0,pr.bitMask)((0,pr.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:N,c1:B})=>r.eql(w,N)&&r.eql(b,B),neg:({c0:w,c1:b})=>({c0:r.neg(w),c1:r.neg(b)}),pow:(w,b)=>En.FpPow(u,w,b),invertBatch:w=>En.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 N=r.inv(r.create(w*w+b*b));return{c0:r.mul(N,r.create(w)),c1:r.mul(N,r.create(-b))}},sqrt:w=>{if(t.Fp2sqrt)return t.Fp2sqrt(w);let{c0:b,c1:N}=w;if(r.is0(N))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 B=r.sqrt(r.sub(r.sqr(b),r.mul(r.sqr(N),n))),R=r.mul(r.add(B,b),s),V=i(r,R);!r.is0(V)&&!r.eql(V,r.ONE)&&(R=r.sub(R,B));let D=r.sqrt(R),ce=u.create({c0:D,c1:r.div(r.mul(N,s),D)});if(!u.eql(u.sqr(ce),w))throw new Error("Cannot find square root");let ae=ce,Z=u.neg(ae),{re:M,im:y}=u.reim(ae),{re:L,im:re}=u.reim(Z);return y>re||y===re&&M>L?ae:Z},isOdd:w=>{let{re:b,im:N}=u.reim(w),B=b%en,R=b===bw,V=N%en;return BigInt(B||R&&V)==Bi},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,pr.concatBytes)(r.toBytes(w),r.toBytes(b)),cmov:({c0:w,c1:b},{c0:N,c1:B},R)=>({c0:r.cmov(w,N,R),c1:r.cmov(b,B,R)}),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},N)=>({c0:w,c1:r.mul(b,o[N%2])})},O=({c0:w,c1:b,c2:N},{c0:B,c1:R,c2:V})=>({c0:u.add(w,B),c1:u.add(b,R),c2:u.add(N,V)}),T=({c0:w,c1:b,c2:N},{c0:B,c1:R,c2:V})=>({c0:u.sub(w,B),c1:u.sub(b,R),c2:u.sub(N,V)}),P=({c0:w,c1:b,c2:N},B)=>{if(typeof B=="bigint")return{c0:u.mul(w,B),c1:u.mul(b,B),c2:u.mul(N,B)};let{c0:R,c1:V,c2:D}=B,ce=u.mul(w,R),ae=u.mul(b,V),Z=u.mul(N,D);return{c0:u.add(ce,u.mulByNonresidue(u.sub(u.mul(u.add(b,N),u.add(V,D)),u.add(ae,Z)))),c1:u.add(u.sub(u.mul(u.add(w,b),u.add(R,V)),u.add(ce,ae)),u.mulByNonresidue(Z)),c2:u.sub(u.add(ae,u.mul(u.add(w,N),u.add(R,D))),u.add(ce,Z))}},F=({c0:w,c1:b,c2:N})=>{let B=u.sqr(w),R=u.mul(u.mul(w,b),en),V=u.mul(u.mul(b,N),en),D=u.sqr(N);return{c0:u.add(u.mulByNonresidue(V),B),c1:u.add(u.mulByNonresidue(D),R),c2:u.sub(u.sub(u.add(u.add(R,u.sqr(u.add(u.sub(w,b),N))),V),B),D)}},[A,K]=pl(u,_,r.ORDER,6,2,3),E={ORDER:u.ORDER,BITS:3*u.BITS,BYTES:3*u.BYTES,MASK:(0,pr.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:N})=>u.isValid(w)&&u.isValid(b)&&u.isValid(N),is0:({c0:w,c1:b,c2:N})=>u.is0(w)&&u.is0(b)&&u.is0(N),neg:({c0:w,c1:b,c2:N})=>({c0:u.neg(w),c1:u.neg(b),c2:u.neg(N)}),eql:({c0:w,c1:b,c2:N},{c0:B,c1:R,c2:V})=>u.eql(w,B)&&u.eql(b,R)&&u.eql(N,V),sqrt:pr.notImplemented,div:(w,b)=>E.mul(w,typeof b=="bigint"?r.inv(r.create(b)):E.inv(b)),pow:(w,b)=>En.FpPow(E,w,b),invertBatch:w=>En.FpInvertBatch(E,w),add:O,sub:T,mul:P,sqr:F,addN:O,subN:T,mulN:P,sqrN:F,inv:({c0:w,c1:b,c2:N})=>{let B=u.sub(u.sqr(w),u.mulByNonresidue(u.mul(N,b))),R=u.sub(u.mulByNonresidue(u.sqr(N)),u.mul(w,b)),V=u.sub(u.sqr(b),u.mul(w,N)),D=u.inv(u.add(u.mulByNonresidue(u.add(u.mul(N,R),u.mul(b,V))),u.mul(w,B)));return{c0:u.mul(D,B),c1:u.mul(D,R),c2:u.mul(D,V)}},fromBytes:w=>{if(w.length!==E.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:N})=>(0,pr.concatBytes)(u.toBytes(w),u.toBytes(b),u.toBytes(N)),cmov:({c0:w,c1:b,c2:N},{c0:B,c1:R,c2:V},D)=>({c0:u.cmov(w,B,D),c1:u.cmov(b,R,D),c2:u.cmov(N,V,D)}),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:N},B)=>({c0:u.frobeniusMap(w,B),c1:u.mul(u.frobeniusMap(b,B),A[B%6]),c2:u.mul(u.frobeniusMap(N,B),K[B%6])}),mulByFp2:({c0:w,c1:b,c2:N},B)=>({c0:u.mul(w,B),c1:u.mul(b,B),c2:u.mul(N,B)}),mulByNonresidue:({c0:w,c1:b,c2:N})=>({c0:u.mulByNonresidue(N),c1:w,c2:b}),mul1:({c0:w,c1:b,c2:N},B)=>({c0:u.mulByNonresidue(u.mul(N,B)),c1:u.mul(w,B),c2:u.mul(b,B)}),mul01({c0:w,c1:b,c2:N},B,R){let V=u.mul(w,B),D=u.mul(b,R);return{c0:u.add(u.mulByNonresidue(u.sub(u.mul(u.add(b,N),R),D)),V),c1:u.sub(u.sub(u.mul(u.add(B,R),u.add(w,b)),V),D),c2:u.add(u.sub(u.mul(u.add(w,N),B),V),D)}}},k=pl(u,_,r.ORDER,12,1,6)[0],G=({c0:w,c1:b},{c0:N,c1:B})=>({c0:E.add(w,N),c1:E.add(b,B)}),z=({c0:w,c1:b},{c0:N,c1:B})=>({c0:E.sub(w,N),c1:E.sub(b,B)}),C=({c0:w,c1:b},N)=>{if(typeof N=="bigint")return{c0:E.mul(w,N),c1:E.mul(b,N)};let{c0:B,c1:R}=N,V=E.mul(w,B),D=E.mul(b,R);return{c0:E.add(V,E.mulByNonresidue(D)),c1:E.sub(E.mul(E.add(w,b),E.add(B,R)),E.add(V,D))}},oe=({c0:w,c1:b})=>{let N=E.mul(w,b);return{c0:E.sub(E.sub(E.mul(E.add(E.mulByNonresidue(b),w),E.add(w,b)),N),E.mulByNonresidue(N)),c1:E.add(N,N)}};function Q(w,b){let N=u.sqr(w),B=u.sqr(b);return{first:u.add(u.mulByNonresidue(B),N),second:u.sub(u.sub(u.sqr(u.add(w,b)),N),B)}}let ie={ORDER:u.ORDER,BITS:2*u.BITS,BYTES:2*u.BYTES,MASK:(0,pr.bitMask)(2*u.BITS),ZERO:{c0:E.ZERO,c1:E.ZERO},ONE:{c0:E.ONE,c1:E.ZERO},create:w=>w,isValid:({c0:w,c1:b})=>E.isValid(w)&&E.isValid(b),is0:({c0:w,c1:b})=>E.is0(w)&&E.is0(b),neg:({c0:w,c1:b})=>({c0:E.neg(w),c1:E.neg(b)}),eql:({c0:w,c1:b},{c0:N,c1:B})=>E.eql(w,N)&&E.eql(b,B),sqrt:pr.notImplemented,inv:({c0:w,c1:b})=>{let N=E.inv(E.sub(E.sqr(w),E.mulByNonresidue(E.sqr(b))));return{c0:E.mul(w,N),c1:E.neg(E.mul(b,N))}},div:(w,b)=>ie.mul(w,typeof b=="bigint"?r.inv(r.create(b)):ie.inv(b)),pow:(w,b)=>En.FpPow(ie,w,b),invertBatch:w=>En.FpInvertBatch(ie,w),add:G,sub:z,mul:C,sqr:oe,addN:G,subN:z,mulN:C,sqrN:oe,fromBytes:w=>{if(w.length!==ie.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:E.fromBytes(w.subarray(0,E.BYTES)),c1:E.fromBytes(w.subarray(E.BYTES))}},toBytes:({c0:w,c1:b})=>(0,pr.concatBytes)(E.toBytes(w),E.toBytes(b)),cmov:({c0:w,c1:b},{c0:N,c1:B},R)=>({c0:E.cmov(w,N,R),c1:E.cmov(b,B,R)}),fromBigTwelve:w=>({c0:E.fromBigSix(w.slice(0,6)),c1:E.fromBigSix(w.slice(6,12))}),frobeniusMap(w,b){let{c0:N,c1:B,c2:R}=E.frobeniusMap(w.c1,b),V=k[b%12];return{c0:E.frobeniusMap(w.c0,b),c1:E.create({c0:u.mul(N,V),c1:u.mul(B,V),c2:u.mul(R,V)})}},mulByFp2:({c0:w,c1:b},N)=>({c0:E.mulByFp2(w,N),c1:E.mulByFp2(b,N)}),conjugate:({c0:w,c1:b})=>({c0:w,c1:E.neg(b)}),mul014:({c0:w,c1:b},N,B,R)=>{let V=E.mul01(w,N,B),D=E.mul1(b,R);return{c0:E.add(E.mulByNonresidue(D),V),c1:E.sub(E.sub(E.mul01(E.add(b,w),N,u.add(B,R)),V),D)}},mul034:({c0:w,c1:b},N,B,R)=>{let V=E.create({c0:u.mul(w.c0,N),c1:u.mul(w.c1,N),c2:u.mul(w.c2,N)}),D=E.mul01(b,B,R),ce=E.mul01(E.add(w,b),u.add(N,B),R);return{c0:E.add(E.mulByNonresidue(D),V),c1:E.sub(ce,E.add(V,D))}},_cyclotomicSquare:t.Fp12cyclotomicSquare,_cyclotomicExp:t.Fp12cyclotomicExp,finalExponentiate:t.Fp12finalExponentiate};return{Fp:r,Fp2:u,Fp6:E,Fp4Square:Q,Fp12:ie}}});var Sh=ee(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.bls12_381=void 0;var xh=fo(),Ew=jn(),xw=yh(),vw=Mr(),Be=Zt(),vh=ia(),Th=fl(),Ah=mh(),Mt=BigInt(0),fa=BigInt(1),pt=BigInt(2),ua=BigInt(3),_s=BigInt(4),xn=BigInt("0xd201000000010000"),Tw=(0,Be.bitLen)(xn),{Fp:fe,Fp2:pe,Fp6:ml,Fp4Square:yl,Fp12:ve}=(0,Ah.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[fa,fa],Fp2mulByB:({c0:t,c1:e})=>{let r=fe.mul(t,_s),n=fe.mul(e,_s);return{c0:fe.sub(r,n),c1:fe.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}=yl(r,o),{first:d,second:h}=yl(s,i),{first:m,second:_}=yl(n,a),u=pe.mulByNonresidue(_);return{c0:ml.create({c0:pe.add(pe.mul(pe.sub(c,r),pt),c),c1:pe.add(pe.mul(pe.sub(d,n),pt),d),c2:pe.add(pe.mul(pe.sub(m,i),pt),m)}),c1:ml.create({c0:pe.add(pe.mul(pe.add(u,s),pt),u),c1:pe.add(pe.mul(pe.add(f,o),pt),f),c2:pe.add(pe.mul(pe.add(h,a),pt),h)})}},Fp12cyclotomicExp(t,e){let r=ve.ONE;for(let n=Tw-1;n>=0;n--)r=ve._cyclotomicSquare(r),(0,Be.bitGet)(e,n)&&(r=ve.mul(r,t));return r},Fp12finalExponentiate:t=>{let e=xn,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),_)}}),bh=vw.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Aw=(0,vh.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))))),Sw=(0,vh.isogenyMap)(fe,[["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,Th.mapToCurveSimpleSWU)(pe,{A:pe.create({c0:fe.create(Mt),c1:fe.create(BigInt(240))}),B:pe.create({c0:fe.create(BigInt(1012)),c1:fe.create(BigInt(1012))}),Z:pe.create({c0:fe.create(BigInt(-2)),c1:fe.create(BigInt(-1))})}),Ow=(0,Th.mapToCurveSimpleSWU)(fe,{A:fe.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:fe.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:fe.create(BigInt(11))}),{G2psi:_h,G2psi2:Nw}=(0,Ah.psiFrobenius)(fe,pe,pe.div(pe.ONE,pe.NONRESIDUE)),gl=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:fe.ORDER,m:2,k:128,expand:"xmd",hash:xh.sha256}),da=ws(fe.toBytes(Mt),{infinity:!0,compressed:!0});function la(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 ws(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 wh(t){t.assertValidity();let e=t.equals(qt.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return da.slice();let i=fe.ORDER,s=!!(n*pt/i);return ws((0,Be.numberToBytesBE)(r,fe.BYTES),{compressed:!0,sort:s})}function Eh(t){t.assertValidity();let e=fe.BYTES;if(t.equals(qt.bls12_381.G2.ProjectivePoint.ZERO))return(0,Be.concatBytes)(da,(0,Be.numberToBytesBE)(Mt,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=pe.reim(r),{re:o,im:a}=pe.reim(n),f=!!((a>Mt?a*pt:o*pt)/fe.ORDER&fa),d=i;return(0,Be.concatBytes)(ws((0,Be.numberToBytesBE)(s,e),{sort:f,compressed:!0}),(0,Be.numberToBytesBE)(d,e))}qt.bls12_381=(0,xw.bls)({fields:{Fp:fe,Fp2:pe,Fp6:ml,Fp12:ve,Fr:bh},G1:{Fp:fe,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:fe.ZERO,b:_s,htfDefaults:{...gl,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(fe.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(xn).negate().multiplyUnsafe(xn).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(xn).add(e),mapToCurve:t=>{let{x:e,y:r}=Ow(fe.create(t[0]));return Sw(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=la(t);if(i.length===48&&e){let s=fe.ORDER,o=(0,Be.bytesToNumberBE)(i),a=fe.create(o&fe.MASK);if(r){if(a!==Mt)throw new Error("G1: non-empty compressed point at infinity");return{x:Mt,y:Mt}}let c=fe.add(fe.pow(a,ua),fe.create(qt.bls12_381.params.G1b)),f=fe.sqrt(c);if(!f)throw new Error("Invalid compressed G1 point");return f*pt/s!==BigInt(n)&&(f=fe.neg(f)),{x:fe.create(a),y:fe.create(f)}}else if(i.length===96&&!e){let s=(0,Be.bytesToNumberBE)(i.subarray(0,fe.BYTES)),o=(0,Be.bytesToNumberBE)(i.subarray(fe.BYTES));if(r){if(s!==Mt||o!==Mt)throw new Error("G1: non-empty point at infinity");return qt.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:fe.create(s),y:fe.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 da.slice();let o=fe.ORDER,a=!!(s*pt/o);return ws((0,Be.numberToBytesBE)(i,fe.BYTES),{compressed:!0,sort:a})}else return n?(0,Be.concatBytes)(new Uint8Array([64]),new Uint8Array(2*fe.BYTES-1)):(0,Be.concatBytes)((0,Be.numberToBytesBE)(i,fe.BYTES),(0,Be.numberToBytesBE)(s,fe.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=la((0,Be.ensureBytes)("signatureHex",t,48)),i=fe.ORDER,s=(0,Be.bytesToNumberBE)(n);if(e)return qt.bls12_381.G1.ProjectivePoint.ZERO;let o=fe.create(s&fe.MASK),a=fe.add(fe.pow(o,ua),fe.create(qt.bls12_381.params.G1b)),c=fe.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let f=BigInt(r);c*pt/i!==f&&(c=fe.neg(c));let d=qt.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return d.assertValidity(),d},toRawBytes(t){return wh(t)},toHex(t){return(0,Be.bytesToHex)(wh(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([_s,_s]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...gl},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=Bw(pe.fromBigTuple(t));return Aw(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(xn).negate().equals(_h(t,e)),clearCofactor:(t,e)=>{let r=xn,n=e.multiplyUnsafe(r).negate(),i=_h(t,e),s=e.double();return s=Nw(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}=la(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=fe.BYTES,o=(a,c,f)=>(0,Be.bytesToNumberBE)(a.slice(c,f));if(i.length===96&&e){let a=qt.bls12_381.params.G2b,c=fe.ORDER;if(r){if(i.reduce((O,T)=>O!==0?T+1:T,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:fe.create(d),c1:fe.create(f)}),m=pe.add(pe.pow(h,ua),a),_=pe.sqrt(m),u=_.c1===Mt?_.c0*pt/c:_.c1*pt/c?fa:Mt;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}=fe,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return(0,Be.concatBytes)(da,(0,Be.numberToBytesBE)(Mt,n));let c=!!(a.c1===Mt?a.c0*pt/i:a.c1*pt/i);return(0,Be.concatBytes)(ws((0,Be.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,Be.numberToBytesBE)(o.c0,n))}else{if(s)return(0,Be.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,Be.concatBytes)((0,Be.numberToBytesBE)(f,n),(0,Be.numberToBytesBE)(c,n),(0,Be.numberToBytesBE)(h,n),(0,Be.numberToBytesBE)(d,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=la((0,Be.ensureBytes)("signatureHex",t)),i=fe.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,Be.bytesToNumberBE)(n.slice(0,s)),a=(0,Be.bytesToNumberBE)(n.slice(s));if(e)return qt.bls12_381.G2.ProjectivePoint.ZERO;let c=fe.create(o&fe.MASK),f=fe.create(a),d=pe.create({c0:f,c1:c}),h=pe.add(pe.pow(d,ua),qt.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),O=BigInt(r),T=u>Mt&&u*pt/i!==O,P=u===Mt&&_*pt/i!==O;(T||P)&&(m=pe.neg(m));let F=qt.bls12_381.G2.ProjectivePoint.fromAffine({x:d,y:m});return F.assertValidity(),F},toRawBytes(t){return Eh(t)},toHex(t){return(0,Be.bytesToHex)(Eh(t))}}},params:{ateLoopSize:xn,r:bh.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:gl,hash:xh.sha256,randomBytes:Ew.randomBytes})});var _l=ee(Es=>{"use strict";Object.defineProperty(Es,"__esModule",{value:!0});Es.blsVerify=Es.verify=void 0;var Rw=Sh(),bl=Vt();function Pw(t,e,r){let n=typeof t=="string"?t:(0,bl.toHex)(t),i=typeof e=="string"?e:(0,bl.toHex)(e),s=typeof r=="string"?r:(0,bl.toHex)(r);return Rw.bls12_381.verifyShortSignature(i,s,n)}Es.blsVerify=Pw});var ha=ee(Yn=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.decodeTime=Yn.decodeLeb128=void 0;var Bh=xi(),Iw=t=>(0,Bh.lebDecode)(new Bh.PipeArrayBuffer(t));Yn.decodeLeb128=Iw;var Uw=t=>{let e=(0,Yn.decodeLeb128)(t);return new Date(Number(e)/1e6)};Yn.decodeTime=Uw});var Oi=ee(Te=>{"use strict";var Fw=Te&&Te.__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=Te&&Te.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Oh=Te&&Te.__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},qw=Te&&Te.__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},Cw=Te&&Te.__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;Object.defineProperty(Te,"__esModule",{value:!0});Te.check_canister_ranges=Te.find_label=Te.flatten_forks=Te.lookup_path=Te.LookupStatus=Te.reconstruct=Te.lookupResultToBuffer=Te.Certificate=Te.hashTreeToString=Te.NodeType=Te.CertificateVerificationError=void 0;var Nh=Oh(ys()),kw=yi(),pa=ds(),yr=Vt(),wl=Ut(),jw=Oh(_l()),Hw=ha(),Vw=Ss(),tn=class extends kw.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};Te.CertificateVerificationError=tn;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=Te.NodeType||(Te.NodeType={}));function ga(t){let e=n=>n.split(`
|
|
16
|
+
`)}return c.encodeValue(f)}));return(0,Pe.concat)(n,i,s,o,a)}W.encode=qb;function jb(t,e){let r=new Pe.PipeArrayBuffer(e);if(e.byteLength<xo.length)throw new Error("Message length smaller than magic number");let n=(0,se.safeRead)(r,xo.length),i=new TextDecoder().decode(n);if(i!==xo)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(_){let u=[],O=Number((0,se.lebDecode)(_));for(let F=0;F<O;F++){let A=Number((0,se.slebDecode)(_));switch(A){case-18:case-19:{let K=Number((0,se.slebDecode)(_));u.push([A,K]);break}case-20:case-21:{let K=[],E=Number((0,se.lebDecode)(_)),j;for(;E--;){let G=Number((0,se.lebDecode)(_));if(G>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof j=="number"&&j>=G)throw new Error("field id collision or not sorted");j=G;let z=Number((0,se.slebDecode)(_));K.push([G,z])}u.push([A,K]);break}case-22:{let K=[],E=Number((0,se.lebDecode)(_));for(;E--;)K.push(Number((0,se.slebDecode)(_)));let j=[],G=Number((0,se.lebDecode)(_));for(;G--;)j.push(Number((0,se.slebDecode)(_)));let z=[],q=Number((0,se.lebDecode)(_));for(;q--;)switch(Number((0,se.lebDecode)(_))){case 1:{z.push("query");break}case 2:{z.push("oneway");break}case 3:{z.push("composite_query");break}default:throw new Error("unknown annotation")}u.push([A,[K,j,z]]);break}case-23:{let K=Number((0,se.lebDecode)(_)),E=[];for(;K--;){let j=Number((0,se.lebDecode)(_)),G=new TextDecoder().decode((0,se.safeRead)(_,j)),z=(0,se.slebDecode)(_);E.push([G,z])}u.push([A,E]);break}default:throw new Error("Illegal op_code: "+A)}}let T=[],P=Number((0,se.lebDecode)(_));for(let F=0;F<P;F++)T.push(Number((0,se.slebDecode)(_)));return[u,T]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(_=>Wd());function f(_){if(_<-24)throw new Error("future value not supported");if(_<0)switch(_){case-1:return W.Null;case-2:return W.Bool;case-3:return W.Nat;case-4:return W.Int;case-5:return W.Nat8;case-6:return W.Nat16;case-7:return W.Nat32;case-8:return W.Nat64;case-9:return W.Int8;case-10:return W.Int16;case-11:return W.Int32;case-12:return W.Int64;case-13:return W.Float32;case-14:return W.Float64;case-15:return W.Text;case-16:return W.Reserved;case-17:return W.Empty;case-24:return W.Principal;default:throw new Error("Illegal op_code: "+_)}if(_>=o.length)throw new Error("type index out of range");return c[_]}function d(_){switch(_[0]){case-19:{let u=f(_[1]);return $d(u)}case-18:{let u=f(_[1]);return Kd(u)}case-20:{let u={};for(let[P,F]of _[1]){let A=`_${P}_`;u[A]=f(F)}let O=Gd(u),T=O.tryAsTuple();return Array.isArray(T)?Vd(...T):O}case-21:{let u={};for(let[O,T]of _[1]){let P=`_${O}_`;u[P]=f(T)}return Yd(u)}case-22:{let[u,O,T]=_[1];return zd(u.map(P=>f(P)),O.map(P=>f(P)),T)}case-23:{let u={},O=_[1];for(let[T,P]of O){let F=f(P);if(F instanceof pn&&(F=F.getType()),!(F instanceof ss))throw new Error("Illegal service definition: services can only contain functions");u[T]=F}return Dd(u)}default:throw new Error("Illegal op_code: "+_[0])}}o.forEach((_,u)=>{if(_[0]===-22){let O=d(_);c[u].fill(O)}}),o.forEach((_,u)=>{if(_[0]!==-22){let O=d(_);c[u].fill(O)}});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}W.decode=jb;W.Empty=new vo;W.Reserved=new bi;W.Unknown=new To;W.Bool=new Ao;W.Null=new So;W.Text=new Bo;W.Int=new Oo;W.Nat=new No;W.Float32=new ns(32);W.Float64=new ns(64);W.Int8=new Xr(8);W.Int16=new Xr(16);W.Int32=new Xr(32);W.Int64=new Xr(64);W.Nat8=new Rr(8);W.Nat16=new Rr(16);W.Nat32=new Rr(32);W.Nat64=new Rr(64);W.Principal=new Uo;function Vd(...t){return new Po(t)}W.Tuple=Vd;function $d(t){return new Ro(t)}W.Vec=$d;function Kd(t){return new _i(t)}W.Opt=Kd;function Gd(t){return new is(t)}W.Record=Gd;function Yd(t){return new Io(t)}W.Variant=Yd;function Wd(){return new pn}W.Rec=Wd;function zd(t,e,r=[]){return new ss(t,e,r)}W.Func=zd;function Dd(t){return new Fo(t)}W.Service=Dd});var yu=ee(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.VecForm=St.OptionForm=St.VariantForm=St.TupleForm=St.RecordForm=St.InputForm=St.InputBox=void 0;var uu=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)}};St.InputBox=uu;var yn=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)}};St.InputForm=yn;var lu=class extends yn{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}};St.RecordForm=lu;var fu=class extends yn{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}};St.TupleForm=fu;var du=class extends yn{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}};St.VariantForm=du;var hu=class extends yn{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]}}};St.OptionForm=hu;var pu=class extends yn{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}};St.VecForm=pu});var Jd=ee(Ee=>{"use strict";var kb=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]}),Hb=Ee&&Ee.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Zd=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)&&kb(e,t,r);return Hb(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 Co=Zd(cu()),gu=Ut(),wi=Zd(yu()),Vb={parse:Db},os={render:wu},$b=(t,e)=>new wi.InputBox(t,Object.assign(Object.assign({},Vb),e));Ee.inputBox=$b;var Kb=(t,e)=>new wi.RecordForm(t,Object.assign(Object.assign({},os),e));Ee.recordForm=Kb;var Gb=(t,e)=>new wi.TupleForm(t,Object.assign(Object.assign({},os),e));Ee.tupleForm=Gb;var Yb=(t,e)=>new wi.VariantForm(t,Object.assign(Object.assign({},os),e));Ee.variantForm=Yb;var Wb=(t,e)=>new wi.OptionForm(t,Object.assign(Object.assign({},os),e));Ee.optForm=Wb;var zb=(t,e)=>new wi.VecForm(t,Object.assign(Object.assign({},os),e));Ee.vecForm=zb;var Mo=class extends Co.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 wu(r)}};Ee.Render=Mo;var mu=class extends Co.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 gu.Principal.fromText(r)}visitService(e,r){return gu.Principal.fromText(r)}visitFunc(e,r){let n=r.split(".",2);return[gu.Principal.fromText(n[0]),n[1]]}},bu=class extends Co.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 Db(t,e,r){return e.random&&r===""?t.accept(new bu,r):t.accept(new mu,r)}function wu(t){return t.accept(new Mo,null)}Ee.renderInput=wu;function Hn(t,e,r){return t.accept(new _u,{input:e,value:r})}Ee.renderValue=Hn;var _u=class extends Co.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){Hn(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)),Hn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{Hn(o,i.form[a],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{Hn(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)),Hn(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)=>{Hn(r,i.form[c],a)})}}});var Qd=ee(Xd=>{"use strict";Object.defineProperty(Xd,"__esModule",{value:!0})});var xi=ee(ht=>{"use strict";var Ld=ht&&ht.__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]}),Zb=ht&&ht.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ei=ht&&ht.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Ld(e,t,r)},Jb=ht&&ht.__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)&&Ld(e,t,r);return Zb(e,t),e};Object.defineProperty(ht,"__esModule",{value:!0});ht.IDL=void 0;Ei(Jd(),ht);Ei(yu(),ht);ht.IDL=Jb(cu());Ei(tu(),ht);Ei(nu(),ht);Ei(_o(),ht);Ei(Qd(),ht)});var as=ee((e0,qo)=>{(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 _(E){var j,G,z,q=M.prototype={constructor:M,toString:null,valueOf:null},oe=new M(1),Q=20,ie=4,w=-7,b=21,N=-1e7,B=1e7,R=!1,V=1,Z=0,ce={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ae="0123456789abcdefghijklmnopqrstuvwxyz",D=!0;function M(l,p){var g,I,S,U,H,x,C,$,k=this;if(!(k instanceof M))return new M(l,p);if(p==null){if(l&&l._isBigNumber===!0){k.s=l.s,!l.c||l.e>B?k.c=k.e=null:l.e<N?k.c=[k.e=0]:(k.e=l.e,k.c=l.c.slice());return}if((x=typeof l=="number")&&l*0==0){if(k.s=1/l<0?(l=-l,-1):1,l===~~l){for(U=0,H=l;H>=10;H/=10,U++);U>B?k.c=k.e=null:(k.e=U,k.c=[l]);return}$=String(l)}else{if(!r.test($=String(l)))return z(k,$,x);k.s=$.charCodeAt(0)==45?($=$.slice(1),-1):1}(U=$.indexOf("."))>-1&&($=$.replace(".","")),(H=$.search(/e/i))>0?(U<0&&(U=H),U+=+$.slice(H+1),$=$.substring(0,H)):U<0&&(U=$.length)}else{if(P(p,2,ae.length,"Base"),p==10&&D)return k=new M(l),le(k,Q+k.e+1,ie);if($=String(l),x=typeof l=="number"){if(l*0!=0)return z(k,$,x,p);if(k.s=1/l<0?($=$.slice(1),-1):1,M.DEBUG&&$.replace(/^0\.0*|\./,"").length>15)throw Error(o+l)}else k.s=$.charCodeAt(0)===45?($=$.slice(1),-1):1;for(g=ae.slice(0,p),U=H=0,C=$.length;H<C;H++)if(g.indexOf(I=$.charAt(H))<0){if(I=="."){if(H>U){U=C;continue}}else if(!S&&($==$.toUpperCase()&&($=$.toLowerCase())||$==$.toLowerCase()&&($=$.toUpperCase()))){S=!0,H=-1,U=0;continue}return z(k,String(l),x,p)}x=!1,$=G($,p,10,k.s),(U=$.indexOf("."))>-1?$=$.replace(".",""):U=$.length}for(H=0;$.charCodeAt(H)===48;H++);for(C=$.length;$.charCodeAt(--C)===48;);if($=$.slice(H,++C)){if(C-=H,x&&M.DEBUG&&C>15&&(l>f||l!==i(l)))throw Error(o+k.s*l);if((U=U-H-1)>B)k.c=k.e=null;else if(U<N)k.c=[k.e=0];else{if(k.e=U,k.c=[],H=(U+1)%c,U<0&&(H+=c),H<C){for(H&&k.c.push(+$.slice(0,H)),C-=c;H<C;)k.c.push(+$.slice(H,H+=c));H=c-($=$.slice(H)).length}else H-=C;for(;H--;$+="0");k.c.push(+$)}}else k.c=[k.e=0]}M.clone=_,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(l){var p,g;if(l!=null)if(typeof l=="object"){if(l.hasOwnProperty(p="DECIMAL_PLACES")&&(g=l[p],P(g,0,m,p),Q=g),l.hasOwnProperty(p="ROUNDING_MODE")&&(g=l[p],P(g,0,8,p),ie=g),l.hasOwnProperty(p="EXPONENTIAL_AT")&&(g=l[p],g&&g.pop?(P(g[0],-m,0,p),P(g[1],0,m,p),w=g[0],b=g[1]):(P(g,-m,m,p),w=-(b=g<0?-g:g))),l.hasOwnProperty(p="RANGE"))if(g=l[p],g&&g.pop)P(g[0],-m,-1,p),P(g[1],1,m,p),N=g[0],B=g[1];else if(P(g,-m,m,p),g)N=-(B=g<0?-g:g);else throw Error(s+p+" cannot be zero: "+g);if(l.hasOwnProperty(p="CRYPTO"))if(g=l[p],g===!!g)if(g)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))R=g;else throw R=!g,Error(s+"crypto unavailable");else R=g;else throw Error(s+p+" not true or false: "+g);if(l.hasOwnProperty(p="MODULO_MODE")&&(g=l[p],P(g,0,9,p),V=g),l.hasOwnProperty(p="POW_PRECISION")&&(g=l[p],P(g,0,m,p),Z=g),l.hasOwnProperty(p="FORMAT"))if(g=l[p],typeof g=="object")ce=g;else throw Error(s+p+" not an object: "+g);if(l.hasOwnProperty(p="ALPHABET"))if(g=l[p],typeof g=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(g))D=g.slice(0,10)=="0123456789",ae=g;else throw Error(s+p+" invalid: "+g)}else throw Error(s+"Object expected: "+l);return{DECIMAL_PLACES:Q,ROUNDING_MODE:ie,EXPONENTIAL_AT:[w,b],RANGE:[N,B],CRYPTO:R,MODULO_MODE:V,POW_PRECISION:Z,FORMAT:ce,ALPHABET:ae}},M.isBigNumber=function(l){if(!l||l._isBigNumber!==!0)return!1;if(!M.DEBUG)return!0;var p,g,I=l.c,S=l.e,U=l.s;e:if({}.toString.call(I)=="[object Array]"){if((U===1||U===-1)&&S>=-m&&S<=m&&S===i(S)){if(I[0]===0){if(S===0&&I.length===1)return!0;break e}if(p=(S+1)%c,p<1&&(p+=c),String(I[0]).length==p){for(p=0;p<I.length;p++)if(g=I[p],g<0||g>=a||g!==i(g))break e;if(g!==0)return!0}}}else if(I===null&&S===null&&(U===null||U===1||U===-1))return!0;throw Error(s+"Invalid BigNumber: "+l)},M.maximum=M.max=function(){return L(arguments,-1)},M.minimum=M.min=function(){return L(arguments,1)},M.random=function(){var l=9007199254740992,p=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 I,S,U,H,x,C=0,$=[],k=new M(oe);if(g==null?g=Q:P(g,0,m),H=n(g/c),R)if(crypto.getRandomValues){for(I=crypto.getRandomValues(new Uint32Array(H*=2));C<H;)x=I[C]*131072+(I[C+1]>>>11),x>=9e15?(S=crypto.getRandomValues(new Uint32Array(2)),I[C]=S[0],I[C+1]=S[1]):($.push(x%1e14),C+=2);C=H/2}else if(crypto.randomBytes){for(I=crypto.randomBytes(H*=7);C<H;)x=(I[C]&31)*281474976710656+I[C+1]*1099511627776+I[C+2]*4294967296+I[C+3]*16777216+(I[C+4]<<16)+(I[C+5]<<8)+I[C+6],x>=9e15?crypto.randomBytes(7).copy(I,C):($.push(x%1e14),C+=7);C=H/7}else throw R=!1,Error(s+"crypto unavailable");if(!R)for(;C<H;)x=p(),x<9e15&&($[C++]=x%1e14);for(H=$[--C],g%=c,H&&g&&(x=d[c-g],$[C]=i(H/x)*x);$[C]===0;$.pop(),C--);if(C<0)$=[U=0];else{for(U=-1;$[0]===0;$.splice(0,1),U-=c);for(C=1,x=$[0];x>=10;x/=10,C++);C<c&&(U-=c-C)}return k.e=U,k.c=$,k}}(),M.sum=function(){for(var l=1,p=arguments,g=new M(p[0]);l<p.length;)g=g.plus(p[l++]);return g},G=function(){var l="0123456789";function p(g,I,S,U){for(var H,x=[0],C,$=0,k=g.length;$<k;){for(C=x.length;C--;x[C]*=I);for(x[0]+=U.indexOf(g.charAt($++)),H=0;H<x.length;H++)x[H]>S-1&&(x[H+1]==null&&(x[H+1]=0),x[H+1]+=x[H]/S|0,x[H]%=S)}return x.reverse()}return function(g,I,S,U,H){var x,C,$,k,J,te,de,_e,Me=g.indexOf("."),Ve=Q,me=ie;for(Me>=0&&(k=Z,Z=0,g=g.replace(".",""),_e=new M(I),te=_e.pow(g.length-Me),Z=k,_e.c=p(K(O(te.c),te.e,"0"),10,S,l),_e.e=_e.c.length),de=p(g,I,S,H?(x=ae,l):(x=l,ae)),$=k=de.length;de[--k]==0;de.pop());if(!de[0])return x.charAt(0);if(Me<0?--$:(te.c=de,te.e=$,te.s=U,te=j(te,_e,Ve,me,S),de=te.c,J=te.r,$=te.e),C=$+Ve+1,Me=de[C],k=S/2,J=J||C<0||de[C+1]!=null,J=me<4?(Me!=null||J)&&(me==0||me==(te.s<0?3:2)):Me>k||Me==k&&(me==4||J||me==6&&de[C-1]&1||me==(te.s<0?8:7)),C<1||!de[0])g=J?K(x.charAt(1),-Ve,x.charAt(0)):x.charAt(0);else{if(de.length=C,J)for(--S;++de[--C]>S;)de[C]=0,C||(++$,de=[1].concat(de));for(k=de.length;!de[--k];);for(Me=0,g="";Me<=k;g+=x.charAt(de[Me++]));g=K(g,$,x.charAt(0))}return g}}(),j=function(){function l(I,S,U){var H,x,C,$,k=0,J=I.length,te=S%h,de=S/h|0;for(I=I.slice();J--;)C=I[J]%h,$=I[J]/h|0,H=de*C+$*te,x=te*C+H%h*h+k,k=(x/U|0)+(H/h|0)+de*$,I[J]=x%U;return k&&(I=[k].concat(I)),I}function p(I,S,U,H){var x,C;if(U!=H)C=U>H?1:-1;else for(x=C=0;x<U;x++)if(I[x]!=S[x]){C=I[x]>S[x]?1:-1;break}return C}function g(I,S,U,H){for(var x=0;U--;)I[U]-=x,x=I[U]<S[U]?1:0,I[U]=x*H+I[U]-S[U];for(;!I[0]&&I.length>1;I.splice(0,1));}return function(I,S,U,H,x){var C,$,k,J,te,de,_e,Me,Ve,me,he,Je,vr,zr,Dr,kt,Ne,Tt=I.s==S.s?1:-1,st=I.c,$e=S.c;if(!st||!st[0]||!$e||!$e[0])return new M(!I.s||!S.s||(st?$e&&st[0]==$e[0]:!$e)?NaN:st&&st[0]==0||!$e?Tt*0:Tt/0);for(Me=new M(Tt),Ve=Me.c=[],$=I.e-S.e,Tt=U+$+1,x||(x=a,$=u(I.e/c)-u(S.e/c),Tt=Tt/c|0),k=0;$e[k]==(st[k]||0);k++);if($e[k]>(st[k]||0)&&$--,Tt<0)Ve.push(1),J=!0;else{for(zr=st.length,kt=$e.length,k=0,Tt+=2,te=i(x/($e[0]+1)),te>1&&($e=l($e,te,x),st=l(st,te,x),kt=$e.length,zr=st.length),vr=kt,me=st.slice(0,kt),he=me.length;he<kt;me[he++]=0);Ne=$e.slice(),Ne=[0].concat(Ne),Dr=$e[0],$e[1]>=x/2&&Dr++;do{if(te=0,C=p($e,me,kt,he),C<0){if(Je=me[0],kt!=he&&(Je=Je*x+(me[1]||0)),te=i(Je/Dr),te>1)for(te>=x&&(te=x-1),de=l($e,te,x),_e=de.length,he=me.length;p(de,me,_e,he)==1;)te--,g(de,kt<_e?Ne:$e,_e,x),_e=de.length,C=1;else te==0&&(C=te=1),de=$e.slice(),_e=de.length;if(_e<he&&(de=[0].concat(de)),g(me,de,he,x),he=me.length,C==-1)for(;p($e,me,kt,he)<1;)te++,g(me,kt<he?Ne:$e,he,x),he=me.length}else C===0&&(te++,me=[0]);Ve[k++]=te,me[0]?me[he++]=st[vr]||0:(me=[st[vr]],he=1)}while((vr++<zr||me[0]!=null)&&Tt--);J=me[0]!=null,Ve[0]||Ve.splice(0,1)}if(x==a){for(k=1,Tt=Ve[0];Tt>=10;Tt/=10,k++);le(Me,U+(Me.e=k+$*c-1)+1,H,J)}else Me.e=$,Me.r=+J;return Me}}();function y(l,p,g,I){var S,U,H,x,C;if(g==null?g=ie:P(g,0,8),!l.c)return l.toString();if(S=l.c[0],H=l.e,p==null)C=O(l.c),C=I==1||I==2&&(H<=w||H>=b)?A(C,H):K(C,H,"0");else if(l=le(new M(l),p,g),U=l.e,C=O(l.c),x=C.length,I==1||I==2&&(p<=U||U<=w)){for(;x<p;C+="0",x++);C=A(C,U)}else if(p-=H,C=K(C,U,"0"),U+1>x){if(--p>0)for(C+=".";p--;C+="0");}else if(p+=U-x,p>0)for(U+1==x&&(C+=".");p--;C+="0");return l.s<0&&S?"-"+C:C}function L(l,p){for(var g,I,S=1,U=new M(l[0]);S<l.length;S++)I=new M(l[S]),(!I.s||(g=T(U,I))===p||g===0&&U.s===p)&&(U=I);return U}function re(l,p,g){for(var I=1,S=p.length;!p[--S];p.pop());for(S=p[0];S>=10;S/=10,I++);return(g=I+g*c-1)>B?l.c=l.e=null:g<N?l.c=[l.e=0]:(l.e=g,l.c=p),l}z=function(){var l=/^(-?)0([xbo])(?=\w[\w.]*$)/i,p=/^([^.]+)\.$/,g=/^\.([^.]+)$/,I=/^-?(Infinity|NaN)$/,S=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(U,H,x,C){var $,k=x?H:H.replace(S,"");if(I.test(k))U.s=isNaN(k)?null:k<0?-1:1;else{if(!x&&(k=k.replace(l,function(J,te,de){return $=(de=de.toLowerCase())=="x"?16:de=="b"?2:8,!C||C==$?te:J}),C&&($=C,k=k.replace(p,"$1").replace(g,"0.$1")),H!=k))return new M(k,$);if(M.DEBUG)throw Error(s+"Not a"+(C?" base "+C:"")+" number: "+H);U.s=null}U.c=U.e=null}}();function le(l,p,g,I){var S,U,H,x,C,$,k,J=l.c,te=d;if(J){e:{for(S=1,x=J[0];x>=10;x/=10,S++);if(U=p-S,U<0)U+=c,H=p,C=J[$=0],k=i(C/te[S-H-1]%10);else if($=n((U+1)/c),$>=J.length)if(I){for(;J.length<=$;J.push(0));C=k=0,S=1,U%=c,H=U-c+1}else break e;else{for(C=x=J[$],S=1;x>=10;x/=10,S++);U%=c,H=U-c+S,k=H<0?0:i(C/te[S-H-1]%10)}if(I=I||p<0||J[$+1]!=null||(H<0?C:C%te[S-H-1]),I=g<4?(k||I)&&(g==0||g==(l.s<0?3:2)):k>5||k==5&&(g==4||I||g==6&&(U>0?H>0?C/te[S-H]:0:J[$-1])%10&1||g==(l.s<0?8:7)),p<1||!J[0])return J.length=0,I?(p-=l.e+1,J[0]=te[(c-p%c)%c],l.e=-p||0):J[0]=l.e=0,l;if(U==0?(J.length=$,x=1,$--):(J.length=$+1,x=te[c-U],J[$]=H>0?i(C/te[S-H]%te[H])*x:0),I)for(;;)if($==0){for(U=1,H=J[0];H>=10;H/=10,U++);for(H=J[0]+=x,x=1;H>=10;H/=10,x++);U!=x&&(l.e++,J[0]==a&&(J[0]=1));break}else{if(J[$]+=x,J[$]!=a)break;J[$--]=0,x=1}for(U=J.length;J[--U]===0;J.pop());}l.e>B?l.c=l.e=null:l.e<N&&(l.c=[l.e=0])}return l}function X(l){var p,g=l.e;return g===null?l.toString():(p=O(l.c),p=g<=w||g>=b?A(p,g):K(p,g,"0"),l.s<0?"-"+p:p)}return q.absoluteValue=q.abs=function(){var l=new M(this);return l.s<0&&(l.s=1),l},q.comparedTo=function(l,p){return T(this,new M(l,p))},q.decimalPlaces=q.dp=function(l,p){var g,I,S,U=this;if(l!=null)return P(l,0,m),p==null?p=ie:P(p,0,8),le(new M(U),l+U.e+1,p);if(!(g=U.c))return null;if(I=((S=g.length-1)-u(this.e/c))*c,S=g[S])for(;S%10==0;S/=10,I--);return I<0&&(I=0),I},q.dividedBy=q.div=function(l,p){return j(this,new M(l,p),Q,ie)},q.dividedToIntegerBy=q.idiv=function(l,p){return j(this,new M(l,p),0,1)},q.exponentiatedBy=q.pow=function(l,p){var g,I,S,U,H,x,C,$,k,J=this;if(l=new M(l),l.c&&!l.isInteger())throw Error(s+"Exponent not an integer: "+X(l));if(p!=null&&(p=new M(p)),x=l.e>14,!J.c||!J.c[0]||J.c[0]==1&&!J.e&&J.c.length==1||!l.c||!l.c[0])return k=new M(Math.pow(+X(J),x?l.s*(2-F(l)):+X(l))),p?k.mod(p):k;if(C=l.s<0,p){if(p.c?!p.c[0]:!p.s)return new M(NaN);I=!C&&J.isInteger()&&p.isInteger(),I&&(J=J.mod(p))}else{if(l.e>9&&(J.e>0||J.e<-1||(J.e==0?J.c[0]>1||x&&J.c[1]>=24e7:J.c[0]<8e13||x&&J.c[0]<=9999975e7)))return U=J.s<0&&F(l)?-0:0,J.e>-1&&(U=1/U),new M(C?1/U:U);Z&&(U=n(Z/c+2))}for(x?(g=new M(.5),C&&(l.s=1),$=F(l)):(S=Math.abs(+X(l)),$=S%2),k=new M(oe);;){if($){if(k=k.times(J),!k.c)break;U?k.c.length>U&&(k.c.length=U):I&&(k=k.mod(p))}if(S){if(S=i(S/2),S===0)break;$=S%2}else if(l=l.times(g),le(l,l.e+1,1),l.e>14)$=F(l);else{if(S=+X(l),S===0)break;$=S%2}J=J.times(J),U?J.c&&J.c.length>U&&(J.c.length=U):I&&(J=J.mod(p))}return I?k:(C&&(k=oe.div(k)),p?k.mod(p):U?le(k,Z,ie,H):k)},q.integerValue=function(l){var p=new M(this);return l==null?l=ie:P(l,0,8),le(p,p.e+1,l)},q.isEqualTo=q.eq=function(l,p){return T(this,new M(l,p))===0},q.isFinite=function(){return!!this.c},q.isGreaterThan=q.gt=function(l,p){return T(this,new M(l,p))>0},q.isGreaterThanOrEqualTo=q.gte=function(l,p){return(p=T(this,new M(l,p)))===1||p===0},q.isInteger=function(){return!!this.c&&u(this.e/c)>this.c.length-2},q.isLessThan=q.lt=function(l,p){return T(this,new M(l,p))<0},q.isLessThanOrEqualTo=q.lte=function(l,p){return(p=T(this,new M(l,p)))===-1||p===0},q.isNaN=function(){return!this.s},q.isNegative=function(){return this.s<0},q.isPositive=function(){return this.s>0},q.isZero=function(){return!!this.c&&this.c[0]==0},q.minus=function(l,p){var g,I,S,U,H=this,x=H.s;if(l=new M(l,p),p=l.s,!x||!p)return new M(NaN);if(x!=p)return l.s=-p,H.plus(l);var C=H.e/c,$=l.e/c,k=H.c,J=l.c;if(!C||!$){if(!k||!J)return k?(l.s=-p,l):new M(J?H:NaN);if(!k[0]||!J[0])return J[0]?(l.s=-p,l):new M(k[0]?H:ie==3?-0:0)}if(C=u(C),$=u($),k=k.slice(),x=C-$){for((U=x<0)?(x=-x,S=k):($=C,S=J),S.reverse(),p=x;p--;S.push(0));S.reverse()}else for(I=(U=(x=k.length)<(p=J.length))?x:p,x=p=0;p<I;p++)if(k[p]!=J[p]){U=k[p]<J[p];break}if(U&&(S=k,k=J,J=S,l.s=-l.s),p=(I=J.length)-(g=k.length),p>0)for(;p--;k[g++]=0);for(p=a-1;I>x;){if(k[--I]<J[I]){for(g=I;g&&!k[--g];k[g]=p);--k[g],k[I]+=a}k[I]-=J[I]}for(;k[0]==0;k.splice(0,1),--$);return k[0]?re(l,k,$):(l.s=ie==3?-1:1,l.c=[l.e=0],l)},q.modulo=q.mod=function(l,p){var g,I,S=this;return l=new M(l,p),!S.c||!l.s||l.c&&!l.c[0]?new M(NaN):!l.c||S.c&&!S.c[0]?new M(S):(V==9?(I=l.s,l.s=1,g=j(S,l,0,3),l.s=I,g.s*=I):g=j(S,l,0,V),l=S.minus(g.times(l)),!l.c[0]&&V==1&&(l.s=S.s),l)},q.multipliedBy=q.times=function(l,p){var g,I,S,U,H,x,C,$,k,J,te,de,_e,Me,Ve,me=this,he=me.c,Je=(l=new M(l,p)).c;if(!he||!Je||!he[0]||!Je[0])return!me.s||!l.s||he&&!he[0]&&!Je||Je&&!Je[0]&&!he?l.c=l.e=l.s=null:(l.s*=me.s,!he||!Je?l.c=l.e=null:(l.c=[0],l.e=0)),l;for(I=u(me.e/c)+u(l.e/c),l.s*=me.s,C=he.length,J=Je.length,C<J&&(_e=he,he=Je,Je=_e,S=C,C=J,J=S),S=C+J,_e=[];S--;_e.push(0));for(Me=a,Ve=h,S=J;--S>=0;){for(g=0,te=Je[S]%Ve,de=Je[S]/Ve|0,H=C,U=S+H;U>S;)$=he[--H]%Ve,k=he[H]/Ve|0,x=de*$+k*te,$=te*$+x%Ve*Ve+_e[U]+g,g=($/Me|0)+(x/Ve|0)+de*k,_e[U--]=$%Me;_e[U]=g}return g?++I:_e.splice(0,1),re(l,_e,I)},q.negated=function(){var l=new M(this);return l.s=-l.s||null,l},q.plus=function(l,p){var g,I=this,S=I.s;if(l=new M(l,p),p=l.s,!S||!p)return new M(NaN);if(S!=p)return l.s=-p,I.minus(l);var U=I.e/c,H=l.e/c,x=I.c,C=l.c;if(!U||!H){if(!x||!C)return new M(S/0);if(!x[0]||!C[0])return C[0]?l:new M(x[0]?I:S*0)}if(U=u(U),H=u(H),x=x.slice(),S=U-H){for(S>0?(H=U,g=C):(S=-S,g=x),g.reverse();S--;g.push(0));g.reverse()}for(S=x.length,p=C.length,S-p<0&&(g=C,C=x,x=g,p=S),S=0;p;)S=(x[--p]=x[p]+C[p]+S)/a|0,x[p]=a===x[p]?0:x[p]%a;return S&&(x=[S].concat(x),++H),re(l,x,H)},q.precision=q.sd=function(l,p){var g,I,S,U=this;if(l!=null&&l!==!!l)return P(l,1,m),p==null?p=ie:P(p,0,8),le(new M(U),l,p);if(!(g=U.c))return null;if(S=g.length-1,I=S*c+1,S=g[S]){for(;S%10==0;S/=10,I--);for(S=g[0];S>=10;S/=10,I++);}return l&&U.e+1>I&&(I=U.e+1),I},q.shiftedBy=function(l){return P(l,-f,f),this.times("1e"+l)},q.squareRoot=q.sqrt=function(){var l,p,g,I,S,U=this,H=U.c,x=U.s,C=U.e,$=Q+4,k=new M("0.5");if(x!==1||!H||!H[0])return new M(!x||x<0&&(!H||H[0])?NaN:H?U:1/0);if(x=Math.sqrt(+X(U)),x==0||x==1/0?(p=O(H),(p.length+C)%2==0&&(p+="0"),x=Math.sqrt(+p),C=u((C+1)/2)-(C<0||C%2),x==1/0?p="5e"+C:(p=x.toExponential(),p=p.slice(0,p.indexOf("e")+1)+C),g=new M(p)):g=new M(x+""),g.c[0]){for(C=g.e,x=C+$,x<3&&(x=0);;)if(S=g,g=k.times(S.plus(j(U,S,$,1))),O(S.c).slice(0,x)===(p=O(g.c)).slice(0,x))if(g.e<C&&--x,p=p.slice(x-3,x+1),p=="9999"||!I&&p=="4999"){if(!I&&(le(S,S.e+Q+2,0),S.times(S).eq(U))){g=S;break}$+=4,x+=4,I=1}else{(!+p||!+p.slice(1)&&p.charAt(0)=="5")&&(le(g,g.e+Q+2,1),l=!g.times(g).eq(U));break}}return le(g,g.e+Q+1,ie,l)},q.toExponential=function(l,p){return l!=null&&(P(l,0,m),l++),y(this,l,p,1)},q.toFixed=function(l,p){return l!=null&&(P(l,0,m),l=l+this.e+1),y(this,l,p)},q.toFormat=function(l,p,g){var I,S=this;if(g==null)l!=null&&p&&typeof p=="object"?(g=p,p=null):l&&typeof l=="object"?(g=l,l=p=null):g=ce;else if(typeof g!="object")throw Error(s+"Argument not an object: "+g);if(I=S.toFixed(l,p),S.c){var U,H=I.split("."),x=+g.groupSize,C=+g.secondaryGroupSize,$=g.groupSeparator||"",k=H[0],J=H[1],te=S.s<0,de=te?k.slice(1):k,_e=de.length;if(C&&(U=x,x=C,C=U,_e-=U),x>0&&_e>0){for(U=_e%x||x,k=de.substr(0,U);U<_e;U+=x)k+=$+de.substr(U,x);C>0&&(k+=$+de.slice(U)),te&&(k="-"+k)}I=J?k+(g.decimalSeparator||"")+((C=+g.fractionGroupSize)?J.replace(new RegExp("\\d{"+C+"}\\B","g"),"$&"+(g.fractionGroupSeparator||"")):J):k}return(g.prefix||"")+I+(g.suffix||"")},q.toFraction=function(l){var p,g,I,S,U,H,x,C,$,k,J,te,de=this,_e=de.c;if(l!=null&&(x=new M(l),!x.isInteger()&&(x.c||x.s!==1)||x.lt(oe)))throw Error(s+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+X(x));if(!_e)return new M(de);for(p=new M(oe),$=g=new M(oe),I=C=new M(oe),te=O(_e),U=p.e=te.length-de.e-1,p.c[0]=d[(H=U%c)<0?c+H:H],l=!l||x.comparedTo(p)>0?U>0?p:$:x,H=B,B=1/0,x=new M(te),C.c[0]=0;k=j(x,p,0,1),S=g.plus(k.times(I)),S.comparedTo(l)!=1;)g=I,I=S,$=C.plus(k.times(S=$)),C=S,p=x.minus(k.times(S=p)),x=S;return S=j(l.minus(g),I,0,1),C=C.plus(S.times($)),g=g.plus(S.times(I)),C.s=$.s=de.s,U=U*2,J=j($,I,U,ie).minus(de).abs().comparedTo(j(C,g,U,ie).minus(de).abs())<1?[$,I]:[C,g],B=H,J},q.toNumber=function(){return+X(this)},q.toPrecision=function(l,p){return l!=null&&P(l,1,m),y(this,l,p,2)},q.toString=function(l){var p,g=this,I=g.s,S=g.e;return S===null?I?(p="Infinity",I<0&&(p="-"+p)):p="NaN":(l==null?p=S<=w||S>=b?A(O(g.c),S):K(O(g.c),S,"0"):l===10&&D?(g=le(new M(g),Q+S+1,ie),p=K(O(g.c),g.e,"0")):(P(l,2,ae.length,"Base"),p=G(K(O(g.c),S,"0"),10,l,I,!0)),I<0&&g.c[0]&&(p="-"+p)),p},q.valueOf=q.toJSON=function(){return X(this)},q._isBigNumber=!0,E!=null&&M.set(E),M}function u(E){var j=E|0;return E>0||E===j?j:j-1}function O(E){for(var j,G,z=1,q=E.length,oe=E[0]+"";z<q;){for(j=E[z++]+"",G=c-j.length;G--;j="0"+j);oe+=j}for(q=oe.length;oe.charCodeAt(--q)===48;);return oe.slice(0,q+1||1)}function T(E,j){var G,z,q=E.c,oe=j.c,Q=E.s,ie=j.s,w=E.e,b=j.e;if(!Q||!ie)return null;if(G=q&&!q[0],z=oe&&!oe[0],G||z)return G?z?0:-ie:Q;if(Q!=ie)return Q;if(G=Q<0,z=w==b,!q||!oe)return z?0:!q^G?1:-1;if(!z)return w>b^G?1:-1;for(ie=(w=q.length)<(b=oe.length)?w:b,Q=0;Q<ie;Q++)if(q[Q]!=oe[Q])return q[Q]>oe[Q]^G?1:-1;return w==b?0:w>b^G?1:-1}function P(E,j,G,z){if(E<j||E>G||E!==i(E))throw Error(s+(z||"Argument")+(typeof E=="number"?E<j||E>G?" out of range: ":" not an integer: ":" not a primitive number: ")+String(E))}function F(E){var j=E.c.length-1;return u(E.e/c)==j&&E.c[j]%2!=0}function A(E,j){return(E.length>1?E.charAt(0)+"."+E.slice(1):E)+(j<0?"e":"e+")+j}function K(E,j,G){var z,q;if(j<0){for(q=G+".";++j;q+=G);E=q+E}else if(z=E.length,++j>z){for(q=G,j-=z;--j;q+=G);E+=q}else j<z&&(E=E.slice(0,j)+"."+E.slice(j));return E}e=_(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof qo<"u"&&qo.exports?qo.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(e0)});var r0=ee((rv,t0)=>{t0.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,O=r.pushUndefined,T=r.pushNull,P=r.pushInfinity,F=r.pushInfinityNeg,A=r.pushNaN,K=r.pushNaNNeg,E=r.pushArrayStart,j=r.pushArrayStartFixed,G=r.pushArrayStartFixed32,z=r.pushArrayStartFixed64,q=r.pushObjectStart,oe=r.pushObjectStartFixed,Q=r.pushObjectStartFixed32,ie=r.pushObjectStartFixed64,w=r.pushByteString,b=r.pushByteStringStart,N=r.pushUtf8String,B=r.pushUtf8StringStart,R=r.pushSimpleUnassigned,V=r.pushTagStart,Z=r.pushTagStart4,ce=r.pushTagStart8,ae=r.pushTagUnassigned,D=r.pushBreak,M=e.Math.pow,y=0,L=0,re=0;function le(v){for(v=v|0,y=0,L=v;(y|0)<(L|0)&&(re=zg[i[y]&255](i[y]|0)|0,!((re|0)>0)););return re|0}function X(v){return v=v|0,((y|0)+(v|0)|0)<(L|0)?0:1}function l(v){return v=v|0,i[v|0]<<8|i[v+1|0]|0}function p(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),y=y+1|0,0}function I(v){return v=v|0,X(1)|0?1:(s(i[y+1|0]|0),y=y+2|0,0)}function S(v){return v=v|0,X(2)|0?1:(s(l(y+1|0)|0),y=y+3|0,0)}function U(v){return v=v|0,X(4)|0?1:(o(l(y+1|0)|0,l(y+3|0)|0),y=y+5|0,0)}function H(v){return v=v|0,X(8)|0?1:(c(l(y+1|0)|0,l(y+3|0)|0,l(y+5|0)|0,l(y+7|0)|0),y=y+9|0,0)}function x(v){return v=v|0,s(-1-(v-32|0)|0),y=y+1|0,0}function C(v){return v=v|0,X(1)|0?1:(s(-1-(i[y+1|0]|0)|0),y=y+2|0,0)}function $(v){v=v|0;var Ae=0;return X(2)|0?1:(Ae=l(y+1|0)|0,s(-1-(Ae|0)|0),y=y+3|0,0)}function k(v){return v=v|0,X(4)|0?1:(a(l(y+1|0)|0,l(y+3|0)|0),y=y+5|0,0)}function J(v){return v=v|0,X(8)|0?1:(f(l(y+1|0)|0,l(y+3|0)|0,l(y+5|0)|0,l(y+7|0)|0),y=y+9|0,0)}function te(v){v=v|0;var Ae=0,Oe=0,xe=0;return xe=v-64|0,X(xe|0)|0?1:(Ae=y+1|0,Oe=(y+1|0)+(xe|0)|0,w(Ae|0,Oe|0),y=Oe|0,0)}function de(v){v=v|0;var Ae=0,Oe=0,xe=0;return X(1)|0||(xe=i[y+1|0]|0,Ae=y+2|0,Oe=(y+2|0)+(xe|0)|0,X(xe+1|0)|0)?1:(w(Ae|0,Oe|0),y=Oe|0,0)}function _e(v){v=v|0;var Ae=0,Oe=0,xe=0;return X(2)|0||(xe=l(y+1|0)|0,Ae=y+3|0,Oe=(y+3|0)+(xe|0)|0,X(xe+2|0)|0)?1:(w(Ae|0,Oe|0),y=Oe|0,0)}function Me(v){v=v|0;var Ae=0,Oe=0,xe=0;return X(4)|0||(xe=p(y+1|0)|0,Ae=y+5|0,Oe=(y+5|0)+(xe|0)|0,X(xe+4|0)|0)?1:(w(Ae|0,Oe|0),y=Oe|0,0)}function Ve(v){return v=v|0,1}function me(v){return v=v|0,b(),y=y+1|0,0}function he(v){v=v|0;var Ae=0,Oe=0,xe=0;return xe=v-96|0,X(xe|0)|0?1:(Ae=y+1|0,Oe=(y+1|0)+(xe|0)|0,N(Ae|0,Oe|0),y=Oe|0,0)}function Je(v){v=v|0;var Ae=0,Oe=0,xe=0;return X(1)|0||(xe=i[y+1|0]|0,Ae=y+2|0,Oe=(y+2|0)+(xe|0)|0,X(xe+1|0)|0)?1:(N(Ae|0,Oe|0),y=Oe|0,0)}function vr(v){v=v|0;var Ae=0,Oe=0,xe=0;return X(2)|0||(xe=l(y+1|0)|0,Ae=y+3|0,Oe=(y+3|0)+(xe|0)|0,X(xe+2|0)|0)?1:(N(Ae|0,Oe|0),y=Oe|0,0)}function zr(v){v=v|0;var Ae=0,Oe=0,xe=0;return X(4)|0||(xe=p(y+1|0)|0,Ae=y+5|0,Oe=(y+5|0)+(xe|0)|0,X(xe+4|0)|0)?1:(N(Ae|0,Oe|0),y=Oe|0,0)}function Dr(v){return v=v|0,1}function kt(v){return v=v|0,B(),y=y+1|0,0}function Ne(v){return v=v|0,j(v-128|0),y=y+1|0,0}function Tt(v){return v=v|0,X(1)|0?1:(j(i[y+1|0]|0),y=y+2|0,0)}function st(v){return v=v|0,X(2)|0?1:(j(l(y+1|0)|0),y=y+3|0,0)}function $e(v){return v=v|0,X(4)|0?1:(G(l(y+1|0)|0,l(y+3|0)|0),y=y+5|0,0)}function xc(v){return v=v|0,X(8)|0?1:(z(l(y+1|0)|0,l(y+3|0)|0,l(y+5|0)|0,l(y+7|0)|0),y=y+9|0,0)}function vc(v){return v=v|0,E(),y=y+1|0,0}function Ke(v){v=v|0;var Ae=0;return Ae=v-160|0,X(Ae|0)|0?1:(oe(Ae|0),y=y+1|0,0)}function Tc(v){return v=v|0,X(1)|0?1:(oe(i[y+1|0]|0),y=y+2|0,0)}function Ac(v){return v=v|0,X(2)|0?1:(oe(l(y+1|0)|0),y=y+3|0,0)}function Sc(v){return v=v|0,X(4)|0?1:(Q(l(y+1|0)|0,l(y+3|0)|0),y=y+5|0,0)}function Bc(v){return v=v|0,X(8)|0?1:(ie(l(y+1|0)|0,l(y+3|0)|0,l(y+5|0)|0,l(y+7|0)|0),y=y+9|0,0)}function Oc(v){return v=v|0,q(),y=y+1|0,0}function an(v){return v=v|0,V(v-192|0|0),y=y+1|0,0}function x8(v){return v=v|0,V(v|0),y=y+1|0,0}function v8(v){return v=v|0,V(v|0),y=y+1|0,0}function T8(v){return v=v|0,V(v|0),y=y+1|0,0}function A8(v){return v=v|0,V(v|0),y=y+1|0,0}function ft(v){return v=v|0,V(v-192|0|0),y=y+1|0,0}function S8(v){return v=v|0,V(v|0),y=y+1|0,0}function B8(v){return v=v|0,V(v|0),y=y+1|0,0}function O8(v){return v=v|0,V(v|0),y=y+1|0,0}function Fg(v){return v=v|0,X(1)|0?1:(V(i[y+1|0]|0),y=y+2|0,0)}function Mg(v){return v=v|0,X(2)|0?1:(V(l(y+1|0)|0),y=y+3|0,0)}function Cg(v){return v=v|0,X(4)|0?1:(Z(l(y+1|0)|0,l(y+3|0)|0),y=y+5|0,0)}function qg(v){return v=v|0,X(8)|0?1:(ce(l(y+1|0)|0,l(y+3|0)|0,l(y+5|0)|0,l(y+7|0)|0),y=y+9|0,0)}function rt(v){return v=v|0,R((v|0)-224|0),y=y+1|0,0}function jg(v){return v=v|0,u(),y=y+1|0,0}function kg(v){return v=v|0,_(),y=y+1|0,0}function Hg(v){return v=v|0,T(),y=y+1|0,0}function Vg(v){return v=v|0,O(),y=y+1|0,0}function $g(v){return v=v|0,X(1)|0?1:(R(i[y+1|0]|0),y=y+2|0,0)}function Kg(v){v=v|0;var Ae=0,Oe=0,xe=1,ro=0,Ji=0,N8=0;return X(2)|0?1:(Ae=i[y+1|0]|0,Oe=i[y+2|0]|0,(Ae|0)&128&&(xe=-1),ro=+(((Ae|0)&124)>>2),Ji=+(((Ae|0)&3)<<8|Oe),+ro==0?d(+(+xe*5960464477539063e-23*+Ji)):+ro==31?+xe==1?+Ji>0?A():P():+Ji>0?K():F():d(+(+xe*M(2,+(+ro-25))*+(1024+Ji))),y=y+3|0,0)}function Gg(v){return v=v|0,X(4)|0?1:(h(i[y+1|0]|0,i[y+2|0]|0,i[y+3|0]|0,i[y+4|0]|0),y=y+5|0,0)}function Yg(v){return v=v|0,X(8)|0?1:(m(i[y+1|0]|0,i[y+2|0]|0,i[y+3|0]|0,i[y+4|0]|0,i[y+5|0]|0,i[y+6|0]|0,i[y+7|0]|0,i[y+8|0]|0),y=y+9|0,0)}function ke(v){return v=v|0,1}function Wg(v){return v=v|0,D(),y=y+1|0,0}var zg=[g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,I,S,U,H,ke,ke,ke,ke,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,C,$,k,J,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,Me,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,Je,vr,zr,Dr,ke,ke,ke,kt,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Ne,Tt,st,$e,xc,ke,ke,ke,vc,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Tc,Ac,Sc,Bc,ke,ke,ke,Oc,an,an,an,an,an,an,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,Fg,Mg,Cg,qg,ke,ke,ke,ke,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,jg,kg,Hg,Vg,$g,Kg,Gg,Yg,ke,ke,ke,Wg];return{parse:le}}});var cs=ee(zt=>{"use strict";var Eu=as().BigNumber;zt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};zt.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};zt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};zt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};zt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};zt.SHIFT32=Math.pow(2,32);zt.SHIFT16=Math.pow(2,16);zt.MAX_SAFE_HIGH=2097151;zt.NEG_ONE=new Eu(-1);zt.TEN=new Eu(10);zt.TWO=new Eu(2);zt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var jo=ee(nr=>{"use strict";var{Buffer:Xb}=ai("buffer"),i0=as().BigNumber,s0=cs(),n0=s0.SHIFT32,Qb=s0.SHIFT16,Lb=2097151;nr.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 e_(t){return t<16?"0"+t.toString(16):t.toString(16)}nr.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=e_(t[n]);return new i0(r,16)};nr.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};nr.buildInt32=(t,e)=>t*Qb+e;nr.buildInt64=(t,e,r,n)=>{let i=nr.buildInt32(t,e),s=nr.buildInt32(r,n);return i>Lb?new i0(i).times(n0).plus(s):i*n0+s};nr.writeHalf=function(e,r){let n=Xb.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if((i&8191)!==0)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};nr.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])};nr.isNegativeZero=t=>t===0&&1/t<0;nr.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Au=ee((sv,o0)=>{"use strict";var Tu=cs(),t_=Tu.MT,ko=Tu.SIMPLE,xu=Tu.SYMS,vu=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,t_.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case ko.FALSE:return!1;case ko.TRUE:return!0;case ko.NULL:return r?null:xu.NULL;case ko.UNDEFINED:return r?void 0:xu.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return xu.BREAK;default:return new t(e)}}};o0.exports=vu});var Bu=ee((ov,a0)=>{"use strict";var Su=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}}};a0.exports=Su});var Nu=ee((av,u0)=>{"use strict";var{URL:r_,URLSearchParams:n_,format:i_}=ai("url"),c0="http://localhost",Ou=class extends r_{constructor(e="",r=c0){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()}};u0.exports={URLWithLegacySupport:Ou,URLSearchParams:n_,format:i_,defaultBase:c0}});var d0=ee((cv,f0)=>{"use strict";var{URLWithLegacySupport:l0,format:s_}=Nu();f0.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new l0(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new l0(t,s_(o)).toString()}});var Ru=ee((uv,h0)=>{"use strict";var{URLWithLegacySupport:o_,format:a_,URLSearchParams:c_,defaultBase:u_}=Nu(),l_=d0();h0.exports={URL:o_,URLSearchParams:c_,format:a_,relative:l_,defaultBase:u_}});var Pu=ee((lv,y0)=>{"use strict";var{Buffer:vi}=ai("buffer"),p0=Pc(),f_=as().BigNumber,d_=r0(),Ft=jo(),Ce=cs(),h_=Au(),p_=Bu(),{URL:y_}=Ru(),us=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=Ft.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=vi.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>Ft.arrayBufferToBignumber(r),3:r=>Ce.NEG_ONE.minus(Ft.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 y_(r),35:r=>new RegExp(r)},e.tags),this.parser=d_(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=Ft.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 p_(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return vi.concat(e)}createByteStringFromHeap(e,r){return e===r?vi.alloc(0):vi.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return Ft.buildInt32(e,r)}createInt64(e,r,n,i){return Ft.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return p0.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return p0.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-Ft.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=Ft.buildInt32(e,r),o=Ft.buildInt32(n,i);return s>Ce.MAX_SAFE_HIGH?Ce.NEG_ONE.minus(new f_(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 h_(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=Ft.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=Ft.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=Ft.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=Ft.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(Ft.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(Ft.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=vi.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=vi.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};us.decodeFirst=us.decode;y0.exports=us});var b0=ee((fv,m0)=>{"use strict";var{Buffer:Iu}=ai("buffer"),g_=Pu(),m_=jo(),Uu=class t extends g_{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 m_.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'${Iu.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(g0(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(g0(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${Iu.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=Iu.from(e,r||"hex")),new t().decodeFirst(e)}};m0.exports=Uu;function g0(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var v0=ee((dv,x0)=>{"use strict";var{Buffer:Ir}=ai("buffer"),{URL:b_}=Ru(),Mu=as().BigNumber,Fu=jo(),ot=cs(),lr=ot.MT,Ho=ot.NUMBYTES,_0=ot.SHIFT32,w0=ot.SYMS,Ti=ot.TAG,__=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.TWO,w_=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.FOUR,E_=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.EIGHT,x_=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.TRUE,v_=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.FALSE,T_=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.UNDEFINED,E0=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.NULL,A_=new Mu("0x20000000000000"),S_=Ir.from("f97e00","hex"),B_=Ir.from("f9fc00","hex"),O_=Ir.from("f97c00","hex");function N_(t){return{}.toString.call(t).slice(8,-1)}var Cu=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[b_,this._pushUrl],[Mu,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(S_)}_pushInfinity(e){let r=e<0?B_:O_;return this.push(r)}_pushFloat(e){let r=Ir.allocUnsafe(2);if(Fu.writeHalf(r,e)&&Fu.parseHalf(r)===e)return this._pushUInt8(__)&&this.push(r);let n=Ir.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(w_)&&this.push(n):this._pushUInt8(E_)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|Ho.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|Ho.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|Ho.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Ho.EIGHT)&&this._pushUInt32BE(Math.floor(e/_0))&&this._pushUInt32BE(e%_0):r===lr.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,lr.NEG_INT,e):this._pushInt(e,lr.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=Ir.byteLength(e,"utf8");return this._pushInt(r,lr.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?x_:v_)}_pushUndefined(e){return this._pushUInt8(T_)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,lr.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,lr.TAG)}_pushDate(e,r){return e._pushTag(Ti.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,lr.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(Ti.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,lr.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(Ti.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=Ti.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=Ti.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Ir.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(Ti.DECIMAL_FRAC)&&e._pushInt(2,lr.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new Mu(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(A_)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,lr.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(E0);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,lr.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(Fu.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=N_(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,Ir.isBuffer(e)?e:Ir.from(e));case"Null":return this._pushUInt8(E0);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 w0.NULL:return this._pushObject(null);case w0.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=Ir.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()}};x0.exports=Cu});var Vo=ee(at=>{"use strict";at.Diagnose=b0();at.Decoder=Pu();at.Encoder=v0();at.Simple=Au();at.Tagged=Bu();at.decodeAll=at.Decoder.decodeAll;at.decodeFirst=at.Decoder.decodeFirst;at.diagnose=at.Diagnose.diagnose;at.encode=at.Encoder.encode;at.decode=at.Decoder.decode;at.leveldb={decode:at.Decoder.decodeAll,encode:at.Encoder.encode,buffer:!0,name:"cbor"}});var ds=ee(ir=>{"use strict";var R_=ir&&ir.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ir,"__esModule",{value:!0});ir.hashOfMap=ir.requestIdOf=ir.hashValue=ir.hash=void 0;var T0=xi(),P_=R_(Vo()),I_=ho(),ls=Vt();function gn(t){return(0,ls.uint8ToBuf)(I_.sha256.create().update(new Uint8Array(t)).digest())}ir.hash=gn;function fs(t){if(t instanceof P_.default.Tagged)return fs(t.value);if(typeof t=="string")return A0(t);if(typeof t=="number")return gn((0,T0.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return gn(t);if(Array.isArray(t)){let e=t.map(fs);return gn((0,ls.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return gn(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return fs(t.toHash());if(typeof t=="object")return qu(t);if(typeof t=="bigint")return gn((0,T0.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}ir.hashValue=fs;var A0=t=>{let e=new TextEncoder().encode(t);return gn(e)};function U_(t){return qu(t)}ir.requestIdOf=U_;function qu(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=A0(o),f=fs(a);return[c,f]}).sort(([o],[a])=>(0,ls.compare)(o,a)),i=(0,ls.concat)(...n.map(o=>(0,ls.concat)(...o)));return gn(i)}ir.hashOfMap=qu});var Hu=ee(Ur=>{"use strict";var F_=Ur&&Ur.__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(Ur,"__esModule",{value:!0});Ur.createIdentityDescriptor=Ur.AnonymousIdentity=Ur.SignIdentity=void 0;var S0=Ut(),M_=ds(),B0=Vt(),C_=new TextEncoder().encode(`
|
|
17
|
+
ic-request`),ju=class{getPrincipal(){return this._principal||(this._principal=S0.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=F_(e,["body"]),i=(0,M_.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,B0.concat)(C_,i))}})}};Ur.SignIdentity=ju;var ku=class{getPrincipal(){return S0.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};Ur.AnonymousIdentity=ku;function q_(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,B0.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Ur.createIdentityDescriptor=q_});var Ku=ee(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});var j_=9007199254740992;function Qr(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 fr(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 $o(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 fr(t,r,e.toString(16))}}function O0(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 Qr(new Uint8Array($o(3,t.length)),new Uint8Array(e))}function k_(t,e){if(t==14277111)return Qr(new Uint8Array([217,217,247]),e);if(t<24)return Qr(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}}Ge.tagged=k_;function hs(t){return new Uint8Array(t).buffer}Ge.raw=hs;function Vu(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}Ge.uSmall=Vu;function N0(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),fr(0,24,t)}Ge.u8=N0;function R0(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),fr(0,25,t)}Ge.u16=R0;function P0(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),fr(0,26,t)}Ge.u32=P0;function $u(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return fr(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),j_),t=t.toString(16),fr(0,27,t)}Ge.u64=$u;function I0(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Vu(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ge.iSmall=I0;function U0(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),fr(1,24,t)}Ge.i8=U0;function F0(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),fr(1,25,t)}Ge.i16=F0;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),fr(1,26,t)}Ge.i32=M0;function C0(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?fr(1,27,n):$u(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),fr(1,27,t)}Ge.i64=C0;function H_(t){return t>=0?t<24?Vu(t):t<=255?N0(t):t<=65535?R0(t):t<=4294967295?P0(t):$u(t):t>=-24?I0(t):t>=-255?U0(t):t>=-65535?F0(t):t>=-4294967295?M0(t):C0(t)}Ge.number=H_;function V_(t){return Qr($o(2,t.byteLength),t)}Ge.bytes=V_;function $_(t){return O0(t)}Ge.string=$_;function K_(t){return Qr($o(4,t.length),...t)}Ge.array=K_;function G_(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))),Qr($o(5,t.size),...r.map(([n,i])=>Qr(O0(n),i)))}Ge.map=G_;function Y_(t){let e=new Float32Array([t]);return Qr(new Uint8Array([250]),new Uint8Array(e.buffer))}Ge.singleFloat=Y_;function W_(t){let e=new Float64Array([t]);return Qr(new Uint8Array([251]),new Uint8Array(e.buffer))}Ge.doubleFloat=W_;function z_(t){return t?q0():j0()}Ge.bool=z_;function q0(){return hs(new Uint8Array([245]))}Ge.true_=q0;function j0(){return hs(new Uint8Array([244]))}Ge.false_=j0;function D_(){return hs(new Uint8Array([246]))}Ge.null_=D_;function Z_(){return hs(new Uint8Array([247]))}Ge.undefined_=Z_});var k0=ee(mn=>{"use strict";var J_=mn&&mn.__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(mn,"__esModule",{value:!0});var dr=J_(Ku()),X_=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Ko=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 dr.undefined_();case"boolean":return dr.bool(e);case"number":return Math.floor(e)===e?dr.number(e):dr.doubleFloat(e);case"string":return dr.string(e);case"object":if(e===null)return dr.null_();if(Array.isArray(e))return dr.array(e.map(r=>this._serializer.serializeValue(r)));if(X_.find(r=>e instanceof r))return dr.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 dr.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 dr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};mn.JsonDefaultCborEncoder=Ko;var Go=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};mn.ToCborEncoder=Go;var Yo=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new Ko(r,e)),r.addEncoder(new Go),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)}};mn.CborSerializer=Yo;var Gu=class extends Yo{serialize(e){return dr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};mn.SelfDescribeCborSerializer=Gu});var ps=ee(Vn=>{"use strict";function Q_(t){for(var e in t)Vn.hasOwnProperty(e)||(Vn[e]=t[e])}var L_=Vn&&Vn.__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(Vn,"__esModule",{value:!0});Q_(k0());var e1=L_(Ku());Vn.value=e1});var ys=ee(bt=>{"use strict";var t1=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]}),r1=bt&&bt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n1=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)&&t1(e,t,r);return r1(e,t),e},i1=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 s1=i1(Vo()),Ai=n1(ps()),o1=ps(),Wo=Vt(),Yu=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Ai.value.bytes(e.toUint8Array())}},Wu=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Ai.value.bytes(new Uint8Array(e))}},zu=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Ai.value.tagged(2,Ai.value.bytes((0,Wo.fromHex)(e.toString(16)))):Ai.value.tagged(3,Ai.value.bytes((0,Wo.fromHex)((BigInt("-1")*e).toString(16))))}},zo=o1.SelfDescribeCborSerializer.withDefaultEncoders(!0);zo.addEncoder(new Yu);zo.addEncoder(new Wu);zo.addEncoder(new zu);var V0;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(V0=bt.CborTag||(bt.CborTag={}));function a1(t){return zo.serialize(t)}bt.encode=a1;function H0(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 Du=class extends s1.default.Decoder{createByteString(e){return(0,Wo.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function c1(t){let e=new Uint8Array(t),r=new Du({size:e.byteLength,tags:{2:n=>H0(n),3:n=>-H0(n),[V0.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,Wo.toHex)(e)}`)}}bt.decode=c1});var Zu=ee(Do=>{"use strict";Object.defineProperty(Do,"__esModule",{value:!0});Do.randomNumber=void 0;var u1=()=>{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)};Do.randomNumber=u1});var gs=ee($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.makeNonce=$n.SubmitRequestType=void 0;var Zo=Zu(),l1;(function(t){t.Call="call"})(l1=$n.SubmitRequestType||($n.SubmitRequestType={}));function f1(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,Zo.randomNumber)(),n=(0,Zo.randomNumber)(),i=(0,Zo.randomNumber)(),s=(0,Zo.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}$n.makeNonce=f1});var Xo=ee(Bt=>{"use strict";var d1=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]}),h1=Bt&&Bt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),p1=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)&&d1(e,t,r);return h1(e,t),e};Object.defineProperty(Bt,"__esModule",{value:!0});Bt.httpHeadersTransform=Bt.makeExpiryTransform=Bt.makeNonceTransform=Bt.Expiry=void 0;var y1=xi(),g1=p1(ps()),m1=gs(),$0=BigInt(1e6),b1=60*1e3,Jo=class{constructor(e){if(e<90*1e3){let a=BigInt(Date.now()+e)*$0/BigInt(1e9);this._value=a*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-b1))*$0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return g1.value.u64(this._value.toString(16),16)}toHash(){return(0,y1.lebEncode)(this._value)}};Bt.Expiry=Jo;function _1(t=m1.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}Bt.makeNonceTransform=_1;function w1(t){return async e=>{e.body.ingress_expiry=new Jo(t)}}Bt.makeExpiryTransform=w1;function E1(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}Bt.httpHeadersTransform=E1});var Lo=ee(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.AgentReadStateError=Fr.AgentQueryError=Fr.AgentCallError=Fr.AgentHTTPResponseError=void 0;var Qo=yi(),Ju=class extends Qo.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Fr.AgentHTTPResponseError=Ju;var Xu=class extends Qo.AgentError{constructor(e,r,n,i,s,o){super(e),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}};Fr.AgentCallError=Xu;var Qu=class extends Qo.AgentError{constructor(e,r,n,i,s,o){super(e),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}};Fr.AgentQueryError=Qu;var Lu=class extends Qo.AgentError{constructor(e,r,n,i,s,o){super(e),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};Fr.AgentReadStateError=Lu});var Dt=ee(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.notImplemented=Ie.bitMask=void 0;Ie.isBytes=ta;Ie.abytes=ra;Ie.abool=v1;Ie.bytesToHex=nl;Ie.numberToHexUnpadded=Y0;Ie.hexToNumber=il;Ie.hexToBytes=na;Ie.bytesToNumberBE=A1;Ie.bytesToNumberLE=S1;Ie.numberToBytesBE=W0;Ie.numberToBytesLE=B1;Ie.numberToVarBytesBE=O1;Ie.ensureBytes=N1;Ie.concatBytes=z0;Ie.equalBytes=R1;Ie.utf8ToBytes=P1;Ie.inRange=D0;Ie.aInRange=I1;Ie.bitLen=U1;Ie.bitGet=F1;Ie.bitSet=M1;Ie.createHmacDrbg=q1;Ie.validateObject=k1;Ie.memoized=V1;var rl=BigInt(0),ea=BigInt(1),x1=BigInt(2);function ta(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function ra(t){if(!ta(t))throw new Error("Uint8Array expected")}function v1(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}var T1=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function nl(t){ra(t);let e="";for(let r=0;r<t.length;r++)e+=T1[t[r]];return e}function Y0(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function il(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Lr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function K0(t){if(t>=Lr._0&&t<=Lr._9)return t-Lr._0;if(t>=Lr._A&&t<=Lr._F)return t-(Lr._A-10);if(t>=Lr._a&&t<=Lr._f)return t-(Lr._a-10)}function na(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=K0(t.charCodeAt(s)),a=K0(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 A1(t){return il(nl(t))}function S1(t){return ra(t),il(nl(Uint8Array.from(t).reverse()))}function W0(t,e){return na(t.toString(16).padStart(e*2,"0"))}function B1(t,e){return W0(t,e).reverse()}function O1(t){return na(Y0(t))}function N1(t,e,r){let n;if(typeof e=="string")try{n=na(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(ta(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 z0(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];ra(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 R1(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 P1(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}var el=t=>typeof t=="bigint"&&rl<=t;function D0(t,e,r){return el(t)&&el(e)&&el(r)&&e<=t&&t<r}function I1(t,e,r,n){if(!D0(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function U1(t){let e;for(e=0;t>rl;t>>=ea,e+=1);return e}function F1(t,e){return t>>BigInt(e)&ea}function M1(t,e,r){return t|(r?ea:rl)<<BigInt(e)}var C1=t=>(x1<<BigInt(t-1))-ea;Ie.bitMask=C1;var tl=t=>new Uint8Array(t),G0=t=>Uint8Array.from(t);function q1(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=tl(t),i=tl(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...h)=>r(i,n,...h),c=(h=tl())=>{i=a(G0([0]),h),n=a(),h.length!==0&&(i=a(G0([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 z0(...m)};return(h,m)=>{o(),c(h);let _;for(;!(_=m(f()));)c();return o(),_}}var j1={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"||ta(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 k1(t,e,r={}){let n=(i,s,o)=>{let a=j1[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 H1=()=>{throw new Error("not implemented")};Ie.notImplemented=H1;function V1(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 Mr=ee(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.isNegativeLE=void 0;ze.mod=Zt;ze.pow=X0;ze.pow2=Y1;ze.invert=ia;ze.tonelliShanks=Q0;ze.FpSqrt=L0;ze.validateField=D1;ze.FpPow=eh;ze.FpInvertBatch=th;ze.FpDiv=Z1;ze.FpLegendre=rh;ze.FpIsSquare=J1;ze.nLength=ol;ze.Field=X1;ze.FpSqrtOdd=Q1;ze.FpSqrtEven=L1;ze.hashToPrivateScalar=ew;ze.getFieldBytesLength=al;ze.getMinHashLength=nh;ze.mapHashToField=tw;var Jt=Dt(),ct=BigInt(0),He=BigInt(1),bn=BigInt(2),$1=BigInt(3),sl=BigInt(4),Z0=BigInt(5),J0=BigInt(8),K1=BigInt(9),G1=BigInt(16);function Zt(t,e){let r=t%e;return r>=ct?r:e+r}function X0(t,e,r){if(r<=ct||e<ct)throw new Error("Expected power/modulo > 0");if(r===He)return ct;let n=He;for(;e>ct;)e&He&&(n=n*t%r),t=t*t%r,e>>=He;return n}function Y1(t,e,r){let n=t;for(;e-- >ct;)n*=n,n%=r;return n}function ia(t,e){if(t===ct||e<=ct)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Zt(t,e),n=e,i=ct,s=He,o=He,a=ct;for(;r!==ct;){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 Zt(i,e)}function Q0(t){let e=(t-He)/bn,r,n,i;for(r=t-He,n=0;r%bn===ct;r/=bn,n++);for(i=bn;i<t&&X0(i,e,t)!==t-He;i++);if(n===1){let o=(t+He)/sl;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)/bn;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 O=a.sqr(m);_<f&&!a.eql(O,a.ONE);_++)O=a.sqr(O);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 L0(t){if(t%sl===$1){let e=(t+He)/sl;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%J0===Z0){let e=(t-Z0)/J0;return function(n,i){let s=n.mul(i,bn),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,bn),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%G1,Q0(t)}var W1=(t,e)=>(Zt(t,e)&He)===He;ze.isNegativeLE=W1;var z1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function D1(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=z1.reduce((n,i)=>(n[i]="function",n),e);return(0,Jt.validateObject)(t,r)}function eh(t,e,r){if(r<ct)throw new Error("Expected power > 0");if(r===ct)return t.ONE;if(r===He)return e;let n=t.ONE,i=e;for(;r>ct;)r&He&&(n=t.mul(n,i)),i=t.sqr(i),r>>=He;return n}function th(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 Z1(t,e,r){return t.mul(e,typeof r=="bigint"?ia(r,t.ORDER):t.inv(r))}function rh(t){let e=(t-He)/bn;return(r,n)=>r.pow(n,e)}function J1(t){let e=rh(t.ORDER);return r=>{let n=e(t,r);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}function ol(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function X1(t,e,r=!1,n={}){if(t<=ct)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=ol(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=L0(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Jt.bitMask)(i),ZERO:ct,ONE:He,create:c=>Zt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ct<=c&&c<t},is0:c=>c===ct,isOdd:c=>(c&He)===He,neg:c=>Zt(-c,t),eql:(c,f)=>c===f,sqr:c=>Zt(c*c,t),add:(c,f)=>Zt(c+f,t),sub:(c,f)=>Zt(c-f,t),mul:(c,f)=>Zt(c*f,t),pow:(c,f)=>eh(a,c,f),div:(c,f)=>Zt(c*ia(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>ia(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>th(a,c),cmov:(c,f,d)=>d?f:c,toBytes:c=>r?(0,Jt.numberToBytesLE)(c,s):(0,Jt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Jt.bytesToNumberLE)(c):(0,Jt.bytesToNumberBE)(c)}});return Object.freeze(a)}function Q1(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 L1(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 ew(t,e,r=!1){t=(0,Jt.ensureBytes)("privateHash",t);let n=t.length,i=ol(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,Jt.bytesToNumberLE)(t):(0,Jt.bytesToNumberBE)(t);return Zt(s,e-He)+He}function al(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 nh(t){let e=al(t);return e+Math.ceil(e/2)}function tw(t,e,r=!1){let n=t.length,i=al(e),s=nh(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Jt.bytesToNumberBE)(t):(0,Jt.bytesToNumberLE)(t),a=Zt(o,e-He)+He;return r?(0,Jt.numberToBytesLE)(a,i):(0,Jt.numberToBytesBE)(a,i)}});var sa=ee(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.expand_message_xmd=ih;Kn.expand_message_xof=sh;Kn.hash_to_field=cl;Kn.isogenyMap=sw;Kn.createHasher=ow;var rw=Mr(),Ot=Dt(),nw=Ot.bytesToNumberBE;function _n(t,e){if(ms(t),ms(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 iw(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 ms(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function ih(t,e,r,n){(0,Ot.abytes)(t),(0,Ot.abytes)(e),ms(r),e.length>255&&(e=n((0,Ot.concatBytes)((0,Ot.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,Ot.concatBytes)(e,_n(e.length,1)),c=_n(0,s),f=_n(r,2),d=new Array(o),h=n((0,Ot.concatBytes)(c,t,f,_n(0,1),a));d[0]=n((0,Ot.concatBytes)(h,_n(1,1),a));for(let _=1;_<=o;_++){let u=[iw(h,d[_-1]),_n(_+1,1),a];d[_]=n((0,Ot.concatBytes)(...u))}return(0,Ot.concatBytes)(...d).slice(0,r)}function sh(t,e,r,n,i){if((0,Ot.abytes)(t),(0,Ot.abytes)(e),ms(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update((0,Ot.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(_n(r,2)).update(e).update(_n(e.length,1)).digest()}function cl(t,e,r){(0,Ot.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,Ot.abytes)(t),ms(e);let f=typeof c=="string"?(0,Ot.utf8ToBytes)(c):c,d=n.toString(2).length,h=Math.ceil((d+i)/8),m=e*s*h,_;if(a==="xmd")_=ih(t,f,m,o);else if(a==="xof")_=sh(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 O=0;O<e;O++){let T=new Array(s);for(let P=0;P<s;P++){let F=h*(P+O*s),A=_.subarray(F,F+h);T[P]=(0,rw.mod)(nw(A),n)}u[O]=T}return u}function sw(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 ow(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=cl(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=cl(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 fl=ee(bs=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});bs.wNAF=cw;bs.pippenger=uw;bs.validateBasic=lw;var oh=Mr(),ch=Dt(),aw=BigInt(0),ul=BigInt(1),ll=new WeakMap,ah=new WeakMap;function cw(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>aw;)o&ul&&(a=a.add(c)),c=c.double(),o>>=ul;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 O=0;O<c;O++){let T=O*f,P=Number(a&m);a>>=u,P>f&&(P-=_,a+=ul);let F=T,A=T+Math.abs(P)-1,K=O%2!==0,E=P<0;P===0?h=h.add(r(K,o[F])):d=d.add(r(E,o[A]))}return{p:d,f:h}},wNAFCached(s,o,a){let c=ah.get(s)||1,f=ll.get(s);return f||(f=this.precomputeWindow(s,c),c!==1&&ll.set(s,a(f))),this.wNAF(c,f,o)},setWindowSize(s,o){n(o),ah.set(s,o),ll.delete(s)}}}function uw(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,ch.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 lw(t){return(0,oh.validateField)(t.Fp),(0,ch.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,oh.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}});var dl=ee(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.DER=void 0;wt.weierstrassPoints=fh;wt.weierstrass=yw;wt.SWUFpSqrtRatio=dh;wt.mapToCurveSimpleSWU=gw;var oa=fl(),Gn=Mr(),Se=Dt(),_t=Dt();function uh(t){t.lowS!==void 0&&(0,_t.abool)("lowS",t.lowS),t.prehash!==void 0&&(0,_t.abool)("prehash",t.prehash)}function fw(t){let e=(0,oa.validateBasic)(t);Se.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:dw,hexToBytes:hw}=Se;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=Se.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Se.numberToHexUnpadded(i.length/2|128):"";return`${Se.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<hr)throw new e("integer: negative integers are not allowed");let r=Se.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 dw(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=wt.DER,i=typeof t=="string"?hw(t):t;Se.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 hr=BigInt(0),qe=BigInt(1),wn=BigInt(2),aa=BigInt(3),lh=BigInt(4);function fh(t){let e=fw(t),{Fp:r}=e,n=Gn.Field(e.n,e.nBitLength),i=e.toBytes||((O,T,P)=>{let F=T.toAffine();return Se.concatBytes(Uint8Array.from([4]),r.toBytes(F.x),r.toBytes(F.y))}),s=e.fromBytes||(O=>{let T=O.subarray(1),P=r.fromBytes(T.subarray(0,r.BYTES)),F=r.fromBytes(T.subarray(r.BYTES,2*r.BYTES));return{x:P,y:F}});function o(O){let{a:T,b:P}=e,F=r.sqr(O),A=r.mul(F,O);return r.add(r.add(A,r.mul(O,T)),P)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(O){return Se.inRange(O,qe,e.n)}function c(O){let{allowedPrivateKeyLengths:T,nByteLength:P,wrapPrivateKey:F,n:A}=e;if(T&&typeof O!="bigint"){if(Se.isBytes(O)&&(O=Se.bytesToHex(O)),typeof O!="string"||!T.includes(O.length))throw new Error("Invalid key");O=O.padStart(P*2,"0")}let K;try{K=typeof O=="bigint"?O:Se.bytesToNumberBE((0,_t.ensureBytes)("private key",O,P))}catch{throw new Error(`private key must be ${P} bytes, hex or bigint, not ${typeof O}`)}return F&&(K=Gn.mod(K,A)),Se.aInRange("private key",K,qe,A),K}function f(O){if(!(O instanceof m))throw new Error("ProjectivePoint expected")}let d=(0,_t.memoized)((O,T)=>{let{px:P,py:F,pz:A}=O;if(r.eql(A,r.ONE))return{x:P,y:F};let K=O.is0();T==null&&(T=K?r.ONE:r.inv(A));let E=r.mul(P,T),j=r.mul(F,T),G=r.mul(A,T);if(K)return{x:r.ZERO,y:r.ZERO};if(!r.eql(G,r.ONE))throw new Error("invZ was invalid");return{x:E,y:j}}),h=(0,_t.memoized)(O=>{if(O.is0()){if(e.allowInfinityPoint&&!r.is0(O.py))return;throw new Error("bad point: ZERO")}let{x:T,y:P}=O.toAffine();if(!r.isValid(T)||!r.isValid(P))throw new Error("bad point: x or y not FE");let F=r.sqr(P),A=o(T);if(!r.eql(F,A))throw new Error("bad point: equation left != right");if(!O.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(T,P,F){if(this.px=T,this.py=P,this.pz=F,T==null||!r.isValid(T))throw new Error("x required");if(P==null||!r.isValid(P))throw new Error("y required");if(F==null||!r.isValid(F))throw new Error("z required");Object.freeze(this)}static fromAffine(T){let{x:P,y:F}=T||{};if(!T||!r.isValid(P)||!r.isValid(F))throw new Error("invalid affine point");if(T instanceof m)throw new Error("projective point not allowed");let A=K=>r.eql(K,r.ZERO);return A(P)&&A(F)?m.ZERO:new m(P,F,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(T){let P=r.invertBatch(T.map(F=>F.pz));return T.map((F,A)=>F.toAffine(P[A])).map(m.fromAffine)}static fromHex(T){let P=m.fromAffine(s((0,_t.ensureBytes)("pointHex",T)));return P.assertValidity(),P}static fromPrivateKey(T){return m.BASE.multiply(c(T))}static msm(T,P){return(0,oa.pippenger)(m,n,T,P)}_setWindowSize(T){u.setWindowSize(this,T)}assertValidity(){h(this)}hasEvenY(){let{y:T}=this.toAffine();if(r.isOdd)return!r.isOdd(T);throw new Error("Field doesn't support isOdd")}equals(T){f(T);let{px:P,py:F,pz:A}=this,{px:K,py:E,pz:j}=T,G=r.eql(r.mul(P,j),r.mul(K,A)),z=r.eql(r.mul(F,j),r.mul(E,A));return G&&z}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:T,b:P}=e,F=r.mul(P,aa),{px:A,py:K,pz:E}=this,j=r.ZERO,G=r.ZERO,z=r.ZERO,q=r.mul(A,A),oe=r.mul(K,K),Q=r.mul(E,E),ie=r.mul(A,K);return ie=r.add(ie,ie),z=r.mul(A,E),z=r.add(z,z),j=r.mul(T,z),G=r.mul(F,Q),G=r.add(j,G),j=r.sub(oe,G),G=r.add(oe,G),G=r.mul(j,G),j=r.mul(ie,j),z=r.mul(F,z),Q=r.mul(T,Q),ie=r.sub(q,Q),ie=r.mul(T,ie),ie=r.add(ie,z),z=r.add(q,q),q=r.add(z,q),q=r.add(q,Q),q=r.mul(q,ie),G=r.add(G,q),Q=r.mul(K,E),Q=r.add(Q,Q),q=r.mul(Q,ie),j=r.sub(j,q),z=r.mul(Q,oe),z=r.add(z,z),z=r.add(z,z),new m(j,G,z)}add(T){f(T);let{px:P,py:F,pz:A}=this,{px:K,py:E,pz:j}=T,G=r.ZERO,z=r.ZERO,q=r.ZERO,oe=e.a,Q=r.mul(e.b,aa),ie=r.mul(P,K),w=r.mul(F,E),b=r.mul(A,j),N=r.add(P,F),B=r.add(K,E);N=r.mul(N,B),B=r.add(ie,w),N=r.sub(N,B),B=r.add(P,A);let R=r.add(K,j);return B=r.mul(B,R),R=r.add(ie,b),B=r.sub(B,R),R=r.add(F,A),G=r.add(E,j),R=r.mul(R,G),G=r.add(w,b),R=r.sub(R,G),q=r.mul(oe,B),G=r.mul(Q,b),q=r.add(G,q),G=r.sub(w,q),q=r.add(w,q),z=r.mul(G,q),w=r.add(ie,ie),w=r.add(w,ie),b=r.mul(oe,b),B=r.mul(Q,B),w=r.add(w,b),b=r.sub(ie,b),b=r.mul(oe,b),B=r.add(B,b),ie=r.mul(w,B),z=r.add(z,ie),ie=r.mul(R,B),G=r.mul(N,G),G=r.sub(G,ie),ie=r.mul(N,w),q=r.mul(R,q),q=r.add(q,ie),new m(G,z,q)}subtract(T){return this.add(T.negate())}is0(){return this.equals(m.ZERO)}wNAF(T){return u.wNAFCached(this,T,m.normalizeZ)}multiplyUnsafe(T){Se.aInRange("scalar",T,hr,e.n);let P=m.ZERO;if(T===hr)return P;if(T===qe)return this;let{endo:F}=e;if(!F)return u.unsafeLadder(this,T);let{k1neg:A,k1:K,k2neg:E,k2:j}=F.splitScalar(T),G=P,z=P,q=this;for(;K>hr||j>hr;)K&qe&&(G=G.add(q)),j&qe&&(z=z.add(q)),q=q.double(),K>>=qe,j>>=qe;return A&&(G=G.negate()),E&&(z=z.negate()),z=new m(r.mul(z.px,F.beta),z.py,z.pz),G.add(z)}multiply(T){let{endo:P,n:F}=e;Se.aInRange("scalar",T,qe,F);let A,K;if(P){let{k1neg:E,k1:j,k2neg:G,k2:z}=P.splitScalar(T),{p:q,f:oe}=this.wNAF(j),{p:Q,f:ie}=this.wNAF(z);q=u.constTimeNegate(E,q),Q=u.constTimeNegate(G,Q),Q=new m(r.mul(Q.px,P.beta),Q.py,Q.pz),A=q.add(Q),K=oe.add(ie)}else{let{p:E,f:j}=this.wNAF(T);A=E,K=j}return m.normalizeZ([A,K])[0]}multiplyAndAddUnsafe(T,P,F){let A=m.BASE,K=(j,G)=>G===hr||G===qe||!j.equals(A)?j.multiplyUnsafe(G):j.multiply(G),E=K(this,P).add(K(T,F));return E.is0()?void 0:E}toAffine(T){return d(this,T)}isTorsionFree(){let{h:T,isTorsionFree:P}=e;if(T===qe)return!0;if(P)return P(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:T,clearCofactor:P}=e;return T===qe?this:P?P(m,this):this.multiplyUnsafe(e.h)}toRawBytes(T=!0){return(0,_t.abool)("isCompressed",T),this.assertValidity(),i(m,this,T)}toHex(T=!0){return(0,_t.abool)("isCompressed",T),Se.bytesToHex(this.toRawBytes(T))}}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,oa.wNAF)(m,e.endo?Math.ceil(_/2):_);return{CURVE:e,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function pw(t){let e=(0,oa.validateBasic)(t);return Se.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function yw(t){let e=pw(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(b){return Gn.mod(b,n)}function a(b){return Gn.invert(b,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:d,isWithinCurveOrder:h}=fh({...e,toBytes(b,N,B){let R=N.toAffine(),V=r.toBytes(R.x),Z=Se.concatBytes;return(0,_t.abool)("isCompressed",B),B?Z(Uint8Array.from([N.hasEvenY()?2:3]),V):Z(Uint8Array.from([4]),V,r.toBytes(R.y))},fromBytes(b){let N=b.length,B=b[0],R=b.subarray(1);if(N===i&&(B===2||B===3)){let V=Se.bytesToNumberBE(R);if(!Se.inRange(V,qe,r.ORDER))throw new Error("Point is not on curve");let Z=d(V),ce;try{ce=r.sqrt(Z)}catch(M){let y=M instanceof Error?": "+M.message:"";throw new Error("Point is not on curve"+y)}let ae=(ce&qe)===qe;return(B&1)===1!==ae&&(ce=r.neg(ce)),{x:V,y:ce}}else if(N===s&&B===4){let V=r.fromBytes(R.subarray(0,r.BYTES)),Z=r.fromBytes(R.subarray(r.BYTES,2*r.BYTES));return{x:V,y:Z}}else throw new Error(`Point of length ${N} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=b=>Se.bytesToHex(Se.numberToBytesBE(b,e.nByteLength));function _(b){let N=n>>qe;return b>N}function u(b){return _(b)?o(-b):b}let O=(b,N,B)=>Se.bytesToNumberBE(b.slice(N,B));class T{constructor(N,B,R){this.r=N,this.s=B,this.recovery=R,this.assertValidity()}static fromCompact(N){let B=e.nByteLength;return N=(0,_t.ensureBytes)("compactSignature",N,B*2),new T(O(N,0,B),O(N,B,2*B))}static fromDER(N){let{r:B,s:R}=wt.DER.toSig((0,_t.ensureBytes)("DER",N));return new T(B,R)}assertValidity(){Se.aInRange("r",this.r,qe,n),Se.aInRange("s",this.s,qe,n)}addRecoveryBit(N){return new T(this.r,this.s,N)}recoverPublicKey(N){let{r:B,s:R,recovery:V}=this,Z=j((0,_t.ensureBytes)("msgHash",N));if(V==null||![0,1,2,3].includes(V))throw new Error("recovery id invalid");let ce=V===2||V===3?B+e.n:B;if(ce>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let ae=(V&1)===0?"02":"03",D=c.fromHex(ae+m(ce)),M=a(ce),y=o(-Z*M),L=o(R*M),re=c.BASE.multiplyAndAddUnsafe(D,y,L);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new T(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Se.hexToBytes(this.toDERHex())}toDERHex(){return wt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Se.hexToBytes(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let P={isValidPrivateKey(b){try{return f(b),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let b=Gn.getMinHashLength(e.n);return Gn.mapHashToField(e.randomBytes(b),e.n)},precompute(b=8,N=c.BASE){return N._setWindowSize(b),N.multiply(BigInt(3)),N}};function F(b,N=!0){return c.fromPrivateKey(b).toRawBytes(N)}function A(b){let N=Se.isBytes(b),B=typeof b=="string",R=(N||B)&&b.length;return N?R===i||R===s:B?R===2*i||R===2*s:b instanceof c}function K(b,N,B=!0){if(A(b))throw new Error("first arg must be private key");if(!A(N))throw new Error("second arg must be public key");return c.fromHex(N).multiply(f(b)).toRawBytes(B)}let E=e.bits2int||function(b){let N=Se.bytesToNumberBE(b),B=b.length*8-e.nBitLength;return B>0?N>>BigInt(B):N},j=e.bits2int_modN||function(b){return o(E(b))},G=Se.bitMask(e.nBitLength);function z(b){return Se.aInRange(`num < 2^${e.nBitLength}`,b,hr,G),Se.numberToBytesBE(b,e.nByteLength)}function q(b,N,B=oe){if(["recovered","canonical"].some(X=>X in B))throw new Error("sign() legacy options not supported");let{hash:R,randomBytes:V}=e,{lowS:Z,prehash:ce,extraEntropy:ae}=B;Z==null&&(Z=!0),b=(0,_t.ensureBytes)("msgHash",b),uh(B),ce&&(b=(0,_t.ensureBytes)("prehashed msgHash",R(b)));let D=j(b),M=f(N),y=[z(M),z(D)];if(ae!=null&&ae!==!1){let X=ae===!0?V(r.BYTES):ae;y.push((0,_t.ensureBytes)("extraEntropy",X))}let L=Se.concatBytes(...y),re=D;function le(X){let l=E(X);if(!h(l))return;let p=a(l),g=c.BASE.multiply(l).toAffine(),I=o(g.x);if(I===hr)return;let S=o(p*o(re+I*M));if(S===hr)return;let U=(g.x===I?0:2)|Number(g.y&qe),H=S;return Z&&_(S)&&(H=u(S),U^=1),new T(I,H,U)}return{seed:L,k2sig:le}}let oe={lowS:e.lowS,prehash:!1},Q={lowS:e.lowS,prehash:!1};function ie(b,N,B=oe){let{seed:R,k2sig:V}=q(b,N,B),Z=e;return Se.createHmacDrbg(Z.hash.outputLen,Z.nByteLength,Z.hmac)(R,V)}c.BASE._setWindowSize(8);function w(b,N,B,R=Q){let V=b;if(N=(0,_t.ensureBytes)("msgHash",N),B=(0,_t.ensureBytes)("publicKey",B),"strict"in R)throw new Error("options.strict was renamed to lowS");uh(R);let{lowS:Z,prehash:ce}=R,ae,D;try{if(typeof V=="string"||Se.isBytes(V))try{ae=T.fromDER(V)}catch(g){if(!(g instanceof wt.DER.Err))throw g;ae=T.fromCompact(V)}else if(typeof V=="object"&&typeof V.r=="bigint"&&typeof V.s=="bigint"){let{r:g,s:I}=V;ae=new T(g,I)}else throw new Error("PARSE");D=c.fromHex(B)}catch(g){if(g.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Z&&ae.hasHighS())return!1;ce&&(N=e.hash(N));let{r:M,s:y}=ae,L=j(N),re=a(y),le=o(L*re),X=o(M*re),l=c.BASE.multiplyAndAddUnsafe(D,le,X)?.toAffine();return l?o(l.x)===M:!1}return{CURVE:e,getPublicKey:F,getSharedSecret:K,sign:ie,verify:w,ProjectivePoint:c,Signature:T,utils:P}}function dh(t,e){let r=t.ORDER,n=hr;for(let u=r-qe;u%wn===hr;u/=wn)n+=qe;let i=n,s=wn<<i-qe-qe,o=s*wn,a=(r-qe)/o,c=(a-qe)/wn,f=o-qe,d=s,h=t.pow(e,a),m=t.pow(e,(a+qe)/wn),_=(u,O)=>{let T=h,P=t.pow(O,f),F=t.sqr(P);F=t.mul(F,O);let A=t.mul(u,F);A=t.pow(A,c),A=t.mul(A,P),P=t.mul(A,O),F=t.mul(A,u);let K=t.mul(F,P);A=t.pow(K,d);let E=t.eql(A,t.ONE);P=t.mul(F,m),A=t.mul(K,T),F=t.cmov(P,F,E),K=t.cmov(A,K,E);for(let j=i;j>qe;j--){let G=j-wn;G=wn<<G-qe;let z=t.pow(K,G),q=t.eql(z,t.ONE);P=t.mul(F,T),T=t.mul(T,T),z=t.mul(K,T),F=t.cmov(P,F,q),K=t.cmov(z,K,q)}return{isValid:E,value:F}};if(t.ORDER%lh===aa){let u=(t.ORDER-aa)/lh,O=t.sqrt(t.neg(e));_=(T,P)=>{let F=t.sqr(P),A=t.mul(T,P);F=t.mul(F,A);let K=t.pow(F,u);K=t.mul(K,A);let E=t.mul(K,O),j=t.mul(t.sqr(K),P),G=t.eql(j,T),z=t.cmov(E,K,G);return{isValid:G,value:z}}}return _}function gw(t,e){if(Gn.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=dh(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 mh=ee(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});pl.bls=_w;var hh=Mr(),hl=Dt(),ph=sa(),yh=dl(),mw=BigInt(0),ca=BigInt(1),gh=BigInt(2),Si=BigInt(3);function bw(t){let e=[];for(;t>ca;t>>=ca)(t&ca)===mw?e.unshift(0):(t&Si)===Si?(e.unshift(-1),t+=ca):e.unshift(1);return e}function _w(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=t.params.xNegative,a=t.params.twistType,c=(0,yh.weierstrassPoints)({n:r.ORDER,...t.G1}),f=Object.assign(c,(0,ph.createHasher)(c.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),d=(0,yh.weierstrassPoints)({n:r.ORDER,...t.G2}),h=Object.assign(d,(0,ph.createHasher)(d.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),m;if(a==="multiplicative")m=(D,M,y,L,re,le)=>s.mul014(L,D,n.mul(M,re),n.mul(y,le));else if(a==="divisive")m=(D,M,y,L,re,le)=>s.mul034(L,n.mul(y,le),n.mul(M,re),D);else throw new Error("bls: unknown twist type");let _=n.div(n.ONE,n.mul(n.ONE,gh));function u(D,M,y,L){let re=n.sqr(y),le=n.sqr(L),X=n.mulByB(n.mul(le,Si)),l=n.mul(X,Si),p=n.sub(n.sub(n.sqr(n.add(y,L)),le),re),g=n.sub(X,re),I=n.mul(n.sqr(M),Si),S=n.neg(p);return D.push([g,I,S]),M=n.mul(n.mul(n.mul(n.sub(re,l),M),y),_),y=n.sub(n.sqr(n.mul(n.add(re,l),_)),n.mul(n.sqr(X),Si)),L=n.mul(re,p),{Rx:M,Ry:y,Rz:L}}function O(D,M,y,L,re,le){let X=n.sub(y,n.mul(le,L)),l=n.sub(M,n.mul(re,L)),p=n.sub(n.mul(X,re),n.mul(l,le)),g=n.neg(X),I=l;D.push([p,g,I]);let S=n.sqr(l),U=n.mul(S,l),H=n.mul(S,M),x=n.add(n.sub(U,n.mul(H,gh)),n.mul(n.sqr(X),L));return M=n.mul(l,x),y=n.sub(n.mul(n.sub(H,x),X),n.mul(U,y)),L=n.mul(L,U),{Rx:M,Ry:y,Rz:L}}let T=bw(t.params.ateLoopSize),P=(0,hl.memoized)(D=>{let M=D,{x:y,y:L}=M.toAffine(),re=y,le=L,X=n.neg(L),l=re,p=le,g=n.ONE,I=[];for(let S of T){let U=[];({Rx:l,Ry:p,Rz:g}=u(U,l,p,g)),S&&({Rx:l,Ry:p,Rz:g}=O(U,l,p,g,re,S===-1?X:le)),I.push(U)}if(t.postPrecompute){let S=I[I.length-1];t.postPrecompute(l,p,g,re,le,O.bind(null,S))}return I});function F(D,M=!1){let y=s.ONE;if(D.length){let L=D[0][0].length;for(let re=0;re<L;re++){y=s.sqr(y);for(let[le,X,l]of D)for(let[p,g,I]of le[re])y=m(p,g,I,y,X,l)}}return o&&(y=s.conjugate(y)),M?s.finalExponentiate(y):y}function A(D,M=!0){let y=[];f.ProjectivePoint.normalizeZ(D.map(({g1:L})=>L)),h.ProjectivePoint.normalizeZ(D.map(({g2:L})=>L));for(let{g1:L,g2:re}of D){if(L.equals(f.ProjectivePoint.ZERO)||re.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");L.assertValidity(),re.assertValidity();let le=L.toAffine();y.push([P(re),le.x,le.y])}return F(y,M)}function K(D,M,y=!0){return A([{g1:D,g2:M}],y)}let E={randomPrivateKey:()=>{let D=(0,hh.getMinHashLength)(r.ORDER);return(0,hh.mapHashToField)(t.randomBytes(D),r.ORDER)},calcPairingPrecomputes:P},{ShortSignature:j}=t.G1,{Signature:G}=t.G2;function z(D){return D instanceof f.ProjectivePoint?D:f.ProjectivePoint.fromHex(D)}function q(D,M){return D instanceof f.ProjectivePoint?D:f.hashToCurve((0,hl.ensureBytes)("point",D),M)}function oe(D){return D instanceof h.ProjectivePoint?D:G.fromHex(D)}function Q(D,M){return D instanceof h.ProjectivePoint?D:h.hashToCurve((0,hl.ensureBytes)("point",D),M)}function ie(D){return f.ProjectivePoint.fromPrivateKey(D).toRawBytes(!0)}function w(D){return h.ProjectivePoint.fromPrivateKey(D).toRawBytes(!0)}function b(D,M,y){let L=Q(D,y);L.assertValidity();let re=L.multiply(f.normPrivateKeyToScalar(M));return D instanceof h.ProjectivePoint?re:G.toRawBytes(re)}function N(D,M,y){let L=q(D,y);L.assertValidity();let re=L.multiply(f.normPrivateKeyToScalar(M));return D instanceof f.ProjectivePoint?re:j.toRawBytes(re)}function B(D,M,y,L){let re=z(y),le=Q(M,L),X=f.ProjectivePoint.BASE,l=oe(D),p=A([{g1:re.negate(),g2:le},{g1:X,g2:l}]);return s.eql(p,s.ONE)}function R(D,M,y,L){let re=oe(y),le=q(M,L),X=h.ProjectivePoint.BASE,l=z(D),p=A([{g1:le,g2:re},{g1:l,g2:X.negate()}]);return s.eql(p,s.ONE)}function V(D){if(!D.length)throw new Error("Expected non-empty array");let y=D.map(z).reduce((L,re)=>L.add(re),f.ProjectivePoint.ZERO);return D[0]instanceof f.ProjectivePoint?(y.assertValidity(),y):y.toRawBytes(!0)}function Z(D){if(!D.length)throw new Error("Expected non-empty array");let y=D.map(oe).reduce((L,re)=>L.add(re),h.ProjectivePoint.ZERO);return D[0]instanceof h.ProjectivePoint?(y.assertValidity(),y):G.toRawBytes(y)}function ce(D){if(!D.length)throw new Error("Expected non-empty array");let y=D.map(z).reduce((L,re)=>L.add(re),f.ProjectivePoint.ZERO);return D[0]instanceof f.ProjectivePoint?(y.assertValidity(),y):j.toRawBytes(y)}function ae(D,M,y,L){if(!M.length)throw new Error("Expected non-empty messages array");if(y.length!==M.length)throw new Error("Pubkey count should equal msg count");let re=oe(D),le=M.map(g=>Q(g,L)),X=y.map(z),l=new Map;for(let g=0;g<X.length;g++){let I=X[g],S=le[g],U=l.get(S);U===void 0&&(U=[],l.set(S,U)),U.push(I)}let p=[];try{for(let[g,I]of l){let S=I.reduce((U,H)=>U.add(H));p.push({g1:S,g2:g})}return p.push({g1:f.ProjectivePoint.BASE.negate(),g2:re}),s.eql(A(p),s.ONE)}catch{return!1}}return f.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ie,getPublicKeyForShortSignatures:w,sign:b,signShortSignature:N,verify:B,verifyBatch:ae,verifyShortSignature:R,aggregatePublicKeys:V,aggregateSignatures:Z,aggregateShortSignatures:ce,millerLoopBatch:F,pairing:K,pairingBatch:A,G1:f,G2:h,Signature:G,ShortSignature:j,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:E}}});var _h=ee(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.psiFrobenius=Ew;ua.tower12=xw;var En=Mr(),pr=Dt(),ww=BigInt(0),Bi=BigInt(1),en=BigInt(2),bh=BigInt(3);function yl(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,_=Bi;m<n;m++){let u=(d*_-d)/o%a;h.push(t.pow(e,u)),_*=r}c.push(h)}return c}function Ew(t,e,r){let n=e.pow(r,(t.ORDER-Bi)/bh),i=e.pow(r,(t.ORDER-Bi)/en);function s(m,_){let u=e.mul(e.frobeniusMap(m,1),n),O=e.mul(e.frobeniusMap(_,1),i);return[u,O]}let o=e.pow(r,(t.ORDER**en-Bi)/bh),a=e.pow(r,(t.ORDER**en-Bi)/en);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 O=u.toAffine(),T=m(O.x,O.y);return _.fromAffine({x:T[0],y:T[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 xw(t){let{ORDER:e}=t,r=En.Field(e),n=r.create(t.NONRESIDUE||BigInt(-1)),i=En.FpLegendre(e),s=r.div(r.ONE,en),o=yl(r,n,r.ORDER,2)[0],a=({c0:w,c1:b},{c0:N,c1:B})=>({c0:r.add(w,N),c1:r.add(b,B)}),c=({c0:w,c1:b},{c0:N,c1:B})=>({c0:r.sub(w,N),c1:r.sub(b,B)}),f=({c0:w,c1:b},N)=>{if(typeof N=="bigint")return{c0:r.mul(w,N),c1:r.mul(b,N)};let{c0:B,c1:R}=N,V=r.mul(w,B),Z=r.mul(b,R),ce=r.sub(V,Z),ae=r.sub(r.mul(r.add(w,b),r.add(B,R)),r.add(V,Z));return{c0:ce,c1:ae}},d=({c0:w,c1:b})=>{let N=r.add(w,b),B=r.sub(w,b),R=r.add(w,w);return{c0:r.mul(N,B),c1:r.mul(R,b)}},h=w=>{if(w.length!==2)throw new Error("Invalid tuple");let b=w.map(N=>r.create(N));return{c0:b[0],c1:b[1]}},m=e*e,_=h(t.FP2_NONRESIDUE),u={ORDER:m,NONRESIDUE:_,BITS:(0,pr.bitLen)(m),BYTES:Math.ceil((0,pr.bitLen)(m)/8),MASK:(0,pr.bitMask)((0,pr.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:N,c1:B})=>r.eql(w,N)&&r.eql(b,B),neg:({c0:w,c1:b})=>({c0:r.neg(w),c1:r.neg(b)}),pow:(w,b)=>En.FpPow(u,w,b),invertBatch:w=>En.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 N=r.inv(r.create(w*w+b*b));return{c0:r.mul(N,r.create(w)),c1:r.mul(N,r.create(-b))}},sqrt:w=>{if(t.Fp2sqrt)return t.Fp2sqrt(w);let{c0:b,c1:N}=w;if(r.is0(N))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 B=r.sqrt(r.sub(r.sqr(b),r.mul(r.sqr(N),n))),R=r.mul(r.add(B,b),s),V=i(r,R);!r.is0(V)&&!r.eql(V,r.ONE)&&(R=r.sub(R,B));let Z=r.sqrt(R),ce=u.create({c0:Z,c1:r.div(r.mul(N,s),Z)});if(!u.eql(u.sqr(ce),w))throw new Error("Cannot find square root");let ae=ce,D=u.neg(ae),{re:M,im:y}=u.reim(ae),{re:L,im:re}=u.reim(D);return y>re||y===re&&M>L?ae:D},isOdd:w=>{let{re:b,im:N}=u.reim(w),B=b%en,R=b===ww,V=N%en;return BigInt(B||R&&V)==Bi},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,pr.concatBytes)(r.toBytes(w),r.toBytes(b)),cmov:({c0:w,c1:b},{c0:N,c1:B},R)=>({c0:r.cmov(w,N,R),c1:r.cmov(b,B,R)}),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},N)=>({c0:w,c1:r.mul(b,o[N%2])})},O=({c0:w,c1:b,c2:N},{c0:B,c1:R,c2:V})=>({c0:u.add(w,B),c1:u.add(b,R),c2:u.add(N,V)}),T=({c0:w,c1:b,c2:N},{c0:B,c1:R,c2:V})=>({c0:u.sub(w,B),c1:u.sub(b,R),c2:u.sub(N,V)}),P=({c0:w,c1:b,c2:N},B)=>{if(typeof B=="bigint")return{c0:u.mul(w,B),c1:u.mul(b,B),c2:u.mul(N,B)};let{c0:R,c1:V,c2:Z}=B,ce=u.mul(w,R),ae=u.mul(b,V),D=u.mul(N,Z);return{c0:u.add(ce,u.mulByNonresidue(u.sub(u.mul(u.add(b,N),u.add(V,Z)),u.add(ae,D)))),c1:u.add(u.sub(u.mul(u.add(w,b),u.add(R,V)),u.add(ce,ae)),u.mulByNonresidue(D)),c2:u.sub(u.add(ae,u.mul(u.add(w,N),u.add(R,Z))),u.add(ce,D))}},F=({c0:w,c1:b,c2:N})=>{let B=u.sqr(w),R=u.mul(u.mul(w,b),en),V=u.mul(u.mul(b,N),en),Z=u.sqr(N);return{c0:u.add(u.mulByNonresidue(V),B),c1:u.add(u.mulByNonresidue(Z),R),c2:u.sub(u.sub(u.add(u.add(R,u.sqr(u.add(u.sub(w,b),N))),V),B),Z)}},[A,K]=yl(u,_,r.ORDER,6,2,3),E={ORDER:u.ORDER,BITS:3*u.BITS,BYTES:3*u.BYTES,MASK:(0,pr.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:N})=>u.isValid(w)&&u.isValid(b)&&u.isValid(N),is0:({c0:w,c1:b,c2:N})=>u.is0(w)&&u.is0(b)&&u.is0(N),neg:({c0:w,c1:b,c2:N})=>({c0:u.neg(w),c1:u.neg(b),c2:u.neg(N)}),eql:({c0:w,c1:b,c2:N},{c0:B,c1:R,c2:V})=>u.eql(w,B)&&u.eql(b,R)&&u.eql(N,V),sqrt:pr.notImplemented,div:(w,b)=>E.mul(w,typeof b=="bigint"?r.inv(r.create(b)):E.inv(b)),pow:(w,b)=>En.FpPow(E,w,b),invertBatch:w=>En.FpInvertBatch(E,w),add:O,sub:T,mul:P,sqr:F,addN:O,subN:T,mulN:P,sqrN:F,inv:({c0:w,c1:b,c2:N})=>{let B=u.sub(u.sqr(w),u.mulByNonresidue(u.mul(N,b))),R=u.sub(u.mulByNonresidue(u.sqr(N)),u.mul(w,b)),V=u.sub(u.sqr(b),u.mul(w,N)),Z=u.inv(u.add(u.mulByNonresidue(u.add(u.mul(N,R),u.mul(b,V))),u.mul(w,B)));return{c0:u.mul(Z,B),c1:u.mul(Z,R),c2:u.mul(Z,V)}},fromBytes:w=>{if(w.length!==E.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:N})=>(0,pr.concatBytes)(u.toBytes(w),u.toBytes(b),u.toBytes(N)),cmov:({c0:w,c1:b,c2:N},{c0:B,c1:R,c2:V},Z)=>({c0:u.cmov(w,B,Z),c1:u.cmov(b,R,Z),c2:u.cmov(N,V,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:N},B)=>({c0:u.frobeniusMap(w,B),c1:u.mul(u.frobeniusMap(b,B),A[B%6]),c2:u.mul(u.frobeniusMap(N,B),K[B%6])}),mulByFp2:({c0:w,c1:b,c2:N},B)=>({c0:u.mul(w,B),c1:u.mul(b,B),c2:u.mul(N,B)}),mulByNonresidue:({c0:w,c1:b,c2:N})=>({c0:u.mulByNonresidue(N),c1:w,c2:b}),mul1:({c0:w,c1:b,c2:N},B)=>({c0:u.mulByNonresidue(u.mul(N,B)),c1:u.mul(w,B),c2:u.mul(b,B)}),mul01({c0:w,c1:b,c2:N},B,R){let V=u.mul(w,B),Z=u.mul(b,R);return{c0:u.add(u.mulByNonresidue(u.sub(u.mul(u.add(b,N),R),Z)),V),c1:u.sub(u.sub(u.mul(u.add(B,R),u.add(w,b)),V),Z),c2:u.add(u.sub(u.mul(u.add(w,N),B),V),Z)}}},j=yl(u,_,r.ORDER,12,1,6)[0],G=({c0:w,c1:b},{c0:N,c1:B})=>({c0:E.add(w,N),c1:E.add(b,B)}),z=({c0:w,c1:b},{c0:N,c1:B})=>({c0:E.sub(w,N),c1:E.sub(b,B)}),q=({c0:w,c1:b},N)=>{if(typeof N=="bigint")return{c0:E.mul(w,N),c1:E.mul(b,N)};let{c0:B,c1:R}=N,V=E.mul(w,B),Z=E.mul(b,R);return{c0:E.add(V,E.mulByNonresidue(Z)),c1:E.sub(E.mul(E.add(w,b),E.add(B,R)),E.add(V,Z))}},oe=({c0:w,c1:b})=>{let N=E.mul(w,b);return{c0:E.sub(E.sub(E.mul(E.add(E.mulByNonresidue(b),w),E.add(w,b)),N),E.mulByNonresidue(N)),c1:E.add(N,N)}};function Q(w,b){let N=u.sqr(w),B=u.sqr(b);return{first:u.add(u.mulByNonresidue(B),N),second:u.sub(u.sub(u.sqr(u.add(w,b)),N),B)}}let ie={ORDER:u.ORDER,BITS:2*u.BITS,BYTES:2*u.BYTES,MASK:(0,pr.bitMask)(2*u.BITS),ZERO:{c0:E.ZERO,c1:E.ZERO},ONE:{c0:E.ONE,c1:E.ZERO},create:w=>w,isValid:({c0:w,c1:b})=>E.isValid(w)&&E.isValid(b),is0:({c0:w,c1:b})=>E.is0(w)&&E.is0(b),neg:({c0:w,c1:b})=>({c0:E.neg(w),c1:E.neg(b)}),eql:({c0:w,c1:b},{c0:N,c1:B})=>E.eql(w,N)&&E.eql(b,B),sqrt:pr.notImplemented,inv:({c0:w,c1:b})=>{let N=E.inv(E.sub(E.sqr(w),E.mulByNonresidue(E.sqr(b))));return{c0:E.mul(w,N),c1:E.neg(E.mul(b,N))}},div:(w,b)=>ie.mul(w,typeof b=="bigint"?r.inv(r.create(b)):ie.inv(b)),pow:(w,b)=>En.FpPow(ie,w,b),invertBatch:w=>En.FpInvertBatch(ie,w),add:G,sub:z,mul:q,sqr:oe,addN:G,subN:z,mulN:q,sqrN:oe,fromBytes:w=>{if(w.length!==ie.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:E.fromBytes(w.subarray(0,E.BYTES)),c1:E.fromBytes(w.subarray(E.BYTES))}},toBytes:({c0:w,c1:b})=>(0,pr.concatBytes)(E.toBytes(w),E.toBytes(b)),cmov:({c0:w,c1:b},{c0:N,c1:B},R)=>({c0:E.cmov(w,N,R),c1:E.cmov(b,B,R)}),fromBigTwelve:w=>({c0:E.fromBigSix(w.slice(0,6)),c1:E.fromBigSix(w.slice(6,12))}),frobeniusMap(w,b){let{c0:N,c1:B,c2:R}=E.frobeniusMap(w.c1,b),V=j[b%12];return{c0:E.frobeniusMap(w.c0,b),c1:E.create({c0:u.mul(N,V),c1:u.mul(B,V),c2:u.mul(R,V)})}},mulByFp2:({c0:w,c1:b},N)=>({c0:E.mulByFp2(w,N),c1:E.mulByFp2(b,N)}),conjugate:({c0:w,c1:b})=>({c0:w,c1:E.neg(b)}),mul014:({c0:w,c1:b},N,B,R)=>{let V=E.mul01(w,N,B),Z=E.mul1(b,R);return{c0:E.add(E.mulByNonresidue(Z),V),c1:E.sub(E.sub(E.mul01(E.add(b,w),N,u.add(B,R)),V),Z)}},mul034:({c0:w,c1:b},N,B,R)=>{let V=E.create({c0:u.mul(w.c0,N),c1:u.mul(w.c1,N),c2:u.mul(w.c2,N)}),Z=E.mul01(b,B,R),ce=E.mul01(E.add(w,b),u.add(N,B),R);return{c0:E.add(E.mulByNonresidue(Z),V),c1:E.sub(ce,E.add(V,Z))}},_cyclotomicSquare:t.Fp12cyclotomicSquare,_cyclotomicExp:t.Fp12cyclotomicExp,finalExponentiate:t.Fp12finalExponentiate};return{Fp:r,Fp2:u,Fp6:E,Fp4Square:Q,Fp12:ie}}});var Oh=ee(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.bls12_381=void 0;var Th=ho(),vw=kn(),Tw=mh(),Aw=Mr(),Be=Dt(),Ah=sa(),Sh=dl(),Bh=_h(),Mt=BigInt(0),da=BigInt(1),pt=BigInt(2),la=BigInt(3),_s=BigInt(4),xn=BigInt("0xd201000000010000"),Sw=(0,Be.bitLen)(xn),{Fp:fe,Fp2:pe,Fp6:bl,Fp4Square:gl,Fp12:ve}=(0,Bh.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[da,da],Fp2mulByB:({c0:t,c1:e})=>{let r=fe.mul(t,_s),n=fe.mul(e,_s);return{c0:fe.sub(r,n),c1:fe.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}=gl(r,o),{first:d,second:h}=gl(s,i),{first:m,second:_}=gl(n,a),u=pe.mulByNonresidue(_);return{c0:bl.create({c0:pe.add(pe.mul(pe.sub(c,r),pt),c),c1:pe.add(pe.mul(pe.sub(d,n),pt),d),c2:pe.add(pe.mul(pe.sub(m,i),pt),m)}),c1:bl.create({c0:pe.add(pe.mul(pe.add(u,s),pt),u),c1:pe.add(pe.mul(pe.add(f,o),pt),f),c2:pe.add(pe.mul(pe.add(h,a),pt),h)})}},Fp12cyclotomicExp(t,e){let r=ve.ONE;for(let n=Sw-1;n>=0;n--)r=ve._cyclotomicSquare(r),(0,Be.bitGet)(e,n)&&(r=ve.mul(r,t));return r},Fp12finalExponentiate:t=>{let e=xn,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),_)}}),wh=Aw.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Bw=(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))))),Ow=(0,Ah.isogenyMap)(fe,[["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)))),Nw=(0,Sh.mapToCurveSimpleSWU)(pe,{A:pe.create({c0:fe.create(Mt),c1:fe.create(BigInt(240))}),B:pe.create({c0:fe.create(BigInt(1012)),c1:fe.create(BigInt(1012))}),Z:pe.create({c0:fe.create(BigInt(-2)),c1:fe.create(BigInt(-1))})}),Rw=(0,Sh.mapToCurveSimpleSWU)(fe,{A:fe.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:fe.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:fe.create(BigInt(11))}),{G2psi:Eh,G2psi2:Pw}=(0,Bh.psiFrobenius)(fe,pe,pe.div(pe.ONE,pe.NONRESIDUE)),ml=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:fe.ORDER,m:2,k:128,expand:"xmd",hash:Th.sha256}),ha=ws(fe.toBytes(Mt),{infinity:!0,compressed:!0});function fa(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 ws(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 xh(t){t.assertValidity();let e=t.equals(Ct.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return ha.slice();let i=fe.ORDER,s=!!(n*pt/i);return ws((0,Be.numberToBytesBE)(r,fe.BYTES),{compressed:!0,sort:s})}function vh(t){t.assertValidity();let e=fe.BYTES;if(t.equals(Ct.bls12_381.G2.ProjectivePoint.ZERO))return(0,Be.concatBytes)(ha,(0,Be.numberToBytesBE)(Mt,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=pe.reim(r),{re:o,im:a}=pe.reim(n),f=!!((a>Mt?a*pt:o*pt)/fe.ORDER&da),d=i;return(0,Be.concatBytes)(ws((0,Be.numberToBytesBE)(s,e),{sort:f,compressed:!0}),(0,Be.numberToBytesBE)(d,e))}Ct.bls12_381=(0,Tw.bls)({fields:{Fp:fe,Fp2:pe,Fp6:bl,Fp12:ve,Fr:wh},G1:{Fp:fe,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:fe.ZERO,b:_s,htfDefaults:{...ml,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(fe.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(xn).negate().multiplyUnsafe(xn).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(xn).add(e),mapToCurve:t=>{let{x:e,y:r}=Rw(fe.create(t[0]));return Ow(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=fa(t);if(i.length===48&&e){let s=fe.ORDER,o=(0,Be.bytesToNumberBE)(i),a=fe.create(o&fe.MASK);if(r){if(a!==Mt)throw new Error("G1: non-empty compressed point at infinity");return{x:Mt,y:Mt}}let c=fe.add(fe.pow(a,la),fe.create(Ct.bls12_381.params.G1b)),f=fe.sqrt(c);if(!f)throw new Error("Invalid compressed G1 point");return f*pt/s!==BigInt(n)&&(f=fe.neg(f)),{x:fe.create(a),y:fe.create(f)}}else if(i.length===96&&!e){let s=(0,Be.bytesToNumberBE)(i.subarray(0,fe.BYTES)),o=(0,Be.bytesToNumberBE)(i.subarray(fe.BYTES));if(r){if(s!==Mt||o!==Mt)throw new Error("G1: non-empty point at infinity");return Ct.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:fe.create(s),y:fe.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 ha.slice();let o=fe.ORDER,a=!!(s*pt/o);return ws((0,Be.numberToBytesBE)(i,fe.BYTES),{compressed:!0,sort:a})}else return n?(0,Be.concatBytes)(new Uint8Array([64]),new Uint8Array(2*fe.BYTES-1)):(0,Be.concatBytes)((0,Be.numberToBytesBE)(i,fe.BYTES),(0,Be.numberToBytesBE)(s,fe.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=fa((0,Be.ensureBytes)("signatureHex",t,48)),i=fe.ORDER,s=(0,Be.bytesToNumberBE)(n);if(e)return Ct.bls12_381.G1.ProjectivePoint.ZERO;let o=fe.create(s&fe.MASK),a=fe.add(fe.pow(o,la),fe.create(Ct.bls12_381.params.G1b)),c=fe.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let f=BigInt(r);c*pt/i!==f&&(c=fe.neg(c));let d=Ct.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return d.assertValidity(),d},toRawBytes(t){return xh(t)},toHex(t){return(0,Be.bytesToHex)(xh(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([_s,_s]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...ml},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=Nw(pe.fromBigTuple(t));return Bw(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(xn).negate().equals(Eh(t,e)),clearCofactor:(t,e)=>{let r=xn,n=e.multiplyUnsafe(r).negate(),i=Eh(t,e),s=e.double();return s=Pw(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}=fa(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=fe.BYTES,o=(a,c,f)=>(0,Be.bytesToNumberBE)(a.slice(c,f));if(i.length===96&&e){let a=Ct.bls12_381.params.G2b,c=fe.ORDER;if(r){if(i.reduce((O,T)=>O!==0?T+1:T,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:fe.create(d),c1:fe.create(f)}),m=pe.add(pe.pow(h,la),a),_=pe.sqrt(m),u=_.c1===Mt?_.c0*pt/c:_.c1*pt/c?da:Mt;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}=fe,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return(0,Be.concatBytes)(ha,(0,Be.numberToBytesBE)(Mt,n));let c=!!(a.c1===Mt?a.c0*pt/i:a.c1*pt/i);return(0,Be.concatBytes)(ws((0,Be.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,Be.numberToBytesBE)(o.c0,n))}else{if(s)return(0,Be.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,Be.concatBytes)((0,Be.numberToBytesBE)(f,n),(0,Be.numberToBytesBE)(c,n),(0,Be.numberToBytesBE)(h,n),(0,Be.numberToBytesBE)(d,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=fa((0,Be.ensureBytes)("signatureHex",t)),i=fe.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,Be.bytesToNumberBE)(n.slice(0,s)),a=(0,Be.bytesToNumberBE)(n.slice(s));if(e)return Ct.bls12_381.G2.ProjectivePoint.ZERO;let c=fe.create(o&fe.MASK),f=fe.create(a),d=pe.create({c0:f,c1:c}),h=pe.add(pe.pow(d,la),Ct.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),O=BigInt(r),T=u>Mt&&u*pt/i!==O,P=u===Mt&&_*pt/i!==O;(T||P)&&(m=pe.neg(m));let F=Ct.bls12_381.G2.ProjectivePoint.fromAffine({x:d,y:m});return F.assertValidity(),F},toRawBytes(t){return vh(t)},toHex(t){return(0,Be.bytesToHex)(vh(t))}}},params:{ateLoopSize:xn,r:wh.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:ml,hash:Th.sha256,randomBytes:vw.randomBytes})});var wl=ee(Es=>{"use strict";Object.defineProperty(Es,"__esModule",{value:!0});Es.blsVerify=Es.verify=void 0;var Iw=Oh(),_l=Vt();function Uw(t,e,r){let n=typeof t=="string"?t:(0,_l.toHex)(t),i=typeof e=="string"?e:(0,_l.toHex)(e),s=typeof r=="string"?r:(0,_l.toHex)(r);return Iw.bls12_381.verifyShortSignature(i,s,n)}Es.blsVerify=Uw});var pa=ee(Yn=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.decodeTime=Yn.decodeLeb128=void 0;var Nh=xi(),Fw=t=>(0,Nh.lebDecode)(new Nh.PipeArrayBuffer(t));Yn.decodeLeb128=Fw;var Mw=t=>{let e=(0,Yn.decodeLeb128)(t);return new Date(Number(e)/1e6)};Yn.decodeTime=Mw});var Oi=ee(Te=>{"use strict";var Cw=Te&&Te.__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=Te&&Te.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Rh=Te&&Te.__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},jw=Te&&Te.__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},kw=Te&&Te.__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)},ga;Object.defineProperty(Te,"__esModule",{value:!0});Te.check_canister_ranges=Te.find_label=Te.flatten_forks=Te.lookup_path=Te.LookupStatus=Te.reconstruct=Te.lookupResultToBuffer=Te.Certificate=Te.hashTreeToString=Te.NodeType=Te.CertificateVerificationError=void 0;var Ph=Rh(ys()),Hw=yi(),ya=ds(),yr=Vt(),El=Ut(),Vw=Rh(wl()),$w=pa(),Kw=Ss(),tn=class extends Hw.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};Te.CertificateVerificationError=tn;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=Te.NodeType||(Te.NodeType={}));function ma(t){let e=n=>n.split(`
|
|
18
18
|
`).map(i=>" "+i).join(`
|
|
19
|
-
`);function r(n){let i=new TextDecoder(void 0,{fatal:!0});try{return JSON.stringify(i.decode(n))}catch{return`data(...${n.byteLength} bytes)`}}switch(t[0]){case Et.Empty:return"()";case Et.Fork:if(t[1]instanceof Array&&t[2]instanceof ArrayBuffer){let n=
|
|
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=ma(t[1]),i=ma(t[2]);return`sub(
|
|
20
20
|
left:
|
|
21
21
|
${e(n)}
|
|
22
22
|
---
|
|
23
23
|
right:
|
|
24
24
|
${e(i)}
|
|
25
|
-
)`}else throw new Error("Invalid tree structure for fork");case Et.Labeled:if(t[1]instanceof ArrayBuffer&&t[2]instanceof ArrayBuffer){let n=r(t[1]),i=
|
|
25
|
+
)`}else throw new Error("Invalid tree structure for fork");case Et.Labeled:if(t[1]instanceof ArrayBuffer&&t[2]instanceof ArrayBuffer){let n=r(t[1]),i=ma(t[2]);return`label(
|
|
26
26
|
label:
|
|
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,yr.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}Te.hashTreeToString=ga;function $w(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 El=class t{constructor(e,r,n,i,s=5,o=!1){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,ya.set(this,!1),qw(this,ya,o,"f"),this.cert=Nh.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=jw.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes,e.disableTimeVerification)}lookup(e){return ma(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await Ts(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Gw(r),s=(0,yr.concat)(vs("ic-state-root"),e),o=!1,a=xl(this.lookup(["time"]));if(!a)throw new tn("Certificate does not contain a time");if(!Cw(this,ya,"f")){let f=this._maxAgeInMinutes*60*1e3,d=Date.now(),h=d-f,m=d+3e5,_=(0,Hw.decodeTime)(a);if(_.getTime()<h)throw new tn(`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 tn("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 tn("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 tn("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==Vw.MANAGEMENT_CANISTER_ID&&!Rh({canisterId:this._canisterId,subnetId:wl.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new tn(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,yr.toHex)(e.subnet_id)}`);let n=xl(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,yr.toHex)(e.subnet_id)}`);return n}};Te.Certificate=El;ya=new WeakMap;var xs=(0,yr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Kw=96;function Gw(t){let e=xs.byteLength+Kw;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,xs.byteLength);if(!(0,yr.bufEquals)(r,xs))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${xs}, but get ${r}`);return t.slice(xs.byteLength)}function xl(t){if(t.status===Ct.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}Te.lookupResultToBuffer=xl;async function Ts(t){switch(t[0]){case Et.Empty:return(0,pa.hash)(vs("ic-hashtree-empty"));case Et.Pruned:return t[1];case Et.Leaf:return(0,pa.hash)((0,yr.concat)(vs("ic-hashtree-leaf"),t[1]));case Et.Labeled:return(0,pa.hash)((0,yr.concat)(vs("ic-hashtree-labeled"),t[1],await Ts(t[2])));case Et.Fork:return(0,pa.hash)((0,yr.concat)(vs("ic-hashtree-fork"),await Ts(t[1]),await Ts(t[2])));default:throw new Error("unreachable")}}Te.reconstruct=Ts;function vs(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,yr.concat)(e,r)}var Ct;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(Ct=Te.LookupStatus||(Te.LookupStatus={}));var rn;(function(t){t.Less="less",t.Greater="greater"})(rn||(rn={}));function ma(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:Ct.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:Ct.Found,value:e[1].buffer}:{status:Ct.Found,value:e[1]}}default:return{status:Ct.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=As(r,e);switch(n.status){case Ct.Found:return ma(t.slice(1),n.value);case rn.Greater:case rn.Less:return{status:Ct.Absent};default:return n}}Te.lookup_path=ma;function vl(t){switch(t[0]){case Et.Empty:return[];case Et.Fork:return vl(t[1]).concat(vl(t[2]));default:return[t]}}Te.flatten_forks=vl;function As(t,e){switch(e[0]){case Et.Labeled:return $w(t,e[1])?{status:rn.Greater}:(0,yr.bufEquals)(t,e[1])?{status:Ct.Found,value:e[2]}:{status:rn.Less};case Et.Fork:let r=As(t,e[1]);switch(r.status){case rn.Greater:{let n=As(t,e[2]);return n.status===rn.Less?{status:Ct.Absent}:n}case Ct.Unknown:{let n=As(t,e[2]);return n.status===rn.Less?{status:Ct.Unknown}:n}default:return r}case Et.Pruned:return{status:Ct.Unknown};default:return{status:Ct.Absent}}}Te.find_label=As;function Rh(t){let{canisterId:e,subnetId:r,tree:n}=t,i=ma(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Ct.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return Nh.decode(i.value).map(c=>[wl.Principal.fromUint8Array(c[0]),wl.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}Te.check_canister_ranges=Rh});var Bs=ee(ut=>{"use strict";var Yw=ut&&ut.__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]}),Ww=ut&&ut.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),zw=ut&&ut.__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)&&Yw(e,t,r);return Ww(e,t),e};Object.defineProperty(ut,"__esModule",{value:!0});ut.encodePath=ut.fetchNodeKeys=ut.request=ut.CustomPath=void 0;var vn=Ut(),Zw=yi(),Tn=Oi(),Dw=Vt(),Uh=zw(ys()),Ph=ha(),Tl=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};ut.CustomPath=Tl;var Xw=async t=>{let{agent:e,paths:r}=t,n=vn.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>(0,ut.encodePath)(c,n)),o=new Map,a=i.map((c,f)=>(async()=>{var d;try{let h=await e.readState(n,{paths:[s[f]]});if(e.rootKey==null)throw new Error("Agent is missing root key");let m=await Tn.Certificate.create({certificate:h.certificate,rootKey:e.rootKey,canisterId:n,disableTimeVerification:!0}),_=(T,P)=>{if(P==="subnet"){if(e.rootKey==null)throw new Error("Agent is missing root key");let F=(0,ut.fetchNodeKeys)(h.certificate,n,e.rootKey);return{path:P,data:F}}else return{path:P,data:(0,Tn.lookupResultToBuffer)(T.lookup((0,ut.encodePath)(P,n)))}},{path:u,data:O}=_(m,i[f]);if(!O)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,Ph.decodeTime)(O));break}case"controllers":{o.set(u,e2(O));break}case"module_hash":{o.set(u,Ih(O));break}case"subnet":{o.set(u,O);break}case"candid":{o.set(u,new TextDecoder().decode(O));break}default:if(typeof u!="string"&&"key"in u&&"path"in u)switch(u.decodeStrategy){case"raw":o.set(u.key,O);break;case"leb128":{o.set(u.key,(0,Ph.decodeLeb128)(O));break}case"cbor":{o.set(u.key,Fh(O));break}case"hex":{o.set(u.key,Ih(O));break}case"utf-8":o.set(u.key,Lw(O))}}}catch(h){if(!((d=h?.message)===null||d===void 0)&&d.includes("Invalid certificate"))throw new Zw.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};ut.request=Xw;var Jw=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=Uh.decode(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=vn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=vn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=vn.Principal.selfAuthenticating(vn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,Tn.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,Tn.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==Tn.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let f=(0,Tn.flatten_forks)(c.value),d=new Map;return f.forEach(h=>{let m=vn.Principal.from(new Uint8Array(h[1])).toText(),_=(0,Tn.lookup_path)(["public_key"],h[2]);if(_.status!==Tn.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:vn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:d}};ut.fetchNodeKeys=Jw;var Qw=(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.`)};ut.encodePath=Qw;var Ih=t=>(0,Dw.toHex)(t),Fh=t=>Uh.decode(t),Lw=t=>new TextDecoder().decode(t),e2=t=>Fh(t).map(r=>vn.Principal.fromUint8Array(new Uint8Array(r)))});var rp=ee(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.add5L=ye.add5H=ye.add4H=ye.add4L=ye.add3H=ye.add3L=ye.rotlBL=ye.rotlBH=ye.rotlSL=ye.rotlSH=ye.rotr32L=ye.rotr32H=ye.rotrBL=ye.rotrBH=ye.rotrSL=ye.rotrSH=ye.shrSL=ye.shrSH=ye.toBig=void 0;ye.fromBig=Sl;ye.split=Mh;ye.add=Dh;var ba=BigInt(2**32-1),Al=BigInt(32);function Sl(t,e=!1){return e?{h:Number(t&ba),l:Number(t>>Al&ba)}:{h:Number(t>>Al&ba)|0,l:Number(t&ba)|0}}function Mh(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}=Sl(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}var qh=(t,e)=>BigInt(t>>>0)<<Al|BigInt(e>>>0);ye.toBig=qh;var Ch=(t,e,r)=>t>>>r;ye.shrSH=Ch;var kh=(t,e,r)=>t<<32-r|e>>>r;ye.shrSL=kh;var jh=(t,e,r)=>t>>>r|e<<32-r;ye.rotrSH=jh;var Hh=(t,e,r)=>t<<32-r|e>>>r;ye.rotrSL=Hh;var Vh=(t,e,r)=>t<<64-r|e>>>r-32;ye.rotrBH=Vh;var $h=(t,e,r)=>t>>>r-32|e<<64-r;ye.rotrBL=$h;var Kh=(t,e)=>e;ye.rotr32H=Kh;var Gh=(t,e)=>t;ye.rotr32L=Gh;var Yh=(t,e,r)=>t<<r|e>>>32-r;ye.rotlSH=Yh;var Wh=(t,e,r)=>e<<r|t>>>32-r;ye.rotlSL=Wh;var zh=(t,e,r)=>e<<r-32|t>>>64-r;ye.rotlBH=zh;var Zh=(t,e,r)=>t<<r-32|e>>>64-r;ye.rotlBL=Zh;function Dh(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Xh=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);ye.add3L=Xh;var Jh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;ye.add3H=Jh;var Qh=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);ye.add4L=Qh;var Lh=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;ye.add4H=Lh;var ep=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);ye.add5L=ep;var tp=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;ye.add5H=tp;var t2={fromBig:Sl,split:Mh,toBig:qh,shrSH:Ch,shrSL:kh,rotrSH:jh,rotrSL:Hh,rotrBH:Vh,rotrBL:$h,rotr32H:Kh,rotr32L:Gh,rotlSH:Yh,rotlSL:Wh,rotlBH:zh,rotlBL:Zh,add:Dh,add3L:Xh,add3H:Jh,add4L:Qh,add4H:Lh,add5H:tp,add5L:ep};ye.default=t2});var np=ee(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.sha384=yt.sha512_256=yt.sha512_224=yt.sha512=yt.SHA384=yt.SHA512_256=yt.SHA512_224=yt.SHA512=void 0;var r2=Wc(),be=rp(),xa=jn(),[n2,i2]=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))),An=new Uint32Array(80),Sn=new Uint32Array(80),Wn=class extends r2.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:O,Hl:T}=this;return[e,r,n,i,s,o,a,c,f,d,h,m,_,u,O,T]}set(e,r,n,i,s,o,a,c,f,d,h,m,_,u,O,T){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=O|0,this.Hl=T|0}process(e,r){for(let A=0;A<16;A++,r+=4)An[A]=e.getUint32(r),Sn[A]=e.getUint32(r+=4);for(let A=16;A<80;A++){let K=An[A-15]|0,E=Sn[A-15]|0,k=be.default.rotrSH(K,E,1)^be.default.rotrSH(K,E,8)^be.default.shrSH(K,E,7),G=be.default.rotrSL(K,E,1)^be.default.rotrSL(K,E,8)^be.default.shrSL(K,E,7),z=An[A-2]|0,C=Sn[A-2]|0,oe=be.default.rotrSH(z,C,19)^be.default.rotrBH(z,C,61)^be.default.shrSH(z,C,6),Q=be.default.rotrSL(z,C,19)^be.default.rotrBL(z,C,61)^be.default.shrSL(z,C,6),ie=be.default.add4L(G,Q,Sn[A-7],Sn[A-16]),w=be.default.add4H(ie,k,oe,An[A-7],An[A-16]);An[A]=w|0,Sn[A]=ie|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:O,Gl:T,Hh:P,Hl:F}=this;for(let A=0;A<80;A++){let K=be.default.rotrSH(h,m,14)^be.default.rotrSH(h,m,18)^be.default.rotrBH(h,m,41),E=be.default.rotrSL(h,m,14)^be.default.rotrSL(h,m,18)^be.default.rotrBL(h,m,41),k=h&_^~h&O,G=m&u^~m&T,z=be.default.add5L(F,E,G,i2[A],Sn[A]),C=be.default.add5H(z,P,K,k,n2[A],An[A]),oe=z|0,Q=be.default.rotrSH(n,i,28)^be.default.rotrBH(n,i,34)^be.default.rotrBH(n,i,39),ie=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;P=O|0,F=T|0,O=_|0,T=u|0,_=h|0,u=m|0,{h,l:m}=be.default.add(f|0,d|0,C|0,oe|0),f=a|0,d=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let N=be.default.add3L(oe,ie,b);n=be.default.add3H(N,C,Q,w),i=N|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:O,l:T}=be.default.add(this.Gh|0,this.Gl|0,O|0,T|0),{h:P,l:F}=be.default.add(this.Hh|0,this.Hl|0,P|0,F|0),this.set(n,i,s,o,a,c,f,d,h,m,_,u,O,T,P,F)}roundClean(){An.fill(0),Sn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};yt.SHA512=Wn;var _a=class extends Wn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}};yt.SHA512_224=_a;var wa=class extends Wn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}};yt.SHA512_256=wa;var Ea=class extends Wn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};yt.SHA384=Ea;yt.sha512=(0,xa.wrapConstructor)(()=>new Wn);yt.sha512_224=(0,xa.wrapConstructor)(()=>new _a);yt.sha512_256=(0,xa.wrapConstructor)(()=>new wa);yt.sha384=(0,xa.wrapConstructor)(()=>new Ea)});var sp=ee(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});Ol.twistedEdwards=c2;var Bl=ll(),ip=Mr(),Yt=Zt(),Jt=Zt(),gr=BigInt(0),Gt=BigInt(1),va=BigInt(2),s2=BigInt(8),o2={zip215:!0};function a2(t){let e=(0,Bl.validateBasic)(t);return Yt.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function c2(t){let e=a2(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=va<<BigInt(a*8)-Gt,d=r.create,h=(0,ip.Field)(e.n,e.nBitLength),m=e.uvRatio||((B,R)=>{try{return{isValid:!0,value:r.sqrt(B*r.inv(R))}}catch{return{isValid:!1,value:gr}}}),_=e.adjustScalarBytes||(B=>B),u=e.domain||((B,R,V)=>{if((0,Jt.abool)("phflag",V),R.length||V)throw new Error("Contexts/pre-hash are not supported");return B});function O(B,R){Yt.aInRange("coordinate "+B,R,gr,f)}function T(B){if(!(B instanceof A))throw new Error("ExtendedPoint expected")}let P=(0,Jt.memoized)((B,R)=>{let{ex:V,ey:D,ez:ce}=B,ae=B.is0();R==null&&(R=ae?s2:r.inv(ce));let Z=d(V*R),M=d(D*R),y=d(ce*R);if(ae)return{x:gr,y:Gt};if(y!==Gt)throw new Error("invZ was invalid");return{x:Z,y:M}}),F=(0,Jt.memoized)(B=>{let{a:R,d:V}=e;if(B.is0())throw new Error("bad point: ZERO");let{ex:D,ey:ce,ez:ae,et:Z}=B,M=d(D*D),y=d(ce*ce),L=d(ae*ae),re=d(L*L),le=d(M*R),J=d(L*d(le+y)),l=d(re+d(V*d(M*y)));if(J!==l)throw new Error("bad point: equation left != right (1)");let p=d(D*ce),g=d(ae*Z);if(p!==g)throw new Error("bad point: equation left != right (2)");return!0});class A{constructor(R,V,D,ce){this.ex=R,this.ey=V,this.ez=D,this.et=ce,O("x",R),O("y",V),O("z",D),O("t",ce),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(R){if(R instanceof A)throw new Error("extended point not allowed");let{x:V,y:D}=R||{};return O("x",V),O("y",D),new A(V,D,Gt,d(V*D))}static normalizeZ(R){let V=r.invertBatch(R.map(D=>D.ez));return R.map((D,ce)=>D.toAffine(V[ce])).map(A.fromAffine)}static msm(R,V){return(0,Bl.pippenger)(A,h,R,V)}_setWindowSize(R){k.setWindowSize(this,R)}assertValidity(){F(this)}equals(R){T(R);let{ex:V,ey:D,ez:ce}=this,{ex:ae,ey:Z,ez:M}=R,y=d(V*M),L=d(ae*ce),re=d(D*M),le=d(Z*ce);return y===L&&re===le}is0(){return this.equals(A.ZERO)}negate(){return new A(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:R}=e,{ex:V,ey:D,ez:ce}=this,ae=d(V*V),Z=d(D*D),M=d(va*d(ce*ce)),y=d(R*ae),L=V+D,re=d(d(L*L)-ae-Z),le=y+Z,J=le-M,l=y-Z,p=d(re*J),g=d(le*l),I=d(re*l),S=d(J*le);return new A(p,g,S,I)}add(R){T(R);let{a:V,d:D}=e,{ex:ce,ey:ae,ez:Z,et:M}=this,{ex:y,ey:L,ez:re,et:le}=R;if(V===BigInt(-1)){let X=d((ae-ce)*(L+y)),te=d((ae+ce)*(L-y)),de=d(te-X);if(de===gr)return this.double();let _e=d(Z*va*le),Me=d(M*va*re),Ve=Me+_e,me=te+X,he=Me-_e,Xe=d(Ve*de),vr=d(me*he),zr=d(Ve*he),Zr=d(de*me);return new A(Xe,vr,Zr,zr)}let J=d(ce*y),l=d(ae*L),p=d(M*D*le),g=d(Z*re),I=d((ce+ae)*(y+L)-J-l),S=g-p,U=g+p,H=d(l-V*J),x=d(I*S),q=d(U*H),$=d(I*H),j=d(S*U);return new A(x,q,j,$)}subtract(R){return this.add(R.negate())}wNAF(R){return k.wNAFCached(this,R,A.normalizeZ)}multiply(R){let V=R;Yt.aInRange("scalar",V,Gt,n);let{p:D,f:ce}=this.wNAF(V);return A.normalizeZ([D,ce])[0]}multiplyUnsafe(R){let V=R;return Yt.aInRange("scalar",V,gr,n),V===gr?E:this.equals(E)||V===Gt?this:this.equals(K)?this.wNAF(V).p:k.unsafeLadder(this,V)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return k.unsafeLadder(this,n).is0()}toAffine(R){return P(this,R)}clearCofactor(){let{h:R}=e;return R===Gt?this:this.multiplyUnsafe(R)}static fromHex(R,V=!1){let{d:D,a:ce}=e,ae=r.BYTES;R=(0,Jt.ensureBytes)("pointHex",R,ae),(0,Jt.abool)("zip215",V);let Z=R.slice(),M=R[ae-1];Z[ae-1]=M&-129;let y=Yt.bytesToNumberLE(Z),L=V?f:r.ORDER;Yt.aInRange("pointHex.y",y,gr,L);let re=d(y*y),le=d(re-Gt),J=d(D*re-ce),{isValid:l,value:p}=m(le,J);if(!l)throw new Error("Point.fromHex: invalid y coordinate");let g=(p&Gt)===Gt,I=(M&128)!==0;if(!V&&p===gr&&I)throw new Error("Point.fromHex: x=0 and x_0=1");return I!==g&&(p=d(-p)),A.fromAffine({x:p,y})}static fromPrivateKey(R){return C(R).point}toRawBytes(){let{x:R,y:V}=this.toAffine(),D=Yt.numberToBytesLE(V,r.BYTES);return D[D.length-1]|=R&Gt?128:0,D}toHex(){return Yt.bytesToHex(this.toRawBytes())}}A.BASE=new A(e.Gx,e.Gy,Gt,d(e.Gx*e.Gy)),A.ZERO=new A(gr,Gt,Gt,gr);let{BASE:K,ZERO:E}=A,k=(0,Bl.wNAF)(A,a*8);function G(B){return(0,ip.mod)(B,n)}function z(B){return G(Yt.bytesToNumberLE(B))}function C(B){let R=a;B=(0,Jt.ensureBytes)("private key",B,R);let V=(0,Jt.ensureBytes)("hashed private key",s(B),2*R),D=_(V.slice(0,R)),ce=V.slice(R,2*R),ae=z(D),Z=K.multiply(ae),M=Z.toRawBytes();return{head:D,prefix:ce,scalar:ae,point:Z,pointBytes:M}}function oe(B){return C(B).pointBytes}function Q(B=new Uint8Array,...R){let V=Yt.concatBytes(...R);return z(s(u(V,(0,Jt.ensureBytes)("context",B),!!i)))}function ie(B,R,V={}){B=(0,Jt.ensureBytes)("message",B),i&&(B=i(B));let{prefix:D,scalar:ce,pointBytes:ae}=C(R),Z=Q(V.context,D,B),M=K.multiply(Z).toRawBytes(),y=Q(V.context,M,ae,B),L=G(Z+y*ce);Yt.aInRange("signature.s",L,gr,n);let re=Yt.concatBytes(M,Yt.numberToBytesLE(L,r.BYTES));return(0,Jt.ensureBytes)("result",re,a*2)}let w=o2;function b(B,R,V,D=w){let{context:ce,zip215:ae}=D,Z=r.BYTES;B=(0,Jt.ensureBytes)("signature",B,2*Z),R=(0,Jt.ensureBytes)("message",R),ae!==void 0&&(0,Jt.abool)("zip215",ae),i&&(R=i(R));let M=Yt.bytesToNumberLE(B.slice(Z,2*Z)),y,L,re;try{y=A.fromHex(V,ae),L=A.fromHex(B.slice(0,Z),ae),re=K.multiplyUnsafe(M)}catch{return!1}if(!ae&&y.isSmallOrder())return!1;let le=Q(ce,L.toRawBytes(),y.toRawBytes(),R);return L.add(y.multiplyUnsafe(le)).subtract(re).clearCofactor().equals(A.ZERO)}return K._setWindowSize(8),{CURVE:e,getPublicKey:oe,sign:ie,verify:b,ExtendedPoint:A,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>o(r.BYTES),precompute(B=8,R=A.BASE){return R._setWindowSize(B),R.multiply(BigInt(3)),R}}}}});var ap=ee(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});Rl.montgomery=l2;var op=Mr(),Bn=Zt(),Ni=BigInt(0),Nl=BigInt(1);function u2(t){return(0,Bn.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function l2(t){let e=u2(t),{P:r}=e,n=F=>(0,op.mod)(F,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(F=>F),c=e.powPminus2||(F=>(0,op.pow)(F,r-BigInt(2),r));function f(F,A,K){let E=n(F*(A-K));return A=n(A-E),K=n(K+E),[A,K]}let d=(e.a-BigInt(2))/BigInt(4);function h(F,A){(0,Bn.aInRange)("u",F,Ni,r),(0,Bn.aInRange)("scalar",A,Ni,r);let K=A,E=F,k=Nl,G=Ni,z=F,C=Nl,oe=Ni,Q;for(let w=BigInt(i-1);w>=Ni;w--){let b=K>>w&Nl;oe^=b,Q=f(oe,k,z),k=Q[0],z=Q[1],Q=f(oe,G,C),G=Q[0],C=Q[1],oe=b;let N=k+G,B=n(N*N),R=k-G,V=n(R*R),D=B-V,ce=z+C,ae=z-C,Z=n(ae*N),M=n(ce*R),y=Z+M,L=Z-M;z=n(y*y),C=n(E*n(L*L)),k=n(B*V),G=n(D*(B+n(d*D)))}Q=f(oe,k,z),k=Q[0],z=Q[1],Q=f(oe,G,C),G=Q[0],C=Q[1];let ie=c(G);return n(k*ie)}function m(F){return(0,Bn.numberToBytesLE)(n(F),s)}function _(F){let A=(0,Bn.ensureBytes)("u coordinate",F,s);return o===32&&(A[31]&=127),(0,Bn.bytesToNumberLE)(A)}function u(F){let A=(0,Bn.ensureBytes)("scalar",F),K=A.length;if(K!==s&&K!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${K}`);return(0,Bn.bytesToNumberLE)(a(A))}function O(F,A){let K=_(A),E=u(F),k=h(K,E);if(k===Ni)throw new Error("Invalid private or public key received");return m(k)}let T=m(e.Gu);function P(F){return O(F,T)}return{scalarMult:O,scalarMultBase:P,getSharedSecret:(F,A)=>O(F,A),getPublicKey:F=>P(F),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:T}}});var kl=ee(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=mp;ge.edwardsToMontgomeryPriv=h2;var Aa=np(),Os=jn(),Ml=sp(),fp=ia(),Ue=Mr(),f2=ap(),zn=Zt(),Ns=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ul=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),d2=BigInt(0),qr=BigInt(1),Ta=BigInt(2),dp=BigInt(3),hp=BigInt(5),ql=BigInt(8);function pp(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=Ns,a=t*t%s*t%s,c=(0,Ue.pow2)(a,Ta,s)*a%s,f=(0,Ue.pow2)(c,qr,s)*t%s,d=(0,Ue.pow2)(f,hp,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,O=(0,Ue.pow2)(u,i,s)*_%s,T=(0,Ue.pow2)(O,e,s)*d%s;return{pow_p_5_8:(0,Ue.pow2)(T,Ta,s)*t%s,b2:a}}function yp(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Cl(t,e){let r=Ns,n=(0,Ue.mod)(e*e*e,r),i=(0,Ue.mod)(n*n*e,r),s=pp(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*Ul,r),d=a===t,h=a===(0,Ue.mod)(-t,r),m=a===(0,Ue.mod)(-t*Ul,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 ue=(0,Ue.Field)(Ns,void 0,!0),Rs={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ue,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:ql,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Aa.sha512,randomBytes:Os.randomBytes,adjustScalarBytes:yp,uvRatio:Cl};ge.ed25519=(0,Ml.twistedEdwards)(Rs);function gp(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,Os.concatBytes)((0,Os.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}ge.ed25519ctx=(0,Ml.twistedEdwards)({...Rs,domain:gp});ge.ed25519ph=(0,Ml.twistedEdwards)(Object.assign({},Rs,{domain:gp,prehash:Aa.sha512}));ge.x25519=(0,f2.montgomery)({P:Ns,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=Ns,{pow_p_5_8:r,b2:n}=pp(t);return(0,Ue.mod)((0,Ue.pow2)(r,dp,e)*n,e)},adjustScalarBytes:yp,randomBytes:Os.randomBytes});function mp(t){let{y:e}=ge.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return ue.toBytes(ue.create((r+e)*ue.inv(r-e)))}ge.edwardsToMontgomery=mp;function h2(t){let e=Rs.hash(t.subarray(0,32));return Rs.adjustScalarBytes(e).subarray(0,32)}var p2=(ue.ORDER+dp)/ql,y2=ue.pow(Ta,p2),cp=ue.sqrt(ue.neg(ue.ONE));function g2(t){let e=(ue.ORDER-hp)/ql,r=BigInt(486662),n=ue.sqr(t);n=ue.mul(n,Ta);let i=ue.add(n,ue.ONE),s=ue.neg(r),o=ue.sqr(i),a=ue.mul(o,i),c=ue.mul(n,r);c=ue.mul(c,s),c=ue.add(c,o),c=ue.mul(c,s);let f=ue.sqr(a);o=ue.sqr(f),f=ue.mul(f,a),f=ue.mul(f,c),o=ue.mul(o,f);let d=ue.pow(o,e);d=ue.mul(d,f);let h=ue.mul(d,cp);o=ue.sqr(d),o=ue.mul(o,a);let m=ue.eql(o,c),_=ue.cmov(h,d,m),u=ue.mul(s,n),O=ue.mul(d,t);O=ue.mul(O,y2);let T=ue.mul(O,cp),P=ue.mul(c,n);o=ue.sqr(O),o=ue.mul(o,a);let F=ue.eql(o,P),A=ue.cmov(T,O,F);o=ue.sqr(_),o=ue.mul(o,a);let K=ue.eql(o,c),E=ue.cmov(u,s,K),k=ue.cmov(A,_,K),G=ue.isOdd(k);return k=ue.cmov(k,ue.neg(k),K!==G),{xMn:E,xMd:i,yMn:k,yMd:qr}}var m2=(0,Ue.FpSqrtEven)(ue,ue.neg(BigInt(486664)));function b2(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=g2(t),s=ue.mul(e,i);s=ue.mul(s,m2);let o=ue.mul(r,n),a=ue.sub(e,r),c=ue.add(e,r),f=ue.mul(o,c),d=ue.eql(f,ue.ZERO);s=ue.cmov(s,ue.ZERO,d),o=ue.cmov(o,ue.ONE,d),a=ue.cmov(a,ue.ONE,d),c=ue.cmov(c,ue.ONE,d);let h=ue.invertBatch([o,c]);return{x:ue.mul(s,h[0]),y:ue.mul(a,h[1])}}var bp=(0,fp.createHasher)(ge.ed25519.ExtendedPoint,t=>b2(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:ue.ORDER,m:1,k:128,expand:"xmd",hash:Aa.sha512});ge.hashToCurve=bp.hashToCurve;ge.encodeToCurve=bp.encodeToCurve;function Pl(t){if(!(t instanceof mr))throw new Error("RistrettoPoint expected")}var Fl=Ul,_2=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),w2=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),E2=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),x2=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),up=t=>Cl(qr,t),v2=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Il=t=>ge.ed25519.CURVE.Fp.create((0,zn.bytesToNumberLE)(t)&v2);function lp(t){let{d:e}=ge.ed25519.CURVE,r=ge.ed25519.CURVE.Fp.ORDER,n=ge.ed25519.CURVE.Fp.create,i=n(Fl*t*t),s=n((i+qr)*E2),o=BigInt(-1),a=n((o-e*i)*n(i+e)),{isValid:c,value:f}=Cl(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-qr)*x2-a),m=f*f,_=n((f+f)*a),u=n(h*_2),O=n(qr-m),T=n(qr+m);return new ge.ed25519.ExtendedPoint(n(_*T),n(O*u),n(u*T),n(_*O))}var mr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(ge.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,zn.ensureBytes)("ristrettoHash",e,64);let r=Il(e.slice(0,32)),n=lp(r),i=Il(e.slice(32,64)),s=lp(i);return new t(n.add(s))}static fromHex(e){e=(0,zn.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=Il(e);if(!(0,zn.equalBytes)((0,zn.numberToBytesLE)(a,32),e)||(0,Ue.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),f=s(qr+r*c),d=s(qr-r*c),h=s(f*f),m=s(d*d),_=s(r*n*h-m),{isValid:u,value:O}=up(s(_*m)),T=s(O*d),P=s(O*T*_),F=s((a+a)*T);(0,Ue.isNegativeLE)(F,i)&&(F=s(-F));let A=s(f*P),K=s(F*A);if(!u||(0,Ue.isNegativeLE)(K,i)||A===d2)throw new Error(o);return new t(new ge.ed25519.ExtendedPoint(F,A,qr,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}=up(o(a*f)),h=o(d*a),m=o(d*c),_=o(h*m*i),u;if((0,Ue.isNegativeLE)(i*_,s)){let T=o(r*Fl),P=o(e*Fl);e=T,r=P,u=o(h*w2)}else u=m;(0,Ue.isNegativeLE)(e*_,s)&&(r=o(-r));let O=o((n-r)*u);return(0,Ue.isNegativeLE)(O,s)&&(O=o(-O)),(0,zn.numberToBytesLE)(O,32)}toHex(){return(0,zn.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=(mr.BASE||(mr.BASE=new mr(ge.ed25519.ExtendedPoint.BASE)),mr.ZERO||(mr.ZERO=new mr(ge.ed25519.ExtendedPoint.ZERO)),mr);var T2=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,Os.utf8ToBytes)(r):r,i=(0,fp.expand_message_xmd)(t,n,64,Aa.sha512);return mr.hashToCurve(i)};ge.hashToRistretto255=T2;ge.hash_to_ristretto255=ge.hashToRistretto255});var xp=ee(On=>{"use strict";var _p=On&&On.__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},kt=On&&On.__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)},Nt,Ps,wp,Ep;Object.defineProperty(On,"__esModule",{value:!0});On.ExpirableMap=void 0;var jl=class{constructor(e={}){Nt.set(this,void 0),Ps.set(this,void 0),this[wp]=this.entries.bind(this),this[Ep]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();_p(this,Nt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),_p(this,Ps,n,"f")}prune(){let e=Date.now();for(let[r,n]of kt(this,Nt,"f").entries())e-n.timestamp>kt(this,Ps,"f")&&kt(this,Nt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return kt(this,Nt,"f").set(e,n),this}get(e){let r=kt(this,Nt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>kt(this,Ps,"f")){kt(this,Nt,"f").delete(e);return}return r.value}}clear(){kt(this,Nt,"f").clear()}entries(){let e=kt(this,Nt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=kt(this,Nt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return kt(this,Nt,"f").keys()}forEach(e,r){for(let[n,i]of kt(this,Nt,"f").entries())e.call(r,i.value,n,this)}has(e){return kt(this,Nt,"f").has(e)}delete(e){return kt(this,Nt,"f").delete(e)}get size(){return kt(this,Nt,"f").size}};On.ExpirableMap=jl;Nt=new WeakMap,Ps=new WeakMap,wp=Symbol.iterator,Ep=Symbol.toStringTag});var Hl=ee(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.unwrapDER=ke.wrapDER=ke.SECP256K1_OID=ke.ED25519_OID=ke.DER_COSE_OID=ke.decodeLen=ke.decodeLenBytes=ke.encodeLen=ke.encodeLenBytes=void 0;var A2=Vt(),S2=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)")};ke.encodeLenBytes=S2;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)")};ke.encodeLen=B2;var O2=(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)")};ke.decodeLenBytes=O2;var N2=(t,e)=>{let r=(0,ke.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)")};ke.decodeLen=N2;ke.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);ke.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);ke.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function R2(t,e){let r=2+(0,ke.encodeLenBytes)(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+(0,ke.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,ke.encodeLen)(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=(0,ke.encodeLen)(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}ke.wrapDER=R2;var P2=(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,ke.decodeLenBytes)(i,r),!(0,A2.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,ke.decodeLen)(i,r)-1;r+=(0,ke.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};ke.unwrapDER=P2});var Vl=ee(Nn=>{"use strict";var vp=Nn&&Nn.__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},Tp=Nn&&Nn.__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)},Ba,Oa;Object.defineProperty(Nn,"__esModule",{value:!0});Nn.Ed25519PublicKey=void 0;var Sa=Hl(),Na=class t{constructor(e){if(Ba.set(this,void 0),Oa.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");vp(this,Ba,e,"f"),vp(this,Oa,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,Sa.wrapDER)(e,Sa.ED25519_OID).buffer}static derDecode(e){let r=(0,Sa.unwrapDER)(e,Sa.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Tp(this,Ba,"f")}get derKey(){return Tp(this,Oa,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Nn.Ed25519PublicKey=Na;Ba=new WeakMap,Oa=new WeakMap;Na.RAW_KEY_LENGTH=32});var Kl=ee(Ri=>{"use strict";Object.defineProperty(Ri,"__esModule",{value:!0});Ri.ObservableLog=Ri.Observable=void 0;var Ra=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))}};Ri.Observable=Ra;var $l=class extends Ra{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)}};Ri.ObservableLog=$l});var Pp=ee(jr=>{"use strict";var Cr=jr&&jr.__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},Rt=jr&&jr.__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)},kr,Pa,Ia,Ua,Fa,Ma,qa,Ca,Pi;Object.defineProperty(jr,"__esModule",{value:!0});jr.exponentialBackoff=jr.ExponentialBackoff=void 0;var Ap=.5,Sp=1.5,Bp=500,Op=6e4,Np=9e5,Rp=10,Ii=class t{constructor(e=t.default){kr.set(this,void 0),Pa.set(this,void 0),Ia.set(this,void 0),Ua.set(this,void 0),Fa.set(this,void 0),Ma.set(this,void 0),qa.set(this,void 0),Ca.set(this,void 0),Pi.set(this,0);let{initialInterval:r=Bp,randomizationFactor:n=Ap,multiplier:i=Sp,maxInterval:s=Op,maxElapsedTime:o=Np,maxIterations:a=Rp,date:c=Date}=e;Cr(this,kr,r,"f"),Cr(this,Pa,n,"f"),Cr(this,Ia,i,"f"),Cr(this,Ua,s,"f"),Cr(this,Ca,c,"f"),Cr(this,Fa,c.now(),"f"),Cr(this,Ma,o,"f"),Cr(this,qa,a,"f")}get ellapsedTimeInMsec(){return Rt(this,Ca,"f").now()-Rt(this,Fa,"f")}get currentInterval(){return Rt(this,kr,"f")}get count(){return Rt(this,Pi,"f")}get randomValueFromInterval(){let e=Rt(this,Pa,"f")*Rt(this,kr,"f"),r=Rt(this,kr,"f")-e,n=Rt(this,kr,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Cr(this,kr,Math.min(Rt(this,kr,"f")*Rt(this,Ia,"f"),Rt(this,Ua,"f")),"f"),Cr(this,Pi,(e=Rt(this,Pi,"f"),e++,e),"f"),Rt(this,kr,"f")}next(){return this.ellapsedTimeInMsec>=Rt(this,Ma,"f")||Rt(this,Pi,"f")>=Rt(this,qa,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};jr.ExponentialBackoff=Ii;kr=new WeakMap,Pa=new WeakMap,Ia=new WeakMap,Ua=new WeakMap,Fa=new WeakMap,Ma=new WeakMap,qa=new WeakMap,Ca=new WeakMap,Pi=new WeakMap;Ii.default={initialInterval:Bp,randomizationFactor:Ap,multiplier:Sp,maxInterval:Op,maxElapsedTime:Np,maxIterations:Rp,date:Date};function*I2(t=Ii.default){let e=new Ii(t),r=e.next();for(;r;)yield r,r=e.next()}jr.exponentialBackoff=I2});var Wl=ee(Fe=>{"use strict";var Up=Fe&&Fe.__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]}),U2=Fe&&Fe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Fp=Fe&&Fe.__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)&&Up(e,t,r);return U2(e,t),e},Mp=Fe&&Fe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Up(e,t,r)},xt=Fe&&Fe.__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},ne=Fe&&Fe.__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)},Pt,Zn,ki,Hr,nn,Ci,Is,Fi,_r,wr,Dn,Xn,Us,Mi,qi,Jn,Ln,qp,Ha,Va,Qn;Object.defineProperty(Fe,"__esModule",{value:!0});Fe.HttpAgent=Fe.IdentityInvalidError=Fe.MANAGEMENT_CANISTER_ID=Fe.IC_ROOT_KEY=Fe.RequestStatusResponseStatus=Fe.makeNonce=void 0;var sr=Ut(),Vr=yi(),Ip=ju(),Rn=Fp(ys()),ka=ds(),br=Vt(),Er=Xo(),Gl=gs(),ji=Qo(),F2=Bs(),Ui=Oi(),M2=kl(),q2=xp(),C2=Vl(),k2=ha(),j2=Kl(),H2=Pp();Mp(Xo(),Fe);Mp(Qo(),Fe);var V2=gs();Object.defineProperty(Fe,"makeNonce",{enumerable:!0,get:function(){return V2.makeNonce}});var $2;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})($2=Fe.RequestStatusResponseStatus||(Fe.RequestStatusResponseStatus={}));var ja=60*1e3;Fe.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Fe.MANAGEMENT_CANISTER_ID="aaaaa-aa";var K2="ic0.app",G2=".ic0.app",Y2="icp0.io",W2=".icp0.io",z2="icp-api.io",Z2=".icp-api.io",Fs=class extends Vr.AgentError{constructor(e){super(e),this.message=e}},ei=class extends Vr.AgentError{constructor(e){super(e),this.message=e}};Fe.IdentityInvalidError=ei;function D2(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Fs("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 Fs("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 Fs("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function X2(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 Yl=class t{constructor(e={}){var r,n;Pt.add(this),Zn.set(this,null),ki.set(this,!1),Hr.set(this,void 0),nn.set(this,void 0),Ci.set(this,void 0),Is.set(this,void 0),Fi.set(this,0),_r.set(this,void 0),wr.set(this,void 0),Dn.set(this,void 0),Xn.set(this,void 0),this._isAgent=!0,this.config={},Us.set(this,0),this.log=new j2.ObservableLog,Mi.set(this,[]),qi.set(this,[]),Jn.set(this,new q2.ExpirableMap({expirationTime:5*60*1e3})),Ln.set(this,!0),Va.set(this,(o,a)=>{if(ne(this,Ln,"f")===!1)return o;if(!a)throw new Ui.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:c,signatures:f=[],requestId:d}=o,h=new TextEncoder().encode("\vic-response");for(let m of f){let{timestamp:_,identity:u}=m,O=sr.Principal.fromUint8Array(u).toText(),T;if(c==="replied"){let{reply:E}=o;T=(0,ka.hashOfMap)({status:c,reply:E,timestamp:BigInt(_),request_id:d})}else if(c==="rejected"){let{reject_code:E,reject_message:k,error_code:G}=o;T=(0,ka.hashOfMap)({status:c,reject_code:E,reject_message:k,error_code:G,timestamp:BigInt(_),request_id:d})}else throw new Error(`Unknown status: ${c}`);let P=(0,br.concat)(h,new Uint8Array(T)),F=a?.nodeKeys.get(O);if(!F)throw new Ui.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let A=C2.Ed25519PublicKey.fromDer(F).rawKey;if(M2.ed25519.verify(m.signature,new Uint8Array(P),new Uint8Array(A)))return o;throw new Ui.CertificateVerificationError(`Invalid signature from replica ${O} signed query.`)}return o}),this.config=e,xt(this,nn,e.fetch||D2()||fetch.bind(global),"f"),xt(this,Ci,e.fetchOptions,"f"),xt(this,Is,e.callOptions,"f"),xt(this,ki,(r=e.shouldFetchRootKey)!==null&&r!==void 0?r:!1,"f"),e.rootKey?this.rootKey=e.rootKey:ne(this,ki,"f")?this.rootKey=null:this.rootKey=(0,br.fromHex)(Fe.IC_ROOT_KEY);let i=X2(e.host);this.host=new URL(i),e.verifyQuerySignatures!==void 0&&xt(this,Ln,e.verifyQuerySignatures,"f"),xt(this,wr,(n=e.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new H2.ExponentialBackoff({maxIterations:ne(this,wr,"f")});if(xt(this,Dn,e.backoffStrategy||s,"f"),this.host.hostname.endsWith(G2)?this.host.hostname=K2:this.host.hostname.endsWith(W2)?this.host.hostname=Y2:this.host.hostname.endsWith(Z2)&&(this.host.hostname=z2),e.credentials){let{name:o,password:a}=e.credentials;xt(this,_r,`${o}${a?":"+a:""}`,"f")}if(xt(this,Hr,Promise.resolve(e.identity||new Ip.AnonymousIdentity),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new Vr.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 Vr.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);xt(this,Xn,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,Er.makeNonceTransform)(Gl.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,Er.makeNonceTransform)(Gl.makeNonce)),e.logToConsole&&this.log.subscribe(o=>{o.level==="error"?console.error(o.message):o.level==="warn"?console.warn(o.message):console.log(o.message)})}get waterMark(){return ne(this,Us,"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 Vr.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=ne(this,qi,"f").findIndex(s=>(s.priority||0)<n);ne(this,qi,"f").splice(i>=0?i:ne(this,qi,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ne(this,Mi,"f").findIndex(s=>(s.priority||0)<n);ne(this,Mi,"f").splice(i>=0?i:ne(this,Mi,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ne(this,Hr,"f"))throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ne(this,Hr,"f")).getPrincipal()}async call(e,r,n){var i,s;await ne(this,Pt,"m",Qn).call(this);let o=(i=r.callSync)!==null&&i!==void 0?i:!0,a=await(n!==void 0?await n:await ne(this,Hr,"f"));if(!a)throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");let c=sr.Principal.from(e),f=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):c,d=a.getPrincipal()||sr.Principal.anonymous(),h=new Er.Expiry(ne(this,Xn,"f")*ja);Math.abs(ne(this,Fi,"f"))>1e3*30&&(h=new Er.Expiry(ne(this,Xn,"f")*ja+ne(this,Fi,"f")));let m={request_type:Gl.SubmitRequestType.Call,canister_id:c,method_name:r.methodName,arg:r.arg,sender:d,ingress_expiry:h},_=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,_r,"f")?{Authorization:"Basic "+btoa(ne(this,_r,"f"))}:{})},endpoint:"call",body:m}),u=_.body.nonce?O(_.body.nonce):void 0;m.nonce=u;function O(A){return new Uint8Array(A)}_=await a.transformRequest(_);let T=Rn.encode(_.body),P=ne(this,Dn,"f").call(this),F=(0,ka.requestIdOf)(m);try{let A=()=>(this.log.print(`fetching "/api/v3/canister/${f.toText()}/call" with request:`,_),ne(this,nn,"f").call(this,""+new URL(`/api/v3/canister/${f.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Is,"f")),_.request),{body:T}))),K=()=>(this.log.print(`fetching "/api/v2/canister/${f.toText()}/call" with request:`,_),ne(this,nn,"f").call(this,""+new URL(`/api/v2/canister/${f.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Is,"f")),_.request),{body:T}))),k=await ne(this,Pt,"m",Ha).call(this,{request:o?A:K,backoff:P,tries:0}),G=await k.arrayBuffer(),z=k.status===200&&G.byteLength>0?Rn.decode(G):null;if(z&&"certificate"in z){let C=await this.parseTimeFromResponse({certificate:z.certificate});xt(this,Us,C,"f")}return{requestId:F,response:{ok:k.ok,status:k.status,statusText:k.statusText,body:z,headers:(0,Er.httpHeadersTransform)(k.headers)},requestDetails:m}}catch(A){if(A.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);let K=`Error while making call: ${(s=A.message)!==null&&s!==void 0?s:String(A)}`,E=new ji.AgentCallError(K,A,(0,br.toHex)(F),(0,br.toHex)(_.body.sender_pubkey),(0,br.toHex)(_.body.sender_sig),String(_.body.content.ingress_expiry._value));throw this.log.error(K,E),E}}async query(e,r,n){var i,s,o,a;await ne(this,Pt,"m",Qn).call(this);let c=ne(this,Dn,"f").call(this),f=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):sr.Principal.from(e);this.log.print(`ecid ${f.toString()}`),this.log.print(`canisterId ${e.toString()}`);let d,h,m=await(n!==void 0?n:ne(this,Hr,"f"));if(!m)throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");let _=sr.Principal.from(e),u=m?.getPrincipal()||sr.Principal.anonymous(),O={request_type:"query",canister_id:_,method_name:r.methodName,arg:r.arg,sender:u,ingress_expiry:new Er.Expiry(ne(this,Xn,"f")*ja)},T=(0,ka.requestIdOf)(O);d=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,_r,"f")?{Authorization:"Basic "+btoa(ne(this,_r,"f"))}:{})},endpoint:"read",body:O}),d=await m?.transformRequest(d);let P=Rn.encode(d.body),F={canister:_.toText(),ecid:f,transformedRequest:d,body:P,requestId:T,backoff:c,tries:0},A=async()=>({requestDetails:O,query:await ne(this,Pt,"m",qp).call(this,F)}),K=async()=>{if(!ne(this,Ln,"f"))return;let E=ne(this,Jn,"f").get(f.toString());return E||(await this.fetchSubnetKeys(f.toString()),ne(this,Jn,"f").get(f.toString()))};try{let[E,k]=await Promise.all([A(),K()]);h=E;let{requestDetails:G,query:z}=h,C=Object.assign(Object.assign({},z),{requestDetails:G});if(this.log.print("Query response:",C),!ne(this,Ln,"f"))return C;try{return ne(this,Va,"f").call(this,C,k)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ne(this,Jn,"f").delete(e.toString()),await this.fetchSubnetKeys(f.toString());let Q=ne(this,Jn,"f").get(e.toString());if(!Q)throw new Ui.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ne(this,Va,"f").call(this,C,Q)}}catch(E){let k=`Error while making call: ${(i=E.message)!==null&&i!==void 0?i:String(E)}`,G=new ji.AgentQueryError(k,E,String(T),(0,br.toHex)((s=d?.body)===null||s===void 0?void 0:s.sender_pubkey),(0,br.toHex)((o=d?.body)===null||o===void 0?void 0:o.sender_sig),String((a=d?.body)===null||a===void 0?void 0:a.content.ingress_expiry._value));throw this.log.error(k,G),G}}async createReadStateRequest(e,r){await ne(this,Pt,"m",Qn).call(this);let n=await(r!==void 0?await r:await ne(this,Hr,"f"));if(!n)throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||sr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,_r,"f")?{Authorization:"Basic "+btoa(ne(this,_r,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Er.Expiry(ne(this,Xn,"f")*ja)}});return n?.transformRequest(s)}async readState(e,r,n,i){var s,o,a,c;function f(O){for(let T of O.paths){let[P,F]=T,A=new TextEncoder().encode("request_status");if((0,br.bufEquals)(P,A))return F}}let d=f(r);await ne(this,Pt,"m",Qn).call(this);let h=typeof e=="string"?sr.Principal.fromText(e):e,m=i??await this.createReadStateRequest(r,n),_=Rn.encode(m.body);this.log.print(`fetching "/api/v2/canister/${h}/read_state" with request:`,m);let u=ne(this,Dn,"f").call(this);try{let O=await ne(this,Pt,"m",Ha).call(this,{request:()=>ne(this,nn,"f").call(this,""+new URL(`/api/v2/canister/${h.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Ci,"f")),m.request),{body:_})),backoff:u,tries:0});if(!O.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,yr.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}Te.hashTreeToString=ma;function Gw(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 xl=class t{constructor(e,r,n,i,s=5,o=!1){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,ga.set(this,!1),jw(this,ga,o,"f"),this.cert=Ph.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=Vw.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes,e.disableTimeVerification)}lookup(e){return ba(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await Ts(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Ww(r),s=(0,yr.concat)(vs("ic-state-root"),e),o=!1,a=vl(this.lookup(["time"]));if(!a)throw new tn("Certificate does not contain a time");if(!kw(this,ga,"f")){let f=this._maxAgeInMinutes*60*1e3,d=Date.now(),h=d-f,m=d+3e5,_=(0,$w.decodeTime)(a);if(_.getTime()<h)throw new tn(`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 tn("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 tn("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 tn("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==Kw.MANAGEMENT_CANISTER_ID&&!Ih({canisterId:this._canisterId,subnetId:El.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new tn(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,yr.toHex)(e.subnet_id)}`);let n=vl(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,yr.toHex)(e.subnet_id)}`);return n}};Te.Certificate=xl;ga=new WeakMap;var xs=(0,yr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Yw=96;function Ww(t){let e=xs.byteLength+Yw;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,xs.byteLength);if(!(0,yr.bufEquals)(r,xs))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${xs}, but get ${r}`);return t.slice(xs.byteLength)}function vl(t){if(t.status===qt.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}Te.lookupResultToBuffer=vl;async function Ts(t){switch(t[0]){case Et.Empty:return(0,ya.hash)(vs("ic-hashtree-empty"));case Et.Pruned:return t[1];case Et.Leaf:return(0,ya.hash)((0,yr.concat)(vs("ic-hashtree-leaf"),t[1]));case Et.Labeled:return(0,ya.hash)((0,yr.concat)(vs("ic-hashtree-labeled"),t[1],await Ts(t[2])));case Et.Fork:return(0,ya.hash)((0,yr.concat)(vs("ic-hashtree-fork"),await Ts(t[1]),await Ts(t[2])));default:throw new Error("unreachable")}}Te.reconstruct=Ts;function vs(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,yr.concat)(e,r)}var qt;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(qt=Te.LookupStatus||(Te.LookupStatus={}));var rn;(function(t){t.Less="less",t.Greater="greater"})(rn||(rn={}));function ba(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:qt.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:qt.Found,value:e[1].buffer}:{status:qt.Found,value:e[1]}}default:return{status:qt.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=As(r,e);switch(n.status){case qt.Found:return ba(t.slice(1),n.value);case rn.Greater:case rn.Less:return{status:qt.Absent};default:return n}}Te.lookup_path=ba;function Tl(t){switch(t[0]){case Et.Empty:return[];case Et.Fork:return Tl(t[1]).concat(Tl(t[2]));default:return[t]}}Te.flatten_forks=Tl;function As(t,e){switch(e[0]){case Et.Labeled:return Gw(t,e[1])?{status:rn.Greater}:(0,yr.bufEquals)(t,e[1])?{status:qt.Found,value:e[2]}:{status:rn.Less};case Et.Fork:let r=As(t,e[1]);switch(r.status){case rn.Greater:{let n=As(t,e[2]);return n.status===rn.Less?{status:qt.Absent}:n}case qt.Unknown:{let n=As(t,e[2]);return n.status===rn.Less?{status:qt.Unknown}:n}default:return r}case Et.Pruned:return{status:qt.Unknown};default:return{status:qt.Absent}}}Te.find_label=As;function Ih(t){let{canisterId:e,subnetId:r,tree:n}=t,i=ba(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==qt.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return Ph.decode(i.value).map(c=>[El.Principal.fromUint8Array(c[0]),El.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}Te.check_canister_ranges=Ih});var Bs=ee(ut=>{"use strict";var zw=ut&&ut.__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]}),Dw=ut&&ut.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Zw=ut&&ut.__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)&&zw(e,t,r);return Dw(e,t),e};Object.defineProperty(ut,"__esModule",{value:!0});ut.encodePath=ut.fetchNodeKeys=ut.request=ut.CustomPath=void 0;var vn=Ut(),Jw=yi(),Tn=Oi(),Xw=Vt(),Mh=Zw(ys()),Uh=pa(),Al=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};ut.CustomPath=Al;var Qw=async t=>{let{agent:e,paths:r}=t,n=vn.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>(0,ut.encodePath)(c,n)),o=new Map,a=i.map((c,f)=>(async()=>{var d;try{let h=await e.readState(n,{paths:[s[f]]});if(e.rootKey==null)throw new Error("Agent is missing root key");let m=await Tn.Certificate.create({certificate:h.certificate,rootKey:e.rootKey,canisterId:n,disableTimeVerification:!0}),_=(T,P)=>{if(P==="subnet"){if(e.rootKey==null)throw new Error("Agent is missing root key");let F=(0,ut.fetchNodeKeys)(h.certificate,n,e.rootKey);return{path:P,data:F}}else return{path:P,data:(0,Tn.lookupResultToBuffer)(T.lookup((0,ut.encodePath)(P,n)))}},{path:u,data:O}=_(m,i[f]);if(!O)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,Uh.decodeTime)(O));break}case"controllers":{o.set(u,r2(O));break}case"module_hash":{o.set(u,Fh(O));break}case"subnet":{o.set(u,O);break}case"candid":{o.set(u,new TextDecoder().decode(O));break}default:if(typeof u!="string"&&"key"in u&&"path"in u)switch(u.decodeStrategy){case"raw":o.set(u.key,O);break;case"leb128":{o.set(u.key,(0,Uh.decodeLeb128)(O));break}case"cbor":{o.set(u.key,Ch(O));break}case"hex":{o.set(u.key,Fh(O));break}case"utf-8":o.set(u.key,t2(O))}}}catch(h){if(!((d=h?.message)===null||d===void 0)&&d.includes("Invalid certificate"))throw new Jw.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};ut.request=Qw;var Lw=(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=vn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=vn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=vn.Principal.selfAuthenticating(vn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,Tn.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,Tn.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==Tn.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let f=(0,Tn.flatten_forks)(c.value),d=new Map;return f.forEach(h=>{let m=vn.Principal.from(new Uint8Array(h[1])).toText(),_=(0,Tn.lookup_path)(["public_key"],h[2]);if(_.status!==Tn.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:vn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:d}};ut.fetchNodeKeys=Lw;var e2=(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.`)};ut.encodePath=e2;var Fh=t=>(0,Xw.toHex)(t),Ch=t=>Mh.decode(t),t2=t=>new TextDecoder().decode(t),r2=t=>Ch(t).map(r=>vn.Principal.fromUint8Array(new Uint8Array(r)))});var ip=ee(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.add5L=ye.add5H=ye.add4H=ye.add4L=ye.add3H=ye.add3L=ye.rotlBL=ye.rotlBH=ye.rotlSL=ye.rotlSH=ye.rotr32L=ye.rotr32H=ye.rotrBL=ye.rotrBH=ye.rotrSL=ye.rotrSH=ye.shrSL=ye.shrSH=ye.toBig=void 0;ye.fromBig=Bl;ye.split=qh;ye.add=Xh;var _a=BigInt(2**32-1),Sl=BigInt(32);function Bl(t,e=!1){return e?{h:Number(t&_a),l:Number(t>>Sl&_a)}:{h:Number(t>>Sl&_a)|0,l:Number(t&_a)|0}}function qh(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}=Bl(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}var jh=(t,e)=>BigInt(t>>>0)<<Sl|BigInt(e>>>0);ye.toBig=jh;var kh=(t,e,r)=>t>>>r;ye.shrSH=kh;var Hh=(t,e,r)=>t<<32-r|e>>>r;ye.shrSL=Hh;var Vh=(t,e,r)=>t>>>r|e<<32-r;ye.rotrSH=Vh;var $h=(t,e,r)=>t<<32-r|e>>>r;ye.rotrSL=$h;var Kh=(t,e,r)=>t<<64-r|e>>>r-32;ye.rotrBH=Kh;var Gh=(t,e,r)=>t>>>r-32|e<<64-r;ye.rotrBL=Gh;var Yh=(t,e)=>e;ye.rotr32H=Yh;var Wh=(t,e)=>t;ye.rotr32L=Wh;var zh=(t,e,r)=>t<<r|e>>>32-r;ye.rotlSH=zh;var Dh=(t,e,r)=>e<<r|t>>>32-r;ye.rotlSL=Dh;var Zh=(t,e,r)=>e<<r-32|t>>>64-r;ye.rotlBH=Zh;var Jh=(t,e,r)=>t<<r-32|e>>>64-r;ye.rotlBL=Jh;function Xh(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Qh=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);ye.add3L=Qh;var Lh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;ye.add3H=Lh;var ep=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);ye.add4L=ep;var tp=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;ye.add4H=tp;var rp=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);ye.add5L=rp;var np=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;ye.add5H=np;var n2={fromBig:Bl,split:qh,toBig:jh,shrSH:kh,shrSL:Hh,rotrSH:Vh,rotrSL:$h,rotrBH:Kh,rotrBL:Gh,rotr32H:Yh,rotr32L:Wh,rotlSH:zh,rotlSL:Dh,rotlBH:Zh,rotlBL:Jh,add:Xh,add3L:Qh,add3H:Lh,add4L:ep,add4H:tp,add5H:np,add5L:rp};ye.default=n2});var sp=ee(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.sha384=yt.sha512_256=yt.sha512_224=yt.sha512=yt.SHA384=yt.SHA512_256=yt.SHA512_224=yt.SHA512=void 0;var i2=zc(),be=ip(),va=kn(),[s2,o2]=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))),An=new Uint32Array(80),Sn=new Uint32Array(80),Wn=class extends i2.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:O,Hl:T}=this;return[e,r,n,i,s,o,a,c,f,d,h,m,_,u,O,T]}set(e,r,n,i,s,o,a,c,f,d,h,m,_,u,O,T){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=O|0,this.Hl=T|0}process(e,r){for(let A=0;A<16;A++,r+=4)An[A]=e.getUint32(r),Sn[A]=e.getUint32(r+=4);for(let A=16;A<80;A++){let K=An[A-15]|0,E=Sn[A-15]|0,j=be.default.rotrSH(K,E,1)^be.default.rotrSH(K,E,8)^be.default.shrSH(K,E,7),G=be.default.rotrSL(K,E,1)^be.default.rotrSL(K,E,8)^be.default.shrSL(K,E,7),z=An[A-2]|0,q=Sn[A-2]|0,oe=be.default.rotrSH(z,q,19)^be.default.rotrBH(z,q,61)^be.default.shrSH(z,q,6),Q=be.default.rotrSL(z,q,19)^be.default.rotrBL(z,q,61)^be.default.shrSL(z,q,6),ie=be.default.add4L(G,Q,Sn[A-7],Sn[A-16]),w=be.default.add4H(ie,j,oe,An[A-7],An[A-16]);An[A]=w|0,Sn[A]=ie|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:O,Gl:T,Hh:P,Hl:F}=this;for(let A=0;A<80;A++){let K=be.default.rotrSH(h,m,14)^be.default.rotrSH(h,m,18)^be.default.rotrBH(h,m,41),E=be.default.rotrSL(h,m,14)^be.default.rotrSL(h,m,18)^be.default.rotrBL(h,m,41),j=h&_^~h&O,G=m&u^~m&T,z=be.default.add5L(F,E,G,o2[A],Sn[A]),q=be.default.add5H(z,P,K,j,s2[A],An[A]),oe=z|0,Q=be.default.rotrSH(n,i,28)^be.default.rotrBH(n,i,34)^be.default.rotrBH(n,i,39),ie=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;P=O|0,F=T|0,O=_|0,T=u|0,_=h|0,u=m|0,{h,l:m}=be.default.add(f|0,d|0,q|0,oe|0),f=a|0,d=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let N=be.default.add3L(oe,ie,b);n=be.default.add3H(N,q,Q,w),i=N|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:O,l:T}=be.default.add(this.Gh|0,this.Gl|0,O|0,T|0),{h:P,l:F}=be.default.add(this.Hh|0,this.Hl|0,P|0,F|0),this.set(n,i,s,o,a,c,f,d,h,m,_,u,O,T,P,F)}roundClean(){An.fill(0),Sn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};yt.SHA512=Wn;var wa=class extends Wn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}};yt.SHA512_224=wa;var Ea=class extends Wn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}};yt.SHA512_256=Ea;var xa=class extends Wn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};yt.SHA384=xa;yt.sha512=(0,va.wrapConstructor)(()=>new Wn);yt.sha512_224=(0,va.wrapConstructor)(()=>new wa);yt.sha512_256=(0,va.wrapConstructor)(()=>new Ea);yt.sha384=(0,va.wrapConstructor)(()=>new xa)});var ap=ee(Nl=>{"use strict";Object.defineProperty(Nl,"__esModule",{value:!0});Nl.twistedEdwards=l2;var Ol=fl(),op=Mr(),Yt=Dt(),Xt=Dt(),gr=BigInt(0),Gt=BigInt(1),Ta=BigInt(2),a2=BigInt(8),c2={zip215:!0};function u2(t){let e=(0,Ol.validateBasic)(t);return Yt.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function l2(t){let e=u2(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=Ta<<BigInt(a*8)-Gt,d=r.create,h=(0,op.Field)(e.n,e.nBitLength),m=e.uvRatio||((B,R)=>{try{return{isValid:!0,value:r.sqrt(B*r.inv(R))}}catch{return{isValid:!1,value:gr}}}),_=e.adjustScalarBytes||(B=>B),u=e.domain||((B,R,V)=>{if((0,Xt.abool)("phflag",V),R.length||V)throw new Error("Contexts/pre-hash are not supported");return B});function O(B,R){Yt.aInRange("coordinate "+B,R,gr,f)}function T(B){if(!(B instanceof A))throw new Error("ExtendedPoint expected")}let P=(0,Xt.memoized)((B,R)=>{let{ex:V,ey:Z,ez:ce}=B,ae=B.is0();R==null&&(R=ae?a2:r.inv(ce));let D=d(V*R),M=d(Z*R),y=d(ce*R);if(ae)return{x:gr,y:Gt};if(y!==Gt)throw new Error("invZ was invalid");return{x:D,y:M}}),F=(0,Xt.memoized)(B=>{let{a:R,d:V}=e;if(B.is0())throw new Error("bad point: ZERO");let{ex:Z,ey:ce,ez:ae,et:D}=B,M=d(Z*Z),y=d(ce*ce),L=d(ae*ae),re=d(L*L),le=d(M*R),X=d(L*d(le+y)),l=d(re+d(V*d(M*y)));if(X!==l)throw new Error("bad point: equation left != right (1)");let p=d(Z*ce),g=d(ae*D);if(p!==g)throw new Error("bad point: equation left != right (2)");return!0});class A{constructor(R,V,Z,ce){this.ex=R,this.ey=V,this.ez=Z,this.et=ce,O("x",R),O("y",V),O("z",Z),O("t",ce),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(R){if(R instanceof A)throw new Error("extended point not allowed");let{x:V,y:Z}=R||{};return O("x",V),O("y",Z),new A(V,Z,Gt,d(V*Z))}static normalizeZ(R){let V=r.invertBatch(R.map(Z=>Z.ez));return R.map((Z,ce)=>Z.toAffine(V[ce])).map(A.fromAffine)}static msm(R,V){return(0,Ol.pippenger)(A,h,R,V)}_setWindowSize(R){j.setWindowSize(this,R)}assertValidity(){F(this)}equals(R){T(R);let{ex:V,ey:Z,ez:ce}=this,{ex:ae,ey:D,ez:M}=R,y=d(V*M),L=d(ae*ce),re=d(Z*M),le=d(D*ce);return y===L&&re===le}is0(){return this.equals(A.ZERO)}negate(){return new A(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:R}=e,{ex:V,ey:Z,ez:ce}=this,ae=d(V*V),D=d(Z*Z),M=d(Ta*d(ce*ce)),y=d(R*ae),L=V+Z,re=d(d(L*L)-ae-D),le=y+D,X=le-M,l=y-D,p=d(re*X),g=d(le*l),I=d(re*l),S=d(X*le);return new A(p,g,S,I)}add(R){T(R);let{a:V,d:Z}=e,{ex:ce,ey:ae,ez:D,et:M}=this,{ex:y,ey:L,ez:re,et:le}=R;if(V===BigInt(-1)){let J=d((ae-ce)*(L+y)),te=d((ae+ce)*(L-y)),de=d(te-J);if(de===gr)return this.double();let _e=d(D*Ta*le),Me=d(M*Ta*re),Ve=Me+_e,me=te+J,he=Me-_e,Je=d(Ve*de),vr=d(me*he),zr=d(Ve*he),Dr=d(de*me);return new A(Je,vr,Dr,zr)}let X=d(ce*y),l=d(ae*L),p=d(M*Z*le),g=d(D*re),I=d((ce+ae)*(y+L)-X-l),S=g-p,U=g+p,H=d(l-V*X),x=d(I*S),C=d(U*H),$=d(I*H),k=d(S*U);return new A(x,C,k,$)}subtract(R){return this.add(R.negate())}wNAF(R){return j.wNAFCached(this,R,A.normalizeZ)}multiply(R){let V=R;Yt.aInRange("scalar",V,Gt,n);let{p:Z,f:ce}=this.wNAF(V);return A.normalizeZ([Z,ce])[0]}multiplyUnsafe(R){let V=R;return Yt.aInRange("scalar",V,gr,n),V===gr?E:this.equals(E)||V===Gt?this:this.equals(K)?this.wNAF(V).p:j.unsafeLadder(this,V)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return j.unsafeLadder(this,n).is0()}toAffine(R){return P(this,R)}clearCofactor(){let{h:R}=e;return R===Gt?this:this.multiplyUnsafe(R)}static fromHex(R,V=!1){let{d:Z,a:ce}=e,ae=r.BYTES;R=(0,Xt.ensureBytes)("pointHex",R,ae),(0,Xt.abool)("zip215",V);let D=R.slice(),M=R[ae-1];D[ae-1]=M&-129;let y=Yt.bytesToNumberLE(D),L=V?f:r.ORDER;Yt.aInRange("pointHex.y",y,gr,L);let re=d(y*y),le=d(re-Gt),X=d(Z*re-ce),{isValid:l,value:p}=m(le,X);if(!l)throw new Error("Point.fromHex: invalid y coordinate");let g=(p&Gt)===Gt,I=(M&128)!==0;if(!V&&p===gr&&I)throw new Error("Point.fromHex: x=0 and x_0=1");return I!==g&&(p=d(-p)),A.fromAffine({x:p,y})}static fromPrivateKey(R){return q(R).point}toRawBytes(){let{x:R,y:V}=this.toAffine(),Z=Yt.numberToBytesLE(V,r.BYTES);return Z[Z.length-1]|=R&Gt?128:0,Z}toHex(){return Yt.bytesToHex(this.toRawBytes())}}A.BASE=new A(e.Gx,e.Gy,Gt,d(e.Gx*e.Gy)),A.ZERO=new A(gr,Gt,Gt,gr);let{BASE:K,ZERO:E}=A,j=(0,Ol.wNAF)(A,a*8);function G(B){return(0,op.mod)(B,n)}function z(B){return G(Yt.bytesToNumberLE(B))}function q(B){let R=a;B=(0,Xt.ensureBytes)("private key",B,R);let V=(0,Xt.ensureBytes)("hashed private key",s(B),2*R),Z=_(V.slice(0,R)),ce=V.slice(R,2*R),ae=z(Z),D=K.multiply(ae),M=D.toRawBytes();return{head:Z,prefix:ce,scalar:ae,point:D,pointBytes:M}}function oe(B){return q(B).pointBytes}function Q(B=new Uint8Array,...R){let V=Yt.concatBytes(...R);return z(s(u(V,(0,Xt.ensureBytes)("context",B),!!i)))}function ie(B,R,V={}){B=(0,Xt.ensureBytes)("message",B),i&&(B=i(B));let{prefix:Z,scalar:ce,pointBytes:ae}=q(R),D=Q(V.context,Z,B),M=K.multiply(D).toRawBytes(),y=Q(V.context,M,ae,B),L=G(D+y*ce);Yt.aInRange("signature.s",L,gr,n);let re=Yt.concatBytes(M,Yt.numberToBytesLE(L,r.BYTES));return(0,Xt.ensureBytes)("result",re,a*2)}let w=c2;function b(B,R,V,Z=w){let{context:ce,zip215:ae}=Z,D=r.BYTES;B=(0,Xt.ensureBytes)("signature",B,2*D),R=(0,Xt.ensureBytes)("message",R),ae!==void 0&&(0,Xt.abool)("zip215",ae),i&&(R=i(R));let M=Yt.bytesToNumberLE(B.slice(D,2*D)),y,L,re;try{y=A.fromHex(V,ae),L=A.fromHex(B.slice(0,D),ae),re=K.multiplyUnsafe(M)}catch{return!1}if(!ae&&y.isSmallOrder())return!1;let le=Q(ce,L.toRawBytes(),y.toRawBytes(),R);return L.add(y.multiplyUnsafe(le)).subtract(re).clearCofactor().equals(A.ZERO)}return K._setWindowSize(8),{CURVE:e,getPublicKey:oe,sign:ie,verify:b,ExtendedPoint:A,utils:{getExtendedPublicKey:q,randomPrivateKey:()=>o(r.BYTES),precompute(B=8,R=A.BASE){return R._setWindowSize(B),R.multiply(BigInt(3)),R}}}}});var up=ee(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});Pl.montgomery=d2;var cp=Mr(),Bn=Dt(),Ni=BigInt(0),Rl=BigInt(1);function f2(t){return(0,Bn.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function d2(t){let e=f2(t),{P:r}=e,n=F=>(0,cp.mod)(F,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(F=>F),c=e.powPminus2||(F=>(0,cp.pow)(F,r-BigInt(2),r));function f(F,A,K){let E=n(F*(A-K));return A=n(A-E),K=n(K+E),[A,K]}let d=(e.a-BigInt(2))/BigInt(4);function h(F,A){(0,Bn.aInRange)("u",F,Ni,r),(0,Bn.aInRange)("scalar",A,Ni,r);let K=A,E=F,j=Rl,G=Ni,z=F,q=Rl,oe=Ni,Q;for(let w=BigInt(i-1);w>=Ni;w--){let b=K>>w&Rl;oe^=b,Q=f(oe,j,z),j=Q[0],z=Q[1],Q=f(oe,G,q),G=Q[0],q=Q[1],oe=b;let N=j+G,B=n(N*N),R=j-G,V=n(R*R),Z=B-V,ce=z+q,ae=z-q,D=n(ae*N),M=n(ce*R),y=D+M,L=D-M;z=n(y*y),q=n(E*n(L*L)),j=n(B*V),G=n(Z*(B+n(d*Z)))}Q=f(oe,j,z),j=Q[0],z=Q[1],Q=f(oe,G,q),G=Q[0],q=Q[1];let ie=c(G);return n(j*ie)}function m(F){return(0,Bn.numberToBytesLE)(n(F),s)}function _(F){let A=(0,Bn.ensureBytes)("u coordinate",F,s);return o===32&&(A[31]&=127),(0,Bn.bytesToNumberLE)(A)}function u(F){let A=(0,Bn.ensureBytes)("scalar",F),K=A.length;if(K!==s&&K!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${K}`);return(0,Bn.bytesToNumberLE)(a(A))}function O(F,A){let K=_(A),E=u(F),j=h(K,E);if(j===Ni)throw new Error("Invalid private or public key received");return m(j)}let T=m(e.Gu);function P(F){return O(F,T)}return{scalarMult:O,scalarMultBase:P,getSharedSecret:(F,A)=>O(F,A),getPublicKey:F=>P(F),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:T}}});var kl=ee(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=_p;ge.edwardsToMontgomeryPriv=y2;var Sa=sp(),Os=kn(),Cl=ap(),hp=sa(),Ue=Mr(),h2=up(),zn=Dt(),Ns=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Fl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),p2=BigInt(0),Cr=BigInt(1),Aa=BigInt(2),pp=BigInt(3),yp=BigInt(5),ql=BigInt(8);function gp(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=Ns,a=t*t%s*t%s,c=(0,Ue.pow2)(a,Aa,s)*a%s,f=(0,Ue.pow2)(c,Cr,s)*t%s,d=(0,Ue.pow2)(f,yp,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,O=(0,Ue.pow2)(u,i,s)*_%s,T=(0,Ue.pow2)(O,e,s)*d%s;return{pow_p_5_8:(0,Ue.pow2)(T,Aa,s)*t%s,b2:a}}function mp(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function jl(t,e){let r=Ns,n=(0,Ue.mod)(e*e*e,r),i=(0,Ue.mod)(n*n*e,r),s=gp(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*Fl,r),d=a===t,h=a===(0,Ue.mod)(-t,r),m=a===(0,Ue.mod)(-t*Fl,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 ue=(0,Ue.Field)(Ns,void 0,!0),Rs={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ue,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:ql,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Sa.sha512,randomBytes:Os.randomBytes,adjustScalarBytes:mp,uvRatio:jl};ge.ed25519=(0,Cl.twistedEdwards)(Rs);function bp(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,Os.concatBytes)((0,Os.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}ge.ed25519ctx=(0,Cl.twistedEdwards)({...Rs,domain:bp});ge.ed25519ph=(0,Cl.twistedEdwards)(Object.assign({},Rs,{domain:bp,prehash:Sa.sha512}));ge.x25519=(0,h2.montgomery)({P:Ns,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=Ns,{pow_p_5_8:r,b2:n}=gp(t);return(0,Ue.mod)((0,Ue.pow2)(r,pp,e)*n,e)},adjustScalarBytes:mp,randomBytes:Os.randomBytes});function _p(t){let{y:e}=ge.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return ue.toBytes(ue.create((r+e)*ue.inv(r-e)))}ge.edwardsToMontgomery=_p;function y2(t){let e=Rs.hash(t.subarray(0,32));return Rs.adjustScalarBytes(e).subarray(0,32)}var g2=(ue.ORDER+pp)/ql,m2=ue.pow(Aa,g2),lp=ue.sqrt(ue.neg(ue.ONE));function b2(t){let e=(ue.ORDER-yp)/ql,r=BigInt(486662),n=ue.sqr(t);n=ue.mul(n,Aa);let i=ue.add(n,ue.ONE),s=ue.neg(r),o=ue.sqr(i),a=ue.mul(o,i),c=ue.mul(n,r);c=ue.mul(c,s),c=ue.add(c,o),c=ue.mul(c,s);let f=ue.sqr(a);o=ue.sqr(f),f=ue.mul(f,a),f=ue.mul(f,c),o=ue.mul(o,f);let d=ue.pow(o,e);d=ue.mul(d,f);let h=ue.mul(d,lp);o=ue.sqr(d),o=ue.mul(o,a);let m=ue.eql(o,c),_=ue.cmov(h,d,m),u=ue.mul(s,n),O=ue.mul(d,t);O=ue.mul(O,m2);let T=ue.mul(O,lp),P=ue.mul(c,n);o=ue.sqr(O),o=ue.mul(o,a);let F=ue.eql(o,P),A=ue.cmov(T,O,F);o=ue.sqr(_),o=ue.mul(o,a);let K=ue.eql(o,c),E=ue.cmov(u,s,K),j=ue.cmov(A,_,K),G=ue.isOdd(j);return j=ue.cmov(j,ue.neg(j),K!==G),{xMn:E,xMd:i,yMn:j,yMd:Cr}}var _2=(0,Ue.FpSqrtEven)(ue,ue.neg(BigInt(486664)));function w2(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=b2(t),s=ue.mul(e,i);s=ue.mul(s,_2);let o=ue.mul(r,n),a=ue.sub(e,r),c=ue.add(e,r),f=ue.mul(o,c),d=ue.eql(f,ue.ZERO);s=ue.cmov(s,ue.ZERO,d),o=ue.cmov(o,ue.ONE,d),a=ue.cmov(a,ue.ONE,d),c=ue.cmov(c,ue.ONE,d);let h=ue.invertBatch([o,c]);return{x:ue.mul(s,h[0]),y:ue.mul(a,h[1])}}var wp=(0,hp.createHasher)(ge.ed25519.ExtendedPoint,t=>w2(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:ue.ORDER,m:1,k:128,expand:"xmd",hash:Sa.sha512});ge.hashToCurve=wp.hashToCurve;ge.encodeToCurve=wp.encodeToCurve;function Il(t){if(!(t instanceof mr))throw new Error("RistrettoPoint expected")}var Ml=Fl,E2=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),x2=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),v2=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),T2=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),fp=t=>jl(Cr,t),A2=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Ul=t=>ge.ed25519.CURVE.Fp.create((0,zn.bytesToNumberLE)(t)&A2);function dp(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+Cr)*v2),o=BigInt(-1),a=n((o-e*i)*n(i+e)),{isValid:c,value:f}=jl(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-Cr)*T2-a),m=f*f,_=n((f+f)*a),u=n(h*E2),O=n(Cr-m),T=n(Cr+m);return new ge.ed25519.ExtendedPoint(n(_*T),n(O*u),n(u*T),n(_*O))}var mr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(ge.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,zn.ensureBytes)("ristrettoHash",e,64);let r=Ul(e.slice(0,32)),n=dp(r),i=Ul(e.slice(32,64)),s=dp(i);return new t(n.add(s))}static fromHex(e){e=(0,zn.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=Ul(e);if(!(0,zn.equalBytes)((0,zn.numberToBytesLE)(a,32),e)||(0,Ue.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),f=s(Cr+r*c),d=s(Cr-r*c),h=s(f*f),m=s(d*d),_=s(r*n*h-m),{isValid:u,value:O}=fp(s(_*m)),T=s(O*d),P=s(O*T*_),F=s((a+a)*T);(0,Ue.isNegativeLE)(F,i)&&(F=s(-F));let A=s(f*P),K=s(F*A);if(!u||(0,Ue.isNegativeLE)(K,i)||A===p2)throw new Error(o);return new t(new ge.ed25519.ExtendedPoint(F,A,Cr,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}=fp(o(a*f)),h=o(d*a),m=o(d*c),_=o(h*m*i),u;if((0,Ue.isNegativeLE)(i*_,s)){let T=o(r*Ml),P=o(e*Ml);e=T,r=P,u=o(h*x2)}else u=m;(0,Ue.isNegativeLE)(e*_,s)&&(r=o(-r));let O=o((n-r)*u);return(0,Ue.isNegativeLE)(O,s)&&(O=o(-O)),(0,zn.numberToBytesLE)(O,32)}toHex(){return(0,zn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){Il(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 Il(e),new t(this.ep.add(e.ep))}subtract(e){return Il(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=(mr.BASE||(mr.BASE=new mr(ge.ed25519.ExtendedPoint.BASE)),mr.ZERO||(mr.ZERO=new mr(ge.ed25519.ExtendedPoint.ZERO)),mr);var S2=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,Os.utf8ToBytes)(r):r,i=(0,hp.expand_message_xmd)(t,n,64,Sa.sha512);return mr.hashToCurve(i)};ge.hashToRistretto255=S2;ge.hash_to_ristretto255=ge.hashToRistretto255});var Tp=ee(On=>{"use strict";var Ep=On&&On.__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},jt=On&&On.__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)},Nt,Ps,xp,vp;Object.defineProperty(On,"__esModule",{value:!0});On.ExpirableMap=void 0;var Hl=class{constructor(e={}){Nt.set(this,void 0),Ps.set(this,void 0),this[xp]=this.entries.bind(this),this[vp]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();Ep(this,Nt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),Ep(this,Ps,n,"f")}prune(){let e=Date.now();for(let[r,n]of jt(this,Nt,"f").entries())e-n.timestamp>jt(this,Ps,"f")&&jt(this,Nt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return jt(this,Nt,"f").set(e,n),this}get(e){let r=jt(this,Nt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>jt(this,Ps,"f")){jt(this,Nt,"f").delete(e);return}return r.value}}clear(){jt(this,Nt,"f").clear()}entries(){let e=jt(this,Nt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=jt(this,Nt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return jt(this,Nt,"f").keys()}forEach(e,r){for(let[n,i]of jt(this,Nt,"f").entries())e.call(r,i.value,n,this)}has(e){return jt(this,Nt,"f").has(e)}delete(e){return jt(this,Nt,"f").delete(e)}get size(){return jt(this,Nt,"f").size}};On.ExpirableMap=Hl;Nt=new WeakMap,Ps=new WeakMap,xp=Symbol.iterator,vp=Symbol.toStringTag});var Vl=ee(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.unwrapDER=je.wrapDER=je.SECP256K1_OID=je.ED25519_OID=je.DER_COSE_OID=je.decodeLen=je.decodeLenBytes=je.encodeLen=je.encodeLenBytes=void 0;var B2=Vt(),O2=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=O2;var N2=(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=N2;var R2=(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=R2;var P2=(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=P2;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 I2(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=I2;var U2=(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,B2.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=U2});var $l=ee(Nn=>{"use strict";var Ap=Nn&&Nn.__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},Sp=Nn&&Nn.__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)},Oa,Na;Object.defineProperty(Nn,"__esModule",{value:!0});Nn.Ed25519PublicKey=void 0;var Ba=Vl(),Ra=class t{constructor(e){if(Oa.set(this,void 0),Na.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Ap(this,Oa,e,"f"),Ap(this,Na,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,Ba.wrapDER)(e,Ba.ED25519_OID).buffer}static derDecode(e){let r=(0,Ba.unwrapDER)(e,Ba.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 Sp(this,Oa,"f")}get derKey(){return Sp(this,Na,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Nn.Ed25519PublicKey=Ra;Oa=new WeakMap,Na=new WeakMap;Ra.RAW_KEY_LENGTH=32});var Gl=ee(Ri=>{"use strict";Object.defineProperty(Ri,"__esModule",{value:!0});Ri.ObservableLog=Ri.Observable=void 0;var Pa=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))}};Ri.Observable=Pa;var Kl=class extends Pa{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)}};Ri.ObservableLog=Kl});var Up=ee(kr=>{"use strict";var qr=kr&&kr.__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},Rt=kr&&kr.__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,Ia,Ua,Fa,Ma,Ca,qa,ja,Pi;Object.defineProperty(kr,"__esModule",{value:!0});kr.exponentialBackoff=kr.ExponentialBackoff=void 0;var Bp=.5,Op=1.5,Np=500,Rp=6e4,Pp=9e5,Ip=10,Ii=class t{constructor(e=t.default){jr.set(this,void 0),Ia.set(this,void 0),Ua.set(this,void 0),Fa.set(this,void 0),Ma.set(this,void 0),Ca.set(this,void 0),qa.set(this,void 0),ja.set(this,void 0),Pi.set(this,0);let{initialInterval:r=Np,randomizationFactor:n=Bp,multiplier:i=Op,maxInterval:s=Rp,maxElapsedTime:o=Pp,maxIterations:a=Ip,date:c=Date}=e;qr(this,jr,r,"f"),qr(this,Ia,n,"f"),qr(this,Ua,i,"f"),qr(this,Fa,s,"f"),qr(this,ja,c,"f"),qr(this,Ma,c.now(),"f"),qr(this,Ca,o,"f"),qr(this,qa,a,"f")}get ellapsedTimeInMsec(){return Rt(this,ja,"f").now()-Rt(this,Ma,"f")}get currentInterval(){return Rt(this,jr,"f")}get count(){return Rt(this,Pi,"f")}get randomValueFromInterval(){let e=Rt(this,Ia,"f")*Rt(this,jr,"f"),r=Rt(this,jr,"f")-e,n=Rt(this,jr,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return qr(this,jr,Math.min(Rt(this,jr,"f")*Rt(this,Ua,"f"),Rt(this,Fa,"f")),"f"),qr(this,Pi,(e=Rt(this,Pi,"f"),e++,e),"f"),Rt(this,jr,"f")}next(){return this.ellapsedTimeInMsec>=Rt(this,Ca,"f")||Rt(this,Pi,"f")>=Rt(this,qa,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};kr.ExponentialBackoff=Ii;jr=new WeakMap,Ia=new WeakMap,Ua=new WeakMap,Fa=new WeakMap,Ma=new WeakMap,Ca=new WeakMap,qa=new WeakMap,ja=new WeakMap,Pi=new WeakMap;Ii.default={initialInterval:Np,randomizationFactor:Bp,multiplier:Op,maxInterval:Rp,maxElapsedTime:Pp,maxIterations:Ip,date:Date};function*F2(t=Ii.default){let e=new Ii(t),r=e.next();for(;r;)yield r,r=e.next()}kr.exponentialBackoff=F2});var zl=ee(Fe=>{"use strict";var Mp=Fe&&Fe.__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]}),M2=Fe&&Fe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Cp=Fe&&Fe.__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 M2(e,t),e},qp=Fe&&Fe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Mp(e,t,r)},xt=Fe&&Fe.__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},ne=Fe&&Fe.__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)},Pt,Dn,ji,Hr,nn,qi,Is,Fi,_r,wr,Zn,Jn,Us,Mi,Ci,Xn,Ln,jp,Va,$a,Qn;Object.defineProperty(Fe,"__esModule",{value:!0});Fe.HttpAgent=Fe.IdentityInvalidError=Fe.MANAGEMENT_CANISTER_ID=Fe.IC_ROOT_KEY=Fe.RequestStatusResponseStatus=Fe.makeNonce=void 0;var sr=Ut(),Vr=yi(),Fp=Hu(),Rn=Cp(ys()),ka=ds(),br=Vt(),Er=Xo(),Yl=gs(),ki=Lo(),C2=Bs(),Ui=Oi(),q2=kl(),j2=Tp(),k2=$l(),H2=pa(),V2=Gl(),$2=Up();qp(Xo(),Fe);qp(Lo(),Fe);var K2=gs();Object.defineProperty(Fe,"makeNonce",{enumerable:!0,get:function(){return K2.makeNonce}});var G2;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(G2=Fe.RequestStatusResponseStatus||(Fe.RequestStatusResponseStatus={}));var Ha=60*1e3;Fe.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Fe.MANAGEMENT_CANISTER_ID="aaaaa-aa";var Y2="ic0.app",W2=".ic0.app",z2="icp0.io",D2=".icp0.io",Z2="icp-api.io",J2=".icp-api.io",Fs=class extends Vr.AgentError{constructor(e){super(e),this.message=e}},ei=class extends Vr.AgentError{constructor(e){super(e),this.message=e}};Fe.IdentityInvalidError=ei;function X2(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Fs("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 Fs("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 Fs("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function Q2(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 Wl=class t{constructor(e={}){var r,n;Pt.add(this),Dn.set(this,null),ji.set(this,!1),Hr.set(this,void 0),nn.set(this,void 0),qi.set(this,void 0),Is.set(this,void 0),Fi.set(this,0),_r.set(this,void 0),wr.set(this,void 0),Zn.set(this,void 0),Jn.set(this,void 0),this._isAgent=!0,this.config={},Us.set(this,0),this.log=new V2.ObservableLog,Mi.set(this,[]),Ci.set(this,[]),Xn.set(this,new j2.ExpirableMap({expirationTime:5*60*1e3})),Ln.set(this,!0),$a.set(this,(o,a)=>{if(ne(this,Ln,"f")===!1)return o;if(!a)throw new Ui.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:c,signatures:f=[],requestId:d}=o,h=new TextEncoder().encode("\vic-response");for(let m of f){let{timestamp:_,identity:u}=m,O=sr.Principal.fromUint8Array(u).toText(),T;if(c==="replied"){let{reply:E}=o;T=(0,ka.hashOfMap)({status:c,reply:E,timestamp:BigInt(_),request_id:d})}else if(c==="rejected"){let{reject_code:E,reject_message:j,error_code:G}=o;T=(0,ka.hashOfMap)({status:c,reject_code:E,reject_message:j,error_code:G,timestamp:BigInt(_),request_id:d})}else throw new Error(`Unknown status: ${c}`);let P=(0,br.concat)(h,new Uint8Array(T)),F=a?.nodeKeys.get(O);if(!F)throw new Ui.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let A=k2.Ed25519PublicKey.fromDer(F).rawKey;if(q2.ed25519.verify(m.signature,new Uint8Array(P),new Uint8Array(A)))return o;throw new Ui.CertificateVerificationError(`Invalid signature from replica ${O} signed query.`)}return o}),this.config=e,xt(this,nn,e.fetch||X2()||fetch.bind(global),"f"),xt(this,qi,e.fetchOptions,"f"),xt(this,Is,e.callOptions,"f"),xt(this,ji,(r=e.shouldFetchRootKey)!==null&&r!==void 0?r:!1,"f"),e.rootKey?this.rootKey=e.rootKey:ne(this,ji,"f")?this.rootKey=null:this.rootKey=(0,br.fromHex)(Fe.IC_ROOT_KEY);let i=Q2(e.host);this.host=new URL(i),e.verifyQuerySignatures!==void 0&&xt(this,Ln,e.verifyQuerySignatures,"f"),xt(this,wr,(n=e.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new $2.ExponentialBackoff({maxIterations:ne(this,wr,"f")});if(xt(this,Zn,e.backoffStrategy||s,"f"),this.host.hostname.endsWith(W2)?this.host.hostname=Y2:this.host.hostname.endsWith(D2)?this.host.hostname=z2:this.host.hostname.endsWith(J2)&&(this.host.hostname=Z2),e.credentials){let{name:o,password:a}=e.credentials;xt(this,_r,`${o}${a?":"+a:""}`,"f")}if(xt(this,Hr,Promise.resolve(e.identity||new Fp.AnonymousIdentity),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new Vr.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 Vr.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);xt(this,Jn,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,Er.makeNonceTransform)(Yl.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,Er.makeNonceTransform)(Yl.makeNonce)),e.logToConsole&&this.log.subscribe(o=>{o.level==="error"?console.error(o.message):o.level==="warn"?console.warn(o.message):console.log(o.message)})}get waterMark(){return ne(this,Us,"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 Vr.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=ne(this,Ci,"f").findIndex(s=>(s.priority||0)<n);ne(this,Ci,"f").splice(i>=0?i:ne(this,Ci,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ne(this,Mi,"f").findIndex(s=>(s.priority||0)<n);ne(this,Mi,"f").splice(i>=0?i:ne(this,Mi,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ne(this,Hr,"f"))throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ne(this,Hr,"f")).getPrincipal()}async call(e,r,n){var i,s;await ne(this,Pt,"m",Qn).call(this);let o=(i=r.callSync)!==null&&i!==void 0?i:!0,a=await(n!==void 0?await n:await ne(this,Hr,"f"));if(!a)throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");let c=sr.Principal.from(e),f=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):c,d=a.getPrincipal()||sr.Principal.anonymous(),h=new Er.Expiry(ne(this,Jn,"f")*Ha);Math.abs(ne(this,Fi,"f"))>1e3*30&&(h=new Er.Expiry(ne(this,Jn,"f")*Ha+ne(this,Fi,"f")));let m={request_type:Yl.SubmitRequestType.Call,canister_id:c,method_name:r.methodName,arg:r.arg,sender:d,ingress_expiry:h},_=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,_r,"f")?{Authorization:"Basic "+btoa(ne(this,_r,"f"))}:{})},endpoint:"call",body:m}),u=_.body.nonce?O(_.body.nonce):void 0;m.nonce=u;function O(A){return new Uint8Array(A)}_=await a.transformRequest(_);let T=Rn.encode(_.body),P=ne(this,Zn,"f").call(this),F=(0,ka.requestIdOf)(m);try{let A=()=>(this.log.print(`fetching "/api/v3/canister/${f.toText()}/call" with request:`,_),ne(this,nn,"f").call(this,""+new URL(`/api/v3/canister/${f.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Is,"f")),_.request),{body:T}))),K=()=>(this.log.print(`fetching "/api/v2/canister/${f.toText()}/call" with request:`,_),ne(this,nn,"f").call(this,""+new URL(`/api/v2/canister/${f.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Is,"f")),_.request),{body:T}))),j=await ne(this,Pt,"m",Va).call(this,{request:o?A:K,backoff:P,tries:0}),G=await j.arrayBuffer(),z=j.status===200&&G.byteLength>0?Rn.decode(G):null;if(z&&"certificate"in z){let q=await this.parseTimeFromResponse({certificate:z.certificate});xt(this,Us,q,"f")}return{requestId:F,response:{ok:j.ok,status:j.status,statusText:j.statusText,body:z,headers:(0,Er.httpHeadersTransform)(j.headers)},requestDetails:m}}catch(A){if(A.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);let K=`Error while making call: ${(s=A.message)!==null&&s!==void 0?s:String(A)}`,E=new ki.AgentCallError(K,A,(0,br.toHex)(F),(0,br.toHex)(_.body.sender_pubkey),(0,br.toHex)(_.body.sender_sig),String(_.body.content.ingress_expiry._value));throw this.log.error(K,E),E}}async query(e,r,n){var i,s,o,a;await ne(this,Pt,"m",Qn).call(this);let c=ne(this,Zn,"f").call(this),f=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):sr.Principal.from(e);this.log.print(`ecid ${f.toString()}`),this.log.print(`canisterId ${e.toString()}`);let d,h,m=await(n!==void 0?n:ne(this,Hr,"f"));if(!m)throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");let _=sr.Principal.from(e),u=m?.getPrincipal()||sr.Principal.anonymous(),O={request_type:"query",canister_id:_,method_name:r.methodName,arg:r.arg,sender:u,ingress_expiry:new Er.Expiry(ne(this,Jn,"f")*Ha)},T=(0,ka.requestIdOf)(O);d=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,_r,"f")?{Authorization:"Basic "+btoa(ne(this,_r,"f"))}:{})},endpoint:"read",body:O}),d=await m?.transformRequest(d);let P=Rn.encode(d.body),F={canister:_.toText(),ecid:f,transformedRequest:d,body:P,requestId:T,backoff:c,tries:0},A=async()=>({requestDetails:O,query:await ne(this,Pt,"m",jp).call(this,F)}),K=async()=>{if(!ne(this,Ln,"f"))return;let E=ne(this,Xn,"f").get(f.toString());return E||(await this.fetchSubnetKeys(f.toString()),ne(this,Xn,"f").get(f.toString()))};try{let[E,j]=await Promise.all([A(),K()]);h=E;let{requestDetails:G,query:z}=h,q=Object.assign(Object.assign({},z),{requestDetails:G});if(this.log.print("Query response:",q),!ne(this,Ln,"f"))return q;try{return ne(this,$a,"f").call(this,q,j)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ne(this,Xn,"f").delete(e.toString()),await this.fetchSubnetKeys(f.toString());let Q=ne(this,Xn,"f").get(e.toString());if(!Q)throw new Ui.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ne(this,$a,"f").call(this,q,Q)}}catch(E){let j=`Error while making call: ${(i=E.message)!==null&&i!==void 0?i:String(E)}`,G=new ki.AgentQueryError(j,E,String(T),(0,br.toHex)((s=d?.body)===null||s===void 0?void 0:s.sender_pubkey),(0,br.toHex)((o=d?.body)===null||o===void 0?void 0:o.sender_sig),String((a=d?.body)===null||a===void 0?void 0:a.content.ingress_expiry._value));throw this.log.error(j,G),G}}async createReadStateRequest(e,r){await ne(this,Pt,"m",Qn).call(this);let n=await(r!==void 0?await r:await ne(this,Hr,"f"));if(!n)throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||sr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,_r,"f")?{Authorization:"Basic "+btoa(ne(this,_r,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Er.Expiry(ne(this,Jn,"f")*Ha)}});return n?.transformRequest(s)}async readState(e,r,n,i){var s,o,a,c;function f(O){for(let T of O.paths){let[P,F]=T,A=new TextEncoder().encode("request_status");if((0,br.bufEquals)(P,A))return F}}let d=f(r);await ne(this,Pt,"m",Qn).call(this);let h=typeof e=="string"?sr.Principal.fromText(e):e,m=i??await this.createReadStateRequest(r,n),_=Rn.encode(m.body);this.log.print(`fetching "/api/v2/canister/${h}/read_state" with request:`,m);let u=ne(this,Zn,"f").call(this);try{let O=await ne(this,Pt,"m",Va).call(this,{request:()=>ne(this,nn,"f").call(this,""+new URL(`/api/v2/canister/${h.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,qi,"f")),m.request),{body:_})),backoff:u,tries:0});if(!O.ok)throw new Error(`Server returned an error:
|
|
31
31
|
Code: ${O.status} (${O.statusText})
|
|
32
32
|
Body: ${await O.text()}
|
|
33
|
-
`);let T=Rn.decode(await O.arrayBuffer());this.log.print("Read state response:",T);let P=await this.parseTimeFromResponse(T);return P>0&&(this.log.print("Read state response time:",P),xt(this,Us,P,"f")),T}catch(O){let T=`Caught exception while attempting to read state: ${(s=O.message)!==null&&s!==void 0?s:String(O)}`,P=new
|
|
33
|
+
`);let T=Rn.decode(await O.arrayBuffer());this.log.print("Read state response:",T);let P=await this.parseTimeFromResponse(T);return P>0&&(this.log.print("Read state response time:",P),xt(this,Us,P,"f")),T}catch(O){let T=`Caught exception while attempting to read state: ${(s=O.message)!==null&&s!==void 0?s:String(O)}`,P=new ki.AgentReadStateError(T,O,String(d),(0,br.toHex)((o=m?.body)===null||o===void 0?void 0:o.sender_pubkey),(0,br.toHex)((a=m?.body)===null||a===void 0?void 0:a.sender_sig),String((c=m?.body)===null||c===void 0?void 0:c.content.ingress_expiry._value));throw this.log.error(T,P),P}}async parseTimeFromResponse(e){let r;if(e.certificate){let n=Rn.decode(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,Ui.lookup_path)(["time"],r);if(i.status!==Ui.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,H2.decodeTime)((0,br.bufFromBufLike)(i.value));return this.log.print("Time from response:",s),this.log.print("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){await ne(this,Pt,"m",Qn).call(this);let r=await Promise.resolve().then(()=>Cp(Bs())),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 i=t.createSync({identity:new Fp.AnonymousIdentity,host:this.host.toString(),fetch:ne(this,nn,"f"),retryTimes:0}),o=(await r.request({canisterId:e??sr.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:i,paths:["time"]})).get("time");o&&(xt(this,Fi,Number(o)-Number(n),"f"),this.log.notify({message:`Syncing time: offset of ${ne(this,Fi,"f")}`,level:"info"}))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=ne(this,_r,"f")?{Authorization:"Basic "+btoa(ne(this,_r,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ne(this,Zn,"f").call(this),n=await ne(this,Pt,"m",Va).call(this,{backoff:r,request:()=>ne(this,nn,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:e},ne(this,qi,"f"))),tries:0});return Rn.decode(await n.arrayBuffer())}async fetchRootKey(){let e;return ne(this,Dn,"f")?e=await ne(this,Dn,"f"):(xt(this,Dn,new Promise((r,n)=>{this.status().then(i=>{let s=i.root_key;this.rootKey=s,r(s)}).catch(n)}),"f"),e=await ne(this,Dn,"f")),xt(this,Dn,null,"f"),e}invalidateIdentity(){xt(this,Hr,null,"f")}replaceIdentity(e){xt(this,Hr,Promise.resolve(e),"f")}async fetchSubnetKeys(e){await ne(this,Pt,"m",Qn).call(this);let r=sr.Principal.from(e),i=(await(0,C2.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ne(this,Xn,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of ne(this,Ci,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ne(this,Mi,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Fe.HttpAgent=Wl;Dn=new WeakMap,ji=new WeakMap,Hr=new WeakMap,nn=new WeakMap,qi=new WeakMap,Is=new WeakMap,Fi=new WeakMap,_r=new WeakMap,wr=new WeakMap,Zn=new WeakMap,Jn=new WeakMap,Us=new WeakMap,Mi=new WeakMap,Ci=new WeakMap,Xn=new WeakMap,Ln=new WeakMap,$a=new WeakMap,Pt=new WeakSet,jp=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 Vr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,wr,"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 ne(this,nn,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,qi,"f")),s.request),{body:o}));if(u.status===200){let O=Rn.decode(await u.arrayBuffer());h=Object.assign(Object.assign({},O),{httpDetails:{ok:u.ok,status:u.status,statusText:u.statusText,headers:(0,Er.httpHeadersTransform)(u.headers)},requestId:a})}else throw new ki.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,Er.httpHeadersTransform)(u.headers)})}catch(u){if(f<ne(this,wr,"f"))return this.log.warn(`Caught exception while attempting to make query:
|
|
37
37
|
${u}
|
|
38
|
-
Retrying query.`),await ne(this,Pt,"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(!ne(this,Ln,"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 Vr.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",u,{timestamp:m,waterMark:this.waterMark}),f<ne(this,wr,"f"))return await ne(this,Pt,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw new Vr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,wr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return h},
|
|
38
|
+
Retrying query.`),await ne(this,Pt,"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(!ne(this,Ln,"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 Vr.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",u,{timestamp:m,waterMark:this.waterMark}),f<ne(this,wr,"f"))return await ne(this,Pt,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw new Vr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,wr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return h},Va=async function t(e){let{request:r,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new Vr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,wr,"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(ne(this,wr,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
|
|
39
39
|
${f}
|
|
40
40
|
Retrying request.`),await ne(this,Pt,"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 ki.AgentHTTPResponseError("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,Er.httpHeadersTransform)(o.headers)});if(i<ne(this,wr,"f"))return await ne(this,Pt,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new ki.AgentHTTPResponseError(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,Er.httpHeadersTransform)(o.headers)})},Qn=async function(){if(!this.rootKey)if(this.rootKey===null&&ne(this,ji,"f"))await this.fetchRootKey();else throw new Vr.AgentError(`Invalid root key detected. The root key for this agent is ${this.rootKey} and the shouldFetchRootKey value is set to ${ne(this,ji,"f")}. The root key should only be unknown if you are in local development. Otherwise you should avoid fetching and use the default IC Root Key or the known root key of your environment.`)}});var kp=ee(sn=>{"use strict";Object.defineProperty(sn,"__esModule",{value:!0});sn.ProxyAgent=sn.ProxyStubAgent=sn.ProxyMessageKind=void 0;var L2=Ut(),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=sn.ProxyMessageKind||(sn.ProxyMessageKind={}));var Dl=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)}`)}}};sn.ProxyStubAgent=Dl;var Zl=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 L2.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}};sn.ProxyAgent=Zl});var Ss=ee(or=>{"use strict";var eE=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]}),Ka=or&&or.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&eE(e,t,r)};Object.defineProperty(or,"__esModule",{value:!0});or.getDefaultAgent=void 0;Ka(Hc(),or);Ka(zl(),or);Ka(Lo(),or);Ka(kp(),or);function tE(){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=tE});var Ga=ee(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.chain=gt.backoff=gt.timeout=gt.throttle=gt.maxAttempts=gt.conditionalDelay=gt.once=gt.defaultStrategy=void 0;var Hp=Vt(),rE=5*60*1e3;function nE(){return Yp($p(Vp(),1e3),Gp(1e3,1.2),Kp(rE))}gt.defaultStrategy=nE;function Vp(){let t=!0;return async()=>t?(t=!1,!0):!1}gt.once=Vp;function $p(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}gt.conditionalDelay=$p;function iE(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,Hp.toHex)(n)}
|
|
45
45
|
Request status: ${i}
|
|
46
|
-
`)}}gt.maxAttempts=
|
|
47
|
-
Request ID: ${(0,
|
|
46
|
+
`)}}gt.maxAttempts=iE;function sE(t){return()=>new Promise(e=>setTimeout(e,t))}gt.throttle=sE;function Kp(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,Hp.toHex)(n)}
|
|
48
48
|
Request status: ${i}
|
|
49
|
-
`)}}gt.timeout=
|
|
50
|
-
Request ID: ${(0,
|
|
49
|
+
`)}}gt.timeout=Kp;function Gp(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}gt.backoff=Gp;function Yp(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}gt.chain=Yp});var Ya=ee(Wt=>{"use strict";var oE=Wt&&Wt.__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]}),aE=Wt&&Wt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),cE=Wt&&Wt.__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)&&oE(e,t,r);return aE(e,t),e};Object.defineProperty(Wt,"__esModule",{value:!0});Wt.pollForResponse=Wt.defaultStrategy=Wt.strategy=void 0;var ti=Ss(),Ms=Oi(),Wp=Vt();Wt.strategy=cE(Ga());var uE=Ga(),lE=Ga();Object.defineProperty(Wt,"defaultStrategy",{enumerable:!0,get:function(){return lE.defaultStrategy}});async function zp(t,e,r,n=(0,uE.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]})),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 Ms.Certificate.create({certificate:f.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),h=(0,Ms.lookupResultToBuffer)(d.lookup([...a,new TextEncoder().encode("status")])),m;switch(typeof h>"u"?m=ti.RequestStatusResponseStatus.Unknown:m=new TextDecoder().decode(h),m){case ti.RequestStatusResponseStatus.Replied:return{reply:(0,Ms.lookupResultToBuffer)(d.lookup([...a,"reply"])),certificate:d};case ti.RequestStatusResponseStatus.Received:case ti.RequestStatusResponseStatus.Unknown:case ti.RequestStatusResponseStatus.Processing:return await n(e,r,m),zp(t,e,r,n,c,s);case ti.RequestStatusResponseStatus.Rejected:{let _=new Uint8Array((0,Ms.lookupResultToBuffer)(d.lookup([...a,"reject_code"])))[0],u=new TextDecoder().decode((0,Ms.lookupResultToBuffer)(d.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
|
|
50
|
+
Request ID: ${(0,Wp.toHex)(r)}
|
|
51
51
|
Reject code: ${_}
|
|
52
52
|
Reject text: ${u}
|
|
53
53
|
`)}case ti.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")}Wt.pollForResponse=
|
|
56
|
-
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}};Ye.ActorCallError=Cs;var Ya=class extends Cs{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Xl.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};Ye.QueryCallRejectedError=Ya;var ks=class extends Cs{constructor(e,r,n,i,s,o,a){super(e,r,"update",Object.assign({"Request ID":(0,fE.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}};Ye.UpdateCallRejectedError=ks;var ar=Symbol.for("ic-agent-metadata"),js=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 cr.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"?cr.Principal.fromText(r.canisterId):r.canisterId;await Ql(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 Ql(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:qs.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new Jl.AgentError(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?cr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Zp),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&f.annotations.push(Ye.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=hE(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Jl.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)}};Ye.Actor=js;function Vi(t,e){let r=qs.IDL.decode(t,lE.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Zp={pollingStrategyFactory:zp.strategy.defaultStrategy};Ye.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";Ye.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function hE(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,Xl.getDefaultAgent)(),h=cr.Principal.from(o.canisterId||t[ar].config.canisterId),m=qs.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 Ya(h,e,_);case"replied":return r.annotations.includes(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:u,result:Vi(r.retTypes,_.reply.arg)}:Vi(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,Xl.getDefaultAgent)(),{canisterId:h,effectiveCanisterId:m,pollingStrategyFactory:_}=Object.assign(Object.assign(Object.assign({},Zp),t[ar].config),o),u=cr.Principal.from(h),O=m!==void 0?cr.Principal.from(m):u,T=qs.IDL.encode(r.argTypes,a),{requestId:P,response:F,requestDetails:A}=await d.call(u,{methodName:e,arg:T,effectiveCanisterId:O}),K,E;if(F.body&&F.body.certificate){if(d.rootKey==null)throw new Error("Agent is missing root key");let C=F.body.certificate;E=await Hi.Certificate.create({certificate:(0,qs.bufFromBufLike)(C),rootKey:d.rootKey,canisterId:cr.Principal.from(h),blsVerify:n});let oe=[new TextEncoder().encode("request_status"),P];switch(new TextDecoder().decode((0,Hi.lookupResultToBuffer)(E.lookup([...oe,"status"])))){case"replied":K=(0,Hi.lookupResultToBuffer)(E.lookup([...oe,"reply"]));break;case"rejected":{let ie=new Uint8Array((0,Hi.lookupResultToBuffer)(E.lookup([...oe,"reject_code"])))[0],w=new TextDecoder().decode((0,Hi.lookupResultToBuffer)(E.lookup([...oe,"reject_message"]))),b=(0,Hi.lookupResultToBuffer)(E.lookup([...oe,"error_code"])),N=b?new TextDecoder().decode(b):void 0;throw new ks(u,e,P,F,ie,w,N)}}}else if(F.body&&"reject_message"in F.body){let{reject_code:C,reject_message:oe,error_code:Q}=F.body;throw new ks(u,e,P,F,C,oe,Q)}if(F.status===202){let C=_(),oe=await(0,zp.pollForResponse)(d,O,P,C,n);E=oe.certificate,K=oe.reply}let k=r.annotations.includes(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS),G=r.annotations.includes(Ye.ACTOR_METHOD_WITH_CERTIFICATE),z=Object.assign(Object.assign({},F),{requestDetails:A});if(K!==void 0)return k&&G?{httpDetails:z,certificate:E,result:Vi(r.retTypes,K)}:G?{certificate:E,result:Vi(r.retTypes,K)}:k?{httpDetails:z,result:Vi(r.retTypes,K)}:Vi(r.retTypes,K);if(r.retTypes.length===0)return k?{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 Ql(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:cr.Principal.from(t.effectiveCanisterId)};let i=n[0],s=cr.Principal.fromHex("");return i&&typeof i=="object"&&i.target_canister&&r==="install_chunked_code"&&(s=cr.Principal.from(i.target_canister)),i&&typeof i=="object"&&i.canister_id&&(s=cr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return js.createActor(dE.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:cr.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}Ye.getManagementCanister=Ql;var Ll=class extends js{constructor(e){super(e)}};Ye.AdvancedActor=Ll});var Dp=ee(ef=>{"use strict";Object.defineProperty(ef,"__esModule",{value:!0});ef.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 Xp=ee($i=>{"use strict";var pE=$i&&$i.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty($i,"__esModule",{value:!0});$i.createAssetCanisterActor=void 0;var yE=Wa(),gE=pE(Dp());function mE(t){return yE.Actor.createActor(gE.default,t)}$i.createAssetCanisterActor=mE});var Jp=ee($r=>{"use strict";var bE=$r&&$r.__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=$r&&$r.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),wE=$r&&$r.__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)&&bE(e,t,r);return _E(e,t),e};Object.defineProperty($r,"__esModule",{value:!0});$r.fetchCandid=void 0;var EE=Ut(),xE=wE(Bs()),vE=Wl(),TE=Wa();async function AE(t,e){e||(e=await vE.HttpAgent.create());let n=(await xE.request({agent:e,canisterId:EE.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 TE.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}$r.fetchCandid=AE});var Qt=ee(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]}),SE=Re&&Re.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),It=Re&&Re.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Qp(e,t,r)},tf=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 SE(e,t),e};Object.defineProperty(Re,"__esModule",{value:!0});Re.Cbor=Re.CanisterStatus=Re.polling=void 0;It(Wa(),Re);It(Ss(),Re);It(Xo(),Re);It(gs(),Re);It(ju(),Re);It(Xp(),Re);It(Oi(),Re);It(Hl(),Re);It(Jp(),Re);It(Kl(),Re);It(Vl(),Re);It(ds(),Re);It(_l(),Re);It(Vt(),Re);It(Zu(),Re);Re.polling=tf(Ga());Re.CanisterStatus=tf(Bs());Re.Cbor=tf(ys());It(Ga(),Re)});var mt=ee((r3,hy)=>{"use strict";var af=Object.defineProperty,BE=Object.getOwnPropertyDescriptor,OE=Object.getOwnPropertyNames,NE=Object.prototype.hasOwnProperty,RE=(t,e)=>{for(var r in e)af(t,r,{get:e[r],enumerable:!0})},PE=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of OE(e))!NE.call(t,i)&&i!==r&&af(t,i,{get:()=>e[i],enumerable:!(n=BE(e,i))||n.enumerable});return t},IE=t=>PE(af({},"__esModule",{value:!0}),t),ry={};RE(ry,{AgentManager:()=>VE,Canister:()=>jE,FromStringToTokenError:()=>ny,ICPToken:()=>qE,InvalidPercentageError:()=>uy,NullishError:()=>ly,TokenAmount:()=>CE,TokenAmountV2:()=>kE,arrayBufferToUint8Array:()=>ZE,arrayOfNumberToUint8Array:()=>XE,asNonNullish:()=>KE,asciiStringToByteArray:()=>JE,assertNonNullish:()=>Ks,assertPercentageNumber:()=>GE,bigEndianCrc32:()=>sx,bigIntToUint8Array:()=>WE,candidNumberArrayToBigInt:()=>ex,convertStringToE8s:()=>iy,createAgent:()=>ay,createServices:()=>$E,debounce:()=>lx,decodeBase32:()=>rx,defaultAgent:()=>oy,encodeBase32:()=>tx,fromDefinedNullable:()=>dx,fromNullable:()=>cf,fromNullishNullable:()=>hx,hexStringToUint8Array:()=>QE,isEmptyString:()=>HE,isNullish:()=>za,jsonReplacer:()=>px,jsonReviver:()=>yx,nonNullish:()=>Kr,notEmptyString:()=>sy,nowInBigIntNanoSeconds:()=>ux,numberToUint8Array:()=>zE,principalToSubAccount:()=>gx,secondsToDuration:()=>ax,smallerVersion:()=>mx,toNullable:()=>fx,uint8ArrayToArrayOfNumber:()=>DE,uint8ArrayToBigInt:()=>YE,uint8ArrayToHexString:()=>LE});hy.exports=IE(ry);var ny=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(ny||{}),UE=BigInt(1e8),FE=8,iy=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)*UE}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},ME=({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},qE={symbol:"ICP",name:"Internet Computer",decimals:8},CE=class Vs{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 Vs(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=iy(e);return typeof n=="bigint"?new Vs(n,r):n}static fromNumber({amount:e,token:r}){let n=Vs.fromString({amount:e.toString(),token:r});if(n instanceof Vs)return n;throw n===0?new Error(`Number ${e} has more than 8 decimals`):new Error(`Invalid number ${e}`)}toE8s(){return this.e8s}},kE=class $s{constructor(e,r){this.ulps=e,this.token=r}static fromUlps({amount:e,token:r}){return new $s(e,r)}static fromString({amount:e,token:r}){let n=ME({amount:e,decimals:r.decimals});return typeof n=="bigint"?new $s(n,r):n}static fromNumber({amount:e,token:r}){let n=$s.fromString({amount:e.toFixed(Math.min(FE,r.decimals)),token:r});if(n instanceof $s)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)}},jE=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}},Lp=Qt(),rf=Qt(),za=t=>t==null,Kr=t=>!za(t),sy=t=>Kr(t)&&t!=="",HE=t=>!sy(t),oy=()=>rf.HttpAgent.createSync({host:"https://icp-api.io",identity:new rf.AnonymousIdentity}),ay=async({identity:t,host:e,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await rf.HttpAgent.create({identity:t,...Kr(e)&&{host:e},verifyQuerySignatures:n,...Kr(i)&&{retryTimes:i},shouldFetchRootKey:r}),VE=class cy{constructor(e){this.config=e,this.agents=void 0}static create(e){return new cy(e)}async getAgent({identity:e}){let r=e.getPrincipal().toText();if(za(this.agents)||za(this.agents[r])){let n=await ay({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}},$E=({options:{canisterId:t,serviceOverride:e,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:o,certifiedIdlFactory:a})=>{let c=n??oy(),f=e??Lp.Actor.createActor(o,{agent:c,canisterId:t,callTransform:i,queryTransform:s}),d=r??Lp.Actor.createActor(a,{agent:c,canisterId:t,callTransform:i,queryTransform:s});return{service:f,certifiedService:d,agent:c,canisterId:t}},uy=class extends Error{},ly=class extends Error{},Ks=(t,e)=>{if(t==null)throw new ly(e)},KE=(t,e)=>(Ks(t,e),t),GE=t=>{if(t<0||t>100)throw new uy(`${t} is not a valid percentage number.`)},YE=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}},WE=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)},zE=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)},ZE=t=>new Uint8Array(t),DE=t=>Array.from(t),XE=t=>new Uint8Array(t),JE=t=>Array.from(t).map(e=>e.charCodeAt(0)),QE=t=>{let e=t.match(/.{1,2}/g);return Ks(e,"Invalid hex string."),Uint8Array.from(e.map(r=>parseInt(r,16)))},LE=t=>(t instanceof Uint8Array||(t=Uint8Array.from(t)),t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")),ex=t=>{let e=0n;for(let r=t.length-1;r>=0;r--)e=(e<<32n)+BigInt(t[r]);return e},Za="abcdefghijklmnopqrstuvwxyz234567",Ki=Object.create(null);for(let t=0;t<Za.length;t++)Ki[Za[t]]=t;Ki[0]=Ki.o;Ki[1]=Ki.i;var tx=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+=Za[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Za[r>>3]:"")};function rx(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Ki[o.toLowerCase()];Ks(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 nx=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]),ix=t=>{let e=-1;for(let r=0;r<t.length;r++){let n=(t[r]^e)&255;e=nx[n]^e>>>8}return(e^-1)>>>0},sx=t=>{let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,ix(t),!1),new Uint8Array(e)},ox={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"},ax=({seconds:t,i18n:e=ox})=>{let r=t/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=cx(i);return i-=fy(s),[Hs("year",s),Hs("day",i),Hs("hour",n),Hs("minute",r),...t>BigInt(0)&&t<BigInt(60)?[Hs("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(", ")},cx=t=>{let e=t/BigInt(365);for(;fy(e)>t;)e--;return e},fy=t=>{let e=t/BigInt(4);return t*BigInt(365)+e},Hs=(t,e)=>({labelKey:t,amount:Number(e)}),ux=()=>BigInt(Date.now())*BigInt(1e6),lx=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},fx=t=>Kr(t)?[t]:[],cf=t=>t?.[0],dx=t=>{let e=cf(t);return Ks(e),e},hx=t=>cf(t??[]),dy=Ut(),nf="__bigint__",sf="__principal__",of="__uint8array__",px=(t,e)=>typeof e=="bigint"?{[nf]:`${e}`}:Kr(e)&&e instanceof dy.Principal?{[sf]:e.toText()}:Kr(e)&&e instanceof Uint8Array?{[of]:Array.from(e)}:e,yx=(t,e)=>{let r=n=>e[n];return Kr(e)&&typeof e=="object"&&nf in e?BigInt(r(nf)):Kr(e)&&typeof e=="object"&&sf in e?dy.Principal.fromText(r(sf)):Kr(e)&&typeof e=="object"&&of in e?Uint8Array.from(r(of)):e},gx=t=>{let e=t.toUint8Array(),r=new Uint8Array(32);return r[0]=e.length,r.set(e,1),r},ey=(t,e)=>e>t.length?[...t,...[...Array(e-t.length).keys()].map(()=>0)]:t,ty=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)},mx=({minVersion:t,currentVersion:e})=>{let r=ey(t.split(".").map(ty),3).join(".");return ey(e.split(".").map(ty),3).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var yy=ee(Gr=>{"use strict";var Ja=Gr&&Gr.__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},Pn=Gr&&Gr.__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)},Da,Xa,Yi,Wi;Object.defineProperty(Gr,"__esModule",{value:!0});Gr.Ed25519KeyIdentity=Gr.Ed25519PublicKey=void 0;var bx=Qt(),Lt=Qt(),Gs=kl();function py(t){return t!==null&&typeof t=="object"}var ri=class t{constructor(e){if(Da.set(this,void 0),Xa.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Ja(this,Da,e,"f"),Ja(this,Xa,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,Lt.fromHex)(e);return this.fromRaw(r)}else if(py(e)){let r=e;if(py(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Lt.bufFromBufLike)(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=(0,Lt.wrapDER)(e,Lt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,Lt.unwrapDER)(e,Lt.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Pn(this,Da,"f")}get derKey(){return Pn(this,Xa,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Gr.Ed25519PublicKey=ri;Da=new WeakMap,Xa=new WeakMap;ri.RAW_KEY_LENGTH=32;var lf=class t extends Lt.SignIdentity{constructor(e,r){super(),Yi.set(this,void 0),Wi.set(this,void 0),Ja(this,Yi,ri.from(e),"f"),Ja(this,Wi,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=Gs.ed25519.utils.randomPrivateKey()),(0,bx.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=Gs.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(ri.fromDer((0,Lt.fromHex)(r)),(0,Lt.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(ri.fromRaw(e),r)}static fromSecretKey(e){let r=Gs.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,Lt.toHex)(Pn(this,Yi,"f").toDer()),(0,Lt.toHex)(Pn(this,Wi,"f"))]}getKeyPair(){return{secretKey:Pn(this,Wi,"f"),publicKey:Pn(this,Yi,"f")}}getPublicKey(){return Pn(this,Yi,"f")}async sign(e){let r=new Uint8Array(e),n=(0,Lt.uint8ToBuf)(Gs.ed25519.sign(r,Pn(this,Wi,"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,Lt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Gs.ed25519.verify(s,i,o)}};Gr.Ed25519KeyIdentity=lf;Yi=new WeakMap,Wi=new WeakMap});var my=ee(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});ni.ECDSAKeyIdentity=ni.CryptoError=void 0;var _x=Qt(),Qa=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};ni.CryptoError=Qa;function gy(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 Qa("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 La=class t extends _x.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=gy(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=gy(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)}};ni.ECDSAKeyIdentity=La;ni.default=La});var df=ee(Un=>{"use strict";var wx=Un&&Un.__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},Ys=Un&&Un.__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)},In;Object.defineProperty(Un,"__esModule",{value:!0});Un.PartialIdentity=void 0;var Ex=Ut(),ff=class{constructor(e){In.set(this,void 0),wx(this,In,e,"f")}get rawKey(){return Ys(this,In,"f").rawKey}get derKey(){return Ys(this,In,"f").derKey}toDer(){return Ys(this,In,"f").toDer()}getPublicKey(){return Ys(this,In,"f")}getPrincipal(){return Ex.Principal.from(Ys(this,In,"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.")}};Un.PartialIdentity=ff;In=new WeakMap});var by=ee(Ze=>{"use strict";var xx=Ze&&Ze.__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]}),vx=Ze&&Ze.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Tx=Ze&&Ze.__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)&&xx(e,t,r);return vx(e,t),e},Ax=Ze&&Ze.__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},Sx=Ze&&Ze.__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)},Bx=Ze&&Ze.__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},ec;Object.defineProperty(Ze,"__esModule",{value:!0});Ze.isDelegationValid=Ze.PartialDelegationIdentity=Ze.DelegationIdentity=Ze.DelegationChain=Ze.Delegation=void 0;var Fn=Qt(),pf=Ut(),Ws=Tx(ps()),Ox=df(),Nx=new TextEncoder().encode("ic-request-auth-delegation"),Rx=new TextEncoder().encode(`
|
|
57
|
-
ic-request`);function hf(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,Fn.fromHex)(t)}var zs=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return Ws.value.map(Object.assign({pubkey:Ws.value.bytes(this.pubkey),expiration:Ws.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Ws.value.array(this.targets.map(e=>Ws.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Fn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};Ze.Delegation=zs;async function Px(t,e,r,n){let i=new zs(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...Nx,...new Uint8Array((0,Fn.requestIdOf)(Object.assign({},i)))]),o=await t.sign(s);return{delegation:i,signature:o}}var yf=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 Px(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 zs(hf(c),BigInt("0x"+f),d&&d.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return pf.Principal.fromHex(h)})),signature:hf(a)}});return new this(i,hf(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,Fn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Fn.toHex)(n)}}),publicKey:(0,Fn.toHex)(this.publicKey)}}};Ze.DelegationChain=yf;var gf=class extends Fn.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=Bx(e,["body"]),i=await(0,Fn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Rx,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};Ze.DelegationIdentity=gf;var mf=class t extends Ox.PartialIdentity{constructor(e,r){super(e),ec.set(this,void 0),Ax(this,ec,r,"f")}get delegation(){return Sx(this,ec,"f")}static fromDelegation(e,r){return new t(e,r)}};Ze.PartialDelegationIdentity=mf;ec=new WeakMap;function Ix(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"?pf.Principal.fromText(i):i)):r.push(typeof n=="string"?pf.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}Ze.isDelegationValid=Ix});var _y=ee(Mn=>{"use strict";var Ux=Mn&&Mn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Mn,"__esModule",{value:!0});Mn.WebAuthnIdentity=Mn.CosePublicKey=void 0;var ii=Qt(),bf=Ux(Ho()),Fx=jn(),Mx=xi();function qx(t){return(0,ii.wrapDER)(t,ii.DER_COSE_OID).buffer}function Cx(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 tc=class{constructor(e){this._cose=e,this._encodedKey=qx(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};Mn.CosePublicKey=tc;function kx(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function jx(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:kx(),pubKeyCredParams:[{type:"public-key",alg:_f.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Fx.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,Mx.bufFromBufLike)(e.rawId)}}var _f;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(_f||(_f={}));var wf=class extends ii.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new tc(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,ii.fromHex)(n),(0,ii.fromHex)(r),void 0)}static async create(e){var r;let n=await jx(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=bf.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,Cx(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=bf.default.encode(new bf.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,ii.toHex)(this._publicKey.getCose()),rawId:(0,ii.toHex)(this.rawId)}}};Mn.WebAuthnIdentity=wf});var Ey=ee(We=>{"use strict";var Hx=We&&We.__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]}),xf=We&&We.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Hx(e,t,r)};Object.defineProperty(We,"__esModule",{value:!0});We.Secp256k1KeyIdentity=We.ED25519_OID=We.DER_COSE_OID=We.unwrapDER=We.wrapDER=We.WebAuthnIdentity=We.Ed25519PublicKey=We.Ed25519KeyIdentity=void 0;var wy=yy();Object.defineProperty(We,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return wy.Ed25519KeyIdentity}});Object.defineProperty(We,"Ed25519PublicKey",{enumerable:!0,get:function(){return wy.Ed25519PublicKey}});xf(my(),We);xf(by(),We);xf(df(),We);var Vx=_y();Object.defineProperty(We,"WebAuthnIdentity",{enumerable:!0,get:function(){return Vx.WebAuthnIdentity}});var rc=Qt();Object.defineProperty(We,"wrapDER",{enumerable:!0,get:function(){return rc.wrapDER}});Object.defineProperty(We,"unwrapDER",{enumerable:!0,get:function(){return rc.unwrapDER}});Object.defineProperty(We,"DER_COSE_OID",{enumerable:!0,get:function(){return rc.DER_COSE_OID}});Object.defineProperty(We,"ED25519_OID",{enumerable:!0,get:function(){return rc.ED25519_OID}});var Ef=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};We.Secp256k1KeyIdentity=Ef});var Tf=ee(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});nc.IdleManager=void 0;var xy=["mousedown","mousemove","keydown","touchstart","wheel"],vf=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),xy.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);xy.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)}};nc.IdleManager=vf});function Kx(){return vy||(vy=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Gx(){return Ty||(Ty=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function Yx(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(ur(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&Ay.set(r,t)}).catch(()=>{}),Of.set(e,t),e}function Wx(t){if(Sf.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)});Sf.set(t,e)}function By(t){Bf=t(Bf)}function zx(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Zs(this),e,...r);return Sy.set(n,e.sort?e.sort():[e]),ur(n)}:Gx().includes(t)?function(...e){return t.apply(Zs(this),e),ur(Ay.get(this))}:function(...e){return ur(t.apply(Zs(this),e))}}function Zx(t){return typeof t=="function"?zx(t):(t instanceof IDBTransaction&&Wx(t),$x(t,Kx())?new Proxy(t,Bf):t)}function ur(t){if(t instanceof IDBRequest)return Yx(t);if(Af.has(t))return Af.get(t);let e=Zx(t);return e!==t&&(Af.set(t,e),Of.set(e,t)),e}var $x,vy,Ty,Ay,Sf,Sy,Af,Of,Bf,Zs,Nf=Df(()=>{$x=(t,e)=>e.some(r=>t instanceof r);Ay=new WeakMap,Sf=new WeakMap,Sy=new WeakMap,Af=new WeakMap,Of=new WeakMap;Bf={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Sf.get(t);if(e==="objectStoreNames")return t.objectStoreNames||Sy.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ur(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}};Zs=t=>Of.get(t)});var Ny={};Jg(Ny,{deleteDB:()=>Xx,openDB:()=>Dx,unwrap:()=>Zs,wrap:()=>ur});function Dx(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=ur(o);return n&&o.addEventListener("upgradeneeded",c=>{n(ur(o.result),c.oldVersion,c.newVersion,ur(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),a}function Xx(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),ur(r).then(()=>{})}function Oy(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Rf.get(e))return Rf.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=Qx.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||Jx.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 Rf.set(e,s),s}var Jx,Qx,Rf,Ry=Df(()=>{Nf();Nf();Jx=["get","getKey","getAll","getAllKeys","count"],Qx=["put","add","delete","clear"],Rf=new Map;By(t=>({...t,get:(e,r,n)=>Oy(e,r)||t.get(e,r,n),has:(e,r)=>!!Oy(e,r)||t.has(e,r)}))});var If=ee(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.IdbKeyVal=void 0;var Lx=(Ry(),Qg(Ny)),Ds=sc(),Py="auth-client-db",Iy="ic-keyval",e8=async(t=Py,e=Iy,r)=>(Ds.isBrowser&&(localStorage!=null&&localStorage.getItem(Ds.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Ds.KEY_STORAGE_DELEGATION),localStorage.removeItem(Ds.KEY_STORAGE_KEY)),await(0,Lx.openDB)(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function t8(t,e,r){return await t.get(e,r)}async function r8(t,e,r,n){return await t.put(e,n,r)}async function n8(t,e,r){return await t.delete(e,r)}var Pf=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=Py,storeName:n=Iy,version:i=Ds.DB_VERSION}=e??{},s=await e8(r,n,i);return new t(s,n)}async set(e,r){return await r8(this._db,this._storeName,e,r)}async get(e){var r;return(r=await t8(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await n8(this._db,this._storeName,e)}};ic.IdbKeyVal=Pf});var sc=ee(nt=>{"use strict";var i8=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},s8=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)},oc;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 o8=If();nt.KEY_STORAGE_KEY="identity";nt.KEY_STORAGE_DELEGATION="delegation";nt.KEY_VECTOR="iv";nt.DB_VERSION=1;nt.isBrowser=typeof window<"u";var Uf=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=Uf;var Ff=class{constructor(e){oc.set(this,void 0),i8(this,oc,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}o8.IdbKeyVal.create(s8(this,oc,"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=Ff;oc=new WeakMap});var jf=ee(Le=>{"use strict";var a8=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]}),c8=Le&&Le.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&a8(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 Uy=Qt(),er=Ey(),Fy=Tf(),vt=sc(),ac=sc();Object.defineProperty(Le,"IdbStorage",{enumerable:!0,get:function(){return ac.IdbStorage}});Object.defineProperty(Le,"LocalStorage",{enumerable:!0,get:function(){return ac.LocalStorage}});Object.defineProperty(Le,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return ac.KEY_STORAGE_DELEGATION}});Object.defineProperty(Le,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return ac.KEY_STORAGE_KEY}});var u8=If();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return u8.IdbKeyVal}});var l8="https://identity.ic0.app",f8="#authorize",Mf="ECDSA",qf="Ed25519",d8=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";c8(Tf(),Le);var kf=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 vt.IdbStorage,o=(n=e.keyType)!==null&&n!==void 0?n:Mf,a=null;if(e.identity)a=e.identity;else{let h=await s.get(vt.KEY_STORAGE_KEY);if(!h&&vt.isBrowser)try{let m=new vt.LocalStorage,_=await m.get(vt.KEY_STORAGE_DELEGATION),u=await m.get(vt.KEY_STORAGE_KEY);_&&u&&o===Mf&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(vt.KEY_STORAGE_DELEGATION,_),await s.set(vt.KEY_STORAGE_KEY,u),h=_,await m.remove(vt.KEY_STORAGE_DELEGATION),await m.remove(vt.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(h)try{typeof h=="object"?o===qf&&typeof h=="string"?a=await er.Ed25519KeyIdentity.fromJSON(h):a=await er.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=er.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new Uy.AnonymousIdentity,f=null;if(a)try{let h=await s.get(vt.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=er.DelegationChain.fromJSON(h),(0,er.isDelegationValid)(f)?"toDer"in a?c=er.PartialDelegationIdentity.fromDelegation(a,f):c=er.DelegationIdentity.fromDelegation(a,f):(await Cf(s),a=null))}catch(h){console.error(h),await Cf(s),a=null}let d;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?d=void 0:(f||e.identity)&&(d=Fy.IdleManager.create(e.idleOptions)),a||(o===qf?(a=await er.Ed25519KeyIdentity.generate(),await s.set(vt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===Mf&&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 '${qf}' as the key type, as it can serialize to a string`),a=await er.ECDSAKeyIdentity.generate(),await s.set(vt.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 er.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=er.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=er.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=er.DelegationIdentity.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=Fy.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(vt.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())||l8);a.hash=f8,(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,d8))};c()}_getEventHandler(e,r){return async n=>{var i,s,o;if(n.origin!==e.origin)return;let a=n.data;switch(a.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,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 Cf(this._storage),this._identity=new Uy.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Le.AuthClient=kf;async function Cf(t){await t.remove(vt.KEY_STORAGE_KEY),await t.remove(vt.KEY_STORAGE_DELEGATION),await t.remove(vt.KEY_VECTOR)}});var Pg=De(mt(),1);var yg=De(mt(),1);var Gi=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 on=class t extends Gi{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 uf=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var hg=De(jf(),1),pg=De(mt(),1);var My=BigInt(144e11),qy=!1,Cy={width:576,height:576},ky={width:505,height:705},jy="internetcomputer.org";var Xs=De(mt(),1);var zi="http://127.0.0.1:5987",Hy="rdmx6-jaaaa-aaaaa-aaadq-cai";var Yr=class t extends Gi{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 Hf=De(mt(),1);var cc=De(mt(),1),Vy=async t=>{let e=new Blob([JSON.stringify(t,cc.jsonReplacer)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},uc=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(),cc.jsonReviver)},lc=()=>typeof window<"u";var Vf=({width:t,height:e})=>{if(!lc()||(0,Hf.isNullish)(window)||(0,Hf.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 fc=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=Yr.getInstance().get()?.container;if((0,Xs.isNullish)(n)||n===!1)return`https://identity.${this.#e??jy}`;let i=Yr.getInstance().get(),s=(0,Xs.nonNullish)(i)&&(0,Xs.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:Hy,{host:o,protocol:a}=new URL(n===!0?zi:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Vf(Cy)},identityProvider:r()}}},$y=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:Vf(ky)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var Gy=De(Qt(),1),dc=De(mt(),1);var Ky=De(Qt(),1),si=De(mt(),1);var Zi=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,si.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...r}){let n=e.getPrincipal().toText();if((0,si.isNullish)(this.#e)||(0,si.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,si.nonNullish)(n)&&n!==!1?n===!0?zi:n:"https://icp-api.io",o=(0,si.nonNullish)(n);return await Ky.HttpAgent.create({identity:e,shouldFetchRootKey:o,host:s,...r&&{fetch:r}})}};var Di=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,dc.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,dc.isNullish)(this.#e)||(0,dc.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 Zi.getInstance().getAgent(n);return Gy.Actor.createActor(e,{agent:i,canisterId:r})}};var hc=class extends Error{},pc=class extends Error{},yc=class extends Error{},gc=class extends Error{},mc=class extends Error{};var Yy=De(jf(),1),bc=()=>Yy.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Wf=De(mt(),1);var xr=De(mt(),1);var Wy=async({data:t})=>{try{return await uc(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var oi=De(mt(),1);var $f=async t=>{let{data:e,version:r,description:n}=t;return{description:(0,oi.toNullable)(n),data:await Vy(e),version:(0,oi.toNullable)(r)}},Kf=t=>{let{version:e}=t;return{version:(0,oi.toNullable)(e)}},Js=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:(0,oi.fromNullable)(i),owner:r.toText(),data:await uc(s),version:(0,oi.fromNullable)(n),...o}};var Zy=De(Ut(),1),it=De(mt(),1);var zy=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 mc("Invalid list matcher for timestamp",t)}},qn=({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:zy(t.createdAt),updated_at:zy(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"?Zy.Principal.fromText(n):n)});var Jy=De(mt(),1);var Dy=({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}),O=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}),T=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),P=t.Record({key:O,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,T)),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)}),A=t.Record({internet_identity:t.Opt(F)}),K=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),E=t.Record({max_memory_size:t.Opt(K)}),k=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),G=t.Variant({Deny:t.Null,Allow:t.Null}),z=t.Record({status_code:t.Nat16,location:t.Text}),C=t.Record({iframe:t.Opt(k),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(G),redirects:t.Opt(t.Vec(t.Tuple(t.Text,z)))}),oe=t.Record({db:t.Opt(E),authentication:t.Opt(A),storage:C}),Q=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)}),ie=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}),N=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ie),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}),B=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)}),R=t.Record({memory:ie,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}),V=t.Variant({Callback:t.Record({token:R,callback:t.Func([],[],["query"])})}),D=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(V),status_code:t.Nat16}),ce=t.Record({token:t.Opt(R),body:t.Vec(t.Nat8)}),ae=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}),Z=t.Record({batch_id:t.Nat}),M=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,P)),items_length:t.Nat64}),y=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),L=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,Q)),items_length:t.Nat64}),re=t.Record({stable:t.Nat64,heap:t.Nat64}),le=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:f,expires_at:t.Opt(t.Nat64)}),J=t.Record({controller:le,controllers:t.Vec(t.Principal)}),l=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),p=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ie),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)}),I=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(P)],["query"]),get_auth_config:t.Func([],[t.Opt(A)],["query"]),get_config:t.Func([],[oe],[]),get_db_config:t.Func([],[t.Opt(E)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(Q)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(P)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(Q)))],["query"]),get_rule:t.Func([m,t.Text],[t.Opt(N)],["query"]),get_storage_config:t.Func([],[C],["query"]),http_request:t.Func([B],[D],["query"]),http_request_streaming_callback:t.Func([R],[ce],["query"]),init_asset_upload:t.Func([ae],[Z],[]),list_assets:t.Func([t.Text,a],[M],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,y))],["query"]),list_docs:t.Func([t.Text,a],[L],["query"]),list_rules:t.Func([m],[t.Vec(t.Tuple(t.Text,N))],["query"]),memory_size:t.Func([],[re],["query"]),set_auth_config:t.Func([A],[],[]),set_controllers:t.Func([J],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([E],[],[]),set_doc:t.Func([t.Text,t.Text,l],[Q],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,l))],[t.Vec(t.Tuple(t.Text,Q))],[]),set_rule:t.Func([m,t.Text,p],[N],[]),set_storage_config:t.Func([C],[],[]),upload_asset_chunk:t.Func([g],[I],[]),version:t.Func([],[t.Text],["query"])})};var _c=De(mt(),1);var Xy=({satelliteId:t,container:e})=>{let{satelliteId:r}=Gf({satelliteId:t}),{container:n}=Yf({container:e});if((0,_c.nonNullish)(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?zi:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Gf=({satelliteId:t})=>(0,_c.nonNullish)(t)?{satelliteId:t}:Yr.getInstance().get()??{satelliteId:void 0},Yf=({container:t})=>(0,_c.nonNullish)(t)?{container:t}:Yr.getInstance().get()??{container:void 0};var lt=t=>Ly({idlFactory:Dy,buildType:"stock",...t}),Qy=({idlFactory:t,...e})=>Ly({idlFactory:t,buildType:"extended",...e}),Ly=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Gf({satelliteId:t});(0,Jy.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Yf({container:e});return await Di.getInstance().getActor({satelliteId:n,container:i,...r})};var eg=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await lt(r),i=(0,xr.fromNullable)(await n(t,e));if(!(0,xr.isNullish)(i))return Js({doc:i,key:e})},tg=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await lt(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=(0,xr.fromNullable)(a);s.push((0,xr.nonNullish)(c)?await Js({key:o,doc:c}):void 0)}return s},rg=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await lt(r),{key:i}=e,s=await $f(e),o=await n(t,i,s);return await Js({key:i,doc:o})},ng=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await lt(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await $f(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await Js({key:o,doc:a}));return s},ig=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await lt(r),{key:i}=e;return n(t,i,Kf(e))},sg=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await lt(e),n=t.map(({collection:i,doc:s})=>[i,s.key,Kf(s)]);await r(n)},og=async({collection:t,filter:e,satellite:r})=>{let{del_filtered_docs:n}=await lt(r);return n(t,qn(e))},ag=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await lt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(t,qn(e)),f=[];for(let[d,h]of i){let{data:m,owner:_,description:u,version:O,...T}=h;f.push({key:d,description:(0,xr.fromNullable)(u),owner:_.toText(),data:await Wy({data:m}),version:(0,xr.fromNullable)(O),...T})}return{items:f,items_length:o,items_page:(0,xr.fromNullable)(s),matches_length:a,matches_pages:(0,xr.fromNullable)(c)}},cg=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await lt(r);return n(t,qn(e))};var ug=De(Qt(),1);var et=t=>t!==void 0?t:wc()??new ug.AnonymousIdentity;var lg=async({satellite:t,...e})=>{let r=et(t?.identity);return await eg({...e,satellite:{...t,identity:r}})},l6=async({satellite:t,...e})=>{let r=et(t?.identity);return await tg({...e,satellite:{...t,identity:r}})},fg=async({satellite:t,...e})=>{let r=et(t?.identity);return await rg({...e,satellite:{...t,identity:r}})},f6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ng({...e,satellite:{...t,identity:r}})},d6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ig({...e,satellite:{...t,identity:r}})},h6=async({satellite:t,...e})=>{let r=et(t?.identity);return await sg({...e,satellite:{...t,identity:r}})},p6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await og({...r,filter:e??{},satellite:{...t,identity:n}})},y6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await ag({...r,filter:e??{},satellite:{...t,identity:n}})},g6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await cg({...r,filter:e??{},satellite:{...t,identity:n}})};var dg=async t=>{let e=wc();if((0,Wf.isNullish)(e))throw new gc("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await lg({collection:"#user",key:r});return(0,Wf.isNullish)(n)?await h8({userId:r,provider:t}):n},h8=({userId:t,...e})=>fg({collection:"#user",doc:{key:t,data:e}});var Wr,zf=async t=>{if(Wr=Wr??await bc(),!(await Wr?.isAuthenticated()??!1))return;let r=await dg(t);on.getInstance().set(r)},p8=t=>new Promise(async(e,r)=>{if((0,pg.isNullish)(Wr)){r(new pc("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=t?.provider??new fc({});await Wr.login({onSuccess:async()=>{await zf(n.id),e()},onError:i=>{if(i===hg.ERROR_USER_INTERRUPT){r(new yc(i));return}r(new hc(i))},maxTimeToLive:t?.maxTimeToLive??My,allowPinAuthentication:t?.allowPin??qy,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Zf=async()=>{await Wr?.logout(),Wr=null,on.getInstance().reset(),Di.getInstance().reset(),Zi.getInstance().reset(),Wr=await bc()},wc=()=>Wr?.getIdentity(),y8=async()=>(Wr??await bc()).getIdentity();var gg=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{uf({message:"junoSignOutAuthTimer"}),await Zf()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":uf({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},on.getInstance().subscribe(i=>{if((0,yg.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var mg=()=>{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()},bg=()=>{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 j6=async({idlFactory:t,satellite:e})=>{let r=et(e?.identity);return await Qy({idlFactory:t,...e,identity:r})};var eo=De(mt(),1);var Ls=De(mt(),1);var Qs=De(mt(),1);var _g=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,Qs.toNullable)(i),encoding_type:(0,Qs.toNullable)(o),description:(0,Qs.toNullable)(a)}),h=19e5,m=[],_=lc()?new Blob([await t.arrayBuffer()]):t,u=0n;for(let P=0;P<_.size;P+=h){let F=_.slice(P,P+h);m.push({batchId:d,chunk:F,actor:c,orderId:u}),u++}let O=[];for await(let P of g8({uploadChunks:m}))O=[...O,...P];let T=n.find(([P,F])=>P.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:O.map(({chunk_id:P})=>P),headers:[...n,...T||[]]})};async function*g8({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=>m8(i)))}}var m8=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,Qs.toNullable)(n)});var wg=async({satellite:t,...e})=>{let r=await lt(t);await _g({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},Eg=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await lt(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(t,qn(r));return{items:i.map(([f,d])=>d),items_length:s,items_page:(0,Ls.fromNullable)(o),matches_length:a,matches_pages:(0,Ls.fromNullable)(c)}},xg=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await lt(e);return n(t,qn(r))},vg=async({collection:t,fullPath:e,satellite:r})=>(await lt(r)).del_asset(t,e),Tg=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await lt(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},Ag=async({collection:t,satellite:e,filter:r})=>{let{del_filtered_assets:n}=await lt(e);return n(t,qn(r))},Sg=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await lt(r);return(0,Ls.fromNullable)(await n(t,e))},Bg=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await lt(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>(0,Ls.fromNullable)(o))};var Og=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Q6=t=>Ng(t),L6=t=>Ng({filename:t.data.name,...t}),Ng=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 wg({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:m,description:c}),{downloadUrl:Rg({satellite:m,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},e5=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)},{items:i,...s}=await Eg({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:O})=>{let T=(0,eo.fromNullable)(c);return{fullPath:a,description:(0,eo.fromNullable)(h),name:f,downloadUrl:Rg({satellite:n,assetKey:{fullPath:a,token:T}}),token:T,headers:m,encodings:_.reduce((P,[F,{modified:A,sha256:K,total_length:E}])=>({...P,[F]:{modified:A,sha256:Og(K),total_length:E}}),{}),owner:d.toText(),created_at:u,updated_at:O}});return{items:o,assets:o,...s}},t5=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await xg({collection:t,satellite:n,filter:r??{}})},r5=({collection:t,fullPath:e,satellite:r})=>vg({collection:t,fullPath:e,satellite:{...r,identity:et(r?.identity)}}),n5=({assets:t,satellite:e})=>Tg({assets:t,satellite:{...e,identity:et(e?.identity)}}),i5=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await Ag({collection:t,satellite:n,filter:r??{}})},s5=async({satellite:t,...e})=>{let r=et(t?.identity);return await Sg({...e,satellite:{...t,identity:r}})},o5=async({satellite:t,...e})=>{let r=et(t?.identity);return await Bg({...e,satellite:{...t,identity:r}})},Rg=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${Xy(n)}${t}${(0,eo.nonNullish)(e)?`?token=${e}`:""}`};var b8=t=>{let e=t?.satelliteId??mg();(0,Pg.assertNonNullish)(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??bg();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},h5=t=>_8(t),_8=async t=>{let e=b8(t);Yr.getInstance().set(e),await zf();let r=e.workers?.auth!==void 0?gg(e.workers.auth):void 0;return[...r?[r]:[]]},p5=t=>on.getInstance().subscribe(t);export{gc as InitError,fc as InternetIdentityProvider,mc as ListError,$y as NFIDProvider,hc as SignInError,pc as SignInInitError,yc as SignInUserInterruptError,p5 as authSubscribe,t5 as countAssets,g6 as countDocs,r5 as deleteAsset,d6 as deleteDoc,i5 as deleteFilteredAssets,p6 as deleteFilteredDocs,n5 as deleteManyAssets,h6 as deleteManyDocs,Rg as downloadUrl,s5 as getAsset,lg as getDoc,o5 as getManyAssets,l6 as getManyDocs,j6 as getSatelliteExtendedActor,h5 as initJuno,_8 as initSatellite,e5 as listAssets,y6 as listDocs,fg as setDoc,f6 as setManyDocs,p8 as signIn,Zf as signOut,y8 as unsafeIdentity,Q6 as uploadBlob,L6 as uploadFile};
|
|
54
|
+
Request ID: ${(0,Wp.toHex)(r)}
|
|
55
|
+
`)}throw new Error("unreachable")}Wt.pollForResponse=zp});var Dp=ee(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});Jl.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.Nat32,a=t.Record({start_height:o,end_height:t.Opt(o),network:e}),c=t.Vec(t.Nat8),f=t.Record({tip_height:o,block_headers:t.Vec(c)}),d=t.Record({network:e}),h=t.Nat64,m=t.Vec(h),_=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),u=t.Vec(t.Nat8),O=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),T=t.Record({height:t.Nat32,value:i,outpoint:O}),P=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:o,tip_block_hash:u,utxos:t.Vec(T)}),F=t.Record({transaction:t.Vec(t.Nat8),network:e}),A=t.Principal,K=t.Record({canister_id:A,num_requested_changes:t.Opt(t.Nat64)}),E=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),j=t.Vec(t.Nat8),G=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)}),load_snapshot:t.Record({canister_version:t.Nat64,taken_at_timestamp:t.Nat64,snapshot_id:j}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),z=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:E,details:G}),q=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(z),total_num_changes:t.Nat64}),oe=t.Record({canister_id:A}),Q=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),ie=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:Q,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),w=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:ie,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}),b=t.Record({canister_id:A}),N=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(Q),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),B=t.Record({settings:t.Opt(N),sender_canister_version:t.Opt(t.Nat64)}),R=t.Record({canister_id:A}),V=t.Record({canister_id:A}),Z=t.Record({canister_id:A,snapshot_id:j}),ce=t.Record({canister_id:A}),ae=t.Variant({secp256k1:t.Null}),D=t.Record({key_id:t.Record({name:t.Text,curve:ae}),canister_id:t.Opt(A),derivation_path:t.Vec(t.Vec(t.Nat8))}),M=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),y=t.Record({canister_id:A}),L=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),re=t.Record({canister_log_records:t.Vec(L)}),le=t.Record({value:t.Text,name:t.Text}),X=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(le)}),l=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:X})],[X],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(le)}),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}),g=t.Record({hash:t.Vec(t.Nat8)}),I=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:p,chunk_hashes_list:t.Vec(g),target_canister:A,store_canister:t.Opt(A),sender_canister_version:t.Opt(t.Nat64)}),S=t.Vec(t.Nat8),U=t.Record({arg:t.Vec(t.Nat8),wasm_module:S,mode:p,canister_id:A,sender_canister_version:t.Opt(t.Nat64)}),H=t.Record({canister_id:A}),x=t.Record({id:j,total_size:t.Nat64,taken_at_timestamp:t.Nat64}),C=t.Vec(x),$=t.Record({canister_id:A,sender_canister_version:t.Opt(t.Nat64),snapshot_id:j}),k=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),J=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),te=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(J)})),de=t.Record({settings:t.Opt(N),specified_id:t.Opt(A),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),_e=t.Record({canister_id:A}),Me=t.Record({canister_id:A,amount:t.Nat}),Ve=t.Vec(t.Nat8),me=t.Variant({ed25519:t.Null,bip340secp256k1:t.Null}),he=t.Record({key_id:t.Record({algorithm:me,name:t.Text}),canister_id:t.Opt(A),derivation_path:t.Vec(t.Vec(t.Nat8))}),Je=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),vr=t.Record({key_id:t.Record({name:t.Text,curve:ae}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),zr=t.Record({signature:t.Vec(t.Nat8)}),Dr=t.Variant({bip341:t.Record({merkle_root_hash:t.Vec(t.Nat8)})}),kt=t.Record({aux:t.Opt(Dr),key_id:t.Record({algorithm:me,name:t.Text}),derivation_path:t.Vec(t.Vec(t.Nat8)),message:t.Vec(t.Nat8)}),Ne=t.Record({signature:t.Vec(t.Nat8)}),Tt=t.Record({canister_id:A}),st=t.Record({canister_id:A}),$e=t.Record({canister_id:A}),xc=t.Vec(g),vc=t.Record({subnet_id:t.Principal}),Ke=t.Record({replica_version:t.Text}),Tc=t.Record({replace_snapshot:t.Opt(j),canister_id:A}),Ac=x,Sc=t.Record({canister_id:A,sender_canister_version:t.Opt(t.Nat64)}),Bc=t.Record({canister_id:t.Principal,settings:N,sender_canister_version:t.Opt(t.Nat64)}),Oc=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),an=g;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_block_headers:t.Func([a],[f],[]),bitcoin_get_current_fee_percentiles:t.Func([d],[m],[]),bitcoin_get_utxos:t.Func([_],[P],[]),bitcoin_send_transaction:t.Func([F],[],[]),canister_info:t.Func([K],[q],[]),canister_status:t.Func([oe],[w],[]),clear_chunk_store:t.Func([b],[],[]),create_canister:t.Func([B],[R],[]),delete_canister:t.Func([V],[],[]),delete_canister_snapshot:t.Func([Z],[],[]),deposit_cycles:t.Func([ce],[],[]),ecdsa_public_key:t.Func([D],[M],[]),fetch_canister_logs:t.Func([y],[re],["query"]),http_request:t.Func([l],[X],[]),install_chunked_code:t.Func([I],[],[]),install_code:t.Func([U],[],[]),list_canister_snapshots:t.Func([H],[C],[]),load_canister_snapshot:t.Func([$],[],[]),node_metrics_history:t.Func([k],[te],[]),provisional_create_canister_with_cycles:t.Func([de],[_e],[]),provisional_top_up_canister:t.Func([Me],[],[]),raw_rand:t.Func([],[Ve],[]),schnorr_public_key:t.Func([he],[Je],[]),sign_with_ecdsa:t.Func([vr],[zr],[]),sign_with_schnorr:t.Func([kt],[Ne],[]),start_canister:t.Func([Tt],[],[]),stop_canister:t.Func([st],[],[]),stored_chunks:t.Func([$e],[xc],[]),subnet_info:t.Func([vc],[Ke],[]),take_canister_snapshot:t.Func([Tc],[Ac],[]),uninstall_code:t.Func([Sc],[],[]),update_settings:t.Func([Bc],[],[]),upload_chunk:t.Func([Oc],[an],[])})}});var za=ee(Ye=>{"use strict";var fE=Ye&&Ye.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.AdvancedActor=Ye.getManagementCanister=Ye.ACTOR_METHOD_WITH_CERTIFICATE=Ye.ACTOR_METHOD_WITH_HTTP_DETAILS=Ye.Actor=Ye.UpdateCallRejectedError=Ye.QueryCallRejectedError=Ye.ActorCallError=void 0;var dE=bd(),Xl=Ss(),Ql=yi(),Cs=xi(),Zp=Ya(),cr=Ut(),hE=Vt(),Hi=Oi(),pE=fE(Dp()),qs=class extends Ql.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}};Ye.ActorCallError=qs;var Wa=class extends qs{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Xl.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};Ye.QueryCallRejectedError=Wa;var js=class extends qs{constructor(e,r,n,i,s,o,a){super(e,r,"update",Object.assign({"Request ID":(0,hE.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}};Ye.UpdateCallRejectedError=js;var ar=Symbol.for("ic-agent-metadata"),ks=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 cr.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"?cr.Principal.fromText(r.canisterId):r.canisterId;await Ll(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 Ll(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:Cs.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new Ql.AgentError(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?cr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Jp),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&f.annotations.push(Ye.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=yE(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Ql.AgentError(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(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)}};Ye.Actor=ks;function Vi(t,e){let r=Cs.IDL.decode(t,dE.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Jp={pollingStrategyFactory:Zp.strategy.defaultStrategy};Ye.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";Ye.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function yE(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,Xl.getDefaultAgent)(),h=cr.Principal.from(o.canisterId||t[ar].config.canisterId),m=Cs.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 Wa(h,e,_);case"replied":return r.annotations.includes(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:u,result:Vi(r.retTypes,_.reply.arg)}:Vi(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,Xl.getDefaultAgent)(),{canisterId:h,effectiveCanisterId:m,pollingStrategyFactory:_}=Object.assign(Object.assign(Object.assign({},Jp),t[ar].config),o),u=cr.Principal.from(h),O=m!==void 0?cr.Principal.from(m):u,T=Cs.IDL.encode(r.argTypes,a),{requestId:P,response:F,requestDetails:A}=await d.call(u,{methodName:e,arg:T,effectiveCanisterId:O}),K,E;if(F.body&&F.body.certificate){if(d.rootKey==null)throw new Error("Agent is missing root key");let q=F.body.certificate;E=await Hi.Certificate.create({certificate:(0,Cs.bufFromBufLike)(q),rootKey:d.rootKey,canisterId:cr.Principal.from(h),blsVerify:n});let oe=[new TextEncoder().encode("request_status"),P];switch(new TextDecoder().decode((0,Hi.lookupResultToBuffer)(E.lookup([...oe,"status"])))){case"replied":K=(0,Hi.lookupResultToBuffer)(E.lookup([...oe,"reply"]));break;case"rejected":{let ie=new Uint8Array((0,Hi.lookupResultToBuffer)(E.lookup([...oe,"reject_code"])))[0],w=new TextDecoder().decode((0,Hi.lookupResultToBuffer)(E.lookup([...oe,"reject_message"]))),b=(0,Hi.lookupResultToBuffer)(E.lookup([...oe,"error_code"])),N=b?new TextDecoder().decode(b):void 0;throw new js(u,e,P,F,ie,w,N)}}}else if(F.body&&"reject_message"in F.body){let{reject_code:q,reject_message:oe,error_code:Q}=F.body;throw new js(u,e,P,F,q,oe,Q)}if(F.status===202){let q=_(),oe=await(0,Zp.pollForResponse)(d,O,P,q,n);E=oe.certificate,K=oe.reply}let j=r.annotations.includes(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS),G=r.annotations.includes(Ye.ACTOR_METHOD_WITH_CERTIFICATE),z=Object.assign(Object.assign({},F),{requestDetails:A});if(K!==void 0)return j&&G?{httpDetails:z,certificate:E,result:Vi(r.retTypes,K)}:G?{certificate:E,result:Vi(r.retTypes,K)}:j?{httpDetails:z,result:Vi(r.retTypes,K)}:Vi(r.retTypes,K);if(r.retTypes.length===0)return j?{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 Ll(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:cr.Principal.from(t.effectiveCanisterId)};let i=n[0],s=cr.Principal.fromHex("");return i&&typeof i=="object"&&i.target_canister&&r==="install_chunked_code"&&(s=cr.Principal.from(i.target_canister)),i&&typeof i=="object"&&i.canister_id&&(s=cr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return ks.createActor(pE.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:cr.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}Ye.getManagementCanister=Ll;var ef=class extends ks{constructor(e){super(e)}};Ye.AdvancedActor=ef});var Xp=ee(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});tf.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 Qp=ee($i=>{"use strict";var gE=$i&&$i.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty($i,"__esModule",{value:!0});$i.createAssetCanisterActor=void 0;var mE=za(),bE=gE(Xp());function _E(t){return mE.Actor.createActor(bE.default,t)}$i.createAssetCanisterActor=_E});var Lp=ee($r=>{"use strict";var wE=$r&&$r.__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=$r&&$r.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),xE=$r&&$r.__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)&&wE(e,t,r);return EE(e,t),e};Object.defineProperty($r,"__esModule",{value:!0});$r.fetchCandid=void 0;var vE=Ut(),TE=xE(Bs()),AE=zl(),SE=za();async function BE(t,e){e||(e=await AE.HttpAgent.create());let n=(await TE.request({agent:e,canisterId:vE.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 SE.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}$r.fetchCandid=BE});var Qt=ee(Re=>{"use strict";var ey=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]}),OE=Re&&Re.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),It=Re&&Re.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ey(e,t,r)},rf=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)&&ey(e,t,r);return OE(e,t),e};Object.defineProperty(Re,"__esModule",{value:!0});Re.Cbor=Re.CanisterStatus=Re.polling=void 0;It(za(),Re);It(Ss(),Re);It(Xo(),Re);It(gs(),Re);It(Hu(),Re);It(Qp(),Re);It(Oi(),Re);It(Vl(),Re);It(Lp(),Re);It(Gl(),Re);It($l(),Re);It(ds(),Re);It(wl(),Re);It(Vt(),Re);It(Zu(),Re);Re.polling=rf(Ya());Re.CanisterStatus=rf(Bs());Re.Cbor=rf(ys());It(Ya(),Re)});var mt=ee((i3,yy)=>{"use strict";var cf=Object.defineProperty,NE=Object.getOwnPropertyDescriptor,RE=Object.getOwnPropertyNames,PE=Object.prototype.hasOwnProperty,IE=(t,e)=>{for(var r in e)cf(t,r,{get:e[r],enumerable:!0})},UE=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of RE(e))!PE.call(t,i)&&i!==r&&cf(t,i,{get:()=>e[i],enumerable:!(n=NE(e,i))||n.enumerable});return t},FE=t=>UE(cf({},"__esModule",{value:!0}),t),iy={};IE(iy,{AgentManager:()=>KE,Canister:()=>VE,FromStringToTokenError:()=>sy,ICPToken:()=>jE,InvalidPercentageError:()=>fy,NullishError:()=>dy,TokenAmount:()=>kE,TokenAmountV2:()=>HE,arrayBufferToUint8Array:()=>JE,arrayOfNumberToUint8Array:()=>QE,asNonNullish:()=>YE,asciiStringToByteArray:()=>LE,assertNonNullish:()=>Ks,assertPercentageNumber:()=>WE,bigEndianCrc32:()=>ax,bigIntToUint8Array:()=>DE,candidNumberArrayToBigInt:()=>rx,convertStringToE8s:()=>oy,createAgent:()=>uy,createServices:()=>GE,debounce:()=>dx,decodeBase32:()=>ix,defaultAgent:()=>cy,encodeBase32:()=>nx,fromDefinedNullable:()=>px,fromNullable:()=>uf,fromNullishNullable:()=>yx,hexStringToUint8Array:()=>ex,isEmptyString:()=>$E,isNullish:()=>Da,jsonReplacer:()=>gx,jsonReviver:()=>mx,nonNullish:()=>Kr,notEmptyString:()=>ay,nowInBigIntNanoSeconds:()=>fx,numberToUint8Array:()=>ZE,principalToSubAccount:()=>bx,secondsToDuration:()=>ux,smallerVersion:()=>_x,toNullable:()=>hx,uint8ArrayToArrayOfNumber:()=>XE,uint8ArrayToBigInt:()=>zE,uint8ArrayToHexString:()=>tx});yy.exports=FE(iy);var sy=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(sy||{}),ME=BigInt(1e8),CE=8,oy=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)*ME}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},qE=({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},jE={symbol:"ICP",name:"Internet Computer",decimals:8},kE=class Vs{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 Vs(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=oy(e);return typeof n=="bigint"?new Vs(n,r):n}static fromNumber({amount:e,token:r}){let n=Vs.fromString({amount:e.toString(),token:r});if(n instanceof Vs)return n;throw n===0?new Error(`Number ${e} has more than 8 decimals`):new Error(`Invalid number ${e}`)}toE8s(){return this.e8s}},HE=class $s{constructor(e,r){this.ulps=e,this.token=r}static fromUlps({amount:e,token:r}){return new $s(e,r)}static fromString({amount:e,token:r}){let n=qE({amount:e,decimals:r.decimals});return typeof n=="bigint"?new $s(n,r):n}static fromNumber({amount:e,token:r}){let n=$s.fromString({amount:e.toFixed(Math.min(CE,r.decimals)),token:r});if(n instanceof $s)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)}},VE=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}},ty=Qt(),nf=Qt(),Da=t=>t==null,Kr=t=>!Da(t),ay=t=>Kr(t)&&t!=="",$E=t=>!ay(t),cy=()=>nf.HttpAgent.createSync({host:"https://icp-api.io",identity:new nf.AnonymousIdentity}),uy=async({identity:t,host:e,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await nf.HttpAgent.create({identity:t,...Kr(e)&&{host:e},verifyQuerySignatures:n,...Kr(i)&&{retryTimes:i},shouldFetchRootKey:r}),KE=class ly{constructor(e){this.config=e,this.agents=void 0}static create(e){return new ly(e)}async getAgent({identity:e}){let r=e.getPrincipal().toText();if(Da(this.agents)||Da(this.agents[r])){let n=await uy({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}},GE=({options:{canisterId:t,serviceOverride:e,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:o,certifiedIdlFactory:a})=>{let c=n??cy(),f=e??ty.Actor.createActor(o,{agent:c,canisterId:t,callTransform:i,queryTransform:s}),d=r??ty.Actor.createActor(a,{agent:c,canisterId:t,callTransform:i,queryTransform:s});return{service:f,certifiedService:d,agent:c,canisterId:t}},fy=class extends Error{},dy=class extends Error{},Ks=(t,e)=>{if(t==null)throw new dy(e)},YE=(t,e)=>(Ks(t,e),t),WE=t=>{if(t<0||t>100)throw new fy(`${t} is not a valid percentage number.`)},zE=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}},DE=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)},ZE=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)},JE=t=>new Uint8Array(t),XE=t=>Array.from(t),QE=t=>new Uint8Array(t),LE=t=>Array.from(t).map(e=>e.charCodeAt(0)),ex=t=>{let e=t.match(/.{1,2}/g);return Ks(e,"Invalid hex string."),Uint8Array.from(e.map(r=>parseInt(r,16)))},tx=t=>(t instanceof Uint8Array||(t=Uint8Array.from(t)),t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")),rx=t=>{let e=0n;for(let r=t.length-1;r>=0;r--)e=(e<<32n)+BigInt(t[r]);return e},Za="abcdefghijklmnopqrstuvwxyz234567",Ki=Object.create(null);for(let t=0;t<Za.length;t++)Ki[Za[t]]=t;Ki[0]=Ki.o;Ki[1]=Ki.i;var nx=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+=Za[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Za[r>>3]:"")};function ix(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Ki[o.toLowerCase()];Ks(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 sx=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]),ox=t=>{let e=-1;for(let r=0;r<t.length;r++){let n=(t[r]^e)&255;e=sx[n]^e>>>8}return(e^-1)>>>0},ax=t=>{let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,ox(t),!1),new Uint8Array(e)},cx={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"},ux=({seconds:t,i18n:e=cx})=>{let r=t/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=lx(i);return i-=hy(s),[Hs("year",s),Hs("day",i),Hs("hour",n),Hs("minute",r),...t>BigInt(0)&&t<BigInt(60)?[Hs("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(", ")},lx=t=>{let e=t/BigInt(365);for(;hy(e)>t;)e--;return e},hy=t=>{let e=t/BigInt(4);return t*BigInt(365)+e},Hs=(t,e)=>({labelKey:t,amount:Number(e)}),fx=()=>BigInt(Date.now())*BigInt(1e6),dx=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},hx=t=>Kr(t)?[t]:[],uf=t=>t?.[0],px=t=>{let e=uf(t);return Ks(e),e},yx=t=>uf(t??[]),py=Ut(),sf="__bigint__",of="__principal__",af="__uint8array__",gx=(t,e)=>typeof e=="bigint"?{[sf]:`${e}`}:Kr(e)&&e instanceof py.Principal?{[of]:e.toText()}:Kr(e)&&e instanceof Uint8Array?{[af]:Array.from(e)}:e,mx=(t,e)=>{let r=n=>e[n];return Kr(e)&&typeof e=="object"&&sf in e?BigInt(r(sf)):Kr(e)&&typeof e=="object"&&of in e?py.Principal.fromText(r(of)):Kr(e)&&typeof e=="object"&&af in e?Uint8Array.from(r(af)):e},bx=t=>{let e=t.toUint8Array(),r=new Uint8Array(32);return r[0]=e.length,r.set(e,1),r},ry=(t,e)=>e>t.length?[...t,...[...Array(e-t.length).keys()].map(()=>0)]:t,ny=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)},_x=({minVersion:t,currentVersion:e})=>{let r=ry(t.split(".").map(ny),3).join(".");return ry(e.split(".").map(ny),3).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var my=ee(Gr=>{"use strict";var Qa=Gr&&Gr.__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},Pn=Gr&&Gr.__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)},Ja,Xa,Yi,Wi;Object.defineProperty(Gr,"__esModule",{value:!0});Gr.Ed25519KeyIdentity=Gr.Ed25519PublicKey=void 0;var wx=Qt(),Lt=Qt(),Gs=kl();function gy(t){return t!==null&&typeof t=="object"}var ri=class t{constructor(e){if(Ja.set(this,void 0),Xa.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Qa(this,Ja,e,"f"),Qa(this,Xa,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,Lt.fromHex)(e);return this.fromRaw(r)}else if(gy(e)){let r=e;if(gy(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Lt.bufFromBufLike)(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=(0,Lt.wrapDER)(e,Lt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,Lt.unwrapDER)(e,Lt.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Pn(this,Ja,"f")}get derKey(){return Pn(this,Xa,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Gr.Ed25519PublicKey=ri;Ja=new WeakMap,Xa=new WeakMap;ri.RAW_KEY_LENGTH=32;var ff=class t extends Lt.SignIdentity{constructor(e,r){super(),Yi.set(this,void 0),Wi.set(this,void 0),Qa(this,Yi,ri.from(e),"f"),Qa(this,Wi,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=Gs.ed25519.utils.randomPrivateKey()),(0,wx.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=Gs.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(ri.fromDer((0,Lt.fromHex)(r)),(0,Lt.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(ri.fromRaw(e),r)}static fromSecretKey(e){let r=Gs.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,Lt.toHex)(Pn(this,Yi,"f").toDer()),(0,Lt.toHex)(Pn(this,Wi,"f"))]}getKeyPair(){return{secretKey:Pn(this,Wi,"f"),publicKey:Pn(this,Yi,"f")}}getPublicKey(){return Pn(this,Yi,"f")}async sign(e){let r=new Uint8Array(e),n=(0,Lt.uint8ToBuf)(Gs.ed25519.sign(r,Pn(this,Wi,"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,Lt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Gs.ed25519.verify(s,i,o)}};Gr.Ed25519KeyIdentity=ff;Yi=new WeakMap,Wi=new WeakMap});var _y=ee(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});ni.ECDSAKeyIdentity=ni.CryptoError=void 0;var Ex=Qt(),La=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};ni.CryptoError=La;function by(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 La("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var ec=class t extends Ex.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=by(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=by(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)}};ni.ECDSAKeyIdentity=ec;ni.default=ec});var hf=ee(Un=>{"use strict";var xx=Un&&Un.__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},Ys=Un&&Un.__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)},In;Object.defineProperty(Un,"__esModule",{value:!0});Un.PartialIdentity=void 0;var vx=Ut(),df=class{constructor(e){In.set(this,void 0),xx(this,In,e,"f")}get rawKey(){return Ys(this,In,"f").rawKey}get derKey(){return Ys(this,In,"f").derKey}toDer(){return Ys(this,In,"f").toDer()}getPublicKey(){return Ys(this,In,"f")}getPrincipal(){return vx.Principal.from(Ys(this,In,"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.")}};Un.PartialIdentity=df;In=new WeakMap});var wy=ee(De=>{"use strict";var Tx=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]}),Ax=De&&De.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Sx=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)&&Tx(e,t,r);return Ax(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},Ox=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)},Nx=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},tc;Object.defineProperty(De,"__esModule",{value:!0});De.isDelegationValid=De.PartialDelegationIdentity=De.DelegationIdentity=De.DelegationChain=De.Delegation=void 0;var Fn=Qt(),yf=Ut(),Ws=Sx(ps()),Rx=hf(),Px=new TextEncoder().encode("ic-request-auth-delegation"),Ix=new TextEncoder().encode(`
|
|
57
|
+
ic-request`);function pf(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,Fn.fromHex)(t)}var zs=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return Ws.value.map(Object.assign({pubkey:Ws.value.bytes(this.pubkey),expiration:Ws.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Ws.value.array(this.targets.map(e=>Ws.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Fn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};De.Delegation=zs;async function Ux(t,e,r,n){let i=new zs(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...Px,...new Uint8Array((0,Fn.requestIdOf)(Object.assign({},i)))]),o=await t.sign(s);return{delegation:i,signature:o}}var gf=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 Ux(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 zs(pf(c),BigInt("0x"+f),d&&d.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return yf.Principal.fromHex(h)})),signature:pf(a)}});return new this(i,pf(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,Fn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Fn.toHex)(n)}}),publicKey:(0,Fn.toHex)(this.publicKey)}}};De.DelegationChain=gf;var mf=class extends Fn.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=Nx(e,["body"]),i=await(0,Fn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Ix,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};De.DelegationIdentity=mf;var bf=class t extends Rx.PartialIdentity{constructor(e,r){super(e),tc.set(this,void 0),Bx(this,tc,r,"f")}get delegation(){return Ox(this,tc,"f")}static fromDelegation(e,r){return new t(e,r)}};De.PartialDelegationIdentity=bf;tc=new WeakMap;function Fx(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"?yf.Principal.fromText(i):i)):r.push(typeof n=="string"?yf.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=Fx});var Ey=ee(Mn=>{"use strict";var Mx=Mn&&Mn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Mn,"__esModule",{value:!0});Mn.WebAuthnIdentity=Mn.CosePublicKey=void 0;var ii=Qt(),_f=Mx(Vo()),Cx=kn(),qx=xi();function jx(t){return(0,ii.wrapDER)(t,ii.DER_COSE_OID).buffer}function kx(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 rc=class{constructor(e){this._cose=e,this._encodedKey=jx(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};Mn.CosePublicKey=rc;function Hx(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function Vx(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:Hx(),pubKeyCredParams:[{type:"public-key",alg:wf.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Cx.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,qx.bufFromBufLike)(e.rawId)}}var wf;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(wf||(wf={}));var Ef=class extends ii.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new rc(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,ii.fromHex)(n),(0,ii.fromHex)(r),void 0)}static async create(e){var r;let n=await Vx(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=_f.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,kx(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=_f.default.encode(new _f.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,ii.toHex)(this._publicKey.getCose()),rawId:(0,ii.toHex)(this.rawId)}}};Mn.WebAuthnIdentity=Ef});var vy=ee(We=>{"use strict";var $x=We&&We.__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]}),vf=We&&We.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&$x(e,t,r)};Object.defineProperty(We,"__esModule",{value:!0});We.Secp256k1KeyIdentity=We.ED25519_OID=We.DER_COSE_OID=We.unwrapDER=We.wrapDER=We.WebAuthnIdentity=We.Ed25519PublicKey=We.Ed25519KeyIdentity=void 0;var xy=my();Object.defineProperty(We,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return xy.Ed25519KeyIdentity}});Object.defineProperty(We,"Ed25519PublicKey",{enumerable:!0,get:function(){return xy.Ed25519PublicKey}});vf(_y(),We);vf(wy(),We);vf(hf(),We);var Kx=Ey();Object.defineProperty(We,"WebAuthnIdentity",{enumerable:!0,get:function(){return Kx.WebAuthnIdentity}});var nc=Qt();Object.defineProperty(We,"wrapDER",{enumerable:!0,get:function(){return nc.wrapDER}});Object.defineProperty(We,"unwrapDER",{enumerable:!0,get:function(){return nc.unwrapDER}});Object.defineProperty(We,"DER_COSE_OID",{enumerable:!0,get:function(){return nc.DER_COSE_OID}});Object.defineProperty(We,"ED25519_OID",{enumerable:!0,get:function(){return nc.ED25519_OID}});var xf=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};We.Secp256k1KeyIdentity=xf});var Af=ee(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.IdleManager=void 0;var Ty=["mousedown","mousemove","keydown","touchstart","wheel"],Tf=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),Ty.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);Ty.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)}};ic.IdleManager=Tf});function Yx(){return Ay||(Ay=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Wx(){return Sy||(Sy=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function zx(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(ur(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(()=>{}),Nf.set(e,t),e}function Dx(t){if(Bf.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)});Bf.set(t,e)}function Ny(t){Of=t(Of)}function Zx(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Ds(this),e,...r);return Oy.set(n,e.sort?e.sort():[e]),ur(n)}:Wx().includes(t)?function(...e){return t.apply(Ds(this),e),ur(By.get(this))}:function(...e){return ur(t.apply(Ds(this),e))}}function Jx(t){return typeof t=="function"?Zx(t):(t instanceof IDBTransaction&&Dx(t),Gx(t,Yx())?new Proxy(t,Of):t)}function ur(t){if(t instanceof IDBRequest)return zx(t);if(Sf.has(t))return Sf.get(t);let e=Jx(t);return e!==t&&(Sf.set(t,e),Nf.set(e,t)),e}var Gx,Ay,Sy,By,Bf,Oy,Sf,Nf,Of,Ds,Rf=Xf(()=>{Gx=(t,e)=>e.some(r=>t instanceof r);By=new WeakMap,Bf=new WeakMap,Oy=new WeakMap,Sf=new WeakMap,Nf=new WeakMap;Of={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Bf.get(t);if(e==="objectStoreNames")return t.objectStoreNames||Oy.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ur(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}};Ds=t=>Nf.get(t)});var Py={};Lg(Py,{deleteDB:()=>Qx,openDB:()=>Xx,unwrap:()=>Ds,wrap:()=>ur});function Xx(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=ur(o);return n&&o.addEventListener("upgradeneeded",c=>{n(ur(o.result),c.oldVersion,c.newVersion,ur(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),a}function Qx(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),ur(r).then(()=>{})}function Ry(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Pf.get(e))return Pf.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=e8.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||Lx.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 Pf.set(e,s),s}var Lx,e8,Pf,Iy=Xf(()=>{Rf();Rf();Lx=["get","getKey","getAll","getAllKeys","count"],e8=["put","add","delete","clear"],Pf=new Map;Ny(t=>({...t,get:(e,r,n)=>Ry(e,r)||t.get(e,r,n),has:(e,r)=>!!Ry(e,r)||t.has(e,r)}))});var Uf=ee(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.IdbKeyVal=void 0;var t8=(Iy(),em(Py)),Zs=oc(),Uy="auth-client-db",Fy="ic-keyval",r8=async(t=Uy,e=Fy,r)=>(Zs.isBrowser&&(localStorage!=null&&localStorage.getItem(Zs.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Zs.KEY_STORAGE_DELEGATION),localStorage.removeItem(Zs.KEY_STORAGE_KEY)),await(0,t8.openDB)(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function n8(t,e,r){return await t.get(e,r)}async function i8(t,e,r,n){return await t.put(e,n,r)}async function s8(t,e,r){return await t.delete(e,r)}var If=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=Uy,storeName:n=Fy,version:i=Zs.DB_VERSION}=e??{},s=await r8(r,n,i);return new t(s,n)}async set(e,r){return await i8(this._db,this._storeName,e,r)}async get(e){var r;return(r=await n8(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await s8(this._db,this._storeName,e)}};sc.IdbKeyVal=If});var oc=ee(nt=>{"use strict";var o8=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},a8=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)},ac;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 c8=Uf();nt.KEY_STORAGE_KEY="identity";nt.KEY_STORAGE_DELEGATION="delegation";nt.KEY_VECTOR="iv";nt.DB_VERSION=1;nt.isBrowser=typeof window<"u";var Ff=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=Ff;var Mf=class{constructor(e){ac.set(this,void 0),o8(this,ac,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}c8.IdbKeyVal.create(a8(this,ac,"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=Mf;ac=new WeakMap});var Hf=ee(Le=>{"use strict";var u8=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]}),l8=Le&&Le.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&u8(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 My=Qt(),er=vy(),Cy=Af(),vt=oc(),cc=oc();Object.defineProperty(Le,"IdbStorage",{enumerable:!0,get:function(){return cc.IdbStorage}});Object.defineProperty(Le,"LocalStorage",{enumerable:!0,get:function(){return cc.LocalStorage}});Object.defineProperty(Le,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return cc.KEY_STORAGE_DELEGATION}});Object.defineProperty(Le,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return cc.KEY_STORAGE_KEY}});var f8=Uf();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return f8.IdbKeyVal}});var d8="https://identity.ic0.app",h8="#authorize",Cf="ECDSA",qf="Ed25519",p8=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";l8(Af(),Le);var kf=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 vt.IdbStorage,o=(n=e.keyType)!==null&&n!==void 0?n:Cf,a=null;if(e.identity)a=e.identity;else{let h=await s.get(vt.KEY_STORAGE_KEY);if(!h&&vt.isBrowser)try{let m=new vt.LocalStorage,_=await m.get(vt.KEY_STORAGE_DELEGATION),u=await m.get(vt.KEY_STORAGE_KEY);_&&u&&o===Cf&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(vt.KEY_STORAGE_DELEGATION,_),await s.set(vt.KEY_STORAGE_KEY,u),h=_,await m.remove(vt.KEY_STORAGE_DELEGATION),await m.remove(vt.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(h)try{typeof h=="object"?o===qf&&typeof h=="string"?a=await er.Ed25519KeyIdentity.fromJSON(h):a=await er.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=er.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new My.AnonymousIdentity,f=null;if(a)try{let h=await s.get(vt.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=er.DelegationChain.fromJSON(h),(0,er.isDelegationValid)(f)?"toDer"in a?c=er.PartialDelegationIdentity.fromDelegation(a,f):c=er.DelegationIdentity.fromDelegation(a,f):(await jf(s),a=null))}catch(h){console.error(h),await jf(s),a=null}let d;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?d=void 0:(f||e.identity)&&(d=Cy.IdleManager.create(e.idleOptions)),a||(o===qf?(a=await er.Ed25519KeyIdentity.generate(),await s.set(vt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===Cf&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${qf}' as the key type, as it can serialize to a string`),a=await er.ECDSAKeyIdentity.generate(),await s.set(vt.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 er.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=er.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=er.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=er.DelegationIdentity.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=Cy.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(vt.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())||d8);a.hash=h8,(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,p8))};c()}_getEventHandler(e,r){return async n=>{var i,s,o;if(n.origin!==e.origin)return;let a=n.data;switch(a.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,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 jf(this._storage),this._identity=new My.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Le.AuthClient=kf;async function jf(t){await t.remove(vt.KEY_STORAGE_KEY),await t.remove(vt.KEY_STORAGE_DELEGATION),await t.remove(vt.KEY_VECTOR)}});var Ug=Ze(mt(),1);var mg=Ze(mt(),1);var Gi=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 on=class t extends Gi{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 lf=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var yg=Ze(Hf(),1),gg=Ze(mt(),1);var qy=BigInt(144e11),jy=!1,ky={width:576,height:576},Hy={width:505,height:705},Vy="internetcomputer.org";var Js=Ze(mt(),1);var zi="http://127.0.0.1:5987",$y="rdmx6-jaaaa-aaaaa-aaadq-cai";var Yr=class t extends Gi{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 Vf=Ze(mt(),1);var uc=Ze(mt(),1),Ky=async t=>{let e=new Blob([JSON.stringify(t,uc.jsonReplacer)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},lc=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(),uc.jsonReviver)},fc=()=>typeof window<"u";var $f=({width:t,height:e})=>{if(!fc()||(0,Vf.isNullish)(window)||(0,Vf.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 dc=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=Yr.getInstance().get()?.container;if((0,Js.isNullish)(n)||n===!1)return`https://identity.${this.#e??Vy}`;let i=Yr.getInstance().get(),s=(0,Js.nonNullish)(i)&&(0,Js.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:$y,{host:o,protocol:a}=new URL(n===!0?zi:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:$f(ky)},identityProvider:r()}}},Gy=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:$f(Hy)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var Wy=Ze(Qt(),1),hc=Ze(mt(),1);var Yy=Ze(Qt(),1),si=Ze(mt(),1);var Di=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,si.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...r}){let n=e.getPrincipal().toText();if((0,si.isNullish)(this.#e)||(0,si.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,si.nonNullish)(n)&&n!==!1?n===!0?zi:n:"https://icp-api.io",o=(0,si.nonNullish)(n);return await Yy.HttpAgent.create({identity:e,shouldFetchRootKey:o,host:s,...r&&{fetch:r}})}};var Zi=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,hc.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,hc.isNullish)(this.#e)||(0,hc.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 Di.getInstance().getAgent(n);return Wy.Actor.createActor(e,{agent:i,canisterId:r})}};var pc=class extends Error{},yc=class extends Error{},gc=class extends Error{},mc=class extends Error{},bc=class extends Error{};var zy=Ze(Hf(),1),_c=()=>zy.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Qs=Ze(mt(),1);var Kf="juno.datastore.error.user.cannot_update";var Gf=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;var xr=Ze(mt(),1);var Dy=async({data:t})=>{try{return await lc(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var oi=Ze(mt(),1);var Yf=async t=>{let{data:e,version:r,description:n}=t;return{description:(0,oi.toNullable)(n),data:await Ky(e),version:(0,oi.toNullable)(r)}},Wf=t=>{let{version:e}=t;return{version:(0,oi.toNullable)(e)}},Xs=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:(0,oi.fromNullable)(i),owner:r.toText(),data:await lc(s),version:(0,oi.fromNullable)(n),...o}};var Jy=Ze(Ut(),1),it=Ze(mt(),1);var Zy=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 bc("Invalid list matcher for timestamp",t)}},Cn=({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:Zy(t.createdAt),updated_at:Zy(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"?Jy.Principal.fromText(n):n)});var Ly=Ze(mt(),1);var Xy=({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}),O=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}),T=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),P=t.Record({key:O,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,T)),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),external_alternative_origins:t.Opt(t.Vec(t.Text))}),A=t.Record({internet_identity:t.Opt(F)}),K=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),E=t.Record({max_memory_size:t.Opt(K)}),j=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),G=t.Variant({Deny:t.Null,Allow:t.Null}),z=t.Record({status_code:t.Nat16,location:t.Text}),q=t.Record({iframe:t.Opt(j),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(G),redirects:t.Opt(t.Vec(t.Tuple(t.Text,z)))}),oe=t.Record({db:t.Opt(E),authentication:t.Opt(A),storage:q}),Q=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)}),ie=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}),N=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ie),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,max_changes_per_user:t.Opt(t.Nat32)}),B=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)}),R=t.Record({memory:ie,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}),V=t.Variant({Callback:t.Record({token:R,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(V),status_code:t.Nat16}),ce=t.Record({token:t.Opt(R),body:t.Vec(t.Nat8)}),ae=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}),D=t.Record({batch_id:t.Nat}),M=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,P)),items_length:t.Nat64}),y=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),L=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,Q)),items_length:t.Nat64}),re=t.Record({stable:t.Nat64,heap:t.Nat64}),le=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:f,expires_at:t.Opt(t.Nat64)}),X=t.Record({controller:le,controllers:t.Vec(t.Principal)}),l=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),p=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ie),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,max_changes_per_user:t.Opt(t.Nat32)}),g=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),I=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(P)],["query"]),get_auth_config:t.Func([],[t.Opt(A)],["query"]),get_config:t.Func([],[oe],[]),get_db_config:t.Func([],[t.Opt(E)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(Q)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(P)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(Q)))],["query"]),get_rule:t.Func([m,t.Text],[t.Opt(N)],["query"]),get_storage_config:t.Func([],[q],["query"]),http_request:t.Func([B],[Z],["query"]),http_request_streaming_callback:t.Func([R],[ce],["query"]),init_asset_upload:t.Func([ae],[D],[]),list_assets:t.Func([t.Text,a],[M],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,y))],["query"]),list_docs:t.Func([t.Text,a],[L],["query"]),list_rules:t.Func([m],[t.Vec(t.Tuple(t.Text,N))],["query"]),memory_size:t.Func([],[re],["query"]),set_auth_config:t.Func([A],[],[]),set_controllers:t.Func([X],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([E],[],[]),set_doc:t.Func([t.Text,t.Text,l],[Q],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,l))],[t.Vec(t.Tuple(t.Text,Q))],[]),set_rule:t.Func([m,t.Text,p],[N],[]),set_storage_config:t.Func([q],[],[]),upload_asset_chunk:t.Func([g],[I],[]),version:t.Func([],[t.Text],["query"])})};var wc=Ze(mt(),1);var Qy=({satelliteId:t,container:e})=>{let{satelliteId:r}=zf({satelliteId:t}),{container:n}=Df({container:e});if((0,wc.nonNullish)(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?zi:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},zf=({satelliteId:t})=>(0,wc.nonNullish)(t)?{satelliteId:t}:Yr.getInstance().get()??{satelliteId:void 0},Df=({container:t})=>(0,wc.nonNullish)(t)?{container:t}:Yr.getInstance().get()??{container:void 0};var lt=t=>tg({idlFactory:Xy,buildType:"stock",...t}),eg=({idlFactory:t,...e})=>tg({idlFactory:t,buildType:"extended",...e}),tg=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=zf({satelliteId:t});(0,Ly.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Df({container:e});return await Zi.getInstance().getActor({satelliteId:n,container:i,...r})};var rg=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await lt(r),i=(0,xr.fromNullable)(await n(t,e));if(!(0,xr.isNullish)(i))return Xs({doc:i,key:e})},ng=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await lt(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=(0,xr.fromNullable)(a);s.push((0,xr.nonNullish)(c)?await Xs({key:o,doc:c}):void 0)}return s},ig=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await lt(r),{key:i}=e,s=await Yf(e),o=await n(t,i,s);return await Xs({key:i,doc:o})},sg=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await lt(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await Yf(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await Xs({key:o,doc:a}));return s},og=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await lt(r),{key:i}=e;return n(t,i,Wf(e))},ag=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await lt(e),n=t.map(({collection:i,doc:s})=>[i,s.key,Wf(s)]);await r(n)},cg=async({collection:t,filter:e,satellite:r})=>{let{del_filtered_docs:n}=await lt(r);return n(t,Cn(e))},ug=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await lt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(t,Cn(e)),f=[];for(let[d,h]of i){let{data:m,owner:_,description:u,version:O,...T}=h;f.push({key:d,description:(0,xr.fromNullable)(u),owner:_.toText(),data:await Dy({data:m}),version:(0,xr.fromNullable)(O),...T})}return{items:f,items_length:o,items_page:(0,xr.fromNullable)(s),matches_length:a,matches_pages:(0,xr.fromNullable)(c)}},lg=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await lt(r);return n(t,Cn(e))};var fg=Ze(Qt(),1);var et=t=>t!==void 0?t:Ec()??new fg.AnonymousIdentity;var dg=async({satellite:t,...e})=>{let r=et(t?.identity);return await rg({...e,satellite:{...t,identity:r}})},q6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ng({...e,satellite:{...t,identity:r}})},hg=async({satellite:t,...e})=>{let r=et(t?.identity);return await ig({...e,satellite:{...t,identity:r}})},j6=async({satellite:t,...e})=>{let r=et(t?.identity);return await sg({...e,satellite:{...t,identity:r}})},k6=async({satellite:t,...e})=>{let r=et(t?.identity);return await og({...e,satellite:{...t,identity:r}})},H6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ag({...e,satellite:{...t,identity:r}})},V6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await cg({...r,filter:e??{},satellite:{...t,identity:n}})},$6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await ug({...r,filter:e??{},satellite:{...t,identity:n}})},K6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await lg({...r,filter:e??{},satellite:{...t,identity:n}})};var pg=async t=>{let e=Ec();if((0,Qs.isNullish)(e))throw new mc("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=()=>dg({collection:"#user",key:r}),i=await n();if((0,Qs.nonNullish)(i))return i;try{return await y8({userId:r,provider:t})}catch(s){if(Gf({error:s,type:Kf})){let o=await n();if((0,Qs.nonNullish)(o))return o}throw s}},y8=({userId:t,...e})=>hg({collection:"#user",doc:{key:t,data:e}});var Wr,Zf=async t=>{if(Wr=Wr??await _c(),!(await Wr?.isAuthenticated()??!1))return;let r=await pg(t);on.getInstance().set(r)},g8=t=>new Promise(async(e,r)=>{if((0,gg.isNullish)(Wr)){r(new yc("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=t?.provider??new dc({});await Wr.login({onSuccess:async()=>{await Zf(n.id),e()},onError:i=>{if(i===yg.ERROR_USER_INTERRUPT){r(new gc(i));return}r(new pc(i))},maxTimeToLive:t?.maxTimeToLive??qy,allowPinAuthentication:t?.allowPin??jy,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Jf=async()=>{await Wr?.logout(),Wr=null,on.getInstance().reset(),Zi.getInstance().reset(),Di.getInstance().reset(),Wr=await _c()},Ec=()=>Wr?.getIdentity(),m8=async()=>(Wr??await _c()).getIdentity();var bg=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{lf({message:"junoSignOutAuthTimer"}),await Jf()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":lf({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},on.getInstance().subscribe(i=>{if((0,mg.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var _g=()=>{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()},wg=()=>{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 hT=async({idlFactory:t,satellite:e})=>{let r=et(e?.identity);return await eg({idlFactory:t,...e,identity:r})};var to=Ze(mt(),1);var eo=Ze(mt(),1);var Ls=Ze(mt(),1);var Eg=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,Ls.toNullable)(i),encoding_type:(0,Ls.toNullable)(o),description:(0,Ls.toNullable)(a)}),h=19e5,m=[],_=fc()?new Blob([await t.arrayBuffer()]):t,u=0n;for(let P=0;P<_.size;P+=h){let F=_.slice(P,P+h);m.push({batchId:d,chunk:F,actor:c,orderId:u}),u++}let O=[];for await(let P of b8({uploadChunks:m}))O=[...O,...P];let T=n.find(([P,F])=>P.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:O.map(({chunk_id:P})=>P),headers:[...n,...T||[]]})};async function*b8({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=>_8(i)))}}var _8=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,Ls.toNullable)(n)});var xg=async({satellite:t,...e})=>{let r=await lt(t);await Eg({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},vg=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await lt(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(t,Cn(r));return{items:i.map(([f,d])=>d),items_length:s,items_page:(0,eo.fromNullable)(o),matches_length:a,matches_pages:(0,eo.fromNullable)(c)}},Tg=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await lt(e);return n(t,Cn(r))},Ag=async({collection:t,fullPath:e,satellite:r})=>(await lt(r)).del_asset(t,e),Sg=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await lt(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},Bg=async({collection:t,satellite:e,filter:r})=>{let{del_filtered_assets:n}=await lt(e);return n(t,Cn(r))},Og=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await lt(r);return(0,eo.fromNullable)(await n(t,e))},Ng=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await lt(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>(0,eo.fromNullable)(o))};var Rg=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var ST=t=>Pg(t),BT=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 xg({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:m,description:c}),{downloadUrl:Ig({satellite:m,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},OT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)},{items:i,...s}=await vg({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:O})=>{let T=(0,to.fromNullable)(c);return{fullPath:a,description:(0,to.fromNullable)(h),name:f,downloadUrl:Ig({satellite:n,assetKey:{fullPath:a,token:T}}),token:T,headers:m,encodings:_.reduce((P,[F,{modified:A,sha256:K,total_length:E}])=>({...P,[F]:{modified:A,sha256:Rg(K),total_length:E}}),{}),owner:d.toText(),created_at:u,updated_at:O}});return{items:o,assets:o,...s}},NT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await Tg({collection:t,satellite:n,filter:r??{}})},RT=({collection:t,fullPath:e,satellite:r})=>Ag({collection:t,fullPath:e,satellite:{...r,identity:et(r?.identity)}}),PT=({assets:t,satellite:e})=>Sg({assets:t,satellite:{...e,identity:et(e?.identity)}}),IT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await Bg({collection:t,satellite:n,filter:r??{}})},UT=async({satellite:t,...e})=>{let r=et(t?.identity);return await Og({...e,satellite:{...t,identity:r}})},FT=async({satellite:t,...e})=>{let r=et(t?.identity);return await Ng({...e,satellite:{...t,identity:r}})},Ig=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${Qy(n)}${t}${(0,to.nonNullish)(e)?`?token=${e}`:""}`};var w8=t=>{let e=t?.satelliteId??_g();(0,Ug.assertNonNullish)(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??wg();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},VT=t=>E8(t),E8=async t=>{let e=w8(t);Yr.getInstance().set(e),await Zf();let r=e.workers?.auth!==void 0?bg(e.workers.auth):void 0;return[...r?[r]:[]]},$T=t=>on.getInstance().subscribe(t);export{mc as InitError,dc as InternetIdentityProvider,bc as ListError,Gy as NFIDProvider,pc as SignInError,yc as SignInInitError,gc as SignInUserInterruptError,$T as authSubscribe,NT as countAssets,K6 as countDocs,RT as deleteAsset,k6 as deleteDoc,IT as deleteFilteredAssets,V6 as deleteFilteredDocs,PT as deleteManyAssets,H6 as deleteManyDocs,Ig as downloadUrl,UT as getAsset,dg as getDoc,FT as getManyAssets,q6 as getManyDocs,hT as getSatelliteExtendedActor,VT as initJuno,E8 as initSatellite,OT as listAssets,$6 as listDocs,hg as setDoc,j6 as setManyDocs,g8 as signIn,Jf as signOut,m8 as unsafeIdentity,ST as uploadBlob,BT as uploadFile};
|
|
58
58
|
/*! Bundled license information:
|
|
59
59
|
|
|
60
60
|
ieee754/index.js:
|