@junobuild/core-peer 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,22 @@
1
- "use strict";(()=>{var lu=Object.create;var ui=Object.defineProperty;var hu=Object.getOwnPropertyDescriptor;var du=Object.getOwnPropertyNames;var pu=Object.getPrototypeOf,yu=Object.prototype.hasOwnProperty;var ut=(r,t)=>()=>(r&&(t=r(r=0)),t);var At=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),wu=(r,t)=>{for(var e in t)ui(r,e,{get:t[e],enumerable:!0})},gu=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of du(t))!yu.call(r,i)&&i!==e&&ui(r,i,{get:()=>t[i],enumerable:!(n=hu(t,i))||n.enumerable});return r};var Te=(r,t,e)=>(e=r!=null?lu(pu(r)):{},gu(t||!r||!r.__esModule?ui(e,"default",{value:r,enumerable:!0}):e,r));var li=At(rn=>{"use strict";rn.byteLength=xu;rn.toByteArray=bu;rn.fromByteArray=vu;var fe=[],Jt=[],mu=typeof Uint8Array<"u"?Uint8Array:Array,fi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ve=0,to=fi.length;Ve<to;++Ve)fe[Ve]=fi[Ve],Jt[fi.charCodeAt(Ve)]=Ve;var Ve,to;Jt[45]=62;Jt[95]=63;function eo(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function xu(r){var t=eo(r),e=t[0],n=t[1];return(e+n)*3/4-n}function _u(r,t,e){return(t+e)*3/4-e}function bu(r){var t,e=eo(r),n=e[0],i=e[1],s=new mu(_u(r,n,i)),o=0,c=i>0?n-4:n,u;for(u=0;u<c;u+=4)t=Jt[r.charCodeAt(u)]<<18|Jt[r.charCodeAt(u+1)]<<12|Jt[r.charCodeAt(u+2)]<<6|Jt[r.charCodeAt(u+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=Jt[r.charCodeAt(u)]<<2|Jt[r.charCodeAt(u+1)]>>4,s[o++]=t&255),i===1&&(t=Jt[r.charCodeAt(u)]<<10|Jt[r.charCodeAt(u+1)]<<4|Jt[r.charCodeAt(u+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function Eu(r){return fe[r>>18&63]+fe[r>>12&63]+fe[r>>6&63]+fe[r&63]}function Au(r,t,e){for(var n,i=[],s=t;s<e;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(Eu(n));return i.join("")}function vu(r){for(var t,e=r.length,n=e%3,i=[],s=16383,o=0,c=e-n;o<c;o+=s)i.push(Au(r,o,o+s>c?c:o+s));return n===1?(t=r[e-1],i.push(fe[t>>2]+fe[t<<4&63]+"==")):n===2&&(t=(r[e-2]<<8)+r[e-1],i.push(fe[t>>10]+fe[t>>4&63]+fe[t<<2&63]+"=")),i.join("")}});var nn=At(hi=>{hi.read=function(r,t,e,n,i){var s,o,c=i*8-n-1,u=(1<<c)-1,w=u>>1,y=-7,_=e?i-1:0,N=e?-1:1,L=r[t+_];for(_+=N,s=L&(1<<-y)-1,L>>=-y,y+=c;y>0;s=s*256+r[t+_],_+=N,y-=8);for(o=s&(1<<-y)-1,s>>=-y,y+=n;y>0;o=o*256+r[t+_],_+=N,y-=8);if(s===0)s=1-w;else{if(s===u)return o?NaN:(L?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-w}return(L?-1:1)*o*Math.pow(2,s-n)};hi.write=function(r,t,e,n,i,s){var o,c,u,w=s*8-i-1,y=(1<<w)-1,_=y>>1,N=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,L=n?0:s-1,P=n?1:-1,G=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,o=y):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+_>=1?t+=N/u:t+=N*Math.pow(2,1-_),t*u>=2&&(o++,u/=2),o+_>=y?(c=0,o=y):o+_>=1?(c=(t*u-1)*Math.pow(2,i),o=o+_):(c=t*Math.pow(2,_-1)*Math.pow(2,i),o=0));i>=8;r[e+L]=c&255,L+=P,c/=256,i-=8);for(o=o<<i|c,w+=i;w>0;r[e+L]=o&255,L+=P,o/=256,w-=8);r[e+L-P]|=G*128}});var xo=At(rr=>{"use strict";var di=li(),tr=nn(),ro=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;rr.Buffer=T;rr.SlowBuffer=Uu;rr.INSPECT_MAX_BYTES=50;var sn=2147483647;rr.kMaxLength=sn;T.TYPED_ARRAY_SUPPORT=Tu();!T.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Tu(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(T.prototype,"parent",{enumerable:!0,get:function(){if(T.isBuffer(this))return this.buffer}});Object.defineProperty(T.prototype,"offset",{enumerable:!0,get:function(){if(T.isBuffer(this))return this.byteOffset}});function _e(r){if(r>sn)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,T.prototype),t}function T(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return gi(r)}return oo(r,t,e)}T.poolSize=8192;function oo(r,t,e){if(typeof r=="string")return Su(r,t);if(ArrayBuffer.isView(r))return Iu(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(le(r,ArrayBuffer)||r&&le(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(le(r,SharedArrayBuffer)||r&&le(r.buffer,SharedArrayBuffer)))return yi(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return T.from(n,t,e);let i=Nu(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return T.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}T.from=function(r,t,e){return oo(r,t,e)};Object.setPrototypeOf(T.prototype,Uint8Array.prototype);Object.setPrototypeOf(T,Uint8Array);function ao(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Bu(r,t,e){return ao(r),r<=0?_e(r):t!==void 0?typeof e=="string"?_e(r).fill(t,e):_e(r).fill(t):_e(r)}T.alloc=function(r,t,e){return Bu(r,t,e)};function gi(r){return ao(r),_e(r<0?0:mi(r)|0)}T.allocUnsafe=function(r){return gi(r)};T.allocUnsafeSlow=function(r){return gi(r)};function Su(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!T.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=co(r,t)|0,n=_e(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function pi(r){let t=r.length<0?0:mi(r.length)|0,e=_e(t);for(let n=0;n<t;n+=1)e[n]=r[n]&255;return e}function Iu(r){if(le(r,Uint8Array)){let t=new Uint8Array(r);return yi(t.buffer,t.byteOffset,t.byteLength)}return pi(r)}function yi(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,T.prototype),n}function Nu(r){if(T.isBuffer(r)){let t=mi(r.length)|0,e=_e(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||_i(r.length)?_e(0):pi(r);if(r.type==="Buffer"&&Array.isArray(r.data))return pi(r.data)}function mi(r){if(r>=sn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+sn.toString(16)+" bytes");return r|0}function Uu(r){return+r!=r&&(r=0),T.alloc(+r)}T.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==T.prototype};T.compare=function(t,e){if(le(t,Uint8Array)&&(t=T.from(t,t.offset,t.byteLength)),le(e,Uint8Array)&&(e=T.from(e,e.offset,e.byteLength)),!T.isBuffer(t)||!T.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,i=e.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==e[s]){n=t[s],i=e[s];break}return n<i?-1:i<n?1:0};T.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};T.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return T.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;let i=T.allocUnsafe(e),s=0;for(n=0;n<t.length;++n){let o=t[n];if(le(o,Uint8Array))s+o.length>i.length?(T.isBuffer(o)||(o=T.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(T.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function co(r,t){if(T.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||le(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return wi(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return mo(r).length;default:if(i)return n?-1:wi(r).length;t=(""+t).toLowerCase(),i=!0}}T.byteLength=co;function Ru(r,t,e){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return qu(this,t,e);case"utf8":case"utf-8":return fo(this,t,e);case"ascii":return Lu(this,t,e);case"latin1":case"binary":return Vu(this,t,e);case"base64":return Cu(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Hu(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}T.prototype._isBuffer=!0;function qe(r,t,e){let n=r[t];r[t]=r[e],r[e]=n}T.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)qe(this,e,e+1);return this};T.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)qe(this,e,e+3),qe(this,e+1,e+2);return this};T.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)qe(this,e,e+7),qe(this,e+1,e+6),qe(this,e+2,e+5),qe(this,e+3,e+4);return this};T.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?fo(this,0,t):Ru.apply(this,arguments)};T.prototype.toLocaleString=T.prototype.toString;T.prototype.equals=function(t){if(!T.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:T.compare(this,t)===0};T.prototype.inspect=function(){let t="",e=rr.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};ro&&(T.prototype[ro]=T.prototype.inspect);T.prototype.compare=function(t,e,n,i,s){if(le(t,Uint8Array)&&(t=T.from(t,t.offset,t.byteLength)),!T.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;let o=s-i,c=n-e,u=Math.min(o,c),w=this.slice(i,s),y=t.slice(e,n);for(let _=0;_<u;++_)if(w[_]!==y[_]){o=w[_],c=y[_];break}return o<c?-1:c<o?1:0};function uo(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,_i(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=T.from(t,n)),T.isBuffer(t))return t.length===0?-1:no(r,t,e,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):no(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function no(r,t,e,n,i){let s=1,o=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;s=2,o/=2,c/=2,e/=2}function u(y,_){return s===1?y[_]:y.readUInt16BE(_*s)}let w;if(i){let y=-1;for(w=e;w<o;w++)if(u(r,w)===u(t,y===-1?0:w-y)){if(y===-1&&(y=w),w-y+1===c)return y*s}else y!==-1&&(w-=w-y),y=-1}else for(e+c>o&&(e=o-c),w=e;w>=0;w--){let y=!0;for(let _=0;_<c;_++)if(u(r,w+_)!==u(t,_)){y=!1;break}if(y)return w}return-1}T.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};T.prototype.indexOf=function(t,e,n){return uo(this,t,e,n,!0)};T.prototype.lastIndexOf=function(t,e,n){return uo(this,t,e,n,!1)};function Fu(r,t,e,n){e=Number(e)||0;let i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;let s=t.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let c=parseInt(t.substr(o*2,2),16);if(_i(c))return o;r[e+o]=c}return o}function Ou(r,t,e,n){return on(wi(t,r.length-e),r,e,n)}function Pu(r,t,e,n){return on(ju(t),r,e,n)}function ku(r,t,e,n){return on(mo(t),r,e,n)}function Mu(r,t,e,n){return on(Wu(t,r.length-e),r,e,n)}T.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-e;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return Fu(this,t,e,n);case"utf8":case"utf-8":return Ou(this,t,e,n);case"ascii":case"latin1":case"binary":return Pu(this,t,e,n);case"base64":return ku(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Mu(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};T.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Cu(r,t,e){return t===0&&e===r.length?di.fromByteArray(r):di.fromByteArray(r.slice(t,e))}function fo(r,t,e){e=Math.min(r.length,e);let n=[],i=t;for(;i<e;){let s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=e){let u,w,y,_;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[i+1],(u&192)===128&&(_=(s&31)<<6|u&63,_>127&&(o=_));break;case 3:u=r[i+1],w=r[i+2],(u&192)===128&&(w&192)===128&&(_=(s&15)<<12|(u&63)<<6|w&63,_>2047&&(_<55296||_>57343)&&(o=_));break;case 4:u=r[i+1],w=r[i+2],y=r[i+3],(u&192)===128&&(w&192)===128&&(y&192)===128&&(_=(s&15)<<18|(u&63)<<12|(w&63)<<6|y&63,_>65535&&_<1114112&&(o=_))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return $u(n)}var io=4096;function $u(r){let t=r.length;if(t<=io)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=io));return e}function Lu(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function Vu(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function qu(r,t,e){let n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);let i="";for(let s=t;s<e;++s)i+=zu[r[s]];return i}function Hu(r,t,e){let n=r.slice(t,e),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}T.prototype.slice=function(t,e){let n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);let i=this.subarray(t,e);return Object.setPrototypeOf(i,T.prototype),i};function Rt(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}T.prototype.readUintLE=T.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Rt(t,e,this.length);let i=this[t],s=1,o=0;for(;++o<e&&(s*=256);)i+=this[t+o]*s;return i};T.prototype.readUintBE=T.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Rt(t,e,this.length);let i=this[t+--e],s=1;for(;e>0&&(s*=256);)i+=this[t+--e]*s;return i};T.prototype.readUint8=T.prototype.readUInt8=function(t,e){return t=t>>>0,e||Rt(t,1,this.length),this[t]};T.prototype.readUint16LE=T.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||Rt(t,2,this.length),this[t]|this[t+1]<<8};T.prototype.readUint16BE=T.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||Rt(t,2,this.length),this[t]<<8|this[t+1]};T.prototype.readUint32LE=T.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||Rt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};T.prototype.readUint32BE=T.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||Rt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};T.prototype.readBigUInt64LE=Be(function(t){t=t>>>0,er(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Sr(t,this.length-8);let i=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,s=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});T.prototype.readBigUInt64BE=Be(function(t){t=t>>>0,er(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Sr(t,this.length-8);let i=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],s=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});T.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Rt(t,e,this.length);let i=this[t],s=1,o=0;for(;++o<e&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*e)),i};T.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Rt(t,e,this.length);let i=e,s=1,o=this[t+--i];for(;i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*e)),o};T.prototype.readInt8=function(t,e){return t=t>>>0,e||Rt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};T.prototype.readInt16LE=function(t,e){t=t>>>0,e||Rt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};T.prototype.readInt16BE=function(t,e){t=t>>>0,e||Rt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};T.prototype.readInt32LE=function(t,e){return t=t>>>0,e||Rt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};T.prototype.readInt32BE=function(t,e){return t=t>>>0,e||Rt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};T.prototype.readBigInt64LE=Be(function(t){t=t>>>0,er(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Sr(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});T.prototype.readBigInt64BE=Be(function(t){t=t>>>0,er(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Sr(t,this.length-8);let i=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});T.prototype.readFloatLE=function(t,e){return t=t>>>0,e||Rt(t,4,this.length),tr.read(this,t,!0,23,4)};T.prototype.readFloatBE=function(t,e){return t=t>>>0,e||Rt(t,4,this.length),tr.read(this,t,!1,23,4)};T.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||Rt(t,8,this.length),tr.read(this,t,!0,52,8)};T.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||Rt(t,8,this.length),tr.read(this,t,!1,52,8)};function qt(r,t,e,n,i,s){if(!T.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}T.prototype.writeUintLE=T.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;qt(this,t,e,n,c,0)}let s=1,o=0;for(this[e]=t&255;++o<n&&(s*=256);)this[e+o]=t/s&255;return e+n};T.prototype.writeUintBE=T.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;qt(this,t,e,n,c,0)}let s=n-1,o=1;for(this[e+s]=t&255;--s>=0&&(o*=256);)this[e+s]=t/o&255;return e+n};T.prototype.writeUint8=T.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,1,255,0),this[e]=t&255,e+1};T.prototype.writeUint16LE=T.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};T.prototype.writeUint16BE=T.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};T.prototype.writeUint32LE=T.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};T.prototype.writeUint32BE=T.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function lo(r,t,e,n,i){go(t,n,i,r,e,7);let s=Number(t&BigInt(4294967295));r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o,e}function ho(r,t,e,n,i){go(t,n,i,r,e,7);let s=Number(t&BigInt(4294967295));r[e+7]=s,s=s>>8,r[e+6]=s,s=s>>8,r[e+5]=s,s=s>>8,r[e+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=o,o=o>>8,r[e+2]=o,o=o>>8,r[e+1]=o,o=o>>8,r[e]=o,e+8}T.prototype.writeBigUInt64LE=Be(function(t,e=0){return lo(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});T.prototype.writeBigUInt64BE=Be(function(t,e=0){return ho(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});T.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*n-1);qt(this,t,e,n,u-1,-u)}let s=0,o=1,c=0;for(this[e]=t&255;++s<n&&(o*=256);)t<0&&c===0&&this[e+s-1]!==0&&(c=1),this[e+s]=(t/o>>0)-c&255;return e+n};T.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*n-1);qt(this,t,e,n,u-1,-u)}let s=n-1,o=1,c=0;for(this[e+s]=t&255;--s>=0&&(o*=256);)t<0&&c===0&&this[e+s+1]!==0&&(c=1),this[e+s]=(t/o>>0)-c&255;return e+n};T.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};T.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};T.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};T.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};T.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};T.prototype.writeBigInt64LE=Be(function(t,e=0){return lo(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});T.prototype.writeBigInt64BE=Be(function(t,e=0){return ho(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function po(r,t,e,n,i,s){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function yo(r,t,e,n,i){return t=+t,e=e>>>0,i||po(r,t,e,4,34028234663852886e22,-34028234663852886e22),tr.write(r,t,e,n,23,4),e+4}T.prototype.writeFloatLE=function(t,e,n){return yo(this,t,e,!0,n)};T.prototype.writeFloatBE=function(t,e,n){return yo(this,t,e,!1,n)};function wo(r,t,e,n,i){return t=+t,e=e>>>0,i||po(r,t,e,8,17976931348623157e292,-17976931348623157e292),tr.write(r,t,e,n,52,8),e+8}T.prototype.writeDoubleLE=function(t,e,n){return wo(this,t,e,!0,n)};T.prototype.writeDoubleBE=function(t,e,n){return wo(this,t,e,!1,n)};T.prototype.copy=function(t,e,n,i){if(!T.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);let s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),s};T.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!T.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let o=t.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(t=o)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let s;if(typeof t=="number")for(s=e;s<n;++s)this[s]=t;else{let o=T.isBuffer(t)?t:T.from(t,i),c=o.length;if(c===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-e;++s)this[s+e]=o[s%c]}return this};var Qe={};function xi(r,t,e){Qe[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}xi("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);xi("ERR_INVALID_ARG_TYPE",function(r,t){return`The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError);xi("ERR_OUT_OF_RANGE",function(r,t,e){let n=`The value of "${r}" is out of range.`,i=e;return Number.isInteger(e)&&Math.abs(e)>2**32?i=so(String(e)):typeof e=="bigint"&&(i=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(i=so(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function so(r){let t="",e=r.length,n=r[0]==="-"?1:0;for(;e>=n+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return`${r.slice(0,e)}${t}`}function Gu(r,t,e){er(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&Sr(t,r.length-(e+1))}function go(r,t,e,n,i,s){if(r>e||r<t){let o=typeof t=="bigint"?"n":"",c;throw s>3?t===0||t===BigInt(0)?c=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:c=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:c=`>= ${t}${o} and <= ${e}${o}`,new Qe.ERR_OUT_OF_RANGE("value",c,r)}Gu(n,i,s)}function er(r,t){if(typeof r!="number")throw new Qe.ERR_INVALID_ARG_TYPE(t,"number",r)}function Sr(r,t,e){throw Math.floor(r)!==r?(er(r,e),new Qe.ERR_OUT_OF_RANGE(e||"offset","an integer",r)):t<0?new Qe.ERR_BUFFER_OUT_OF_BOUNDS:new Qe.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,r)}var Ku=/[^+/0-9A-Za-z-_]/g;function Du(r){if(r=r.split("=")[0],r=r.trim().replace(Ku,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function wi(r,t){t=t||1/0;let e,n=r.length,i=null,s=[];for(let o=0;o<n;++o){if(e=r.charCodeAt(o),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&s.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;s.push(e)}else if(e<2048){if((t-=2)<0)break;s.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;s.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;s.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return s}function ju(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function Wu(r,t){let e,n,i,s=[];for(let o=0;o<r.length&&!((t-=2)<0);++o)e=r.charCodeAt(o),n=e>>8,i=e%256,s.push(i),s.push(n);return s}function mo(r){return di.toByteArray(Du(r))}function on(r,t,e,n){let i;for(i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function le(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function _i(r){return r!==r}var zu=function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let n=e*16;for(let i=0;i<16;++i)t[n+i]=r[e]+r[i]}return t}();function Be(r){return typeof BigInt>"u"?Yu:r}function Yu(){throw new Error("BigInt not supported")}});function _o(r){let t=0,e=0,n="";function i(s){return t<0?e|=s>>-t:e=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=an[e>>3],t+=5),0)}for(let s=0;s<r.length;)s+=i(r[s]);return n+(t<0?an[e>>3]:"")}function bo(r){let t=0,e=0,n=new Uint8Array(r.length*4/3|0),i=0;function s(o){let c=nr[o.toLowerCase()];if(c===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);c<<=3,e|=c>>>t,t+=5,t>=8&&(n[i++]=e,t-=8,t>0?e=c<<5-t&255:e=0)}for(let o of r)s(o);return n.slice(0,i)}var an,nr,Eo=ut(()=>{an="abcdefghijklmnopqrstuvwxyz234567",nr=Object.create(null);for(let r=0;r<an.length;r++)nr[an[r]]=r;nr[0]=nr.o;nr[1]=nr.i});function Ao(r){let t=new Uint8Array(r),e=-1;for(let n=0;n<t.length;n++){let s=(t[n]^e)&255;e=Xu[s]^e>>>8}return(e^-1)>>>0}var Xu,vo=ut(()=>{Xu=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 Ju(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Ei(r,...t){if(!Ju(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function Ai(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function To(r,t){Ei(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var vi=ut(()=>{});var cn,Bo=ut(()=>{cn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});function So(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ti(r){return typeof r=="string"&&(r=So(r)),Ei(r),r}function Ir(r){let t=n=>r().update(Ti(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Io(r=32){if(cn&&typeof cn.getRandomValues=="function")return cn.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}var fn,ne,W0,un,z0,Nr=ut(()=>{Bo();vi();fn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ne=(r,t)=>r<<32-t|r>>>t,W0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;un=class{clone(){return this._cloneInto()}},z0={}.toString});function Zu(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),c=Number(e&s),u=n?4:0,w=n?0:4;r.setUint32(t+u,o,n),r.setUint32(t+w,c,n)}var No,Uo,ir,Bi=ut(()=>{vi();Nr();No=(r,t,e)=>r&t^~r&e,Uo=(r,t,e)=>r&t^r&e^t&e,ir=class extends un{constructor(t,e,n,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=fn(this.buffer)}update(t){Ai(this);let{view:e,buffer:n,blockLen:i}=this;t=Ti(t);let s=t.length;for(let o=0;o<s;){let c=Math.min(i-this.pos,s-o);if(c===i){let u=fn(t);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(t.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ai(this),To(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let _=o;_<i;_++)e[_]=0;Zu(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=fn(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let w=u/4,y=this.get();if(w>y.length)throw new Error("_sha2: outputLen bigger than state");for(let _=0;_<w;_++)c.setUint32(4*_,y[_],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:i,finished:s,destroyed:o,pos:c}=this;return t.length=i,t.pos=c,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(n),t}}});var Qu,Se,Ie,ln,Si,Ro,Fo,Ii=ut(()=>{Bi();Nr();Qu=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]),Se=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ie=new Uint32Array(64),ln=class extends ir{constructor(){super(64,32,8,!1),this.A=Se[0]|0,this.B=Se[1]|0,this.C=Se[2]|0,this.D=Se[3]|0,this.E=Se[4]|0,this.F=Se[5]|0,this.G=Se[6]|0,this.H=Se[7]|0}get(){let{A:t,B:e,C:n,D:i,E:s,F:o,G:c,H:u}=this;return[t,e,n,i,s,o,c,u]}set(t,e,n,i,s,o,c,u){this.A=t|0,this.B=e|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=u|0}process(t,e){for(let _=0;_<16;_++,e+=4)Ie[_]=t.getUint32(e,!1);for(let _=16;_<64;_++){let N=Ie[_-15],L=Ie[_-2],P=ne(N,7)^ne(N,18)^N>>>3,G=ne(L,17)^ne(L,19)^L>>>10;Ie[_]=G+Ie[_-7]+P+Ie[_-16]|0}let{A:n,B:i,C:s,D:o,E:c,F:u,G:w,H:y}=this;for(let _=0;_<64;_++){let N=ne(c,6)^ne(c,11)^ne(c,25),L=y+N+No(c,u,w)+Qu[_]+Ie[_]|0,G=(ne(n,2)^ne(n,13)^ne(n,22))+Uo(n,i,s)|0;y=w,w=u,u=c,c=o+L|0,o=s,s=i,i=n,n=L+G|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,w=w+this.G|0,y=y+this.H|0,this.set(n,i,s,o,c,u,w,y)}roundClean(){Ie.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Si=class extends ln{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}},Ro=Ir(()=>new ln),Fo=Ir(()=>new Si)});function Oo(r){return Fo.create().update(new Uint8Array(r)).digest()}var Po=ut(()=>{Ii()});var hn,tf,ko,ef,rf,nf,vt,Zt=ut(()=>{Eo();vo();Po();hn="__principal__",tf=2,ko=4,ef="aaaaa-aa",rf=r=>{var t;return new Uint8Array(((t=r.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(e=>parseInt(e,16)))},nf=r=>r.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),""),vt=class r{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([ko]))}static managementCanister(){return this.fromHex(ef)}static selfAuthenticating(t){let e=Oo(t);return new this(new Uint8Array([...e,tf]))}static from(t){if(typeof t=="string")return r.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new r(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new r(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(rf(t))}static fromText(t){let e=t;if(t.includes(hn)){let o=JSON.parse(t);hn in o&&(e=o[hn])}let n=e.toLowerCase().replace(/-/g,""),i=bo(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==e)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${e}" may not be a valid Principal ID).`);return s}static fromUint8Array(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===ko}toUint8Array(){return this._arr}toHex(){return nf(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,Ao(this._arr));let n=new Uint8Array(t),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),c=_o(s).match(/.{1,5}/g);if(!c)throw new Error;return c.join("-")}toString(){return this.toText()}toJSON(){return{[hn]:this.toText()}}compareTo(t){for(let e=0;e<Math.min(this._arr.length,t._arr.length);e++){if(this._arr[e]<t._arr[e])return"lt";if(this._arr[e]>t._arr[e])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let e=this.compareTo(t);return e=="lt"||e=="eq"}gtEq(t){let e=this.compareTo(t);return e=="gt"||e=="eq"}}});var Qt,sr=ut(()=>{Qt=class r extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,r.prototype)}}});function Ui(...r){let t=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),e=0;for(let n of r)t.set(new Uint8Array(n),e),e+=n.byteLength;return t}function Ni(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function dn(r){return r instanceof Uint8Array?Ni(r):r instanceof ArrayBuffer?r:Array.isArray(r)?Ni(new Uint8Array(r)):"buffer"in r?dn(r.buffer):Ni(new Uint8Array(r))}var Ne,pn=ut(()=>{Ne=class{constructor(t,e=t?.byteLength||0){this._buffer=dn(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,e)}get buffer(){return dn(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let e=this._view.subarray(0,t);return this._view=this._view.subarray(t),e.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let e=new Uint8Array(t),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+e.byteLength>=this._buffer.byteLength?this.alloc(e.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+e.byteLength),this._view.set(e,n)}get end(){return this._view.byteLength===0}alloc(t){let e=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(e,0,this._view.byteLength+t);n.set(this._view),this._buffer=e,this._view=n}}});var Ri=ut(()=>{});function Mo(){throw new Error("unexpected end of buffer")}function Ur(r,t){return r.byteLength<t&&Mo(),r.read(t)}function or(r){let t=r.readUint8();return t===void 0&&Mo(),t}function Ue(r){if(typeof r=="number"&&(r=BigInt(r)),r<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,e=new Ne(new ArrayBuffer(t),0);for(;;){let n=Number(r&BigInt(127));if(r/=BigInt(128),r===BigInt(0)){e.write(new Uint8Array([n]));break}else e.write(new Uint8Array([n|128]))}return e.buffer}function ar(r){let t=BigInt(1),e=BigInt(0),n;do n=or(r),e+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return e}function Kt(r){typeof r=="number"&&(r=BigInt(r));let t=r<BigInt(0);t&&(r=-r-BigInt(1));let e=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,n=new Ne(new ArrayBuffer(e),0);for(;;){let s=i(r);if(r/=BigInt(128),t&&r===BigInt(0)&&s&64||!t&&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(t?BigInt(128)-o-BigInt(1):o)}return n.buffer}function Co(r){let t=new Uint8Array(r.buffer),e=0;for(;e<t.byteLength;e++)if(t[e]<128){if(!(t[e]&64))return ar(r);break}let n=new Uint8Array(Ur(r,e+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 $o(r,t){if(BigInt(r)<BigInt(0))throw new Error("Cannot write negative values.");return Fi(r,t)}function Fi(r,t){r=BigInt(r);let e=new Ne(new ArrayBuffer(Math.min(1,t)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(r%i);for(e.write(new Uint8Array([o]));++n<t;)r<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((r/i-s)%BigInt(256)),e.write(new Uint8Array([o])),i*=BigInt(256);return e.buffer}function Oi(r,t){let e=BigInt(or(r)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(or(r));e=e+n*s}return e}function Lo(r,t){let e=Oi(r,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return e>=n&&(e-=n*BigInt(2)),e}var Pi=ut(()=>{pn()});function yn(r){let t=BigInt(r);if(r<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}var Vo=ut(()=>{});function sf(r){if(or(r)!==1)throw new Error("Cannot decode principal");let e=Number(ar(r));return vt.fromUint8Array(new Uint8Array(Ur(r,e)))}function jt(r){let t=JSON.stringify(r,(e,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>qo?t.substring(0,qo-3)+"...":t}var qo,Rr,Dt,ki,Mi,Ci,$i,Li,Vi,qi,Hi,Gi,wn,cr,ur,Fr,Ki,_d,bd,Ed,Ad,vd,Td,Bd,Sd,Id,Nd,Ud,Rd,Fd,Od,Pd,kd,Md,Cd,$d,ji=ut(()=>{Zt();pn();Ri();Pi();Vo();qo=400,Rr=class{display(){return this.name}valueToString(t){return jt(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},Dt=class extends Rr{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}},ki=class extends Rr{checkType(t){if(t instanceof Fr){let e=t.getType();if(typeof e>"u")throw new Error("type mismatch with uninitialized type");return e}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}},Mi=class extends Dt{accept(t,e){return t.visitEmpty(this,e)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${jt(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return Kt(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Ci=class extends Rr{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,e){throw t.visitType(this,e)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${jt(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,e){let n=e.decodeValue(t,e);Object(n)!==n&&(n=Object(n));let i;return e instanceof Fr?i=()=>e.getType():i=()=>e,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"}},$i=class extends Dt{accept(t,e){return t.visitBool(this,e)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${jt(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return Kt(-2)}decodeValue(t,e){switch(this.checkType(e),or(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},Li=class extends Dt{accept(t,e){return t.visitNull(this,e)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${jt(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return Kt(-1)}decodeValue(t,e){return this.checkType(e),null}get name(){return"null"}},Vi=class extends Dt{accept(t,e){return t.visitReserved(this,e)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return Kt(-16)}decodeValue(t,e){return e.name!==this.name&&e.decodeValue(t,e),null}get name(){return"reserved"}},qi=class extends Dt{accept(t,e){return t.visitText(this,e)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${jt(t)}`)}encodeValue(t){let e=new TextEncoder().encode(t),n=Ue(e.byteLength);return Ui(n,e)}encodeType(){return Kt(-15)}decodeValue(t,e){this.checkType(e);let n=ar(t),i=Ur(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},Hi=class extends Dt{accept(t,e){return t.visitInt(this,e)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${jt(t)}`)}encodeValue(t){return Kt(t)}encodeType(){return Kt(-4)}decodeValue(t,e){return this.checkType(e),Co(t)}get name(){return"int"}valueToString(t){return t.toString()}},Gi=class extends Dt{accept(t,e){return t.visitNat(this,e)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${jt(t)}`)}encodeValue(t){return Ue(t)}encodeType(){return Kt(-3)}decodeValue(t,e){return this.checkType(e),ar(t)}get name(){return"nat"}valueToString(t){return t.toString()}},wn=class extends Dt{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,e){return t.visitFloat(this,e)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${jt(t)}`)}encodeValue(t){let e=new ArrayBuffer(this._bits/8),n=new DataView(e);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),e}encodeType(){let t=this._bits===32?-13:-14;return Kt(t)}decodeValue(t,e){this.checkType(e);let n=Ur(t,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}},cr=class extends Dt{constructor(t){super(),this._bits=t}accept(t,e){return t.visitFixedInt(this,e)}covariant(t){let e=yn(this._bits-1)*BigInt(-1),n=yn(this._bits-1)-BigInt(1),i=!1;if(typeof t=="bigint")i=t>=e&&t<=n;else if(Number.isInteger(t)){let s=BigInt(t);i=s>=e&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${jt(t)}`)}encodeValue(t){return Fi(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return Kt(-9-t)}decodeValue(t,e){this.checkType(e);let n=Lo(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},ur=class extends Dt{constructor(t){super(),this._bits=t}accept(t,e){return t.visitFixedNat(this,e)}covariant(t){let e=yn(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<e:Number.isInteger(t)&&t>=0?n=BigInt(t)<e:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${jt(t)}`)}encodeValue(t){return $o(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return Kt(-5-t)}decodeValue(t,e){this.checkType(e);let n=Oi(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}},Fr=class r extends ki{constructor(){super(...arguments),this._id=r._counter++,this._type=void 0}accept(t,e){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,e)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${jt(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,e)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};Fr._counter=0;Ki=class extends Dt{accept(t,e){return t.visitPrincipal(this,e)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${jt(t)}`)}encodeValue(t){let e=t.toUint8Array(),n=Ue(e.byteLength);return Ui(new Uint8Array([1]),n,e)}encodeType(){return Kt(-24)}decodeValue(t,e){return this.checkType(e),sf(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};_d=new Mi,bd=new Vi,Ed=new Ci,Ad=new $i,vd=new Li,Td=new qi,Bd=new Hi,Sd=new Gi,Id=new wn(32),Nd=new wn(64),Ud=new cr(8),Rd=new cr(16),Fd=new cr(32),Od=new cr(64),Pd=new ur(8),kd=new ur(16),Md=new ur(32),Cd=new ur(64),$d=new Ki});var Wi=ut(()=>{});var Ho=ut(()=>{ji();Zt();Wi()});var Go=ut(()=>{});var fr=ut(()=>{Ho();Wi();ji();Ri();Pi();pn();Go()});var Or=At(hr=>{"use strict";var zi=li(),lr=nn(),Ko=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;hr.Buffer=B;hr.SlowBuffer=hf;hr.INSPECT_MAX_BYTES=50;var gn=2147483647;hr.kMaxLength=gn;B.TYPED_ARRAY_SUPPORT=af();!B.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function af(){try{var r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(B.prototype,"parent",{enumerable:!0,get:function(){if(B.isBuffer(this))return this.buffer}});Object.defineProperty(B.prototype,"offset",{enumerable:!0,get:function(){if(B.isBuffer(this))return this.byteOffset}});function be(r){if(r>gn)throw new RangeError('The value "'+r+'" is invalid for option "size"');var t=new Uint8Array(r);return Object.setPrototypeOf(t,B.prototype),t}function B(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Zi(r)}return Wo(r,t,e)}B.poolSize=8192;function Wo(r,t,e){if(typeof r=="string")return uf(r,t);if(ArrayBuffer.isView(r))return ff(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(he(r,ArrayBuffer)||r&&he(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(he(r,SharedArrayBuffer)||r&&he(r.buffer,SharedArrayBuffer)))return Xi(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return B.from(n,t,e);var i=lf(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return B.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}B.from=function(r,t,e){return Wo(r,t,e)};Object.setPrototypeOf(B.prototype,Uint8Array.prototype);Object.setPrototypeOf(B,Uint8Array);function zo(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function cf(r,t,e){return zo(r),r<=0?be(r):t!==void 0?typeof e=="string"?be(r).fill(t,e):be(r).fill(t):be(r)}B.alloc=function(r,t,e){return cf(r,t,e)};function Zi(r){return zo(r),be(r<0?0:Qi(r)|0)}B.allocUnsafe=function(r){return Zi(r)};B.allocUnsafeSlow=function(r){return Zi(r)};function uf(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!B.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=Yo(r,t)|0,n=be(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function Yi(r){for(var t=r.length<0?0:Qi(r.length)|0,e=be(t),n=0;n<t;n+=1)e[n]=r[n]&255;return e}function ff(r){if(he(r,Uint8Array)){var t=new Uint8Array(r);return Xi(t.buffer,t.byteOffset,t.byteLength)}return Yi(r)}function Xi(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,B.prototype),n}function lf(r){if(B.isBuffer(r)){var t=Qi(r.length)|0,e=be(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||ts(r.length)?be(0):Yi(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Yi(r.data)}function Qi(r){if(r>=gn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+gn.toString(16)+" bytes");return r|0}function hf(r){return+r!=r&&(r=0),B.alloc(+r)}B.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==B.prototype};B.compare=function(t,e){if(he(t,Uint8Array)&&(t=B.from(t,t.offset,t.byteLength)),he(e,Uint8Array)&&(e=B.from(e,e.offset,e.byteLength)),!B.isBuffer(t)||!B.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,i=e.length,s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==e[s]){n=t[s],i=e[s];break}return n<i?-1:i<n?1:0};B.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};B.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return B.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var i=B.allocUnsafe(e),s=0;for(n=0;n<t.length;++n){var o=t[n];if(he(o,Uint8Array))s+o.length>i.length?B.from(o).copy(i,s):Uint8Array.prototype.set.call(i,o,s);else if(B.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Yo(r,t){if(B.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||he(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);var e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Ji(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return ea(r).length;default:if(i)return n?-1:Ji(r).length;t=(""+t).toLowerCase(),i=!0}}B.byteLength=Yo;function df(r,t,e){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Af(this,t,e);case"utf8":case"utf-8":return Jo(this,t,e);case"ascii":return bf(this,t,e);case"latin1":case"binary":return Ef(this,t,e);case"base64":return xf(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vf(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}B.prototype._isBuffer=!0;function He(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}B.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)He(this,e,e+1);return this};B.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)He(this,e,e+3),He(this,e+1,e+2);return this};B.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)He(this,e,e+7),He(this,e+1,e+6),He(this,e+2,e+5),He(this,e+3,e+4);return this};B.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?Jo(this,0,t):df.apply(this,arguments)};B.prototype.toLocaleString=B.prototype.toString;B.prototype.equals=function(t){if(!B.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:B.compare(this,t)===0};B.prototype.inspect=function(){var t="",e=hr.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};Ko&&(B.prototype[Ko]=B.prototype.inspect);B.prototype.compare=function(t,e,n,i,s){if(he(t,Uint8Array)&&(t=B.from(t,t.offset,t.byteLength)),!B.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;for(var o=s-i,c=n-e,u=Math.min(o,c),w=this.slice(i,s),y=t.slice(e,n),_=0;_<u;++_)if(w[_]!==y[_]){o=w[_],c=y[_];break}return o<c?-1:c<o?1:0};function Xo(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,ts(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=B.from(t,n)),B.isBuffer(t))return t.length===0?-1:Do(r,t,e,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Do(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function Do(r,t,e,n,i){var s=1,o=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;s=2,o/=2,c/=2,e/=2}function u(L,P){return s===1?L[P]:L.readUInt16BE(P*s)}var w;if(i){var y=-1;for(w=e;w<o;w++)if(u(r,w)===u(t,y===-1?0:w-y)){if(y===-1&&(y=w),w-y+1===c)return y*s}else y!==-1&&(w-=w-y),y=-1}else for(e+c>o&&(e=o-c),w=e;w>=0;w--){for(var _=!0,N=0;N<c;N++)if(u(r,w+N)!==u(t,N)){_=!1;break}if(_)return w}return-1}B.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};B.prototype.indexOf=function(t,e,n){return Xo(this,t,e,n,!0)};B.prototype.lastIndexOf=function(t,e,n){return Xo(this,t,e,n,!1)};function pf(r,t,e,n){e=Number(e)||0;var i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;var s=t.length;n>s/2&&(n=s/2);for(var o=0;o<n;++o){var c=parseInt(t.substr(o*2,2),16);if(ts(c))return o;r[e+o]=c}return o}function yf(r,t,e,n){return mn(Ji(t,r.length-e),r,e,n)}function wf(r,t,e,n){return mn(Sf(t),r,e,n)}function gf(r,t,e,n){return mn(ea(t),r,e,n)}function mf(r,t,e,n){return mn(If(t,r.length-e),r,e,n)}B.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e>>>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-e;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return pf(this,t,e,n);case"utf8":case"utf-8":return yf(this,t,e,n);case"ascii":case"latin1":case"binary":return wf(this,t,e,n);case"base64":return gf(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mf(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};B.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function xf(r,t,e){return t===0&&e===r.length?zi.fromByteArray(r):zi.fromByteArray(r.slice(t,e))}function Jo(r,t,e){e=Math.min(r.length,e);for(var n=[],i=t;i<e;){var s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=e){var u,w,y,_;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[i+1],(u&192)===128&&(_=(s&31)<<6|u&63,_>127&&(o=_));break;case 3:u=r[i+1],w=r[i+2],(u&192)===128&&(w&192)===128&&(_=(s&15)<<12|(u&63)<<6|w&63,_>2047&&(_<55296||_>57343)&&(o=_));break;case 4:u=r[i+1],w=r[i+2],y=r[i+3],(u&192)===128&&(w&192)===128&&(y&192)===128&&(_=(s&15)<<18|(u&63)<<12|(w&63)<<6|y&63,_>65535&&_<1114112&&(o=_))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return _f(n)}var jo=4096;function _f(r){var t=r.length;if(t<=jo)return String.fromCharCode.apply(String,r);for(var e="",n=0;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=jo));return e}function bf(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function Ef(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function Af(r,t,e){var n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);for(var i="",s=t;s<e;++s)i+=Nf[r[s]];return i}function vf(r,t,e){for(var n=r.slice(t,e),i="",s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}B.prototype.slice=function(t,e){var n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);var i=this.subarray(t,e);return Object.setPrototypeOf(i,B.prototype),i};function Ft(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}B.prototype.readUintLE=B.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Ft(t,e,this.length);for(var i=this[t],s=1,o=0;++o<e&&(s*=256);)i+=this[t+o]*s;return i};B.prototype.readUintBE=B.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Ft(t,e,this.length);for(var i=this[t+--e],s=1;e>0&&(s*=256);)i+=this[t+--e]*s;return i};B.prototype.readUint8=B.prototype.readUInt8=function(t,e){return t=t>>>0,e||Ft(t,1,this.length),this[t]};B.prototype.readUint16LE=B.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||Ft(t,2,this.length),this[t]|this[t+1]<<8};B.prototype.readUint16BE=B.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||Ft(t,2,this.length),this[t]<<8|this[t+1]};B.prototype.readUint32LE=B.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||Ft(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};B.prototype.readUint32BE=B.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||Ft(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};B.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Ft(t,e,this.length);for(var i=this[t],s=1,o=0;++o<e&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*e)),i};B.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Ft(t,e,this.length);for(var i=e,s=1,o=this[t+--i];i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*e)),o};B.prototype.readInt8=function(t,e){return t=t>>>0,e||Ft(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};B.prototype.readInt16LE=function(t,e){t=t>>>0,e||Ft(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};B.prototype.readInt16BE=function(t,e){t=t>>>0,e||Ft(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};B.prototype.readInt32LE=function(t,e){return t=t>>>0,e||Ft(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};B.prototype.readInt32BE=function(t,e){return t=t>>>0,e||Ft(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};B.prototype.readFloatLE=function(t,e){return t=t>>>0,e||Ft(t,4,this.length),lr.read(this,t,!0,23,4)};B.prototype.readFloatBE=function(t,e){return t=t>>>0,e||Ft(t,4,this.length),lr.read(this,t,!1,23,4)};B.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||Ft(t,8,this.length),lr.read(this,t,!0,52,8)};B.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||Ft(t,8,this.length),lr.read(this,t,!1,52,8)};function Ht(r,t,e,n,i,s){if(!B.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}B.prototype.writeUintLE=B.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){var s=Math.pow(2,8*n)-1;Ht(this,t,e,n,s,0)}var o=1,c=0;for(this[e]=t&255;++c<n&&(o*=256);)this[e+c]=t/o&255;return e+n};B.prototype.writeUintBE=B.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){var s=Math.pow(2,8*n)-1;Ht(this,t,e,n,s,0)}var o=n-1,c=1;for(this[e+o]=t&255;--o>=0&&(c*=256);)this[e+o]=t/c&255;return e+n};B.prototype.writeUint8=B.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,1,255,0),this[e]=t&255,e+1};B.prototype.writeUint16LE=B.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};B.prototype.writeUint16BE=B.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};B.prototype.writeUint32LE=B.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};B.prototype.writeUint32BE=B.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};B.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){var s=Math.pow(2,8*n-1);Ht(this,t,e,n,s-1,-s)}var o=0,c=1,u=0;for(this[e]=t&255;++o<n&&(c*=256);)t<0&&u===0&&this[e+o-1]!==0&&(u=1),this[e+o]=(t/c>>0)-u&255;return e+n};B.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){var s=Math.pow(2,8*n-1);Ht(this,t,e,n,s-1,-s)}var o=n-1,c=1,u=0;for(this[e+o]=t&255;--o>=0&&(c*=256);)t<0&&u===0&&this[e+o+1]!==0&&(u=1),this[e+o]=(t/c>>0)-u&255;return e+n};B.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};B.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};B.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};B.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};B.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function Zo(r,t,e,n,i,s){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Qo(r,t,e,n,i){return t=+t,e=e>>>0,i||Zo(r,t,e,4,34028234663852886e22,-34028234663852886e22),lr.write(r,t,e,n,23,4),e+4}B.prototype.writeFloatLE=function(t,e,n){return Qo(this,t,e,!0,n)};B.prototype.writeFloatBE=function(t,e,n){return Qo(this,t,e,!1,n)};function ta(r,t,e,n,i){return t=+t,e=e>>>0,i||Zo(r,t,e,8,17976931348623157e292,-17976931348623157e292),lr.write(r,t,e,n,52,8),e+8}B.prototype.writeDoubleLE=function(t,e,n){return ta(this,t,e,!0,n)};B.prototype.writeDoubleBE=function(t,e,n){return ta(this,t,e,!1,n)};B.prototype.copy=function(t,e,n,i){if(!B.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);var s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),s};B.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!B.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){var s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var o;if(typeof t=="number")for(o=e;o<n;++o)this[o]=t;else{var c=B.isBuffer(t)?t:B.from(t,i),u=c.length;if(u===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=c[o%u]}return this};var Tf=/[^+/0-9A-Za-z-_]/g;function Bf(r){if(r=r.split("=")[0],r=r.trim().replace(Tf,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Ji(r,t){t=t||1/0;for(var e,n=r.length,i=null,s=[],o=0;o<n;++o){if(e=r.charCodeAt(o),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&s.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;s.push(e)}else if(e<2048){if((t-=2)<0)break;s.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;s.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;s.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return s}function Sf(r){for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function If(r,t){for(var e,n,i,s=[],o=0;o<r.length&&!((t-=2)<0);++o)e=r.charCodeAt(o),n=e>>8,i=e%256,s.push(i),s.push(n);return s}function ea(r){return zi.toByteArray(Bf(r))}function mn(r,t,e,n){for(var i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function he(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function ts(r){return r!==r}var Nf=function(){for(var r="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var n=e*16,i=0;i<16;++i)t[n+i]=r[e]+r[i];return t}()});var Pr=At((ra,xn)=>{(function(r){"use strict";var t,e=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",c=1e14,u=14,w=9007199254740991,y=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],_=1e7,N=1e9;function L(O){var $,it,z,R=S.prototype={constructor:S,toString:null,valueOf:null},ot=new S(1),et=20,at=4,ht=-7,Bt=21,Pt=-1e7,Ct=1e7,re=!1,k=1,U=0,q={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},H="0123456789abcdefghijklmnopqrstuvwxyz",J=!0;function S(a,f){var l,b,g,x,v,d,m,A,E=this;if(!(E instanceof S))return new S(a,f);if(f==null){if(a&&a._isBigNumber===!0){E.s=a.s,!a.c||a.e>Ct?E.c=E.e=null:a.e<Pt?E.c=[E.e=0]:(E.e=a.e,E.c=a.c.slice());return}if((d=typeof a=="number")&&a*0==0){if(E.s=1/a<0?(a=-a,-1):1,a===~~a){for(x=0,v=a;v>=10;v/=10,x++);x>Ct?E.c=E.e=null:(E.e=x,E.c=[a]);return}A=String(a)}else{if(!e.test(A=String(a)))return z(E,A,d);E.s=A.charCodeAt(0)==45?(A=A.slice(1),-1):1}(x=A.indexOf("."))>-1&&(A=A.replace(".","")),(v=A.search(/e/i))>0?(x<0&&(x=v),x+=+A.slice(v+1),A=A.substring(0,v)):x<0&&(x=A.length)}else{if(D(f,2,H.length,"Base"),f==10&&J)return E=new S(a),j(E,et+E.e+1,at);if(A=String(a),d=typeof a=="number"){if(a*0!=0)return z(E,A,d,f);if(E.s=1/a<0?(A=A.slice(1),-1):1,S.DEBUG&&A.replace(/^0\.0*|\./,"").length>15)throw Error(o+a)}else E.s=A.charCodeAt(0)===45?(A=A.slice(1),-1):1;for(l=H.slice(0,f),x=v=0,m=A.length;v<m;v++)if(l.indexOf(b=A.charAt(v))<0){if(b=="."){if(v>x){x=m;continue}}else if(!g&&(A==A.toUpperCase()&&(A=A.toLowerCase())||A==A.toLowerCase()&&(A=A.toUpperCase()))){g=!0,v=-1,x=0;continue}return z(E,String(a),d,f)}d=!1,A=it(A,f,10,E.s),(x=A.indexOf("."))>-1?A=A.replace(".",""):x=A.length}for(v=0;A.charCodeAt(v)===48;v++);for(m=A.length;A.charCodeAt(--m)===48;);if(A=A.slice(v,++m)){if(m-=v,d&&S.DEBUG&&m>15&&(a>w||a!==i(a)))throw Error(o+E.s*a);if((x=x-v-1)>Ct)E.c=E.e=null;else if(x<Pt)E.c=[E.e=0];else{if(E.e=x,E.c=[],v=(x+1)%u,x<0&&(v+=u),v<m){for(v&&E.c.push(+A.slice(0,v)),m-=u;v<m;)E.c.push(+A.slice(v,v+=u));v=u-(A=A.slice(v)).length}else v-=m;for(;v--;A+="0");E.c.push(+A)}}else E.c=[E.e=0]}S.clone=L,S.ROUND_UP=0,S.ROUND_DOWN=1,S.ROUND_CEIL=2,S.ROUND_FLOOR=3,S.ROUND_HALF_UP=4,S.ROUND_HALF_DOWN=5,S.ROUND_HALF_EVEN=6,S.ROUND_HALF_CEIL=7,S.ROUND_HALF_FLOOR=8,S.EUCLID=9,S.config=S.set=function(a){var f,l;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(f="DECIMAL_PLACES")&&(l=a[f],D(l,0,N,f),et=l),a.hasOwnProperty(f="ROUNDING_MODE")&&(l=a[f],D(l,0,8,f),at=l),a.hasOwnProperty(f="EXPONENTIAL_AT")&&(l=a[f],l&&l.pop?(D(l[0],-N,0,f),D(l[1],0,N,f),ht=l[0],Bt=l[1]):(D(l,-N,N,f),ht=-(Bt=l<0?-l:l))),a.hasOwnProperty(f="RANGE"))if(l=a[f],l&&l.pop)D(l[0],-N,-1,f),D(l[1],1,N,f),Pt=l[0],Ct=l[1];else if(D(l,-N,N,f),l)Pt=-(Ct=l<0?-l:l);else throw Error(s+f+" cannot be zero: "+l);if(a.hasOwnProperty(f="CRYPTO"))if(l=a[f],l===!!l)if(l)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))re=l;else throw re=!l,Error(s+"crypto unavailable");else re=l;else throw Error(s+f+" not true or false: "+l);if(a.hasOwnProperty(f="MODULO_MODE")&&(l=a[f],D(l,0,9,f),k=l),a.hasOwnProperty(f="POW_PRECISION")&&(l=a[f],D(l,0,N,f),U=l),a.hasOwnProperty(f="FORMAT"))if(l=a[f],typeof l=="object")q=l;else throw Error(s+f+" not an object: "+l);if(a.hasOwnProperty(f="ALPHABET"))if(l=a[f],typeof l=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(l))J=l.slice(0,10)=="0123456789",H=l;else throw Error(s+f+" invalid: "+l)}else throw Error(s+"Object expected: "+a);return{DECIMAL_PLACES:et,ROUNDING_MODE:at,EXPONENTIAL_AT:[ht,Bt],RANGE:[Pt,Ct],CRYPTO:re,MODULO_MODE:k,POW_PRECISION:U,FORMAT:q,ALPHABET:H}},S.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!S.DEBUG)return!0;var f,l,b=a.c,g=a.e,x=a.s;t:if({}.toString.call(b)=="[object Array]"){if((x===1||x===-1)&&g>=-N&&g<=N&&g===i(g)){if(b[0]===0){if(g===0&&b.length===1)return!0;break t}if(f=(g+1)%u,f<1&&(f+=u),String(b[0]).length==f){for(f=0;f<b.length;f++)if(l=b[f],l<0||l>=c||l!==i(l))break t;if(l!==0)return!0}}}else if(b===null&&g===null&&(x===null||x===1||x===-1))return!0;throw Error(s+"Invalid BigNumber: "+a)},S.maximum=S.max=function(){return ct(arguments,-1)},S.minimum=S.min=function(){return ct(arguments,1)},S.random=function(){var a=9007199254740992,f=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 b,g,x,v,d,m=0,A=[],E=new S(ot);if(l==null?l=et:D(l,0,N),v=n(l/u),re)if(crypto.getRandomValues){for(b=crypto.getRandomValues(new Uint32Array(v*=2));m<v;)d=b[m]*131072+(b[m+1]>>>11),d>=9e15?(g=crypto.getRandomValues(new Uint32Array(2)),b[m]=g[0],b[m+1]=g[1]):(A.push(d%1e14),m+=2);m=v/2}else if(crypto.randomBytes){for(b=crypto.randomBytes(v*=7);m<v;)d=(b[m]&31)*281474976710656+b[m+1]*1099511627776+b[m+2]*4294967296+b[m+3]*16777216+(b[m+4]<<16)+(b[m+5]<<8)+b[m+6],d>=9e15?crypto.randomBytes(7).copy(b,m):(A.push(d%1e14),m+=7);m=v/7}else throw re=!1,Error(s+"crypto unavailable");if(!re)for(;m<v;)d=f(),d<9e15&&(A[m++]=d%1e14);for(v=A[--m],l%=u,v&&l&&(d=y[u-l],A[m]=i(v/d)*d);A[m]===0;A.pop(),m--);if(m<0)A=[x=0];else{for(x=-1;A[0]===0;A.splice(0,1),x-=u);for(m=1,d=A[0];d>=10;d/=10,m++);m<u&&(x-=u-m)}return E.e=x,E.c=A,E}}(),S.sum=function(){for(var a=1,f=arguments,l=new S(f[0]);a<f.length;)l=l.plus(f[a++]);return l},it=function(){var a="0123456789";function f(l,b,g,x){for(var v,d=[0],m,A=0,E=l.length;A<E;){for(m=d.length;m--;d[m]*=b);for(d[0]+=x.indexOf(l.charAt(A++)),v=0;v<d.length;v++)d[v]>g-1&&(d[v+1]==null&&(d[v+1]=0),d[v+1]+=d[v]/g|0,d[v]%=g)}return d.reverse()}return function(l,b,g,x,v){var d,m,A,E,I,F,C,Y,ft=l.indexOf("."),wt=et,W=at;for(ft>=0&&(E=U,U=0,l=l.replace(".",""),Y=new S(b),F=Y.pow(l.length-ft),U=E,Y.c=f(yt(G(F.c),F.e,"0"),10,g,a),Y.e=Y.c.length),C=f(l,b,g,v?(d=H,a):(d=a,H)),A=E=C.length;C[--E]==0;C.pop());if(!C[0])return d.charAt(0);if(ft<0?--A:(F.c=C,F.e=A,F.s=x,F=$(F,Y,wt,W,g),C=F.c,I=F.r,A=F.e),m=A+wt+1,ft=C[m],E=g/2,I=I||m<0||C[m+1]!=null,I=W<4?(ft!=null||I)&&(W==0||W==(F.s<0?3:2)):ft>E||ft==E&&(W==4||I||W==6&&C[m-1]&1||W==(F.s<0?8:7)),m<1||!C[0])l=I?yt(d.charAt(1),-wt,d.charAt(0)):d.charAt(0);else{if(C.length=m,I)for(--g;++C[--m]>g;)C[m]=0,m||(++A,C=[1].concat(C));for(E=C.length;!C[--E];);for(ft=0,l="";ft<=E;l+=d.charAt(C[ft++]));l=yt(l,A,d.charAt(0))}return l}}(),$=function(){function a(b,g,x){var v,d,m,A,E=0,I=b.length,F=g%_,C=g/_|0;for(b=b.slice();I--;)m=b[I]%_,A=b[I]/_|0,v=C*m+A*F,d=F*m+v%_*_+E,E=(d/x|0)+(v/_|0)+C*A,b[I]=d%x;return E&&(b=[E].concat(b)),b}function f(b,g,x,v){var d,m;if(x!=v)m=x>v?1:-1;else for(d=m=0;d<x;d++)if(b[d]!=g[d]){m=b[d]>g[d]?1:-1;break}return m}function l(b,g,x,v){for(var d=0;x--;)b[x]-=d,d=b[x]<g[x]?1:0,b[x]=d*v+b[x]-g[x];for(;!b[0]&&b.length>1;b.splice(0,1));}return function(b,g,x,v,d){var m,A,E,I,F,C,Y,ft,wt,W,V,_t,xe,$e,Le,Lt,st,Vt=b.s==g.s?1:-1,kt=b.c,gt=g.c;if(!kt||!kt[0]||!gt||!gt[0])return new S(!b.s||!g.s||(kt?gt&&kt[0]==gt[0]:!gt)?NaN:kt&&kt[0]==0||!gt?Vt*0:Vt/0);for(ft=new S(Vt),wt=ft.c=[],A=b.e-g.e,Vt=x+A+1,d||(d=c,A=P(b.e/u)-P(g.e/u),Vt=Vt/u|0),E=0;gt[E]==(kt[E]||0);E++);if(gt[E]>(kt[E]||0)&&A--,Vt<0)wt.push(1),I=!0;else{for($e=kt.length,Lt=gt.length,E=0,Vt+=2,F=i(d/(gt[0]+1)),F>1&&(gt=a(gt,F,d),kt=a(kt,F,d),Lt=gt.length,$e=kt.length),xe=Lt,W=kt.slice(0,Lt),V=W.length;V<Lt;W[V++]=0);st=gt.slice(),st=[0].concat(st),Le=gt[0],gt[1]>=d/2&&Le++;do{if(F=0,m=f(gt,W,Lt,V),m<0){if(_t=W[0],Lt!=V&&(_t=_t*d+(W[1]||0)),F=i(_t/Le),F>1)for(F>=d&&(F=d-1),C=a(gt,F,d),Y=C.length,V=W.length;f(C,W,Y,V)==1;)F--,l(C,Lt<Y?st:gt,Y,d),Y=C.length,m=1;else F==0&&(m=F=1),C=gt.slice(),Y=C.length;if(Y<V&&(C=[0].concat(C)),l(W,C,V,d),V=W.length,m==-1)for(;f(gt,W,Lt,V)<1;)F++,l(W,Lt<V?st:gt,V,d),V=W.length}else m===0&&(F++,W=[0]);wt[E++]=F,W[0]?W[V++]=kt[xe]||0:(W=[kt[xe]],V=1)}while((xe++<$e||W[0]!=null)&&Vt--);I=W[0]!=null,wt[0]||wt.splice(0,1)}if(d==c){for(E=1,Vt=wt[0];Vt>=10;Vt/=10,E++);j(ft,x+(ft.e=E+A*u-1)+1,v,I)}else ft.e=A,ft.r=+I;return ft}}();function h(a,f,l,b){var g,x,v,d,m;if(l==null?l=at:D(l,0,8),!a.c)return a.toString();if(g=a.c[0],v=a.e,f==null)m=G(a.c),m=b==1||b==2&&(v<=ht||v>=Bt)?X(m,v):yt(m,v,"0");else if(a=j(new S(a),f,l),x=a.e,m=G(a.c),d=m.length,b==1||b==2&&(f<=x||x<=ht)){for(;d<f;m+="0",d++);m=X(m,x)}else if(f-=v,m=yt(m,x,"0"),x+1>d){if(--f>0)for(m+=".";f--;m+="0");}else if(f+=x-d,f>0)for(x+1==d&&(m+=".");f--;m+="0");return a.s<0&&g?"-"+m:m}function ct(a,f){for(var l,b,g=1,x=new S(a[0]);g<a.length;g++)b=new S(a[g]),(!b.s||(l=tt(x,b))===f||l===0&&x.s===f)&&(x=b);return x}function Z(a,f,l){for(var b=1,g=f.length;!f[--g];f.pop());for(g=f[0];g>=10;g/=10,b++);return(l=b+l*u-1)>Ct?a.c=a.e=null:l<Pt?a.c=[a.e=0]:(a.e=l,a.c=f),a}z=function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,f=/^([^.]+)\.$/,l=/^\.([^.]+)$/,b=/^-?(Infinity|NaN)$/,g=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(x,v,d,m){var A,E=d?v:v.replace(g,"");if(b.test(E))x.s=isNaN(E)?null:E<0?-1:1;else{if(!d&&(E=E.replace(a,function(I,F,C){return A=(C=C.toLowerCase())=="x"?16:C=="b"?2:8,!m||m==A?F:I}),m&&(A=m,E=E.replace(f,"$1").replace(l,"0.$1")),v!=E))return new S(E,A);if(S.DEBUG)throw Error(s+"Not a"+(m?" base "+m:"")+" number: "+v);x.s=null}x.c=x.e=null}}();function j(a,f,l,b){var g,x,v,d,m,A,E,I=a.c,F=y;if(I){t:{for(g=1,d=I[0];d>=10;d/=10,g++);if(x=f-g,x<0)x+=u,v=f,m=I[A=0],E=i(m/F[g-v-1]%10);else if(A=n((x+1)/u),A>=I.length)if(b){for(;I.length<=A;I.push(0));m=E=0,g=1,x%=u,v=x-u+1}else break t;else{for(m=d=I[A],g=1;d>=10;d/=10,g++);x%=u,v=x-u+g,E=v<0?0:i(m/F[g-v-1]%10)}if(b=b||f<0||I[A+1]!=null||(v<0?m:m%F[g-v-1]),b=l<4?(E||b)&&(l==0||l==(a.s<0?3:2)):E>5||E==5&&(l==4||b||l==6&&(x>0?v>0?m/F[g-v]:0:I[A-1])%10&1||l==(a.s<0?8:7)),f<1||!I[0])return I.length=0,b?(f-=a.e+1,I[0]=F[(u-f%u)%u],a.e=-f||0):I[0]=a.e=0,a;if(x==0?(I.length=A,d=1,A--):(I.length=A+1,d=F[u-x],I[A]=v>0?i(m/F[g-v]%F[v])*d:0),b)for(;;)if(A==0){for(x=1,v=I[0];v>=10;v/=10,x++);for(v=I[0]+=d,d=1;v>=10;v/=10,d++);x!=d&&(a.e++,I[0]==c&&(I[0]=1));break}else{if(I[A]+=d,I[A]!=c)break;I[A--]=0,d=1}for(x=I.length;I[--x]===0;I.pop());}a.e>Ct?a.c=a.e=null:a.e<Pt&&(a.c=[a.e=0])}return a}function M(a){var f,l=a.e;return l===null?a.toString():(f=G(a.c),f=l<=ht||l>=Bt?X(f,l):yt(f,l,"0"),a.s<0?"-"+f:f)}return R.absoluteValue=R.abs=function(){var a=new S(this);return a.s<0&&(a.s=1),a},R.comparedTo=function(a,f){return tt(this,new S(a,f))},R.decimalPlaces=R.dp=function(a,f){var l,b,g,x=this;if(a!=null)return D(a,0,N),f==null?f=at:D(f,0,8),j(new S(x),a+x.e+1,f);if(!(l=x.c))return null;if(b=((g=l.length-1)-P(this.e/u))*u,g=l[g])for(;g%10==0;g/=10,b--);return b<0&&(b=0),b},R.dividedBy=R.div=function(a,f){return $(this,new S(a,f),et,at)},R.dividedToIntegerBy=R.idiv=function(a,f){return $(this,new S(a,f),0,1)},R.exponentiatedBy=R.pow=function(a,f){var l,b,g,x,v,d,m,A,E,I=this;if(a=new S(a),a.c&&!a.isInteger())throw Error(s+"Exponent not an integer: "+M(a));if(f!=null&&(f=new S(f)),d=a.e>14,!I.c||!I.c[0]||I.c[0]==1&&!I.e&&I.c.length==1||!a.c||!a.c[0])return E=new S(Math.pow(+M(I),d?a.s*(2-Ot(a)):+M(a))),f?E.mod(f):E;if(m=a.s<0,f){if(f.c?!f.c[0]:!f.s)return new S(NaN);b=!m&&I.isInteger()&&f.isInteger(),b&&(I=I.mod(f))}else{if(a.e>9&&(I.e>0||I.e<-1||(I.e==0?I.c[0]>1||d&&I.c[1]>=24e7:I.c[0]<8e13||d&&I.c[0]<=9999975e7)))return x=I.s<0&&Ot(a)?-0:0,I.e>-1&&(x=1/x),new S(m?1/x:x);U&&(x=n(U/u+2))}for(d?(l=new S(.5),m&&(a.s=1),A=Ot(a)):(g=Math.abs(+M(a)),A=g%2),E=new S(ot);;){if(A){if(E=E.times(I),!E.c)break;x?E.c.length>x&&(E.c.length=x):b&&(E=E.mod(f))}if(g){if(g=i(g/2),g===0)break;A=g%2}else if(a=a.times(l),j(a,a.e+1,1),a.e>14)A=Ot(a);else{if(g=+M(a),g===0)break;A=g%2}I=I.times(I),x?I.c&&I.c.length>x&&(I.c.length=x):b&&(I=I.mod(f))}return b?E:(m&&(E=ot.div(E)),f?E.mod(f):x?j(E,U,at,v):E)},R.integerValue=function(a){var f=new S(this);return a==null?a=at:D(a,0,8),j(f,f.e+1,a)},R.isEqualTo=R.eq=function(a,f){return tt(this,new S(a,f))===0},R.isFinite=function(){return!!this.c},R.isGreaterThan=R.gt=function(a,f){return tt(this,new S(a,f))>0},R.isGreaterThanOrEqualTo=R.gte=function(a,f){return(f=tt(this,new S(a,f)))===1||f===0},R.isInteger=function(){return!!this.c&&P(this.e/u)>this.c.length-2},R.isLessThan=R.lt=function(a,f){return tt(this,new S(a,f))<0},R.isLessThanOrEqualTo=R.lte=function(a,f){return(f=tt(this,new S(a,f)))===-1||f===0},R.isNaN=function(){return!this.s},R.isNegative=function(){return this.s<0},R.isPositive=function(){return this.s>0},R.isZero=function(){return!!this.c&&this.c[0]==0},R.minus=function(a,f){var l,b,g,x,v=this,d=v.s;if(a=new S(a,f),f=a.s,!d||!f)return new S(NaN);if(d!=f)return a.s=-f,v.plus(a);var m=v.e/u,A=a.e/u,E=v.c,I=a.c;if(!m||!A){if(!E||!I)return E?(a.s=-f,a):new S(I?v:NaN);if(!E[0]||!I[0])return I[0]?(a.s=-f,a):new S(E[0]?v:at==3?-0:0)}if(m=P(m),A=P(A),E=E.slice(),d=m-A){for((x=d<0)?(d=-d,g=E):(A=m,g=I),g.reverse(),f=d;f--;g.push(0));g.reverse()}else for(b=(x=(d=E.length)<(f=I.length))?d:f,d=f=0;f<b;f++)if(E[f]!=I[f]){x=E[f]<I[f];break}if(x&&(g=E,E=I,I=g,a.s=-a.s),f=(b=I.length)-(l=E.length),f>0)for(;f--;E[l++]=0);for(f=c-1;b>d;){if(E[--b]<I[b]){for(l=b;l&&!E[--l];E[l]=f);--E[l],E[b]+=c}E[b]-=I[b]}for(;E[0]==0;E.splice(0,1),--A);return E[0]?Z(a,E,A):(a.s=at==3?-1:1,a.c=[a.e=0],a)},R.modulo=R.mod=function(a,f){var l,b,g=this;return a=new S(a,f),!g.c||!a.s||a.c&&!a.c[0]?new S(NaN):!a.c||g.c&&!g.c[0]?new S(g):(k==9?(b=a.s,a.s=1,l=$(g,a,0,3),a.s=b,l.s*=b):l=$(g,a,0,k),a=g.minus(l.times(a)),!a.c[0]&&k==1&&(a.s=g.s),a)},R.multipliedBy=R.times=function(a,f){var l,b,g,x,v,d,m,A,E,I,F,C,Y,ft,wt,W=this,V=W.c,_t=(a=new S(a,f)).c;if(!V||!_t||!V[0]||!_t[0])return!W.s||!a.s||V&&!V[0]&&!_t||_t&&!_t[0]&&!V?a.c=a.e=a.s=null:(a.s*=W.s,!V||!_t?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(b=P(W.e/u)+P(a.e/u),a.s*=W.s,m=V.length,I=_t.length,m<I&&(Y=V,V=_t,_t=Y,g=m,m=I,I=g),g=m+I,Y=[];g--;Y.push(0));for(ft=c,wt=_,g=I;--g>=0;){for(l=0,F=_t[g]%wt,C=_t[g]/wt|0,v=m,x=g+v;x>g;)A=V[--v]%wt,E=V[v]/wt|0,d=C*A+E*F,A=F*A+d%wt*wt+Y[x]+l,l=(A/ft|0)+(d/wt|0)+C*E,Y[x--]=A%ft;Y[x]=l}return l?++b:Y.splice(0,1),Z(a,Y,b)},R.negated=function(){var a=new S(this);return a.s=-a.s||null,a},R.plus=function(a,f){var l,b=this,g=b.s;if(a=new S(a,f),f=a.s,!g||!f)return new S(NaN);if(g!=f)return a.s=-f,b.minus(a);var x=b.e/u,v=a.e/u,d=b.c,m=a.c;if(!x||!v){if(!d||!m)return new S(g/0);if(!d[0]||!m[0])return m[0]?a:new S(d[0]?b:g*0)}if(x=P(x),v=P(v),d=d.slice(),g=x-v){for(g>0?(v=x,l=m):(g=-g,l=d),l.reverse();g--;l.push(0));l.reverse()}for(g=d.length,f=m.length,g-f<0&&(l=m,m=d,d=l,f=g),g=0;f;)g=(d[--f]=d[f]+m[f]+g)/c|0,d[f]=c===d[f]?0:d[f]%c;return g&&(d=[g].concat(d),++v),Z(a,d,v)},R.precision=R.sd=function(a,f){var l,b,g,x=this;if(a!=null&&a!==!!a)return D(a,1,N),f==null?f=at:D(f,0,8),j(new S(x),a,f);if(!(l=x.c))return null;if(g=l.length-1,b=g*u+1,g=l[g]){for(;g%10==0;g/=10,b--);for(g=l[0];g>=10;g/=10,b++);}return a&&x.e+1>b&&(b=x.e+1),b},R.shiftedBy=function(a){return D(a,-w,w),this.times("1e"+a)},R.squareRoot=R.sqrt=function(){var a,f,l,b,g,x=this,v=x.c,d=x.s,m=x.e,A=et+4,E=new S("0.5");if(d!==1||!v||!v[0])return new S(!d||d<0&&(!v||v[0])?NaN:v?x:1/0);if(d=Math.sqrt(+M(x)),d==0||d==1/0?(f=G(v),(f.length+m)%2==0&&(f+="0"),d=Math.sqrt(+f),m=P((m+1)/2)-(m<0||m%2),d==1/0?f="5e"+m:(f=d.toExponential(),f=f.slice(0,f.indexOf("e")+1)+m),l=new S(f)):l=new S(d+""),l.c[0]){for(m=l.e,d=m+A,d<3&&(d=0);;)if(g=l,l=E.times(g.plus($(x,g,A,1))),G(g.c).slice(0,d)===(f=G(l.c)).slice(0,d))if(l.e<m&&--d,f=f.slice(d-3,d+1),f=="9999"||!b&&f=="4999"){if(!b&&(j(g,g.e+et+2,0),g.times(g).eq(x))){l=g;break}A+=4,d+=4,b=1}else{(!+f||!+f.slice(1)&&f.charAt(0)=="5")&&(j(l,l.e+et+2,1),a=!l.times(l).eq(x));break}}return j(l,l.e+et+1,at,a)},R.toExponential=function(a,f){return a!=null&&(D(a,0,N),a++),h(this,a,f,1)},R.toFixed=function(a,f){return a!=null&&(D(a,0,N),a=a+this.e+1),h(this,a,f)},R.toFormat=function(a,f,l){var b,g=this;if(l==null)a!=null&&f&&typeof f=="object"?(l=f,f=null):a&&typeof a=="object"?(l=a,a=f=null):l=q;else if(typeof l!="object")throw Error(s+"Argument not an object: "+l);if(b=g.toFixed(a,f),g.c){var x,v=b.split("."),d=+l.groupSize,m=+l.secondaryGroupSize,A=l.groupSeparator||"",E=v[0],I=v[1],F=g.s<0,C=F?E.slice(1):E,Y=C.length;if(m&&(x=d,d=m,m=x,Y-=x),d>0&&Y>0){for(x=Y%d||d,E=C.substr(0,x);x<Y;x+=d)E+=A+C.substr(x,d);m>0&&(E+=A+C.slice(x)),F&&(E="-"+E)}b=I?E+(l.decimalSeparator||"")+((m=+l.fractionGroupSize)?I.replace(new RegExp("\\d{"+m+"}\\B","g"),"$&"+(l.fractionGroupSeparator||"")):I):E}return(l.prefix||"")+b+(l.suffix||"")},R.toFraction=function(a){var f,l,b,g,x,v,d,m,A,E,I,F,C=this,Y=C.c;if(a!=null&&(d=new S(a),!d.isInteger()&&(d.c||d.s!==1)||d.lt(ot)))throw Error(s+"Argument "+(d.isInteger()?"out of range: ":"not an integer: ")+M(d));if(!Y)return new S(C);for(f=new S(ot),A=l=new S(ot),b=m=new S(ot),F=G(Y),x=f.e=F.length-C.e-1,f.c[0]=y[(v=x%u)<0?u+v:v],a=!a||d.comparedTo(f)>0?x>0?f:A:d,v=Ct,Ct=1/0,d=new S(F),m.c[0]=0;E=$(d,f,0,1),g=l.plus(E.times(b)),g.comparedTo(a)!=1;)l=b,b=g,A=m.plus(E.times(g=A)),m=g,f=d.minus(E.times(g=f)),d=g;return g=$(a.minus(l),b,0,1),m=m.plus(g.times(A)),l=l.plus(g.times(b)),m.s=A.s=C.s,x=x*2,I=$(A,b,x,at).minus(C).abs().comparedTo($(m,l,x,at).minus(C).abs())<1?[A,b]:[m,l],Ct=v,I},R.toNumber=function(){return+M(this)},R.toPrecision=function(a,f){return a!=null&&D(a,1,N),h(this,a,f,2)},R.toString=function(a){var f,l=this,b=l.s,g=l.e;return g===null?b?(f="Infinity",b<0&&(f="-"+f)):f="NaN":(a==null?f=g<=ht||g>=Bt?X(G(l.c),g):yt(G(l.c),g,"0"):a===10&&J?(l=j(new S(l),et+g+1,at),f=yt(G(l.c),l.e,"0")):(D(a,2,H.length,"Base"),f=it(yt(G(l.c),g,"0"),10,a,b,!0)),b<0&&l.c[0]&&(f="-"+f)),f},R.valueOf=R.toJSON=function(){return M(this)},R._isBigNumber=!0,O!=null&&S.set(O),S}function P(O){var $=O|0;return O>0||O===$?$:$-1}function G(O){for(var $,it,z=1,R=O.length,ot=O[0]+"";z<R;){for($=O[z++]+"",it=u-$.length;it--;$="0"+$);ot+=$}for(R=ot.length;ot.charCodeAt(--R)===48;);return ot.slice(0,R+1||1)}function tt(O,$){var it,z,R=O.c,ot=$.c,et=O.s,at=$.s,ht=O.e,Bt=$.e;if(!et||!at)return null;if(it=R&&!R[0],z=ot&&!ot[0],it||z)return it?z?0:-at:et;if(et!=at)return et;if(it=et<0,z=ht==Bt,!R||!ot)return z?0:!R^it?1:-1;if(!z)return ht>Bt^it?1:-1;for(at=(ht=R.length)<(Bt=ot.length)?ht:Bt,et=0;et<at;et++)if(R[et]!=ot[et])return R[et]>ot[et]^it?1:-1;return ht==Bt?0:ht>Bt^it?1:-1}function D(O,$,it,z){if(O<$||O>it||O!==i(O))throw Error(s+(z||"Argument")+(typeof O=="number"?O<$||O>it?" out of range: ":" not an integer: ":" not a primitive number: ")+String(O))}function Ot(O){var $=O.c.length-1;return P(O.e/u)==$&&O.c[$]%2!=0}function X(O,$){return(O.length>1?O.charAt(0)+"."+O.slice(1):O)+($<0?"e":"e+")+$}function yt(O,$,it){var z,R;if($<0){for(R=it+".";++$;R+=it);O=R+O}else if(z=O.length,++$>z){for(R=it,$-=z;--$;R+=it);O+=R}else $<z&&(O=O.slice(0,$)+"."+O.slice($));return O}t=L(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof xn<"u"&&xn.exports?xn.exports=t:(r||(r=typeof self<"u"&&self?self:window),r.BigNumber=t)})(ra)});var ia=At((rp,na)=>{na.exports=function(t,e,n){var i=new t.Uint8Array(n),s=e.pushInt,o=e.pushInt32,c=e.pushInt32Neg,u=e.pushInt64,w=e.pushInt64Neg,y=e.pushFloat,_=e.pushFloatSingle,N=e.pushFloatDouble,L=e.pushTrue,P=e.pushFalse,G=e.pushUndefined,tt=e.pushNull,D=e.pushInfinity,Ot=e.pushInfinityNeg,X=e.pushNaN,yt=e.pushNaNNeg,O=e.pushArrayStart,$=e.pushArrayStartFixed,it=e.pushArrayStartFixed32,z=e.pushArrayStartFixed64,R=e.pushObjectStart,ot=e.pushObjectStartFixed,et=e.pushObjectStartFixed32,at=e.pushObjectStartFixed64,ht=e.pushByteString,Bt=e.pushByteStringStart,Pt=e.pushUtf8String,Ct=e.pushUtf8StringStart,re=e.pushSimpleUnassigned,k=e.pushTagStart,U=e.pushTagStart4,q=e.pushTagStart8,H=e.pushTagUnassigned,J=e.pushBreak,S=t.Math.pow,h=0,ct=0,Z=0;function j(p){for(p=p|0,h=0,ct=p;(h|0)<(ct|0)&&(Z=fu[i[h]&255](i[h]|0)|0,!((Z|0)>0)););return Z|0}function M(p){return p=p|0,((h|0)+(p|0)|0)<(ct|0)?0:1}function a(p){return p=p|0,i[p|0]<<8|i[p+1|0]|0}function f(p){return p=p|0,i[p|0]<<24|i[p+1|0]<<16|i[p+2|0]<<8|i[p+3|0]|0}function l(p){return p=p|0,s(p|0),h=h+1|0,0}function b(p){return p=p|0,M(1)|0?1:(s(i[h+1|0]|0),h=h+2|0,0)}function g(p){return p=p|0,M(2)|0?1:(s(a(h+1|0)|0),h=h+3|0,0)}function x(p){return p=p|0,M(4)|0?1:(o(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function v(p){return p=p|0,M(8)|0?1:(u(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function d(p){return p=p|0,s(-1-(p-32|0)|0),h=h+1|0,0}function m(p){return p=p|0,M(1)|0?1:(s(-1-(i[h+1|0]|0)|0),h=h+2|0,0)}function A(p){p=p|0;var rt=0;return M(2)|0?1:(rt=a(h+1|0)|0,s(-1-(rt|0)|0),h=h+3|0,0)}function E(p){return p=p|0,M(4)|0?1:(c(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function I(p){return p=p|0,M(8)|0?1:(w(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function F(p){p=p|0;var rt=0,nt=0,Q=0;return Q=p-64|0,M(Q|0)|0?1:(rt=h+1|0,nt=(h+1|0)+(Q|0)|0,ht(rt|0,nt|0),h=nt|0,0)}function C(p){p=p|0;var rt=0,nt=0,Q=0;return M(1)|0||(Q=i[h+1|0]|0,rt=h+2|0,nt=(h+2|0)+(Q|0)|0,M(Q+1|0)|0)?1:(ht(rt|0,nt|0),h=nt|0,0)}function Y(p){p=p|0;var rt=0,nt=0,Q=0;return M(2)|0||(Q=a(h+1|0)|0,rt=h+3|0,nt=(h+3|0)+(Q|0)|0,M(Q+2|0)|0)?1:(ht(rt|0,nt|0),h=nt|0,0)}function ft(p){p=p|0;var rt=0,nt=0,Q=0;return M(4)|0||(Q=f(h+1|0)|0,rt=h+5|0,nt=(h+5|0)+(Q|0)|0,M(Q+4|0)|0)?1:(ht(rt|0,nt|0),h=nt|0,0)}function wt(p){return p=p|0,1}function W(p){return p=p|0,Bt(),h=h+1|0,0}function V(p){p=p|0;var rt=0,nt=0,Q=0;return Q=p-96|0,M(Q|0)|0?1:(rt=h+1|0,nt=(h+1|0)+(Q|0)|0,Pt(rt|0,nt|0),h=nt|0,0)}function _t(p){p=p|0;var rt=0,nt=0,Q=0;return M(1)|0||(Q=i[h+1|0]|0,rt=h+2|0,nt=(h+2|0)+(Q|0)|0,M(Q+1|0)|0)?1:(Pt(rt|0,nt|0),h=nt|0,0)}function xe(p){p=p|0;var rt=0,nt=0,Q=0;return M(2)|0||(Q=a(h+1|0)|0,rt=h+3|0,nt=(h+3|0)+(Q|0)|0,M(Q+2|0)|0)?1:(Pt(rt|0,nt|0),h=nt|0,0)}function $e(p){p=p|0;var rt=0,nt=0,Q=0;return M(4)|0||(Q=f(h+1|0)|0,rt=h+5|0,nt=(h+5|0)+(Q|0)|0,M(Q+4|0)|0)?1:(Pt(rt|0,nt|0),h=nt|0,0)}function Le(p){return p=p|0,1}function Lt(p){return p=p|0,Ct(),h=h+1|0,0}function st(p){return p=p|0,$(p-128|0),h=h+1|0,0}function Vt(p){return p=p|0,M(1)|0?1:($(i[h+1|0]|0),h=h+2|0,0)}function kt(p){return p=p|0,M(2)|0?1:($(a(h+1|0)|0),h=h+3|0,0)}function gt(p){return p=p|0,M(4)|0?1:(it(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function Kc(p){return p=p|0,M(8)|0?1:(z(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function Dc(p){return p=p|0,O(),h=h+1|0,0}function mt(p){p=p|0;var rt=0;return rt=p-160|0,M(rt|0)|0?1:(ot(rt|0),h=h+1|0,0)}function jc(p){return p=p|0,M(1)|0?1:(ot(i[h+1|0]|0),h=h+2|0,0)}function Wc(p){return p=p|0,M(2)|0?1:(ot(a(h+1|0)|0),h=h+3|0,0)}function zc(p){return p=p|0,M(4)|0?1:(et(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function Yc(p){return p=p|0,M(8)|0?1:(at(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function Xc(p){return p=p|0,R(),h=h+1|0,0}function Ze(p){return p=p|0,k(p-192|0|0),h=h+1|0,0}function S0(p){return p=p|0,k(p|0),h=h+1|0,0}function I0(p){return p=p|0,k(p|0),h=h+1|0,0}function N0(p){return p=p|0,k(p|0),h=h+1|0,0}function U0(p){return p=p|0,k(p|0),h=h+1|0,0}function Ut(p){return p=p|0,k(p-192|0|0),h=h+1|0,0}function R0(p){return p=p|0,k(p|0),h=h+1|0,0}function F0(p){return p=p|0,k(p|0),h=h+1|0,0}function O0(p){return p=p|0,k(p|0),h=h+1|0,0}function Jc(p){return p=p|0,M(1)|0?1:(k(i[h+1|0]|0),h=h+2|0,0)}function Zc(p){return p=p|0,M(2)|0?1:(k(a(h+1|0)|0),h=h+3|0,0)}function Qc(p){return p=p|0,M(4)|0?1:(U(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function tu(p){return p=p|0,M(8)|0?1:(q(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function Et(p){return p=p|0,re((p|0)-224|0),h=h+1|0,0}function eu(p){return p=p|0,P(),h=h+1|0,0}function ru(p){return p=p|0,L(),h=h+1|0,0}function nu(p){return p=p|0,tt(),h=h+1|0,0}function iu(p){return p=p|0,G(),h=h+1|0,0}function su(p){return p=p|0,M(1)|0?1:(re(i[h+1|0]|0),h=h+2|0,0)}function ou(p){p=p|0;var rt=0,nt=0,Q=1,en=0,Br=0,P0=0;return M(2)|0?1:(rt=i[h+1|0]|0,nt=i[h+2|0]|0,(rt|0)&128&&(Q=-1),en=+(((rt|0)&124)>>2),Br=+(((rt|0)&3)<<8|nt),+en==0?y(+(+Q*5960464477539063e-23*+Br)):+en==31?+Q==1?+Br>0?X():D():+Br>0?yt():Ot():y(+(+Q*S(2,+(+en-25))*+(1024+Br))),h=h+3|0,0)}function au(p){return p=p|0,M(4)|0?1:(_(i[h+1|0]|0,i[h+2|0]|0,i[h+3|0]|0,i[h+4|0]|0),h=h+5|0,0)}function cu(p){return p=p|0,M(8)|0?1:(N(i[h+1|0]|0,i[h+2|0]|0,i[h+3|0]|0,i[h+4|0]|0,i[h+5|0]|0,i[h+6|0]|0,i[h+7|0]|0,i[h+8|0]|0),h=h+9|0,0)}function dt(p){return p=p|0,1}function uu(p){return p=p|0,J(),h=h+1|0,0}var fu=[l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,b,g,x,v,dt,dt,dt,dt,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,m,A,E,I,dt,dt,dt,dt,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,C,Y,ft,wt,dt,dt,dt,W,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,_t,xe,$e,Le,dt,dt,dt,Lt,st,st,st,st,st,st,st,st,st,st,st,st,st,st,st,st,st,st,st,st,st,st,st,st,Vt,kt,gt,Kc,dt,dt,dt,Dc,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,mt,jc,Wc,zc,Yc,dt,dt,dt,Xc,Ze,Ze,Ze,Ze,Ze,Ze,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Ut,Jc,Zc,Qc,tu,dt,dt,dt,dt,Et,Et,Et,Et,Et,Et,Et,Et,Et,Et,Et,Et,Et,Et,Et,Et,Et,Et,Et,Et,eu,ru,nu,iu,su,ou,au,cu,dt,dt,dt,uu];return{parse:j}}});var kr=At(Wt=>{"use strict";var es=Pr().BigNumber;Wt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Wt.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};Wt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Wt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Wt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Wt.SHIFT32=Math.pow(2,32);Wt.SHIFT16=Math.pow(2,16);Wt.MAX_SAFE_HIGH=2097151;Wt.NEG_ONE=new es(-1);Wt.TEN=new es(10);Wt.TWO=new es(2);Wt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var _n=At(te=>{"use strict";var{Buffer:Uf}=Or(),oa=Pr().BigNumber,aa=kr(),sa=aa.SHIFT32,Rf=aa.SHIFT16,Ff=2097151;te.parseHalf=function(t){var e,n,i;return i=t[0]&128?-1:1,e=(t[0]&124)>>2,n=(t[0]&3)<<8|t[1],e?e===31?i*(n?NaN:1/0):i*Math.pow(2,e-25)*(1024+n):i*5960464477539063e-23*n};function Of(r){return r<16?"0"+r.toString(16):r.toString(16)}te.arrayBufferToBignumber=function(r){let t=r.byteLength,e="";for(let n=0;n<t;n++)e+=Of(r[n]);return new oa(e,16)};te.buildMap=r=>{let t=new Map,e=Object.keys(r),n=e.length;for(let i=0;i<n;i++)t.set(e[i],r[e[i]]);return t};te.buildInt32=(r,t)=>r*Rf+t;te.buildInt64=(r,t,e,n)=>{let i=te.buildInt32(r,t),s=te.buildInt32(e,n);return i>Ff?new oa(i).times(sa).plus(s):i*sa+s};te.writeHalf=function(t,e){let n=Uf.allocUnsafe(4);n.writeFloatBE(e,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,c=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(c>>13);else if(o>=103&&o<113){if(c&(1<<126-o)-1)return!1;s+=c+8388608>>126-o}else return!1;return t.writeUInt16BE(s,0),!0};te.keySorter=function(r,t){var e=r[0].byteLength,n=t[0].byteLength;return e>n?1:n>e?-1:r[0].compare(t[0])};te.isNegativeZero=r=>r===0&&1/r<0;te.nextPowerOf2=r=>{let t=0;if(r&&!(r&r-1))return r;for(;r!==0;)r>>=1,t+=1;return 1<<t}});var ss=At((sp,ca)=>{"use strict";var is=kr(),Pf=is.MT,bn=is.SIMPLE,rs=is.SYMS,ns=class r{constructor(t){if(typeof t!="number")throw new Error("Invalid Simple type: "+typeof t);if(t<0||t>255||(t|0)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,Pf.SIMPLE_FLOAT)}static isSimple(t){return t instanceof r}static decode(t,e){switch(e==null&&(e=!0),t){case bn.FALSE:return!1;case bn.TRUE:return!0;case bn.NULL:return e?null:rs.NULL;case bn.UNDEFINED:return e?void 0:rs.UNDEFINED;case-1:if(!e)throw new Error("Invalid BREAK");return rs.BREAK;default:return new r(t)}}};ca.exports=ns});var as=At((op,ua)=>{"use strict";var os=class r{constructor(t,e,n){if(this.tag=t,this.value=e,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){var e,n;if(n=t?.[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 e=i,this.err=e,this}}};ua.exports=os});var fs=At((ap,la)=>{"use strict";var fa=self.location?self.location.protocol+"//"+self.location.host:"",cs=self.URL,us=class{constructor(t="",e=fa){this.super=new cs(t,e),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(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set origin(t){this.super.origin=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set searchParams(t){this.super.searchParams=t}set username(t){this.super.username=t}createObjectURL(t){return this.super.createObjectURL(t)}revokeObjectURL(t){this.super.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function kf(r){if(typeof r=="string")return new cs(r).toString();if(!(r instanceof cs)){let t=r.username&&r.password?`${r.username}:${r.password}@`:"",e=r.auth?r.auth+"@":"",n=r.port?":"+r.port:"",i=r.protocol?r.protocol+"//":"",s=r.host||"",o=r.hostname||"",c=r.search||(r.query?"?"+r.query:""),u=r.hash||"",w=r.pathname||"",y=r.path||w+c;return`${i}${t||e}${s||o+n}${y}${u}`}}la.exports={URLWithLegacySupport:us,URLSearchParams:self.URLSearchParams,defaultBase:fa,format:kf}});var pa=At((cp,da)=>{"use strict";var{URLWithLegacySupport:ha,format:Mf}=fs();da.exports=(r,t={},e={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(e[i]||n||i)+":";let s;try{s=new ha(r)}catch{s={}}let o=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new ha(r,Mf(o)).toString()}});var ls=At((up,ya)=>{"use strict";var{URLWithLegacySupport:Cf,format:$f,URLSearchParams:Lf,defaultBase:Vf}=fs(),qf=pa();ya.exports={URL:Cf,URLSearchParams:Lf,format:$f,relative:qf,defaultBase:Vf}});var hs=At((fp,ga)=>{"use strict";var{Buffer:dr}=Or(),wa=nn(),Hf=Pr().BigNumber,Gf=ia(),$t=_n(),lt=kr(),Kf=ss(),Df=as(),{URL:jf}=ls(),Mr=class r{constructor(t){t=t||{},!t.size||t.size<65536?t.size=65536:t.size=$t.nextPowerOf2(t.size),this._heap=new ArrayBuffer(t.size),this._heap8=new Uint8Array(this._heap),this._buffer=dr.from(this._heap),this._reset(),this._knownTags=Object.assign({0:e=>new Date(e),1:e=>new Date(e*1e3),2:e=>$t.arrayBufferToBignumber(e),3:e=>lt.NEG_ONE.minus($t.arrayBufferToBignumber(e)),4:e=>lt.TEN.pow(e[0]).times(e[1]),5:e=>lt.TWO.pow(e[0]).times(e[1]),32:e=>new jf(e),35:e=>new RegExp(e)},t.tags),this.parser=Gf(global,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var t=this._parents.pop();if(t.length>0)throw new Error(`Missing ${t.length} elements`);switch(t.type){case lt.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case lt.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case lt.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case lt.PARENT.MAP:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(t.ref,t.length));break;case lt.PARENT.OBJECT:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(t.ref,t.length));break;case lt.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===lt.PARENT.TAG&&this._dec()}_dec(){let t=this._currentParent;t.length<0||(t.length--,t.length===0&&this._closeParent())}_push(t,e){let n=this._currentParent;switch(n.values++,n.type){case lt.PARENT.ARRAY:case lt.PARENT.BYTE_STRING:case lt.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case lt.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=lt.PARENT.MAP,n.ref=$t.buildMap(n.ref)));break;case lt.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case lt.PARENT.TAG:this._ref.push(t),e||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(t,e,n){this._parents[this._depth]={type:e,length:n,ref:t,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:lt.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,e){let n=this._knownTags[t];return n?n(e):new Df(t,e)}createMap(t,e){return t}createObject(t,e){return t}createArray(t,e){return t}createByteString(t,e){return dr.concat(t)}createByteStringFromHeap(t,e){return t===e?dr.alloc(0):dr.from(this._heap.slice(t,e))}createInt(t){return t}createInt32(t,e){return $t.buildInt32(t,e)}createInt64(t,e,n,i){return $t.buildInt64(t,e,n,i)}createFloat(t){return t}createFloatSingle(t,e,n,i){return wa.read([t,e,n,i],0,!1,23,4)}createFloatDouble(t,e,n,i,s,o,c,u){return wa.read([t,e,n,i,s,o,c,u],0,!1,52,8)}createInt32Neg(t,e){return-1-$t.buildInt32(t,e)}createInt64Neg(t,e,n,i){let s=$t.buildInt32(t,e),o=$t.buildInt32(n,i);return s>lt.MAX_SAFE_HIGH?lt.NEG_ONE.minus(new Hf(s).times(lt.SHIFT32).plus(o)):-1-(s*lt.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(t,e){return t.join("")}createUtf8StringFromHeap(t,e){return t===e?"":this._buffer.toString("utf8",t,e)}createSimpleUnassigned(t){return new Kf(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,e){this._push(this.createInt32(t,e))}pushInt64(t,e,n,i){this._push(this.createInt64(t,e,n,i))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,e,n,i){this._push(this.createFloatSingle(t,e,n,i))}pushFloatDouble(t,e,n,i,s,o,c,u){this._push(this.createFloatDouble(t,e,n,i,s,o,c,u))}pushInt32Neg(t,e){this._push(this.createInt32Neg(t,e))}pushInt64Neg(t,e,n,i){this._push(this.createInt64Neg(t,e,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([],lt.PARENT.ARRAY,-1)}pushArrayStartFixed(t){this._createArrayStartFixed(t)}pushArrayStartFixed32(t,e){let n=$t.buildInt32(t,e);this._createArrayStartFixed(n)}pushArrayStartFixed64(t,e,n,i){let s=$t.buildInt64(t,e,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(t){this._createObjectStartFixed(t)}pushObjectStartFixed32(t,e){let n=$t.buildInt32(t,e);this._createObjectStartFixed(n)}pushObjectStartFixed64(t,e,n,i){let s=$t.buildInt64(t,e,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:lt.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(t,e){this._push(this.createByteStringFromHeap(t,e))}pushUtf8StringStart(){this._parents[this._depth]={type:lt.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(t,e){this._push(this.createUtf8StringFromHeap(t,e))}pushSimpleUnassigned(t){this._push(this.createSimpleUnassigned(t))}pushTagStart(t){this._parents[this._depth]={type:lt.PARENT.TAG,length:1,ref:[t]}}pushTagStart4(t,e){this.pushTagStart($t.buildInt32(t,e))}pushTagStart8(t,e,n,i){this.pushTagStart($t.buildInt64(t,e,n,i))}pushTagUnassigned(t){this._push(this.createTag(t))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(t){if(t===0){this._push(this.createObject({}));return}this._createParent({},lt.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),lt.PARENT.ARRAY,t)}_decode(t){if(t.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(t);let e=this.parser.parse(t.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(e>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(t){return this._decode(t),this._res[0]}decodeAll(t){return this._decode(t),this._res}static decode(t,e){return typeof t=="string"&&(t=dr.from(t,e||"hex")),new r({size:t.length}).decodeFirst(t)}static decodeAll(t,e){return typeof t=="string"&&(t=dr.from(t,e||"hex")),new r({size:t.length}).decodeAll(t)}};Mr.decodeFirst=Mr.decode;ga.exports=Mr});var _a=At((lp,xa)=>{"use strict";var{Buffer:ds}=Or(),Wf=hs(),zf=_n(),ps=class r extends Wf{createTag(t,e){return`${t}(${e})`}createInt(t){return super.createInt(t).toString()}createInt32(t,e){return super.createInt32(t,e).toString()}createInt64(t,e,n,i){return super.createInt64(t,e,n,i).toString()}createInt32Neg(t,e){return super.createInt32Neg(t,e).toString()}createInt64Neg(t,e,n,i){return super.createInt64Neg(t,e,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(t){let e=super.createFloat(t);return zf.isNegativeZero(t)?"-0_1":`${e}_1`}createFloatSingle(t,e,n,i){return`${super.createFloatSingle(t,e,n,i)}_2`}createFloatDouble(t,e,n,i,s,o,c,u){return`${super.createFloatDouble(t,e,n,i,s,o,c,u)}_3`}createByteString(t,e){let n=t.join(", ");return e===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(t,e){return`h'${ds.from(super.createByteStringFromHeap(t,e)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(t){return`simple(${t})`}createArray(t,e){let n=super.createArray(t,e);return e===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(t,e){let n=super.createMap(t),i=Array.from(n.keys()).reduce(ma(n),"");return e===-1?`{_ ${i}}`:`{${i}}`}createObject(t,e){let n=super.createObject(t),i=Object.keys(n).reduce(ma(n),"");return e===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(t,e){let n=t.join(", ");return e===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(t,e){return`"${ds.from(super.createUtf8StringFromHeap(t,e)).toString("utf8")}"`}static diagnose(t,e){return typeof t=="string"&&(t=ds.from(t,e||"hex")),new r().decodeFirst(t)}};xa.exports=ps;function ma(r){return(t,e)=>t?`${t}, ${e}: ${r[e]}`:`${e}: ${r[e]}`}});var Ta=At((hp,va)=>{"use strict";var{Buffer:de}=Or(),{URL:Yf}=ls(),ws=Pr().BigNumber,ys=_n(),St=kr(),ie=St.MT,En=St.NUMBYTES,ba=St.SHIFT32,Ea=St.SYMS,pr=St.TAG,Xf=St.MT.SIMPLE_FLOAT<<5|St.NUMBYTES.TWO,Jf=St.MT.SIMPLE_FLOAT<<5|St.NUMBYTES.FOUR,Zf=St.MT.SIMPLE_FLOAT<<5|St.NUMBYTES.EIGHT,Qf=St.MT.SIMPLE_FLOAT<<5|St.SIMPLE.TRUE,tl=St.MT.SIMPLE_FLOAT<<5|St.SIMPLE.FALSE,el=St.MT.SIMPLE_FLOAT<<5|St.SIMPLE.UNDEFINED,Aa=St.MT.SIMPLE_FLOAT<<5|St.SIMPLE.NULL,rl=new ws("0x20000000000000"),nl=de.from("f97e00","hex"),il=de.from("f9fc00","hex"),sl=de.from("f97c00","hex");function ol(r){return{}.toString.call(r).slice(8,-1)}var gs=class r{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[Yf,this._pushUrl],[ws,this._pushBigNumber]];let e=t.genTypes||[],n=e.length;for(let i=0;i<n;i++)this.addSemanticType(e[i][0],e[i][1]);this._reset()}addSemanticType(t,e){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===t){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=e,o}return this.semanticTypes.push([t,e]),null}push(t){return t&&(this.result[this.offset]=t,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=t.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(t,e,n){return this.result[this.offset]=t,this.resultMethod[this.offset]=e,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(t){return this.pushWrite(t,1,1)}_pushUInt16BE(t){return this.pushWrite(t,2,2)}_pushUInt32BE(t){return this.pushWrite(t,3,4)}_pushDoubleBE(t){return this.pushWrite(t,4,8)}_pushNaN(){return this.push(nl)}_pushInfinity(t){let e=t<0?il:sl;return this.push(e)}_pushFloat(t){let e=de.allocUnsafe(2);if(ys.writeHalf(e,t)&&ys.parseHalf(e)===t)return this._pushUInt8(Xf)&&this.push(e);let n=de.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(Jf)&&this.push(n):this._pushUInt8(Zf)&&this._pushDoubleBE(t)}_pushInt(t,e,n){let i=e<<5;return t<24?this._pushUInt8(i|t):t<=255?this._pushUInt8(i|En.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|En.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|En.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|En.EIGHT)&&this._pushUInt32BE(Math.floor(t/ba))&&this._pushUInt32BE(t%ba):e===ie.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,ie.NEG_INT,t):this._pushInt(t,ie.POS_INT)}_pushNumber(t){switch(!1){case t===t:return this._pushNaN(t);case isFinite(t):return this._pushInfinity(t);case t%1!==0:return this._pushIntNum(t);default:return this._pushFloat(t)}}_pushString(t){let e=de.byteLength(t,"utf8");return this._pushInt(e,ie.UTF8_STRING)&&this.pushWrite(t,5,e)}_pushBoolean(t){return this._pushUInt8(t?Qf:tl)}_pushUndefined(t){return this._pushUInt8(el)}_pushArray(t,e){let n=e.length;if(!t._pushInt(n,ie.ARRAY))return!1;for(let i=0;i<n;i++)if(!t.pushAny(e[i]))return!1;return!0}_pushTag(t){return this._pushInt(t,ie.TAG)}_pushDate(t,e){return t._pushTag(pr.DATE_EPOCH)&&t.pushAny(Math.round(e/1e3))}_pushBuffer(t,e){return t._pushInt(e.length,ie.BYTE_STRING)&&t.push(e)}_pushNoFilter(t,e){return t._pushBuffer(t,e.slice())}_pushRegexp(t,e){return t._pushTag(pr.REGEXP)&&t.pushAny(e.source)}_pushSet(t,e){if(!t._pushInt(e.size,ie.ARRAY))return!1;for(let n of e)if(!t.pushAny(n))return!1;return!0}_pushUrl(t,e){return t._pushTag(pr.URI)&&t.pushAny(e.format())}_pushBigint(t){let e=pr.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),e=pr.NEG_BIGINT);let n=t.toString(16);n.length%2&&(n="0"+n);let i=de.from(n,"hex");return this._pushTag(e)&&this._pushBuffer(this,i)}_pushBigNumber(t,e){if(e.isNaN())return t._pushNaN();if(!e.isFinite())return t._pushInfinity(e.isNegative()?-1/0:1/0);if(e.isInteger())return t._pushBigint(e);if(!(t._pushTag(pr.DECIMAL_FRAC)&&t._pushInt(2,ie.ARRAY)))return!1;let n=e.decimalPlaces(),i=e.multipliedBy(new ws(10).pow(n));return t._pushIntNum(-n)?i.abs().isLessThan(rl)?t._pushIntNum(i.toNumber()):t._pushBigint(i):!1}_pushMap(t,e){return t._pushInt(e.size,ie.MAP)?this._pushRawMap(e.size,Array.from(e)):!1}_pushObject(t){if(!t)return this._pushUInt8(Aa);for(var e=this.semanticTypes.length,n=0;n<e;n++)if(t instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(t,this,t);var i=t.encodeCBOR;if(typeof i=="function")return i.call(t,this);var s=Object.keys(t),o=s.length;return this._pushInt(o,ie.MAP)?this._pushRawMap(o,s.map(c=>[c,t[c]])):!1}_pushRawMap(t,e){e=e.map(function(i){return i[0]=r.encode(i[0]),i}).sort(ys.keySorter);for(var n=0;n<t;n++)if(!this.push(e[n][0])||!this.pushAny(e[n][1]))return!1;return!0}write(t){return this.pushAny(t)}pushAny(t){var e=ol(t);switch(e){case"Number":return this._pushNumber(t);case"String":return this._pushString(t);case"Boolean":return this._pushBoolean(t);case"Object":return this._pushObject(t);case"Array":return this._pushArray(this,t);case"Uint8Array":return this._pushBuffer(this,de.isBuffer(t)?t:de.from(t));case"Null":return this._pushUInt8(Aa);case"Undefined":return this._pushUndefined(t);case"Map":return this._pushMap(this,t);case"Set":return this._pushSet(this,t);case"URL":return this._pushUrl(this,t);case"BigNumber":return this._pushBigNumber(this,t);case"Date":return this._pushDate(this,t);case"RegExp":return this._pushRegexp(this,t);case"Symbol":switch(t){case Ea.NULL:return this._pushObject(null);case Ea.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+t.toString())}default:throw new Error("Unknown type: "+typeof t+", "+(t?t.toString():""))}}finalize(){if(this.offset===0)return null;for(var t=this.result,e=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=e[o];var c=de.allocUnsafe(s),u=0,w=0;for(o=0;o<i;o++){switch(w=e[o],n[o]){case 0:t[o].copy(c,u);break;case 1:c.writeUInt8(t[o],u,!0);break;case 2:c.writeUInt16BE(t[o],u,!0);break;case 3:c.writeUInt32BE(t[o],u,!0);break;case 4:c.writeDoubleBE(t[o],u,!0);break;case 5:c.write(t[o],u,w,"utf8");break;default:throw new Error("unkown method")}u+=w}var y=c;return this._reset(),y}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(t){let e=new r;if(!e.pushAny(t))throw new Error("Failed to encode input");return e.finalize()}};va.exports=gs});var An=At(It=>{"use strict";It.Diagnose=_a();It.Decoder=hs();It.Encoder=Ta();It.Simple=ss();It.Tagged=as();It.decodeAll=It.Decoder.decodeAll;It.decodeFirst=It.Decoder.decodeFirst;It.diagnose=It.Diagnose.diagnose;It.encode=It.Encoder.encode;It.decode=It.Decoder.decode;It.leveldb={decode:It.Decoder.decodeAll,encode:It.Encoder.encode,buffer:!0,name:"cbor"}});function pe(...r){let t=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),e=0;for(let n of r)t.set(new Uint8Array(n),e),e+=n.byteLength;return t.buffer}function Tt(r){return[...new Uint8Array(r)].map(t=>t.toString(16).padStart(2,"0")).join("")}function Gt(r){if(!al.test(r))throw new Error("Invalid hexadecimal string.");let t=[...r].reduce((e,n,i)=>(e[i/2|0]=(e[i/2|0]||"")+n,e),[]).map(e=>Number.parseInt(e,16));return new Uint8Array(t).buffer}function ms(r,t){if(r.byteLength!==t.byteLength)return r.byteLength-t.byteLength;let e=new Uint8Array(r),n=new Uint8Array(t);for(let i=0;i<e.length;i++)if(e[i]!==n[i])return e[i]-n[i];return 0}function Cr(r,t){return ms(r,t)===0}function Ge(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function vn(r){return r instanceof Uint8Array?Ge(r):r instanceof ArrayBuffer?r:Array.isArray(r)?Ge(new Uint8Array(r)):"buffer"in r?vn(r.buffer):Ge(new Uint8Array(r))}var al,zt=ut(()=>{al=new RegExp(/^[0-9a-fA-F]+$/)});function Re(r){return Ge(Ro.create().update(new Uint8Array(r)).digest())}function Tn(r){if(r instanceof Ba.default.Tagged)return Tn(r.value);if(typeof r=="string")return Sa(r);if(typeof r=="number")return Re(Ue(r));if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))return Re(r);if(Array.isArray(r)){let t=r.map(Tn);return Re(pe(...t))}else{if(r&&typeof r=="object"&&r._isPrincipal)return Re(r.toUint8Array());if(typeof r=="object"&&r!==null&&typeof r.toHash=="function")return Tn(r.toHash());if(typeof r=="object")return xs(r);if(typeof r=="bigint")return Re(Ue(r))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${r}`),{value:r})}function yr(r){return xs(r)}function xs(r){let n=Object.entries(r).filter(([,o])=>o!==void 0).map(([o,c])=>{let u=Sa(o),w=Tn(c);return[u,w]}).sort(([o],[c])=>ms(o,c)),i=pe(...n.map(o=>pe(...o)));return Re(i)}var Ba,Sa,$r=ut(()=>{fr();Ba=Te(An());Ii();zt();Sa=r=>{let t=new TextEncoder().encode(r);return Re(t)}});var Es=At(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});var fl=9007199254740992;function Ae(r,...t){let e=new Uint8Array(r.byteLength+t.reduce((i,s)=>i+s.byteLength,0));e.set(new Uint8Array(r),0);let n=r.byteLength;for(let i of t)e.set(new Uint8Array(i),n),n+=i.byteLength;return e.buffer}function se(r,t,e){e=e.replace(/[^0-9a-fA-F]/g,"");let n=2**(t-24);e=e.slice(-n*2).padStart(n*2,"0");let i=[(r<<5)+t].concat(e.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function Bn(r,t){if(t<24)return new Uint8Array([(r<<5)+t]).buffer;{let e=t<=255?24:t<=65535?25:t<=4294967295?26:27;return se(r,e,t.toString(16))}}function Ia(r){let t=[];for(let e=0;e<r.length;e++){let n=r.charCodeAt(e);n<128?t.push(n):n<2048?t.push(192|n>>6,128|n&63):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|n&63):(e++,n=(n&1023)<<10|r.charCodeAt(e)&1023,t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Ae(new Uint8Array(Bn(3,r.length)),new Uint8Array(t))}function ll(r,t){if(r==14277111)return Ae(new Uint8Array([217,217,247]),t);if(r<24)return Ae(new Uint8Array([192+r]),t);{let e=r<=255?24:r<=65535?25:r<=4294967295?26:27,n=2**(e-24),i=r.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+e].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}pt.tagged=ll;function Lr(r){return new Uint8Array(r).buffer}pt.raw=Lr;function _s(r){if(isNaN(r))throw new RangeError("Invalid number.");r=Math.min(Math.max(0,r),23);let t=[0+r];return new Uint8Array(t).buffer}pt.uSmall=_s;function Na(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),255),r=r.toString(16),se(0,24,r)}pt.u8=Na;function Ua(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),65535),r=r.toString(16),se(0,25,r)}pt.u16=Ua;function Ra(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),4294967295),r=r.toString(16),se(0,26,r)}pt.u32=Ra;function bs(r,t){if(typeof r=="string"&&t==16){if(r.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return se(0,27,r)}if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),fl),r=r.toString(16),se(0,27,r)}pt.u64=bs;function Fa(r){if(isNaN(r))throw new RangeError("Invalid number.");if(r===0)return _s(0);r=Math.min(Math.max(0,-r),24)-1;let t=[32+r];return new Uint8Array(t).buffer}pt.iSmall=Fa;function Oa(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),255),r=r.toString(16),se(1,24,r)}pt.i8=Oa;function Pa(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),65535),r=r.toString(16),se(1,25,r)}pt.i16=Pa;function ka(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),4294967295),r=r.toString(16),se(1,26,r)}pt.i32=ka;function Ma(r,t){if(typeof r=="string"&&t==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 e=!1,n=r.split("").reduceRight((i,s)=>{if(e)return s+i;let o=parseInt(s,16)-1;return o>=0?(e=!0,o.toString(16)+i):"f"+i},"");return e?se(1,27,n):bs(0)}if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),9007199254740992),r=r.toString(16),se(1,27,r)}pt.i64=Ma;function hl(r){return r>=0?r<24?_s(r):r<=255?Na(r):r<=65535?Ua(r):r<=4294967295?Ra(r):bs(r):r>=-24?Fa(r):r>=-255?Oa(r):r>=-65535?Pa(r):r>=-4294967295?ka(r):Ma(r)}pt.number=hl;function dl(r){return Ae(Bn(2,r.byteLength),r)}pt.bytes=dl;function pl(r){return Ia(r)}pt.string=pl;function yl(r){return Ae(Bn(4,r.length),...r)}pt.array=yl;function wl(r,t=!1){r instanceof Map||(r=new Map(Object.entries(r)));let e=Array.from(r.entries());return t&&(e=e.sort(([n],[i])=>n.localeCompare(i))),Ae(Bn(5,r.size),...e.map(([n,i])=>Ae(Ia(n),i)))}pt.map=wl;function gl(r){let t=new Float32Array([r]);return Ae(new Uint8Array([250]),new Uint8Array(t.buffer))}pt.singleFloat=gl;function ml(r){let t=new Float64Array([r]);return Ae(new Uint8Array([251]),new Uint8Array(t.buffer))}pt.doubleFloat=ml;function xl(r){return r?Ca():$a()}pt.bool=xl;function Ca(){return Lr(new Uint8Array([245]))}pt.true_=Ca;function $a(){return Lr(new Uint8Array([244]))}pt.false_=$a;function _l(){return Lr(new Uint8Array([246]))}pt.null_=_l;function bl(){return Lr(new Uint8Array([247]))}pt.undefined_=bl});var La=At(Fe=>{"use strict";var El=Fe&&Fe.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t};Object.defineProperty(Fe,"__esModule",{value:!0});var oe=El(Es()),Al=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Sn=class{constructor(t,e=!1){this._serializer=t,this._stable=e,this.name="jsonDefault",this.priority=-100}match(t){return["undefined","boolean","number","string","object"].indexOf(typeof t)!=-1}encode(t){switch(typeof t){case"undefined":return oe.undefined_();case"boolean":return oe.bool(t);case"number":return Math.floor(t)===t?oe.number(t):oe.doubleFloat(t);case"string":return oe.string(t);case"object":if(t===null)return oe.null_();if(Array.isArray(t))return oe.array(t.map(e=>this._serializer.serializeValue(e)));if(Al.find(e=>t instanceof e))return oe.bytes(t.buffer);if(Object.getOwnPropertyNames(t).indexOf("toJSON")!==-1)return this.encode(t.toJSON());if(t instanceof Map){let e=new Map;for(let[n,i]of t.entries())e.set(n,this._serializer.serializeValue(i));return oe.map(e,this._stable)}else{let e=new Map;for(let[n,i]of Object.entries(t))e.set(n,this._serializer.serializeValue(i));return oe.map(e,this._stable)}default:throw new Error("Invalid value.")}}};Fe.JsonDefaultCborEncoder=Sn;var In=class{constructor(){this.name="cborEncoder",this.priority=-90}match(t){return typeof t=="object"&&typeof t.toCBOR=="function"}encode(t){return t.toCBOR()}};Fe.ToCborEncoder=In;var Nn=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let e=new this;return e.addEncoder(new Sn(e,t)),e.addEncoder(new In),e}removeEncoder(t){for(let e of this._encoders.values())e.name==t&&this._encoders.delete(e)}addEncoder(t){this._encoders.add(t)}getEncoderFor(t){let e=null;for(let n of this._encoders)(!e||n.priority>e.priority)&&n.match(t)&&(e=n);if(e===null)throw new Error("Could not find an encoder for value.");return e}serializeValue(t){return this.getEncoderFor(t).encode(t)}serialize(t){return this.serializeValue(t)}};Fe.CborSerializer=Nn;var As=class extends Nn{serialize(t){return oe.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};Fe.SelfDescribeCborSerializer=As});var Vr=At(Ke=>{"use strict";function vl(r){for(var t in r)Ke.hasOwnProperty(t)||(Ke[t]=r[t])}var Tl=Ke&&Ke.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t};Object.defineProperty(Ke,"__esModule",{value:!0});vl(La());var Bl=Tl(Es());Ke.value=Bl});function Va(r){let t=r.byteLength,e=BigInt(0);for(let n=0;n<t;n++)e=e*BigInt(256)+BigInt(r[n]);return e}function Un(r){let t=new Uint8Array(r),e=new Is({size:t.byteLength,tags:{2:n=>Va(n),3:n=>-Va(n),[Ss.Semantic]:n=>n}});try{return e.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${Tt(t)}`)}}var qa,De,Ha,vs,Ts,Bs,Ns,Ss,Is,qr=ut(()=>{qa=Te(An()),De=Te(Vr()),Ha=Te(Vr());zt();vs=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return De.value.bytes(t.toUint8Array())}},Ts=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return De.value.bytes(new Uint8Array(t))}},Bs=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?De.value.tagged(2,De.value.bytes(Gt(t.toString(16)))):De.value.tagged(3,De.value.bytes(Gt((BigInt("-1")*t).toString(16))))}},Ns=Ha.SelfDescribeCborSerializer.withDefaultEncoders(!0);Ns.addEncoder(new vs);Ns.addEncoder(new Ts);Ns.addEncoder(new Bs);(function(r){r[r.Uint64LittleEndian=71]="Uint64LittleEndian",r[r.Semantic=55799]="Semantic"})(Ss||(Ss={}));Is=class extends qa.default.Decoder{createByteString(t){return pe(...t)}createByteStringFromHeap(t,e){return t===e?new ArrayBuffer(0):new Uint8Array(this._heap.slice(t,e))}}});function Rs(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Fs(r){if(!Rs(r))throw new Error("Uint8Array expected")}function On(r){Fs(r);let t="";for(let e=0;e<r.length;e++)t+=Ul[r[e]];return t}function Da(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Ka(r){if(r>=ve._0&&r<=ve._9)return r-ve._0;if(r>=ve._A&&r<=ve._F)return r-(ve._A-10);if(r>=ve._a&&r<=ve._f)return r-(ve._a-10)}function ja(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let i=0,s=0;i<e;i++,s+=2){let o=Ka(r.charCodeAt(s)),c=Ka(r.charCodeAt(s+1));if(o===void 0||c===void 0){let u=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}n[i]=o*16+c}return n}function Wa(r){return Da(On(r))}function gr(r){return Fs(r),Da(On(Uint8Array.from(r).reverse()))}function Os(r,t){return ja(r.toString(16).padStart(t*2,"0"))}function Gr(r,t){return Os(r,t).reverse()}function ye(r,t,e){let n;if(typeof t=="string")try{n=ja(t)}catch(s){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${s}`)}else if(Rs(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let i=n.length;if(typeof e=="number"&&i!==e)throw new Error(`${r} expected ${e} bytes, got ${i}`);return n}function Ps(...r){let t=0;for(let n=0;n<r.length;n++){let i=r[n];Fs(i),t+=i.length}let e=new Uint8Array(t);for(let n=0,i=0;n<r.length;n++){let s=r[n];e.set(s,i),i+=s.length}return e}function mr(r,t,e={}){let n=(i,s,o)=>{let c=Rl[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let u=r[i];if(!(o&&u===void 0)&&!c(u,r))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(let[i,s]of Object.entries(t))n(i,s,!1);for(let[i,s]of Object.entries(e))n(i,s,!0);return r}var Il,Nl,Ul,ve,za,Rl,Kr=ut(()=>{Il=BigInt(1),Nl=BigInt(2);Ul=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));ve={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};za=r=>(Nl<<BigInt(r-1))-Il,Rl={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"||Rs(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)}});function bt(r,t){let e=r%t;return e>=Nt?e:t+e}function Ml(r,t,e){if(e<=Nt||t<Nt)throw new Error("Expected power/modulo > 0");if(e===xt)return Nt;let n=xt;for(;t>Nt;)t&xt&&(n=n*r%e),r=r*r%e,t>>=xt;return n}function ae(r,t,e){let n=r;for(;t-- >Nt;)n*=n,n%=e;return n}function Ja(r,t){if(r===Nt||t<=Nt)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=bt(r,t),n=t,i=Nt,s=xt,o=xt,c=Nt;for(;e!==Nt;){let w=n/e,y=n%e,_=i-o*w,N=s-c*w;n=e,e=y,i=o,s=c,o=_,c=N}if(n!==xt)throw new Error("invert: does not exist");return bt(i,t)}function Cl(r){let t=(r-xt)/je,e,n,i;for(e=r-xt,n=0;e%je===Nt;e/=je,n++);for(i=je;i<r&&Ml(i,t,r)!==r-xt;i++);if(n===1){let o=(r+xt)/ks;return function(u,w){let y=u.pow(w,o);if(!u.eql(u.sqr(y),w))throw new Error("Cannot find square root");return y}}let s=(e+xt)/je;return function(c,u){if(c.pow(u,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let w=n,y=c.pow(c.mul(c.ONE,i),e),_=c.pow(u,s),N=c.pow(u,e);for(;!c.eql(N,c.ONE);){if(c.eql(N,c.ZERO))return c.ZERO;let L=1;for(let G=c.sqr(N);L<w&&!c.eql(G,c.ONE);L++)G=c.sqr(G);let P=c.pow(y,xt<<BigInt(w-L-1));y=c.sqr(P),_=c.mul(_,P),N=c.mul(N,y),w=L}return _}}function $l(r){if(r%ks===Ol){let t=(r+xt)/ks;return function(n,i){let s=n.pow(i,t);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%Xa===Ya){let t=(r-Ya)/Xa;return function(n,i){let s=n.mul(i,je),o=n.pow(s,t),c=n.mul(i,o),u=n.mul(n.mul(c,je),o),w=n.mul(c,n.sub(u,n.ONE));if(!n.eql(n.sqr(w),i))throw new Error("Cannot find square root");return w}}return r%kl,Cl(r)}function Qa(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Ll.reduce((n,i)=>(n[i]="function",n),t);return mr(r,e)}function Vl(r,t,e){if(e<Nt)throw new Error("Expected power > 0");if(e===Nt)return r.ONE;if(e===xt)return t;let n=r.ONE,i=t;for(;e>Nt;)e&xt&&(n=r.mul(n,i)),i=r.sqr(i),e>>=xt;return n}function ql(r,t){let e=new Array(t.length),n=t.reduce((s,o,c)=>r.is0(o)?s:(e[c]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return t.reduceRight((s,o,c)=>r.is0(o)?s:(e[c]=r.mul(s,e[c]),r.mul(s,o)),i),e}function Ms(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function tc(r,t,e=!1,n={}){if(r<=Nt)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:s}=Ms(r,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=$l(r),c=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:za(i),ZERO:Nt,ONE:xt,create:u=>bt(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return Nt<=u&&u<r},is0:u=>u===Nt,isOdd:u=>(u&xt)===xt,neg:u=>bt(-u,r),eql:(u,w)=>u===w,sqr:u=>bt(u*u,r),add:(u,w)=>bt(u+w,r),sub:(u,w)=>bt(u-w,r),mul:(u,w)=>bt(u*w,r),pow:(u,w)=>Vl(c,u,w),div:(u,w)=>bt(u*Ja(w,r),r),sqrN:u=>u*u,addN:(u,w)=>u+w,subN:(u,w)=>u-w,mulN:(u,w)=>u*w,inv:u=>Ja(u,r),sqrt:n.sqrt||(u=>o(c,u)),invertBatch:u=>ql(c,u),cmov:(u,w,y)=>y?w:u,toBytes:u=>e?Gr(u,s):Os(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return e?gr(u):Wa(u)}});return Object.freeze(c)}var Nt,xt,je,Ol,ks,Ya,Xa,Pl,kl,Za,Ll,Pn=ut(()=>{Kr();Nt=BigInt(0),xt=BigInt(1),je=BigInt(2),Ol=BigInt(3),ks=BigInt(4),Ya=BigInt(5),Xa=BigInt(8),Pl=BigInt(9),kl=BigInt(16);Za=(r,t)=>(bt(r,t)&xt)===xt,Ll=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function ec(r,t){let e=(i,s)=>{let o=s.negate();return i?o:s},n=i=>{let s=Math.ceil(t/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:e,unsafeLadder(i,s){let o=r.ZERO,c=i;for(;s>Hl;)s&Cs&&(o=o.add(c)),c=c.double(),s>>=Cs;return o},precomputeWindow(i,s){let{windows:o,windowSize:c}=n(s),u=[],w=i,y=w;for(let _=0;_<o;_++){y=w,u.push(y);for(let N=1;N<c;N++)y=y.add(w),u.push(y);w=y.double()}return u},wNAF(i,s,o){let{windows:c,windowSize:u}=n(i),w=r.ZERO,y=r.BASE,_=BigInt(2**i-1),N=2**i,L=BigInt(i);for(let P=0;P<c;P++){let G=P*u,tt=Number(o&_);o>>=L,tt>u&&(tt-=N,o+=Cs);let D=G,Ot=G+Math.abs(tt)-1,X=P%2!==0,yt=tt<0;tt===0?y=y.add(e(X,s[D])):w=w.add(e(yt,s[Ot]))}return{p:w,f:y}},wNAFCached(i,s,o,c){let u=i._WINDOW_SIZE||1,w=s.get(i);return w||(w=this.precomputeWindow(i,u),u!==1&&s.set(i,c(w))),this.wNAF(u,w,o)}}}function rc(r){return Qa(r.Fp),mr(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ms(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Hl,Cs,nc=ut(()=>{Pn();Kr();Hl=BigInt(0),Cs=BigInt(1)});var $s=ut(()=>{zt()});var kn=ut(()=>{fr()});var ic,Zp,Mn,sc,Dr=ut(()=>{qr();sr();$r();zt();Zt();$s();kn();(function(r){r[r.Empty=0]="Empty",r[r.Fork=1]="Fork",r[r.Labeled=2]="Labeled",r[r.Leaf=3]="Leaf",r[r.Pruned=4]="Pruned"})(ic||(ic={}));Zp=Gt("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100");(function(r){r.Unknown="unknown",r.Absent="absent",r.Found="found"})(Mn||(Mn={}));(function(r){r.Less="less",r.Greater="greater"})(sc||(sc={}))});var Cn=ut(()=>{Zt();sr();Dr();zt();qr();kn()});var jh=Te(xo());var bi;(function(r){r[r.SysFatal=1]="SysFatal",r[r.SysTransient=2]="SysTransient",r[r.DestinationInvalid=3]="DestinationInvalid",r[r.CanisterReject=4]="CanisterReject",r[r.CanisterError=5]="CanisterError"})(bi||(bi={}));Zt();sr();Zt();$r();zt();var cl=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e},ul=new TextEncoder().encode(`
2
- ic-request`),Ee=class{getPrincipal(){return this._principal||(this._principal=vt.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:e}=t,n=cl(t,["body"]),i=await yr(e);return Object.assign(Object.assign({},n),{body:{content:e,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(pe(ul,i))}})}},wr=class{getPrincipal(){return vt.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}};qr();$r();zt();fr();var Sl=Te(Vr());var Us;(function(r){r.Call="call"})(Us||(Us={}));var Op=BigInt(1e6),Pp=60*1e3;function Fn(r){let t=[];return r.forEach((e,n)=>{t.push([n,e])}),t}sr();var Hr=class extends Qt{constructor(t,e){super(t),this.response=e,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Cn();Dr();Bi();var $n=BigInt(4294967295),Ls=BigInt(32);function cc(r,t=!1){return t?{h:Number(r&$n),l:Number(r>>Ls&$n)}:{h:Number(r>>Ls&$n)|0,l:Number(r&$n)|0}}function Wl(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:s,l:o}=cc(r[i],t);[e[i],n[i]]=[s,o]}return[e,n]}var zl=(r,t)=>BigInt(r>>>0)<<Ls|BigInt(t>>>0),Yl=(r,t,e)=>r>>>e,Xl=(r,t,e)=>r<<32-e|t>>>e,Jl=(r,t,e)=>r>>>e|t<<32-e,Zl=(r,t,e)=>r<<32-e|t>>>e,Ql=(r,t,e)=>r<<64-e|t>>>e-32,th=(r,t,e)=>r>>>e-32|t<<64-e,eh=(r,t)=>t,rh=(r,t)=>r,nh=(r,t,e)=>r<<e|t>>>32-e,ih=(r,t,e)=>t<<e|r>>>32-e,sh=(r,t,e)=>t<<e-32|r>>>64-e,oh=(r,t,e)=>r<<e-32|t>>>64-e;function ah(r,t,e,n){let i=(t>>>0)+(n>>>0);return{h:r+e+(i/2**32|0)|0,l:i|0}}var ch=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),uh=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,fh=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),lh=(r,t,e,n,i)=>t+e+n+i+(r/2**32|0)|0,hh=(r,t,e,n,i)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(i>>>0),dh=(r,t,e,n,i,s)=>t+e+n+i+s+(r/2**32|0)|0;var ph={fromBig:cc,split:Wl,toBig:zl,shrSH:Yl,shrSL:Xl,rotrSH:Jl,rotrSL:Zl,rotrBH:Ql,rotrBL:th,rotr32H:eh,rotr32L:rh,rotlSH:nh,rotlSL:ih,rotlBH:sh,rotlBL:oh,add:ah,add3L:ch,add3H:uh,add4L:fh,add4H:lh,add5H:dh,add5L:hh},K=ph;Nr();var[yh,wh]=K.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Oe=new Uint32Array(80),Pe=new Uint32Array(80),Vs=class extends ir{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:i,Ch:s,Cl:o,Dh:c,Dl:u,Eh:w,El:y,Fh:_,Fl:N,Gh:L,Gl:P,Hh:G,Hl:tt}=this;return[t,e,n,i,s,o,c,u,w,y,_,N,L,P,G,tt]}set(t,e,n,i,s,o,c,u,w,y,_,N,L,P,G,tt){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=u|0,this.Eh=w|0,this.El=y|0,this.Fh=_|0,this.Fl=N|0,this.Gh=L|0,this.Gl=P|0,this.Hh=G|0,this.Hl=tt|0}process(t,e){for(let X=0;X<16;X++,e+=4)Oe[X]=t.getUint32(e),Pe[X]=t.getUint32(e+=4);for(let X=16;X<80;X++){let yt=Oe[X-15]|0,O=Pe[X-15]|0,$=K.rotrSH(yt,O,1)^K.rotrSH(yt,O,8)^K.shrSH(yt,O,7),it=K.rotrSL(yt,O,1)^K.rotrSL(yt,O,8)^K.shrSL(yt,O,7),z=Oe[X-2]|0,R=Pe[X-2]|0,ot=K.rotrSH(z,R,19)^K.rotrBH(z,R,61)^K.shrSH(z,R,6),et=K.rotrSL(z,R,19)^K.rotrBL(z,R,61)^K.shrSL(z,R,6),at=K.add4L(it,et,Pe[X-7],Pe[X-16]),ht=K.add4H(at,$,ot,Oe[X-7],Oe[X-16]);Oe[X]=ht|0,Pe[X]=at|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:u,Dh:w,Dl:y,Eh:_,El:N,Fh:L,Fl:P,Gh:G,Gl:tt,Hh:D,Hl:Ot}=this;for(let X=0;X<80;X++){let yt=K.rotrSH(_,N,14)^K.rotrSH(_,N,18)^K.rotrBH(_,N,41),O=K.rotrSL(_,N,14)^K.rotrSL(_,N,18)^K.rotrBL(_,N,41),$=_&L^~_&G,it=N&P^~N&tt,z=K.add5L(Ot,O,it,wh[X],Pe[X]),R=K.add5H(z,D,yt,$,yh[X],Oe[X]),ot=z|0,et=K.rotrSH(n,i,28)^K.rotrBH(n,i,34)^K.rotrBH(n,i,39),at=K.rotrSL(n,i,28)^K.rotrBL(n,i,34)^K.rotrBL(n,i,39),ht=n&s^n&c^s&c,Bt=i&o^i&u^o&u;D=G|0,Ot=tt|0,G=L|0,tt=P|0,L=_|0,P=N|0,{h:_,l:N}=K.add(w|0,y|0,R|0,ot|0),w=c|0,y=u|0,c=s|0,u=o|0,s=n|0,o=i|0;let Pt=K.add3L(ot,at,Bt);n=K.add3H(Pt,R,et,ht),i=Pt|0}({h:n,l:i}=K.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=K.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:u}=K.add(this.Ch|0,this.Cl|0,c|0,u|0),{h:w,l:y}=K.add(this.Dh|0,this.Dl|0,w|0,y|0),{h:_,l:N}=K.add(this.Eh|0,this.El|0,_|0,N|0),{h:L,l:P}=K.add(this.Fh|0,this.Fl|0,L|0,P|0),{h:G,l:tt}=K.add(this.Gh|0,this.Gl|0,G|0,tt|0),{h:D,l:Ot}=K.add(this.Hh|0,this.Hl|0,D|0,Ot|0),this.set(n,i,s,o,c,u,w,y,_,N,L,P,G,tt,D,Ot)}roundClean(){Oe.fill(0),Pe.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var uc=Ir(()=>new Vs);Nr();nc();Pn();Kr();Kr();var ce=BigInt(0),Yt=BigInt(1),Ln=BigInt(2),gh=BigInt(8),mh={zip215:!0};function xh(r){let t=rc(r);return mr(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function fc(r){let t=xh(r),{Fp:e,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:u}=t,w=Ln<<BigInt(c*8)-Yt,y=e.create,_=t.uvRatio||((k,U)=>{try{return{isValid:!0,value:e.sqrt(k*e.inv(U))}}catch{return{isValid:!1,value:ce}}}),N=t.adjustScalarBytes||(k=>k),L=t.domain||((k,U,q)=>{if(U.length||q)throw new Error("Contexts/pre-hash are not supported");return k}),P=k=>typeof k=="bigint"&&ce<k,G=(k,U)=>P(k)&&P(U)&&k<U,tt=k=>k===ce||G(k,w);function D(k,U){if(G(k,U))return k;throw new Error(`Expected valid scalar < ${U}, got ${typeof k} ${k}`)}function Ot(k){return k===ce?k:D(k,n)}let X=new Map;function yt(k){if(!(k instanceof O))throw new Error("ExtendedPoint expected")}class O{constructor(U,q,H,J){if(this.ex=U,this.ey=q,this.ez=H,this.et=J,!tt(U))throw new Error("x required");if(!tt(q))throw new Error("y required");if(!tt(H))throw new Error("z required");if(!tt(J))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(U){if(U instanceof O)throw new Error("extended point not allowed");let{x:q,y:H}=U||{};if(!tt(q)||!tt(H))throw new Error("invalid affine point");return new O(q,H,Yt,y(q*H))}static normalizeZ(U){let q=e.invertBatch(U.map(H=>H.ez));return U.map((H,J)=>H.toAffine(q[J])).map(O.fromAffine)}_setWindowSize(U){this._WINDOW_SIZE=U,X.delete(this)}assertValidity(){let{a:U,d:q}=t;if(this.is0())throw new Error("bad point: ZERO");let{ex:H,ey:J,ez:S,et:h}=this,ct=y(H*H),Z=y(J*J),j=y(S*S),M=y(j*j),a=y(ct*U),f=y(j*y(a+Z)),l=y(M+y(q*y(ct*Z)));if(f!==l)throw new Error("bad point: equation left != right (1)");let b=y(H*J),g=y(S*h);if(b!==g)throw new Error("bad point: equation left != right (2)")}equals(U){yt(U);let{ex:q,ey:H,ez:J}=this,{ex:S,ey:h,ez:ct}=U,Z=y(q*ct),j=y(S*J),M=y(H*ct),a=y(h*J);return Z===j&&M===a}is0(){return this.equals(O.ZERO)}negate(){return new O(y(-this.ex),this.ey,this.ez,y(-this.et))}double(){let{a:U}=t,{ex:q,ey:H,ez:J}=this,S=y(q*q),h=y(H*H),ct=y(Ln*y(J*J)),Z=y(U*S),j=q+H,M=y(y(j*j)-S-h),a=Z+h,f=a-ct,l=Z-h,b=y(M*f),g=y(a*l),x=y(M*l),v=y(f*a);return new O(b,g,v,x)}add(U){yt(U);let{a:q,d:H}=t,{ex:J,ey:S,ez:h,et:ct}=this,{ex:Z,ey:j,ez:M,et:a}=U;if(q===BigInt(-1)){let C=y((S-J)*(j+Z)),Y=y((S+J)*(j-Z)),ft=y(Y-C);if(ft===ce)return this.double();let wt=y(h*Ln*a),W=y(ct*Ln*M),V=W+wt,_t=Y+C,xe=W-wt,$e=y(V*ft),Le=y(_t*xe),Lt=y(V*xe),st=y(ft*_t);return new O($e,Le,st,Lt)}let f=y(J*Z),l=y(S*j),b=y(ct*H*a),g=y(h*M),x=y((J+S)*(Z+j)-f-l),v=g-b,d=g+b,m=y(l-q*f),A=y(x*v),E=y(d*m),I=y(x*m),F=y(v*d);return new O(A,E,F,I)}subtract(U){return this.add(U.negate())}wNAF(U){return z.wNAFCached(this,X,U,O.normalizeZ)}multiply(U){let{p:q,f:H}=this.wNAF(D(U,n));return O.normalizeZ([q,H])[0]}multiplyUnsafe(U){let q=Ot(U);return q===ce?it:this.equals(it)||q===Yt?this:this.equals($)?this.wNAF(q).p:z.unsafeLadder(this,q)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return z.unsafeLadder(this,n).is0()}toAffine(U){let{ex:q,ey:H,ez:J}=this,S=this.is0();U==null&&(U=S?gh:e.inv(J));let h=y(q*U),ct=y(H*U),Z=y(J*U);if(S)return{x:ce,y:Yt};if(Z!==Yt)throw new Error("invZ was invalid");return{x:h,y:ct}}clearCofactor(){let{h:U}=t;return U===Yt?this:this.multiplyUnsafe(U)}static fromHex(U,q=!1){let{d:H,a:J}=t,S=e.BYTES;U=ye("pointHex",U,S);let h=U.slice(),ct=U[S-1];h[S-1]=ct&-129;let Z=gr(h);Z===ce||(q?D(Z,w):D(Z,e.ORDER));let j=y(Z*Z),M=y(j-Yt),a=y(H*j-J),{isValid:f,value:l}=_(M,a);if(!f)throw new Error("Point.fromHex: invalid y coordinate");let b=(l&Yt)===Yt,g=(ct&128)!==0;if(!q&&l===ce&&g)throw new Error("Point.fromHex: x=0 and x_0=1");return g!==b&&(l=y(-l)),O.fromAffine({x:l,y:Z})}static fromPrivateKey(U){return et(U).point}toRawBytes(){let{x:U,y:q}=this.toAffine(),H=Gr(q,e.BYTES);return H[H.length-1]|=U&Yt?128:0,H}toHex(){return On(this.toRawBytes())}}O.BASE=new O(t.Gx,t.Gy,Yt,y(t.Gx*t.Gy)),O.ZERO=new O(ce,Yt,Yt,ce);let{BASE:$,ZERO:it}=O,z=ec(O,c*8);function R(k){return bt(k,n)}function ot(k){return R(gr(k))}function et(k){let U=c;k=ye("private key",k,U);let q=ye("hashed private key",s(k),2*U),H=N(q.slice(0,U)),J=q.slice(U,2*U),S=ot(H),h=$.multiply(S),ct=h.toRawBytes();return{head:H,prefix:J,scalar:S,point:h,pointBytes:ct}}function at(k){return et(k).pointBytes}function ht(k=new Uint8Array,...U){let q=Ps(...U);return ot(s(L(q,ye("context",k),!!i)))}function Bt(k,U,q={}){k=ye("message",k),i&&(k=i(k));let{prefix:H,scalar:J,pointBytes:S}=et(U),h=ht(q.context,H,k),ct=$.multiply(h).toRawBytes(),Z=ht(q.context,ct,S,k),j=R(h+Z*J);Ot(j);let M=Ps(ct,Gr(j,e.BYTES));return ye("result",M,c*2)}let Pt=mh;function Ct(k,U,q,H=Pt){let{context:J,zip215:S}=H,h=e.BYTES;k=ye("signature",k,2*h),U=ye("message",U),i&&(U=i(U));let ct=gr(k.slice(h,2*h)),Z,j,M;try{Z=O.fromHex(q,S),j=O.fromHex(k.slice(0,h),S),M=$.multiplyUnsafe(ct)}catch{return!1}if(!S&&Z.isSmallOrder())return!1;let a=ht(J,j.toRawBytes(),Z.toRawBytes(),U);return j.add(Z.multiplyUnsafe(a)).subtract(M).clearCofactor().equals(O.ZERO)}return $._setWindowSize(8),{CURVE:t,getPublicKey:at,sign:Bt,verify:Ct,ExtendedPoint:O,utils:{getExtendedPublicKey:et,randomPrivateKey:()=>o(e.BYTES),precompute(k=8,U=O.BASE){return U._setWindowSize(k),U.multiply(BigInt(3)),U}}}}Pn();var qs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),lc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ay=BigInt(0),_h=BigInt(1),hc=BigInt(2),vy=BigInt(3),bh=BigInt(5),Eh=BigInt(8);function Ah(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),i=BigInt(80),s=qs,c=r*r%s*r%s,u=ae(c,hc,s)*c%s,w=ae(u,_h,s)*r%s,y=ae(w,bh,s)*w%s,_=ae(y,t,s)*y%s,N=ae(_,e,s)*_%s,L=ae(N,n,s)*N%s,P=ae(L,i,s)*L%s,G=ae(P,i,s)*L%s,tt=ae(G,t,s)*y%s;return{pow_p_5_8:ae(tt,hc,s)*r%s,b2:c}}function vh(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Th(r,t){let e=qs,n=bt(t*t*t,e),i=bt(n*n*t,e),s=Ah(r*i).pow_p_5_8,o=bt(r*n*s,e),c=bt(t*o*o,e),u=o,w=bt(o*lc,e),y=c===r,_=c===bt(-r,e),N=c===bt(-r*lc,e);return y&&(o=u),(_||N)&&(o=w),Za(o,e)&&(o=bt(-o,e)),{isValid:y||_,value:o}}var Bh=tc(qs,void 0,!0),Sh={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Bh,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Eh,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:uc,randomBytes:Io,adjustScalarBytes:vh,uvRatio:Th},xr=fc(Sh);var Ih,Nh,Uh,Rh;Ih=new WeakMap,Nh=new WeakMap,Uh=Symbol.iterator,Rh=Symbol.toStringTag;zt();var dc=r=>{if(r<=127)return 1;if(r<=255)return 2;if(r<=65535)return 3;if(r<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},pc=(r,t,e)=>{if(e<=127)return r[t]=e,1;if(e<=255)return r[t]=129,r[t+1]=e,2;if(e<=65535)return r[t]=130,r[t+1]=e>>8,r[t+2]=e,3;if(e<=16777215)return r[t]=131,r[t+1]=e>>16,r[t+2]=e>>8,r[t+3]=e,4;throw new Error("Length too long (> 4 bytes)")},Hs=(r,t)=>{if(r[t]<128)return 1;if(r[t]===128)throw new Error("Invalid length 0");if(r[t]===129)return 2;if(r[t]===130)return 3;if(r[t]===131)return 4;throw new Error("Length too long (> 4 bytes)")},Fh=(r,t)=>{let e=Hs(r,t);if(e===1)return r[t];if(e===2)return r[t+1];if(e===3)return(r[t+1]<<8)+r[t+2];if(e===4)return(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];throw new Error("Length too long (> 4 bytes)")},yc=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),We=Uint8Array.from([48,5,6,3,43,101,112]),Iy=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function _r(r,t){let e=2+dc(r.byteLength+1),n=t.byteLength+e+r.byteLength,i=0,s=new Uint8Array(1+dc(n)+n);return s[i++]=48,i+=pc(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=pc(s,i,r.byteLength+1),s[i++]=0,s.set(new Uint8Array(r),i),s}var jr=(r,t)=>{let e=0,n=(c,u)=>{if(i[e++]!==c)throw new Error("Expected: "+u)},i=new Uint8Array(r);if(n(48,"sequence"),e+=Hs(i,e),!Cr(i.slice(e,e+t.byteLength),t))throw new Error("Not the expected OID.");e+=t.byteLength,n(3,"bit string");let s=Fh(i,e)-1;e+=Hs(i,e),n(0,"0 padding");let o=i.slice(e);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};var wc=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},gc=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Vn,qn,Hn=class r{constructor(t){if(Vn.set(this,void 0),qn.set(this,void 0),t.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");wc(this,Vn,t,"f"),wc(this,qn,r.derEncode(t),"f")}static from(t){return this.fromDer(t.toDer())}static fromRaw(t){return new r(t)}static fromDer(t){return new r(this.derDecode(t))}static derEncode(t){return _r(t,We).buffer}static derDecode(t){let e=jr(t,We);if(e.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return e}get rawKey(){return gc(this,Vn,"f")}get derKey(){return gc(this,qn,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Vn=new WeakMap,qn=new WeakMap;Hn.RAW_KEY_LENGTH=32;kn();var we=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Mt=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ge,Gn,Kn,Dn,jn,Wn,zn,Yn,br;var Xn=class r{constructor(t=r.default){ge.set(this,void 0),Gn.set(this,void 0),Kn.set(this,void 0),Dn.set(this,void 0),jn.set(this,void 0),Wn.set(this,void 0),zn.set(this,void 0),Yn.set(this,void 0),br.set(this,0);let{initialInterval:e=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:c=10,date:u=Date}=t;we(this,ge,e,"f"),we(this,Gn,n,"f"),we(this,Kn,i,"f"),we(this,Dn,s,"f"),we(this,Yn,u,"f"),we(this,jn,u.now(),"f"),we(this,Wn,o,"f"),we(this,zn,c,"f")}get ellapsedTimeInMsec(){return Mt(this,Yn,"f").now()-Mt(this,jn,"f")}get currentInterval(){return Mt(this,ge,"f")}get count(){return Mt(this,br,"f")}get randomValueFromInterval(){let t=Mt(this,Gn,"f")*Mt(this,ge,"f"),e=Mt(this,ge,"f")-t,n=Mt(this,ge,"f")+t;return Math.random()*(n-e)+e}incrementCurrentInterval(){var t;return we(this,ge,Math.min(Mt(this,ge,"f")*Mt(this,Kn,"f"),Mt(this,Dn,"f")),"f"),we(this,br,(t=Mt(this,br,"f"),t++,t),"f"),Mt(this,ge,"f")}next(){return this.ellapsedTimeInMsec>=Mt(this,Wn,"f")||Mt(this,br,"f")>=Mt(this,zn,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};ge=new WeakMap,Gn=new WeakMap,Kn=new WeakMap,Dn=new WeakMap,jn=new WeakMap,Wn=new WeakMap,zn=new WeakMap,Yn=new WeakMap,br=new WeakMap;Xn.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var ee=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Wr,ke,Ph,kh,Mh,Ch,$h,mc,Lh,Vh,qh,Gs;(function(r){r.Received="received",r.Processing="processing",r.Replied="replied",r.Rejected="rejected",r.Unknown="unknown",r.Done="done"})(Gs||(Gs={}));var ew=5*60*1e3;ke=new WeakMap,Ph=new WeakMap,kh=new WeakMap,Mh=new WeakMap,Ch=new WeakMap,$h=new WeakMap,mc=new WeakMap,qh=new WeakMap,Wr=new WeakSet,Lh=async function r(t){var e,n;let{ecid:i,transformedRequest:s,body:o,requestId:c,backoff:u,tries:w}=t,y=w===0?0:u.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:w,backoff:u,delay:y}),y===null)throw new Qt(`Timestamp failed to pass the watermark after retrying the configured ${ee(this,ke,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);y>0&&await new Promise(P=>setTimeout(P,y));let _;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let P=await this._fetch(""+new URL(`/api/v2/canister/${i.toString()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),s.request),{body:o}));if(P.status===200){let G=Un(await P.arrayBuffer());_=Object.assign(Object.assign({},G),{httpDetails:{ok:P.ok,status:P.status,statusText:P.statusText,headers:Fn(P.headers)},requestId:c})}else throw new Hr(`Gateway returned an error:
3
- Code: ${P.status} (${P.statusText})
4
- Body: ${await P.text()}
5
- `,{ok:P.ok,status:P.status,statusText:P.statusText,headers:Fn(P.headers)})}catch(P){if(w<ee(this,ke,"f"))return this.log.warn(`Caught exception while attempting to make query:
6
- ${P}
7
- Retrying query.`),await ee(this,Wr,"m",r).call(this,Object.assign(Object.assign({},t),{tries:w+1}));throw P}let N=(n=(e=_.signatures)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.timestamp;if(!ee(this,mc,"f"))return _;if(!N)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let L=Number(BigInt(N)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:L}),Number(this.waterMark)>L){let P=new Qt("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",P,{timestamp:N,waterMark:this.waterMark}),w<ee(this,ke,"f"))return await ee(this,Wr,"m",r).call(this,Object.assign(Object.assign({},t),{tries:w+1}));throw new Qt(`Timestamp failed to pass the watermark after retrying the configured ${ee(this,ke,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return _},Vh=async function r(t){let{request:e,backoff:n,tries:i}=t,s=i===0?0:n.next();if(s===null)throw new Qt(`Timestamp failed to pass the watermark after retrying the configured ${ee(this,ke,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(w=>setTimeout(w,s));let o;try{o=await e()}catch(w){if(ee(this,ke,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
1
+ "use strict";(()=>{var xu=Object.create;var li=Object.defineProperty;var _u=Object.getOwnPropertyDescriptor;var bu=Object.getOwnPropertyNames;var Eu=Object.getPrototypeOf,Au=Object.prototype.hasOwnProperty;var ct=(r,t)=>()=>(r&&(t=r(r=0)),t);var Bt=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),vu=(r,t)=>{for(var e in t)li(r,e,{get:t[e],enumerable:!0})},Tu=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of bu(t))!Au.call(r,i)&&i!==e&&li(r,i,{get:()=>t[i],enumerable:!(n=_u(t,i))||n.enumerable});return r};var Te=(r,t,e)=>(e=r!=null?xu(Eu(r)):{},Tu(t||!r||!r.__esModule?li(e,"default",{value:r,enumerable:!0}):e,r));var di=Bt(nn=>{"use strict";nn.byteLength=Bu;nn.toByteArray=Nu;nn.fromByteArray=Fu;var fe=[],Qt=[],Su=typeof Uint8Array<"u"?Uint8Array:Array,hi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ve=0,so=hi.length;Ve<so;++Ve)fe[Ve]=hi[Ve],Qt[hi.charCodeAt(Ve)]=Ve;var Ve,so;Qt[45]=62;Qt[95]=63;function oo(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function Bu(r){var t=oo(r),e=t[0],n=t[1];return(e+n)*3/4-n}function Iu(r,t,e){return(t+e)*3/4-e}function Nu(r){var t,e=oo(r),n=e[0],i=e[1],s=new Su(Iu(r,n,i)),o=0,c=i>0?n-4:n,u;for(u=0;u<c;u+=4)t=Qt[r.charCodeAt(u)]<<18|Qt[r.charCodeAt(u+1)]<<12|Qt[r.charCodeAt(u+2)]<<6|Qt[r.charCodeAt(u+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=Qt[r.charCodeAt(u)]<<2|Qt[r.charCodeAt(u+1)]>>4,s[o++]=t&255),i===1&&(t=Qt[r.charCodeAt(u)]<<10|Qt[r.charCodeAt(u+1)]<<4|Qt[r.charCodeAt(u+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function Uu(r){return fe[r>>18&63]+fe[r>>12&63]+fe[r>>6&63]+fe[r&63]}function Ru(r,t,e){for(var n,i=[],s=t;s<e;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(Uu(n));return i.join("")}function Fu(r){for(var t,e=r.length,n=e%3,i=[],s=16383,o=0,c=e-n;o<c;o+=s)i.push(Ru(r,o,o+s>c?c:o+s));return n===1?(t=r[e-1],i.push(fe[t>>2]+fe[t<<4&63]+"==")):n===2&&(t=(r[e-2]<<8)+r[e-1],i.push(fe[t>>10]+fe[t>>4&63]+fe[t<<2&63]+"=")),i.join("")}});var sn=Bt(pi=>{pi.read=function(r,t,e,n,i){var s,o,c=i*8-n-1,u=(1<<c)-1,w=u>>1,y=-7,m=e?i-1:0,N=e?-1:1,M=r[t+m];for(m+=N,s=M&(1<<-y)-1,M>>=-y,y+=c;y>0;s=s*256+r[t+m],m+=N,y-=8);for(o=s&(1<<-y)-1,s>>=-y,y+=n;y>0;o=o*256+r[t+m],m+=N,y-=8);if(s===0)s=1-w;else{if(s===u)return o?NaN:(M?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-w}return(M?-1:1)*o*Math.pow(2,s-n)};pi.write=function(r,t,e,n,i,s){var o,c,u,w=s*8-i-1,y=(1<<w)-1,m=y>>1,N=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,M=n?0:s-1,O=n?1:-1,G=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,o=y):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+m>=1?t+=N/u:t+=N*Math.pow(2,1-m),t*u>=2&&(o++,u/=2),o+m>=y?(c=0,o=y):o+m>=1?(c=(t*u-1)*Math.pow(2,i),o=o+m):(c=t*Math.pow(2,m-1)*Math.pow(2,i),o=0));i>=8;r[e+M]=c&255,M+=O,c/=256,i-=8);for(o=o<<i|c,w+=i;w>0;r[e+M]=o&255,M+=O,o/=256,w-=8);r[e+M-O]|=G*128}});var vo=Bt(er=>{"use strict";var yi=di(),Qe=sn(),ao=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;er.Buffer=T;er.SlowBuffer=$u;er.INSPECT_MAX_BYTES=50;var on=2147483647;er.kMaxLength=on;T.TYPED_ARRAY_SUPPORT=Ou();!T.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Ou(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(T.prototype,"parent",{enumerable:!0,get:function(){if(T.isBuffer(this))return this.buffer}});Object.defineProperty(T.prototype,"offset",{enumerable:!0,get:function(){if(T.isBuffer(this))return this.byteOffset}});function xe(r){if(r>on)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,T.prototype),t}function T(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return xi(r)}return lo(r,t,e)}T.poolSize=8192;function lo(r,t,e){if(typeof r=="string")return ku(r,t);if(ArrayBuffer.isView(r))return Mu(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(le(r,ArrayBuffer)||r&&le(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(le(r,SharedArrayBuffer)||r&&le(r.buffer,SharedArrayBuffer)))return gi(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return T.from(n,t,e);let i=Cu(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return T.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}T.from=function(r,t,e){return lo(r,t,e)};Object.setPrototypeOf(T.prototype,Uint8Array.prototype);Object.setPrototypeOf(T,Uint8Array);function ho(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Pu(r,t,e){return ho(r),r<=0?xe(r):t!==void 0?typeof e=="string"?xe(r).fill(t,e):xe(r).fill(t):xe(r)}T.alloc=function(r,t,e){return Pu(r,t,e)};function xi(r){return ho(r),xe(r<0?0:_i(r)|0)}T.allocUnsafe=function(r){return xi(r)};T.allocUnsafeSlow=function(r){return xi(r)};function ku(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!T.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=po(r,t)|0,n=xe(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function wi(r){let t=r.length<0?0:_i(r.length)|0,e=xe(t);for(let n=0;n<t;n+=1)e[n]=r[n]&255;return e}function Mu(r){if(le(r,Uint8Array)){let t=new Uint8Array(r);return gi(t.buffer,t.byteOffset,t.byteLength)}return wi(r)}function gi(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,T.prototype),n}function Cu(r){if(T.isBuffer(r)){let t=_i(r.length)|0,e=xe(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||Ei(r.length)?xe(0):wi(r);if(r.type==="Buffer"&&Array.isArray(r.data))return wi(r.data)}function _i(r){if(r>=on)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+on.toString(16)+" bytes");return r|0}function $u(r){return+r!=r&&(r=0),T.alloc(+r)}T.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==T.prototype};T.compare=function(t,e){if(le(t,Uint8Array)&&(t=T.from(t,t.offset,t.byteLength)),le(e,Uint8Array)&&(e=T.from(e,e.offset,e.byteLength)),!T.isBuffer(t)||!T.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,i=e.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==e[s]){n=t[s],i=e[s];break}return n<i?-1:i<n?1:0};T.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};T.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return T.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;let i=T.allocUnsafe(e),s=0;for(n=0;n<t.length;++n){let o=t[n];if(le(o,Uint8Array))s+o.length>i.length?(T.isBuffer(o)||(o=T.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(T.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function po(r,t){if(T.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||le(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return mi(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ao(r).length;default:if(i)return n?-1:mi(r).length;t=(""+t).toLowerCase(),i=!0}}T.byteLength=po;function Vu(r,t,e){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Yu(this,t,e);case"utf8":case"utf-8":return wo(this,t,e);case"ascii":return Wu(this,t,e);case"latin1":case"binary":return zu(this,t,e);case"base64":return Du(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xu(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}T.prototype._isBuffer=!0;function Le(r,t,e){let n=r[t];r[t]=r[e],r[e]=n}T.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)Le(this,e,e+1);return this};T.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)Le(this,e,e+3),Le(this,e+1,e+2);return this};T.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)Le(this,e,e+7),Le(this,e+1,e+6),Le(this,e+2,e+5),Le(this,e+3,e+4);return this};T.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?wo(this,0,t):Vu.apply(this,arguments)};T.prototype.toLocaleString=T.prototype.toString;T.prototype.equals=function(t){if(!T.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:T.compare(this,t)===0};T.prototype.inspect=function(){let t="",e=er.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};ao&&(T.prototype[ao]=T.prototype.inspect);T.prototype.compare=function(t,e,n,i,s){if(le(t,Uint8Array)&&(t=T.from(t,t.offset,t.byteLength)),!T.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;let o=s-i,c=n-e,u=Math.min(o,c),w=this.slice(i,s),y=t.slice(e,n);for(let m=0;m<u;++m)if(w[m]!==y[m]){o=w[m],c=y[m];break}return o<c?-1:c<o?1:0};function yo(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Ei(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=T.from(t,n)),T.isBuffer(t))return t.length===0?-1:co(r,t,e,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):co(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function co(r,t,e,n,i){let s=1,o=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;s=2,o/=2,c/=2,e/=2}function u(y,m){return s===1?y[m]:y.readUInt16BE(m*s)}let w;if(i){let y=-1;for(w=e;w<o;w++)if(u(r,w)===u(t,y===-1?0:w-y)){if(y===-1&&(y=w),w-y+1===c)return y*s}else y!==-1&&(w-=w-y),y=-1}else for(e+c>o&&(e=o-c),w=e;w>=0;w--){let y=!0;for(let m=0;m<c;m++)if(u(r,w+m)!==u(t,m)){y=!1;break}if(y)return w}return-1}T.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};T.prototype.indexOf=function(t,e,n){return yo(this,t,e,n,!0)};T.prototype.lastIndexOf=function(t,e,n){return yo(this,t,e,n,!1)};function Lu(r,t,e,n){e=Number(e)||0;let i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;let s=t.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let c=parseInt(t.substr(o*2,2),16);if(Ei(c))return o;r[e+o]=c}return o}function qu(r,t,e,n){return an(mi(t,r.length-e),r,e,n)}function Hu(r,t,e,n){return an(tf(t),r,e,n)}function Gu(r,t,e,n){return an(Ao(t),r,e,n)}function Ku(r,t,e,n){return an(ef(t,r.length-e),r,e,n)}T.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-e;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return Lu(this,t,e,n);case"utf8":case"utf-8":return qu(this,t,e,n);case"ascii":case"latin1":case"binary":return Hu(this,t,e,n);case"base64":return Gu(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ku(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};T.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Du(r,t,e){return t===0&&e===r.length?yi.fromByteArray(r):yi.fromByteArray(r.slice(t,e))}function wo(r,t,e){e=Math.min(r.length,e);let n=[],i=t;for(;i<e;){let s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=e){let u,w,y,m;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[i+1],(u&192)===128&&(m=(s&31)<<6|u&63,m>127&&(o=m));break;case 3:u=r[i+1],w=r[i+2],(u&192)===128&&(w&192)===128&&(m=(s&15)<<12|(u&63)<<6|w&63,m>2047&&(m<55296||m>57343)&&(o=m));break;case 4:u=r[i+1],w=r[i+2],y=r[i+3],(u&192)===128&&(w&192)===128&&(y&192)===128&&(m=(s&15)<<18|(u&63)<<12|(w&63)<<6|y&63,m>65535&&m<1114112&&(o=m))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return ju(n)}var uo=4096;function ju(r){let t=r.length;if(t<=uo)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=uo));return e}function Wu(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function zu(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function Yu(r,t,e){let n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);let i="";for(let s=t;s<e;++s)i+=rf[r[s]];return i}function Xu(r,t,e){let n=r.slice(t,e),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}T.prototype.slice=function(t,e){let n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);let i=this.subarray(t,e);return Object.setPrototypeOf(i,T.prototype),i};function kt(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}T.prototype.readUintLE=T.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||kt(t,e,this.length);let i=this[t],s=1,o=0;for(;++o<e&&(s*=256);)i+=this[t+o]*s;return i};T.prototype.readUintBE=T.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||kt(t,e,this.length);let i=this[t+--e],s=1;for(;e>0&&(s*=256);)i+=this[t+--e]*s;return i};T.prototype.readUint8=T.prototype.readUInt8=function(t,e){return t=t>>>0,e||kt(t,1,this.length),this[t]};T.prototype.readUint16LE=T.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||kt(t,2,this.length),this[t]|this[t+1]<<8};T.prototype.readUint16BE=T.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||kt(t,2,this.length),this[t]<<8|this[t+1]};T.prototype.readUint32LE=T.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};T.prototype.readUint32BE=T.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};T.prototype.readBigUInt64LE=Se(function(t){t=t>>>0,tr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Ir(t,this.length-8);let i=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,s=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});T.prototype.readBigUInt64BE=Se(function(t){t=t>>>0,tr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Ir(t,this.length-8);let i=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],s=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});T.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||kt(t,e,this.length);let i=this[t],s=1,o=0;for(;++o<e&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*e)),i};T.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||kt(t,e,this.length);let i=e,s=1,o=this[t+--i];for(;i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*e)),o};T.prototype.readInt8=function(t,e){return t=t>>>0,e||kt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};T.prototype.readInt16LE=function(t,e){t=t>>>0,e||kt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};T.prototype.readInt16BE=function(t,e){t=t>>>0,e||kt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};T.prototype.readInt32LE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};T.prototype.readInt32BE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};T.prototype.readBigInt64LE=Se(function(t){t=t>>>0,tr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Ir(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});T.prototype.readBigInt64BE=Se(function(t){t=t>>>0,tr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Ir(t,this.length-8);let i=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});T.prototype.readFloatLE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),Qe.read(this,t,!0,23,4)};T.prototype.readFloatBE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),Qe.read(this,t,!1,23,4)};T.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||kt(t,8,this.length),Qe.read(this,t,!0,52,8)};T.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||kt(t,8,this.length),Qe.read(this,t,!1,52,8)};function qt(r,t,e,n,i,s){if(!T.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}T.prototype.writeUintLE=T.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;qt(this,t,e,n,c,0)}let s=1,o=0;for(this[e]=t&255;++o<n&&(s*=256);)this[e+o]=t/s&255;return e+n};T.prototype.writeUintBE=T.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;qt(this,t,e,n,c,0)}let s=n-1,o=1;for(this[e+s]=t&255;--s>=0&&(o*=256);)this[e+s]=t/o&255;return e+n};T.prototype.writeUint8=T.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,1,255,0),this[e]=t&255,e+1};T.prototype.writeUint16LE=T.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};T.prototype.writeUint16BE=T.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};T.prototype.writeUint32LE=T.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};T.prototype.writeUint32BE=T.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function go(r,t,e,n,i){Eo(t,n,i,r,e,7);let s=Number(t&BigInt(4294967295));r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o,e}function mo(r,t,e,n,i){Eo(t,n,i,r,e,7);let s=Number(t&BigInt(4294967295));r[e+7]=s,s=s>>8,r[e+6]=s,s=s>>8,r[e+5]=s,s=s>>8,r[e+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=o,o=o>>8,r[e+2]=o,o=o>>8,r[e+1]=o,o=o>>8,r[e]=o,e+8}T.prototype.writeBigUInt64LE=Se(function(t,e=0){return go(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});T.prototype.writeBigUInt64BE=Se(function(t,e=0){return mo(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});T.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*n-1);qt(this,t,e,n,u-1,-u)}let s=0,o=1,c=0;for(this[e]=t&255;++s<n&&(o*=256);)t<0&&c===0&&this[e+s-1]!==0&&(c=1),this[e+s]=(t/o>>0)-c&255;return e+n};T.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*n-1);qt(this,t,e,n,u-1,-u)}let s=n-1,o=1,c=0;for(this[e+s]=t&255;--s>=0&&(o*=256);)t<0&&c===0&&this[e+s+1]!==0&&(c=1),this[e+s]=(t/o>>0)-c&255;return e+n};T.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};T.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};T.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};T.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};T.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};T.prototype.writeBigInt64LE=Se(function(t,e=0){return go(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});T.prototype.writeBigInt64BE=Se(function(t,e=0){return mo(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function xo(r,t,e,n,i,s){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function _o(r,t,e,n,i){return t=+t,e=e>>>0,i||xo(r,t,e,4,34028234663852886e22,-34028234663852886e22),Qe.write(r,t,e,n,23,4),e+4}T.prototype.writeFloatLE=function(t,e,n){return _o(this,t,e,!0,n)};T.prototype.writeFloatBE=function(t,e,n){return _o(this,t,e,!1,n)};function bo(r,t,e,n,i){return t=+t,e=e>>>0,i||xo(r,t,e,8,17976931348623157e292,-17976931348623157e292),Qe.write(r,t,e,n,52,8),e+8}T.prototype.writeDoubleLE=function(t,e,n){return bo(this,t,e,!0,n)};T.prototype.writeDoubleBE=function(t,e,n){return bo(this,t,e,!1,n)};T.prototype.copy=function(t,e,n,i){if(!T.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);let s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),s};T.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!T.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let o=t.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(t=o)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let s;if(typeof t=="number")for(s=e;s<n;++s)this[s]=t;else{let o=T.isBuffer(t)?t:T.from(t,i),c=o.length;if(c===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-e;++s)this[s+e]=o[s%c]}return this};var Ze={};function bi(r,t,e){Ze[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}bi("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);bi("ERR_INVALID_ARG_TYPE",function(r,t){return`The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError);bi("ERR_OUT_OF_RANGE",function(r,t,e){let n=`The value of "${r}" is out of range.`,i=e;return Number.isInteger(e)&&Math.abs(e)>2**32?i=fo(String(e)):typeof e=="bigint"&&(i=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(i=fo(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function fo(r){let t="",e=r.length,n=r[0]==="-"?1:0;for(;e>=n+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return`${r.slice(0,e)}${t}`}function Ju(r,t,e){tr(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&Ir(t,r.length-(e+1))}function Eo(r,t,e,n,i,s){if(r>e||r<t){let o=typeof t=="bigint"?"n":"",c;throw s>3?t===0||t===BigInt(0)?c=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:c=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:c=`>= ${t}${o} and <= ${e}${o}`,new Ze.ERR_OUT_OF_RANGE("value",c,r)}Ju(n,i,s)}function tr(r,t){if(typeof r!="number")throw new Ze.ERR_INVALID_ARG_TYPE(t,"number",r)}function Ir(r,t,e){throw Math.floor(r)!==r?(tr(r,e),new Ze.ERR_OUT_OF_RANGE(e||"offset","an integer",r)):t<0?new Ze.ERR_BUFFER_OUT_OF_BOUNDS:new Ze.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,r)}var Zu=/[^+/0-9A-Za-z-_]/g;function Qu(r){if(r=r.split("=")[0],r=r.trim().replace(Zu,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function mi(r,t){t=t||1/0;let e,n=r.length,i=null,s=[];for(let o=0;o<n;++o){if(e=r.charCodeAt(o),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&s.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;s.push(e)}else if(e<2048){if((t-=2)<0)break;s.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;s.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;s.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return s}function tf(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function ef(r,t){let e,n,i,s=[];for(let o=0;o<r.length&&!((t-=2)<0);++o)e=r.charCodeAt(o),n=e>>8,i=e%256,s.push(i),s.push(n);return s}function Ao(r){return yi.toByteArray(Qu(r))}function an(r,t,e,n){let i;for(i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function le(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function Ei(r){return r!==r}var rf=function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let n=e*16;for(let i=0;i<16;++i)t[n+i]=r[e]+r[i]}return t}();function Se(r){return typeof BigInt>"u"?nf:r}function nf(){throw new Error("BigInt not supported")}});function To(r){let t=0,e=0,n="";function i(s){return t<0?e|=s>>-t:e=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=cn[e>>3],t+=5),0)}for(let s=0;s<r.length;)s+=i(r[s]);return n+(t<0?cn[e>>3]:"")}function So(r){let t=0,e=0,n=new Uint8Array(r.length*4/3|0),i=0;function s(o){let c=rr[o.toLowerCase()];if(c===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);c<<=3,e|=c>>>t,t+=5,t>=8&&(n[i++]=e,t-=8,t>0?e=c<<5-t&255:e=0)}for(let o of r)s(o);return n.slice(0,i)}var cn,rr,Bo=ct(()=>{cn="abcdefghijklmnopqrstuvwxyz234567",rr=Object.create(null);for(let r=0;r<cn.length;r++)rr[cn[r]]=r;rr[0]=rr.o;rr[1]=rr.i});function Io(r){let t=new Uint8Array(r),e=-1;for(let n=0;n<t.length;n++){let s=(t[n]^e)&255;e=sf[s]^e>>>8}return(e^-1)>>>0}var sf,No=ct(()=>{sf=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 of(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function vi(r,...t){if(!of(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function Ti(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Uo(r,t){vi(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Si=ct(()=>{});var un,Ro=ct(()=>{un=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});function Fo(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Bi(r){return typeof r=="string"&&(r=Fo(r)),vi(r),r}function Nr(r){let t=n=>r().update(Bi(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Oo(r=32){if(un&&typeof un.getRandomValues=="function")return un.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}var ln,ne,cd,fn,ud,Ur=ct(()=>{Ro();Si();ln=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ne=(r,t)=>r<<32-t|r>>>t,cd=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;fn=class{clone(){return this._cloneInto()}},ud={}.toString});function af(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),c=Number(e&s),u=n?4:0,w=n?0:4;r.setUint32(t+u,o,n),r.setUint32(t+w,c,n)}var Po,ko,nr,Ii=ct(()=>{Si();Ur();Po=(r,t,e)=>r&t^~r&e,ko=(r,t,e)=>r&t^r&e^t&e,nr=class extends fn{constructor(t,e,n,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ln(this.buffer)}update(t){Ti(this);let{view:e,buffer:n,blockLen:i}=this;t=Bi(t);let s=t.length;for(let o=0;o<s;){let c=Math.min(i-this.pos,s-o);if(c===i){let u=ln(t);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(t.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ti(this),Uo(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let m=o;m<i;m++)e[m]=0;af(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=ln(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let w=u/4,y=this.get();if(w>y.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<w;m++)c.setUint32(4*m,y[m],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:i,finished:s,destroyed:o,pos:c}=this;return t.length=i,t.pos=c,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(n),t}}});var cf,Be,Ie,hn,Ni,Mo,Co,Ui=ct(()=>{Ii();Ur();cf=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]),Be=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ie=new Uint32Array(64),hn=class extends nr{constructor(){super(64,32,8,!1),this.A=Be[0]|0,this.B=Be[1]|0,this.C=Be[2]|0,this.D=Be[3]|0,this.E=Be[4]|0,this.F=Be[5]|0,this.G=Be[6]|0,this.H=Be[7]|0}get(){let{A:t,B:e,C:n,D:i,E:s,F:o,G:c,H:u}=this;return[t,e,n,i,s,o,c,u]}set(t,e,n,i,s,o,c,u){this.A=t|0,this.B=e|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=u|0}process(t,e){for(let m=0;m<16;m++,e+=4)Ie[m]=t.getUint32(e,!1);for(let m=16;m<64;m++){let N=Ie[m-15],M=Ie[m-2],O=ne(N,7)^ne(N,18)^N>>>3,G=ne(M,17)^ne(M,19)^M>>>10;Ie[m]=G+Ie[m-7]+O+Ie[m-16]|0}let{A:n,B:i,C:s,D:o,E:c,F:u,G:w,H:y}=this;for(let m=0;m<64;m++){let N=ne(c,6)^ne(c,11)^ne(c,25),M=y+N+Po(c,u,w)+cf[m]+Ie[m]|0,G=(ne(n,2)^ne(n,13)^ne(n,22))+ko(n,i,s)|0;y=w,w=u,u=c,c=o+M|0,o=s,s=i,i=n,n=M+G|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,w=w+this.G|0,y=y+this.H|0,this.set(n,i,s,o,c,u,w,y)}roundClean(){Ie.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Ni=class extends hn{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}},Mo=Nr(()=>new hn),Co=Nr(()=>new Ni)});function $o(r){return Co.create().update(new Uint8Array(r)).digest()}var Vo=ct(()=>{Ui()});var dn,uf,Lo,ff,lf,hf,It,te=ct(()=>{Bo();No();Vo();dn="__principal__",uf=2,Lo=4,ff="aaaaa-aa",lf=r=>{var t;return new Uint8Array(((t=r.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(e=>parseInt(e,16)))},hf=r=>r.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),""),It=class r{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Lo]))}static managementCanister(){return this.fromHex(ff)}static selfAuthenticating(t){let e=$o(t);return new this(new Uint8Array([...e,uf]))}static from(t){if(typeof t=="string")return r.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new r(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new r(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(lf(t))}static fromText(t){let e=t;if(t.includes(dn)){let o=JSON.parse(t);dn in o&&(e=o[dn])}let n=e.toLowerCase().replace(/-/g,""),i=So(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==e)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${e}" may not be a valid Principal ID).`);return s}static fromUint8Array(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Lo}toUint8Array(){return this._arr}toHex(){return hf(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,Io(this._arr));let n=new Uint8Array(t),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),c=To(s).match(/.{1,5}/g);if(!c)throw new Error;return c.join("-")}toString(){return this.toText()}toJSON(){return{[dn]:this.toText()}}compareTo(t){for(let e=0;e<Math.min(this._arr.length,t._arr.length);e++){if(this._arr[e]<t._arr[e])return"lt";if(this._arr[e]>t._arr[e])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let e=this.compareTo(t);return e=="lt"||e=="eq"}gtEq(t){let e=this.compareTo(t);return e=="gt"||e=="eq"}}});var ee,ir=ct(()=>{ee=class r extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,r.prototype)}}});function Fi(...r){let t=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),e=0;for(let n of r)t.set(new Uint8Array(n),e),e+=n.byteLength;return t}function Ri(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function pn(r){return r instanceof Uint8Array?Ri(r):r instanceof ArrayBuffer?r:Array.isArray(r)?Ri(new Uint8Array(r)):"buffer"in r?pn(r.buffer):Ri(new Uint8Array(r))}var Ne,yn=ct(()=>{Ne=class{constructor(t,e=t?.byteLength||0){this._buffer=pn(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,e)}get buffer(){return pn(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let e=this._view.subarray(0,t);return this._view=this._view.subarray(t),e.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let e=new Uint8Array(t),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+e.byteLength>=this._buffer.byteLength?this.alloc(e.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+e.byteLength),this._view.set(e,n)}get end(){return this._view.byteLength===0}alloc(t){let e=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(e,0,this._view.byteLength+t);n.set(this._view),this._buffer=e,this._view=n}}});var Oi=ct(()=>{});function qo(){throw new Error("unexpected end of buffer")}function Rr(r,t){return r.byteLength<t&&qo(),r.read(t)}function sr(r){let t=r.readUint8();return t===void 0&&qo(),t}function Ue(r){if(typeof r=="number"&&(r=BigInt(r)),r<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,e=new Ne(new ArrayBuffer(t),0);for(;;){let n=Number(r&BigInt(127));if(r/=BigInt(128),r===BigInt(0)){e.write(new Uint8Array([n]));break}else e.write(new Uint8Array([n|128]))}return e.buffer}function or(r){let t=BigInt(1),e=BigInt(0),n;do n=sr(r),e+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return e}function jt(r){typeof r=="number"&&(r=BigInt(r));let t=r<BigInt(0);t&&(r=-r-BigInt(1));let e=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,n=new Ne(new ArrayBuffer(e),0);for(;;){let s=i(r);if(r/=BigInt(128),t&&r===BigInt(0)&&s&64||!t&&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(t?BigInt(128)-o-BigInt(1):o)}return n.buffer}function Ho(r){let t=new Uint8Array(r.buffer),e=0;for(;e<t.byteLength;e++)if(t[e]<128){if(!(t[e]&64))return or(r);break}let n=new Uint8Array(Rr(r,e+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 Go(r,t){if(BigInt(r)<BigInt(0))throw new Error("Cannot write negative values.");return Pi(r,t)}function Pi(r,t){r=BigInt(r);let e=new Ne(new ArrayBuffer(Math.min(1,t)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(r%i);for(e.write(new Uint8Array([o]));++n<t;)r<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((r/i-s)%BigInt(256)),e.write(new Uint8Array([o])),i*=BigInt(256);return e.buffer}function ki(r,t){let e=BigInt(sr(r)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(sr(r));e=e+n*s}return e}function Ko(r,t){let e=ki(r,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return e>=n&&(e-=n*BigInt(2)),e}var Mi=ct(()=>{yn()});function wn(r){let t=BigInt(r);if(r<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}var Do=ct(()=>{});function df(r){if(sr(r)!==1)throw new Error("Cannot decode principal");let e=Number(or(r));return It.fromUint8Array(new Uint8Array(Rr(r,e)))}function zt(r){let t=JSON.stringify(r,(e,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>jo?t.substring(0,jo-3)+"...":t}var jo,Fr,Wt,Ci,$i,Vi,Li,qi,Hi,Gi,Ki,Di,gn,ar,cr,Or,ji,kd,Md,Cd,$d,Vd,Ld,qd,Hd,Gd,Kd,Dd,jd,Wd,zd,Yd,Xd,Jd,Zd,Qd,zi=ct(()=>{te();yn();Oi();Mi();Do();jo=400,Fr=class{display(){return this.name}valueToString(t){return zt(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},Wt=class extends Fr{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}},Ci=class extends Fr{checkType(t){if(t instanceof Or){let e=t.getType();if(typeof e>"u")throw new Error("type mismatch with uninitialized type");return e}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}},$i=class extends Wt{accept(t,e){return t.visitEmpty(this,e)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return jt(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Vi=class extends Fr{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,e){throw t.visitType(this,e)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,e){let n=e.decodeValue(t,e);Object(n)!==n&&(n=Object(n));let i;return e instanceof Or?i=()=>e.getType():i=()=>e,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"}},Li=class extends Wt{accept(t,e){return t.visitBool(this,e)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return jt(-2)}decodeValue(t,e){switch(this.checkType(e),sr(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},qi=class extends Wt{accept(t,e){return t.visitNull(this,e)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return jt(-1)}decodeValue(t,e){return this.checkType(e),null}get name(){return"null"}},Hi=class extends Wt{accept(t,e){return t.visitReserved(this,e)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return jt(-16)}decodeValue(t,e){return e.name!==this.name&&e.decodeValue(t,e),null}get name(){return"reserved"}},Gi=class extends Wt{accept(t,e){return t.visitText(this,e)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){let e=new TextEncoder().encode(t),n=Ue(e.byteLength);return Fi(n,e)}encodeType(){return jt(-15)}decodeValue(t,e){this.checkType(e);let n=or(t),i=Rr(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},Ki=class extends Wt{accept(t,e){return t.visitInt(this,e)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){return jt(t)}encodeType(){return jt(-4)}decodeValue(t,e){return this.checkType(e),Ho(t)}get name(){return"int"}valueToString(t){return t.toString()}},Di=class extends Wt{accept(t,e){return t.visitNat(this,e)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){return Ue(t)}encodeType(){return jt(-3)}decodeValue(t,e){return this.checkType(e),or(t)}get name(){return"nat"}valueToString(t){return t.toString()}},gn=class extends Wt{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,e){return t.visitFloat(this,e)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){let e=new ArrayBuffer(this._bits/8),n=new DataView(e);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),e}encodeType(){let t=this._bits===32?-13:-14;return jt(t)}decodeValue(t,e){this.checkType(e);let n=Rr(t,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}},ar=class extends Wt{constructor(t){super(),this._bits=t}accept(t,e){return t.visitFixedInt(this,e)}covariant(t){let e=wn(this._bits-1)*BigInt(-1),n=wn(this._bits-1)-BigInt(1),i=!1;if(typeof t=="bigint")i=t>=e&&t<=n;else if(Number.isInteger(t)){let s=BigInt(t);i=s>=e&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){return Pi(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return jt(-9-t)}decodeValue(t,e){this.checkType(e);let n=Ko(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},cr=class extends Wt{constructor(t){super(),this._bits=t}accept(t,e){return t.visitFixedNat(this,e)}covariant(t){let e=wn(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<e:Number.isInteger(t)&&t>=0?n=BigInt(t)<e:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){return Go(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return jt(-5-t)}decodeValue(t,e){this.checkType(e);let n=ki(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}},Or=class r extends Ci{constructor(){super(...arguments),this._id=r._counter++,this._type=void 0}accept(t,e){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,e)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,e)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};Or._counter=0;ji=class extends Wt{accept(t,e){return t.visitPrincipal(this,e)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){let e=t.toUint8Array(),n=Ue(e.byteLength);return Fi(new Uint8Array([1]),n,e)}encodeType(){return jt(-24)}decodeValue(t,e){return this.checkType(e),df(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};kd=new $i,Md=new Hi,Cd=new Vi,$d=new Li,Vd=new qi,Ld=new Gi,qd=new Ki,Hd=new Di,Gd=new gn(32),Kd=new gn(64),Dd=new ar(8),jd=new ar(16),Wd=new ar(32),zd=new ar(64),Yd=new cr(8),Xd=new cr(16),Jd=new cr(32),Zd=new cr(64),Qd=new ji});var Yi=ct(()=>{});var Wo=ct(()=>{zi();te();Yi()});var zo=ct(()=>{});var ur=ct(()=>{Wo();Yi();zi();Oi();Mi();yn();zo()});var Pr=Bt(lr=>{"use strict";var Xi=di(),fr=sn(),Yo=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;lr.Buffer=S;lr.SlowBuffer=_f;lr.INSPECT_MAX_BYTES=50;var mn=2147483647;lr.kMaxLength=mn;S.TYPED_ARRAY_SUPPORT=yf();!S.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function yf(){try{var r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(S.prototype,"parent",{enumerable:!0,get:function(){if(S.isBuffer(this))return this.buffer}});Object.defineProperty(S.prototype,"offset",{enumerable:!0,get:function(){if(S.isBuffer(this))return this.byteOffset}});function _e(r){if(r>mn)throw new RangeError('The value "'+r+'" is invalid for option "size"');var t=new Uint8Array(r);return Object.setPrototypeOf(t,S.prototype),t}function S(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return ts(r)}return Zo(r,t,e)}S.poolSize=8192;function Zo(r,t,e){if(typeof r=="string")return gf(r,t);if(ArrayBuffer.isView(r))return mf(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(he(r,ArrayBuffer)||r&&he(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(he(r,SharedArrayBuffer)||r&&he(r.buffer,SharedArrayBuffer)))return Zi(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return S.from(n,t,e);var i=xf(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return S.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}S.from=function(r,t,e){return Zo(r,t,e)};Object.setPrototypeOf(S.prototype,Uint8Array.prototype);Object.setPrototypeOf(S,Uint8Array);function Qo(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function wf(r,t,e){return Qo(r),r<=0?_e(r):t!==void 0?typeof e=="string"?_e(r).fill(t,e):_e(r).fill(t):_e(r)}S.alloc=function(r,t,e){return wf(r,t,e)};function ts(r){return Qo(r),_e(r<0?0:es(r)|0)}S.allocUnsafe=function(r){return ts(r)};S.allocUnsafeSlow=function(r){return ts(r)};function gf(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!S.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=ta(r,t)|0,n=_e(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function Ji(r){for(var t=r.length<0?0:es(r.length)|0,e=_e(t),n=0;n<t;n+=1)e[n]=r[n]&255;return e}function mf(r){if(he(r,Uint8Array)){var t=new Uint8Array(r);return Zi(t.buffer,t.byteOffset,t.byteLength)}return Ji(r)}function Zi(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,S.prototype),n}function xf(r){if(S.isBuffer(r)){var t=es(r.length)|0,e=_e(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||rs(r.length)?_e(0):Ji(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Ji(r.data)}function es(r){if(r>=mn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+mn.toString(16)+" bytes");return r|0}function _f(r){return+r!=r&&(r=0),S.alloc(+r)}S.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==S.prototype};S.compare=function(t,e){if(he(t,Uint8Array)&&(t=S.from(t,t.offset,t.byteLength)),he(e,Uint8Array)&&(e=S.from(e,e.offset,e.byteLength)),!S.isBuffer(t)||!S.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,i=e.length,s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==e[s]){n=t[s],i=e[s];break}return n<i?-1:i<n?1:0};S.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};S.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return S.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var i=S.allocUnsafe(e),s=0;for(n=0;n<t.length;++n){var o=t[n];if(he(o,Uint8Array))s+o.length>i.length?S.from(o).copy(i,s):Uint8Array.prototype.set.call(i,o,s);else if(S.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function ta(r,t){if(S.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||he(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);var e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Qi(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return oa(r).length;default:if(i)return n?-1:Qi(r).length;t=(""+t).toLowerCase(),i=!0}}S.byteLength=ta;function bf(r,t,e){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Rf(this,t,e);case"utf8":case"utf-8":return ra(this,t,e);case"ascii":return Nf(this,t,e);case"latin1":case"binary":return Uf(this,t,e);case"base64":return Bf(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ff(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}S.prototype._isBuffer=!0;function qe(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}S.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)qe(this,e,e+1);return this};S.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)qe(this,e,e+3),qe(this,e+1,e+2);return this};S.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)qe(this,e,e+7),qe(this,e+1,e+6),qe(this,e+2,e+5),qe(this,e+3,e+4);return this};S.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?ra(this,0,t):bf.apply(this,arguments)};S.prototype.toLocaleString=S.prototype.toString;S.prototype.equals=function(t){if(!S.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:S.compare(this,t)===0};S.prototype.inspect=function(){var t="",e=lr.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};Yo&&(S.prototype[Yo]=S.prototype.inspect);S.prototype.compare=function(t,e,n,i,s){if(he(t,Uint8Array)&&(t=S.from(t,t.offset,t.byteLength)),!S.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;for(var o=s-i,c=n-e,u=Math.min(o,c),w=this.slice(i,s),y=t.slice(e,n),m=0;m<u;++m)if(w[m]!==y[m]){o=w[m],c=y[m];break}return o<c?-1:c<o?1:0};function ea(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,rs(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=S.from(t,n)),S.isBuffer(t))return t.length===0?-1:Xo(r,t,e,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Xo(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function Xo(r,t,e,n,i){var s=1,o=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;s=2,o/=2,c/=2,e/=2}function u(M,O){return s===1?M[O]:M.readUInt16BE(O*s)}var w;if(i){var y=-1;for(w=e;w<o;w++)if(u(r,w)===u(t,y===-1?0:w-y)){if(y===-1&&(y=w),w-y+1===c)return y*s}else y!==-1&&(w-=w-y),y=-1}else for(e+c>o&&(e=o-c),w=e;w>=0;w--){for(var m=!0,N=0;N<c;N++)if(u(r,w+N)!==u(t,N)){m=!1;break}if(m)return w}return-1}S.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};S.prototype.indexOf=function(t,e,n){return ea(this,t,e,n,!0)};S.prototype.lastIndexOf=function(t,e,n){return ea(this,t,e,n,!1)};function Ef(r,t,e,n){e=Number(e)||0;var i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;var s=t.length;n>s/2&&(n=s/2);for(var o=0;o<n;++o){var c=parseInt(t.substr(o*2,2),16);if(rs(c))return o;r[e+o]=c}return o}function Af(r,t,e,n){return xn(Qi(t,r.length-e),r,e,n)}function vf(r,t,e,n){return xn(kf(t),r,e,n)}function Tf(r,t,e,n){return xn(oa(t),r,e,n)}function Sf(r,t,e,n){return xn(Mf(t,r.length-e),r,e,n)}S.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e>>>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-e;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return Ef(this,t,e,n);case"utf8":case"utf-8":return Af(this,t,e,n);case"ascii":case"latin1":case"binary":return vf(this,t,e,n);case"base64":return Tf(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Sf(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};S.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Bf(r,t,e){return t===0&&e===r.length?Xi.fromByteArray(r):Xi.fromByteArray(r.slice(t,e))}function ra(r,t,e){e=Math.min(r.length,e);for(var n=[],i=t;i<e;){var s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=e){var u,w,y,m;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[i+1],(u&192)===128&&(m=(s&31)<<6|u&63,m>127&&(o=m));break;case 3:u=r[i+1],w=r[i+2],(u&192)===128&&(w&192)===128&&(m=(s&15)<<12|(u&63)<<6|w&63,m>2047&&(m<55296||m>57343)&&(o=m));break;case 4:u=r[i+1],w=r[i+2],y=r[i+3],(u&192)===128&&(w&192)===128&&(y&192)===128&&(m=(s&15)<<18|(u&63)<<12|(w&63)<<6|y&63,m>65535&&m<1114112&&(o=m))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return If(n)}var Jo=4096;function If(r){var t=r.length;if(t<=Jo)return String.fromCharCode.apply(String,r);for(var e="",n=0;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Jo));return e}function Nf(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function Uf(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function Rf(r,t,e){var n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);for(var i="",s=t;s<e;++s)i+=Cf[r[s]];return i}function Ff(r,t,e){for(var n=r.slice(t,e),i="",s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}S.prototype.slice=function(t,e){var n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);var i=this.subarray(t,e);return Object.setPrototypeOf(i,S.prototype),i};function Mt(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}S.prototype.readUintLE=S.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Mt(t,e,this.length);for(var i=this[t],s=1,o=0;++o<e&&(s*=256);)i+=this[t+o]*s;return i};S.prototype.readUintBE=S.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Mt(t,e,this.length);for(var i=this[t+--e],s=1;e>0&&(s*=256);)i+=this[t+--e]*s;return i};S.prototype.readUint8=S.prototype.readUInt8=function(t,e){return t=t>>>0,e||Mt(t,1,this.length),this[t]};S.prototype.readUint16LE=S.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||Mt(t,2,this.length),this[t]|this[t+1]<<8};S.prototype.readUint16BE=S.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||Mt(t,2,this.length),this[t]<<8|this[t+1]};S.prototype.readUint32LE=S.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||Mt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};S.prototype.readUint32BE=S.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||Mt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};S.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Mt(t,e,this.length);for(var i=this[t],s=1,o=0;++o<e&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*e)),i};S.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Mt(t,e,this.length);for(var i=e,s=1,o=this[t+--i];i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*e)),o};S.prototype.readInt8=function(t,e){return t=t>>>0,e||Mt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};S.prototype.readInt16LE=function(t,e){t=t>>>0,e||Mt(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};S.prototype.readInt16BE=function(t,e){t=t>>>0,e||Mt(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};S.prototype.readInt32LE=function(t,e){return t=t>>>0,e||Mt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};S.prototype.readInt32BE=function(t,e){return t=t>>>0,e||Mt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};S.prototype.readFloatLE=function(t,e){return t=t>>>0,e||Mt(t,4,this.length),fr.read(this,t,!0,23,4)};S.prototype.readFloatBE=function(t,e){return t=t>>>0,e||Mt(t,4,this.length),fr.read(this,t,!1,23,4)};S.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||Mt(t,8,this.length),fr.read(this,t,!0,52,8)};S.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||Mt(t,8,this.length),fr.read(this,t,!1,52,8)};function Ht(r,t,e,n,i,s){if(!S.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}S.prototype.writeUintLE=S.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){var s=Math.pow(2,8*n)-1;Ht(this,t,e,n,s,0)}var o=1,c=0;for(this[e]=t&255;++c<n&&(o*=256);)this[e+c]=t/o&255;return e+n};S.prototype.writeUintBE=S.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){var s=Math.pow(2,8*n)-1;Ht(this,t,e,n,s,0)}var o=n-1,c=1;for(this[e+o]=t&255;--o>=0&&(c*=256);)this[e+o]=t/c&255;return e+n};S.prototype.writeUint8=S.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,1,255,0),this[e]=t&255,e+1};S.prototype.writeUint16LE=S.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};S.prototype.writeUint16BE=S.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};S.prototype.writeUint32LE=S.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};S.prototype.writeUint32BE=S.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};S.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){var s=Math.pow(2,8*n-1);Ht(this,t,e,n,s-1,-s)}var o=0,c=1,u=0;for(this[e]=t&255;++o<n&&(c*=256);)t<0&&u===0&&this[e+o-1]!==0&&(u=1),this[e+o]=(t/c>>0)-u&255;return e+n};S.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){var s=Math.pow(2,8*n-1);Ht(this,t,e,n,s-1,-s)}var o=n-1,c=1,u=0;for(this[e+o]=t&255;--o>=0&&(c*=256);)t<0&&u===0&&this[e+o+1]!==0&&(u=1),this[e+o]=(t/c>>0)-u&255;return e+n};S.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};S.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};S.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};S.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};S.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function na(r,t,e,n,i,s){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ia(r,t,e,n,i){return t=+t,e=e>>>0,i||na(r,t,e,4,34028234663852886e22,-34028234663852886e22),fr.write(r,t,e,n,23,4),e+4}S.prototype.writeFloatLE=function(t,e,n){return ia(this,t,e,!0,n)};S.prototype.writeFloatBE=function(t,e,n){return ia(this,t,e,!1,n)};function sa(r,t,e,n,i){return t=+t,e=e>>>0,i||na(r,t,e,8,17976931348623157e292,-17976931348623157e292),fr.write(r,t,e,n,52,8),e+8}S.prototype.writeDoubleLE=function(t,e,n){return sa(this,t,e,!0,n)};S.prototype.writeDoubleBE=function(t,e,n){return sa(this,t,e,!1,n)};S.prototype.copy=function(t,e,n,i){if(!S.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);var s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),s};S.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!S.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){var s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var o;if(typeof t=="number")for(o=e;o<n;++o)this[o]=t;else{var c=S.isBuffer(t)?t:S.from(t,i),u=c.length;if(u===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=c[o%u]}return this};var Of=/[^+/0-9A-Za-z-_]/g;function Pf(r){if(r=r.split("=")[0],r=r.trim().replace(Of,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Qi(r,t){t=t||1/0;for(var e,n=r.length,i=null,s=[],o=0;o<n;++o){if(e=r.charCodeAt(o),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&s.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;s.push(e)}else if(e<2048){if((t-=2)<0)break;s.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;s.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;s.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return s}function kf(r){for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function Mf(r,t){for(var e,n,i,s=[],o=0;o<r.length&&!((t-=2)<0);++o)e=r.charCodeAt(o),n=e>>8,i=e%256,s.push(i),s.push(n);return s}function oa(r){return Xi.toByteArray(Pf(r))}function xn(r,t,e,n){for(var i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function he(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function rs(r){return r!==r}var Cf=function(){for(var r="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var n=e*16,i=0;i<16;++i)t[n+i]=r[e]+r[i];return t}()});var kr=Bt((aa,_n)=>{(function(r){"use strict";var t,e=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",c=1e14,u=14,w=9007199254740991,y=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],m=1e7,N=1e9;function M(C){var H,nt,Y,R=B.prototype={constructor:B,toString:null,valueOf:null},it=new B(1),st=20,ot=4,wt=-7,Ot=21,V=-1e7,U=1e7,P=!1,L=1,K=0,J={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},tt="0123456789abcdefghijklmnopqrstuvwxyz",ut=!0;function B(a,f){var l,b,g,_,v,d,x,A,E=this;if(!(E instanceof B))return new B(a,f);if(f==null){if(a&&a._isBigNumber===!0){E.s=a.s,!a.c||a.e>U?E.c=E.e=null:a.e<V?E.c=[E.e=0]:(E.e=a.e,E.c=a.c.slice());return}if((d=typeof a=="number")&&a*0==0){if(E.s=1/a<0?(a=-a,-1):1,a===~~a){for(_=0,v=a;v>=10;v/=10,_++);_>U?E.c=E.e=null:(E.e=_,E.c=[a]);return}A=String(a)}else{if(!e.test(A=String(a)))return Y(E,A,d);E.s=A.charCodeAt(0)==45?(A=A.slice(1),-1):1}(_=A.indexOf("."))>-1&&(A=A.replace(".","")),(v=A.search(/e/i))>0?(_<0&&(_=v),_+=+A.slice(v+1),A=A.substring(0,v)):_<0&&(_=A.length)}else{if(j(f,2,tt.length,"Base"),f==10&&ut)return E=new B(a),gt(E,st+E.e+1,ot);if(A=String(a),d=typeof a=="number"){if(a*0!=0)return Y(E,A,d,f);if(E.s=1/a<0?(A=A.slice(1),-1):1,B.DEBUG&&A.replace(/^0\.0*|\./,"").length>15)throw Error(o+a)}else E.s=A.charCodeAt(0)===45?(A=A.slice(1),-1):1;for(l=tt.slice(0,f),_=v=0,x=A.length;v<x;v++)if(l.indexOf(b=A.charAt(v))<0){if(b=="."){if(v>_){_=x;continue}}else if(!g&&(A==A.toUpperCase()&&(A=A.toLowerCase())||A==A.toLowerCase()&&(A=A.toUpperCase()))){g=!0,v=-1,_=0;continue}return Y(E,String(a),d,f)}d=!1,A=nt(A,f,10,E.s),(_=A.indexOf("."))>-1?A=A.replace(".",""):_=A.length}for(v=0;A.charCodeAt(v)===48;v++);for(x=A.length;A.charCodeAt(--x)===48;);if(A=A.slice(v,++x)){if(x-=v,d&&B.DEBUG&&x>15&&(a>w||a!==i(a)))throw Error(o+E.s*a);if((_=_-v-1)>U)E.c=E.e=null;else if(_<V)E.c=[E.e=0];else{if(E.e=_,E.c=[],v=(_+1)%u,_<0&&(v+=u),v<x){for(v&&E.c.push(+A.slice(0,v)),x-=u;v<x;)E.c.push(+A.slice(v,v+=u));v=u-(A=A.slice(v)).length}else v-=x;for(;v--;A+="0");E.c.push(+A)}}else E.c=[E.e=0]}B.clone=M,B.ROUND_UP=0,B.ROUND_DOWN=1,B.ROUND_CEIL=2,B.ROUND_FLOOR=3,B.ROUND_HALF_UP=4,B.ROUND_HALF_DOWN=5,B.ROUND_HALF_EVEN=6,B.ROUND_HALF_CEIL=7,B.ROUND_HALF_FLOOR=8,B.EUCLID=9,B.config=B.set=function(a){var f,l;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(f="DECIMAL_PLACES")&&(l=a[f],j(l,0,N,f),st=l),a.hasOwnProperty(f="ROUNDING_MODE")&&(l=a[f],j(l,0,8,f),ot=l),a.hasOwnProperty(f="EXPONENTIAL_AT")&&(l=a[f],l&&l.pop?(j(l[0],-N,0,f),j(l[1],0,N,f),wt=l[0],Ot=l[1]):(j(l,-N,N,f),wt=-(Ot=l<0?-l:l))),a.hasOwnProperty(f="RANGE"))if(l=a[f],l&&l.pop)j(l[0],-N,-1,f),j(l[1],1,N,f),V=l[0],U=l[1];else if(j(l,-N,N,f),l)V=-(U=l<0?-l:l);else throw Error(s+f+" cannot be zero: "+l);if(a.hasOwnProperty(f="CRYPTO"))if(l=a[f],l===!!l)if(l)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))P=l;else throw P=!l,Error(s+"crypto unavailable");else P=l;else throw Error(s+f+" not true or false: "+l);if(a.hasOwnProperty(f="MODULO_MODE")&&(l=a[f],j(l,0,9,f),L=l),a.hasOwnProperty(f="POW_PRECISION")&&(l=a[f],j(l,0,N,f),K=l),a.hasOwnProperty(f="FORMAT"))if(l=a[f],typeof l=="object")J=l;else throw Error(s+f+" not an object: "+l);if(a.hasOwnProperty(f="ALPHABET"))if(l=a[f],typeof l=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(l))ut=l.slice(0,10)=="0123456789",tt=l;else throw Error(s+f+" invalid: "+l)}else throw Error(s+"Object expected: "+a);return{DECIMAL_PLACES:st,ROUNDING_MODE:ot,EXPONENTIAL_AT:[wt,Ot],RANGE:[V,U],CRYPTO:P,MODULO_MODE:L,POW_PRECISION:K,FORMAT:J,ALPHABET:tt}},B.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!B.DEBUG)return!0;var f,l,b=a.c,g=a.e,_=a.s;t:if({}.toString.call(b)=="[object Array]"){if((_===1||_===-1)&&g>=-N&&g<=N&&g===i(g)){if(b[0]===0){if(g===0&&b.length===1)return!0;break t}if(f=(g+1)%u,f<1&&(f+=u),String(b[0]).length==f){for(f=0;f<b.length;f++)if(l=b[f],l<0||l>=c||l!==i(l))break t;if(l!==0)return!0}}}else if(b===null&&g===null&&(_===null||_===1||_===-1))return!0;throw Error(s+"Invalid BigNumber: "+a)},B.maximum=B.max=function(){return mt(arguments,-1)},B.minimum=B.min=function(){return mt(arguments,1)},B.random=function(){var a=9007199254740992,f=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 b,g,_,v,d,x=0,A=[],E=new B(it);if(l==null?l=st:j(l,0,N),v=n(l/u),P)if(crypto.getRandomValues){for(b=crypto.getRandomValues(new Uint32Array(v*=2));x<v;)d=b[x]*131072+(b[x+1]>>>11),d>=9e15?(g=crypto.getRandomValues(new Uint32Array(2)),b[x]=g[0],b[x+1]=g[1]):(A.push(d%1e14),x+=2);x=v/2}else if(crypto.randomBytes){for(b=crypto.randomBytes(v*=7);x<v;)d=(b[x]&31)*281474976710656+b[x+1]*1099511627776+b[x+2]*4294967296+b[x+3]*16777216+(b[x+4]<<16)+(b[x+5]<<8)+b[x+6],d>=9e15?crypto.randomBytes(7).copy(b,x):(A.push(d%1e14),x+=7);x=v/7}else throw P=!1,Error(s+"crypto unavailable");if(!P)for(;x<v;)d=f(),d<9e15&&(A[x++]=d%1e14);for(v=A[--x],l%=u,v&&l&&(d=y[u-l],A[x]=i(v/d)*d);A[x]===0;A.pop(),x--);if(x<0)A=[_=0];else{for(_=-1;A[0]===0;A.splice(0,1),_-=u);for(x=1,d=A[0];d>=10;d/=10,x++);x<u&&(_-=u-x)}return E.e=_,E.c=A,E}}(),B.sum=function(){for(var a=1,f=arguments,l=new B(f[0]);a<f.length;)l=l.plus(f[a++]);return l},nt=function(){var a="0123456789";function f(l,b,g,_){for(var v,d=[0],x,A=0,E=l.length;A<E;){for(x=d.length;x--;d[x]*=b);for(d[0]+=_.indexOf(l.charAt(A++)),v=0;v<d.length;v++)d[v]>g-1&&(d[v+1]==null&&(d[v+1]=0),d[v+1]+=d[v]/g|0,d[v]%=g)}return d.reverse()}return function(l,b,g,_,v){var d,x,A,E,I,F,$,Z,ht=l.indexOf("."),xt=st,X=ot;for(ht>=0&&(E=K,K=0,l=l.replace(".",""),Z=new B(b),F=Z.pow(l.length-ht),K=E,Z.c=f(yt(G(F.c),F.e,"0"),10,g,a),Z.e=Z.c.length),$=f(l,b,g,v?(d=tt,a):(d=a,tt)),A=E=$.length;$[--E]==0;$.pop());if(!$[0])return d.charAt(0);if(ht<0?--A:(F.c=$,F.e=A,F.s=_,F=H(F,Z,xt,X,g),$=F.c,I=F.r,A=F.e),x=A+xt+1,ht=$[x],E=g/2,I=I||x<0||$[x+1]!=null,I=X<4?(ht!=null||I)&&(X==0||X==(F.s<0?3:2)):ht>E||ht==E&&(X==4||I||X==6&&$[x-1]&1||X==(F.s<0?8:7)),x<1||!$[0])l=I?yt(d.charAt(1),-xt,d.charAt(0)):d.charAt(0);else{if($.length=x,I)for(--g;++$[--x]>g;)$[x]=0,x||(++A,$=[1].concat($));for(E=$.length;!$[--E];);for(ht=0,l="";ht<=E;l+=d.charAt($[ht++]));l=yt(l,A,d.charAt(0))}return l}}(),H=function(){function a(b,g,_){var v,d,x,A,E=0,I=b.length,F=g%m,$=g/m|0;for(b=b.slice();I--;)x=b[I]%m,A=b[I]/m|0,v=$*x+A*F,d=F*x+v%m*m+E,E=(d/_|0)+(v/m|0)+$*A,b[I]=d%_;return E&&(b=[E].concat(b)),b}function f(b,g,_,v){var d,x;if(_!=v)x=_>v?1:-1;else for(d=x=0;d<_;d++)if(b[d]!=g[d]){x=b[d]>g[d]?1:-1;break}return x}function l(b,g,_,v){for(var d=0;_--;)b[_]-=d,d=b[_]<g[_]?1:0,b[_]=d*v+b[_]-g[_];for(;!b[0]&&b.length>1;b.splice(0,1));}return function(b,g,_,v,d){var x,A,E,I,F,$,Z,ht,xt,X,q,Tt,ve,$e,Sr,Zt,at,Lt=b.s==g.s?1:-1,Ct=b.c,_t=g.c;if(!Ct||!Ct[0]||!_t||!_t[0])return new B(!b.s||!g.s||(Ct?_t&&Ct[0]==_t[0]:!_t)?NaN:Ct&&Ct[0]==0||!_t?Lt*0:Lt/0);for(ht=new B(Lt),xt=ht.c=[],A=b.e-g.e,Lt=_+A+1,d||(d=c,A=O(b.e/u)-O(g.e/u),Lt=Lt/u|0),E=0;_t[E]==(Ct[E]||0);E++);if(_t[E]>(Ct[E]||0)&&A--,Lt<0)xt.push(1),I=!0;else{for($e=Ct.length,Zt=_t.length,E=0,Lt+=2,F=i(d/(_t[0]+1)),F>1&&(_t=a(_t,F,d),Ct=a(Ct,F,d),Zt=_t.length,$e=Ct.length),ve=Zt,X=Ct.slice(0,Zt),q=X.length;q<Zt;X[q++]=0);at=_t.slice(),at=[0].concat(at),Sr=_t[0],_t[1]>=d/2&&Sr++;do{if(F=0,x=f(_t,X,Zt,q),x<0){if(Tt=X[0],Zt!=q&&(Tt=Tt*d+(X[1]||0)),F=i(Tt/Sr),F>1)for(F>=d&&(F=d-1),$=a(_t,F,d),Z=$.length,q=X.length;f($,X,Z,q)==1;)F--,l($,Zt<Z?at:_t,Z,d),Z=$.length,x=1;else F==0&&(x=F=1),$=_t.slice(),Z=$.length;if(Z<q&&($=[0].concat($)),l(X,$,q,d),q=X.length,x==-1)for(;f(_t,X,Zt,q)<1;)F++,l(X,Zt<q?at:_t,q,d),q=X.length}else x===0&&(F++,X=[0]);xt[E++]=F,X[0]?X[q++]=Ct[ve]||0:(X=[Ct[ve]],q=1)}while((ve++<$e||X[0]!=null)&&Lt--);I=X[0]!=null,xt[0]||xt.splice(0,1)}if(d==c){for(E=1,Lt=xt[0];Lt>=10;Lt/=10,E++);gt(ht,_+(ht.e=E+A*u-1)+1,v,I)}else ht.e=A,ht.r=+I;return ht}}();function h(a,f,l,b){var g,_,v,d,x;if(l==null?l=ot:j(l,0,8),!a.c)return a.toString();if(g=a.c[0],v=a.e,f==null)x=G(a.c),x=b==1||b==2&&(v<=wt||v>=Ot)?z(x,v):yt(x,v,"0");else if(a=gt(new B(a),f,l),_=a.e,x=G(a.c),d=x.length,b==1||b==2&&(f<=_||_<=wt)){for(;d<f;x+="0",d++);x=z(x,_)}else if(f-=v,x=yt(x,_,"0"),_+1>d){if(--f>0)for(x+=".";f--;x+="0");}else if(f+=_-d,f>0)for(_+1==d&&(x+=".");f--;x+="0");return a.s<0&&g?"-"+x:x}function mt(a,f){for(var l,b,g=1,_=new B(a[0]);g<a.length;g++)b=new B(a[g]),(!b.s||(l=lt(_,b))===f||l===0&&_.s===f)&&(_=b);return _}function Et(a,f,l){for(var b=1,g=f.length;!f[--g];f.pop());for(g=f[0];g>=10;g/=10,b++);return(l=b+l*u-1)>U?a.c=a.e=null:l<V?a.c=[a.e=0]:(a.e=l,a.c=f),a}Y=function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,f=/^([^.]+)\.$/,l=/^\.([^.]+)$/,b=/^-?(Infinity|NaN)$/,g=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(_,v,d,x){var A,E=d?v:v.replace(g,"");if(b.test(E))_.s=isNaN(E)?null:E<0?-1:1;else{if(!d&&(E=E.replace(a,function(I,F,$){return A=($=$.toLowerCase())=="x"?16:$=="b"?2:8,!x||x==A?F:I}),x&&(A=x,E=E.replace(f,"$1").replace(l,"0.$1")),v!=E))return new B(E,A);if(B.DEBUG)throw Error(s+"Not a"+(x?" base "+x:"")+" number: "+v);_.s=null}_.c=_.e=null}}();function gt(a,f,l,b){var g,_,v,d,x,A,E,I=a.c,F=y;if(I){t:{for(g=1,d=I[0];d>=10;d/=10,g++);if(_=f-g,_<0)_+=u,v=f,x=I[A=0],E=i(x/F[g-v-1]%10);else if(A=n((_+1)/u),A>=I.length)if(b){for(;I.length<=A;I.push(0));x=E=0,g=1,_%=u,v=_-u+1}else break t;else{for(x=d=I[A],g=1;d>=10;d/=10,g++);_%=u,v=_-u+g,E=v<0?0:i(x/F[g-v-1]%10)}if(b=b||f<0||I[A+1]!=null||(v<0?x:x%F[g-v-1]),b=l<4?(E||b)&&(l==0||l==(a.s<0?3:2)):E>5||E==5&&(l==4||b||l==6&&(_>0?v>0?x/F[g-v]:0:I[A-1])%10&1||l==(a.s<0?8:7)),f<1||!I[0])return I.length=0,b?(f-=a.e+1,I[0]=F[(u-f%u)%u],a.e=-f||0):I[0]=a.e=0,a;if(_==0?(I.length=A,d=1,A--):(I.length=A+1,d=F[u-_],I[A]=v>0?i(x/F[g-v]%F[v])*d:0),b)for(;;)if(A==0){for(_=1,v=I[0];v>=10;v/=10,_++);for(v=I[0]+=d,d=1;v>=10;v/=10,d++);_!=d&&(a.e++,I[0]==c&&(I[0]=1));break}else{if(I[A]+=d,I[A]!=c)break;I[A--]=0,d=1}for(_=I.length;I[--_]===0;I.pop());}a.e>U?a.c=a.e=null:a.e<V&&(a.c=[a.e=0])}return a}function k(a){var f,l=a.e;return l===null?a.toString():(f=G(a.c),f=l<=wt||l>=Ot?z(f,l):yt(f,l,"0"),a.s<0?"-"+f:f)}return R.absoluteValue=R.abs=function(){var a=new B(this);return a.s<0&&(a.s=1),a},R.comparedTo=function(a,f){return lt(this,new B(a,f))},R.decimalPlaces=R.dp=function(a,f){var l,b,g,_=this;if(a!=null)return j(a,0,N),f==null?f=ot:j(f,0,8),gt(new B(_),a+_.e+1,f);if(!(l=_.c))return null;if(b=((g=l.length-1)-O(this.e/u))*u,g=l[g])for(;g%10==0;g/=10,b--);return b<0&&(b=0),b},R.dividedBy=R.div=function(a,f){return H(this,new B(a,f),st,ot)},R.dividedToIntegerBy=R.idiv=function(a,f){return H(this,new B(a,f),0,1)},R.exponentiatedBy=R.pow=function(a,f){var l,b,g,_,v,d,x,A,E,I=this;if(a=new B(a),a.c&&!a.isInteger())throw Error(s+"Exponent not an integer: "+k(a));if(f!=null&&(f=new B(f)),d=a.e>14,!I.c||!I.c[0]||I.c[0]==1&&!I.e&&I.c.length==1||!a.c||!a.c[0])return E=new B(Math.pow(+k(I),d?a.s*(2-W(a)):+k(a))),f?E.mod(f):E;if(x=a.s<0,f){if(f.c?!f.c[0]:!f.s)return new B(NaN);b=!x&&I.isInteger()&&f.isInteger(),b&&(I=I.mod(f))}else{if(a.e>9&&(I.e>0||I.e<-1||(I.e==0?I.c[0]>1||d&&I.c[1]>=24e7:I.c[0]<8e13||d&&I.c[0]<=9999975e7)))return _=I.s<0&&W(a)?-0:0,I.e>-1&&(_=1/_),new B(x?1/_:_);K&&(_=n(K/u+2))}for(d?(l=new B(.5),x&&(a.s=1),A=W(a)):(g=Math.abs(+k(a)),A=g%2),E=new B(it);;){if(A){if(E=E.times(I),!E.c)break;_?E.c.length>_&&(E.c.length=_):b&&(E=E.mod(f))}if(g){if(g=i(g/2),g===0)break;A=g%2}else if(a=a.times(l),gt(a,a.e+1,1),a.e>14)A=W(a);else{if(g=+k(a),g===0)break;A=g%2}I=I.times(I),_?I.c&&I.c.length>_&&(I.c.length=_):b&&(I=I.mod(f))}return b?E:(x&&(E=it.div(E)),f?E.mod(f):_?gt(E,K,ot,v):E)},R.integerValue=function(a){var f=new B(this);return a==null?a=ot:j(a,0,8),gt(f,f.e+1,a)},R.isEqualTo=R.eq=function(a,f){return lt(this,new B(a,f))===0},R.isFinite=function(){return!!this.c},R.isGreaterThan=R.gt=function(a,f){return lt(this,new B(a,f))>0},R.isGreaterThanOrEqualTo=R.gte=function(a,f){return(f=lt(this,new B(a,f)))===1||f===0},R.isInteger=function(){return!!this.c&&O(this.e/u)>this.c.length-2},R.isLessThan=R.lt=function(a,f){return lt(this,new B(a,f))<0},R.isLessThanOrEqualTo=R.lte=function(a,f){return(f=lt(this,new B(a,f)))===-1||f===0},R.isNaN=function(){return!this.s},R.isNegative=function(){return this.s<0},R.isPositive=function(){return this.s>0},R.isZero=function(){return!!this.c&&this.c[0]==0},R.minus=function(a,f){var l,b,g,_,v=this,d=v.s;if(a=new B(a,f),f=a.s,!d||!f)return new B(NaN);if(d!=f)return a.s=-f,v.plus(a);var x=v.e/u,A=a.e/u,E=v.c,I=a.c;if(!x||!A){if(!E||!I)return E?(a.s=-f,a):new B(I?v:NaN);if(!E[0]||!I[0])return I[0]?(a.s=-f,a):new B(E[0]?v:ot==3?-0:0)}if(x=O(x),A=O(A),E=E.slice(),d=x-A){for((_=d<0)?(d=-d,g=E):(A=x,g=I),g.reverse(),f=d;f--;g.push(0));g.reverse()}else for(b=(_=(d=E.length)<(f=I.length))?d:f,d=f=0;f<b;f++)if(E[f]!=I[f]){_=E[f]<I[f];break}if(_&&(g=E,E=I,I=g,a.s=-a.s),f=(b=I.length)-(l=E.length),f>0)for(;f--;E[l++]=0);for(f=c-1;b>d;){if(E[--b]<I[b]){for(l=b;l&&!E[--l];E[l]=f);--E[l],E[b]+=c}E[b]-=I[b]}for(;E[0]==0;E.splice(0,1),--A);return E[0]?Et(a,E,A):(a.s=ot==3?-1:1,a.c=[a.e=0],a)},R.modulo=R.mod=function(a,f){var l,b,g=this;return a=new B(a,f),!g.c||!a.s||a.c&&!a.c[0]?new B(NaN):!a.c||g.c&&!g.c[0]?new B(g):(L==9?(b=a.s,a.s=1,l=H(g,a,0,3),a.s=b,l.s*=b):l=H(g,a,0,L),a=g.minus(l.times(a)),!a.c[0]&&L==1&&(a.s=g.s),a)},R.multipliedBy=R.times=function(a,f){var l,b,g,_,v,d,x,A,E,I,F,$,Z,ht,xt,X=this,q=X.c,Tt=(a=new B(a,f)).c;if(!q||!Tt||!q[0]||!Tt[0])return!X.s||!a.s||q&&!q[0]&&!Tt||Tt&&!Tt[0]&&!q?a.c=a.e=a.s=null:(a.s*=X.s,!q||!Tt?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(b=O(X.e/u)+O(a.e/u),a.s*=X.s,x=q.length,I=Tt.length,x<I&&(Z=q,q=Tt,Tt=Z,g=x,x=I,I=g),g=x+I,Z=[];g--;Z.push(0));for(ht=c,xt=m,g=I;--g>=0;){for(l=0,F=Tt[g]%xt,$=Tt[g]/xt|0,v=x,_=g+v;_>g;)A=q[--v]%xt,E=q[v]/xt|0,d=$*A+E*F,A=F*A+d%xt*xt+Z[_]+l,l=(A/ht|0)+(d/xt|0)+$*E,Z[_--]=A%ht;Z[_]=l}return l?++b:Z.splice(0,1),Et(a,Z,b)},R.negated=function(){var a=new B(this);return a.s=-a.s||null,a},R.plus=function(a,f){var l,b=this,g=b.s;if(a=new B(a,f),f=a.s,!g||!f)return new B(NaN);if(g!=f)return a.s=-f,b.minus(a);var _=b.e/u,v=a.e/u,d=b.c,x=a.c;if(!_||!v){if(!d||!x)return new B(g/0);if(!d[0]||!x[0])return x[0]?a:new B(d[0]?b:g*0)}if(_=O(_),v=O(v),d=d.slice(),g=_-v){for(g>0?(v=_,l=x):(g=-g,l=d),l.reverse();g--;l.push(0));l.reverse()}for(g=d.length,f=x.length,g-f<0&&(l=x,x=d,d=l,f=g),g=0;f;)g=(d[--f]=d[f]+x[f]+g)/c|0,d[f]=c===d[f]?0:d[f]%c;return g&&(d=[g].concat(d),++v),Et(a,d,v)},R.precision=R.sd=function(a,f){var l,b,g,_=this;if(a!=null&&a!==!!a)return j(a,1,N),f==null?f=ot:j(f,0,8),gt(new B(_),a,f);if(!(l=_.c))return null;if(g=l.length-1,b=g*u+1,g=l[g]){for(;g%10==0;g/=10,b--);for(g=l[0];g>=10;g/=10,b++);}return a&&_.e+1>b&&(b=_.e+1),b},R.shiftedBy=function(a){return j(a,-w,w),this.times("1e"+a)},R.squareRoot=R.sqrt=function(){var a,f,l,b,g,_=this,v=_.c,d=_.s,x=_.e,A=st+4,E=new B("0.5");if(d!==1||!v||!v[0])return new B(!d||d<0&&(!v||v[0])?NaN:v?_:1/0);if(d=Math.sqrt(+k(_)),d==0||d==1/0?(f=G(v),(f.length+x)%2==0&&(f+="0"),d=Math.sqrt(+f),x=O((x+1)/2)-(x<0||x%2),d==1/0?f="5e"+x:(f=d.toExponential(),f=f.slice(0,f.indexOf("e")+1)+x),l=new B(f)):l=new B(d+""),l.c[0]){for(x=l.e,d=x+A,d<3&&(d=0);;)if(g=l,l=E.times(g.plus(H(_,g,A,1))),G(g.c).slice(0,d)===(f=G(l.c)).slice(0,d))if(l.e<x&&--d,f=f.slice(d-3,d+1),f=="9999"||!b&&f=="4999"){if(!b&&(gt(g,g.e+st+2,0),g.times(g).eq(_))){l=g;break}A+=4,d+=4,b=1}else{(!+f||!+f.slice(1)&&f.charAt(0)=="5")&&(gt(l,l.e+st+2,1),a=!l.times(l).eq(_));break}}return gt(l,l.e+st+1,ot,a)},R.toExponential=function(a,f){return a!=null&&(j(a,0,N),a++),h(this,a,f,1)},R.toFixed=function(a,f){return a!=null&&(j(a,0,N),a=a+this.e+1),h(this,a,f)},R.toFormat=function(a,f,l){var b,g=this;if(l==null)a!=null&&f&&typeof f=="object"?(l=f,f=null):a&&typeof a=="object"?(l=a,a=f=null):l=J;else if(typeof l!="object")throw Error(s+"Argument not an object: "+l);if(b=g.toFixed(a,f),g.c){var _,v=b.split("."),d=+l.groupSize,x=+l.secondaryGroupSize,A=l.groupSeparator||"",E=v[0],I=v[1],F=g.s<0,$=F?E.slice(1):E,Z=$.length;if(x&&(_=d,d=x,x=_,Z-=_),d>0&&Z>0){for(_=Z%d||d,E=$.substr(0,_);_<Z;_+=d)E+=A+$.substr(_,d);x>0&&(E+=A+$.slice(_)),F&&(E="-"+E)}b=I?E+(l.decimalSeparator||"")+((x=+l.fractionGroupSize)?I.replace(new RegExp("\\d{"+x+"}\\B","g"),"$&"+(l.fractionGroupSeparator||"")):I):E}return(l.prefix||"")+b+(l.suffix||"")},R.toFraction=function(a){var f,l,b,g,_,v,d,x,A,E,I,F,$=this,Z=$.c;if(a!=null&&(d=new B(a),!d.isInteger()&&(d.c||d.s!==1)||d.lt(it)))throw Error(s+"Argument "+(d.isInteger()?"out of range: ":"not an integer: ")+k(d));if(!Z)return new B($);for(f=new B(it),A=l=new B(it),b=x=new B(it),F=G(Z),_=f.e=F.length-$.e-1,f.c[0]=y[(v=_%u)<0?u+v:v],a=!a||d.comparedTo(f)>0?_>0?f:A:d,v=U,U=1/0,d=new B(F),x.c[0]=0;E=H(d,f,0,1),g=l.plus(E.times(b)),g.comparedTo(a)!=1;)l=b,b=g,A=x.plus(E.times(g=A)),x=g,f=d.minus(E.times(g=f)),d=g;return g=H(a.minus(l),b,0,1),x=x.plus(g.times(A)),l=l.plus(g.times(b)),x.s=A.s=$.s,_=_*2,I=H(A,b,_,ot).minus($).abs().comparedTo(H(x,l,_,ot).minus($).abs())<1?[A,b]:[x,l],U=v,I},R.toNumber=function(){return+k(this)},R.toPrecision=function(a,f){return a!=null&&j(a,1,N),h(this,a,f,2)},R.toString=function(a){var f,l=this,b=l.s,g=l.e;return g===null?b?(f="Infinity",b<0&&(f="-"+f)):f="NaN":(a==null?f=g<=wt||g>=Ot?z(G(l.c),g):yt(G(l.c),g,"0"):a===10&&ut?(l=gt(new B(l),st+g+1,ot),f=yt(G(l.c),l.e,"0")):(j(a,2,tt.length,"Base"),f=nt(yt(G(l.c),g,"0"),10,a,b,!0)),b<0&&l.c[0]&&(f="-"+f)),f},R.valueOf=R.toJSON=function(){return k(this)},R._isBigNumber=!0,C!=null&&B.set(C),B}function O(C){var H=C|0;return C>0||C===H?H:H-1}function G(C){for(var H,nt,Y=1,R=C.length,it=C[0]+"";Y<R;){for(H=C[Y++]+"",nt=u-H.length;nt--;H="0"+H);it+=H}for(R=it.length;it.charCodeAt(--R)===48;);return it.slice(0,R+1||1)}function lt(C,H){var nt,Y,R=C.c,it=H.c,st=C.s,ot=H.s,wt=C.e,Ot=H.e;if(!st||!ot)return null;if(nt=R&&!R[0],Y=it&&!it[0],nt||Y)return nt?Y?0:-ot:st;if(st!=ot)return st;if(nt=st<0,Y=wt==Ot,!R||!it)return Y?0:!R^nt?1:-1;if(!Y)return wt>Ot^nt?1:-1;for(ot=(wt=R.length)<(Ot=it.length)?wt:Ot,st=0;st<ot;st++)if(R[st]!=it[st])return R[st]>it[st]^nt?1:-1;return wt==Ot?0:wt>Ot^nt?1:-1}function j(C,H,nt,Y){if(C<H||C>nt||C!==i(C))throw Error(s+(Y||"Argument")+(typeof C=="number"?C<H||C>nt?" out of range: ":" not an integer: ":" not a primitive number: ")+String(C))}function W(C){var H=C.c.length-1;return O(C.e/u)==H&&C.c[H]%2!=0}function z(C,H){return(C.length>1?C.charAt(0)+"."+C.slice(1):C)+(H<0?"e":"e+")+H}function yt(C,H,nt){var Y,R;if(H<0){for(R=nt+".";++H;R+=nt);C=R+C}else if(Y=C.length,++H>Y){for(R=nt,H-=Y;--H;R+=nt);C+=R}else H<Y&&(C=C.slice(0,H)+"."+C.slice(H));return C}t=M(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof _n<"u"&&_n.exports?_n.exports=t:(r||(r=typeof self<"u"&&self?self:window),r.BigNumber=t)})(aa)});var ua=Bt((gp,ca)=>{ca.exports=function(t,e,n){var i=new t.Uint8Array(n),s=e.pushInt,o=e.pushInt32,c=e.pushInt32Neg,u=e.pushInt64,w=e.pushInt64Neg,y=e.pushFloat,m=e.pushFloatSingle,N=e.pushFloatDouble,M=e.pushTrue,O=e.pushFalse,G=e.pushUndefined,lt=e.pushNull,j=e.pushInfinity,W=e.pushInfinityNeg,z=e.pushNaN,yt=e.pushNaNNeg,C=e.pushArrayStart,H=e.pushArrayStartFixed,nt=e.pushArrayStartFixed32,Y=e.pushArrayStartFixed64,R=e.pushObjectStart,it=e.pushObjectStartFixed,st=e.pushObjectStartFixed32,ot=e.pushObjectStartFixed64,wt=e.pushByteString,Ot=e.pushByteStringStart,V=e.pushUtf8String,U=e.pushUtf8StringStart,P=e.pushSimpleUnassigned,L=e.pushTagStart,K=e.pushTagStart4,J=e.pushTagStart8,tt=e.pushTagUnassigned,ut=e.pushBreak,B=t.Math.pow,h=0,mt=0,Et=0;function gt(p){for(p=p|0,h=0,mt=p;(h|0)<(mt|0)&&(Et=mu[i[h]&255](i[h]|0)|0,!((Et|0)>0)););return Et|0}function k(p){return p=p|0,((h|0)+(p|0)|0)<(mt|0)?0:1}function a(p){return p=p|0,i[p|0]<<8|i[p+1|0]|0}function f(p){return p=p|0,i[p|0]<<24|i[p+1|0]<<16|i[p+2|0]<<8|i[p+3|0]|0}function l(p){return p=p|0,s(p|0),h=h+1|0,0}function b(p){return p=p|0,k(1)|0?1:(s(i[h+1|0]|0),h=h+2|0,0)}function g(p){return p=p|0,k(2)|0?1:(s(a(h+1|0)|0),h=h+3|0,0)}function _(p){return p=p|0,k(4)|0?1:(o(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function v(p){return p=p|0,k(8)|0?1:(u(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function d(p){return p=p|0,s(-1-(p-32|0)|0),h=h+1|0,0}function x(p){return p=p|0,k(1)|0?1:(s(-1-(i[h+1|0]|0)|0),h=h+2|0,0)}function A(p){p=p|0;var et=0;return k(2)|0?1:(et=a(h+1|0)|0,s(-1-(et|0)|0),h=h+3|0,0)}function E(p){return p=p|0,k(4)|0?1:(c(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function I(p){return p=p|0,k(8)|0?1:(w(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function F(p){p=p|0;var et=0,rt=0,Q=0;return Q=p-64|0,k(Q|0)|0?1:(et=h+1|0,rt=(h+1|0)+(Q|0)|0,wt(et|0,rt|0),h=rt|0,0)}function $(p){p=p|0;var et=0,rt=0,Q=0;return k(1)|0||(Q=i[h+1|0]|0,et=h+2|0,rt=(h+2|0)+(Q|0)|0,k(Q+1|0)|0)?1:(wt(et|0,rt|0),h=rt|0,0)}function Z(p){p=p|0;var et=0,rt=0,Q=0;return k(2)|0||(Q=a(h+1|0)|0,et=h+3|0,rt=(h+3|0)+(Q|0)|0,k(Q+2|0)|0)?1:(wt(et|0,rt|0),h=rt|0,0)}function ht(p){p=p|0;var et=0,rt=0,Q=0;return k(4)|0||(Q=f(h+1|0)|0,et=h+5|0,rt=(h+5|0)+(Q|0)|0,k(Q+4|0)|0)?1:(wt(et|0,rt|0),h=rt|0,0)}function xt(p){return p=p|0,1}function X(p){return p=p|0,Ot(),h=h+1|0,0}function q(p){p=p|0;var et=0,rt=0,Q=0;return Q=p-96|0,k(Q|0)|0?1:(et=h+1|0,rt=(h+1|0)+(Q|0)|0,V(et|0,rt|0),h=rt|0,0)}function Tt(p){p=p|0;var et=0,rt=0,Q=0;return k(1)|0||(Q=i[h+1|0]|0,et=h+2|0,rt=(h+2|0)+(Q|0)|0,k(Q+1|0)|0)?1:(V(et|0,rt|0),h=rt|0,0)}function ve(p){p=p|0;var et=0,rt=0,Q=0;return k(2)|0||(Q=a(h+1|0)|0,et=h+3|0,rt=(h+3|0)+(Q|0)|0,k(Q+2|0)|0)?1:(V(et|0,rt|0),h=rt|0,0)}function $e(p){p=p|0;var et=0,rt=0,Q=0;return k(4)|0||(Q=f(h+1|0)|0,et=h+5|0,rt=(h+5|0)+(Q|0)|0,k(Q+4|0)|0)?1:(V(et|0,rt|0),h=rt|0,0)}function Sr(p){return p=p|0,1}function Zt(p){return p=p|0,U(),h=h+1|0,0}function at(p){return p=p|0,H(p-128|0),h=h+1|0,0}function Lt(p){return p=p|0,k(1)|0?1:(H(i[h+1|0]|0),h=h+2|0,0)}function Ct(p){return p=p|0,k(2)|0?1:(H(a(h+1|0)|0),h=h+3|0,0)}function _t(p){return p=p|0,k(4)|0?1:(nt(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function Zc(p){return p=p|0,k(8)|0?1:(Y(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function Qc(p){return p=p|0,C(),h=h+1|0,0}function bt(p){p=p|0;var et=0;return et=p-160|0,k(et|0)|0?1:(it(et|0),h=h+1|0,0)}function tu(p){return p=p|0,k(1)|0?1:(it(i[h+1|0]|0),h=h+2|0,0)}function eu(p){return p=p|0,k(2)|0?1:(it(a(h+1|0)|0),h=h+3|0,0)}function ru(p){return p=p|0,k(4)|0?1:(st(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function nu(p){return p=p|0,k(8)|0?1:(ot(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function iu(p){return p=p|0,R(),h=h+1|0,0}function Je(p){return p=p|0,L(p-192|0|0),h=h+1|0,0}function H0(p){return p=p|0,L(p|0),h=h+1|0,0}function G0(p){return p=p|0,L(p|0),h=h+1|0,0}function K0(p){return p=p|0,L(p|0),h=h+1|0,0}function D0(p){return p=p|0,L(p|0),h=h+1|0,0}function Pt(p){return p=p|0,L(p-192|0|0),h=h+1|0,0}function j0(p){return p=p|0,L(p|0),h=h+1|0,0}function W0(p){return p=p|0,L(p|0),h=h+1|0,0}function z0(p){return p=p|0,L(p|0),h=h+1|0,0}function su(p){return p=p|0,k(1)|0?1:(L(i[h+1|0]|0),h=h+2|0,0)}function ou(p){return p=p|0,k(2)|0?1:(L(a(h+1|0)|0),h=h+3|0,0)}function au(p){return p=p|0,k(4)|0?1:(K(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function cu(p){return p=p|0,k(8)|0?1:(J(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function St(p){return p=p|0,P((p|0)-224|0),h=h+1|0,0}function uu(p){return p=p|0,O(),h=h+1|0,0}function fu(p){return p=p|0,M(),h=h+1|0,0}function lu(p){return p=p|0,lt(),h=h+1|0,0}function hu(p){return p=p|0,G(),h=h+1|0,0}function du(p){return p=p|0,k(1)|0?1:(P(i[h+1|0]|0),h=h+2|0,0)}function pu(p){p=p|0;var et=0,rt=0,Q=1,rn=0,Br=0,Y0=0;return k(2)|0?1:(et=i[h+1|0]|0,rt=i[h+2|0]|0,(et|0)&128&&(Q=-1),rn=+(((et|0)&124)>>2),Br=+(((et|0)&3)<<8|rt),+rn==0?y(+(+Q*5960464477539063e-23*+Br)):+rn==31?+Q==1?+Br>0?z():j():+Br>0?yt():W():y(+(+Q*B(2,+(+rn-25))*+(1024+Br))),h=h+3|0,0)}function yu(p){return p=p|0,k(4)|0?1:(m(i[h+1|0]|0,i[h+2|0]|0,i[h+3|0]|0,i[h+4|0]|0),h=h+5|0,0)}function wu(p){return p=p|0,k(8)|0?1:(N(i[h+1|0]|0,i[h+2|0]|0,i[h+3|0]|0,i[h+4|0]|0,i[h+5|0]|0,i[h+6|0]|0,i[h+7|0]|0,i[h+8|0]|0),h=h+9|0,0)}function dt(p){return p=p|0,1}function gu(p){return p=p|0,ut(),h=h+1|0,0}var mu=[l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,b,g,_,v,dt,dt,dt,dt,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,x,A,E,I,dt,dt,dt,dt,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,$,Z,ht,xt,dt,dt,dt,X,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,Tt,ve,$e,Sr,dt,dt,dt,Zt,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,Lt,Ct,_t,Zc,dt,dt,dt,Qc,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,tu,eu,ru,nu,dt,dt,dt,iu,Je,Je,Je,Je,Je,Je,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,su,ou,au,cu,dt,dt,dt,dt,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,uu,fu,lu,hu,du,pu,yu,wu,dt,dt,dt,gu];return{parse:gt}}});var Mr=Bt(Yt=>{"use strict";var ns=kr().BigNumber;Yt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Yt.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};Yt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Yt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Yt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Yt.SHIFT32=Math.pow(2,32);Yt.SHIFT16=Math.pow(2,16);Yt.MAX_SAFE_HIGH=2097151;Yt.NEG_ONE=new ns(-1);Yt.TEN=new ns(10);Yt.TWO=new ns(2);Yt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var bn=Bt(re=>{"use strict";var{Buffer:$f}=Pr(),la=kr().BigNumber,ha=Mr(),fa=ha.SHIFT32,Vf=ha.SHIFT16,Lf=2097151;re.parseHalf=function(t){var e,n,i;return i=t[0]&128?-1:1,e=(t[0]&124)>>2,n=(t[0]&3)<<8|t[1],e?e===31?i*(n?NaN:1/0):i*Math.pow(2,e-25)*(1024+n):i*5960464477539063e-23*n};function qf(r){return r<16?"0"+r.toString(16):r.toString(16)}re.arrayBufferToBignumber=function(r){let t=r.byteLength,e="";for(let n=0;n<t;n++)e+=qf(r[n]);return new la(e,16)};re.buildMap=r=>{let t=new Map,e=Object.keys(r),n=e.length;for(let i=0;i<n;i++)t.set(e[i],r[e[i]]);return t};re.buildInt32=(r,t)=>r*Vf+t;re.buildInt64=(r,t,e,n)=>{let i=re.buildInt32(r,t),s=re.buildInt32(e,n);return i>Lf?new la(i).times(fa).plus(s):i*fa+s};re.writeHalf=function(t,e){let n=$f.allocUnsafe(4);n.writeFloatBE(e,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,c=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(c>>13);else if(o>=103&&o<113){if(c&(1<<126-o)-1)return!1;s+=c+8388608>>126-o}else return!1;return t.writeUInt16BE(s,0),!0};re.keySorter=function(r,t){var e=r[0].byteLength,n=t[0].byteLength;return e>n?1:n>e?-1:r[0].compare(t[0])};re.isNegativeZero=r=>r===0&&1/r<0;re.nextPowerOf2=r=>{let t=0;if(r&&!(r&r-1))return r;for(;r!==0;)r>>=1,t+=1;return 1<<t}});var as=Bt((_p,da)=>{"use strict";var os=Mr(),Hf=os.MT,En=os.SIMPLE,is=os.SYMS,ss=class r{constructor(t){if(typeof t!="number")throw new Error("Invalid Simple type: "+typeof t);if(t<0||t>255||(t|0)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,Hf.SIMPLE_FLOAT)}static isSimple(t){return t instanceof r}static decode(t,e){switch(e==null&&(e=!0),t){case En.FALSE:return!1;case En.TRUE:return!0;case En.NULL:return e?null:is.NULL;case En.UNDEFINED:return e?void 0:is.UNDEFINED;case-1:if(!e)throw new Error("Invalid BREAK");return is.BREAK;default:return new r(t)}}};da.exports=ss});var us=Bt((bp,pa)=>{"use strict";var cs=class r{constructor(t,e,n){if(this.tag=t,this.value=e,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){var e,n;if(n=t?.[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 e=i,this.err=e,this}}};pa.exports=cs});var hs=Bt((Ep,wa)=>{"use strict";var ya=self.location?self.location.protocol+"//"+self.location.host:"",fs=self.URL,ls=class{constructor(t="",e=ya){this.super=new fs(t,e),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(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set origin(t){this.super.origin=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set searchParams(t){this.super.searchParams=t}set username(t){this.super.username=t}createObjectURL(t){return this.super.createObjectURL(t)}revokeObjectURL(t){this.super.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function Gf(r){if(typeof r=="string")return new fs(r).toString();if(!(r instanceof fs)){let t=r.username&&r.password?`${r.username}:${r.password}@`:"",e=r.auth?r.auth+"@":"",n=r.port?":"+r.port:"",i=r.protocol?r.protocol+"//":"",s=r.host||"",o=r.hostname||"",c=r.search||(r.query?"?"+r.query:""),u=r.hash||"",w=r.pathname||"",y=r.path||w+c;return`${i}${t||e}${s||o+n}${y}${u}`}}wa.exports={URLWithLegacySupport:ls,URLSearchParams:self.URLSearchParams,defaultBase:ya,format:Gf}});var xa=Bt((Ap,ma)=>{"use strict";var{URLWithLegacySupport:ga,format:Kf}=hs();ma.exports=(r,t={},e={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(e[i]||n||i)+":";let s;try{s=new ga(r)}catch{s={}}let o=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new ga(r,Kf(o)).toString()}});var ds=Bt((vp,_a)=>{"use strict";var{URLWithLegacySupport:Df,format:jf,URLSearchParams:Wf,defaultBase:zf}=hs(),Yf=xa();_a.exports={URL:Df,URLSearchParams:Wf,format:jf,relative:Yf,defaultBase:zf}});var ps=Bt((Tp,Ea)=>{"use strict";var{Buffer:hr}=Pr(),ba=sn(),Xf=kr().BigNumber,Jf=ua(),Vt=bn(),ft=Mr(),Zf=as(),Qf=us(),{URL:tl}=ds(),Cr=class r{constructor(t){t=t||{},!t.size||t.size<65536?t.size=65536:t.size=Vt.nextPowerOf2(t.size),this._heap=new ArrayBuffer(t.size),this._heap8=new Uint8Array(this._heap),this._buffer=hr.from(this._heap),this._reset(),this._knownTags=Object.assign({0:e=>new Date(e),1:e=>new Date(e*1e3),2:e=>Vt.arrayBufferToBignumber(e),3:e=>ft.NEG_ONE.minus(Vt.arrayBufferToBignumber(e)),4:e=>ft.TEN.pow(e[0]).times(e[1]),5:e=>ft.TWO.pow(e[0]).times(e[1]),32:e=>new tl(e),35:e=>new RegExp(e)},t.tags),this.parser=Jf(global,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var t=this._parents.pop();if(t.length>0)throw new Error(`Missing ${t.length} elements`);switch(t.type){case ft.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case ft.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case ft.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case ft.PARENT.MAP:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(t.ref,t.length));break;case ft.PARENT.OBJECT:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(t.ref,t.length));break;case ft.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===ft.PARENT.TAG&&this._dec()}_dec(){let t=this._currentParent;t.length<0||(t.length--,t.length===0&&this._closeParent())}_push(t,e){let n=this._currentParent;switch(n.values++,n.type){case ft.PARENT.ARRAY:case ft.PARENT.BYTE_STRING:case ft.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case ft.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=ft.PARENT.MAP,n.ref=Vt.buildMap(n.ref)));break;case ft.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case ft.PARENT.TAG:this._ref.push(t),e||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(t,e,n){this._parents[this._depth]={type:e,length:n,ref:t,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:ft.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,e){let n=this._knownTags[t];return n?n(e):new Qf(t,e)}createMap(t,e){return t}createObject(t,e){return t}createArray(t,e){return t}createByteString(t,e){return hr.concat(t)}createByteStringFromHeap(t,e){return t===e?hr.alloc(0):hr.from(this._heap.slice(t,e))}createInt(t){return t}createInt32(t,e){return Vt.buildInt32(t,e)}createInt64(t,e,n,i){return Vt.buildInt64(t,e,n,i)}createFloat(t){return t}createFloatSingle(t,e,n,i){return ba.read([t,e,n,i],0,!1,23,4)}createFloatDouble(t,e,n,i,s,o,c,u){return ba.read([t,e,n,i,s,o,c,u],0,!1,52,8)}createInt32Neg(t,e){return-1-Vt.buildInt32(t,e)}createInt64Neg(t,e,n,i){let s=Vt.buildInt32(t,e),o=Vt.buildInt32(n,i);return s>ft.MAX_SAFE_HIGH?ft.NEG_ONE.minus(new Xf(s).times(ft.SHIFT32).plus(o)):-1-(s*ft.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(t,e){return t.join("")}createUtf8StringFromHeap(t,e){return t===e?"":this._buffer.toString("utf8",t,e)}createSimpleUnassigned(t){return new Zf(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,e){this._push(this.createInt32(t,e))}pushInt64(t,e,n,i){this._push(this.createInt64(t,e,n,i))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,e,n,i){this._push(this.createFloatSingle(t,e,n,i))}pushFloatDouble(t,e,n,i,s,o,c,u){this._push(this.createFloatDouble(t,e,n,i,s,o,c,u))}pushInt32Neg(t,e){this._push(this.createInt32Neg(t,e))}pushInt64Neg(t,e,n,i){this._push(this.createInt64Neg(t,e,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([],ft.PARENT.ARRAY,-1)}pushArrayStartFixed(t){this._createArrayStartFixed(t)}pushArrayStartFixed32(t,e){let n=Vt.buildInt32(t,e);this._createArrayStartFixed(n)}pushArrayStartFixed64(t,e,n,i){let s=Vt.buildInt64(t,e,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(t){this._createObjectStartFixed(t)}pushObjectStartFixed32(t,e){let n=Vt.buildInt32(t,e);this._createObjectStartFixed(n)}pushObjectStartFixed64(t,e,n,i){let s=Vt.buildInt64(t,e,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:ft.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(t,e){this._push(this.createByteStringFromHeap(t,e))}pushUtf8StringStart(){this._parents[this._depth]={type:ft.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(t,e){this._push(this.createUtf8StringFromHeap(t,e))}pushSimpleUnassigned(t){this._push(this.createSimpleUnassigned(t))}pushTagStart(t){this._parents[this._depth]={type:ft.PARENT.TAG,length:1,ref:[t]}}pushTagStart4(t,e){this.pushTagStart(Vt.buildInt32(t,e))}pushTagStart8(t,e,n,i){this.pushTagStart(Vt.buildInt64(t,e,n,i))}pushTagUnassigned(t){this._push(this.createTag(t))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(t){if(t===0){this._push(this.createObject({}));return}this._createParent({},ft.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),ft.PARENT.ARRAY,t)}_decode(t){if(t.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(t);let e=this.parser.parse(t.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(e>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(t){return this._decode(t),this._res[0]}decodeAll(t){return this._decode(t),this._res}static decode(t,e){return typeof t=="string"&&(t=hr.from(t,e||"hex")),new r({size:t.length}).decodeFirst(t)}static decodeAll(t,e){return typeof t=="string"&&(t=hr.from(t,e||"hex")),new r({size:t.length}).decodeAll(t)}};Cr.decodeFirst=Cr.decode;Ea.exports=Cr});var Ta=Bt((Sp,va)=>{"use strict";var{Buffer:ys}=Pr(),el=ps(),rl=bn(),ws=class r extends el{createTag(t,e){return`${t}(${e})`}createInt(t){return super.createInt(t).toString()}createInt32(t,e){return super.createInt32(t,e).toString()}createInt64(t,e,n,i){return super.createInt64(t,e,n,i).toString()}createInt32Neg(t,e){return super.createInt32Neg(t,e).toString()}createInt64Neg(t,e,n,i){return super.createInt64Neg(t,e,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(t){let e=super.createFloat(t);return rl.isNegativeZero(t)?"-0_1":`${e}_1`}createFloatSingle(t,e,n,i){return`${super.createFloatSingle(t,e,n,i)}_2`}createFloatDouble(t,e,n,i,s,o,c,u){return`${super.createFloatDouble(t,e,n,i,s,o,c,u)}_3`}createByteString(t,e){let n=t.join(", ");return e===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(t,e){return`h'${ys.from(super.createByteStringFromHeap(t,e)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(t){return`simple(${t})`}createArray(t,e){let n=super.createArray(t,e);return e===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(t,e){let n=super.createMap(t),i=Array.from(n.keys()).reduce(Aa(n),"");return e===-1?`{_ ${i}}`:`{${i}}`}createObject(t,e){let n=super.createObject(t),i=Object.keys(n).reduce(Aa(n),"");return e===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(t,e){let n=t.join(", ");return e===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(t,e){return`"${ys.from(super.createUtf8StringFromHeap(t,e)).toString("utf8")}"`}static diagnose(t,e){return typeof t=="string"&&(t=ys.from(t,e||"hex")),new r().decodeFirst(t)}};va.exports=ws;function Aa(r){return(t,e)=>t?`${t}, ${e}: ${r[e]}`:`${e}: ${r[e]}`}});var Ua=Bt((Bp,Na)=>{"use strict";var{Buffer:de}=Pr(),{URL:nl}=ds(),ms=kr().BigNumber,gs=bn(),Ut=Mr(),ie=Ut.MT,An=Ut.NUMBYTES,Sa=Ut.SHIFT32,Ba=Ut.SYMS,dr=Ut.TAG,il=Ut.MT.SIMPLE_FLOAT<<5|Ut.NUMBYTES.TWO,sl=Ut.MT.SIMPLE_FLOAT<<5|Ut.NUMBYTES.FOUR,ol=Ut.MT.SIMPLE_FLOAT<<5|Ut.NUMBYTES.EIGHT,al=Ut.MT.SIMPLE_FLOAT<<5|Ut.SIMPLE.TRUE,cl=Ut.MT.SIMPLE_FLOAT<<5|Ut.SIMPLE.FALSE,ul=Ut.MT.SIMPLE_FLOAT<<5|Ut.SIMPLE.UNDEFINED,Ia=Ut.MT.SIMPLE_FLOAT<<5|Ut.SIMPLE.NULL,fl=new ms("0x20000000000000"),ll=de.from("f97e00","hex"),hl=de.from("f9fc00","hex"),dl=de.from("f97c00","hex");function pl(r){return{}.toString.call(r).slice(8,-1)}var xs=class r{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[nl,this._pushUrl],[ms,this._pushBigNumber]];let e=t.genTypes||[],n=e.length;for(let i=0;i<n;i++)this.addSemanticType(e[i][0],e[i][1]);this._reset()}addSemanticType(t,e){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===t){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=e,o}return this.semanticTypes.push([t,e]),null}push(t){return t&&(this.result[this.offset]=t,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=t.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(t,e,n){return this.result[this.offset]=t,this.resultMethod[this.offset]=e,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(t){return this.pushWrite(t,1,1)}_pushUInt16BE(t){return this.pushWrite(t,2,2)}_pushUInt32BE(t){return this.pushWrite(t,3,4)}_pushDoubleBE(t){return this.pushWrite(t,4,8)}_pushNaN(){return this.push(ll)}_pushInfinity(t){let e=t<0?hl:dl;return this.push(e)}_pushFloat(t){let e=de.allocUnsafe(2);if(gs.writeHalf(e,t)&&gs.parseHalf(e)===t)return this._pushUInt8(il)&&this.push(e);let n=de.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(sl)&&this.push(n):this._pushUInt8(ol)&&this._pushDoubleBE(t)}_pushInt(t,e,n){let i=e<<5;return t<24?this._pushUInt8(i|t):t<=255?this._pushUInt8(i|An.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|An.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|An.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|An.EIGHT)&&this._pushUInt32BE(Math.floor(t/Sa))&&this._pushUInt32BE(t%Sa):e===ie.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,ie.NEG_INT,t):this._pushInt(t,ie.POS_INT)}_pushNumber(t){switch(!1){case t===t:return this._pushNaN(t);case isFinite(t):return this._pushInfinity(t);case t%1!==0:return this._pushIntNum(t);default:return this._pushFloat(t)}}_pushString(t){let e=de.byteLength(t,"utf8");return this._pushInt(e,ie.UTF8_STRING)&&this.pushWrite(t,5,e)}_pushBoolean(t){return this._pushUInt8(t?al:cl)}_pushUndefined(t){return this._pushUInt8(ul)}_pushArray(t,e){let n=e.length;if(!t._pushInt(n,ie.ARRAY))return!1;for(let i=0;i<n;i++)if(!t.pushAny(e[i]))return!1;return!0}_pushTag(t){return this._pushInt(t,ie.TAG)}_pushDate(t,e){return t._pushTag(dr.DATE_EPOCH)&&t.pushAny(Math.round(e/1e3))}_pushBuffer(t,e){return t._pushInt(e.length,ie.BYTE_STRING)&&t.push(e)}_pushNoFilter(t,e){return t._pushBuffer(t,e.slice())}_pushRegexp(t,e){return t._pushTag(dr.REGEXP)&&t.pushAny(e.source)}_pushSet(t,e){if(!t._pushInt(e.size,ie.ARRAY))return!1;for(let n of e)if(!t.pushAny(n))return!1;return!0}_pushUrl(t,e){return t._pushTag(dr.URI)&&t.pushAny(e.format())}_pushBigint(t){let e=dr.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),e=dr.NEG_BIGINT);let n=t.toString(16);n.length%2&&(n="0"+n);let i=de.from(n,"hex");return this._pushTag(e)&&this._pushBuffer(this,i)}_pushBigNumber(t,e){if(e.isNaN())return t._pushNaN();if(!e.isFinite())return t._pushInfinity(e.isNegative()?-1/0:1/0);if(e.isInteger())return t._pushBigint(e);if(!(t._pushTag(dr.DECIMAL_FRAC)&&t._pushInt(2,ie.ARRAY)))return!1;let n=e.decimalPlaces(),i=e.multipliedBy(new ms(10).pow(n));return t._pushIntNum(-n)?i.abs().isLessThan(fl)?t._pushIntNum(i.toNumber()):t._pushBigint(i):!1}_pushMap(t,e){return t._pushInt(e.size,ie.MAP)?this._pushRawMap(e.size,Array.from(e)):!1}_pushObject(t){if(!t)return this._pushUInt8(Ia);for(var e=this.semanticTypes.length,n=0;n<e;n++)if(t instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(t,this,t);var i=t.encodeCBOR;if(typeof i=="function")return i.call(t,this);var s=Object.keys(t),o=s.length;return this._pushInt(o,ie.MAP)?this._pushRawMap(o,s.map(c=>[c,t[c]])):!1}_pushRawMap(t,e){e=e.map(function(i){return i[0]=r.encode(i[0]),i}).sort(gs.keySorter);for(var n=0;n<t;n++)if(!this.push(e[n][0])||!this.pushAny(e[n][1]))return!1;return!0}write(t){return this.pushAny(t)}pushAny(t){var e=pl(t);switch(e){case"Number":return this._pushNumber(t);case"String":return this._pushString(t);case"Boolean":return this._pushBoolean(t);case"Object":return this._pushObject(t);case"Array":return this._pushArray(this,t);case"Uint8Array":return this._pushBuffer(this,de.isBuffer(t)?t:de.from(t));case"Null":return this._pushUInt8(Ia);case"Undefined":return this._pushUndefined(t);case"Map":return this._pushMap(this,t);case"Set":return this._pushSet(this,t);case"URL":return this._pushUrl(this,t);case"BigNumber":return this._pushBigNumber(this,t);case"Date":return this._pushDate(this,t);case"RegExp":return this._pushRegexp(this,t);case"Symbol":switch(t){case Ba.NULL:return this._pushObject(null);case Ba.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+t.toString())}default:throw new Error("Unknown type: "+typeof t+", "+(t?t.toString():""))}}finalize(){if(this.offset===0)return null;for(var t=this.result,e=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=e[o];var c=de.allocUnsafe(s),u=0,w=0;for(o=0;o<i;o++){switch(w=e[o],n[o]){case 0:t[o].copy(c,u);break;case 1:c.writeUInt8(t[o],u,!0);break;case 2:c.writeUInt16BE(t[o],u,!0);break;case 3:c.writeUInt32BE(t[o],u,!0);break;case 4:c.writeDoubleBE(t[o],u,!0);break;case 5:c.write(t[o],u,w,"utf8");break;default:throw new Error("unkown method")}u+=w}var y=c;return this._reset(),y}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(t){let e=new r;if(!e.pushAny(t))throw new Error("Failed to encode input");return e.finalize()}};Na.exports=xs});var vn=Bt(Rt=>{"use strict";Rt.Diagnose=Ta();Rt.Decoder=ps();Rt.Encoder=Ua();Rt.Simple=as();Rt.Tagged=us();Rt.decodeAll=Rt.Decoder.decodeAll;Rt.decodeFirst=Rt.Decoder.decodeFirst;Rt.diagnose=Rt.Diagnose.diagnose;Rt.encode=Rt.Encoder.encode;Rt.decode=Rt.Decoder.decode;Rt.leveldb={decode:Rt.Decoder.decodeAll,encode:Rt.Encoder.encode,buffer:!0,name:"cbor"}});function pe(...r){let t=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),e=0;for(let n of r)t.set(new Uint8Array(n),e),e+=n.byteLength;return t.buffer}function Nt(r){return[...new Uint8Array(r)].map(t=>t.toString(16).padStart(2,"0")).join("")}function Gt(r){if(!yl.test(r))throw new Error("Invalid hexadecimal string.");let t=[...r].reduce((e,n,i)=>(e[i/2|0]=(e[i/2|0]||"")+n,e),[]).map(e=>Number.parseInt(e,16));return new Uint8Array(t).buffer}function _s(r,t){if(r.byteLength!==t.byteLength)return r.byteLength-t.byteLength;let e=new Uint8Array(r),n=new Uint8Array(t);for(let i=0;i<e.length;i++)if(e[i]!==n[i])return e[i]-n[i];return 0}function $r(r,t){return _s(r,t)===0}function He(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function Tn(r){return r instanceof Uint8Array?He(r):r instanceof ArrayBuffer?r:Array.isArray(r)?He(new Uint8Array(r)):"buffer"in r?Tn(r.buffer):He(new Uint8Array(r))}var yl,Xt=ct(()=>{yl=new RegExp(/^[0-9a-fA-F]+$/)});function Re(r){return He(Mo.create().update(new Uint8Array(r)).digest())}function Sn(r){if(r instanceof Ra.default.Tagged)return Sn(r.value);if(typeof r=="string")return Fa(r);if(typeof r=="number")return Re(Ue(r));if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))return Re(r);if(Array.isArray(r)){let t=r.map(Sn);return Re(pe(...t))}else{if(r&&typeof r=="object"&&r._isPrincipal)return Re(r.toUint8Array());if(typeof r=="object"&&r!==null&&typeof r.toHash=="function")return Sn(r.toHash());if(typeof r=="object")return bs(r);if(typeof r=="bigint")return Re(Ue(r))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${r}`),{value:r})}function pr(r){return bs(r)}function bs(r){let n=Object.entries(r).filter(([,o])=>o!==void 0).map(([o,c])=>{let u=Fa(o),w=Sn(c);return[u,w]}).sort(([o],[c])=>_s(o,c)),i=pe(...n.map(o=>pe(...o)));return Re(i)}var Ra,Fa,Vr=ct(()=>{ur();Ra=Te(vn());Ui();Xt();Fa=r=>{let t=new TextEncoder().encode(r);return Re(t)}});var vs=Bt(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});var ml=9007199254740992;function Ee(r,...t){let e=new Uint8Array(r.byteLength+t.reduce((i,s)=>i+s.byteLength,0));e.set(new Uint8Array(r),0);let n=r.byteLength;for(let i of t)e.set(new Uint8Array(i),n),n+=i.byteLength;return e.buffer}function se(r,t,e){e=e.replace(/[^0-9a-fA-F]/g,"");let n=2**(t-24);e=e.slice(-n*2).padStart(n*2,"0");let i=[(r<<5)+t].concat(e.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function Bn(r,t){if(t<24)return new Uint8Array([(r<<5)+t]).buffer;{let e=t<=255?24:t<=65535?25:t<=4294967295?26:27;return se(r,e,t.toString(16))}}function Oa(r){let t=[];for(let e=0;e<r.length;e++){let n=r.charCodeAt(e);n<128?t.push(n):n<2048?t.push(192|n>>6,128|n&63):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|n&63):(e++,n=(n&1023)<<10|r.charCodeAt(e)&1023,t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Ee(new Uint8Array(Bn(3,r.length)),new Uint8Array(t))}function xl(r,t){if(r==14277111)return Ee(new Uint8Array([217,217,247]),t);if(r<24)return Ee(new Uint8Array([192+r]),t);{let e=r<=255?24:r<=65535?25:r<=4294967295?26:27,n=2**(e-24),i=r.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+e].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}pt.tagged=xl;function Lr(r){return new Uint8Array(r).buffer}pt.raw=Lr;function Es(r){if(isNaN(r))throw new RangeError("Invalid number.");r=Math.min(Math.max(0,r),23);let t=[0+r];return new Uint8Array(t).buffer}pt.uSmall=Es;function Pa(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),255),r=r.toString(16),se(0,24,r)}pt.u8=Pa;function ka(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),65535),r=r.toString(16),se(0,25,r)}pt.u16=ka;function Ma(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),4294967295),r=r.toString(16),se(0,26,r)}pt.u32=Ma;function As(r,t){if(typeof r=="string"&&t==16){if(r.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return se(0,27,r)}if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),ml),r=r.toString(16),se(0,27,r)}pt.u64=As;function Ca(r){if(isNaN(r))throw new RangeError("Invalid number.");if(r===0)return Es(0);r=Math.min(Math.max(0,-r),24)-1;let t=[32+r];return new Uint8Array(t).buffer}pt.iSmall=Ca;function $a(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),255),r=r.toString(16),se(1,24,r)}pt.i8=$a;function Va(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),65535),r=r.toString(16),se(1,25,r)}pt.i16=Va;function La(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),4294967295),r=r.toString(16),se(1,26,r)}pt.i32=La;function qa(r,t){if(typeof r=="string"&&t==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 e=!1,n=r.split("").reduceRight((i,s)=>{if(e)return s+i;let o=parseInt(s,16)-1;return o>=0?(e=!0,o.toString(16)+i):"f"+i},"");return e?se(1,27,n):As(0)}if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),9007199254740992),r=r.toString(16),se(1,27,r)}pt.i64=qa;function _l(r){return r>=0?r<24?Es(r):r<=255?Pa(r):r<=65535?ka(r):r<=4294967295?Ma(r):As(r):r>=-24?Ca(r):r>=-255?$a(r):r>=-65535?Va(r):r>=-4294967295?La(r):qa(r)}pt.number=_l;function bl(r){return Ee(Bn(2,r.byteLength),r)}pt.bytes=bl;function El(r){return Oa(r)}pt.string=El;function Al(r){return Ee(Bn(4,r.length),...r)}pt.array=Al;function vl(r,t=!1){r instanceof Map||(r=new Map(Object.entries(r)));let e=Array.from(r.entries());return t&&(e=e.sort(([n],[i])=>n.localeCompare(i))),Ee(Bn(5,r.size),...e.map(([n,i])=>Ee(Oa(n),i)))}pt.map=vl;function Tl(r){let t=new Float32Array([r]);return Ee(new Uint8Array([250]),new Uint8Array(t.buffer))}pt.singleFloat=Tl;function Sl(r){let t=new Float64Array([r]);return Ee(new Uint8Array([251]),new Uint8Array(t.buffer))}pt.doubleFloat=Sl;function Bl(r){return r?Ha():Ga()}pt.bool=Bl;function Ha(){return Lr(new Uint8Array([245]))}pt.true_=Ha;function Ga(){return Lr(new Uint8Array([244]))}pt.false_=Ga;function Il(){return Lr(new Uint8Array([246]))}pt.null_=Il;function Nl(){return Lr(new Uint8Array([247]))}pt.undefined_=Nl});var Ka=Bt(Fe=>{"use strict";var Ul=Fe&&Fe.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t};Object.defineProperty(Fe,"__esModule",{value:!0});var oe=Ul(vs()),Rl=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],In=class{constructor(t,e=!1){this._serializer=t,this._stable=e,this.name="jsonDefault",this.priority=-100}match(t){return["undefined","boolean","number","string","object"].indexOf(typeof t)!=-1}encode(t){switch(typeof t){case"undefined":return oe.undefined_();case"boolean":return oe.bool(t);case"number":return Math.floor(t)===t?oe.number(t):oe.doubleFloat(t);case"string":return oe.string(t);case"object":if(t===null)return oe.null_();if(Array.isArray(t))return oe.array(t.map(e=>this._serializer.serializeValue(e)));if(Rl.find(e=>t instanceof e))return oe.bytes(t.buffer);if(Object.getOwnPropertyNames(t).indexOf("toJSON")!==-1)return this.encode(t.toJSON());if(t instanceof Map){let e=new Map;for(let[n,i]of t.entries())e.set(n,this._serializer.serializeValue(i));return oe.map(e,this._stable)}else{let e=new Map;for(let[n,i]of Object.entries(t))e.set(n,this._serializer.serializeValue(i));return oe.map(e,this._stable)}default:throw new Error("Invalid value.")}}};Fe.JsonDefaultCborEncoder=In;var Nn=class{constructor(){this.name="cborEncoder",this.priority=-90}match(t){return typeof t=="object"&&typeof t.toCBOR=="function"}encode(t){return t.toCBOR()}};Fe.ToCborEncoder=Nn;var Un=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let e=new this;return e.addEncoder(new In(e,t)),e.addEncoder(new Nn),e}removeEncoder(t){for(let e of this._encoders.values())e.name==t&&this._encoders.delete(e)}addEncoder(t){this._encoders.add(t)}getEncoderFor(t){let e=null;for(let n of this._encoders)(!e||n.priority>e.priority)&&n.match(t)&&(e=n);if(e===null)throw new Error("Could not find an encoder for value.");return e}serializeValue(t){return this.getEncoderFor(t).encode(t)}serialize(t){return this.serializeValue(t)}};Fe.CborSerializer=Un;var Ts=class extends Un{serialize(t){return oe.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};Fe.SelfDescribeCborSerializer=Ts});var qr=Bt(Ge=>{"use strict";function Fl(r){for(var t in r)Ge.hasOwnProperty(t)||(Ge[t]=r[t])}var Ol=Ge&&Ge.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t};Object.defineProperty(Ge,"__esModule",{value:!0});Fl(Ka());var Pl=Ol(vs());Ge.value=Pl});function Da(r){let t=r.byteLength,e=BigInt(0);for(let n=0;n<t;n++)e=e*BigInt(256)+BigInt(r[n]);return e}function Rn(r){let t=new Uint8Array(r),e=new Us({size:t.byteLength,tags:{2:n=>Da(n),3:n=>-Da(n),[Ns.Semantic]:n=>n}});try{return e.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${Nt(t)}`)}}var ja,Ke,Wa,Ss,Bs,Is,Rs,Ns,Us,Hr=ct(()=>{ja=Te(vn()),Ke=Te(qr()),Wa=Te(qr());Xt();Ss=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return Ke.value.bytes(t.toUint8Array())}},Bs=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return Ke.value.bytes(new Uint8Array(t))}},Is=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?Ke.value.tagged(2,Ke.value.bytes(Gt(t.toString(16)))):Ke.value.tagged(3,Ke.value.bytes(Gt((BigInt("-1")*t).toString(16))))}},Rs=Wa.SelfDescribeCborSerializer.withDefaultEncoders(!0);Rs.addEncoder(new Ss);Rs.addEncoder(new Bs);Rs.addEncoder(new Is);(function(r){r[r.Uint64LittleEndian=71]="Uint64LittleEndian",r[r.Semantic=55799]="Semantic"})(Ns||(Ns={}));Us=class extends ja.default.Decoder{createByteString(t){return pe(...t)}createByteStringFromHeap(t,e){return t===e?new ArrayBuffer(0):new Uint8Array(this._heap.slice(t,e))}}});function Ps(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function ks(r){if(!Ps(r))throw new Error("Uint8Array expected")}function Pn(r,t){if(typeof t!="boolean")throw new Error(`${r} must be valid boolean, got "${t}".`)}function kn(r){ks(r);let t="";for(let e=0;e<r.length;e++)t+=Vl[r[e]];return t}function Xa(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Ya(r){if(r>=Ae._0&&r<=Ae._9)return r-Ae._0;if(r>=Ae._A&&r<=Ae._F)return r-(Ae._A-10);if(r>=Ae._a&&r<=Ae._f)return r-(Ae._a-10)}function Ja(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let i=0,s=0;i<e;i++,s+=2){let o=Ya(r.charCodeAt(s)),c=Ya(r.charCodeAt(s+1));if(o===void 0||c===void 0){let u=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}n[i]=o*16+c}return n}function Za(r){return Xa(kn(r))}function wr(r){return ks(r),Xa(kn(Uint8Array.from(r).reverse()))}function Ms(r,t){return Ja(r.toString(16).padStart(t*2,"0"))}function Kr(r,t){return Ms(r,t).reverse()}function ye(r,t,e){let n;if(typeof t=="string")try{n=Ja(t)}catch(s){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${s}`)}else if(Ps(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let i=n.length;if(typeof e=="number"&&i!==e)throw new Error(`${r} expected ${e} bytes, got ${i}`);return n}function Cs(...r){let t=0;for(let n=0;n<r.length;n++){let i=r[n];ks(i),t+=i.length}let e=new Uint8Array(t);for(let n=0,i=0;n<r.length;n++){let s=r[n];e.set(s,i),i+=s.length}return e}function Ll(r,t,e){return Os(r)&&Os(t)&&Os(e)&&t<=r&&r<e}function gr(r,t,e,n){if(!Ll(t,e,n))throw new Error(`expected valid ${r}: ${e} <= n < ${n}, got ${typeof t} ${t}`)}function mr(r,t,e={}){let n=(i,s,o)=>{let c=ql[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let u=r[i];if(!(o&&u===void 0)&&!c(u,r))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(let[i,s]of Object.entries(t))n(i,s,!1);for(let[i,s]of Object.entries(e))n(i,s,!0);return r}function $s(r){let t=new WeakMap;return(e,...n)=>{let i=t.get(e);if(i!==void 0)return i;let s=r(e,...n);return t.set(e,s),s}}var Ml,Cl,$l,Vl,Ae,Os,Qa,ql,Dr=ct(()=>{Ml=BigInt(0),Cl=BigInt(1),$l=BigInt(2);Vl=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));Ae={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};Os=r=>typeof r=="bigint"&&Ml<=r;Qa=r=>($l<<BigInt(r-1))-Cl,ql={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"||Ps(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)}});function vt(r,t){let e=r%t;return e>=Ft?e:t+e}function jl(r,t,e){if(e<=Ft||t<Ft)throw new Error("Expected power/modulo > 0");if(e===At)return Ft;let n=At;for(;t>Ft;)t&At&&(n=n*r%e),r=r*r%e,t>>=At;return n}function ae(r,t,e){let n=r;for(;t-- >Ft;)n*=n,n%=e;return n}function rc(r,t){if(r===Ft||t<=Ft)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=vt(r,t),n=t,i=Ft,s=At,o=At,c=Ft;for(;e!==Ft;){let w=n/e,y=n%e,m=i-o*w,N=s-c*w;n=e,e=y,i=o,s=c,o=m,c=N}if(n!==At)throw new Error("invert: does not exist");return vt(i,t)}function Wl(r){let t=(r-At)/De,e,n,i;for(e=r-At,n=0;e%De===Ft;e/=De,n++);for(i=De;i<r&&jl(i,t,r)!==r-At;i++);if(n===1){let o=(r+At)/Vs;return function(u,w){let y=u.pow(w,o);if(!u.eql(u.sqr(y),w))throw new Error("Cannot find square root");return y}}let s=(e+At)/De;return function(c,u){if(c.pow(u,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let w=n,y=c.pow(c.mul(c.ONE,i),e),m=c.pow(u,s),N=c.pow(u,e);for(;!c.eql(N,c.ONE);){if(c.eql(N,c.ZERO))return c.ZERO;let M=1;for(let G=c.sqr(N);M<w&&!c.eql(G,c.ONE);M++)G=c.sqr(G);let O=c.pow(y,At<<BigInt(w-M-1));y=c.sqr(O),m=c.mul(m,O),N=c.mul(N,y),w=M}return m}}function zl(r){if(r%Vs===Gl){let t=(r+At)/Vs;return function(n,i){let s=n.pow(i,t);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%ec===tc){let t=(r-tc)/ec;return function(n,i){let s=n.mul(i,De),o=n.pow(s,t),c=n.mul(i,o),u=n.mul(n.mul(c,De),o),w=n.mul(c,n.sub(u,n.ONE));if(!n.eql(n.sqr(w),i))throw new Error("Cannot find square root");return w}}return r%Dl,Wl(r)}function ic(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Yl.reduce((n,i)=>(n[i]="function",n),t);return mr(r,e)}function Xl(r,t,e){if(e<Ft)throw new Error("Expected power > 0");if(e===Ft)return r.ONE;if(e===At)return t;let n=r.ONE,i=t;for(;e>Ft;)e&At&&(n=r.mul(n,i)),i=r.sqr(i),e>>=At;return n}function Jl(r,t){let e=new Array(t.length),n=t.reduce((s,o,c)=>r.is0(o)?s:(e[c]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return t.reduceRight((s,o,c)=>r.is0(o)?s:(e[c]=r.mul(s,e[c]),r.mul(s,o)),i),e}function Ls(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function sc(r,t,e=!1,n={}){if(r<=Ft)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:s}=Ls(r,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=zl(r),c=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:Qa(i),ZERO:Ft,ONE:At,create:u=>vt(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return Ft<=u&&u<r},is0:u=>u===Ft,isOdd:u=>(u&At)===At,neg:u=>vt(-u,r),eql:(u,w)=>u===w,sqr:u=>vt(u*u,r),add:(u,w)=>vt(u+w,r),sub:(u,w)=>vt(u-w,r),mul:(u,w)=>vt(u*w,r),pow:(u,w)=>Xl(c,u,w),div:(u,w)=>vt(u*rc(w,r),r),sqrN:u=>u*u,addN:(u,w)=>u+w,subN:(u,w)=>u-w,mulN:(u,w)=>u*w,inv:u=>rc(u,r),sqrt:n.sqrt||(u=>o(c,u)),invertBatch:u=>Jl(c,u),cmov:(u,w,y)=>y?w:u,toBytes:u=>e?Kr(u,s):Ms(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return e?wr(u):Za(u)}});return Object.freeze(c)}var Ft,At,De,Gl,Vs,tc,ec,Kl,Dl,nc,Yl,Mn=ct(()=>{Dr();Ft=BigInt(0),At=BigInt(1),De=BigInt(2),Gl=BigInt(3),Vs=BigInt(4),tc=BigInt(5),ec=BigInt(8),Kl=BigInt(9),Dl=BigInt(16);nc=(r,t)=>(vt(r,t)&At)===At,Yl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function ac(r,t){let e=(s,o)=>{let c=o.negate();return s?c:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},i=s=>{n(s);let o=Math.ceil(t/s)+1,c=2**(s-1);return{windows:o,windowSize:c}};return{constTimeNegate:e,unsafeLadder(s,o){let c=r.ZERO,u=s;for(;o>Zl;)o&qs&&(c=c.add(u)),u=u.double(),o>>=qs;return c},precomputeWindow(s,o){let{windows:c,windowSize:u}=i(o),w=[],y=s,m=y;for(let N=0;N<c;N++){m=y,w.push(m);for(let M=1;M<u;M++)m=m.add(y),w.push(m);y=m.double()}return w},wNAF(s,o,c){let{windows:u,windowSize:w}=i(s),y=r.ZERO,m=r.BASE,N=BigInt(2**s-1),M=2**s,O=BigInt(s);for(let G=0;G<u;G++){let lt=G*w,j=Number(c&N);c>>=O,j>w&&(j-=M,c+=qs);let W=lt,z=lt+Math.abs(j)-1,yt=G%2!==0,C=j<0;j===0?m=m.add(e(yt,o[W])):y=y.add(e(C,o[z]))}return{p:y,f:m}},wNAFCached(s,o,c){let u=oc.get(s)||1,w=Hs.get(s);return w||(w=this.precomputeWindow(s,u),u!==1&&Hs.set(s,c(w))),this.wNAF(u,w,o)},setWindowSize(s,o){n(o),oc.set(s,o),Hs.delete(s)}}}function cc(r){return ic(r.Fp),mr(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ls(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Zl,qs,Hs,oc,uc=ct(()=>{Mn();Dr();Zl=BigInt(0),qs=BigInt(1),Hs=new WeakMap,oc=new WeakMap});var Gs=ct(()=>{Xt()});var Cn=ct(()=>{ur()});var fc,dy,$n,lc,jr=ct(()=>{Hr();ir();Vr();Xt();te();Gs();Cn();(function(r){r[r.Empty=0]="Empty",r[r.Fork=1]="Fork",r[r.Labeled=2]="Labeled",r[r.Leaf=3]="Leaf",r[r.Pruned=4]="Pruned"})(fc||(fc={}));dy=Gt("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100");(function(r){r.Unknown="unknown",r.Absent="absent",r.Found="found"})($n||($n={}));(function(r){r.Less="less",r.Greater="greater"})(lc||(lc={}))});var Vn=ct(()=>{te();ir();jr();Xt();Hr();Cn()});var a0=Te(vo());var Ai;(function(r){r[r.SysFatal=1]="SysFatal",r[r.SysTransient=2]="SysTransient",r[r.DestinationInvalid=3]="DestinationInvalid",r[r.CanisterReject=4]="CanisterReject",r[r.CanisterError=5]="CanisterError"})(Ai||(Ai={}));te();ir();te();Vr();Xt();var wl=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e},gl=new TextEncoder().encode(`
2
+ ic-request`),be=class{getPrincipal(){return this._principal||(this._principal=It.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:e}=t,n=wl(t,["body"]),i=await pr(e);return Object.assign(Object.assign({},n),{body:{content:e,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(pe(gl,i))}})}},yr=class{getPrincipal(){return It.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}};Hr();Vr();Xt();ur();var kl=Te(qr());var Fs;(function(r){r.Call="call"})(Fs||(Fs={}));var zp=BigInt(1e6),Yp=60*1e3;function On(r){let t=[];return r.forEach((e,n)=>{t.push([n,e])}),t}ir();var Gr=class extends ee{constructor(t,e){super(t),this.response=e,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Vn();jr();Ii();var Ln=BigInt(4294967295),Ks=BigInt(32);function pc(r,t=!1){return t?{h:Number(r&Ln),l:Number(r>>Ks&Ln)}:{h:Number(r>>Ks&Ln)|0,l:Number(r&Ln)|0}}function nh(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:s,l:o}=pc(r[i],t);[e[i],n[i]]=[s,o]}return[e,n]}var ih=(r,t)=>BigInt(r>>>0)<<Ks|BigInt(t>>>0),sh=(r,t,e)=>r>>>e,oh=(r,t,e)=>r<<32-e|t>>>e,ah=(r,t,e)=>r>>>e|t<<32-e,ch=(r,t,e)=>r<<32-e|t>>>e,uh=(r,t,e)=>r<<64-e|t>>>e-32,fh=(r,t,e)=>r>>>e-32|t<<64-e,lh=(r,t)=>t,hh=(r,t)=>r,dh=(r,t,e)=>r<<e|t>>>32-e,ph=(r,t,e)=>t<<e|r>>>32-e,yh=(r,t,e)=>t<<e-32|r>>>64-e,wh=(r,t,e)=>r<<e-32|t>>>64-e;function gh(r,t,e,n){let i=(t>>>0)+(n>>>0);return{h:r+e+(i/2**32|0)|0,l:i|0}}var mh=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),xh=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,_h=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),bh=(r,t,e,n,i)=>t+e+n+i+(r/2**32|0)|0,Eh=(r,t,e,n,i)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(i>>>0),Ah=(r,t,e,n,i,s)=>t+e+n+i+s+(r/2**32|0)|0;var vh={fromBig:pc,split:nh,toBig:ih,shrSH:sh,shrSL:oh,rotrSH:ah,rotrSL:ch,rotrBH:uh,rotrBL:fh,rotr32H:lh,rotr32L:hh,rotlSH:dh,rotlSL:ph,rotlBH:yh,rotlBL:wh,add:gh,add3L:mh,add3H:xh,add4L:_h,add4H:bh,add5H:Ah,add5L:Eh},D=vh;Ur();var[Th,Sh]=D.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Oe=new Uint32Array(80),Pe=new Uint32Array(80),Ds=class extends nr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:i,Ch:s,Cl:o,Dh:c,Dl:u,Eh:w,El:y,Fh:m,Fl:N,Gh:M,Gl:O,Hh:G,Hl:lt}=this;return[t,e,n,i,s,o,c,u,w,y,m,N,M,O,G,lt]}set(t,e,n,i,s,o,c,u,w,y,m,N,M,O,G,lt){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=u|0,this.Eh=w|0,this.El=y|0,this.Fh=m|0,this.Fl=N|0,this.Gh=M|0,this.Gl=O|0,this.Hh=G|0,this.Hl=lt|0}process(t,e){for(let z=0;z<16;z++,e+=4)Oe[z]=t.getUint32(e),Pe[z]=t.getUint32(e+=4);for(let z=16;z<80;z++){let yt=Oe[z-15]|0,C=Pe[z-15]|0,H=D.rotrSH(yt,C,1)^D.rotrSH(yt,C,8)^D.shrSH(yt,C,7),nt=D.rotrSL(yt,C,1)^D.rotrSL(yt,C,8)^D.shrSL(yt,C,7),Y=Oe[z-2]|0,R=Pe[z-2]|0,it=D.rotrSH(Y,R,19)^D.rotrBH(Y,R,61)^D.shrSH(Y,R,6),st=D.rotrSL(Y,R,19)^D.rotrBL(Y,R,61)^D.shrSL(Y,R,6),ot=D.add4L(nt,st,Pe[z-7],Pe[z-16]),wt=D.add4H(ot,H,it,Oe[z-7],Oe[z-16]);Oe[z]=wt|0,Pe[z]=ot|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:u,Dh:w,Dl:y,Eh:m,El:N,Fh:M,Fl:O,Gh:G,Gl:lt,Hh:j,Hl:W}=this;for(let z=0;z<80;z++){let yt=D.rotrSH(m,N,14)^D.rotrSH(m,N,18)^D.rotrBH(m,N,41),C=D.rotrSL(m,N,14)^D.rotrSL(m,N,18)^D.rotrBL(m,N,41),H=m&M^~m&G,nt=N&O^~N&lt,Y=D.add5L(W,C,nt,Sh[z],Pe[z]),R=D.add5H(Y,j,yt,H,Th[z],Oe[z]),it=Y|0,st=D.rotrSH(n,i,28)^D.rotrBH(n,i,34)^D.rotrBH(n,i,39),ot=D.rotrSL(n,i,28)^D.rotrBL(n,i,34)^D.rotrBL(n,i,39),wt=n&s^n&c^s&c,Ot=i&o^i&u^o&u;j=G|0,W=lt|0,G=M|0,lt=O|0,M=m|0,O=N|0,{h:m,l:N}=D.add(w|0,y|0,R|0,it|0),w=c|0,y=u|0,c=s|0,u=o|0,s=n|0,o=i|0;let V=D.add3L(it,ot,Ot);n=D.add3H(V,R,st,wt),i=V|0}({h:n,l:i}=D.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=D.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:u}=D.add(this.Ch|0,this.Cl|0,c|0,u|0),{h:w,l:y}=D.add(this.Dh|0,this.Dl|0,w|0,y|0),{h:m,l:N}=D.add(this.Eh|0,this.El|0,m|0,N|0),{h:M,l:O}=D.add(this.Fh|0,this.Fl|0,M|0,O|0),{h:G,l:lt}=D.add(this.Gh|0,this.Gl|0,G|0,lt|0),{h:j,l:W}=D.add(this.Hh|0,this.Hl|0,j|0,W|0),this.set(n,i,s,o,c,u,w,y,m,N,M,O,G,lt,j,W)}roundClean(){Oe.fill(0),Pe.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var yc=Nr(()=>new Ds);Ur();uc();Mn();Dr();Dr();var ce=BigInt(0),Kt=BigInt(1),qn=BigInt(2),Bh=BigInt(8),Ih={zip215:!0};function Nh(r){let t=cc(r);return mr(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function wc(r){let t=Nh(r),{Fp:e,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:u}=t,w=qn<<BigInt(c*8)-Kt,y=e.create,m=t.uvRatio||((V,U)=>{try{return{isValid:!0,value:e.sqrt(V*e.inv(U))}}catch{return{isValid:!1,value:ce}}}),N=t.adjustScalarBytes||(V=>V),M=t.domain||((V,U,P)=>{if(Pn("phflag",P),U.length||P)throw new Error("Contexts/pre-hash are not supported");return V});function O(V,U){gr("coordinate "+V,U,ce,w)}function G(V){if(!(V instanceof W))throw new Error("ExtendedPoint expected")}let lt=$s((V,U)=>{let{ex:P,ey:L,ez:K}=V,J=V.is0();U==null&&(U=J?Bh:e.inv(K));let tt=y(P*U),ut=y(L*U),B=y(K*U);if(J)return{x:ce,y:Kt};if(B!==Kt)throw new Error("invZ was invalid");return{x:tt,y:ut}}),j=$s(V=>{let{a:U,d:P}=t;if(V.is0())throw new Error("bad point: ZERO");let{ex:L,ey:K,ez:J,et:tt}=V,ut=y(L*L),B=y(K*K),h=y(J*J),mt=y(h*h),Et=y(ut*U),gt=y(h*y(Et+B)),k=y(mt+y(P*y(ut*B)));if(gt!==k)throw new Error("bad point: equation left != right (1)");let a=y(L*K),f=y(J*tt);if(a!==f)throw new Error("bad point: equation left != right (2)");return!0});class W{constructor(U,P,L,K){this.ex=U,this.ey=P,this.ez=L,this.et=K,O("x",U),O("y",P),O("z",L),O("t",K),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(U){if(U instanceof W)throw new Error("extended point not allowed");let{x:P,y:L}=U||{};return O("x",P),O("y",L),new W(P,L,Kt,y(P*L))}static normalizeZ(U){let P=e.invertBatch(U.map(L=>L.ez));return U.map((L,K)=>L.toAffine(P[K])).map(W.fromAffine)}_setWindowSize(U){C.setWindowSize(this,U)}assertValidity(){j(this)}equals(U){G(U);let{ex:P,ey:L,ez:K}=this,{ex:J,ey:tt,ez:ut}=U,B=y(P*ut),h=y(J*K),mt=y(L*ut),Et=y(tt*K);return B===h&&mt===Et}is0(){return this.equals(W.ZERO)}negate(){return new W(y(-this.ex),this.ey,this.ez,y(-this.et))}double(){let{a:U}=t,{ex:P,ey:L,ez:K}=this,J=y(P*P),tt=y(L*L),ut=y(qn*y(K*K)),B=y(U*J),h=P+L,mt=y(y(h*h)-J-tt),Et=B+tt,gt=Et-ut,k=B-tt,a=y(mt*gt),f=y(Et*k),l=y(mt*k),b=y(gt*Et);return new W(a,f,b,l)}add(U){G(U);let{a:P,d:L}=t,{ex:K,ey:J,ez:tt,et:ut}=this,{ex:B,ey:h,ez:mt,et:Et}=U;if(P===BigInt(-1)){let E=y((J-K)*(h+B)),I=y((J+K)*(h-B)),F=y(I-E);if(F===ce)return this.double();let $=y(tt*qn*Et),Z=y(ut*qn*mt),ht=Z+$,xt=I+E,X=Z-$,q=y(ht*F),Tt=y(xt*X),ve=y(ht*X),$e=y(F*xt);return new W(q,Tt,$e,ve)}let gt=y(K*B),k=y(J*h),a=y(ut*L*Et),f=y(tt*mt),l=y((K+J)*(B+h)-gt-k),b=f-a,g=f+a,_=y(k-P*gt),v=y(l*b),d=y(g*_),x=y(l*_),A=y(b*g);return new W(v,d,A,x)}subtract(U){return this.add(U.negate())}wNAF(U){return C.wNAFCached(this,U,W.normalizeZ)}multiply(U){let P=U;gr("scalar",P,Kt,n);let{p:L,f:K}=this.wNAF(P);return W.normalizeZ([L,K])[0]}multiplyUnsafe(U){let P=U;return gr("scalar",P,ce,n),P===ce?yt:this.equals(yt)||P===Kt?this:this.equals(z)?this.wNAF(P).p:C.unsafeLadder(this,P)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return C.unsafeLadder(this,n).is0()}toAffine(U){return lt(this,U)}clearCofactor(){let{h:U}=t;return U===Kt?this:this.multiplyUnsafe(U)}static fromHex(U,P=!1){let{d:L,a:K}=t,J=e.BYTES;U=ye("pointHex",U,J),Pn("zip215",P);let tt=U.slice(),ut=U[J-1];tt[J-1]=ut&-129;let B=wr(tt),h=P?w:e.ORDER;gr("pointHex.y",B,ce,h);let mt=y(B*B),Et=y(mt-Kt),gt=y(L*mt-K),{isValid:k,value:a}=m(Et,gt);if(!k)throw new Error("Point.fromHex: invalid y coordinate");let f=(a&Kt)===Kt,l=(ut&128)!==0;if(!P&&a===ce&&l)throw new Error("Point.fromHex: x=0 and x_0=1");return l!==f&&(a=y(-a)),W.fromAffine({x:a,y:B})}static fromPrivateKey(U){return Y(U).point}toRawBytes(){let{x:U,y:P}=this.toAffine(),L=Kr(P,e.BYTES);return L[L.length-1]|=U&Kt?128:0,L}toHex(){return kn(this.toRawBytes())}}W.BASE=new W(t.Gx,t.Gy,Kt,y(t.Gx*t.Gy)),W.ZERO=new W(ce,Kt,Kt,ce);let{BASE:z,ZERO:yt}=W,C=ac(W,c*8);function H(V){return vt(V,n)}function nt(V){return H(wr(V))}function Y(V){let U=c;V=ye("private key",V,U);let P=ye("hashed private key",s(V),2*U),L=N(P.slice(0,U)),K=P.slice(U,2*U),J=nt(L),tt=z.multiply(J),ut=tt.toRawBytes();return{head:L,prefix:K,scalar:J,point:tt,pointBytes:ut}}function R(V){return Y(V).pointBytes}function it(V=new Uint8Array,...U){let P=Cs(...U);return nt(s(M(P,ye("context",V),!!i)))}function st(V,U,P={}){V=ye("message",V),i&&(V=i(V));let{prefix:L,scalar:K,pointBytes:J}=Y(U),tt=it(P.context,L,V),ut=z.multiply(tt).toRawBytes(),B=it(P.context,ut,J,V),h=H(tt+B*K);gr("signature.s",h,ce,n);let mt=Cs(ut,Kr(h,e.BYTES));return ye("result",mt,c*2)}let ot=Ih;function wt(V,U,P,L=ot){let{context:K,zip215:J}=L,tt=e.BYTES;V=ye("signature",V,2*tt),U=ye("message",U),J!==void 0&&Pn("zip215",J),i&&(U=i(U));let ut=wr(V.slice(tt,2*tt)),B,h,mt;try{B=W.fromHex(P,J),h=W.fromHex(V.slice(0,tt),J),mt=z.multiplyUnsafe(ut)}catch{return!1}if(!J&&B.isSmallOrder())return!1;let Et=it(K,h.toRawBytes(),B.toRawBytes(),U);return h.add(B.multiplyUnsafe(Et)).subtract(mt).clearCofactor().equals(W.ZERO)}return z._setWindowSize(8),{CURVE:t,getPublicKey:R,sign:st,verify:wt,ExtendedPoint:W,utils:{getExtendedPublicKey:Y,randomPrivateKey:()=>o(e.BYTES),precompute(V=8,U=W.BASE){return U._setWindowSize(V),U.multiply(BigInt(3)),U}}}}Mn();var js=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),gc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),$y=BigInt(0),Uh=BigInt(1),mc=BigInt(2),Vy=BigInt(3),Rh=BigInt(5),Fh=BigInt(8);function Oh(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),i=BigInt(80),s=js,c=r*r%s*r%s,u=ae(c,mc,s)*c%s,w=ae(u,Uh,s)*r%s,y=ae(w,Rh,s)*w%s,m=ae(y,t,s)*y%s,N=ae(m,e,s)*m%s,M=ae(N,n,s)*N%s,O=ae(M,i,s)*M%s,G=ae(O,i,s)*M%s,lt=ae(G,t,s)*y%s;return{pow_p_5_8:ae(lt,mc,s)*r%s,b2:c}}function Ph(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function kh(r,t){let e=js,n=vt(t*t*t,e),i=vt(n*n*t,e),s=Oh(r*i).pow_p_5_8,o=vt(r*n*s,e),c=vt(t*o*o,e),u=o,w=vt(o*gc,e),y=c===r,m=c===vt(-r,e),N=c===vt(-r*gc,e);return y&&(o=u),(m||N)&&(o=w),nc(o,e)&&(o=vt(-o,e)),{isValid:y||m,value:o}}var Mh=sc(js,void 0,!0),Ch={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Mh,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Fh,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:yc,randomBytes:Oo,adjustScalarBytes:Ph,uvRatio:kh},xr=wc(Ch);var $h,Vh,Lh,qh;$h=new WeakMap,Vh=new WeakMap,Lh=Symbol.iterator,qh=Symbol.toStringTag;Xt();var xc=r=>{if(r<=127)return 1;if(r<=255)return 2;if(r<=65535)return 3;if(r<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},_c=(r,t,e)=>{if(e<=127)return r[t]=e,1;if(e<=255)return r[t]=129,r[t+1]=e,2;if(e<=65535)return r[t]=130,r[t+1]=e>>8,r[t+2]=e,3;if(e<=16777215)return r[t]=131,r[t+1]=e>>16,r[t+2]=e>>8,r[t+3]=e,4;throw new Error("Length too long (> 4 bytes)")},Ws=(r,t)=>{if(r[t]<128)return 1;if(r[t]===128)throw new Error("Invalid length 0");if(r[t]===129)return 2;if(r[t]===130)return 3;if(r[t]===131)return 4;throw new Error("Length too long (> 4 bytes)")},Hh=(r,t)=>{let e=Ws(r,t);if(e===1)return r[t];if(e===2)return r[t+1];if(e===3)return(r[t+1]<<8)+r[t+2];if(e===4)return(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];throw new Error("Length too long (> 4 bytes)")},bc=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),je=Uint8Array.from([48,5,6,3,43,101,112]),Gy=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function _r(r,t){let e=2+xc(r.byteLength+1),n=t.byteLength+e+r.byteLength,i=0,s=new Uint8Array(1+xc(n)+n);return s[i++]=48,i+=_c(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=_c(s,i,r.byteLength+1),s[i++]=0,s.set(new Uint8Array(r),i),s}var Wr=(r,t)=>{let e=0,n=(c,u)=>{if(i[e++]!==c)throw new Error("Expected: "+u)},i=new Uint8Array(r);if(n(48,"sequence"),e+=Ws(i,e),!$r(i.slice(e,e+t.byteLength),t))throw new Error("Not the expected OID.");e+=t.byteLength,n(3,"bit string");let s=Hh(i,e)-1;e+=Ws(i,e),n(0,"0 padding");let o=i.slice(e);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};var Ec=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Ac=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Hn,Gn,Kn=class r{constructor(t){if(Hn.set(this,void 0),Gn.set(this,void 0),t.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Ec(this,Hn,t,"f"),Ec(this,Gn,r.derEncode(t),"f")}static from(t){return this.fromDer(t.toDer())}static fromRaw(t){return new r(t)}static fromDer(t){return new r(this.derDecode(t))}static derEncode(t){return _r(t,je).buffer}static derDecode(t){let e=Wr(t,je);if(e.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return e}get rawKey(){return Ac(this,Hn,"f")}get derKey(){return Ac(this,Gn,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Hn=new WeakMap,Gn=new WeakMap;Kn.RAW_KEY_LENGTH=32;Cn();var we=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},$t=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ge,Dn,jn,Wn,zn,Yn,Xn,Jn,br;var Zn=class r{constructor(t=r.default){ge.set(this,void 0),Dn.set(this,void 0),jn.set(this,void 0),Wn.set(this,void 0),zn.set(this,void 0),Yn.set(this,void 0),Xn.set(this,void 0),Jn.set(this,void 0),br.set(this,0);let{initialInterval:e=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:c=10,date:u=Date}=t;we(this,ge,e,"f"),we(this,Dn,n,"f"),we(this,jn,i,"f"),we(this,Wn,s,"f"),we(this,Jn,u,"f"),we(this,zn,u.now(),"f"),we(this,Yn,o,"f"),we(this,Xn,c,"f")}get ellapsedTimeInMsec(){return $t(this,Jn,"f").now()-$t(this,zn,"f")}get currentInterval(){return $t(this,ge,"f")}get count(){return $t(this,br,"f")}get randomValueFromInterval(){let t=$t(this,Dn,"f")*$t(this,ge,"f"),e=$t(this,ge,"f")-t,n=$t(this,ge,"f")+t;return Math.random()*(n-e)+e}incrementCurrentInterval(){var t;return we(this,ge,Math.min($t(this,ge,"f")*$t(this,jn,"f"),$t(this,Wn,"f")),"f"),we(this,br,(t=$t(this,br,"f"),t++,t),"f"),$t(this,ge,"f")}next(){return this.ellapsedTimeInMsec>=$t(this,Yn,"f")||$t(this,br,"f")>=$t(this,Xn,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};ge=new WeakMap,Dn=new WeakMap,jn=new WeakMap,Wn=new WeakMap,zn=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,Jn=new WeakMap,br=new WeakMap;Zn.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var Dt=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},zr,Kh,vc,Tc,Dh,jh,Wh,zh,ke,Yh,Xh,Jh,Zh,Qh,Sc,t0,e0,r0,zs;(function(r){r.Received="received",r.Processing="processing",r.Replied="replied",r.Rejected="rejected",r.Unknown="unknown",r.Done="done"})(zs||(zs={}));var ww=5*60*1e3;Kh=new WeakMap,vc=new WeakMap,Tc=new WeakMap,Dh=new WeakMap,jh=new WeakMap,Wh=new WeakMap,zh=new WeakMap,ke=new WeakMap,Yh=new WeakMap,Xh=new WeakMap,Jh=new WeakMap,Zh=new WeakMap,Qh=new WeakMap,Sc=new WeakMap,r0=new WeakMap,zr=new WeakSet,t0=async function r(t){var e,n;let{ecid:i,transformedRequest:s,body:o,requestId:c,backoff:u,tries:w}=t,y=w===0?0:u.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:w,backoff:u,delay:y}),y===null)throw new ee(`Timestamp failed to pass the watermark after retrying the configured ${Dt(this,ke,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);y>0&&await new Promise(O=>setTimeout(O,y));let m;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let O=await Dt(this,vc,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},Dt(this,Tc,"f")),s.request),{body:o}));if(O.status===200){let G=Rn(await O.arrayBuffer());m=Object.assign(Object.assign({},G),{httpDetails:{ok:O.ok,status:O.status,statusText:O.statusText,headers:On(O.headers)},requestId:c})}else throw new Gr(`Gateway returned an error:
3
+ Code: ${O.status} (${O.statusText})
4
+ Body: ${await O.text()}
5
+ `,{ok:O.ok,status:O.status,statusText:O.statusText,headers:On(O.headers)})}catch(O){if(w<Dt(this,ke,"f"))return this.log.warn(`Caught exception while attempting to make query:
6
+ ${O}
7
+ Retrying query.`),await Dt(this,zr,"m",r).call(this,Object.assign(Object.assign({},t),{tries:w+1}));throw O}let N=(n=(e=m.signatures)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.timestamp;if(!Dt(this,Sc,"f"))return m;if(!N)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let M=Number(BigInt(N)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:M}),Number(this.waterMark)>M){let O=new ee("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",O,{timestamp:N,waterMark:this.waterMark}),w<Dt(this,ke,"f"))return await Dt(this,zr,"m",r).call(this,Object.assign(Object.assign({},t),{tries:w+1}));throw new ee(`Timestamp failed to pass the watermark after retrying the configured ${Dt(this,ke,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return m},e0=async function r(t){let{request:e,backoff:n,tries:i}=t,s=i===0?0:n.next();if(s===null)throw new ee(`Timestamp failed to pass the watermark after retrying the configured ${Dt(this,ke,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(w=>setTimeout(w,s));let o;try{o=await e()}catch(w){if(Dt(this,ke,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
8
8
  ${w}
9
- Retrying request.`),await ee(this,Wr,"m",r).call(this,{request:e,backoff:n,tries:i+1});throw w}if(o.ok)return o;let c=await o.clone().text(),u=`Server returned an error:
9
+ Retrying request.`),await Dt(this,zr,"m",r).call(this,{request:e,backoff:n,tries:i+1});throw w}if(o.ok)return o;let c=await o.clone().text(),u=`Server returned an error:
10
10
  Code: ${o.status} (${o.statusText})
11
11
  Body: ${c}
12
- `;if(i<ee(this,ke,"f"))return await ee(this,Wr,"m",r).call(this,{request:e,backoff:n,tries:i+1});throw new Hr(u,{ok:o.ok,status:o.status,statusText:o.statusText,headers:Fn(o.headers)})};Zt();var xc;(function(r){r.Error="err",r.GetPrincipal="gp",r.GetPrincipalResponse="gpr",r.Query="q",r.QueryResponse="qr",r.Call="c",r.CallResponse="cr",r.ReadState="rs",r.ReadStateResponse="rsr",r.Status="s",r.StatusResponse="sr"})(xc||(xc={}));sr();fr();Dr();zt();var Jn={};wu(Jn,{backoff:()=>vc,chain:()=>Tc,conditionalDelay:()=>Ec,defaultStrategy:()=>_c,maxAttempts:()=>Gh,once:()=>bc,throttle:()=>Kh,timeout:()=>Ac});zt();var Hh=5*60*1e3;function _c(){return Tc(Ec(bc(),1e3),vc(1e3,1.2),Ac(Hh))}function bc(){let r=!0;return async()=>r?(r=!1,!0):!1}function Ec(r,t){return async(e,n,i)=>{if(await r(e,n,i))return new Promise(s=>setTimeout(s,t))}}function Gh(r){let t=r;return async(e,n,i)=>{if(--t<=0)throw new Error(`Failed to retrieve a reply for request after ${r} attempts:
13
- Request ID: ${Tt(n)}
12
+ `;if(i<Dt(this,ke,"f"))return await Dt(this,zr,"m",r).call(this,{request:e,backoff:n,tries:i+1});throw new Gr(u,{ok:o.ok,status:o.status,statusText:o.statusText,headers:On(o.headers)})};te();var Bc;(function(r){r.Error="err",r.GetPrincipal="gp",r.GetPrincipalResponse="gpr",r.Query="q",r.QueryResponse="qr",r.Call="c",r.CallResponse="cr",r.ReadState="rs",r.ReadStateResponse="rsr",r.Status="s",r.StatusResponse="sr"})(Bc||(Bc={}));ir();ur();jr();Xt();var Qn={};vu(Qn,{backoff:()=>Fc,chain:()=>Oc,conditionalDelay:()=>Uc,defaultStrategy:()=>Ic,maxAttempts:()=>i0,once:()=>Nc,throttle:()=>s0,timeout:()=>Rc});Xt();var n0=5*60*1e3;function Ic(){return Oc(Uc(Nc(),1e3),Fc(1e3,1.2),Rc(n0))}function Nc(){let r=!0;return async()=>r?(r=!1,!0):!1}function Uc(r,t){return async(e,n,i)=>{if(await r(e,n,i))return new Promise(s=>setTimeout(s,t))}}function i0(r){let t=r;return async(e,n,i)=>{if(--t<=0)throw new Error(`Failed to retrieve a reply for request after ${r} attempts:
13
+ Request ID: ${Nt(n)}
14
14
  Request status: ${i}
15
- `)}}function Kh(r){return()=>new Promise(t=>setTimeout(t,r))}function Ac(r){let t=Date.now()+r;return async(e,n,i)=>{if(Date.now()>t)throw new Error(`Request timed out after ${r} msec:
16
- Request ID: ${Tt(n)}
15
+ `)}}function s0(r){return()=>new Promise(t=>setTimeout(t,r))}function Rc(r){let t=Date.now()+r;return async(e,n,i)=>{if(Date.now()>t)throw new Error(`Request timed out after ${r} msec:
16
+ Request ID: ${Nt(n)}
17
17
  Request status: ${i}
18
- `)}}function vc(r,t){let e=r;return()=>new Promise(n=>setTimeout(()=>{e*=t,n()},e))}function Tc(...r){return async(t,e,n)=>{for(let i of r)await i(t,e,n)}}Zt();zt();var Iw=Symbol.for("ic-agent-metadata");var Nw={pollingStrategyFactory:Jn.defaultStrategy};Dr();Zt();Cn();$r();$s();zt();Cn();qr();var ti=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Me=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Zn,Qn,Er,Ar;function Bc(r){return r!==null&&typeof r=="object"}var ze=class r{constructor(t){if(Zn.set(this,void 0),Qn.set(this,void 0),t.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");ti(this,Zn,t,"f"),ti(this,Qn,r.derEncode(t),"f")}static from(t){if(typeof t=="string"){let e=Gt(t);return this.fromRaw(e)}else if(Bc(t)){let e=t;if(Bc(e)&&Object.hasOwnProperty.call(e,"__derEncodedPublicKey__"))return this.fromDer(e);if(ArrayBuffer.isView(e)){let n=e;return this.fromRaw(vn(n.buffer))}else{if(e instanceof ArrayBuffer)return this.fromRaw(e);if("rawKey"in e)return this.fromRaw(e.rawKey);if("derKey"in e)return this.fromDer(e.derKey);if("toDer"in e)return this.fromDer(e.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(t){return new r(t)}static fromDer(t){return new r(this.derDecode(t))}static derEncode(t){let e=_r(t,We).buffer;return e.__derEncodedPublicKey__=void 0,e}static derDecode(t){let e=jr(t,We);if(e.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return e}get rawKey(){return Me(this,Zn,"f")}get derKey(){return Me(this,Qn,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Zn=new WeakMap,Qn=new WeakMap;ze.RAW_KEY_LENGTH=32;var Ye=class r extends Ee{constructor(t,e){super(),Er.set(this,void 0),Ar.set(this,void 0),ti(this,Er,ze.from(t),"f"),ti(this,Ar,new Uint8Array(e),"f")}static generate(t){if(t&&t.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");t||(t=xr.utils.randomPrivateKey()),Cr(t,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let e=new Uint8Array(32);for(let i=0;i<32;i++)e[i]=new Uint8Array(t)[i];let n=xr.getPublicKey(e);return r.fromKeyPair(n,e)}static fromParsedJson(t){let[e,n]=t;return new r(ze.fromDer(Gt(e)),Gt(n))}static fromJSON(t){let e=JSON.parse(t);if(Array.isArray(e)){if(typeof e[0]=="string"&&typeof e[1]=="string")return this.fromParsedJson([e[0],e[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(t)}`)}static fromKeyPair(t,e){return new r(ze.fromRaw(t),e)}static fromSecretKey(t){let e=xr.getPublicKey(new Uint8Array(t));return r.fromKeyPair(e,t)}toJSON(){return[Tt(Me(this,Er,"f").toDer()),Tt(Me(this,Ar,"f"))]}getKeyPair(){return{secretKey:Me(this,Ar,"f"),publicKey:Me(this,Er,"f")}}getPublicKey(){return Me(this,Er,"f")}async sign(t){let e=new Uint8Array(t),n=Ge(xr.sign(e,Me(this,Ar,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(t,e,n){let[i,s,o]=[t,e,n].map(c=>(typeof c=="string"&&(c=Gt(c)),c instanceof Uint8Array&&(c=c.buffer),new Uint8Array(c)));return xr.verify(s,i,o)}};Er=new WeakMap,Ar=new WeakMap;var Ks=class r extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,r.prototype)}};function Sc(r){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(r)return r;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new Ks("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var zr=class r extends Ee{constructor(t,e,n){super(),this._keyPair=t,this._derKey=e,this._subtleCrypto=n}static async generate(t){let{extractable:e=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=t??{},s=Sc(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},e,n),c=await s.exportKey("spki",o.publicKey);return new this(o,c,s)}static async fromKeyPair(t,e){let n=Sc(e),i=await n.exportKey("spki",t.publicKey);return new r(t,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let t=this._derKey,e=Object.create(this._keyPair.publicKey);return e.toDer=function(){return t},e}async sign(t){let e={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(e,this._keyPair.privateKey,t)}};Zt();var vr=Te(Vr());Zt();var zh=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Yr=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Ce,ei=class{constructor(t){Ce.set(this,void 0),zh(this,Ce,t,"f")}get rawKey(){return Yr(this,Ce,"f").rawKey}get derKey(){return Yr(this,Ce,"f").derKey}toDer(){return Yr(this,Ce,"f").toDer()}getPublicKey(){return Yr(this,Ce,"f")}getPrincipal(){return vt.from(Yr(this,Ce,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};Ce=new WeakMap;var Yh=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Xh=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Jh=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e},ri,Zh=new TextEncoder().encode("ic-request-auth-delegation"),Qh=new TextEncoder().encode(`
19
- ic-request`);function Ds(r){if(typeof r!="string"||r.length<64)throw new Error("Invalid public key.");return Gt(r)}var Tr=class{constructor(t,e,n){this.pubkey=t,this.expiration=e,this.targets=n}toCBOR(){return vr.value.map(Object.assign({pubkey:vr.value.bytes(this.pubkey),expiration:vr.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:vr.value.array(this.targets.map(t=>vr.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:Tt(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};async function t0(r,t,e,n){let i=new Tr(t.toDer(),BigInt(+e)*BigInt(1e6),n),s=new Uint8Array([...Zh,...new Uint8Array(yr(i))]),o=await r.sign(s);return{delegation:i,signature:o}}var Xe=class r{constructor(t,e){this.delegations=t,this.publicKey=e}static async create(t,e,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let c=await t0(t,e,n,i.targets);return new r([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],c],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||t.getPublicKey().toDer())}static fromJSON(t){let{publicKey:e,delegations:n}=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:c}=s,{pubkey:u,expiration:w,targets:y}=o;if(y!==void 0&&!Array.isArray(y))throw new Error("Invalid targets.");return{delegation:new Tr(Ds(u),BigInt("0x"+w),y&&y.map(_=>{if(typeof _!="string")throw new Error("Invalid target.");return vt.fromHex(_)})),signature:Ds(c)}});return new this(i,Ds(e))}static fromDelegations(t,e){return new this(t,e)}toJSON(){return{delegations:this.delegations.map(t=>{let{delegation:e,signature:n}=t,{targets:i}=e;return{delegation:Object.assign({expiration:e.expiration.toString(16),pubkey:Tt(e.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:Tt(n)}}),publicKey:Tt(this.publicKey)}}},Xr=class extends Ee{constructor(t,e){super(),this._inner=t,this._delegation=e}static fromDelegation(t,e){return new this(t,e)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(t){return this._inner.sign(t)}async transformRequest(t){let{body:e}=t,n=Jh(t,["body"]),i=await yr(e);return Object.assign(Object.assign({},n),{body:{content:e,sender_sig:await this.sign(new Uint8Array([...Qh,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},Jr=class r extends ei{constructor(t,e){super(t),ri.set(this,void 0),Yh(this,ri,e,"f")}get delegation(){return Xh(this,ri,"f")}static fromDelegation(t,e){return new r(t,e)}};ri=new WeakMap;function ni(r,t){for(let{delegation:i}of r.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let e=[],n=t?.scope;n&&(Array.isArray(n)?e.push(...n.map(i=>typeof i=="string"?vt.fromText(i):i)):e.push(typeof n=="string"?vt.fromText(n):n));for(let i of e){let s=i.toText();for(let{delegation:o}of r.delegations){if(o.targets===void 0)continue;let c=!0;for(let u of o.targets)if(u.toText()===s){c=!1;break}if(c)return!1}}return!0}var e0=Te(An());fr();var Ic;(function(r){r[r.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Ic||(Ic={}));var Nc=["mousedown","mousemove","keydown","touchstart","wheel"],Zr=class{constructor(t={}){var e;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=t||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),Nc.forEach(function(c){document.addEventListener(c,s,!0)});let o=(c,u)=>{let w;return(...y)=>{let _=this,N=function(){w=void 0,c.apply(_,y)};clearTimeout(w),w=window.setTimeout(N,u)}};if(t?.captureScroll){let c=o(s,(e=t?.scrollDebounce)!==null&&e!==void 0?e:100);window.addEventListener("scroll",c,!0)}s()}static create(t={}){return new this(t)}registerCallback(t){this.callbacks.push(t)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let t=this._resetTimer.bind(this);Nc.forEach(function(e){document.removeEventListener(e,t,!0)}),this.callbacks.forEach(e=>e())}_resetTimer(){let t=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(t,this.idleTimeout)}};var r0=(r,t)=>t.some(e=>r instanceof e),Uc,Rc;function n0(){return Uc||(Uc=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function i0(){return Rc||(Rc=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Fc=new WeakMap,Ws=new WeakMap,Oc=new WeakMap,js=new WeakMap,Ys=new WeakMap;function s0(r){let t=new Promise((e,n)=>{let i=()=>{r.removeEventListener("success",s),r.removeEventListener("error",o)},s=()=>{e(me(r.result)),i()},o=()=>{n(r.error),i()};r.addEventListener("success",s),r.addEventListener("error",o)});return t.then(e=>{e instanceof IDBCursor&&Fc.set(e,r)}).catch(()=>{}),Ys.set(t,r),t}function o0(r){if(Ws.has(r))return;let t=new Promise((e,n)=>{let i=()=>{r.removeEventListener("complete",s),r.removeEventListener("error",o),r.removeEventListener("abort",o)},s=()=>{e(),i()},o=()=>{n(r.error||new DOMException("AbortError","AbortError")),i()};r.addEventListener("complete",s),r.addEventListener("error",o),r.addEventListener("abort",o)});Ws.set(r,t)}var zs={get(r,t,e){if(r instanceof IDBTransaction){if(t==="done")return Ws.get(r);if(t==="objectStoreNames")return r.objectStoreNames||Oc.get(r);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return me(r[t])},set(r,t,e){return r[t]=e,!0},has(r,t){return r instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in r}};function Pc(r){zs=r(zs)}function a0(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...e){let n=r.call(ii(this),t,...e);return Oc.set(n,t.sort?t.sort():[t]),me(n)}:i0().includes(r)?function(...t){return r.apply(ii(this),t),me(Fc.get(this))}:function(...t){return me(r.apply(ii(this),t))}}function c0(r){return typeof r=="function"?a0(r):(r instanceof IDBTransaction&&o0(r),r0(r,n0())?new Proxy(r,zs):r)}function me(r){if(r instanceof IDBRequest)return s0(r);if(js.has(r))return js.get(r);let t=c0(r);return t!==r&&(js.set(r,t),Ys.set(t,r)),t}var ii=r=>Ys.get(r);function Mc(r,t,{blocked:e,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(r,t),c=me(o);return n&&o.addEventListener("upgradeneeded",u=>{n(me(o.result),u.oldVersion,u.newVersion,me(o.transaction),u)}),e&&o.addEventListener("blocked",u=>e(u.oldVersion,u.newVersion,u)),c.then(u=>{s&&u.addEventListener("close",()=>s()),i&&u.addEventListener("versionchange",w=>i(w.oldVersion,w.newVersion,w))}).catch(()=>{}),c}var u0=["get","getKey","getAll","getAllKeys","count"],f0=["put","add","delete","clear"],Xs=new Map;function kc(r,t){if(!(r instanceof IDBDatabase&&!(t in r)&&typeof t=="string"))return;if(Xs.get(t))return Xs.get(t);let e=t.replace(/FromIndex$/,""),n=t!==e,i=f0.includes(e);if(!(e in(n?IDBIndex:IDBObjectStore).prototype)||!(i||u0.includes(e)))return;let s=async function(o,...c){let u=this.transaction(o,i?"readwrite":"readonly"),w=u.store;return n&&(w=w.index(c.shift())),(await Promise.all([w[e](...c),i&&u.done]))[0]};return Xs.set(t,s),s}Pc(r=>({...r,get:(t,e,n)=>kc(t,e)||r.get(t,e,n),has:(t,e)=>!!kc(t,e)||r.has(t,e)}));var Cc="auth-client-db",$c="ic-keyval",l0=async(r=Cc,t=$c,e)=>(si&&(localStorage!=null&&localStorage.getItem(Xt))&&(localStorage.removeItem(Xt),localStorage.removeItem(ue)),await Mc(r,e,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(t)&&n.clear(t),n.createObjectStore(t)}}));async function h0(r,t,e){return await r.get(t,e)}async function d0(r,t,e,n){return await r.put(t,n,e)}async function p0(r,t,e){return await r.delete(t,e)}var Qr=class r{constructor(t,e){this._db=t,this._storeName=e}static async create(t){let{dbName:e=Cc,storeName:n=$c,version:i=Lc}=t??{},s=await l0(e,n,i);return new r(s,n)}async set(t,e){return await d0(this._db,this._storeName,t,e)}async get(t){var e;return(e=await h0(this._db,this._storeName,t))!==null&&e!==void 0?e:null}async remove(t){return await p0(this._db,this._storeName,t)}};var y0=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},w0=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},oi,ue="identity",Xt="delegation",Vc="iv",Lc=1,si=typeof window<"u",tn=class{constructor(t="ic-",e){this.prefix=t,this._localStorage=e}get(t){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+t))}set(t,e){return this._getLocalStorage().setItem(this.prefix+t,e),Promise.resolve()}remove(t){return this._getLocalStorage().removeItem(this.prefix+t),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!t)throw new Error("Could not find local storage.");return t}},Je=class{constructor(t){oi.set(this,void 0),y0(this,oi,t??{},"f")}get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}Qr.create(w0(this,oi,"f")).then(e=>{this.initializedDb=e,t(e)})})}async get(t){return await(await this._db).get(t)}async set(t,e){await(await this._db).set(t,e)}async remove(t){await(await this._db).remove(t)}};oi=new WeakMap;var g0="https://identity.ic0.app",m0="#authorize",Js="ECDSA",Zs="Ed25519",x0=500,_0="UserInterrupt",ai=class{constructor(t,e,n,i,s,o,c,u){this._identity=t,this._key=e,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=c,this._eventHandler=u,this._registerDefaultIdleCallback()}static async create(t={}){var e,n,i;let s=(e=t.storage)!==null&&e!==void 0?e:new Je,o=(n=t.keyType)!==null&&n!==void 0?n:Js,c=null;if(t.identity)c=t.identity;else{let _=await s.get(ue);if(!_&&si)try{let N=new tn,L=await N.get(Xt),P=await N.get(ue);L&&P&&o===Js&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Xt,L),await s.set(ue,P),_=L,await N.remove(Xt),await N.remove(ue))}catch(N){console.error("error while attempting to recover localstorage: "+N)}if(_)try{typeof _=="object"?o===Zs&&typeof _=="string"?c=await Ye.fromJSON(_):c=await zr.fromKeyPair(_):typeof _=="string"&&(c=Ye.fromJSON(_))}catch{}}let u=new wr,w=null;if(c)try{let _=await s.get(Xt);if(typeof _=="object"&&_!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?u=t.identity:_&&(w=Xe.fromJSON(_),ni(w)?"toDer"in c?u=Jr.fromDelegation(c,w):u=Xr.fromDelegation(c,w):(await Qs(s),c=null))}catch(_){console.error(_),await Qs(s),c=null}let y;return!((i=t.idleOptions)===null||i===void 0)&&i.disableIdle?y=void 0:(w||t.identity)&&(y=Zr.create(t.idleOptions)),c||(o===Zs?(c=await Ye.generate(),await s.set(ue,JSON.stringify(c.toJSON()))):(t.storage&&o===Js&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${Zs}' as the key type, as it can serialize to a string`),c=await zr.generate(),await s.set(ue,c.getKeyPair()))),new this(u,c,w,s,y,t)}_registerDefaultIdleCallback(){var t,e;let n=(t=this._createOptions)===null||t===void 0?void 0:t.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((e=this.idleManager)===null||e===void 0||e.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(t,e){var n,i;let s=t.delegations.map(w=>({delegation:new Tr(w.delegation.pubkey,w.delegation.expiration,w.delegation.targets),signature:w.signature.buffer})),o=Xe.fromDelegations(s,t.userPublicKey.buffer),c=this._key;if(!c)return;this._chain=o,"toDer"in c?this._identity=Jr.fromDelegation(c,this._chain):this._identity=Xr.fromDelegation(c,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let u=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!u?.disableIdle&&(this.idleManager=Zr.create(u),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Xt,JSON.stringify(this._chain.toJSON())),e?.(t)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(t){var e,n,i,s;let o=BigInt(8)*BigInt(36e11),c=new URL(((e=t?.identityProvider)===null||e===void 0?void 0:e.toString())||g0);c.hash=m0,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(c,Object.assign({maxTimeToLive:(i=t?.maxTimeToLive)!==null&&i!==void 0?i:o},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(c.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let u=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(_0,t?.onError):setTimeout(u,x0))};u()}_getEventHandler(t,e){return async n=>{var i,s,o;if(n.origin!==t.origin){console.warn(`WARNING: expected origin '${t.origin}', got '${n.origin}' (ignoring)`);return}let c=n.data;switch(c.kind){case"authorize-ready":{let u=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:e?.maxTimeToLive,allowPinAuthentication:e?.allowPinAuthentication,derivationOrigin:(s=e?.derivationOrigin)===null||s===void 0?void 0:s.toString()},e?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(u,t.origin);break}case"authorize-client-success":try{await this._handleSuccess(c,e?.onSuccess)}catch(u){this._handleFailure(u.message,e?.onError)}break;case"authorize-client-failure":this._handleFailure(c.text,e?.onError);break;default:break}}}_handleFailure(t,e){var n;(n=this._idpWindow)===null||n===void 0||n.close(),e?.(t),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(t={}){if(await Qs(this._storage),this._identity=new wr,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};async function Qs(r){await r.remove(ue),await r.remove(Xt),await r.remove(Vc)}var Gg=BigInt(144e11);var qc=1e3;var Hc=()=>ai.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});onmessage=({data:r})=>{let{msg:t}=r;switch(t){case"junoStartAuthTimer":b0();return;case"junoStopAuthTimer":Gc();return}};var ci,b0=()=>ci=setInterval(async()=>await E0(),qc),Gc=()=>{ci&&(clearInterval(ci),ci=void 0)},E0=async()=>{let[r,t]=await Promise.all([A0(),v0()]);if(r&&t.valid&&t.delegation!==null){B0(t.delegation);return}T0()},A0=async()=>(await Hc()).isAuthenticated(),v0=async()=>{let t=await new Je().get(Xt),e=t!==null?Xe.fromJSON(t):null;return{valid:e!==null&&ni(e),delegation:e}},T0=()=>{Gc(),postMessage({msg:"junoSignOutAuthTimer"})},B0=r=>{let t=r.delegations[0]?.delegation.expiration;if(t===void 0)return;let e=new Date(Number(t/BigInt(1e6))).getTime()-Date.now();postMessage({msg:"junoDelegationRemainingTime",data:{authRemainingTime:e}})};})();
18
+ `)}}function Fc(r,t){let e=r;return()=>new Promise(n=>setTimeout(()=>{e*=t,n()},e))}function Oc(...r){return async(t,e,n)=>{for(let i of r)await i(t,e,n)}}te();Xt();var Gw=Symbol.for("ic-agent-metadata");var Kw={pollingStrategyFactory:Qn.defaultStrategy};jr();te();Vn();Vr();Gs();Xt();Vn();Hr();var ri=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Me=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ti,ei,Er,Ar;function Pc(r){return r!==null&&typeof r=="object"}var We=class r{constructor(t){if(ti.set(this,void 0),ei.set(this,void 0),t.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");ri(this,ti,t,"f"),ri(this,ei,r.derEncode(t),"f")}static from(t){if(typeof t=="string"){let e=Gt(t);return this.fromRaw(e)}else if(Pc(t)){let e=t;if(Pc(e)&&Object.hasOwnProperty.call(e,"__derEncodedPublicKey__"))return this.fromDer(e);if(ArrayBuffer.isView(e)){let n=e;return this.fromRaw(Tn(n.buffer))}else{if(e instanceof ArrayBuffer)return this.fromRaw(e);if("rawKey"in e)return this.fromRaw(e.rawKey);if("derKey"in e)return this.fromDer(e.derKey);if("toDer"in e)return this.fromDer(e.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(t){return new r(t)}static fromDer(t){return new r(this.derDecode(t))}static derEncode(t){let e=_r(t,je).buffer;return e.__derEncodedPublicKey__=void 0,e}static derDecode(t){let e=Wr(t,je);if(e.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return e}get rawKey(){return Me(this,ti,"f")}get derKey(){return Me(this,ei,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};ti=new WeakMap,ei=new WeakMap;We.RAW_KEY_LENGTH=32;var ze=class r extends be{constructor(t,e){super(),Er.set(this,void 0),Ar.set(this,void 0),ri(this,Er,We.from(t),"f"),ri(this,Ar,new Uint8Array(e),"f")}static generate(t){if(t&&t.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");t||(t=xr.utils.randomPrivateKey()),$r(t,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let e=new Uint8Array(32);for(let i=0;i<32;i++)e[i]=new Uint8Array(t)[i];let n=xr.getPublicKey(e);return r.fromKeyPair(n,e)}static fromParsedJson(t){let[e,n]=t;return new r(We.fromDer(Gt(e)),Gt(n))}static fromJSON(t){let e=JSON.parse(t);if(Array.isArray(e)){if(typeof e[0]=="string"&&typeof e[1]=="string")return this.fromParsedJson([e[0],e[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(t)}`)}static fromKeyPair(t,e){return new r(We.fromRaw(t),e)}static fromSecretKey(t){let e=xr.getPublicKey(new Uint8Array(t));return r.fromKeyPair(e,t)}toJSON(){return[Nt(Me(this,Er,"f").toDer()),Nt(Me(this,Ar,"f"))]}getKeyPair(){return{secretKey:Me(this,Ar,"f"),publicKey:Me(this,Er,"f")}}getPublicKey(){return Me(this,Er,"f")}async sign(t){let e=new Uint8Array(t),n=He(xr.sign(e,Me(this,Ar,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(t,e,n){let[i,s,o]=[t,e,n].map(c=>(typeof c=="string"&&(c=Gt(c)),c instanceof Uint8Array&&(c=c.buffer),new Uint8Array(c)));return xr.verify(s,i,o)}};Er=new WeakMap,Ar=new WeakMap;var Ys=class r extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,r.prototype)}};function kc(r){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(r)return r;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new Ys("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var Yr=class r extends be{constructor(t,e,n){super(),this._keyPair=t,this._derKey=e,this._subtleCrypto=n}static async generate(t){let{extractable:e=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=t??{},s=kc(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},e,n),c=await s.exportKey("spki",o.publicKey);return new this(o,c,s)}static async fromKeyPair(t,e){let n=kc(e),i=await n.exportKey("spki",t.publicKey);return new r(t,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let t=this._derKey,e=Object.create(this._keyPair.publicKey);return e.toDer=function(){return t},e}async sign(t){let e={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(e,this._keyPair.privateKey,t)}};te();var vr=Te(qr());te();var u0=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Xr=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Ce,ni=class{constructor(t){Ce.set(this,void 0),u0(this,Ce,t,"f")}get rawKey(){return Xr(this,Ce,"f").rawKey}get derKey(){return Xr(this,Ce,"f").derKey}toDer(){return Xr(this,Ce,"f").toDer()}getPublicKey(){return Xr(this,Ce,"f")}getPrincipal(){return It.from(Xr(this,Ce,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};Ce=new WeakMap;var f0=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},l0=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},h0=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e},ii,d0=new TextEncoder().encode("ic-request-auth-delegation"),p0=new TextEncoder().encode(`
19
+ ic-request`);function Xs(r){if(typeof r!="string"||r.length<64)throw new Error("Invalid public key.");return Gt(r)}var Tr=class{constructor(t,e,n){this.pubkey=t,this.expiration=e,this.targets=n}toCBOR(){return vr.value.map(Object.assign({pubkey:vr.value.bytes(this.pubkey),expiration:vr.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:vr.value.array(this.targets.map(t=>vr.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:Nt(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};async function y0(r,t,e,n){let i=new Tr(t.toDer(),BigInt(+e)*BigInt(1e6),n),s=new Uint8Array([...d0,...new Uint8Array(pr(i))]),o=await r.sign(s);return{delegation:i,signature:o}}var Ye=class r{constructor(t,e){this.delegations=t,this.publicKey=e}static async create(t,e,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let c=await y0(t,e,n,i.targets);return new r([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],c],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||t.getPublicKey().toDer())}static fromJSON(t){let{publicKey:e,delegations:n}=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:c}=s,{pubkey:u,expiration:w,targets:y}=o;if(y!==void 0&&!Array.isArray(y))throw new Error("Invalid targets.");return{delegation:new Tr(Xs(u),BigInt("0x"+w),y&&y.map(m=>{if(typeof m!="string")throw new Error("Invalid target.");return It.fromHex(m)})),signature:Xs(c)}});return new this(i,Xs(e))}static fromDelegations(t,e){return new this(t,e)}toJSON(){return{delegations:this.delegations.map(t=>{let{delegation:e,signature:n}=t,{targets:i}=e;return{delegation:Object.assign({expiration:e.expiration.toString(16),pubkey:Nt(e.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:Nt(n)}}),publicKey:Nt(this.publicKey)}}},Jr=class extends be{constructor(t,e){super(),this._inner=t,this._delegation=e}static fromDelegation(t,e){return new this(t,e)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(t){return this._inner.sign(t)}async transformRequest(t){let{body:e}=t,n=h0(t,["body"]),i=await pr(e);return Object.assign(Object.assign({},n),{body:{content:e,sender_sig:await this.sign(new Uint8Array([...p0,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},Zr=class r extends ni{constructor(t,e){super(t),ii.set(this,void 0),f0(this,ii,e,"f")}get delegation(){return l0(this,ii,"f")}static fromDelegation(t,e){return new r(t,e)}};ii=new WeakMap;function si(r,t){for(let{delegation:i}of r.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let e=[],n=t?.scope;n&&(Array.isArray(n)?e.push(...n.map(i=>typeof i=="string"?It.fromText(i):i)):e.push(typeof n=="string"?It.fromText(n):n));for(let i of e){let s=i.toText();for(let{delegation:o}of r.delegations){if(o.targets===void 0)continue;let c=!0;for(let u of o.targets)if(u.toText()===s){c=!1;break}if(c)return!1}}return!0}var w0=Te(vn());ur();var Mc;(function(r){r[r.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Mc||(Mc={}));var Cc=["mousedown","mousemove","keydown","touchstart","wheel"],Qr=class{constructor(t={}){var e;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=t||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),Cc.forEach(function(c){document.addEventListener(c,s,!0)});let o=(c,u)=>{let w;return(...y)=>{let m=this,N=function(){w=void 0,c.apply(m,y)};clearTimeout(w),w=window.setTimeout(N,u)}};if(t?.captureScroll){let c=o(s,(e=t?.scrollDebounce)!==null&&e!==void 0?e:100);window.addEventListener("scroll",c,!0)}s()}static create(t={}){return new this(t)}registerCallback(t){this.callbacks.push(t)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let t=this._resetTimer.bind(this);Cc.forEach(function(e){document.removeEventListener(e,t,!0)}),this.callbacks.forEach(e=>e())}_resetTimer(){let t=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(t,this.idleTimeout)}};var g0=(r,t)=>t.some(e=>r instanceof e),$c,Vc;function m0(){return $c||($c=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function x0(){return Vc||(Vc=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Lc=new WeakMap,Zs=new WeakMap,qc=new WeakMap,Js=new WeakMap,to=new WeakMap;function _0(r){let t=new Promise((e,n)=>{let i=()=>{r.removeEventListener("success",s),r.removeEventListener("error",o)},s=()=>{e(me(r.result)),i()},o=()=>{n(r.error),i()};r.addEventListener("success",s),r.addEventListener("error",o)});return t.then(e=>{e instanceof IDBCursor&&Lc.set(e,r)}).catch(()=>{}),to.set(t,r),t}function b0(r){if(Zs.has(r))return;let t=new Promise((e,n)=>{let i=()=>{r.removeEventListener("complete",s),r.removeEventListener("error",o),r.removeEventListener("abort",o)},s=()=>{e(),i()},o=()=>{n(r.error||new DOMException("AbortError","AbortError")),i()};r.addEventListener("complete",s),r.addEventListener("error",o),r.addEventListener("abort",o)});Zs.set(r,t)}var Qs={get(r,t,e){if(r instanceof IDBTransaction){if(t==="done")return Zs.get(r);if(t==="objectStoreNames")return r.objectStoreNames||qc.get(r);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return me(r[t])},set(r,t,e){return r[t]=e,!0},has(r,t){return r instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in r}};function Hc(r){Qs=r(Qs)}function E0(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...e){let n=r.call(oi(this),t,...e);return qc.set(n,t.sort?t.sort():[t]),me(n)}:x0().includes(r)?function(...t){return r.apply(oi(this),t),me(Lc.get(this))}:function(...t){return me(r.apply(oi(this),t))}}function A0(r){return typeof r=="function"?E0(r):(r instanceof IDBTransaction&&b0(r),g0(r,m0())?new Proxy(r,Qs):r)}function me(r){if(r instanceof IDBRequest)return _0(r);if(Js.has(r))return Js.get(r);let t=A0(r);return t!==r&&(Js.set(r,t),to.set(t,r)),t}var oi=r=>to.get(r);function Kc(r,t,{blocked:e,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(r,t),c=me(o);return n&&o.addEventListener("upgradeneeded",u=>{n(me(o.result),u.oldVersion,u.newVersion,me(o.transaction),u)}),e&&o.addEventListener("blocked",u=>e(u.oldVersion,u.newVersion,u)),c.then(u=>{s&&u.addEventListener("close",()=>s()),i&&u.addEventListener("versionchange",w=>i(w.oldVersion,w.newVersion,w))}).catch(()=>{}),c}var v0=["get","getKey","getAll","getAllKeys","count"],T0=["put","add","delete","clear"],eo=new Map;function Gc(r,t){if(!(r instanceof IDBDatabase&&!(t in r)&&typeof t=="string"))return;if(eo.get(t))return eo.get(t);let e=t.replace(/FromIndex$/,""),n=t!==e,i=T0.includes(e);if(!(e in(n?IDBIndex:IDBObjectStore).prototype)||!(i||v0.includes(e)))return;let s=async function(o,...c){let u=this.transaction(o,i?"readwrite":"readonly"),w=u.store;return n&&(w=w.index(c.shift())),(await Promise.all([w[e](...c),i&&u.done]))[0]};return eo.set(t,s),s}Hc(r=>({...r,get:(t,e,n)=>Gc(t,e)||r.get(t,e,n),has:(t,e)=>!!Gc(t,e)||r.has(t,e)}));var Dc="auth-client-db",jc="ic-keyval",S0=async(r=Dc,t=jc,e)=>(ai&&(localStorage!=null&&localStorage.getItem(Jt))&&(localStorage.removeItem(Jt),localStorage.removeItem(ue)),await Kc(r,e,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(t)&&n.clear(t),n.createObjectStore(t)}}));async function B0(r,t,e){return await r.get(t,e)}async function I0(r,t,e,n){return await r.put(t,n,e)}async function N0(r,t,e){return await r.delete(t,e)}var tn=class r{constructor(t,e){this._db=t,this._storeName=e}static async create(t){let{dbName:e=Dc,storeName:n=jc,version:i=Wc}=t??{},s=await S0(e,n,i);return new r(s,n)}async set(t,e){return await I0(this._db,this._storeName,t,e)}async get(t){var e;return(e=await B0(this._db,this._storeName,t))!==null&&e!==void 0?e:null}async remove(t){return await N0(this._db,this._storeName,t)}};var U0=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},R0=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ci,ue="identity",Jt="delegation",zc="iv",Wc=1,ai=typeof window<"u",en=class{constructor(t="ic-",e){this.prefix=t,this._localStorage=e}get(t){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+t))}set(t,e){return this._getLocalStorage().setItem(this.prefix+t,e),Promise.resolve()}remove(t){return this._getLocalStorage().removeItem(this.prefix+t),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!t)throw new Error("Could not find local storage.");return t}},Xe=class{constructor(t){ci.set(this,void 0),U0(this,ci,t??{},"f")}get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}tn.create(R0(this,ci,"f")).then(e=>{this.initializedDb=e,t(e)})})}async get(t){return await(await this._db).get(t)}async set(t,e){await(await this._db).set(t,e)}async remove(t){await(await this._db).remove(t)}};ci=new WeakMap;var F0="https://identity.ic0.app",O0="#authorize",ro="ECDSA",no="Ed25519",P0=500,k0="UserInterrupt",ui=class{constructor(t,e,n,i,s,o,c,u){this._identity=t,this._key=e,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=c,this._eventHandler=u,this._registerDefaultIdleCallback()}static async create(t={}){var e,n,i;let s=(e=t.storage)!==null&&e!==void 0?e:new Xe,o=(n=t.keyType)!==null&&n!==void 0?n:ro,c=null;if(t.identity)c=t.identity;else{let m=await s.get(ue);if(!m&&ai)try{let N=new en,M=await N.get(Jt),O=await N.get(ue);M&&O&&o===ro&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Jt,M),await s.set(ue,O),m=M,await N.remove(Jt),await N.remove(ue))}catch(N){console.error("error while attempting to recover localstorage: "+N)}if(m)try{typeof m=="object"?o===no&&typeof m=="string"?c=await ze.fromJSON(m):c=await Yr.fromKeyPair(m):typeof m=="string"&&(c=ze.fromJSON(m))}catch{}}let u=new yr,w=null;if(c)try{let m=await s.get(Jt);if(typeof m=="object"&&m!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?u=t.identity:m&&(w=Ye.fromJSON(m),si(w)?"toDer"in c?u=Zr.fromDelegation(c,w):u=Jr.fromDelegation(c,w):(await io(s),c=null))}catch(m){console.error(m),await io(s),c=null}let y;return!((i=t.idleOptions)===null||i===void 0)&&i.disableIdle?y=void 0:(w||t.identity)&&(y=Qr.create(t.idleOptions)),c||(o===no?(c=await ze.generate(),await s.set(ue,JSON.stringify(c.toJSON()))):(t.storage&&o===ro&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${no}' as the key type, as it can serialize to a string`),c=await Yr.generate(),await s.set(ue,c.getKeyPair()))),new this(u,c,w,s,y,t)}_registerDefaultIdleCallback(){var t,e;let n=(t=this._createOptions)===null||t===void 0?void 0:t.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((e=this.idleManager)===null||e===void 0||e.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(t,e){var n,i;let s=t.delegations.map(w=>({delegation:new Tr(w.delegation.pubkey,w.delegation.expiration,w.delegation.targets),signature:w.signature.buffer})),o=Ye.fromDelegations(s,t.userPublicKey.buffer),c=this._key;if(!c)return;this._chain=o,"toDer"in c?this._identity=Zr.fromDelegation(c,this._chain):this._identity=Jr.fromDelegation(c,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let u=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!u?.disableIdle&&(this.idleManager=Qr.create(u),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Jt,JSON.stringify(this._chain.toJSON())),e?.(t)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(t){var e,n,i,s;let o=BigInt(8)*BigInt(36e11),c=new URL(((e=t?.identityProvider)===null||e===void 0?void 0:e.toString())||F0);c.hash=O0,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(c,Object.assign({maxTimeToLive:(i=t?.maxTimeToLive)!==null&&i!==void 0?i:o},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(c.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let u=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(k0,t?.onError):setTimeout(u,P0))};u()}_getEventHandler(t,e){return async n=>{var i,s,o;if(n.origin!==t.origin){console.warn(`WARNING: expected origin '${t.origin}', got '${n.origin}' (ignoring)`);return}let c=n.data;switch(c.kind){case"authorize-ready":{let u=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:e?.maxTimeToLive,allowPinAuthentication:e?.allowPinAuthentication,derivationOrigin:(s=e?.derivationOrigin)===null||s===void 0?void 0:s.toString()},e?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(u,t.origin);break}case"authorize-client-success":try{await this._handleSuccess(c,e?.onSuccess)}catch(u){this._handleFailure(u.message,e?.onError)}break;case"authorize-client-failure":this._handleFailure(c.text,e?.onError);break;default:break}}}_handleFailure(t,e){var n;(n=this._idpWindow)===null||n===void 0||n.close(),e?.(t),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(t={}){if(await io(this._storage),this._identity=new yr,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};async function io(r){await r.remove(ue),await r.remove(Jt),await r.remove(zc)}var im=BigInt(144e11);var Yc=1e3;var Xc=()=>ui.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});onmessage=({data:r})=>{let{msg:t}=r;switch(t){case"junoStartAuthTimer":M0();return;case"junoStopAuthTimer":Jc();return}};var fi,M0=()=>fi=setInterval(async()=>await C0(),Yc),Jc=()=>{fi&&(clearInterval(fi),fi=void 0)},C0=async()=>{let[r,t]=await Promise.all([$0(),V0()]);if(r&&t.valid&&t.delegation!==null){q0(t.delegation);return}L0()},$0=async()=>(await Xc()).isAuthenticated(),V0=async()=>{let t=await new Xe().get(Jt),e=t!==null?Ye.fromJSON(t):null;return{valid:e!==null&&si(e),delegation:e}},L0=()=>{Jc(),postMessage({msg:"junoSignOutAuthTimer"})},q0=r=>{let t=r.delegations[0]?.delegation.expiration;if(t===void 0)return;let e=new Date(Number(t/BigInt(1e6))).getTime()-Date.now();postMessage({msg:"junoDelegationRemainingTime",data:{authRemainingTime:e}})};})();
20
20
  /*! Bundled license information:
21
21
 
22
22
  ieee754/index.js: