@junobuild/core 0.0.54 → 0.0.55

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/core",
3
- "version": "0.0.54",
3
+ "version": "0.0.55",
4
4
  "description": "JavaScript core client for Juno",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",
@@ -51,11 +51,11 @@
51
51
  ],
52
52
  "homepage": "https://juno.build",
53
53
  "dependencies": {
54
- "@dfinity/agent": "^1.3.0",
55
- "@dfinity/auth-client": "^1.3.0",
56
- "@dfinity/identity": "^1.3.0",
57
- "@dfinity/principal": "^1.3.0",
58
- "@junobuild/utils": "*",
59
- "@junobuild/storage": "*"
54
+ "@dfinity/agent": "^1.4.0",
55
+ "@dfinity/auth-client": "^1.4.0",
56
+ "@dfinity/identity": "^1.4.0",
57
+ "@dfinity/principal": "^1.4.0",
58
+ "@junobuild/storage": "*",
59
+ "@junobuild/utils": "*"
60
60
  }
61
61
  }
@@ -1,2 +0,0 @@
1
- import{Q as a,R as b,S as c,T as d}from"./chunk-JAXPYESO.js";export{a as CustomPath,d as encodePath,c as fetchNodeKeys,b as request};
2
- //# sourceMappingURL=canisterStatus-TBLYKI2M.js.map
@@ -1,43 +0,0 @@
1
- var Ja=Object.create;var Ur=Object.defineProperty;var Qa=Object.getOwnPropertyDescriptor;var ec=Object.getOwnPropertyNames;var tc=Object.getPrototypeOf,rc=Object.prototype.hasOwnProperty;var nc=(r,e)=>()=>(r&&(e=r(r=0)),e);var Ce=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Fn=(r,e)=>{for(var t in e)Ur(r,t,{get:e[t],enumerable:!0})},Zi=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ec(e))!rc.call(r,i)&&i!==t&&Ur(r,i,{get:()=>e[i],enumerable:!(n=Qa(e,i))||n.enumerable});return r};var Rr=(r,e,t)=>(t=r!=null?Ja(tc(r)):{},Zi(e||!r||!r.__esModule?Ur(t,"default",{value:r,enumerable:!0}):t,r)),ic=r=>Zi(Ur({},"__esModule",{value:!0}),r);var Is={};Fn(Is,{Buffer:()=>M,INSPECT_MAX_BYTES:()=>us,SlowBuffer:()=>Bc,isBuffer:()=>Es,kMaxLength:()=>xc});function as(){$n=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=r.length;e<t;++e)pt[e]=r[e],tt[r.charCodeAt(e)]=e;tt[45]=62,tt[95]=63}function bc(r){$n||as();var e,t,n,i,s,o,f=r.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=r[f-2]==="="?2:r[f-1]==="="?1:0,o=new pc(f*3/4-s),n=s>0?f-4:f;var c=0;for(e=0,t=0;e<n;e+=4,t+=3)i=tt[r.charCodeAt(e)]<<18|tt[r.charCodeAt(e+1)]<<12|tt[r.charCodeAt(e+2)]<<6|tt[r.charCodeAt(e+3)],o[c++]=i>>16&255,o[c++]=i>>8&255,o[c++]=i&255;return s===2?(i=tt[r.charCodeAt(e)]<<2|tt[r.charCodeAt(e+1)]>>4,o[c++]=i&255):s===1&&(i=tt[r.charCodeAt(e)]<<10|tt[r.charCodeAt(e+1)]<<4|tt[r.charCodeAt(e+2)]>>2,o[c++]=i>>8&255,o[c++]=i&255),o}function gc(r){return pt[r>>18&63]+pt[r>>12&63]+pt[r>>6&63]+pt[r&63]}function mc(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(gc(n));return i.join("")}function is(r){$n||as();for(var e,t=r.length,n=t%3,i="",s=[],o=16383,f=0,c=t-n;f<c;f+=o)s.push(mc(r,f,f+o>c?c:f+o));return n===1?(e=r[t-1],i+=pt[e>>2],i+=pt[e<<4&63],i+="=="):n===2&&(e=(r[t-2]<<8)+r[t-1],i+=pt[e>>10],i+=pt[e>>4&63],i+=pt[e<<2&63],i+="="),s.push(i),s.join("")}function Gr(r,e,t,n,i){var s,o,f=i*8-n-1,c=(1<<f)-1,m=c>>1,E=-7,h=t?i-1:0,O=t?-1:1,B=r[e+h];for(h+=O,s=B&(1<<-E)-1,B>>=-E,E+=f;E>0;s=s*256+r[e+h],h+=O,E-=8);for(o=s&(1<<-E)-1,s>>=-E,E+=n;E>0;o=o*256+r[e+h],h+=O,E-=8);if(s===0)s=1-m;else{if(s===c)return o?NaN:(B?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-m}return(B?-1:1)*o*Math.pow(2,s-n)}function cs(r,e,t,n,i,s){var o,f,c,m=s*8-i-1,E=(1<<m)-1,h=E>>1,O=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=n?0:s-1,v=n?1:-1,A=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(f=isNaN(e)?1:0,o=E):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?e+=O/c:e+=O*Math.pow(2,1-h),e*c>=2&&(o++,c/=2),o+h>=E?(f=0,o=E):o+h>=1?(f=(e*c-1)*Math.pow(2,i),o=o+h):(f=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;r[t+B]=f&255,B+=v,f/=256,i-=8);for(o=o<<i|f,m+=i;m>0;r[t+B]=o&255,B+=v,o/=256,m-=8);r[t+B-v]|=A*128}function kr(){return M.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function wt(r,e){if(kr()<e)throw new RangeError("Invalid typed array length");return M.TYPED_ARRAY_SUPPORT?(r=new Uint8Array(e),r.__proto__=M.prototype):(r===null&&(r=new M(e)),r.length=e),r}function M(r,e,t){if(!M.TYPED_ARRAY_SUPPORT&&!(this instanceof M))return new M(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 kn(this,r)}return ls(this,r,e,t)}function ls(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?_c(r,e,t,n):typeof e=="string"?Ec(r,e,t):Ic(r,e)}function ds(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 wc(r,e,t,n){return ds(e),e<=0?wt(r,e):t!==void 0?typeof n=="string"?wt(r,e).fill(t,n):wt(r,e).fill(t):wt(r,e)}function kn(r,e){if(ds(e),r=wt(r,e<0?0:Cn(e)|0),!M.TYPED_ARRAY_SUPPORT)for(var t=0;t<e;++t)r[t]=0;return r}function Ec(r,e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!M.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var n=hs(e,t)|0;r=wt(r,n);var i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function qn(r,e){var t=e.length<0?0:Cn(e.length)|0;r=wt(r,t);for(var n=0;n<t;n+=1)r[n]=e[n]&255;return r}function _c(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),M.TYPED_ARRAY_SUPPORT?(r=e,r.__proto__=M.prototype):r=qn(r,e),r}function Ic(r,e){if(bt(e)){var t=Cn(e.length)|0;return r=wt(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"||Vc(e.length)?wt(r,0):qn(r,e);if(e.type==="Buffer"&&fs(e.data))return qn(r,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Cn(r){if(r>=kr())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kr().toString(16)+" bytes");return r|0}function Bc(r){return+r!=r&&(r=0),M.alloc(+r)}function bt(r){return!!(r!=null&&r._isBuffer)}function hs(r,e){if(bt(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 Cr(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return ws(r).length;default:if(n)return Cr(r).length;e=(""+e).toLowerCase(),n=!0}}function vc(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 Lc(this,e,t);case"utf8":case"utf-8":return gs(this,e,t);case"ascii":return Fc(this,e,t);case"latin1":case"binary":return Pc(this,e,t);case"base64":return Rc(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Mc(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}function $t(r,e,t){var n=r[e];r[e]=r[t],r[t]=n}function ps(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=M.from(e,n)),bt(e))return e.length===0?-1:ss(r,e,t,n,i);if(typeof e=="number")return e=e&255,M.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):ss(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function ss(r,e,t,n,i){var s=1,o=r.length,f=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,f/=2,t/=2}function c(B,v){return s===1?B[v]:B.readUInt16BE(v*s)}var m;if(i){var E=-1;for(m=t;m<o;m++)if(c(r,m)===c(e,E===-1?0:m-E)){if(E===-1&&(E=m),m-E+1===f)return E*s}else E!==-1&&(m-=m-E),E=-1}else for(t+f>o&&(t=o-f),m=t;m>=0;m--){for(var h=!0,O=0;O<f;O++)if(c(r,m+O)!==c(e,O)){h=!1;break}if(h)return m}return-1}function Ac(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 f=parseInt(e.substr(o*2,2),16);if(isNaN(f))return o;r[t+o]=f}return o}function Sc(r,e,t,n){return Hr(Cr(e,r.length-t),r,t,n)}function bs(r,e,t,n){return Hr(Cc(e),r,t,n)}function Tc(r,e,t,n){return bs(r,e,t,n)}function Nc(r,e,t,n){return Hr(ws(e),r,t,n)}function Uc(r,e,t,n){return Hr(Gc(e,r.length-t),r,t,n)}function Rc(r,e,t){return e===0&&t===r.length?is(r):is(r.slice(e,t))}function gs(r,e,t){t=Math.min(r.length,t);for(var n=[],i=e;i<t;){var s=r[i],o=null,f=s>239?4:s>223?3:s>191?2:1;if(i+f<=t){var c,m,E,h;switch(f){case 1:s<128&&(o=s);break;case 2:c=r[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=r[i+1],m=r[i+2],(c&192)===128&&(m&192)===128&&(h=(s&15)<<12|(c&63)<<6|m&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=r[i+1],m=r[i+2],E=r[i+3],(c&192)===128&&(m&192)===128&&(E&192)===128&&(h=(s&15)<<18|(c&63)<<12|(m&63)<<6|E&63,h>65535&&h<1114112&&(o=h))}}o===null?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=f}return Oc(n)}function Oc(r){var e=r.length;if(e<=os)return String.fromCharCode.apply(String,r);for(var t="",n=0;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=os));return t}function Fc(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 Pc(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 Lc(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+=kc(r[s]);return i}function Mc(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 Ve(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 Xe(r,e,t,n,i,s){if(!bt(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 Vr(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 Yr(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 ms(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 ys(r,e,t,n,i){return i||ms(r,e,t,4),cs(r,e,t,n,23,4),t+4}function xs(r,e,t,n,i){return i||ms(r,e,t,8),cs(r,e,t,n,52,8),t+8}function qc(r){if(r=$c(r).replace(Dc,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function $c(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function kc(r){return r<16?"0"+r.toString(16):r.toString(16)}function Cr(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 Cc(r){for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Gc(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 ws(r){return bc(qc(r))}function Hr(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 Vc(r){return r!==r}function Es(r){return r!=null&&(!!r._isBuffer||_s(r)||Yc(r))}function _s(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function Yc(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&_s(r.slice(0,0))}var pt,tt,pc,$n,yc,fs,us,xc,os,Dc,Bs=nc(()=>{pt=[],tt=[],pc=typeof Uint8Array<"u"?Uint8Array:Array,$n=!1;yc={}.toString,fs=Array.isArray||function(r){return yc.call(r)=="[object Array]"};us=50;M.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;xc=kr();M.poolSize=8192;M._augment=function(r){return r.__proto__=M.prototype,r};M.from=function(r,e,t){return ls(null,r,e,t)};M.TYPED_ARRAY_SUPPORT&&(M.prototype.__proto__=Uint8Array.prototype,M.__proto__=Uint8Array);M.alloc=function(r,e,t){return wc(null,r,e,t)};M.allocUnsafe=function(r){return kn(null,r)};M.allocUnsafeSlow=function(r){return kn(null,r)};M.isBuffer=Es;M.compare=function(e,t){if(!bt(e)||!bt(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};M.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}};M.concat=function(e,t){if(!fs(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return M.alloc(0);var n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var i=M.allocUnsafe(t),s=0;for(n=0;n<e.length;++n){var o=e[n];if(!bt(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i};M.byteLength=hs;M.prototype._isBuffer=!0;M.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)$t(this,t,t+1);return this};M.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)$t(this,t,t+3),$t(this,t+1,t+2);return this};M.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)$t(this,t,t+7),$t(this,t+1,t+6),$t(this,t+2,t+5),$t(this,t+3,t+4);return this};M.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?gs(this,0,e):vc.apply(this,arguments)};M.prototype.equals=function(e){if(!bt(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:M.compare(this,e)===0};M.prototype.inspect=function(){var e="",t=us;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"};M.prototype.compare=function(e,t,n,i,s){if(!bt(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,f=n-t,c=Math.min(o,f),m=this.slice(i,s),E=e.slice(t,n),h=0;h<c;++h)if(m[h]!==E[h]){o=m[h],f=E[h];break}return o<f?-1:f<o?1:0};M.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};M.prototype.indexOf=function(e,t,n){return ps(this,e,t,n,!0)};M.prototype.lastIndexOf=function(e,t,n){return ps(this,e,t,n,!1)};M.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 Ac(this,e,t,n);case"utf8":case"utf-8":return Sc(this,e,t,n);case"ascii":return bs(this,e,t,n);case"latin1":case"binary":return Tc(this,e,t,n);case"base64":return Nc(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Uc(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};M.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};os=4096;M.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(M.TYPED_ARRAY_SUPPORT)i=this.subarray(e,t),i.__proto__=M.prototype;else{var s=t-e;i=new M(s,void 0);for(var o=0;o<s;++o)i[o]=this[o+e]}return i};M.prototype.readUIntLE=function(e,t,n){e=e|0,t=t|0,n||Ve(e,t,this.length);for(var i=this[e],s=1,o=0;++o<t&&(s*=256);)i+=this[e+o]*s;return i};M.prototype.readUIntBE=function(e,t,n){e=e|0,t=t|0,n||Ve(e,t,this.length);for(var i=this[e+--t],s=1;t>0&&(s*=256);)i+=this[e+--t]*s;return i};M.prototype.readUInt8=function(e,t){return t||Ve(e,1,this.length),this[e]};M.prototype.readUInt16LE=function(e,t){return t||Ve(e,2,this.length),this[e]|this[e+1]<<8};M.prototype.readUInt16BE=function(e,t){return t||Ve(e,2,this.length),this[e]<<8|this[e+1]};M.prototype.readUInt32LE=function(e,t){return t||Ve(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};M.prototype.readUInt32BE=function(e,t){return t||Ve(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};M.prototype.readIntLE=function(e,t,n){e=e|0,t=t|0,n||Ve(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};M.prototype.readIntBE=function(e,t,n){e=e|0,t=t|0,n||Ve(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};M.prototype.readInt8=function(e,t){return t||Ve(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};M.prototype.readInt16LE=function(e,t){t||Ve(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};M.prototype.readInt16BE=function(e,t){t||Ve(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};M.prototype.readInt32LE=function(e,t){return t||Ve(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};M.prototype.readInt32BE=function(e,t){return t||Ve(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};M.prototype.readFloatLE=function(e,t){return t||Ve(e,4,this.length),Gr(this,e,!0,23,4)};M.prototype.readFloatBE=function(e,t){return t||Ve(e,4,this.length),Gr(this,e,!1,23,4)};M.prototype.readDoubleLE=function(e,t){return t||Ve(e,8,this.length),Gr(this,e,!0,52,8)};M.prototype.readDoubleBE=function(e,t){return t||Ve(e,8,this.length),Gr(this,e,!1,52,8)};M.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;Xe(this,e,t,n,s,0)}var o=1,f=0;for(this[t]=e&255;++f<n&&(o*=256);)this[t+f]=e/o&255;return t+n};M.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;Xe(this,e,t,n,s,0)}var o=n-1,f=1;for(this[t+o]=e&255;--o>=0&&(f*=256);)this[t+o]=e/f&255;return t+n};M.prototype.writeUInt8=function(e,t,n){return e=+e,t=t|0,n||Xe(this,e,t,1,255,0),M.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e&255,t+1};M.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t|0,n||Xe(this,e,t,2,65535,0),M.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Vr(this,e,t,!0),t+2};M.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t|0,n||Xe(this,e,t,2,65535,0),M.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Vr(this,e,t,!1),t+2};M.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t|0,n||Xe(this,e,t,4,4294967295,0),M.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255):Yr(this,e,t,!0),t+4};M.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t|0,n||Xe(this,e,t,4,4294967295,0),M.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):Yr(this,e,t,!1),t+4};M.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t|0,!i){var s=Math.pow(2,8*n-1);Xe(this,e,t,n,s-1,-s)}var o=0,f=1,c=0;for(this[t]=e&255;++o<n&&(f*=256);)e<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(e/f>>0)-c&255;return t+n};M.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t|0,!i){var s=Math.pow(2,8*n-1);Xe(this,e,t,n,s-1,-s)}var o=n-1,f=1,c=0;for(this[t+o]=e&255;--o>=0&&(f*=256);)e<0&&c===0&&this[t+o+1]!==0&&(c=1),this[t+o]=(e/f>>0)-c&255;return t+n};M.prototype.writeInt8=function(e,t,n){return e=+e,t=t|0,n||Xe(this,e,t,1,127,-128),M.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=e&255,t+1};M.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t|0,n||Xe(this,e,t,2,32767,-32768),M.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Vr(this,e,t,!0),t+2};M.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t|0,n||Xe(this,e,t,2,32767,-32768),M.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Vr(this,e,t,!1),t+2};M.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t|0,n||Xe(this,e,t,4,2147483647,-2147483648),M.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Yr(this,e,t,!0),t+4};M.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t|0,n||Xe(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),M.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):Yr(this,e,t,!1),t+4};M.prototype.writeFloatLE=function(e,t,n){return ys(this,e,t,!0,n)};M.prototype.writeFloatBE=function(e,t,n){return ys(this,e,t,!1,n)};M.prototype.writeDoubleLE=function(e,t,n){return xs(this,e,t,!0,n)};M.prototype.writeDoubleBE=function(e,t,n){return xs(this,e,t,!1,n)};M.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||!M.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};M.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"&&!M.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 f=bt(e)?e:Cr(new M(e,i).toString()),c=f.length;for(o=0;o<n-t;++o)this[o+t]=f[o%c]}return this};Dc=/[^+\/0-9A-Za-z-_]/g});var fr=Ce((g0,zr)=>{var kt=(Bs(),ic(Is));if(kt&&kt.default){zr.exports=kt.default;for(let r in kt)zr.exports[r]=kt[r]}else kt&&(zr.exports=kt)});var vs=Ce(Gn=>{Gn.read=function(r,e,t,n,i){var s,o,f=i*8-n-1,c=(1<<f)-1,m=c>>1,E=-7,h=t?i-1:0,O=t?-1:1,B=r[e+h];for(h+=O,s=B&(1<<-E)-1,B>>=-E,E+=f;E>0;s=s*256+r[e+h],h+=O,E-=8);for(o=s&(1<<-E)-1,s>>=-E,E+=n;E>0;o=o*256+r[e+h],h+=O,E-=8);if(s===0)s=1-m;else{if(s===c)return o?NaN:(B?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-m}return(B?-1:1)*o*Math.pow(2,s-n)};Gn.write=function(r,e,t,n,i,s){var o,f,c,m=s*8-i-1,E=(1<<m)-1,h=E>>1,O=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=n?0:s-1,v=n?1:-1,A=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(f=isNaN(e)?1:0,o=E):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?e+=O/c:e+=O*Math.pow(2,1-h),e*c>=2&&(o++,c/=2),o+h>=E?(f=0,o=E):o+h>=1?(f=(e*c-1)*Math.pow(2,i),o=o+h):(f=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;r[t+B]=f&255,B+=v,f/=256,i-=8);for(o=o<<i|f,m+=i;m>0;r[t+B]=o&255,B+=v,o/=256,m-=8);r[t+B-v]|=A*128}});var ur=Ce((As,Zr)=>{(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: ",f=1e14,c=14,m=9007199254740991,E=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,O=1e9;function B(q){var F,C,Y,$=R.prototype={constructor:R,toString:null,valueOf:null},J=new R(1),Z=20,te=4,ce=-7,me=21,ue=-1e7,k=1e7,ee=!1,Q=1,re=0,fe={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ge="0123456789abcdefghijklmnopqrstuvwxyz",Ie=!0;function R(a,u){var l,_,y,w,T,p,x,S,I=this;if(!(I instanceof R))return new R(a,u);if(u==null){if(a&&a._isBigNumber===!0){I.s=a.s,!a.c||a.e>k?I.c=I.e=null:a.e<ue?I.c=[I.e=0]:(I.e=a.e,I.c=a.c.slice());return}if((p=typeof a=="number")&&a*0==0){if(I.s=1/a<0?(a=-a,-1):1,a===~~a){for(w=0,T=a;T>=10;T/=10,w++);w>k?I.c=I.e=null:(I.e=w,I.c=[a]);return}S=String(a)}else{if(!t.test(S=String(a)))return Y(I,S,p);I.s=S.charCodeAt(0)==45?(S=S.slice(1),-1):1}(w=S.indexOf("."))>-1&&(S=S.replace(".","")),(T=S.search(/e/i))>0?(w<0&&(w=T),w+=+S.slice(T+1),S=S.substring(0,T)):w<0&&(w=S.length)}else{if(N(u,2,ge.length,"Base"),u==10&&Ie)return I=new R(a),ye(I,Z+I.e+1,te);if(S=String(a),p=typeof a=="number"){if(a*0!=0)return Y(I,S,p,u);if(I.s=1/a<0?(S=S.slice(1),-1):1,R.DEBUG&&S.replace(/^0\.0*|\./,"").length>15)throw Error(o+a)}else I.s=S.charCodeAt(0)===45?(S=S.slice(1),-1):1;for(l=ge.slice(0,u),w=T=0,x=S.length;T<x;T++)if(l.indexOf(_=S.charAt(T))<0){if(_=="."){if(T>w){w=x;continue}}else if(!y&&(S==S.toUpperCase()&&(S=S.toLowerCase())||S==S.toLowerCase()&&(S=S.toUpperCase()))){y=!0,T=-1,w=0;continue}return Y(I,String(a),p,u)}p=!1,S=C(S,u,10,I.s),(w=S.indexOf("."))>-1?S=S.replace(".",""):w=S.length}for(T=0;S.charCodeAt(T)===48;T++);for(x=S.length;S.charCodeAt(--x)===48;);if(S=S.slice(T,++x)){if(x-=T,p&&R.DEBUG&&x>15&&(a>m||a!==i(a)))throw Error(o+I.s*a);if((w=w-T-1)>k)I.c=I.e=null;else if(w<ue)I.c=[I.e=0];else{if(I.e=w,I.c=[],T=(w+1)%c,w<0&&(T+=c),T<x){for(T&&I.c.push(+S.slice(0,T)),x-=c;T<x;)I.c.push(+S.slice(T,T+=c));T=c-(S=S.slice(T)).length}else T-=x;for(;T--;S+="0");I.c.push(+S)}}else I.c=[I.e=0]}R.clone=B,R.ROUND_UP=0,R.ROUND_DOWN=1,R.ROUND_CEIL=2,R.ROUND_FLOOR=3,R.ROUND_HALF_UP=4,R.ROUND_HALF_DOWN=5,R.ROUND_HALF_EVEN=6,R.ROUND_HALF_CEIL=7,R.ROUND_HALF_FLOOR=8,R.EUCLID=9,R.config=R.set=function(a){var u,l;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(u="DECIMAL_PLACES")&&(l=a[u],N(l,0,O,u),Z=l),a.hasOwnProperty(u="ROUNDING_MODE")&&(l=a[u],N(l,0,8,u),te=l),a.hasOwnProperty(u="EXPONENTIAL_AT")&&(l=a[u],l&&l.pop?(N(l[0],-O,0,u),N(l[1],0,O,u),ce=l[0],me=l[1]):(N(l,-O,O,u),ce=-(me=l<0?-l:l))),a.hasOwnProperty(u="RANGE"))if(l=a[u],l&&l.pop)N(l[0],-O,-1,u),N(l[1],1,O,u),ue=l[0],k=l[1];else if(N(l,-O,O,u),l)ue=-(k=l<0?-l:l);else throw Error(s+u+" cannot be zero: "+l);if(a.hasOwnProperty(u="CRYPTO"))if(l=a[u],l===!!l)if(l)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))ee=l;else throw ee=!l,Error(s+"crypto unavailable");else ee=l;else throw Error(s+u+" not true or false: "+l);if(a.hasOwnProperty(u="MODULO_MODE")&&(l=a[u],N(l,0,9,u),Q=l),a.hasOwnProperty(u="POW_PRECISION")&&(l=a[u],N(l,0,O,u),re=l),a.hasOwnProperty(u="FORMAT"))if(l=a[u],typeof l=="object")fe=l;else throw Error(s+u+" not an object: "+l);if(a.hasOwnProperty(u="ALPHABET"))if(l=a[u],typeof l=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(l))Ie=l.slice(0,10)=="0123456789",ge=l;else throw Error(s+u+" invalid: "+l)}else throw Error(s+"Object expected: "+a);return{DECIMAL_PLACES:Z,ROUNDING_MODE:te,EXPONENTIAL_AT:[ce,me],RANGE:[ue,k],CRYPTO:ee,MODULO_MODE:Q,POW_PRECISION:re,FORMAT:fe,ALPHABET:ge}},R.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!R.DEBUG)return!0;var u,l,_=a.c,y=a.e,w=a.s;e:if({}.toString.call(_)=="[object Array]"){if((w===1||w===-1)&&y>=-O&&y<=O&&y===i(y)){if(_[0]===0){if(y===0&&_.length===1)return!0;break e}if(u=(y+1)%c,u<1&&(u+=c),String(_[0]).length==u){for(u=0;u<_.length;u++)if(l=_[u],l<0||l>=f||l!==i(l))break e;if(l!==0)return!0}}}else if(_===null&&y===null&&(w===null||w===1||w===-1))return!0;throw Error(s+"Invalid BigNumber: "+a)},R.maximum=R.max=function(){return Ue(arguments,-1)},R.minimum=R.min=function(){return Ue(arguments,1)},R.random=function(){var a=9007199254740992,u=Math.random()*a&2097151?function(){return i(Math.random()*a)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(l){var _,y,w,T,p,x=0,S=[],I=new R(J);if(l==null?l=Z:N(l,0,O),T=n(l/c),ee)if(crypto.getRandomValues){for(_=crypto.getRandomValues(new Uint32Array(T*=2));x<T;)p=_[x]*131072+(_[x+1]>>>11),p>=9e15?(y=crypto.getRandomValues(new Uint32Array(2)),_[x]=y[0],_[x+1]=y[1]):(S.push(p%1e14),x+=2);x=T/2}else if(crypto.randomBytes){for(_=crypto.randomBytes(T*=7);x<T;)p=(_[x]&31)*281474976710656+_[x+1]*1099511627776+_[x+2]*4294967296+_[x+3]*16777216+(_[x+4]<<16)+(_[x+5]<<8)+_[x+6],p>=9e15?crypto.randomBytes(7).copy(_,x):(S.push(p%1e14),x+=7);x=T/7}else throw ee=!1,Error(s+"crypto unavailable");if(!ee)for(;x<T;)p=u(),p<9e15&&(S[x++]=p%1e14);for(T=S[--x],l%=c,T&&l&&(p=E[c-l],S[x]=i(T/p)*p);S[x]===0;S.pop(),x--);if(x<0)S=[w=0];else{for(w=-1;S[0]===0;S.splice(0,1),w-=c);for(x=1,p=S[0];p>=10;p/=10,x++);x<c&&(w-=c-x)}return I.e=w,I.c=S,I}}(),R.sum=function(){for(var a=1,u=arguments,l=new R(u[0]);a<u.length;)l=l.plus(u[a++]);return l},C=function(){var a="0123456789";function u(l,_,y,w){for(var T,p=[0],x,S=0,I=l.length;S<I;){for(x=p.length;x--;p[x]*=_);for(p[0]+=w.indexOf(l.charAt(S++)),T=0;T<p.length;T++)p[T]>y-1&&(p[T+1]==null&&(p[T+1]=0),p[T+1]+=p[T]/y|0,p[T]%=y)}return p.reverse()}return function(l,_,y,w,T){var p,x,S,I,L,G,K,oe,xe=l.indexOf("."),Se=Z,ie=te;for(xe>=0&&(I=re,re=0,l=l.replace(".",""),oe=new R(_),G=oe.pow(l.length-xe),re=I,oe.c=u(z(A(G.c),G.e,"0"),10,y,a),oe.e=oe.c.length),K=u(l,_,y,T?(p=ge,a):(p=a,ge)),S=I=K.length;K[--I]==0;K.pop());if(!K[0])return p.charAt(0);if(xe<0?--S:(G.c=K,G.e=S,G.s=w,G=F(G,oe,Se,ie,y),K=G.c,L=G.r,S=G.e),x=S+Se+1,xe=K[x],I=y/2,L=L||x<0||K[x+1]!=null,L=ie<4?(xe!=null||L)&&(ie==0||ie==(G.s<0?3:2)):xe>I||xe==I&&(ie==4||L||ie==6&&K[x-1]&1||ie==(G.s<0?8:7)),x<1||!K[0])l=L?z(p.charAt(1),-Se,p.charAt(0)):p.charAt(0);else{if(K.length=x,L)for(--y;++K[--x]>y;)K[x]=0,x||(++S,K=[1].concat(K));for(I=K.length;!K[--I];);for(xe=0,l="";xe<=I;l+=p.charAt(K[xe++]));l=z(l,S,p.charAt(0))}return l}}(),F=function(){function a(_,y,w){var T,p,x,S,I=0,L=_.length,G=y%h,K=y/h|0;for(_=_.slice();L--;)x=_[L]%h,S=_[L]/h|0,T=K*x+S*G,p=G*x+T%h*h+I,I=(p/w|0)+(T/h|0)+K*S,_[L]=p%w;return I&&(_=[I].concat(_)),_}function u(_,y,w,T){var p,x;if(w!=T)x=w>T?1:-1;else for(p=x=0;p<w;p++)if(_[p]!=y[p]){x=_[p]>y[p]?1:-1;break}return x}function l(_,y,w,T){for(var p=0;w--;)_[w]-=p,p=_[w]<y[w]?1:0,_[w]=p*T+_[w]-y[w];for(;!_[0]&&_.length>1;_.splice(0,1));}return function(_,y,w,T,p){var x,S,I,L,G,K,oe,xe,Se,ie,W,$e,zt,sr,or,et,le,We=_.s==y.s?1:-1,ze=_.c,we=y.c;if(!ze||!ze[0]||!we||!we[0])return new R(!_.s||!y.s||(ze?we&&ze[0]==we[0]:!we)?NaN:ze&&ze[0]==0||!we?We*0:We/0);for(xe=new R(We),Se=xe.c=[],S=_.e-y.e,We=w+S+1,p||(p=f,S=v(_.e/c)-v(y.e/c),We=We/c|0),I=0;we[I]==(ze[I]||0);I++);if(we[I]>(ze[I]||0)&&S--,We<0)Se.push(1),L=!0;else{for(sr=ze.length,et=we.length,I=0,We+=2,G=i(p/(we[0]+1)),G>1&&(we=a(we,G,p),ze=a(ze,G,p),et=we.length,sr=ze.length),zt=et,ie=ze.slice(0,et),W=ie.length;W<et;ie[W++]=0);le=we.slice(),le=[0].concat(le),or=we[0],we[1]>=p/2&&or++;do{if(G=0,x=u(we,ie,et,W),x<0){if($e=ie[0],et!=W&&($e=$e*p+(ie[1]||0)),G=i($e/or),G>1)for(G>=p&&(G=p-1),K=a(we,G,p),oe=K.length,W=ie.length;u(K,ie,oe,W)==1;)G--,l(K,et<oe?le:we,oe,p),oe=K.length,x=1;else G==0&&(x=G=1),K=we.slice(),oe=K.length;if(oe<W&&(K=[0].concat(K)),l(ie,K,W,p),W=ie.length,x==-1)for(;u(we,ie,et,W)<1;)G++,l(ie,et<W?le:we,W,p),W=ie.length}else x===0&&(G++,ie=[0]);Se[I++]=G,ie[0]?ie[W++]=ze[zt]||0:(ie=[ze[zt]],W=1)}while((zt++<sr||ie[0]!=null)&&We--);L=ie[0]!=null,Se[0]||Se.splice(0,1)}if(p==f){for(I=1,We=Se[0];We>=10;We/=10,I++);ye(xe,w+(xe.e=I+S*c-1)+1,T,L)}else xe.e=S,xe.r=+L;return xe}}();function g(a,u,l,_){var y,w,T,p,x;if(l==null?l=te:N(l,0,8),!a.c)return a.toString();if(y=a.c[0],T=a.e,u==null)x=A(a.c),x=_==1||_==2&&(T<=ce||T>=me)?H(x,T):z(x,T,"0");else if(a=ye(new R(a),u,l),w=a.e,x=A(a.c),p=x.length,_==1||_==2&&(u<=w||w<=ce)){for(;p<u;x+="0",p++);x=H(x,w)}else if(u-=T,x=z(x,w,"0"),w+1>p){if(--u>0)for(x+=".";u--;x+="0");}else if(u+=w-p,u>0)for(w+1==p&&(x+=".");u--;x+="0");return a.s<0&&y?"-"+x:x}function Ue(a,u){for(var l,_,y=1,w=new R(a[0]);y<a.length;y++)_=new R(a[y]),(!_.s||(l=P(w,_))===u||l===0&&w.s===u)&&(w=_);return w}function Re(a,u,l){for(var _=1,y=u.length;!u[--y];u.pop());for(y=u[0];y>=10;y/=10,_++);return(l=_+l*c-1)>k?a.c=a.e=null:l<ue?a.c=[a.e=0]:(a.e=l,a.c=u),a}Y=function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,u=/^([^.]+)\.$/,l=/^\.([^.]+)$/,_=/^-?(Infinity|NaN)$/,y=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(w,T,p,x){var S,I=p?T:T.replace(y,"");if(_.test(I))w.s=isNaN(I)?null:I<0?-1:1;else{if(!p&&(I=I.replace(a,function(L,G,K){return S=(K=K.toLowerCase())=="x"?16:K=="b"?2:8,!x||x==S?G:L}),x&&(S=x,I=I.replace(u,"$1").replace(l,"0.$1")),T!=I))return new R(I,S);if(R.DEBUG)throw Error(s+"Not a"+(x?" base "+x:"")+" number: "+T);w.s=null}w.c=w.e=null}}();function ye(a,u,l,_){var y,w,T,p,x,S,I,L=a.c,G=E;if(L){e:{for(y=1,p=L[0];p>=10;p/=10,y++);if(w=u-y,w<0)w+=c,T=u,x=L[S=0],I=i(x/G[y-T-1]%10);else if(S=n((w+1)/c),S>=L.length)if(_){for(;L.length<=S;L.push(0));x=I=0,y=1,w%=c,T=w-c+1}else break e;else{for(x=p=L[S],y=1;p>=10;p/=10,y++);w%=c,T=w-c+y,I=T<0?0:i(x/G[y-T-1]%10)}if(_=_||u<0||L[S+1]!=null||(T<0?x:x%G[y-T-1]),_=l<4?(I||_)&&(l==0||l==(a.s<0?3:2)):I>5||I==5&&(l==4||_||l==6&&(w>0?T>0?x/G[y-T]:0:L[S-1])%10&1||l==(a.s<0?8:7)),u<1||!L[0])return L.length=0,_?(u-=a.e+1,L[0]=G[(c-u%c)%c],a.e=-u||0):L[0]=a.e=0,a;if(w==0?(L.length=S,p=1,S--):(L.length=S+1,p=G[c-w],L[S]=T>0?i(x/G[y-T]%G[T])*p:0),_)for(;;)if(S==0){for(w=1,T=L[0];T>=10;T/=10,w++);for(T=L[0]+=p,p=1;T>=10;T/=10,p++);w!=p&&(a.e++,L[0]==f&&(L[0]=1));break}else{if(L[S]+=p,L[S]!=f)break;L[S--]=0,p=1}for(w=L.length;L[--w]===0;L.pop());}a.e>k?a.c=a.e=null:a.e<ue&&(a.c=[a.e=0])}return a}function j(a){var u,l=a.e;return l===null?a.toString():(u=A(a.c),u=l<=ce||l>=me?H(u,l):z(u,l,"0"),a.s<0?"-"+u:u)}return $.absoluteValue=$.abs=function(){var a=new R(this);return a.s<0&&(a.s=1),a},$.comparedTo=function(a,u){return P(this,new R(a,u))},$.decimalPlaces=$.dp=function(a,u){var l,_,y,w=this;if(a!=null)return N(a,0,O),u==null?u=te:N(u,0,8),ye(new R(w),a+w.e+1,u);if(!(l=w.c))return null;if(_=((y=l.length-1)-v(this.e/c))*c,y=l[y])for(;y%10==0;y/=10,_--);return _<0&&(_=0),_},$.dividedBy=$.div=function(a,u){return F(this,new R(a,u),Z,te)},$.dividedToIntegerBy=$.idiv=function(a,u){return F(this,new R(a,u),0,1)},$.exponentiatedBy=$.pow=function(a,u){var l,_,y,w,T,p,x,S,I,L=this;if(a=new R(a),a.c&&!a.isInteger())throw Error(s+"Exponent not an integer: "+j(a));if(u!=null&&(u=new R(u)),p=a.e>14,!L.c||!L.c[0]||L.c[0]==1&&!L.e&&L.c.length==1||!a.c||!a.c[0])return I=new R(Math.pow(+j(L),p?a.s*(2-D(a)):+j(a))),u?I.mod(u):I;if(x=a.s<0,u){if(u.c?!u.c[0]:!u.s)return new R(NaN);_=!x&&L.isInteger()&&u.isInteger(),_&&(L=L.mod(u))}else{if(a.e>9&&(L.e>0||L.e<-1||(L.e==0?L.c[0]>1||p&&L.c[1]>=24e7:L.c[0]<8e13||p&&L.c[0]<=9999975e7)))return w=L.s<0&&D(a)?-0:0,L.e>-1&&(w=1/w),new R(x?1/w:w);re&&(w=n(re/c+2))}for(p?(l=new R(.5),x&&(a.s=1),S=D(a)):(y=Math.abs(+j(a)),S=y%2),I=new R(J);;){if(S){if(I=I.times(L),!I.c)break;w?I.c.length>w&&(I.c.length=w):_&&(I=I.mod(u))}if(y){if(y=i(y/2),y===0)break;S=y%2}else if(a=a.times(l),ye(a,a.e+1,1),a.e>14)S=D(a);else{if(y=+j(a),y===0)break;S=y%2}L=L.times(L),w?L.c&&L.c.length>w&&(L.c.length=w):_&&(L=L.mod(u))}return _?I:(x&&(I=J.div(I)),u?I.mod(u):w?ye(I,re,te,T):I)},$.integerValue=function(a){var u=new R(this);return a==null?a=te:N(a,0,8),ye(u,u.e+1,a)},$.isEqualTo=$.eq=function(a,u){return P(this,new R(a,u))===0},$.isFinite=function(){return!!this.c},$.isGreaterThan=$.gt=function(a,u){return P(this,new R(a,u))>0},$.isGreaterThanOrEqualTo=$.gte=function(a,u){return(u=P(this,new R(a,u)))===1||u===0},$.isInteger=function(){return!!this.c&&v(this.e/c)>this.c.length-2},$.isLessThan=$.lt=function(a,u){return P(this,new R(a,u))<0},$.isLessThanOrEqualTo=$.lte=function(a,u){return(u=P(this,new R(a,u)))===-1||u===0},$.isNaN=function(){return!this.s},$.isNegative=function(){return this.s<0},$.isPositive=function(){return this.s>0},$.isZero=function(){return!!this.c&&this.c[0]==0},$.minus=function(a,u){var l,_,y,w,T=this,p=T.s;if(a=new R(a,u),u=a.s,!p||!u)return new R(NaN);if(p!=u)return a.s=-u,T.plus(a);var x=T.e/c,S=a.e/c,I=T.c,L=a.c;if(!x||!S){if(!I||!L)return I?(a.s=-u,a):new R(L?T:NaN);if(!I[0]||!L[0])return L[0]?(a.s=-u,a):new R(I[0]?T:te==3?-0:0)}if(x=v(x),S=v(S),I=I.slice(),p=x-S){for((w=p<0)?(p=-p,y=I):(S=x,y=L),y.reverse(),u=p;u--;y.push(0));y.reverse()}else for(_=(w=(p=I.length)<(u=L.length))?p:u,p=u=0;u<_;u++)if(I[u]!=L[u]){w=I[u]<L[u];break}if(w&&(y=I,I=L,L=y,a.s=-a.s),u=(_=L.length)-(l=I.length),u>0)for(;u--;I[l++]=0);for(u=f-1;_>p;){if(I[--_]<L[_]){for(l=_;l&&!I[--l];I[l]=u);--I[l],I[_]+=f}I[_]-=L[_]}for(;I[0]==0;I.splice(0,1),--S);return I[0]?Re(a,I,S):(a.s=te==3?-1:1,a.c=[a.e=0],a)},$.modulo=$.mod=function(a,u){var l,_,y=this;return a=new R(a,u),!y.c||!a.s||a.c&&!a.c[0]?new R(NaN):!a.c||y.c&&!y.c[0]?new R(y):(Q==9?(_=a.s,a.s=1,l=F(y,a,0,3),a.s=_,l.s*=_):l=F(y,a,0,Q),a=y.minus(l.times(a)),!a.c[0]&&Q==1&&(a.s=y.s),a)},$.multipliedBy=$.times=function(a,u){var l,_,y,w,T,p,x,S,I,L,G,K,oe,xe,Se,ie=this,W=ie.c,$e=(a=new R(a,u)).c;if(!W||!$e||!W[0]||!$e[0])return!ie.s||!a.s||W&&!W[0]&&!$e||$e&&!$e[0]&&!W?a.c=a.e=a.s=null:(a.s*=ie.s,!W||!$e?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(_=v(ie.e/c)+v(a.e/c),a.s*=ie.s,x=W.length,L=$e.length,x<L&&(oe=W,W=$e,$e=oe,y=x,x=L,L=y),y=x+L,oe=[];y--;oe.push(0));for(xe=f,Se=h,y=L;--y>=0;){for(l=0,G=$e[y]%Se,K=$e[y]/Se|0,T=x,w=y+T;w>y;)S=W[--T]%Se,I=W[T]/Se|0,p=K*S+I*G,S=G*S+p%Se*Se+oe[w]+l,l=(S/xe|0)+(p/Se|0)+K*I,oe[w--]=S%xe;oe[w]=l}return l?++_:oe.splice(0,1),Re(a,oe,_)},$.negated=function(){var a=new R(this);return a.s=-a.s||null,a},$.plus=function(a,u){var l,_=this,y=_.s;if(a=new R(a,u),u=a.s,!y||!u)return new R(NaN);if(y!=u)return a.s=-u,_.minus(a);var w=_.e/c,T=a.e/c,p=_.c,x=a.c;if(!w||!T){if(!p||!x)return new R(y/0);if(!p[0]||!x[0])return x[0]?a:new R(p[0]?_:y*0)}if(w=v(w),T=v(T),p=p.slice(),y=w-T){for(y>0?(T=w,l=x):(y=-y,l=p),l.reverse();y--;l.push(0));l.reverse()}for(y=p.length,u=x.length,y-u<0&&(l=x,x=p,p=l,u=y),y=0;u;)y=(p[--u]=p[u]+x[u]+y)/f|0,p[u]=f===p[u]?0:p[u]%f;return y&&(p=[y].concat(p),++T),Re(a,p,T)},$.precision=$.sd=function(a,u){var l,_,y,w=this;if(a!=null&&a!==!!a)return N(a,1,O),u==null?u=te:N(u,0,8),ye(new R(w),a,u);if(!(l=w.c))return null;if(y=l.length-1,_=y*c+1,y=l[y]){for(;y%10==0;y/=10,_--);for(y=l[0];y>=10;y/=10,_++);}return a&&w.e+1>_&&(_=w.e+1),_},$.shiftedBy=function(a){return N(a,-m,m),this.times("1e"+a)},$.squareRoot=$.sqrt=function(){var a,u,l,_,y,w=this,T=w.c,p=w.s,x=w.e,S=Z+4,I=new R("0.5");if(p!==1||!T||!T[0])return new R(!p||p<0&&(!T||T[0])?NaN:T?w:1/0);if(p=Math.sqrt(+j(w)),p==0||p==1/0?(u=A(T),(u.length+x)%2==0&&(u+="0"),p=Math.sqrt(+u),x=v((x+1)/2)-(x<0||x%2),p==1/0?u="5e"+x:(u=p.toExponential(),u=u.slice(0,u.indexOf("e")+1)+x),l=new R(u)):l=new R(p+""),l.c[0]){for(x=l.e,p=x+S,p<3&&(p=0);;)if(y=l,l=I.times(y.plus(F(w,y,S,1))),A(y.c).slice(0,p)===(u=A(l.c)).slice(0,p))if(l.e<x&&--p,u=u.slice(p-3,p+1),u=="9999"||!_&&u=="4999"){if(!_&&(ye(y,y.e+Z+2,0),y.times(y).eq(w))){l=y;break}S+=4,p+=4,_=1}else{(!+u||!+u.slice(1)&&u.charAt(0)=="5")&&(ye(l,l.e+Z+2,1),a=!l.times(l).eq(w));break}}return ye(l,l.e+Z+1,te,a)},$.toExponential=function(a,u){return a!=null&&(N(a,0,O),a++),g(this,a,u,1)},$.toFixed=function(a,u){return a!=null&&(N(a,0,O),a=a+this.e+1),g(this,a,u)},$.toFormat=function(a,u,l){var _,y=this;if(l==null)a!=null&&u&&typeof u=="object"?(l=u,u=null):a&&typeof a=="object"?(l=a,a=u=null):l=fe;else if(typeof l!="object")throw Error(s+"Argument not an object: "+l);if(_=y.toFixed(a,u),y.c){var w,T=_.split("."),p=+l.groupSize,x=+l.secondaryGroupSize,S=l.groupSeparator||"",I=T[0],L=T[1],G=y.s<0,K=G?I.slice(1):I,oe=K.length;if(x&&(w=p,p=x,x=w,oe-=w),p>0&&oe>0){for(w=oe%p||p,I=K.substr(0,w);w<oe;w+=p)I+=S+K.substr(w,p);x>0&&(I+=S+K.slice(w)),G&&(I="-"+I)}_=L?I+(l.decimalSeparator||"")+((x=+l.fractionGroupSize)?L.replace(new RegExp("\\d{"+x+"}\\B","g"),"$&"+(l.fractionGroupSeparator||"")):L):I}return(l.prefix||"")+_+(l.suffix||"")},$.toFraction=function(a){var u,l,_,y,w,T,p,x,S,I,L,G,K=this,oe=K.c;if(a!=null&&(p=new R(a),!p.isInteger()&&(p.c||p.s!==1)||p.lt(J)))throw Error(s+"Argument "+(p.isInteger()?"out of range: ":"not an integer: ")+j(p));if(!oe)return new R(K);for(u=new R(J),S=l=new R(J),_=x=new R(J),G=A(oe),w=u.e=G.length-K.e-1,u.c[0]=E[(T=w%c)<0?c+T:T],a=!a||p.comparedTo(u)>0?w>0?u:S:p,T=k,k=1/0,p=new R(G),x.c[0]=0;I=F(p,u,0,1),y=l.plus(I.times(_)),y.comparedTo(a)!=1;)l=_,_=y,S=x.plus(I.times(y=S)),x=y,u=p.minus(I.times(y=u)),p=y;return y=F(a.minus(l),_,0,1),x=x.plus(y.times(S)),l=l.plus(y.times(_)),x.s=S.s=K.s,w=w*2,L=F(S,_,w,te).minus(K).abs().comparedTo(F(x,l,w,te).minus(K).abs())<1?[S,_]:[x,l],k=T,L},$.toNumber=function(){return+j(this)},$.toPrecision=function(a,u){return a!=null&&N(a,1,O),g(this,a,u,2)},$.toString=function(a){var u,l=this,_=l.s,y=l.e;return y===null?_?(u="Infinity",_<0&&(u="-"+u)):u="NaN":(a==null?u=y<=ce||y>=me?H(A(l.c),y):z(A(l.c),y,"0"):a===10&&Ie?(l=ye(new R(l),Z+y+1,te),u=z(A(l.c),l.e,"0")):(N(a,2,ge.length,"Base"),u=C(z(A(l.c),y,"0"),10,a,_,!0)),_<0&&l.c[0]&&(u="-"+u)),u},$.valueOf=$.toJSON=function(){return j(this)},$._isBigNumber=!0,q!=null&&R.set(q),R}function v(q){var F=q|0;return q>0||q===F?F:F-1}function A(q){for(var F,C,Y=1,$=q.length,J=q[0]+"";Y<$;){for(F=q[Y++]+"",C=c-F.length;C--;F="0"+F);J+=F}for($=J.length;J.charCodeAt(--$)===48;);return J.slice(0,$+1||1)}function P(q,F){var C,Y,$=q.c,J=F.c,Z=q.s,te=F.s,ce=q.e,me=F.e;if(!Z||!te)return null;if(C=$&&!$[0],Y=J&&!J[0],C||Y)return C?Y?0:-te:Z;if(Z!=te)return Z;if(C=Z<0,Y=ce==me,!$||!J)return Y?0:!$^C?1:-1;if(!Y)return ce>me^C?1:-1;for(te=(ce=$.length)<(me=J.length)?ce:me,Z=0;Z<te;Z++)if($[Z]!=J[Z])return $[Z]>J[Z]^C?1:-1;return ce==me?0:ce>me^C?1:-1}function N(q,F,C,Y){if(q<F||q>C||q!==i(q))throw Error(s+(Y||"Argument")+(typeof q=="number"?q<F||q>C?" out of range: ":" not an integer: ":" not a primitive number: ")+String(q))}function D(q){var F=q.c.length-1;return v(q.e/c)==F&&q.c[F]%2!=0}function H(q,F){return(q.length>1?q.charAt(0)+"."+q.slice(1):q)+(F<0?"e":"e+")+F}function z(q,F,C){var Y,$;if(F<0){for($=C+".";++F;$+=C);q=$+q}else if(Y=q.length,++F>Y){for($=C,F-=Y;--F;$+=C);q+=$}else F<Y&&(q=q.slice(0,F)+"."+q.slice(F));return q}e=B(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof Zr<"u"&&Zr.exports?Zr.exports=e:(r||(r=typeof self<"u"&&self?self:window),r.BigNumber=e)})(As)});var Ts=Ce((y0,Ss)=>{Ss.exports=function(e,t,n){var i=new e.Uint8Array(n),s=t.pushInt,o=t.pushInt32,f=t.pushInt32Neg,c=t.pushInt64,m=t.pushInt64Neg,E=t.pushFloat,h=t.pushFloatSingle,O=t.pushFloatDouble,B=t.pushTrue,v=t.pushFalse,A=t.pushUndefined,P=t.pushNull,N=t.pushInfinity,D=t.pushInfinityNeg,H=t.pushNaN,z=t.pushNaNNeg,q=t.pushArrayStart,F=t.pushArrayStartFixed,C=t.pushArrayStartFixed32,Y=t.pushArrayStartFixed64,$=t.pushObjectStart,J=t.pushObjectStartFixed,Z=t.pushObjectStartFixed32,te=t.pushObjectStartFixed64,ce=t.pushByteString,me=t.pushByteStringStart,ue=t.pushUtf8String,k=t.pushUtf8StringStart,ee=t.pushSimpleUnassigned,Q=t.pushTagStart,re=t.pushTagStart4,fe=t.pushTagStart8,ge=t.pushTagUnassigned,Ie=t.pushBreak,R=e.Math.pow,g=0,Ue=0,Re=0;function ye(b){for(b=b|0,g=0,Ue=b;(g|0)<(Ue|0)&&(Re=Xa[i[g]&255](i[g]|0)|0,!((Re|0)>0)););return Re|0}function j(b){return b=b|0,((g|0)+(b|0)|0)<(Ue|0)?0:1}function a(b){return b=b|0,i[b|0]<<8|i[b+1|0]|0}function u(b){return b=b|0,i[b|0]<<24|i[b+1|0]<<16|i[b+2|0]<<8|i[b+3|0]|0}function l(b){return b=b|0,s(b|0),g=g+1|0,0}function _(b){return b=b|0,j(1)|0?1:(s(i[g+1|0]|0),g=g+2|0,0)}function y(b){return b=b|0,j(2)|0?1:(s(a(g+1|0)|0),g=g+3|0,0)}function w(b){return b=b|0,j(4)|0?1:(o(a(g+1|0)|0,a(g+3|0)|0),g=g+5|0,0)}function T(b){return b=b|0,j(8)|0?1:(c(a(g+1|0)|0,a(g+3|0)|0,a(g+5|0)|0,a(g+7|0)|0),g=g+9|0,0)}function p(b){return b=b|0,s(-1-(b-32|0)|0),g=g+1|0,0}function x(b){return b=b|0,j(1)|0?1:(s(-1-(i[g+1|0]|0)|0),g=g+2|0,0)}function S(b){b=b|0;var se=0;return j(2)|0?1:(se=a(g+1|0)|0,s(-1-(se|0)|0),g=g+3|0,0)}function I(b){return b=b|0,j(4)|0?1:(f(a(g+1|0)|0,a(g+3|0)|0),g=g+5|0,0)}function L(b){return b=b|0,j(8)|0?1:(m(a(g+1|0)|0,a(g+3|0)|0,a(g+5|0)|0,a(g+7|0)|0),g=g+9|0,0)}function G(b){b=b|0;var se=0,ae=0,ne=0;return ne=b-64|0,j(ne|0)|0?1:(se=g+1|0,ae=(g+1|0)+(ne|0)|0,ce(se|0,ae|0),g=ae|0,0)}function K(b){b=b|0;var se=0,ae=0,ne=0;return j(1)|0||(ne=i[g+1|0]|0,se=g+2|0,ae=(g+2|0)+(ne|0)|0,j(ne+1|0)|0)?1:(ce(se|0,ae|0),g=ae|0,0)}function oe(b){b=b|0;var se=0,ae=0,ne=0;return j(2)|0||(ne=a(g+1|0)|0,se=g+3|0,ae=(g+3|0)+(ne|0)|0,j(ne+2|0)|0)?1:(ce(se|0,ae|0),g=ae|0,0)}function xe(b){b=b|0;var se=0,ae=0,ne=0;return j(4)|0||(ne=u(g+1|0)|0,se=g+5|0,ae=(g+5|0)+(ne|0)|0,j(ne+4|0)|0)?1:(ce(se|0,ae|0),g=ae|0,0)}function Se(b){return b=b|0,1}function ie(b){return b=b|0,me(),g=g+1|0,0}function W(b){b=b|0;var se=0,ae=0,ne=0;return ne=b-96|0,j(ne|0)|0?1:(se=g+1|0,ae=(g+1|0)+(ne|0)|0,ue(se|0,ae|0),g=ae|0,0)}function $e(b){b=b|0;var se=0,ae=0,ne=0;return j(1)|0||(ne=i[g+1|0]|0,se=g+2|0,ae=(g+2|0)+(ne|0)|0,j(ne+1|0)|0)?1:(ue(se|0,ae|0),g=ae|0,0)}function zt(b){b=b|0;var se=0,ae=0,ne=0;return j(2)|0||(ne=a(g+1|0)|0,se=g+3|0,ae=(g+3|0)+(ne|0)|0,j(ne+2|0)|0)?1:(ue(se|0,ae|0),g=ae|0,0)}function sr(b){b=b|0;var se=0,ae=0,ne=0;return j(4)|0||(ne=u(g+1|0)|0,se=g+5|0,ae=(g+5|0)+(ne|0)|0,j(ne+4|0)|0)?1:(ue(se|0,ae|0),g=ae|0,0)}function or(b){return b=b|0,1}function et(b){return b=b|0,k(),g=g+1|0,0}function le(b){return b=b|0,F(b-128|0),g=g+1|0,0}function We(b){return b=b|0,j(1)|0?1:(F(i[g+1|0]|0),g=g+2|0,0)}function ze(b){return b=b|0,j(2)|0?1:(F(a(g+1|0)|0),g=g+3|0,0)}function we(b){return b=b|0,j(4)|0?1:(C(a(g+1|0)|0,a(g+3|0)|0),g=g+5|0,0)}function Ra(b){return b=b|0,j(8)|0?1:(Y(a(g+1|0)|0,a(g+3|0)|0,a(g+5|0)|0,a(g+7|0)|0),g=g+9|0,0)}function Oa(b){return b=b|0,q(),g=g+1|0,0}function Ee(b){b=b|0;var se=0;return se=b-160|0,j(se|0)|0?1:(J(se|0),g=g+1|0,0)}function Fa(b){return b=b|0,j(1)|0?1:(J(i[g+1|0]|0),g=g+2|0,0)}function Pa(b){return b=b|0,j(2)|0?1:(J(a(g+1|0)|0),g=g+3|0,0)}function La(b){return b=b|0,j(4)|0?1:(Z(a(g+1|0)|0,a(g+3|0)|0),g=g+5|0,0)}function Ma(b){return b=b|0,j(8)|0?1:(te(a(g+1|0)|0,a(g+3|0)|0,a(g+5|0)|0,a(g+7|0)|0),g=g+9|0,0)}function Da(b){return b=b|0,$(),g=g+1|0,0}function Zt(b){return b=b|0,Q(b-192|0|0),g=g+1|0,0}function qu(b){return b=b|0,Q(b|0),g=g+1|0,0}function $u(b){return b=b|0,Q(b|0),g=g+1|0,0}function ku(b){return b=b|0,Q(b|0),g=g+1|0,0}function Cu(b){return b=b|0,Q(b|0),g=g+1|0,0}function ke(b){return b=b|0,Q(b-192|0|0),g=g+1|0,0}function Gu(b){return b=b|0,Q(b|0),g=g+1|0,0}function Vu(b){return b=b|0,Q(b|0),g=g+1|0,0}function Yu(b){return b=b|0,Q(b|0),g=g+1|0,0}function qa(b){return b=b|0,j(1)|0?1:(Q(i[g+1|0]|0),g=g+2|0,0)}function $a(b){return b=b|0,j(2)|0?1:(Q(a(g+1|0)|0),g=g+3|0,0)}function ka(b){return b=b|0,j(4)|0?1:(re(a(g+1|0)|0,a(g+3|0)|0),g=g+5|0,0)}function Ca(b){return b=b|0,j(8)|0?1:(fe(a(g+1|0)|0,a(g+3|0)|0,a(g+5|0)|0,a(g+7|0)|0),g=g+9|0,0)}function Oe(b){return b=b|0,ee((b|0)-224|0),g=g+1|0,0}function Ga(b){return b=b|0,v(),g=g+1|0,0}function Va(b){return b=b|0,B(),g=g+1|0,0}function Ya(b){return b=b|0,P(),g=g+1|0,0}function Ha(b){return b=b|0,A(),g=g+1|0,0}function za(b){return b=b|0,j(1)|0?1:(ee(i[g+1|0]|0),g=g+2|0,0)}function Za(b){b=b|0;var se=0,ae=0,ne=1,Nr=0,ar=0,Hu=0;return j(2)|0?1:(se=i[g+1|0]|0,ae=i[g+2|0]|0,(se|0)&128&&(ne=-1),Nr=+(((se|0)&124)>>2),ar=+(((se|0)&3)<<8|ae),+Nr==0?E(+(+ne*5960464477539063e-23*+ar)):+Nr==31?+ne==1?+ar>0?H():N():+ar>0?z():D():E(+(+ne*R(2,+(+Nr-25))*+(1024+ar))),g=g+3|0,0)}function ja(b){return b=b|0,j(4)|0?1:(h(i[g+1|0]|0,i[g+2|0]|0,i[g+3|0]|0,i[g+4|0]|0),g=g+5|0,0)}function Ka(b){return b=b|0,j(8)|0?1:(O(i[g+1|0]|0,i[g+2|0]|0,i[g+3|0]|0,i[g+4|0]|0,i[g+5|0]|0,i[g+6|0]|0,i[g+7|0]|0,i[g+8|0]|0),g=g+9|0,0)}function pe(b){return b=b|0,1}function Wa(b){return b=b|0,Ie(),g=g+1|0,0}var Xa=[l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,_,y,w,T,pe,pe,pe,pe,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,x,S,I,L,pe,pe,pe,pe,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,K,oe,xe,Se,pe,pe,pe,ie,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,$e,zt,sr,or,pe,pe,pe,et,le,le,le,le,le,le,le,le,le,le,le,le,le,le,le,le,le,le,le,le,le,le,le,le,We,ze,we,Ra,pe,pe,pe,Oa,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Fa,Pa,La,Ma,pe,pe,pe,Da,Zt,Zt,Zt,Zt,Zt,Zt,ke,ke,ke,ke,ke,ke,ke,ke,ke,ke,ke,ke,ke,ke,ke,ke,ke,ke,qa,$a,ka,Ca,pe,pe,pe,pe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Ga,Va,Ya,Ha,za,Za,ja,Ka,pe,pe,pe,Wa];return{parse:ye}}});var lr=Ce(Qe=>{"use strict";var Vn=ur().BigNumber;Qe.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Qe.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};Qe.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Qe.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Qe.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Qe.SHIFT32=Math.pow(2,32);Qe.SHIFT16=Math.pow(2,16);Qe.MAX_SAFE_HIGH=2097151;Qe.NEG_ONE=new Vn(-1);Qe.TEN=new Vn(10);Qe.TWO=new Vn(2);Qe.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var jr=Ce(rt=>{"use strict";var{Buffer:Hc}=fr(),Us=ur().BigNumber,Rs=lr(),Ns=Rs.SHIFT32,zc=Rs.SHIFT16,Zc=2097151;rt.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 jc(r){return r<16?"0"+r.toString(16):r.toString(16)}rt.arrayBufferToBignumber=function(r){let e=r.byteLength,t="";for(let n=0;n<e;n++)t+=jc(r[n]);return new Us(t,16)};rt.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};rt.buildInt32=(r,e)=>r*zc+e;rt.buildInt64=(r,e,t,n)=>{let i=rt.buildInt32(r,e),s=rt.buildInt32(t,n);return i>Zc?new Us(i).times(Ns).plus(s):i*Ns+s};rt.writeHalf=function(e,t){let n=Hc.allocUnsafe(4);n.writeFloatBE(t,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,f=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(f>>13);else if(o>=103&&o<113){if(f&(1<<126-o)-1)return!1;s+=f+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};rt.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])};rt.isNegativeZero=r=>r===0&&1/r<0;rt.nextPowerOf2=r=>{let e=0;if(r&&!(r&r-1))return r;for(;r!==0;)r>>=1,e+=1;return 1<<e}});var Zn=Ce((E0,Os)=>{"use strict";var zn=lr(),Kc=zn.MT,Kr=zn.SIMPLE,Yn=zn.SYMS,Hn=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,Kc.SIMPLE_FLOAT)}static isSimple(e){return e instanceof r}static decode(e,t){switch(t==null&&(t=!0),e){case Kr.FALSE:return!1;case Kr.TRUE:return!0;case Kr.NULL:return t?null:Yn.NULL;case Kr.UNDEFINED:return t?void 0:Yn.UNDEFINED;case-1:if(!t)throw new Error("Invalid BREAK");return Yn.BREAK;default:return new r(e)}}};Os.exports=Hn});var Kn=Ce((_0,Fs)=>{"use strict";var jn=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}}};Fs.exports=jn});var Jn=Ce((I0,Ls)=>{"use strict";var Ps=self.location?self.location.protocol+"//"+self.location.host:"",Wn=self.URL,Xn=class{constructor(e="",t=Ps){this.super=new Wn(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 Wc(r){if(typeof r=="string")return new Wn(r).toString();if(!(r instanceof Wn)){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||"",f=r.search||(r.query?"?"+r.query:""),c=r.hash||"",m=r.pathname||"",E=r.path||m+f;return`${i}${e||t}${s||o+n}${E}${c}`}}Ls.exports={URLWithLegacySupport:Xn,URLSearchParams:self.URLSearchParams,defaultBase:Ps,format:Wc}});var qs=Ce((B0,Ds)=>{"use strict";var{URLWithLegacySupport:Ms,format:Xc}=Jn();Ds.exports=(r,e={},t={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(t[i]||n||i)+":";let s;try{s=new Ms(r)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new Ms(r,Xc(o)).toString()}});var Qn=Ce((v0,$s)=>{"use strict";var{URLWithLegacySupport:Jc,format:Qc,URLSearchParams:ef,defaultBase:tf}=Jn(),rf=qs();$s.exports={URL:Jc,URLSearchParams:ef,format:Qc,relative:rf,defaultBase:tf}});var ei=Ce((A0,Cs)=>{"use strict";var{Buffer:Wt}=fr(),ks=vs(),nf=ur().BigNumber,sf=Ts(),je=jr(),he=lr(),of=Zn(),af=Kn(),{URL:cf}=Qn(),dr=class r{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=je.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=Wt.from(this._heap),this._reset(),this._knownTags=Object.assign({0:t=>new Date(t),1:t=>new Date(t*1e3),2:t=>je.arrayBufferToBignumber(t),3:t=>he.NEG_ONE.minus(je.arrayBufferToBignumber(t)),4:t=>he.TEN.pow(t[0]).times(t[1]),5:t=>he.TWO.pow(t[0]).times(t[1]),32:t=>new cf(t),35:t=>new RegExp(t)},e.tags),this.parser=sf(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 he.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case he.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case he.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case he.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 he.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 he.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===he.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 he.PARENT.ARRAY:case he.PARENT.BYTE_STRING:case he.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case he.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=he.PARENT.MAP,n.ref=je.buildMap(n.ref)));break;case he.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case he.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:he.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,t){let n=this._knownTags[e];return n?n(t):new af(e,t)}createMap(e,t){return e}createObject(e,t){return e}createArray(e,t){return e}createByteString(e,t){return Wt.concat(e)}createByteStringFromHeap(e,t){return e===t?Wt.alloc(0):Wt.from(this._heap.slice(e,t))}createInt(e){return e}createInt32(e,t){return je.buildInt32(e,t)}createInt64(e,t,n,i){return je.buildInt64(e,t,n,i)}createFloat(e){return e}createFloatSingle(e,t,n,i){return ks.read([e,t,n,i],0,!1,23,4)}createFloatDouble(e,t,n,i,s,o,f,c){return ks.read([e,t,n,i,s,o,f,c],0,!1,52,8)}createInt32Neg(e,t){return-1-je.buildInt32(e,t)}createInt64Neg(e,t,n,i){let s=je.buildInt32(e,t),o=je.buildInt32(n,i);return s>he.MAX_SAFE_HIGH?he.NEG_ONE.minus(new nf(s).times(he.SHIFT32).plus(o)):-1-(s*he.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 of(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,f,c){this._push(this.createFloatDouble(e,t,n,i,s,o,f,c))}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([],he.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,t){let n=je.buildInt32(e,t);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,t,n,i){let s=je.buildInt64(e,t,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,t){let n=je.buildInt32(e,t);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,t,n,i){let s=je.buildInt64(e,t,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:he.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:he.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:he.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,t){this.pushTagStart(je.buildInt32(e,t))}pushTagStart8(e,t,n,i){this.pushTagStart(je.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({},he.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),he.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=Wt.from(e,t||"hex")),new r({size:e.length}).decodeFirst(e)}static decodeAll(e,t){return typeof e=="string"&&(e=Wt.from(e,t||"hex")),new r({size:e.length}).decodeAll(e)}};dr.decodeFirst=dr.decode;Cs.exports=dr});var Ys=Ce((S0,Vs)=>{"use strict";var{Buffer:ti}=fr(),ff=ei(),uf=jr(),ri=class r extends ff{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 uf.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,f,c){return`${super.createFloatDouble(e,t,n,i,s,o,f,c)}_3`}createByteString(e,t){let n=e.join(", ");return t===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,t){return`h'${ti.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(Gs(n),"");return t===-1?`{_ ${i}}`:`{${i}}`}createObject(e,t){let n=super.createObject(e),i=Object.keys(n).reduce(Gs(n),"");return t===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,t){let n=e.join(", ");return t===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,t){return`"${ti.from(super.createUtf8StringFromHeap(e,t)).toString("utf8")}"`}static diagnose(e,t){return typeof e=="string"&&(e=ti.from(e,t||"hex")),new r().decodeFirst(e)}};Vs.exports=ri;function Gs(r){return(e,t)=>e?`${e}, ${t}: ${r[t]}`:`${t}: ${r[t]}`}});var Ks=Ce((T0,js)=>{"use strict";var{Buffer:gt}=fr(),{URL:lf}=Qn(),ii=ur().BigNumber,ni=jr(),Me=lr(),ot=Me.MT,Wr=Me.NUMBYTES,Hs=Me.SHIFT32,zs=Me.SYMS,Xt=Me.TAG,df=Me.MT.SIMPLE_FLOAT<<5|Me.NUMBYTES.TWO,hf=Me.MT.SIMPLE_FLOAT<<5|Me.NUMBYTES.FOUR,pf=Me.MT.SIMPLE_FLOAT<<5|Me.NUMBYTES.EIGHT,bf=Me.MT.SIMPLE_FLOAT<<5|Me.SIMPLE.TRUE,gf=Me.MT.SIMPLE_FLOAT<<5|Me.SIMPLE.FALSE,mf=Me.MT.SIMPLE_FLOAT<<5|Me.SIMPLE.UNDEFINED,Zs=Me.MT.SIMPLE_FLOAT<<5|Me.SIMPLE.NULL,yf=new ii("0x20000000000000"),xf=gt.from("f97e00","hex"),wf=gt.from("f9fc00","hex"),Ef=gt.from("f97c00","hex");function _f(r){return{}.toString.call(r).slice(8,-1)}var si=class r{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[lf,this._pushUrl],[ii,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(xf)}_pushInfinity(e){let t=e<0?wf:Ef;return this.push(t)}_pushFloat(e){let t=gt.allocUnsafe(2);if(ni.writeHalf(t,e)&&ni.parseHalf(t)===e)return this._pushUInt8(df)&&this.push(t);let n=gt.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(hf)&&this.push(n):this._pushUInt8(pf)&&this._pushDoubleBE(e)}_pushInt(e,t,n){let i=t<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|Wr.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|Wr.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|Wr.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Wr.EIGHT)&&this._pushUInt32BE(Math.floor(e/Hs))&&this._pushUInt32BE(e%Hs):t===ot.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,ot.NEG_INT,e):this._pushInt(e,ot.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=gt.byteLength(e,"utf8");return this._pushInt(t,ot.UTF8_STRING)&&this.pushWrite(e,5,t)}_pushBoolean(e){return this._pushUInt8(e?bf:gf)}_pushUndefined(e){return this._pushUInt8(mf)}_pushArray(e,t){let n=t.length;if(!e._pushInt(n,ot.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,ot.TAG)}_pushDate(e,t){return e._pushTag(Xt.DATE_EPOCH)&&e.pushAny(Math.round(t/1e3))}_pushBuffer(e,t){return e._pushInt(t.length,ot.BYTE_STRING)&&e.push(t)}_pushNoFilter(e,t){return e._pushBuffer(e,t.slice())}_pushRegexp(e,t){return e._pushTag(Xt.REGEXP)&&e.pushAny(t.source)}_pushSet(e,t){if(!e._pushInt(t.size,ot.ARRAY))return!1;for(let n of t)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,t){return e._pushTag(Xt.URI)&&e.pushAny(t.format())}_pushBigint(e){let t=Xt.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),t=Xt.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=gt.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(Xt.DECIMAL_FRAC)&&e._pushInt(2,ot.ARRAY)))return!1;let n=t.decimalPlaces(),i=t.multipliedBy(new ii(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(yf)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,t){return e._pushInt(t.size,ot.MAP)?this._pushRawMap(t.size,Array.from(t)):!1}_pushObject(e){if(!e)return this._pushUInt8(Zs);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,ot.MAP)?this._pushRawMap(o,s.map(f=>[f,e[f]])):!1}_pushRawMap(e,t){t=t.map(function(i){return i[0]=r.encode(i[0]),i}).sort(ni.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=_f(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,gt.isBuffer(e)?e:gt.from(e));case"Null":return this._pushUInt8(Zs);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 zs.NULL:return this._pushObject(null);case zs.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 f=gt.allocUnsafe(s),c=0,m=0;for(o=0;o<i;o++){switch(m=t[o],n[o]){case 0:e[o].copy(f,c);break;case 1:f.writeUInt8(e[o],c,!0);break;case 2:f.writeUInt16BE(e[o],c,!0);break;case 3:f.writeUInt32BE(e[o],c,!0);break;case 4:f.writeDoubleBE(e[o],c,!0);break;case 5:f.write(e[o],c,m,"utf8");break;default:throw new Error("unkown method")}c+=m}var E=f;return this._reset(),E}_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()}};js.exports=si});var oi=Ce(De=>{"use strict";De.Diagnose=Ys();De.Decoder=ei();De.Encoder=Ks();De.Simple=Zn();De.Tagged=Kn();De.decodeAll=De.Decoder.decodeAll;De.decodeFirst=De.Decoder.decodeFirst;De.diagnose=De.Diagnose.diagnose;De.encode=De.Encoder.encode;De.decode=De.Decoder.decode;De.leveldb={decode:De.Decoder.decodeAll,encode:De.Encoder.encode,buffer:!0,name:"cbor"}});var fi=Ce(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});var If=9007199254740992;function Et(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 at(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 Xr(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 at(r,t,e.toString(16))}}function Ws(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 Et(new Uint8Array(Xr(3,r.length)),new Uint8Array(e))}function Bf(r,e){if(r==14277111)return Et(new Uint8Array([217,217,247]),e);if(r<24)return Et(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}}be.tagged=Bf;function hr(r){return new Uint8Array(r).buffer}be.raw=hr;function ai(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}be.uSmall=ai;function Xs(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),at(0,24,r)}be.u8=Xs;function Js(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),at(0,25,r)}be.u16=Js;function Qs(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),at(0,26,r)}be.u32=Qs;function ci(r,e){if(typeof r=="string"&&e==16){if(r.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return at(0,27,r)}if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),If),r=r.toString(16),at(0,27,r)}be.u64=ci;function eo(r){if(isNaN(r))throw new RangeError("Invalid number.");if(r===0)return ai(0);r=Math.min(Math.max(0,-r),24)-1;let e=[32+r];return new Uint8Array(e).buffer}be.iSmall=eo;function to(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),at(1,24,r)}be.i8=to;function ro(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),at(1,25,r)}be.i16=ro;function no(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),at(1,26,r)}be.i32=no;function io(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?at(1,27,n):ci(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),at(1,27,r)}be.i64=io;function vf(r){return r>=0?r<24?ai(r):r<=255?Xs(r):r<=65535?Js(r):r<=4294967295?Qs(r):ci(r):r>=-24?eo(r):r>=-255?to(r):r>=-65535?ro(r):r>=-4294967295?no(r):io(r)}be.number=vf;function Af(r){return Et(Xr(2,r.byteLength),r)}be.bytes=Af;function Sf(r){return Ws(r)}be.string=Sf;function Tf(r){return Et(Xr(4,r.length),...r)}be.array=Tf;function Nf(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))),Et(Xr(5,r.size),...t.map(([n,i])=>Et(Ws(n),i)))}be.map=Nf;function Uf(r){let e=new Float32Array([r]);return Et(new Uint8Array([250]),new Uint8Array(e.buffer))}be.singleFloat=Uf;function Rf(r){let e=new Float64Array([r]);return Et(new Uint8Array([251]),new Uint8Array(e.buffer))}be.doubleFloat=Rf;function Of(r){return r?so():oo()}be.bool=Of;function so(){return hr(new Uint8Array([245]))}be.true_=so;function oo(){return hr(new Uint8Array([244]))}be.false_=oo;function Ff(){return hr(new Uint8Array([246]))}be.null_=Ff;function Pf(){return hr(new Uint8Array([247]))}be.undefined_=Pf});var ao=Ce(Nt=>{"use strict";var Lf=Nt&&Nt.__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(Nt,"__esModule",{value:!0});var ct=Lf(fi()),Mf=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Jr=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 ct.undefined_();case"boolean":return ct.bool(e);case"number":return Math.floor(e)===e?ct.number(e):ct.doubleFloat(e);case"string":return ct.string(e);case"object":if(e===null)return ct.null_();if(Array.isArray(e))return ct.array(e.map(t=>this._serializer.serializeValue(t)));if(Mf.find(t=>e instanceof t))return ct.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 ct.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 ct.map(t,this._stable)}default:throw new Error("Invalid value.")}}};Nt.JsonDefaultCborEncoder=Jr;var Qr=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};Nt.ToCborEncoder=Qr;var en=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let t=new this;return t.addEncoder(new Jr(t,e)),t.addEncoder(new Qr),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)}};Nt.CborSerializer=en;var ui=class extends en{serialize(e){return ct.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};Nt.SelfDescribeCborSerializer=ui});var li=Ce(Ct=>{"use strict";function Df(r){for(var e in r)Ct.hasOwnProperty(e)||(Ct[e]=r[e])}var qf=Ct&&Ct.__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(Ct,"__esModule",{value:!0});Df(ao());var $f=qf(fi());Ct.value=$f});var Or="abcdefghijklmnopqrstuvwxyz234567",jt=Object.create(null);for(let r=0;r<Or.length;r++)jt[Or[r]]=r;jt[0]=jt.o;jt[1]=jt.i;function ji(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+=Or[t>>3],e+=5),0)}for(let s=0;s<r.length;)s+=i(r[s]);return n+(e<0?Or[t>>3]:"")}function Ki(r){let e=0,t=0,n=new Uint8Array(r.length*4/3|0),i=0;function s(o){let f=jt[o.toLowerCase()];if(f===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);f<<=3,t|=f>>>e,e+=5,e>=8&&(n[i++]=t,e-=8,e>0?t=f<<5-e&255:t=0)}for(let o of r)s(o);return n.slice(0,i)}var sc=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 Wi(r){let e=new Uint8Array(r),t=-1;for(let n=0;n<e.length;n++){let s=(e[n]^t)&255;t=sc[s]^t>>>8}return(t^-1)>>>0}function oc(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Fr(r,...e){if(!oc(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 Pn(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 Xi(r,e){Fr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Pr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Mr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),st=(r,e)=>r<<32-e|r>>>e;var Qu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ac(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ln(r){return typeof r=="string"&&(r=ac(r)),Fr(r),r}function e0(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];Fr(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}var Lr=class{clone(){return this._cloneInto()}},t0={}.toString;function Mn(r){let e=n=>r().update(Ln(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Ji(r=32){if(Pr&&typeof Pr.getRandomValues=="function")return Pr.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function cc(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),f=Number(t&s),c=n?4:0,m=n?0:4;r.setUint32(e+c,o,n),r.setUint32(e+m,f,n)}var Qi=(r,e,t)=>r&e^~r&t,es=(r,e,t)=>r&e^r&t^e&t,Dr=class extends Lr{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=Mr(this.buffer)}update(e){Pn(this);let{view:t,buffer:n,blockLen:i}=this;e=Ln(e);let s=e.length;for(let o=0;o<s;){let f=Math.min(i-this.pos,s-o);if(f===i){let c=Mr(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+f),this.pos),this.pos+=f,o+=f,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Pn(this),Xi(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 h=o;h<i;h++)t[h]=0;cc(n,i-8,BigInt(this.length*8),s),this.process(n,0);let f=Mr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let m=c/4,E=this.get();if(m>E.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<m;h++)f.setUint32(4*h,E[h],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:f}=this;return e.length=i,e.pos=f,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}};var fc=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]),St=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Tt=new Uint32Array(64),qr=class extends Dr{constructor(){super(64,32,8,!1),this.A=St[0]|0,this.B=St[1]|0,this.C=St[2]|0,this.D=St[3]|0,this.E=St[4]|0,this.F=St[5]|0,this.G=St[6]|0,this.H=St[7]|0}get(){let{A:e,B:t,C:n,D:i,E:s,F:o,G:f,H:c}=this;return[e,t,n,i,s,o,f,c]}set(e,t,n,i,s,o,f,c){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=f|0,this.H=c|0}process(e,t){for(let h=0;h<16;h++,t+=4)Tt[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){let O=Tt[h-15],B=Tt[h-2],v=st(O,7)^st(O,18)^O>>>3,A=st(B,17)^st(B,19)^B>>>10;Tt[h]=A+Tt[h-7]+v+Tt[h-16]|0}let{A:n,B:i,C:s,D:o,E:f,F:c,G:m,H:E}=this;for(let h=0;h<64;h++){let O=st(f,6)^st(f,11)^st(f,25),B=E+O+Qi(f,c,m)+fc[h]+Tt[h]|0,A=(st(n,2)^st(n,13)^st(n,22))+es(n,i,s)|0;E=m,m=c,c=f,f=o+B|0,o=s,s=i,i=n,n=B+A|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,f=f+this.E|0,c=c+this.F|0,m=m+this.G|0,E=E+this.H|0,this.set(n,i,s,o,f,c,m,E)}roundClean(){Tt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Dn=class extends qr{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}},cr=Mn(()=>new qr),ts=Mn(()=>new Dn);function rs(r){return ts.create().update(new Uint8Array(r)).digest()}var $r="__principal__",uc=2,ns=4,lc="aaaaa-aa",dc=r=>{var e;return new Uint8Array(((e=r.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(t=>parseInt(t,16)))},hc=r=>r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),""),Ge=class r{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([ns]))}static managementCanister(){return this.fromHex(lc)}static selfAuthenticating(e){let t=rs(e);return new this(new Uint8Array([...t,uc]))}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(dc(e))}static fromText(e){let t=e;if(e.includes($r)){let o=JSON.parse(e);$r in o&&(t=o[$r])}let n=t.toLowerCase().replace(/-/g,""),i=Ki(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]===ns}toUint8Array(){return this._arr}toHex(){return hc(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,Wi(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),f=ji(s).match(/.{1,5}/g);if(!f)throw new Error;return f.join("-")}toString(){return this.toText()}toJSON(){return{[$r]: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 Kt=class r extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,r.prototype)}};var fo=Rr(oi()),Gt=Rr(li()),uo=Rr(li());function nt(...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 ft(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}var kf=new RegExp(/^[0-9a-fA-F]+$/);function br(r){if(!kf.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 di(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 F0(r,e){return di(r,e)===0}function pr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function Cf(r){return r instanceof Uint8Array?pr(r):r instanceof ArrayBuffer?r:Array.isArray(r)?pr(new Uint8Array(r)):"buffer"in r?Cf(r.buffer):pr(new Uint8Array(r))}var hi=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Gt.value.bytes(e.toUint8Array())}},pi=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Gt.value.bytes(new Uint8Array(e))}},bi=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Gt.value.tagged(2,Gt.value.bytes(br(e.toString(16)))):Gt.value.tagged(3,Gt.value.bytes(br((BigInt("-1")*e).toString(16))))}},tn=uo.SelfDescribeCborSerializer.withDefaultEncoders(!0);tn.addEncoder(new hi);tn.addEncoder(new pi);tn.addEncoder(new bi);var gi;(function(r){r[r.Uint64LittleEndian=71]="Uint64LittleEndian",r[r.Semantic=55799]="Semantic"})(gi||(gi={}));function M0(r){return tn.serialize(r)}function co(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 mi=class extends fo.default.Decoder{createByteString(e){return nt(...e)}createByteStringFromHeap(e,t){return e===t?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,t))}};function Jt(r){let e=new Uint8Array(r),t=new mi({size:e.byteLength,tags:{2:n=>co(n),3:n=>-co(n),[gi.Semantic]:n=>n}});try{return t.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${ft(e)}`)}}var Bi={};Fn(Bi,{Bool:()=>xo,BoolClass:()=>cn,ConstructType:()=>yt,Empty:()=>mo,EmptyClass:()=>on,FixedIntClass:()=>It,FixedNatClass:()=>mt,Float32:()=>Bo,Float64:()=>vo,FloatClass:()=>mr,Func:()=>Co,FuncClass:()=>xr,Int:()=>_o,Int16:()=>So,Int32:()=>To,Int64:()=>No,Int8:()=>Ao,IntClass:()=>ln,Nat:()=>Io,Nat16:()=>Ro,Nat32:()=>Oo,Nat64:()=>Fo,Nat8:()=>Uo,NatClass:()=>dn,Null:()=>wo,NullClass:()=>fn,Opt:()=>Do,OptClass:()=>tr,PrimitiveType:()=>Je,Principal:()=>Po,PrincipalClass:()=>gn,Rec:()=>ko,RecClass:()=>Ot,Record:()=>qo,RecordClass:()=>yr,Reserved:()=>yo,ReservedClass:()=>er,Service:()=>Go,ServiceClass:()=>mn,Text:()=>Eo,TextClass:()=>un,Tuple:()=>Lo,TupleClass:()=>pn,Type:()=>Qt,Unknown:()=>Hf,UnknownClass:()=>an,Variant:()=>$o,VariantClass:()=>bn,Vec:()=>Mo,VecClass:()=>hn,Visitor:()=>sn,decode:()=>Yf,encode:()=>Vf});function de(...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 ut=class{constructor(e,t=e?.byteLength||0){this._buffer=xi(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,t)}get buffer(){return xi(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 yi(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function xi(r){return r instanceof Uint8Array?yi(r):r instanceof ArrayBuffer?r:Array.isArray(r)?yi(new Uint8Array(r)):"buffer"in r?xi(r.buffer):yi(new Uint8Array(r))}function Gf(r){let t=new TextEncoder().encode(r),n=0;for(let i of t)n=(n*223+i)%2**32;return n}function lt(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 Gf(r)}function ho(){throw new Error("unexpected end of buffer")}function Rt(r,e){return r.byteLength<e&&ho(),r.read(e)}function Ut(r){let e=r.readUint8();return e===void 0&&ho(),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 ut(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 Fe(r){let e=BigInt(1),t=BigInt(0),n;do n=Ut(r),t+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return t}function Pe(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 ut(new ArrayBuffer(t),0);for(;;){let s=i(r);if(r/=BigInt(128),e&&r===BigInt(0)&&s&64||!e&&r===BigInt(0)&&!(s&64)){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}function _t(r){let e=new Uint8Array(r.buffer),t=0;for(;t<e.byteLength;t++)if(e[t]<128){if(!(e[t]&64))return Fe(r);break}let n=new Uint8Array(Rt(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 po(r,e){if(BigInt(r)<BigInt(0))throw new Error("Cannot write negative values.");return wi(r,e)}function wi(r,e){r=BigInt(r);let t=new ut(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 Ei(r,e){let t=BigInt(Ut(r)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(Ut(r));t=t+n*s}return t}function bo(r,e){let t=Ei(r,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return t>=n&&(t-=n*BigInt(2)),t}function rn(r){let e=BigInt(r);if(r<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}var nn="DIDL",go=400;function gr(r,e,t){return r.map((n,i)=>t(n,e[i]))}var _i=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=de(...this._typs);return de(e,t)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return Pe(this._idx.get(e)||0)}},sn=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)}},Qt=class{display(){return this.name}valueToString(e){return Te(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}},Je=class extends Qt{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){}},yt=class extends Qt{checkType(e){if(e instanceof Ot){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)}},on=class extends Je{accept(e,t){return e.visitEmpty(this,t)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Te(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return Pe(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},an=class extends Qt{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: ${Te(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 Ot?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"}},cn=class extends Je{accept(e,t){return e.visitBool(this,t)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Te(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return Pe(-2)}decodeValue(e,t){switch(this.checkType(t),Ut(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},fn=class extends Je{accept(e,t){return e.visitNull(this,t)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Te(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return Pe(-1)}decodeValue(e,t){return this.checkType(t),null}get name(){return"null"}},er=class extends Je{accept(e,t){return e.visitReserved(this,t)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return Pe(-16)}decodeValue(e,t){return t.name!==this.name&&t.decodeValue(e,t),null}get name(){return"reserved"}},un=class extends Je{accept(e,t){return e.visitText(this,t)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Te(e)}`)}encodeValue(e){let t=new TextEncoder().encode(e),n=Be(t.byteLength);return de(n,t)}encodeType(){return Pe(-15)}decodeValue(e,t){this.checkType(t);let n=Fe(e),i=Rt(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}},ln=class extends Je{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: ${Te(e)}`)}encodeValue(e){return Pe(e)}encodeType(){return Pe(-4)}decodeValue(e,t){return this.checkType(t),_t(e)}get name(){return"int"}valueToString(e){return e.toString()}},dn=class extends Je{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: ${Te(e)}`)}encodeValue(e){return Be(e)}encodeType(){return Pe(-3)}decodeValue(e,t){return this.checkType(t),Fe(e)}get name(){return"nat"}valueToString(e){return e.toString()}},mr=class extends Je{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: ${Te(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 Pe(e)}decodeValue(e,t){this.checkType(t);let n=Rt(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()}},It=class extends Je{constructor(e){super(),this._bits=e}accept(e,t){return e.visitFixedInt(this,t)}covariant(e){let t=rn(this._bits-1)*BigInt(-1),n=rn(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: ${Te(e)}`)}encodeValue(e){return wi(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return Pe(-9-e)}decodeValue(e,t){this.checkType(t);let n=bo(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 Je{constructor(e){super(),this._bits=e}accept(e,t){return e.visitFixedNat(this,t)}covariant(e){let t=rn(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: ${Te(e)}`)}encodeValue(e){return po(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return Pe(-5-e)}decodeValue(e,t){this.checkType(t);let n=Ei(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}},hn=class r extends yt{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 It?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: ${Te(e)}`)}encodeValue(e){let t=Be(e.length);if(this._blobOptimization)return de(t,new Uint8Array(e));if(ArrayBuffer.isView(e))return de(t,new Uint8Array(e.buffer));let n=new ut(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=Pe(-19),n=this._type.encodeType(e);e.add(this,de(t,n))}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))throw new Error("Not a vector type");let i=Number(Fe(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 It){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("; ")+"}"}},tr=class r extends yt{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: ${Te(e)}
4
-
5
- -> ${t.message}`)}throw new Error(`Invalid ${this.display()} argument: ${Te(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):de(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let t=Pe(-18),n=this._type.encodeType(e);e.add(this,de(t,n))}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))throw new Error("Not an option type");switch(Ut(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])}`}},yr=class r extends yt{constructor(e={}){super(),this._fields=Object.entries(e).sort((t,n)=>lt(t[0])-lt(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: ${Te(e)}`)}encodeValue(e){let t=this._fields.map(([i])=>e[i]),n=gr(this._fields,t,([,i],s)=>i.encodeValue(s));return de(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let t=Pe(-20),n=Be(this._fields.length),i=this._fields.map(([s,o])=>de(Be(lt(s)),o.encodeType(e)));e.add(this,de(t,n,de(...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[f,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(e,c),o++;continue}let[m,E]=this._fields[s],h=lt(this._fields[s][0]),O=lt(f);if(h===O)i[m]=E.decodeValue(e,c),s++,o++;else if(O>h)if(E instanceof tr||E instanceof er)i[m]=[],s++;else throw new Error("Cannot find required field "+m);else c.decodeValue(e,c),o++}for(let[f,c]of this._fields.slice(s))if(c instanceof tr||c instanceof er)i[f]=[];else throw new Error("Cannot find required field "+f);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 {${gr(this._fields,t,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}},pn=class r extends yr{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: ${Te(e)}`)}encodeValue(e){let t=gr(this._components,e,(n,i)=>n.encodeValue(i));return de(...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 {${gr(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}},bn=class r extends yt{constructor(e={}){super(),this._fields=Object.entries(e).sort((t,n)=>lt(t[0])-lt(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: ${Te(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 de(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let t=Pe(-21),n=Be(this._fields.length),i=this._fields.map(([s,o])=>de(Be(lt(s)),o.encodeType(e)));e.add(this,de(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(Fe(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[f,c]of this._fields)if(lt(s)===lt(f)){let m=c.decodeValue(e,o);return{[f]:m}}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)}},Ot=class r extends yt{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: ${Te(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)}};Ot._counter=0;function Ii(r){if(Ut(r)!==1)throw new Error("Cannot decode principal");let t=Number(Fe(r));return Ge.fromUint8Array(new Uint8Array(Rt(r,t)))}var gn=class extends Je{accept(e,t){return e.visitPrincipal(this,t)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Te(e)}`)}encodeValue(e){let t=e.toUint8Array(),n=Be(t.byteLength);return de(new Uint8Array([1]),n,t)}encodeType(){return Pe(-24)}decodeValue(e,t){return this.checkType(t),Ii(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}},xr=class extends yt{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: ${Te(e)}`)}encodeValue([e,t]){let n=e.toUint8Array(),i=Be(n.byteLength),s=de(new Uint8Array([1]),i,n),o=new TextEncoder().encode(t),f=Be(o.byteLength);return de(new Uint8Array([1]),s,f,o)}_buildTypeTableImpl(e){this.argTypes.forEach(m=>m.buildTypeTable(e)),this.retTypes.forEach(m=>m.buildTypeTable(e));let t=Pe(-22),n=Be(this.argTypes.length),i=de(...this.argTypes.map(m=>m.encodeType(e))),s=Be(this.retTypes.length),o=de(...this.retTypes.map(m=>m.encodeType(e))),f=Be(this.annotations.length),c=de(...this.annotations.map(m=>this.encodeAnnotation(m)));e.add(this,de(t,n,i,s,o,f,c))}decodeValue(e){if(Ut(e)!==1)throw new Error("Cannot decode function reference");let n=Ii(e),i=Number(Fe(e)),s=Rt(e,i),f=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,f]}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")}},mn=class extends yt{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: ${Te(e)}`)}encodeValue(e){let t=e.toUint8Array(),n=Be(t.length);return de(new Uint8Array([1]),n,t)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let t=Pe(-23),n=Be(this._fields.length),i=this._fields.map(([s,o])=>{let f=new TextEncoder().encode(s),c=Be(f.length);return de(c,f,o.encodeType(e))});e.add(this,de(t,n,...i))}decodeValue(e){return Ii(e)}get name(){return`service {${this._fields.map(([t,n])=>t+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};function Te(r){let e=JSON.stringify(r,(t,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>go?e.substring(0,go-3)+"...":e}function Vf(r,e){if(e.length<r.length)throw Error("Wrong number of message arguments");let t=new _i;r.forEach(c=>c.buildTypeTable(t));let n=new TextEncoder().encode(nn),i=t.encode(),s=Be(e.length),o=de(...r.map(c=>c.encodeType(t))),f=de(...gr(r,e,(c,m)=>{try{c.covariant(m)}catch(E){throw new Error(E.message+`
12
-
13
- `)}return c.encodeValue(m)}));return de(n,i,s,o,f)}function Yf(r,e){let t=new ut(e);if(e.byteLength<nn.length)throw new Error("Message length smaller than magic number");let n=Rt(t,nn.length),i=new TextDecoder().decode(n);if(i!==nn)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(B){let v=[],A=Number(Fe(B));for(let D=0;D<A;D++){let H=Number(_t(B));switch(H){case-18:case-19:{let z=Number(_t(B));v.push([H,z]);break}case-20:case-21:{let z=[],q=Number(Fe(B)),F;for(;q--;){let C=Number(Fe(B));if(C>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof F=="number"&&F>=C)throw new Error("field id collision or not sorted");F=C;let Y=Number(_t(B));z.push([C,Y])}v.push([H,z]);break}case-22:{let z=[],q=Number(Fe(B));for(;q--;)z.push(Number(_t(B)));let F=[],C=Number(Fe(B));for(;C--;)F.push(Number(_t(B)));let Y=[],$=Number(Fe(B));for(;$--;)switch(Number(Fe(B))){case 1:{Y.push("query");break}case 2:{Y.push("oneway");break}case 3:{Y.push("composite_query");break}default:throw new Error("unknown annotation")}v.push([H,[z,F,Y]]);break}case-23:{let z=Number(Fe(B)),q=[];for(;z--;){let F=Number(Fe(B)),C=new TextDecoder().decode(Rt(B,F)),Y=_t(B);q.push([C,Y])}v.push([H,q]);break}default:throw new Error("Illegal op_code: "+H)}}let P=[],N=Number(Fe(B));for(let D=0;D<N;D++)P.push(Number(_t(B)));return[v,P]}let[o,f]=s(t);if(f.length<r.length)throw new Error("Wrong number of return values");let c=o.map(B=>ko());function m(B){if(B<-24)throw new Error("future value not supported");if(B<0)switch(B){case-1:return wo;case-2:return xo;case-3:return Io;case-4:return _o;case-5:return Uo;case-6:return Ro;case-7:return Oo;case-8:return Fo;case-9:return Ao;case-10:return So;case-11:return To;case-12:return No;case-13:return Bo;case-14:return vo;case-15:return Eo;case-16:return yo;case-17:return mo;case-24:return Po;default:throw new Error("Illegal op_code: "+B)}if(B>=o.length)throw new Error("type index out of range");return c[B]}function E(B){switch(B[0]){case-19:{let v=m(B[1]);return Mo(v)}case-18:{let v=m(B[1]);return Do(v)}case-20:{let v={};for(let[N,D]of B[1]){let H=`_${N}_`;v[H]=m(D)}let A=qo(v),P=A.tryAsTuple();return Array.isArray(P)?Lo(...P):A}case-21:{let v={};for(let[A,P]of B[1]){let N=`_${A}_`;v[N]=m(P)}return $o(v)}case-22:{let[v,A,P]=B[1];return Co(v.map(N=>m(N)),A.map(N=>m(N)),P)}case-23:{let v={},A=B[1];for(let[P,N]of A){let D=m(N);if(D instanceof Ot&&(D=D.getType()),!(D instanceof xr))throw new Error("Illegal service definition: services can only contain functions");v[P]=D}return Go(v)}default:throw new Error("Illegal op_code: "+B[0])}}o.forEach((B,v)=>{if(B[0]===-22){let A=E(B);c[v].fill(A)}}),o.forEach((B,v)=>{if(B[0]!==-22){let A=E(B);c[v].fill(A)}});let h=f.map(B=>m(B)),O=r.map((B,v)=>B.decodeValue(t,h[v]));for(let B=r.length;B<h.length;B++)h[B].decodeValue(t,h[B]);if(t.byteLength>0)throw new Error("decode: Left-over bytes");return O}var mo=new on,yo=new er,Hf=new an,xo=new cn,wo=new fn,Eo=new un,_o=new ln,Io=new dn,Bo=new mr(32),vo=new mr(64),Ao=new It(8),So=new It(16),To=new It(32),No=new It(64),Uo=new mt(8),Ro=new mt(16),Oo=new mt(32),Fo=new mt(64),Po=new gn;function Lo(...r){return new pn(r)}function Mo(r){return new hn(r)}function Do(r){return new tr(r)}function qo(r){return new yr(r)}function $o(r){return new bn(r)}function ko(){return new Ot}function Co(r,e,t=[]){return new xr(r,e,t)}function Go(r){return new mn(r)}var Vo=Rr(oi());function it(r){return pr(cr.create().update(new Uint8Array(r)).digest())}function yn(r){if(r instanceof Vo.default.Tagged)return yn(r.value);if(typeof r=="string")return Yo(r);if(typeof r=="number")return it(Be(r));if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))return it(r);if(Array.isArray(r)){let e=r.map(yn);return it(nt(...e))}else{if(r&&typeof r=="object"&&r._isPrincipal)return it(r.toUint8Array());if(typeof r=="object"&&r!==null&&typeof r.toHash=="function")return yn(r.toHash());if(typeof r=="object")return Ho(r);if(typeof r=="bigint")return it(Be(r))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${r}`),{value:r})}var Yo=r=>{let e=new TextEncoder().encode(r);return it(e)};function ll(r){return Ho(r)}function Ho(r){let n=Object.entries(r).filter(([,o])=>o!==void 0).map(([o,f])=>{let c=Yo(o),m=yn(f);return[c,m]}).sort(([o],[f])=>di(o,f)),i=nt(...n.map(o=>nt(...o)));return it(i)}var Si={};Fn(Si,{abytes:()=>dt,bitGet:()=>nr,bitLen:()=>Ft,bitMask:()=>Pt,bitSet:()=>Xf,bytesToHex:()=>vt,bytesToNumberBE:()=>Ze,bytesToNumberLE:()=>wn,concatBytes:()=>ve,createHmacDrbg:()=>Wo,ensureBytes:()=>ht,equalBytes:()=>Wf,hexToBytes:()=>wr,hexToNumber:()=>Ai,isBytes:()=>rr,numberToBytesBE:()=>Ne,numberToBytesLE:()=>En,numberToHexUnpadded:()=>Ko,numberToVarBytesBE:()=>Kf,utf8ToBytes:()=>Er,validateObject:()=>At});var jo=BigInt(0),xn=BigInt(1),Zf=BigInt(2);function rr(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function dt(r){if(!rr(r))throw new Error("Uint8Array expected")}var jf=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function vt(r){dt(r);let e="";for(let t=0;t<r.length;t++)e+=jf[r[t]];return e}function Ko(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Ai(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Bt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function zo(r){if(r>=Bt._0&&r<=Bt._9)return r-Bt._0;if(r>=Bt._A&&r<=Bt._F)return r-(Bt._A-10);if(r>=Bt._a&&r<=Bt._f)return r-(Bt._a-10)}function wr(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=zo(r.charCodeAt(s)),f=zo(r.charCodeAt(s+1));if(o===void 0||f===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+f}return n}function Ze(r){return Ai(vt(r))}function wn(r){return dt(r),Ai(vt(Uint8Array.from(r).reverse()))}function Ne(r,e){return wr(r.toString(16).padStart(e*2,"0"))}function En(r,e){return Ne(r,e).reverse()}function Kf(r){return wr(Ko(r))}function ht(r,e,t){let n;if(typeof e=="string")try{n=wr(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(rr(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 ve(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];dt(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 Wf(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 Er(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ft(r){let e;for(e=0;r>jo;r>>=xn,e+=1);return e}function nr(r,e){return r>>BigInt(e)&xn}function Xf(r,e,t){return r|(t?xn:jo)<<BigInt(e)}var Pt=r=>(Zf<<BigInt(r-1))-xn,vi=r=>new Uint8Array(r),Zo=r=>Uint8Array.from(r);function Wo(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=vi(r),i=vi(r),s=0,o=()=>{n.fill(1),i.fill(0),s=0},f=(...h)=>t(i,n,...h),c=(h=vi())=>{i=f(Zo([0]),h),n=f(),h.length!==0&&(i=f(Zo([1]),h),n=f())},m=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,O=[];for(;h<e;){n=f();let B=n.slice();O.push(B),h+=n.length}return ve(...O)};return(h,O)=>{o(),c(h);let B;for(;!(B=O(m()));)c();return o(),B}}var Jf={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"||rr(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 At(r,e,t={}){let n=(i,s,o)=>{let f=Jf[s];if(typeof f!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=r[i];if(!(o&&c===void 0)&&!f(c,r))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(t))n(i,s,!0);return r}var qe=BigInt(0),_e=BigInt(1),Vt=BigInt(2),Qf=BigInt(3),Ti=BigInt(4),Xo=BigInt(5),Jo=BigInt(8),eu=BigInt(9),tu=BigInt(16);function Ke(r,e){let t=r%e;return t>=qe?t:e+t}function ru(r,e,t){if(t<=qe||e<qe)throw new Error("Expected power/modulo > 0");if(t===_e)return qe;let n=_e;for(;e>qe;)e&_e&&(n=n*r%t),r=r*r%t,e>>=_e;return n}function pl(r,e,t){let n=r;for(;e-- >qe;)n*=n,n%=t;return n}function Ni(r,e){if(r===qe||e<=qe)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Ke(r,e),n=e,i=qe,s=_e,o=_e,f=qe;for(;t!==qe;){let m=n/t,E=n%t,h=i-o*m,O=s-f*m;n=t,t=E,i=o,s=f,o=h,f=O}if(n!==_e)throw new Error("invert: does not exist");return Ke(i,e)}function nu(r){let e=(r-_e)/Vt,t,n,i;for(t=r-_e,n=0;t%Vt===qe;t/=Vt,n++);for(i=Vt;i<r&&ru(i,e,r)!==r-_e;i++);if(n===1){let o=(r+_e)/Ti;return function(c,m){let E=c.pow(m,o);if(!c.eql(c.sqr(E),m))throw new Error("Cannot find square root");return E}}let s=(t+_e)/Vt;return function(f,c){if(f.pow(c,e)===f.neg(f.ONE))throw new Error("Cannot find square root");let m=n,E=f.pow(f.mul(f.ONE,i),t),h=f.pow(c,s),O=f.pow(c,t);for(;!f.eql(O,f.ONE);){if(f.eql(O,f.ZERO))return f.ZERO;let B=1;for(let A=f.sqr(O);B<m&&!f.eql(A,f.ONE);B++)A=f.sqr(A);let v=f.pow(E,_e<<BigInt(m-B-1));E=f.sqr(v),h=f.mul(h,v),O=f.mul(O,E),m=B}return h}}function iu(r){if(r%Ti===Qf){let e=(r+_e)/Ti;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%Jo===Xo){let e=(r-Xo)/Jo;return function(n,i){let s=n.mul(i,Vt),o=n.pow(s,e),f=n.mul(i,o),c=n.mul(n.mul(f,Vt),o),m=n.mul(f,n.sub(c,n.ONE));if(!n.eql(n.sqr(m),i))throw new Error("Cannot find square root");return m}}return r%tu,nu(r)}var bl=(r,e)=>(Ke(r,e)&_e)===_e,su=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function _n(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=su.reduce((n,i)=>(n[i]="function",n),e);return At(r,t)}function _r(r,e,t){if(t<qe)throw new Error("Expected power > 0");if(t===qe)return r.ONE;if(t===_e)return e;let n=r.ONE,i=e;for(;t>qe;)t&_e&&(n=r.mul(n,i)),i=r.sqr(i),t>>=_e;return n}function Ir(r,e){let t=new Array(e.length),n=e.reduce((s,o,f)=>r.is0(o)?s:(t[f]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,f)=>r.is0(o)?s:(t[f]=r.mul(s,t[f]),r.mul(s,o)),i),t}function Ui(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Ri(r,e,t=!1,n={}){if(r<=qe)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:s}=Ui(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=iu(r),f=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:Pt(i),ZERO:qe,ONE:_e,create:c=>Ke(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return qe<=c&&c<r},is0:c=>c===qe,isOdd:c=>(c&_e)===_e,neg:c=>Ke(-c,r),eql:(c,m)=>c===m,sqr:c=>Ke(c*c,r),add:(c,m)=>Ke(c+m,r),sub:(c,m)=>Ke(c-m,r),mul:(c,m)=>Ke(c*m,r),pow:(c,m)=>_r(f,c,m),div:(c,m)=>Ke(c*Ni(m,r),r),sqrN:c=>c*c,addN:(c,m)=>c+m,subN:(c,m)=>c-m,mulN:(c,m)=>c*m,inv:c=>Ni(c,r),sqrt:n.sqrt||(c=>o(f,c)),invertBatch:c=>Ir(f,c),cmov:(c,m,E)=>E?m:c,toBytes:c=>t?En(c,s):Ne(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return t?wn(c):Ze(c)}});return Object.freeze(f)}function gl(r,e){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let t=r.sqrt(e);return r.isOdd(t)?r.neg(t):t}function Qo(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 In(r){let e=Qo(r);return e+Math.ceil(e/2)}function Oi(r,e,t=!1){let n=r.length,i=Qo(e),s=In(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=t?Ze(r):wn(r),f=Ke(o,e-_e)+_e;return t?En(f,i):Ne(f,i)}var ou=Ze;function Lt(r,e){if(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 au(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 Fi(r){if(!Number.isSafeInteger(r))throw new Error("number expected")}function cu(r,e,t,n){dt(r),dt(e),Fi(t),e.length>255&&(e=n(ve(Er("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(t/i);if(o>255)throw new Error("Invalid xmd length");let f=ve(e,Lt(e.length,1)),c=Lt(0,s),m=Lt(t,2),E=new Array(o),h=n(ve(c,r,m,Lt(0,1),f));E[0]=n(ve(h,Lt(1,1),f));for(let B=1;B<=o;B++){let v=[au(h,E[B-1]),Lt(B+1,1),f];E[B]=n(ve(...v))}return ve(...E).slice(0,t)}function fu(r,e,t,n,i){if(dt(r),dt(e),Fi(t),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update(Er("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(Lt(t,2)).update(e).update(Lt(e.length,1)).digest()}function ta(r,e,t){At(t,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:f,DST:c}=t;dt(r),Fi(e);let m=typeof c=="string"?Er(c):c,E=n.toString(2).length,h=Math.ceil((E+i)/8),O=e*s*h,B;if(f==="xmd")B=cu(r,m,O,o);else if(f==="xof")B=fu(r,m,O,i,o);else if(f==="_internal_pass")B=r;else throw new Error('expand must be "xmd" or "xof"');let v=new Array(e);for(let A=0;A<e;A++){let P=new Array(s);for(let N=0;N<s;N++){let D=h*(N+A*s),H=B.subarray(D,D+h);P[N]=Ke(ou(H),n)}v[A]=P}return v}function Pi(r,e){let t=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,f,c]=t.map(m=>m.reduce((E,h)=>r.add(r.mul(E,n),h)));return n=r.div(s,o),i=r.mul(i,r.div(f,c)),{x:n,y:i}}}function Li(r,e,t){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=ta(n,2,{...t,DST:t.DST,...i}),o=r.fromAffine(e(s[0])),f=r.fromAffine(e(s[1])),c=o.add(f).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=ta(n,1,{...t,DST:t.encodeDST,...i}),o=r.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o}}}var uu=BigInt(0),Mi=BigInt(1);function ra(r,e){let t=(i,s)=>{let o=s.negate();return i?o:s},n=i=>{let s=Math.ceil(e/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:t,unsafeLadder(i,s){let o=r.ZERO,f=i;for(;s>uu;)s&Mi&&(o=o.add(f)),f=f.double(),s>>=Mi;return o},precomputeWindow(i,s){let{windows:o,windowSize:f}=n(s),c=[],m=i,E=m;for(let h=0;h<o;h++){E=m,c.push(E);for(let O=1;O<f;O++)E=E.add(m),c.push(E);m=E.double()}return c},wNAF(i,s,o){let{windows:f,windowSize:c}=n(i),m=r.ZERO,E=r.BASE,h=BigInt(2**i-1),O=2**i,B=BigInt(i);for(let v=0;v<f;v++){let A=v*c,P=Number(o&h);o>>=B,P>c&&(P-=O,o+=Mi);let N=A,D=A+Math.abs(P)-1,H=v%2!==0,z=P<0;P===0?E=E.add(t(H,s[N])):m=m.add(t(z,s[D]))}return{p:m,f:E}},wNAFCached(i,s,o,f){let c=i._WINDOW_SIZE||1,m=s.get(i);return m||(m=this.precomputeWindow(i,c),c!==1&&s.set(i,f(m))),this.wNAF(c,m,o)}}}function na(r){return _n(r.Fp),At(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ui(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function lu(r){let e=na(r);At(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:vl,hexToBytes:Al}=Si;var Yt=BigInt(0),Ye=BigInt(1),Mt=BigInt(2),Bn=BigInt(3),ia=BigInt(4);function Di(r){let e=lu(r),{Fp:t}=e,n=e.toBytes||((v,A,P)=>{let N=A.toAffine();return ve(Uint8Array.from([4]),t.toBytes(N.x),t.toBytes(N.y))}),i=e.fromBytes||(v=>{let A=v.subarray(1),P=t.fromBytes(A.subarray(0,t.BYTES)),N=t.fromBytes(A.subarray(t.BYTES,2*t.BYTES));return{x:P,y:N}});function s(v){let{a:A,b:P}=e,N=t.sqr(v),D=t.mul(N,v);return t.add(t.add(D,t.mul(v,A)),P)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(v){return typeof v=="bigint"&&Yt<v&&v<e.n}function f(v){if(!o(v))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(v){let{allowedPrivateKeyLengths:A,nByteLength:P,wrapPrivateKey:N,n:D}=e;if(A&&typeof v!="bigint"){if(rr(v)&&(v=vt(v)),typeof v!="string"||!A.includes(v.length))throw new Error("Invalid key");v=v.padStart(P*2,"0")}let H;try{H=typeof v=="bigint"?v:Ze(ht("private key",v,P))}catch{throw new Error(`private key must be ${P} bytes, hex or bigint, not ${typeof v}`)}return N&&(H=Ke(H,D)),f(H),H}let m=new Map;function E(v){if(!(v instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(A,P,N){if(this.px=A,this.py=P,this.pz=N,A==null||!t.isValid(A))throw new Error("x required");if(P==null||!t.isValid(P))throw new Error("y required");if(N==null||!t.isValid(N))throw new Error("z required")}static fromAffine(A){let{x:P,y:N}=A||{};if(!A||!t.isValid(P)||!t.isValid(N))throw new Error("invalid affine point");if(A instanceof h)throw new Error("projective point not allowed");let D=H=>t.eql(H,t.ZERO);return D(P)&&D(N)?h.ZERO:new h(P,N,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(A){let P=t.invertBatch(A.map(N=>N.pz));return A.map((N,D)=>N.toAffine(P[D])).map(h.fromAffine)}static fromHex(A){let P=h.fromAffine(i(ht("pointHex",A)));return P.assertValidity(),P}static fromPrivateKey(A){return h.BASE.multiply(c(A))}_setWindowSize(A){this._WINDOW_SIZE=A,m.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:A,y:P}=this.toAffine();if(!t.isValid(A)||!t.isValid(P))throw new Error("bad point: x or y not FE");let N=t.sqr(P),D=s(A);if(!t.eql(N,D))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:A}=this.toAffine();if(t.isOdd)return!t.isOdd(A);throw new Error("Field doesn't support isOdd")}equals(A){E(A);let{px:P,py:N,pz:D}=this,{px:H,py:z,pz:q}=A,F=t.eql(t.mul(P,q),t.mul(H,D)),C=t.eql(t.mul(N,q),t.mul(z,D));return F&&C}negate(){return new h(this.px,t.neg(this.py),this.pz)}double(){let{a:A,b:P}=e,N=t.mul(P,Bn),{px:D,py:H,pz:z}=this,q=t.ZERO,F=t.ZERO,C=t.ZERO,Y=t.mul(D,D),$=t.mul(H,H),J=t.mul(z,z),Z=t.mul(D,H);return Z=t.add(Z,Z),C=t.mul(D,z),C=t.add(C,C),q=t.mul(A,C),F=t.mul(N,J),F=t.add(q,F),q=t.sub($,F),F=t.add($,F),F=t.mul(q,F),q=t.mul(Z,q),C=t.mul(N,C),J=t.mul(A,J),Z=t.sub(Y,J),Z=t.mul(A,Z),Z=t.add(Z,C),C=t.add(Y,Y),Y=t.add(C,Y),Y=t.add(Y,J),Y=t.mul(Y,Z),F=t.add(F,Y),J=t.mul(H,z),J=t.add(J,J),Y=t.mul(J,Z),q=t.sub(q,Y),C=t.mul(J,$),C=t.add(C,C),C=t.add(C,C),new h(q,F,C)}add(A){E(A);let{px:P,py:N,pz:D}=this,{px:H,py:z,pz:q}=A,F=t.ZERO,C=t.ZERO,Y=t.ZERO,$=e.a,J=t.mul(e.b,Bn),Z=t.mul(P,H),te=t.mul(N,z),ce=t.mul(D,q),me=t.add(P,N),ue=t.add(H,z);me=t.mul(me,ue),ue=t.add(Z,te),me=t.sub(me,ue),ue=t.add(P,D);let k=t.add(H,q);return ue=t.mul(ue,k),k=t.add(Z,ce),ue=t.sub(ue,k),k=t.add(N,D),F=t.add(z,q),k=t.mul(k,F),F=t.add(te,ce),k=t.sub(k,F),Y=t.mul($,ue),F=t.mul(J,ce),Y=t.add(F,Y),F=t.sub(te,Y),Y=t.add(te,Y),C=t.mul(F,Y),te=t.add(Z,Z),te=t.add(te,Z),ce=t.mul($,ce),ue=t.mul(J,ue),te=t.add(te,ce),ce=t.sub(Z,ce),ce=t.mul($,ce),ue=t.add(ue,ce),Z=t.mul(te,ue),C=t.add(C,Z),Z=t.mul(k,ue),F=t.mul(me,F),F=t.sub(F,Z),Z=t.mul(me,te),Y=t.mul(k,Y),Y=t.add(Y,Z),new h(F,C,Y)}subtract(A){return this.add(A.negate())}is0(){return this.equals(h.ZERO)}wNAF(A){return B.wNAFCached(this,m,A,P=>{let N=t.invertBatch(P.map(D=>D.pz));return P.map((D,H)=>D.toAffine(N[H])).map(h.fromAffine)})}multiplyUnsafe(A){let P=h.ZERO;if(A===Yt)return P;if(f(A),A===Ye)return this;let{endo:N}=e;if(!N)return B.unsafeLadder(this,A);let{k1neg:D,k1:H,k2neg:z,k2:q}=N.splitScalar(A),F=P,C=P,Y=this;for(;H>Yt||q>Yt;)H&Ye&&(F=F.add(Y)),q&Ye&&(C=C.add(Y)),Y=Y.double(),H>>=Ye,q>>=Ye;return D&&(F=F.negate()),z&&(C=C.negate()),C=new h(t.mul(C.px,N.beta),C.py,C.pz),F.add(C)}multiply(A){f(A);let P=A,N,D,{endo:H}=e;if(H){let{k1neg:z,k1:q,k2neg:F,k2:C}=H.splitScalar(P),{p:Y,f:$}=this.wNAF(q),{p:J,f:Z}=this.wNAF(C);Y=B.constTimeNegate(z,Y),J=B.constTimeNegate(F,J),J=new h(t.mul(J.px,H.beta),J.py,J.pz),N=Y.add(J),D=$.add(Z)}else{let{p:z,f:q}=this.wNAF(P);N=z,D=q}return h.normalizeZ([N,D])[0]}multiplyAndAddUnsafe(A,P,N){let D=h.BASE,H=(q,F)=>F===Yt||F===Ye||!q.equals(D)?q.multiplyUnsafe(F):q.multiply(F),z=H(this,P).add(H(A,N));return z.is0()?void 0:z}toAffine(A){let{px:P,py:N,pz:D}=this,H=this.is0();A==null&&(A=H?t.ONE:t.inv(D));let z=t.mul(P,A),q=t.mul(N,A),F=t.mul(D,A);if(H)return{x:t.ZERO,y:t.ZERO};if(!t.eql(F,t.ONE))throw new Error("invZ was invalid");return{x:z,y:q}}isTorsionFree(){let{h:A,isTorsionFree:P}=e;if(A===Ye)return!0;if(P)return P(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:A,clearCofactor:P}=e;return A===Ye?this:P?P(h,this):this.multiplyUnsafe(e.h)}toRawBytes(A=!0){return this.assertValidity(),n(h,this,A)}toHex(A=!0){return vt(this.toRawBytes(A))}}h.BASE=new h(e.Gx,e.Gy,t.ONE),h.ZERO=new h(t.ZERO,t.ONE,t.ZERO);let O=e.nBitLength,B=ra(h,e.endo?Math.ceil(O/2):O);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:o}}function du(r,e){let t=r.ORDER,n=Yt;for(let v=t-Ye;v%Mt===Yt;v/=Mt)n+=Ye;let i=n,s=Mt<<i-Ye-Ye,o=s*Mt,f=(t-Ye)/o,c=(f-Ye)/Mt,m=o-Ye,E=s,h=r.pow(e,f),O=r.pow(e,(f+Ye)/Mt),B=(v,A)=>{let P=h,N=r.pow(A,m),D=r.sqr(N);D=r.mul(D,A);let H=r.mul(v,D);H=r.pow(H,c),H=r.mul(H,N),N=r.mul(H,A),D=r.mul(H,v);let z=r.mul(D,N);H=r.pow(z,E);let q=r.eql(H,r.ONE);N=r.mul(D,O),H=r.mul(z,P),D=r.cmov(N,D,q),z=r.cmov(H,z,q);for(let F=i;F>Ye;F--){let C=F-Mt;C=Mt<<C-Ye;let Y=r.pow(z,C),$=r.eql(Y,r.ONE);N=r.mul(D,P),P=r.mul(P,P),Y=r.mul(z,P),D=r.cmov(N,D,$),z=r.cmov(Y,z,$)}return{isValid:q,value:D}};if(r.ORDER%ia===Bn){let v=(r.ORDER-Bn)/ia,A=r.sqrt(r.neg(e));B=(P,N)=>{let D=r.sqr(N),H=r.mul(P,N);D=r.mul(D,H);let z=r.pow(D,v);z=r.mul(z,H);let q=r.mul(z,A),F=r.mul(r.sqr(z),N),C=r.eql(F,P),Y=r.cmov(q,z,C);return{isValid:C,value:Y}}}return B}function qi(r,e){if(_n(r),!r.isValid(e.A)||!r.isValid(e.B)||!r.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let t=du(r,e.Z);if(!r.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,f,c,m,E,h;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),f=r.cmov(e.Z,r.neg(s),!r.eql(s,r.ZERO)),f=r.mul(f,e.A),s=r.sqr(o),m=r.sqr(f),c=r.mul(m,e.A),s=r.add(s,c),s=r.mul(s,o),m=r.mul(m,f),c=r.mul(m,e.B),s=r.add(s,c),E=r.mul(i,o);let{isValid:O,value:B}=t(s,m);h=r.mul(i,n),h=r.mul(h,B),E=r.cmov(E,o,O),h=r.cmov(h,B,O);let v=r.isOdd(n)===r.isOdd(h);return h=r.cmov(r.neg(h),h,v),E=r.div(E,f),{x:E,y:h}}}var $i=BigInt(2),vn=BigInt(3);function sa(r){let{Fp:e,Fr:t,Fp2:n,Fp6:i,Fp12:s}=r.fields,o=Ft(r.params.x);function f(k){let{x:ee,y:Q}=k,re=ee,fe=Q,ge=n.ONE,Ie=re,R=fe,g=ge,Ue=[];for(let Re=o-2;Re>=0;Re--){let ye=n.sqr(R),j=n.sqr(g),a=n.multiplyByB(n.mul(j,vn)),u=n.mul(a,vn),l=n.sub(n.sub(n.sqr(n.add(R,g)),j),ye);if(Ue.push([n.sub(a,ye),n.mul(n.sqr(Ie),vn),n.neg(l)]),Ie=n.div(n.mul(n.mul(n.sub(ye,u),Ie),R),$i),R=n.sub(n.sqr(n.div(n.add(ye,u),$i)),n.mul(n.sqr(a),vn)),g=n.mul(ye,l),nr(r.params.x,Re)){let _=n.sub(R,n.mul(fe,g)),y=n.sub(Ie,n.mul(re,g));Ue.push([n.sub(n.mul(_,re),n.mul(y,fe)),n.neg(_),y]);let w=n.sqr(y),T=n.mul(w,y),p=n.mul(w,Ie),x=n.add(n.sub(T,n.mul(p,$i)),n.mul(n.sqr(_),g));Ie=n.mul(y,x),R=n.sub(n.mul(n.sub(p,x),_),n.mul(T,R)),g=n.mul(g,T)}}return Ue}function c(k,ee){let{x:Q}=r.params,re=ee[0],fe=ee[1],ge=s.ONE;for(let Ie=0,R=o-2;R>=0;R--,Ie++){let g=k[Ie];if(ge=s.multiplyBy014(ge,g[0],n.mul(g[1],re),n.mul(g[2],fe)),nr(Q,R)){Ie+=1;let Ue=k[Ie];ge=s.multiplyBy014(ge,Ue[0],n.mul(Ue[1],re),n.mul(Ue[2],fe))}R!==0&&(ge=s.sqr(ge))}return s.conjugate(ge)}let m={randomPrivateKey:()=>{let k=In(t.ORDER);return Oi(r.randomBytes(k),t.ORDER)},calcPairingPrecomputes:f},E=Di({n:t.ORDER,...r.G1}),h=Object.assign(E,Li(E.ProjectivePoint,r.G1.mapToCurve,{...r.htfDefaults,...r.G1.htfDefaults}));function O(k){let ee=k;return ee._PPRECOMPUTES||(ee._PPRECOMPUTES=f(k.toAffine())),ee._PPRECOMPUTES}let B=Di({n:t.ORDER,...r.G2}),v=Object.assign(B,Li(B.ProjectivePoint,r.G2.mapToCurve,{...r.htfDefaults,...r.G2.htfDefaults})),{ShortSignature:A}=r.G1,{Signature:P}=r.G2;function N(k,ee,Q=!0){if(k.equals(h.ProjectivePoint.ZERO)||ee.equals(v.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");k.assertValidity(),ee.assertValidity();let re=k.toAffine(),fe=c(O(ee),[re.x,re.y]);return Q?s.finalExponentiate(fe):fe}function D(k){return k instanceof h.ProjectivePoint?k:h.ProjectivePoint.fromHex(k)}function H(k,ee){return k instanceof h.ProjectivePoint?k:h.hashToCurve(ht("point",k),ee)}function z(k){return k instanceof v.ProjectivePoint?k:P.fromHex(k)}function q(k,ee){return k instanceof v.ProjectivePoint?k:v.hashToCurve(ht("point",k),ee)}function F(k){return h.ProjectivePoint.fromPrivateKey(k).toRawBytes(!0)}function C(k){return v.ProjectivePoint.fromPrivateKey(k).toRawBytes(!0)}function Y(k,ee,Q){let re=q(k,Q);re.assertValidity();let fe=re.multiply(h.normPrivateKeyToScalar(ee));return k instanceof v.ProjectivePoint?fe:P.toRawBytes(fe)}function $(k,ee,Q){let re=H(k,Q);re.assertValidity();let fe=re.multiply(h.normPrivateKeyToScalar(ee));return k instanceof h.ProjectivePoint?fe:A.toRawBytes(fe)}function J(k,ee,Q,re){let fe=D(Q),ge=q(ee,re),Ie=h.ProjectivePoint.BASE,R=z(k),g=N(fe.negate(),ge,!1),Ue=N(Ie,R,!1),Re=s.finalExponentiate(s.mul(Ue,g));return s.eql(Re,s.ONE)}function Z(k,ee,Q,re){let fe=z(Q),ge=H(ee,re),Ie=v.ProjectivePoint.BASE,R=D(k),g=N(ge,fe,!1),Ue=N(R,Ie.negate(),!1),Re=s.finalExponentiate(s.mul(Ue,g));return s.eql(Re,s.ONE)}function te(k){if(!k.length)throw new Error("Expected non-empty array");let Q=k.map(D).reduce((re,fe)=>re.add(fe),h.ProjectivePoint.ZERO);return k[0]instanceof h.ProjectivePoint?(Q.assertValidity(),Q):Q.toRawBytes(!0)}function ce(k){if(!k.length)throw new Error("Expected non-empty array");let Q=k.map(z).reduce((re,fe)=>re.add(fe),v.ProjectivePoint.ZERO);return k[0]instanceof v.ProjectivePoint?(Q.assertValidity(),Q):P.toRawBytes(Q)}function me(k){if(!k.length)throw new Error("Expected non-empty array");let Q=k.map(D).reduce((re,fe)=>re.add(fe),h.ProjectivePoint.ZERO);return k[0]instanceof h.ProjectivePoint?(Q.assertValidity(),Q):A.toRawBytes(Q)}function ue(k,ee,Q,re){if(!ee.length)throw new Error("Expected non-empty messages array");if(Q.length!==ee.length)throw new Error("Pubkey count should equal msg count");let fe=z(k),ge=ee.map(R=>q(R,re)),Ie=Q.map(D);try{let R=[];for(let Re of new Set(ge)){let ye=ge.reduce((j,a,u)=>a===Re?j.add(Ie[u]):j,h.ProjectivePoint.ZERO);R.push(N(ye,Re,!1))}R.push(N(h.ProjectivePoint.BASE.negate(),fe,!1));let g=R.reduce((Re,ye)=>s.mul(Re,ye),s.ONE),Ue=s.finalExponentiate(g);return s.eql(Ue,s.ONE)}catch{return!1}}return h.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:F,getPublicKeyForShortSignatures:C,sign:Y,signShortSignature:$,verify:J,verifyBatch:ue,verifyShortSignature:Z,aggregatePublicKeys:te,aggregateSignatures:ce,aggregateShortSignatures:me,millerLoop:c,pairing:N,G1:h,G2:v,Signature:P,ShortSignature:A,fields:{Fr:t,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{x:r.params.x,r:r.params.r,G1b:r.G1.b,G2b:r.G2.b},utils:m}}var Le=BigInt(0),Ht=BigInt(1),Ae=BigInt(2),An=BigInt(3),Br=BigInt(4),hu=BigInt(8),pu=BigInt(16),Gi=BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),U=Ri(Gi),oa=Ri(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),aa=({c0:r,c1:e},{c0:t,c1:n})=>({c0:U.add(r,t),c1:U.add(e,n)}),ca=({c0:r,c1:e},{c0:t,c1:n})=>({c0:U.sub(r,t),c1:U.sub(e,n)}),fa=({c0:r,c1:e},t)=>{if(typeof t=="bigint")return{c0:U.mul(r,t),c1:U.mul(e,t)};let{c0:n,c1:i}=t,s=U.mul(r,n),o=U.mul(e,i),f=U.sub(s,o),c=U.sub(U.mul(U.add(r,e),U.add(n,i)),U.add(s,o));return{c0:f,c1:c}},ua=({c0:r,c1:e})=>{let t=U.add(r,e),n=U.sub(r,e),i=U.add(r,r);return{c0:U.mul(t,n),c1:U.mul(i,e)}},Sn=Gi*Gi,d={ORDER:Sn,BITS:Ft(Sn),BYTES:Math.ceil(Ft(Sn)/8),MASK:Pt(Ft(Sn)),ZERO:{c0:U.ZERO,c1:U.ZERO},ONE:{c0:U.ONE,c1:U.ZERO},create:r=>r,isValid:({c0:r,c1:e})=>typeof r=="bigint"&&typeof e=="bigint",is0:({c0:r,c1:e})=>U.is0(r)&&U.is0(e),eql:({c0:r,c1:e},{c0:t,c1:n})=>U.eql(r,t)&&U.eql(e,n),neg:({c0:r,c1:e})=>({c0:U.neg(r),c1:U.neg(e)}),pow:(r,e)=>_r(d,r,e),invertBatch:r=>Ir(d,r),add:aa,sub:ca,mul:fa,sqr:ua,addN:aa,subN:ca,mulN:fa,sqrN:ua,div:(r,e)=>d.mul(r,typeof e=="bigint"?U.inv(U.create(e)):d.inv(e)),inv:({c0:r,c1:e})=>{let t=U.inv(U.create(r*r+e*e));return{c0:U.mul(t,U.create(r)),c1:U.mul(t,U.create(-e))}},sqrt:r=>{if(d.eql(r,d.ZERO))return d.ZERO;let e=d.pow(r,(d.ORDER+hu)/pu),t=d.div(d.sqr(e),r),n=gu,i=[n[0],n[2],n[4],n[6]].find(B=>d.eql(B,t));if(!i)throw new Error("No root");let s=n.indexOf(i),o=n[s/2];if(!o)throw new Error("Invalid root");let f=d.div(e,o),c=d.neg(f),{re:m,im:E}=d.reim(f),{re:h,im:O}=d.reim(c);return E>O||E===O&&m>h?f:c},isOdd:r=>{let{re:e,im:t}=d.reim(r),n=e%Ae,i=e===Le,s=t%Ae;return BigInt(n||i&&s)==Ht},fromBytes(r){if(r.length!==d.BYTES)throw new Error(`fromBytes wrong length=${r.length}`);return{c0:U.fromBytes(r.subarray(0,U.BYTES)),c1:U.fromBytes(r.subarray(U.BYTES))}},toBytes:({c0:r,c1:e})=>ve(U.toBytes(r),U.toBytes(e)),cmov:({c0:r,c1:e},{c0:t,c1:n},i)=>({c0:U.cmov(r,t,i),c1:U.cmov(e,n,i)}),reim:({c0:r,c1:e})=>({re:r,im:e}),mulByNonresidue:({c0:r,c1:e})=>({c0:U.sub(r,e),c1:U.add(r,e)}),multiplyByB:({c0:r,c1:e})=>{let t=U.mul(r,Br),n=U.mul(e,Br);return{c0:U.sub(t,n),c1:U.add(t,n)}},fromBigTuple:r=>{if(r.length!==2)throw new Error("Invalid tuple");let e=r.map(t=>U.create(t));return{c0:e[0],c1:e[1]}},frobeniusMap:({c0:r,c1:e},t)=>({c0:r,c1:U.mul(e,bu[t%2])})},bu=[BigInt("0x1"),BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa")].map(r=>U.create(r)),Dt=BigInt("0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),gu=[[Ht,Le],[Dt,-Dt],[Le,Ht],[Dt,Dt],[-Ht,Le],[-Dt,Dt],[Le,-Ht],[-Dt,-Dt]].map(r=>d.fromBigTuple(r)),la=({c0:r,c1:e,c2:t},{c0:n,c1:i,c2:s})=>({c0:d.add(r,n),c1:d.add(e,i),c2:d.add(t,s)}),da=({c0:r,c1:e,c2:t},{c0:n,c1:i,c2:s})=>({c0:d.sub(r,n),c1:d.sub(e,i),c2:d.sub(t,s)}),ha=({c0:r,c1:e,c2:t},n)=>{if(typeof n=="bigint")return{c0:d.mul(r,n),c1:d.mul(e,n),c2:d.mul(t,n)};let{c0:i,c1:s,c2:o}=n,f=d.mul(r,i),c=d.mul(e,s),m=d.mul(t,o);return{c0:d.add(f,d.mulByNonresidue(d.sub(d.mul(d.add(e,t),d.add(s,o)),d.add(c,m)))),c1:d.add(d.sub(d.mul(d.add(r,e),d.add(i,s)),d.add(f,c)),d.mulByNonresidue(m)),c2:d.sub(d.add(c,d.mul(d.add(r,t),d.add(i,o))),d.add(f,m))}},pa=({c0:r,c1:e,c2:t})=>{let n=d.sqr(r),i=d.mul(d.mul(r,e),Ae),s=d.mul(d.mul(e,t),Ae),o=d.sqr(t);return{c0:d.add(d.mulByNonresidue(s),n),c1:d.add(d.mulByNonresidue(o),i),c2:d.sub(d.sub(d.add(d.add(i,d.sqr(d.add(d.sub(r,e),t))),s),n),o)}},V={ORDER:d.ORDER,BITS:3*d.BITS,BYTES:3*d.BYTES,MASK:Pt(3*d.BITS),ZERO:{c0:d.ZERO,c1:d.ZERO,c2:d.ZERO},ONE:{c0:d.ONE,c1:d.ZERO,c2:d.ZERO},create:r=>r,isValid:({c0:r,c1:e,c2:t})=>d.isValid(r)&&d.isValid(e)&&d.isValid(t),is0:({c0:r,c1:e,c2:t})=>d.is0(r)&&d.is0(e)&&d.is0(t),neg:({c0:r,c1:e,c2:t})=>({c0:d.neg(r),c1:d.neg(e),c2:d.neg(t)}),eql:({c0:r,c1:e,c2:t},{c0:n,c1:i,c2:s})=>d.eql(r,n)&&d.eql(e,i)&&d.eql(t,s),sqrt:()=>{throw new Error("Not implemented")},div:(r,e)=>V.mul(r,typeof e=="bigint"?U.inv(U.create(e)):V.inv(e)),pow:(r,e)=>_r(V,r,e),invertBatch:r=>Ir(V,r),add:la,sub:da,mul:ha,sqr:pa,addN:la,subN:da,mulN:ha,sqrN:pa,inv:({c0:r,c1:e,c2:t})=>{let n=d.sub(d.sqr(r),d.mulByNonresidue(d.mul(t,e))),i=d.sub(d.mulByNonresidue(d.sqr(t)),d.mul(r,e)),s=d.sub(d.sqr(e),d.mul(r,t)),o=d.inv(d.add(d.mulByNonresidue(d.add(d.mul(t,i),d.mul(e,s))),d.mul(r,n)));return{c0:d.mul(o,n),c1:d.mul(o,i),c2:d.mul(o,s)}},fromBytes:r=>{if(r.length!==V.BYTES)throw new Error(`fromBytes wrong length=${r.length}`);return{c0:d.fromBytes(r.subarray(0,d.BYTES)),c1:d.fromBytes(r.subarray(d.BYTES,2*d.BYTES)),c2:d.fromBytes(r.subarray(2*d.BYTES))}},toBytes:({c0:r,c1:e,c2:t})=>ve(d.toBytes(r),d.toBytes(e),d.toBytes(t)),cmov:({c0:r,c1:e,c2:t},{c0:n,c1:i,c2:s},o)=>({c0:d.cmov(r,n,o),c1:d.cmov(e,i,o),c2:d.cmov(t,s,o)}),fromBigSix:r=>{if(!Array.isArray(r)||r.length!==6)throw new Error("Invalid Fp6 usage");return{c0:d.fromBigTuple(r.slice(0,2)),c1:d.fromBigTuple(r.slice(2,4)),c2:d.fromBigTuple(r.slice(4,6))}},frobeniusMap:({c0:r,c1:e,c2:t},n)=>({c0:d.frobeniusMap(r,n),c1:d.mul(d.frobeniusMap(e,n),mu[n%6]),c2:d.mul(d.frobeniusMap(t,n),yu[n%6])}),mulByNonresidue:({c0:r,c1:e,c2:t})=>({c0:d.mulByNonresidue(t),c1:r,c2:e}),multiplyBy1:({c0:r,c1:e,c2:t},n)=>({c0:d.mulByNonresidue(d.mul(t,n)),c1:d.mul(r,n),c2:d.mul(e,n)}),multiplyBy01({c0:r,c1:e,c2:t},n,i){let s=d.mul(r,n),o=d.mul(e,i);return{c0:d.add(d.mulByNonresidue(d.sub(d.mul(d.add(e,t),i),o)),s),c1:d.sub(d.sub(d.mul(d.add(n,i),d.add(r,e)),s),o),c2:d.add(d.sub(d.mul(d.add(r,t),n),s),o)}},multiplyByFp2:({c0:r,c1:e,c2:t},n)=>({c0:d.mul(r,n),c1:d.mul(e,n),c2:d.mul(t,n)})},mu=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe")]].map(r=>d.fromBigTuple(r)),yu=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")]].map(r=>d.fromBigTuple(r)),Vi=BigInt("0xd201000000010000"),xu=Ft(Vi),ba=({c0:r,c1:e},{c0:t,c1:n})=>({c0:V.add(r,t),c1:V.add(e,n)}),ga=({c0:r,c1:e},{c0:t,c1:n})=>({c0:V.sub(r,t),c1:V.sub(e,n)}),ma=({c0:r,c1:e},t)=>{if(typeof t=="bigint")return{c0:V.mul(r,t),c1:V.mul(e,t)};let{c0:n,c1:i}=t,s=V.mul(r,n),o=V.mul(e,i);return{c0:V.add(s,V.mulByNonresidue(o)),c1:V.sub(V.mul(V.add(r,e),V.add(n,i)),V.add(s,o))}},ya=({c0:r,c1:e})=>{let t=V.mul(r,e);return{c0:V.sub(V.sub(V.mul(V.add(V.mulByNonresidue(e),r),V.add(r,e)),t),V.mulByNonresidue(t)),c1:V.add(t,t)}};function ki(r,e){let t=d.sqr(r),n=d.sqr(e);return{first:d.add(d.mulByNonresidue(n),t),second:d.sub(d.sub(d.sqr(d.add(r,e)),t),n)}}var X={ORDER:d.ORDER,BITS:2*d.BITS,BYTES:2*d.BYTES,MASK:Pt(2*d.BITS),ZERO:{c0:V.ZERO,c1:V.ZERO},ONE:{c0:V.ONE,c1:V.ZERO},create:r=>r,isValid:({c0:r,c1:e})=>V.isValid(r)&&V.isValid(e),is0:({c0:r,c1:e})=>V.is0(r)&&V.is0(e),neg:({c0:r,c1:e})=>({c0:V.neg(r),c1:V.neg(e)}),eql:({c0:r,c1:e},{c0:t,c1:n})=>V.eql(r,t)&&V.eql(e,n),sqrt:()=>{throw new Error("Not implemented")},inv:({c0:r,c1:e})=>{let t=V.inv(V.sub(V.sqr(r),V.mulByNonresidue(V.sqr(e))));return{c0:V.mul(r,t),c1:V.neg(V.mul(e,t))}},div:(r,e)=>X.mul(r,typeof e=="bigint"?U.inv(U.create(e)):X.inv(e)),pow:(r,e)=>_r(X,r,e),invertBatch:r=>Ir(X,r),add:ba,sub:ga,mul:ma,sqr:ya,addN:ba,subN:ga,mulN:ma,sqrN:ya,fromBytes:r=>{if(r.length!==X.BYTES)throw new Error(`fromBytes wrong length=${r.length}`);return{c0:V.fromBytes(r.subarray(0,V.BYTES)),c1:V.fromBytes(r.subarray(V.BYTES))}},toBytes:({c0:r,c1:e})=>ve(V.toBytes(r),V.toBytes(e)),cmov:({c0:r,c1:e},{c0:t,c1:n},i)=>({c0:V.cmov(r,t,i),c1:V.cmov(e,n,i)}),fromBigTwelve:r=>({c0:V.fromBigSix(r.slice(0,6)),c1:V.fromBigSix(r.slice(6,12))}),frobeniusMap(r,e){let t=V.frobeniusMap(r.c0,e),{c0:n,c1:i,c2:s}=V.frobeniusMap(r.c1,e),o=wu[e%12];return{c0:t,c1:V.create({c0:d.mul(n,o),c1:d.mul(i,o),c2:d.mul(s,o)})}},multiplyBy014:({c0:r,c1:e},t,n,i)=>{let s=V.multiplyBy01(r,t,n),o=V.multiplyBy1(e,i);return{c0:V.add(V.mulByNonresidue(o),s),c1:V.sub(V.sub(V.multiplyBy01(V.add(e,r),t,d.add(n,i)),s),o)}},multiplyByFp2:({c0:r,c1:e},t)=>({c0:V.multiplyByFp2(r,t),c1:V.multiplyByFp2(e,t)}),conjugate:({c0:r,c1:e})=>({c0:r,c1:V.neg(e)}),_cyclotomicSquare:({c0:r,c1:e})=>{let{c0:t,c1:n,c2:i}=r,{c0:s,c1:o,c2:f}=e,{first:c,second:m}=ki(t,o),{first:E,second:h}=ki(s,i),{first:O,second:B}=ki(n,f),v=d.mulByNonresidue(B);return{c0:V.create({c0:d.add(d.mul(d.sub(c,t),Ae),c),c1:d.add(d.mul(d.sub(E,n),Ae),E),c2:d.add(d.mul(d.sub(O,i),Ae),O)}),c1:V.create({c0:d.add(d.mul(d.add(v,s),Ae),v),c1:d.add(d.mul(d.add(m,o),Ae),m),c2:d.add(d.mul(d.add(h,f),Ae),h)})}},_cyclotomicExp(r,e){let t=X.ONE;for(let n=xu-1;n>=0;n--)t=X._cyclotomicSquare(t),nr(e,n)&&(t=X.mul(t,r));return t},finalExponentiate:r=>{let e=Vi,t=X.div(X.frobeniusMap(r,6),r),n=X.mul(X.frobeniusMap(t,2),t),i=X.conjugate(X._cyclotomicExp(n,e)),s=X.mul(X.conjugate(X._cyclotomicSquare(n)),i),o=X.conjugate(X._cyclotomicExp(s,e)),f=X.conjugate(X._cyclotomicExp(o,e)),c=X.mul(X.conjugate(X._cyclotomicExp(f,e)),X._cyclotomicSquare(i)),m=X.conjugate(X._cyclotomicExp(c,e)),E=X.frobeniusMap(X.mul(i,f),2),h=X.frobeniusMap(X.mul(o,n),3),O=X.frobeniusMap(X.mul(c,X.conjugate(n)),1),B=X.mul(X.mul(m,X.conjugate(s)),n);return X.mul(X.mul(X.mul(E,h),O),B)}},wu=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8"),BigInt("0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")],[BigInt("0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2"),BigInt("0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995"),BigInt("0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3"),BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),BigInt("0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116"),BigInt("0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995")]].map(r=>d.fromBigTuple(r)),Eu=Pi(d,[[["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=>d.fromBigTuple(e.map(BigInt))))),_u=Pi(U,[["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)))),Iu=qi(d,{A:d.create({c0:U.create(Le),c1:U.create(BigInt(240))}),B:d.create({c0:U.create(BigInt(1012)),c1:U.create(BigInt(1012))}),Z:d.create({c0:U.create(BigInt(-2)),c1:U.create(BigInt(-1))})}),Bu=qi(U,{A:U.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:U.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:U.create(BigInt(11))}),_a=V.create({c0:d.ZERO,c1:d.ONE,c2:d.ZERO}),Ia=X.create({c0:_a,c1:V.ZERO}),Ba=X.create({c0:V.ZERO,c1:_a}),[vu,Au]=X.invertBatch([Ia,Ba]);function Su(r,e){let t=X.mul(X.frobeniusMap(X.multiplyByFp2(vu,r),1),Ia).c0.c0,n=X.mul(X.frobeniusMap(X.multiplyByFp2(Au,e),1),Ba).c0.c0;return[t,n]}function xa(r,e){let t=e.toAffine(),n=Su(t.x,t.y);return new r(n[0],n[1],d.ONE)}var Tu=BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac");function Nu(r,e){return[d.mul(r,Tu),d.neg(e)]}function Uu(r,e){let t=e.toAffine(),n=Nu(t.x,t.y);return new r(n[0],n[1],d.ONE)}var Ci=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:U.ORDER,m:2,k:128,expand:"xmd",hash:cr}),Nn=vr(U.toBytes(Le),{infinity:!0,compressed:!0});function Tn(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 vr(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 wa(r){r.assertValidity();let e=r.equals(He.G1.ProjectivePoint.ZERO),{x:t,y:n}=r.toAffine();if(e)return Nn.slice();let i=U.ORDER,s=!!(n*Ae/i);return vr(Ne(t,U.BYTES),{compressed:!0,sort:s})}function Ea(r){r.assertValidity();let e=U.BYTES;if(r.equals(He.G2.ProjectivePoint.ZERO))return ve(Nn,Ne(Le,e));let{x:t,y:n}=r.toAffine(),{re:i,im:s}=d.reim(t),{re:o,im:f}=d.reim(n),m=!!((f>Le?f*Ae:o*Ae)/U.ORDER&Ht),E=i;return ve(vr(Ne(s,e),{sort:m,compressed:!0}),Ne(E,e))}var He=sa({fields:{Fp:U,Fp2:d,Fp6:V,Fp12:X,Fr:oa},G1:{Fp:U,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:U.ZERO,b:Br,htfDefaults:{...Ci,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(U.mul(e.px,t),e.py,e.pz);return e.multiplyUnsafe(He.params.x).negate().multiplyUnsafe(He.params.x).equals(n)},clearCofactor:(r,e)=>e.multiplyUnsafe(He.params.x).add(e),mapToCurve:r=>{let{x:e,y:t}=Bu(U.create(r[0]));return _u(e,t)},fromBytes:r=>{let{compressed:e,infinity:t,sort:n,value:i}=Tn(r);if(i.length===48&&e){let s=U.ORDER,o=Ze(i),f=U.create(o&U.MASK);if(t){if(f!==Le)throw new Error("G1: non-empty compressed point at infinity");return{x:Le,y:Le}}let c=U.add(U.pow(f,An),U.create(He.params.G1b)),m=U.sqrt(c);if(!m)throw new Error("Invalid compressed G1 point");return m*Ae/s!==BigInt(n)&&(m=U.neg(m)),{x:U.create(f),y:U.create(m)}}else if(i.length===96&&!e){let s=Ze(i.subarray(0,U.BYTES)),o=Ze(i.subarray(U.BYTES));if(t){if(s!==Le||o!==Le)throw new Error("G1: non-empty point at infinity");return He.G1.ProjectivePoint.ZERO.toAffine()}return{x:U.create(s),y:U.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 Nn.slice();let o=U.ORDER,f=!!(s*Ae/o);return vr(Ne(i,U.BYTES),{compressed:!0,sort:f})}else return n?ve(new Uint8Array([64]),new Uint8Array(2*U.BYTES-1)):ve(Ne(i,U.BYTES),Ne(s,U.BYTES))},ShortSignature:{fromHex(r){let{infinity:e,sort:t,value:n}=Tn(ht("signatureHex",r,48)),i=U.ORDER,s=Ze(n);if(e)return He.G1.ProjectivePoint.ZERO;let o=U.create(s&U.MASK),f=U.add(U.pow(o,An),U.create(He.params.G1b)),c=U.sqrt(f);if(!c)throw new Error("Invalid compressed G1 point");let m=BigInt(t);c*Ae/i!==m&&(c=U.neg(c));let E=He.G1.ProjectivePoint.fromAffine({x:o,y:c});return E.assertValidity(),E},toRawBytes(r){return wa(r)},toHex(r){return vt(wa(r))}}},G2:{Fp:d,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:d.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:d.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:d.ZERO,b:d.fromBigTuple([Br,Br]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...Ci},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:r=>{let{x:e,y:t}=Iu(d.fromBigTuple(r));return Eu(e,t)},isTorsionFree:(r,e)=>e.multiplyUnsafe(He.params.x).negate().equals(xa(r,e)),clearCofactor:(r,e)=>{let t=He.params.x,n=e.multiplyUnsafe(t).negate(),i=xa(r,e),s=e.double();return s=Uu(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}=Tn(r);if(!e&&!t&&n||!e&&t&&n||n&&t&&e)throw new Error("Invalid encoding flag: "+(r[0]&224));let s=U.BYTES,o=(f,c,m)=>Ze(f.slice(c,m));if(i.length===96&&e){let f=He.params.G2b,c=U.ORDER;if(t){if(i.reduce((A,P)=>A!==0?P+1:P,0)>0)throw new Error("Invalid compressed G2 point");return{x:d.ZERO,y:d.ZERO}}let m=o(i,0,s),E=o(i,s,2*s),h=d.create({c0:U.create(E),c1:U.create(m)}),O=d.add(d.pow(h,An),f),B=d.sqrt(O),v=B.c1===Le?B.c0*Ae/c:B.c1*Ae/c?Ht:Le;return B=n&&v>0?B:d.neg(B),{x:h,y:B}}else if(i.length===192&&!e){if(t){if(i.reduce((h,O)=>h!==0?O+1:O,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:d.ZERO,y:d.ZERO}}let f=o(i,0,s),c=o(i,s,2*s),m=o(i,2*s,3*s),E=o(i,3*s,4*s);return{x:d.fromBigTuple([c,f]),y:d.fromBigTuple([E,m])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(r,e,t)=>{let{BYTES:n,ORDER:i}=U,s=e.equals(r.ZERO),{x:o,y:f}=e.toAffine();if(t){if(s)return ve(Nn,Ne(Le,n));let c=!!(f.c1===Le?f.c0*Ae/i:f.c1*Ae/i);return ve(vr(Ne(o.c1,n),{compressed:!0,sort:c}),Ne(o.c0,n))}else{if(s)return ve(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:m}=d.reim(o),{re:E,im:h}=d.reim(f);return ve(Ne(m,n),Ne(c,n),Ne(h,n),Ne(E,n))}},Signature:{fromHex(r){let{infinity:e,sort:t,value:n}=Tn(ht("signatureHex",r)),i=U.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=Ze(n.slice(0,s)),f=Ze(n.slice(s));if(e)return He.G2.ProjectivePoint.ZERO;let c=U.create(o&U.MASK),m=U.create(f),E=d.create({c0:m,c1:c}),h=d.add(d.pow(E,An),He.params.G2b),O=d.sqrt(h);if(!O)throw new Error("Failed to find a square root");let{re:B,im:v}=d.reim(O),A=BigInt(t),P=v>Le&&v*Ae/i!==A,N=v===Le&&B*Ae/i!==A;(P||N)&&(O=d.neg(O));let D=He.G2.ProjectivePoint.fromAffine({x:E,y:O});return D.assertValidity(),D},toRawBytes(r){return Ea(r)},toHex(r){return vt(Ea(r))}}},params:{x:Vi,r:oa.ORDER},htfDefaults:Ci,hash:cr,randomBytes:Ji});function va(r,e,t){let n=typeof r=="string"?r:ft(r),i=typeof e=="string"?e:ft(e),s=typeof t=="string"?t:ft(t);return He.verifyShortSignature(i,s,n)}var Yi=r=>Fe(new ut(r)),Un=r=>{let e=Yi(r);return new Date(Number(e)/1e6)};var qt=class extends Kt{constructor(e){super(`Invalid certificate: ${e}`)}},xt={Empty:0,Fork:1,Labeled:2,Leaf:3,Pruned:4};function Aa(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0}var On=class r{constructor(e,t,n,i,s=5){this._rootKey=t,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=Jt(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=va),new r(e.certificate,e.rootKey,e.canisterId,t,e.maxAgeInMinutes)}lookup(e){return Hi(ir(e,this.cert.tree))}lookup_label(e){return this.lookup([e])}async verify(){let e=await Rn(this.cert.tree),t=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Fu(t),s=nt(Sr("ic-state-root"),e),o=!1,f=this.lookup(["time"]);if(!f)throw new qt("Certificate does not contain a time");let c=5*60*1e3,m=this._maxAgeInMinutes*60*1e3,E=Date.now(),h=E-m,O=E+c,B=Un(f);if(B.getTime()<h)throw new qt(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+B.toISOString()+" Current time: "+new Date(E).toISOString());if(B.getTime()>O)throw new qt("Certificate is signed more than 5 minutes in the future. Certificate time: "+B.toISOString()+" Current time: "+new Date(E).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new qt("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 qt("Delegation certificates cannot be nested");if(await t.verify(),!zi({canisterId:this._canisterId,subnetId:Ge.fromUint8Array(new Uint8Array(e.subnet_id)),tree:t.cert.tree}))throw new qt(`Canister ${this._canisterId} not in range of delegations for subnet 0x${ft(e.subnet_id)}`);let i=t.lookup(["subnet",e.subnet_id,"public_key"]);if(!i)throw new Error(`Could not find subnet key for subnet 0x${ft(e.subnet_id)}`);return i}},Ar=br("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Ou=96;function Fu(r){let e=Ar.byteLength+Ou;if(r.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let t=r.slice(0,Ar.byteLength);if(!Aa(t,Ar))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Ar}, but get ${t}`);return r.slice(Ar.byteLength)}function Hi(r){if(r instanceof ArrayBuffer)return r;if(r instanceof Uint8Array)return r.buffer}async function Rn(r){switch(r[0]){case xt.Empty:return it(Sr("ic-hashtree-empty"));case xt.Pruned:return r[1];case xt.Leaf:return it(nt(Sr("ic-hashtree-leaf"),r[1]));case xt.Labeled:return it(nt(Sr("ic-hashtree-labeled"),r[1],await Rn(r[2])));case xt.Fork:return it(nt(Sr("ic-hashtree-fork"),await Rn(r[1]),await Rn(r[2])));default:throw new Error("unreachable")}}function Sr(r){let e=new Uint8Array([r.length]),t=new TextEncoder().encode(r);return nt(e,t)}function ir(r,e){if(r.length===0)switch(e[0]){case xt.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?e[1]:e[1]instanceof Uint8Array?e[1].buffer:e[1]}case xt.Fork:return e;default:return e}let t=typeof r[0]=="string"?new TextEncoder().encode(r[0]):r[0],n=Pu(t,Tr(e));if(n)return ir(r.slice(1),n)}function Tr(r){switch(r[0]){case xt.Empty:return[];case xt.Fork:return Tr(r[1]).concat(Tr(r[2]));default:return[r]}}function Pu(r,e){if(e.length!==0){for(let t of e)if(t[0]===xt.Labeled){let n=t[1];if(Aa(r,n))return t[2]}}}function zi(r){let{canisterId:e,subnetId:t,tree:n}=r,i=ir(["subnet",t.toUint8Array(),"canister_ranges"],n);if(!i||!(i instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${t}`);return Jt(i).map(c=>[Ge.fromUint8Array(c[0]),Ge.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}var Sa=class{constructor(e,t,n){this.key=e,this.path=t,this.decodeStrategy=n}},td=async r=>{let{agent:e,paths:t}=r,n=Ge.from(r.canisterId),i=[...new Set(t)],s=i.map(c=>Ta(c,n)),o=new Map,f=i.map((c,m)=>(async()=>{var E;try{let h=await e.readState(n,{paths:[s[m]]}),O=await On.create({certificate:h.certificate,rootKey:e.rootKey,canisterId:n}),B=(P,N)=>{if(N==="subnet"){let D=Lu(h.certificate,n,e.rootKey);return{path:N,data:D}}else return{path:N,data:Hi(P.lookup(Ta(N,n)))}},{path:v,data:A}=B(O,i[m]);if(!A)console.warn(`Expected to find result for path ${v}, but instead found nothing.`),typeof v=="string"?o.set(v,null):o.set(v.key,null);else switch(v){case"time":{o.set(v,Un(A));break}case"controllers":{o.set(v,Du(A));break}case"module_hash":{o.set(v,Na(A));break}case"subnet":{o.set(v,A);break}case"candid":{o.set(v,new TextDecoder().decode(A));break}default:if(typeof v!="string"&&"key"in v&&"path"in v)switch(v.decodeStrategy){case"raw":o.set(v.key,A);break;case"leb128":{o.set(v.key,Yi(A));break}case"cbor":{o.set(v.key,Ua(A));break}case"hex":{o.set(v.key,Na(A));break}case"utf-8":o.set(v.key,Mu(A))}}}catch(h){if(!((E=h?.message)===null||E===void 0)&&E.includes("Invalid certificate"))throw new Kt(h.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(h),console.groupEnd()}})());return await Promise.all(f),o},Lu=(r,e,t)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=Jt(new Uint8Array(r)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=Ge.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof t<"u"?(o=Ge.selfAuthenticating(new Uint8Array(t)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=Ge.selfAuthenticating(Ge.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!zi({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=ir(["subnet",s?.subnet_id,"node"],i),m=Tr(c);m.length;let E=new Map;return m.forEach(h=>{Object.getPrototypeOf(new Uint8Array(h[1]));let O=Ge.from(new Uint8Array(h[1])).toText(),B=ir(["public_key"],h[2]);if(B.byteLength!==44)throw new Error("Invalid public key length");E.set(O,B)}),{subnetId:Ge.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:E}},Ta=(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.`)},Na=r=>ft(r),Ua=r=>Jt(r),Mu=r=>new TextDecoder().decode(r),Du=r=>Ua(r).map(t=>Ge.fromUint8Array(new Uint8Array(t)));export{Ce as a,Fn as b,Rr as c,ac as d,e0 as e,Mn as f,Ji as g,Dr as h,Ge as i,vs as j,Kt as k,Be as l,Bi as m,oi as n,nt as o,ft as p,br as q,F0 as r,pr as s,Cf as t,ll as u,Ho as v,li as w,M0 as x,Jt as y,vt as z,wn as A,En as B,ht as C,ve as D,At as E,Ke as F,pl as G,bl as H,Ri as I,gl as J,ra as K,na as L,Un as M,qt as N,On as O,ir as P,Sa as Q,td as R,Lu as S,Ta as T};
14
- /*!
15
- * The buffer module from node.js, for the browser.
16
- *
17
- * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
18
- * @license MIT
19
- */
20
- /*! Bundled license information:
21
-
22
- ieee754/index.js:
23
- (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
24
-
25
- @noble/hashes/esm/utils.js:
26
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
27
-
28
- @noble/curves/esm/abstract/utils.js:
29
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
30
-
31
- @noble/curves/esm/abstract/modular.js:
32
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
33
-
34
- @noble/curves/esm/abstract/curve.js:
35
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
36
-
37
- @noble/curves/esm/abstract/weierstrass.js:
38
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
39
-
40
- @noble/curves/esm/bls12-381.js:
41
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
42
- */
43
- //# sourceMappingURL=chunk-JAXPYESO.js.map