@junobuild/core-standalone 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +67 -22
- package/dist/browser/index.js.map +4 -4
- package/dist/node/index.mjs +119 -55
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/functions/services/functions.services.d.ts +1 -2
- package/dist/workers/auth.worker.js +12 -32
- package/dist/workers/auth.worker.js.map +4 -4
- package/package.json +8 -8
- package/dist/browser/canisterStatus-ENEUF6W6.js +0 -2
- package/dist/browser/canisterStatus-ENEUF6W6.js.map +0 -7
- package/dist/browser/chunk-GGU5IQIJ.js +0 -53
- package/dist/browser/chunk-GGU5IQIJ.js.map +0 -7
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
var zu=Object.create;var Dn=Object.defineProperty;var Ku=Object.getOwnPropertyDescriptor;var Zu=Object.getOwnPropertyNames;var Wu=Object.getPrototypeOf,Xu=Object.prototype.hasOwnProperty;var Qu=(r,e)=>()=>(r&&(e=r(r=0)),e);var ze=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),kn=(r,e)=>{for(var t in e)Dn(r,t,{get:e[t],enumerable:!0})},Lo=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Zu(e))!Xu.call(r,i)&&i!==t&&Dn(r,i,{get:()=>e[i],enumerable:!(n=Ku(e,i))||n.enumerable});return r};var rn=(r,e,t)=>(t=r!=null?zu(Wu(r)):{},Lo(e||!r||!r.__esModule?Dn(t,"default",{value:r,enumerable:!0}):t,r)),Ju=r=>Lo(Dn({},"__esModule",{value:!0}),r);var la={};kn(la,{Buffer:()=>z,INSPECT_MAX_BYTES:()=>Qo,SlowBuffer:()=>xf,isBuffer:()=>ua,kMaxLength:()=>mf});function Zo(){_s=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=r.length;e<t;++e)Ft[e]=r[e],gt[r.charCodeAt(e)]=e;gt[45]=62,gt[95]=63}function lf(r){_s||Zo();var e,t,n,i,s,o,c=r.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=r[c-2]==="="?2:r[c-1]==="="?1:0,o=new ff(c*3/4-s),n=s>0?c-4:c;var a=0;for(e=0,t=0;e<n;e+=4,t+=3)i=gt[r.charCodeAt(e)]<<18|gt[r.charCodeAt(e+1)]<<12|gt[r.charCodeAt(e+2)]<<6|gt[r.charCodeAt(e+3)],o[a++]=i>>16&255,o[a++]=i>>8&255,o[a++]=i&255;return s===2?(i=gt[r.charCodeAt(e)]<<2|gt[r.charCodeAt(e+1)]>>4,o[a++]=i&255):s===1&&(i=gt[r.charCodeAt(e)]<<10|gt[r.charCodeAt(e+1)]<<4|gt[r.charCodeAt(e+2)]>>2,o[a++]=i>>8&255,o[a++]=i&255),o}function hf(r){return Ft[r>>18&63]+Ft[r>>12&63]+Ft[r>>6&63]+Ft[r&63]}function df(r,e,t){for(var n,i=[],s=e;s<t;s+=3)n=(r[s]<<16)+(r[s+1]<<8)+r[s+2],i.push(hf(n));return i.join("")}function Yo(r){_s||Zo();for(var e,t=r.length,n=t%3,i="",s=[],o=16383,c=0,a=t-n;c<a;c+=o)s.push(df(r,c,c+o>a?a:c+o));return n===1?(e=r[t-1],i+=Ft[e>>2],i+=Ft[e<<4&63],i+="=="):n===2&&(e=(r[t-2]<<8)+r[t-1],i+=Ft[e>>10],i+=Ft[e>>4&63],i+=Ft[e<<2&63],i+="="),s.push(i),s.join("")}function zn(r,e,t,n,i){var s,o,c=i*8-n-1,a=(1<<c)-1,h=a>>1,p=-7,g=t?i-1:0,w=t?-1:1,x=r[e+g];for(g+=w,s=x&(1<<-p)-1,x>>=-p,p+=c;p>0;s=s*256+r[e+g],g+=w,p-=8);for(o=s&(1<<-p)-1,s>>=-p,p+=n;p>0;o=o*256+r[e+g],g+=w,p-=8);if(s===0)s=1-h;else{if(s===a)return o?NaN:(x?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-h}return(x?-1:1)*o*Math.pow(2,s-n)}function Wo(r,e,t,n,i,s){var o,c,a,h=s*8-i-1,p=(1<<h)-1,g=p>>1,w=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:s-1,f=n?1:-1,N=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=p):(o=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-o))<1&&(o--,a*=2),o+g>=1?e+=w/a:e+=w*Math.pow(2,1-g),e*a>=2&&(o++,a/=2),o+g>=p?(c=0,o=p):o+g>=1?(c=(e*a-1)*Math.pow(2,i),o=o+g):(c=e*Math.pow(2,g-1)*Math.pow(2,i),o=0));i>=8;r[t+x]=c&255,x+=f,c/=256,i-=8);for(o=o<<i|c,h+=i;h>0;r[t+x]=o&255,x+=f,o/=256,h-=8);r[t+x-f]|=N*128}function jn(){return z.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ht(r,e){if(jn()<e)throw new RangeError("Invalid typed array length");return z.TYPED_ARRAY_SUPPORT?(r=new Uint8Array(e),r.__proto__=z.prototype):(r===null&&(r=new z(e)),r.length=e),r}function z(r,e,t){if(!z.TYPED_ARRAY_SUPPORT&&!(this instanceof z))return new z(r,e,t);if(typeof r=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return Es(this,r)}return Jo(this,r,e,t)}function Jo(r,e,t,n){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?wf(r,e,t,n):typeof e=="string"?yf(r,e,t):bf(r,e)}function ea(r){if(typeof r!="number")throw new TypeError('"size" argument must be a number');if(r<0)throw new RangeError('"size" argument must not be negative')}function gf(r,e,t,n){return ea(e),e<=0?Ht(r,e):t!==void 0?typeof n=="string"?Ht(r,e).fill(t,n):Ht(r,e).fill(t):Ht(r,e)}function Es(r,e){if(ea(e),r=Ht(r,e<0?0:vs(e)|0),!z.TYPED_ARRAY_SUPPORT)for(var t=0;t<e;++t)r[t]=0;return r}function yf(r,e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!z.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var n=ta(e,t)|0;r=Ht(r,n);var i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function xs(r,e){var t=e.length<0?0:vs(e.length)|0;r=Ht(r,t);for(var n=0;n<t;n+=1)r[n]=e[n]&255;return r}function wf(r,e,t,n){if(e.byteLength,t<0||e.byteLength<t)throw new RangeError("'offset' is out of bounds");if(e.byteLength<t+(n||0))throw new RangeError("'length' is out of bounds");return t===void 0&&n===void 0?e=new Uint8Array(e):n===void 0?e=new Uint8Array(e,t):e=new Uint8Array(e,t,n),z.TYPED_ARRAY_SUPPORT?(r=e,r.__proto__=z.prototype):r=xs(r,e),r}function bf(r,e){if(Pt(e)){var t=vs(e.length)|0;return r=Ht(r,t),r.length===0||e.copy(r,0,0,t),r}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||qf(e.length)?Ht(r,0):xs(r,e);if(e.type==="Buffer"&&Xo(e.data))return xs(r,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function vs(r){if(r>=jn())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+jn().toString(16)+" bytes");return r|0}function xf(r){return+r!=r&&(r=0),z.alloc(+r)}function Pt(r){return!!(r!=null&&r._isBuffer)}function ta(r,e){if(Pt(r))return r.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;typeof r!="string"&&(r=""+r);var t=r.length;if(t===0)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return Yn(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return ca(r).length;default:if(n)return Yn(r).length;e=(""+e).toLowerCase(),n=!0}}function _f(r,e,t){var n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Of(this,e,t);case"utf8":case"utf-8":return ia(this,e,t);case"ascii":return Nf(this,e,t);case"latin1":case"binary":return Rf(this,e,t);case"base64":return Bf(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Uf(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}function xr(r,e,t){var n=r[e];r[e]=r[t],r[t]=n}function ra(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=z.from(e,n)),Pt(e))return e.length===0?-1:zo(r,e,t,n,i);if(typeof e=="number")return e=e&255,z.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):zo(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function zo(r,e,t,n,i){var s=1,o=r.length,c=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,o/=2,c/=2,t/=2}function a(x,f){return s===1?x[f]:x.readUInt16BE(f*s)}var h;if(i){var p=-1;for(h=t;h<o;h++)if(a(r,h)===a(e,p===-1?0:h-p)){if(p===-1&&(p=h),h-p+1===c)return p*s}else p!==-1&&(h-=h-p),p=-1}else for(t+c>o&&(t=o-c),h=t;h>=0;h--){for(var g=!0,w=0;w<c;w++)if(a(r,h+w)!==a(e,w)){g=!1;break}if(g)return h}return-1}function Ef(r,e,t,n){t=Number(t)||0;var i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;var s=e.length;if(s%2!==0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var c=parseInt(e.substr(o*2,2),16);if(isNaN(c))return o;r[t+o]=c}return o}function vf(r,e,t,n){return Wn(Yn(e,r.length-t),r,t,n)}function na(r,e,t,n){return Wn(Df(e),r,t,n)}function If(r,e,t,n){return na(r,e,t,n)}function Af(r,e,t,n){return Wn(ca(e),r,t,n)}function Sf(r,e,t,n){return Wn(kf(e,r.length-t),r,t,n)}function Bf(r,e,t){return e===0&&t===r.length?Yo(r):Yo(r.slice(e,t))}function ia(r,e,t){t=Math.min(r.length,t);for(var n=[],i=e;i<t;){var s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=t){var a,h,p,g;switch(c){case 1:s<128&&(o=s);break;case 2:a=r[i+1],(a&192)===128&&(g=(s&31)<<6|a&63,g>127&&(o=g));break;case 3:a=r[i+1],h=r[i+2],(a&192)===128&&(h&192)===128&&(g=(s&15)<<12|(a&63)<<6|h&63,g>2047&&(g<55296||g>57343)&&(o=g));break;case 4:a=r[i+1],h=r[i+2],p=r[i+3],(a&192)===128&&(h&192)===128&&(p&192)===128&&(g=(s&15)<<18|(a&63)<<12|(h&63)<<6|p&63,g>65535&&g<1114112&&(o=g))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return Tf(n)}function Tf(r){var e=r.length;if(e<=Ko)return String.fromCharCode.apply(String,r);for(var t="",n=0;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Ko));return t}function Nf(r,e,t){var n="";t=Math.min(r.length,t);for(var i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function Rf(r,e,t){var n="";t=Math.min(r.length,t);for(var i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function Of(r,e,t){var n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);for(var i="",s=e;s<t;++s)i+=Mf(r[s]);return i}function Uf(r,e,t){for(var n=r.slice(e,t),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}function Ke(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}function at(r,e,t,n,i,s){if(!Pt(r))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(t+n>r.length)throw new RangeError("Index out of range")}function Kn(r,e,t,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(r.length-t,2);i<s;++i)r[t+i]=(e&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function Zn(r,e,t,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(r.length-t,4);i<s;++i)r[t+i]=e>>>(n?i:3-i)*8&255}function sa(r,e,t,n,i,s){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function oa(r,e,t,n,i){return i||sa(r,e,t,4),Wo(r,e,t,n,23,4),t+4}function aa(r,e,t,n,i){return i||sa(r,e,t,8),Wo(r,e,t,n,52,8),t+8}function Pf(r){if(r=Lf(r).replace(Ff,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Lf(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function Mf(r){return r<16?"0"+r.toString(16):r.toString(16)}function Yn(r,e){e=e||1/0;for(var t,n=r.length,i=null,s=[],o=0;o<n;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!i){if(t>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=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function Df(r){for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function kf(r,e){for(var t,n,i,s=[],o=0;o<r.length&&!((e-=2)<0);++o)t=r.charCodeAt(o),n=t>>8,i=t%256,s.push(i),s.push(n);return s}function ca(r){return lf(Pf(r))}function Wn(r,e,t,n){for(var i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function qf(r){return r!==r}function ua(r){return r!=null&&(!!r._isBuffer||fa(r)||Cf(r))}function fa(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function Cf(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&fa(r.slice(0,0))}var Ft,gt,ff,_s,pf,Xo,Qo,mf,Ko,Ff,ha=Qu(()=>{Ft=[],gt=[],ff=typeof Uint8Array<"u"?Uint8Array:Array,_s=!1;pf={}.toString,Xo=Array.isArray||function(r){return pf.call(r)=="[object Array]"};Qo=50;z.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;mf=jn();z.poolSize=8192;z._augment=function(r){return r.__proto__=z.prototype,r};z.from=function(r,e,t){return Jo(null,r,e,t)};z.TYPED_ARRAY_SUPPORT&&(z.prototype.__proto__=Uint8Array.prototype,z.__proto__=Uint8Array);z.alloc=function(r,e,t){return gf(null,r,e,t)};z.allocUnsafe=function(r){return Es(null,r)};z.allocUnsafeSlow=function(r){return Es(null,r)};z.isBuffer=ua;z.compare=function(e,t){if(!Pt(e)||!Pt(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,i=t.length,s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==t[s]){n=e[s],i=t[s];break}return n<i?-1:i<n?1:0};z.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}};z.concat=function(e,t){if(!Xo(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return z.alloc(0);var n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var i=z.allocUnsafe(t),s=0;for(n=0;n<e.length;++n){var o=e[n];if(!Pt(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i};z.byteLength=ta;z.prototype._isBuffer=!0;z.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)xr(this,t,t+1);return this};z.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)xr(this,t,t+3),xr(this,t+1,t+2);return this};z.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)xr(this,t,t+7),xr(this,t+1,t+6),xr(this,t+2,t+5),xr(this,t+3,t+4);return this};z.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?ia(this,0,e):_f.apply(this,arguments)};z.prototype.equals=function(e){if(!Pt(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:z.compare(this,e)===0};z.prototype.inspect=function(){var e="",t=Qo;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"};z.prototype.compare=function(e,t,n,i,s){if(!Pt(e))throw new TypeError("Argument must be a Buffer");if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),t<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&t>=n)return 0;if(i>=s)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;for(var o=s-i,c=n-t,a=Math.min(o,c),h=this.slice(i,s),p=e.slice(t,n),g=0;g<a;++g)if(h[g]!==p[g]){o=h[g],c=p[g];break}return o<c?-1:c<o?1:0};z.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};z.prototype.indexOf=function(e,t,n){return ra(this,e,t,n,!0)};z.prototype.lastIndexOf=function(e,t,n){return ra(this,e,t,n,!1)};z.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t|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");var s=this.length-t;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return Ef(this,e,t,n);case"utf8":case"utf-8":return vf(this,e,t,n);case"ascii":return na(this,e,t,n);case"latin1":case"binary":return If(this,e,t,n);case"base64":return Af(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Sf(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};z.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};Ko=4096;z.prototype.slice=function(e,t){var n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);var i;if(z.TYPED_ARRAY_SUPPORT)i=this.subarray(e,t),i.__proto__=z.prototype;else{var s=t-e;i=new z(s,void 0);for(var o=0;o<s;++o)i[o]=this[o+e]}return i};z.prototype.readUIntLE=function(e,t,n){e=e|0,t=t|0,n||Ke(e,t,this.length);for(var i=this[e],s=1,o=0;++o<t&&(s*=256);)i+=this[e+o]*s;return i};z.prototype.readUIntBE=function(e,t,n){e=e|0,t=t|0,n||Ke(e,t,this.length);for(var i=this[e+--t],s=1;t>0&&(s*=256);)i+=this[e+--t]*s;return i};z.prototype.readUInt8=function(e,t){return t||Ke(e,1,this.length),this[e]};z.prototype.readUInt16LE=function(e,t){return t||Ke(e,2,this.length),this[e]|this[e+1]<<8};z.prototype.readUInt16BE=function(e,t){return t||Ke(e,2,this.length),this[e]<<8|this[e+1]};z.prototype.readUInt32LE=function(e,t){return t||Ke(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};z.prototype.readUInt32BE=function(e,t){return t||Ke(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};z.prototype.readIntLE=function(e,t,n){e=e|0,t=t|0,n||Ke(e,t,this.length);for(var i=this[e],s=1,o=0;++o<t&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*t)),i};z.prototype.readIntBE=function(e,t,n){e=e|0,t=t|0,n||Ke(e,t,this.length);for(var i=t,s=1,o=this[e+--i];i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*t)),o};z.prototype.readInt8=function(e,t){return t||Ke(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};z.prototype.readInt16LE=function(e,t){t||Ke(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};z.prototype.readInt16BE=function(e,t){t||Ke(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};z.prototype.readInt32LE=function(e,t){return t||Ke(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};z.prototype.readInt32BE=function(e,t){return t||Ke(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};z.prototype.readFloatLE=function(e,t){return t||Ke(e,4,this.length),zn(this,e,!0,23,4)};z.prototype.readFloatBE=function(e,t){return t||Ke(e,4,this.length),zn(this,e,!1,23,4)};z.prototype.readDoubleLE=function(e,t){return t||Ke(e,8,this.length),zn(this,e,!0,52,8)};z.prototype.readDoubleBE=function(e,t){return t||Ke(e,8,this.length),zn(this,e,!1,52,8)};z.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;at(this,e,t,n,s,0)}var o=1,c=0;for(this[t]=e&255;++c<n&&(o*=256);)this[t+c]=e/o&255;return t+n};z.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;at(this,e,t,n,s,0)}var o=n-1,c=1;for(this[t+o]=e&255;--o>=0&&(c*=256);)this[t+o]=e/c&255;return t+n};z.prototype.writeUInt8=function(e,t,n){return e=+e,t=t|0,n||at(this,e,t,1,255,0),z.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e&255,t+1};z.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t|0,n||at(this,e,t,2,65535,0),z.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Kn(this,e,t,!0),t+2};z.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t|0,n||at(this,e,t,2,65535,0),z.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Kn(this,e,t,!1),t+2};z.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t|0,n||at(this,e,t,4,4294967295,0),z.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255):Zn(this,e,t,!0),t+4};z.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t|0,n||at(this,e,t,4,4294967295,0),z.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):Zn(this,e,t,!1),t+4};z.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t|0,!i){var s=Math.pow(2,8*n-1);at(this,e,t,n,s-1,-s)}var o=0,c=1,a=0;for(this[t]=e&255;++o<n&&(c*=256);)e<0&&a===0&&this[t+o-1]!==0&&(a=1),this[t+o]=(e/c>>0)-a&255;return t+n};z.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t|0,!i){var s=Math.pow(2,8*n-1);at(this,e,t,n,s-1,-s)}var o=n-1,c=1,a=0;for(this[t+o]=e&255;--o>=0&&(c*=256);)e<0&&a===0&&this[t+o+1]!==0&&(a=1),this[t+o]=(e/c>>0)-a&255;return t+n};z.prototype.writeInt8=function(e,t,n){return e=+e,t=t|0,n||at(this,e,t,1,127,-128),z.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=e&255,t+1};z.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t|0,n||at(this,e,t,2,32767,-32768),z.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Kn(this,e,t,!0),t+2};z.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t|0,n||at(this,e,t,2,32767,-32768),z.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Kn(this,e,t,!1),t+2};z.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t|0,n||at(this,e,t,4,2147483647,-2147483648),z.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Zn(this,e,t,!0),t+4};z.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t|0,n||at(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),z.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):Zn(this,e,t,!1),t+4};z.prototype.writeFloatLE=function(e,t,n){return oa(this,e,t,!0,n)};z.prototype.writeFloatBE=function(e,t,n){return oa(this,e,t,!1,n)};z.prototype.writeDoubleLE=function(e,t,n){return aa(this,e,t,!0,n)};z.prototype.writeDoubleBE=function(e,t,n){return aa(this,e,t,!1,n)};z.prototype.copy=function(e,t,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);var s=i-n,o;if(this===e&&n<t&&t<i)for(o=s-1;o>=0;--o)e[o+t]=this[o+n];else if(s<1e3||!z.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),t);return s};z.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),e.length===1){var s=e.charCodeAt(0);s<256&&(e=s)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!z.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof e=="number"&&(e=e&255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);var o;if(typeof e=="number")for(o=t;o<n;++o)this[o]=e;else{var c=Pt(e)?e:Yn(new z(e,i).toString()),a=c.length;for(o=0;o<n-t;++o)this[o+t]=c[o%a]}return this};Ff=/[^+\/0-9A-Za-z-_]/g});var an=ze((ed,Xn)=>{var _r=(ha(),Ju(la));if(_r&&_r.default){Xn.exports=_r.default;for(let r in _r)Xn.exports[r]=_r[r]}else _r&&(Xn.exports=_r)});var da=ze(Is=>{Is.read=function(r,e,t,n,i){var s,o,c=i*8-n-1,a=(1<<c)-1,h=a>>1,p=-7,g=t?i-1:0,w=t?-1:1,x=r[e+g];for(g+=w,s=x&(1<<-p)-1,x>>=-p,p+=c;p>0;s=s*256+r[e+g],g+=w,p-=8);for(o=s&(1<<-p)-1,s>>=-p,p+=n;p>0;o=o*256+r[e+g],g+=w,p-=8);if(s===0)s=1-h;else{if(s===a)return o?NaN:(x?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-h}return(x?-1:1)*o*Math.pow(2,s-n)};Is.write=function(r,e,t,n,i,s){var o,c,a,h=s*8-i-1,p=(1<<h)-1,g=p>>1,w=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:s-1,f=n?1:-1,N=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=p):(o=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-o))<1&&(o--,a*=2),o+g>=1?e+=w/a:e+=w*Math.pow(2,1-g),e*a>=2&&(o++,a/=2),o+g>=p?(c=0,o=p):o+g>=1?(c=(e*a-1)*Math.pow(2,i),o=o+g):(c=e*Math.pow(2,g-1)*Math.pow(2,i),o=0));i>=8;r[t+x]=c&255,x+=f,c/=256,i-=8);for(o=o<<i|c,h+=i;h>0;r[t+x]=o&255,x+=f,o/=256,h-=8);r[t+x-f]|=N*128}});var cn=ze((pa,Qn)=>{(function(r){"use strict";var e,t=/^-?(?:\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: ",c=1e14,a=14,h=9007199254740991,p=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],g=1e7,w=1e9;function x(E){var C,G,j,k=U.prototype={constructor:U,toString:null,valueOf:null},fe=new U(1),re=20,te=4,y=-7,I=21,q=-1e7,F=1e7,P=!1,$=1,Z=0,ue={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ce="0123456789abcdefghijklmnopqrstuvwxyz",Y=!0;function U(u,l){var m,S,v,A,M,b,B,L,R=this;if(!(R instanceof U))return new U(u,l);if(l==null){if(u&&u._isBigNumber===!0){R.s=u.s,!u.c||u.e>F?R.c=R.e=null:u.e<q?R.c=[R.e=0]:(R.e=u.e,R.c=u.c.slice());return}if((b=typeof u=="number")&&u*0==0){if(R.s=1/u<0?(u=-u,-1):1,u===~~u){for(A=0,M=u;M>=10;M/=10,A++);A>F?R.c=R.e=null:(R.e=A,R.c=[u]);return}L=String(u)}else{if(!t.test(L=String(u)))return j(R,L,b);R.s=L.charCodeAt(0)==45?(L=L.slice(1),-1):1}(A=L.indexOf("."))>-1&&(L=L.replace(".","")),(M=L.search(/e/i))>0?(A<0&&(A=M),A+=+L.slice(M+1),L=L.substring(0,M)):A<0&&(A=L.length)}else{if(O(l,2,ce.length,"Base"),l==10&&Y)return R=new U(u),ae(R,re+R.e+1,te);if(L=String(u),b=typeof u=="number"){if(u*0!=0)return j(R,L,b,l);if(R.s=1/u<0?(L=L.slice(1),-1):1,U.DEBUG&&L.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else R.s=L.charCodeAt(0)===45?(L=L.slice(1),-1):1;for(m=ce.slice(0,l),A=M=0,B=L.length;M<B;M++)if(m.indexOf(S=L.charAt(M))<0){if(S=="."){if(M>A){A=B;continue}}else if(!v&&(L==L.toUpperCase()&&(L=L.toLowerCase())||L==L.toLowerCase()&&(L=L.toUpperCase()))){v=!0,M=-1,A=0;continue}return j(R,String(u),b,l)}b=!1,L=G(L,l,10,R.s),(A=L.indexOf("."))>-1?L=L.replace(".",""):A=L.length}for(M=0;L.charCodeAt(M)===48;M++);for(B=L.length;L.charCodeAt(--B)===48;);if(L=L.slice(M,++B)){if(B-=M,b&&U.DEBUG&&B>15&&(u>h||u!==i(u)))throw Error(o+R.s*u);if((A=A-M-1)>F)R.c=R.e=null;else if(A<q)R.c=[R.e=0];else{if(R.e=A,R.c=[],M=(A+1)%a,A<0&&(M+=a),M<B){for(M&&R.c.push(+L.slice(0,M)),B-=a;M<B;)R.c.push(+L.slice(M,M+=a));M=a-(L=L.slice(M)).length}else M-=B;for(;M--;L+="0");R.c.push(+L)}}else R.c=[R.e=0]}U.clone=x,U.ROUND_UP=0,U.ROUND_DOWN=1,U.ROUND_CEIL=2,U.ROUND_FLOOR=3,U.ROUND_HALF_UP=4,U.ROUND_HALF_DOWN=5,U.ROUND_HALF_EVEN=6,U.ROUND_HALF_CEIL=7,U.ROUND_HALF_FLOOR=8,U.EUCLID=9,U.config=U.set=function(u){var l,m;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(l="DECIMAL_PLACES")&&(m=u[l],O(m,0,w,l),re=m),u.hasOwnProperty(l="ROUNDING_MODE")&&(m=u[l],O(m,0,8,l),te=m),u.hasOwnProperty(l="EXPONENTIAL_AT")&&(m=u[l],m&&m.pop?(O(m[0],-w,0,l),O(m[1],0,w,l),y=m[0],I=m[1]):(O(m,-w,w,l),y=-(I=m<0?-m:m))),u.hasOwnProperty(l="RANGE"))if(m=u[l],m&&m.pop)O(m[0],-w,-1,l),O(m[1],1,w,l),q=m[0],F=m[1];else if(O(m,-w,w,l),m)q=-(F=m<0?-m:m);else throw Error(s+l+" cannot be zero: "+m);if(u.hasOwnProperty(l="CRYPTO"))if(m=u[l],m===!!m)if(m)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))P=m;else throw P=!m,Error(s+"crypto unavailable");else P=m;else throw Error(s+l+" not true or false: "+m);if(u.hasOwnProperty(l="MODULO_MODE")&&(m=u[l],O(m,0,9,l),$=m),u.hasOwnProperty(l="POW_PRECISION")&&(m=u[l],O(m,0,w,l),Z=m),u.hasOwnProperty(l="FORMAT"))if(m=u[l],typeof m=="object")ue=m;else throw Error(s+l+" not an object: "+m);if(u.hasOwnProperty(l="ALPHABET"))if(m=u[l],typeof m=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(m))Y=m.slice(0,10)=="0123456789",ce=m;else throw Error(s+l+" invalid: "+m)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:re,ROUNDING_MODE:te,EXPONENTIAL_AT:[y,I],RANGE:[q,F],CRYPTO:P,MODULO_MODE:$,POW_PRECISION:Z,FORMAT:ue,ALPHABET:ce}},U.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!U.DEBUG)return!0;var l,m,S=u.c,v=u.e,A=u.s;e:if({}.toString.call(S)=="[object Array]"){if((A===1||A===-1)&&v>=-w&&v<=w&&v===i(v)){if(S[0]===0){if(v===0&&S.length===1)return!0;break e}if(l=(v+1)%a,l<1&&(l+=a),String(S[0]).length==l){for(l=0;l<S.length;l++)if(m=S[l],m<0||m>=c||m!==i(m))break e;if(m!==0)return!0}}}else if(S===null&&v===null&&(A===null||A===1||A===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},U.maximum=U.max=function(){return J(arguments,-1)},U.minimum=U.min=function(){return J(arguments,1)},U.random=function(){var u=9007199254740992,l=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(m){var S,v,A,M,b,B=0,L=[],R=new U(fe);if(m==null?m=re:O(m,0,w),M=n(m/a),P)if(crypto.getRandomValues){for(S=crypto.getRandomValues(new Uint32Array(M*=2));B<M;)b=S[B]*131072+(S[B+1]>>>11),b>=9e15?(v=crypto.getRandomValues(new Uint32Array(2)),S[B]=v[0],S[B+1]=v[1]):(L.push(b%1e14),B+=2);B=M/2}else if(crypto.randomBytes){for(S=crypto.randomBytes(M*=7);B<M;)b=(S[B]&31)*281474976710656+S[B+1]*1099511627776+S[B+2]*4294967296+S[B+3]*16777216+(S[B+4]<<16)+(S[B+5]<<8)+S[B+6],b>=9e15?crypto.randomBytes(7).copy(S,B):(L.push(b%1e14),B+=7);B=M/7}else throw P=!1,Error(s+"crypto unavailable");if(!P)for(;B<M;)b=l(),b<9e15&&(L[B++]=b%1e14);for(M=L[--B],m%=a,M&&m&&(b=p[a-m],L[B]=i(M/b)*b);L[B]===0;L.pop(),B--);if(B<0)L=[A=0];else{for(A=-1;L[0]===0;L.splice(0,1),A-=a);for(B=1,b=L[0];b>=10;b/=10,B++);B<a&&(A-=a-B)}return R.e=A,R.c=L,R}}(),U.sum=function(){for(var u=1,l=arguments,m=new U(l[0]);u<l.length;)m=m.plus(l[u++]);return m},G=function(){var u="0123456789";function l(m,S,v,A){for(var M,b=[0],B,L=0,R=m.length;L<R;){for(B=b.length;B--;b[B]*=S);for(b[0]+=A.indexOf(m.charAt(L++)),M=0;M<b.length;M++)b[M]>v-1&&(b[M+1]==null&&(b[M+1]=0),b[M+1]+=b[M]/v|0,b[M]%=v)}return b.reverse()}return function(m,S,v,A,M){var b,B,L,R,V,W,ie,de,Ee=m.indexOf("."),Ne=re,he=te;for(Ee>=0&&(R=Z,Z=0,m=m.replace(".",""),de=new U(S),W=de.pow(m.length-Ee),Z=R,de.c=l(K(N(W.c),W.e,"0"),10,v,u),de.e=de.c.length),ie=l(m,S,v,M?(b=ce,u):(b=u,ce)),L=R=ie.length;ie[--R]==0;ie.pop());if(!ie[0])return b.charAt(0);if(Ee<0?--L:(W.c=ie,W.e=L,W.s=A,W=C(W,de,Ne,he,v),ie=W.c,V=W.r,L=W.e),B=L+Ne+1,Ee=ie[B],R=v/2,V=V||B<0||ie[B+1]!=null,V=he<4?(Ee!=null||V)&&(he==0||he==(W.s<0?3:2)):Ee>R||Ee==R&&(he==4||V||he==6&&ie[B-1]&1||he==(W.s<0?8:7)),B<1||!ie[0])m=V?K(b.charAt(1),-Ne,b.charAt(0)):b.charAt(0);else{if(ie.length=B,V)for(--v;++ie[--B]>v;)ie[B]=0,B||(++L,ie=[1].concat(ie));for(R=ie.length;!ie[--R];);for(Ee=0,m="";Ee<=R;m+=b.charAt(ie[Ee++]));m=K(m,L,b.charAt(0))}return m}}(),C=function(){function u(S,v,A){var M,b,B,L,R=0,V=S.length,W=v%g,ie=v/g|0;for(S=S.slice();V--;)B=S[V]%g,L=S[V]/g|0,M=ie*B+L*W,b=W*B+M%g*g+R,R=(b/A|0)+(M/g|0)+ie*L,S[V]=b%A;return R&&(S=[R].concat(S)),S}function l(S,v,A,M){var b,B;if(A!=M)B=A>M?1:-1;else for(b=B=0;b<A;b++)if(S[b]!=v[b]){B=S[b]>v[b]?1:-1;break}return B}function m(S,v,A,M){for(var b=0;A--;)S[A]-=b,b=S[A]<v[A]?1:0,S[A]=b*M+S[A]-v[A];for(;!S[0]&&S.length>1;S.splice(0,1));}return function(S,v,A,M,b){var B,L,R,V,W,ie,de,Ee,Ne,he,oe,ke,Qt,mr,gr,mt,be,ot=S.s==v.s?1:-1,We=S.c,Re=v.c;if(!We||!We[0]||!Re||!Re[0])return new U(!S.s||!v.s||(We?Re&&We[0]==Re[0]:!Re)?NaN:We&&We[0]==0||!Re?ot*0:ot/0);for(Ee=new U(ot),Ne=Ee.c=[],L=S.e-v.e,ot=A+L+1,b||(b=c,L=f(S.e/a)-f(v.e/a),ot=ot/a|0),R=0;Re[R]==(We[R]||0);R++);if(Re[R]>(We[R]||0)&&L--,ot<0)Ne.push(1),V=!0;else{for(mr=We.length,mt=Re.length,R=0,ot+=2,W=i(b/(Re[0]+1)),W>1&&(Re=u(Re,W,b),We=u(We,W,b),mt=Re.length,mr=We.length),Qt=mt,he=We.slice(0,mt),oe=he.length;oe<mt;he[oe++]=0);be=Re.slice(),be=[0].concat(be),gr=Re[0],Re[1]>=b/2&&gr++;do{if(W=0,B=l(Re,he,mt,oe),B<0){if(ke=he[0],mt!=oe&&(ke=ke*b+(he[1]||0)),W=i(ke/gr),W>1)for(W>=b&&(W=b-1),ie=u(Re,W,b),de=ie.length,oe=he.length;l(ie,he,de,oe)==1;)W--,m(ie,mt<de?be:Re,de,b),de=ie.length,B=1;else W==0&&(B=W=1),ie=Re.slice(),de=ie.length;if(de<oe&&(ie=[0].concat(ie)),m(he,ie,oe,b),oe=he.length,B==-1)for(;l(Re,he,mt,oe)<1;)W++,m(he,mt<oe?be:Re,oe,b),oe=he.length}else B===0&&(W++,he=[0]);Ne[R++]=W,he[0]?he[oe++]=We[Qt]||0:(he=[We[Qt]],oe=1)}while((Qt++<mr||he[0]!=null)&&ot--);V=he[0]!=null,Ne[0]||Ne.splice(0,1)}if(b==c){for(R=1,ot=Ne[0];ot>=10;ot/=10,R++);ae(Ee,A+(Ee.e=R+L*a-1)+1,M,V)}else Ee.e=L,Ee.r=+V;return Ee}}();function d(u,l,m,S){var v,A,M,b,B;if(m==null?m=te:O(m,0,8),!u.c)return u.toString();if(v=u.c[0],M=u.e,l==null)B=N(u.c),B=S==1||S==2&&(M<=y||M>=I)?D(B,M):K(B,M,"0");else if(u=ae(new U(u),l,m),A=u.e,B=N(u.c),b=B.length,S==1||S==2&&(l<=A||A<=y)){for(;b<l;B+="0",b++);B=D(B,A)}else if(l-=M,B=K(B,A,"0"),A+1>b){if(--l>0)for(B+=".";l--;B+="0");}else if(l+=A-b,l>0)for(A+1==b&&(B+=".");l--;B+="0");return u.s<0&&v?"-"+B:B}function J(u,l){for(var m,S,v=1,A=new U(u[0]);v<u.length;v++)S=new U(u[v]),(!S.s||(m=T(A,S))===l||m===0&&A.s===l)&&(A=S);return A}function ee(u,l,m){for(var S=1,v=l.length;!l[--v];l.pop());for(v=l[0];v>=10;v/=10,S++);return(m=S+m*a-1)>F?u.c=u.e=null:m<q?u.c=[u.e=0]:(u.e=m,u.c=l),u}j=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,l=/^([^.]+)\.$/,m=/^\.([^.]+)$/,S=/^-?(Infinity|NaN)$/,v=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(A,M,b,B){var L,R=b?M:M.replace(v,"");if(S.test(R))A.s=isNaN(R)?null:R<0?-1:1;else{if(!b&&(R=R.replace(u,function(V,W,ie){return L=(ie=ie.toLowerCase())=="x"?16:ie=="b"?2:8,!B||B==L?W:V}),B&&(L=B,R=R.replace(l,"$1").replace(m,"0.$1")),M!=R))return new U(R,L);if(U.DEBUG)throw Error(s+"Not a"+(B?" base "+B:"")+" number: "+M);A.s=null}A.c=A.e=null}}();function ae(u,l,m,S){var v,A,M,b,B,L,R,V=u.c,W=p;if(V){e:{for(v=1,b=V[0];b>=10;b/=10,v++);if(A=l-v,A<0)A+=a,M=l,B=V[L=0],R=i(B/W[v-M-1]%10);else if(L=n((A+1)/a),L>=V.length)if(S){for(;V.length<=L;V.push(0));B=R=0,v=1,A%=a,M=A-a+1}else break e;else{for(B=b=V[L],v=1;b>=10;b/=10,v++);A%=a,M=A-a+v,R=M<0?0:i(B/W[v-M-1]%10)}if(S=S||l<0||V[L+1]!=null||(M<0?B:B%W[v-M-1]),S=m<4?(R||S)&&(m==0||m==(u.s<0?3:2)):R>5||R==5&&(m==4||S||m==6&&(A>0?M>0?B/W[v-M]:0:V[L-1])%10&1||m==(u.s<0?8:7)),l<1||!V[0])return V.length=0,S?(l-=u.e+1,V[0]=W[(a-l%a)%a],u.e=-l||0):V[0]=u.e=0,u;if(A==0?(V.length=L,b=1,L--):(V.length=L+1,b=W[a-A],V[L]=M>0?i(B/W[v-M]%W[M])*b:0),S)for(;;)if(L==0){for(A=1,M=V[0];M>=10;M/=10,A++);for(M=V[0]+=b,b=1;M>=10;M/=10,b++);A!=b&&(u.e++,V[0]==c&&(V[0]=1));break}else{if(V[L]+=b,V[L]!=c)break;V[L--]=0,b=1}for(A=V.length;V[--A]===0;V.pop());}u.e>F?u.c=u.e=null:u.e<q&&(u.c=[u.e=0])}return u}function Q(u){var l,m=u.e;return m===null?u.toString():(l=N(u.c),l=m<=y||m>=I?D(l,m):K(l,m,"0"),u.s<0?"-"+l:l)}return k.absoluteValue=k.abs=function(){var u=new U(this);return u.s<0&&(u.s=1),u},k.comparedTo=function(u,l){return T(this,new U(u,l))},k.decimalPlaces=k.dp=function(u,l){var m,S,v,A=this;if(u!=null)return O(u,0,w),l==null?l=te:O(l,0,8),ae(new U(A),u+A.e+1,l);if(!(m=A.c))return null;if(S=((v=m.length-1)-f(this.e/a))*a,v=m[v])for(;v%10==0;v/=10,S--);return S<0&&(S=0),S},k.dividedBy=k.div=function(u,l){return C(this,new U(u,l),re,te)},k.dividedToIntegerBy=k.idiv=function(u,l){return C(this,new U(u,l),0,1)},k.exponentiatedBy=k.pow=function(u,l){var m,S,v,A,M,b,B,L,R,V=this;if(u=new U(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+Q(u));if(l!=null&&(l=new U(l)),b=u.e>14,!V.c||!V.c[0]||V.c[0]==1&&!V.e&&V.c.length==1||!u.c||!u.c[0])return R=new U(Math.pow(+Q(V),b?u.s*(2-H(u)):+Q(u))),l?R.mod(l):R;if(B=u.s<0,l){if(l.c?!l.c[0]:!l.s)return new U(NaN);S=!B&&V.isInteger()&&l.isInteger(),S&&(V=V.mod(l))}else{if(u.e>9&&(V.e>0||V.e<-1||(V.e==0?V.c[0]>1||b&&V.c[1]>=24e7:V.c[0]<8e13||b&&V.c[0]<=9999975e7)))return A=V.s<0&&H(u)?-0:0,V.e>-1&&(A=1/A),new U(B?1/A:A);Z&&(A=n(Z/a+2))}for(b?(m=new U(.5),B&&(u.s=1),L=H(u)):(v=Math.abs(+Q(u)),L=v%2),R=new U(fe);;){if(L){if(R=R.times(V),!R.c)break;A?R.c.length>A&&(R.c.length=A):S&&(R=R.mod(l))}if(v){if(v=i(v/2),v===0)break;L=v%2}else if(u=u.times(m),ae(u,u.e+1,1),u.e>14)L=H(u);else{if(v=+Q(u),v===0)break;L=v%2}V=V.times(V),A?V.c&&V.c.length>A&&(V.c.length=A):S&&(V=V.mod(l))}return S?R:(B&&(R=fe.div(R)),l?R.mod(l):A?ae(R,Z,te,M):R)},k.integerValue=function(u){var l=new U(this);return u==null?u=te:O(u,0,8),ae(l,l.e+1,u)},k.isEqualTo=k.eq=function(u,l){return T(this,new U(u,l))===0},k.isFinite=function(){return!!this.c},k.isGreaterThan=k.gt=function(u,l){return T(this,new U(u,l))>0},k.isGreaterThanOrEqualTo=k.gte=function(u,l){return(l=T(this,new U(u,l)))===1||l===0},k.isInteger=function(){return!!this.c&&f(this.e/a)>this.c.length-2},k.isLessThan=k.lt=function(u,l){return T(this,new U(u,l))<0},k.isLessThanOrEqualTo=k.lte=function(u,l){return(l=T(this,new U(u,l)))===-1||l===0},k.isNaN=function(){return!this.s},k.isNegative=function(){return this.s<0},k.isPositive=function(){return this.s>0},k.isZero=function(){return!!this.c&&this.c[0]==0},k.minus=function(u,l){var m,S,v,A,M=this,b=M.s;if(u=new U(u,l),l=u.s,!b||!l)return new U(NaN);if(b!=l)return u.s=-l,M.plus(u);var B=M.e/a,L=u.e/a,R=M.c,V=u.c;if(!B||!L){if(!R||!V)return R?(u.s=-l,u):new U(V?M:NaN);if(!R[0]||!V[0])return V[0]?(u.s=-l,u):new U(R[0]?M:te==3?-0:0)}if(B=f(B),L=f(L),R=R.slice(),b=B-L){for((A=b<0)?(b=-b,v=R):(L=B,v=V),v.reverse(),l=b;l--;v.push(0));v.reverse()}else for(S=(A=(b=R.length)<(l=V.length))?b:l,b=l=0;l<S;l++)if(R[l]!=V[l]){A=R[l]<V[l];break}if(A&&(v=R,R=V,V=v,u.s=-u.s),l=(S=V.length)-(m=R.length),l>0)for(;l--;R[m++]=0);for(l=c-1;S>b;){if(R[--S]<V[S]){for(m=S;m&&!R[--m];R[m]=l);--R[m],R[S]+=c}R[S]-=V[S]}for(;R[0]==0;R.splice(0,1),--L);return R[0]?ee(u,R,L):(u.s=te==3?-1:1,u.c=[u.e=0],u)},k.modulo=k.mod=function(u,l){var m,S,v=this;return u=new U(u,l),!v.c||!u.s||u.c&&!u.c[0]?new U(NaN):!u.c||v.c&&!v.c[0]?new U(v):($==9?(S=u.s,u.s=1,m=C(v,u,0,3),u.s=S,m.s*=S):m=C(v,u,0,$),u=v.minus(m.times(u)),!u.c[0]&&$==1&&(u.s=v.s),u)},k.multipliedBy=k.times=function(u,l){var m,S,v,A,M,b,B,L,R,V,W,ie,de,Ee,Ne,he=this,oe=he.c,ke=(u=new U(u,l)).c;if(!oe||!ke||!oe[0]||!ke[0])return!he.s||!u.s||oe&&!oe[0]&&!ke||ke&&!ke[0]&&!oe?u.c=u.e=u.s=null:(u.s*=he.s,!oe||!ke?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(S=f(he.e/a)+f(u.e/a),u.s*=he.s,B=oe.length,V=ke.length,B<V&&(de=oe,oe=ke,ke=de,v=B,B=V,V=v),v=B+V,de=[];v--;de.push(0));for(Ee=c,Ne=g,v=V;--v>=0;){for(m=0,W=ke[v]%Ne,ie=ke[v]/Ne|0,M=B,A=v+M;A>v;)L=oe[--M]%Ne,R=oe[M]/Ne|0,b=ie*L+R*W,L=W*L+b%Ne*Ne+de[A]+m,m=(L/Ee|0)+(b/Ne|0)+ie*R,de[A--]=L%Ee;de[A]=m}return m?++S:de.splice(0,1),ee(u,de,S)},k.negated=function(){var u=new U(this);return u.s=-u.s||null,u},k.plus=function(u,l){var m,S=this,v=S.s;if(u=new U(u,l),l=u.s,!v||!l)return new U(NaN);if(v!=l)return u.s=-l,S.minus(u);var A=S.e/a,M=u.e/a,b=S.c,B=u.c;if(!A||!M){if(!b||!B)return new U(v/0);if(!b[0]||!B[0])return B[0]?u:new U(b[0]?S:v*0)}if(A=f(A),M=f(M),b=b.slice(),v=A-M){for(v>0?(M=A,m=B):(v=-v,m=b),m.reverse();v--;m.push(0));m.reverse()}for(v=b.length,l=B.length,v-l<0&&(m=B,B=b,b=m,l=v),v=0;l;)v=(b[--l]=b[l]+B[l]+v)/c|0,b[l]=c===b[l]?0:b[l]%c;return v&&(b=[v].concat(b),++M),ee(u,b,M)},k.precision=k.sd=function(u,l){var m,S,v,A=this;if(u!=null&&u!==!!u)return O(u,1,w),l==null?l=te:O(l,0,8),ae(new U(A),u,l);if(!(m=A.c))return null;if(v=m.length-1,S=v*a+1,v=m[v]){for(;v%10==0;v/=10,S--);for(v=m[0];v>=10;v/=10,S++);}return u&&A.e+1>S&&(S=A.e+1),S},k.shiftedBy=function(u){return O(u,-h,h),this.times("1e"+u)},k.squareRoot=k.sqrt=function(){var u,l,m,S,v,A=this,M=A.c,b=A.s,B=A.e,L=re+4,R=new U("0.5");if(b!==1||!M||!M[0])return new U(!b||b<0&&(!M||M[0])?NaN:M?A:1/0);if(b=Math.sqrt(+Q(A)),b==0||b==1/0?(l=N(M),(l.length+B)%2==0&&(l+="0"),b=Math.sqrt(+l),B=f((B+1)/2)-(B<0||B%2),b==1/0?l="5e"+B:(l=b.toExponential(),l=l.slice(0,l.indexOf("e")+1)+B),m=new U(l)):m=new U(b+""),m.c[0]){for(B=m.e,b=B+L,b<3&&(b=0);;)if(v=m,m=R.times(v.plus(C(A,v,L,1))),N(v.c).slice(0,b)===(l=N(m.c)).slice(0,b))if(m.e<B&&--b,l=l.slice(b-3,b+1),l=="9999"||!S&&l=="4999"){if(!S&&(ae(v,v.e+re+2,0),v.times(v).eq(A))){m=v;break}L+=4,b+=4,S=1}else{(!+l||!+l.slice(1)&&l.charAt(0)=="5")&&(ae(m,m.e+re+2,1),u=!m.times(m).eq(A));break}}return ae(m,m.e+re+1,te,u)},k.toExponential=function(u,l){return u!=null&&(O(u,0,w),u++),d(this,u,l,1)},k.toFixed=function(u,l){return u!=null&&(O(u,0,w),u=u+this.e+1),d(this,u,l)},k.toFormat=function(u,l,m){var S,v=this;if(m==null)u!=null&&l&&typeof l=="object"?(m=l,l=null):u&&typeof u=="object"?(m=u,u=l=null):m=ue;else if(typeof m!="object")throw Error(s+"Argument not an object: "+m);if(S=v.toFixed(u,l),v.c){var A,M=S.split("."),b=+m.groupSize,B=+m.secondaryGroupSize,L=m.groupSeparator||"",R=M[0],V=M[1],W=v.s<0,ie=W?R.slice(1):R,de=ie.length;if(B&&(A=b,b=B,B=A,de-=A),b>0&&de>0){for(A=de%b||b,R=ie.substr(0,A);A<de;A+=b)R+=L+ie.substr(A,b);B>0&&(R+=L+ie.slice(A)),W&&(R="-"+R)}S=V?R+(m.decimalSeparator||"")+((B=+m.fractionGroupSize)?V.replace(new RegExp("\\d{"+B+"}\\B","g"),"$&"+(m.fractionGroupSeparator||"")):V):R}return(m.prefix||"")+S+(m.suffix||"")},k.toFraction=function(u){var l,m,S,v,A,M,b,B,L,R,V,W,ie=this,de=ie.c;if(u!=null&&(b=new U(u),!b.isInteger()&&(b.c||b.s!==1)||b.lt(fe)))throw Error(s+"Argument "+(b.isInteger()?"out of range: ":"not an integer: ")+Q(b));if(!de)return new U(ie);for(l=new U(fe),L=m=new U(fe),S=B=new U(fe),W=N(de),A=l.e=W.length-ie.e-1,l.c[0]=p[(M=A%a)<0?a+M:M],u=!u||b.comparedTo(l)>0?A>0?l:L:b,M=F,F=1/0,b=new U(W),B.c[0]=0;R=C(b,l,0,1),v=m.plus(R.times(S)),v.comparedTo(u)!=1;)m=S,S=v,L=B.plus(R.times(v=L)),B=v,l=b.minus(R.times(v=l)),b=v;return v=C(u.minus(m),S,0,1),B=B.plus(v.times(L)),m=m.plus(v.times(S)),B.s=L.s=ie.s,A=A*2,V=C(L,S,A,te).minus(ie).abs().comparedTo(C(B,m,A,te).minus(ie).abs())<1?[L,S]:[B,m],F=M,V},k.toNumber=function(){return+Q(this)},k.toPrecision=function(u,l){return u!=null&&O(u,1,w),d(this,u,l,2)},k.toString=function(u){var l,m=this,S=m.s,v=m.e;return v===null?S?(l="Infinity",S<0&&(l="-"+l)):l="NaN":(u==null?l=v<=y||v>=I?D(N(m.c),v):K(N(m.c),v,"0"):u===10&&Y?(m=ae(new U(m),re+v+1,te),l=K(N(m.c),m.e,"0")):(O(u,2,ce.length,"Base"),l=G(K(N(m.c),v,"0"),10,u,S,!0)),S<0&&m.c[0]&&(l="-"+l)),l},k.valueOf=k.toJSON=function(){return Q(this)},k._isBigNumber=!0,E!=null&&U.set(E),U}function f(E){var C=E|0;return E>0||E===C?C:C-1}function N(E){for(var C,G,j=1,k=E.length,fe=E[0]+"";j<k;){for(C=E[j++]+"",G=a-C.length;G--;C="0"+C);fe+=C}for(k=fe.length;fe.charCodeAt(--k)===48;);return fe.slice(0,k+1||1)}function T(E,C){var G,j,k=E.c,fe=C.c,re=E.s,te=C.s,y=E.e,I=C.e;if(!re||!te)return null;if(G=k&&!k[0],j=fe&&!fe[0],G||j)return G?j?0:-te:re;if(re!=te)return re;if(G=re<0,j=y==I,!k||!fe)return j?0:!k^G?1:-1;if(!j)return y>I^G?1:-1;for(te=(y=k.length)<(I=fe.length)?y:I,re=0;re<te;re++)if(k[re]!=fe[re])return k[re]>fe[re]^G?1:-1;return y==I?0:y>I^G?1:-1}function O(E,C,G,j){if(E<C||E>G||E!==i(E))throw Error(s+(j||"Argument")+(typeof E=="number"?E<C||E>G?" out of range: ":" not an integer: ":" not a primitive number: ")+String(E))}function H(E){var C=E.c.length-1;return f(E.e/a)==C&&E.c[C]%2!=0}function D(E,C){return(E.length>1?E.charAt(0)+"."+E.slice(1):E)+(C<0?"e":"e+")+C}function K(E,C,G){var j,k;if(C<0){for(k=G+".";++C;k+=G);E=k+E}else if(j=E.length,++C>j){for(k=G,C-=j;--C;k+=G);E+=k}else C<j&&(E=E.slice(0,C)+"."+E.slice(C));return E}e=x(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof Qn<"u"&&Qn.exports?Qn.exports=e:(r||(r=typeof self<"u"&&self?self:window),r.BigNumber=e)})(pa)});var ga=ze((rd,ma)=>{ma.exports=function(e,t,n){var i=new e.Uint8Array(n),s=t.pushInt,o=t.pushInt32,c=t.pushInt32Neg,a=t.pushInt64,h=t.pushInt64Neg,p=t.pushFloat,g=t.pushFloatSingle,w=t.pushFloatDouble,x=t.pushTrue,f=t.pushFalse,N=t.pushUndefined,T=t.pushNull,O=t.pushInfinity,H=t.pushInfinityNeg,D=t.pushNaN,K=t.pushNaNNeg,E=t.pushArrayStart,C=t.pushArrayStartFixed,G=t.pushArrayStartFixed32,j=t.pushArrayStartFixed64,k=t.pushObjectStart,fe=t.pushObjectStartFixed,re=t.pushObjectStartFixed32,te=t.pushObjectStartFixed64,y=t.pushByteString,I=t.pushByteStringStart,q=t.pushUtf8String,F=t.pushUtf8StringStart,P=t.pushSimpleUnassigned,$=t.pushTagStart,Z=t.pushTagStart4,ue=t.pushTagStart8,ce=t.pushTagUnassigned,Y=t.pushBreak,U=e.Math.pow,d=0,J=0,ee=0;function ae(_){for(_=_|0,d=0,J=_;(d|0)<(J|0)&&(ee=Yu[i[d]&255](i[d]|0)|0,!((ee|0)>0)););return ee|0}function Q(_){return _=_|0,((d|0)+(_|0)|0)<(J|0)?0:1}function u(_){return _=_|0,i[_|0]<<8|i[_+1|0]|0}function l(_){return _=_|0,i[_|0]<<24|i[_+1|0]<<16|i[_+2|0]<<8|i[_+3|0]|0}function m(_){return _=_|0,s(_|0),d=d+1|0,0}function S(_){return _=_|0,Q(1)|0?1:(s(i[d+1|0]|0),d=d+2|0,0)}function v(_){return _=_|0,Q(2)|0?1:(s(u(d+1|0)|0),d=d+3|0,0)}function A(_){return _=_|0,Q(4)|0?1:(o(u(d+1|0)|0,u(d+3|0)|0),d=d+5|0,0)}function M(_){return _=_|0,Q(8)|0?1:(a(u(d+1|0)|0,u(d+3|0)|0,u(d+5|0)|0,u(d+7|0)|0),d=d+9|0,0)}function b(_){return _=_|0,s(-1-(_-32|0)|0),d=d+1|0,0}function B(_){return _=_|0,Q(1)|0?1:(s(-1-(i[d+1|0]|0)|0),d=d+2|0,0)}function L(_){_=_|0;var ye=0;return Q(2)|0?1:(ye=u(d+1|0)|0,s(-1-(ye|0)|0),d=d+3|0,0)}function R(_){return _=_|0,Q(4)|0?1:(c(u(d+1|0)|0,u(d+3|0)|0),d=d+5|0,0)}function V(_){return _=_|0,Q(8)|0?1:(h(u(d+1|0)|0,u(d+3|0)|0,u(d+5|0)|0,u(d+7|0)|0),d=d+9|0,0)}function W(_){_=_|0;var ye=0,we=0,pe=0;return pe=_-64|0,Q(pe|0)|0?1:(ye=d+1|0,we=(d+1|0)+(pe|0)|0,y(ye|0,we|0),d=we|0,0)}function ie(_){_=_|0;var ye=0,we=0,pe=0;return Q(1)|0||(pe=i[d+1|0]|0,ye=d+2|0,we=(d+2|0)+(pe|0)|0,Q(pe+1|0)|0)?1:(y(ye|0,we|0),d=we|0,0)}function de(_){_=_|0;var ye=0,we=0,pe=0;return Q(2)|0||(pe=u(d+1|0)|0,ye=d+3|0,we=(d+3|0)+(pe|0)|0,Q(pe+2|0)|0)?1:(y(ye|0,we|0),d=we|0,0)}function Ee(_){_=_|0;var ye=0,we=0,pe=0;return Q(4)|0||(pe=l(d+1|0)|0,ye=d+5|0,we=(d+5|0)+(pe|0)|0,Q(pe+4|0)|0)?1:(y(ye|0,we|0),d=we|0,0)}function Ne(_){return _=_|0,1}function he(_){return _=_|0,I(),d=d+1|0,0}function oe(_){_=_|0;var ye=0,we=0,pe=0;return pe=_-96|0,Q(pe|0)|0?1:(ye=d+1|0,we=(d+1|0)+(pe|0)|0,q(ye|0,we|0),d=we|0,0)}function ke(_){_=_|0;var ye=0,we=0,pe=0;return Q(1)|0||(pe=i[d+1|0]|0,ye=d+2|0,we=(d+2|0)+(pe|0)|0,Q(pe+1|0)|0)?1:(q(ye|0,we|0),d=we|0,0)}function Qt(_){_=_|0;var ye=0,we=0,pe=0;return Q(2)|0||(pe=u(d+1|0)|0,ye=d+3|0,we=(d+3|0)+(pe|0)|0,Q(pe+2|0)|0)?1:(q(ye|0,we|0),d=we|0,0)}function mr(_){_=_|0;var ye=0,we=0,pe=0;return Q(4)|0||(pe=l(d+1|0)|0,ye=d+5|0,we=(d+5|0)+(pe|0)|0,Q(pe+4|0)|0)?1:(q(ye|0,we|0),d=we|0,0)}function gr(_){return _=_|0,1}function mt(_){return _=_|0,F(),d=d+1|0,0}function be(_){return _=_|0,C(_-128|0),d=d+1|0,0}function ot(_){return _=_|0,Q(1)|0?1:(C(i[d+1|0]|0),d=d+2|0,0)}function We(_){return _=_|0,Q(2)|0?1:(C(u(d+1|0)|0),d=d+3|0,0)}function Re(_){return _=_|0,Q(4)|0?1:(G(u(d+1|0)|0,u(d+3|0)|0),d=d+5|0,0)}function Su(_){return _=_|0,Q(8)|0?1:(j(u(d+1|0)|0,u(d+3|0)|0,u(d+5|0)|0,u(d+7|0)|0),d=d+9|0,0)}function Bu(_){return _=_|0,E(),d=d+1|0,0}function Oe(_){_=_|0;var ye=0;return ye=_-160|0,Q(ye|0)|0?1:(fe(ye|0),d=d+1|0,0)}function Tu(_){return _=_|0,Q(1)|0?1:(fe(i[d+1|0]|0),d=d+2|0,0)}function Nu(_){return _=_|0,Q(2)|0?1:(fe(u(d+1|0)|0),d=d+3|0,0)}function Ru(_){return _=_|0,Q(4)|0?1:(re(u(d+1|0)|0,u(d+3|0)|0),d=d+5|0,0)}function Ou(_){return _=_|0,Q(8)|0?1:(te(u(d+1|0)|0,u(d+3|0)|0,u(d+5|0)|0,u(d+7|0)|0),d=d+9|0,0)}function Uu(_){return _=_|0,k(),d=d+1|0,0}function Fr(_){return _=_|0,$(_-192|0|0),d=d+1|0,0}function wh(_){return _=_|0,$(_|0),d=d+1|0,0}function bh(_){return _=_|0,$(_|0),d=d+1|0,0}function xh(_){return _=_|0,$(_|0),d=d+1|0,0}function _h(_){return _=_|0,$(_|0),d=d+1|0,0}function Ye(_){return _=_|0,$(_-192|0|0),d=d+1|0,0}function Eh(_){return _=_|0,$(_|0),d=d+1|0,0}function vh(_){return _=_|0,$(_|0),d=d+1|0,0}function Ih(_){return _=_|0,$(_|0),d=d+1|0,0}function Fu(_){return _=_|0,Q(1)|0?1:($(i[d+1|0]|0),d=d+2|0,0)}function Pu(_){return _=_|0,Q(2)|0?1:($(u(d+1|0)|0),d=d+3|0,0)}function Lu(_){return _=_|0,Q(4)|0?1:(Z(u(d+1|0)|0,u(d+3|0)|0),d=d+5|0,0)}function Mu(_){return _=_|0,Q(8)|0?1:(ue(u(d+1|0)|0,u(d+3|0)|0,u(d+5|0)|0,u(d+7|0)|0),d=d+9|0,0)}function qe(_){return _=_|0,P((_|0)-224|0),d=d+1|0,0}function Du(_){return _=_|0,f(),d=d+1|0,0}function ku(_){return _=_|0,x(),d=d+1|0,0}function qu(_){return _=_|0,T(),d=d+1|0,0}function Cu(_){return _=_|0,N(),d=d+1|0,0}function $u(_){return _=_|0,Q(1)|0?1:(P(i[d+1|0]|0),d=d+2|0,0)}function Hu(_){_=_|0;var ye=0,we=0,pe=1,Mn=0,tn=0,Ah=0;return Q(2)|0?1:(ye=i[d+1|0]|0,we=i[d+2|0]|0,(ye|0)&128&&(pe=-1),Mn=+(((ye|0)&124)>>2),tn=+(((ye|0)&3)<<8|we),+Mn==0?p(+(+pe*5960464477539063e-23*+tn)):+Mn==31?+pe==1?+tn>0?D():O():+tn>0?K():H():p(+(+pe*U(2,+(+Mn-25))*+(1024+tn))),d=d+3|0,0)}function Gu(_){return _=_|0,Q(4)|0?1:(g(i[d+1|0]|0,i[d+2|0]|0,i[d+3|0]|0,i[d+4|0]|0),d=d+5|0,0)}function Vu(_){return _=_|0,Q(8)|0?1:(w(i[d+1|0]|0,i[d+2|0]|0,i[d+3|0]|0,i[d+4|0]|0,i[d+5|0]|0,i[d+6|0]|0,i[d+7|0]|0,i[d+8|0]|0),d=d+9|0,0)}function ve(_){return _=_|0,1}function ju(_){return _=_|0,Y(),d=d+1|0,0}var Yu=[m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,S,v,A,M,ve,ve,ve,ve,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,B,L,R,V,ve,ve,ve,ve,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,ie,de,Ee,Ne,ve,ve,ve,he,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,oe,ke,Qt,mr,gr,ve,ve,ve,mt,be,be,be,be,be,be,be,be,be,be,be,be,be,be,be,be,be,be,be,be,be,be,be,be,ot,We,Re,Su,ve,ve,ve,Bu,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Tu,Nu,Ru,Ou,ve,ve,ve,Uu,Fr,Fr,Fr,Fr,Fr,Fr,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Ye,Fu,Pu,Lu,Mu,ve,ve,ve,ve,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,Du,ku,qu,Cu,$u,Hu,Gu,Vu,ve,ve,ve,ju];return{parse:ae}}});var un=ze(ft=>{"use strict";var As=cn().BigNumber;ft.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};ft.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};ft.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};ft.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};ft.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};ft.SHIFT32=Math.pow(2,32);ft.SHIFT16=Math.pow(2,16);ft.MAX_SAFE_HIGH=2097151;ft.NEG_ONE=new As(-1);ft.TEN=new As(10);ft.TWO=new As(2);ft.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Jn=ze(yt=>{"use strict";var{Buffer:$f}=an(),wa=cn().BigNumber,ba=un(),ya=ba.SHIFT32,Hf=ba.SHIFT16,Gf=2097151;yt.parseHalf=function(e){var t,n,i;return i=e[0]&128?-1:1,t=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],t?t===31?i*(n?NaN:1/0):i*Math.pow(2,t-25)*(1024+n):i*5960464477539063e-23*n};function Vf(r){return r<16?"0"+r.toString(16):r.toString(16)}yt.arrayBufferToBignumber=function(r){let e=r.byteLength,t="";for(let n=0;n<e;n++)t+=Vf(r[n]);return new wa(t,16)};yt.buildMap=r=>{let e=new Map,t=Object.keys(r),n=t.length;for(let i=0;i<n;i++)e.set(t[i],r[t[i]]);return e};yt.buildInt32=(r,e)=>r*Hf+e;yt.buildInt64=(r,e,t,n)=>{let i=yt.buildInt32(r,e),s=yt.buildInt32(t,n);return i>Gf?new wa(i).times(ya).plus(s):i*ya+s};yt.writeHalf=function(e,t){let n=$f.allocUnsafe(4);n.writeFloatBE(t,0);let i=n.readUInt32BE(0);if((i&8191)!==0)return!1;var s=i>>16&32768;let o=i>>23&255,c=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(c>>13);else if(o>=103&&o<113){if(c&(1<<126-o)-1)return!1;s+=c+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};yt.keySorter=function(r,e){var t=r[0].byteLength,n=e[0].byteLength;return t>n?1:n>t?-1:r[0].compare(e[0])};yt.isNegativeZero=r=>r===0&&1/r<0;yt.nextPowerOf2=r=>{let e=0;if(r&&!(r&r-1))return r;for(;r!==0;)r>>=1,e+=1;return 1<<e}});var Ns=ze((sd,xa)=>{"use strict";var Ts=un(),jf=Ts.MT,ei=Ts.SIMPLE,Ss=Ts.SYMS,Bs=class r{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,jf.SIMPLE_FLOAT)}static isSimple(e){return e instanceof r}static decode(e,t){switch(t==null&&(t=!0),e){case ei.FALSE:return!1;case ei.TRUE:return!0;case ei.NULL:return t?null:Ss.NULL;case ei.UNDEFINED:return t?void 0:Ss.UNDEFINED;case-1:if(!t)throw new Error("Invalid BREAK");return Ss.BREAK;default:return new r(e)}}};xa.exports=Bs});var Os=ze((od,_a)=>{"use strict";var Rs=class r{constructor(e,t,n){if(this.tag=e,this.value=t,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 t,n;if(n=e?.[this.tag],typeof n!="function"&&(n=r["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(r,this.value)}catch(i){return t=i,this.err=t,this}}};_a.exports=Rs});var Ps=ze((ad,va)=>{"use strict";var Ea=self.location?self.location.protocol+"//"+self.location.host:"",Us=self.URL,Fs=class{constructor(e="",t=Ea){this.super=new Us(e,t),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}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set origin(e){this.super.origin=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set searchParams(e){this.super.searchParams=e}set username(e){this.super.username=e}createObjectURL(e){return this.super.createObjectURL(e)}revokeObjectURL(e){this.super.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function Yf(r){if(typeof r=="string")return new Us(r).toString();if(!(r instanceof Us)){let e=r.username&&r.password?`${r.username}:${r.password}@`:"",t=r.auth?r.auth+"@":"",n=r.port?":"+r.port:"",i=r.protocol?r.protocol+"//":"",s=r.host||"",o=r.hostname||"",c=r.search||(r.query?"?"+r.query:""),a=r.hash||"",h=r.pathname||"",p=r.path||h+c;return`${i}${e||t}${s||o+n}${p}${a}`}}va.exports={URLWithLegacySupport:Fs,URLSearchParams:self.URLSearchParams,defaultBase:Ea,format:Yf}});var Sa=ze((cd,Aa)=>{"use strict";var{URLWithLegacySupport:Ia,format:zf}=Ps();Aa.exports=(r,e={},t={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(t[i]||n||i)+":";let s;try{s=new Ia(r)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new Ia(r,zf(o)).toString()}});var Ls=ze((ud,Ba)=>{"use strict";var{URLWithLegacySupport:Kf,format:Zf,URLSearchParams:Wf,defaultBase:Xf}=Ps(),Qf=Sa();Ba.exports={URL:Kf,URLSearchParams:Wf,format:Zf,relative:Qf,defaultBase:Xf}});var Ms=ze((fd,Na)=>{"use strict";var{Buffer:Mr}=an(),Ta=da(),Jf=cn().BigNumber,e0=ga(),nt=Jn(),_e=un(),t0=Ns(),r0=Os(),{URL:n0}=Ls(),fn=class r{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=nt.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=Mr.from(this._heap),this._reset(),this._knownTags=Object.assign({0:t=>new Date(t),1:t=>new Date(t*1e3),2:t=>nt.arrayBufferToBignumber(t),3:t=>_e.NEG_ONE.minus(nt.arrayBufferToBignumber(t)),4:t=>_e.TEN.pow(t[0]).times(t[1]),5:t=>_e.TWO.pow(t[0]).times(t[1]),32:t=>new n0(t),35:t=>new RegExp(t)},e.tags),this.parser=e0(globalThis,{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 _e.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case _e.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case _e.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case _e.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 _e.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 _e.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===_e.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,t){let n=this._currentParent;switch(n.values++,n.type){case _e.PARENT.ARRAY:case _e.PARENT.BYTE_STRING:case _e.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case _e.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=_e.PARENT.MAP,n.ref=nt.buildMap(n.ref)));break;case _e.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case _e.PARENT.TAG:this._ref.push(e),t||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,t,n){this._parents[this._depth]={type:t,length:n,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:_e.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,t){let n=this._knownTags[e];return n?n(t):new r0(e,t)}createMap(e,t){return e}createObject(e,t){return e}createArray(e,t){return e}createByteString(e,t){return Mr.concat(e)}createByteStringFromHeap(e,t){return e===t?Mr.alloc(0):Mr.from(this._heap.slice(e,t))}createInt(e){return e}createInt32(e,t){return nt.buildInt32(e,t)}createInt64(e,t,n,i){return nt.buildInt64(e,t,n,i)}createFloat(e){return e}createFloatSingle(e,t,n,i){return Ta.read([e,t,n,i],0,!1,23,4)}createFloatDouble(e,t,n,i,s,o,c,a){return Ta.read([e,t,n,i,s,o,c,a],0,!1,52,8)}createInt32Neg(e,t){return-1-nt.buildInt32(e,t)}createInt64Neg(e,t,n,i){let s=nt.buildInt32(e,t),o=nt.buildInt32(n,i);return s>_e.MAX_SAFE_HIGH?_e.NEG_ONE.minus(new Jf(s).times(_e.SHIFT32).plus(o)):-1-(s*_e.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,t){return e.join("")}createUtf8StringFromHeap(e,t){return e===t?"":this._buffer.toString("utf8",e,t)}createSimpleUnassigned(e){return new t0(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,t){this._push(this.createInt32(e,t))}pushInt64(e,t,n,i){this._push(this.createInt64(e,t,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,t,n,i){this._push(this.createFloatSingle(e,t,n,i))}pushFloatDouble(e,t,n,i,s,o,c,a){this._push(this.createFloatDouble(e,t,n,i,s,o,c,a))}pushInt32Neg(e,t){this._push(this.createInt32Neg(e,t))}pushInt64Neg(e,t,n,i){this._push(this.createInt64Neg(e,t,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([],_e.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,t){let n=nt.buildInt32(e,t);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,t,n,i){let s=nt.buildInt64(e,t,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,t){let n=nt.buildInt32(e,t);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,t,n,i){let s=nt.buildInt64(e,t,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:_e.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,t){this._push(this.createByteStringFromHeap(e,t))}pushUtf8StringStart(){this._parents[this._depth]={type:_e.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,t){this._push(this.createUtf8StringFromHeap(e,t))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:_e.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,t){this.pushTagStart(nt.buildInt32(e,t))}pushTagStart8(e,t,n,i){this.pushTagStart(nt.buildInt64(e,t,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({},_e.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),_e.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let t=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(t>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,t){return typeof e=="string"&&(e=Mr.from(e,t||"hex")),new r({size:e.length}).decodeFirst(e)}static decodeAll(e,t){return typeof e=="string"&&(e=Mr.from(e,t||"hex")),new r({size:e.length}).decodeAll(e)}};fn.decodeFirst=fn.decode;Na.exports=fn});var Ua=ze((ld,Oa)=>{"use strict";var{Buffer:Ds}=an(),i0=Ms(),s0=Jn(),ks=class r extends i0{createTag(e,t){return`${e}(${t})`}createInt(e){return super.createInt(e).toString()}createInt32(e,t){return super.createInt32(e,t).toString()}createInt64(e,t,n,i){return super.createInt64(e,t,n,i).toString()}createInt32Neg(e,t){return super.createInt32Neg(e,t).toString()}createInt64Neg(e,t,n,i){return super.createInt64Neg(e,t,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let t=super.createFloat(e);return s0.isNegativeZero(e)?"-0_1":`${t}_1`}createFloatSingle(e,t,n,i){return`${super.createFloatSingle(e,t,n,i)}_2`}createFloatDouble(e,t,n,i,s,o,c,a){return`${super.createFloatDouble(e,t,n,i,s,o,c,a)}_3`}createByteString(e,t){let n=e.join(", ");return t===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,t){return`h'${Ds.from(super.createByteStringFromHeap(e,t)).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,t){let n=super.createArray(e,t);return t===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(e,t){let n=super.createMap(e),i=Array.from(n.keys()).reduce(Ra(n),"");return t===-1?`{_ ${i}}`:`{${i}}`}createObject(e,t){let n=super.createObject(e),i=Object.keys(n).reduce(Ra(n),"");return t===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,t){let n=e.join(", ");return t===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,t){return`"${Ds.from(super.createUtf8StringFromHeap(e,t)).toString("utf8")}"`}static diagnose(e,t){return typeof e=="string"&&(e=Ds.from(e,t||"hex")),new r().decodeFirst(e)}};Oa.exports=ks;function Ra(r){return(e,t)=>e?`${e}, ${t}: ${r[t]}`:`${t}: ${r[t]}`}});var Da=ze((hd,Ma)=>{"use strict";var{Buffer:Lt}=an(),{URL:o0}=Ls(),Cs=cn().BigNumber,qs=Jn(),Ge=un(),xt=Ge.MT,ti=Ge.NUMBYTES,Fa=Ge.SHIFT32,Pa=Ge.SYMS,Dr=Ge.TAG,a0=Ge.MT.SIMPLE_FLOAT<<5|Ge.NUMBYTES.TWO,c0=Ge.MT.SIMPLE_FLOAT<<5|Ge.NUMBYTES.FOUR,u0=Ge.MT.SIMPLE_FLOAT<<5|Ge.NUMBYTES.EIGHT,f0=Ge.MT.SIMPLE_FLOAT<<5|Ge.SIMPLE.TRUE,l0=Ge.MT.SIMPLE_FLOAT<<5|Ge.SIMPLE.FALSE,h0=Ge.MT.SIMPLE_FLOAT<<5|Ge.SIMPLE.UNDEFINED,La=Ge.MT.SIMPLE_FLOAT<<5|Ge.SIMPLE.NULL,d0=new Cs("0x20000000000000"),p0=Lt.from("f97e00","hex"),m0=Lt.from("f9fc00","hex"),g0=Lt.from("f97c00","hex");function y0(r){return{}.toString.call(r).slice(8,-1)}var $s=class r{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[o0,this._pushUrl],[Cs,this._pushBigNumber]];let t=e.genTypes||[],n=t.length;for(let i=0;i<n;i++)this.addSemanticType(t[i][0],t[i][1]);this._reset()}addSemanticType(e,t){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]=t,o}return this.semanticTypes.push([e,t]),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,t,n){return this.result[this.offset]=e,this.resultMethod[this.offset]=t,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(p0)}_pushInfinity(e){let t=e<0?m0:g0;return this.push(t)}_pushFloat(e){let t=Lt.allocUnsafe(2);if(qs.writeHalf(t,e)&&qs.parseHalf(t)===e)return this._pushUInt8(a0)&&this.push(t);let n=Lt.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(c0)&&this.push(n):this._pushUInt8(u0)&&this._pushDoubleBE(e)}_pushInt(e,t,n){let i=t<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|ti.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|ti.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|ti.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|ti.EIGHT)&&this._pushUInt32BE(Math.floor(e/Fa))&&this._pushUInt32BE(e%Fa):t===xt.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,xt.NEG_INT,e):this._pushInt(e,xt.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 t=Lt.byteLength(e,"utf8");return this._pushInt(t,xt.UTF8_STRING)&&this.pushWrite(e,5,t)}_pushBoolean(e){return this._pushUInt8(e?f0:l0)}_pushUndefined(e){return this._pushUInt8(h0)}_pushArray(e,t){let n=t.length;if(!e._pushInt(n,xt.ARRAY))return!1;for(let i=0;i<n;i++)if(!e.pushAny(t[i]))return!1;return!0}_pushTag(e){return this._pushInt(e,xt.TAG)}_pushDate(e,t){return e._pushTag(Dr.DATE_EPOCH)&&e.pushAny(Math.round(t/1e3))}_pushBuffer(e,t){return e._pushInt(t.length,xt.BYTE_STRING)&&e.push(t)}_pushNoFilter(e,t){return e._pushBuffer(e,t.slice())}_pushRegexp(e,t){return e._pushTag(Dr.REGEXP)&&e.pushAny(t.source)}_pushSet(e,t){if(!e._pushInt(t.size,xt.ARRAY))return!1;for(let n of t)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,t){return e._pushTag(Dr.URI)&&e.pushAny(t.format())}_pushBigint(e){let t=Dr.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),t=Dr.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Lt.from(n,"hex");return this._pushTag(t)&&this._pushBuffer(this,i)}_pushBigNumber(e,t){if(t.isNaN())return e._pushNaN();if(!t.isFinite())return e._pushInfinity(t.isNegative()?-1/0:1/0);if(t.isInteger())return e._pushBigint(t);if(!(e._pushTag(Dr.DECIMAL_FRAC)&&e._pushInt(2,xt.ARRAY)))return!1;let n=t.decimalPlaces(),i=t.multipliedBy(new Cs(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(d0)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,t){return e._pushInt(t.size,xt.MAP)?this._pushRawMap(t.size,Array.from(t)):!1}_pushObject(e){if(!e)return this._pushUInt8(La);for(var t=this.semanticTypes.length,n=0;n<t;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,xt.MAP)?this._pushRawMap(o,s.map(c=>[c,e[c]])):!1}_pushRawMap(e,t){t=t.map(function(i){return i[0]=r.encode(i[0]),i}).sort(qs.keySorter);for(var n=0;n<e;n++)if(!this.push(t[n][0])||!this.pushAny(t[n][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var t=y0(e);switch(t){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,Lt.isBuffer(e)?e:Lt.from(e));case"Null":return this._pushUInt8(La);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 Pa.NULL:return this._pushObject(null);case Pa.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,t=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=t[o];var c=Lt.allocUnsafe(s),a=0,h=0;for(o=0;o<i;o++){switch(h=t[o],n[o]){case 0:e[o].copy(c,a);break;case 1:c.writeUInt8(e[o],a,!0);break;case 2:c.writeUInt16BE(e[o],a,!0);break;case 3:c.writeUInt32BE(e[o],a,!0);break;case 4:c.writeDoubleBE(e[o],a,!0);break;case 5:c.write(e[o],a,h,"utf8");break;default:throw new Error("unkown method")}a+=h}var p=c;return this._reset(),p}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let t=new r;if(!t.pushAny(e))throw new Error("Failed to encode input");return t.finalize()}};Ma.exports=$s});var Hs=ze(Ve=>{"use strict";Ve.Diagnose=Ua();Ve.Decoder=Ms();Ve.Encoder=Da();Ve.Simple=Ns();Ve.Tagged=Os();Ve.decodeAll=Ve.Decoder.decodeAll;Ve.decodeFirst=Ve.Decoder.decodeFirst;Ve.diagnose=Ve.Diagnose.diagnose;Ve.encode=Ve.Encoder.encode;Ve.decode=Ve.Decoder.decode;Ve.leveldb={decode:Ve.Decoder.decodeAll,encode:Ve.Encoder.encode,buffer:!0,name:"cbor"}});var js=ze(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});var w0=9007199254740992;function Gt(r,...e){let t=new Uint8Array(r.byteLength+e.reduce((i,s)=>i+s.byteLength,0));t.set(new Uint8Array(r),0);let n=r.byteLength;for(let i of e)t.set(new Uint8Array(i),n),n+=i.byteLength;return t.buffer}function _t(r,e,t){t=t.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);t=t.slice(-n*2).padStart(n*2,"0");let i=[(r<<5)+e].concat(t.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function ri(r,e){if(e<24)return new Uint8Array([(r<<5)+e]).buffer;{let t=e<=255?24:e<=65535?25:e<=4294967295?26:27;return _t(r,t,e.toString(16))}}function ka(r){let e=[];for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);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):(t++,n=(n&1023)<<10|r.charCodeAt(t)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Gt(new Uint8Array(ri(3,r.length)),new Uint8Array(e))}function b0(r,e){if(r==14277111)return Gt(new Uint8Array([217,217,247]),e);if(r<24)return Gt(new Uint8Array([192+r]),e);{let t=r<=255?24:r<=65535?25:r<=4294967295?26:27,n=2**(t-24),i=r.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+t].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}Ae.tagged=b0;function ln(r){return new Uint8Array(r).buffer}Ae.raw=ln;function Gs(r){if(isNaN(r))throw new RangeError("Invalid number.");r=Math.min(Math.max(0,r),23);let e=[0+r];return new Uint8Array(e).buffer}Ae.uSmall=Gs;function qa(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),255),r=r.toString(16),_t(0,24,r)}Ae.u8=qa;function Ca(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),65535),r=r.toString(16),_t(0,25,r)}Ae.u16=Ca;function $a(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),4294967295),r=r.toString(16),_t(0,26,r)}Ae.u32=$a;function Vs(r,e){if(typeof r=="string"&&e==16){if(r.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return _t(0,27,r)}if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),w0),r=r.toString(16),_t(0,27,r)}Ae.u64=Vs;function Ha(r){if(isNaN(r))throw new RangeError("Invalid number.");if(r===0)return Gs(0);r=Math.min(Math.max(0,-r),24)-1;let e=[32+r];return new Uint8Array(e).buffer}Ae.iSmall=Ha;function Ga(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),255),r=r.toString(16),_t(1,24,r)}Ae.i8=Ga;function Va(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),65535),r=r.toString(16),_t(1,25,r)}Ae.i16=Va;function ja(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),4294967295),r=r.toString(16),_t(1,26,r)}Ae.i32=ja;function Ya(r,e){if(typeof r=="string"&&e==16){if(r.startsWith("-")?r=r.slice(1):r="0",r.match(/[^0-9a-fA-F]/)||r.length>16)throw new RangeError("Invalid number.");let t=!1,n=r.split("").reduceRight((i,s)=>{if(t)return s+i;let o=parseInt(s,16)-1;return o>=0?(t=!0,o.toString(16)+i):"f"+i},"");return t?_t(1,27,n):Vs(0)}if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),9007199254740992),r=r.toString(16),_t(1,27,r)}Ae.i64=Ya;function x0(r){return r>=0?r<24?Gs(r):r<=255?qa(r):r<=65535?Ca(r):r<=4294967295?$a(r):Vs(r):r>=-24?Ha(r):r>=-255?Ga(r):r>=-65535?Va(r):r>=-4294967295?ja(r):Ya(r)}Ae.number=x0;function _0(r){return Gt(ri(2,r.byteLength),r)}Ae.bytes=_0;function E0(r){return ka(r)}Ae.string=E0;function v0(r){return Gt(ri(4,r.length),...r)}Ae.array=v0;function I0(r,e=!1){r instanceof Map||(r=new Map(Object.entries(r)));let t=Array.from(r.entries());return e&&(t=t.sort(([n],[i])=>n.localeCompare(i))),Gt(ri(5,r.size),...t.map(([n,i])=>Gt(ka(n),i)))}Ae.map=I0;function A0(r){let e=new Float32Array([r]);return Gt(new Uint8Array([250]),new Uint8Array(e.buffer))}Ae.singleFloat=A0;function S0(r){let e=new Float64Array([r]);return Gt(new Uint8Array([251]),new Uint8Array(e.buffer))}Ae.doubleFloat=S0;function B0(r){return r?za():Ka()}Ae.bool=B0;function za(){return ln(new Uint8Array([245]))}Ae.true_=za;function Ka(){return ln(new Uint8Array([244]))}Ae.false_=Ka;function T0(){return ln(new Uint8Array([246]))}Ae.null_=T0;function N0(){return ln(new Uint8Array([247]))}Ae.undefined_=N0});var Za=ze(tr=>{"use strict";var R0=tr&&tr.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e};Object.defineProperty(tr,"__esModule",{value:!0});var Et=R0(js()),O0=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],ni=class{constructor(e,t=!1){this._serializer=e,this._stable=t,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 Et.undefined_();case"boolean":return Et.bool(e);case"number":return Math.floor(e)===e?Et.number(e):Et.doubleFloat(e);case"string":return Et.string(e);case"object":if(e===null)return Et.null_();if(Array.isArray(e))return Et.array(e.map(t=>this._serializer.serializeValue(t)));if(O0.find(t=>e instanceof t))return Et.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let t=new Map;for(let[n,i]of e.entries())t.set(n,this._serializer.serializeValue(i));return Et.map(t,this._stable)}else{let t=new Map;for(let[n,i]of Object.entries(e))t.set(n,this._serializer.serializeValue(i));return Et.map(t,this._stable)}default:throw new Error("Invalid value.")}}};tr.JsonDefaultCborEncoder=ni;var ii=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};tr.ToCborEncoder=ii;var si=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let t=new this;return t.addEncoder(new ni(t,e)),t.addEncoder(new ii),t}removeEncoder(e){for(let t of this._encoders.values())t.name==e&&this._encoders.delete(t)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let t=null;for(let n of this._encoders)(!t||n.priority>t.priority)&&n.match(e)&&(t=n);if(t===null)throw new Error("Could not find an encoder for value.");return t}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};tr.CborSerializer=si;var Ys=class extends si{serialize(e){return Et.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};tr.SelfDescribeCborSerializer=Ys});var oi=ze(Er=>{"use strict";function U0(r){for(var e in r)Er.hasOwnProperty(e)||(Er[e]=r[e])}var F0=Er&&Er.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e};Object.defineProperty(Er,"__esModule",{value:!0});U0(Za());var P0=F0(js());Er.value=P0});var qn="abcdefghijklmnopqrstuvwxyz234567",Pr=Object.create(null);for(let r=0;r<qn.length;r++)Pr[qn[r]]=r;Pr[0]=Pr.o;Pr[1]=Pr.i;function Mo(r){let e=0,t=0,n="";function i(s){return e<0?t|=s>>-e:t=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=qn[t>>3],e+=5),0)}for(let s=0;s<r.length;)s+=i(r[s]);return n+(e<0?qn[t>>3]:"")}function Do(r){let e=0,t=0,n=new Uint8Array(r.length*4/3|0),i=0;function s(o){let c=Pr[o.toLowerCase()];if(c===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);c<<=3,t|=c>>>e,e+=5,e>=8&&(n[i++]=t,e-=8,e>0?t=c<<5-e&255:t=0)}for(let o of r)s(o);return n.slice(0,i)}var ef=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 ko(r){let e=new Uint8Array(r),t=-1;for(let n=0;n<e.length;n++){let s=(e[n]^t)&255;t=ef[s]^t>>>8}return(t^-1)>>>0}function tf(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function ds(r,...e){if(!tf(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function ps(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function qo(r,e){ds(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var yr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var $n=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),bt=(r,e)=>r<<32-e|r>>>e;var Fh=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Co(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function ms(r){return typeof r=="string"&&(r=Co(r)),ds(r),r}var Cn=class{clone(){return this._cloneInto()}},Ph={}.toString;function nn(r){let e=n=>r().update(ms(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Hn(r=32){if(yr&&typeof yr.getRandomValues=="function")return yr.getRandomValues(new Uint8Array(r));if(yr&&typeof yr.randomBytes=="function")return yr.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function rf(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),c=Number(t&s),a=n?4:0,h=n?0:4;r.setUint32(e+a,o,n),r.setUint32(e+h,c,n)}var $o=(r,e,t)=>r&e^~r&t,Ho=(r,e,t)=>r&e^r&t^e&t,Lr=class extends Cn{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,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=$n(this.buffer)}update(e){ps(this);let{view:t,buffer:n,blockLen:i}=this;e=ms(e);let s=e.length;for(let o=0;o<s;){let c=Math.min(i-this.pos,s-o);if(c===i){let a=$n(e);for(;i<=s-o;o+=i)this.process(a,o);continue}n.set(e.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ps(this),qo(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let g=o;g<i;g++)t[g]=0;rf(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=$n(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let h=a/4,p=this.get();if(h>p.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<h;g++)c.setUint32(4*g,p[g],s)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:i,finished:s,destroyed:o,pos:c}=this;return e.length=i,e.pos=c,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}};var nf=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]),Jt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),er=new Uint32Array(64),Gn=class extends Lr{constructor(){super(64,32,8,!1),this.A=Jt[0]|0,this.B=Jt[1]|0,this.C=Jt[2]|0,this.D=Jt[3]|0,this.E=Jt[4]|0,this.F=Jt[5]|0,this.G=Jt[6]|0,this.H=Jt[7]|0}get(){let{A:e,B:t,C:n,D:i,E:s,F:o,G:c,H:a}=this;return[e,t,n,i,s,o,c,a]}set(e,t,n,i,s,o,c,a){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=a|0}process(e,t){for(let g=0;g<16;g++,t+=4)er[g]=e.getUint32(t,!1);for(let g=16;g<64;g++){let w=er[g-15],x=er[g-2],f=bt(w,7)^bt(w,18)^w>>>3,N=bt(x,17)^bt(x,19)^x>>>10;er[g]=N+er[g-7]+f+er[g-16]|0}let{A:n,B:i,C:s,D:o,E:c,F:a,G:h,H:p}=this;for(let g=0;g<64;g++){let w=bt(c,6)^bt(c,11)^bt(c,25),x=p+w+$o(c,a,h)+nf[g]+er[g]|0,N=(bt(n,2)^bt(n,13)^bt(n,22))+Ho(n,i,s)|0;p=h,h=a,a=c,c=o+x|0,o=s,s=i,i=n,n=x+N|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,a=a+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(n,i,s,o,c,a,h,p)}roundClean(){er.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},gs=class extends Gn{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}},sn=nn(()=>new Gn),Go=nn(()=>new gs);function Vo(r){return Go.create().update(new Uint8Array(r)).digest()}var Vn="__principal__",sf=2,jo=4,of="aaaaa-aa",af=r=>{var e;return new Uint8Array(((e=r.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(t=>parseInt(t,16)))},cf=r=>r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),""),me=class r{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([jo]))}static managementCanister(){return this.fromHex(of)}static selfAuthenticating(e){let t=Vo(e);return new this(new Uint8Array([...t,sf]))}static from(e){if(typeof e=="string")return r.fromText(e);if(Object.getPrototypeOf(e)===Uint8Array.prototype)return new r(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new r(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(af(e))}static fromText(e){let t=e;if(e.includes(Vn)){let o=JSON.parse(e);Vn in o&&(t=o[Vn])}let n=t.toLowerCase().replace(/-/g,""),i=Do(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==t)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${t}" 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]===jo}toUint8Array(){return this._arr}toHex(){return cf(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,ko(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),c=Mo(s).match(/.{1,5}/g);if(!c)throw new Error;return c.join("-")}toString(){return this.toText()}toJSON(){return{[Vn]:this.toText()}}compareTo(e){for(let t=0;t<Math.min(this._arr.length,e._arr.length);t++){if(this._arr[t]<e._arr[t])return"lt";if(this._arr[t]>e._arr[t])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let t=this.compareTo(e);return t=="lt"||t=="eq"}gtEq(e){let t=this.compareTo(e);return t=="gt"||t=="eq"}};var ys;(function(r){r[r.SysFatal=1]="SysFatal",r[r.SysTransient=2]="SysTransient",r[r.DestinationInvalid=3]="DestinationInvalid",r[r.CanisterReject=4]="CanisterReject",r[r.CanisterError=5]="CanisterError"})(ys||(ys={}));function Qe(...r){let e=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),t=0;for(let n of r)e.set(new Uint8Array(n),t),t+=n.byteLength;return e.buffer}function Fe(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}var uf=new RegExp(/^[0-9a-fA-F]+$/);function wr(r){if(!uf.test(r))throw new Error("Invalid hexadecimal string.");let e=[...r].reduce((t,n,i)=>(t[i/2|0]=(t[i/2|0]||"")+n,t),[]).map(t=>Number.parseInt(t,16));return new Uint8Array(e).buffer}function ws(r,e){if(r.byteLength!==e.byteLength)return r.byteLength-e.byteLength;let t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return t[i]-n[i];return 0}function br(r,e){return ws(r,e)===0}function on(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function bs(r){return r instanceof Uint8Array?on(r):r instanceof ArrayBuffer?r:Array.isArray(r)?on(new Uint8Array(r)):"buffer"in r?bs(r.buffer):on(new Uint8Array(r))}var Ue=class r extends Error{constructor(e){super(e),this.message=e,this.name="AgentError",this.__proto__=r.prototype,Object.setPrototypeOf(this,r.prototype)}};var ui={};kn(ui,{CborTag:()=>ai,decode:()=>lt,encode:()=>hn});var Xa=rn(Hs()),vr=rn(oi()),Qa=rn(oi());var zs=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return vr.value.bytes(e.toUint8Array())}},Ks=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return vr.value.bytes(new Uint8Array(e))}},Zs=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?vr.value.tagged(2,vr.value.bytes(wr(e.toString(16)))):vr.value.tagged(3,vr.value.bytes(wr((BigInt("-1")*e).toString(16))))}},ci=Qa.SelfDescribeCborSerializer.withDefaultEncoders(!0);ci.addEncoder(new zs);ci.addEncoder(new Ks);ci.addEncoder(new Zs);var ai;(function(r){r[r.Uint64LittleEndian=71]="Uint64LittleEndian",r[r.Semantic=55799]="Semantic"})(ai||(ai={}));function hn(r){return ci.serialize(r)}function Wa(r){let e=r.byteLength,t=BigInt(0);for(let n=0;n<e;n++)t=t*BigInt(256)+BigInt(r[n]);return t}var Ws=class extends Xa.default.Decoder{createByteString(e){return Qe(...e)}createByteStringFromHeap(e,t){return e===t?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,t))}};function lt(r){let e=new Uint8Array(r),t=new Ws({size:e.byteLength,tags:{2:n=>Wa(n),3:n=>-Wa(n),[ai.Semantic]:n=>n}});try{return t.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${Fe(e)}`)}}var no={};kn(no,{Bool:()=>sc,BoolClass:()=>mi,ConstructType:()=>Dt,Empty:()=>nc,EmptyClass:()=>di,FixedIntClass:()=>jt,FixedNatClass:()=>Mt,Float32:()=>fc,Float64:()=>lc,FloatClass:()=>pn,Func:()=>Bc,FuncClass:()=>gn,Int:()=>cc,Int16:()=>dc,Int32:()=>pc,Int64:()=>mc,Int8:()=>hc,IntClass:()=>wi,Nat:()=>uc,Nat16:()=>yc,Nat32:()=>wc,Nat64:()=>bc,Nat8:()=>gc,NatClass:()=>bi,Null:()=>oc,NullClass:()=>gi,Opt:()=>vc,OptClass:()=>Cr,PrimitiveType:()=>ct,Principal:()=>xc,PrincipalClass:()=>vi,Rec:()=>Sc,RecClass:()=>ir,Record:()=>Ic,RecordClass:()=>mn,Reserved:()=>ic,ReservedClass:()=>qr,Service:()=>Tc,ServiceClass:()=>Ii,Text:()=>ac,TextClass:()=>yi,Tuple:()=>_c,TupleClass:()=>_i,Type:()=>kr,Unknown:()=>k0,UnknownClass:()=>pi,Variant:()=>Ac,VariantClass:()=>Ei,Vec:()=>Ec,VecClass:()=>xi,Visitor:()=>hi,decode:()=>D0,encode:()=>M0});function xe(...r){let e=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),t=0;for(let n of r)e.set(new Uint8Array(n),t),t+=n.byteLength;return e}var vt=class{constructor(e,t=e?.byteLength||0){this._buffer=Qs(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,t)}get buffer(){return Qs(this._view.slice())}get byteLength(){return this._view.byteLength}read(e){let t=this._view.subarray(0,e);return this._view=this._view.subarray(e),t.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let t=new Uint8Array(e),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+t.byteLength>=this._buffer.byteLength?this.alloc(t.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+t.byteLength),this._view.set(t,n)}get end(){return this._view.byteLength===0}alloc(e){let t=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),n=new Uint8Array(t,0,this._view.byteLength+e);n.set(this._view),this._buffer=t,this._view=n}};function Xs(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function Qs(r){return r instanceof Uint8Array?Xs(r):r instanceof ArrayBuffer?r:Array.isArray(r)?Xs(new Uint8Array(r)):"buffer"in r?Qs(r.buffer):Xs(new Uint8Array(r))}function L0(r){let t=new TextEncoder().encode(r),n=0;for(let i of t)n=(n*223+i)%2**32;return n}function It(r){if(/^_\d+_$/.test(r)||/^_0x[0-9a-fA-F]+_$/.test(r)){let e=+r.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return L0(r)}function Ja(){throw new Error("unexpected end of buffer")}function nr(r,e){return r.byteLength<e&&Ja(),r.read(e)}function rr(r){let e=r.readUint8();return e===void 0&&Ja(),e}function Be(r){if(typeof r=="number"&&(r=BigInt(r)),r<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,t=new vt(new ArrayBuffer(e),0);for(;;){let n=Number(r&BigInt(127));if(r/=BigInt(128),r===BigInt(0)){t.write(new Uint8Array([n]));break}else t.write(new Uint8Array([n|128]))}return t.buffer}function Ce(r){let e=BigInt(1),t=BigInt(0),n;do n=rr(r),t+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return t}function $e(r){typeof r=="number"&&(r=BigInt(r));let e=r<BigInt(0);e&&(r=-r-BigInt(1));let t=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,n=new vt(new ArrayBuffer(t),0);for(;;){let s=i(r);if(r/=BigInt(128),e&&r===BigInt(0)&&(s&64)!==0||!e&&r===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}function Vt(r){let e=new Uint8Array(r.buffer),t=0;for(;t<e.byteLength;t++)if(e[t]<128){if((e[t]&64)===0)return Ce(r);break}let n=new Uint8Array(nr(r,t+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)}function ec(r,e){if(BigInt(r)<BigInt(0))throw new Error("Cannot write negative values.");return Js(r,e)}function Js(r,e){r=BigInt(r);let t=new vt(new ArrayBuffer(Math.min(1,e)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(r%i);for(t.write(new Uint8Array([o]));++n<e;)r<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((r/i-s)%BigInt(256)),t.write(new Uint8Array([o])),i*=BigInt(256);return t.buffer}function eo(r,e){let t=BigInt(rr(r)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(rr(r));t=t+n*s}return t}function tc(r,e){let t=eo(r,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return t>=n&&(t-=n*BigInt(2)),t}function fi(r){let e=BigInt(r);if(r<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}var li="DIDL",rc=400;function dn(r,e,t){return r.map((n,i)=>t(n,e[i]))}var to=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,t){let n=this._typs.length;this._idx.set(e.name,n),this._typs.push(t)}merge(e,t){let n=this._idx.get(e.name),i=this._idx.get(t);if(n===void 0)throw new Error("Missing type index for "+e);if(i===void 0)throw new Error("Missing type index for "+t);this._typs[n]=this._typs[i],this._typs.splice(i,1),this._idx.delete(t)}encode(){let e=Be(this._typs.length),t=xe(...this._typs);return xe(e,t)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return $e(this._idx.get(e)||0)}},hi=class{visitType(e,t){throw new Error("Not implemented")}visitPrimitive(e,t){return this.visitType(e,t)}visitEmpty(e,t){return this.visitPrimitive(e,t)}visitBool(e,t){return this.visitPrimitive(e,t)}visitNull(e,t){return this.visitPrimitive(e,t)}visitReserved(e,t){return this.visitPrimitive(e,t)}visitText(e,t){return this.visitPrimitive(e,t)}visitNumber(e,t){return this.visitPrimitive(e,t)}visitInt(e,t){return this.visitNumber(e,t)}visitNat(e,t){return this.visitNumber(e,t)}visitFloat(e,t){return this.visitPrimitive(e,t)}visitFixedInt(e,t){return this.visitNumber(e,t)}visitFixedNat(e,t){return this.visitNumber(e,t)}visitPrincipal(e,t){return this.visitPrimitive(e,t)}visitConstruct(e,t){return this.visitType(e,t)}visitVec(e,t,n){return this.visitConstruct(e,n)}visitOpt(e,t,n){return this.visitConstruct(e,n)}visitRecord(e,t,n){return this.visitConstruct(e,n)}visitTuple(e,t,n){let i=t.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(e,i,n)}visitVariant(e,t,n){return this.visitConstruct(e,n)}visitRec(e,t,n){return this.visitConstruct(t,n)}visitFunc(e,t){return this.visitConstruct(e,t)}visitService(e,t){return this.visitConstruct(e,t)}},kr=class{display(){return this.name}valueToString(e){return Pe(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}},ct=class extends kr{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){}},Dt=class extends kr{checkType(e){if(e instanceof ir){let t=e.getType();if(typeof t>"u")throw new Error("type mismatch with uninitialized type");return t}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}},di=class extends ct{accept(e,t){return e.visitEmpty(this,t)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return $e(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},pi=class extends kr{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,t){throw e.visitType(this,t)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Pe(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,t){let n=t.decodeValue(e,t);Object(n)!==n&&(n=Object(n));let i;return t instanceof ir?i=()=>t.getType():i=()=>t,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"}},mi=class extends ct{accept(e,t){return e.visitBool(this,t)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return $e(-2)}decodeValue(e,t){switch(this.checkType(t),rr(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},gi=class extends ct{accept(e,t){return e.visitNull(this,t)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return $e(-1)}decodeValue(e,t){return this.checkType(t),null}get name(){return"null"}},qr=class extends ct{accept(e,t){return e.visitReserved(this,t)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return $e(-16)}decodeValue(e,t){return t.name!==this.name&&t.decodeValue(e,t),null}get name(){return"reserved"}},yi=class extends ct{accept(e,t){return e.visitText(this,t)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){let t=new TextEncoder().encode(e),n=Be(t.byteLength);return xe(n,t)}encodeType(){return $e(-15)}decodeValue(e,t){this.checkType(t);let n=Ce(e),i=nr(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}},wi=class extends ct{accept(e,t){return e.visitInt(this,t)}covariant(e){if(typeof e=="bigint"||Number.isInteger(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){return $e(e)}encodeType(){return $e(-4)}decodeValue(e,t){return this.checkType(t),Vt(e)}get name(){return"int"}valueToString(e){return e.toString()}},bi=class extends ct{accept(e,t){return e.visitNat(this,t)}covariant(e){if(typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){return Be(e)}encodeType(){return $e(-3)}decodeValue(e,t){return this.checkType(t),Ce(e)}get name(){return"nat"}valueToString(e){return e.toString()}},pn=class extends ct{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,t){return e.visitFloat(this,t)}covariant(e){if(typeof e=="number"||e instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){let t=new ArrayBuffer(this._bits/8),n=new DataView(t);return this._bits===32?n.setFloat32(0,e,!0):n.setFloat64(0,e,!0),t}encodeType(){let e=this._bits===32?-13:-14;return $e(e)}decodeValue(e,t){this.checkType(t);let n=nr(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()}},jt=class extends ct{constructor(e){super(),this._bits=e}accept(e,t){return e.visitFixedInt(this,t)}covariant(e){let t=fi(this._bits-1)*BigInt(-1),n=fi(this._bits-1)-BigInt(1),i=!1;if(typeof e=="bigint")i=e>=t&&e<=n;else if(Number.isInteger(e)){let s=BigInt(e);i=s>=t&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){return Js(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return $e(-9-e)}decodeValue(e,t){this.checkType(t);let n=tc(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}},Mt=class extends ct{constructor(e){super(),this._bits=e}accept(e,t){return e.visitFixedNat(this,t)}covariant(e){let t=fi(this._bits),n=!1;if(typeof e=="bigint"&&e>=BigInt(0)?n=e<t:Number.isInteger(e)&&e>=0?n=BigInt(e)<t:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){return ec(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return $e(-5-e)}decodeValue(e,t){this.checkType(t);let n=eo(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}},xi=class r extends Dt{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Mt&&e._bits===8&&(this._blobOptimization=!0)}accept(e,t){return e.visitVec(this,this._type,t)}covariant(e){let t=this._type instanceof Mt?this._type._bits:this._type instanceof jt?this._type._bits:0;if(ArrayBuffer.isView(e)&&t==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:
|
|
2
|
-
|
|
3
|
-
index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){let t=Be(e.length);if(this._blobOptimization)return xe(t,new Uint8Array(e));if(ArrayBuffer.isView(e))return xe(t,new Uint8Array(e.buffer));let n=new vt(new ArrayBuffer(t.byteLength+e.length),0);n.write(t);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 t=$e(-19),n=this._type.encodeType(e);e.add(this,xe(t,n))}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))throw new Error("Not a vector type");let i=Number(Ce(e));if(this._type instanceof Mt){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 jt){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("; ")+"}"}},Cr=class r extends Dt{constructor(e){super(),this._type=e}accept(e,t){return e.visitOpt(this,this._type,t)}covariant(e){try{if(Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0])))return!0}catch(t){throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}
|
|
4
|
-
|
|
5
|
-
-> ${t.message}`)}throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):xe(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let t=$e(-18),n=this._type.encodeType(e);e.add(this,xe(t,n))}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))throw new Error("Not an option type");switch(rr(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])}`}},mn=class r extends Dt{constructor(e={}){super(),this._fields=Object.entries(e).sort((t,n)=>It(t[0])-It(n[0]))}accept(e,t){return e.visitRecord(this,this._fields,t)}tryAsTuple(){let e=[];for(let t=0;t<this._fields.length;t++){let[n,i]=this._fields[t];if(n!==`_${t}_`)return null;e.push(i)}return e}covariant(e){if(typeof e=="object"&&this._fields.every(([t,n])=>{if(!e.hasOwnProperty(t))throw new Error(`Record is missing key "${t}".`);try{return n.covariant(e[t])}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
6
|
-
|
|
7
|
-
field ${t} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){let t=this._fields.map(([i])=>e[i]),n=dn(this._fields,t,([,i],s)=>i.encodeValue(s));return xe(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let t=$e(-20),n=Be(this._fields.length),i=this._fields.map(([s,o])=>xe(Be(It(s)),o.encodeType(e)));e.add(this,xe(t,n,xe(...i)))}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[c,a]=n._fields[o];if(s>=this._fields.length){a.decodeValue(e,a),o++;continue}let[h,p]=this._fields[s],g=It(this._fields[s][0]),w=It(c);if(g===w)i[h]=p.decodeValue(e,a),s++,o++;else if(w>g)if(p instanceof Cr||p instanceof qr)i[h]=[],s++;else throw new Error("Cannot find required field "+h);else a.decodeValue(e,a),o++}for(let[c,a]of this._fields.slice(s))if(a instanceof Cr||a instanceof qr)i[c]=[];else throw new Error("Cannot find required field "+c);return i}get name(){return`record {${this._fields.map(([t,n])=>t+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([t,n])=>t+":"+n.display()).join("; ")}}`}valueToString(e){let t=this._fields.map(([i])=>e[i]);return`record {${dn(this._fields,t,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}},_i=class r extends mn{constructor(e){let t={};e.forEach((n,i)=>t["_"+i+"_"]=n),super(t),this._components=e}accept(e,t){return e.visitTuple(this,this._components,t)}covariant(e){if(Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((t,n)=>{try{return t.covariant(e[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
8
|
-
|
|
9
|
-
index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){let t=dn(this._components,e,(n,i)=>n.encodeValue(i));return xe(...t)}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))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(t=>t.display()).join("; ")}}`}valueToString(e){return`record {${dn(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}},Ei=class r extends Dt{constructor(e={}){super(),this._fields=Object.entries(e).sort((t,n)=>It(t[0])-It(n[0]))}accept(e,t){return e.visitVariant(this,this._fields,t)}covariant(e){if(typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([t,n])=>{try{return!e.hasOwnProperty(t)||n.covariant(e[t])}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
10
|
-
|
|
11
|
-
variant ${t} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){for(let t=0;t<this._fields.length;t++){let[n,i]=this._fields[t];if(e.hasOwnProperty(n)){let s=Be(t),o=i.encodeValue(e[n]);return xe(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let t=$e(-21),n=Be(this._fields.length),i=this._fields.map(([s,o])=>xe(Be(It(s)),o.encodeType(e)));e.add(this,xe(t,n,...i))}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))throw new Error("Not a variant type");let i=Number(Ce(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[c,a]of this._fields)if(It(s)===It(c)){let h=a.decodeValue(e,o);return{[c]:h}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([t,n])=>t+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([t,n])=>t+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(e){for(let[t,n]of this._fields)if(e.hasOwnProperty(t)){let i=n.valueToString(e[t]);return i==="null"?`variant {${t}}`:`variant {${t}=${i}}`}throw new Error("Variant has no data: "+e)}},ir=class r extends Dt{constructor(){super(...arguments),this._id=r._counter++,this._type=void 0}accept(e,t){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,t)}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: ${Pe(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,t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,t)}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)}};ir._counter=0;function ro(r){if(rr(r)!==1)throw new Error("Cannot decode principal");let t=Number(Ce(r));return me.fromUint8Array(new Uint8Array(nr(r,t)))}var vi=class extends ct{accept(e,t){return e.visitPrincipal(this,t)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){let t=e.toUint8Array(),n=Be(t.byteLength);return xe(new Uint8Array([1]),n,t)}encodeType(){return $e(-24)}decodeValue(e,t){return this.checkType(t),ro(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}},gn=class extends Dt{constructor(e,t,n=[]){super(),this.argTypes=e,this.retTypes=t,this.annotations=n}static argsToString(e,t){if(e.length!==t.length)throw new Error("arity mismatch");return"("+e.map((n,i)=>n.valueToString(t[i])).join(", ")+")"}accept(e,t){return e.visitFunc(this,t)}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: ${Pe(e)}`)}encodeValue([e,t]){let n=e.toUint8Array(),i=Be(n.byteLength),s=xe(new Uint8Array([1]),i,n),o=new TextEncoder().encode(t),c=Be(o.byteLength);return xe(new Uint8Array([1]),s,c,o)}_buildTypeTableImpl(e){this.argTypes.forEach(h=>h.buildTypeTable(e)),this.retTypes.forEach(h=>h.buildTypeTable(e));let t=$e(-22),n=Be(this.argTypes.length),i=xe(...this.argTypes.map(h=>h.encodeType(e))),s=Be(this.retTypes.length),o=xe(...this.retTypes.map(h=>h.encodeType(e))),c=Be(this.annotations.length),a=xe(...this.annotations.map(h=>this.encodeAnnotation(h)));e.add(this,xe(t,n,i,s,o,c,a))}decodeValue(e){if(rr(e)!==1)throw new Error("Cannot decode function reference");let n=ro(e),i=Number(Ce(e)),s=nr(e,i),c=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,c]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),t=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${t})${n}`}valueToString([e,t]){return`func "${e.toText()}".${t}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),t=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${t})${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")}},Ii=class extends Dt{constructor(e){super(),this._fields=Object.entries(e).sort((t,n)=>t[0]<n[0]?-1:t[0]>n[0]?1:0)}accept(e,t){return e.visitService(this,t)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pe(e)}`)}encodeValue(e){let t=e.toUint8Array(),n=Be(t.length);return xe(new Uint8Array([1]),n,t)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let t=$e(-23),n=Be(this._fields.length),i=this._fields.map(([s,o])=>{let c=new TextEncoder().encode(s),a=Be(c.length);return xe(a,c,o.encodeType(e))});e.add(this,xe(t,n,...i))}decodeValue(e){return ro(e)}get name(){return`service {${this._fields.map(([t,n])=>t+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};function Pe(r){let e=JSON.stringify(r,(t,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>rc?e.substring(0,rc-3)+"...":e}function M0(r,e){if(e.length<r.length)throw Error("Wrong number of message arguments");let t=new to;r.forEach(a=>a.buildTypeTable(t));let n=new TextEncoder().encode(li),i=t.encode(),s=Be(e.length),o=xe(...r.map(a=>a.encodeType(t))),c=xe(...dn(r,e,(a,h)=>{try{a.covariant(h)}catch(p){throw new Error(p.message+`
|
|
12
|
-
|
|
13
|
-
`)}return a.encodeValue(h)}));return xe(n,i,s,o,c)}function D0(r,e){let t=new vt(e);if(e.byteLength<li.length)throw new Error("Message length smaller than magic number");let n=nr(t,li.length),i=new TextDecoder().decode(n);if(i!==li)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(x){let f=[],N=Number(Ce(x));for(let H=0;H<N;H++){let D=Number(Vt(x));switch(D){case-18:case-19:{let K=Number(Vt(x));f.push([D,K]);break}case-20:case-21:{let K=[],E=Number(Ce(x)),C;for(;E--;){let G=Number(Ce(x));if(G>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof C=="number"&&C>=G)throw new Error("field id collision or not sorted");C=G;let j=Number(Vt(x));K.push([G,j])}f.push([D,K]);break}case-22:{let K=[],E=Number(Ce(x));for(;E--;)K.push(Number(Vt(x)));let C=[],G=Number(Ce(x));for(;G--;)C.push(Number(Vt(x)));let j=[],k=Number(Ce(x));for(;k--;)switch(Number(Ce(x))){case 1:{j.push("query");break}case 2:{j.push("oneway");break}case 3:{j.push("composite_query");break}default:throw new Error("unknown annotation")}f.push([D,[K,C,j]]);break}case-23:{let K=Number(Ce(x)),E=[];for(;K--;){let C=Number(Ce(x)),G=new TextDecoder().decode(nr(x,C)),j=Vt(x);E.push([G,j])}f.push([D,E]);break}default:throw new Error("Illegal op_code: "+D)}}let T=[],O=Number(Ce(x));for(let H=0;H<O;H++)T.push(Number(Vt(x)));return[f,T]}let[o,c]=s(t);if(c.length<r.length)throw new Error("Wrong number of return values");let a=o.map(x=>Sc());function h(x){if(x<-24)throw new Error("future value not supported");if(x<0)switch(x){case-1:return oc;case-2:return sc;case-3:return uc;case-4:return cc;case-5:return gc;case-6:return yc;case-7:return wc;case-8:return bc;case-9:return hc;case-10:return dc;case-11:return pc;case-12:return mc;case-13:return fc;case-14:return lc;case-15:return ac;case-16:return ic;case-17:return nc;case-24:return xc;default:throw new Error("Illegal op_code: "+x)}if(x>=o.length)throw new Error("type index out of range");return a[x]}function p(x){switch(x[0]){case-19:{let f=h(x[1]);return Ec(f)}case-18:{let f=h(x[1]);return vc(f)}case-20:{let f={};for(let[O,H]of x[1]){let D=`_${O}_`;f[D]=h(H)}let N=Ic(f),T=N.tryAsTuple();return Array.isArray(T)?_c(...T):N}case-21:{let f={};for(let[N,T]of x[1]){let O=`_${N}_`;f[O]=h(T)}return Ac(f)}case-22:{let[f,N,T]=x[1];return Bc(f.map(O=>h(O)),N.map(O=>h(O)),T)}case-23:{let f={},N=x[1];for(let[T,O]of N){let H=h(O);if(H instanceof ir&&(H=H.getType()),!(H instanceof gn))throw new Error("Illegal service definition: services can only contain functions");f[T]=H}return Tc(f)}default:throw new Error("Illegal op_code: "+x[0])}}o.forEach((x,f)=>{if(x[0]===-22){let N=p(x);a[f].fill(N)}}),o.forEach((x,f)=>{if(x[0]!==-22){let N=p(x);a[f].fill(N)}});let g=c.map(x=>h(x)),w=r.map((x,f)=>x.decodeValue(t,g[f]));for(let x=r.length;x<g.length;x++)g[x].decodeValue(t,g[x]);if(t.byteLength>0)throw new Error("decode: Left-over bytes");return w}var nc=new di,ic=new qr,k0=new pi,sc=new mi,oc=new gi,ac=new yi,cc=new wi,uc=new bi,fc=new pn(32),lc=new pn(64),hc=new jt(8),dc=new jt(16),pc=new jt(32),mc=new jt(64),gc=new Mt(8),yc=new Mt(16),wc=new Mt(32),bc=new Mt(64),xc=new vi;function _c(...r){return new _i(r)}function Ec(r){return new xi(r)}function vc(r){return new Cr(r)}function Ic(r){return new mn(r)}function Ac(r){return new Ei(r)}function Sc(){return new ir}function Bc(r,e,t=[]){return new gn(r,e,t)}function Tc(r){return new Ii(r)}var Nc=rn(Hs());function wt(r){return on(sn.create().update(new Uint8Array(r)).digest())}function Ai(r){if(r instanceof Nc.default.Tagged)return Ai(r.value);if(typeof r=="string")return Rc(r);if(typeof r=="number")return wt(Be(r));if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))return wt(r);if(Array.isArray(r)){let e=r.map(Ai);return wt(Qe(...e))}else{if(r&&typeof r=="object"&&r._isPrincipal)return wt(r.toUint8Array());if(typeof r=="object"&&r!==null&&typeof r.toHash=="function")return Ai(r.toHash());if(typeof r=="object")return wn(r);if(typeof r=="bigint")return wt(Be(r))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${r}`),{value:r})}var Rc=r=>{let e=new TextEncoder().encode(r);return wt(e)};function yn(r){return wn(r)}function wn(r){let n=Object.entries(r).filter(([,o])=>o!==void 0).map(([o,c])=>{let a=Rc(o),h=Ai(c);return[a,h]}).sort(([o],[c])=>ws(o,c)),i=Qe(...n.map(o=>Qe(...o)));return wt(i)}var Ni={};kn(Ni,{aInRange:()=>Bt,abool:()=>sr,abytes:()=>At,bitGet:()=>uo,bitLen:()=>zt,bitMask:()=>ar,bitSet:()=>V0,bytesToHex:()=>St,bytesToNumberBE:()=>Je,bytesToNumberLE:()=>or,concatBytes:()=>Ie,createHmacDrbg:()=>Fc,ensureBytes:()=>He,equalBytes:()=>G0,hexToBytes:()=>bn,hexToNumber:()=>co,inRange:()=>Bi,isBytes:()=>$r,memoized:()=>Kt,notImplemented:()=>Ti,numberToBytesBE:()=>Le,numberToBytesLE:()=>Ir,numberToHexUnpadded:()=>ao,numberToVarBytesBE:()=>H0,utf8ToBytes:()=>xn,validateObject:()=>Tt});var oo=BigInt(0),Si=BigInt(1),C0=BigInt(2);function $r(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function At(r){if(!$r(r))throw new Error("Uint8Array expected")}function sr(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var $0=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function St(r){At(r);let e="";for(let t=0;t<r.length;t++)e+=$0[r[t]];return e}function ao(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function co(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Yt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Oc(r){if(r>=Yt._0&&r<=Yt._9)return r-Yt._0;if(r>=Yt._A&&r<=Yt._F)return r-(Yt._A-10);if(r>=Yt._a&&r<=Yt._f)return r-(Yt._a-10)}function bn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){let o=Oc(r.charCodeAt(s)),c=Oc(r.charCodeAt(s+1));if(o===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[i]=o*16+c}return n}function Je(r){return co(St(r))}function or(r){return At(r),co(St(Uint8Array.from(r).reverse()))}function Le(r,e){return bn(r.toString(16).padStart(e*2,"0"))}function Ir(r,e){return Le(r,e).reverse()}function H0(r){return bn(ao(r))}function He(r,e,t){let n;if(typeof e=="string")try{n=bn(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if($r(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let i=n.length;if(typeof t=="number"&&i!==t)throw new Error(`${r} expected ${t} bytes, got ${i}`);return n}function Ie(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];At(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}function G0(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function xn(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var io=r=>typeof r=="bigint"&&oo<=r;function Bi(r,e,t){return io(r)&&io(e)&&io(t)&&e<=r&&r<t}function Bt(r,e,t,n){if(!Bi(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function zt(r){let e;for(e=0;r>oo;r>>=Si,e+=1);return e}function uo(r,e){return r>>BigInt(e)&Si}function V0(r,e,t){return r|(t?Si:oo)<<BigInt(e)}var ar=r=>(C0<<BigInt(r-1))-Si,so=r=>new Uint8Array(r),Uc=r=>Uint8Array.from(r);function Fc(r,e,t){if(typeof r!="number"||r<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 t!="function")throw new Error("hmacFn must be a function");let n=so(r),i=so(r),s=0,o=()=>{n.fill(1),i.fill(0),s=0},c=(...g)=>t(i,n,...g),a=(g=so())=>{i=c(Uc([0]),g),n=c(),g.length!==0&&(i=c(Uc([1]),g),n=c())},h=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0,w=[];for(;g<e;){n=c();let x=n.slice();w.push(x),g+=n.length}return Ie(...w)};return(g,w)=>{o(),a(g);let x;for(;!(x=w(h()));)a();return o(),x}}var j0={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||$r(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Tt(r,e,t={}){let n=(i,s,o)=>{let c=j0[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let a=r[i];if(!(o&&a===void 0)&&!c(a,r))throw new Error(`Invalid param ${String(i)}=${a} (${typeof a}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(t))n(i,s,!0);return r}var Ti=()=>{throw new Error("not implemented")};function Kt(r){let e=new WeakMap;return(t,...n)=>{let i=e.get(t);if(i!==void 0)return i;let s=r(t,...n);return e.set(t,s),s}}var je=BigInt(0),Te=BigInt(1),cr=BigInt(2),Y0=BigInt(3),fo=BigInt(4),Pc=BigInt(5),Lc=BigInt(8),z0=BigInt(9),K0=BigInt(16);function Se(r,e){let t=r%e;return t>=je?t:e+t}function Z0(r,e,t){if(t<=je||e<je)throw new Error("Expected power/modulo > 0");if(t===Te)return je;let n=Te;for(;e>je;)e&Te&&(n=n*r%t),r=r*r%t,e>>=Te;return n}function Nt(r,e,t){let n=r;for(;e-- >je;)n*=n,n%=t;return n}function lo(r,e){if(r===je||e<=je)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Se(r,e),n=e,i=je,s=Te,o=Te,c=je;for(;t!==je;){let h=n/t,p=n%t,g=i-o*h,w=s-c*h;n=t,t=p,i=o,s=c,o=g,c=w}if(n!==Te)throw new Error("invert: does not exist");return Se(i,e)}function W0(r){let e=(r-Te)/cr,t,n,i;for(t=r-Te,n=0;t%cr===je;t/=cr,n++);for(i=cr;i<r&&Z0(i,e,r)!==r-Te;i++);if(n===1){let o=(r+Te)/fo;return function(a,h){let p=a.pow(h,o);if(!a.eql(a.sqr(p),h))throw new Error("Cannot find square root");return p}}let s=(t+Te)/cr;return function(c,a){if(c.pow(a,e)===c.neg(c.ONE))throw new Error("Cannot find square root");let h=n,p=c.pow(c.mul(c.ONE,i),t),g=c.pow(a,s),w=c.pow(a,t);for(;!c.eql(w,c.ONE);){if(c.eql(w,c.ZERO))return c.ZERO;let x=1;for(let N=c.sqr(w);x<h&&!c.eql(N,c.ONE);x++)N=c.sqr(N);let f=c.pow(p,Te<<BigInt(h-x-1));p=c.sqr(f),g=c.mul(g,f),w=c.mul(w,p),h=x}return g}}function X0(r){if(r%fo===Y0){let e=(r+Te)/fo;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(r%Lc===Pc){let e=(r-Pc)/Lc;return function(n,i){let s=n.mul(i,cr),o=n.pow(s,e),c=n.mul(i,o),a=n.mul(n.mul(c,cr),o),h=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(h),i))throw new Error("Cannot find square root");return h}}return r%K0,W0(r)}var Mc=(r,e)=>(Se(r,e)&Te)===Te,Q0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ri(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Q0.reduce((n,i)=>(n[i]="function",n),e);return Tt(r,t)}function _n(r,e,t){if(t<je)throw new Error("Expected power > 0");if(t===je)return r.ONE;if(t===Te)return e;let n=r.ONE,i=e;for(;t>je;)t&Te&&(n=r.mul(n,i)),i=r.sqr(i),t>>=Te;return n}function En(r,e){let t=new Array(e.length),n=e.reduce((s,o,c)=>r.is0(o)?s:(t[c]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,c)=>r.is0(o)?s:(t[c]=r.mul(s,t[c]),r.mul(s,o)),i),t}function Dc(r){let e=(r-Te)/cr;return(t,n)=>t.pow(n,e)}function ho(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function kt(r,e,t=!1,n={}){if(r<=je)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:s}=ho(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=X0(r),c=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:ar(i),ZERO:je,ONE:Te,create:a=>Se(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return je<=a&&a<r},is0:a=>a===je,isOdd:a=>(a&Te)===Te,neg:a=>Se(-a,r),eql:(a,h)=>a===h,sqr:a=>Se(a*a,r),add:(a,h)=>Se(a+h,r),sub:(a,h)=>Se(a-h,r),mul:(a,h)=>Se(a*h,r),pow:(a,h)=>_n(c,a,h),div:(a,h)=>Se(a*lo(h,r),r),sqrN:a=>a*a,addN:(a,h)=>a+h,subN:(a,h)=>a-h,mulN:(a,h)=>a*h,inv:a=>lo(a,r),sqrt:n.sqrt||(a=>o(c,a)),invertBatch:a=>En(c,a),cmov:(a,h,p)=>p?h:a,toBytes:a=>t?Ir(a,s):Le(a,s),fromBytes:a=>{if(a.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${a.length}`);return t?or(a):Je(a)}});return Object.freeze(c)}function kc(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function Oi(r){let e=kc(r);return e+Math.ceil(e/2)}function po(r,e,t=!1){let n=r.length,i=kc(e),s=Oi(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=t?Je(r):or(r),c=Se(o,e-Te)+Te;return t?Ir(c,i):Le(c,i)}var J0=Je;function ur(r,e){if(vn(r),vn(e),r<0||r>=1<<8*e)throw new Error(`bad I2OSP call: value=${r} length=${e}`);let t=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)t[n]=r&255,r>>>=8;return new Uint8Array(t)}function el(r,e){let t=new Uint8Array(r.length);for(let n=0;n<r.length;n++)t[n]=r[n]^e[n];return t}function vn(r){if(!Number.isSafeInteger(r))throw new Error("number expected")}function tl(r,e,t,n){At(r),At(e),vn(t),e.length>255&&(e=n(Ie(xn("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(t/i);if(t>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let c=Ie(e,ur(e.length,1)),a=ur(0,s),h=ur(t,2),p=new Array(o),g=n(Ie(a,r,h,ur(0,1),c));p[0]=n(Ie(g,ur(1,1),c));for(let x=1;x<=o;x++){let f=[el(g,p[x-1]),ur(x+1,1),c];p[x]=n(Ie(...f))}return Ie(...p).slice(0,t)}function rl(r,e,t,n,i){if(At(r),At(e),vn(t),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update(xn("H2C-OVERSIZE-DST-")).update(e).digest()}if(t>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:t}).update(r).update(ur(t,2)).update(e).update(ur(e.length,1)).digest()}function qc(r,e,t){Tt(t,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:c,DST:a}=t;At(r),vn(e);let h=typeof a=="string"?xn(a):a,p=n.toString(2).length,g=Math.ceil((p+i)/8),w=e*s*g,x;if(c==="xmd")x=tl(r,h,w,o);else if(c==="xof")x=rl(r,h,w,i,o);else if(c==="_internal_pass")x=r;else throw new Error('expand must be "xmd" or "xof"');let f=new Array(e);for(let N=0;N<e;N++){let T=new Array(s);for(let O=0;O<s;O++){let H=g*(O+N*s),D=x.subarray(H,H+g);T[O]=Se(J0(D),n)}f[N]=T}return f}function go(r,e){let t=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,c,a]=t.map(h=>h.reduce((p,g)=>r.add(r.mul(p,n),g)));return n=r.div(s,o),i=r.mul(i,r.div(c,a)),{x:n,y:i}}}function yo(r,e,t){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=qc(n,2,{...t,DST:t.DST,...i}),o=r.fromAffine(e(s[0])),c=r.fromAffine(e(s[1])),a=o.add(c).clearCofactor();return a.assertValidity(),a},encodeToCurve(n,i){let s=qc(n,1,{...t,DST:t.encodeDST,...i}),o=r.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=r.fromAffine(e(n)).clearCofactor();return i.assertValidity(),i}}}var nl=BigInt(0),wo=BigInt(1),bo=new WeakMap,Cc=new WeakMap;function Ui(r,e){let t=(s,o)=>{let c=o.negate();return s?c: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,c=2**(s-1);return{windows:o,windowSize:c}};return{constTimeNegate:t,unsafeLadder(s,o){let c=r.ZERO,a=s;for(;o>nl;)o&wo&&(c=c.add(a)),a=a.double(),o>>=wo;return c},precomputeWindow(s,o){let{windows:c,windowSize:a}=i(o),h=[],p=s,g=p;for(let w=0;w<c;w++){g=p,h.push(g);for(let x=1;x<a;x++)g=g.add(p),h.push(g);p=g.double()}return h},wNAF(s,o,c){let{windows:a,windowSize:h}=i(s),p=r.ZERO,g=r.BASE,w=BigInt(2**s-1),x=2**s,f=BigInt(s);for(let N=0;N<a;N++){let T=N*h,O=Number(c&w);c>>=f,O>h&&(O-=x,c+=wo);let H=T,D=T+Math.abs(O)-1,K=N%2!==0,E=O<0;O===0?g=g.add(t(K,o[H])):p=p.add(t(E,o[D]))}return{p,f:g}},wNAFCached(s,o,c){let a=Cc.get(s)||1,h=bo.get(s);return h||(h=this.precomputeWindow(s,a),a!==1&&bo.set(s,c(h))),this.wNAF(a,h,o)},setWindowSize(s,o){n(o),Cc.set(s,o),bo.delete(s)}}}function Fi(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((p,g)=>{if(!e.isValid(p))throw new Error(`wrong scalar at index ${g}`)}),t.forEach((p,g)=>{if(!(p instanceof r))throw new Error(`wrong point at index ${g}`)});let i=zt(BigInt(t.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,c=new Array(o+1).fill(r.ZERO),a=Math.floor((e.BITS-1)/s)*s,h=r.ZERO;for(let p=a;p>=0;p-=s){c.fill(r.ZERO);for(let w=0;w<n.length;w++){let x=n[w],f=Number(x>>BigInt(p)&BigInt(o));c[f]=c[f].add(t[w])}let g=r.ZERO;for(let w=c.length-1,x=r.ZERO;w>0;w--)x=x.add(c[w]),g=g.add(x);if(h=h.add(g),p!==0)for(let w=0;w<s;w++)h=h.double()}return h}function Pi(r){return Ri(r.Fp),Tt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ho(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function il(r){let e=Pi(r);Tt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:rp,hexToBytes:np}=Ni;var Ar=BigInt(0),Me=BigInt(1),fr=BigInt(2),Li=BigInt(3),$c=BigInt(4);function xo(r){let e=il(r),{Fp:t}=e,n=kt(e.n,e.nBitLength),i=e.toBytes||((N,T,O)=>{let H=T.toAffine();return Ie(Uint8Array.from([4]),t.toBytes(H.x),t.toBytes(H.y))}),s=e.fromBytes||(N=>{let T=N.subarray(1),O=t.fromBytes(T.subarray(0,t.BYTES)),H=t.fromBytes(T.subarray(t.BYTES,2*t.BYTES));return{x:O,y:H}});function o(N){let{a:T,b:O}=e,H=t.sqr(N),D=t.mul(H,N);return t.add(t.add(D,t.mul(N,T)),O)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function c(N){return Bi(N,Me,e.n)}function a(N){let{allowedPrivateKeyLengths:T,nByteLength:O,wrapPrivateKey:H,n:D}=e;if(T&&typeof N!="bigint"){if($r(N)&&(N=St(N)),typeof N!="string"||!T.includes(N.length))throw new Error("Invalid key");N=N.padStart(O*2,"0")}let K;try{K=typeof N=="bigint"?N:Je(He("private key",N,O))}catch{throw new Error(`private key must be ${O} bytes, hex or bigint, not ${typeof N}`)}return H&&(K=Se(K,D)),Bt("private key",K,Me,D),K}function h(N){if(!(N instanceof w))throw new Error("ProjectivePoint expected")}let p=Kt((N,T)=>{let{px:O,py:H,pz:D}=N;if(t.eql(D,t.ONE))return{x:O,y:H};let K=N.is0();T==null&&(T=K?t.ONE:t.inv(D));let E=t.mul(O,T),C=t.mul(H,T),G=t.mul(D,T);if(K)return{x:t.ZERO,y:t.ZERO};if(!t.eql(G,t.ONE))throw new Error("invZ was invalid");return{x:E,y:C}}),g=Kt(N=>{if(N.is0()){if(e.allowInfinityPoint&&!t.is0(N.py))return;throw new Error("bad point: ZERO")}let{x:T,y:O}=N.toAffine();if(!t.isValid(T)||!t.isValid(O))throw new Error("bad point: x or y not FE");let H=t.sqr(O),D=o(T);if(!t.eql(H,D))throw new Error("bad point: equation left != right");if(!N.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class w{constructor(T,O,H){if(this.px=T,this.py=O,this.pz=H,T==null||!t.isValid(T))throw new Error("x required");if(O==null||!t.isValid(O))throw new Error("y required");if(H==null||!t.isValid(H))throw new Error("z required");Object.freeze(this)}static fromAffine(T){let{x:O,y:H}=T||{};if(!T||!t.isValid(O)||!t.isValid(H))throw new Error("invalid affine point");if(T instanceof w)throw new Error("projective point not allowed");let D=K=>t.eql(K,t.ZERO);return D(O)&&D(H)?w.ZERO:new w(O,H,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(T){let O=t.invertBatch(T.map(H=>H.pz));return T.map((H,D)=>H.toAffine(O[D])).map(w.fromAffine)}static fromHex(T){let O=w.fromAffine(s(He("pointHex",T)));return O.assertValidity(),O}static fromPrivateKey(T){return w.BASE.multiply(a(T))}static msm(T,O){return Fi(w,n,T,O)}_setWindowSize(T){f.setWindowSize(this,T)}assertValidity(){g(this)}hasEvenY(){let{y:T}=this.toAffine();if(t.isOdd)return!t.isOdd(T);throw new Error("Field doesn't support isOdd")}equals(T){h(T);let{px:O,py:H,pz:D}=this,{px:K,py:E,pz:C}=T,G=t.eql(t.mul(O,C),t.mul(K,D)),j=t.eql(t.mul(H,C),t.mul(E,D));return G&&j}negate(){return new w(this.px,t.neg(this.py),this.pz)}double(){let{a:T,b:O}=e,H=t.mul(O,Li),{px:D,py:K,pz:E}=this,C=t.ZERO,G=t.ZERO,j=t.ZERO,k=t.mul(D,D),fe=t.mul(K,K),re=t.mul(E,E),te=t.mul(D,K);return te=t.add(te,te),j=t.mul(D,E),j=t.add(j,j),C=t.mul(T,j),G=t.mul(H,re),G=t.add(C,G),C=t.sub(fe,G),G=t.add(fe,G),G=t.mul(C,G),C=t.mul(te,C),j=t.mul(H,j),re=t.mul(T,re),te=t.sub(k,re),te=t.mul(T,te),te=t.add(te,j),j=t.add(k,k),k=t.add(j,k),k=t.add(k,re),k=t.mul(k,te),G=t.add(G,k),re=t.mul(K,E),re=t.add(re,re),k=t.mul(re,te),C=t.sub(C,k),j=t.mul(re,fe),j=t.add(j,j),j=t.add(j,j),new w(C,G,j)}add(T){h(T);let{px:O,py:H,pz:D}=this,{px:K,py:E,pz:C}=T,G=t.ZERO,j=t.ZERO,k=t.ZERO,fe=e.a,re=t.mul(e.b,Li),te=t.mul(O,K),y=t.mul(H,E),I=t.mul(D,C),q=t.add(O,H),F=t.add(K,E);q=t.mul(q,F),F=t.add(te,y),q=t.sub(q,F),F=t.add(O,D);let P=t.add(K,C);return F=t.mul(F,P),P=t.add(te,I),F=t.sub(F,P),P=t.add(H,D),G=t.add(E,C),P=t.mul(P,G),G=t.add(y,I),P=t.sub(P,G),k=t.mul(fe,F),G=t.mul(re,I),k=t.add(G,k),G=t.sub(y,k),k=t.add(y,k),j=t.mul(G,k),y=t.add(te,te),y=t.add(y,te),I=t.mul(fe,I),F=t.mul(re,F),y=t.add(y,I),I=t.sub(te,I),I=t.mul(fe,I),F=t.add(F,I),te=t.mul(y,F),j=t.add(j,te),te=t.mul(P,F),G=t.mul(q,G),G=t.sub(G,te),te=t.mul(q,y),k=t.mul(P,k),k=t.add(k,te),new w(G,j,k)}subtract(T){return this.add(T.negate())}is0(){return this.equals(w.ZERO)}wNAF(T){return f.wNAFCached(this,T,w.normalizeZ)}multiplyUnsafe(T){Bt("scalar",T,Ar,e.n);let O=w.ZERO;if(T===Ar)return O;if(T===Me)return this;let{endo:H}=e;if(!H)return f.unsafeLadder(this,T);let{k1neg:D,k1:K,k2neg:E,k2:C}=H.splitScalar(T),G=O,j=O,k=this;for(;K>Ar||C>Ar;)K&Me&&(G=G.add(k)),C&Me&&(j=j.add(k)),k=k.double(),K>>=Me,C>>=Me;return D&&(G=G.negate()),E&&(j=j.negate()),j=new w(t.mul(j.px,H.beta),j.py,j.pz),G.add(j)}multiply(T){let{endo:O,n:H}=e;Bt("scalar",T,Me,H);let D,K;if(O){let{k1neg:E,k1:C,k2neg:G,k2:j}=O.splitScalar(T),{p:k,f:fe}=this.wNAF(C),{p:re,f:te}=this.wNAF(j);k=f.constTimeNegate(E,k),re=f.constTimeNegate(G,re),re=new w(t.mul(re.px,O.beta),re.py,re.pz),D=k.add(re),K=fe.add(te)}else{let{p:E,f:C}=this.wNAF(T);D=E,K=C}return w.normalizeZ([D,K])[0]}multiplyAndAddUnsafe(T,O,H){let D=w.BASE,K=(C,G)=>G===Ar||G===Me||!C.equals(D)?C.multiplyUnsafe(G):C.multiply(G),E=K(this,O).add(K(T,H));return E.is0()?void 0:E}toAffine(T){return p(this,T)}isTorsionFree(){let{h:T,isTorsionFree:O}=e;if(T===Me)return!0;if(O)return O(w,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:T,clearCofactor:O}=e;return T===Me?this:O?O(w,this):this.multiplyUnsafe(e.h)}toRawBytes(T=!0){return sr("isCompressed",T),this.assertValidity(),i(w,this,T)}toHex(T=!0){return sr("isCompressed",T),St(this.toRawBytes(T))}}w.BASE=new w(e.Gx,e.Gy,t.ONE),w.ZERO=new w(t.ZERO,t.ONE,t.ZERO);let x=e.nBitLength,f=Ui(w,e.endo?Math.ceil(x/2):x);return{CURVE:e,ProjectivePoint:w,normPrivateKeyToScalar:a,weierstrassEquation:o,isWithinCurveOrder:c}}function sl(r,e){let t=r.ORDER,n=Ar;for(let f=t-Me;f%fr===Ar;f/=fr)n+=Me;let i=n,s=fr<<i-Me-Me,o=s*fr,c=(t-Me)/o,a=(c-Me)/fr,h=o-Me,p=s,g=r.pow(e,c),w=r.pow(e,(c+Me)/fr),x=(f,N)=>{let T=g,O=r.pow(N,h),H=r.sqr(O);H=r.mul(H,N);let D=r.mul(f,H);D=r.pow(D,a),D=r.mul(D,O),O=r.mul(D,N),H=r.mul(D,f);let K=r.mul(H,O);D=r.pow(K,p);let E=r.eql(D,r.ONE);O=r.mul(H,w),D=r.mul(K,T),H=r.cmov(O,H,E),K=r.cmov(D,K,E);for(let C=i;C>Me;C--){let G=C-fr;G=fr<<G-Me;let j=r.pow(K,G),k=r.eql(j,r.ONE);O=r.mul(H,T),T=r.mul(T,T),j=r.mul(K,T),H=r.cmov(O,H,k),K=r.cmov(j,K,k)}return{isValid:E,value:H}};if(r.ORDER%$c===Li){let f=(r.ORDER-Li)/$c,N=r.sqrt(r.neg(e));x=(T,O)=>{let H=r.sqr(O),D=r.mul(T,O);H=r.mul(H,D);let K=r.pow(H,f);K=r.mul(K,D);let E=r.mul(K,N),C=r.mul(r.sqr(K),O),G=r.eql(C,T),j=r.cmov(E,K,G);return{isValid:G,value:j}}}return x}function _o(r,e){if(Ri(r),!r.isValid(e.A)||!r.isValid(e.B)||!r.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let t=sl(r,e.Z);if(!r.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,c,a,h,p,g;i=r.sqr(n),i=r.mul(i,e.Z),s=r.sqr(i),s=r.add(s,i),o=r.add(s,r.ONE),o=r.mul(o,e.B),c=r.cmov(e.Z,r.neg(s),!r.eql(s,r.ZERO)),c=r.mul(c,e.A),s=r.sqr(o),h=r.sqr(c),a=r.mul(h,e.A),s=r.add(s,a),s=r.mul(s,o),h=r.mul(h,c),a=r.mul(h,e.B),s=r.add(s,a),p=r.mul(i,o);let{isValid:w,value:x}=t(s,h);g=r.mul(i,n),g=r.mul(g,x),p=r.cmov(p,o,w),g=r.cmov(g,x,w);let f=r.isOdd(n)===r.isOdd(g);return g=r.cmov(r.neg(g),g,f),p=r.div(p,c),{x:p,y:g}}}var ol=BigInt(0),Mi=BigInt(1),Hc=BigInt(2),Hr=BigInt(3);function al(r){let e=[];for(;r>Mi;r>>=Mi)(r&Mi)===ol?e.unshift(0):(r&Hr)===Hr?(e.unshift(-1),r+=Mi):e.unshift(1);return e}function Gc(r){let{Fp:e,Fr:t,Fp2:n,Fp6:i,Fp12:s}=r.fields,o=r.params.xNegative,c=r.params.twistType,a=xo({n:t.ORDER,...r.G1}),h=Object.assign(a,yo(a.ProjectivePoint,r.G1.mapToCurve,{...r.htfDefaults,...r.G1.htfDefaults})),p=xo({n:t.ORDER,...r.G2}),g=Object.assign(p,yo(p.ProjectivePoint,r.G2.mapToCurve,{...r.htfDefaults,...r.G2.htfDefaults})),w;if(c==="multiplicative")w=(Y,U,d,J,ee,ae)=>s.mul014(J,Y,n.mul(U,ee),n.mul(d,ae));else if(c==="divisive")w=(Y,U,d,J,ee,ae)=>s.mul034(J,n.mul(d,ae),n.mul(U,ee),Y);else throw new Error("bls: unknown twist type");let x=n.div(n.ONE,n.mul(n.ONE,Hc));function f(Y,U,d,J){let ee=n.sqr(d),ae=n.sqr(J),Q=n.mulByB(n.mul(ae,Hr)),u=n.mul(Q,Hr),l=n.sub(n.sub(n.sqr(n.add(d,J)),ae),ee),m=n.sub(Q,ee),S=n.mul(n.sqr(U),Hr),v=n.neg(l);return Y.push([m,S,v]),U=n.mul(n.mul(n.mul(n.sub(ee,u),U),d),x),d=n.sub(n.sqr(n.mul(n.add(ee,u),x)),n.mul(n.sqr(Q),Hr)),J=n.mul(ee,l),{Rx:U,Ry:d,Rz:J}}function N(Y,U,d,J,ee,ae){let Q=n.sub(d,n.mul(ae,J)),u=n.sub(U,n.mul(ee,J)),l=n.sub(n.mul(Q,ee),n.mul(u,ae)),m=n.neg(Q),S=u;Y.push([l,m,S]);let v=n.sqr(u),A=n.mul(v,u),M=n.mul(v,U),b=n.add(n.sub(A,n.mul(M,Hc)),n.mul(n.sqr(Q),J));return U=n.mul(u,b),d=n.sub(n.mul(n.sub(M,b),Q),n.mul(A,d)),J=n.mul(J,A),{Rx:U,Ry:d,Rz:J}}let T=al(r.params.ateLoopSize),O=Kt(Y=>{let U=Y,{x:d,y:J}=U.toAffine(),ee=d,ae=J,Q=n.neg(J),u=ee,l=ae,m=n.ONE,S=[];for(let v of T){let A=[];({Rx:u,Ry:l,Rz:m}=f(A,u,l,m)),v&&({Rx:u,Ry:l,Rz:m}=N(A,u,l,m,ee,v===-1?Q:ae)),S.push(A)}if(r.postPrecompute){let v=S[S.length-1];r.postPrecompute(u,l,m,ee,ae,N.bind(null,v))}return S});function H(Y,U=!1){let d=s.ONE;if(Y.length){let J=Y[0][0].length;for(let ee=0;ee<J;ee++){d=s.sqr(d);for(let[ae,Q,u]of Y)for(let[l,m,S]of ae[ee])d=w(l,m,S,d,Q,u)}}return o&&(d=s.conjugate(d)),U?s.finalExponentiate(d):d}function D(Y,U=!0){let d=[];h.ProjectivePoint.normalizeZ(Y.map(({g1:J})=>J)),g.ProjectivePoint.normalizeZ(Y.map(({g2:J})=>J));for(let{g1:J,g2:ee}of Y){if(J.equals(h.ProjectivePoint.ZERO)||ee.equals(g.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");J.assertValidity(),ee.assertValidity();let ae=J.toAffine();d.push([O(ee),ae.x,ae.y])}return H(d,U)}function K(Y,U,d=!0){return D([{g1:Y,g2:U}],d)}let E={randomPrivateKey:()=>{let Y=Oi(t.ORDER);return po(r.randomBytes(Y),t.ORDER)},calcPairingPrecomputes:O},{ShortSignature:C}=r.G1,{Signature:G}=r.G2;function j(Y){return Y instanceof h.ProjectivePoint?Y:h.ProjectivePoint.fromHex(Y)}function k(Y,U){return Y instanceof h.ProjectivePoint?Y:h.hashToCurve(He("point",Y),U)}function fe(Y){return Y instanceof g.ProjectivePoint?Y:G.fromHex(Y)}function re(Y,U){return Y instanceof g.ProjectivePoint?Y:g.hashToCurve(He("point",Y),U)}function te(Y){return h.ProjectivePoint.fromPrivateKey(Y).toRawBytes(!0)}function y(Y){return g.ProjectivePoint.fromPrivateKey(Y).toRawBytes(!0)}function I(Y,U,d){let J=re(Y,d);J.assertValidity();let ee=J.multiply(h.normPrivateKeyToScalar(U));return Y instanceof g.ProjectivePoint?ee:G.toRawBytes(ee)}function q(Y,U,d){let J=k(Y,d);J.assertValidity();let ee=J.multiply(h.normPrivateKeyToScalar(U));return Y instanceof h.ProjectivePoint?ee:C.toRawBytes(ee)}function F(Y,U,d,J){let ee=j(d),ae=re(U,J),Q=h.ProjectivePoint.BASE,u=fe(Y),l=D([{g1:ee.negate(),g2:ae},{g1:Q,g2:u}]);return s.eql(l,s.ONE)}function P(Y,U,d,J){let ee=fe(d),ae=k(U,J),Q=g.ProjectivePoint.BASE,u=j(Y),l=D([{g1:ae,g2:ee},{g1:u,g2:Q.negate()}]);return s.eql(l,s.ONE)}function $(Y){if(!Y.length)throw new Error("Expected non-empty array");let d=Y.map(j).reduce((J,ee)=>J.add(ee),h.ProjectivePoint.ZERO);return Y[0]instanceof h.ProjectivePoint?(d.assertValidity(),d):d.toRawBytes(!0)}function Z(Y){if(!Y.length)throw new Error("Expected non-empty array");let d=Y.map(fe).reduce((J,ee)=>J.add(ee),g.ProjectivePoint.ZERO);return Y[0]instanceof g.ProjectivePoint?(d.assertValidity(),d):G.toRawBytes(d)}function ue(Y){if(!Y.length)throw new Error("Expected non-empty array");let d=Y.map(j).reduce((J,ee)=>J.add(ee),h.ProjectivePoint.ZERO);return Y[0]instanceof h.ProjectivePoint?(d.assertValidity(),d):C.toRawBytes(d)}function ce(Y,U,d,J){if(!U.length)throw new Error("Expected non-empty messages array");if(d.length!==U.length)throw new Error("Pubkey count should equal msg count");let ee=fe(Y),ae=U.map(m=>re(m,J)),Q=d.map(j),u=new Map;for(let m=0;m<Q.length;m++){let S=Q[m],v=ae[m],A=u.get(v);A===void 0&&(A=[],u.set(v,A)),A.push(S)}let l=[];try{for(let[m,S]of u){let v=S.reduce((A,M)=>A.add(M));l.push({g1:v,g2:m})}return l.push({g1:h.ProjectivePoint.BASE.negate(),g2:ee}),s.eql(D(l),s.ONE)}catch{return!1}}return h.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:te,getPublicKeyForShortSignatures:y,sign:I,signShortSignature:q,verify:F,verifyBatch:ce,verifyShortSignature:P,aggregatePublicKeys:$,aggregateSignatures:Z,aggregateShortSignatures:ue,millerLoopBatch:H,pairing:K,pairingBatch:D,G1:h,G2:g,Signature:G,ShortSignature:C,fields:{Fr:t,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:r.params.ateLoopSize,r:r.params.r,G1b:r.G1.b,G2b:r.G2.b},utils:E}}var cl=BigInt(0),Gr=BigInt(1),Zt=BigInt(2),Vc=BigInt(3);function Eo(r,e,t,n,i=1,s){let o=BigInt(s===void 0?n:s),c=t**BigInt(n),a=[];for(let h=0;h<i;h++){let p=BigInt(h+1),g=[];for(let w=0,x=Gr;w<n;w++){let f=(p*x-p)/o%c;g.push(r.pow(e,f)),x*=t}a.push(g)}return a}function jc(r,e,t){let n=e.pow(t,(r.ORDER-Gr)/Vc),i=e.pow(t,(r.ORDER-Gr)/Zt);function s(w,x){let f=e.mul(e.frobeniusMap(w,1),n),N=e.mul(e.frobeniusMap(x,1),i);return[f,N]}let o=e.pow(t,(r.ORDER**Zt-Gr)/Vc),c=e.pow(t,(r.ORDER**Zt-Gr)/Zt);if(!e.eql(c,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function a(w,x){return[e.mul(w,o),e.neg(x)]}let h=w=>(x,f)=>{let N=f.toAffine(),T=w(N.x,N.y);return x.fromAffine({x:T[0],y:T[1]})},p=h(s),g=h(a);return{psi:s,psi2:a,G2psi:p,G2psi2:g,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:c}}function Yc(r){let{ORDER:e}=r,t=kt(e),n=t.create(r.NONRESIDUE||BigInt(-1)),i=Dc(e),s=t.div(t.ONE,Zt),o=Eo(t,n,t.ORDER,2)[0],c=({c0:y,c1:I},{c0:q,c1:F})=>({c0:t.add(y,q),c1:t.add(I,F)}),a=({c0:y,c1:I},{c0:q,c1:F})=>({c0:t.sub(y,q),c1:t.sub(I,F)}),h=({c0:y,c1:I},q)=>{if(typeof q=="bigint")return{c0:t.mul(y,q),c1:t.mul(I,q)};let{c0:F,c1:P}=q,$=t.mul(y,F),Z=t.mul(I,P),ue=t.sub($,Z),ce=t.sub(t.mul(t.add(y,I),t.add(F,P)),t.add($,Z));return{c0:ue,c1:ce}},p=({c0:y,c1:I})=>{let q=t.add(y,I),F=t.sub(y,I),P=t.add(y,y);return{c0:t.mul(q,F),c1:t.mul(P,I)}},g=y=>{if(y.length!==2)throw new Error("Invalid tuple");let I=y.map(q=>t.create(q));return{c0:I[0],c1:I[1]}},w=e*e,x=g(r.FP2_NONRESIDUE),f={ORDER:w,NONRESIDUE:x,BITS:zt(w),BYTES:Math.ceil(zt(w)/8),MASK:ar(zt(w)),ZERO:{c0:t.ZERO,c1:t.ZERO},ONE:{c0:t.ONE,c1:t.ZERO},create:y=>y,isValid:({c0:y,c1:I})=>typeof y=="bigint"&&typeof I=="bigint",is0:({c0:y,c1:I})=>t.is0(y)&&t.is0(I),eql:({c0:y,c1:I},{c0:q,c1:F})=>t.eql(y,q)&&t.eql(I,F),neg:({c0:y,c1:I})=>({c0:t.neg(y),c1:t.neg(I)}),pow:(y,I)=>_n(f,y,I),invertBatch:y=>En(f,y),add:c,sub:a,mul:h,sqr:p,addN:c,subN:a,mulN:h,sqrN:p,div:(y,I)=>f.mul(y,typeof I=="bigint"?t.inv(t.create(I)):f.inv(I)),inv:({c0:y,c1:I})=>{let q=t.inv(t.create(y*y+I*I));return{c0:t.mul(q,t.create(y)),c1:t.mul(q,t.create(-I))}},sqrt:y=>{if(r.Fp2sqrt)return r.Fp2sqrt(y);let{c0:I,c1:q}=y;if(t.is0(q))return t.eql(i(t,I),t.ONE)?f.create({c0:t.sqrt(I),c1:t.ZERO}):f.create({c0:t.ZERO,c1:t.sqrt(t.div(I,n))});let F=t.sqrt(t.sub(t.sqr(I),t.mul(t.sqr(q),n))),P=t.mul(t.add(F,I),s),$=i(t,P);!t.is0($)&&!t.eql($,t.ONE)&&(P=t.sub(P,F));let Z=t.sqrt(P),ue=f.create({c0:Z,c1:t.div(t.mul(q,s),Z)});if(!f.eql(f.sqr(ue),y))throw new Error("Cannot find square root");let ce=ue,Y=f.neg(ce),{re:U,im:d}=f.reim(ce),{re:J,im:ee}=f.reim(Y);return d>ee||d===ee&&U>J?ce:Y},isOdd:y=>{let{re:I,im:q}=f.reim(y),F=I%Zt,P=I===cl,$=q%Zt;return BigInt(F||P&&$)==Gr},fromBytes(y){if(y.length!==f.BYTES)throw new Error(`fromBytes wrong length=${y.length}`);return{c0:t.fromBytes(y.subarray(0,t.BYTES)),c1:t.fromBytes(y.subarray(t.BYTES))}},toBytes:({c0:y,c1:I})=>Ie(t.toBytes(y),t.toBytes(I)),cmov:({c0:y,c1:I},{c0:q,c1:F},P)=>({c0:t.cmov(y,q,P),c1:t.cmov(I,F,P)}),reim:({c0:y,c1:I})=>({re:y,im:I}),mulByNonresidue:({c0:y,c1:I})=>f.mul({c0:y,c1:I},x),mulByB:r.Fp2mulByB,fromBigTuple:g,frobeniusMap:({c0:y,c1:I},q)=>({c0:y,c1:t.mul(I,o[q%2])})},N=({c0:y,c1:I,c2:q},{c0:F,c1:P,c2:$})=>({c0:f.add(y,F),c1:f.add(I,P),c2:f.add(q,$)}),T=({c0:y,c1:I,c2:q},{c0:F,c1:P,c2:$})=>({c0:f.sub(y,F),c1:f.sub(I,P),c2:f.sub(q,$)}),O=({c0:y,c1:I,c2:q},F)=>{if(typeof F=="bigint")return{c0:f.mul(y,F),c1:f.mul(I,F),c2:f.mul(q,F)};let{c0:P,c1:$,c2:Z}=F,ue=f.mul(y,P),ce=f.mul(I,$),Y=f.mul(q,Z);return{c0:f.add(ue,f.mulByNonresidue(f.sub(f.mul(f.add(I,q),f.add($,Z)),f.add(ce,Y)))),c1:f.add(f.sub(f.mul(f.add(y,I),f.add(P,$)),f.add(ue,ce)),f.mulByNonresidue(Y)),c2:f.sub(f.add(ce,f.mul(f.add(y,q),f.add(P,Z))),f.add(ue,Y))}},H=({c0:y,c1:I,c2:q})=>{let F=f.sqr(y),P=f.mul(f.mul(y,I),Zt),$=f.mul(f.mul(I,q),Zt),Z=f.sqr(q);return{c0:f.add(f.mulByNonresidue($),F),c1:f.add(f.mulByNonresidue(Z),P),c2:f.sub(f.sub(f.add(f.add(P,f.sqr(f.add(f.sub(y,I),q))),$),F),Z)}},[D,K]=Eo(f,x,t.ORDER,6,2,3),E={ORDER:f.ORDER,BITS:3*f.BITS,BYTES:3*f.BYTES,MASK:ar(3*f.BITS),ZERO:{c0:f.ZERO,c1:f.ZERO,c2:f.ZERO},ONE:{c0:f.ONE,c1:f.ZERO,c2:f.ZERO},create:y=>y,isValid:({c0:y,c1:I,c2:q})=>f.isValid(y)&&f.isValid(I)&&f.isValid(q),is0:({c0:y,c1:I,c2:q})=>f.is0(y)&&f.is0(I)&&f.is0(q),neg:({c0:y,c1:I,c2:q})=>({c0:f.neg(y),c1:f.neg(I),c2:f.neg(q)}),eql:({c0:y,c1:I,c2:q},{c0:F,c1:P,c2:$})=>f.eql(y,F)&&f.eql(I,P)&&f.eql(q,$),sqrt:Ti,div:(y,I)=>E.mul(y,typeof I=="bigint"?t.inv(t.create(I)):E.inv(I)),pow:(y,I)=>_n(E,y,I),invertBatch:y=>En(E,y),add:N,sub:T,mul:O,sqr:H,addN:N,subN:T,mulN:O,sqrN:H,inv:({c0:y,c1:I,c2:q})=>{let F=f.sub(f.sqr(y),f.mulByNonresidue(f.mul(q,I))),P=f.sub(f.mulByNonresidue(f.sqr(q)),f.mul(y,I)),$=f.sub(f.sqr(I),f.mul(y,q)),Z=f.inv(f.add(f.mulByNonresidue(f.add(f.mul(q,P),f.mul(I,$))),f.mul(y,F)));return{c0:f.mul(Z,F),c1:f.mul(Z,P),c2:f.mul(Z,$)}},fromBytes:y=>{if(y.length!==E.BYTES)throw new Error(`fromBytes wrong length=${y.length}`);return{c0:f.fromBytes(y.subarray(0,f.BYTES)),c1:f.fromBytes(y.subarray(f.BYTES,2*f.BYTES)),c2:f.fromBytes(y.subarray(2*f.BYTES))}},toBytes:({c0:y,c1:I,c2:q})=>Ie(f.toBytes(y),f.toBytes(I),f.toBytes(q)),cmov:({c0:y,c1:I,c2:q},{c0:F,c1:P,c2:$},Z)=>({c0:f.cmov(y,F,Z),c1:f.cmov(I,P,Z),c2:f.cmov(q,$,Z)}),fromBigSix:y=>{if(!Array.isArray(y)||y.length!==6)throw new Error("Invalid Fp6 usage");return{c0:f.fromBigTuple(y.slice(0,2)),c1:f.fromBigTuple(y.slice(2,4)),c2:f.fromBigTuple(y.slice(4,6))}},frobeniusMap:({c0:y,c1:I,c2:q},F)=>({c0:f.frobeniusMap(y,F),c1:f.mul(f.frobeniusMap(I,F),D[F%6]),c2:f.mul(f.frobeniusMap(q,F),K[F%6])}),mulByFp2:({c0:y,c1:I,c2:q},F)=>({c0:f.mul(y,F),c1:f.mul(I,F),c2:f.mul(q,F)}),mulByNonresidue:({c0:y,c1:I,c2:q})=>({c0:f.mulByNonresidue(q),c1:y,c2:I}),mul1:({c0:y,c1:I,c2:q},F)=>({c0:f.mulByNonresidue(f.mul(q,F)),c1:f.mul(y,F),c2:f.mul(I,F)}),mul01({c0:y,c1:I,c2:q},F,P){let $=f.mul(y,F),Z=f.mul(I,P);return{c0:f.add(f.mulByNonresidue(f.sub(f.mul(f.add(I,q),P),Z)),$),c1:f.sub(f.sub(f.mul(f.add(F,P),f.add(y,I)),$),Z),c2:f.add(f.sub(f.mul(f.add(y,q),F),$),Z)}}},C=Eo(f,x,t.ORDER,12,1,6)[0],G=({c0:y,c1:I},{c0:q,c1:F})=>({c0:E.add(y,q),c1:E.add(I,F)}),j=({c0:y,c1:I},{c0:q,c1:F})=>({c0:E.sub(y,q),c1:E.sub(I,F)}),k=({c0:y,c1:I},q)=>{if(typeof q=="bigint")return{c0:E.mul(y,q),c1:E.mul(I,q)};let{c0:F,c1:P}=q,$=E.mul(y,F),Z=E.mul(I,P);return{c0:E.add($,E.mulByNonresidue(Z)),c1:E.sub(E.mul(E.add(y,I),E.add(F,P)),E.add($,Z))}},fe=({c0:y,c1:I})=>{let q=E.mul(y,I);return{c0:E.sub(E.sub(E.mul(E.add(E.mulByNonresidue(I),y),E.add(y,I)),q),E.mulByNonresidue(q)),c1:E.add(q,q)}};function re(y,I){let q=f.sqr(y),F=f.sqr(I);return{first:f.add(f.mulByNonresidue(F),q),second:f.sub(f.sub(f.sqr(f.add(y,I)),q),F)}}let te={ORDER:f.ORDER,BITS:2*f.BITS,BYTES:2*f.BYTES,MASK:ar(2*f.BITS),ZERO:{c0:E.ZERO,c1:E.ZERO},ONE:{c0:E.ONE,c1:E.ZERO},create:y=>y,isValid:({c0:y,c1:I})=>E.isValid(y)&&E.isValid(I),is0:({c0:y,c1:I})=>E.is0(y)&&E.is0(I),neg:({c0:y,c1:I})=>({c0:E.neg(y),c1:E.neg(I)}),eql:({c0:y,c1:I},{c0:q,c1:F})=>E.eql(y,q)&&E.eql(I,F),sqrt:Ti,inv:({c0:y,c1:I})=>{let q=E.inv(E.sub(E.sqr(y),E.mulByNonresidue(E.sqr(I))));return{c0:E.mul(y,q),c1:E.neg(E.mul(I,q))}},div:(y,I)=>te.mul(y,typeof I=="bigint"?t.inv(t.create(I)):te.inv(I)),pow:(y,I)=>_n(te,y,I),invertBatch:y=>En(te,y),add:G,sub:j,mul:k,sqr:fe,addN:G,subN:j,mulN:k,sqrN:fe,fromBytes:y=>{if(y.length!==te.BYTES)throw new Error(`fromBytes wrong length=${y.length}`);return{c0:E.fromBytes(y.subarray(0,E.BYTES)),c1:E.fromBytes(y.subarray(E.BYTES))}},toBytes:({c0:y,c1:I})=>Ie(E.toBytes(y),E.toBytes(I)),cmov:({c0:y,c1:I},{c0:q,c1:F},P)=>({c0:E.cmov(y,q,P),c1:E.cmov(I,F,P)}),fromBigTwelve:y=>({c0:E.fromBigSix(y.slice(0,6)),c1:E.fromBigSix(y.slice(6,12))}),frobeniusMap(y,I){let{c0:q,c1:F,c2:P}=E.frobeniusMap(y.c1,I),$=C[I%12];return{c0:E.frobeniusMap(y.c0,I),c1:E.create({c0:f.mul(q,$),c1:f.mul(F,$),c2:f.mul(P,$)})}},mulByFp2:({c0:y,c1:I},q)=>({c0:E.mulByFp2(y,q),c1:E.mulByFp2(I,q)}),conjugate:({c0:y,c1:I})=>({c0:y,c1:E.neg(I)}),mul014:({c0:y,c1:I},q,F,P)=>{let $=E.mul01(y,q,F),Z=E.mul1(I,P);return{c0:E.add(E.mulByNonresidue(Z),$),c1:E.sub(E.sub(E.mul01(E.add(I,y),q,f.add(F,P)),$),Z)}},mul034:({c0:y,c1:I},q,F,P)=>{let $=E.create({c0:f.mul(y.c0,q),c1:f.mul(y.c1,q),c2:f.mul(y.c2,q)}),Z=E.mul01(I,F,P),ue=E.mul01(E.add(y,I),f.add(q,F),P);return{c0:E.add(E.mulByNonresidue(Z),$),c1:E.sub(ue,E.add($,Z))}},_cyclotomicSquare:r.Fp12cyclotomicSquare,_cyclotomicExp:r.Fp12cyclotomicExp,finalExponentiate:r.Fp12finalExponentiate};return{Fp:t,Fp2:f,Fp6:E,Fp4Square:re,Fp12:te}}var it=BigInt(0),qi=BigInt(1),Ze=BigInt(2),Di=BigInt(3),In=BigInt(4),lr=BigInt("0xd201000000010000"),ul=zt(lr),{Fp:ne,Fp2:se,Fp6:Ao,Fp4Square:vo,Fp12:ge}=Yc({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[qi,qi],Fp2mulByB:({c0:r,c1:e})=>{let t=ne.mul(r,In),n=ne.mul(e,In);return{c0:ne.sub(t,n),c1:ne.add(t,n)}},Fp12cyclotomicSquare:({c0:r,c1:e})=>{let{c0:t,c1:n,c2:i}=r,{c0:s,c1:o,c2:c}=e,{first:a,second:h}=vo(t,o),{first:p,second:g}=vo(s,i),{first:w,second:x}=vo(n,c),f=se.mulByNonresidue(x);return{c0:Ao.create({c0:se.add(se.mul(se.sub(a,t),Ze),a),c1:se.add(se.mul(se.sub(p,n),Ze),p),c2:se.add(se.mul(se.sub(w,i),Ze),w)}),c1:Ao.create({c0:se.add(se.mul(se.add(f,s),Ze),f),c1:se.add(se.mul(se.add(h,o),Ze),h),c2:se.add(se.mul(se.add(g,c),Ze),g)})}},Fp12cyclotomicExp(r,e){let t=ge.ONE;for(let n=ul-1;n>=0;n--)t=ge._cyclotomicSquare(t),uo(e,n)&&(t=ge.mul(t,r));return t},Fp12finalExponentiate:r=>{let e=lr,t=ge.div(ge.frobeniusMap(r,6),r),n=ge.mul(ge.frobeniusMap(t,2),t),i=ge.conjugate(ge._cyclotomicExp(n,e)),s=ge.mul(ge.conjugate(ge._cyclotomicSquare(n)),i),o=ge.conjugate(ge._cyclotomicExp(s,e)),c=ge.conjugate(ge._cyclotomicExp(o,e)),a=ge.mul(ge.conjugate(ge._cyclotomicExp(c,e)),ge._cyclotomicSquare(i)),h=ge.conjugate(ge._cyclotomicExp(a,e)),p=ge.frobeniusMap(ge.mul(i,c),2),g=ge.frobeniusMap(ge.mul(o,n),3),w=ge.frobeniusMap(ge.mul(a,ge.conjugate(n)),1),x=ge.mul(ge.mul(h,ge.conjugate(s)),n);return ge.mul(ge.mul(ge.mul(p,g),w),x)}}),zc=kt(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),fl=go(se,[[["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(r=>r.map(e=>se.fromBigTuple(e.map(BigInt))))),ll=go(ne,[["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(r=>r.map(e=>BigInt(e)))),hl=_o(se,{A:se.create({c0:ne.create(it),c1:ne.create(BigInt(240))}),B:se.create({c0:ne.create(BigInt(1012)),c1:ne.create(BigInt(1012))}),Z:se.create({c0:ne.create(BigInt(-2)),c1:ne.create(BigInt(-1))})}),dl=_o(ne,{A:ne.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:ne.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:ne.create(BigInt(11))}),{G2psi:Kc,G2psi2:pl}=jc(ne,se,se.div(se.ONE,se.NONRESIDUE)),Io=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:ne.ORDER,m:2,k:128,expand:"xmd",hash:sn}),Ci=An(ne.toBytes(it),{infinity:!0,compressed:!0});function ki(r){r=r.slice();let e=r[0]&224,t=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return r[0]&=31,{compressed:t,infinity:n,sort:i,value:r}}function An(r,e){if(r[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(r[0]|=128),e.infinity&&(r[0]|=64),e.sort&&(r[0]|=32),r}function Zc(r){r.assertValidity();let e=r.equals(ht.G1.ProjectivePoint.ZERO),{x:t,y:n}=r.toAffine();if(e)return Ci.slice();let i=ne.ORDER,s=!!(n*Ze/i);return An(Le(t,ne.BYTES),{compressed:!0,sort:s})}function Wc(r){r.assertValidity();let e=ne.BYTES;if(r.equals(ht.G2.ProjectivePoint.ZERO))return Ie(Ci,Le(it,e));let{x:t,y:n}=r.toAffine(),{re:i,im:s}=se.reim(t),{re:o,im:c}=se.reim(n),h=!!((c>it?c*Ze:o*Ze)/ne.ORDER&qi),p=i;return Ie(An(Le(s,e),{sort:h,compressed:!0}),Le(p,e))}var ht=Gc({fields:{Fp:ne,Fp2:se,Fp6:Ao,Fp12:ge,Fr:zc},G1:{Fp:ne,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:ne.ZERO,b:In,htfDefaults:{...Io,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(r,e)=>{let t=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new r(ne.mul(e.px,t),e.py,e.pz);return e.multiplyUnsafe(lr).negate().multiplyUnsafe(lr).equals(n)},clearCofactor:(r,e)=>e.multiplyUnsafe(lr).add(e),mapToCurve:r=>{let{x:e,y:t}=dl(ne.create(r[0]));return ll(e,t)},fromBytes:r=>{let{compressed:e,infinity:t,sort:n,value:i}=ki(r);if(i.length===48&&e){let s=ne.ORDER,o=Je(i),c=ne.create(o&ne.MASK);if(t){if(c!==it)throw new Error("G1: non-empty compressed point at infinity");return{x:it,y:it}}let a=ne.add(ne.pow(c,Di),ne.create(ht.params.G1b)),h=ne.sqrt(a);if(!h)throw new Error("Invalid compressed G1 point");return h*Ze/s!==BigInt(n)&&(h=ne.neg(h)),{x:ne.create(c),y:ne.create(h)}}else if(i.length===96&&!e){let s=Je(i.subarray(0,ne.BYTES)),o=Je(i.subarray(ne.BYTES));if(t){if(s!==it||o!==it)throw new Error("G1: non-empty point at infinity");return ht.G1.ProjectivePoint.ZERO.toAffine()}return{x:ne.create(s),y:ne.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(r,e,t)=>{let n=e.equals(r.ZERO),{x:i,y:s}=e.toAffine();if(t){if(n)return Ci.slice();let o=ne.ORDER,c=!!(s*Ze/o);return An(Le(i,ne.BYTES),{compressed:!0,sort:c})}else return n?Ie(new Uint8Array([64]),new Uint8Array(2*ne.BYTES-1)):Ie(Le(i,ne.BYTES),Le(s,ne.BYTES))},ShortSignature:{fromHex(r){let{infinity:e,sort:t,value:n}=ki(He("signatureHex",r,48)),i=ne.ORDER,s=Je(n);if(e)return ht.G1.ProjectivePoint.ZERO;let o=ne.create(s&ne.MASK),c=ne.add(ne.pow(o,Di),ne.create(ht.params.G1b)),a=ne.sqrt(c);if(!a)throw new Error("Invalid compressed G1 point");let h=BigInt(t);a*Ze/i!==h&&(a=ne.neg(a));let p=ht.G1.ProjectivePoint.fromAffine({x:o,y:a});return p.assertValidity(),p},toRawBytes(r){return Zc(r)},toHex(r){return St(Zc(r))}}},G2:{Fp:se,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:se.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:se.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:se.ZERO,b:se.fromBigTuple([In,In]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...Io},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:r=>{let{x:e,y:t}=hl(se.fromBigTuple(r));return fl(e,t)},isTorsionFree:(r,e)=>e.multiplyUnsafe(lr).negate().equals(Kc(r,e)),clearCofactor:(r,e)=>{let t=lr,n=e.multiplyUnsafe(t).negate(),i=Kc(r,e),s=e.double();return s=pl(r,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(t).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:r=>{let{compressed:e,infinity:t,sort:n,value:i}=ki(r);if(!e&&!t&&n||!e&&t&&n||n&&t&&e)throw new Error("Invalid encoding flag: "+(r[0]&224));let s=ne.BYTES,o=(c,a,h)=>Je(c.slice(a,h));if(i.length===96&&e){let c=ht.params.G2b,a=ne.ORDER;if(t){if(i.reduce((N,T)=>N!==0?T+1:T,0)>0)throw new Error("Invalid compressed G2 point");return{x:se.ZERO,y:se.ZERO}}let h=o(i,0,s),p=o(i,s,2*s),g=se.create({c0:ne.create(p),c1:ne.create(h)}),w=se.add(se.pow(g,Di),c),x=se.sqrt(w),f=x.c1===it?x.c0*Ze/a:x.c1*Ze/a?qi:it;return x=n&&f>0?x:se.neg(x),{x:g,y:x}}else if(i.length===192&&!e){if(t){if(i.reduce((g,w)=>g!==0?w+1:w,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:se.ZERO,y:se.ZERO}}let c=o(i,0,s),a=o(i,s,2*s),h=o(i,2*s,3*s),p=o(i,3*s,4*s);return{x:se.fromBigTuple([a,c]),y:se.fromBigTuple([p,h])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(r,e,t)=>{let{BYTES:n,ORDER:i}=ne,s=e.equals(r.ZERO),{x:o,y:c}=e.toAffine();if(t){if(s)return Ie(Ci,Le(it,n));let a=!!(c.c1===it?c.c0*Ze/i:c.c1*Ze/i);return Ie(An(Le(o.c1,n),{compressed:!0,sort:a}),Le(o.c0,n))}else{if(s)return Ie(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:a,im:h}=se.reim(o),{re:p,im:g}=se.reim(c);return Ie(Le(h,n),Le(a,n),Le(g,n),Le(p,n))}},Signature:{fromHex(r){let{infinity:e,sort:t,value:n}=ki(He("signatureHex",r)),i=ne.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=Je(n.slice(0,s)),c=Je(n.slice(s));if(e)return ht.G2.ProjectivePoint.ZERO;let a=ne.create(o&ne.MASK),h=ne.create(c),p=se.create({c0:h,c1:a}),g=se.add(se.pow(p,Di),ht.params.G2b),w=se.sqrt(g);if(!w)throw new Error("Failed to find a square root");let{re:x,im:f}=se.reim(w),N=BigInt(t),T=f>it&&f*Ze/i!==N,O=f===it&&x*Ze/i!==N;(T||O)&&(w=se.neg(w));let H=ht.G2.ProjectivePoint.fromAffine({x:p,y:w});return H.assertValidity(),H},toRawBytes(r){return Wc(r)},toHex(r){return St(Wc(r))}}},params:{ateLoopSize:lr,r:zc.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:Io,hash:sn,randomBytes:Hn});function Xc(r,e,t){let n=typeof r=="string"?r:Fe(r),i=typeof e=="string"?e:Fe(e),s=typeof t=="string"?t:Fe(t);return ht.verifyShortSignature(i,s,n)}var So=r=>Ce(new vt(r)),Vr=r=>{let e=So(r);return new Date(Number(e)/1e6)};var gl=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t},yl=new TextEncoder().encode(`
|
|
14
|
-
ic-request`),Qc=class{getPrincipal(){return this._principal||(this._principal=me.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:t}=e,n=gl(e,["body"]),i=yn(t);return Object.assign(Object.assign({},n),{body:{content:t,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(Qe(yl,i))}})}},Sn=class{getPrincipal(){return me.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};var eu=rn(oi());var Bn=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let r=new Uint32Array(1);return window.crypto.getRandomValues(r),r[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let r=new Uint32Array(1);return crypto.getRandomValues(r),r[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};var $i;(function(r){r.Call="call"})($i||($i={}));function jr(){let r=new ArrayBuffer(16),e=new DataView(r),t=Bn(),n=Bn(),i=Bn(),s=Bn();return e.setUint32(0,t),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),r}var Jc=BigInt(1e6),wl=60*1e3,Sr=class{constructor(e){if(e<90*1e3){let c=BigInt(Date.now()+e)*Jc/BigInt(1e9);this._value=c*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-wl))*Jc/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return eu.value.u64(this._value.toString(16),16)}toHash(){return Be(this._value)}};function Bo(r=jr){return async e=>{let t=e.request.headers;e.request.headers=t,e.endpoint==="call"&&(e.body.nonce=r())}}function Yr(r){let e=[];return r.forEach((t,n)=>{e.push([n,t])}),e}var zr=class extends Ue{constructor(e,t){super(e),this.response=t,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}},Hi=class extends Ue{constructor(e,t,n,i,s,o){super(e),this.response=t,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}},Gi=class extends Ue{constructor(e,t,n,i,s,o){super(e),this.response=t,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}},Vi=class extends Ue{constructor(e,t,n,i,s,o){super(e),this.response=t,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};var ji=BigInt(4294967295),To=BigInt(32);function tu(r,e=!1){return e?{h:Number(r&ji),l:Number(r>>To&ji)}:{h:Number(r>>To&ji)|0,l:Number(r&ji)|0}}function bl(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:s,l:o}=tu(r[i],e);[t[i],n[i]]=[s,o]}return[t,n]}var xl=(r,e)=>BigInt(r>>>0)<<To|BigInt(e>>>0),_l=(r,e,t)=>r>>>t,El=(r,e,t)=>r<<32-t|e>>>t,vl=(r,e,t)=>r>>>t|e<<32-t,Il=(r,e,t)=>r<<32-t|e>>>t,Al=(r,e,t)=>r<<64-t|e>>>t-32,Sl=(r,e,t)=>r>>>t-32|e<<64-t,Bl=(r,e)=>e,Tl=(r,e)=>r,Nl=(r,e,t)=>r<<t|e>>>32-t,Rl=(r,e,t)=>e<<t|r>>>32-t,Ol=(r,e,t)=>e<<t-32|r>>>64-t,Ul=(r,e,t)=>r<<t-32|e>>>64-t;function Fl(r,e,t,n){let i=(e>>>0)+(n>>>0);return{h:r+t+(i/2**32|0)|0,l:i|0}}var Pl=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Ll=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Ml=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Dl=(r,e,t,n,i)=>e+t+n+i+(r/2**32|0)|0,kl=(r,e,t,n,i)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0),ql=(r,e,t,n,i,s)=>e+t+n+i+s+(r/2**32|0)|0;var Cl={fromBig:tu,split:bl,toBig:xl,shrSH:_l,shrSL:El,rotrSH:vl,rotrSL:Il,rotrBH:Al,rotrBL:Sl,rotr32H:Bl,rotr32L:Tl,rotlSH:Nl,rotlSL:Rl,rotlBH:Ol,rotlBL:Ul,add:Fl,add3L:Pl,add3H:Ll,add4L:Ml,add4H:Dl,add5H:ql,add5L:kl},le=Cl;var[$l,Hl]=le.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(r=>BigInt(r))),hr=new Uint32Array(80),dr=new Uint32Array(80),No=class extends Lr{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:t,Bh:n,Bl:i,Ch:s,Cl:o,Dh:c,Dl:a,Eh:h,El:p,Fh:g,Fl:w,Gh:x,Gl:f,Hh:N,Hl:T}=this;return[e,t,n,i,s,o,c,a,h,p,g,w,x,f,N,T]}set(e,t,n,i,s,o,c,a,h,p,g,w,x,f,N,T){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=a|0,this.Eh=h|0,this.El=p|0,this.Fh=g|0,this.Fl=w|0,this.Gh=x|0,this.Gl=f|0,this.Hh=N|0,this.Hl=T|0}process(e,t){for(let D=0;D<16;D++,t+=4)hr[D]=e.getUint32(t),dr[D]=e.getUint32(t+=4);for(let D=16;D<80;D++){let K=hr[D-15]|0,E=dr[D-15]|0,C=le.rotrSH(K,E,1)^le.rotrSH(K,E,8)^le.shrSH(K,E,7),G=le.rotrSL(K,E,1)^le.rotrSL(K,E,8)^le.shrSL(K,E,7),j=hr[D-2]|0,k=dr[D-2]|0,fe=le.rotrSH(j,k,19)^le.rotrBH(j,k,61)^le.shrSH(j,k,6),re=le.rotrSL(j,k,19)^le.rotrBL(j,k,61)^le.shrSL(j,k,6),te=le.add4L(G,re,dr[D-7],dr[D-16]),y=le.add4H(te,C,fe,hr[D-7],hr[D-16]);hr[D]=y|0,dr[D]=te|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:a,Dh:h,Dl:p,Eh:g,El:w,Fh:x,Fl:f,Gh:N,Gl:T,Hh:O,Hl:H}=this;for(let D=0;D<80;D++){let K=le.rotrSH(g,w,14)^le.rotrSH(g,w,18)^le.rotrBH(g,w,41),E=le.rotrSL(g,w,14)^le.rotrSL(g,w,18)^le.rotrBL(g,w,41),C=g&x^~g&N,G=w&f^~w&T,j=le.add5L(H,E,G,Hl[D],dr[D]),k=le.add5H(j,O,K,C,$l[D],hr[D]),fe=j|0,re=le.rotrSH(n,i,28)^le.rotrBH(n,i,34)^le.rotrBH(n,i,39),te=le.rotrSL(n,i,28)^le.rotrBL(n,i,34)^le.rotrBL(n,i,39),y=n&s^n&c^s&c,I=i&o^i&a^o&a;O=N|0,H=T|0,N=x|0,T=f|0,x=g|0,f=w|0,{h:g,l:w}=le.add(h|0,p|0,k|0,fe|0),h=c|0,p=a|0,c=s|0,a=o|0,s=n|0,o=i|0;let q=le.add3L(fe,te,I);n=le.add3H(q,k,re,y),i=q|0}({h:n,l:i}=le.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=le.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:a}=le.add(this.Ch|0,this.Cl|0,c|0,a|0),{h,l:p}=le.add(this.Dh|0,this.Dl|0,h|0,p|0),{h:g,l:w}=le.add(this.Eh|0,this.El|0,g|0,w|0),{h:x,l:f}=le.add(this.Fh|0,this.Fl|0,x|0,f|0),{h:N,l:T}=le.add(this.Gh|0,this.Gl|0,N|0,T|0),{h:O,l:H}=le.add(this.Hh|0,this.Hl|0,O|0,H|0),this.set(n,i,s,o,c,a,h,p,g,w,x,f,N,T,O,H)}roundClean(){hr.fill(0),dr.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)}};var ru=nn(()=>new No);var Rt=BigInt(0),ut=BigInt(1),Yi=BigInt(2),Gl=BigInt(8),Vl={zip215:!0};function jl(r){let e=Pi(r);return Tt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function nu(r){let e=jl(r),{Fp:t,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:a}=e,h=Yi<<BigInt(c*8)-ut,p=t.create,g=kt(e.n,e.nBitLength),w=e.uvRatio||((F,P)=>{try{return{isValid:!0,value:t.sqrt(F*t.inv(P))}}catch{return{isValid:!1,value:Rt}}}),x=e.adjustScalarBytes||(F=>F),f=e.domain||((F,P,$)=>{if(sr("phflag",$),P.length||$)throw new Error("Contexts/pre-hash are not supported");return F});function N(F,P){Bt("coordinate "+F,P,Rt,h)}function T(F){if(!(F instanceof D))throw new Error("ExtendedPoint expected")}let O=Kt((F,P)=>{let{ex:$,ey:Z,ez:ue}=F,ce=F.is0();P==null&&(P=ce?Gl:t.inv(ue));let Y=p($*P),U=p(Z*P),d=p(ue*P);if(ce)return{x:Rt,y:ut};if(d!==ut)throw new Error("invZ was invalid");return{x:Y,y:U}}),H=Kt(F=>{let{a:P,d:$}=e;if(F.is0())throw new Error("bad point: ZERO");let{ex:Z,ey:ue,ez:ce,et:Y}=F,U=p(Z*Z),d=p(ue*ue),J=p(ce*ce),ee=p(J*J),ae=p(U*P),Q=p(J*p(ae+d)),u=p(ee+p($*p(U*d)));if(Q!==u)throw new Error("bad point: equation left != right (1)");let l=p(Z*ue),m=p(ce*Y);if(l!==m)throw new Error("bad point: equation left != right (2)");return!0});class D{constructor(P,$,Z,ue){this.ex=P,this.ey=$,this.ez=Z,this.et=ue,N("x",P),N("y",$),N("z",Z),N("t",ue),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(P){if(P instanceof D)throw new Error("extended point not allowed");let{x:$,y:Z}=P||{};return N("x",$),N("y",Z),new D($,Z,ut,p($*Z))}static normalizeZ(P){let $=t.invertBatch(P.map(Z=>Z.ez));return P.map((Z,ue)=>Z.toAffine($[ue])).map(D.fromAffine)}static msm(P,$){return Fi(D,g,P,$)}_setWindowSize(P){C.setWindowSize(this,P)}assertValidity(){H(this)}equals(P){T(P);let{ex:$,ey:Z,ez:ue}=this,{ex:ce,ey:Y,ez:U}=P,d=p($*U),J=p(ce*ue),ee=p(Z*U),ae=p(Y*ue);return d===J&&ee===ae}is0(){return this.equals(D.ZERO)}negate(){return new D(p(-this.ex),this.ey,this.ez,p(-this.et))}double(){let{a:P}=e,{ex:$,ey:Z,ez:ue}=this,ce=p($*$),Y=p(Z*Z),U=p(Yi*p(ue*ue)),d=p(P*ce),J=$+Z,ee=p(p(J*J)-ce-Y),ae=d+Y,Q=ae-U,u=d-Y,l=p(ee*Q),m=p(ae*u),S=p(ee*u),v=p(Q*ae);return new D(l,m,v,S)}add(P){T(P);let{a:$,d:Z}=e,{ex:ue,ey:ce,ez:Y,et:U}=this,{ex:d,ey:J,ez:ee,et:ae}=P;if($===BigInt(-1)){let V=p((ce-ue)*(J+d)),W=p((ce+ue)*(J-d)),ie=p(W-V);if(ie===Rt)return this.double();let de=p(Y*Yi*ae),Ee=p(U*Yi*ee),Ne=Ee+de,he=W+V,oe=Ee-de,ke=p(Ne*ie),Qt=p(he*oe),mr=p(Ne*oe),gr=p(ie*he);return new D(ke,Qt,gr,mr)}let Q=p(ue*d),u=p(ce*J),l=p(U*Z*ae),m=p(Y*ee),S=p((ue+ce)*(d+J)-Q-u),v=m-l,A=m+l,M=p(u-$*Q),b=p(S*v),B=p(A*M),L=p(S*M),R=p(v*A);return new D(b,B,R,L)}subtract(P){return this.add(P.negate())}wNAF(P){return C.wNAFCached(this,P,D.normalizeZ)}multiply(P){let $=P;Bt("scalar",$,ut,n);let{p:Z,f:ue}=this.wNAF($);return D.normalizeZ([Z,ue])[0]}multiplyUnsafe(P){let $=P;return Bt("scalar",$,Rt,n),$===Rt?E:this.equals(E)||$===ut?this:this.equals(K)?this.wNAF($).p:C.unsafeLadder(this,$)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return C.unsafeLadder(this,n).is0()}toAffine(P){return O(this,P)}clearCofactor(){let{h:P}=e;return P===ut?this:this.multiplyUnsafe(P)}static fromHex(P,$=!1){let{d:Z,a:ue}=e,ce=t.BYTES;P=He("pointHex",P,ce),sr("zip215",$);let Y=P.slice(),U=P[ce-1];Y[ce-1]=U&-129;let d=or(Y),J=$?h:t.ORDER;Bt("pointHex.y",d,Rt,J);let ee=p(d*d),ae=p(ee-ut),Q=p(Z*ee-ue),{isValid:u,value:l}=w(ae,Q);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let m=(l&ut)===ut,S=(U&128)!==0;if(!$&&l===Rt&&S)throw new Error("Point.fromHex: x=0 and x_0=1");return S!==m&&(l=p(-l)),D.fromAffine({x:l,y:d})}static fromPrivateKey(P){return k(P).point}toRawBytes(){let{x:P,y:$}=this.toAffine(),Z=Ir($,t.BYTES);return Z[Z.length-1]|=P&ut?128:0,Z}toHex(){return St(this.toRawBytes())}}D.BASE=new D(e.Gx,e.Gy,ut,p(e.Gx*e.Gy)),D.ZERO=new D(Rt,ut,ut,Rt);let{BASE:K,ZERO:E}=D,C=Ui(D,c*8);function G(F){return Se(F,n)}function j(F){return G(or(F))}function k(F){let P=c;F=He("private key",F,P);let $=He("hashed private key",s(F),2*P),Z=x($.slice(0,P)),ue=$.slice(P,2*P),ce=j(Z),Y=K.multiply(ce),U=Y.toRawBytes();return{head:Z,prefix:ue,scalar:ce,point:Y,pointBytes:U}}function fe(F){return k(F).pointBytes}function re(F=new Uint8Array,...P){let $=Ie(...P);return j(s(f($,He("context",F),!!i)))}function te(F,P,$={}){F=He("message",F),i&&(F=i(F));let{prefix:Z,scalar:ue,pointBytes:ce}=k(P),Y=re($.context,Z,F),U=K.multiply(Y).toRawBytes(),d=re($.context,U,ce,F),J=G(Y+d*ue);Bt("signature.s",J,Rt,n);let ee=Ie(U,Ir(J,t.BYTES));return He("result",ee,c*2)}let y=Vl;function I(F,P,$,Z=y){let{context:ue,zip215:ce}=Z,Y=t.BYTES;F=He("signature",F,2*Y),P=He("message",P),ce!==void 0&&sr("zip215",ce),i&&(P=i(P));let U=or(F.slice(Y,2*Y)),d,J,ee;try{d=D.fromHex($,ce),J=D.fromHex(F.slice(0,Y),ce),ee=K.multiplyUnsafe(U)}catch{return!1}if(!ce&&d.isSmallOrder())return!1;let ae=re(ue,J.toRawBytes(),d.toRawBytes(),P);return J.add(d.multiplyUnsafe(ae)).subtract(ee).clearCofactor().equals(D.ZERO)}return K._setWindowSize(8),{CURVE:e,getPublicKey:fe,sign:te,verify:I,ExtendedPoint:D,utils:{getExtendedPublicKey:k,randomPrivateKey:()=>o(t.BYTES),precompute(F=8,P=D.BASE){return P._setWindowSize(F),P.multiply(BigInt(3)),P}}}}var Ro=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),iu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Xp=BigInt(0),Yl=BigInt(1),su=BigInt(2),Qp=BigInt(3),zl=BigInt(5),Kl=BigInt(8);function Zl(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),i=BigInt(80),s=Ro,c=r*r%s*r%s,a=Nt(c,su,s)*c%s,h=Nt(a,Yl,s)*r%s,p=Nt(h,zl,s)*h%s,g=Nt(p,e,s)*p%s,w=Nt(g,t,s)*g%s,x=Nt(w,n,s)*w%s,f=Nt(x,i,s)*x%s,N=Nt(f,i,s)*x%s,T=Nt(N,e,s)*p%s;return{pow_p_5_8:Nt(T,su,s)*r%s,b2:c}}function Wl(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Xl(r,e){let t=Ro,n=Se(e*e*e,t),i=Se(n*n*e,t),s=Zl(r*i).pow_p_5_8,o=Se(r*n*s,t),c=Se(e*o*o,t),a=o,h=Se(o*iu,t),p=c===r,g=c===Se(-r,t),w=c===Se(-r*iu,t);return p&&(o=a),(g||w)&&(o=h),Mc(o,t)&&(o=Se(-o,t)),{isValid:p||g,value:o}}var Ql=kt(Ro,void 0,!0),Jl={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ql,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Kl,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ru,randomBytes:Hn,adjustScalarBytes:Wl,uvRatio:Xl},ou=nu(Jl);var au=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},st=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},et,Tn,cu,uu,zi=class{constructor(e={}){et.set(this,void 0),Tn.set(this,void 0),this[cu]=this.entries.bind(this),this[uu]="ExpirableMap";let{source:t=[],expirationTime:n=600*1e3}=e,i=Date.now();au(this,et,new Map([...t].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),au(this,Tn,n,"f")}prune(){let e=Date.now();for(let[t,n]of st(this,et,"f").entries())e-n.timestamp>st(this,Tn,"f")&&st(this,et,"f").delete(t);return this}set(e,t){this.prune();let n={value:t,timestamp:Date.now()};return st(this,et,"f").set(e,n),this}get(e){let t=st(this,et,"f").get(e);if(t!==void 0){if(Date.now()-t.timestamp>st(this,Tn,"f")){st(this,et,"f").delete(e);return}return t.value}}clear(){st(this,et,"f").clear()}entries(){let e=st(this,et,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=st(this,et,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return st(this,et,"f").keys()}forEach(e,t){for(let[n,i]of st(this,et,"f").entries())e.call(t,i.value,n,this)}has(e){return st(this,et,"f").has(e)}delete(e){return st(this,et,"f").delete(e)}get size(){return st(this,et,"f").size}};et=new WeakMap,Tn=new WeakMap,cu=Symbol.iterator,uu=Symbol.toStringTag;var fu=r=>{if(r<=127)return 1;if(r<=255)return 2;if(r<=65535)return 3;if(r<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},lu=(r,e,t)=>{if(t<=127)return r[e]=t,1;if(t<=255)return r[e]=129,r[e+1]=t,2;if(t<=65535)return r[e]=130,r[e+1]=t>>8,r[e+2]=t,3;if(t<=16777215)return r[e]=131,r[e+1]=t>>16,r[e+2]=t>>8,r[e+3]=t,4;throw new Error("Length too long (> 4 bytes)")},Oo=(r,e)=>{if(r[e]<128)return 1;if(r[e]===128)throw new Error("Invalid length 0");if(r[e]===129)return 2;if(r[e]===130)return 3;if(r[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")},eh=(r,e)=>{let t=Oo(r,e);if(t===1)return r[e];if(t===2)return r[e+1];if(t===3)return(r[e+1]<<8)+r[e+2];if(t===4)return(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];throw new Error("Length too long (> 4 bytes)")},r1=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Uo=Uint8Array.from([48,5,6,3,43,101,112]),n1=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function hu(r,e){let t=2+fu(r.byteLength+1),n=e.byteLength+t+r.byteLength,i=0,s=new Uint8Array(1+fu(n)+n);return s[i++]=48,i+=lu(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=lu(s,i,r.byteLength+1),s[i++]=0,s.set(new Uint8Array(r),i),s}var du=(r,e)=>{let t=0,n=(c,a)=>{if(i[t++]!==c)throw new Error("Expected: "+a)},i=new Uint8Array(r);if(n(48,"sequence"),t+=Oo(i,t),!br(i.slice(t,t+e.byteLength),e))throw new Error("Not the expected OID.");t+=e.byteLength,n(3,"bit string");let s=eh(i,t)-1;t+=Oo(i,t),n(0,"0 padding");let o=i.slice(t);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};var pu=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},mu=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Ki,Zi,Nn=class r{constructor(e){if(Ki.set(this,void 0),Zi.set(this,void 0),e.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");pu(this,Ki,e,"f"),pu(this,Zi,r.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new r(e)}static fromDer(e){return new r(this.derDecode(e))}static derEncode(e){return hu(e,Uo).buffer}static derDecode(e){let t=du(e,Uo);if(t.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return t}get rawKey(){return mu(this,Ki,"f")}get derKey(){return mu(this,Zi,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Ki=new WeakMap,Zi=new WeakMap;Nn.RAW_KEY_LENGTH=32;var Fo=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(t=>t!==e)}notify(e,...t){this.observers.forEach(n=>n(e,...t))}},Wi=class extends Fo{constructor(){super()}print(e,...t){this.notify({message:e,level:"info"},...t)}warn(e,...t){this.notify({message:e,level:"warn"},...t)}error(e,t,...n){this.notify({message:e,level:"error",error:t},...n)}};var qt=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},tt=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Ct,Xi,Qi,Ji,es,ts,rs,ns,Kr;var Rn=class r{constructor(e=r.default){Ct.set(this,void 0),Xi.set(this,void 0),Qi.set(this,void 0),Ji.set(this,void 0),es.set(this,void 0),ts.set(this,void 0),rs.set(this,void 0),ns.set(this,void 0),Kr.set(this,0);let{initialInterval:t=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:c=10,date:a=Date}=e;qt(this,Ct,t,"f"),qt(this,Xi,n,"f"),qt(this,Qi,i,"f"),qt(this,Ji,s,"f"),qt(this,ns,a,"f"),qt(this,es,a.now(),"f"),qt(this,ts,o,"f"),qt(this,rs,c,"f")}get ellapsedTimeInMsec(){return tt(this,ns,"f").now()-tt(this,es,"f")}get currentInterval(){return tt(this,Ct,"f")}get count(){return tt(this,Kr,"f")}get randomValueFromInterval(){let e=tt(this,Xi,"f")*tt(this,Ct,"f"),t=tt(this,Ct,"f")-e,n=tt(this,Ct,"f")+e;return Math.random()*(n-t)+t}incrementCurrentInterval(){var e;return qt(this,Ct,Math.min(tt(this,Ct,"f")*tt(this,Qi,"f"),tt(this,Ji,"f")),"f"),qt(this,Kr,(e=tt(this,Kr,"f"),e++,e),"f"),tt(this,Ct,"f")}next(){return this.ellapsedTimeInMsec>=tt(this,ts,"f")||tt(this,Kr,"f")>=tt(this,rs,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Ct=new WeakMap,Xi=new WeakMap,Qi=new WeakMap,Ji=new WeakMap,es=new WeakMap,ts=new WeakMap,rs=new WeakMap,ns=new WeakMap,Kr=new WeakMap;Rn.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var Xe=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},X=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},rt,Br,en,$t,Wt,Qr,On,Zr,Ot,Ut,Tr,Nr,Un,Wr,Xr,Rr,Ur,bu,ss,os,Or,gu;(function(r){r.Received="received",r.Processing="processing",r.Replied="replied",r.Rejected="rejected",r.Unknown="unknown",r.Done="done"})(gu||(gu={}));var is=60*1e3,th="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",xu="aaaaa-aa",rh="ic0.app",nh=".ic0.app",ih="icp0.io",sh=".icp0.io",oh="icp-api.io",ah=".icp-api.io",Fn=class extends Ue{constructor(e){super(e),this.message=e}},Jr=class extends Ue{constructor(e){super(e),this.message=e}};function ch(){let r;if(typeof window<"u")if(window.fetch)r=window.fetch.bind(window);else throw new Fn("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof globalThis<"u")if(globalThis.fetch)r=globalThis.fetch.bind(globalThis);else throw new Fn("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&&(r=self.fetch.bind(self));if(r)return r;throw new Fn("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function uh(r){let e;if(r!==void 0)!r.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+r):e=new URL(r);else{let t=["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(c=>s.endsWith(c))?o=s:o=t.find(c=>s.endsWith(c))),i&&o?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var yu=class r{constructor(e={}){var t,n;rt.add(this),Br.set(this,null),en.set(this,!1),$t.set(this,void 0),Wt.set(this,void 0),Qr.set(this,void 0),On.set(this,void 0),Zr.set(this,0),Ot.set(this,void 0),Ut.set(this,void 0),Tr.set(this,void 0),Nr.set(this,void 0),this._isAgent=!0,this.config={},Un.set(this,0),this.log=new Wi,Wr.set(this,[]),Xr.set(this,[]),Rr.set(this,new zi({expirationTime:300*1e3})),Ur.set(this,!0),os.set(this,(o,c)=>{if(X(this,Ur,"f")===!1)return o;if(!c)throw new dt("Invalid signature from replica signed query: no matching node key found.");let{status:a,signatures:h=[],requestId:p}=o,g=new TextEncoder().encode("\vic-response");for(let w of h){let{timestamp:x,identity:f}=w,N=me.fromUint8Array(f).toText(),T;if(a==="replied"){let{reply:E}=o;T=wn({status:a,reply:E,timestamp:BigInt(x),request_id:p})}else if(a==="rejected"){let{reject_code:E,reject_message:C,error_code:G}=o;T=wn({status:a,reject_code:E,reject_message:C,error_code:G,timestamp:BigInt(x),request_id:p})}else throw new Error(`Unknown status: ${a}`);let O=Qe(g,new Uint8Array(T)),H=c?.nodeKeys.get(N);if(!H)throw new dt("Invalid signature from replica signed query: no matching node key found.");let D=Nn.fromDer(H).rawKey;if(ou.verify(w.signature,new Uint8Array(O),new Uint8Array(D)))return o;throw new dt(`Invalid signature from replica ${N} signed query.`)}return o}),this.config=e,Xe(this,Wt,e.fetch||ch()||fetch.bind(globalThis),"f"),Xe(this,Qr,e.fetchOptions,"f"),Xe(this,On,e.callOptions,"f"),Xe(this,en,(t=e.shouldFetchRootKey)!==null&&t!==void 0?t:!1,"f"),e.rootKey?this.rootKey=e.rootKey:X(this,en,"f")?this.rootKey=null:this.rootKey=wr(th);let i=uh(e.host);this.host=new URL(i),e.verifyQuerySignatures!==void 0&&Xe(this,Ur,e.verifyQuerySignatures,"f"),Xe(this,Ut,(n=e.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new Rn({maxIterations:X(this,Ut,"f")});if(Xe(this,Tr,e.backoffStrategy||s,"f"),this.host.hostname.endsWith(nh)?this.host.hostname=rh:this.host.hostname.endsWith(sh)?this.host.hostname=ih:this.host.hostname.endsWith(ah)&&(this.host.hostname=oh),e.credentials){let{name:o,password:c}=e.credentials;Xe(this,Ot,`${o}${c?":"+c:""}`,"f")}if(Xe(this,$t,Promise.resolve(e.identity||new Sn),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new Ue(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);if(e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes<=0)throw new Ue(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);Xe(this,Nr,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",Bo(jr)),e.useQueryNonces&&this.addTransform("query",Bo(jr)),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 X(this,Un,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let t=r.createSync(e),n=[t.syncTime()];return t.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(t.fetchRootKey()),await Promise.all(n),t}static async from(e){var t;try{return"config"in e?await r.create(e.config):await r.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(t=e._identity)!==null&&t!==void 0?t:void 0})}catch{throw new Ue("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,t,n=t.priority||0){if(e==="update"){let i=X(this,Xr,"f").findIndex(s=>(s.priority||0)<n);X(this,Xr,"f").splice(i>=0?i:X(this,Xr,"f").length,0,Object.assign(t,{priority:n}))}else if(e==="query"){let i=X(this,Wr,"f").findIndex(s=>(s.priority||0)<n);X(this,Wr,"f").splice(i>=0?i:X(this,Wr,"f").length,0,Object.assign(t,{priority:n}))}}async getPrincipal(){if(!X(this,$t,"f"))throw new Jr("This identity has expired due this application's security policy. Please refresh your authentication.");return(await X(this,$t,"f")).getPrincipal()}async call(e,t,n){var i,s;await X(this,rt,"m",Or).call(this);let o=(i=t.callSync)!==null&&i!==void 0?i:!0,c=await(n!==void 0?await n:await X(this,$t,"f"));if(!c)throw new Jr("This identity has expired due this application's security policy. Please refresh your authentication.");let a=me.from(e),h=t.effectiveCanisterId?me.from(t.effectiveCanisterId):a,p=c.getPrincipal()||me.anonymous(),g=new Sr(X(this,Nr,"f")*is);Math.abs(X(this,Zr,"f"))>1e3*30&&(g=new Sr(X(this,Nr,"f")*is+X(this,Zr,"f")));let w={request_type:$i.Call,canister_id:a,method_name:t.methodName,arg:t.arg,sender:p,ingress_expiry:g},x=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},X(this,Ot,"f")?{Authorization:"Basic "+btoa(X(this,Ot,"f"))}:{})},endpoint:"call",body:w}),f=x.body.nonce?N(x.body.nonce):void 0;w.nonce=f;function N(D){return new Uint8Array(D)}x=await c.transformRequest(x);let T=hn(x.body),O=X(this,Tr,"f").call(this),H=yn(w);try{let D=()=>(this.log.print(`fetching "/api/v3/canister/${h.toText()}/call" with request:`,x),X(this,Wt,"f").call(this,""+new URL(`/api/v3/canister/${h.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},X(this,On,"f")),x.request),{body:T}))),K=()=>(this.log.print(`fetching "/api/v2/canister/${h.toText()}/call" with request:`,x),X(this,Wt,"f").call(this,""+new URL(`/api/v2/canister/${h.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},X(this,On,"f")),x.request),{body:T}))),C=await X(this,rt,"m",ss).call(this,{request:o?D:K,backoff:O,tries:0}),G=await C.arrayBuffer(),j=C.status===200&&G.byteLength>0?lt(G):null;if(j&&"certificate"in j){let k=await this.parseTimeFromResponse({certificate:j.certificate});Xe(this,Un,k,"f")}return{requestId:H,response:{ok:C.ok,status:C.status,statusText:C.statusText,body:j,headers:Yr(C.headers)},requestDetails:w}}catch(D){if(D.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({},t),{callSync:!1}),n);let K=`Error while making call: ${(s=D.message)!==null&&s!==void 0?s:String(D)}`,E=new Hi(K,D,Fe(H),Fe(x.body.sender_pubkey),Fe(x.body.sender_sig),String(x.body.content.ingress_expiry._value));throw this.log.error(K,E),E}}async query(e,t,n){var i,s,o,c;await X(this,rt,"m",Or).call(this);let a=X(this,Tr,"f").call(this),h=t.effectiveCanisterId?me.from(t.effectiveCanisterId):me.from(e);this.log.print(`ecid ${h.toString()}`),this.log.print(`canisterId ${e.toString()}`);let p,g,w=await(n!==void 0?n:X(this,$t,"f"));if(!w)throw new Jr("This identity has expired due this application's security policy. Please refresh your authentication.");let x=me.from(e),f=w?.getPrincipal()||me.anonymous(),N={request_type:"query",canister_id:x,method_name:t.methodName,arg:t.arg,sender:f,ingress_expiry:new Sr(X(this,Nr,"f")*is)},T=yn(N);p=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},X(this,Ot,"f")?{Authorization:"Basic "+btoa(X(this,Ot,"f"))}:{})},endpoint:"read",body:N}),p=await w?.transformRequest(p);let O=hn(p.body),H={canister:x.toText(),ecid:h,transformedRequest:p,body:O,requestId:T,backoff:a,tries:0},D=async()=>({requestDetails:N,query:await X(this,rt,"m",bu).call(this,H)}),K=async()=>{if(!X(this,Ur,"f"))return;let E=X(this,Rr,"f").get(h.toString());return E||(await this.fetchSubnetKeys(h.toString()),X(this,Rr,"f").get(h.toString()))};try{let[E,C]=await Promise.all([D(),K()]);g=E;let{requestDetails:G,query:j}=g,k=Object.assign(Object.assign({},j),{requestDetails:G});if(this.log.print("Query response:",k),!X(this,Ur,"f"))return k;try{return X(this,os,"f").call(this,k,C)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),X(this,Rr,"f").delete(e.toString()),await this.fetchSubnetKeys(h.toString());let re=X(this,Rr,"f").get(e.toString());if(!re)throw new dt("Invalid signature from replica signed query: no matching node key found.");return X(this,os,"f").call(this,k,re)}}catch(E){let C=`Error while making call: ${(i=E.message)!==null&&i!==void 0?i:String(E)}`,G=new Gi(C,E,String(T),Fe((s=p?.body)===null||s===void 0?void 0:s.sender_pubkey),Fe((o=p?.body)===null||o===void 0?void 0:o.sender_sig),String((c=p?.body)===null||c===void 0?void 0:c.content.ingress_expiry._value));throw this.log.error(C,G),G}}async createReadStateRequest(e,t){await X(this,rt,"m",Or).call(this);let n=await(t!==void 0?await t:await X(this,$t,"f"));if(!n)throw new Jr("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||me.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},X(this,Ot,"f")?{Authorization:"Basic "+btoa(X(this,Ot,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Sr(X(this,Nr,"f")*is)}});return n?.transformRequest(s)}async readState(e,t,n,i){var s,o,c,a;function h(N){for(let T of N.paths){let[O,H]=T,D=new TextEncoder().encode("request_status");if(br(O,D))return H}}let p=h(t);await X(this,rt,"m",Or).call(this);let g=typeof e=="string"?me.fromText(e):e,w=i??await this.createReadStateRequest(t,n),x=hn(w.body);this.log.print(`fetching "/api/v2/canister/${g}/read_state" with request:`,w);let f=X(this,Tr,"f").call(this);try{let N=await X(this,rt,"m",ss).call(this,{request:()=>X(this,Wt,"f").call(this,""+new URL(`/api/v2/canister/${g.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},X(this,Qr,"f")),w.request),{body:x})),backoff:f,tries:0});if(!N.ok)throw new Error(`Server returned an error:
|
|
15
|
-
Code: ${N.status} (${N.statusText})
|
|
16
|
-
Body: ${await N.text()}
|
|
17
|
-
`);let T=lt(await N.arrayBuffer());this.log.print("Read state response:",T);let O=await this.parseTimeFromResponse(T);return O>0&&(this.log.print("Read state response time:",O),Xe(this,Un,O,"f")),T}catch(N){let T=`Caught exception while attempting to read state: ${(s=N.message)!==null&&s!==void 0?s:String(N)}`,O=new Vi(T,N,String(p),Fe((o=w?.body)===null||o===void 0?void 0:o.sender_pubkey),Fe((c=w?.body)===null||c===void 0?void 0:c.sender_sig),String((a=w?.body)===null||a===void 0?void 0:a.content.ingress_expiry._value));throw this.log.error(T,O),O}}async parseTimeFromResponse(e){let t;if(e.certificate){let n=lt(e.certificate);if(n&&"tree"in n)t=n.tree;else throw new Error("Could not decode time from response");let i=pr(["time"],t);if(i.status!==De.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=Vr(bs(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 X(this,rt,"m",Or).call(this);let t=await import("./canisterStatus-ENEUF6W6.js"),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=r.createSync({identity:new Sn,host:this.host.toString(),fetch:X(this,Wt,"f"),retryTimes:0}),o=(await t.request({canisterId:e??me.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:i,paths:["time"]})).get("time");o&&(Xe(this,Zr,Number(o)-Number(n),"f"),this.log.notify({message:`Syncing time: offset of ${X(this,Zr,"f")}`,level:"info"}))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=X(this,Ot,"f")?{Authorization:"Basic "+btoa(X(this,Ot,"f"))}:{};this.log.print('fetching "/api/v2/status"');let t=X(this,Tr,"f").call(this),n=await X(this,rt,"m",ss).call(this,{backoff:t,request:()=>X(this,Wt,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:e},X(this,Qr,"f"))),tries:0});return lt(await n.arrayBuffer())}async fetchRootKey(){let e;return X(this,Br,"f")?e=await X(this,Br,"f"):(Xe(this,Br,new Promise((t,n)=>{this.status().then(i=>{let s=i.root_key;this.rootKey=s,t(s)}).catch(n)}),"f"),e=await X(this,Br,"f")),Xe(this,Br,null,"f"),e}invalidateIdentity(){Xe(this,$t,null,"f")}replaceIdentity(e){Xe(this,$t,Promise.resolve(e),"f")}async fetchSubnetKeys(e){await X(this,rt,"m",Or).call(this);let t=me.from(e),i=(await wu({canisterId:t,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return X(this,Rr,"f").set(t.toText(),i),i}_transform(e){let t=Promise.resolve(e);if(e.endpoint==="call")for(let n of X(this,Xr,"f"))t=t.then(i=>n(i).then(s=>s||i));else for(let n of X(this,Wr,"f"))t=t.then(i=>n(i).then(s=>s||i));return t}};Br=new WeakMap,en=new WeakMap,$t=new WeakMap,Wt=new WeakMap,Qr=new WeakMap,On=new WeakMap,Zr=new WeakMap,Ot=new WeakMap,Ut=new WeakMap,Tr=new WeakMap,Nr=new WeakMap,Un=new WeakMap,Wr=new WeakMap,Xr=new WeakMap,Rr=new WeakMap,Ur=new WeakMap,os=new WeakMap,rt=new WeakSet,bu=async function r(e){var t,n;let{ecid:i,transformedRequest:s,body:o,requestId:c,backoff:a,tries:h}=e,p=h===0?0:a.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:h,backoff:a,delay:p}),p===null)throw new Ue(`Timestamp failed to pass the watermark after retrying the configured ${X(this,Ut,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);p>0&&await new Promise(f=>setTimeout(f,p));let g;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let f=await X(this,Wt,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},X(this,Qr,"f")),s.request),{body:o}));if(f.status===200){let N=lt(await f.arrayBuffer());g=Object.assign(Object.assign({},N),{httpDetails:{ok:f.ok,status:f.status,statusText:f.statusText,headers:Yr(f.headers)},requestId:c})}else throw new zr(`Gateway returned an error:
|
|
18
|
-
Code: ${f.status} (${f.statusText})
|
|
19
|
-
Body: ${await f.text()}
|
|
20
|
-
`,{ok:f.ok,status:f.status,statusText:f.statusText,headers:Yr(f.headers)})}catch(f){if(h<X(this,Ut,"f"))return this.log.warn(`Caught exception while attempting to make query:
|
|
21
|
-
${f}
|
|
22
|
-
Retrying query.`),await X(this,rt,"m",r).call(this,Object.assign(Object.assign({},e),{tries:h+1}));throw f}let w=(n=(t=g.signatures)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.timestamp;if(!X(this,Ur,"f"))return g;if(!w)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let x=Number(BigInt(w)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:x}),Number(this.waterMark)>x){let f=new Ue("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",f,{timestamp:w,waterMark:this.waterMark}),h<X(this,Ut,"f"))return await X(this,rt,"m",r).call(this,Object.assign(Object.assign({},e),{tries:h+1}));throw new Ue(`Timestamp failed to pass the watermark after retrying the configured ${X(this,Ut,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return g},ss=async function r(e){let{request:t,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new Ue(`Timestamp failed to pass the watermark after retrying the configured ${X(this,Ut,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(h=>setTimeout(h,s));let o;try{o=await t()}catch(h){if(X(this,Ut,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
|
|
23
|
-
${h}
|
|
24
|
-
Retrying request.`),await X(this,rt,"m",r).call(this,{request:t,backoff:n,tries:i+1});throw h}if(o.ok)return o;let c=await o.clone().text(),a=`Server returned an error:
|
|
25
|
-
Code: ${o.status} (${o.statusText})
|
|
26
|
-
Body: ${c}
|
|
27
|
-
`;if(o.status===404&&o.url.includes("api/v3"))throw new zr("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:Yr(o.headers)});if(i<X(this,Ut,"f"))return await X(this,rt,"m",r).call(this,{request:t,backoff:n,tries:i+1});throw new zr(a,{ok:o.ok,status:o.status,statusText:o.statusText,headers:Yr(o.headers)})},Or=async function(){if(!this.rootKey)if(this.rootKey===null&&X(this,en,"f"))await this.fetchRootKey();else throw new Ue(`Invalid root key detected. The root key for this agent is ${this.rootKey} and the shouldFetchRootKey value is set to ${X(this,en,"f")}. The root key should only be unknown if you are in local development. Otherwise you should avoid fetching and use the default IC Root Key or the known root key of your environment.`)};var _u;(function(r){r.Error="err",r.GetPrincipal="gp",r.GetPrincipalResponse="gpr",r.Query="q",r.QueryResponse="qr",r.Call="c",r.CallResponse="cr",r.ReadState="rs",r.ReadStateResponse="rsr",r.Status="s",r.StatusResponse="sr"})(_u||(_u={}));function O1(){let r=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.ic.agent:globalThis.ic.agent:window.ic.agent;if(!r)throw new Error("No Agent could be found.");return r}var fh=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},lh=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},as,dt=class extends Ue{constructor(e){super(`Invalid certificate: ${e}`)}},pt;(function(r){r[r.Empty=0]="Empty",r[r.Fork=1]="Fork",r[r.Labeled=2]="Labeled",r[r.Leaf=3]="Leaf",r[r.Pruned=4]="Pruned"})(pt||(pt={}));function hh(r,e){let t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]>n[i])return!0;return!1}var fs=class r{constructor(e,t,n,i,s=5,o=!1){this._rootKey=t,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,as.set(this,!1),fh(this,as,o,"f"),this.cert=lt(new Uint8Array(e))}static async create(e){let t=r.createUnverified(e);return await t.verify(),t}static createUnverified(e){let t=e.blsVerify;return t||(t=Xc),new r(e.certificate,e.rootKey,e.canisterId,t,e.maxAgeInMinutes,e.disableTimeVerification)}lookup(e){return pr(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await cs(this.cert.tree),t=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=ph(t),s=Qe(Ln("ic-state-root"),e),o=!1,c=ls(this.lookup(["time"]));if(!c)throw new dt("Certificate does not contain a time");if(!lh(this,as,"f")){let h=this._maxAgeInMinutes*60*1e3,p=Date.now(),g=p-h,w=p+3e5,x=Vr(c);if(x.getTime()<g)throw new dt(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+x.toISOString()+" Current time: "+new Date(p).toISOString());if(x.getTime()>w)throw new dt("Certificate is signed more than 5 minutes in the future. Certificate time: "+x.toISOString()+" Current time: "+new Date(p).toISOString())}try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new dt("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let t=await r.createUnverified({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(t.cert.delegation)throw new dt("Delegation certificates cannot be nested");if(await t.verify(),this._canisterId.toString()!==xu&&!Po({canisterId:this._canisterId,subnetId:me.fromUint8Array(new Uint8Array(e.subnet_id)),tree:t.cert.tree}))throw new dt(`Canister ${this._canisterId} not in range of delegations for subnet 0x${Fe(e.subnet_id)}`);let n=ls(t.lookup(["subnet",e.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${Fe(e.subnet_id)}`);return n}};as=new WeakMap;var Pn=wr("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),dh=96;function ph(r){let e=Pn.byteLength+dh;if(r.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let t=r.slice(0,Pn.byteLength);if(!br(t,Pn))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Pn}, but get ${t}`);return r.slice(Pn.byteLength)}function ls(r){if(r.status===De.Found){if(r.value instanceof ArrayBuffer)return r.value;if(r.value instanceof Uint8Array)return r.value.buffer}}async function cs(r){switch(r[0]){case pt.Empty:return wt(Ln("ic-hashtree-empty"));case pt.Pruned:return r[1];case pt.Leaf:return wt(Qe(Ln("ic-hashtree-leaf"),r[1]));case pt.Labeled:return wt(Qe(Ln("ic-hashtree-labeled"),r[1],await cs(r[2])));case pt.Fork:return wt(Qe(Ln("ic-hashtree-fork"),await cs(r[1]),await cs(r[2])));default:throw new Error("unreachable")}}function Ln(r){let e=new Uint8Array([r.length]),t=new TextEncoder().encode(r);return Qe(e,t)}var De;(function(r){r.Unknown="unknown",r.Absent="absent",r.Found="found"})(De||(De={}));var Xt;(function(r){r.Less="less",r.Greater="greater"})(Xt||(Xt={}));function pr(r,e){if(r.length===0)switch(e[0]){case pt.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:De.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:De.Found,value:e[1].buffer}:{status:De.Found,value:e[1]}}default:return{status:De.Found,value:e}}let t=typeof r[0]=="string"?new TextEncoder().encode(r[0]):r[0],n=us(t,e);switch(n.status){case De.Found:return pr(r.slice(1),n.value);case Xt.Greater:case Xt.Less:return{status:De.Absent};default:return n}}function hs(r){switch(r[0]){case pt.Empty:return[];case pt.Fork:return hs(r[1]).concat(hs(r[2]));default:return[r]}}function us(r,e){switch(e[0]){case pt.Labeled:return hh(r,e[1])?{status:Xt.Greater}:br(r,e[1])?{status:De.Found,value:e[2]}:{status:Xt.Less};case pt.Fork:let t=us(r,e[1]);switch(t.status){case Xt.Greater:{let n=us(r,e[2]);return n.status===Xt.Less?{status:De.Absent}:n}case De.Unknown:{let n=us(r,e[2]);return n.status===Xt.Less?{status:De.Unknown}:n}default:return t}case pt.Pruned:return{status:De.Unknown};default:return{status:De.Absent}}}function Po(r){let{canisterId:e,subnetId:t,tree:n}=r,i=pr(["subnet",t.toUint8Array(),"canister_ranges"],n);if(i.status!==De.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${t}`);return lt(i.value).map(a=>[me.fromUint8Array(a[0]),me.fromUint8Array(a[1])]).some(a=>a[0].ltEq(e)&&a[1].gtEq(e))}var Eu=class{constructor(e,t,n){this.key=e,this.path=t,this.decodeStrategy=n}},wu=async r=>{let{agent:e,paths:t}=r,n=me.from(r.canisterId),i=[...new Set(t)],s=i.map(a=>vu(a,n)),o=new Map,c=i.map((a,h)=>(async()=>{var p;try{let g=await e.readState(n,{paths:[s[h]]});if(e.rootKey==null)throw new Error("Agent is missing root key");let w=await fs.create({certificate:g.certificate,rootKey:e.rootKey,canisterId:n,disableTimeVerification:!0}),x=(T,O)=>{if(O==="subnet"){if(e.rootKey==null)throw new Error("Agent is missing root key");let H=mh(g.certificate,n,e.rootKey);return{path:O,data:H}}else return{path:O,data:ls(T.lookup(vu(O,n)))}},{path:f,data:N}=x(w,i[h]);if(!N)console.warn(`Expected to find result for path ${f}, but instead found nothing.`),typeof f=="string"?o.set(f,null):o.set(f.key,null);else switch(f){case"time":{o.set(f,Vr(N));break}case"controllers":{o.set(f,yh(N));break}case"module_hash":{o.set(f,Iu(N));break}case"subnet":{o.set(f,N);break}case"candid":{o.set(f,new TextDecoder().decode(N));break}default:if(typeof f!="string"&&"key"in f&&"path"in f)switch(f.decodeStrategy){case"raw":o.set(f.key,N);break;case"leb128":{o.set(f.key,So(N));break}case"cbor":{o.set(f.key,Au(N));break}case"hex":{o.set(f.key,Iu(N));break}case"utf-8":o.set(f.key,gh(N))}}}catch(g){if(!((p=g?.message)===null||p===void 0)&&p.includes("Invalid certificate"))throw new Ue(g.message);typeof a!="string"&&"key"in a&&"path"in a?o.set(a.key,null):o.set(a,null),console.group(),console.warn(`Expected to find result for path ${a}, but instead found nothing.`),console.warn(g),console.groupEnd()}})());return await Promise.all(c),o},mh=(r,e,t)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=lt(new Uint8Array(r)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=me.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof t<"u"?(o=me.selfAuthenticating(new Uint8Array(t)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=me.selfAuthenticating(me.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!Po({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let a=pr(["subnet",s.subnet_id,"node"],i);if(a.status!==De.Found)throw new Error("Node not found");if(a.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let h=hs(a.value),p=new Map;return h.forEach(g=>{let w=me.from(new Uint8Array(g[1])).toText(),x=pr(["public_key"],g[2]);if(x.status!==De.Found)throw new Error("Public key not found");let f=x.value;if(f.byteLength!==44)throw new Error("Invalid public key length");p.set(w,f)}),{subnetId:me.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:p}},vu=(r,e)=>{let t=new TextEncoder,n=s=>new DataView(t.encode(s).buffer).buffer,i=new DataView(e.toUint8Array().buffer).buffer;switch(r){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 r&&"path"in r)if(typeof r.path=="string"||r.path instanceof ArrayBuffer){let s=r.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return r.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${r} was formatted correctly.`)},Iu=r=>Fe(r),Au=r=>lt(r),gh=r=>new TextDecoder().decode(r),yh=r=>Au(r).map(t=>me.fromUint8Array(new Uint8Array(t)));export{ze as a,kn as b,rn as c,da as d,ys as e,me as f,Fe as g,wr as h,br as i,on as j,bs as k,Ue as l,Qs as m,no as n,Hs as o,yn as p,Qc as q,Sn as r,oi as s,ui as t,fs as u,ls as v,Eu as w,wu as x,mh as y,vu as z,ou as A,r1 as B,Uo as C,hu as D,du as E,gu as F,yu as G,O1 as H};
|
|
28
|
-
/*!
|
|
29
|
-
* The buffer module from node.js, for the browser.
|
|
30
|
-
*
|
|
31
|
-
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
32
|
-
* @license MIT
|
|
33
|
-
*/
|
|
34
|
-
/*! Bundled license information:
|
|
35
|
-
|
|
36
|
-
ieee754/index.js:
|
|
37
|
-
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
38
|
-
|
|
39
|
-
@noble/hashes/esm/utils.js:
|
|
40
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
41
|
-
|
|
42
|
-
@noble/curves/esm/abstract/utils.js:
|
|
43
|
-
@noble/curves/esm/abstract/modular.js:
|
|
44
|
-
@noble/curves/esm/abstract/curve.js:
|
|
45
|
-
@noble/curves/esm/abstract/weierstrass.js:
|
|
46
|
-
@noble/curves/esm/abstract/bls.js:
|
|
47
|
-
@noble/curves/esm/abstract/tower.js:
|
|
48
|
-
@noble/curves/esm/bls12-381.js:
|
|
49
|
-
@noble/curves/esm/abstract/edwards.js:
|
|
50
|
-
@noble/curves/esm/ed25519.js:
|
|
51
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
52
|
-
*/
|
|
53
|
-
//# sourceMappingURL=chunk-GGU5IQIJ.js.map
|