@coinflowlabs/vue 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,28 +1,28 @@
1
- (function(le,Ct){typeof exports=="object"&&typeof module<"u"?Ct(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],Ct):(le=typeof globalThis<"u"?globalThis:le||self,Ct(le.VueTypeWriter={},le.Vue))})(this,function(le,Ct){"use strict";var Td=Object.defineProperty;var Md=(le,Ct,mn)=>Ct in le?Td(le,Ct,{enumerable:!0,configurable:!0,writable:!0,value:mn}):le[Ct]=mn;var ir=(le,Ct,mn)=>Md(le,typeof Ct!="symbol"?Ct+"":Ct,mn);var mn=(o=>(o.Credits="Credits",o.USDC="USDC",o.Bank="Bank",o))(mn||{}),As=(o=>(o.Rounded="rounded",o.Sharp="sharp",o.Pill="pill",o))(As||{}),Rs=(o=>(o.NoPreference="NoPreference",o.Frictionless="Frictionless",o.Challenge="Challenge",o))(Rs||{}),Fn=(o=>(o.VISA="VISA",o.MASTERCARD="MSTR",o.AMEX="AMEX",o.DISCOVER="DISC",o))(Fn||{}),Or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ii(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function uo(o){if(o.__esModule)return o;var t=o.default;if(typeof t=="function"){var e=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(o).forEach(function(n){var a=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(e,n,a.get?a:{enumerable:!0,get:function(){return o[n]}})}),e}var Nt={},On={};On.byteLength=nu,On.toByteArray=ou,On.fromByteArray=cu;for(var Wr=[],Ur=[],eu=typeof Uint8Array<"u"?Uint8Array:Array,fo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Nn=0,ru=fo.length;Nn<ru;++Nn)Wr[Nn]=fo[Nn],Ur[fo.charCodeAt(Nn)]=Nn;Ur[45]=62,Ur[95]=63;function Ts(o){var t=o.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=o.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function nu(o){var t=Ts(o),e=t[0],n=t[1];return(e+n)*3/4-n}function iu(o,t,e){return(t+e)*3/4-e}function ou(o){var t,e=Ts(o),n=e[0],a=e[1],s=new eu(iu(o,n,a)),f=0,u=a>0?n-4:n,y;for(y=0;y<u;y+=4)t=Ur[o.charCodeAt(y)]<<18|Ur[o.charCodeAt(y+1)]<<12|Ur[o.charCodeAt(y+2)]<<6|Ur[o.charCodeAt(y+3)],s[f++]=t>>16&255,s[f++]=t>>8&255,s[f++]=t&255;return a===2&&(t=Ur[o.charCodeAt(y)]<<2|Ur[o.charCodeAt(y+1)]>>4,s[f++]=t&255),a===1&&(t=Ur[o.charCodeAt(y)]<<10|Ur[o.charCodeAt(y+1)]<<4|Ur[o.charCodeAt(y+2)]>>2,s[f++]=t>>8&255,s[f++]=t&255),s}function su(o){return Wr[o>>18&63]+Wr[o>>12&63]+Wr[o>>6&63]+Wr[o&63]}function au(o,t,e){for(var n,a=[],s=t;s<e;s+=3)n=(o[s]<<16&16711680)+(o[s+1]<<8&65280)+(o[s+2]&255),a.push(su(n));return a.join("")}function cu(o){for(var t,e=o.length,n=e%3,a=[],s=16383,f=0,u=e-n;f<u;f+=s)a.push(au(o,f,f+s>u?u:f+s));return n===1?(t=o[e-1],a.push(Wr[t>>2]+Wr[t<<4&63]+"==")):n===2&&(t=(o[e-2]<<8)+o[e-1],a.push(Wr[t>>10]+Wr[t>>4&63]+Wr[t<<2&63]+"=")),a.join("")}var oi={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */oi.read=function(o,t,e,n,a){var s,f,u=a*8-n-1,y=(1<<u)-1,x=y>>1,v=-7,_=e?a-1:0,F=e?-1:1,L=o[t+_];for(_+=F,s=L&(1<<-v)-1,L>>=-v,v+=u;v>0;s=s*256+o[t+_],_+=F,v-=8);for(f=s&(1<<-v)-1,s>>=-v,v+=n;v>0;f=f*256+o[t+_],_+=F,v-=8);if(s===0)s=1-x;else{if(s===y)return f?NaN:(L?-1:1)*(1/0);f=f+Math.pow(2,n),s=s-x}return(L?-1:1)*f*Math.pow(2,s-n)},oi.write=function(o,t,e,n,a,s){var f,u,y,x=s*8-a-1,v=(1<<x)-1,_=v>>1,F=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,L=n?0:s-1,D=n?1:-1,C=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,f=v):(f=Math.floor(Math.log(t)/Math.LN2),t*(y=Math.pow(2,-f))<1&&(f--,y*=2),f+_>=1?t+=F/y:t+=F*Math.pow(2,1-_),t*y>=2&&(f++,y/=2),f+_>=v?(u=0,f=v):f+_>=1?(u=(t*y-1)*Math.pow(2,a),f=f+_):(u=t*Math.pow(2,_-1)*Math.pow(2,a),f=0));a>=8;o[e+L]=u&255,L+=D,u/=256,a-=8);for(f=f<<a|u,x+=a;x>0;o[e+L]=f&255,L+=D,f/=256,x-=8);o[e+L-D]|=C*128};/*!
1
+ (function(le,pt){typeof exports=="object"&&typeof module<"u"?pt(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],pt):(le=typeof globalThis<"u"?globalThis:le||self,pt(le.VueTypeWriter={},le.Vue))})(this,function(le,pt){"use strict";var qd=Object.defineProperty;var Hd=(le,pt,wn)=>pt in le?qd(le,pt,{enumerable:!0,configurable:!0,writable:!0,value:wn}):le[pt]=wn;var ir=(le,pt,wn)=>Hd(le,typeof pt!="symbol"?pt+"":pt,wn);var wn=(o=>(o.Credits="Credits",o.USDC="USDC",o.Bank="Bank",o))(wn||{}),As=(o=>(o.Rounded="rounded",o.Sharp="sharp",o.Pill="pill",o))(As||{}),Rs=(o=>(o.NoPreference="NoPreference",o.Frictionless="Frictionless",o.Challenge="Challenge",o))(Rs||{}),Fn=(o=>(o.VISA="VISA",o.MASTERCARD="MSTR",o.AMEX="AMEX",o.DISCOVER="DISC",o))(Fn||{}),Or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ii(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function fo(o){if(o.__esModule)return o;var t=o.default;if(typeof t=="function"){var e=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(o).forEach(function(n){var a=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(e,n,a.get?a:{enumerable:!0,get:function(){return o[n]}})}),e}var Nt={},On={};On.byteLength=nu,On.toByteArray=ou,On.fromByteArray=cu;for(var qr=[],Pr=[],eu=typeof Uint8Array<"u"?Uint8Array:Array,ho="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Nn=0,ru=ho.length;Nn<ru;++Nn)qr[Nn]=ho[Nn],Pr[ho.charCodeAt(Nn)]=Nn;Pr[45]=62,Pr[95]=63;function Ts(o){var t=o.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=o.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function nu(o){var t=Ts(o),e=t[0],n=t[1];return(e+n)*3/4-n}function iu(o,t,e){return(t+e)*3/4-e}function ou(o){var t,e=Ts(o),n=e[0],a=e[1],s=new eu(iu(o,n,a)),f=0,u=a>0?n-4:n,y;for(y=0;y<u;y+=4)t=Pr[o.charCodeAt(y)]<<18|Pr[o.charCodeAt(y+1)]<<12|Pr[o.charCodeAt(y+2)]<<6|Pr[o.charCodeAt(y+3)],s[f++]=t>>16&255,s[f++]=t>>8&255,s[f++]=t&255;return a===2&&(t=Pr[o.charCodeAt(y)]<<2|Pr[o.charCodeAt(y+1)]>>4,s[f++]=t&255),a===1&&(t=Pr[o.charCodeAt(y)]<<10|Pr[o.charCodeAt(y+1)]<<4|Pr[o.charCodeAt(y+2)]>>2,s[f++]=t>>8&255,s[f++]=t&255),s}function su(o){return qr[o>>18&63]+qr[o>>12&63]+qr[o>>6&63]+qr[o&63]}function au(o,t,e){for(var n,a=[],s=t;s<e;s+=3)n=(o[s]<<16&16711680)+(o[s+1]<<8&65280)+(o[s+2]&255),a.push(su(n));return a.join("")}function cu(o){for(var t,e=o.length,n=e%3,a=[],s=16383,f=0,u=e-n;f<u;f+=s)a.push(au(o,f,f+s>u?u:f+s));return n===1?(t=o[e-1],a.push(qr[t>>2]+qr[t<<4&63]+"==")):n===2&&(t=(o[e-2]<<8)+o[e-1],a.push(qr[t>>10]+qr[t>>4&63]+qr[t<<2&63]+"=")),a.join("")}var oi={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */oi.read=function(o,t,e,n,a){var s,f,u=a*8-n-1,y=(1<<u)-1,x=y>>1,B=-7,v=e?a-1:0,F=e?-1:1,L=o[t+v];for(v+=F,s=L&(1<<-B)-1,L>>=-B,B+=u;B>0;s=s*256+o[t+v],v+=F,B-=8);for(f=s&(1<<-B)-1,s>>=-B,B+=n;B>0;f=f*256+o[t+v],v+=F,B-=8);if(s===0)s=1-x;else{if(s===y)return f?NaN:(L?-1:1)*(1/0);f=f+Math.pow(2,n),s=s-x}return(L?-1:1)*f*Math.pow(2,s-n)},oi.write=function(o,t,e,n,a,s){var f,u,y,x=s*8-a-1,B=(1<<x)-1,v=B>>1,F=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,L=n?0:s-1,D=n?1:-1,U=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,f=B):(f=Math.floor(Math.log(t)/Math.LN2),t*(y=Math.pow(2,-f))<1&&(f--,y*=2),f+v>=1?t+=F/y:t+=F*Math.pow(2,1-v),t*y>=2&&(f++,y/=2),f+v>=B?(u=0,f=B):f+v>=1?(u=(t*y-1)*Math.pow(2,a),f=f+v):(u=t*Math.pow(2,v-1)*Math.pow(2,a),f=0));a>=8;o[e+L]=u&255,L+=D,u/=256,a-=8);for(f=f<<a|u,x+=a;x>0;o[e+L]=f&255,L+=D,f/=256,x-=8);o[e+L-D]|=U*128};/*!
2
2
  * The buffer module from node.js, for the browser.
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
5
5
  * @license MIT
6
- */(function(o){const t=On,e=oi,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;o.Buffer=u,o.SlowBuffer=X,o.INSPECT_MAX_BYTES=50;const a=2147483647;o.kMaxLength=a,u.TYPED_ARRAY_SUPPORT=s(),!u.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 s(){try{const c=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(c,r),c.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function f(c){if(c>a)throw new RangeError('The value "'+c+'" is invalid for option "size"');const r=new Uint8Array(c);return Object.setPrototypeOf(r,u.prototype),r}function u(c,r,i){if(typeof c=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _(c)}return y(c,r,i)}u.poolSize=8192;function y(c,r,i){if(typeof c=="string")return F(c,r);if(ArrayBuffer.isView(c))return D(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(Qt(c,ArrayBuffer)||c&&Qt(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Qt(c,SharedArrayBuffer)||c&&Qt(c.buffer,SharedArrayBuffer)))return C(c,r,i);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const h=c.valueOf&&c.valueOf();if(h!=null&&h!==c)return u.from(h,r,i);const g=z(c);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return u.from(c[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}u.from=function(c,r,i){return y(c,r,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function x(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function v(c,r,i){return x(c),c<=0?f(c):r!==void 0?typeof i=="string"?f(c).fill(r,i):f(c).fill(r):f(c)}u.alloc=function(c,r,i){return v(c,r,i)};function _(c){return x(c),f(c<0?0:$(c)|0)}u.allocUnsafe=function(c){return _(c)},u.allocUnsafeSlow=function(c){return _(c)};function F(c,r){if((typeof r!="string"||r==="")&&(r="utf8"),!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const i=j(c,r)|0;let h=f(i);const g=h.write(c,r);return g!==i&&(h=h.slice(0,g)),h}function L(c){const r=c.length<0?0:$(c.length)|0,i=f(r);for(let h=0;h<r;h+=1)i[h]=c[h]&255;return i}function D(c){if(Qt(c,Uint8Array)){const r=new Uint8Array(c);return C(r.buffer,r.byteOffset,r.byteLength)}return L(c)}function C(c,r,i){if(r<0||c.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let h;return r===void 0&&i===void 0?h=new Uint8Array(c):i===void 0?h=new Uint8Array(c,r):h=new Uint8Array(c,r,i),Object.setPrototypeOf(h,u.prototype),h}function z(c){if(u.isBuffer(c)){const r=$(c.length)|0,i=f(r);return i.length===0||c.copy(i,0,0,r),i}if(c.length!==void 0)return typeof c.length!="number"||fe(c.length)?f(0):L(c);if(c.type==="Buffer"&&Array.isArray(c.data))return L(c.data)}function $(c){if(c>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return c|0}function X(c){return+c!=c&&(c=0),u.alloc(+c)}u.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==u.prototype},u.compare=function(r,i){if(Qt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),Qt(i,Uint8Array)&&(i=u.from(i,i.offset,i.byteLength)),!u.isBuffer(r)||!u.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let h=r.length,g=i.length;for(let b=0,S=Math.min(h,g);b<S;++b)if(r[b]!==i[b]){h=r[b],g=i[b];break}return h<g?-1:g<h?1:0},u.isEncoding=function(r){switch(String(r).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}},u.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);let h;if(i===void 0)for(i=0,h=0;h<r.length;++h)i+=r[h].length;const g=u.allocUnsafe(i);let b=0;for(h=0;h<r.length;++h){let S=r[h];if(Qt(S,Uint8Array))b+S.length>g.length?(u.isBuffer(S)||(S=u.from(S)),S.copy(g,b)):Uint8Array.prototype.set.call(g,S,b);else if(u.isBuffer(S))S.copy(g,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=S.length}return g};function j(c,r){if(u.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||Qt(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const i=c.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&i===0)return 0;let g=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return de(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return we(c).length;default:if(g)return h?-1:de(c).length;r=(""+r).toLowerCase(),g=!0}}u.byteLength=j;function it(c,r,i){let h=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(c||(c="utf8");;)switch(c){case"hex":return T(this,r,i);case"utf8":case"utf-8":return d(this,r,i);case"ascii":return P(this,r,i);case"latin1":case"binary":return R(this,r,i);case"base64":return U(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,r,i);default:if(h)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),h=!0}}u.prototype._isBuffer=!0;function G(c,r,i){const h=c[r];c[r]=c[i],c[i]=h}u.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)G(this,i,i+1);return this},u.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)G(this,i,i+3),G(this,i+1,i+2);return this},u.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)G(this,i,i+7),G(this,i+1,i+6),G(this,i+2,i+5),G(this,i+3,i+4);return this},u.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?d(this,0,r):it.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(r){if(!u.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0},u.prototype.inspect=function(){let r="";const i=o.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(r,i,h,g,b){if(Qt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),h===void 0&&(h=r?r.length:0),g===void 0&&(g=0),b===void 0&&(b=this.length),i<0||h>r.length||g<0||b>this.length)throw new RangeError("out of range index");if(g>=b&&i>=h)return 0;if(g>=b)return-1;if(i>=h)return 1;if(i>>>=0,h>>>=0,g>>>=0,b>>>=0,this===r)return 0;let S=b-g,et=h-i;const lt=Math.min(S,et),ht=this.slice(g,b),Et=r.slice(i,h);for(let st=0;st<lt;++st)if(ht[st]!==Et[st]){S=ht[st],et=Et[st];break}return S<et?-1:et<S?1:0};function W(c,r,i,h,g){if(c.length===0)return-1;if(typeof i=="string"?(h=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,fe(i)&&(i=g?0:c.length-1),i<0&&(i=c.length+i),i>=c.length){if(g)return-1;i=c.length-1}else if(i<0)if(g)i=0;else return-1;if(typeof r=="string"&&(r=u.from(r,h)),u.isBuffer(r))return r.length===0?-1:Q(c,r,i,h,g);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?g?Uint8Array.prototype.indexOf.call(c,r,i):Uint8Array.prototype.lastIndexOf.call(c,r,i):Q(c,[r],i,h,g);throw new TypeError("val must be string, number or Buffer")}function Q(c,r,i,h,g){let b=1,S=c.length,et=r.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(c.length<2||r.length<2)return-1;b=2,S/=2,et/=2,i/=2}function lt(Et,st){return b===1?Et[st]:Et.readUInt16BE(st*b)}let ht;if(g){let Et=-1;for(ht=i;ht<S;ht++)if(lt(c,ht)===lt(r,Et===-1?0:ht-Et)){if(Et===-1&&(Et=ht),ht-Et+1===et)return Et*b}else Et!==-1&&(ht-=ht-Et),Et=-1}else for(i+et>S&&(i=S-et),ht=i;ht>=0;ht--){let Et=!0;for(let st=0;st<et;st++)if(lt(c,ht+st)!==lt(r,st)){Et=!1;break}if(Et)return ht}return-1}u.prototype.includes=function(r,i,h){return this.indexOf(r,i,h)!==-1},u.prototype.indexOf=function(r,i,h){return W(this,r,i,h,!0)},u.prototype.lastIndexOf=function(r,i,h){return W(this,r,i,h,!1)};function rt(c,r,i,h){i=Number(i)||0;const g=c.length-i;h?(h=Number(h),h>g&&(h=g)):h=g;const b=r.length;h>b/2&&(h=b/2);let S;for(S=0;S<h;++S){const et=parseInt(r.substr(S*2,2),16);if(fe(et))return S;c[i+S]=et}return S}function ae(c,r,i,h){return ce(de(r,c.length-i),c,i,h)}function Vt(c,r,i,h){return ce(Pe(r),c,i,h)}function Bt(c,r,i,h){return ce(we(r),c,i,h)}function re(c,r,i,h){return ce(hr(r,c.length-i),c,i,h)}u.prototype.write=function(r,i,h,g){if(i===void 0)g="utf8",h=this.length,i=0;else if(h===void 0&&typeof i=="string")g=i,h=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(h)?(h=h>>>0,g===void 0&&(g="utf8")):(g=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const b=this.length-i;if((h===void 0||h>b)&&(h=b),r.length>0&&(h<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let S=!1;for(;;)switch(g){case"hex":return rt(this,r,i,h);case"utf8":case"utf-8":return ae(this,r,i,h);case"ascii":case"latin1":case"binary":return Vt(this,r,i,h);case"base64":return Bt(this,r,i,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return re(this,r,i,h);default:if(S)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),S=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function U(c,r,i){return r===0&&i===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(r,i))}function d(c,r,i){i=Math.min(c.length,i);const h=[];let g=r;for(;g<i;){const b=c[g];let S=null,et=b>239?4:b>223?3:b>191?2:1;if(g+et<=i){let lt,ht,Et,st;switch(et){case 1:b<128&&(S=b);break;case 2:lt=c[g+1],(lt&192)===128&&(st=(b&31)<<6|lt&63,st>127&&(S=st));break;case 3:lt=c[g+1],ht=c[g+2],(lt&192)===128&&(ht&192)===128&&(st=(b&15)<<12|(lt&63)<<6|ht&63,st>2047&&(st<55296||st>57343)&&(S=st));break;case 4:lt=c[g+1],ht=c[g+2],Et=c[g+3],(lt&192)===128&&(ht&192)===128&&(Et&192)===128&&(st=(b&15)<<18|(lt&63)<<12|(ht&63)<<6|Et&63,st>65535&&st<1114112&&(S=st))}}S===null?(S=65533,et=1):S>65535&&(S-=65536,h.push(S>>>10&1023|55296),S=56320|S&1023),h.push(S),g+=et}return E(h)}const w=4096;function E(c){const r=c.length;if(r<=w)return String.fromCharCode.apply(String,c);let i="",h=0;for(;h<r;)i+=String.fromCharCode.apply(String,c.slice(h,h+=w));return i}function P(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]&127);return h}function R(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]);return h}function T(c,r,i){const h=c.length;(!r||r<0)&&(r=0),(!i||i<0||i>h)&&(i=h);let g="";for(let b=r;b<i;++b)g+=be[c[b]];return g}function N(c,r,i){const h=c.slice(r,i);let g="";for(let b=0;b<h.length-1;b+=2)g+=String.fromCharCode(h[b]+h[b+1]*256);return g}u.prototype.slice=function(r,i){const h=this.length;r=~~r,i=i===void 0?h:~~i,r<0?(r+=h,r<0&&(r=0)):r>h&&(r=h),i<0?(i+=h,i<0&&(i=0)):i>h&&(i=h),i<r&&(i=r);const g=this.subarray(r,i);return Object.setPrototypeOf(g,u.prototype),g};function k(c,r,i){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+r>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r],b=1,S=0;for(;++S<i&&(b*=256);)g+=this[r+S]*b;return g},u.prototype.readUintBE=u.prototype.readUIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r+--i],b=1;for(;i>0&&(b*=256);)g+=this[r+--i]*b;return g},u.prototype.readUint8=u.prototype.readUInt8=function(r,i){return r=r>>>0,i||k(r,1,this.length),this[r]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||k(r,2,this.length),this[r]|this[r+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||k(r,2,this.length),this[r]<<8|this[r+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||k(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},u.prototype.readBigUInt64LE=me(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,b=this[++r]+this[++r]*2**8+this[++r]*2**16+h*2**24;return BigInt(g)+(BigInt(b)<<BigInt(32))}),u.prototype.readBigUInt64BE=me(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=i*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],b=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h;return(BigInt(g)<<BigInt(32))+BigInt(b)}),u.prototype.readIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r],b=1,S=0;for(;++S<i&&(b*=256);)g+=this[r+S]*b;return b*=128,g>=b&&(g-=Math.pow(2,8*i)),g},u.prototype.readIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=i,b=1,S=this[r+--g];for(;g>0&&(b*=256);)S+=this[r+--g]*b;return b*=128,S>=b&&(S-=Math.pow(2,8*i)),S},u.prototype.readInt8=function(r,i){return r=r>>>0,i||k(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},u.prototype.readInt16LE=function(r,i){r=r>>>0,i||k(r,2,this.length);const h=this[r]|this[r+1]<<8;return h&32768?h|4294901760:h},u.prototype.readInt16BE=function(r,i){r=r>>>0,i||k(r,2,this.length);const h=this[r+1]|this[r]<<8;return h&32768?h|4294901760:h},u.prototype.readInt32LE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},u.prototype.readInt32BE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},u.prototype.readBigInt64LE=me(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(h<<24);return(BigInt(g)<<BigInt(32))+BigInt(i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),u.prototype.readBigInt64BE=me(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=(i<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(g)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h)}),u.prototype.readFloatLE=function(r,i){return r=r>>>0,i||k(r,4,this.length),e.read(this,r,!0,23,4)},u.prototype.readFloatBE=function(r,i){return r=r>>>0,i||k(r,4,this.length),e.read(this,r,!1,23,4)},u.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||k(r,8,this.length),e.read(this,r,!0,52,8)},u.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||k(r,8,this.length),e.read(this,r,!1,52,8)};function p(c,r,i,h,g,b){if(!u.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>g||r<b)throw new RangeError('"value" argument is out of bounds');if(i+h>c.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const et=Math.pow(2,8*h)-1;p(this,r,i,h,et,0)}let b=1,S=0;for(this[i]=r&255;++S<h&&(b*=256);)this[i+S]=r/b&255;return i+h},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const et=Math.pow(2,8*h)-1;p(this,r,i,h,et,0)}let b=h-1,S=1;for(this[i+b]=r&255;--b>=0&&(S*=256);)this[i+b]=r/S&255;return i+h},u.prototype.writeUint8=u.prototype.writeUInt8=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,1,255,0),this[i]=r&255,i+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function M(c,r,i,h,g){Wt(r,h,g,c,i,7);let b=Number(r&BigInt(4294967295));c[i++]=b,b=b>>8,c[i++]=b,b=b>>8,c[i++]=b,b=b>>8,c[i++]=b;let S=Number(r>>BigInt(32)&BigInt(4294967295));return c[i++]=S,S=S>>8,c[i++]=S,S=S>>8,c[i++]=S,S=S>>8,c[i++]=S,i}function at(c,r,i,h,g){Wt(r,h,g,c,i,7);let b=Number(r&BigInt(4294967295));c[i+7]=b,b=b>>8,c[i+6]=b,b=b>>8,c[i+5]=b,b=b>>8,c[i+4]=b;let S=Number(r>>BigInt(32)&BigInt(4294967295));return c[i+3]=S,S=S>>8,c[i+2]=S,S=S>>8,c[i+1]=S,S=S>>8,c[i]=S,i+8}u.prototype.writeBigUInt64LE=me(function(r,i=0){return M(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=me(function(r,i=0){return at(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const lt=Math.pow(2,8*h-1);p(this,r,i,h,lt-1,-lt)}let b=0,S=1,et=0;for(this[i]=r&255;++b<h&&(S*=256);)r<0&&et===0&&this[i+b-1]!==0&&(et=1),this[i+b]=(r/S>>0)-et&255;return i+h},u.prototype.writeIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const lt=Math.pow(2,8*h-1);p(this,r,i,h,lt-1,-lt)}let b=h-1,S=1,et=0;for(this[i+b]=r&255;--b>=0&&(S*=256);)r<0&&et===0&&this[i+b+1]!==0&&(et=1),this[i+b]=(r/S>>0)-et&255;return i+h},u.prototype.writeInt8=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},u.prototype.writeInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},u.prototype.writeInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},u.prototype.writeBigInt64LE=me(function(r,i=0){return M(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=me(function(r,i=0){return at(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function tt(c,r,i,h,g,b){if(i+h>c.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function ft(c,r,i,h,g){return r=+r,i=i>>>0,g||tt(c,r,i,4),e.write(c,r,i,h,23,4),i+4}u.prototype.writeFloatLE=function(r,i,h){return ft(this,r,i,!0,h)},u.prototype.writeFloatBE=function(r,i,h){return ft(this,r,i,!1,h)};function Lt(c,r,i,h,g){return r=+r,i=i>>>0,g||tt(c,r,i,8),e.write(c,r,i,h,52,8),i+8}u.prototype.writeDoubleLE=function(r,i,h){return Lt(this,r,i,!0,h)},u.prototype.writeDoubleBE=function(r,i,h){return Lt(this,r,i,!1,h)},u.prototype.copy=function(r,i,h,g){if(!u.isBuffer(r))throw new TypeError("argument should be a Buffer");if(h||(h=0),!g&&g!==0&&(g=this.length),i>=r.length&&(i=r.length),i||(i=0),g>0&&g<h&&(g=h),g===h||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),r.length-i<g-h&&(g=r.length-i+h);const b=g-h;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,h,g):Uint8Array.prototype.set.call(r,this.subarray(h,g),i),b},u.prototype.fill=function(r,i,h,g){if(typeof r=="string"){if(typeof i=="string"?(g=i,i=0,h=this.length):typeof h=="string"&&(g=h,h=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!u.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(r.length===1){const S=r.charCodeAt(0);(g==="utf8"&&S<128||g==="latin1")&&(r=S)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<h)throw new RangeError("Out of range index");if(h<=i)return this;i=i>>>0,h=h===void 0?this.length:h>>>0,r||(r=0);let b;if(typeof r=="number")for(b=i;b<h;++b)this[b]=r;else{const S=u.isBuffer(r)?r:u.from(r,g),et=S.length;if(et===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(b=0;b<h-i;++b)this[b+i]=S[b%et]}return this};const _t={};function Ut(c,r,i){_t[c]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Ut("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ut("ERR_INVALID_ARG_TYPE",function(c,r){return`The "${c}" argument must be of type number. Received type ${typeof r}`},TypeError),Ut("ERR_OUT_OF_RANGE",function(c,r,i){let h=`The value of "${c}" is out of range.`,g=i;return Number.isInteger(i)&&Math.abs(i)>2**32?g=Ee(String(i)):typeof i=="bigint"&&(g=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(g=Ee(g)),g+="n"),h+=` It must be ${r}. Received ${g}`,h},RangeError);function Ee(c){let r="",i=c.length;const h=c[0]==="-"?1:0;for(;i>=h+4;i-=3)r=`_${c.slice(i-3,i)}${r}`;return`${c.slice(0,i)}${r}`}function Zt(c,r,i){Yt(r,"offset"),(c[r]===void 0||c[r+i]===void 0)&&zt(r,c.length-(i+1))}function Wt(c,r,i,h,g,b){if(c>i||c<r){const S=typeof r=="bigint"?"n":"";let et;throw r===0||r===BigInt(0)?et=`>= 0${S} and < 2${S} ** ${(b+1)*8}${S}`:et=`>= -(2${S} ** ${(b+1)*8-1}${S}) and < 2 ** ${(b+1)*8-1}${S}`,new _t.ERR_OUT_OF_RANGE("value",et,c)}Zt(h,g,b)}function Yt(c,r){if(typeof c!="number")throw new _t.ERR_INVALID_ARG_TYPE(r,"number",c)}function zt(c,r,i){throw Math.floor(c)!==c?(Yt(c,i),new _t.ERR_OUT_OF_RANGE("offset","an integer",c)):r<0?new _t.ERR_BUFFER_OUT_OF_BOUNDS:new _t.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,c)}const ge=/[^+/0-9A-Za-z-_]/g;function xr(c){if(c=c.split("=")[0],c=c.trim().replace(ge,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function de(c,r){r=r||1/0;let i;const h=c.length;let g=null;const b=[];for(let S=0;S<h;++S){if(i=c.charCodeAt(S),i>55295&&i<57344){if(!g){if(i>56319){(r-=3)>-1&&b.push(239,191,189);continue}else if(S+1===h){(r-=3)>-1&&b.push(239,191,189);continue}g=i;continue}if(i<56320){(r-=3)>-1&&b.push(239,191,189),g=i;continue}i=(g-55296<<10|i-56320)+65536}else g&&(r-=3)>-1&&b.push(239,191,189);if(g=null,i<128){if((r-=1)<0)break;b.push(i)}else if(i<2048){if((r-=2)<0)break;b.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;b.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;b.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return b}function Pe(c){const r=[];for(let i=0;i<c.length;++i)r.push(c.charCodeAt(i)&255);return r}function hr(c,r){let i,h,g;const b=[];for(let S=0;S<c.length&&!((r-=2)<0);++S)i=c.charCodeAt(S),h=i>>8,g=i%256,b.push(g),b.push(h);return b}function we(c){return t.toByteArray(xr(c))}function ce(c,r,i,h){let g;for(g=0;g<h&&!(g+i>=r.length||g>=c.length);++g)r[g+i]=c[g];return g}function Qt(c,r){return c instanceof r||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===r.name}function fe(c){return c!==c}const be=function(){const c="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){const h=i*16;for(let g=0;g<16;++g)r[h+g]=c[i]+c[g]}return r}();function me(c){return typeof BigInt>"u"?ke:c}function ke(){throw new Error("BigInt not supported")}})(Nt);function vi(o){if(!Number.isSafeInteger(o)||o<0)throw new Error(`positive integer expected, not ${o}`)}function uu(o){return o instanceof Uint8Array||o!=null&&typeof o=="object"&&o.constructor.name==="Uint8Array"}function si(o,...t){if(!uu(o))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(o.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${o.length}`)}function fu(o){if(typeof o!="function"||typeof o.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");vi(o.outputLen),vi(o.blockLen)}function zn(o,t=!0){if(o.destroyed)throw new Error("Hash instance has been destroyed");if(t&&o.finished)throw new Error("Hash#digest() has already been called")}function Ms(o,t){si(o);const e=t.outputLen;if(o.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}const ho=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const hu=o=>new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)),lo=o=>new DataView(o.buffer,o.byteOffset,o.byteLength),qr=(o,t)=>o<<32-t|o>>>t,Ps=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,lu=o=>o<<24&4278190080|o<<8&16711680|o>>>8&65280|o>>>24&255;function Us(o){for(let t=0;t<o.length;t++)o[t]=lu(o[t])}function du(o){if(typeof o!="string")throw new Error(`utf8ToBytes expected string, got ${typeof o}`);return new Uint8Array(new TextEncoder().encode(o))}function _i(o){return typeof o=="string"&&(o=du(o)),si(o),o}function pu(...o){let t=0;for(let n=0;n<o.length;n++){const a=o[n];si(a),t+=a.length}const e=new Uint8Array(t);for(let n=0,a=0;n<o.length;n++){const s=o[n];e.set(s,a),a+=s.length}return e}class po{clone(){return this._cloneInto()}}function yo(o){const t=n=>o().update(_i(n)).digest(),e=o();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>o(),t}function Cs(o=32){if(ho&&typeof ho.getRandomValues=="function")return ho.getRandomValues(new Uint8Array(o));throw new Error("crypto.getRandomValues must be defined")}function yu(o,t,e,n){if(typeof o.setBigUint64=="function")return o.setBigUint64(t,e,n);const a=BigInt(32),s=BigInt(4294967295),f=Number(e>>a&s),u=Number(e&s),y=n?4:0,x=n?0:4;o.setUint32(t+y,f,n),o.setUint32(t+x,u,n)}const gu=(o,t,e)=>o&t^~o&e,wu=(o,t,e)=>o&t^o&e^t&e;class Ls extends po{constructor(t,e,n,a){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=a,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=lo(this.buffer)}update(t){zn(this);const{view:e,buffer:n,blockLen:a}=this;t=_i(t);const s=t.length;for(let f=0;f<s;){const u=Math.min(a-this.pos,s-f);if(u===a){const y=lo(t);for(;a<=s-f;f+=a)this.process(y,f);continue}n.set(t.subarray(f,f+u),this.pos),this.pos+=u,f+=u,this.pos===a&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){zn(this),Ms(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:a,isLE:s}=this;let{pos:f}=this;e[f++]=128,this.buffer.subarray(f).fill(0),this.padOffset>a-f&&(this.process(n,0),f=0);for(let _=f;_<a;_++)e[_]=0;yu(n,a-8,BigInt(this.length*8),s),this.process(n,0);const u=lo(t),y=this.outputLen;if(y%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const x=y/4,v=this.get();if(x>v.length)throw new Error("_sha2: outputLen bigger than state");for(let _=0;_<x;_++)u.setUint32(4*_,v[_],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:a,finished:s,destroyed:f,pos:u}=this;return t.length=a,t.pos=u,t.finished=s,t.destroyed=f,a%e&&t.buffer.set(n),t}}const Ai=BigInt(2**32-1),go=BigInt(32);function Fs(o,t=!1){return t?{h:Number(o&Ai),l:Number(o>>go&Ai)}:{h:Number(o>>go&Ai)|0,l:Number(o&Ai)|0}}function Os(o,t=!1){let e=new Uint32Array(o.length),n=new Uint32Array(o.length);for(let a=0;a<o.length;a++){const{h:s,l:f}=Fs(o[a],t);[e[a],n[a]]=[s,f]}return[e,n]}const mu=(o,t)=>BigInt(o>>>0)<<go|BigInt(t>>>0),bu=(o,t,e)=>o>>>e,xu=(o,t,e)=>o<<32-e|t>>>e,Eu=(o,t,e)=>o>>>e|t<<32-e,ku=(o,t,e)=>o<<32-e|t>>>e,Su=(o,t,e)=>o<<64-e|t>>>e-32,Iu=(o,t,e)=>o>>>e-32|t<<64-e,Bu=(o,t)=>t,vu=(o,t)=>o,Ns=(o,t,e)=>o<<e|t>>>32-e,zs=(o,t,e)=>t<<e|o>>>32-e,Ds=(o,t,e)=>t<<e-32|o>>>64-e,$s=(o,t,e)=>o<<e-32|t>>>64-e;function _u(o,t,e,n){const a=(t>>>0)+(n>>>0);return{h:o+e+(a/2**32|0)|0,l:a|0}}const ie={fromBig:Fs,split:Os,toBig:mu,shrSH:bu,shrSL:xu,rotrSH:Eu,rotrSL:ku,rotrBH:Su,rotrBL:Iu,rotr32H:Bu,rotr32L:vu,rotlSH:Ns,rotlSL:zs,rotlBH:Ds,rotlBL:$s,add:_u,add3L:(o,t,e)=>(o>>>0)+(t>>>0)+(e>>>0),add3H:(o,t,e,n)=>t+e+n+(o/2**32|0)|0,add4L:(o,t,e,n)=>(o>>>0)+(t>>>0)+(e>>>0)+(n>>>0),add4H:(o,t,e,n,a)=>t+e+n+a+(o/2**32|0)|0,add5H:(o,t,e,n,a,s)=>t+e+n+a+s+(o/2**32|0)|0,add5L:(o,t,e,n,a)=>(o>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(a>>>0)},[Au,Ru]=ie.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(o=>BigInt(o))),un=new Uint32Array(80),fn=new Uint32Array(80);class Tu extends Ls{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(){const{Ah:t,Al:e,Bh:n,Bl:a,Ch:s,Cl:f,Dh:u,Dl:y,Eh:x,El:v,Fh:_,Fl:F,Gh:L,Gl:D,Hh:C,Hl:z}=this;return[t,e,n,a,s,f,u,y,x,v,_,F,L,D,C,z]}set(t,e,n,a,s,f,u,y,x,v,_,F,L,D,C,z){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=a|0,this.Ch=s|0,this.Cl=f|0,this.Dh=u|0,this.Dl=y|0,this.Eh=x|0,this.El=v|0,this.Fh=_|0,this.Fl=F|0,this.Gh=L|0,this.Gl=D|0,this.Hh=C|0,this.Hl=z|0}process(t,e){for(let j=0;j<16;j++,e+=4)un[j]=t.getUint32(e),fn[j]=t.getUint32(e+=4);for(let j=16;j<80;j++){const it=un[j-15]|0,G=fn[j-15]|0,W=ie.rotrSH(it,G,1)^ie.rotrSH(it,G,8)^ie.shrSH(it,G,7),Q=ie.rotrSL(it,G,1)^ie.rotrSL(it,G,8)^ie.shrSL(it,G,7),rt=un[j-2]|0,ae=fn[j-2]|0,Vt=ie.rotrSH(rt,ae,19)^ie.rotrBH(rt,ae,61)^ie.shrSH(rt,ae,6),Bt=ie.rotrSL(rt,ae,19)^ie.rotrBL(rt,ae,61)^ie.shrSL(rt,ae,6),re=ie.add4L(Q,Bt,fn[j-7],fn[j-16]),U=ie.add4H(re,W,Vt,un[j-7],un[j-16]);un[j]=U|0,fn[j]=re|0}let{Ah:n,Al:a,Bh:s,Bl:f,Ch:u,Cl:y,Dh:x,Dl:v,Eh:_,El:F,Fh:L,Fl:D,Gh:C,Gl:z,Hh:$,Hl:X}=this;for(let j=0;j<80;j++){const it=ie.rotrSH(_,F,14)^ie.rotrSH(_,F,18)^ie.rotrBH(_,F,41),G=ie.rotrSL(_,F,14)^ie.rotrSL(_,F,18)^ie.rotrBL(_,F,41),W=_&L^~_&C,Q=F&D^~F&z,rt=ie.add5L(X,G,Q,Ru[j],fn[j]),ae=ie.add5H(rt,$,it,W,Au[j],un[j]),Vt=rt|0,Bt=ie.rotrSH(n,a,28)^ie.rotrBH(n,a,34)^ie.rotrBH(n,a,39),re=ie.rotrSL(n,a,28)^ie.rotrBL(n,a,34)^ie.rotrBL(n,a,39),U=n&s^n&u^s&u,d=a&f^a&y^f&y;$=C|0,X=z|0,C=L|0,z=D|0,L=_|0,D=F|0,{h:_,l:F}=ie.add(x|0,v|0,ae|0,Vt|0),x=u|0,v=y|0,u=s|0,y=f|0,s=n|0,f=a|0;const w=ie.add3L(Vt,re,d);n=ie.add3H(w,ae,Bt,U),a=w|0}({h:n,l:a}=ie.add(this.Ah|0,this.Al|0,n|0,a|0)),{h:s,l:f}=ie.add(this.Bh|0,this.Bl|0,s|0,f|0),{h:u,l:y}=ie.add(this.Ch|0,this.Cl|0,u|0,y|0),{h:x,l:v}=ie.add(this.Dh|0,this.Dl|0,x|0,v|0),{h:_,l:F}=ie.add(this.Eh|0,this.El|0,_|0,F|0),{h:L,l:D}=ie.add(this.Fh|0,this.Fl|0,L|0,D|0),{h:C,l:z}=ie.add(this.Gh|0,this.Gl|0,C|0,z|0),{h:$,l:X}=ie.add(this.Hh|0,this.Hl|0,$|0,X|0),this.set(n,a,s,f,u,y,x,v,_,F,L,D,C,z,$,X)}roundClean(){un.fill(0),fn.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)}}const Mu=yo(()=>new Tu);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ks=BigInt(0),Ri=BigInt(1),Pu=BigInt(2);function bn(o){return o instanceof Uint8Array||o!=null&&typeof o=="object"&&o.constructor.name==="Uint8Array"}function ai(o){if(!bn(o))throw new Error("Uint8Array expected")}const Uu=Array.from({length:256},(o,t)=>t.toString(16).padStart(2,"0"));function xn(o){ai(o);let t="";for(let e=0;e<o.length;e++)t+=Uu[o[e]];return t}function Ws(o){const t=o.toString(16);return t.length&1?`0${t}`:t}function wo(o){if(typeof o!="string")throw new Error("hex string expected, got "+typeof o);return BigInt(o===""?"0":`0x${o}`)}const rn={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function qs(o){if(o>=rn._0&&o<=rn._9)return o-rn._0;if(o>=rn._A&&o<=rn._F)return o-(rn._A-10);if(o>=rn._a&&o<=rn._f)return o-(rn._a-10)}function Dn(o){if(typeof o!="string")throw new Error("hex string expected, got "+typeof o);const t=o.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(e);for(let a=0,s=0;a<e;a++,s+=2){const f=qs(o.charCodeAt(s)),u=qs(o.charCodeAt(s+1));if(f===void 0||u===void 0){const y=o[s]+o[s+1];throw new Error('hex string expected, got non-hex character "'+y+'" at index '+s)}n[a]=f*16+u}return n}function En(o){return wo(xn(o))}function $n(o){return ai(o),wo(xn(Uint8Array.from(o).reverse()))}function Kn(o,t){return Dn(o.toString(16).padStart(t*2,"0"))}function ci(o,t){return Kn(o,t).reverse()}function Cu(o){return Dn(Ws(o))}function or(o,t,e){let n;if(typeof t=="string")try{n=Dn(t)}catch(s){throw new Error(`${o} must be valid hex string, got "${t}". Cause: ${s}`)}else if(bn(t))n=Uint8Array.from(t);else throw new Error(`${o} must be hex string or Uint8Array`);const a=n.length;if(typeof e=="number"&&a!==e)throw new Error(`${o} expected ${e} bytes, got ${a}`);return n}function kn(...o){let t=0;for(let n=0;n<o.length;n++){const a=o[n];ai(a),t+=a.length}const e=new Uint8Array(t);for(let n=0,a=0;n<o.length;n++){const s=o[n];e.set(s,a),a+=s.length}return e}function Lu(o,t){if(o.length!==t.length)return!1;let e=0;for(let n=0;n<o.length;n++)e|=o[n]^t[n];return e===0}function Fu(o){if(typeof o!="string")throw new Error(`utf8ToBytes expected string, got ${typeof o}`);return new Uint8Array(new TextEncoder().encode(o))}function Ou(o){let t;for(t=0;o>Ks;o>>=Ri,t+=1);return t}function Nu(o,t){return o>>BigInt(t)&Ri}function zu(o,t,e){return o|(e?Ri:Ks)<<BigInt(t)}const mo=o=>(Pu<<BigInt(o-1))-Ri,bo=o=>new Uint8Array(o),Hs=o=>Uint8Array.from(o);function js(o,t,e){if(typeof o!="number"||o<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=bo(o),a=bo(o),s=0;const f=()=>{n.fill(1),a.fill(0),s=0},u=(..._)=>e(a,n,..._),y=(_=bo())=>{a=u(Hs([0]),_),n=u(),_.length!==0&&(a=u(Hs([1]),_),n=u())},x=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let _=0;const F=[];for(;_<t;){n=u();const L=n.slice();F.push(L),_+=n.length}return kn(...F)};return(_,F)=>{f(),y(_);let L;for(;!(L=F(x()));)y();return f(),L}}const Du={bigint:o=>typeof o=="bigint",function:o=>typeof o=="function",boolean:o=>typeof o=="boolean",string:o=>typeof o=="string",stringOrUint8Array:o=>typeof o=="string"||bn(o),isSafeInteger:o=>Number.isSafeInteger(o),array:o=>Array.isArray(o),field:(o,t)=>t.Fp.isValid(o),hash:o=>typeof o=="function"&&Number.isSafeInteger(o.outputLen)};function Wn(o,t,e={}){const n=(a,s,f)=>{const u=Du[s];if(typeof u!="function")throw new Error(`Invalid validator "${s}", expected function`);const y=o[a];if(!(f&&y===void 0)&&!u(y,o))throw new Error(`Invalid param ${String(a)}=${y} (${typeof y}), expected ${s}`)};for(const[a,s]of Object.entries(t))n(a,s,!1);for(const[a,s]of Object.entries(e))n(a,s,!0);return o}const $u=Object.freeze(Object.defineProperty({__proto__:null,abytes:ai,bitGet:Nu,bitLen:Ou,bitMask:mo,bitSet:zu,bytesToHex:xn,bytesToNumberBE:En,bytesToNumberLE:$n,concatBytes:kn,createHmacDrbg:js,ensureBytes:or,equalBytes:Lu,hexToBytes:Dn,hexToNumber:wo,isBytes:bn,numberToBytesBE:Kn,numberToBytesLE:ci,numberToHexUnpadded:Ws,numberToVarBytesBE:Cu,utf8ToBytes:Fu,validateObject:Wn},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ar=BigInt(0),je=BigInt(1),Sn=BigInt(2),Ku=BigInt(3),xo=BigInt(4),Vs=BigInt(5),Gs=BigInt(8);BigInt(9),BigInt(16);function We(o,t){const e=o%t;return e>=ar?e:t+e}function Wu(o,t,e){if(e<=ar||t<ar)throw new Error("Expected power/modulo > 0");if(e===je)return ar;let n=je;for(;t>ar;)t&je&&(n=n*o%e),o=o*o%e,t>>=je;return n}function Ze(o,t,e){let n=o;for(;t-- >ar;)n*=n,n%=e;return n}function Eo(o,t){if(o===ar||t<=ar)throw new Error(`invert: expected positive integers, got n=${o} mod=${t}`);let e=We(o,t),n=t,a=ar,s=je;for(;e!==ar;){const u=n/e,y=n%e,x=a-s*u;n=e,e=y,a=s,s=x}if(n!==je)throw new Error("invert: does not exist");return We(a,t)}function qu(o){const t=(o-je)/Sn;let e,n,a;for(e=o-je,n=0;e%Sn===ar;e/=Sn,n++);for(a=Sn;a<o&&Wu(a,t,o)!==o-je;a++);if(n===1){const f=(o+je)/xo;return function(y,x){const v=y.pow(x,f);if(!y.eql(y.sqr(v),x))throw new Error("Cannot find square root");return v}}const s=(e+je)/Sn;return function(u,y){if(u.pow(y,t)===u.neg(u.ONE))throw new Error("Cannot find square root");let x=n,v=u.pow(u.mul(u.ONE,a),e),_=u.pow(y,s),F=u.pow(y,e);for(;!u.eql(F,u.ONE);){if(u.eql(F,u.ZERO))return u.ZERO;let L=1;for(let C=u.sqr(F);L<x&&!u.eql(C,u.ONE);L++)C=u.sqr(C);const D=u.pow(v,je<<BigInt(x-L-1));v=u.sqr(D),_=u.mul(_,D),F=u.mul(F,v),x=L}return _}}function Hu(o){if(o%xo===Ku){const t=(o+je)/xo;return function(n,a){const s=n.pow(a,t);if(!n.eql(n.sqr(s),a))throw new Error("Cannot find square root");return s}}if(o%Gs===Vs){const t=(o-Vs)/Gs;return function(n,a){const s=n.mul(a,Sn),f=n.pow(s,t),u=n.mul(a,f),y=n.mul(n.mul(u,Sn),f),x=n.mul(u,n.sub(y,n.ONE));if(!n.eql(n.sqr(x),a))throw new Error("Cannot find square root");return x}}return qu(o)}const ju=(o,t)=>(We(o,t)&je)===je,Vu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Gu(o){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Vu.reduce((n,a)=>(n[a]="function",n),t);return Wn(o,e)}function Yu(o,t,e){if(e<ar)throw new Error("Expected power > 0");if(e===ar)return o.ONE;if(e===je)return t;let n=o.ONE,a=t;for(;e>ar;)e&je&&(n=o.mul(n,a)),a=o.sqr(a),e>>=je;return n}function Zu(o,t){const e=new Array(t.length),n=t.reduce((s,f,u)=>o.is0(f)?s:(e[u]=s,o.mul(s,f)),o.ONE),a=o.inv(n);return t.reduceRight((s,f,u)=>o.is0(f)?s:(e[u]=o.mul(s,e[u]),o.mul(s,f)),a),e}function Ys(o,t){const e=t!==void 0?t:o.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Zs(o,t,e=!1,n={}){if(o<=ar)throw new Error(`Expected Field ORDER > 0, got ${o}`);const{nBitLength:a,nByteLength:s}=Ys(o,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const f=Hu(o),u=Object.freeze({ORDER:o,BITS:a,BYTES:s,MASK:mo(a),ZERO:ar,ONE:je,create:y=>We(y,o),isValid:y=>{if(typeof y!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof y}`);return ar<=y&&y<o},is0:y=>y===ar,isOdd:y=>(y&je)===je,neg:y=>We(-y,o),eql:(y,x)=>y===x,sqr:y=>We(y*y,o),add:(y,x)=>We(y+x,o),sub:(y,x)=>We(y-x,o),mul:(y,x)=>We(y*x,o),pow:(y,x)=>Yu(u,y,x),div:(y,x)=>We(y*Eo(x,o),o),sqrN:y=>y*y,addN:(y,x)=>y+x,subN:(y,x)=>y-x,mulN:(y,x)=>y*x,inv:y=>Eo(y,o),sqrt:n.sqrt||(y=>f(u,y)),invertBatch:y=>Zu(u,y),cmov:(y,x,v)=>v?x:y,toBytes:y=>e?ci(y,s):Kn(y,s),fromBytes:y=>{if(y.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${y.length}`);return e?$n(y):En(y)}});return Object.freeze(u)}function Js(o){if(typeof o!="bigint")throw new Error("field order must be bigint");const t=o.toString(2).length;return Math.ceil(t/8)}function Xs(o){const t=Js(o);return t+Math.ceil(t/2)}function Ju(o,t,e=!1){const n=o.length,a=Js(t),s=Xs(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);const f=e?En(o):$n(o),u=We(f,t-je)+je;return e?ci(u,a):Kn(u,a)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Xu=BigInt(0),ko=BigInt(1);function Qs(o,t){const e=(a,s)=>{const f=s.negate();return a?f:s},n=a=>{const s=Math.ceil(t/a)+1,f=2**(a-1);return{windows:s,windowSize:f}};return{constTimeNegate:e,unsafeLadder(a,s){let f=o.ZERO,u=a;for(;s>Xu;)s&ko&&(f=f.add(u)),u=u.double(),s>>=ko;return f},precomputeWindow(a,s){const{windows:f,windowSize:u}=n(s),y=[];let x=a,v=x;for(let _=0;_<f;_++){v=x,y.push(v);for(let F=1;F<u;F++)v=v.add(x),y.push(v);x=v.double()}return y},wNAF(a,s,f){const{windows:u,windowSize:y}=n(a);let x=o.ZERO,v=o.BASE;const _=BigInt(2**a-1),F=2**a,L=BigInt(a);for(let D=0;D<u;D++){const C=D*y;let z=Number(f&_);f>>=L,z>y&&(z-=F,f+=ko);const $=C,X=C+Math.abs(z)-1,j=D%2!==0,it=z<0;z===0?v=v.add(e(j,s[$])):x=x.add(e(it,s[X]))}return{p:x,f:v}},wNAFCached(a,s,f,u){const y=a._WINDOW_SIZE||1;let x=s.get(a);return x||(x=this.precomputeWindow(a,y),y!==1&&s.set(a,u(x))),this.wNAF(y,x,f)}}}function So(o){return Gu(o.Fp),Wn(o,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ys(o.n,o.nBitLength),...o,p:o.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Nr=BigInt(0),Rr=BigInt(1),Ti=BigInt(2),Qu=BigInt(8),tf={zip215:!0};function ef(o){const t=So(o);return Wn(o,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function rf(o){const t=ef(o),{Fp:e,n,prehash:a,hash:s,randomBytes:f,nByteLength:u,h:y}=t,x=Ti<<BigInt(u*8)-Rr,v=e.create,_=t.uvRatio||((R,T)=>{try{return{isValid:!0,value:e.sqrt(R*e.inv(T))}}catch{return{isValid:!1,value:Nr}}}),F=t.adjustScalarBytes||(R=>R),L=t.domain||((R,T,N)=>{if(T.length||N)throw new Error("Contexts/pre-hash are not supported");return R}),D=R=>typeof R=="bigint"&&Nr<R,C=(R,T)=>D(R)&&D(T)&&R<T,z=R=>R===Nr||C(R,x);function $(R,T){if(C(R,T))return R;throw new Error(`Expected valid scalar < ${T}, got ${typeof R} ${R}`)}function X(R){return R===Nr?R:$(R,n)}const j=new Map;function it(R){if(!(R instanceof G))throw new Error("ExtendedPoint expected")}class G{constructor(T,N,k,p){if(this.ex=T,this.ey=N,this.ez=k,this.et=p,!z(T))throw new Error("x required");if(!z(N))throw new Error("y required");if(!z(k))throw new Error("z required");if(!z(p))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(T){if(T instanceof G)throw new Error("extended point not allowed");const{x:N,y:k}=T||{};if(!z(N)||!z(k))throw new Error("invalid affine point");return new G(N,k,Rr,v(N*k))}static normalizeZ(T){const N=e.invertBatch(T.map(k=>k.ez));return T.map((k,p)=>k.toAffine(N[p])).map(G.fromAffine)}_setWindowSize(T){this._WINDOW_SIZE=T,j.delete(this)}assertValidity(){const{a:T,d:N}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:k,ey:p,ez:M,et:at}=this,tt=v(k*k),ft=v(p*p),Lt=v(M*M),_t=v(Lt*Lt),Ut=v(tt*T),Ee=v(Lt*v(Ut+ft)),Zt=v(_t+v(N*v(tt*ft)));if(Ee!==Zt)throw new Error("bad point: equation left != right (1)");const Wt=v(k*p),Yt=v(M*at);if(Wt!==Yt)throw new Error("bad point: equation left != right (2)")}equals(T){it(T);const{ex:N,ey:k,ez:p}=this,{ex:M,ey:at,ez:tt}=T,ft=v(N*tt),Lt=v(M*p),_t=v(k*tt),Ut=v(at*p);return ft===Lt&&_t===Ut}is0(){return this.equals(G.ZERO)}negate(){return new G(v(-this.ex),this.ey,this.ez,v(-this.et))}double(){const{a:T}=t,{ex:N,ey:k,ez:p}=this,M=v(N*N),at=v(k*k),tt=v(Ti*v(p*p)),ft=v(T*M),Lt=N+k,_t=v(v(Lt*Lt)-M-at),Ut=ft+at,Ee=Ut-tt,Zt=ft-at,Wt=v(_t*Ee),Yt=v(Ut*Zt),zt=v(_t*Zt),ge=v(Ee*Ut);return new G(Wt,Yt,ge,zt)}add(T){it(T);const{a:N,d:k}=t,{ex:p,ey:M,ez:at,et:tt}=this,{ex:ft,ey:Lt,ez:_t,et:Ut}=T;if(N===BigInt(-1)){const Qt=v((M-p)*(Lt+ft)),fe=v((M+p)*(Lt-ft)),be=v(fe-Qt);if(be===Nr)return this.double();const me=v(at*Ti*Ut),ke=v(tt*Ti*_t),c=ke+me,r=fe+Qt,i=ke-me,h=v(c*be),g=v(r*i),b=v(c*i),S=v(be*r);return new G(h,g,S,b)}const Ee=v(p*ft),Zt=v(M*Lt),Wt=v(tt*k*Ut),Yt=v(at*_t),zt=v((p+M)*(ft+Lt)-Ee-Zt),ge=Yt-Wt,xr=Yt+Wt,de=v(Zt-N*Ee),Pe=v(zt*ge),hr=v(xr*de),we=v(zt*de),ce=v(ge*xr);return new G(Pe,hr,ce,we)}subtract(T){return this.add(T.negate())}wNAF(T){return rt.wNAFCached(this,j,T,G.normalizeZ)}multiply(T){const{p:N,f:k}=this.wNAF($(T,n));return G.normalizeZ([N,k])[0]}multiplyUnsafe(T){let N=X(T);return N===Nr?Q:this.equals(Q)||N===Rr?this:this.equals(W)?this.wNAF(N).p:rt.unsafeLadder(this,N)}isSmallOrder(){return this.multiplyUnsafe(y).is0()}isTorsionFree(){return rt.unsafeLadder(this,n).is0()}toAffine(T){const{ex:N,ey:k,ez:p}=this,M=this.is0();T==null&&(T=M?Qu:e.inv(p));const at=v(N*T),tt=v(k*T),ft=v(p*T);if(M)return{x:Nr,y:Rr};if(ft!==Rr)throw new Error("invZ was invalid");return{x:at,y:tt}}clearCofactor(){const{h:T}=t;return T===Rr?this:this.multiplyUnsafe(T)}static fromHex(T,N=!1){const{d:k,a:p}=t,M=e.BYTES;T=or("pointHex",T,M);const at=T.slice(),tt=T[M-1];at[M-1]=tt&-129;const ft=$n(at);ft===Nr||(N?$(ft,x):$(ft,e.ORDER));const Lt=v(ft*ft),_t=v(Lt-Rr),Ut=v(k*Lt-p);let{isValid:Ee,value:Zt}=_(_t,Ut);if(!Ee)throw new Error("Point.fromHex: invalid y coordinate");const Wt=(Zt&Rr)===Rr,Yt=(tt&128)!==0;if(!N&&Zt===Nr&&Yt)throw new Error("Point.fromHex: x=0 and x_0=1");return Yt!==Wt&&(Zt=v(-Zt)),G.fromAffine({x:Zt,y:ft})}static fromPrivateKey(T){return Bt(T).point}toRawBytes(){const{x:T,y:N}=this.toAffine(),k=ci(N,e.BYTES);return k[k.length-1]|=T&Rr?128:0,k}toHex(){return xn(this.toRawBytes())}}G.BASE=new G(t.Gx,t.Gy,Rr,v(t.Gx*t.Gy)),G.ZERO=new G(Nr,Rr,Rr,Nr);const{BASE:W,ZERO:Q}=G,rt=Qs(G,u*8);function ae(R){return We(R,n)}function Vt(R){return ae($n(R))}function Bt(R){const T=u;R=or("private key",R,T);const N=or("hashed private key",s(R),2*T),k=F(N.slice(0,T)),p=N.slice(T,2*T),M=Vt(k),at=W.multiply(M),tt=at.toRawBytes();return{head:k,prefix:p,scalar:M,point:at,pointBytes:tt}}function re(R){return Bt(R).pointBytes}function U(R=new Uint8Array,...T){const N=kn(...T);return Vt(s(L(N,or("context",R),!!a)))}function d(R,T,N={}){R=or("message",R),a&&(R=a(R));const{prefix:k,scalar:p,pointBytes:M}=Bt(T),at=U(N.context,k,R),tt=W.multiply(at).toRawBytes(),ft=U(N.context,tt,M,R),Lt=ae(at+ft*p);X(Lt);const _t=kn(tt,ci(Lt,e.BYTES));return or("result",_t,u*2)}const w=tf;function E(R,T,N,k=w){const{context:p,zip215:M}=k,at=e.BYTES;R=or("signature",R,2*at),T=or("message",T),a&&(T=a(T));const tt=$n(R.slice(at,2*at));let ft,Lt,_t;try{ft=G.fromHex(N,M),Lt=G.fromHex(R.slice(0,at),M),_t=W.multiplyUnsafe(tt)}catch{return!1}if(!M&&ft.isSmallOrder())return!1;const Ut=U(p,Lt.toRawBytes(),ft.toRawBytes(),T);return Lt.add(ft.multiplyUnsafe(Ut)).subtract(_t).clearCofactor().equals(G.ZERO)}return W._setWindowSize(8),{CURVE:t,getPublicKey:re,sign:d,verify:E,ExtendedPoint:G,utils:{getExtendedPublicKey:Bt,randomPrivateKey:()=>f(e.BYTES),precompute(R=8,T=G.BASE){return T._setWindowSize(R),T.multiply(BigInt(3)),T}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Io=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ta=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const nf=BigInt(1),ea=BigInt(2);BigInt(3);const of=BigInt(5),sf=BigInt(8);function af(o){const t=BigInt(10),e=BigInt(20),n=BigInt(40),a=BigInt(80),s=Io,u=o*o%s*o%s,y=Ze(u,ea,s)*u%s,x=Ze(y,nf,s)*o%s,v=Ze(x,of,s)*x%s,_=Ze(v,t,s)*v%s,F=Ze(_,e,s)*_%s,L=Ze(F,n,s)*F%s,D=Ze(L,a,s)*L%s,C=Ze(D,a,s)*L%s,z=Ze(C,t,s)*v%s;return{pow_p_5_8:Ze(z,ea,s)*o%s,b2:u}}function cf(o){return o[0]&=248,o[31]&=127,o[31]|=64,o}function uf(o,t){const e=Io,n=We(t*t*t,e),a=We(n*n*t,e),s=af(o*a).pow_p_5_8;let f=We(o*n*s,e);const u=We(t*f*f,e),y=f,x=We(f*ta,e),v=u===o,_=u===We(-o,e),F=u===We(-o*ta,e);return v&&(f=y),(_||F)&&(f=x),ju(f,e)&&(f=We(-f,e)),{isValid:v||_,value:f}}const ff=Zs(Io,void 0,!0),hf={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ff,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:sf,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Mu,randomBytes:Cs,adjustScalarBytes:cf,uvRatio:uf},qn=rf(hf);var Bo={exports:{}};const ra=uo(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));Bo.exports,function(o){(function(t,e){function n(U,d){if(!U)throw new Error(d||"Assertion failed")}function a(U,d){U.super_=d;var w=function(){};w.prototype=d.prototype,U.prototype=new w,U.prototype.constructor=U}function s(U,d,w){if(s.isBN(U))return U;this.negative=0,this.words=null,this.length=0,this.red=null,U!==null&&((d==="le"||d==="be")&&(w=d,d=10),this._init(U||0,d||10,w||"be"))}typeof t=="object"?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;var f;try{typeof window<"u"&&typeof window.Buffer<"u"?f=window.Buffer:f=ra.Buffer}catch{}s.isBN=function(d){return d instanceof s?!0:d!==null&&typeof d=="object"&&d.constructor.wordSize===s.wordSize&&Array.isArray(d.words)},s.max=function(d,w){return d.cmp(w)>0?d:w},s.min=function(d,w){return d.cmp(w)<0?d:w},s.prototype._init=function(d,w,E){if(typeof d=="number")return this._initNumber(d,w,E);if(typeof d=="object")return this._initArray(d,w,E);w==="hex"&&(w=16),n(w===(w|0)&&w>=2&&w<=36),d=d.toString().replace(/\s+/g,"");var P=0;d[0]==="-"&&(P++,this.negative=1),P<d.length&&(w===16?this._parseHex(d,P,E):(this._parseBase(d,w,P),E==="le"&&this._initArray(this.toArray(),w,E)))},s.prototype._initNumber=function(d,w,E){d<0&&(this.negative=1,d=-d),d<67108864?(this.words=[d&67108863],this.length=1):d<4503599627370496?(this.words=[d&67108863,d/67108864&67108863],this.length=2):(n(d<9007199254740992),this.words=[d&67108863,d/67108864&67108863,1],this.length=3),E==="le"&&this._initArray(this.toArray(),w,E)},s.prototype._initArray=function(d,w,E){if(n(typeof d.length=="number"),d.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(d.length/3),this.words=new Array(this.length);for(var P=0;P<this.length;P++)this.words[P]=0;var R,T,N=0;if(E==="be")for(P=d.length-1,R=0;P>=0;P-=3)T=d[P]|d[P-1]<<8|d[P-2]<<16,this.words[R]|=T<<N&67108863,this.words[R+1]=T>>>26-N&67108863,N+=24,N>=26&&(N-=26,R++);else if(E==="le")for(P=0,R=0;P<d.length;P+=3)T=d[P]|d[P+1]<<8|d[P+2]<<16,this.words[R]|=T<<N&67108863,this.words[R+1]=T>>>26-N&67108863,N+=24,N>=26&&(N-=26,R++);return this._strip()};function u(U,d){var w=U.charCodeAt(d);if(w>=48&&w<=57)return w-48;if(w>=65&&w<=70)return w-55;if(w>=97&&w<=102)return w-87;n(!1,"Invalid character in "+U)}function y(U,d,w){var E=u(U,w);return w-1>=d&&(E|=u(U,w-1)<<4),E}s.prototype._parseHex=function(d,w,E){this.length=Math.ceil((d.length-w)/6),this.words=new Array(this.length);for(var P=0;P<this.length;P++)this.words[P]=0;var R=0,T=0,N;if(E==="be")for(P=d.length-1;P>=w;P-=2)N=y(d,w,P)<<R,this.words[T]|=N&67108863,R>=18?(R-=18,T+=1,this.words[T]|=N>>>26):R+=8;else{var k=d.length-w;for(P=k%2===0?w+1:w;P<d.length;P+=2)N=y(d,w,P)<<R,this.words[T]|=N&67108863,R>=18?(R-=18,T+=1,this.words[T]|=N>>>26):R+=8}this._strip()};function x(U,d,w,E){for(var P=0,R=0,T=Math.min(U.length,w),N=d;N<T;N++){var k=U.charCodeAt(N)-48;P*=E,k>=49?R=k-49+10:k>=17?R=k-17+10:R=k,n(k>=0&&R<E,"Invalid character"),P+=R}return P}s.prototype._parseBase=function(d,w,E){this.words=[0],this.length=1;for(var P=0,R=1;R<=67108863;R*=w)P++;P--,R=R/w|0;for(var T=d.length-E,N=T%P,k=Math.min(T,T-N)+E,p=0,M=E;M<k;M+=P)p=x(d,M,M+P,w),this.imuln(R),this.words[0]+p<67108864?this.words[0]+=p:this._iaddn(p);if(N!==0){var at=1;for(p=x(d,M,d.length,w),M=0;M<N;M++)at*=w;this.imuln(at),this.words[0]+p<67108864?this.words[0]+=p:this._iaddn(p)}this._strip()},s.prototype.copy=function(d){d.words=new Array(this.length);for(var w=0;w<this.length;w++)d.words[w]=this.words[w];d.length=this.length,d.negative=this.negative,d.red=this.red};function v(U,d){U.words=d.words,U.length=d.length,U.negative=d.negative,U.red=d.red}if(s.prototype._move=function(d){v(d,this)},s.prototype.clone=function(){var d=new s(null);return this.copy(d),d},s.prototype._expand=function(d){for(;this.length<d;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=_}catch{s.prototype.inspect=_}else s.prototype.inspect=_;function _(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var F=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],L=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],D=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(d,w){d=d||10,w=w|0||1;var E;if(d===16||d==="hex"){E="";for(var P=0,R=0,T=0;T<this.length;T++){var N=this.words[T],k=((N<<P|R)&16777215).toString(16);R=N>>>24-P&16777215,P+=2,P>=26&&(P-=26,T--),R!==0||T!==this.length-1?E=F[6-k.length]+k+E:E=k+E}for(R!==0&&(E=R.toString(16)+E);E.length%w!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}if(d===(d|0)&&d>=2&&d<=36){var p=L[d],M=D[d];E="";var at=this.clone();for(at.negative=0;!at.isZero();){var tt=at.modrn(M).toString(d);at=at.idivn(M),at.isZero()?E=tt+E:E=F[p-tt.length]+tt+E}for(this.isZero()&&(E="0"+E);E.length%w!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var d=this.words[0];return this.length===2?d+=this.words[1]*67108864:this.length===3&&this.words[2]===1?d+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-d:d},s.prototype.toJSON=function(){return this.toString(16,2)},f&&(s.prototype.toBuffer=function(d,w){return this.toArrayLike(f,d,w)}),s.prototype.toArray=function(d,w){return this.toArrayLike(Array,d,w)};var C=function(d,w){return d.allocUnsafe?d.allocUnsafe(w):new d(w)};s.prototype.toArrayLike=function(d,w,E){this._strip();var P=this.byteLength(),R=E||Math.max(1,P);n(P<=R,"byte array longer than desired length"),n(R>0,"Requested array length <= 0");var T=C(d,R),N=w==="le"?"LE":"BE";return this["_toArrayLike"+N](T,P),T},s.prototype._toArrayLikeLE=function(d,w){for(var E=0,P=0,R=0,T=0;R<this.length;R++){var N=this.words[R]<<T|P;d[E++]=N&255,E<d.length&&(d[E++]=N>>8&255),E<d.length&&(d[E++]=N>>16&255),T===6?(E<d.length&&(d[E++]=N>>24&255),P=0,T=0):(P=N>>>24,T+=2)}if(E<d.length)for(d[E++]=P;E<d.length;)d[E++]=0},s.prototype._toArrayLikeBE=function(d,w){for(var E=d.length-1,P=0,R=0,T=0;R<this.length;R++){var N=this.words[R]<<T|P;d[E--]=N&255,E>=0&&(d[E--]=N>>8&255),E>=0&&(d[E--]=N>>16&255),T===6?(E>=0&&(d[E--]=N>>24&255),P=0,T=0):(P=N>>>24,T+=2)}if(E>=0)for(d[E--]=P;E>=0;)d[E--]=0},Math.clz32?s.prototype._countBits=function(d){return 32-Math.clz32(d)}:s.prototype._countBits=function(d){var w=d,E=0;return w>=4096&&(E+=13,w>>>=13),w>=64&&(E+=7,w>>>=7),w>=8&&(E+=4,w>>>=4),w>=2&&(E+=2,w>>>=2),E+w},s.prototype._zeroBits=function(d){if(d===0)return 26;var w=d,E=0;return w&8191||(E+=13,w>>>=13),w&127||(E+=7,w>>>=7),w&15||(E+=4,w>>>=4),w&3||(E+=2,w>>>=2),w&1||E++,E},s.prototype.bitLength=function(){var d=this.words[this.length-1],w=this._countBits(d);return(this.length-1)*26+w};function z(U){for(var d=new Array(U.bitLength()),w=0;w<d.length;w++){var E=w/26|0,P=w%26;d[w]=U.words[E]>>>P&1}return d}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var d=0,w=0;w<this.length;w++){var E=this._zeroBits(this.words[w]);if(d+=E,E!==26)break}return d},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(d){return this.negative!==0?this.abs().inotn(d).iaddn(1):this.clone()},s.prototype.fromTwos=function(d){return this.testn(d-1)?this.notn(d).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(d){for(;this.length<d.length;)this.words[this.length++]=0;for(var w=0;w<d.length;w++)this.words[w]=this.words[w]|d.words[w];return this._strip()},s.prototype.ior=function(d){return n((this.negative|d.negative)===0),this.iuor(d)},s.prototype.or=function(d){return this.length>d.length?this.clone().ior(d):d.clone().ior(this)},s.prototype.uor=function(d){return this.length>d.length?this.clone().iuor(d):d.clone().iuor(this)},s.prototype.iuand=function(d){var w;this.length>d.length?w=d:w=this;for(var E=0;E<w.length;E++)this.words[E]=this.words[E]&d.words[E];return this.length=w.length,this._strip()},s.prototype.iand=function(d){return n((this.negative|d.negative)===0),this.iuand(d)},s.prototype.and=function(d){return this.length>d.length?this.clone().iand(d):d.clone().iand(this)},s.prototype.uand=function(d){return this.length>d.length?this.clone().iuand(d):d.clone().iuand(this)},s.prototype.iuxor=function(d){var w,E;this.length>d.length?(w=this,E=d):(w=d,E=this);for(var P=0;P<E.length;P++)this.words[P]=w.words[P]^E.words[P];if(this!==w)for(;P<w.length;P++)this.words[P]=w.words[P];return this.length=w.length,this._strip()},s.prototype.ixor=function(d){return n((this.negative|d.negative)===0),this.iuxor(d)},s.prototype.xor=function(d){return this.length>d.length?this.clone().ixor(d):d.clone().ixor(this)},s.prototype.uxor=function(d){return this.length>d.length?this.clone().iuxor(d):d.clone().iuxor(this)},s.prototype.inotn=function(d){n(typeof d=="number"&&d>=0);var w=Math.ceil(d/26)|0,E=d%26;this._expand(w),E>0&&w--;for(var P=0;P<w;P++)this.words[P]=~this.words[P]&67108863;return E>0&&(this.words[P]=~this.words[P]&67108863>>26-E),this._strip()},s.prototype.notn=function(d){return this.clone().inotn(d)},s.prototype.setn=function(d,w){n(typeof d=="number"&&d>=0);var E=d/26|0,P=d%26;return this._expand(E+1),w?this.words[E]=this.words[E]|1<<P:this.words[E]=this.words[E]&~(1<<P),this._strip()},s.prototype.iadd=function(d){var w;if(this.negative!==0&&d.negative===0)return this.negative=0,w=this.isub(d),this.negative^=1,this._normSign();if(this.negative===0&&d.negative!==0)return d.negative=0,w=this.isub(d),d.negative=1,w._normSign();var E,P;this.length>d.length?(E=this,P=d):(E=d,P=this);for(var R=0,T=0;T<P.length;T++)w=(E.words[T]|0)+(P.words[T]|0)+R,this.words[T]=w&67108863,R=w>>>26;for(;R!==0&&T<E.length;T++)w=(E.words[T]|0)+R,this.words[T]=w&67108863,R=w>>>26;if(this.length=E.length,R!==0)this.words[this.length]=R,this.length++;else if(E!==this)for(;T<E.length;T++)this.words[T]=E.words[T];return this},s.prototype.add=function(d){var w;return d.negative!==0&&this.negative===0?(d.negative=0,w=this.sub(d),d.negative^=1,w):d.negative===0&&this.negative!==0?(this.negative=0,w=d.sub(this),this.negative=1,w):this.length>d.length?this.clone().iadd(d):d.clone().iadd(this)},s.prototype.isub=function(d){if(d.negative!==0){d.negative=0;var w=this.iadd(d);return d.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(d),this.negative=1,this._normSign();var E=this.cmp(d);if(E===0)return this.negative=0,this.length=1,this.words[0]=0,this;var P,R;E>0?(P=this,R=d):(P=d,R=this);for(var T=0,N=0;N<R.length;N++)w=(P.words[N]|0)-(R.words[N]|0)+T,T=w>>26,this.words[N]=w&67108863;for(;T!==0&&N<P.length;N++)w=(P.words[N]|0)+T,T=w>>26,this.words[N]=w&67108863;if(T===0&&N<P.length&&P!==this)for(;N<P.length;N++)this.words[N]=P.words[N];return this.length=Math.max(this.length,N),P!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(d){return this.clone().isub(d)};function $(U,d,w){w.negative=d.negative^U.negative;var E=U.length+d.length|0;w.length=E,E=E-1|0;var P=U.words[0]|0,R=d.words[0]|0,T=P*R,N=T&67108863,k=T/67108864|0;w.words[0]=N;for(var p=1;p<E;p++){for(var M=k>>>26,at=k&67108863,tt=Math.min(p,d.length-1),ft=Math.max(0,p-U.length+1);ft<=tt;ft++){var Lt=p-ft|0;P=U.words[Lt]|0,R=d.words[ft]|0,T=P*R+at,M+=T/67108864|0,at=T&67108863}w.words[p]=at|0,k=M|0}return k!==0?w.words[p]=k|0:w.length--,w._strip()}var X=function(d,w,E){var P=d.words,R=w.words,T=E.words,N=0,k,p,M,at=P[0]|0,tt=at&8191,ft=at>>>13,Lt=P[1]|0,_t=Lt&8191,Ut=Lt>>>13,Ee=P[2]|0,Zt=Ee&8191,Wt=Ee>>>13,Yt=P[3]|0,zt=Yt&8191,ge=Yt>>>13,xr=P[4]|0,de=xr&8191,Pe=xr>>>13,hr=P[5]|0,we=hr&8191,ce=hr>>>13,Qt=P[6]|0,fe=Qt&8191,be=Qt>>>13,me=P[7]|0,ke=me&8191,c=me>>>13,r=P[8]|0,i=r&8191,h=r>>>13,g=P[9]|0,b=g&8191,S=g>>>13,et=R[0]|0,lt=et&8191,ht=et>>>13,Et=R[1]|0,st=Et&8191,$e=Et>>>13,ni=R[2]|0,Ye=ni&8191,Xe=ni>>>13,co=R[3]|0,Ce=co&8191,Oe=co>>>13,cn=R[4]|0,qe=cn&8191,He=cn>>>13,Ii=R[5]|0,Qe=Ii&8191,Se=Ii>>>13,Bi=R[6]|0,m=Bi&8191,I=Bi>>>13,B=R[7]|0,l=B&8191,A=B>>>13,q=R[8]|0,K=q&8191,J=q>>>13,pt=R[9]|0,wt=pt&8191,yt=pt>>>13;E.negative=d.negative^w.negative,E.length=19,k=Math.imul(tt,lt),p=Math.imul(tt,ht),p=p+Math.imul(ft,lt)|0,M=Math.imul(ft,ht);var ye=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(ye>>>26)|0,ye&=67108863,k=Math.imul(_t,lt),p=Math.imul(_t,ht),p=p+Math.imul(Ut,lt)|0,M=Math.imul(Ut,ht),k=k+Math.imul(tt,st)|0,p=p+Math.imul(tt,$e)|0,p=p+Math.imul(ft,st)|0,M=M+Math.imul(ft,$e)|0;var vt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(vt>>>26)|0,vt&=67108863,k=Math.imul(Zt,lt),p=Math.imul(Zt,ht),p=p+Math.imul(Wt,lt)|0,M=Math.imul(Wt,ht),k=k+Math.imul(_t,st)|0,p=p+Math.imul(_t,$e)|0,p=p+Math.imul(Ut,st)|0,M=M+Math.imul(Ut,$e)|0,k=k+Math.imul(tt,Ye)|0,p=p+Math.imul(tt,Xe)|0,p=p+Math.imul(ft,Ye)|0,M=M+Math.imul(ft,Xe)|0;var Kt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,k=Math.imul(zt,lt),p=Math.imul(zt,ht),p=p+Math.imul(ge,lt)|0,M=Math.imul(ge,ht),k=k+Math.imul(Zt,st)|0,p=p+Math.imul(Zt,$e)|0,p=p+Math.imul(Wt,st)|0,M=M+Math.imul(Wt,$e)|0,k=k+Math.imul(_t,Ye)|0,p=p+Math.imul(_t,Xe)|0,p=p+Math.imul(Ut,Ye)|0,M=M+Math.imul(Ut,Xe)|0,k=k+Math.imul(tt,Ce)|0,p=p+Math.imul(tt,Oe)|0,p=p+Math.imul(ft,Ce)|0,M=M+Math.imul(ft,Oe)|0;var qt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(qt>>>26)|0,qt&=67108863,k=Math.imul(de,lt),p=Math.imul(de,ht),p=p+Math.imul(Pe,lt)|0,M=Math.imul(Pe,ht),k=k+Math.imul(zt,st)|0,p=p+Math.imul(zt,$e)|0,p=p+Math.imul(ge,st)|0,M=M+Math.imul(ge,$e)|0,k=k+Math.imul(Zt,Ye)|0,p=p+Math.imul(Zt,Xe)|0,p=p+Math.imul(Wt,Ye)|0,M=M+Math.imul(Wt,Xe)|0,k=k+Math.imul(_t,Ce)|0,p=p+Math.imul(_t,Oe)|0,p=p+Math.imul(Ut,Ce)|0,M=M+Math.imul(Ut,Oe)|0,k=k+Math.imul(tt,qe)|0,p=p+Math.imul(tt,He)|0,p=p+Math.imul(ft,qe)|0,M=M+Math.imul(ft,He)|0;var Xt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,k=Math.imul(we,lt),p=Math.imul(we,ht),p=p+Math.imul(ce,lt)|0,M=Math.imul(ce,ht),k=k+Math.imul(de,st)|0,p=p+Math.imul(de,$e)|0,p=p+Math.imul(Pe,st)|0,M=M+Math.imul(Pe,$e)|0,k=k+Math.imul(zt,Ye)|0,p=p+Math.imul(zt,Xe)|0,p=p+Math.imul(ge,Ye)|0,M=M+Math.imul(ge,Xe)|0,k=k+Math.imul(Zt,Ce)|0,p=p+Math.imul(Zt,Oe)|0,p=p+Math.imul(Wt,Ce)|0,M=M+Math.imul(Wt,Oe)|0,k=k+Math.imul(_t,qe)|0,p=p+Math.imul(_t,He)|0,p=p+Math.imul(Ut,qe)|0,M=M+Math.imul(Ut,He)|0,k=k+Math.imul(tt,Qe)|0,p=p+Math.imul(tt,Se)|0,p=p+Math.imul(ft,Qe)|0,M=M+Math.imul(ft,Se)|0;var Jt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Jt>>>26)|0,Jt&=67108863,k=Math.imul(fe,lt),p=Math.imul(fe,ht),p=p+Math.imul(be,lt)|0,M=Math.imul(be,ht),k=k+Math.imul(we,st)|0,p=p+Math.imul(we,$e)|0,p=p+Math.imul(ce,st)|0,M=M+Math.imul(ce,$e)|0,k=k+Math.imul(de,Ye)|0,p=p+Math.imul(de,Xe)|0,p=p+Math.imul(Pe,Ye)|0,M=M+Math.imul(Pe,Xe)|0,k=k+Math.imul(zt,Ce)|0,p=p+Math.imul(zt,Oe)|0,p=p+Math.imul(ge,Ce)|0,M=M+Math.imul(ge,Oe)|0,k=k+Math.imul(Zt,qe)|0,p=p+Math.imul(Zt,He)|0,p=p+Math.imul(Wt,qe)|0,M=M+Math.imul(Wt,He)|0,k=k+Math.imul(_t,Qe)|0,p=p+Math.imul(_t,Se)|0,p=p+Math.imul(Ut,Qe)|0,M=M+Math.imul(Ut,Se)|0,k=k+Math.imul(tt,m)|0,p=p+Math.imul(tt,I)|0,p=p+Math.imul(ft,m)|0,M=M+Math.imul(ft,I)|0;var Ht=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,k=Math.imul(ke,lt),p=Math.imul(ke,ht),p=p+Math.imul(c,lt)|0,M=Math.imul(c,ht),k=k+Math.imul(fe,st)|0,p=p+Math.imul(fe,$e)|0,p=p+Math.imul(be,st)|0,M=M+Math.imul(be,$e)|0,k=k+Math.imul(we,Ye)|0,p=p+Math.imul(we,Xe)|0,p=p+Math.imul(ce,Ye)|0,M=M+Math.imul(ce,Xe)|0,k=k+Math.imul(de,Ce)|0,p=p+Math.imul(de,Oe)|0,p=p+Math.imul(Pe,Ce)|0,M=M+Math.imul(Pe,Oe)|0,k=k+Math.imul(zt,qe)|0,p=p+Math.imul(zt,He)|0,p=p+Math.imul(ge,qe)|0,M=M+Math.imul(ge,He)|0,k=k+Math.imul(Zt,Qe)|0,p=p+Math.imul(Zt,Se)|0,p=p+Math.imul(Wt,Qe)|0,M=M+Math.imul(Wt,Se)|0,k=k+Math.imul(_t,m)|0,p=p+Math.imul(_t,I)|0,p=p+Math.imul(Ut,m)|0,M=M+Math.imul(Ut,I)|0,k=k+Math.imul(tt,l)|0,p=p+Math.imul(tt,A)|0,p=p+Math.imul(ft,l)|0,M=M+Math.imul(ft,A)|0;var Gt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,k=Math.imul(i,lt),p=Math.imul(i,ht),p=p+Math.imul(h,lt)|0,M=Math.imul(h,ht),k=k+Math.imul(ke,st)|0,p=p+Math.imul(ke,$e)|0,p=p+Math.imul(c,st)|0,M=M+Math.imul(c,$e)|0,k=k+Math.imul(fe,Ye)|0,p=p+Math.imul(fe,Xe)|0,p=p+Math.imul(be,Ye)|0,M=M+Math.imul(be,Xe)|0,k=k+Math.imul(we,Ce)|0,p=p+Math.imul(we,Oe)|0,p=p+Math.imul(ce,Ce)|0,M=M+Math.imul(ce,Oe)|0,k=k+Math.imul(de,qe)|0,p=p+Math.imul(de,He)|0,p=p+Math.imul(Pe,qe)|0,M=M+Math.imul(Pe,He)|0,k=k+Math.imul(zt,Qe)|0,p=p+Math.imul(zt,Se)|0,p=p+Math.imul(ge,Qe)|0,M=M+Math.imul(ge,Se)|0,k=k+Math.imul(Zt,m)|0,p=p+Math.imul(Zt,I)|0,p=p+Math.imul(Wt,m)|0,M=M+Math.imul(Wt,I)|0,k=k+Math.imul(_t,l)|0,p=p+Math.imul(_t,A)|0,p=p+Math.imul(Ut,l)|0,M=M+Math.imul(Ut,A)|0,k=k+Math.imul(tt,K)|0,p=p+Math.imul(tt,J)|0,p=p+Math.imul(ft,K)|0,M=M+Math.imul(ft,J)|0;var jt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(jt>>>26)|0,jt&=67108863,k=Math.imul(b,lt),p=Math.imul(b,ht),p=p+Math.imul(S,lt)|0,M=Math.imul(S,ht),k=k+Math.imul(i,st)|0,p=p+Math.imul(i,$e)|0,p=p+Math.imul(h,st)|0,M=M+Math.imul(h,$e)|0,k=k+Math.imul(ke,Ye)|0,p=p+Math.imul(ke,Xe)|0,p=p+Math.imul(c,Ye)|0,M=M+Math.imul(c,Xe)|0,k=k+Math.imul(fe,Ce)|0,p=p+Math.imul(fe,Oe)|0,p=p+Math.imul(be,Ce)|0,M=M+Math.imul(be,Oe)|0,k=k+Math.imul(we,qe)|0,p=p+Math.imul(we,He)|0,p=p+Math.imul(ce,qe)|0,M=M+Math.imul(ce,He)|0,k=k+Math.imul(de,Qe)|0,p=p+Math.imul(de,Se)|0,p=p+Math.imul(Pe,Qe)|0,M=M+Math.imul(Pe,Se)|0,k=k+Math.imul(zt,m)|0,p=p+Math.imul(zt,I)|0,p=p+Math.imul(ge,m)|0,M=M+Math.imul(ge,I)|0,k=k+Math.imul(Zt,l)|0,p=p+Math.imul(Zt,A)|0,p=p+Math.imul(Wt,l)|0,M=M+Math.imul(Wt,A)|0,k=k+Math.imul(_t,K)|0,p=p+Math.imul(_t,J)|0,p=p+Math.imul(Ut,K)|0,M=M+Math.imul(Ut,J)|0,k=k+Math.imul(tt,wt)|0,p=p+Math.imul(tt,yt)|0,p=p+Math.imul(ft,wt)|0,M=M+Math.imul(ft,yt)|0;var At=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(At>>>26)|0,At&=67108863,k=Math.imul(b,st),p=Math.imul(b,$e),p=p+Math.imul(S,st)|0,M=Math.imul(S,$e),k=k+Math.imul(i,Ye)|0,p=p+Math.imul(i,Xe)|0,p=p+Math.imul(h,Ye)|0,M=M+Math.imul(h,Xe)|0,k=k+Math.imul(ke,Ce)|0,p=p+Math.imul(ke,Oe)|0,p=p+Math.imul(c,Ce)|0,M=M+Math.imul(c,Oe)|0,k=k+Math.imul(fe,qe)|0,p=p+Math.imul(fe,He)|0,p=p+Math.imul(be,qe)|0,M=M+Math.imul(be,He)|0,k=k+Math.imul(we,Qe)|0,p=p+Math.imul(we,Se)|0,p=p+Math.imul(ce,Qe)|0,M=M+Math.imul(ce,Se)|0,k=k+Math.imul(de,m)|0,p=p+Math.imul(de,I)|0,p=p+Math.imul(Pe,m)|0,M=M+Math.imul(Pe,I)|0,k=k+Math.imul(zt,l)|0,p=p+Math.imul(zt,A)|0,p=p+Math.imul(ge,l)|0,M=M+Math.imul(ge,A)|0,k=k+Math.imul(Zt,K)|0,p=p+Math.imul(Zt,J)|0,p=p+Math.imul(Wt,K)|0,M=M+Math.imul(Wt,J)|0,k=k+Math.imul(_t,wt)|0,p=p+Math.imul(_t,yt)|0,p=p+Math.imul(Ut,wt)|0,M=M+Math.imul(Ut,yt)|0;var Ft=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,k=Math.imul(b,Ye),p=Math.imul(b,Xe),p=p+Math.imul(S,Ye)|0,M=Math.imul(S,Xe),k=k+Math.imul(i,Ce)|0,p=p+Math.imul(i,Oe)|0,p=p+Math.imul(h,Ce)|0,M=M+Math.imul(h,Oe)|0,k=k+Math.imul(ke,qe)|0,p=p+Math.imul(ke,He)|0,p=p+Math.imul(c,qe)|0,M=M+Math.imul(c,He)|0,k=k+Math.imul(fe,Qe)|0,p=p+Math.imul(fe,Se)|0,p=p+Math.imul(be,Qe)|0,M=M+Math.imul(be,Se)|0,k=k+Math.imul(we,m)|0,p=p+Math.imul(we,I)|0,p=p+Math.imul(ce,m)|0,M=M+Math.imul(ce,I)|0,k=k+Math.imul(de,l)|0,p=p+Math.imul(de,A)|0,p=p+Math.imul(Pe,l)|0,M=M+Math.imul(Pe,A)|0,k=k+Math.imul(zt,K)|0,p=p+Math.imul(zt,J)|0,p=p+Math.imul(ge,K)|0,M=M+Math.imul(ge,J)|0,k=k+Math.imul(Zt,wt)|0,p=p+Math.imul(Zt,yt)|0,p=p+Math.imul(Wt,wt)|0,M=M+Math.imul(Wt,yt)|0;var It=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(It>>>26)|0,It&=67108863,k=Math.imul(b,Ce),p=Math.imul(b,Oe),p=p+Math.imul(S,Ce)|0,M=Math.imul(S,Oe),k=k+Math.imul(i,qe)|0,p=p+Math.imul(i,He)|0,p=p+Math.imul(h,qe)|0,M=M+Math.imul(h,He)|0,k=k+Math.imul(ke,Qe)|0,p=p+Math.imul(ke,Se)|0,p=p+Math.imul(c,Qe)|0,M=M+Math.imul(c,Se)|0,k=k+Math.imul(fe,m)|0,p=p+Math.imul(fe,I)|0,p=p+Math.imul(be,m)|0,M=M+Math.imul(be,I)|0,k=k+Math.imul(we,l)|0,p=p+Math.imul(we,A)|0,p=p+Math.imul(ce,l)|0,M=M+Math.imul(ce,A)|0,k=k+Math.imul(de,K)|0,p=p+Math.imul(de,J)|0,p=p+Math.imul(Pe,K)|0,M=M+Math.imul(Pe,J)|0,k=k+Math.imul(zt,wt)|0,p=p+Math.imul(zt,yt)|0,p=p+Math.imul(ge,wt)|0,M=M+Math.imul(ge,yt)|0;var Rt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,k=Math.imul(b,qe),p=Math.imul(b,He),p=p+Math.imul(S,qe)|0,M=Math.imul(S,He),k=k+Math.imul(i,Qe)|0,p=p+Math.imul(i,Se)|0,p=p+Math.imul(h,Qe)|0,M=M+Math.imul(h,Se)|0,k=k+Math.imul(ke,m)|0,p=p+Math.imul(ke,I)|0,p=p+Math.imul(c,m)|0,M=M+Math.imul(c,I)|0,k=k+Math.imul(fe,l)|0,p=p+Math.imul(fe,A)|0,p=p+Math.imul(be,l)|0,M=M+Math.imul(be,A)|0,k=k+Math.imul(we,K)|0,p=p+Math.imul(we,J)|0,p=p+Math.imul(ce,K)|0,M=M+Math.imul(ce,J)|0,k=k+Math.imul(de,wt)|0,p=p+Math.imul(de,yt)|0,p=p+Math.imul(Pe,wt)|0,M=M+Math.imul(Pe,yt)|0;var Tt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,k=Math.imul(b,Qe),p=Math.imul(b,Se),p=p+Math.imul(S,Qe)|0,M=Math.imul(S,Se),k=k+Math.imul(i,m)|0,p=p+Math.imul(i,I)|0,p=p+Math.imul(h,m)|0,M=M+Math.imul(h,I)|0,k=k+Math.imul(ke,l)|0,p=p+Math.imul(ke,A)|0,p=p+Math.imul(c,l)|0,M=M+Math.imul(c,A)|0,k=k+Math.imul(fe,K)|0,p=p+Math.imul(fe,J)|0,p=p+Math.imul(be,K)|0,M=M+Math.imul(be,J)|0,k=k+Math.imul(we,wt)|0,p=p+Math.imul(we,yt)|0,p=p+Math.imul(ce,wt)|0,M=M+Math.imul(ce,yt)|0;var xt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(xt>>>26)|0,xt&=67108863,k=Math.imul(b,m),p=Math.imul(b,I),p=p+Math.imul(S,m)|0,M=Math.imul(S,I),k=k+Math.imul(i,l)|0,p=p+Math.imul(i,A)|0,p=p+Math.imul(h,l)|0,M=M+Math.imul(h,A)|0,k=k+Math.imul(ke,K)|0,p=p+Math.imul(ke,J)|0,p=p+Math.imul(c,K)|0,M=M+Math.imul(c,J)|0,k=k+Math.imul(fe,wt)|0,p=p+Math.imul(fe,yt)|0,p=p+Math.imul(be,wt)|0,M=M+Math.imul(be,yt)|0;var Y=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Y>>>26)|0,Y&=67108863,k=Math.imul(b,l),p=Math.imul(b,A),p=p+Math.imul(S,l)|0,M=Math.imul(S,A),k=k+Math.imul(i,K)|0,p=p+Math.imul(i,J)|0,p=p+Math.imul(h,K)|0,M=M+Math.imul(h,J)|0,k=k+Math.imul(ke,wt)|0,p=p+Math.imul(ke,yt)|0,p=p+Math.imul(c,wt)|0,M=M+Math.imul(c,yt)|0;var Z=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Z>>>26)|0,Z&=67108863,k=Math.imul(b,K),p=Math.imul(b,J),p=p+Math.imul(S,K)|0,M=Math.imul(S,J),k=k+Math.imul(i,wt)|0,p=p+Math.imul(i,yt)|0,p=p+Math.imul(h,wt)|0,M=M+Math.imul(h,yt)|0;var ct=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(ct>>>26)|0,ct&=67108863,k=Math.imul(b,wt),p=Math.imul(b,yt),p=p+Math.imul(S,wt)|0,M=Math.imul(S,yt);var nt=(N+k|0)+((p&8191)<<13)|0;return N=(M+(p>>>13)|0)+(nt>>>26)|0,nt&=67108863,T[0]=ye,T[1]=vt,T[2]=Kt,T[3]=qt,T[4]=Xt,T[5]=Jt,T[6]=Ht,T[7]=Gt,T[8]=jt,T[9]=At,T[10]=Ft,T[11]=It,T[12]=Rt,T[13]=Tt,T[14]=xt,T[15]=Y,T[16]=Z,T[17]=ct,T[18]=nt,N!==0&&(T[19]=N,E.length++),E};Math.imul||(X=$);function j(U,d,w){w.negative=d.negative^U.negative,w.length=U.length+d.length;for(var E=0,P=0,R=0;R<w.length-1;R++){var T=P;P=0;for(var N=E&67108863,k=Math.min(R,d.length-1),p=Math.max(0,R-U.length+1);p<=k;p++){var M=R-p,at=U.words[M]|0,tt=d.words[p]|0,ft=at*tt,Lt=ft&67108863;T=T+(ft/67108864|0)|0,Lt=Lt+N|0,N=Lt&67108863,T=T+(Lt>>>26)|0,P+=T>>>26,T&=67108863}w.words[R]=N,E=T,T=P}return E!==0?w.words[R]=E:w.length--,w._strip()}function it(U,d,w){return j(U,d,w)}s.prototype.mulTo=function(d,w){var E,P=this.length+d.length;return this.length===10&&d.length===10?E=X(this,d,w):P<63?E=$(this,d,w):P<1024?E=j(this,d,w):E=it(this,d,w),E},s.prototype.mul=function(d){var w=new s(null);return w.words=new Array(this.length+d.length),this.mulTo(d,w)},s.prototype.mulf=function(d){var w=new s(null);return w.words=new Array(this.length+d.length),it(this,d,w)},s.prototype.imul=function(d){return this.clone().mulTo(d,this)},s.prototype.imuln=function(d){var w=d<0;w&&(d=-d),n(typeof d=="number"),n(d<67108864);for(var E=0,P=0;P<this.length;P++){var R=(this.words[P]|0)*d,T=(R&67108863)+(E&67108863);E>>=26,E+=R/67108864|0,E+=T>>>26,this.words[P]=T&67108863}return E!==0&&(this.words[P]=E,this.length++),w?this.ineg():this},s.prototype.muln=function(d){return this.clone().imuln(d)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(d){var w=z(d);if(w.length===0)return new s(1);for(var E=this,P=0;P<w.length&&w[P]===0;P++,E=E.sqr());if(++P<w.length)for(var R=E.sqr();P<w.length;P++,R=R.sqr())w[P]!==0&&(E=E.mul(R));return E},s.prototype.iushln=function(d){n(typeof d=="number"&&d>=0);var w=d%26,E=(d-w)/26,P=67108863>>>26-w<<26-w,R;if(w!==0){var T=0;for(R=0;R<this.length;R++){var N=this.words[R]&P,k=(this.words[R]|0)-N<<w;this.words[R]=k|T,T=N>>>26-w}T&&(this.words[R]=T,this.length++)}if(E!==0){for(R=this.length-1;R>=0;R--)this.words[R+E]=this.words[R];for(R=0;R<E;R++)this.words[R]=0;this.length+=E}return this._strip()},s.prototype.ishln=function(d){return n(this.negative===0),this.iushln(d)},s.prototype.iushrn=function(d,w,E){n(typeof d=="number"&&d>=0);var P;w?P=(w-w%26)/26:P=0;var R=d%26,T=Math.min((d-R)/26,this.length),N=67108863^67108863>>>R<<R,k=E;if(P-=T,P=Math.max(0,P),k){for(var p=0;p<T;p++)k.words[p]=this.words[p];k.length=T}if(T!==0)if(this.length>T)for(this.length-=T,p=0;p<this.length;p++)this.words[p]=this.words[p+T];else this.words[0]=0,this.length=1;var M=0;for(p=this.length-1;p>=0&&(M!==0||p>=P);p--){var at=this.words[p]|0;this.words[p]=M<<26-R|at>>>R,M=at&N}return k&&M!==0&&(k.words[k.length++]=M),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(d,w,E){return n(this.negative===0),this.iushrn(d,w,E)},s.prototype.shln=function(d){return this.clone().ishln(d)},s.prototype.ushln=function(d){return this.clone().iushln(d)},s.prototype.shrn=function(d){return this.clone().ishrn(d)},s.prototype.ushrn=function(d){return this.clone().iushrn(d)},s.prototype.testn=function(d){n(typeof d=="number"&&d>=0);var w=d%26,E=(d-w)/26,P=1<<w;if(this.length<=E)return!1;var R=this.words[E];return!!(R&P)},s.prototype.imaskn=function(d){n(typeof d=="number"&&d>=0);var w=d%26,E=(d-w)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=E)return this;if(w!==0&&E++,this.length=Math.min(E,this.length),w!==0){var P=67108863^67108863>>>w<<w;this.words[this.length-1]&=P}return this._strip()},s.prototype.maskn=function(d){return this.clone().imaskn(d)},s.prototype.iaddn=function(d){return n(typeof d=="number"),n(d<67108864),d<0?this.isubn(-d):this.negative!==0?this.length===1&&(this.words[0]|0)<=d?(this.words[0]=d-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(d),this.negative=1,this):this._iaddn(d)},s.prototype._iaddn=function(d){this.words[0]+=d;for(var w=0;w<this.length&&this.words[w]>=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},s.prototype.isubn=function(d){if(n(typeof d=="number"),n(d<67108864),d<0)return this.iaddn(-d);if(this.negative!==0)return this.negative=0,this.iaddn(d),this.negative=1,this;if(this.words[0]-=d,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w<this.length&&this.words[w]<0;w++)this.words[w]+=67108864,this.words[w+1]-=1;return this._strip()},s.prototype.addn=function(d){return this.clone().iaddn(d)},s.prototype.subn=function(d){return this.clone().isubn(d)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(d,w,E){var P=d.length+E,R;this._expand(P);var T,N=0;for(R=0;R<d.length;R++){T=(this.words[R+E]|0)+N;var k=(d.words[R]|0)*w;T-=k&67108863,N=(T>>26)-(k/67108864|0),this.words[R+E]=T&67108863}for(;R<this.length-E;R++)T=(this.words[R+E]|0)+N,N=T>>26,this.words[R+E]=T&67108863;if(N===0)return this._strip();for(n(N===-1),N=0,R=0;R<this.length;R++)T=-(this.words[R]|0)+N,N=T>>26,this.words[R]=T&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(d,w){var E=this.length-d.length,P=this.clone(),R=d,T=R.words[R.length-1]|0,N=this._countBits(T);E=26-N,E!==0&&(R=R.ushln(E),P.iushln(E),T=R.words[R.length-1]|0);var k=P.length-R.length,p;if(w!=="mod"){p=new s(null),p.length=k+1,p.words=new Array(p.length);for(var M=0;M<p.length;M++)p.words[M]=0}var at=P.clone()._ishlnsubmul(R,1,k);at.negative===0&&(P=at,p&&(p.words[k]=1));for(var tt=k-1;tt>=0;tt--){var ft=(P.words[R.length+tt]|0)*67108864+(P.words[R.length+tt-1]|0);for(ft=Math.min(ft/T|0,67108863),P._ishlnsubmul(R,ft,tt);P.negative!==0;)ft--,P.negative=0,P._ishlnsubmul(R,1,tt),P.isZero()||(P.negative^=1);p&&(p.words[tt]=ft)}return p&&p._strip(),P._strip(),w!=="div"&&E!==0&&P.iushrn(E),{div:p||null,mod:P}},s.prototype.divmod=function(d,w,E){if(n(!d.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var P,R,T;return this.negative!==0&&d.negative===0?(T=this.neg().divmod(d,w),w!=="mod"&&(P=T.div.neg()),w!=="div"&&(R=T.mod.neg(),E&&R.negative!==0&&R.iadd(d)),{div:P,mod:R}):this.negative===0&&d.negative!==0?(T=this.divmod(d.neg(),w),w!=="mod"&&(P=T.div.neg()),{div:P,mod:T.mod}):this.negative&d.negative?(T=this.neg().divmod(d.neg(),w),w!=="div"&&(R=T.mod.neg(),E&&R.negative!==0&&R.isub(d)),{div:T.div,mod:R}):d.length>this.length||this.cmp(d)<0?{div:new s(0),mod:this}:d.length===1?w==="div"?{div:this.divn(d.words[0]),mod:null}:w==="mod"?{div:null,mod:new s(this.modrn(d.words[0]))}:{div:this.divn(d.words[0]),mod:new s(this.modrn(d.words[0]))}:this._wordDiv(d,w)},s.prototype.div=function(d){return this.divmod(d,"div",!1).div},s.prototype.mod=function(d){return this.divmod(d,"mod",!1).mod},s.prototype.umod=function(d){return this.divmod(d,"mod",!0).mod},s.prototype.divRound=function(d){var w=this.divmod(d);if(w.mod.isZero())return w.div;var E=w.div.negative!==0?w.mod.isub(d):w.mod,P=d.ushrn(1),R=d.andln(1),T=E.cmp(P);return T<0||R===1&&T===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},s.prototype.modrn=function(d){var w=d<0;w&&(d=-d),n(d<=67108863);for(var E=(1<<26)%d,P=0,R=this.length-1;R>=0;R--)P=(E*P+(this.words[R]|0))%d;return w?-P:P},s.prototype.modn=function(d){return this.modrn(d)},s.prototype.idivn=function(d){var w=d<0;w&&(d=-d),n(d<=67108863);for(var E=0,P=this.length-1;P>=0;P--){var R=(this.words[P]|0)+E*67108864;this.words[P]=R/d|0,E=R%d}return this._strip(),w?this.ineg():this},s.prototype.divn=function(d){return this.clone().idivn(d)},s.prototype.egcd=function(d){n(d.negative===0),n(!d.isZero());var w=this,E=d.clone();w.negative!==0?w=w.umod(d):w=w.clone();for(var P=new s(1),R=new s(0),T=new s(0),N=new s(1),k=0;w.isEven()&&E.isEven();)w.iushrn(1),E.iushrn(1),++k;for(var p=E.clone(),M=w.clone();!w.isZero();){for(var at=0,tt=1;!(w.words[0]&tt)&&at<26;++at,tt<<=1);if(at>0)for(w.iushrn(at);at-- >0;)(P.isOdd()||R.isOdd())&&(P.iadd(p),R.isub(M)),P.iushrn(1),R.iushrn(1);for(var ft=0,Lt=1;!(E.words[0]&Lt)&&ft<26;++ft,Lt<<=1);if(ft>0)for(E.iushrn(ft);ft-- >0;)(T.isOdd()||N.isOdd())&&(T.iadd(p),N.isub(M)),T.iushrn(1),N.iushrn(1);w.cmp(E)>=0?(w.isub(E),P.isub(T),R.isub(N)):(E.isub(w),T.isub(P),N.isub(R))}return{a:T,b:N,gcd:E.iushln(k)}},s.prototype._invmp=function(d){n(d.negative===0),n(!d.isZero());var w=this,E=d.clone();w.negative!==0?w=w.umod(d):w=w.clone();for(var P=new s(1),R=new s(0),T=E.clone();w.cmpn(1)>0&&E.cmpn(1)>0;){for(var N=0,k=1;!(w.words[0]&k)&&N<26;++N,k<<=1);if(N>0)for(w.iushrn(N);N-- >0;)P.isOdd()&&P.iadd(T),P.iushrn(1);for(var p=0,M=1;!(E.words[0]&M)&&p<26;++p,M<<=1);if(p>0)for(E.iushrn(p);p-- >0;)R.isOdd()&&R.iadd(T),R.iushrn(1);w.cmp(E)>=0?(w.isub(E),P.isub(R)):(E.isub(w),R.isub(P))}var at;return w.cmpn(1)===0?at=P:at=R,at.cmpn(0)<0&&at.iadd(d),at},s.prototype.gcd=function(d){if(this.isZero())return d.abs();if(d.isZero())return this.abs();var w=this.clone(),E=d.clone();w.negative=0,E.negative=0;for(var P=0;w.isEven()&&E.isEven();P++)w.iushrn(1),E.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;E.isEven();)E.iushrn(1);var R=w.cmp(E);if(R<0){var T=w;w=E,E=T}else if(R===0||E.cmpn(1)===0)break;w.isub(E)}while(!0);return E.iushln(P)},s.prototype.invm=function(d){return this.egcd(d).a.umod(d)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(d){return this.words[0]&d},s.prototype.bincn=function(d){n(typeof d=="number");var w=d%26,E=(d-w)/26,P=1<<w;if(this.length<=E)return this._expand(E+1),this.words[E]|=P,this;for(var R=P,T=E;R!==0&&T<this.length;T++){var N=this.words[T]|0;N+=R,R=N>>>26,N&=67108863,this.words[T]=N}return R!==0&&(this.words[T]=R,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(d){var w=d<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this._strip();var E;if(this.length>1)E=1;else{w&&(d=-d),n(d<=67108863,"Number is too big");var P=this.words[0]|0;E=P===d?0:P<d?-1:1}return this.negative!==0?-E|0:E},s.prototype.cmp=function(d){if(this.negative!==0&&d.negative===0)return-1;if(this.negative===0&&d.negative!==0)return 1;var w=this.ucmp(d);return this.negative!==0?-w|0:w},s.prototype.ucmp=function(d){if(this.length>d.length)return 1;if(this.length<d.length)return-1;for(var w=0,E=this.length-1;E>=0;E--){var P=this.words[E]|0,R=d.words[E]|0;if(P!==R){P<R?w=-1:P>R&&(w=1);break}}return w},s.prototype.gtn=function(d){return this.cmpn(d)===1},s.prototype.gt=function(d){return this.cmp(d)===1},s.prototype.gten=function(d){return this.cmpn(d)>=0},s.prototype.gte=function(d){return this.cmp(d)>=0},s.prototype.ltn=function(d){return this.cmpn(d)===-1},s.prototype.lt=function(d){return this.cmp(d)===-1},s.prototype.lten=function(d){return this.cmpn(d)<=0},s.prototype.lte=function(d){return this.cmp(d)<=0},s.prototype.eqn=function(d){return this.cmpn(d)===0},s.prototype.eq=function(d){return this.cmp(d)===0},s.red=function(d){return new Bt(d)},s.prototype.toRed=function(d){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),d.convertTo(this)._forceRed(d)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(d){return this.red=d,this},s.prototype.forceRed=function(d){return n(!this.red,"Already a number in reduction context"),this._forceRed(d)},s.prototype.redAdd=function(d){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,d)},s.prototype.redIAdd=function(d){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,d)},s.prototype.redSub=function(d){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,d)},s.prototype.redISub=function(d){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,d)},s.prototype.redShl=function(d){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,d)},s.prototype.redMul=function(d){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.mul(this,d)},s.prototype.redIMul=function(d){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.imul(this,d)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(d){return n(this.red&&!d.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,d)};var G={k256:null,p224:null,p192:null,p25519:null};function W(U,d){this.name=U,this.p=new s(d,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}W.prototype._tmp=function(){var d=new s(null);return d.words=new Array(Math.ceil(this.n/13)),d},W.prototype.ireduce=function(d){var w=d,E;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),E=w.bitLength();while(E>this.n);var P=E<this.n?-1:w.ucmp(this.p);return P===0?(w.words[0]=0,w.length=1):P>0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},W.prototype.split=function(d,w){d.iushrn(this.n,0,w)},W.prototype.imulK=function(d){return d.imul(this.k)};function Q(){W.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}a(Q,W),Q.prototype.split=function(d,w){for(var E=4194303,P=Math.min(d.length,9),R=0;R<P;R++)w.words[R]=d.words[R];if(w.length=P,d.length<=9){d.words[0]=0,d.length=1;return}var T=d.words[9];for(w.words[w.length++]=T&E,R=10;R<d.length;R++){var N=d.words[R]|0;d.words[R-10]=(N&E)<<4|T>>>22,T=N}T>>>=22,d.words[R-10]=T,T===0&&d.length>10?d.length-=10:d.length-=9},Q.prototype.imulK=function(d){d.words[d.length]=0,d.words[d.length+1]=0,d.length+=2;for(var w=0,E=0;E<d.length;E++){var P=d.words[E]|0;w+=P*977,d.words[E]=w&67108863,w=P*64+(w/67108864|0)}return d.words[d.length-1]===0&&(d.length--,d.words[d.length-1]===0&&d.length--),d};function rt(){W.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}a(rt,W);function ae(){W.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}a(ae,W);function Vt(){W.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}a(Vt,W),Vt.prototype.imulK=function(d){for(var w=0,E=0;E<d.length;E++){var P=(d.words[E]|0)*19+w,R=P&67108863;P>>>=26,d.words[E]=R,w=P}return w!==0&&(d.words[d.length++]=w),d},s._prime=function(d){if(G[d])return G[d];var w;if(d==="k256")w=new Q;else if(d==="p224")w=new rt;else if(d==="p192")w=new ae;else if(d==="p25519")w=new Vt;else throw new Error("Unknown prime "+d);return G[d]=w,w};function Bt(U){if(typeof U=="string"){var d=s._prime(U);this.m=d.p,this.prime=d}else n(U.gtn(1),"modulus must be greater than 1"),this.m=U,this.prime=null}Bt.prototype._verify1=function(d){n(d.negative===0,"red works only with positives"),n(d.red,"red works only with red numbers")},Bt.prototype._verify2=function(d,w){n((d.negative|w.negative)===0,"red works only with positives"),n(d.red&&d.red===w.red,"red works only with red numbers")},Bt.prototype.imod=function(d){return this.prime?this.prime.ireduce(d)._forceRed(this):(v(d,d.umod(this.m)._forceRed(this)),d)},Bt.prototype.neg=function(d){return d.isZero()?d.clone():this.m.sub(d)._forceRed(this)},Bt.prototype.add=function(d,w){this._verify2(d,w);var E=d.add(w);return E.cmp(this.m)>=0&&E.isub(this.m),E._forceRed(this)},Bt.prototype.iadd=function(d,w){this._verify2(d,w);var E=d.iadd(w);return E.cmp(this.m)>=0&&E.isub(this.m),E},Bt.prototype.sub=function(d,w){this._verify2(d,w);var E=d.sub(w);return E.cmpn(0)<0&&E.iadd(this.m),E._forceRed(this)},Bt.prototype.isub=function(d,w){this._verify2(d,w);var E=d.isub(w);return E.cmpn(0)<0&&E.iadd(this.m),E},Bt.prototype.shl=function(d,w){return this._verify1(d),this.imod(d.ushln(w))},Bt.prototype.imul=function(d,w){return this._verify2(d,w),this.imod(d.imul(w))},Bt.prototype.mul=function(d,w){return this._verify2(d,w),this.imod(d.mul(w))},Bt.prototype.isqr=function(d){return this.imul(d,d.clone())},Bt.prototype.sqr=function(d){return this.mul(d,d)},Bt.prototype.sqrt=function(d){if(d.isZero())return d.clone();var w=this.m.andln(3);if(n(w%2===1),w===3){var E=this.m.add(new s(1)).iushrn(2);return this.pow(d,E)}for(var P=this.m.subn(1),R=0;!P.isZero()&&P.andln(1)===0;)R++,P.iushrn(1);n(!P.isZero());var T=new s(1).toRed(this),N=T.redNeg(),k=this.m.subn(1).iushrn(1),p=this.m.bitLength();for(p=new s(2*p*p).toRed(this);this.pow(p,k).cmp(N)!==0;)p.redIAdd(N);for(var M=this.pow(p,P),at=this.pow(d,P.addn(1).iushrn(1)),tt=this.pow(d,P),ft=R;tt.cmp(T)!==0;){for(var Lt=tt,_t=0;Lt.cmp(T)!==0;_t++)Lt=Lt.redSqr();n(_t<ft);var Ut=this.pow(M,new s(1).iushln(ft-_t-1));at=at.redMul(Ut),M=Ut.redSqr(),tt=tt.redMul(M),ft=_t}return at},Bt.prototype.invm=function(d){var w=d._invmp(this.m);return w.negative!==0?(w.negative=0,this.imod(w).redNeg()):this.imod(w)},Bt.prototype.pow=function(d,w){if(w.isZero())return new s(1).toRed(this);if(w.cmpn(1)===0)return d.clone();var E=4,P=new Array(1<<E);P[0]=new s(1).toRed(this),P[1]=d;for(var R=2;R<P.length;R++)P[R]=this.mul(P[R-1],d);var T=P[0],N=0,k=0,p=w.bitLength()%26;for(p===0&&(p=26),R=w.length-1;R>=0;R--){for(var M=w.words[R],at=p-1;at>=0;at--){var tt=M>>at&1;if(T!==P[0]&&(T=this.sqr(T)),tt===0&&N===0){k=0;continue}N<<=1,N|=tt,k++,!(k!==E&&(R!==0||at!==0))&&(T=this.mul(T,P[N]),k=0,N=0)}p=26}return T},Bt.prototype.convertTo=function(d){var w=d.umod(this.m);return w===d?w.clone():w},Bt.prototype.convertFrom=function(d){var w=d.clone();return w.red=null,w},s.mont=function(d){return new re(d)};function re(U){Bt.call(this,U),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}a(re,Bt),re.prototype.convertTo=function(d){return this.imod(d.ushln(this.shift))},re.prototype.convertFrom=function(d){var w=this.imod(d.mul(this.rinv));return w.red=null,w},re.prototype.imul=function(d,w){if(d.isZero()||w.isZero())return d.words[0]=0,d.length=1,d;var E=d.imul(w),P=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),R=E.isub(P).iushrn(this.shift),T=R;return R.cmp(this.m)>=0?T=R.isub(this.m):R.cmpn(0)<0&&(T=R.iadd(this.m)),T._forceRed(this)},re.prototype.mul=function(d,w){if(d.isZero()||w.isZero())return new s(0)._forceRed(this);var E=d.mul(w),P=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),R=E.isub(P).iushrn(this.shift),T=R;return R.cmp(this.m)>=0?T=R.isub(this.m):R.cmpn(0)<0&&(T=R.iadd(this.m)),T._forceRed(this)},re.prototype.invm=function(d){var w=this.imod(d._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(o,Or)}(Bo);var na=Bo.exports;const ia=ii(na);var vo={exports:{}},oa={};/*!
6
+ */(function(o){const t=On,e=oi,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;o.Buffer=u,o.SlowBuffer=X,o.INSPECT_MAX_BYTES=50;const a=2147483647;o.kMaxLength=a,u.TYPED_ARRAY_SUPPORT=s(),!u.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 s(){try{const c=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(c,r),c.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function f(c){if(c>a)throw new RangeError('The value "'+c+'" is invalid for option "size"');const r=new Uint8Array(c);return Object.setPrototypeOf(r,u.prototype),r}function u(c,r,i){if(typeof c=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(c)}return y(c,r,i)}u.poolSize=8192;function y(c,r,i){if(typeof c=="string")return F(c,r);if(ArrayBuffer.isView(c))return D(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(Qt(c,ArrayBuffer)||c&&Qt(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Qt(c,SharedArrayBuffer)||c&&Qt(c.buffer,SharedArrayBuffer)))return U(c,r,i);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const h=c.valueOf&&c.valueOf();if(h!=null&&h!==c)return u.from(h,r,i);const g=z(c);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return u.from(c[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}u.from=function(c,r,i){return y(c,r,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function x(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function B(c,r,i){return x(c),c<=0?f(c):r!==void 0?typeof i=="string"?f(c).fill(r,i):f(c).fill(r):f(c)}u.alloc=function(c,r,i){return B(c,r,i)};function v(c){return x(c),f(c<0?0:$(c)|0)}u.allocUnsafe=function(c){return v(c)},u.allocUnsafeSlow=function(c){return v(c)};function F(c,r){if((typeof r!="string"||r==="")&&(r="utf8"),!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const i=V(c,r)|0;let h=f(i);const g=h.write(c,r);return g!==i&&(h=h.slice(0,g)),h}function L(c){const r=c.length<0?0:$(c.length)|0,i=f(r);for(let h=0;h<r;h+=1)i[h]=c[h]&255;return i}function D(c){if(Qt(c,Uint8Array)){const r=new Uint8Array(c);return U(r.buffer,r.byteOffset,r.byteLength)}return L(c)}function U(c,r,i){if(r<0||c.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let h;return r===void 0&&i===void 0?h=new Uint8Array(c):i===void 0?h=new Uint8Array(c,r):h=new Uint8Array(c,r,i),Object.setPrototypeOf(h,u.prototype),h}function z(c){if(u.isBuffer(c)){const r=$(c.length)|0,i=f(r);return i.length===0||c.copy(i,0,0,r),i}if(c.length!==void 0)return typeof c.length!="number"||fe(c.length)?f(0):L(c);if(c.type==="Buffer"&&Array.isArray(c.data))return L(c.data)}function $(c){if(c>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return c|0}function X(c){return+c!=c&&(c=0),u.alloc(+c)}u.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==u.prototype},u.compare=function(r,i){if(Qt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),Qt(i,Uint8Array)&&(i=u.from(i,i.offset,i.byteLength)),!u.isBuffer(r)||!u.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let h=r.length,g=i.length;for(let b=0,S=Math.min(h,g);b<S;++b)if(r[b]!==i[b]){h=r[b],g=i[b];break}return h<g?-1:g<h?1:0},u.isEncoding=function(r){switch(String(r).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}},u.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);let h;if(i===void 0)for(i=0,h=0;h<r.length;++h)i+=r[h].length;const g=u.allocUnsafe(i);let b=0;for(h=0;h<r.length;++h){let S=r[h];if(Qt(S,Uint8Array))b+S.length>g.length?(u.isBuffer(S)||(S=u.from(S)),S.copy(g,b)):Uint8Array.prototype.set.call(g,S,b);else if(u.isBuffer(S))S.copy(g,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=S.length}return g};function V(c,r){if(u.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||Qt(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const i=c.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&i===0)return 0;let g=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return de(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return me(c).length;default:if(g)return h?-1:de(c).length;r=(""+r).toLowerCase(),g=!0}}u.byteLength=V;function it(c,r,i){let h=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(c||(c="utf8");;)switch(c){case"hex":return T(this,r,i);case"utf8":case"utf-8":return d(this,r,i);case"ascii":return C(this,r,i);case"latin1":case"binary":return R(this,r,i);case"base64":return P(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,r,i);default:if(h)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),h=!0}}u.prototype._isBuffer=!0;function G(c,r,i){const h=c[r];c[r]=c[i],c[i]=h}u.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)G(this,i,i+1);return this},u.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)G(this,i,i+3),G(this,i+1,i+2);return this},u.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)G(this,i,i+7),G(this,i+1,i+6),G(this,i+2,i+5),G(this,i+3,i+4);return this},u.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?d(this,0,r):it.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(r){if(!u.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0},u.prototype.inspect=function(){let r="";const i=o.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(r,i,h,g,b){if(Qt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),h===void 0&&(h=r?r.length:0),g===void 0&&(g=0),b===void 0&&(b=this.length),i<0||h>r.length||g<0||b>this.length)throw new RangeError("out of range index");if(g>=b&&i>=h)return 0;if(g>=b)return-1;if(i>=h)return 1;if(i>>>=0,h>>>=0,g>>>=0,b>>>=0,this===r)return 0;let S=b-g,et=h-i;const lt=Math.min(S,et),ht=this.slice(g,b),kt=r.slice(i,h);for(let st=0;st<lt;++st)if(ht[st]!==kt[st]){S=ht[st],et=kt[st];break}return S<et?-1:et<S?1:0};function W(c,r,i,h,g){if(c.length===0)return-1;if(typeof i=="string"?(h=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,fe(i)&&(i=g?0:c.length-1),i<0&&(i=c.length+i),i>=c.length){if(g)return-1;i=c.length-1}else if(i<0)if(g)i=0;else return-1;if(typeof r=="string"&&(r=u.from(r,h)),u.isBuffer(r))return r.length===0?-1:Q(c,r,i,h,g);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?g?Uint8Array.prototype.indexOf.call(c,r,i):Uint8Array.prototype.lastIndexOf.call(c,r,i):Q(c,[r],i,h,g);throw new TypeError("val must be string, number or Buffer")}function Q(c,r,i,h,g){let b=1,S=c.length,et=r.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(c.length<2||r.length<2)return-1;b=2,S/=2,et/=2,i/=2}function lt(kt,st){return b===1?kt[st]:kt.readUInt16BE(st*b)}let ht;if(g){let kt=-1;for(ht=i;ht<S;ht++)if(lt(c,ht)===lt(r,kt===-1?0:ht-kt)){if(kt===-1&&(kt=ht),ht-kt+1===et)return kt*b}else kt!==-1&&(ht-=ht-kt),kt=-1}else for(i+et>S&&(i=S-et),ht=i;ht>=0;ht--){let kt=!0;for(let st=0;st<et;st++)if(lt(c,ht+st)!==lt(r,st)){kt=!1;break}if(kt)return ht}return-1}u.prototype.includes=function(r,i,h){return this.indexOf(r,i,h)!==-1},u.prototype.indexOf=function(r,i,h){return W(this,r,i,h,!0)},u.prototype.lastIndexOf=function(r,i,h){return W(this,r,i,h,!1)};function rt(c,r,i,h){i=Number(i)||0;const g=c.length-i;h?(h=Number(h),h>g&&(h=g)):h=g;const b=r.length;h>b/2&&(h=b/2);let S;for(S=0;S<h;++S){const et=parseInt(r.substr(S*2,2),16);if(fe(et))return S;c[i+S]=et}return S}function ae(c,r,i,h){return ce(de(r,c.length-i),c,i,h)}function jt(c,r,i,h){return ce(Ce(r),c,i,h)}function _t(c,r,i,h){return ce(me(r),c,i,h)}function re(c,r,i,h){return ce(hr(r,c.length-i),c,i,h)}u.prototype.write=function(r,i,h,g){if(i===void 0)g="utf8",h=this.length,i=0;else if(h===void 0&&typeof i=="string")g=i,h=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(h)?(h=h>>>0,g===void 0&&(g="utf8")):(g=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const b=this.length-i;if((h===void 0||h>b)&&(h=b),r.length>0&&(h<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let S=!1;for(;;)switch(g){case"hex":return rt(this,r,i,h);case"utf8":case"utf-8":return ae(this,r,i,h);case"ascii":case"latin1":case"binary":return jt(this,r,i,h);case"base64":return _t(this,r,i,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return re(this,r,i,h);default:if(S)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),S=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function P(c,r,i){return r===0&&i===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(r,i))}function d(c,r,i){i=Math.min(c.length,i);const h=[];let g=r;for(;g<i;){const b=c[g];let S=null,et=b>239?4:b>223?3:b>191?2:1;if(g+et<=i){let lt,ht,kt,st;switch(et){case 1:b<128&&(S=b);break;case 2:lt=c[g+1],(lt&192)===128&&(st=(b&31)<<6|lt&63,st>127&&(S=st));break;case 3:lt=c[g+1],ht=c[g+2],(lt&192)===128&&(ht&192)===128&&(st=(b&15)<<12|(lt&63)<<6|ht&63,st>2047&&(st<55296||st>57343)&&(S=st));break;case 4:lt=c[g+1],ht=c[g+2],kt=c[g+3],(lt&192)===128&&(ht&192)===128&&(kt&192)===128&&(st=(b&15)<<18|(lt&63)<<12|(ht&63)<<6|kt&63,st>65535&&st<1114112&&(S=st))}}S===null?(S=65533,et=1):S>65535&&(S-=65536,h.push(S>>>10&1023|55296),S=56320|S&1023),h.push(S),g+=et}return E(h)}const m=4096;function E(c){const r=c.length;if(r<=m)return String.fromCharCode.apply(String,c);let i="",h=0;for(;h<r;)i+=String.fromCharCode.apply(String,c.slice(h,h+=m));return i}function C(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]&127);return h}function R(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]);return h}function T(c,r,i){const h=c.length;(!r||r<0)&&(r=0),(!i||i<0||i>h)&&(i=h);let g="";for(let b=r;b<i;++b)g+=be[c[b]];return g}function N(c,r,i){const h=c.slice(r,i);let g="";for(let b=0;b<h.length-1;b+=2)g+=String.fromCharCode(h[b]+h[b+1]*256);return g}u.prototype.slice=function(r,i){const h=this.length;r=~~r,i=i===void 0?h:~~i,r<0?(r+=h,r<0&&(r=0)):r>h&&(r=h),i<0?(i+=h,i<0&&(i=0)):i>h&&(i=h),i<r&&(i=r);const g=this.subarray(r,i);return Object.setPrototypeOf(g,u.prototype),g};function k(c,r,i){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+r>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r],b=1,S=0;for(;++S<i&&(b*=256);)g+=this[r+S]*b;return g},u.prototype.readUintBE=u.prototype.readUIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r+--i],b=1;for(;i>0&&(b*=256);)g+=this[r+--i]*b;return g},u.prototype.readUint8=u.prototype.readUInt8=function(r,i){return r=r>>>0,i||k(r,1,this.length),this[r]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||k(r,2,this.length),this[r]|this[r+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||k(r,2,this.length),this[r]<<8|this[r+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||k(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},u.prototype.readBigUInt64LE=we(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,b=this[++r]+this[++r]*2**8+this[++r]*2**16+h*2**24;return BigInt(g)+(BigInt(b)<<BigInt(32))}),u.prototype.readBigUInt64BE=we(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=i*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],b=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h;return(BigInt(g)<<BigInt(32))+BigInt(b)}),u.prototype.readIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r],b=1,S=0;for(;++S<i&&(b*=256);)g+=this[r+S]*b;return b*=128,g>=b&&(g-=Math.pow(2,8*i)),g},u.prototype.readIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=i,b=1,S=this[r+--g];for(;g>0&&(b*=256);)S+=this[r+--g]*b;return b*=128,S>=b&&(S-=Math.pow(2,8*i)),S},u.prototype.readInt8=function(r,i){return r=r>>>0,i||k(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},u.prototype.readInt16LE=function(r,i){r=r>>>0,i||k(r,2,this.length);const h=this[r]|this[r+1]<<8;return h&32768?h|4294901760:h},u.prototype.readInt16BE=function(r,i){r=r>>>0,i||k(r,2,this.length);const h=this[r+1]|this[r]<<8;return h&32768?h|4294901760:h},u.prototype.readInt32LE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},u.prototype.readInt32BE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},u.prototype.readBigInt64LE=we(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(h<<24);return(BigInt(g)<<BigInt(32))+BigInt(i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),u.prototype.readBigInt64BE=we(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=(i<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(g)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h)}),u.prototype.readFloatLE=function(r,i){return r=r>>>0,i||k(r,4,this.length),e.read(this,r,!0,23,4)},u.prototype.readFloatBE=function(r,i){return r=r>>>0,i||k(r,4,this.length),e.read(this,r,!1,23,4)},u.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||k(r,8,this.length),e.read(this,r,!0,52,8)},u.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||k(r,8,this.length),e.read(this,r,!1,52,8)};function p(c,r,i,h,g,b){if(!u.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>g||r<b)throw new RangeError('"value" argument is out of bounds');if(i+h>c.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const et=Math.pow(2,8*h)-1;p(this,r,i,h,et,0)}let b=1,S=0;for(this[i]=r&255;++S<h&&(b*=256);)this[i+S]=r/b&255;return i+h},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const et=Math.pow(2,8*h)-1;p(this,r,i,h,et,0)}let b=h-1,S=1;for(this[i+b]=r&255;--b>=0&&(S*=256);)this[i+b]=r/S&255;return i+h},u.prototype.writeUint8=u.prototype.writeUInt8=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,1,255,0),this[i]=r&255,i+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function M(c,r,i,h,g){Wt(r,h,g,c,i,7);let b=Number(r&BigInt(4294967295));c[i++]=b,b=b>>8,c[i++]=b,b=b>>8,c[i++]=b,b=b>>8,c[i++]=b;let S=Number(r>>BigInt(32)&BigInt(4294967295));return c[i++]=S,S=S>>8,c[i++]=S,S=S>>8,c[i++]=S,S=S>>8,c[i++]=S,i}function at(c,r,i,h,g){Wt(r,h,g,c,i,7);let b=Number(r&BigInt(4294967295));c[i+7]=b,b=b>>8,c[i+6]=b,b=b>>8,c[i+5]=b,b=b>>8,c[i+4]=b;let S=Number(r>>BigInt(32)&BigInt(4294967295));return c[i+3]=S,S=S>>8,c[i+2]=S,S=S>>8,c[i+1]=S,S=S>>8,c[i]=S,i+8}u.prototype.writeBigUInt64LE=we(function(r,i=0){return M(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=we(function(r,i=0){return at(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const lt=Math.pow(2,8*h-1);p(this,r,i,h,lt-1,-lt)}let b=0,S=1,et=0;for(this[i]=r&255;++b<h&&(S*=256);)r<0&&et===0&&this[i+b-1]!==0&&(et=1),this[i+b]=(r/S>>0)-et&255;return i+h},u.prototype.writeIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const lt=Math.pow(2,8*h-1);p(this,r,i,h,lt-1,-lt)}let b=h-1,S=1,et=0;for(this[i+b]=r&255;--b>=0&&(S*=256);)r<0&&et===0&&this[i+b+1]!==0&&(et=1),this[i+b]=(r/S>>0)-et&255;return i+h},u.prototype.writeInt8=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},u.prototype.writeInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},u.prototype.writeInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},u.prototype.writeBigInt64LE=we(function(r,i=0){return M(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=we(function(r,i=0){return at(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function tt(c,r,i,h,g,b){if(i+h>c.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function ft(c,r,i,h,g){return r=+r,i=i>>>0,g||tt(c,r,i,4),e.write(c,r,i,h,23,4),i+4}u.prototype.writeFloatLE=function(r,i,h){return ft(this,r,i,!0,h)},u.prototype.writeFloatBE=function(r,i,h){return ft(this,r,i,!1,h)};function Lt(c,r,i,h,g){return r=+r,i=i>>>0,g||tt(c,r,i,8),e.write(c,r,i,h,52,8),i+8}u.prototype.writeDoubleLE=function(r,i,h){return Lt(this,r,i,!0,h)},u.prototype.writeDoubleBE=function(r,i,h){return Lt(this,r,i,!1,h)},u.prototype.copy=function(r,i,h,g){if(!u.isBuffer(r))throw new TypeError("argument should be a Buffer");if(h||(h=0),!g&&g!==0&&(g=this.length),i>=r.length&&(i=r.length),i||(i=0),g>0&&g<h&&(g=h),g===h||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),r.length-i<g-h&&(g=r.length-i+h);const b=g-h;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,h,g):Uint8Array.prototype.set.call(r,this.subarray(h,g),i),b},u.prototype.fill=function(r,i,h,g){if(typeof r=="string"){if(typeof i=="string"?(g=i,i=0,h=this.length):typeof h=="string"&&(g=h,h=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!u.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(r.length===1){const S=r.charCodeAt(0);(g==="utf8"&&S<128||g==="latin1")&&(r=S)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<h)throw new RangeError("Out of range index");if(h<=i)return this;i=i>>>0,h=h===void 0?this.length:h>>>0,r||(r=0);let b;if(typeof r=="number")for(b=i;b<h;++b)this[b]=r;else{const S=u.isBuffer(r)?r:u.from(r,g),et=S.length;if(et===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(b=0;b<h-i;++b)this[b+i]=S[b%et]}return this};const At={};function Ut(c,r,i){At[c]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Ut("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ut("ERR_INVALID_ARG_TYPE",function(c,r){return`The "${c}" argument must be of type number. Received type ${typeof r}`},TypeError),Ut("ERR_OUT_OF_RANGE",function(c,r,i){let h=`The value of "${c}" is out of range.`,g=i;return Number.isInteger(i)&&Math.abs(i)>2**32?g=Ee(String(i)):typeof i=="bigint"&&(g=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(g=Ee(g)),g+="n"),h+=` It must be ${r}. Received ${g}`,h},RangeError);function Ee(c){let r="",i=c.length;const h=c[0]==="-"?1:0;for(;i>=h+4;i-=3)r=`_${c.slice(i-3,i)}${r}`;return`${c.slice(0,i)}${r}`}function Zt(c,r,i){Yt(r,"offset"),(c[r]===void 0||c[r+i]===void 0)&&zt(r,c.length-(i+1))}function Wt(c,r,i,h,g,b){if(c>i||c<r){const S=typeof r=="bigint"?"n":"";let et;throw r===0||r===BigInt(0)?et=`>= 0${S} and < 2${S} ** ${(b+1)*8}${S}`:et=`>= -(2${S} ** ${(b+1)*8-1}${S}) and < 2 ** ${(b+1)*8-1}${S}`,new At.ERR_OUT_OF_RANGE("value",et,c)}Zt(h,g,b)}function Yt(c,r){if(typeof c!="number")throw new At.ERR_INVALID_ARG_TYPE(r,"number",c)}function zt(c,r,i){throw Math.floor(c)!==c?(Yt(c,i),new At.ERR_OUT_OF_RANGE("offset","an integer",c)):r<0?new At.ERR_BUFFER_OUT_OF_BOUNDS:new At.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,c)}const ge=/[^+/0-9A-Za-z-_]/g;function xr(c){if(c=c.split("=")[0],c=c.trim().replace(ge,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function de(c,r){r=r||1/0;let i;const h=c.length;let g=null;const b=[];for(let S=0;S<h;++S){if(i=c.charCodeAt(S),i>55295&&i<57344){if(!g){if(i>56319){(r-=3)>-1&&b.push(239,191,189);continue}else if(S+1===h){(r-=3)>-1&&b.push(239,191,189);continue}g=i;continue}if(i<56320){(r-=3)>-1&&b.push(239,191,189),g=i;continue}i=(g-55296<<10|i-56320)+65536}else g&&(r-=3)>-1&&b.push(239,191,189);if(g=null,i<128){if((r-=1)<0)break;b.push(i)}else if(i<2048){if((r-=2)<0)break;b.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;b.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;b.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return b}function Ce(c){const r=[];for(let i=0;i<c.length;++i)r.push(c.charCodeAt(i)&255);return r}function hr(c,r){let i,h,g;const b=[];for(let S=0;S<c.length&&!((r-=2)<0);++S)i=c.charCodeAt(S),h=i>>8,g=i%256,b.push(g),b.push(h);return b}function me(c){return t.toByteArray(xr(c))}function ce(c,r,i,h){let g;for(g=0;g<h&&!(g+i>=r.length||g>=c.length);++g)r[g+i]=c[g];return g}function Qt(c,r){return c instanceof r||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===r.name}function fe(c){return c!==c}const be=function(){const c="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){const h=i*16;for(let g=0;g<16;++g)r[h+g]=c[i]+c[g]}return r}();function we(c){return typeof BigInt>"u"?ke:c}function ke(){throw new Error("BigInt not supported")}})(Nt);function _i(o){if(!Number.isSafeInteger(o)||o<0)throw new Error(`positive integer expected, not ${o}`)}function uu(o){return o instanceof Uint8Array||o!=null&&typeof o=="object"&&o.constructor.name==="Uint8Array"}function si(o,...t){if(!uu(o))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(o.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${o.length}`)}function fu(o){if(typeof o!="function"||typeof o.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");_i(o.outputLen),_i(o.blockLen)}function zn(o,t=!0){if(o.destroyed)throw new Error("Hash instance has been destroyed");if(t&&o.finished)throw new Error("Hash#digest() has already been called")}function Ms(o,t){si(o);const e=t.outputLen;if(o.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}const lo=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const hu=o=>new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)),po=o=>new DataView(o.buffer,o.byteOffset,o.byteLength),Hr=(o,t)=>o<<32-t|o>>>t,Cs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,lu=o=>o<<24&4278190080|o<<8&16711680|o>>>8&65280|o>>>24&255;function Ps(o){for(let t=0;t<o.length;t++)o[t]=lu(o[t])}function du(o){if(typeof o!="string")throw new Error(`utf8ToBytes expected string, got ${typeof o}`);return new Uint8Array(new TextEncoder().encode(o))}function vi(o){return typeof o=="string"&&(o=du(o)),si(o),o}function pu(...o){let t=0;for(let n=0;n<o.length;n++){const a=o[n];si(a),t+=a.length}const e=new Uint8Array(t);for(let n=0,a=0;n<o.length;n++){const s=o[n];e.set(s,a),a+=s.length}return e}class yo{clone(){return this._cloneInto()}}function go(o){const t=n=>o().update(vi(n)).digest(),e=o();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>o(),t}function Us(o=32){if(lo&&typeof lo.getRandomValues=="function")return lo.getRandomValues(new Uint8Array(o));throw new Error("crypto.getRandomValues must be defined")}function yu(o,t,e,n){if(typeof o.setBigUint64=="function")return o.setBigUint64(t,e,n);const a=BigInt(32),s=BigInt(4294967295),f=Number(e>>a&s),u=Number(e&s),y=n?4:0,x=n?0:4;o.setUint32(t+y,f,n),o.setUint32(t+x,u,n)}const gu=(o,t,e)=>o&t^~o&e,mu=(o,t,e)=>o&t^o&e^t&e;class Ls extends yo{constructor(t,e,n,a){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=a,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=po(this.buffer)}update(t){zn(this);const{view:e,buffer:n,blockLen:a}=this;t=vi(t);const s=t.length;for(let f=0;f<s;){const u=Math.min(a-this.pos,s-f);if(u===a){const y=po(t);for(;a<=s-f;f+=a)this.process(y,f);continue}n.set(t.subarray(f,f+u),this.pos),this.pos+=u,f+=u,this.pos===a&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){zn(this),Ms(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:a,isLE:s}=this;let{pos:f}=this;e[f++]=128,this.buffer.subarray(f).fill(0),this.padOffset>a-f&&(this.process(n,0),f=0);for(let v=f;v<a;v++)e[v]=0;yu(n,a-8,BigInt(this.length*8),s),this.process(n,0);const u=po(t),y=this.outputLen;if(y%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const x=y/4,B=this.get();if(x>B.length)throw new Error("_sha2: outputLen bigger than state");for(let v=0;v<x;v++)u.setUint32(4*v,B[v],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:a,finished:s,destroyed:f,pos:u}=this;return t.length=a,t.pos=u,t.finished=s,t.destroyed=f,a%e&&t.buffer.set(n),t}}const Ai=BigInt(2**32-1),mo=BigInt(32);function Fs(o,t=!1){return t?{h:Number(o&Ai),l:Number(o>>mo&Ai)}:{h:Number(o>>mo&Ai)|0,l:Number(o&Ai)|0}}function Os(o,t=!1){let e=new Uint32Array(o.length),n=new Uint32Array(o.length);for(let a=0;a<o.length;a++){const{h:s,l:f}=Fs(o[a],t);[e[a],n[a]]=[s,f]}return[e,n]}const wu=(o,t)=>BigInt(o>>>0)<<mo|BigInt(t>>>0),bu=(o,t,e)=>o>>>e,xu=(o,t,e)=>o<<32-e|t>>>e,Eu=(o,t,e)=>o>>>e|t<<32-e,ku=(o,t,e)=>o<<32-e|t>>>e,Su=(o,t,e)=>o<<64-e|t>>>e-32,Iu=(o,t,e)=>o>>>e-32|t<<64-e,Bu=(o,t)=>t,_u=(o,t)=>o,Ns=(o,t,e)=>o<<e|t>>>32-e,zs=(o,t,e)=>t<<e|o>>>32-e,Ds=(o,t,e)=>t<<e-32|o>>>64-e,$s=(o,t,e)=>o<<e-32|t>>>64-e;function vu(o,t,e,n){const a=(t>>>0)+(n>>>0);return{h:o+e+(a/2**32|0)|0,l:a|0}}const ie={fromBig:Fs,split:Os,toBig:wu,shrSH:bu,shrSL:xu,rotrSH:Eu,rotrSL:ku,rotrBH:Su,rotrBL:Iu,rotr32H:Bu,rotr32L:_u,rotlSH:Ns,rotlSL:zs,rotlBH:Ds,rotlBL:$s,add:vu,add3L:(o,t,e)=>(o>>>0)+(t>>>0)+(e>>>0),add3H:(o,t,e,n)=>t+e+n+(o/2**32|0)|0,add4L:(o,t,e,n)=>(o>>>0)+(t>>>0)+(e>>>0)+(n>>>0),add4H:(o,t,e,n,a)=>t+e+n+a+(o/2**32|0)|0,add5H:(o,t,e,n,a,s)=>t+e+n+a+s+(o/2**32|0)|0,add5L:(o,t,e,n,a)=>(o>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(a>>>0)},[Au,Ru]=ie.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(o=>BigInt(o))),un=new Uint32Array(80),fn=new Uint32Array(80);class Tu extends Ls{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(){const{Ah:t,Al:e,Bh:n,Bl:a,Ch:s,Cl:f,Dh:u,Dl:y,Eh:x,El:B,Fh:v,Fl:F,Gh:L,Gl:D,Hh:U,Hl:z}=this;return[t,e,n,a,s,f,u,y,x,B,v,F,L,D,U,z]}set(t,e,n,a,s,f,u,y,x,B,v,F,L,D,U,z){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=a|0,this.Ch=s|0,this.Cl=f|0,this.Dh=u|0,this.Dl=y|0,this.Eh=x|0,this.El=B|0,this.Fh=v|0,this.Fl=F|0,this.Gh=L|0,this.Gl=D|0,this.Hh=U|0,this.Hl=z|0}process(t,e){for(let V=0;V<16;V++,e+=4)un[V]=t.getUint32(e),fn[V]=t.getUint32(e+=4);for(let V=16;V<80;V++){const it=un[V-15]|0,G=fn[V-15]|0,W=ie.rotrSH(it,G,1)^ie.rotrSH(it,G,8)^ie.shrSH(it,G,7),Q=ie.rotrSL(it,G,1)^ie.rotrSL(it,G,8)^ie.shrSL(it,G,7),rt=un[V-2]|0,ae=fn[V-2]|0,jt=ie.rotrSH(rt,ae,19)^ie.rotrBH(rt,ae,61)^ie.shrSH(rt,ae,6),_t=ie.rotrSL(rt,ae,19)^ie.rotrBL(rt,ae,61)^ie.shrSL(rt,ae,6),re=ie.add4L(Q,_t,fn[V-7],fn[V-16]),P=ie.add4H(re,W,jt,un[V-7],un[V-16]);un[V]=P|0,fn[V]=re|0}let{Ah:n,Al:a,Bh:s,Bl:f,Ch:u,Cl:y,Dh:x,Dl:B,Eh:v,El:F,Fh:L,Fl:D,Gh:U,Gl:z,Hh:$,Hl:X}=this;for(let V=0;V<80;V++){const it=ie.rotrSH(v,F,14)^ie.rotrSH(v,F,18)^ie.rotrBH(v,F,41),G=ie.rotrSL(v,F,14)^ie.rotrSL(v,F,18)^ie.rotrBL(v,F,41),W=v&L^~v&U,Q=F&D^~F&z,rt=ie.add5L(X,G,Q,Ru[V],fn[V]),ae=ie.add5H(rt,$,it,W,Au[V],un[V]),jt=rt|0,_t=ie.rotrSH(n,a,28)^ie.rotrBH(n,a,34)^ie.rotrBH(n,a,39),re=ie.rotrSL(n,a,28)^ie.rotrBL(n,a,34)^ie.rotrBL(n,a,39),P=n&s^n&u^s&u,d=a&f^a&y^f&y;$=U|0,X=z|0,U=L|0,z=D|0,L=v|0,D=F|0,{h:v,l:F}=ie.add(x|0,B|0,ae|0,jt|0),x=u|0,B=y|0,u=s|0,y=f|0,s=n|0,f=a|0;const m=ie.add3L(jt,re,d);n=ie.add3H(m,ae,_t,P),a=m|0}({h:n,l:a}=ie.add(this.Ah|0,this.Al|0,n|0,a|0)),{h:s,l:f}=ie.add(this.Bh|0,this.Bl|0,s|0,f|0),{h:u,l:y}=ie.add(this.Ch|0,this.Cl|0,u|0,y|0),{h:x,l:B}=ie.add(this.Dh|0,this.Dl|0,x|0,B|0),{h:v,l:F}=ie.add(this.Eh|0,this.El|0,v|0,F|0),{h:L,l:D}=ie.add(this.Fh|0,this.Fl|0,L|0,D|0),{h:U,l:z}=ie.add(this.Gh|0,this.Gl|0,U|0,z|0),{h:$,l:X}=ie.add(this.Hh|0,this.Hl|0,$|0,X|0),this.set(n,a,s,f,u,y,x,B,v,F,L,D,U,z,$,X)}roundClean(){un.fill(0),fn.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)}}const Mu=go(()=>new Tu);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ks=BigInt(0),Ri=BigInt(1),Cu=BigInt(2);function bn(o){return o instanceof Uint8Array||o!=null&&typeof o=="object"&&o.constructor.name==="Uint8Array"}function ai(o){if(!bn(o))throw new Error("Uint8Array expected")}const Pu=Array.from({length:256},(o,t)=>t.toString(16).padStart(2,"0"));function xn(o){ai(o);let t="";for(let e=0;e<o.length;e++)t+=Pu[o[e]];return t}function Ws(o){const t=o.toString(16);return t.length&1?`0${t}`:t}function wo(o){if(typeof o!="string")throw new Error("hex string expected, got "+typeof o);return BigInt(o===""?"0":`0x${o}`)}const rn={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function qs(o){if(o>=rn._0&&o<=rn._9)return o-rn._0;if(o>=rn._A&&o<=rn._F)return o-(rn._A-10);if(o>=rn._a&&o<=rn._f)return o-(rn._a-10)}function Dn(o){if(typeof o!="string")throw new Error("hex string expected, got "+typeof o);const t=o.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(e);for(let a=0,s=0;a<e;a++,s+=2){const f=qs(o.charCodeAt(s)),u=qs(o.charCodeAt(s+1));if(f===void 0||u===void 0){const y=o[s]+o[s+1];throw new Error('hex string expected, got non-hex character "'+y+'" at index '+s)}n[a]=f*16+u}return n}function En(o){return wo(xn(o))}function $n(o){return ai(o),wo(xn(Uint8Array.from(o).reverse()))}function Kn(o,t){return Dn(o.toString(16).padStart(t*2,"0"))}function ci(o,t){return Kn(o,t).reverse()}function Uu(o){return Dn(Ws(o))}function or(o,t,e){let n;if(typeof t=="string")try{n=Dn(t)}catch(s){throw new Error(`${o} must be valid hex string, got "${t}". Cause: ${s}`)}else if(bn(t))n=Uint8Array.from(t);else throw new Error(`${o} must be hex string or Uint8Array`);const a=n.length;if(typeof e=="number"&&a!==e)throw new Error(`${o} expected ${e} bytes, got ${a}`);return n}function kn(...o){let t=0;for(let n=0;n<o.length;n++){const a=o[n];ai(a),t+=a.length}const e=new Uint8Array(t);for(let n=0,a=0;n<o.length;n++){const s=o[n];e.set(s,a),a+=s.length}return e}function Lu(o,t){if(o.length!==t.length)return!1;let e=0;for(let n=0;n<o.length;n++)e|=o[n]^t[n];return e===0}function Fu(o){if(typeof o!="string")throw new Error(`utf8ToBytes expected string, got ${typeof o}`);return new Uint8Array(new TextEncoder().encode(o))}function Ou(o){let t;for(t=0;o>Ks;o>>=Ri,t+=1);return t}function Nu(o,t){return o>>BigInt(t)&Ri}function zu(o,t,e){return o|(e?Ri:Ks)<<BigInt(t)}const bo=o=>(Cu<<BigInt(o-1))-Ri,xo=o=>new Uint8Array(o),Hs=o=>Uint8Array.from(o);function Vs(o,t,e){if(typeof o!="number"||o<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=xo(o),a=xo(o),s=0;const f=()=>{n.fill(1),a.fill(0),s=0},u=(...v)=>e(a,n,...v),y=(v=xo())=>{a=u(Hs([0]),v),n=u(),v.length!==0&&(a=u(Hs([1]),v),n=u())},x=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let v=0;const F=[];for(;v<t;){n=u();const L=n.slice();F.push(L),v+=n.length}return kn(...F)};return(v,F)=>{f(),y(v);let L;for(;!(L=F(x()));)y();return f(),L}}const Du={bigint:o=>typeof o=="bigint",function:o=>typeof o=="function",boolean:o=>typeof o=="boolean",string:o=>typeof o=="string",stringOrUint8Array:o=>typeof o=="string"||bn(o),isSafeInteger:o=>Number.isSafeInteger(o),array:o=>Array.isArray(o),field:(o,t)=>t.Fp.isValid(o),hash:o=>typeof o=="function"&&Number.isSafeInteger(o.outputLen)};function Wn(o,t,e={}){const n=(a,s,f)=>{const u=Du[s];if(typeof u!="function")throw new Error(`Invalid validator "${s}", expected function`);const y=o[a];if(!(f&&y===void 0)&&!u(y,o))throw new Error(`Invalid param ${String(a)}=${y} (${typeof y}), expected ${s}`)};for(const[a,s]of Object.entries(t))n(a,s,!1);for(const[a,s]of Object.entries(e))n(a,s,!0);return o}const $u=Object.freeze(Object.defineProperty({__proto__:null,abytes:ai,bitGet:Nu,bitLen:Ou,bitMask:bo,bitSet:zu,bytesToHex:xn,bytesToNumberBE:En,bytesToNumberLE:$n,concatBytes:kn,createHmacDrbg:Vs,ensureBytes:or,equalBytes:Lu,hexToBytes:Dn,hexToNumber:wo,isBytes:bn,numberToBytesBE:Kn,numberToBytesLE:ci,numberToHexUnpadded:Ws,numberToVarBytesBE:Uu,utf8ToBytes:Fu,validateObject:Wn},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ar=BigInt(0),Ve=BigInt(1),Sn=BigInt(2),Ku=BigInt(3),Eo=BigInt(4),js=BigInt(5),Gs=BigInt(8);BigInt(9),BigInt(16);function We(o,t){const e=o%t;return e>=ar?e:t+e}function Wu(o,t,e){if(e<=ar||t<ar)throw new Error("Expected power/modulo > 0");if(e===Ve)return ar;let n=Ve;for(;t>ar;)t&Ve&&(n=n*o%e),o=o*o%e,t>>=Ve;return n}function Ze(o,t,e){let n=o;for(;t-- >ar;)n*=n,n%=e;return n}function ko(o,t){if(o===ar||t<=ar)throw new Error(`invert: expected positive integers, got n=${o} mod=${t}`);let e=We(o,t),n=t,a=ar,s=Ve;for(;e!==ar;){const u=n/e,y=n%e,x=a-s*u;n=e,e=y,a=s,s=x}if(n!==Ve)throw new Error("invert: does not exist");return We(a,t)}function qu(o){const t=(o-Ve)/Sn;let e,n,a;for(e=o-Ve,n=0;e%Sn===ar;e/=Sn,n++);for(a=Sn;a<o&&Wu(a,t,o)!==o-Ve;a++);if(n===1){const f=(o+Ve)/Eo;return function(y,x){const B=y.pow(x,f);if(!y.eql(y.sqr(B),x))throw new Error("Cannot find square root");return B}}const s=(e+Ve)/Sn;return function(u,y){if(u.pow(y,t)===u.neg(u.ONE))throw new Error("Cannot find square root");let x=n,B=u.pow(u.mul(u.ONE,a),e),v=u.pow(y,s),F=u.pow(y,e);for(;!u.eql(F,u.ONE);){if(u.eql(F,u.ZERO))return u.ZERO;let L=1;for(let U=u.sqr(F);L<x&&!u.eql(U,u.ONE);L++)U=u.sqr(U);const D=u.pow(B,Ve<<BigInt(x-L-1));B=u.sqr(D),v=u.mul(v,D),F=u.mul(F,B),x=L}return v}}function Hu(o){if(o%Eo===Ku){const t=(o+Ve)/Eo;return function(n,a){const s=n.pow(a,t);if(!n.eql(n.sqr(s),a))throw new Error("Cannot find square root");return s}}if(o%Gs===js){const t=(o-js)/Gs;return function(n,a){const s=n.mul(a,Sn),f=n.pow(s,t),u=n.mul(a,f),y=n.mul(n.mul(u,Sn),f),x=n.mul(u,n.sub(y,n.ONE));if(!n.eql(n.sqr(x),a))throw new Error("Cannot find square root");return x}}return qu(o)}const Vu=(o,t)=>(We(o,t)&Ve)===Ve,ju=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Gu(o){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=ju.reduce((n,a)=>(n[a]="function",n),t);return Wn(o,e)}function Yu(o,t,e){if(e<ar)throw new Error("Expected power > 0");if(e===ar)return o.ONE;if(e===Ve)return t;let n=o.ONE,a=t;for(;e>ar;)e&Ve&&(n=o.mul(n,a)),a=o.sqr(a),e>>=Ve;return n}function Zu(o,t){const e=new Array(t.length),n=t.reduce((s,f,u)=>o.is0(f)?s:(e[u]=s,o.mul(s,f)),o.ONE),a=o.inv(n);return t.reduceRight((s,f,u)=>o.is0(f)?s:(e[u]=o.mul(s,e[u]),o.mul(s,f)),a),e}function Ys(o,t){const e=t!==void 0?t:o.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Zs(o,t,e=!1,n={}){if(o<=ar)throw new Error(`Expected Field ORDER > 0, got ${o}`);const{nBitLength:a,nByteLength:s}=Ys(o,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const f=Hu(o),u=Object.freeze({ORDER:o,BITS:a,BYTES:s,MASK:bo(a),ZERO:ar,ONE:Ve,create:y=>We(y,o),isValid:y=>{if(typeof y!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof y}`);return ar<=y&&y<o},is0:y=>y===ar,isOdd:y=>(y&Ve)===Ve,neg:y=>We(-y,o),eql:(y,x)=>y===x,sqr:y=>We(y*y,o),add:(y,x)=>We(y+x,o),sub:(y,x)=>We(y-x,o),mul:(y,x)=>We(y*x,o),pow:(y,x)=>Yu(u,y,x),div:(y,x)=>We(y*ko(x,o),o),sqrN:y=>y*y,addN:(y,x)=>y+x,subN:(y,x)=>y-x,mulN:(y,x)=>y*x,inv:y=>ko(y,o),sqrt:n.sqrt||(y=>f(u,y)),invertBatch:y=>Zu(u,y),cmov:(y,x,B)=>B?x:y,toBytes:y=>e?ci(y,s):Kn(y,s),fromBytes:y=>{if(y.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${y.length}`);return e?$n(y):En(y)}});return Object.freeze(u)}function Js(o){if(typeof o!="bigint")throw new Error("field order must be bigint");const t=o.toString(2).length;return Math.ceil(t/8)}function Xs(o){const t=Js(o);return t+Math.ceil(t/2)}function Ju(o,t,e=!1){const n=o.length,a=Js(t),s=Xs(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);const f=e?En(o):$n(o),u=We(f,t-Ve)+Ve;return e?ci(u,a):Kn(u,a)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Xu=BigInt(0),So=BigInt(1);function Qs(o,t){const e=(a,s)=>{const f=s.negate();return a?f:s},n=a=>{const s=Math.ceil(t/a)+1,f=2**(a-1);return{windows:s,windowSize:f}};return{constTimeNegate:e,unsafeLadder(a,s){let f=o.ZERO,u=a;for(;s>Xu;)s&So&&(f=f.add(u)),u=u.double(),s>>=So;return f},precomputeWindow(a,s){const{windows:f,windowSize:u}=n(s),y=[];let x=a,B=x;for(let v=0;v<f;v++){B=x,y.push(B);for(let F=1;F<u;F++)B=B.add(x),y.push(B);x=B.double()}return y},wNAF(a,s,f){const{windows:u,windowSize:y}=n(a);let x=o.ZERO,B=o.BASE;const v=BigInt(2**a-1),F=2**a,L=BigInt(a);for(let D=0;D<u;D++){const U=D*y;let z=Number(f&v);f>>=L,z>y&&(z-=F,f+=So);const $=U,X=U+Math.abs(z)-1,V=D%2!==0,it=z<0;z===0?B=B.add(e(V,s[$])):x=x.add(e(it,s[X]))}return{p:x,f:B}},wNAFCached(a,s,f,u){const y=a._WINDOW_SIZE||1;let x=s.get(a);return x||(x=this.precomputeWindow(a,y),y!==1&&s.set(a,u(x))),this.wNAF(y,x,f)}}}function Io(o){return Gu(o.Fp),Wn(o,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ys(o.n,o.nBitLength),...o,p:o.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Nr=BigInt(0),Rr=BigInt(1),Ti=BigInt(2),Qu=BigInt(8),tf={zip215:!0};function ef(o){const t=Io(o);return Wn(o,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function rf(o){const t=ef(o),{Fp:e,n,prehash:a,hash:s,randomBytes:f,nByteLength:u,h:y}=t,x=Ti<<BigInt(u*8)-Rr,B=e.create,v=t.uvRatio||((R,T)=>{try{return{isValid:!0,value:e.sqrt(R*e.inv(T))}}catch{return{isValid:!1,value:Nr}}}),F=t.adjustScalarBytes||(R=>R),L=t.domain||((R,T,N)=>{if(T.length||N)throw new Error("Contexts/pre-hash are not supported");return R}),D=R=>typeof R=="bigint"&&Nr<R,U=(R,T)=>D(R)&&D(T)&&R<T,z=R=>R===Nr||U(R,x);function $(R,T){if(U(R,T))return R;throw new Error(`Expected valid scalar < ${T}, got ${typeof R} ${R}`)}function X(R){return R===Nr?R:$(R,n)}const V=new Map;function it(R){if(!(R instanceof G))throw new Error("ExtendedPoint expected")}class G{constructor(T,N,k,p){if(this.ex=T,this.ey=N,this.ez=k,this.et=p,!z(T))throw new Error("x required");if(!z(N))throw new Error("y required");if(!z(k))throw new Error("z required");if(!z(p))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(T){if(T instanceof G)throw new Error("extended point not allowed");const{x:N,y:k}=T||{};if(!z(N)||!z(k))throw new Error("invalid affine point");return new G(N,k,Rr,B(N*k))}static normalizeZ(T){const N=e.invertBatch(T.map(k=>k.ez));return T.map((k,p)=>k.toAffine(N[p])).map(G.fromAffine)}_setWindowSize(T){this._WINDOW_SIZE=T,V.delete(this)}assertValidity(){const{a:T,d:N}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:k,ey:p,ez:M,et:at}=this,tt=B(k*k),ft=B(p*p),Lt=B(M*M),At=B(Lt*Lt),Ut=B(tt*T),Ee=B(Lt*B(Ut+ft)),Zt=B(At+B(N*B(tt*ft)));if(Ee!==Zt)throw new Error("bad point: equation left != right (1)");const Wt=B(k*p),Yt=B(M*at);if(Wt!==Yt)throw new Error("bad point: equation left != right (2)")}equals(T){it(T);const{ex:N,ey:k,ez:p}=this,{ex:M,ey:at,ez:tt}=T,ft=B(N*tt),Lt=B(M*p),At=B(k*tt),Ut=B(at*p);return ft===Lt&&At===Ut}is0(){return this.equals(G.ZERO)}negate(){return new G(B(-this.ex),this.ey,this.ez,B(-this.et))}double(){const{a:T}=t,{ex:N,ey:k,ez:p}=this,M=B(N*N),at=B(k*k),tt=B(Ti*B(p*p)),ft=B(T*M),Lt=N+k,At=B(B(Lt*Lt)-M-at),Ut=ft+at,Ee=Ut-tt,Zt=ft-at,Wt=B(At*Ee),Yt=B(Ut*Zt),zt=B(At*Zt),ge=B(Ee*Ut);return new G(Wt,Yt,ge,zt)}add(T){it(T);const{a:N,d:k}=t,{ex:p,ey:M,ez:at,et:tt}=this,{ex:ft,ey:Lt,ez:At,et:Ut}=T;if(N===BigInt(-1)){const Qt=B((M-p)*(Lt+ft)),fe=B((M+p)*(Lt-ft)),be=B(fe-Qt);if(be===Nr)return this.double();const we=B(at*Ti*Ut),ke=B(tt*Ti*At),c=ke+we,r=fe+Qt,i=ke-we,h=B(c*be),g=B(r*i),b=B(c*i),S=B(be*r);return new G(h,g,S,b)}const Ee=B(p*ft),Zt=B(M*Lt),Wt=B(tt*k*Ut),Yt=B(at*At),zt=B((p+M)*(ft+Lt)-Ee-Zt),ge=Yt-Wt,xr=Yt+Wt,de=B(Zt-N*Ee),Ce=B(zt*ge),hr=B(xr*de),me=B(zt*de),ce=B(ge*xr);return new G(Ce,hr,ce,me)}subtract(T){return this.add(T.negate())}wNAF(T){return rt.wNAFCached(this,V,T,G.normalizeZ)}multiply(T){const{p:N,f:k}=this.wNAF($(T,n));return G.normalizeZ([N,k])[0]}multiplyUnsafe(T){let N=X(T);return N===Nr?Q:this.equals(Q)||N===Rr?this:this.equals(W)?this.wNAF(N).p:rt.unsafeLadder(this,N)}isSmallOrder(){return this.multiplyUnsafe(y).is0()}isTorsionFree(){return rt.unsafeLadder(this,n).is0()}toAffine(T){const{ex:N,ey:k,ez:p}=this,M=this.is0();T==null&&(T=M?Qu:e.inv(p));const at=B(N*T),tt=B(k*T),ft=B(p*T);if(M)return{x:Nr,y:Rr};if(ft!==Rr)throw new Error("invZ was invalid");return{x:at,y:tt}}clearCofactor(){const{h:T}=t;return T===Rr?this:this.multiplyUnsafe(T)}static fromHex(T,N=!1){const{d:k,a:p}=t,M=e.BYTES;T=or("pointHex",T,M);const at=T.slice(),tt=T[M-1];at[M-1]=tt&-129;const ft=$n(at);ft===Nr||(N?$(ft,x):$(ft,e.ORDER));const Lt=B(ft*ft),At=B(Lt-Rr),Ut=B(k*Lt-p);let{isValid:Ee,value:Zt}=v(At,Ut);if(!Ee)throw new Error("Point.fromHex: invalid y coordinate");const Wt=(Zt&Rr)===Rr,Yt=(tt&128)!==0;if(!N&&Zt===Nr&&Yt)throw new Error("Point.fromHex: x=0 and x_0=1");return Yt!==Wt&&(Zt=B(-Zt)),G.fromAffine({x:Zt,y:ft})}static fromPrivateKey(T){return _t(T).point}toRawBytes(){const{x:T,y:N}=this.toAffine(),k=ci(N,e.BYTES);return k[k.length-1]|=T&Rr?128:0,k}toHex(){return xn(this.toRawBytes())}}G.BASE=new G(t.Gx,t.Gy,Rr,B(t.Gx*t.Gy)),G.ZERO=new G(Nr,Rr,Rr,Nr);const{BASE:W,ZERO:Q}=G,rt=Qs(G,u*8);function ae(R){return We(R,n)}function jt(R){return ae($n(R))}function _t(R){const T=u;R=or("private key",R,T);const N=or("hashed private key",s(R),2*T),k=F(N.slice(0,T)),p=N.slice(T,2*T),M=jt(k),at=W.multiply(M),tt=at.toRawBytes();return{head:k,prefix:p,scalar:M,point:at,pointBytes:tt}}function re(R){return _t(R).pointBytes}function P(R=new Uint8Array,...T){const N=kn(...T);return jt(s(L(N,or("context",R),!!a)))}function d(R,T,N={}){R=or("message",R),a&&(R=a(R));const{prefix:k,scalar:p,pointBytes:M}=_t(T),at=P(N.context,k,R),tt=W.multiply(at).toRawBytes(),ft=P(N.context,tt,M,R),Lt=ae(at+ft*p);X(Lt);const At=kn(tt,ci(Lt,e.BYTES));return or("result",At,u*2)}const m=tf;function E(R,T,N,k=m){const{context:p,zip215:M}=k,at=e.BYTES;R=or("signature",R,2*at),T=or("message",T),a&&(T=a(T));const tt=$n(R.slice(at,2*at));let ft,Lt,At;try{ft=G.fromHex(N,M),Lt=G.fromHex(R.slice(0,at),M),At=W.multiplyUnsafe(tt)}catch{return!1}if(!M&&ft.isSmallOrder())return!1;const Ut=P(p,Lt.toRawBytes(),ft.toRawBytes(),T);return Lt.add(ft.multiplyUnsafe(Ut)).subtract(At).clearCofactor().equals(G.ZERO)}return W._setWindowSize(8),{CURVE:t,getPublicKey:re,sign:d,verify:E,ExtendedPoint:G,utils:{getExtendedPublicKey:_t,randomPrivateKey:()=>f(e.BYTES),precompute(R=8,T=G.BASE){return T._setWindowSize(R),T.multiply(BigInt(3)),T}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Bo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ta=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const nf=BigInt(1),ea=BigInt(2);BigInt(3);const of=BigInt(5),sf=BigInt(8);function af(o){const t=BigInt(10),e=BigInt(20),n=BigInt(40),a=BigInt(80),s=Bo,u=o*o%s*o%s,y=Ze(u,ea,s)*u%s,x=Ze(y,nf,s)*o%s,B=Ze(x,of,s)*x%s,v=Ze(B,t,s)*B%s,F=Ze(v,e,s)*v%s,L=Ze(F,n,s)*F%s,D=Ze(L,a,s)*L%s,U=Ze(D,a,s)*L%s,z=Ze(U,t,s)*B%s;return{pow_p_5_8:Ze(z,ea,s)*o%s,b2:u}}function cf(o){return o[0]&=248,o[31]&=127,o[31]|=64,o}function uf(o,t){const e=Bo,n=We(t*t*t,e),a=We(n*n*t,e),s=af(o*a).pow_p_5_8;let f=We(o*n*s,e);const u=We(t*f*f,e),y=f,x=We(f*ta,e),B=u===o,v=u===We(-o,e),F=u===We(-o*ta,e);return B&&(f=y),(v||F)&&(f=x),Vu(f,e)&&(f=We(-f,e)),{isValid:B||v,value:f}}const ff=Zs(Bo,void 0,!0),hf={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ff,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:sf,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Mu,randomBytes:Us,adjustScalarBytes:cf,uvRatio:uf},qn=rf(hf);var _o={exports:{}};const ra=fo(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));_o.exports,function(o){(function(t,e){function n(P,d){if(!P)throw new Error(d||"Assertion failed")}function a(P,d){P.super_=d;var m=function(){};m.prototype=d.prototype,P.prototype=new m,P.prototype.constructor=P}function s(P,d,m){if(s.isBN(P))return P;this.negative=0,this.words=null,this.length=0,this.red=null,P!==null&&((d==="le"||d==="be")&&(m=d,d=10),this._init(P||0,d||10,m||"be"))}typeof t=="object"?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;var f;try{typeof window<"u"&&typeof window.Buffer<"u"?f=window.Buffer:f=ra.Buffer}catch{}s.isBN=function(d){return d instanceof s?!0:d!==null&&typeof d=="object"&&d.constructor.wordSize===s.wordSize&&Array.isArray(d.words)},s.max=function(d,m){return d.cmp(m)>0?d:m},s.min=function(d,m){return d.cmp(m)<0?d:m},s.prototype._init=function(d,m,E){if(typeof d=="number")return this._initNumber(d,m,E);if(typeof d=="object")return this._initArray(d,m,E);m==="hex"&&(m=16),n(m===(m|0)&&m>=2&&m<=36),d=d.toString().replace(/\s+/g,"");var C=0;d[0]==="-"&&(C++,this.negative=1),C<d.length&&(m===16?this._parseHex(d,C,E):(this._parseBase(d,m,C),E==="le"&&this._initArray(this.toArray(),m,E)))},s.prototype._initNumber=function(d,m,E){d<0&&(this.negative=1,d=-d),d<67108864?(this.words=[d&67108863],this.length=1):d<4503599627370496?(this.words=[d&67108863,d/67108864&67108863],this.length=2):(n(d<9007199254740992),this.words=[d&67108863,d/67108864&67108863,1],this.length=3),E==="le"&&this._initArray(this.toArray(),m,E)},s.prototype._initArray=function(d,m,E){if(n(typeof d.length=="number"),d.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(d.length/3),this.words=new Array(this.length);for(var C=0;C<this.length;C++)this.words[C]=0;var R,T,N=0;if(E==="be")for(C=d.length-1,R=0;C>=0;C-=3)T=d[C]|d[C-1]<<8|d[C-2]<<16,this.words[R]|=T<<N&67108863,this.words[R+1]=T>>>26-N&67108863,N+=24,N>=26&&(N-=26,R++);else if(E==="le")for(C=0,R=0;C<d.length;C+=3)T=d[C]|d[C+1]<<8|d[C+2]<<16,this.words[R]|=T<<N&67108863,this.words[R+1]=T>>>26-N&67108863,N+=24,N>=26&&(N-=26,R++);return this._strip()};function u(P,d){var m=P.charCodeAt(d);if(m>=48&&m<=57)return m-48;if(m>=65&&m<=70)return m-55;if(m>=97&&m<=102)return m-87;n(!1,"Invalid character in "+P)}function y(P,d,m){var E=u(P,m);return m-1>=d&&(E|=u(P,m-1)<<4),E}s.prototype._parseHex=function(d,m,E){this.length=Math.ceil((d.length-m)/6),this.words=new Array(this.length);for(var C=0;C<this.length;C++)this.words[C]=0;var R=0,T=0,N;if(E==="be")for(C=d.length-1;C>=m;C-=2)N=y(d,m,C)<<R,this.words[T]|=N&67108863,R>=18?(R-=18,T+=1,this.words[T]|=N>>>26):R+=8;else{var k=d.length-m;for(C=k%2===0?m+1:m;C<d.length;C+=2)N=y(d,m,C)<<R,this.words[T]|=N&67108863,R>=18?(R-=18,T+=1,this.words[T]|=N>>>26):R+=8}this._strip()};function x(P,d,m,E){for(var C=0,R=0,T=Math.min(P.length,m),N=d;N<T;N++){var k=P.charCodeAt(N)-48;C*=E,k>=49?R=k-49+10:k>=17?R=k-17+10:R=k,n(k>=0&&R<E,"Invalid character"),C+=R}return C}s.prototype._parseBase=function(d,m,E){this.words=[0],this.length=1;for(var C=0,R=1;R<=67108863;R*=m)C++;C--,R=R/m|0;for(var T=d.length-E,N=T%C,k=Math.min(T,T-N)+E,p=0,M=E;M<k;M+=C)p=x(d,M,M+C,m),this.imuln(R),this.words[0]+p<67108864?this.words[0]+=p:this._iaddn(p);if(N!==0){var at=1;for(p=x(d,M,d.length,m),M=0;M<N;M++)at*=m;this.imuln(at),this.words[0]+p<67108864?this.words[0]+=p:this._iaddn(p)}this._strip()},s.prototype.copy=function(d){d.words=new Array(this.length);for(var m=0;m<this.length;m++)d.words[m]=this.words[m];d.length=this.length,d.negative=this.negative,d.red=this.red};function B(P,d){P.words=d.words,P.length=d.length,P.negative=d.negative,P.red=d.red}if(s.prototype._move=function(d){B(d,this)},s.prototype.clone=function(){var d=new s(null);return this.copy(d),d},s.prototype._expand=function(d){for(;this.length<d;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=v}catch{s.prototype.inspect=v}else s.prototype.inspect=v;function v(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var F=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],L=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],D=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(d,m){d=d||10,m=m|0||1;var E;if(d===16||d==="hex"){E="";for(var C=0,R=0,T=0;T<this.length;T++){var N=this.words[T],k=((N<<C|R)&16777215).toString(16);R=N>>>24-C&16777215,C+=2,C>=26&&(C-=26,T--),R!==0||T!==this.length-1?E=F[6-k.length]+k+E:E=k+E}for(R!==0&&(E=R.toString(16)+E);E.length%m!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}if(d===(d|0)&&d>=2&&d<=36){var p=L[d],M=D[d];E="";var at=this.clone();for(at.negative=0;!at.isZero();){var tt=at.modrn(M).toString(d);at=at.idivn(M),at.isZero()?E=tt+E:E=F[p-tt.length]+tt+E}for(this.isZero()&&(E="0"+E);E.length%m!==0;)E="0"+E;return this.negative!==0&&(E="-"+E),E}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var d=this.words[0];return this.length===2?d+=this.words[1]*67108864:this.length===3&&this.words[2]===1?d+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-d:d},s.prototype.toJSON=function(){return this.toString(16,2)},f&&(s.prototype.toBuffer=function(d,m){return this.toArrayLike(f,d,m)}),s.prototype.toArray=function(d,m){return this.toArrayLike(Array,d,m)};var U=function(d,m){return d.allocUnsafe?d.allocUnsafe(m):new d(m)};s.prototype.toArrayLike=function(d,m,E){this._strip();var C=this.byteLength(),R=E||Math.max(1,C);n(C<=R,"byte array longer than desired length"),n(R>0,"Requested array length <= 0");var T=U(d,R),N=m==="le"?"LE":"BE";return this["_toArrayLike"+N](T,C),T},s.prototype._toArrayLikeLE=function(d,m){for(var E=0,C=0,R=0,T=0;R<this.length;R++){var N=this.words[R]<<T|C;d[E++]=N&255,E<d.length&&(d[E++]=N>>8&255),E<d.length&&(d[E++]=N>>16&255),T===6?(E<d.length&&(d[E++]=N>>24&255),C=0,T=0):(C=N>>>24,T+=2)}if(E<d.length)for(d[E++]=C;E<d.length;)d[E++]=0},s.prototype._toArrayLikeBE=function(d,m){for(var E=d.length-1,C=0,R=0,T=0;R<this.length;R++){var N=this.words[R]<<T|C;d[E--]=N&255,E>=0&&(d[E--]=N>>8&255),E>=0&&(d[E--]=N>>16&255),T===6?(E>=0&&(d[E--]=N>>24&255),C=0,T=0):(C=N>>>24,T+=2)}if(E>=0)for(d[E--]=C;E>=0;)d[E--]=0},Math.clz32?s.prototype._countBits=function(d){return 32-Math.clz32(d)}:s.prototype._countBits=function(d){var m=d,E=0;return m>=4096&&(E+=13,m>>>=13),m>=64&&(E+=7,m>>>=7),m>=8&&(E+=4,m>>>=4),m>=2&&(E+=2,m>>>=2),E+m},s.prototype._zeroBits=function(d){if(d===0)return 26;var m=d,E=0;return m&8191||(E+=13,m>>>=13),m&127||(E+=7,m>>>=7),m&15||(E+=4,m>>>=4),m&3||(E+=2,m>>>=2),m&1||E++,E},s.prototype.bitLength=function(){var d=this.words[this.length-1],m=this._countBits(d);return(this.length-1)*26+m};function z(P){for(var d=new Array(P.bitLength()),m=0;m<d.length;m++){var E=m/26|0,C=m%26;d[m]=P.words[E]>>>C&1}return d}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var d=0,m=0;m<this.length;m++){var E=this._zeroBits(this.words[m]);if(d+=E,E!==26)break}return d},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(d){return this.negative!==0?this.abs().inotn(d).iaddn(1):this.clone()},s.prototype.fromTwos=function(d){return this.testn(d-1)?this.notn(d).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(d){for(;this.length<d.length;)this.words[this.length++]=0;for(var m=0;m<d.length;m++)this.words[m]=this.words[m]|d.words[m];return this._strip()},s.prototype.ior=function(d){return n((this.negative|d.negative)===0),this.iuor(d)},s.prototype.or=function(d){return this.length>d.length?this.clone().ior(d):d.clone().ior(this)},s.prototype.uor=function(d){return this.length>d.length?this.clone().iuor(d):d.clone().iuor(this)},s.prototype.iuand=function(d){var m;this.length>d.length?m=d:m=this;for(var E=0;E<m.length;E++)this.words[E]=this.words[E]&d.words[E];return this.length=m.length,this._strip()},s.prototype.iand=function(d){return n((this.negative|d.negative)===0),this.iuand(d)},s.prototype.and=function(d){return this.length>d.length?this.clone().iand(d):d.clone().iand(this)},s.prototype.uand=function(d){return this.length>d.length?this.clone().iuand(d):d.clone().iuand(this)},s.prototype.iuxor=function(d){var m,E;this.length>d.length?(m=this,E=d):(m=d,E=this);for(var C=0;C<E.length;C++)this.words[C]=m.words[C]^E.words[C];if(this!==m)for(;C<m.length;C++)this.words[C]=m.words[C];return this.length=m.length,this._strip()},s.prototype.ixor=function(d){return n((this.negative|d.negative)===0),this.iuxor(d)},s.prototype.xor=function(d){return this.length>d.length?this.clone().ixor(d):d.clone().ixor(this)},s.prototype.uxor=function(d){return this.length>d.length?this.clone().iuxor(d):d.clone().iuxor(this)},s.prototype.inotn=function(d){n(typeof d=="number"&&d>=0);var m=Math.ceil(d/26)|0,E=d%26;this._expand(m),E>0&&m--;for(var C=0;C<m;C++)this.words[C]=~this.words[C]&67108863;return E>0&&(this.words[C]=~this.words[C]&67108863>>26-E),this._strip()},s.prototype.notn=function(d){return this.clone().inotn(d)},s.prototype.setn=function(d,m){n(typeof d=="number"&&d>=0);var E=d/26|0,C=d%26;return this._expand(E+1),m?this.words[E]=this.words[E]|1<<C:this.words[E]=this.words[E]&~(1<<C),this._strip()},s.prototype.iadd=function(d){var m;if(this.negative!==0&&d.negative===0)return this.negative=0,m=this.isub(d),this.negative^=1,this._normSign();if(this.negative===0&&d.negative!==0)return d.negative=0,m=this.isub(d),d.negative=1,m._normSign();var E,C;this.length>d.length?(E=this,C=d):(E=d,C=this);for(var R=0,T=0;T<C.length;T++)m=(E.words[T]|0)+(C.words[T]|0)+R,this.words[T]=m&67108863,R=m>>>26;for(;R!==0&&T<E.length;T++)m=(E.words[T]|0)+R,this.words[T]=m&67108863,R=m>>>26;if(this.length=E.length,R!==0)this.words[this.length]=R,this.length++;else if(E!==this)for(;T<E.length;T++)this.words[T]=E.words[T];return this},s.prototype.add=function(d){var m;return d.negative!==0&&this.negative===0?(d.negative=0,m=this.sub(d),d.negative^=1,m):d.negative===0&&this.negative!==0?(this.negative=0,m=d.sub(this),this.negative=1,m):this.length>d.length?this.clone().iadd(d):d.clone().iadd(this)},s.prototype.isub=function(d){if(d.negative!==0){d.negative=0;var m=this.iadd(d);return d.negative=1,m._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(d),this.negative=1,this._normSign();var E=this.cmp(d);if(E===0)return this.negative=0,this.length=1,this.words[0]=0,this;var C,R;E>0?(C=this,R=d):(C=d,R=this);for(var T=0,N=0;N<R.length;N++)m=(C.words[N]|0)-(R.words[N]|0)+T,T=m>>26,this.words[N]=m&67108863;for(;T!==0&&N<C.length;N++)m=(C.words[N]|0)+T,T=m>>26,this.words[N]=m&67108863;if(T===0&&N<C.length&&C!==this)for(;N<C.length;N++)this.words[N]=C.words[N];return this.length=Math.max(this.length,N),C!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(d){return this.clone().isub(d)};function $(P,d,m){m.negative=d.negative^P.negative;var E=P.length+d.length|0;m.length=E,E=E-1|0;var C=P.words[0]|0,R=d.words[0]|0,T=C*R,N=T&67108863,k=T/67108864|0;m.words[0]=N;for(var p=1;p<E;p++){for(var M=k>>>26,at=k&67108863,tt=Math.min(p,d.length-1),ft=Math.max(0,p-P.length+1);ft<=tt;ft++){var Lt=p-ft|0;C=P.words[Lt]|0,R=d.words[ft]|0,T=C*R+at,M+=T/67108864|0,at=T&67108863}m.words[p]=at|0,k=M|0}return k!==0?m.words[p]=k|0:m.length--,m._strip()}var X=function(d,m,E){var C=d.words,R=m.words,T=E.words,N=0,k,p,M,at=C[0]|0,tt=at&8191,ft=at>>>13,Lt=C[1]|0,At=Lt&8191,Ut=Lt>>>13,Ee=C[2]|0,Zt=Ee&8191,Wt=Ee>>>13,Yt=C[3]|0,zt=Yt&8191,ge=Yt>>>13,xr=C[4]|0,de=xr&8191,Ce=xr>>>13,hr=C[5]|0,me=hr&8191,ce=hr>>>13,Qt=C[6]|0,fe=Qt&8191,be=Qt>>>13,we=C[7]|0,ke=we&8191,c=we>>>13,r=C[8]|0,i=r&8191,h=r>>>13,g=C[9]|0,b=g&8191,S=g>>>13,et=R[0]|0,lt=et&8191,ht=et>>>13,kt=R[1]|0,st=kt&8191,$e=kt>>>13,ni=R[2]|0,Ye=ni&8191,Xe=ni>>>13,uo=R[3]|0,Ue=uo&8191,Oe=uo>>>13,cn=R[4]|0,qe=cn&8191,He=cn>>>13,Ii=R[5]|0,Qe=Ii&8191,Se=Ii>>>13,Bi=R[6]|0,w=Bi&8191,I=Bi>>>13,_=R[7]|0,l=_&8191,A=_>>>13,q=R[8]|0,K=q&8191,J=q>>>13,yt=R[9]|0,wt=yt&8191,gt=yt>>>13;E.negative=d.negative^m.negative,E.length=19,k=Math.imul(tt,lt),p=Math.imul(tt,ht),p=p+Math.imul(ft,lt)|0,M=Math.imul(ft,ht);var ye=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(ye>>>26)|0,ye&=67108863,k=Math.imul(At,lt),p=Math.imul(At,ht),p=p+Math.imul(Ut,lt)|0,M=Math.imul(Ut,ht),k=k+Math.imul(tt,st)|0,p=p+Math.imul(tt,$e)|0,p=p+Math.imul(ft,st)|0,M=M+Math.imul(ft,$e)|0;var vt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(vt>>>26)|0,vt&=67108863,k=Math.imul(Zt,lt),p=Math.imul(Zt,ht),p=p+Math.imul(Wt,lt)|0,M=Math.imul(Wt,ht),k=k+Math.imul(At,st)|0,p=p+Math.imul(At,$e)|0,p=p+Math.imul(Ut,st)|0,M=M+Math.imul(Ut,$e)|0,k=k+Math.imul(tt,Ye)|0,p=p+Math.imul(tt,Xe)|0,p=p+Math.imul(ft,Ye)|0,M=M+Math.imul(ft,Xe)|0;var Kt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,k=Math.imul(zt,lt),p=Math.imul(zt,ht),p=p+Math.imul(ge,lt)|0,M=Math.imul(ge,ht),k=k+Math.imul(Zt,st)|0,p=p+Math.imul(Zt,$e)|0,p=p+Math.imul(Wt,st)|0,M=M+Math.imul(Wt,$e)|0,k=k+Math.imul(At,Ye)|0,p=p+Math.imul(At,Xe)|0,p=p+Math.imul(Ut,Ye)|0,M=M+Math.imul(Ut,Xe)|0,k=k+Math.imul(tt,Ue)|0,p=p+Math.imul(tt,Oe)|0,p=p+Math.imul(ft,Ue)|0,M=M+Math.imul(ft,Oe)|0;var qt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(qt>>>26)|0,qt&=67108863,k=Math.imul(de,lt),p=Math.imul(de,ht),p=p+Math.imul(Ce,lt)|0,M=Math.imul(Ce,ht),k=k+Math.imul(zt,st)|0,p=p+Math.imul(zt,$e)|0,p=p+Math.imul(ge,st)|0,M=M+Math.imul(ge,$e)|0,k=k+Math.imul(Zt,Ye)|0,p=p+Math.imul(Zt,Xe)|0,p=p+Math.imul(Wt,Ye)|0,M=M+Math.imul(Wt,Xe)|0,k=k+Math.imul(At,Ue)|0,p=p+Math.imul(At,Oe)|0,p=p+Math.imul(Ut,Ue)|0,M=M+Math.imul(Ut,Oe)|0,k=k+Math.imul(tt,qe)|0,p=p+Math.imul(tt,He)|0,p=p+Math.imul(ft,qe)|0,M=M+Math.imul(ft,He)|0;var Xt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,k=Math.imul(me,lt),p=Math.imul(me,ht),p=p+Math.imul(ce,lt)|0,M=Math.imul(ce,ht),k=k+Math.imul(de,st)|0,p=p+Math.imul(de,$e)|0,p=p+Math.imul(Ce,st)|0,M=M+Math.imul(Ce,$e)|0,k=k+Math.imul(zt,Ye)|0,p=p+Math.imul(zt,Xe)|0,p=p+Math.imul(ge,Ye)|0,M=M+Math.imul(ge,Xe)|0,k=k+Math.imul(Zt,Ue)|0,p=p+Math.imul(Zt,Oe)|0,p=p+Math.imul(Wt,Ue)|0,M=M+Math.imul(Wt,Oe)|0,k=k+Math.imul(At,qe)|0,p=p+Math.imul(At,He)|0,p=p+Math.imul(Ut,qe)|0,M=M+Math.imul(Ut,He)|0,k=k+Math.imul(tt,Qe)|0,p=p+Math.imul(tt,Se)|0,p=p+Math.imul(ft,Qe)|0,M=M+Math.imul(ft,Se)|0;var Jt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Jt>>>26)|0,Jt&=67108863,k=Math.imul(fe,lt),p=Math.imul(fe,ht),p=p+Math.imul(be,lt)|0,M=Math.imul(be,ht),k=k+Math.imul(me,st)|0,p=p+Math.imul(me,$e)|0,p=p+Math.imul(ce,st)|0,M=M+Math.imul(ce,$e)|0,k=k+Math.imul(de,Ye)|0,p=p+Math.imul(de,Xe)|0,p=p+Math.imul(Ce,Ye)|0,M=M+Math.imul(Ce,Xe)|0,k=k+Math.imul(zt,Ue)|0,p=p+Math.imul(zt,Oe)|0,p=p+Math.imul(ge,Ue)|0,M=M+Math.imul(ge,Oe)|0,k=k+Math.imul(Zt,qe)|0,p=p+Math.imul(Zt,He)|0,p=p+Math.imul(Wt,qe)|0,M=M+Math.imul(Wt,He)|0,k=k+Math.imul(At,Qe)|0,p=p+Math.imul(At,Se)|0,p=p+Math.imul(Ut,Qe)|0,M=M+Math.imul(Ut,Se)|0,k=k+Math.imul(tt,w)|0,p=p+Math.imul(tt,I)|0,p=p+Math.imul(ft,w)|0,M=M+Math.imul(ft,I)|0;var Ht=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,k=Math.imul(ke,lt),p=Math.imul(ke,ht),p=p+Math.imul(c,lt)|0,M=Math.imul(c,ht),k=k+Math.imul(fe,st)|0,p=p+Math.imul(fe,$e)|0,p=p+Math.imul(be,st)|0,M=M+Math.imul(be,$e)|0,k=k+Math.imul(me,Ye)|0,p=p+Math.imul(me,Xe)|0,p=p+Math.imul(ce,Ye)|0,M=M+Math.imul(ce,Xe)|0,k=k+Math.imul(de,Ue)|0,p=p+Math.imul(de,Oe)|0,p=p+Math.imul(Ce,Ue)|0,M=M+Math.imul(Ce,Oe)|0,k=k+Math.imul(zt,qe)|0,p=p+Math.imul(zt,He)|0,p=p+Math.imul(ge,qe)|0,M=M+Math.imul(ge,He)|0,k=k+Math.imul(Zt,Qe)|0,p=p+Math.imul(Zt,Se)|0,p=p+Math.imul(Wt,Qe)|0,M=M+Math.imul(Wt,Se)|0,k=k+Math.imul(At,w)|0,p=p+Math.imul(At,I)|0,p=p+Math.imul(Ut,w)|0,M=M+Math.imul(Ut,I)|0,k=k+Math.imul(tt,l)|0,p=p+Math.imul(tt,A)|0,p=p+Math.imul(ft,l)|0,M=M+Math.imul(ft,A)|0;var Gt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,k=Math.imul(i,lt),p=Math.imul(i,ht),p=p+Math.imul(h,lt)|0,M=Math.imul(h,ht),k=k+Math.imul(ke,st)|0,p=p+Math.imul(ke,$e)|0,p=p+Math.imul(c,st)|0,M=M+Math.imul(c,$e)|0,k=k+Math.imul(fe,Ye)|0,p=p+Math.imul(fe,Xe)|0,p=p+Math.imul(be,Ye)|0,M=M+Math.imul(be,Xe)|0,k=k+Math.imul(me,Ue)|0,p=p+Math.imul(me,Oe)|0,p=p+Math.imul(ce,Ue)|0,M=M+Math.imul(ce,Oe)|0,k=k+Math.imul(de,qe)|0,p=p+Math.imul(de,He)|0,p=p+Math.imul(Ce,qe)|0,M=M+Math.imul(Ce,He)|0,k=k+Math.imul(zt,Qe)|0,p=p+Math.imul(zt,Se)|0,p=p+Math.imul(ge,Qe)|0,M=M+Math.imul(ge,Se)|0,k=k+Math.imul(Zt,w)|0,p=p+Math.imul(Zt,I)|0,p=p+Math.imul(Wt,w)|0,M=M+Math.imul(Wt,I)|0,k=k+Math.imul(At,l)|0,p=p+Math.imul(At,A)|0,p=p+Math.imul(Ut,l)|0,M=M+Math.imul(Ut,A)|0,k=k+Math.imul(tt,K)|0,p=p+Math.imul(tt,J)|0,p=p+Math.imul(ft,K)|0,M=M+Math.imul(ft,J)|0;var Vt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,k=Math.imul(b,lt),p=Math.imul(b,ht),p=p+Math.imul(S,lt)|0,M=Math.imul(S,ht),k=k+Math.imul(i,st)|0,p=p+Math.imul(i,$e)|0,p=p+Math.imul(h,st)|0,M=M+Math.imul(h,$e)|0,k=k+Math.imul(ke,Ye)|0,p=p+Math.imul(ke,Xe)|0,p=p+Math.imul(c,Ye)|0,M=M+Math.imul(c,Xe)|0,k=k+Math.imul(fe,Ue)|0,p=p+Math.imul(fe,Oe)|0,p=p+Math.imul(be,Ue)|0,M=M+Math.imul(be,Oe)|0,k=k+Math.imul(me,qe)|0,p=p+Math.imul(me,He)|0,p=p+Math.imul(ce,qe)|0,M=M+Math.imul(ce,He)|0,k=k+Math.imul(de,Qe)|0,p=p+Math.imul(de,Se)|0,p=p+Math.imul(Ce,Qe)|0,M=M+Math.imul(Ce,Se)|0,k=k+Math.imul(zt,w)|0,p=p+Math.imul(zt,I)|0,p=p+Math.imul(ge,w)|0,M=M+Math.imul(ge,I)|0,k=k+Math.imul(Zt,l)|0,p=p+Math.imul(Zt,A)|0,p=p+Math.imul(Wt,l)|0,M=M+Math.imul(Wt,A)|0,k=k+Math.imul(At,K)|0,p=p+Math.imul(At,J)|0,p=p+Math.imul(Ut,K)|0,M=M+Math.imul(Ut,J)|0,k=k+Math.imul(tt,wt)|0,p=p+Math.imul(tt,gt)|0,p=p+Math.imul(ft,wt)|0,M=M+Math.imul(ft,gt)|0;var Rt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,k=Math.imul(b,st),p=Math.imul(b,$e),p=p+Math.imul(S,st)|0,M=Math.imul(S,$e),k=k+Math.imul(i,Ye)|0,p=p+Math.imul(i,Xe)|0,p=p+Math.imul(h,Ye)|0,M=M+Math.imul(h,Xe)|0,k=k+Math.imul(ke,Ue)|0,p=p+Math.imul(ke,Oe)|0,p=p+Math.imul(c,Ue)|0,M=M+Math.imul(c,Oe)|0,k=k+Math.imul(fe,qe)|0,p=p+Math.imul(fe,He)|0,p=p+Math.imul(be,qe)|0,M=M+Math.imul(be,He)|0,k=k+Math.imul(me,Qe)|0,p=p+Math.imul(me,Se)|0,p=p+Math.imul(ce,Qe)|0,M=M+Math.imul(ce,Se)|0,k=k+Math.imul(de,w)|0,p=p+Math.imul(de,I)|0,p=p+Math.imul(Ce,w)|0,M=M+Math.imul(Ce,I)|0,k=k+Math.imul(zt,l)|0,p=p+Math.imul(zt,A)|0,p=p+Math.imul(ge,l)|0,M=M+Math.imul(ge,A)|0,k=k+Math.imul(Zt,K)|0,p=p+Math.imul(Zt,J)|0,p=p+Math.imul(Wt,K)|0,M=M+Math.imul(Wt,J)|0,k=k+Math.imul(At,wt)|0,p=p+Math.imul(At,gt)|0,p=p+Math.imul(Ut,wt)|0,M=M+Math.imul(Ut,gt)|0;var Ft=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,k=Math.imul(b,Ye),p=Math.imul(b,Xe),p=p+Math.imul(S,Ye)|0,M=Math.imul(S,Xe),k=k+Math.imul(i,Ue)|0,p=p+Math.imul(i,Oe)|0,p=p+Math.imul(h,Ue)|0,M=M+Math.imul(h,Oe)|0,k=k+Math.imul(ke,qe)|0,p=p+Math.imul(ke,He)|0,p=p+Math.imul(c,qe)|0,M=M+Math.imul(c,He)|0,k=k+Math.imul(fe,Qe)|0,p=p+Math.imul(fe,Se)|0,p=p+Math.imul(be,Qe)|0,M=M+Math.imul(be,Se)|0,k=k+Math.imul(me,w)|0,p=p+Math.imul(me,I)|0,p=p+Math.imul(ce,w)|0,M=M+Math.imul(ce,I)|0,k=k+Math.imul(de,l)|0,p=p+Math.imul(de,A)|0,p=p+Math.imul(Ce,l)|0,M=M+Math.imul(Ce,A)|0,k=k+Math.imul(zt,K)|0,p=p+Math.imul(zt,J)|0,p=p+Math.imul(ge,K)|0,M=M+Math.imul(ge,J)|0,k=k+Math.imul(Zt,wt)|0,p=p+Math.imul(Zt,gt)|0,p=p+Math.imul(Wt,wt)|0,M=M+Math.imul(Wt,gt)|0;var Bt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,k=Math.imul(b,Ue),p=Math.imul(b,Oe),p=p+Math.imul(S,Ue)|0,M=Math.imul(S,Oe),k=k+Math.imul(i,qe)|0,p=p+Math.imul(i,He)|0,p=p+Math.imul(h,qe)|0,M=M+Math.imul(h,He)|0,k=k+Math.imul(ke,Qe)|0,p=p+Math.imul(ke,Se)|0,p=p+Math.imul(c,Qe)|0,M=M+Math.imul(c,Se)|0,k=k+Math.imul(fe,w)|0,p=p+Math.imul(fe,I)|0,p=p+Math.imul(be,w)|0,M=M+Math.imul(be,I)|0,k=k+Math.imul(me,l)|0,p=p+Math.imul(me,A)|0,p=p+Math.imul(ce,l)|0,M=M+Math.imul(ce,A)|0,k=k+Math.imul(de,K)|0,p=p+Math.imul(de,J)|0,p=p+Math.imul(Ce,K)|0,M=M+Math.imul(Ce,J)|0,k=k+Math.imul(zt,wt)|0,p=p+Math.imul(zt,gt)|0,p=p+Math.imul(ge,wt)|0,M=M+Math.imul(ge,gt)|0;var Tt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,k=Math.imul(b,qe),p=Math.imul(b,He),p=p+Math.imul(S,qe)|0,M=Math.imul(S,He),k=k+Math.imul(i,Qe)|0,p=p+Math.imul(i,Se)|0,p=p+Math.imul(h,Qe)|0,M=M+Math.imul(h,Se)|0,k=k+Math.imul(ke,w)|0,p=p+Math.imul(ke,I)|0,p=p+Math.imul(c,w)|0,M=M+Math.imul(c,I)|0,k=k+Math.imul(fe,l)|0,p=p+Math.imul(fe,A)|0,p=p+Math.imul(be,l)|0,M=M+Math.imul(be,A)|0,k=k+Math.imul(me,K)|0,p=p+Math.imul(me,J)|0,p=p+Math.imul(ce,K)|0,M=M+Math.imul(ce,J)|0,k=k+Math.imul(de,wt)|0,p=p+Math.imul(de,gt)|0,p=p+Math.imul(Ce,wt)|0,M=M+Math.imul(Ce,gt)|0;var Mt=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,k=Math.imul(b,Qe),p=Math.imul(b,Se),p=p+Math.imul(S,Qe)|0,M=Math.imul(S,Se),k=k+Math.imul(i,w)|0,p=p+Math.imul(i,I)|0,p=p+Math.imul(h,w)|0,M=M+Math.imul(h,I)|0,k=k+Math.imul(ke,l)|0,p=p+Math.imul(ke,A)|0,p=p+Math.imul(c,l)|0,M=M+Math.imul(c,A)|0,k=k+Math.imul(fe,K)|0,p=p+Math.imul(fe,J)|0,p=p+Math.imul(be,K)|0,M=M+Math.imul(be,J)|0,k=k+Math.imul(me,wt)|0,p=p+Math.imul(me,gt)|0,p=p+Math.imul(ce,wt)|0,M=M+Math.imul(ce,gt)|0;var Et=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Et>>>26)|0,Et&=67108863,k=Math.imul(b,w),p=Math.imul(b,I),p=p+Math.imul(S,w)|0,M=Math.imul(S,I),k=k+Math.imul(i,l)|0,p=p+Math.imul(i,A)|0,p=p+Math.imul(h,l)|0,M=M+Math.imul(h,A)|0,k=k+Math.imul(ke,K)|0,p=p+Math.imul(ke,J)|0,p=p+Math.imul(c,K)|0,M=M+Math.imul(c,J)|0,k=k+Math.imul(fe,wt)|0,p=p+Math.imul(fe,gt)|0,p=p+Math.imul(be,wt)|0,M=M+Math.imul(be,gt)|0;var Y=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Y>>>26)|0,Y&=67108863,k=Math.imul(b,l),p=Math.imul(b,A),p=p+Math.imul(S,l)|0,M=Math.imul(S,A),k=k+Math.imul(i,K)|0,p=p+Math.imul(i,J)|0,p=p+Math.imul(h,K)|0,M=M+Math.imul(h,J)|0,k=k+Math.imul(ke,wt)|0,p=p+Math.imul(ke,gt)|0,p=p+Math.imul(c,wt)|0,M=M+Math.imul(c,gt)|0;var Z=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(Z>>>26)|0,Z&=67108863,k=Math.imul(b,K),p=Math.imul(b,J),p=p+Math.imul(S,K)|0,M=Math.imul(S,J),k=k+Math.imul(i,wt)|0,p=p+Math.imul(i,gt)|0,p=p+Math.imul(h,wt)|0,M=M+Math.imul(h,gt)|0;var ct=(N+k|0)+((p&8191)<<13)|0;N=(M+(p>>>13)|0)+(ct>>>26)|0,ct&=67108863,k=Math.imul(b,wt),p=Math.imul(b,gt),p=p+Math.imul(S,wt)|0,M=Math.imul(S,gt);var nt=(N+k|0)+((p&8191)<<13)|0;return N=(M+(p>>>13)|0)+(nt>>>26)|0,nt&=67108863,T[0]=ye,T[1]=vt,T[2]=Kt,T[3]=qt,T[4]=Xt,T[5]=Jt,T[6]=Ht,T[7]=Gt,T[8]=Vt,T[9]=Rt,T[10]=Ft,T[11]=Bt,T[12]=Tt,T[13]=Mt,T[14]=Et,T[15]=Y,T[16]=Z,T[17]=ct,T[18]=nt,N!==0&&(T[19]=N,E.length++),E};Math.imul||(X=$);function V(P,d,m){m.negative=d.negative^P.negative,m.length=P.length+d.length;for(var E=0,C=0,R=0;R<m.length-1;R++){var T=C;C=0;for(var N=E&67108863,k=Math.min(R,d.length-1),p=Math.max(0,R-P.length+1);p<=k;p++){var M=R-p,at=P.words[M]|0,tt=d.words[p]|0,ft=at*tt,Lt=ft&67108863;T=T+(ft/67108864|0)|0,Lt=Lt+N|0,N=Lt&67108863,T=T+(Lt>>>26)|0,C+=T>>>26,T&=67108863}m.words[R]=N,E=T,T=C}return E!==0?m.words[R]=E:m.length--,m._strip()}function it(P,d,m){return V(P,d,m)}s.prototype.mulTo=function(d,m){var E,C=this.length+d.length;return this.length===10&&d.length===10?E=X(this,d,m):C<63?E=$(this,d,m):C<1024?E=V(this,d,m):E=it(this,d,m),E},s.prototype.mul=function(d){var m=new s(null);return m.words=new Array(this.length+d.length),this.mulTo(d,m)},s.prototype.mulf=function(d){var m=new s(null);return m.words=new Array(this.length+d.length),it(this,d,m)},s.prototype.imul=function(d){return this.clone().mulTo(d,this)},s.prototype.imuln=function(d){var m=d<0;m&&(d=-d),n(typeof d=="number"),n(d<67108864);for(var E=0,C=0;C<this.length;C++){var R=(this.words[C]|0)*d,T=(R&67108863)+(E&67108863);E>>=26,E+=R/67108864|0,E+=T>>>26,this.words[C]=T&67108863}return E!==0&&(this.words[C]=E,this.length++),m?this.ineg():this},s.prototype.muln=function(d){return this.clone().imuln(d)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(d){var m=z(d);if(m.length===0)return new s(1);for(var E=this,C=0;C<m.length&&m[C]===0;C++,E=E.sqr());if(++C<m.length)for(var R=E.sqr();C<m.length;C++,R=R.sqr())m[C]!==0&&(E=E.mul(R));return E},s.prototype.iushln=function(d){n(typeof d=="number"&&d>=0);var m=d%26,E=(d-m)/26,C=67108863>>>26-m<<26-m,R;if(m!==0){var T=0;for(R=0;R<this.length;R++){var N=this.words[R]&C,k=(this.words[R]|0)-N<<m;this.words[R]=k|T,T=N>>>26-m}T&&(this.words[R]=T,this.length++)}if(E!==0){for(R=this.length-1;R>=0;R--)this.words[R+E]=this.words[R];for(R=0;R<E;R++)this.words[R]=0;this.length+=E}return this._strip()},s.prototype.ishln=function(d){return n(this.negative===0),this.iushln(d)},s.prototype.iushrn=function(d,m,E){n(typeof d=="number"&&d>=0);var C;m?C=(m-m%26)/26:C=0;var R=d%26,T=Math.min((d-R)/26,this.length),N=67108863^67108863>>>R<<R,k=E;if(C-=T,C=Math.max(0,C),k){for(var p=0;p<T;p++)k.words[p]=this.words[p];k.length=T}if(T!==0)if(this.length>T)for(this.length-=T,p=0;p<this.length;p++)this.words[p]=this.words[p+T];else this.words[0]=0,this.length=1;var M=0;for(p=this.length-1;p>=0&&(M!==0||p>=C);p--){var at=this.words[p]|0;this.words[p]=M<<26-R|at>>>R,M=at&N}return k&&M!==0&&(k.words[k.length++]=M),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(d,m,E){return n(this.negative===0),this.iushrn(d,m,E)},s.prototype.shln=function(d){return this.clone().ishln(d)},s.prototype.ushln=function(d){return this.clone().iushln(d)},s.prototype.shrn=function(d){return this.clone().ishrn(d)},s.prototype.ushrn=function(d){return this.clone().iushrn(d)},s.prototype.testn=function(d){n(typeof d=="number"&&d>=0);var m=d%26,E=(d-m)/26,C=1<<m;if(this.length<=E)return!1;var R=this.words[E];return!!(R&C)},s.prototype.imaskn=function(d){n(typeof d=="number"&&d>=0);var m=d%26,E=(d-m)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=E)return this;if(m!==0&&E++,this.length=Math.min(E,this.length),m!==0){var C=67108863^67108863>>>m<<m;this.words[this.length-1]&=C}return this._strip()},s.prototype.maskn=function(d){return this.clone().imaskn(d)},s.prototype.iaddn=function(d){return n(typeof d=="number"),n(d<67108864),d<0?this.isubn(-d):this.negative!==0?this.length===1&&(this.words[0]|0)<=d?(this.words[0]=d-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(d),this.negative=1,this):this._iaddn(d)},s.prototype._iaddn=function(d){this.words[0]+=d;for(var m=0;m<this.length&&this.words[m]>=67108864;m++)this.words[m]-=67108864,m===this.length-1?this.words[m+1]=1:this.words[m+1]++;return this.length=Math.max(this.length,m+1),this},s.prototype.isubn=function(d){if(n(typeof d=="number"),n(d<67108864),d<0)return this.iaddn(-d);if(this.negative!==0)return this.negative=0,this.iaddn(d),this.negative=1,this;if(this.words[0]-=d,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var m=0;m<this.length&&this.words[m]<0;m++)this.words[m]+=67108864,this.words[m+1]-=1;return this._strip()},s.prototype.addn=function(d){return this.clone().iaddn(d)},s.prototype.subn=function(d){return this.clone().isubn(d)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(d,m,E){var C=d.length+E,R;this._expand(C);var T,N=0;for(R=0;R<d.length;R++){T=(this.words[R+E]|0)+N;var k=(d.words[R]|0)*m;T-=k&67108863,N=(T>>26)-(k/67108864|0),this.words[R+E]=T&67108863}for(;R<this.length-E;R++)T=(this.words[R+E]|0)+N,N=T>>26,this.words[R+E]=T&67108863;if(N===0)return this._strip();for(n(N===-1),N=0,R=0;R<this.length;R++)T=-(this.words[R]|0)+N,N=T>>26,this.words[R]=T&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(d,m){var E=this.length-d.length,C=this.clone(),R=d,T=R.words[R.length-1]|0,N=this._countBits(T);E=26-N,E!==0&&(R=R.ushln(E),C.iushln(E),T=R.words[R.length-1]|0);var k=C.length-R.length,p;if(m!=="mod"){p=new s(null),p.length=k+1,p.words=new Array(p.length);for(var M=0;M<p.length;M++)p.words[M]=0}var at=C.clone()._ishlnsubmul(R,1,k);at.negative===0&&(C=at,p&&(p.words[k]=1));for(var tt=k-1;tt>=0;tt--){var ft=(C.words[R.length+tt]|0)*67108864+(C.words[R.length+tt-1]|0);for(ft=Math.min(ft/T|0,67108863),C._ishlnsubmul(R,ft,tt);C.negative!==0;)ft--,C.negative=0,C._ishlnsubmul(R,1,tt),C.isZero()||(C.negative^=1);p&&(p.words[tt]=ft)}return p&&p._strip(),C._strip(),m!=="div"&&E!==0&&C.iushrn(E),{div:p||null,mod:C}},s.prototype.divmod=function(d,m,E){if(n(!d.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var C,R,T;return this.negative!==0&&d.negative===0?(T=this.neg().divmod(d,m),m!=="mod"&&(C=T.div.neg()),m!=="div"&&(R=T.mod.neg(),E&&R.negative!==0&&R.iadd(d)),{div:C,mod:R}):this.negative===0&&d.negative!==0?(T=this.divmod(d.neg(),m),m!=="mod"&&(C=T.div.neg()),{div:C,mod:T.mod}):this.negative&d.negative?(T=this.neg().divmod(d.neg(),m),m!=="div"&&(R=T.mod.neg(),E&&R.negative!==0&&R.isub(d)),{div:T.div,mod:R}):d.length>this.length||this.cmp(d)<0?{div:new s(0),mod:this}:d.length===1?m==="div"?{div:this.divn(d.words[0]),mod:null}:m==="mod"?{div:null,mod:new s(this.modrn(d.words[0]))}:{div:this.divn(d.words[0]),mod:new s(this.modrn(d.words[0]))}:this._wordDiv(d,m)},s.prototype.div=function(d){return this.divmod(d,"div",!1).div},s.prototype.mod=function(d){return this.divmod(d,"mod",!1).mod},s.prototype.umod=function(d){return this.divmod(d,"mod",!0).mod},s.prototype.divRound=function(d){var m=this.divmod(d);if(m.mod.isZero())return m.div;var E=m.div.negative!==0?m.mod.isub(d):m.mod,C=d.ushrn(1),R=d.andln(1),T=E.cmp(C);return T<0||R===1&&T===0?m.div:m.div.negative!==0?m.div.isubn(1):m.div.iaddn(1)},s.prototype.modrn=function(d){var m=d<0;m&&(d=-d),n(d<=67108863);for(var E=(1<<26)%d,C=0,R=this.length-1;R>=0;R--)C=(E*C+(this.words[R]|0))%d;return m?-C:C},s.prototype.modn=function(d){return this.modrn(d)},s.prototype.idivn=function(d){var m=d<0;m&&(d=-d),n(d<=67108863);for(var E=0,C=this.length-1;C>=0;C--){var R=(this.words[C]|0)+E*67108864;this.words[C]=R/d|0,E=R%d}return this._strip(),m?this.ineg():this},s.prototype.divn=function(d){return this.clone().idivn(d)},s.prototype.egcd=function(d){n(d.negative===0),n(!d.isZero());var m=this,E=d.clone();m.negative!==0?m=m.umod(d):m=m.clone();for(var C=new s(1),R=new s(0),T=new s(0),N=new s(1),k=0;m.isEven()&&E.isEven();)m.iushrn(1),E.iushrn(1),++k;for(var p=E.clone(),M=m.clone();!m.isZero();){for(var at=0,tt=1;!(m.words[0]&tt)&&at<26;++at,tt<<=1);if(at>0)for(m.iushrn(at);at-- >0;)(C.isOdd()||R.isOdd())&&(C.iadd(p),R.isub(M)),C.iushrn(1),R.iushrn(1);for(var ft=0,Lt=1;!(E.words[0]&Lt)&&ft<26;++ft,Lt<<=1);if(ft>0)for(E.iushrn(ft);ft-- >0;)(T.isOdd()||N.isOdd())&&(T.iadd(p),N.isub(M)),T.iushrn(1),N.iushrn(1);m.cmp(E)>=0?(m.isub(E),C.isub(T),R.isub(N)):(E.isub(m),T.isub(C),N.isub(R))}return{a:T,b:N,gcd:E.iushln(k)}},s.prototype._invmp=function(d){n(d.negative===0),n(!d.isZero());var m=this,E=d.clone();m.negative!==0?m=m.umod(d):m=m.clone();for(var C=new s(1),R=new s(0),T=E.clone();m.cmpn(1)>0&&E.cmpn(1)>0;){for(var N=0,k=1;!(m.words[0]&k)&&N<26;++N,k<<=1);if(N>0)for(m.iushrn(N);N-- >0;)C.isOdd()&&C.iadd(T),C.iushrn(1);for(var p=0,M=1;!(E.words[0]&M)&&p<26;++p,M<<=1);if(p>0)for(E.iushrn(p);p-- >0;)R.isOdd()&&R.iadd(T),R.iushrn(1);m.cmp(E)>=0?(m.isub(E),C.isub(R)):(E.isub(m),R.isub(C))}var at;return m.cmpn(1)===0?at=C:at=R,at.cmpn(0)<0&&at.iadd(d),at},s.prototype.gcd=function(d){if(this.isZero())return d.abs();if(d.isZero())return this.abs();var m=this.clone(),E=d.clone();m.negative=0,E.negative=0;for(var C=0;m.isEven()&&E.isEven();C++)m.iushrn(1),E.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;E.isEven();)E.iushrn(1);var R=m.cmp(E);if(R<0){var T=m;m=E,E=T}else if(R===0||E.cmpn(1)===0)break;m.isub(E)}while(!0);return E.iushln(C)},s.prototype.invm=function(d){return this.egcd(d).a.umod(d)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(d){return this.words[0]&d},s.prototype.bincn=function(d){n(typeof d=="number");var m=d%26,E=(d-m)/26,C=1<<m;if(this.length<=E)return this._expand(E+1),this.words[E]|=C,this;for(var R=C,T=E;R!==0&&T<this.length;T++){var N=this.words[T]|0;N+=R,R=N>>>26,N&=67108863,this.words[T]=N}return R!==0&&(this.words[T]=R,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(d){var m=d<0;if(this.negative!==0&&!m)return-1;if(this.negative===0&&m)return 1;this._strip();var E;if(this.length>1)E=1;else{m&&(d=-d),n(d<=67108863,"Number is too big");var C=this.words[0]|0;E=C===d?0:C<d?-1:1}return this.negative!==0?-E|0:E},s.prototype.cmp=function(d){if(this.negative!==0&&d.negative===0)return-1;if(this.negative===0&&d.negative!==0)return 1;var m=this.ucmp(d);return this.negative!==0?-m|0:m},s.prototype.ucmp=function(d){if(this.length>d.length)return 1;if(this.length<d.length)return-1;for(var m=0,E=this.length-1;E>=0;E--){var C=this.words[E]|0,R=d.words[E]|0;if(C!==R){C<R?m=-1:C>R&&(m=1);break}}return m},s.prototype.gtn=function(d){return this.cmpn(d)===1},s.prototype.gt=function(d){return this.cmp(d)===1},s.prototype.gten=function(d){return this.cmpn(d)>=0},s.prototype.gte=function(d){return this.cmp(d)>=0},s.prototype.ltn=function(d){return this.cmpn(d)===-1},s.prototype.lt=function(d){return this.cmp(d)===-1},s.prototype.lten=function(d){return this.cmpn(d)<=0},s.prototype.lte=function(d){return this.cmp(d)<=0},s.prototype.eqn=function(d){return this.cmpn(d)===0},s.prototype.eq=function(d){return this.cmp(d)===0},s.red=function(d){return new _t(d)},s.prototype.toRed=function(d){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),d.convertTo(this)._forceRed(d)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(d){return this.red=d,this},s.prototype.forceRed=function(d){return n(!this.red,"Already a number in reduction context"),this._forceRed(d)},s.prototype.redAdd=function(d){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,d)},s.prototype.redIAdd=function(d){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,d)},s.prototype.redSub=function(d){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,d)},s.prototype.redISub=function(d){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,d)},s.prototype.redShl=function(d){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,d)},s.prototype.redMul=function(d){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.mul(this,d)},s.prototype.redIMul=function(d){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.imul(this,d)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(d){return n(this.red&&!d.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,d)};var G={k256:null,p224:null,p192:null,p25519:null};function W(P,d){this.name=P,this.p=new s(d,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}W.prototype._tmp=function(){var d=new s(null);return d.words=new Array(Math.ceil(this.n/13)),d},W.prototype.ireduce=function(d){var m=d,E;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),E=m.bitLength();while(E>this.n);var C=E<this.n?-1:m.ucmp(this.p);return C===0?(m.words[0]=0,m.length=1):C>0?m.isub(this.p):m.strip!==void 0?m.strip():m._strip(),m},W.prototype.split=function(d,m){d.iushrn(this.n,0,m)},W.prototype.imulK=function(d){return d.imul(this.k)};function Q(){W.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}a(Q,W),Q.prototype.split=function(d,m){for(var E=4194303,C=Math.min(d.length,9),R=0;R<C;R++)m.words[R]=d.words[R];if(m.length=C,d.length<=9){d.words[0]=0,d.length=1;return}var T=d.words[9];for(m.words[m.length++]=T&E,R=10;R<d.length;R++){var N=d.words[R]|0;d.words[R-10]=(N&E)<<4|T>>>22,T=N}T>>>=22,d.words[R-10]=T,T===0&&d.length>10?d.length-=10:d.length-=9},Q.prototype.imulK=function(d){d.words[d.length]=0,d.words[d.length+1]=0,d.length+=2;for(var m=0,E=0;E<d.length;E++){var C=d.words[E]|0;m+=C*977,d.words[E]=m&67108863,m=C*64+(m/67108864|0)}return d.words[d.length-1]===0&&(d.length--,d.words[d.length-1]===0&&d.length--),d};function rt(){W.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}a(rt,W);function ae(){W.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}a(ae,W);function jt(){W.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}a(jt,W),jt.prototype.imulK=function(d){for(var m=0,E=0;E<d.length;E++){var C=(d.words[E]|0)*19+m,R=C&67108863;C>>>=26,d.words[E]=R,m=C}return m!==0&&(d.words[d.length++]=m),d},s._prime=function(d){if(G[d])return G[d];var m;if(d==="k256")m=new Q;else if(d==="p224")m=new rt;else if(d==="p192")m=new ae;else if(d==="p25519")m=new jt;else throw new Error("Unknown prime "+d);return G[d]=m,m};function _t(P){if(typeof P=="string"){var d=s._prime(P);this.m=d.p,this.prime=d}else n(P.gtn(1),"modulus must be greater than 1"),this.m=P,this.prime=null}_t.prototype._verify1=function(d){n(d.negative===0,"red works only with positives"),n(d.red,"red works only with red numbers")},_t.prototype._verify2=function(d,m){n((d.negative|m.negative)===0,"red works only with positives"),n(d.red&&d.red===m.red,"red works only with red numbers")},_t.prototype.imod=function(d){return this.prime?this.prime.ireduce(d)._forceRed(this):(B(d,d.umod(this.m)._forceRed(this)),d)},_t.prototype.neg=function(d){return d.isZero()?d.clone():this.m.sub(d)._forceRed(this)},_t.prototype.add=function(d,m){this._verify2(d,m);var E=d.add(m);return E.cmp(this.m)>=0&&E.isub(this.m),E._forceRed(this)},_t.prototype.iadd=function(d,m){this._verify2(d,m);var E=d.iadd(m);return E.cmp(this.m)>=0&&E.isub(this.m),E},_t.prototype.sub=function(d,m){this._verify2(d,m);var E=d.sub(m);return E.cmpn(0)<0&&E.iadd(this.m),E._forceRed(this)},_t.prototype.isub=function(d,m){this._verify2(d,m);var E=d.isub(m);return E.cmpn(0)<0&&E.iadd(this.m),E},_t.prototype.shl=function(d,m){return this._verify1(d),this.imod(d.ushln(m))},_t.prototype.imul=function(d,m){return this._verify2(d,m),this.imod(d.imul(m))},_t.prototype.mul=function(d,m){return this._verify2(d,m),this.imod(d.mul(m))},_t.prototype.isqr=function(d){return this.imul(d,d.clone())},_t.prototype.sqr=function(d){return this.mul(d,d)},_t.prototype.sqrt=function(d){if(d.isZero())return d.clone();var m=this.m.andln(3);if(n(m%2===1),m===3){var E=this.m.add(new s(1)).iushrn(2);return this.pow(d,E)}for(var C=this.m.subn(1),R=0;!C.isZero()&&C.andln(1)===0;)R++,C.iushrn(1);n(!C.isZero());var T=new s(1).toRed(this),N=T.redNeg(),k=this.m.subn(1).iushrn(1),p=this.m.bitLength();for(p=new s(2*p*p).toRed(this);this.pow(p,k).cmp(N)!==0;)p.redIAdd(N);for(var M=this.pow(p,C),at=this.pow(d,C.addn(1).iushrn(1)),tt=this.pow(d,C),ft=R;tt.cmp(T)!==0;){for(var Lt=tt,At=0;Lt.cmp(T)!==0;At++)Lt=Lt.redSqr();n(At<ft);var Ut=this.pow(M,new s(1).iushln(ft-At-1));at=at.redMul(Ut),M=Ut.redSqr(),tt=tt.redMul(M),ft=At}return at},_t.prototype.invm=function(d){var m=d._invmp(this.m);return m.negative!==0?(m.negative=0,this.imod(m).redNeg()):this.imod(m)},_t.prototype.pow=function(d,m){if(m.isZero())return new s(1).toRed(this);if(m.cmpn(1)===0)return d.clone();var E=4,C=new Array(1<<E);C[0]=new s(1).toRed(this),C[1]=d;for(var R=2;R<C.length;R++)C[R]=this.mul(C[R-1],d);var T=C[0],N=0,k=0,p=m.bitLength()%26;for(p===0&&(p=26),R=m.length-1;R>=0;R--){for(var M=m.words[R],at=p-1;at>=0;at--){var tt=M>>at&1;if(T!==C[0]&&(T=this.sqr(T)),tt===0&&N===0){k=0;continue}N<<=1,N|=tt,k++,!(k!==E&&(R!==0||at!==0))&&(T=this.mul(T,C[N]),k=0,N=0)}p=26}return T},_t.prototype.convertTo=function(d){var m=d.umod(this.m);return m===d?m.clone():m},_t.prototype.convertFrom=function(d){var m=d.clone();return m.red=null,m},s.mont=function(d){return new re(d)};function re(P){_t.call(this,P),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}a(re,_t),re.prototype.convertTo=function(d){return this.imod(d.ushln(this.shift))},re.prototype.convertFrom=function(d){var m=this.imod(d.mul(this.rinv));return m.red=null,m},re.prototype.imul=function(d,m){if(d.isZero()||m.isZero())return d.words[0]=0,d.length=1,d;var E=d.imul(m),C=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),R=E.isub(C).iushrn(this.shift),T=R;return R.cmp(this.m)>=0?T=R.isub(this.m):R.cmpn(0)<0&&(T=R.iadd(this.m)),T._forceRed(this)},re.prototype.mul=function(d,m){if(d.isZero()||m.isZero())return new s(0)._forceRed(this);var E=d.mul(m),C=E.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),R=E.isub(C).iushrn(this.shift),T=R;return R.cmp(this.m)>=0?T=R.isub(this.m):R.cmpn(0)<0&&(T=R.iadd(this.m)),T._forceRed(this)},re.prototype.invm=function(d){var m=this.imod(d._invmp(this.m).mul(this.r2));return m._forceRed(this)}})(o,Or)}(_o);var na=_o.exports;const ia=ii(na);var vo={exports:{}},oa={};/*!
7
7
  * The buffer module from node.js, for the browser.
8
8
  *
9
9
  * @author Feross Aboukhadijeh <https://feross.org>
10
10
  * @license MIT
11
- */(function(o){const t=On,e=oi,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;o.Buffer=u,o.SlowBuffer=X,o.INSPECT_MAX_BYTES=50;const a=2147483647;o.kMaxLength=a,u.TYPED_ARRAY_SUPPORT=s(),!u.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 s(){try{const c=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(c,r),c.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function f(c){if(c>a)throw new RangeError('The value "'+c+'" is invalid for option "size"');const r=new Uint8Array(c);return Object.setPrototypeOf(r,u.prototype),r}function u(c,r,i){if(typeof c=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _(c)}return y(c,r,i)}u.poolSize=8192;function y(c,r,i){if(typeof c=="string")return F(c,r);if(ArrayBuffer.isView(c))return D(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(Qt(c,ArrayBuffer)||c&&Qt(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Qt(c,SharedArrayBuffer)||c&&Qt(c.buffer,SharedArrayBuffer)))return C(c,r,i);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const h=c.valueOf&&c.valueOf();if(h!=null&&h!==c)return u.from(h,r,i);const g=z(c);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return u.from(c[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}u.from=function(c,r,i){return y(c,r,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function x(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function v(c,r,i){return x(c),c<=0?f(c):r!==void 0?typeof i=="string"?f(c).fill(r,i):f(c).fill(r):f(c)}u.alloc=function(c,r,i){return v(c,r,i)};function _(c){return x(c),f(c<0?0:$(c)|0)}u.allocUnsafe=function(c){return _(c)},u.allocUnsafeSlow=function(c){return _(c)};function F(c,r){if((typeof r!="string"||r==="")&&(r="utf8"),!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const i=j(c,r)|0;let h=f(i);const g=h.write(c,r);return g!==i&&(h=h.slice(0,g)),h}function L(c){const r=c.length<0?0:$(c.length)|0,i=f(r);for(let h=0;h<r;h+=1)i[h]=c[h]&255;return i}function D(c){if(Qt(c,Uint8Array)){const r=new Uint8Array(c);return C(r.buffer,r.byteOffset,r.byteLength)}return L(c)}function C(c,r,i){if(r<0||c.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let h;return r===void 0&&i===void 0?h=new Uint8Array(c):i===void 0?h=new Uint8Array(c,r):h=new Uint8Array(c,r,i),Object.setPrototypeOf(h,u.prototype),h}function z(c){if(u.isBuffer(c)){const r=$(c.length)|0,i=f(r);return i.length===0||c.copy(i,0,0,r),i}if(c.length!==void 0)return typeof c.length!="number"||fe(c.length)?f(0):L(c);if(c.type==="Buffer"&&Array.isArray(c.data))return L(c.data)}function $(c){if(c>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return c|0}function X(c){return+c!=c&&(c=0),u.alloc(+c)}u.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==u.prototype},u.compare=function(r,i){if(Qt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),Qt(i,Uint8Array)&&(i=u.from(i,i.offset,i.byteLength)),!u.isBuffer(r)||!u.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let h=r.length,g=i.length;for(let b=0,S=Math.min(h,g);b<S;++b)if(r[b]!==i[b]){h=r[b],g=i[b];break}return h<g?-1:g<h?1:0},u.isEncoding=function(r){switch(String(r).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}},u.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);let h;if(i===void 0)for(i=0,h=0;h<r.length;++h)i+=r[h].length;const g=u.allocUnsafe(i);let b=0;for(h=0;h<r.length;++h){let S=r[h];if(Qt(S,Uint8Array))b+S.length>g.length?(u.isBuffer(S)||(S=u.from(S)),S.copy(g,b)):Uint8Array.prototype.set.call(g,S,b);else if(u.isBuffer(S))S.copy(g,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=S.length}return g};function j(c,r){if(u.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||Qt(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const i=c.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&i===0)return 0;let g=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return de(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return we(c).length;default:if(g)return h?-1:de(c).length;r=(""+r).toLowerCase(),g=!0}}u.byteLength=j;function it(c,r,i){let h=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(c||(c="utf8");;)switch(c){case"hex":return T(this,r,i);case"utf8":case"utf-8":return d(this,r,i);case"ascii":return P(this,r,i);case"latin1":case"binary":return R(this,r,i);case"base64":return U(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,r,i);default:if(h)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),h=!0}}u.prototype._isBuffer=!0;function G(c,r,i){const h=c[r];c[r]=c[i],c[i]=h}u.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)G(this,i,i+1);return this},u.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)G(this,i,i+3),G(this,i+1,i+2);return this},u.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)G(this,i,i+7),G(this,i+1,i+6),G(this,i+2,i+5),G(this,i+3,i+4);return this},u.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?d(this,0,r):it.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(r){if(!u.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0},u.prototype.inspect=function(){let r="";const i=o.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(r,i,h,g,b){if(Qt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),h===void 0&&(h=r?r.length:0),g===void 0&&(g=0),b===void 0&&(b=this.length),i<0||h>r.length||g<0||b>this.length)throw new RangeError("out of range index");if(g>=b&&i>=h)return 0;if(g>=b)return-1;if(i>=h)return 1;if(i>>>=0,h>>>=0,g>>>=0,b>>>=0,this===r)return 0;let S=b-g,et=h-i;const lt=Math.min(S,et),ht=this.slice(g,b),Et=r.slice(i,h);for(let st=0;st<lt;++st)if(ht[st]!==Et[st]){S=ht[st],et=Et[st];break}return S<et?-1:et<S?1:0};function W(c,r,i,h,g){if(c.length===0)return-1;if(typeof i=="string"?(h=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,fe(i)&&(i=g?0:c.length-1),i<0&&(i=c.length+i),i>=c.length){if(g)return-1;i=c.length-1}else if(i<0)if(g)i=0;else return-1;if(typeof r=="string"&&(r=u.from(r,h)),u.isBuffer(r))return r.length===0?-1:Q(c,r,i,h,g);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?g?Uint8Array.prototype.indexOf.call(c,r,i):Uint8Array.prototype.lastIndexOf.call(c,r,i):Q(c,[r],i,h,g);throw new TypeError("val must be string, number or Buffer")}function Q(c,r,i,h,g){let b=1,S=c.length,et=r.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(c.length<2||r.length<2)return-1;b=2,S/=2,et/=2,i/=2}function lt(Et,st){return b===1?Et[st]:Et.readUInt16BE(st*b)}let ht;if(g){let Et=-1;for(ht=i;ht<S;ht++)if(lt(c,ht)===lt(r,Et===-1?0:ht-Et)){if(Et===-1&&(Et=ht),ht-Et+1===et)return Et*b}else Et!==-1&&(ht-=ht-Et),Et=-1}else for(i+et>S&&(i=S-et),ht=i;ht>=0;ht--){let Et=!0;for(let st=0;st<et;st++)if(lt(c,ht+st)!==lt(r,st)){Et=!1;break}if(Et)return ht}return-1}u.prototype.includes=function(r,i,h){return this.indexOf(r,i,h)!==-1},u.prototype.indexOf=function(r,i,h){return W(this,r,i,h,!0)},u.prototype.lastIndexOf=function(r,i,h){return W(this,r,i,h,!1)};function rt(c,r,i,h){i=Number(i)||0;const g=c.length-i;h?(h=Number(h),h>g&&(h=g)):h=g;const b=r.length;h>b/2&&(h=b/2);let S;for(S=0;S<h;++S){const et=parseInt(r.substr(S*2,2),16);if(fe(et))return S;c[i+S]=et}return S}function ae(c,r,i,h){return ce(de(r,c.length-i),c,i,h)}function Vt(c,r,i,h){return ce(Pe(r),c,i,h)}function Bt(c,r,i,h){return ce(we(r),c,i,h)}function re(c,r,i,h){return ce(hr(r,c.length-i),c,i,h)}u.prototype.write=function(r,i,h,g){if(i===void 0)g="utf8",h=this.length,i=0;else if(h===void 0&&typeof i=="string")g=i,h=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(h)?(h=h>>>0,g===void 0&&(g="utf8")):(g=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const b=this.length-i;if((h===void 0||h>b)&&(h=b),r.length>0&&(h<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let S=!1;for(;;)switch(g){case"hex":return rt(this,r,i,h);case"utf8":case"utf-8":return ae(this,r,i,h);case"ascii":case"latin1":case"binary":return Vt(this,r,i,h);case"base64":return Bt(this,r,i,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return re(this,r,i,h);default:if(S)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),S=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function U(c,r,i){return r===0&&i===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(r,i))}function d(c,r,i){i=Math.min(c.length,i);const h=[];let g=r;for(;g<i;){const b=c[g];let S=null,et=b>239?4:b>223?3:b>191?2:1;if(g+et<=i){let lt,ht,Et,st;switch(et){case 1:b<128&&(S=b);break;case 2:lt=c[g+1],(lt&192)===128&&(st=(b&31)<<6|lt&63,st>127&&(S=st));break;case 3:lt=c[g+1],ht=c[g+2],(lt&192)===128&&(ht&192)===128&&(st=(b&15)<<12|(lt&63)<<6|ht&63,st>2047&&(st<55296||st>57343)&&(S=st));break;case 4:lt=c[g+1],ht=c[g+2],Et=c[g+3],(lt&192)===128&&(ht&192)===128&&(Et&192)===128&&(st=(b&15)<<18|(lt&63)<<12|(ht&63)<<6|Et&63,st>65535&&st<1114112&&(S=st))}}S===null?(S=65533,et=1):S>65535&&(S-=65536,h.push(S>>>10&1023|55296),S=56320|S&1023),h.push(S),g+=et}return E(h)}const w=4096;function E(c){const r=c.length;if(r<=w)return String.fromCharCode.apply(String,c);let i="",h=0;for(;h<r;)i+=String.fromCharCode.apply(String,c.slice(h,h+=w));return i}function P(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]&127);return h}function R(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]);return h}function T(c,r,i){const h=c.length;(!r||r<0)&&(r=0),(!i||i<0||i>h)&&(i=h);let g="";for(let b=r;b<i;++b)g+=be[c[b]];return g}function N(c,r,i){const h=c.slice(r,i);let g="";for(let b=0;b<h.length-1;b+=2)g+=String.fromCharCode(h[b]+h[b+1]*256);return g}u.prototype.slice=function(r,i){const h=this.length;r=~~r,i=i===void 0?h:~~i,r<0?(r+=h,r<0&&(r=0)):r>h&&(r=h),i<0?(i+=h,i<0&&(i=0)):i>h&&(i=h),i<r&&(i=r);const g=this.subarray(r,i);return Object.setPrototypeOf(g,u.prototype),g};function k(c,r,i){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+r>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r],b=1,S=0;for(;++S<i&&(b*=256);)g+=this[r+S]*b;return g},u.prototype.readUintBE=u.prototype.readUIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r+--i],b=1;for(;i>0&&(b*=256);)g+=this[r+--i]*b;return g},u.prototype.readUint8=u.prototype.readUInt8=function(r,i){return r=r>>>0,i||k(r,1,this.length),this[r]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||k(r,2,this.length),this[r]|this[r+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||k(r,2,this.length),this[r]<<8|this[r+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||k(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},u.prototype.readBigUInt64LE=me(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,b=this[++r]+this[++r]*2**8+this[++r]*2**16+h*2**24;return BigInt(g)+(BigInt(b)<<BigInt(32))}),u.prototype.readBigUInt64BE=me(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=i*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],b=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h;return(BigInt(g)<<BigInt(32))+BigInt(b)}),u.prototype.readIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r],b=1,S=0;for(;++S<i&&(b*=256);)g+=this[r+S]*b;return b*=128,g>=b&&(g-=Math.pow(2,8*i)),g},u.prototype.readIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=i,b=1,S=this[r+--g];for(;g>0&&(b*=256);)S+=this[r+--g]*b;return b*=128,S>=b&&(S-=Math.pow(2,8*i)),S},u.prototype.readInt8=function(r,i){return r=r>>>0,i||k(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},u.prototype.readInt16LE=function(r,i){r=r>>>0,i||k(r,2,this.length);const h=this[r]|this[r+1]<<8;return h&32768?h|4294901760:h},u.prototype.readInt16BE=function(r,i){r=r>>>0,i||k(r,2,this.length);const h=this[r+1]|this[r]<<8;return h&32768?h|4294901760:h},u.prototype.readInt32LE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},u.prototype.readInt32BE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},u.prototype.readBigInt64LE=me(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(h<<24);return(BigInt(g)<<BigInt(32))+BigInt(i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),u.prototype.readBigInt64BE=me(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=(i<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(g)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h)}),u.prototype.readFloatLE=function(r,i){return r=r>>>0,i||k(r,4,this.length),e.read(this,r,!0,23,4)},u.prototype.readFloatBE=function(r,i){return r=r>>>0,i||k(r,4,this.length),e.read(this,r,!1,23,4)},u.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||k(r,8,this.length),e.read(this,r,!0,52,8)},u.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||k(r,8,this.length),e.read(this,r,!1,52,8)};function p(c,r,i,h,g,b){if(!u.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>g||r<b)throw new RangeError('"value" argument is out of bounds');if(i+h>c.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const et=Math.pow(2,8*h)-1;p(this,r,i,h,et,0)}let b=1,S=0;for(this[i]=r&255;++S<h&&(b*=256);)this[i+S]=r/b&255;return i+h},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const et=Math.pow(2,8*h)-1;p(this,r,i,h,et,0)}let b=h-1,S=1;for(this[i+b]=r&255;--b>=0&&(S*=256);)this[i+b]=r/S&255;return i+h},u.prototype.writeUint8=u.prototype.writeUInt8=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,1,255,0),this[i]=r&255,i+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function M(c,r,i,h,g){Wt(r,h,g,c,i,7);let b=Number(r&BigInt(4294967295));c[i++]=b,b=b>>8,c[i++]=b,b=b>>8,c[i++]=b,b=b>>8,c[i++]=b;let S=Number(r>>BigInt(32)&BigInt(4294967295));return c[i++]=S,S=S>>8,c[i++]=S,S=S>>8,c[i++]=S,S=S>>8,c[i++]=S,i}function at(c,r,i,h,g){Wt(r,h,g,c,i,7);let b=Number(r&BigInt(4294967295));c[i+7]=b,b=b>>8,c[i+6]=b,b=b>>8,c[i+5]=b,b=b>>8,c[i+4]=b;let S=Number(r>>BigInt(32)&BigInt(4294967295));return c[i+3]=S,S=S>>8,c[i+2]=S,S=S>>8,c[i+1]=S,S=S>>8,c[i]=S,i+8}u.prototype.writeBigUInt64LE=me(function(r,i=0){return M(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=me(function(r,i=0){return at(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const lt=Math.pow(2,8*h-1);p(this,r,i,h,lt-1,-lt)}let b=0,S=1,et=0;for(this[i]=r&255;++b<h&&(S*=256);)r<0&&et===0&&this[i+b-1]!==0&&(et=1),this[i+b]=(r/S>>0)-et&255;return i+h},u.prototype.writeIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const lt=Math.pow(2,8*h-1);p(this,r,i,h,lt-1,-lt)}let b=h-1,S=1,et=0;for(this[i+b]=r&255;--b>=0&&(S*=256);)r<0&&et===0&&this[i+b+1]!==0&&(et=1),this[i+b]=(r/S>>0)-et&255;return i+h},u.prototype.writeInt8=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},u.prototype.writeInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},u.prototype.writeInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},u.prototype.writeBigInt64LE=me(function(r,i=0){return M(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=me(function(r,i=0){return at(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function tt(c,r,i,h,g,b){if(i+h>c.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function ft(c,r,i,h,g){return r=+r,i=i>>>0,g||tt(c,r,i,4),e.write(c,r,i,h,23,4),i+4}u.prototype.writeFloatLE=function(r,i,h){return ft(this,r,i,!0,h)},u.prototype.writeFloatBE=function(r,i,h){return ft(this,r,i,!1,h)};function Lt(c,r,i,h,g){return r=+r,i=i>>>0,g||tt(c,r,i,8),e.write(c,r,i,h,52,8),i+8}u.prototype.writeDoubleLE=function(r,i,h){return Lt(this,r,i,!0,h)},u.prototype.writeDoubleBE=function(r,i,h){return Lt(this,r,i,!1,h)},u.prototype.copy=function(r,i,h,g){if(!u.isBuffer(r))throw new TypeError("argument should be a Buffer");if(h||(h=0),!g&&g!==0&&(g=this.length),i>=r.length&&(i=r.length),i||(i=0),g>0&&g<h&&(g=h),g===h||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),r.length-i<g-h&&(g=r.length-i+h);const b=g-h;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,h,g):Uint8Array.prototype.set.call(r,this.subarray(h,g),i),b},u.prototype.fill=function(r,i,h,g){if(typeof r=="string"){if(typeof i=="string"?(g=i,i=0,h=this.length):typeof h=="string"&&(g=h,h=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!u.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(r.length===1){const S=r.charCodeAt(0);(g==="utf8"&&S<128||g==="latin1")&&(r=S)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<h)throw new RangeError("Out of range index");if(h<=i)return this;i=i>>>0,h=h===void 0?this.length:h>>>0,r||(r=0);let b;if(typeof r=="number")for(b=i;b<h;++b)this[b]=r;else{const S=u.isBuffer(r)?r:u.from(r,g),et=S.length;if(et===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(b=0;b<h-i;++b)this[b+i]=S[b%et]}return this};const _t={};function Ut(c,r,i){_t[c]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Ut("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ut("ERR_INVALID_ARG_TYPE",function(c,r){return`The "${c}" argument must be of type number. Received type ${typeof r}`},TypeError),Ut("ERR_OUT_OF_RANGE",function(c,r,i){let h=`The value of "${c}" is out of range.`,g=i;return Number.isInteger(i)&&Math.abs(i)>2**32?g=Ee(String(i)):typeof i=="bigint"&&(g=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(g=Ee(g)),g+="n"),h+=` It must be ${r}. Received ${g}`,h},RangeError);function Ee(c){let r="",i=c.length;const h=c[0]==="-"?1:0;for(;i>=h+4;i-=3)r=`_${c.slice(i-3,i)}${r}`;return`${c.slice(0,i)}${r}`}function Zt(c,r,i){Yt(r,"offset"),(c[r]===void 0||c[r+i]===void 0)&&zt(r,c.length-(i+1))}function Wt(c,r,i,h,g,b){if(c>i||c<r){const S=typeof r=="bigint"?"n":"";let et;throw r===0||r===BigInt(0)?et=`>= 0${S} and < 2${S} ** ${(b+1)*8}${S}`:et=`>= -(2${S} ** ${(b+1)*8-1}${S}) and < 2 ** ${(b+1)*8-1}${S}`,new _t.ERR_OUT_OF_RANGE("value",et,c)}Zt(h,g,b)}function Yt(c,r){if(typeof c!="number")throw new _t.ERR_INVALID_ARG_TYPE(r,"number",c)}function zt(c,r,i){throw Math.floor(c)!==c?(Yt(c,i),new _t.ERR_OUT_OF_RANGE("offset","an integer",c)):r<0?new _t.ERR_BUFFER_OUT_OF_BOUNDS:new _t.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,c)}const ge=/[^+/0-9A-Za-z-_]/g;function xr(c){if(c=c.split("=")[0],c=c.trim().replace(ge,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function de(c,r){r=r||1/0;let i;const h=c.length;let g=null;const b=[];for(let S=0;S<h;++S){if(i=c.charCodeAt(S),i>55295&&i<57344){if(!g){if(i>56319){(r-=3)>-1&&b.push(239,191,189);continue}else if(S+1===h){(r-=3)>-1&&b.push(239,191,189);continue}g=i;continue}if(i<56320){(r-=3)>-1&&b.push(239,191,189),g=i;continue}i=(g-55296<<10|i-56320)+65536}else g&&(r-=3)>-1&&b.push(239,191,189);if(g=null,i<128){if((r-=1)<0)break;b.push(i)}else if(i<2048){if((r-=2)<0)break;b.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;b.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;b.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return b}function Pe(c){const r=[];for(let i=0;i<c.length;++i)r.push(c.charCodeAt(i)&255);return r}function hr(c,r){let i,h,g;const b=[];for(let S=0;S<c.length&&!((r-=2)<0);++S)i=c.charCodeAt(S),h=i>>8,g=i%256,b.push(g),b.push(h);return b}function we(c){return t.toByteArray(xr(c))}function ce(c,r,i,h){let g;for(g=0;g<h&&!(g+i>=r.length||g>=c.length);++g)r[g+i]=c[g];return g}function Qt(c,r){return c instanceof r||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===r.name}function fe(c){return c!==c}const be=function(){const c="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){const h=i*16;for(let g=0;g<16;++g)r[h+g]=c[i]+c[g]}return r}();function me(c){return typeof BigInt>"u"?ke:c}function ke(){throw new Error("BigInt not supported")}})(oa);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(o,t){var e=oa,n=e.Buffer;function a(f,u){for(var y in f)u[y]=f[y]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?o.exports=e:(a(e,t),t.Buffer=s);function s(f,u,y){return n(f,u,y)}s.prototype=Object.create(n.prototype),a(n,s),s.from=function(f,u,y){if(typeof f=="number")throw new TypeError("Argument must not be a number");return n(f,u,y)},s.alloc=function(f,u,y){if(typeof f!="number")throw new TypeError("Argument must be a number");var x=n(f);return u!==void 0?typeof y=="string"?x.fill(u,y):x.fill(u):x.fill(0),x},s.allocUnsafe=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return n(f)},s.allocUnsafeSlow=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(f)}})(vo,vo.exports);var lf=vo.exports,Mi=lf.Buffer;function df(o){if(o.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),e=0;e<t.length;e++)t[e]=255;for(var n=0;n<o.length;n++){var a=o.charAt(n),s=a.charCodeAt(0);if(t[s]!==255)throw new TypeError(a+" is ambiguous");t[s]=n}var f=o.length,u=o.charAt(0),y=Math.log(f)/Math.log(256),x=Math.log(256)/Math.log(f);function v(L){if((Array.isArray(L)||L instanceof Uint8Array)&&(L=Mi.from(L)),!Mi.isBuffer(L))throw new TypeError("Expected Buffer");if(L.length===0)return"";for(var D=0,C=0,z=0,$=L.length;z!==$&&L[z]===0;)z++,D++;for(var X=($-z)*x+1>>>0,j=new Uint8Array(X);z!==$;){for(var it=L[z],G=0,W=X-1;(it!==0||G<C)&&W!==-1;W--,G++)it+=256*j[W]>>>0,j[W]=it%f>>>0,it=it/f>>>0;if(it!==0)throw new Error("Non-zero carry");C=G,z++}for(var Q=X-C;Q!==X&&j[Q]===0;)Q++;for(var rt=u.repeat(D);Q<X;++Q)rt+=o.charAt(j[Q]);return rt}function _(L){if(typeof L!="string")throw new TypeError("Expected String");if(L.length===0)return Mi.alloc(0);for(var D=0,C=0,z=0;L[D]===u;)C++,D++;for(var $=(L.length-D)*y+1>>>0,X=new Uint8Array($);L[D];){var j=t[L.charCodeAt(D)];if(j===255)return;for(var it=0,G=$-1;(j!==0||it<z)&&G!==-1;G--,it++)j+=f*X[G]>>>0,X[G]=j%256>>>0,j=j/256>>>0;if(j!==0)throw new Error("Non-zero carry");z=it,D++}for(var W=$-z;W!==$&&X[W]===0;)W++;var Q=Mi.allocUnsafe(C+($-W));Q.fill(0,0,C);for(var rt=C;W!==$;)Q[rt++]=X[W++];return Q}function F(L){var D=_(L);if(D)return D;throw new Error("Non-base"+f+" character")}return{encode:v,decodeUnsafe:_,decode:F}}var pf=df,yf=pf,gf="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",sa=yf(gf);const cr=ii(sa),wf=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]),hn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ln=new Uint32Array(64);class mf extends Ls{constructor(){super(64,32,8,!1),this.A=hn[0]|0,this.B=hn[1]|0,this.C=hn[2]|0,this.D=hn[3]|0,this.E=hn[4]|0,this.F=hn[5]|0,this.G=hn[6]|0,this.H=hn[7]|0}get(){const{A:t,B:e,C:n,D:a,E:s,F:f,G:u,H:y}=this;return[t,e,n,a,s,f,u,y]}set(t,e,n,a,s,f,u,y){this.A=t|0,this.B=e|0,this.C=n|0,this.D=a|0,this.E=s|0,this.F=f|0,this.G=u|0,this.H=y|0}process(t,e){for(let _=0;_<16;_++,e+=4)ln[_]=t.getUint32(e,!1);for(let _=16;_<64;_++){const F=ln[_-15],L=ln[_-2],D=qr(F,7)^qr(F,18)^F>>>3,C=qr(L,17)^qr(L,19)^L>>>10;ln[_]=C+ln[_-7]+D+ln[_-16]|0}let{A:n,B:a,C:s,D:f,E:u,F:y,G:x,H:v}=this;for(let _=0;_<64;_++){const F=qr(u,6)^qr(u,11)^qr(u,25),L=v+F+gu(u,y,x)+wf[_]+ln[_]|0,C=(qr(n,2)^qr(n,13)^qr(n,22))+wu(n,a,s)|0;v=x,x=y,y=u,u=f+L|0,f=s,s=a,a=n,n=L+C|0}n=n+this.A|0,a=a+this.B|0,s=s+this.C|0,f=f+this.D|0,u=u+this.E|0,y=y+this.F|0,x=x+this.G|0,v=v+this.H|0,this.set(n,a,s,f,u,y,x,v)}roundClean(){ln.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const _o=yo(()=>new mf);var lr={};function nn(o,t,e){return t<=o&&o<=e}function Pi(o){if(o===void 0)return{};if(o===Object(o))return o;throw TypeError("Could not convert argument to dictionary")}function bf(o){for(var t=String(o),e=t.length,n=0,a=[];n<e;){var s=t.charCodeAt(n);if(s<55296||s>57343)a.push(s);else if(56320<=s&&s<=57343)a.push(65533);else if(55296<=s&&s<=56319)if(n===e-1)a.push(65533);else{var f=o.charCodeAt(n+1);if(56320<=f&&f<=57343){var u=s&1023,y=f&1023;a.push(65536+(u<<10)+y),n+=1}else a.push(65533)}n+=1}return a}function xf(o){for(var t="",e=0;e<o.length;++e){var n=o[e];n<=65535?t+=String.fromCharCode(n):(n-=65536,t+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return t}var Ui=-1;function Ao(o){this.tokens=[].slice.call(o)}Ao.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Ui},prepend:function(o){if(Array.isArray(o))for(var t=o;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(o)},push:function(o){if(Array.isArray(o))for(var t=o;t.length;)this.tokens.push(t.shift());else this.tokens.push(o)}};var Hn=-1;function Ro(o,t){if(o)throw TypeError("Decoder error");return t||65533}var Ci="utf-8";function Li(o,t){if(!(this instanceof Li))return new Li(o,t);if(o=o!==void 0?String(o).toLowerCase():Ci,o!==Ci)throw new Error("Encoding not supported. Only utf-8 is supported");t=Pi(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}Li.prototype={decode:function(t,e){var n;typeof t=="object"&&t instanceof ArrayBuffer?n=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):n=new Uint8Array(0),e=Pi(e),this._streaming||(this._decoder=new Ef({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var a=new Ao(n),s=[],f;!a.endOfStream()&&(f=this._decoder.handler(a,a.read()),f!==Hn);)f!==null&&(Array.isArray(f)?s.push.apply(s,f):s.push(f));if(!this._streaming){do{if(f=this._decoder.handler(a,a.read()),f===Hn)break;f!==null&&(Array.isArray(f)?s.push.apply(s,f):s.push(f))}while(!a.endOfStream());this._decoder=null}return s.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(s[0]===65279?(this._BOMseen=!0,s.shift()):this._BOMseen=!0),xf(s)}};function Fi(o,t){if(!(this instanceof Fi))return new Fi(o,t);if(o=o!==void 0?String(o).toLowerCase():Ci,o!==Ci)throw new Error("Encoding not supported. Only utf-8 is supported");t=Pi(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Fi.prototype={encode:function(t,e){t=t?String(t):"",e=Pi(e),this._streaming||(this._encoder=new kf(this._options)),this._streaming=!!e.stream;for(var n=[],a=new Ao(bf(t)),s;!a.endOfStream()&&(s=this._encoder.handler(a,a.read()),s!==Hn);)Array.isArray(s)?n.push.apply(n,s):n.push(s);if(!this._streaming){for(;s=this._encoder.handler(a,a.read()),s!==Hn;)Array.isArray(s)?n.push.apply(n,s):n.push(s);this._encoder=null}return new Uint8Array(n)}};function Ef(o){var t=o.fatal,e=0,n=0,a=0,s=128,f=191;this.handler=function(u,y){if(y===Ui&&a!==0)return a=0,Ro(t);if(y===Ui)return Hn;if(a===0){if(nn(y,0,127))return y;if(nn(y,194,223))a=1,e=y-192;else if(nn(y,224,239))y===224&&(s=160),y===237&&(f=159),a=2,e=y-224;else if(nn(y,240,244))y===240&&(s=144),y===244&&(f=143),a=3,e=y-240;else return Ro(t);return e=e<<6*a,null}if(!nn(y,s,f))return e=a=n=0,s=128,f=191,u.prepend(y),Ro(t);if(s=128,f=191,n+=1,e+=y-128<<6*(a-n),n!==a)return null;var x=e;return e=a=n=0,x}}function kf(o){o.fatal,this.handler=function(t,e){if(e===Ui)return Hn;if(nn(e,0,127))return e;var n,a;nn(e,128,2047)?(n=1,a=192):nn(e,2048,65535)?(n=2,a=224):nn(e,65536,1114111)&&(n=3,a=240);for(var s=[(e>>6*n)+a];n>0;){var f=e>>6*(n-1);s.push(128|f&63),n-=1}return s}}const Sf=uo(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Li,TextEncoder:Fi},Symbol.toStringTag,{value:"Module"})));var If=Or&&Or.__createBinding||(Object.create?function(o,t,e,n){n===void 0&&(n=e),Object.defineProperty(o,n,{enumerable:!0,get:function(){return t[e]}})}:function(o,t,e,n){n===void 0&&(n=e),o[n]=t[e]}),Bf=Or&&Or.__setModuleDefault||(Object.create?function(o,t){Object.defineProperty(o,"default",{enumerable:!0,value:t})}:function(o,t){o.default=t}),Hr=Or&&Or.__decorate||function(o,t,e,n){var a=arguments.length,s=a<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,n);else for(var u=o.length-1;u>=0;u--)(f=o[u])&&(s=(a<3?f(s):a>3?f(t,e,s):f(t,e))||s);return a>3&&s&&Object.defineProperty(t,e,s),s},vf=Or&&Or.__importStar||function(o){if(o&&o.__esModule)return o;var t={};if(o!=null)for(var e in o)e!=="default"&&Object.hasOwnProperty.call(o,e)&&If(t,o,e);return Bf(t,o),t},aa=Or&&Or.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(lr,"__esModule",{value:!0});var ca=lr.deserializeUnchecked=pa=lr.deserialize=da=lr.serialize=lr.BinaryReader=lr.BinaryWriter=lr.BorshError=lr.baseDecode=lr.baseEncode=void 0;const dn=aa(na),ua=aa(sa),_f=vf(Sf),Af=typeof TextDecoder!="function"?_f.TextDecoder:TextDecoder,Rf=new Af("utf-8",{fatal:!0});function Tf(o){return typeof o=="string"&&(o=Buffer.from(o,"utf8")),ua.default.encode(Buffer.from(o))}lr.baseEncode=Tf;function Mf(o){return Buffer.from(ua.default.decode(o))}lr.baseDecode=Mf;const To=1024;class Ir extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}lr.BorshError=Ir;class fa{constructor(){this.buf=Buffer.alloc(To),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(To)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer.from(new dn.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new dn.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new dn.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new dn.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(To)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const n of t)this.maybeResize(),e(n)}toArray(){return this.buf.subarray(0,this.length)}}lr.BinaryWriter=fa;function jr(o,t,e){const n=e.value;e.value=function(...a){try{return n.apply(this,a)}catch(s){if(s instanceof RangeError){const f=s.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(f)>=0)throw new Ir("Reached the end of buffer when deserializing")}throw s}}}class Tr{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new dn.default(t,"le")}readU128(){const t=this.readBuffer(16);return new dn.default(t,"le")}readU256(){const t=this.readBuffer(32);return new dn.default(t,"le")}readU512(){const t=this.readBuffer(64);return new dn.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new Ir(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return Rf.decode(e)}catch(n){throw new Ir(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),n=Array();for(let a=0;a<e;++a)n.push(t());return n}}Hr([jr],Tr.prototype,"readU8",null),Hr([jr],Tr.prototype,"readU16",null),Hr([jr],Tr.prototype,"readU32",null),Hr([jr],Tr.prototype,"readU64",null),Hr([jr],Tr.prototype,"readU128",null),Hr([jr],Tr.prototype,"readU256",null),Hr([jr],Tr.prototype,"readU512",null),Hr([jr],Tr.prototype,"readString",null),Hr([jr],Tr.prototype,"readFixedArray",null),Hr([jr],Tr.prototype,"readArray",null),lr.BinaryReader=Tr;function ha(o){return o.charAt(0).toUpperCase()+o.slice(1)}function In(o,t,e,n,a){try{if(typeof n=="string")a[`write${ha(n)}`](e);else if(n instanceof Array)if(typeof n[0]=="number"){if(e.length!==n[0])throw new Ir(`Expecting byte array of length ${n[0]}, but got ${e.length} bytes`);a.writeFixedArray(e)}else if(n.length===2&&typeof n[1]=="number"){if(e.length!==n[1])throw new Ir(`Expecting byte array of length ${n[1]}, but got ${e.length} bytes`);for(let s=0;s<n[1];s++)In(o,null,e[s],n[0],a)}else a.writeArray(e,s=>{In(o,t,s,n[0],a)});else if(n.kind!==void 0)switch(n.kind){case"option":{e==null?a.writeU8(0):(a.writeU8(1),In(o,t,e,n.type,a));break}case"map":{a.writeU32(e.size),e.forEach((s,f)=>{In(o,t,f,n.key,a),In(o,t,s,n.value,a)});break}default:throw new Ir(`FieldType ${n} unrecognized`)}else la(o,e,a)}catch(s){throw s instanceof Ir&&s.addToFieldPath(t),s}}function la(o,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const n=o.get(t.constructor);if(!n)throw new Ir(`Class ${t.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([a,s])=>{In(o,a,t[a],s,e)});else if(n.kind==="enum"){const a=t[n.field];for(let s=0;s<n.values.length;++s){const[f,u]=n.values[s];if(f===a){e.writeU8(s),In(o,f,t[f],u,e);break}}}else throw new Ir(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function Pf(o,t,e=fa){const n=new e;return la(o,t,n),n.toArray()}var da=lr.serialize=Pf;function Bn(o,t,e,n){try{if(typeof e=="string")return n[`read${ha(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return n.readFixedArray(e[0]);if(typeof e[1]=="number"){const a=[];for(let s=0;s<e[1];s++)a.push(Bn(o,null,e[0],n));return a}else return n.readArray(()=>Bn(o,t,e[0],n))}if(e.kind==="option")return n.readU8()?Bn(o,t,e.type,n):void 0;if(e.kind==="map"){let a=new Map;const s=n.readU32();for(let f=0;f<s;f++){const u=Bn(o,t,e.key,n),y=Bn(o,t,e.value,n);a.set(u,y)}return a}return Mo(o,e,n)}catch(a){throw a instanceof Ir&&a.addToFieldPath(t),a}}function Mo(o,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const n=o.get(t);if(!n)throw new Ir(`Class ${t.name} is missing in schema`);if(n.kind==="struct"){const a={};for(const[s,f]of o.get(t).fields)a[s]=Bn(o,s,f,e);return new t(a)}if(n.kind==="enum"){const a=e.readU8();if(a>=n.values.length)throw new Ir(`Enum index: ${a} is out of range`);const[s,f]=n.values[a],u=Bn(o,s,f,e);return new t({[s]:u})}throw new Ir(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function Uf(o,t,e,n=Tr){const a=new n(e),s=Mo(o,t,a);if(a.offset<e.length)throw new Ir(`Unexpected ${e.length-a.offset} bytes after deserialized data`);return s}var pa=lr.deserialize=Uf;function Cf(o,t,e,n=Tr){const a=new n(e);return Mo(o,t,a)}ca=lr.deserializeUnchecked=Cf;var V={},ya={};/*!
11
+ */(function(o){const t=On,e=oi,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;o.Buffer=u,o.SlowBuffer=X,o.INSPECT_MAX_BYTES=50;const a=2147483647;o.kMaxLength=a,u.TYPED_ARRAY_SUPPORT=s(),!u.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 s(){try{const c=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(c,r),c.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function f(c){if(c>a)throw new RangeError('The value "'+c+'" is invalid for option "size"');const r=new Uint8Array(c);return Object.setPrototypeOf(r,u.prototype),r}function u(c,r,i){if(typeof c=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(c)}return y(c,r,i)}u.poolSize=8192;function y(c,r,i){if(typeof c=="string")return F(c,r);if(ArrayBuffer.isView(c))return D(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(Qt(c,ArrayBuffer)||c&&Qt(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Qt(c,SharedArrayBuffer)||c&&Qt(c.buffer,SharedArrayBuffer)))return U(c,r,i);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const h=c.valueOf&&c.valueOf();if(h!=null&&h!==c)return u.from(h,r,i);const g=z(c);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return u.from(c[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}u.from=function(c,r,i){return y(c,r,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function x(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function B(c,r,i){return x(c),c<=0?f(c):r!==void 0?typeof i=="string"?f(c).fill(r,i):f(c).fill(r):f(c)}u.alloc=function(c,r,i){return B(c,r,i)};function v(c){return x(c),f(c<0?0:$(c)|0)}u.allocUnsafe=function(c){return v(c)},u.allocUnsafeSlow=function(c){return v(c)};function F(c,r){if((typeof r!="string"||r==="")&&(r="utf8"),!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const i=V(c,r)|0;let h=f(i);const g=h.write(c,r);return g!==i&&(h=h.slice(0,g)),h}function L(c){const r=c.length<0?0:$(c.length)|0,i=f(r);for(let h=0;h<r;h+=1)i[h]=c[h]&255;return i}function D(c){if(Qt(c,Uint8Array)){const r=new Uint8Array(c);return U(r.buffer,r.byteOffset,r.byteLength)}return L(c)}function U(c,r,i){if(r<0||c.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let h;return r===void 0&&i===void 0?h=new Uint8Array(c):i===void 0?h=new Uint8Array(c,r):h=new Uint8Array(c,r,i),Object.setPrototypeOf(h,u.prototype),h}function z(c){if(u.isBuffer(c)){const r=$(c.length)|0,i=f(r);return i.length===0||c.copy(i,0,0,r),i}if(c.length!==void 0)return typeof c.length!="number"||fe(c.length)?f(0):L(c);if(c.type==="Buffer"&&Array.isArray(c.data))return L(c.data)}function $(c){if(c>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return c|0}function X(c){return+c!=c&&(c=0),u.alloc(+c)}u.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==u.prototype},u.compare=function(r,i){if(Qt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),Qt(i,Uint8Array)&&(i=u.from(i,i.offset,i.byteLength)),!u.isBuffer(r)||!u.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let h=r.length,g=i.length;for(let b=0,S=Math.min(h,g);b<S;++b)if(r[b]!==i[b]){h=r[b],g=i[b];break}return h<g?-1:g<h?1:0},u.isEncoding=function(r){switch(String(r).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}},u.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);let h;if(i===void 0)for(i=0,h=0;h<r.length;++h)i+=r[h].length;const g=u.allocUnsafe(i);let b=0;for(h=0;h<r.length;++h){let S=r[h];if(Qt(S,Uint8Array))b+S.length>g.length?(u.isBuffer(S)||(S=u.from(S)),S.copy(g,b)):Uint8Array.prototype.set.call(g,S,b);else if(u.isBuffer(S))S.copy(g,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=S.length}return g};function V(c,r){if(u.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||Qt(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const i=c.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&i===0)return 0;let g=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return de(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return me(c).length;default:if(g)return h?-1:de(c).length;r=(""+r).toLowerCase(),g=!0}}u.byteLength=V;function it(c,r,i){let h=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(c||(c="utf8");;)switch(c){case"hex":return T(this,r,i);case"utf8":case"utf-8":return d(this,r,i);case"ascii":return C(this,r,i);case"latin1":case"binary":return R(this,r,i);case"base64":return P(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,r,i);default:if(h)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),h=!0}}u.prototype._isBuffer=!0;function G(c,r,i){const h=c[r];c[r]=c[i],c[i]=h}u.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)G(this,i,i+1);return this},u.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)G(this,i,i+3),G(this,i+1,i+2);return this},u.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)G(this,i,i+7),G(this,i+1,i+6),G(this,i+2,i+5),G(this,i+3,i+4);return this},u.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?d(this,0,r):it.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(r){if(!u.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0},u.prototype.inspect=function(){let r="";const i=o.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(r,i,h,g,b){if(Qt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),h===void 0&&(h=r?r.length:0),g===void 0&&(g=0),b===void 0&&(b=this.length),i<0||h>r.length||g<0||b>this.length)throw new RangeError("out of range index");if(g>=b&&i>=h)return 0;if(g>=b)return-1;if(i>=h)return 1;if(i>>>=0,h>>>=0,g>>>=0,b>>>=0,this===r)return 0;let S=b-g,et=h-i;const lt=Math.min(S,et),ht=this.slice(g,b),kt=r.slice(i,h);for(let st=0;st<lt;++st)if(ht[st]!==kt[st]){S=ht[st],et=kt[st];break}return S<et?-1:et<S?1:0};function W(c,r,i,h,g){if(c.length===0)return-1;if(typeof i=="string"?(h=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,fe(i)&&(i=g?0:c.length-1),i<0&&(i=c.length+i),i>=c.length){if(g)return-1;i=c.length-1}else if(i<0)if(g)i=0;else return-1;if(typeof r=="string"&&(r=u.from(r,h)),u.isBuffer(r))return r.length===0?-1:Q(c,r,i,h,g);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?g?Uint8Array.prototype.indexOf.call(c,r,i):Uint8Array.prototype.lastIndexOf.call(c,r,i):Q(c,[r],i,h,g);throw new TypeError("val must be string, number or Buffer")}function Q(c,r,i,h,g){let b=1,S=c.length,et=r.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(c.length<2||r.length<2)return-1;b=2,S/=2,et/=2,i/=2}function lt(kt,st){return b===1?kt[st]:kt.readUInt16BE(st*b)}let ht;if(g){let kt=-1;for(ht=i;ht<S;ht++)if(lt(c,ht)===lt(r,kt===-1?0:ht-kt)){if(kt===-1&&(kt=ht),ht-kt+1===et)return kt*b}else kt!==-1&&(ht-=ht-kt),kt=-1}else for(i+et>S&&(i=S-et),ht=i;ht>=0;ht--){let kt=!0;for(let st=0;st<et;st++)if(lt(c,ht+st)!==lt(r,st)){kt=!1;break}if(kt)return ht}return-1}u.prototype.includes=function(r,i,h){return this.indexOf(r,i,h)!==-1},u.prototype.indexOf=function(r,i,h){return W(this,r,i,h,!0)},u.prototype.lastIndexOf=function(r,i,h){return W(this,r,i,h,!1)};function rt(c,r,i,h){i=Number(i)||0;const g=c.length-i;h?(h=Number(h),h>g&&(h=g)):h=g;const b=r.length;h>b/2&&(h=b/2);let S;for(S=0;S<h;++S){const et=parseInt(r.substr(S*2,2),16);if(fe(et))return S;c[i+S]=et}return S}function ae(c,r,i,h){return ce(de(r,c.length-i),c,i,h)}function jt(c,r,i,h){return ce(Ce(r),c,i,h)}function _t(c,r,i,h){return ce(me(r),c,i,h)}function re(c,r,i,h){return ce(hr(r,c.length-i),c,i,h)}u.prototype.write=function(r,i,h,g){if(i===void 0)g="utf8",h=this.length,i=0;else if(h===void 0&&typeof i=="string")g=i,h=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(h)?(h=h>>>0,g===void 0&&(g="utf8")):(g=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const b=this.length-i;if((h===void 0||h>b)&&(h=b),r.length>0&&(h<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let S=!1;for(;;)switch(g){case"hex":return rt(this,r,i,h);case"utf8":case"utf-8":return ae(this,r,i,h);case"ascii":case"latin1":case"binary":return jt(this,r,i,h);case"base64":return _t(this,r,i,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return re(this,r,i,h);default:if(S)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),S=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function P(c,r,i){return r===0&&i===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(r,i))}function d(c,r,i){i=Math.min(c.length,i);const h=[];let g=r;for(;g<i;){const b=c[g];let S=null,et=b>239?4:b>223?3:b>191?2:1;if(g+et<=i){let lt,ht,kt,st;switch(et){case 1:b<128&&(S=b);break;case 2:lt=c[g+1],(lt&192)===128&&(st=(b&31)<<6|lt&63,st>127&&(S=st));break;case 3:lt=c[g+1],ht=c[g+2],(lt&192)===128&&(ht&192)===128&&(st=(b&15)<<12|(lt&63)<<6|ht&63,st>2047&&(st<55296||st>57343)&&(S=st));break;case 4:lt=c[g+1],ht=c[g+2],kt=c[g+3],(lt&192)===128&&(ht&192)===128&&(kt&192)===128&&(st=(b&15)<<18|(lt&63)<<12|(ht&63)<<6|kt&63,st>65535&&st<1114112&&(S=st))}}S===null?(S=65533,et=1):S>65535&&(S-=65536,h.push(S>>>10&1023|55296),S=56320|S&1023),h.push(S),g+=et}return E(h)}const m=4096;function E(c){const r=c.length;if(r<=m)return String.fromCharCode.apply(String,c);let i="",h=0;for(;h<r;)i+=String.fromCharCode.apply(String,c.slice(h,h+=m));return i}function C(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]&127);return h}function R(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]);return h}function T(c,r,i){const h=c.length;(!r||r<0)&&(r=0),(!i||i<0||i>h)&&(i=h);let g="";for(let b=r;b<i;++b)g+=be[c[b]];return g}function N(c,r,i){const h=c.slice(r,i);let g="";for(let b=0;b<h.length-1;b+=2)g+=String.fromCharCode(h[b]+h[b+1]*256);return g}u.prototype.slice=function(r,i){const h=this.length;r=~~r,i=i===void 0?h:~~i,r<0?(r+=h,r<0&&(r=0)):r>h&&(r=h),i<0?(i+=h,i<0&&(i=0)):i>h&&(i=h),i<r&&(i=r);const g=this.subarray(r,i);return Object.setPrototypeOf(g,u.prototype),g};function k(c,r,i){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+r>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r],b=1,S=0;for(;++S<i&&(b*=256);)g+=this[r+S]*b;return g},u.prototype.readUintBE=u.prototype.readUIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r+--i],b=1;for(;i>0&&(b*=256);)g+=this[r+--i]*b;return g},u.prototype.readUint8=u.prototype.readUInt8=function(r,i){return r=r>>>0,i||k(r,1,this.length),this[r]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||k(r,2,this.length),this[r]|this[r+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||k(r,2,this.length),this[r]<<8|this[r+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||k(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},u.prototype.readBigUInt64LE=we(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,b=this[++r]+this[++r]*2**8+this[++r]*2**16+h*2**24;return BigInt(g)+(BigInt(b)<<BigInt(32))}),u.prototype.readBigUInt64BE=we(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=i*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],b=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h;return(BigInt(g)<<BigInt(32))+BigInt(b)}),u.prototype.readIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r],b=1,S=0;for(;++S<i&&(b*=256);)g+=this[r+S]*b;return b*=128,g>=b&&(g-=Math.pow(2,8*i)),g},u.prototype.readIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=i,b=1,S=this[r+--g];for(;g>0&&(b*=256);)S+=this[r+--g]*b;return b*=128,S>=b&&(S-=Math.pow(2,8*i)),S},u.prototype.readInt8=function(r,i){return r=r>>>0,i||k(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},u.prototype.readInt16LE=function(r,i){r=r>>>0,i||k(r,2,this.length);const h=this[r]|this[r+1]<<8;return h&32768?h|4294901760:h},u.prototype.readInt16BE=function(r,i){r=r>>>0,i||k(r,2,this.length);const h=this[r+1]|this[r]<<8;return h&32768?h|4294901760:h},u.prototype.readInt32LE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},u.prototype.readInt32BE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},u.prototype.readBigInt64LE=we(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(h<<24);return(BigInt(g)<<BigInt(32))+BigInt(i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),u.prototype.readBigInt64BE=we(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=(i<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(g)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h)}),u.prototype.readFloatLE=function(r,i){return r=r>>>0,i||k(r,4,this.length),e.read(this,r,!0,23,4)},u.prototype.readFloatBE=function(r,i){return r=r>>>0,i||k(r,4,this.length),e.read(this,r,!1,23,4)},u.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||k(r,8,this.length),e.read(this,r,!0,52,8)},u.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||k(r,8,this.length),e.read(this,r,!1,52,8)};function p(c,r,i,h,g,b){if(!u.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>g||r<b)throw new RangeError('"value" argument is out of bounds');if(i+h>c.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const et=Math.pow(2,8*h)-1;p(this,r,i,h,et,0)}let b=1,S=0;for(this[i]=r&255;++S<h&&(b*=256);)this[i+S]=r/b&255;return i+h},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const et=Math.pow(2,8*h)-1;p(this,r,i,h,et,0)}let b=h-1,S=1;for(this[i+b]=r&255;--b>=0&&(S*=256);)this[i+b]=r/S&255;return i+h},u.prototype.writeUint8=u.prototype.writeUInt8=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,1,255,0),this[i]=r&255,i+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function M(c,r,i,h,g){Wt(r,h,g,c,i,7);let b=Number(r&BigInt(4294967295));c[i++]=b,b=b>>8,c[i++]=b,b=b>>8,c[i++]=b,b=b>>8,c[i++]=b;let S=Number(r>>BigInt(32)&BigInt(4294967295));return c[i++]=S,S=S>>8,c[i++]=S,S=S>>8,c[i++]=S,S=S>>8,c[i++]=S,i}function at(c,r,i,h,g){Wt(r,h,g,c,i,7);let b=Number(r&BigInt(4294967295));c[i+7]=b,b=b>>8,c[i+6]=b,b=b>>8,c[i+5]=b,b=b>>8,c[i+4]=b;let S=Number(r>>BigInt(32)&BigInt(4294967295));return c[i+3]=S,S=S>>8,c[i+2]=S,S=S>>8,c[i+1]=S,S=S>>8,c[i]=S,i+8}u.prototype.writeBigUInt64LE=we(function(r,i=0){return M(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=we(function(r,i=0){return at(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const lt=Math.pow(2,8*h-1);p(this,r,i,h,lt-1,-lt)}let b=0,S=1,et=0;for(this[i]=r&255;++b<h&&(S*=256);)r<0&&et===0&&this[i+b-1]!==0&&(et=1),this[i+b]=(r/S>>0)-et&255;return i+h},u.prototype.writeIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const lt=Math.pow(2,8*h-1);p(this,r,i,h,lt-1,-lt)}let b=h-1,S=1,et=0;for(this[i+b]=r&255;--b>=0&&(S*=256);)r<0&&et===0&&this[i+b+1]!==0&&(et=1),this[i+b]=(r/S>>0)-et&255;return i+h},u.prototype.writeInt8=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},u.prototype.writeInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},u.prototype.writeInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},u.prototype.writeBigInt64LE=we(function(r,i=0){return M(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=we(function(r,i=0){return at(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function tt(c,r,i,h,g,b){if(i+h>c.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function ft(c,r,i,h,g){return r=+r,i=i>>>0,g||tt(c,r,i,4),e.write(c,r,i,h,23,4),i+4}u.prototype.writeFloatLE=function(r,i,h){return ft(this,r,i,!0,h)},u.prototype.writeFloatBE=function(r,i,h){return ft(this,r,i,!1,h)};function Lt(c,r,i,h,g){return r=+r,i=i>>>0,g||tt(c,r,i,8),e.write(c,r,i,h,52,8),i+8}u.prototype.writeDoubleLE=function(r,i,h){return Lt(this,r,i,!0,h)},u.prototype.writeDoubleBE=function(r,i,h){return Lt(this,r,i,!1,h)},u.prototype.copy=function(r,i,h,g){if(!u.isBuffer(r))throw new TypeError("argument should be a Buffer");if(h||(h=0),!g&&g!==0&&(g=this.length),i>=r.length&&(i=r.length),i||(i=0),g>0&&g<h&&(g=h),g===h||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),r.length-i<g-h&&(g=r.length-i+h);const b=g-h;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,h,g):Uint8Array.prototype.set.call(r,this.subarray(h,g),i),b},u.prototype.fill=function(r,i,h,g){if(typeof r=="string"){if(typeof i=="string"?(g=i,i=0,h=this.length):typeof h=="string"&&(g=h,h=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!u.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(r.length===1){const S=r.charCodeAt(0);(g==="utf8"&&S<128||g==="latin1")&&(r=S)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<h)throw new RangeError("Out of range index");if(h<=i)return this;i=i>>>0,h=h===void 0?this.length:h>>>0,r||(r=0);let b;if(typeof r=="number")for(b=i;b<h;++b)this[b]=r;else{const S=u.isBuffer(r)?r:u.from(r,g),et=S.length;if(et===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(b=0;b<h-i;++b)this[b+i]=S[b%et]}return this};const At={};function Ut(c,r,i){At[c]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Ut("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ut("ERR_INVALID_ARG_TYPE",function(c,r){return`The "${c}" argument must be of type number. Received type ${typeof r}`},TypeError),Ut("ERR_OUT_OF_RANGE",function(c,r,i){let h=`The value of "${c}" is out of range.`,g=i;return Number.isInteger(i)&&Math.abs(i)>2**32?g=Ee(String(i)):typeof i=="bigint"&&(g=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(g=Ee(g)),g+="n"),h+=` It must be ${r}. Received ${g}`,h},RangeError);function Ee(c){let r="",i=c.length;const h=c[0]==="-"?1:0;for(;i>=h+4;i-=3)r=`_${c.slice(i-3,i)}${r}`;return`${c.slice(0,i)}${r}`}function Zt(c,r,i){Yt(r,"offset"),(c[r]===void 0||c[r+i]===void 0)&&zt(r,c.length-(i+1))}function Wt(c,r,i,h,g,b){if(c>i||c<r){const S=typeof r=="bigint"?"n":"";let et;throw r===0||r===BigInt(0)?et=`>= 0${S} and < 2${S} ** ${(b+1)*8}${S}`:et=`>= -(2${S} ** ${(b+1)*8-1}${S}) and < 2 ** ${(b+1)*8-1}${S}`,new At.ERR_OUT_OF_RANGE("value",et,c)}Zt(h,g,b)}function Yt(c,r){if(typeof c!="number")throw new At.ERR_INVALID_ARG_TYPE(r,"number",c)}function zt(c,r,i){throw Math.floor(c)!==c?(Yt(c,i),new At.ERR_OUT_OF_RANGE("offset","an integer",c)):r<0?new At.ERR_BUFFER_OUT_OF_BOUNDS:new At.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,c)}const ge=/[^+/0-9A-Za-z-_]/g;function xr(c){if(c=c.split("=")[0],c=c.trim().replace(ge,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function de(c,r){r=r||1/0;let i;const h=c.length;let g=null;const b=[];for(let S=0;S<h;++S){if(i=c.charCodeAt(S),i>55295&&i<57344){if(!g){if(i>56319){(r-=3)>-1&&b.push(239,191,189);continue}else if(S+1===h){(r-=3)>-1&&b.push(239,191,189);continue}g=i;continue}if(i<56320){(r-=3)>-1&&b.push(239,191,189),g=i;continue}i=(g-55296<<10|i-56320)+65536}else g&&(r-=3)>-1&&b.push(239,191,189);if(g=null,i<128){if((r-=1)<0)break;b.push(i)}else if(i<2048){if((r-=2)<0)break;b.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;b.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;b.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return b}function Ce(c){const r=[];for(let i=0;i<c.length;++i)r.push(c.charCodeAt(i)&255);return r}function hr(c,r){let i,h,g;const b=[];for(let S=0;S<c.length&&!((r-=2)<0);++S)i=c.charCodeAt(S),h=i>>8,g=i%256,b.push(g),b.push(h);return b}function me(c){return t.toByteArray(xr(c))}function ce(c,r,i,h){let g;for(g=0;g<h&&!(g+i>=r.length||g>=c.length);++g)r[g+i]=c[g];return g}function Qt(c,r){return c instanceof r||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===r.name}function fe(c){return c!==c}const be=function(){const c="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){const h=i*16;for(let g=0;g<16;++g)r[h+g]=c[i]+c[g]}return r}();function we(c){return typeof BigInt>"u"?ke:c}function ke(){throw new Error("BigInt not supported")}})(oa);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(o,t){var e=oa,n=e.Buffer;function a(f,u){for(var y in f)u[y]=f[y]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?o.exports=e:(a(e,t),t.Buffer=s);function s(f,u,y){return n(f,u,y)}s.prototype=Object.create(n.prototype),a(n,s),s.from=function(f,u,y){if(typeof f=="number")throw new TypeError("Argument must not be a number");return n(f,u,y)},s.alloc=function(f,u,y){if(typeof f!="number")throw new TypeError("Argument must be a number");var x=n(f);return u!==void 0?typeof y=="string"?x.fill(u,y):x.fill(u):x.fill(0),x},s.allocUnsafe=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return n(f)},s.allocUnsafeSlow=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(f)}})(vo,vo.exports);var lf=vo.exports,Mi=lf.Buffer;function df(o){if(o.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),e=0;e<t.length;e++)t[e]=255;for(var n=0;n<o.length;n++){var a=o.charAt(n),s=a.charCodeAt(0);if(t[s]!==255)throw new TypeError(a+" is ambiguous");t[s]=n}var f=o.length,u=o.charAt(0),y=Math.log(f)/Math.log(256),x=Math.log(256)/Math.log(f);function B(L){if((Array.isArray(L)||L instanceof Uint8Array)&&(L=Mi.from(L)),!Mi.isBuffer(L))throw new TypeError("Expected Buffer");if(L.length===0)return"";for(var D=0,U=0,z=0,$=L.length;z!==$&&L[z]===0;)z++,D++;for(var X=($-z)*x+1>>>0,V=new Uint8Array(X);z!==$;){for(var it=L[z],G=0,W=X-1;(it!==0||G<U)&&W!==-1;W--,G++)it+=256*V[W]>>>0,V[W]=it%f>>>0,it=it/f>>>0;if(it!==0)throw new Error("Non-zero carry");U=G,z++}for(var Q=X-U;Q!==X&&V[Q]===0;)Q++;for(var rt=u.repeat(D);Q<X;++Q)rt+=o.charAt(V[Q]);return rt}function v(L){if(typeof L!="string")throw new TypeError("Expected String");if(L.length===0)return Mi.alloc(0);for(var D=0,U=0,z=0;L[D]===u;)U++,D++;for(var $=(L.length-D)*y+1>>>0,X=new Uint8Array($);L[D];){var V=t[L.charCodeAt(D)];if(V===255)return;for(var it=0,G=$-1;(V!==0||it<z)&&G!==-1;G--,it++)V+=f*X[G]>>>0,X[G]=V%256>>>0,V=V/256>>>0;if(V!==0)throw new Error("Non-zero carry");z=it,D++}for(var W=$-z;W!==$&&X[W]===0;)W++;var Q=Mi.allocUnsafe(U+($-W));Q.fill(0,0,U);for(var rt=U;W!==$;)Q[rt++]=X[W++];return Q}function F(L){var D=v(L);if(D)return D;throw new Error("Non-base"+f+" character")}return{encode:B,decodeUnsafe:v,decode:F}}var pf=df,yf=pf,gf="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",sa=yf(gf);const cr=ii(sa),mf=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]),hn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ln=new Uint32Array(64);class wf extends Ls{constructor(){super(64,32,8,!1),this.A=hn[0]|0,this.B=hn[1]|0,this.C=hn[2]|0,this.D=hn[3]|0,this.E=hn[4]|0,this.F=hn[5]|0,this.G=hn[6]|0,this.H=hn[7]|0}get(){const{A:t,B:e,C:n,D:a,E:s,F:f,G:u,H:y}=this;return[t,e,n,a,s,f,u,y]}set(t,e,n,a,s,f,u,y){this.A=t|0,this.B=e|0,this.C=n|0,this.D=a|0,this.E=s|0,this.F=f|0,this.G=u|0,this.H=y|0}process(t,e){for(let v=0;v<16;v++,e+=4)ln[v]=t.getUint32(e,!1);for(let v=16;v<64;v++){const F=ln[v-15],L=ln[v-2],D=Hr(F,7)^Hr(F,18)^F>>>3,U=Hr(L,17)^Hr(L,19)^L>>>10;ln[v]=U+ln[v-7]+D+ln[v-16]|0}let{A:n,B:a,C:s,D:f,E:u,F:y,G:x,H:B}=this;for(let v=0;v<64;v++){const F=Hr(u,6)^Hr(u,11)^Hr(u,25),L=B+F+gu(u,y,x)+mf[v]+ln[v]|0,U=(Hr(n,2)^Hr(n,13)^Hr(n,22))+mu(n,a,s)|0;B=x,x=y,y=u,u=f+L|0,f=s,s=a,a=n,n=L+U|0}n=n+this.A|0,a=a+this.B|0,s=s+this.C|0,f=f+this.D|0,u=u+this.E|0,y=y+this.F|0,x=x+this.G|0,B=B+this.H|0,this.set(n,a,s,f,u,y,x,B)}roundClean(){ln.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ao=go(()=>new wf);var lr={};function nn(o,t,e){return t<=o&&o<=e}function Ci(o){if(o===void 0)return{};if(o===Object(o))return o;throw TypeError("Could not convert argument to dictionary")}function bf(o){for(var t=String(o),e=t.length,n=0,a=[];n<e;){var s=t.charCodeAt(n);if(s<55296||s>57343)a.push(s);else if(56320<=s&&s<=57343)a.push(65533);else if(55296<=s&&s<=56319)if(n===e-1)a.push(65533);else{var f=o.charCodeAt(n+1);if(56320<=f&&f<=57343){var u=s&1023,y=f&1023;a.push(65536+(u<<10)+y),n+=1}else a.push(65533)}n+=1}return a}function xf(o){for(var t="",e=0;e<o.length;++e){var n=o[e];n<=65535?t+=String.fromCharCode(n):(n-=65536,t+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return t}var Pi=-1;function Ro(o){this.tokens=[].slice.call(o)}Ro.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Pi},prepend:function(o){if(Array.isArray(o))for(var t=o;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(o)},push:function(o){if(Array.isArray(o))for(var t=o;t.length;)this.tokens.push(t.shift());else this.tokens.push(o)}};var Hn=-1;function To(o,t){if(o)throw TypeError("Decoder error");return t||65533}var Ui="utf-8";function Li(o,t){if(!(this instanceof Li))return new Li(o,t);if(o=o!==void 0?String(o).toLowerCase():Ui,o!==Ui)throw new Error("Encoding not supported. Only utf-8 is supported");t=Ci(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}Li.prototype={decode:function(t,e){var n;typeof t=="object"&&t instanceof ArrayBuffer?n=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):n=new Uint8Array(0),e=Ci(e),this._streaming||(this._decoder=new Ef({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var a=new Ro(n),s=[],f;!a.endOfStream()&&(f=this._decoder.handler(a,a.read()),f!==Hn);)f!==null&&(Array.isArray(f)?s.push.apply(s,f):s.push(f));if(!this._streaming){do{if(f=this._decoder.handler(a,a.read()),f===Hn)break;f!==null&&(Array.isArray(f)?s.push.apply(s,f):s.push(f))}while(!a.endOfStream());this._decoder=null}return s.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(s[0]===65279?(this._BOMseen=!0,s.shift()):this._BOMseen=!0),xf(s)}};function Fi(o,t){if(!(this instanceof Fi))return new Fi(o,t);if(o=o!==void 0?String(o).toLowerCase():Ui,o!==Ui)throw new Error("Encoding not supported. Only utf-8 is supported");t=Ci(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Fi.prototype={encode:function(t,e){t=t?String(t):"",e=Ci(e),this._streaming||(this._encoder=new kf(this._options)),this._streaming=!!e.stream;for(var n=[],a=new Ro(bf(t)),s;!a.endOfStream()&&(s=this._encoder.handler(a,a.read()),s!==Hn);)Array.isArray(s)?n.push.apply(n,s):n.push(s);if(!this._streaming){for(;s=this._encoder.handler(a,a.read()),s!==Hn;)Array.isArray(s)?n.push.apply(n,s):n.push(s);this._encoder=null}return new Uint8Array(n)}};function Ef(o){var t=o.fatal,e=0,n=0,a=0,s=128,f=191;this.handler=function(u,y){if(y===Pi&&a!==0)return a=0,To(t);if(y===Pi)return Hn;if(a===0){if(nn(y,0,127))return y;if(nn(y,194,223))a=1,e=y-192;else if(nn(y,224,239))y===224&&(s=160),y===237&&(f=159),a=2,e=y-224;else if(nn(y,240,244))y===240&&(s=144),y===244&&(f=143),a=3,e=y-240;else return To(t);return e=e<<6*a,null}if(!nn(y,s,f))return e=a=n=0,s=128,f=191,u.prepend(y),To(t);if(s=128,f=191,n+=1,e+=y-128<<6*(a-n),n!==a)return null;var x=e;return e=a=n=0,x}}function kf(o){o.fatal,this.handler=function(t,e){if(e===Pi)return Hn;if(nn(e,0,127))return e;var n,a;nn(e,128,2047)?(n=1,a=192):nn(e,2048,65535)?(n=2,a=224):nn(e,65536,1114111)&&(n=3,a=240);for(var s=[(e>>6*n)+a];n>0;){var f=e>>6*(n-1);s.push(128|f&63),n-=1}return s}}const Sf=fo(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Li,TextEncoder:Fi},Symbol.toStringTag,{value:"Module"})));var If=Or&&Or.__createBinding||(Object.create?function(o,t,e,n){n===void 0&&(n=e),Object.defineProperty(o,n,{enumerable:!0,get:function(){return t[e]}})}:function(o,t,e,n){n===void 0&&(n=e),o[n]=t[e]}),Bf=Or&&Or.__setModuleDefault||(Object.create?function(o,t){Object.defineProperty(o,"default",{enumerable:!0,value:t})}:function(o,t){o.default=t}),Vr=Or&&Or.__decorate||function(o,t,e,n){var a=arguments.length,s=a<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,n);else for(var u=o.length-1;u>=0;u--)(f=o[u])&&(s=(a<3?f(s):a>3?f(t,e,s):f(t,e))||s);return a>3&&s&&Object.defineProperty(t,e,s),s},_f=Or&&Or.__importStar||function(o){if(o&&o.__esModule)return o;var t={};if(o!=null)for(var e in o)e!=="default"&&Object.hasOwnProperty.call(o,e)&&If(t,o,e);return Bf(t,o),t},aa=Or&&Or.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(lr,"__esModule",{value:!0});var ca=lr.deserializeUnchecked=pa=lr.deserialize=da=lr.serialize=lr.BinaryReader=lr.BinaryWriter=lr.BorshError=lr.baseDecode=lr.baseEncode=void 0;const dn=aa(na),ua=aa(sa),vf=_f(Sf),Af=typeof TextDecoder!="function"?vf.TextDecoder:TextDecoder,Rf=new Af("utf-8",{fatal:!0});function Tf(o){return typeof o=="string"&&(o=Buffer.from(o,"utf8")),ua.default.encode(Buffer.from(o))}lr.baseEncode=Tf;function Mf(o){return Buffer.from(ua.default.decode(o))}lr.baseDecode=Mf;const Mo=1024;class Ir extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}lr.BorshError=Ir;class fa{constructor(){this.buf=Buffer.alloc(Mo),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(Mo)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer.from(new dn.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new dn.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new dn.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new dn.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(Mo)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const n of t)this.maybeResize(),e(n)}toArray(){return this.buf.subarray(0,this.length)}}lr.BinaryWriter=fa;function jr(o,t,e){const n=e.value;e.value=function(...a){try{return n.apply(this,a)}catch(s){if(s instanceof RangeError){const f=s.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(f)>=0)throw new Ir("Reached the end of buffer when deserializing")}throw s}}}class Tr{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new dn.default(t,"le")}readU128(){const t=this.readBuffer(16);return new dn.default(t,"le")}readU256(){const t=this.readBuffer(32);return new dn.default(t,"le")}readU512(){const t=this.readBuffer(64);return new dn.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new Ir(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return Rf.decode(e)}catch(n){throw new Ir(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),n=Array();for(let a=0;a<e;++a)n.push(t());return n}}Vr([jr],Tr.prototype,"readU8",null),Vr([jr],Tr.prototype,"readU16",null),Vr([jr],Tr.prototype,"readU32",null),Vr([jr],Tr.prototype,"readU64",null),Vr([jr],Tr.prototype,"readU128",null),Vr([jr],Tr.prototype,"readU256",null),Vr([jr],Tr.prototype,"readU512",null),Vr([jr],Tr.prototype,"readString",null),Vr([jr],Tr.prototype,"readFixedArray",null),Vr([jr],Tr.prototype,"readArray",null),lr.BinaryReader=Tr;function ha(o){return o.charAt(0).toUpperCase()+o.slice(1)}function In(o,t,e,n,a){try{if(typeof n=="string")a[`write${ha(n)}`](e);else if(n instanceof Array)if(typeof n[0]=="number"){if(e.length!==n[0])throw new Ir(`Expecting byte array of length ${n[0]}, but got ${e.length} bytes`);a.writeFixedArray(e)}else if(n.length===2&&typeof n[1]=="number"){if(e.length!==n[1])throw new Ir(`Expecting byte array of length ${n[1]}, but got ${e.length} bytes`);for(let s=0;s<n[1];s++)In(o,null,e[s],n[0],a)}else a.writeArray(e,s=>{In(o,t,s,n[0],a)});else if(n.kind!==void 0)switch(n.kind){case"option":{e==null?a.writeU8(0):(a.writeU8(1),In(o,t,e,n.type,a));break}case"map":{a.writeU32(e.size),e.forEach((s,f)=>{In(o,t,f,n.key,a),In(o,t,s,n.value,a)});break}default:throw new Ir(`FieldType ${n} unrecognized`)}else la(o,e,a)}catch(s){throw s instanceof Ir&&s.addToFieldPath(t),s}}function la(o,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const n=o.get(t.constructor);if(!n)throw new Ir(`Class ${t.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([a,s])=>{In(o,a,t[a],s,e)});else if(n.kind==="enum"){const a=t[n.field];for(let s=0;s<n.values.length;++s){const[f,u]=n.values[s];if(f===a){e.writeU8(s),In(o,f,t[f],u,e);break}}}else throw new Ir(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function Cf(o,t,e=fa){const n=new e;return la(o,t,n),n.toArray()}var da=lr.serialize=Cf;function Bn(o,t,e,n){try{if(typeof e=="string")return n[`read${ha(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return n.readFixedArray(e[0]);if(typeof e[1]=="number"){const a=[];for(let s=0;s<e[1];s++)a.push(Bn(o,null,e[0],n));return a}else return n.readArray(()=>Bn(o,t,e[0],n))}if(e.kind==="option")return n.readU8()?Bn(o,t,e.type,n):void 0;if(e.kind==="map"){let a=new Map;const s=n.readU32();for(let f=0;f<s;f++){const u=Bn(o,t,e.key,n),y=Bn(o,t,e.value,n);a.set(u,y)}return a}return Co(o,e,n)}catch(a){throw a instanceof Ir&&a.addToFieldPath(t),a}}function Co(o,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const n=o.get(t);if(!n)throw new Ir(`Class ${t.name} is missing in schema`);if(n.kind==="struct"){const a={};for(const[s,f]of o.get(t).fields)a[s]=Bn(o,s,f,e);return new t(a)}if(n.kind==="enum"){const a=e.readU8();if(a>=n.values.length)throw new Ir(`Enum index: ${a} is out of range`);const[s,f]=n.values[a],u=Bn(o,s,f,e);return new t({[s]:u})}throw new Ir(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function Pf(o,t,e,n=Tr){const a=new n(e),s=Co(o,t,a);if(a.offset<e.length)throw new Ir(`Unexpected ${e.length-a.offset} bytes after deserialized data`);return s}var pa=lr.deserialize=Pf;function Uf(o,t,e,n=Tr){const a=new n(e);return Co(o,t,a)}ca=lr.deserializeUnchecked=Uf;var j={},ya={};/*!
12
12
  * The buffer module from node.js, for the browser.
13
13
  *
14
14
  * @author Feross Aboukhadijeh <https://feross.org>
15
15
  * @license MIT
16
- */(function(o){const t=On,e=oi,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;o.Buffer=u,o.SlowBuffer=X,o.INSPECT_MAX_BYTES=50;const a=2147483647;o.kMaxLength=a,u.TYPED_ARRAY_SUPPORT=s(),!u.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 s(){try{const c=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(c,r),c.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function f(c){if(c>a)throw new RangeError('The value "'+c+'" is invalid for option "size"');const r=new Uint8Array(c);return Object.setPrototypeOf(r,u.prototype),r}function u(c,r,i){if(typeof c=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _(c)}return y(c,r,i)}u.poolSize=8192;function y(c,r,i){if(typeof c=="string")return F(c,r);if(ArrayBuffer.isView(c))return D(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(Qt(c,ArrayBuffer)||c&&Qt(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Qt(c,SharedArrayBuffer)||c&&Qt(c.buffer,SharedArrayBuffer)))return C(c,r,i);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const h=c.valueOf&&c.valueOf();if(h!=null&&h!==c)return u.from(h,r,i);const g=z(c);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return u.from(c[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}u.from=function(c,r,i){return y(c,r,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function x(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function v(c,r,i){return x(c),c<=0?f(c):r!==void 0?typeof i=="string"?f(c).fill(r,i):f(c).fill(r):f(c)}u.alloc=function(c,r,i){return v(c,r,i)};function _(c){return x(c),f(c<0?0:$(c)|0)}u.allocUnsafe=function(c){return _(c)},u.allocUnsafeSlow=function(c){return _(c)};function F(c,r){if((typeof r!="string"||r==="")&&(r="utf8"),!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const i=j(c,r)|0;let h=f(i);const g=h.write(c,r);return g!==i&&(h=h.slice(0,g)),h}function L(c){const r=c.length<0?0:$(c.length)|0,i=f(r);for(let h=0;h<r;h+=1)i[h]=c[h]&255;return i}function D(c){if(Qt(c,Uint8Array)){const r=new Uint8Array(c);return C(r.buffer,r.byteOffset,r.byteLength)}return L(c)}function C(c,r,i){if(r<0||c.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let h;return r===void 0&&i===void 0?h=new Uint8Array(c):i===void 0?h=new Uint8Array(c,r):h=new Uint8Array(c,r,i),Object.setPrototypeOf(h,u.prototype),h}function z(c){if(u.isBuffer(c)){const r=$(c.length)|0,i=f(r);return i.length===0||c.copy(i,0,0,r),i}if(c.length!==void 0)return typeof c.length!="number"||fe(c.length)?f(0):L(c);if(c.type==="Buffer"&&Array.isArray(c.data))return L(c.data)}function $(c){if(c>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return c|0}function X(c){return+c!=c&&(c=0),u.alloc(+c)}u.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==u.prototype},u.compare=function(r,i){if(Qt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),Qt(i,Uint8Array)&&(i=u.from(i,i.offset,i.byteLength)),!u.isBuffer(r)||!u.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let h=r.length,g=i.length;for(let b=0,S=Math.min(h,g);b<S;++b)if(r[b]!==i[b]){h=r[b],g=i[b];break}return h<g?-1:g<h?1:0},u.isEncoding=function(r){switch(String(r).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}},u.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);let h;if(i===void 0)for(i=0,h=0;h<r.length;++h)i+=r[h].length;const g=u.allocUnsafe(i);let b=0;for(h=0;h<r.length;++h){let S=r[h];if(Qt(S,Uint8Array))b+S.length>g.length?(u.isBuffer(S)||(S=u.from(S)),S.copy(g,b)):Uint8Array.prototype.set.call(g,S,b);else if(u.isBuffer(S))S.copy(g,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=S.length}return g};function j(c,r){if(u.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||Qt(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const i=c.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&i===0)return 0;let g=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return de(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return we(c).length;default:if(g)return h?-1:de(c).length;r=(""+r).toLowerCase(),g=!0}}u.byteLength=j;function it(c,r,i){let h=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(c||(c="utf8");;)switch(c){case"hex":return T(this,r,i);case"utf8":case"utf-8":return d(this,r,i);case"ascii":return P(this,r,i);case"latin1":case"binary":return R(this,r,i);case"base64":return U(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,r,i);default:if(h)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),h=!0}}u.prototype._isBuffer=!0;function G(c,r,i){const h=c[r];c[r]=c[i],c[i]=h}u.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)G(this,i,i+1);return this},u.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)G(this,i,i+3),G(this,i+1,i+2);return this},u.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)G(this,i,i+7),G(this,i+1,i+6),G(this,i+2,i+5),G(this,i+3,i+4);return this},u.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?d(this,0,r):it.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(r){if(!u.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0},u.prototype.inspect=function(){let r="";const i=o.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(r,i,h,g,b){if(Qt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),h===void 0&&(h=r?r.length:0),g===void 0&&(g=0),b===void 0&&(b=this.length),i<0||h>r.length||g<0||b>this.length)throw new RangeError("out of range index");if(g>=b&&i>=h)return 0;if(g>=b)return-1;if(i>=h)return 1;if(i>>>=0,h>>>=0,g>>>=0,b>>>=0,this===r)return 0;let S=b-g,et=h-i;const lt=Math.min(S,et),ht=this.slice(g,b),Et=r.slice(i,h);for(let st=0;st<lt;++st)if(ht[st]!==Et[st]){S=ht[st],et=Et[st];break}return S<et?-1:et<S?1:0};function W(c,r,i,h,g){if(c.length===0)return-1;if(typeof i=="string"?(h=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,fe(i)&&(i=g?0:c.length-1),i<0&&(i=c.length+i),i>=c.length){if(g)return-1;i=c.length-1}else if(i<0)if(g)i=0;else return-1;if(typeof r=="string"&&(r=u.from(r,h)),u.isBuffer(r))return r.length===0?-1:Q(c,r,i,h,g);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?g?Uint8Array.prototype.indexOf.call(c,r,i):Uint8Array.prototype.lastIndexOf.call(c,r,i):Q(c,[r],i,h,g);throw new TypeError("val must be string, number or Buffer")}function Q(c,r,i,h,g){let b=1,S=c.length,et=r.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(c.length<2||r.length<2)return-1;b=2,S/=2,et/=2,i/=2}function lt(Et,st){return b===1?Et[st]:Et.readUInt16BE(st*b)}let ht;if(g){let Et=-1;for(ht=i;ht<S;ht++)if(lt(c,ht)===lt(r,Et===-1?0:ht-Et)){if(Et===-1&&(Et=ht),ht-Et+1===et)return Et*b}else Et!==-1&&(ht-=ht-Et),Et=-1}else for(i+et>S&&(i=S-et),ht=i;ht>=0;ht--){let Et=!0;for(let st=0;st<et;st++)if(lt(c,ht+st)!==lt(r,st)){Et=!1;break}if(Et)return ht}return-1}u.prototype.includes=function(r,i,h){return this.indexOf(r,i,h)!==-1},u.prototype.indexOf=function(r,i,h){return W(this,r,i,h,!0)},u.prototype.lastIndexOf=function(r,i,h){return W(this,r,i,h,!1)};function rt(c,r,i,h){i=Number(i)||0;const g=c.length-i;h?(h=Number(h),h>g&&(h=g)):h=g;const b=r.length;h>b/2&&(h=b/2);let S;for(S=0;S<h;++S){const et=parseInt(r.substr(S*2,2),16);if(fe(et))return S;c[i+S]=et}return S}function ae(c,r,i,h){return ce(de(r,c.length-i),c,i,h)}function Vt(c,r,i,h){return ce(Pe(r),c,i,h)}function Bt(c,r,i,h){return ce(we(r),c,i,h)}function re(c,r,i,h){return ce(hr(r,c.length-i),c,i,h)}u.prototype.write=function(r,i,h,g){if(i===void 0)g="utf8",h=this.length,i=0;else if(h===void 0&&typeof i=="string")g=i,h=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(h)?(h=h>>>0,g===void 0&&(g="utf8")):(g=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const b=this.length-i;if((h===void 0||h>b)&&(h=b),r.length>0&&(h<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let S=!1;for(;;)switch(g){case"hex":return rt(this,r,i,h);case"utf8":case"utf-8":return ae(this,r,i,h);case"ascii":case"latin1":case"binary":return Vt(this,r,i,h);case"base64":return Bt(this,r,i,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return re(this,r,i,h);default:if(S)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),S=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function U(c,r,i){return r===0&&i===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(r,i))}function d(c,r,i){i=Math.min(c.length,i);const h=[];let g=r;for(;g<i;){const b=c[g];let S=null,et=b>239?4:b>223?3:b>191?2:1;if(g+et<=i){let lt,ht,Et,st;switch(et){case 1:b<128&&(S=b);break;case 2:lt=c[g+1],(lt&192)===128&&(st=(b&31)<<6|lt&63,st>127&&(S=st));break;case 3:lt=c[g+1],ht=c[g+2],(lt&192)===128&&(ht&192)===128&&(st=(b&15)<<12|(lt&63)<<6|ht&63,st>2047&&(st<55296||st>57343)&&(S=st));break;case 4:lt=c[g+1],ht=c[g+2],Et=c[g+3],(lt&192)===128&&(ht&192)===128&&(Et&192)===128&&(st=(b&15)<<18|(lt&63)<<12|(ht&63)<<6|Et&63,st>65535&&st<1114112&&(S=st))}}S===null?(S=65533,et=1):S>65535&&(S-=65536,h.push(S>>>10&1023|55296),S=56320|S&1023),h.push(S),g+=et}return E(h)}const w=4096;function E(c){const r=c.length;if(r<=w)return String.fromCharCode.apply(String,c);let i="",h=0;for(;h<r;)i+=String.fromCharCode.apply(String,c.slice(h,h+=w));return i}function P(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]&127);return h}function R(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]);return h}function T(c,r,i){const h=c.length;(!r||r<0)&&(r=0),(!i||i<0||i>h)&&(i=h);let g="";for(let b=r;b<i;++b)g+=be[c[b]];return g}function N(c,r,i){const h=c.slice(r,i);let g="";for(let b=0;b<h.length-1;b+=2)g+=String.fromCharCode(h[b]+h[b+1]*256);return g}u.prototype.slice=function(r,i){const h=this.length;r=~~r,i=i===void 0?h:~~i,r<0?(r+=h,r<0&&(r=0)):r>h&&(r=h),i<0?(i+=h,i<0&&(i=0)):i>h&&(i=h),i<r&&(i=r);const g=this.subarray(r,i);return Object.setPrototypeOf(g,u.prototype),g};function k(c,r,i){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+r>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r],b=1,S=0;for(;++S<i&&(b*=256);)g+=this[r+S]*b;return g},u.prototype.readUintBE=u.prototype.readUIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r+--i],b=1;for(;i>0&&(b*=256);)g+=this[r+--i]*b;return g},u.prototype.readUint8=u.prototype.readUInt8=function(r,i){return r=r>>>0,i||k(r,1,this.length),this[r]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||k(r,2,this.length),this[r]|this[r+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||k(r,2,this.length),this[r]<<8|this[r+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||k(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},u.prototype.readBigUInt64LE=me(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,b=this[++r]+this[++r]*2**8+this[++r]*2**16+h*2**24;return BigInt(g)+(BigInt(b)<<BigInt(32))}),u.prototype.readBigUInt64BE=me(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=i*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],b=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h;return(BigInt(g)<<BigInt(32))+BigInt(b)}),u.prototype.readIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r],b=1,S=0;for(;++S<i&&(b*=256);)g+=this[r+S]*b;return b*=128,g>=b&&(g-=Math.pow(2,8*i)),g},u.prototype.readIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=i,b=1,S=this[r+--g];for(;g>0&&(b*=256);)S+=this[r+--g]*b;return b*=128,S>=b&&(S-=Math.pow(2,8*i)),S},u.prototype.readInt8=function(r,i){return r=r>>>0,i||k(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},u.prototype.readInt16LE=function(r,i){r=r>>>0,i||k(r,2,this.length);const h=this[r]|this[r+1]<<8;return h&32768?h|4294901760:h},u.prototype.readInt16BE=function(r,i){r=r>>>0,i||k(r,2,this.length);const h=this[r+1]|this[r]<<8;return h&32768?h|4294901760:h},u.prototype.readInt32LE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},u.prototype.readInt32BE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},u.prototype.readBigInt64LE=me(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(h<<24);return(BigInt(g)<<BigInt(32))+BigInt(i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),u.prototype.readBigInt64BE=me(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=(i<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(g)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h)}),u.prototype.readFloatLE=function(r,i){return r=r>>>0,i||k(r,4,this.length),e.read(this,r,!0,23,4)},u.prototype.readFloatBE=function(r,i){return r=r>>>0,i||k(r,4,this.length),e.read(this,r,!1,23,4)},u.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||k(r,8,this.length),e.read(this,r,!0,52,8)},u.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||k(r,8,this.length),e.read(this,r,!1,52,8)};function p(c,r,i,h,g,b){if(!u.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>g||r<b)throw new RangeError('"value" argument is out of bounds');if(i+h>c.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const et=Math.pow(2,8*h)-1;p(this,r,i,h,et,0)}let b=1,S=0;for(this[i]=r&255;++S<h&&(b*=256);)this[i+S]=r/b&255;return i+h},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const et=Math.pow(2,8*h)-1;p(this,r,i,h,et,0)}let b=h-1,S=1;for(this[i+b]=r&255;--b>=0&&(S*=256);)this[i+b]=r/S&255;return i+h},u.prototype.writeUint8=u.prototype.writeUInt8=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,1,255,0),this[i]=r&255,i+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function M(c,r,i,h,g){Wt(r,h,g,c,i,7);let b=Number(r&BigInt(4294967295));c[i++]=b,b=b>>8,c[i++]=b,b=b>>8,c[i++]=b,b=b>>8,c[i++]=b;let S=Number(r>>BigInt(32)&BigInt(4294967295));return c[i++]=S,S=S>>8,c[i++]=S,S=S>>8,c[i++]=S,S=S>>8,c[i++]=S,i}function at(c,r,i,h,g){Wt(r,h,g,c,i,7);let b=Number(r&BigInt(4294967295));c[i+7]=b,b=b>>8,c[i+6]=b,b=b>>8,c[i+5]=b,b=b>>8,c[i+4]=b;let S=Number(r>>BigInt(32)&BigInt(4294967295));return c[i+3]=S,S=S>>8,c[i+2]=S,S=S>>8,c[i+1]=S,S=S>>8,c[i]=S,i+8}u.prototype.writeBigUInt64LE=me(function(r,i=0){return M(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=me(function(r,i=0){return at(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const lt=Math.pow(2,8*h-1);p(this,r,i,h,lt-1,-lt)}let b=0,S=1,et=0;for(this[i]=r&255;++b<h&&(S*=256);)r<0&&et===0&&this[i+b-1]!==0&&(et=1),this[i+b]=(r/S>>0)-et&255;return i+h},u.prototype.writeIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const lt=Math.pow(2,8*h-1);p(this,r,i,h,lt-1,-lt)}let b=h-1,S=1,et=0;for(this[i+b]=r&255;--b>=0&&(S*=256);)r<0&&et===0&&this[i+b+1]!==0&&(et=1),this[i+b]=(r/S>>0)-et&255;return i+h},u.prototype.writeInt8=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},u.prototype.writeInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},u.prototype.writeInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},u.prototype.writeBigInt64LE=me(function(r,i=0){return M(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=me(function(r,i=0){return at(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function tt(c,r,i,h,g,b){if(i+h>c.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function ft(c,r,i,h,g){return r=+r,i=i>>>0,g||tt(c,r,i,4),e.write(c,r,i,h,23,4),i+4}u.prototype.writeFloatLE=function(r,i,h){return ft(this,r,i,!0,h)},u.prototype.writeFloatBE=function(r,i,h){return ft(this,r,i,!1,h)};function Lt(c,r,i,h,g){return r=+r,i=i>>>0,g||tt(c,r,i,8),e.write(c,r,i,h,52,8),i+8}u.prototype.writeDoubleLE=function(r,i,h){return Lt(this,r,i,!0,h)},u.prototype.writeDoubleBE=function(r,i,h){return Lt(this,r,i,!1,h)},u.prototype.copy=function(r,i,h,g){if(!u.isBuffer(r))throw new TypeError("argument should be a Buffer");if(h||(h=0),!g&&g!==0&&(g=this.length),i>=r.length&&(i=r.length),i||(i=0),g>0&&g<h&&(g=h),g===h||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),r.length-i<g-h&&(g=r.length-i+h);const b=g-h;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,h,g):Uint8Array.prototype.set.call(r,this.subarray(h,g),i),b},u.prototype.fill=function(r,i,h,g){if(typeof r=="string"){if(typeof i=="string"?(g=i,i=0,h=this.length):typeof h=="string"&&(g=h,h=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!u.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(r.length===1){const S=r.charCodeAt(0);(g==="utf8"&&S<128||g==="latin1")&&(r=S)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<h)throw new RangeError("Out of range index");if(h<=i)return this;i=i>>>0,h=h===void 0?this.length:h>>>0,r||(r=0);let b;if(typeof r=="number")for(b=i;b<h;++b)this[b]=r;else{const S=u.isBuffer(r)?r:u.from(r,g),et=S.length;if(et===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(b=0;b<h-i;++b)this[b+i]=S[b%et]}return this};const _t={};function Ut(c,r,i){_t[c]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Ut("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ut("ERR_INVALID_ARG_TYPE",function(c,r){return`The "${c}" argument must be of type number. Received type ${typeof r}`},TypeError),Ut("ERR_OUT_OF_RANGE",function(c,r,i){let h=`The value of "${c}" is out of range.`,g=i;return Number.isInteger(i)&&Math.abs(i)>2**32?g=Ee(String(i)):typeof i=="bigint"&&(g=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(g=Ee(g)),g+="n"),h+=` It must be ${r}. Received ${g}`,h},RangeError);function Ee(c){let r="",i=c.length;const h=c[0]==="-"?1:0;for(;i>=h+4;i-=3)r=`_${c.slice(i-3,i)}${r}`;return`${c.slice(0,i)}${r}`}function Zt(c,r,i){Yt(r,"offset"),(c[r]===void 0||c[r+i]===void 0)&&zt(r,c.length-(i+1))}function Wt(c,r,i,h,g,b){if(c>i||c<r){const S=typeof r=="bigint"?"n":"";let et;throw r===0||r===BigInt(0)?et=`>= 0${S} and < 2${S} ** ${(b+1)*8}${S}`:et=`>= -(2${S} ** ${(b+1)*8-1}${S}) and < 2 ** ${(b+1)*8-1}${S}`,new _t.ERR_OUT_OF_RANGE("value",et,c)}Zt(h,g,b)}function Yt(c,r){if(typeof c!="number")throw new _t.ERR_INVALID_ARG_TYPE(r,"number",c)}function zt(c,r,i){throw Math.floor(c)!==c?(Yt(c,i),new _t.ERR_OUT_OF_RANGE("offset","an integer",c)):r<0?new _t.ERR_BUFFER_OUT_OF_BOUNDS:new _t.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,c)}const ge=/[^+/0-9A-Za-z-_]/g;function xr(c){if(c=c.split("=")[0],c=c.trim().replace(ge,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function de(c,r){r=r||1/0;let i;const h=c.length;let g=null;const b=[];for(let S=0;S<h;++S){if(i=c.charCodeAt(S),i>55295&&i<57344){if(!g){if(i>56319){(r-=3)>-1&&b.push(239,191,189);continue}else if(S+1===h){(r-=3)>-1&&b.push(239,191,189);continue}g=i;continue}if(i<56320){(r-=3)>-1&&b.push(239,191,189),g=i;continue}i=(g-55296<<10|i-56320)+65536}else g&&(r-=3)>-1&&b.push(239,191,189);if(g=null,i<128){if((r-=1)<0)break;b.push(i)}else if(i<2048){if((r-=2)<0)break;b.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;b.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;b.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return b}function Pe(c){const r=[];for(let i=0;i<c.length;++i)r.push(c.charCodeAt(i)&255);return r}function hr(c,r){let i,h,g;const b=[];for(let S=0;S<c.length&&!((r-=2)<0);++S)i=c.charCodeAt(S),h=i>>8,g=i%256,b.push(g),b.push(h);return b}function we(c){return t.toByteArray(xr(c))}function ce(c,r,i,h){let g;for(g=0;g<h&&!(g+i>=r.length||g>=c.length);++g)r[g+i]=c[g];return g}function Qt(c,r){return c instanceof r||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===r.name}function fe(c){return c!==c}const be=function(){const c="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){const h=i*16;for(let g=0;g<16;++g)r[h+g]=c[i]+c[g]}return r}();function me(c){return typeof BigInt>"u"?ke:c}function ke(){throw new Error("BigInt not supported")}})(ya),Object.defineProperty(V,"__esModule",{value:!0}),V.s16=V.s8=V.nu64be=V.u48be=V.u40be=V.u32be=V.u24be=V.u16be=dr=V.nu64=V.u48=V.u40=Mt=V.u32=V.u24=Lr=V.u16=ve=V.u8=pn=V.offset=V.greedy=V.Constant=V.UTF8=V.CString=V.Blob=V.Boolean=V.BitField=V.BitStructure=V.VariantLayout=V.Union=V.UnionLayoutDiscriminator=V.UnionDiscriminator=V.Structure=V.Sequence=V.DoubleBE=V.Double=V.FloatBE=V.Float=V.NearInt64BE=V.NearInt64=V.NearUInt64BE=V.NearUInt64=V.IntBE=V.Int=V.UIntBE=V.UInt=V.OffsetLayout=V.GreedyCount=V.ExternalLayout=V.bindConstructorLayout=V.nameWithProperty=V.Layout=V.uint8ArrayToBuffer=V.checkUint8Array=void 0,V.constant=V.utf8=V.cstr=Ke=V.blob=V.unionLayoutDiscriminator=V.union=pr=V.seq=V.bits=Pt=V.struct=V.f64be=V.f64=V.f32be=V.f32=V.ns64be=V.s48be=V.s40be=V.s32be=V.s24be=V.s16be=Mr=V.ns64=V.s48=V.s40=V.s32=V.s24=void 0;const Po=ya;function jn(o){if(!(o instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}V.checkUint8Array=jn;function Te(o){return jn(o),Po.Buffer.from(o.buffer,o.byteOffset,o.length)}V.uint8ArrayToBuffer=Te;class Le{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}V.Layout=Le;function Uo(o,t){return t.property?o+"["+t.property+"]":o}V.nameWithProperty=Uo;function Lf(o,t){if(typeof o!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(o,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Le))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");o.layout_=t,t.boundConstructor_=o,t.makeDestinationObject=()=>new o,Object.defineProperty(o.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(o,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}V.bindConstructorLayout=Lf;class vr extends Le{isCount(){throw new Error("ExternalLayout is abstract")}}V.ExternalLayout=vr;class ga extends vr{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){jn(t);const n=t.length-e;return Math.floor(n/this.elementSpan)}encode(t,e,n){return 0}}V.GreedyCount=ga;class Co extends vr{constructor(t,e=0,n){if(!(t instanceof Le))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,n||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Cr||this.layout instanceof zr}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,n=0){return this.layout.encode(t,e,n+this.offset)}}V.OffsetLayout=Co;class Cr extends Le{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Te(t).readUIntLE(e,this.span)}encode(t,e,n=0){return Te(e).writeUIntLE(t,n,this.span),this.span}}V.UInt=Cr;class zr extends Le{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Te(t).readUIntBE(e,this.span)}encode(t,e,n=0){return Te(e).writeUIntBE(t,n,this.span),this.span}}V.UIntBE=zr;class vn extends Le{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Te(t).readIntLE(e,this.span)}encode(t,e,n=0){return Te(e).writeIntLE(t,n,this.span),this.span}}V.Int=vn;class Vn extends Le{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Te(t).readIntBE(e,this.span)}encode(t,e,n=0){return Te(e).writeIntBE(t,n,this.span),this.span}}V.IntBE=Vn;const Lo=Math.pow(2,32);function Oi(o){const t=Math.floor(o/Lo),e=o-t*Lo;return{hi32:t,lo32:e}}function Ni(o,t){return o*Lo+t}class wa extends Le{constructor(t){super(8,t)}decode(t,e=0){const n=Te(t),a=n.readUInt32LE(e),s=n.readUInt32LE(e+4);return Ni(s,a)}encode(t,e,n=0){const a=Oi(t),s=Te(e);return s.writeUInt32LE(a.lo32,n),s.writeUInt32LE(a.hi32,n+4),8}}V.NearUInt64=wa;class ma extends Le{constructor(t){super(8,t)}decode(t,e=0){const n=Te(t),a=n.readUInt32BE(e),s=n.readUInt32BE(e+4);return Ni(a,s)}encode(t,e,n=0){const a=Oi(t),s=Te(e);return s.writeUInt32BE(a.hi32,n),s.writeUInt32BE(a.lo32,n+4),8}}V.NearUInt64BE=ma;class ba extends Le{constructor(t){super(8,t)}decode(t,e=0){const n=Te(t),a=n.readUInt32LE(e),s=n.readInt32LE(e+4);return Ni(s,a)}encode(t,e,n=0){const a=Oi(t),s=Te(e);return s.writeUInt32LE(a.lo32,n),s.writeInt32LE(a.hi32,n+4),8}}V.NearInt64=ba;class xa extends Le{constructor(t){super(8,t)}decode(t,e=0){const n=Te(t),a=n.readInt32BE(e),s=n.readUInt32BE(e+4);return Ni(a,s)}encode(t,e,n=0){const a=Oi(t),s=Te(e);return s.writeInt32BE(a.hi32,n),s.writeUInt32BE(a.lo32,n+4),8}}V.NearInt64BE=xa;class Ea extends Le{constructor(t){super(4,t)}decode(t,e=0){return Te(t).readFloatLE(e)}encode(t,e,n=0){return Te(e).writeFloatLE(t,n),4}}V.Float=Ea;class ka extends Le{constructor(t){super(4,t)}decode(t,e=0){return Te(t).readFloatBE(e)}encode(t,e,n=0){return Te(e).writeFloatBE(t,n),4}}V.FloatBE=ka;class Sa extends Le{constructor(t){super(8,t)}decode(t,e=0){return Te(t).readDoubleLE(e)}encode(t,e,n=0){return Te(e).writeDoubleLE(t,n),8}}V.Double=Sa;class Ia extends Le{constructor(t){super(8,t)}decode(t,e=0){return Te(t).readDoubleBE(e)}encode(t,e,n=0){return Te(e).writeDoubleBE(t,n),8}}V.DoubleBE=Ia;class Ba extends Le{constructor(t,e,n){if(!(t instanceof Le))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof vr&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let a=-1;!(e instanceof vr)&&0<t.span&&(a=e*t.span),super(a,n),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0,a=this.count;if(a instanceof vr&&(a=a.decode(t,e)),0<this.elementLayout.span)n=a*this.elementLayout.span;else{let s=0;for(;s<a;)n+=this.elementLayout.getSpan(t,e+n),++s}return n}decode(t,e=0){const n=[];let a=0,s=this.count;for(s instanceof vr&&(s=s.decode(t,e));a<s;)n.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),a+=1;return n}encode(t,e,n=0){const a=this.elementLayout,s=t.reduce((f,u)=>f+a.encode(u,e,n+f),0);return this.count instanceof vr&&this.count.encode(t.length,e,n),s}}V.Sequence=Ba;class va extends Le{constructor(t,e,n){if(!(Array.isArray(t)&&t.reduce((s,f)=>s&&f instanceof Le,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&n===void 0&&(n=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let a=-1;try{a=t.reduce((s,f)=>s+f.getSpan(),0)}catch{}super(a,e),this.fields=t,this.decodePrefixes=!!n}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((a,s)=>{const f=s.getSpan(t,e);return e+=f,a+f},0)}catch{throw new RangeError("indeterminate span")}return n}decode(t,e=0){jn(t);const n=this.makeDestinationObject();for(const a of this.fields)if(a.property!==void 0&&(n[a.property]=a.decode(t,e)),e+=a.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return n}encode(t,e,n=0){const a=n;let s=0,f=0;for(const u of this.fields){let y=u.span;if(f=0<y?y:0,u.property!==void 0){const x=t[u.property];x!==void 0&&(f=u.encode(x,e,n),0>y&&(y=u.getSpan(e,n)))}s=n,n+=y}return s+f-a}fromArray(t){const e=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<t.length&&(e[n.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const n of this.fields){if(n.property===t)return e;0>n.span?e=-1:0<=e&&(e+=n.span)}}}V.Structure=va;class Fo{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,n){throw new Error("UnionDiscriminator is abstract")}}V.UnionDiscriminator=Fo;class zi extends Fo{constructor(t,e){if(!(t instanceof vr&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,n){return this.layout.encode(t,e,n)}}V.UnionLayoutDiscriminator=zi;class Oo extends Le{constructor(t,e,n){let a;if(t instanceof Cr||t instanceof zr)a=new zi(new Co(t));else if(t instanceof vr&&t.isCount())a=new zi(t);else if(t instanceof Fo)a=t;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Le))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&(t instanceof Cr||t instanceof zr)&&(s+=a.layout.span)),super(s,n),this.discriminator=a,this.usesPrefixDiscriminator=t instanceof Cr||t instanceof zr,this.defaultLayout=e,this.registry={};let f=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(u){return f(u)},this.configGetSourceVariant=function(u){f=u.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const n=this.getVariant(t,e);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const n=this.registry[e];if(n.property&&Object.prototype.hasOwnProperty.call(t,n.property))return n}throw new Error("unable to infer src variant")}decode(t,e=0){let n;const a=this.discriminator,s=a.decode(t,e),f=this.registry[s];if(f===void 0){const u=this.defaultLayout;let y=0;this.usesPrefixDiscriminator&&(y=a.layout.span),n=this.makeDestinationObject(),n[a.property]=s,n[u.property]=u.decode(t,e+y)}else n=f.decode(t,e);return n}encode(t,e,n=0){const a=this.getSourceVariant(t);if(a===void 0){const s=this.discriminator,f=this.defaultLayout;let u=0;return this.usesPrefixDiscriminator&&(u=s.layout.span),s.encode(t[s.property],e,n),u+f.encode(t[f.property],e,n+u)}return a.encode(t,e,n)}addVariant(t,e,n){const a=new _a(this,t,e,n);return this.registry[t]=a,a}getVariant(t,e=0){let n;return t instanceof Uint8Array?n=this.discriminator.decode(t,e):n=t,this.registry[n]}}V.Union=Oo;class _a extends Le{constructor(t,e,n,a){if(!(t instanceof Oo))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&a===void 0&&(a=n,n=null),n){if(!(n instanceof Le))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=n.span&&n.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof a!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=n?n.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,a),this.union=t,this.variant=e,this.layout=n||null}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let a=0;return this.layout&&(a=this.layout.getSpan(t,e+n)),n+a}decode(t,e=0){const n=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let a=0;return this.union.usesPrefixDiscriminator&&(a=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(t,e+a):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(t,e,n=0){let a=0;if(this.union.usesPrefixDiscriminator&&(a=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,n);let s=a;if(this.layout&&(this.layout.encode(t[this.property],e,n+a),s+=this.layout.getSpan(e,n+a),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}V.VariantLayout=_a;function Gn(o){return 0>o&&(o+=4294967296),o}class No extends Le{constructor(t,e,n){if(!(t instanceof Cr||t instanceof zr))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&n===void 0&&(n=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,n),this.word=t,this.msb=!!e,this.fields=[];let a=0;this._packedSetValue=function(s){return a=Gn(s),this},this._packedGetValue=function(){return a}}decode(t,e=0){const n=this.makeDestinationObject(),a=this.word.decode(t,e);this._packedSetValue(a);for(const s of this.fields)s.property!==void 0&&(n[s.property]=s.decode(t));return n}encode(t,e,n=0){const a=this.word.decode(e,n);this._packedSetValue(a);for(const s of this.fields)if(s.property!==void 0){const f=t[s.property];f!==void 0&&s.encode(f)}return this.word.encode(this._packedGetValue(),e,n)}addField(t,e){const n=new zo(this,t,e);return this.fields.push(n),n}addBoolean(t){const e=new Aa(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}V.BitStructure=No;class zo{constructor(t,e,n){if(!(t instanceof No))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const a=8*t.span,s=t.fields.reduce((f,u)=>f+u.bits,0);if(e+s>a)throw new Error("bits too long for span remainder ("+(a-s)+" of "+a+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=a-s-e),this.wordMask=Gn(this.valueMask<<this.start),this.property=n}decode(t,e){const n=this.container._packedGetValue();return Gn(n&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==Gn(t&this.valueMask))throw new TypeError(Uo("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),n=Gn(t<<this.start);this.container._packedSetValue(Gn(e&~this.wordMask)|n)}}V.BitField=zo;let Aa=class extends zo{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){typeof t=="boolean"&&(t=+t),super.encode(t)}};V.Boolean=Aa;class Ra extends Le{constructor(t,e){if(!(t instanceof vr&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;t instanceof vr||(n=t),super(n,e),this.length=t}getSpan(t,e){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),n}decode(t,e=0){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),Te(t).slice(e,e+n)}encode(t,e,n){let a=this.length;if(this.length instanceof vr&&(a=t.length),!(t instanceof Uint8Array&&a===t.length))throw new TypeError(Uo("Blob.encode",this)+" requires (length "+a+") Uint8Array as src");if(n+a>e.length)throw new RangeError("encoding overruns Uint8Array");const s=Te(t);return Te(e).write(s.toString("hex"),n,a,"hex"),this.length instanceof vr&&this.length.encode(a,e,n),a}}V.Blob=Ra;class Ta extends Le{constructor(t){super(-1,t)}getSpan(t,e=0){jn(t);let n=e;for(;n<t.length&&t[n]!==0;)n+=1;return 1+n-e}decode(t,e=0){const n=this.getSpan(t,e);return Te(t).slice(e,e+n-1).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));const a=Po.Buffer.from(t,"utf8"),s=a.length;if(n+s>e.length)throw new RangeError("encoding overruns Buffer");const f=Te(e);return a.copy(f,n),f[n+s]=0,s+1}}V.CString=Ta;class Ma extends Le{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return jn(t),t.length-e}decode(t,e=0){const n=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return Te(t).slice(e,e+n).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));const a=Po.Buffer.from(t,"utf8"),s=a.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(n+s>e.length)throw new RangeError("encoding overruns Buffer");return a.copy(Te(e),n),s}}V.UTF8=Ma;class Pa extends Le{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,n){return 0}}V.Constant=Pa,V.greedy=(o,t)=>new ga(o,t);var pn=V.offset=(o,t,e)=>new Co(o,t,e),ve=V.u8=o=>new Cr(1,o),Lr=V.u16=o=>new Cr(2,o);V.u24=o=>new Cr(3,o);var Mt=V.u32=o=>new Cr(4,o);V.u40=o=>new Cr(5,o),V.u48=o=>new Cr(6,o);var dr=V.nu64=o=>new wa(o);V.u16be=o=>new zr(2,o),V.u24be=o=>new zr(3,o),V.u32be=o=>new zr(4,o),V.u40be=o=>new zr(5,o),V.u48be=o=>new zr(6,o),V.nu64be=o=>new ma(o),V.s8=o=>new vn(1,o),V.s16=o=>new vn(2,o),V.s24=o=>new vn(3,o),V.s32=o=>new vn(4,o),V.s40=o=>new vn(5,o),V.s48=o=>new vn(6,o);var Mr=V.ns64=o=>new ba(o);V.s16be=o=>new Vn(2,o),V.s24be=o=>new Vn(3,o),V.s32be=o=>new Vn(4,o),V.s40be=o=>new Vn(5,o),V.s48be=o=>new Vn(6,o),V.ns64be=o=>new xa(o),V.f32=o=>new Ea(o),V.f32be=o=>new ka(o),V.f64=o=>new Sa(o),V.f64be=o=>new Ia(o);var Pt=V.struct=(o,t,e)=>new va(o,t,e);V.bits=(o,t,e)=>new No(o,t,e);var pr=V.seq=(o,t,e)=>new Ba(o,t,e);V.union=(o,t,e)=>new Oo(o,t,e),V.unionLayoutDiscriminator=(o,t)=>new zi(o,t);var Ke=V.blob=(o,t)=>new Ra(o,t);V.cstr=o=>new Ta(o),V.utf8=(o,t)=>new Ma(o,t),V.constant=(o,t)=>new Pa(o,t);var ui={};Object.defineProperty(ui,"__esModule",{value:!0});function Ff(o){{const t=Buffer.from(o);t.reverse();const e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}var Of=ui.toBigIntLE=Ff;function Nf(o){{const t=o.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}ui.toBigIntBE=Nf;function zf(o,t){{const e=o.toString(16),n=Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return n.reverse(),n}}var Ua=ui.toBufferLE=zf;function Df(o,t){{const e=o.toString(16);return Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}}ui.toBufferBE=Df;class $f extends TypeError{constructor(t,e){let n;const{message:a,explanation:s,...f}=t,{path:u}=t,y=u.length===0?a:`At path: ${u.join(".")} -- ${a}`;super(s??y),s!=null&&(this.cause=y),Object.assign(this,f),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...e()])}}function Kf(o){return fi(o)&&typeof o[Symbol.iterator]=="function"}function fi(o){return typeof o=="object"&&o!=null}function Di(o){return fi(o)&&!Array.isArray(o)}function Dr(o){return typeof o=="symbol"?o.toString():typeof o=="string"?JSON.stringify(o):`${o}`}function Wf(o){const{done:t,value:e}=o.next();return t?void 0:e}function qf(o,t,e,n){if(o===!0)return;o===!1?o={}:typeof o=="string"&&(o={message:o});const{path:a,branch:s}=t,{type:f}=e,{refinement:u,message:y=`Expected a value of type \`${f}\`${u?` with refinement \`${u}\``:""}, but received: \`${Dr(n)}\``}=o;return{value:n,type:f,refinement:u,key:a[a.length-1],path:a,branch:s,...o,message:y}}function*Ca(o,t,e,n){Kf(o)||(o=[o]);for(const a of o){const s=qf(a,t,e,n);s&&(yield s)}}function*Do(o,t,e={}){const{path:n=[],branch:a=[o],coerce:s=!1,mask:f=!1}=e,u={path:n,branch:a,mask:f};s&&(o=t.coercer(o,u));let y="valid";for(const x of t.validator(o,u))x.explanation=e.message,y="not_valid",yield[x,void 0];for(let[x,v,_]of t.entries(o,u)){const F=Do(v,_,{path:x===void 0?n:[...n,x],branch:x===void 0?a:[...a,v],coerce:s,mask:f,message:e.message});for(const L of F)L[0]?(y=L[0].refinement!=null?"not_refined":"not_valid",yield[L[0],void 0]):s&&(v=L[1],x===void 0?o=v:o instanceof Map?o.set(x,v):o instanceof Set?o.add(v):fi(o)&&(v!==void 0||x in o)&&(o[x]=v))}if(y!=="not_valid")for(const x of t.refiner(o,u))x.explanation=e.message,y="not_refined",yield[x,void 0];y==="valid"&&(yield[void 0,o])}let Vr=class{constructor(t){const{type:e,schema:n,validator:a,refiner:s,coercer:f=y=>y,entries:u=function*(){}}=t;this.type=e,this.schema=n,this.entries=u,this.coercer=f,a?this.validator=(y,x)=>{const v=a(y,x);return Ca(v,x,this,y)}:this.validator=()=>[],s?this.refiner=(y,x)=>{const v=s(y,x);return Ca(v,x,this,y)}:this.refiner=()=>[]}assert(t,e){return La(t,this,e)}create(t,e){return bt(t,this,e)}is(t){return Fa(t,this)}mask(t,e){return Hf(t,this,e)}validate(t,e={}){return hi(t,this,e)}};function La(o,t,e){const n=hi(o,t,{message:e});if(n[0])throw n[0]}function bt(o,t,e){const n=hi(o,t,{coerce:!0,message:e});if(n[0])throw n[0];return n[1]}function Hf(o,t,e){const n=hi(o,t,{coerce:!0,mask:!0,message:e});if(n[0])throw n[0];return n[1]}function Fa(o,t){return!hi(o,t)[0]}function hi(o,t,e={}){const n=Do(o,t,e),a=Wf(n);return a[0]?[new $f(a[0],function*(){for(const f of n)f[0]&&(yield f[0])}),void 0]:[void 0,a[1]]}function _n(o,t){return new Vr({type:o,schema:null,validator:t})}function jf(){return _n("any",()=>!0)}function kt(o){return new Vr({type:"array",schema:o,*entries(t){if(o&&Array.isArray(t))for(const[e,n]of t.entries())yield[e,n,o]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${Dr(t)}`}})}function Gr(){return _n("boolean",o=>typeof o=="boolean")}function $o(o){return _n("instance",t=>t instanceof o||`Expected a \`${o.name}\` instance, but received: ${Dr(t)}`)}function Ve(o){const t=Dr(o),e=typeof o;return new Vr({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?o:null,validator(n){return n===o||`Expected the literal \`${t}\`, but received: ${Dr(n)}`}})}function Vf(){return _n("never",()=>!1)}function St(o){return new Vr({...o,validator:(t,e)=>t===null||o.validator(t,e),refiner:(t,e)=>t===null||o.refiner(t,e)})}function H(){return _n("number",o=>typeof o=="number"&&!isNaN(o)||`Expected a number, but received: ${Dr(o)}`)}function $t(o){return new Vr({...o,validator:(t,e)=>t===void 0||o.validator(t,e),refiner:(t,e)=>t===void 0||o.refiner(t,e)})}function Oa(o,t){return new Vr({type:"record",schema:null,*entries(e){if(fi(e))for(const n in e){const a=e[n];yield[n,n,o],yield[n,a,t]}},validator(e){return Di(e)||`Expected an object, but received: ${Dr(e)}`},coercer(e){return Di(e)?{...e}:e}})}function gt(){return _n("string",o=>typeof o=="string"||`Expected a string, but received: ${Dr(o)}`)}function Ko(o){const t=Vf();return new Vr({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const n=Math.max(o.length,e.length);for(let a=0;a<n;a++)yield[a,e[a],o[a]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Dr(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function ut(o){const t=Object.keys(o);return new Vr({type:"type",schema:o,*entries(e){if(fi(e))for(const n of t)yield[n,e[n],o[n]]},validator(e){return Di(e)||`Expected an object, but received: ${Dr(e)}`},coercer(e){return Di(e)?{...e}:e}})}function Br(o){const t=o.map(e=>e.type).join(" | ");return new Vr({type:"union",schema:null,coercer(e,n){for(const a of o){const[s,f]=a.validate(e,{coerce:!0,mask:n.mask});if(!s)return f}return e},validator(e,n){const a=[];for(const s of o){const[...f]=Do(e,s,n),[u]=f;if(u[0])for(const[y]of f)y&&a.push(y);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Dr(e)}`,...a]}})}function Yn(){return _n("unknown",()=>!0)}function li(o,t,e){return new Vr({...o,coercer:(n,a)=>Fa(n,t)?o.coercer(e(n,a),a):o.coercer(n,a)})}var $i,Gf=new Uint8Array(16);function Na(){if(!$i&&($i=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!$i))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return $i(Gf)}const Yf=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Ki(o){return typeof o=="string"&&Yf.test(o)}for(var yr=[],Wo=0;Wo<256;++Wo)yr.push((Wo+256).toString(16).substr(1));function Wi(o){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(yr[o[t+0]]+yr[o[t+1]]+yr[o[t+2]]+yr[o[t+3]]+"-"+yr[o[t+4]]+yr[o[t+5]]+"-"+yr[o[t+6]]+yr[o[t+7]]+"-"+yr[o[t+8]]+yr[o[t+9]]+"-"+yr[o[t+10]]+yr[o[t+11]]+yr[o[t+12]]+yr[o[t+13]]+yr[o[t+14]]+yr[o[t+15]]).toLowerCase();if(!Ki(e))throw TypeError("Stringified UUID is invalid");return e}var za,qo,Ho=0,jo=0;function Zf(o,t,e){var n=t&&e||0,a=t||new Array(16);o=o||{};var s=o.node||za,f=o.clockseq!==void 0?o.clockseq:qo;if(s==null||f==null){var u=o.random||(o.rng||Na)();s==null&&(s=za=[u[0]|1,u[1],u[2],u[3],u[4],u[5]]),f==null&&(f=qo=(u[6]<<8|u[7])&16383)}var y=o.msecs!==void 0?o.msecs:Date.now(),x=o.nsecs!==void 0?o.nsecs:jo+1,v=y-Ho+(x-jo)/1e4;if(v<0&&o.clockseq===void 0&&(f=f+1&16383),(v<0||y>Ho)&&o.nsecs===void 0&&(x=0),x>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ho=y,jo=x,qo=f,y+=122192928e5;var _=((y&268435455)*1e4+x)%4294967296;a[n++]=_>>>24&255,a[n++]=_>>>16&255,a[n++]=_>>>8&255,a[n++]=_&255;var F=y/4294967296*1e4&268435455;a[n++]=F>>>8&255,a[n++]=F&255,a[n++]=F>>>24&15|16,a[n++]=F>>>16&255,a[n++]=f>>>8|128,a[n++]=f&255;for(var L=0;L<6;++L)a[n+L]=s[L];return t||Wi(a)}function Da(o){if(!Ki(o))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(o.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(o.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(o.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(o.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(o.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}function Jf(o){o=unescape(encodeURIComponent(o));for(var t=[],e=0;e<o.length;++e)t.push(o.charCodeAt(e));return t}var Xf="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Qf="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function $a(o,t,e){function n(a,s,f,u){if(typeof a=="string"&&(a=Jf(a)),typeof s=="string"&&(s=Da(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var y=new Uint8Array(16+a.length);if(y.set(s),y.set(a,s.length),y=e(y),y[6]=y[6]&15|t,y[8]=y[8]&63|128,f){u=u||0;for(var x=0;x<16;++x)f[u+x]=y[x];return f}return Wi(y)}try{n.name=o}catch{}return n.DNS=Xf,n.URL=Qf,n}function th(o){if(typeof o=="string"){var t=unescape(encodeURIComponent(o));o=new Uint8Array(t.length);for(var e=0;e<t.length;++e)o[e]=t.charCodeAt(e)}return eh(rh(nh(o),o.length*8))}function eh(o){for(var t=[],e=o.length*32,n="0123456789abcdef",a=0;a<e;a+=8){var s=o[a>>5]>>>a%32&255,f=parseInt(n.charAt(s>>>4&15)+n.charAt(s&15),16);t.push(f)}return t}function Ka(o){return(o+64>>>9<<4)+14+1}function rh(o,t){o[t>>5]|=128<<t%32,o[Ka(t)-1]=t;for(var e=1732584193,n=-271733879,a=-1732584194,s=271733878,f=0;f<o.length;f+=16){var u=e,y=n,x=a,v=s;e=gr(e,n,a,s,o[f],7,-680876936),s=gr(s,e,n,a,o[f+1],12,-389564586),a=gr(a,s,e,n,o[f+2],17,606105819),n=gr(n,a,s,e,o[f+3],22,-1044525330),e=gr(e,n,a,s,o[f+4],7,-176418897),s=gr(s,e,n,a,o[f+5],12,1200080426),a=gr(a,s,e,n,o[f+6],17,-1473231341),n=gr(n,a,s,e,o[f+7],22,-45705983),e=gr(e,n,a,s,o[f+8],7,1770035416),s=gr(s,e,n,a,o[f+9],12,-1958414417),a=gr(a,s,e,n,o[f+10],17,-42063),n=gr(n,a,s,e,o[f+11],22,-1990404162),e=gr(e,n,a,s,o[f+12],7,1804603682),s=gr(s,e,n,a,o[f+13],12,-40341101),a=gr(a,s,e,n,o[f+14],17,-1502002290),n=gr(n,a,s,e,o[f+15],22,1236535329),e=wr(e,n,a,s,o[f+1],5,-165796510),s=wr(s,e,n,a,o[f+6],9,-1069501632),a=wr(a,s,e,n,o[f+11],14,643717713),n=wr(n,a,s,e,o[f],20,-373897302),e=wr(e,n,a,s,o[f+5],5,-701558691),s=wr(s,e,n,a,o[f+10],9,38016083),a=wr(a,s,e,n,o[f+15],14,-660478335),n=wr(n,a,s,e,o[f+4],20,-405537848),e=wr(e,n,a,s,o[f+9],5,568446438),s=wr(s,e,n,a,o[f+14],9,-1019803690),a=wr(a,s,e,n,o[f+3],14,-187363961),n=wr(n,a,s,e,o[f+8],20,1163531501),e=wr(e,n,a,s,o[f+13],5,-1444681467),s=wr(s,e,n,a,o[f+2],9,-51403784),a=wr(a,s,e,n,o[f+7],14,1735328473),n=wr(n,a,s,e,o[f+12],20,-1926607734),e=mr(e,n,a,s,o[f+5],4,-378558),s=mr(s,e,n,a,o[f+8],11,-2022574463),a=mr(a,s,e,n,o[f+11],16,1839030562),n=mr(n,a,s,e,o[f+14],23,-35309556),e=mr(e,n,a,s,o[f+1],4,-1530992060),s=mr(s,e,n,a,o[f+4],11,1272893353),a=mr(a,s,e,n,o[f+7],16,-155497632),n=mr(n,a,s,e,o[f+10],23,-1094730640),e=mr(e,n,a,s,o[f+13],4,681279174),s=mr(s,e,n,a,o[f],11,-358537222),a=mr(a,s,e,n,o[f+3],16,-722521979),n=mr(n,a,s,e,o[f+6],23,76029189),e=mr(e,n,a,s,o[f+9],4,-640364487),s=mr(s,e,n,a,o[f+12],11,-421815835),a=mr(a,s,e,n,o[f+15],16,530742520),n=mr(n,a,s,e,o[f+2],23,-995338651),e=br(e,n,a,s,o[f],6,-198630844),s=br(s,e,n,a,o[f+7],10,1126891415),a=br(a,s,e,n,o[f+14],15,-1416354905),n=br(n,a,s,e,o[f+5],21,-57434055),e=br(e,n,a,s,o[f+12],6,1700485571),s=br(s,e,n,a,o[f+3],10,-1894986606),a=br(a,s,e,n,o[f+10],15,-1051523),n=br(n,a,s,e,o[f+1],21,-2054922799),e=br(e,n,a,s,o[f+8],6,1873313359),s=br(s,e,n,a,o[f+15],10,-30611744),a=br(a,s,e,n,o[f+6],15,-1560198380),n=br(n,a,s,e,o[f+13],21,1309151649),e=br(e,n,a,s,o[f+4],6,-145523070),s=br(s,e,n,a,o[f+11],10,-1120210379),a=br(a,s,e,n,o[f+2],15,718787259),n=br(n,a,s,e,o[f+9],21,-343485551),e=yn(e,u),n=yn(n,y),a=yn(a,x),s=yn(s,v)}return[e,n,a,s]}function nh(o){if(o.length===0)return[];for(var t=o.length*8,e=new Uint32Array(Ka(t)),n=0;n<t;n+=8)e[n>>5]|=(o[n/8]&255)<<n%32;return e}function yn(o,t){var e=(o&65535)+(t&65535),n=(o>>16)+(t>>16)+(e>>16);return n<<16|e&65535}function ih(o,t){return o<<t|o>>>32-t}function qi(o,t,e,n,a,s){return yn(ih(yn(yn(t,o),yn(n,s)),a),e)}function gr(o,t,e,n,a,s,f){return qi(t&e|~t&n,o,t,a,s,f)}function wr(o,t,e,n,a,s,f){return qi(t&n|e&~n,o,t,a,s,f)}function mr(o,t,e,n,a,s,f){return qi(t^e^n,o,t,a,s,f)}function br(o,t,e,n,a,s,f){return qi(e^(t|~n),o,t,a,s,f)}var oh=$a("v3",48,th);const sh=oh;function ah(o,t,e){o=o||{};var n=o.random||(o.rng||Na)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){e=e||0;for(var a=0;a<16;++a)t[e+a]=n[a];return t}return Wi(n)}function ch(o,t,e,n){switch(o){case 0:return t&e^~t&n;case 1:return t^e^n;case 2:return t&e^t&n^e&n;case 3:return t^e^n}}function Vo(o,t){return o<<t|o>>>32-t}function uh(o){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof o=="string"){var n=unescape(encodeURIComponent(o));o=[];for(var a=0;a<n.length;++a)o.push(n.charCodeAt(a))}else Array.isArray(o)||(o=Array.prototype.slice.call(o));o.push(128);for(var s=o.length/4+2,f=Math.ceil(s/16),u=new Array(f),y=0;y<f;++y){for(var x=new Uint32Array(16),v=0;v<16;++v)x[v]=o[y*64+v*4]<<24|o[y*64+v*4+1]<<16|o[y*64+v*4+2]<<8|o[y*64+v*4+3];u[y]=x}u[f-1][14]=(o.length-1)*8/Math.pow(2,32),u[f-1][14]=Math.floor(u[f-1][14]),u[f-1][15]=(o.length-1)*8&4294967295;for(var _=0;_<f;++_){for(var F=new Uint32Array(80),L=0;L<16;++L)F[L]=u[_][L];for(var D=16;D<80;++D)F[D]=Vo(F[D-3]^F[D-8]^F[D-14]^F[D-16],1);for(var C=e[0],z=e[1],$=e[2],X=e[3],j=e[4],it=0;it<80;++it){var G=Math.floor(it/20),W=Vo(C,5)+ch(G,z,$,X)+j+t[G]+F[it]>>>0;j=X,X=$,$=Vo(z,30)>>>0,z=C,C=W}e[0]=e[0]+C>>>0,e[1]=e[1]+z>>>0,e[2]=e[2]+$>>>0,e[3]=e[3]+X>>>0,e[4]=e[4]+j>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var fh=$a("v5",80,uh);const hh=fh,lh="00000000-0000-0000-0000-000000000000";function dh(o){if(!Ki(o))throw TypeError("Invalid UUID");return parseInt(o.substr(14,1),16)}const Wa=uo(Object.freeze(Object.defineProperty({__proto__:null,NIL:lh,parse:Da,stringify:Wi,v1:Zf,v3:sh,v4:ah,v5:hh,validate:Ki,version:dh},Symbol.toStringTag,{value:"Module"}))),ph=Wa.v4;var yh=function(o,t,e,n){if(typeof o!="string")throw new TypeError(o+" must be a string");n=n||{};const a=typeof n.version=="number"?n.version:2;if(a!==1&&a!==2)throw new TypeError(a+" must be 1 or 2");const s={method:o};if(a===2&&(s.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");s.params=t}if(typeof e>"u"){const f=typeof n.generator=="function"?n.generator:function(){return ph()};s.id=f(s,n)}else a===2&&e===null?n.notificationIdNull&&(s.id=null):s.id=e;return s};const gh=Wa.v4,wh=yh,di=function(o,t){if(!(this instanceof di))return new di(o,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return gh()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=o};var mh=di;di.prototype.request=function(o,t,e,n){const a=this;let s=null;const f=Array.isArray(o)&&typeof t=="function";if(this.options.version===1&&f)throw new TypeError("JSON-RPC 1.0 does not support batching");if(f||!f&&o&&typeof o=="object"&&typeof t=="function")n=t,s=o;else{typeof e=="function"&&(n=e,e=void 0);const x=typeof n=="function";try{s=wh(o,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(v){if(x)return n(v);throw v}if(!x)return s}let y;try{y=JSON.stringify(s,this.options.replacer)}catch(x){return n(x)}return this.callServer(y,function(x,v){a._parseResponse(x,v,n)}),s},di.prototype._parseResponse=function(o,t,e){if(o){e(o);return}if(!t)return e();let n;try{n=JSON.parse(t,this.options.reviver)}catch(a){return e(a)}if(e.length===3)if(Array.isArray(n)){const a=function(f){return typeof f.error<"u"},s=function(f){return!a(f)};return e(null,n.filter(a),n.filter(s))}else return e(null,n.error,n.result);e(null,n)};const bh=ii(mh);var qa={exports:{}};(function(o){var t=Object.prototype.hasOwnProperty,e="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(e=!1));function a(y,x,v){this.fn=y,this.context=x,this.once=v||!1}function s(y,x,v,_,F){if(typeof v!="function")throw new TypeError("The listener must be a function");var L=new a(v,_||y,F),D=e?e+x:x;return y._events[D]?y._events[D].fn?y._events[D]=[y._events[D],L]:y._events[D].push(L):(y._events[D]=L,y._eventsCount++),y}function f(y,x){--y._eventsCount===0?y._events=new n:delete y._events[x]}function u(){this._events=new n,this._eventsCount=0}u.prototype.eventNames=function(){var x=[],v,_;if(this._eventsCount===0)return x;for(_ in v=this._events)t.call(v,_)&&x.push(e?_.slice(1):_);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(v)):x},u.prototype.listeners=function(x){var v=e?e+x:x,_=this._events[v];if(!_)return[];if(_.fn)return[_.fn];for(var F=0,L=_.length,D=new Array(L);F<L;F++)D[F]=_[F].fn;return D},u.prototype.listenerCount=function(x){var v=e?e+x:x,_=this._events[v];return _?_.fn?1:_.length:0},u.prototype.emit=function(x,v,_,F,L,D){var C=e?e+x:x;if(!this._events[C])return!1;var z=this._events[C],$=arguments.length,X,j;if(z.fn){switch(z.once&&this.removeListener(x,z.fn,void 0,!0),$){case 1:return z.fn.call(z.context),!0;case 2:return z.fn.call(z.context,v),!0;case 3:return z.fn.call(z.context,v,_),!0;case 4:return z.fn.call(z.context,v,_,F),!0;case 5:return z.fn.call(z.context,v,_,F,L),!0;case 6:return z.fn.call(z.context,v,_,F,L,D),!0}for(j=1,X=new Array($-1);j<$;j++)X[j-1]=arguments[j];z.fn.apply(z.context,X)}else{var it=z.length,G;for(j=0;j<it;j++)switch(z[j].once&&this.removeListener(x,z[j].fn,void 0,!0),$){case 1:z[j].fn.call(z[j].context);break;case 2:z[j].fn.call(z[j].context,v);break;case 3:z[j].fn.call(z[j].context,v,_);break;case 4:z[j].fn.call(z[j].context,v,_,F);break;default:if(!X)for(G=1,X=new Array($-1);G<$;G++)X[G-1]=arguments[G];z[j].fn.apply(z[j].context,X)}}return!0},u.prototype.on=function(x,v,_){return s(this,x,v,_,!1)},u.prototype.once=function(x,v,_){return s(this,x,v,_,!0)},u.prototype.removeListener=function(x,v,_,F){var L=e?e+x:x;if(!this._events[L])return this;if(!v)return f(this,L),this;var D=this._events[L];if(D.fn)D.fn===v&&(!F||D.once)&&(!_||D.context===_)&&f(this,L);else{for(var C=0,z=[],$=D.length;C<$;C++)(D[C].fn!==v||F&&!D[C].once||_&&D[C].context!==_)&&z.push(D[C]);z.length?this._events[L]=z.length===1?z[0]:z:f(this,L)}return this},u.prototype.removeAllListeners=function(x){var v;return x?(v=e?e+x:x,this._events[v]&&f(this,v)):(this._events=new n,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=e,u.EventEmitter=u,o.exports=u})(qa);var xh=qa.exports;const Ha=ii(xh);var Eh=class extends Ha{constructor(t,e,n){super();ir(this,"socket");this.socket=new window.WebSocket(t,n),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=a=>this.emit("message",a.data),this.socket.onerror=a=>this.emit("error",a),this.socket.onclose=a=>{this.emit("close",a.code,a.reason)}}send(t,e,n){const a=n||e;try{this.socket.send(t),a()}catch(s){a(s)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,n){this.socket.addEventListener(t,e,n)}};function kh(o,t){return new Eh(o,t)}var Sh=class{encode(o){return JSON.stringify(o)}decode(o){return JSON.parse(o)}},Ih=class extends Ha{constructor(t,e="ws://localhost:8080",{autoconnect:n=!0,reconnect:a=!0,reconnect_interval:s=1e3,max_reconnects:f=5,...u}={},y,x){super();ir(this,"address");ir(this,"rpc_id");ir(this,"queue");ir(this,"options");ir(this,"autoconnect");ir(this,"ready");ir(this,"reconnect");ir(this,"reconnect_timer_id");ir(this,"reconnect_interval");ir(this,"max_reconnects");ir(this,"rest_options");ir(this,"current_reconnects");ir(this,"generate_request_id");ir(this,"socket");ir(this,"webSocketFactory");ir(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=n,this.ready=!1,this.reconnect=a,this.reconnect_timer_id=void 0,this.reconnect_interval=s,this.max_reconnects=f,this.rest_options=u,this.current_reconnects=0,this.generate_request_id=y||(()=>++this.rpc_id),x?this.dataPack=x:this.dataPack=new Sh,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(t,e,n,a){return!a&&typeof n=="object"&&(a=n,n=null),new Promise((s,f)=>{if(!this.ready)return f(new Error("socket not ready"));const u=this.generate_request_id(t,e),y={jsonrpc:"2.0",method:t,params:e||void 0,id:u};this.socket.send(this.dataPack.encode(y),a,x=>{if(x)return f(x);this.queue[u]={promise:[s,f]},n&&(this.queue[u].timeout=setTimeout(()=>{delete this.queue[u],f(new Error("reply timeout"))},n))})})}async login(t){const e=await this.call("rpc.login",t);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(t,e){return new Promise((n,a)=>{if(!this.ready)return a(new Error("socket not ready"));const s={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(s),f=>{if(f)return a(f);n()})})}async subscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.on",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed subscribing to an event '"+t+"' with: "+e[t]);return e}async unsubscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.off",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(t,e){this.socket.close(t||1e3,e)}setAutoReconnect(t){this.reconnect=t}setReconnectInterval(t){this.reconnect_interval=t}setMaxReconnects(t){this.max_reconnects=t}_connect(t,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:n})=>{n instanceof ArrayBuffer&&(n=Nt.Buffer.from(n).toString());try{n=this.dataPack.decode(n)}catch{return}if(n.notification&&this.listeners(n.notification).length){if(!Object.keys(n.params).length)return this.emit(n.notification);const a=[n.notification];if(n.params.constructor===Object)a.push(n.params);else for(let s=0;s<n.params.length;s++)a.push(n.params[s]);return Promise.resolve().then(()=>{this.emit.apply(this,a)})}if(!this.queue[n.id])return n.method?Promise.resolve().then(()=>{this.emit(n.method,n==null?void 0:n.params)}):void 0;"error"in n=="result"in n&&this.queue[n.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[n.id].timeout&&clearTimeout(this.queue[n.id].timeout),n.error?this.queue[n.id].promise[1](n.error):this.queue[n.id].promise[0](n.result),delete this.queue[n.id]}),this.socket.addEventListener("error",n=>this.emit("error",n)),this.socket.addEventListener("close",({code:n,reason:a})=>{this.ready&&setTimeout(()=>this.emit("close",n,a),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(t,e),this.reconnect_interval)))})}};const ja=[],Va=[],Ga=[],Bh=BigInt(0),pi=BigInt(1),vh=BigInt(2),_h=BigInt(7),Ah=BigInt(256),Rh=BigInt(113);for(let o=0,t=pi,e=1,n=0;o<24;o++){[e,n]=[n,(2*e+3*n)%5],ja.push(2*(5*n+e)),Va.push((o+1)*(o+2)/2%64);let a=Bh;for(let s=0;s<7;s++)t=(t<<pi^(t>>_h)*Rh)%Ah,t&vh&&(a^=pi<<(pi<<BigInt(s))-pi);Ga.push(a)}const[Th,Mh]=Os(Ga,!0),Ya=(o,t,e)=>e>32?Ds(o,t,e):Ns(o,t,e),Za=(o,t,e)=>e>32?$s(o,t,e):zs(o,t,e);function Ph(o,t=24){const e=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let f=0;f<10;f++)e[f]=o[f]^o[f+10]^o[f+20]^o[f+30]^o[f+40];for(let f=0;f<10;f+=2){const u=(f+8)%10,y=(f+2)%10,x=e[y],v=e[y+1],_=Ya(x,v,1)^e[u],F=Za(x,v,1)^e[u+1];for(let L=0;L<50;L+=10)o[f+L]^=_,o[f+L+1]^=F}let a=o[2],s=o[3];for(let f=0;f<24;f++){const u=Va[f],y=Ya(a,s,u),x=Za(a,s,u),v=ja[f];a=o[v],s=o[v+1],o[v]=y,o[v+1]=x}for(let f=0;f<50;f+=10){for(let u=0;u<10;u++)e[u]=o[f+u];for(let u=0;u<10;u++)o[f+u]^=~e[(u+2)%10]&e[(u+4)%10]}o[0]^=Th[n],o[1]^=Mh[n]}e.fill(0)}class Go extends po{constructor(t,e,n,a=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=a,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,vi(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=hu(this.state)}keccak(){Ps||Us(this.state32),Ph(this.state32,this.rounds),Ps||Us(this.state32),this.posOut=0,this.pos=0}update(t){zn(this);const{blockLen:e,state:n}=this;t=_i(t);const a=t.length;for(let s=0;s<a;){const f=Math.min(e-this.pos,a-s);for(let u=0;u<f;u++)n[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:a}=this;t[n]^=e,e&128&&n===a-1&&this.keccak(),t[a-1]^=128,this.keccak()}writeInto(t){zn(this,!1),si(t),this.finish();const e=this.state,{blockLen:n}=this;for(let a=0,s=t.length;a<s;){this.posOut>=n&&this.keccak();const f=Math.min(n-this.posOut,s-a);t.set(e.subarray(this.posOut,this.posOut+f),a),this.posOut+=f,a+=f}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return vi(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ms(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:a,rounds:s,enableXOF:f}=this;return t||(t=new Go(e,n,a,f,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=a,t.enableXOF=f,t.destroyed=this.destroyed,t}}const Ja=((o,t,e)=>yo(()=>new Go(t,o,e)))(1,136,256/8);class Xa extends po{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,fu(t);const n=_i(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const a=this.blockLen,s=new Uint8Array(a);s.set(n.length>a?t.create().update(n).digest():n);for(let f=0;f<s.length;f++)s[f]^=54;this.iHash.update(s),this.oHash=t.create();for(let f=0;f<s.length;f++)s[f]^=106;this.oHash.update(s),s.fill(0)}update(t){return zn(this),this.iHash.update(t),this}digestInto(t){zn(this),si(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:a,destroyed:s,blockLen:f,outputLen:u}=this;return t=t,t.finished=a,t.destroyed=s,t.blockLen=f,t.outputLen=u,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Qa=(o,t,e)=>new Xa(o,t).update(e).digest();Qa.create=(o,t)=>new Xa(o,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Uh(o){const t=So(o);Wn(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:n,a}=t;if(e){if(!n.eql(a,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:Ch,hexToBytes:Lh}=$u,An={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(o){const{Err:t}=An;if(o.length<2||o[0]!==2)throw new t("Invalid signature integer tag");const e=o[1],n=o.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Ch(n),l:o.subarray(e+2)}},toSig(o){const{Err:t}=An,e=typeof o=="string"?Lh(o):o;ai(e);let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");const{d:a,l:s}=An._parseInt(e.subarray(2)),{d:f,l:u}=An._parseInt(s);if(u.length)throw new t("Invalid signature: left bytes after parsing");return{r:a,s:f}},hexFromSig(o){const t=x=>Number.parseInt(x[0],16)&8?"00"+x:x,e=x=>{const v=x.toString(16);return v.length&1?`0${v}`:v},n=t(e(o.s)),a=t(e(o.r)),s=n.length/2,f=a.length/2,u=e(s),y=e(f);return`30${e(f+s+4)}02${y}${a}02${u}${n}`}},on=BigInt(0),Fr=BigInt(1);BigInt(2);const tc=BigInt(3);BigInt(4);function Fh(o){const t=Uh(o),{Fp:e}=t,n=t.toBytes||((D,C,z)=>{const $=C.toAffine();return kn(Uint8Array.from([4]),e.toBytes($.x),e.toBytes($.y))}),a=t.fromBytes||(D=>{const C=D.subarray(1),z=e.fromBytes(C.subarray(0,e.BYTES)),$=e.fromBytes(C.subarray(e.BYTES,2*e.BYTES));return{x:z,y:$}});function s(D){const{a:C,b:z}=t,$=e.sqr(D),X=e.mul($,D);return e.add(e.add(X,e.mul(D,C)),z)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function f(D){return typeof D=="bigint"&&on<D&&D<t.n}function u(D){if(!f(D))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function y(D){const{allowedPrivateKeyLengths:C,nByteLength:z,wrapPrivateKey:$,n:X}=t;if(C&&typeof D!="bigint"){if(bn(D)&&(D=xn(D)),typeof D!="string"||!C.includes(D.length))throw new Error("Invalid key");D=D.padStart(z*2,"0")}let j;try{j=typeof D=="bigint"?D:En(or("private key",D,z))}catch{throw new Error(`private key must be ${z} bytes, hex or bigint, not ${typeof D}`)}return $&&(j=We(j,X)),u(j),j}const x=new Map;function v(D){if(!(D instanceof _))throw new Error("ProjectivePoint expected")}class _{constructor(C,z,$){if(this.px=C,this.py=z,this.pz=$,C==null||!e.isValid(C))throw new Error("x required");if(z==null||!e.isValid(z))throw new Error("y required");if($==null||!e.isValid($))throw new Error("z required")}static fromAffine(C){const{x:z,y:$}=C||{};if(!C||!e.isValid(z)||!e.isValid($))throw new Error("invalid affine point");if(C instanceof _)throw new Error("projective point not allowed");const X=j=>e.eql(j,e.ZERO);return X(z)&&X($)?_.ZERO:new _(z,$,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(C){const z=e.invertBatch(C.map($=>$.pz));return C.map(($,X)=>$.toAffine(z[X])).map(_.fromAffine)}static fromHex(C){const z=_.fromAffine(a(or("pointHex",C)));return z.assertValidity(),z}static fromPrivateKey(C){return _.BASE.multiply(y(C))}_setWindowSize(C){this._WINDOW_SIZE=C,x.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:C,y:z}=this.toAffine();if(!e.isValid(C)||!e.isValid(z))throw new Error("bad point: x or y not FE");const $=e.sqr(z),X=s(C);if(!e.eql($,X))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:C}=this.toAffine();if(e.isOdd)return!e.isOdd(C);throw new Error("Field doesn't support isOdd")}equals(C){v(C);const{px:z,py:$,pz:X}=this,{px:j,py:it,pz:G}=C,W=e.eql(e.mul(z,G),e.mul(j,X)),Q=e.eql(e.mul($,G),e.mul(it,X));return W&&Q}negate(){return new _(this.px,e.neg(this.py),this.pz)}double(){const{a:C,b:z}=t,$=e.mul(z,tc),{px:X,py:j,pz:it}=this;let G=e.ZERO,W=e.ZERO,Q=e.ZERO,rt=e.mul(X,X),ae=e.mul(j,j),Vt=e.mul(it,it),Bt=e.mul(X,j);return Bt=e.add(Bt,Bt),Q=e.mul(X,it),Q=e.add(Q,Q),G=e.mul(C,Q),W=e.mul($,Vt),W=e.add(G,W),G=e.sub(ae,W),W=e.add(ae,W),W=e.mul(G,W),G=e.mul(Bt,G),Q=e.mul($,Q),Vt=e.mul(C,Vt),Bt=e.sub(rt,Vt),Bt=e.mul(C,Bt),Bt=e.add(Bt,Q),Q=e.add(rt,rt),rt=e.add(Q,rt),rt=e.add(rt,Vt),rt=e.mul(rt,Bt),W=e.add(W,rt),Vt=e.mul(j,it),Vt=e.add(Vt,Vt),rt=e.mul(Vt,Bt),G=e.sub(G,rt),Q=e.mul(Vt,ae),Q=e.add(Q,Q),Q=e.add(Q,Q),new _(G,W,Q)}add(C){v(C);const{px:z,py:$,pz:X}=this,{px:j,py:it,pz:G}=C;let W=e.ZERO,Q=e.ZERO,rt=e.ZERO;const ae=t.a,Vt=e.mul(t.b,tc);let Bt=e.mul(z,j),re=e.mul($,it),U=e.mul(X,G),d=e.add(z,$),w=e.add(j,it);d=e.mul(d,w),w=e.add(Bt,re),d=e.sub(d,w),w=e.add(z,X);let E=e.add(j,G);return w=e.mul(w,E),E=e.add(Bt,U),w=e.sub(w,E),E=e.add($,X),W=e.add(it,G),E=e.mul(E,W),W=e.add(re,U),E=e.sub(E,W),rt=e.mul(ae,w),W=e.mul(Vt,U),rt=e.add(W,rt),W=e.sub(re,rt),rt=e.add(re,rt),Q=e.mul(W,rt),re=e.add(Bt,Bt),re=e.add(re,Bt),U=e.mul(ae,U),w=e.mul(Vt,w),re=e.add(re,U),U=e.sub(Bt,U),U=e.mul(ae,U),w=e.add(w,U),Bt=e.mul(re,w),Q=e.add(Q,Bt),Bt=e.mul(E,w),W=e.mul(d,W),W=e.sub(W,Bt),Bt=e.mul(d,re),rt=e.mul(E,rt),rt=e.add(rt,Bt),new _(W,Q,rt)}subtract(C){return this.add(C.negate())}is0(){return this.equals(_.ZERO)}wNAF(C){return L.wNAFCached(this,x,C,z=>{const $=e.invertBatch(z.map(X=>X.pz));return z.map((X,j)=>X.toAffine($[j])).map(_.fromAffine)})}multiplyUnsafe(C){const z=_.ZERO;if(C===on)return z;if(u(C),C===Fr)return this;const{endo:$}=t;if(!$)return L.unsafeLadder(this,C);let{k1neg:X,k1:j,k2neg:it,k2:G}=$.splitScalar(C),W=z,Q=z,rt=this;for(;j>on||G>on;)j&Fr&&(W=W.add(rt)),G&Fr&&(Q=Q.add(rt)),rt=rt.double(),j>>=Fr,G>>=Fr;return X&&(W=W.negate()),it&&(Q=Q.negate()),Q=new _(e.mul(Q.px,$.beta),Q.py,Q.pz),W.add(Q)}multiply(C){u(C);let z=C,$,X;const{endo:j}=t;if(j){const{k1neg:it,k1:G,k2neg:W,k2:Q}=j.splitScalar(z);let{p:rt,f:ae}=this.wNAF(G),{p:Vt,f:Bt}=this.wNAF(Q);rt=L.constTimeNegate(it,rt),Vt=L.constTimeNegate(W,Vt),Vt=new _(e.mul(Vt.px,j.beta),Vt.py,Vt.pz),$=rt.add(Vt),X=ae.add(Bt)}else{const{p:it,f:G}=this.wNAF(z);$=it,X=G}return _.normalizeZ([$,X])[0]}multiplyAndAddUnsafe(C,z,$){const X=_.BASE,j=(G,W)=>W===on||W===Fr||!G.equals(X)?G.multiplyUnsafe(W):G.multiply(W),it=j(this,z).add(j(C,$));return it.is0()?void 0:it}toAffine(C){const{px:z,py:$,pz:X}=this,j=this.is0();C==null&&(C=j?e.ONE:e.inv(X));const it=e.mul(z,C),G=e.mul($,C),W=e.mul(X,C);if(j)return{x:e.ZERO,y:e.ZERO};if(!e.eql(W,e.ONE))throw new Error("invZ was invalid");return{x:it,y:G}}isTorsionFree(){const{h:C,isTorsionFree:z}=t;if(C===Fr)return!0;if(z)return z(_,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:C,clearCofactor:z}=t;return C===Fr?this:z?z(_,this):this.multiplyUnsafe(t.h)}toRawBytes(C=!0){return this.assertValidity(),n(_,this,C)}toHex(C=!0){return xn(this.toRawBytes(C))}}_.BASE=new _(t.Gx,t.Gy,e.ONE),_.ZERO=new _(e.ZERO,e.ONE,e.ZERO);const F=t.nBitLength,L=Qs(_,t.endo?Math.ceil(F/2):F);return{CURVE:t,ProjectivePoint:_,normPrivateKeyToScalar:y,weierstrassEquation:s,isWithinCurveOrder:f}}function Oh(o){const t=So(o);return Wn(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Nh(o){const t=Oh(o),{Fp:e,n}=t,a=e.BYTES+1,s=2*e.BYTES+1;function f(w){return on<w&&w<e.ORDER}function u(w){return We(w,n)}function y(w){return Eo(w,n)}const{ProjectivePoint:x,normPrivateKeyToScalar:v,weierstrassEquation:_,isWithinCurveOrder:F}=Fh({...t,toBytes(w,E,P){const R=E.toAffine(),T=e.toBytes(R.x),N=kn;return P?N(Uint8Array.from([E.hasEvenY()?2:3]),T):N(Uint8Array.from([4]),T,e.toBytes(R.y))},fromBytes(w){const E=w.length,P=w[0],R=w.subarray(1);if(E===a&&(P===2||P===3)){const T=En(R);if(!f(T))throw new Error("Point is not on curve");const N=_(T);let k;try{k=e.sqrt(N)}catch(at){const tt=at instanceof Error?": "+at.message:"";throw new Error("Point is not on curve"+tt)}const p=(k&Fr)===Fr;return(P&1)===1!==p&&(k=e.neg(k)),{x:T,y:k}}else if(E===s&&P===4){const T=e.fromBytes(R.subarray(0,e.BYTES)),N=e.fromBytes(R.subarray(e.BYTES,2*e.BYTES));return{x:T,y:N}}else throw new Error(`Point of length ${E} was invalid. Expected ${a} compressed bytes or ${s} uncompressed bytes`)}}),L=w=>xn(Kn(w,t.nByteLength));function D(w){const E=n>>Fr;return w>E}function C(w){return D(w)?u(-w):w}const z=(w,E,P)=>En(w.slice(E,P));class ${constructor(E,P,R){this.r=E,this.s=P,this.recovery=R,this.assertValidity()}static fromCompact(E){const P=t.nByteLength;return E=or("compactSignature",E,P*2),new $(z(E,0,P),z(E,P,2*P))}static fromDER(E){const{r:P,s:R}=An.toSig(or("DER",E));return new $(P,R)}assertValidity(){if(!F(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!F(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(E){return new $(this.r,this.s,E)}recoverPublicKey(E){const{r:P,s:R,recovery:T}=this,N=Q(or("msgHash",E));if(T==null||![0,1,2,3].includes(T))throw new Error("recovery id invalid");const k=T===2||T===3?P+t.n:P;if(k>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const p=T&1?"03":"02",M=x.fromHex(p+L(k)),at=y(k),tt=u(-N*at),ft=u(R*at),Lt=x.BASE.multiplyAndAddUnsafe(M,tt,ft);if(!Lt)throw new Error("point at infinify");return Lt.assertValidity(),Lt}hasHighS(){return D(this.s)}normalizeS(){return this.hasHighS()?new $(this.r,u(-this.s),this.recovery):this}toDERRawBytes(){return Dn(this.toDERHex())}toDERHex(){return An.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Dn(this.toCompactHex())}toCompactHex(){return L(this.r)+L(this.s)}}const X={isValidPrivateKey(w){try{return v(w),!0}catch{return!1}},normPrivateKeyToScalar:v,randomPrivateKey:()=>{const w=Xs(t.n);return Ju(t.randomBytes(w),t.n)},precompute(w=8,E=x.BASE){return E._setWindowSize(w),E.multiply(BigInt(3)),E}};function j(w,E=!0){return x.fromPrivateKey(w).toRawBytes(E)}function it(w){const E=bn(w),P=typeof w=="string",R=(E||P)&&w.length;return E?R===a||R===s:P?R===2*a||R===2*s:w instanceof x}function G(w,E,P=!0){if(it(w))throw new Error("first arg must be private key");if(!it(E))throw new Error("second arg must be public key");return x.fromHex(E).multiply(v(w)).toRawBytes(P)}const W=t.bits2int||function(w){const E=En(w),P=w.length*8-t.nBitLength;return P>0?E>>BigInt(P):E},Q=t.bits2int_modN||function(w){return u(W(w))},rt=mo(t.nBitLength);function ae(w){if(typeof w!="bigint")throw new Error("bigint expected");if(!(on<=w&&w<rt))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Kn(w,t.nByteLength)}function Vt(w,E,P=Bt){if(["recovered","canonical"].some(Ut=>Ut in P))throw new Error("sign() legacy options not supported");const{hash:R,randomBytes:T}=t;let{lowS:N,prehash:k,extraEntropy:p}=P;N==null&&(N=!0),w=or("msgHash",w),k&&(w=or("prehashed msgHash",R(w)));const M=Q(w),at=v(E),tt=[ae(at),ae(M)];if(p!=null&&p!==!1){const Ut=p===!0?T(e.BYTES):p;tt.push(or("extraEntropy",Ut))}const ft=kn(...tt),Lt=M;function _t(Ut){const Ee=W(Ut);if(!F(Ee))return;const Zt=y(Ee),Wt=x.BASE.multiply(Ee).toAffine(),Yt=u(Wt.x);if(Yt===on)return;const zt=u(Zt*u(Lt+Yt*at));if(zt===on)return;let ge=(Wt.x===Yt?0:2)|Number(Wt.y&Fr),xr=zt;return N&&D(zt)&&(xr=C(zt),ge^=1),new $(Yt,xr,ge)}return{seed:ft,k2sig:_t}}const Bt={lowS:t.lowS,prehash:!1},re={lowS:t.lowS,prehash:!1};function U(w,E,P=Bt){const{seed:R,k2sig:T}=Vt(w,E,P),N=t;return js(N.hash.outputLen,N.nByteLength,N.hmac)(R,T)}x.BASE._setWindowSize(8);function d(w,E,P,R=re){var Wt;const T=w;if(E=or("msgHash",E),P=or("publicKey",P),"strict"in R)throw new Error("options.strict was renamed to lowS");const{lowS:N,prehash:k}=R;let p,M;try{if(typeof T=="string"||bn(T))try{p=$.fromDER(T)}catch(Yt){if(!(Yt instanceof An.Err))throw Yt;p=$.fromCompact(T)}else if(typeof T=="object"&&typeof T.r=="bigint"&&typeof T.s=="bigint"){const{r:Yt,s:zt}=T;p=new $(Yt,zt)}else throw new Error("PARSE");M=x.fromHex(P)}catch(Yt){if(Yt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(N&&p.hasHighS())return!1;k&&(E=t.hash(E));const{r:at,s:tt}=p,ft=Q(E),Lt=y(tt),_t=u(ft*Lt),Ut=u(at*Lt),Ee=(Wt=x.BASE.multiplyAndAddUnsafe(M,_t,Ut))==null?void 0:Wt.toAffine();return Ee?u(Ee.x)===at:!1}return{CURVE:t,getPublicKey:j,getSharedSecret:G,sign:U,verify:d,ProjectivePoint:x,Signature:$,utils:X}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function zh(o){return{hash:o,hmac:(t,...e)=>Qa(o,t,pu(...e)),randomBytes:Cs}}function Dh(o,t){const e=n=>Nh({...o,...zh(n)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ec=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),rc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),$h=BigInt(1),Yo=BigInt(2),nc=(o,t)=>(o+t/Yo)/t;function Kh(o){const t=ec,e=BigInt(3),n=BigInt(6),a=BigInt(11),s=BigInt(22),f=BigInt(23),u=BigInt(44),y=BigInt(88),x=o*o*o%t,v=x*x*o%t,_=Ze(v,e,t)*v%t,F=Ze(_,e,t)*v%t,L=Ze(F,Yo,t)*x%t,D=Ze(L,a,t)*L%t,C=Ze(D,s,t)*D%t,z=Ze(C,u,t)*C%t,$=Ze(z,y,t)*z%t,X=Ze($,u,t)*C%t,j=Ze(X,e,t)*v%t,it=Ze(j,f,t)*D%t,G=Ze(it,n,t)*x%t,W=Ze(G,Yo,t);if(!Zo.eql(Zo.sqr(W),o))throw new Error("Cannot find square root");return W}const Zo=Zs(ec,void 0,void 0,{sqrt:Kh}),Hi=Dh({a:BigInt(0),b:BigInt(7),Fp:Zo,n:rc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:o=>{const t=rc,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-$h*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),a=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,f=BigInt("0x100000000000000000000000000000000"),u=nc(s*o,t),y=nc(-n*o,t);let x=We(o-u*e-y*a,t),v=We(-u*n-y*s,t);const _=x>f,F=v>f;if(_&&(x=t-x),F&&(v=t-v),x>f||v>f)throw new Error("splitScalar: Endomorphism failed, k="+o);return{k1neg:_,k1:x,k2neg:F,k2:v}}}},_o);BigInt(0),Hi.ProjectivePoint;const Wh=qn.utils.randomPrivateKey,ic=()=>{const o=qn.utils.randomPrivateKey(),t=ji(o),e=new Uint8Array(64);return e.set(o),e.set(t,32),{publicKey:t,secretKey:e}},ji=qn.getPublicKey;function oc(o){try{return qn.ExtendedPoint.fromHex(o),!0}catch{return!1}}const Jo=(o,t)=>qn.sign(o,t.slice(0,32)),qh=qn.verify,oe=o=>Nt.Buffer.isBuffer(o)?o:o instanceof Uint8Array?Nt.Buffer.from(o.buffer,o.byteOffset,o.byteLength):Nt.Buffer.from(o);class Xo{constructor(t){Object.assign(this,t)}encode(){return Nt.Buffer.from(da(yi,this))}static decode(t){return pa(yi,this,t)}static decodeUnchecked(t){return ca(yi,this,t)}}class Hh extends Xo{constructor(t){if(super(t),this.enum="",Object.keys(t).length!==1)throw new Error("Enum can only take single value");Object.keys(t).map(e=>{this.enum=e})}}const yi=new Map;var sc;const ac=32,Yr=32;function jh(o){return o._bn!==void 0}let cc=1;class mt extends Xo{constructor(t){if(super({}),this._bn=void 0,jh(t))this._bn=t._bn;else{if(typeof t=="string"){const e=cr.decode(t);if(e.length!=Yr)throw new Error("Invalid public key input");this._bn=new ia(e)}else this._bn=new ia(t);if(this._bn.byteLength()>Yr)throw new Error("Invalid public key input")}}static unique(){const t=new mt(cc);return cc+=1,new mt(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return cr.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(Nt.Buffer);if(t.length===Yr)return t;const e=Nt.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,n){const a=Nt.Buffer.concat([t.toBuffer(),Nt.Buffer.from(e),n.toBuffer()]),s=_o(a);return new mt(s)}static createProgramAddressSync(t,e){let n=Nt.Buffer.alloc(0);t.forEach(function(s){if(s.length>ac)throw new TypeError("Max seed length exceeded");n=Nt.Buffer.concat([n,oe(s)])}),n=Nt.Buffer.concat([n,e.toBuffer(),Nt.Buffer.from("ProgramDerivedAddress")]);const a=_o(n);if(oc(a))throw new Error("Invalid seeds, address must fall off the curve");return new mt(a)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let n=255,a;for(;n!=0;){try{const s=t.concat(Nt.Buffer.from([n]));a=this.createProgramAddressSync(s,e)}catch(s){if(s instanceof TypeError)throw s;n--;continue}return[a,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){const e=new mt(t);return oc(e.toBytes())}}sc=mt,mt.default=new sc("11111111111111111111111111111111"),yi.set(mt,{kind:"struct",fields:[["_bn","u256"]]});class Vh{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=oe(t);if(t.length!==64)throw new Error("bad secret key size");this._publicKey=e.slice(32,64),this._secretKey=e.slice(0,32)}else this._secretKey=oe(Wh()),this._publicKey=oe(ji(this._secretKey))}get publicKey(){return new mt(this._publicKey)}get secretKey(){return Nt.Buffer.concat([this._secretKey,this._publicKey],64)}}const Gh=new mt("BPFLoader1111111111111111111111111111111111"),gn=1232,Vi=127,gi=64;class Qo extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Qo.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class ts extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty(ts.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Zn extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Zn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class wi{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((s,f)=>{n.set(s.toBase58(),f)});const a=s=>{const f=n.get(s.toBase58());if(f===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return f};return t.map(s=>({programIdIndex:a(s.programId),accountKeyIndexes:s.keys.map(f=>a(f.pubkey)),data:s.data}))}}const pe=(o="publicKey")=>Ke(32,o),Yh=(o="signature")=>Ke(64,o),Rn=(o="string")=>{const t=Pt([Mt("length"),Mt("lengthPadding"),Ke(pn(Mt(),-8),"chars")],o),e=t.decode.bind(t),n=t.encode.bind(t),a=t;return a.decode=(s,f)=>e(s,f).chars.toString(),a.encode=(s,f,u)=>{const y={chars:Nt.Buffer.from(s,"utf8")};return n(y,f,u)},a.alloc=s=>Mt().span+Mt().span+Nt.Buffer.from(s,"utf8").length,a},Zh=(o="authorized")=>Pt([pe("staker"),pe("withdrawer")],o),Jh=(o="lockup")=>Pt([Mr("unixTimestamp"),Mr("epoch"),pe("custodian")],o),Xh=(o="voteInit")=>Pt([pe("nodePubkey"),pe("authorizedVoter"),pe("authorizedWithdrawer"),ve("commission")],o),Qh=(o="voteAuthorizeWithSeedArgs")=>Pt([Mt("voteAuthorizationType"),pe("currentAuthorityDerivedKeyOwnerPubkey"),Rn("currentAuthorityDerivedKeySeed"),pe("newAuthorized")],o);function uc(o,t){const e=a=>{if(a.span>=0)return a.span;if(typeof a.alloc=="function")return a.alloc(t[a.property]);if("count"in a&&"elementLayout"in a){const s=t[a.property];if(Array.isArray(s))return s.length*e(a.elementLayout)}else if("fields"in a)return uc({layout:a},t[a.property]);return 0};let n=0;return o.layout.fields.forEach(a=>{n+=e(a)}),n}function _r(o){let t=0,e=0;for(;;){let n=o.shift();if(t|=(n&127)<<e*7,e+=1,!(n&128))break}return t}function Pr(o,t){let e=t;for(;;){let n=e&127;if(e>>=7,e==0){o.push(n);break}else n|=128,o.push(n)}}function Me(o,t){if(!o)throw new Error(t||"Assertion failed")}class Gi{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const n=new Map,a=f=>{const u=f.toBase58();let y=n.get(u);return y===void 0&&(y={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(u,y)),y},s=a(e);s.isSigner=!0,s.isWritable=!0;for(const f of t){a(f.programId).isInvoked=!0;for(const u of f.keys){const y=a(u.pubkey);y.isSigner||(y.isSigner=u.isSigner),y.isWritable||(y.isWritable=u.isWritable)}}return new Gi(e,n)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];Me(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,y])=>y.isSigner&&y.isWritable),n=t.filter(([,y])=>y.isSigner&&!y.isWritable),a=t.filter(([,y])=>!y.isSigner&&y.isWritable),s=t.filter(([,y])=>!y.isSigner&&!y.isWritable),f={numRequiredSignatures:e.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:s.length};{Me(e.length>0,"Expected at least one writable signer key");const[y]=e[0];Me(y===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const u=[...e.map(([y])=>new mt(y)),...n.map(([y])=>new mt(y)),...a.map(([y])=>new mt(y)),...s.map(([y])=>new mt(y))];return[f,u]}extractTableLookup(t){const[e,n]=this.drainKeysFoundInLookupTable(t.state.addresses,f=>!f.isSigner&&!f.isInvoked&&f.isWritable),[a,s]=this.drainKeysFoundInLookupTable(t.state.addresses,f=>!f.isSigner&&!f.isInvoked&&!f.isWritable);if(!(e.length===0&&a.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:a},{writable:n,readonly:s}]}drainKeysFoundInLookupTable(t,e){const n=new Array,a=new Array;for(const[s,f]of this.keyMetaMap.entries())if(e(f)){const u=new mt(s),y=t.findIndex(x=>x.equals(u));y>=0&&(Me(y<256,"Max lookup table index exceeded"),n.push(y),a.push(u),this.keyMetaMap.delete(s))}return[n,a]}}const fc="Reached end of buffer unexpectedly";function Zr(o){if(o.length===0)throw new Error(fc);return o.shift()}function Ar(o,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>o.length:e>=o.length)throw new Error(fc);return o.splice(...t)}class $r{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(e=>new mt(e)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:cr.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new wi(this.staticAccountKeys)}static compile(t){const e=Gi.compile(t.instructions,t.payerKey),[n,a]=e.getMessageComponents(),f=new wi(a).compileInstructions(t.instructions).map(u=>({programIdIndex:u.programIdIndex,accounts:u.accountKeyIndexes,data:cr.encode(u.data)}));return new $r({header:n,accountKeys:a,recentBlockhash:t.recentBlockhash,instructions:f})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const n=t-e,s=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return n<s}else{const n=e-this.header.numReadonlySignedAccounts;return t<n}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,e)=>!this.isProgramId(e))}serialize(){const t=this.accountKeys.length;let e=[];Pr(e,t);const n=this.instructions.map(_=>{const{accounts:F,programIdIndex:L}=_,D=Array.from(cr.decode(_.data));let C=[];Pr(C,F.length);let z=[];return Pr(z,D.length),{programIdIndex:L,keyIndicesCount:Nt.Buffer.from(C),keyIndices:F,dataLength:Nt.Buffer.from(z),data:D}});let a=[];Pr(a,n.length);let s=Nt.Buffer.alloc(gn);Nt.Buffer.from(a).copy(s);let f=a.length;n.forEach(_=>{const L=Pt([ve("programIdIndex"),Ke(_.keyIndicesCount.length,"keyIndicesCount"),pr(ve("keyIndex"),_.keyIndices.length,"keyIndices"),Ke(_.dataLength.length,"dataLength"),pr(ve("userdatum"),_.data.length,"data")]).encode(_,s,f);f+=L}),s=s.slice(0,f);const u=Pt([Ke(1,"numRequiredSignatures"),Ke(1,"numReadonlySignedAccounts"),Ke(1,"numReadonlyUnsignedAccounts"),Ke(e.length,"keyCount"),pr(pe("key"),t,"keys"),pe("recentBlockhash")]),y={numRequiredSignatures:Nt.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Nt.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Nt.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Nt.Buffer.from(e),keys:this.accountKeys.map(_=>oe(_.toBytes())),recentBlockhash:cr.decode(this.recentBlockhash)};let x=Nt.Buffer.alloc(2048);const v=u.encode(y,x);return s.copy(x,v),x.slice(0,v+s.length)}static from(t){let e=[...t];const n=Zr(e);if(n!==(n&Vi))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const a=Zr(e),s=Zr(e),f=_r(e);let u=[];for(let F=0;F<f;F++){const L=Ar(e,0,Yr);u.push(new mt(Nt.Buffer.from(L)))}const y=Ar(e,0,Yr),x=_r(e);let v=[];for(let F=0;F<x;F++){const L=Zr(e),D=_r(e),C=Ar(e,0,D),z=_r(e),$=Ar(e,0,z),X=cr.encode(Nt.Buffer.from($));v.push({programIdIndex:L,accounts:C,data:X})}const _={header:{numRequiredSignatures:n,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:s},recentBlockhash:cr.encode(Nt.Buffer.from(y)),accountKeys:u,instructions:v};return new $r(_)}}class Tn{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const e of this.addressTableLookups)t+=e.readonlyIndexes.length+e.writableIndexes.length;return t}getAccountKeys(t){let e;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");e=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)e=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new wi(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(t>=n){const a=t-n,s=this.addressTableLookups.reduce((f,u)=>f+u.writableIndexes.length,0);return a<s}else if(t>=this.header.numRequiredSignatures){const a=t-e,f=n-e-this.header.numReadonlyUnsignedAccounts;return a<f}else{const a=e-this.header.numReadonlySignedAccounts;return t<a}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const n of this.addressTableLookups){const a=t.find(s=>s.key.equals(n.accountKey));if(!a)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const s of n.writableIndexes)if(s<a.state.addresses.length)e.writable.push(a.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`);for(const s of n.readonlyIndexes)if(s<a.state.addresses.length)e.readonly.push(a.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`)}return e}static compile(t){const e=Gi.compile(t.instructions,t.payerKey),n=new Array,a={writable:new Array,readonly:new Array},s=t.addressLookupTableAccounts||[];for(const v of s){const _=e.extractTableLookup(v);if(_!==void 0){const[F,{writable:L,readonly:D}]=_;n.push(F),a.writable.push(...L),a.readonly.push(...D)}}const[f,u]=e.getMessageComponents(),x=new wi(u,a).compileInstructions(t.instructions);return new Tn({header:f,staticAccountKeys:u,recentBlockhash:t.recentBlockhash,compiledInstructions:x,addressTableLookups:n})}serialize(){const t=Array();Pr(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),n=Array();Pr(n,this.compiledInstructions.length);const a=this.serializeAddressTableLookups(),s=Array();Pr(s,this.addressTableLookups.length);const f=Pt([ve("prefix"),Pt([ve("numRequiredSignatures"),ve("numReadonlySignedAccounts"),ve("numReadonlyUnsignedAccounts")],"header"),Ke(t.length,"staticAccountKeysLength"),pr(pe(),this.staticAccountKeys.length,"staticAccountKeys"),pe("recentBlockhash"),Ke(n.length,"instructionsLength"),Ke(e.length,"serializedInstructions"),Ke(s.length,"addressTableLookupsLength"),Ke(a.length,"serializedAddressTableLookups")]),u=new Uint8Array(gn),x=f.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(v=>v.toBytes()),recentBlockhash:cr.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:a},u);return u.slice(0,x)}serializeInstructions(){let t=0;const e=new Uint8Array(gn);for(const n of this.compiledInstructions){const a=Array();Pr(a,n.accountKeyIndexes.length);const s=Array();Pr(s,n.data.length);const f=Pt([ve("programIdIndex"),Ke(a.length,"encodedAccountKeyIndexesLength"),pr(ve(),n.accountKeyIndexes.length,"accountKeyIndexes"),Ke(s.length,"encodedDataLength"),Ke(n.data.length,"data")]);t+=f.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(a),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:n.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(gn);for(const n of this.addressTableLookups){const a=Array();Pr(a,n.writableIndexes.length);const s=Array();Pr(s,n.readonlyIndexes.length);const f=Pt([pe("accountKey"),Ke(a.length,"encodedWritableIndexesLength"),pr(ve(),n.writableIndexes.length,"writableIndexes"),Ke(s.length,"encodedReadonlyIndexesLength"),pr(ve(),n.readonlyIndexes.length,"readonlyIndexes")]);t+=f.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(a),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:n.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const n=Zr(e),a=n&Vi;Me(n!==a,"Expected versioned message but received legacy message");const s=a;Me(s===0,`Expected versioned message with version 0 but found version ${s}`);const f={numRequiredSignatures:Zr(e),numReadonlySignedAccounts:Zr(e),numReadonlyUnsignedAccounts:Zr(e)},u=[],y=_r(e);for(let D=0;D<y;D++)u.push(new mt(Ar(e,0,Yr)));const x=cr.encode(Ar(e,0,Yr)),v=_r(e),_=[];for(let D=0;D<v;D++){const C=Zr(e),z=_r(e),$=Ar(e,0,z),X=_r(e),j=new Uint8Array(Ar(e,0,X));_.push({programIdIndex:C,accountKeyIndexes:$,data:j})}const F=_r(e),L=[];for(let D=0;D<F;D++){const C=new mt(Ar(e,0,Yr)),z=_r(e),$=Ar(e,0,z),X=_r(e),j=Ar(e,0,X);L.push({accountKey:C,writableIndexes:$,readonlyIndexes:j})}return new Tn({header:f,staticAccountKeys:u,recentBlockhash:x,compiledInstructions:_,addressTableLookups:L})}}const es={deserializeMessageVersion(o){const t=o[0],e=t&Vi;return e===t?"legacy":e},deserialize:o=>{const t=es.deserializeMessageVersion(o);if(t==="legacy")return $r.from(o);if(t===0)return Tn.deserialize(o);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let sn=function(o){return o[o.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",o[o.PROCESSED=1]="PROCESSED",o[o.TIMED_OUT=2]="TIMED_OUT",o[o.NONCE_INVALID=3]="NONCE_INVALID",o}({});const tl=Nt.Buffer.alloc(gi).fill(0);class Ne{constructor(t){this.keys=void 0,this.programId=void 0,this.data=Nt.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:e,isWritable:n})=>({pubkey:t.toJSON(),isSigner:e,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}}class _e{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:n}=t;this.minNonceContextSlot=e,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:n}=t;this.recentBlockhash=e,this.lastValidBlockHeight=n}else{const{recentBlockhash:e,nonceInfo:n}=t;n&&(this.nonceInfo=n),this.recentBlockhash=e}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new Ne(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let C=0;C<e.length;C++)if(e[C].programId===void 0)throw new Error(`Transaction instruction index ${C} has undefined program id`);const a=[],s=[];e.forEach(C=>{C.keys.forEach($=>{s.push({...$})});const z=C.programId.toString();a.includes(z)||a.push(z)}),a.forEach(C=>{s.push({pubkey:new mt(C),isSigner:!1,isWritable:!1})});const f=[];s.forEach(C=>{const z=C.pubkey.toString(),$=f.findIndex(X=>X.pubkey.toString()===z);$>-1?(f[$].isWritable=f[$].isWritable||C.isWritable,f[$].isSigner=f[$].isSigner||C.isSigner):f.push(C)}),f.sort(function(C,z){if(C.isSigner!==z.isSigner)return C.isSigner?-1:1;if(C.isWritable!==z.isWritable)return C.isWritable?-1:1;const $={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return C.pubkey.toBase58().localeCompare(z.pubkey.toBase58(),"en",$)});const u=f.findIndex(C=>C.pubkey.equals(n));if(u>-1){const[C]=f.splice(u,1);C.isSigner=!0,C.isWritable=!0,f.unshift(C)}else f.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const C of this.signatures){const z=f.findIndex($=>$.pubkey.equals(C.publicKey));if(z>-1)f[z].isSigner||(f[z].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${C.publicKey.toString()}`)}let y=0,x=0,v=0;const _=[],F=[];f.forEach(({pubkey:C,isSigner:z,isWritable:$})=>{z?(_.push(C.toString()),y+=1,$||(x+=1)):(F.push(C.toString()),$||(v+=1))});const L=_.concat(F),D=e.map(C=>{const{data:z,programId:$}=C;return{programIdIndex:L.indexOf($.toString()),accounts:C.keys.map(X=>L.indexOf(X.pubkey.toString())),data:cr.encode(z)}});return D.forEach(C=>{Me(C.programIdIndex>=0),C.accounts.forEach(z=>Me(z>=0))}),new $r({header:{numRequiredSignatures:y,numReadonlySignedAccounts:x,numReadonlyUnsignedAccounts:v},accountKeys:L,recentBlockhash:t,instructions:D})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((a,s)=>e[s].equals(a.publicKey))||(this.signatures=e.map(n=>({signature:null,publicKey:n}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");const e=new Set;this.signatures=t.filter(n=>{const a=n.toString();return e.has(a)?!1:(e.add(a),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,n=[];for(const s of t){const f=s.publicKey.toString();e.has(f)||(e.add(f),n.push(s))}this.signatures=n.map(s=>({signature:null,publicKey:s.publicKey}));const a=this._compile();this._partialSign(a,...n)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,n=[];for(const s of t){const f=s.publicKey.toString();e.has(f)||(e.add(f),n.push(s))}const a=this._compile();this._partialSign(a,...n)}_partialSign(t,...e){const n=t.serialize();e.forEach(a=>{const s=Jo(n,a.secretKey);this._addSignature(a.publicKey,oe(s))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){Me(e.length===64);const n=this.signatures.findIndex(a=>t.equals(a.publicKey));if(n<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[n].signature=Nt.Buffer.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const n={};for(const{signature:a,publicKey:s}of this.signatures)a===null?e&&(n.missing||(n.missing=[])).push(s):qh(a,t,s.toBytes())||(n.invalid||(n.invalid=[])).push(s);return n.invalid||n.missing?n:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),a=this.serializeMessage();if(n){const s=this._getMessageSignednessErrors(a,e);if(s){let f="Signature verification failed.";throw s.invalid&&(f+=`
16
+ */(function(o){const t=On,e=oi,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;o.Buffer=u,o.SlowBuffer=X,o.INSPECT_MAX_BYTES=50;const a=2147483647;o.kMaxLength=a,u.TYPED_ARRAY_SUPPORT=s(),!u.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 s(){try{const c=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(c,r),c.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function f(c){if(c>a)throw new RangeError('The value "'+c+'" is invalid for option "size"');const r=new Uint8Array(c);return Object.setPrototypeOf(r,u.prototype),r}function u(c,r,i){if(typeof c=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(c)}return y(c,r,i)}u.poolSize=8192;function y(c,r,i){if(typeof c=="string")return F(c,r);if(ArrayBuffer.isView(c))return D(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(Qt(c,ArrayBuffer)||c&&Qt(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Qt(c,SharedArrayBuffer)||c&&Qt(c.buffer,SharedArrayBuffer)))return U(c,r,i);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const h=c.valueOf&&c.valueOf();if(h!=null&&h!==c)return u.from(h,r,i);const g=z(c);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return u.from(c[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}u.from=function(c,r,i){return y(c,r,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function x(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function B(c,r,i){return x(c),c<=0?f(c):r!==void 0?typeof i=="string"?f(c).fill(r,i):f(c).fill(r):f(c)}u.alloc=function(c,r,i){return B(c,r,i)};function v(c){return x(c),f(c<0?0:$(c)|0)}u.allocUnsafe=function(c){return v(c)},u.allocUnsafeSlow=function(c){return v(c)};function F(c,r){if((typeof r!="string"||r==="")&&(r="utf8"),!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const i=V(c,r)|0;let h=f(i);const g=h.write(c,r);return g!==i&&(h=h.slice(0,g)),h}function L(c){const r=c.length<0?0:$(c.length)|0,i=f(r);for(let h=0;h<r;h+=1)i[h]=c[h]&255;return i}function D(c){if(Qt(c,Uint8Array)){const r=new Uint8Array(c);return U(r.buffer,r.byteOffset,r.byteLength)}return L(c)}function U(c,r,i){if(r<0||c.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let h;return r===void 0&&i===void 0?h=new Uint8Array(c):i===void 0?h=new Uint8Array(c,r):h=new Uint8Array(c,r,i),Object.setPrototypeOf(h,u.prototype),h}function z(c){if(u.isBuffer(c)){const r=$(c.length)|0,i=f(r);return i.length===0||c.copy(i,0,0,r),i}if(c.length!==void 0)return typeof c.length!="number"||fe(c.length)?f(0):L(c);if(c.type==="Buffer"&&Array.isArray(c.data))return L(c.data)}function $(c){if(c>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return c|0}function X(c){return+c!=c&&(c=0),u.alloc(+c)}u.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==u.prototype},u.compare=function(r,i){if(Qt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),Qt(i,Uint8Array)&&(i=u.from(i,i.offset,i.byteLength)),!u.isBuffer(r)||!u.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let h=r.length,g=i.length;for(let b=0,S=Math.min(h,g);b<S;++b)if(r[b]!==i[b]){h=r[b],g=i[b];break}return h<g?-1:g<h?1:0},u.isEncoding=function(r){switch(String(r).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}},u.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);let h;if(i===void 0)for(i=0,h=0;h<r.length;++h)i+=r[h].length;const g=u.allocUnsafe(i);let b=0;for(h=0;h<r.length;++h){let S=r[h];if(Qt(S,Uint8Array))b+S.length>g.length?(u.isBuffer(S)||(S=u.from(S)),S.copy(g,b)):Uint8Array.prototype.set.call(g,S,b);else if(u.isBuffer(S))S.copy(g,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=S.length}return g};function V(c,r){if(u.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||Qt(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const i=c.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&i===0)return 0;let g=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return de(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return me(c).length;default:if(g)return h?-1:de(c).length;r=(""+r).toLowerCase(),g=!0}}u.byteLength=V;function it(c,r,i){let h=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(c||(c="utf8");;)switch(c){case"hex":return T(this,r,i);case"utf8":case"utf-8":return d(this,r,i);case"ascii":return C(this,r,i);case"latin1":case"binary":return R(this,r,i);case"base64":return P(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,r,i);default:if(h)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),h=!0}}u.prototype._isBuffer=!0;function G(c,r,i){const h=c[r];c[r]=c[i],c[i]=h}u.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)G(this,i,i+1);return this},u.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)G(this,i,i+3),G(this,i+1,i+2);return this},u.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)G(this,i,i+7),G(this,i+1,i+6),G(this,i+2,i+5),G(this,i+3,i+4);return this},u.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?d(this,0,r):it.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(r){if(!u.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0},u.prototype.inspect=function(){let r="";const i=o.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(r,i,h,g,b){if(Qt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),h===void 0&&(h=r?r.length:0),g===void 0&&(g=0),b===void 0&&(b=this.length),i<0||h>r.length||g<0||b>this.length)throw new RangeError("out of range index");if(g>=b&&i>=h)return 0;if(g>=b)return-1;if(i>=h)return 1;if(i>>>=0,h>>>=0,g>>>=0,b>>>=0,this===r)return 0;let S=b-g,et=h-i;const lt=Math.min(S,et),ht=this.slice(g,b),kt=r.slice(i,h);for(let st=0;st<lt;++st)if(ht[st]!==kt[st]){S=ht[st],et=kt[st];break}return S<et?-1:et<S?1:0};function W(c,r,i,h,g){if(c.length===0)return-1;if(typeof i=="string"?(h=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,fe(i)&&(i=g?0:c.length-1),i<0&&(i=c.length+i),i>=c.length){if(g)return-1;i=c.length-1}else if(i<0)if(g)i=0;else return-1;if(typeof r=="string"&&(r=u.from(r,h)),u.isBuffer(r))return r.length===0?-1:Q(c,r,i,h,g);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?g?Uint8Array.prototype.indexOf.call(c,r,i):Uint8Array.prototype.lastIndexOf.call(c,r,i):Q(c,[r],i,h,g);throw new TypeError("val must be string, number or Buffer")}function Q(c,r,i,h,g){let b=1,S=c.length,et=r.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(c.length<2||r.length<2)return-1;b=2,S/=2,et/=2,i/=2}function lt(kt,st){return b===1?kt[st]:kt.readUInt16BE(st*b)}let ht;if(g){let kt=-1;for(ht=i;ht<S;ht++)if(lt(c,ht)===lt(r,kt===-1?0:ht-kt)){if(kt===-1&&(kt=ht),ht-kt+1===et)return kt*b}else kt!==-1&&(ht-=ht-kt),kt=-1}else for(i+et>S&&(i=S-et),ht=i;ht>=0;ht--){let kt=!0;for(let st=0;st<et;st++)if(lt(c,ht+st)!==lt(r,st)){kt=!1;break}if(kt)return ht}return-1}u.prototype.includes=function(r,i,h){return this.indexOf(r,i,h)!==-1},u.prototype.indexOf=function(r,i,h){return W(this,r,i,h,!0)},u.prototype.lastIndexOf=function(r,i,h){return W(this,r,i,h,!1)};function rt(c,r,i,h){i=Number(i)||0;const g=c.length-i;h?(h=Number(h),h>g&&(h=g)):h=g;const b=r.length;h>b/2&&(h=b/2);let S;for(S=0;S<h;++S){const et=parseInt(r.substr(S*2,2),16);if(fe(et))return S;c[i+S]=et}return S}function ae(c,r,i,h){return ce(de(r,c.length-i),c,i,h)}function jt(c,r,i,h){return ce(Ce(r),c,i,h)}function _t(c,r,i,h){return ce(me(r),c,i,h)}function re(c,r,i,h){return ce(hr(r,c.length-i),c,i,h)}u.prototype.write=function(r,i,h,g){if(i===void 0)g="utf8",h=this.length,i=0;else if(h===void 0&&typeof i=="string")g=i,h=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(h)?(h=h>>>0,g===void 0&&(g="utf8")):(g=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const b=this.length-i;if((h===void 0||h>b)&&(h=b),r.length>0&&(h<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");g||(g="utf8");let S=!1;for(;;)switch(g){case"hex":return rt(this,r,i,h);case"utf8":case"utf-8":return ae(this,r,i,h);case"ascii":case"latin1":case"binary":return jt(this,r,i,h);case"base64":return _t(this,r,i,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return re(this,r,i,h);default:if(S)throw new TypeError("Unknown encoding: "+g);g=(""+g).toLowerCase(),S=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function P(c,r,i){return r===0&&i===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(r,i))}function d(c,r,i){i=Math.min(c.length,i);const h=[];let g=r;for(;g<i;){const b=c[g];let S=null,et=b>239?4:b>223?3:b>191?2:1;if(g+et<=i){let lt,ht,kt,st;switch(et){case 1:b<128&&(S=b);break;case 2:lt=c[g+1],(lt&192)===128&&(st=(b&31)<<6|lt&63,st>127&&(S=st));break;case 3:lt=c[g+1],ht=c[g+2],(lt&192)===128&&(ht&192)===128&&(st=(b&15)<<12|(lt&63)<<6|ht&63,st>2047&&(st<55296||st>57343)&&(S=st));break;case 4:lt=c[g+1],ht=c[g+2],kt=c[g+3],(lt&192)===128&&(ht&192)===128&&(kt&192)===128&&(st=(b&15)<<18|(lt&63)<<12|(ht&63)<<6|kt&63,st>65535&&st<1114112&&(S=st))}}S===null?(S=65533,et=1):S>65535&&(S-=65536,h.push(S>>>10&1023|55296),S=56320|S&1023),h.push(S),g+=et}return E(h)}const m=4096;function E(c){const r=c.length;if(r<=m)return String.fromCharCode.apply(String,c);let i="",h=0;for(;h<r;)i+=String.fromCharCode.apply(String,c.slice(h,h+=m));return i}function C(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]&127);return h}function R(c,r,i){let h="";i=Math.min(c.length,i);for(let g=r;g<i;++g)h+=String.fromCharCode(c[g]);return h}function T(c,r,i){const h=c.length;(!r||r<0)&&(r=0),(!i||i<0||i>h)&&(i=h);let g="";for(let b=r;b<i;++b)g+=be[c[b]];return g}function N(c,r,i){const h=c.slice(r,i);let g="";for(let b=0;b<h.length-1;b+=2)g+=String.fromCharCode(h[b]+h[b+1]*256);return g}u.prototype.slice=function(r,i){const h=this.length;r=~~r,i=i===void 0?h:~~i,r<0?(r+=h,r<0&&(r=0)):r>h&&(r=h),i<0?(i+=h,i<0&&(i=0)):i>h&&(i=h),i<r&&(i=r);const g=this.subarray(r,i);return Object.setPrototypeOf(g,u.prototype),g};function k(c,r,i){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+r>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r],b=1,S=0;for(;++S<i&&(b*=256);)g+=this[r+S]*b;return g},u.prototype.readUintBE=u.prototype.readUIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r+--i],b=1;for(;i>0&&(b*=256);)g+=this[r+--i]*b;return g},u.prototype.readUint8=u.prototype.readUInt8=function(r,i){return r=r>>>0,i||k(r,1,this.length),this[r]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||k(r,2,this.length),this[r]|this[r+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||k(r,2,this.length),this[r]<<8|this[r+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||k(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},u.prototype.readBigUInt64LE=we(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,b=this[++r]+this[++r]*2**8+this[++r]*2**16+h*2**24;return BigInt(g)+(BigInt(b)<<BigInt(32))}),u.prototype.readBigUInt64BE=we(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=i*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],b=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h;return(BigInt(g)<<BigInt(32))+BigInt(b)}),u.prototype.readIntLE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=this[r],b=1,S=0;for(;++S<i&&(b*=256);)g+=this[r+S]*b;return b*=128,g>=b&&(g-=Math.pow(2,8*i)),g},u.prototype.readIntBE=function(r,i,h){r=r>>>0,i=i>>>0,h||k(r,i,this.length);let g=i,b=1,S=this[r+--g];for(;g>0&&(b*=256);)S+=this[r+--g]*b;return b*=128,S>=b&&(S-=Math.pow(2,8*i)),S},u.prototype.readInt8=function(r,i){return r=r>>>0,i||k(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},u.prototype.readInt16LE=function(r,i){r=r>>>0,i||k(r,2,this.length);const h=this[r]|this[r+1]<<8;return h&32768?h|4294901760:h},u.prototype.readInt16BE=function(r,i){r=r>>>0,i||k(r,2,this.length);const h=this[r+1]|this[r]<<8;return h&32768?h|4294901760:h},u.prototype.readInt32LE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},u.prototype.readInt32BE=function(r,i){return r=r>>>0,i||k(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},u.prototype.readBigInt64LE=we(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(h<<24);return(BigInt(g)<<BigInt(32))+BigInt(i+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),u.prototype.readBigInt64BE=we(function(r){r=r>>>0,Yt(r,"offset");const i=this[r],h=this[r+7];(i===void 0||h===void 0)&&zt(r,this.length-8);const g=(i<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(g)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+h)}),u.prototype.readFloatLE=function(r,i){return r=r>>>0,i||k(r,4,this.length),e.read(this,r,!0,23,4)},u.prototype.readFloatBE=function(r,i){return r=r>>>0,i||k(r,4,this.length),e.read(this,r,!1,23,4)},u.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||k(r,8,this.length),e.read(this,r,!0,52,8)},u.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||k(r,8,this.length),e.read(this,r,!1,52,8)};function p(c,r,i,h,g,b){if(!u.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>g||r<b)throw new RangeError('"value" argument is out of bounds');if(i+h>c.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const et=Math.pow(2,8*h)-1;p(this,r,i,h,et,0)}let b=1,S=0;for(this[i]=r&255;++S<h&&(b*=256);)this[i+S]=r/b&255;return i+h},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,h=h>>>0,!g){const et=Math.pow(2,8*h)-1;p(this,r,i,h,et,0)}let b=h-1,S=1;for(this[i+b]=r&255;--b>=0&&(S*=256);)this[i+b]=r/S&255;return i+h},u.prototype.writeUint8=u.prototype.writeUInt8=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,1,255,0),this[i]=r&255,i+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function M(c,r,i,h,g){Wt(r,h,g,c,i,7);let b=Number(r&BigInt(4294967295));c[i++]=b,b=b>>8,c[i++]=b,b=b>>8,c[i++]=b,b=b>>8,c[i++]=b;let S=Number(r>>BigInt(32)&BigInt(4294967295));return c[i++]=S,S=S>>8,c[i++]=S,S=S>>8,c[i++]=S,S=S>>8,c[i++]=S,i}function at(c,r,i,h,g){Wt(r,h,g,c,i,7);let b=Number(r&BigInt(4294967295));c[i+7]=b,b=b>>8,c[i+6]=b,b=b>>8,c[i+5]=b,b=b>>8,c[i+4]=b;let S=Number(r>>BigInt(32)&BigInt(4294967295));return c[i+3]=S,S=S>>8,c[i+2]=S,S=S>>8,c[i+1]=S,S=S>>8,c[i]=S,i+8}u.prototype.writeBigUInt64LE=we(function(r,i=0){return M(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=we(function(r,i=0){return at(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const lt=Math.pow(2,8*h-1);p(this,r,i,h,lt-1,-lt)}let b=0,S=1,et=0;for(this[i]=r&255;++b<h&&(S*=256);)r<0&&et===0&&this[i+b-1]!==0&&(et=1),this[i+b]=(r/S>>0)-et&255;return i+h},u.prototype.writeIntBE=function(r,i,h,g){if(r=+r,i=i>>>0,!g){const lt=Math.pow(2,8*h-1);p(this,r,i,h,lt-1,-lt)}let b=h-1,S=1,et=0;for(this[i+b]=r&255;--b>=0&&(S*=256);)r<0&&et===0&&this[i+b+1]!==0&&(et=1),this[i+b]=(r/S>>0)-et&255;return i+h},u.prototype.writeInt8=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},u.prototype.writeInt16LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},u.prototype.writeInt16BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},u.prototype.writeInt32LE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},u.prototype.writeInt32BE=function(r,i,h){return r=+r,i=i>>>0,h||p(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},u.prototype.writeBigInt64LE=we(function(r,i=0){return M(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=we(function(r,i=0){return at(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function tt(c,r,i,h,g,b){if(i+h>c.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function ft(c,r,i,h,g){return r=+r,i=i>>>0,g||tt(c,r,i,4),e.write(c,r,i,h,23,4),i+4}u.prototype.writeFloatLE=function(r,i,h){return ft(this,r,i,!0,h)},u.prototype.writeFloatBE=function(r,i,h){return ft(this,r,i,!1,h)};function Lt(c,r,i,h,g){return r=+r,i=i>>>0,g||tt(c,r,i,8),e.write(c,r,i,h,52,8),i+8}u.prototype.writeDoubleLE=function(r,i,h){return Lt(this,r,i,!0,h)},u.prototype.writeDoubleBE=function(r,i,h){return Lt(this,r,i,!1,h)},u.prototype.copy=function(r,i,h,g){if(!u.isBuffer(r))throw new TypeError("argument should be a Buffer");if(h||(h=0),!g&&g!==0&&(g=this.length),i>=r.length&&(i=r.length),i||(i=0),g>0&&g<h&&(g=h),g===h||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(g<0)throw new RangeError("sourceEnd out of bounds");g>this.length&&(g=this.length),r.length-i<g-h&&(g=r.length-i+h);const b=g-h;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,h,g):Uint8Array.prototype.set.call(r,this.subarray(h,g),i),b},u.prototype.fill=function(r,i,h,g){if(typeof r=="string"){if(typeof i=="string"?(g=i,i=0,h=this.length):typeof h=="string"&&(g=h,h=this.length),g!==void 0&&typeof g!="string")throw new TypeError("encoding must be a string");if(typeof g=="string"&&!u.isEncoding(g))throw new TypeError("Unknown encoding: "+g);if(r.length===1){const S=r.charCodeAt(0);(g==="utf8"&&S<128||g==="latin1")&&(r=S)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<h)throw new RangeError("Out of range index");if(h<=i)return this;i=i>>>0,h=h===void 0?this.length:h>>>0,r||(r=0);let b;if(typeof r=="number")for(b=i;b<h;++b)this[b]=r;else{const S=u.isBuffer(r)?r:u.from(r,g),et=S.length;if(et===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(b=0;b<h-i;++b)this[b+i]=S[b%et]}return this};const At={};function Ut(c,r,i){At[c]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(g){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:g,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Ut("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ut("ERR_INVALID_ARG_TYPE",function(c,r){return`The "${c}" argument must be of type number. Received type ${typeof r}`},TypeError),Ut("ERR_OUT_OF_RANGE",function(c,r,i){let h=`The value of "${c}" is out of range.`,g=i;return Number.isInteger(i)&&Math.abs(i)>2**32?g=Ee(String(i)):typeof i=="bigint"&&(g=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(g=Ee(g)),g+="n"),h+=` It must be ${r}. Received ${g}`,h},RangeError);function Ee(c){let r="",i=c.length;const h=c[0]==="-"?1:0;for(;i>=h+4;i-=3)r=`_${c.slice(i-3,i)}${r}`;return`${c.slice(0,i)}${r}`}function Zt(c,r,i){Yt(r,"offset"),(c[r]===void 0||c[r+i]===void 0)&&zt(r,c.length-(i+1))}function Wt(c,r,i,h,g,b){if(c>i||c<r){const S=typeof r=="bigint"?"n":"";let et;throw r===0||r===BigInt(0)?et=`>= 0${S} and < 2${S} ** ${(b+1)*8}${S}`:et=`>= -(2${S} ** ${(b+1)*8-1}${S}) and < 2 ** ${(b+1)*8-1}${S}`,new At.ERR_OUT_OF_RANGE("value",et,c)}Zt(h,g,b)}function Yt(c,r){if(typeof c!="number")throw new At.ERR_INVALID_ARG_TYPE(r,"number",c)}function zt(c,r,i){throw Math.floor(c)!==c?(Yt(c,i),new At.ERR_OUT_OF_RANGE("offset","an integer",c)):r<0?new At.ERR_BUFFER_OUT_OF_BOUNDS:new At.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,c)}const ge=/[^+/0-9A-Za-z-_]/g;function xr(c){if(c=c.split("=")[0],c=c.trim().replace(ge,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function de(c,r){r=r||1/0;let i;const h=c.length;let g=null;const b=[];for(let S=0;S<h;++S){if(i=c.charCodeAt(S),i>55295&&i<57344){if(!g){if(i>56319){(r-=3)>-1&&b.push(239,191,189);continue}else if(S+1===h){(r-=3)>-1&&b.push(239,191,189);continue}g=i;continue}if(i<56320){(r-=3)>-1&&b.push(239,191,189),g=i;continue}i=(g-55296<<10|i-56320)+65536}else g&&(r-=3)>-1&&b.push(239,191,189);if(g=null,i<128){if((r-=1)<0)break;b.push(i)}else if(i<2048){if((r-=2)<0)break;b.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;b.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;b.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return b}function Ce(c){const r=[];for(let i=0;i<c.length;++i)r.push(c.charCodeAt(i)&255);return r}function hr(c,r){let i,h,g;const b=[];for(let S=0;S<c.length&&!((r-=2)<0);++S)i=c.charCodeAt(S),h=i>>8,g=i%256,b.push(g),b.push(h);return b}function me(c){return t.toByteArray(xr(c))}function ce(c,r,i,h){let g;for(g=0;g<h&&!(g+i>=r.length||g>=c.length);++g)r[g+i]=c[g];return g}function Qt(c,r){return c instanceof r||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===r.name}function fe(c){return c!==c}const be=function(){const c="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){const h=i*16;for(let g=0;g<16;++g)r[h+g]=c[i]+c[g]}return r}();function we(c){return typeof BigInt>"u"?ke:c}function ke(){throw new Error("BigInt not supported")}})(ya),Object.defineProperty(j,"__esModule",{value:!0}),j.s16=j.s8=j.nu64be=j.u48be=j.u40be=j.u32be=j.u24be=j.u16be=dr=j.nu64=j.u48=j.u40=Ct=j.u32=j.u24=Lr=j.u16=_e=j.u8=pn=j.offset=j.greedy=j.Constant=j.UTF8=j.CString=j.Blob=j.Boolean=j.BitField=j.BitStructure=j.VariantLayout=j.Union=j.UnionLayoutDiscriminator=j.UnionDiscriminator=j.Structure=j.Sequence=j.DoubleBE=j.Double=j.FloatBE=j.Float=j.NearInt64BE=j.NearInt64=j.NearUInt64BE=j.NearUInt64=j.IntBE=j.Int=j.UIntBE=j.UInt=j.OffsetLayout=j.GreedyCount=j.ExternalLayout=j.bindConstructorLayout=j.nameWithProperty=j.Layout=j.uint8ArrayToBuffer=j.checkUint8Array=void 0,j.constant=j.utf8=j.cstr=Ke=j.blob=j.unionLayoutDiscriminator=j.union=pr=j.seq=j.bits=Pt=j.struct=j.f64be=j.f64=j.f32be=j.f32=j.ns64be=j.s48be=j.s40be=j.s32be=j.s24be=j.s16be=Mr=j.ns64=j.s48=j.s40=j.s32=j.s24=void 0;const Po=ya;function Vn(o){if(!(o instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}j.checkUint8Array=Vn;function Te(o){return Vn(o),Po.Buffer.from(o.buffer,o.byteOffset,o.length)}j.uint8ArrayToBuffer=Te;class Le{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}j.Layout=Le;function Uo(o,t){return t.property?o+"["+t.property+"]":o}j.nameWithProperty=Uo;function Lf(o,t){if(typeof o!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(o,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Le))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");o.layout_=t,t.boundConstructor_=o,t.makeDestinationObject=()=>new o,Object.defineProperty(o.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(o,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}j.bindConstructorLayout=Lf;class _r extends Le{isCount(){throw new Error("ExternalLayout is abstract")}}j.ExternalLayout=_r;class ga extends _r{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){Vn(t);const n=t.length-e;return Math.floor(n/this.elementSpan)}encode(t,e,n){return 0}}j.GreedyCount=ga;class Lo extends _r{constructor(t,e=0,n){if(!(t instanceof Le))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,n||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Ur||this.layout instanceof zr}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,n=0){return this.layout.encode(t,e,n+this.offset)}}j.OffsetLayout=Lo;class Ur extends Le{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Te(t).readUIntLE(e,this.span)}encode(t,e,n=0){return Te(e).writeUIntLE(t,n,this.span),this.span}}j.UInt=Ur;class zr extends Le{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Te(t).readUIntBE(e,this.span)}encode(t,e,n=0){return Te(e).writeUIntBE(t,n,this.span),this.span}}j.UIntBE=zr;class _n extends Le{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Te(t).readIntLE(e,this.span)}encode(t,e,n=0){return Te(e).writeIntLE(t,n,this.span),this.span}}j.Int=_n;class jn extends Le{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Te(t).readIntBE(e,this.span)}encode(t,e,n=0){return Te(e).writeIntBE(t,n,this.span),this.span}}j.IntBE=jn;const Fo=Math.pow(2,32);function Oi(o){const t=Math.floor(o/Fo),e=o-t*Fo;return{hi32:t,lo32:e}}function Ni(o,t){return o*Fo+t}class ma extends Le{constructor(t){super(8,t)}decode(t,e=0){const n=Te(t),a=n.readUInt32LE(e),s=n.readUInt32LE(e+4);return Ni(s,a)}encode(t,e,n=0){const a=Oi(t),s=Te(e);return s.writeUInt32LE(a.lo32,n),s.writeUInt32LE(a.hi32,n+4),8}}j.NearUInt64=ma;class wa extends Le{constructor(t){super(8,t)}decode(t,e=0){const n=Te(t),a=n.readUInt32BE(e),s=n.readUInt32BE(e+4);return Ni(a,s)}encode(t,e,n=0){const a=Oi(t),s=Te(e);return s.writeUInt32BE(a.hi32,n),s.writeUInt32BE(a.lo32,n+4),8}}j.NearUInt64BE=wa;class ba extends Le{constructor(t){super(8,t)}decode(t,e=0){const n=Te(t),a=n.readUInt32LE(e),s=n.readInt32LE(e+4);return Ni(s,a)}encode(t,e,n=0){const a=Oi(t),s=Te(e);return s.writeUInt32LE(a.lo32,n),s.writeInt32LE(a.hi32,n+4),8}}j.NearInt64=ba;class xa extends Le{constructor(t){super(8,t)}decode(t,e=0){const n=Te(t),a=n.readInt32BE(e),s=n.readUInt32BE(e+4);return Ni(a,s)}encode(t,e,n=0){const a=Oi(t),s=Te(e);return s.writeInt32BE(a.hi32,n),s.writeUInt32BE(a.lo32,n+4),8}}j.NearInt64BE=xa;class Ea extends Le{constructor(t){super(4,t)}decode(t,e=0){return Te(t).readFloatLE(e)}encode(t,e,n=0){return Te(e).writeFloatLE(t,n),4}}j.Float=Ea;class ka extends Le{constructor(t){super(4,t)}decode(t,e=0){return Te(t).readFloatBE(e)}encode(t,e,n=0){return Te(e).writeFloatBE(t,n),4}}j.FloatBE=ka;class Sa extends Le{constructor(t){super(8,t)}decode(t,e=0){return Te(t).readDoubleLE(e)}encode(t,e,n=0){return Te(e).writeDoubleLE(t,n),8}}j.Double=Sa;class Ia extends Le{constructor(t){super(8,t)}decode(t,e=0){return Te(t).readDoubleBE(e)}encode(t,e,n=0){return Te(e).writeDoubleBE(t,n),8}}j.DoubleBE=Ia;class Ba extends Le{constructor(t,e,n){if(!(t instanceof Le))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof _r&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let a=-1;!(e instanceof _r)&&0<t.span&&(a=e*t.span),super(a,n),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0,a=this.count;if(a instanceof _r&&(a=a.decode(t,e)),0<this.elementLayout.span)n=a*this.elementLayout.span;else{let s=0;for(;s<a;)n+=this.elementLayout.getSpan(t,e+n),++s}return n}decode(t,e=0){const n=[];let a=0,s=this.count;for(s instanceof _r&&(s=s.decode(t,e));a<s;)n.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),a+=1;return n}encode(t,e,n=0){const a=this.elementLayout,s=t.reduce((f,u)=>f+a.encode(u,e,n+f),0);return this.count instanceof _r&&this.count.encode(t.length,e,n),s}}j.Sequence=Ba;class _a extends Le{constructor(t,e,n){if(!(Array.isArray(t)&&t.reduce((s,f)=>s&&f instanceof Le,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&n===void 0&&(n=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let a=-1;try{a=t.reduce((s,f)=>s+f.getSpan(),0)}catch{}super(a,e),this.fields=t,this.decodePrefixes=!!n}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((a,s)=>{const f=s.getSpan(t,e);return e+=f,a+f},0)}catch{throw new RangeError("indeterminate span")}return n}decode(t,e=0){Vn(t);const n=this.makeDestinationObject();for(const a of this.fields)if(a.property!==void 0&&(n[a.property]=a.decode(t,e)),e+=a.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return n}encode(t,e,n=0){const a=n;let s=0,f=0;for(const u of this.fields){let y=u.span;if(f=0<y?y:0,u.property!==void 0){const x=t[u.property];x!==void 0&&(f=u.encode(x,e,n),0>y&&(y=u.getSpan(e,n)))}s=n,n+=y}return s+f-a}fromArray(t){const e=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<t.length&&(e[n.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const n of this.fields){if(n.property===t)return e;0>n.span?e=-1:0<=e&&(e+=n.span)}}}j.Structure=_a;class Oo{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,n){throw new Error("UnionDiscriminator is abstract")}}j.UnionDiscriminator=Oo;class zi extends Oo{constructor(t,e){if(!(t instanceof _r&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,n){return this.layout.encode(t,e,n)}}j.UnionLayoutDiscriminator=zi;class No extends Le{constructor(t,e,n){let a;if(t instanceof Ur||t instanceof zr)a=new zi(new Lo(t));else if(t instanceof _r&&t.isCount())a=new zi(t);else if(t instanceof Oo)a=t;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Le))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&(t instanceof Ur||t instanceof zr)&&(s+=a.layout.span)),super(s,n),this.discriminator=a,this.usesPrefixDiscriminator=t instanceof Ur||t instanceof zr,this.defaultLayout=e,this.registry={};let f=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(u){return f(u)},this.configGetSourceVariant=function(u){f=u.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const n=this.getVariant(t,e);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const n=this.registry[e];if(n.property&&Object.prototype.hasOwnProperty.call(t,n.property))return n}throw new Error("unable to infer src variant")}decode(t,e=0){let n;const a=this.discriminator,s=a.decode(t,e),f=this.registry[s];if(f===void 0){const u=this.defaultLayout;let y=0;this.usesPrefixDiscriminator&&(y=a.layout.span),n=this.makeDestinationObject(),n[a.property]=s,n[u.property]=u.decode(t,e+y)}else n=f.decode(t,e);return n}encode(t,e,n=0){const a=this.getSourceVariant(t);if(a===void 0){const s=this.discriminator,f=this.defaultLayout;let u=0;return this.usesPrefixDiscriminator&&(u=s.layout.span),s.encode(t[s.property],e,n),u+f.encode(t[f.property],e,n+u)}return a.encode(t,e,n)}addVariant(t,e,n){const a=new va(this,t,e,n);return this.registry[t]=a,a}getVariant(t,e=0){let n;return t instanceof Uint8Array?n=this.discriminator.decode(t,e):n=t,this.registry[n]}}j.Union=No;class va extends Le{constructor(t,e,n,a){if(!(t instanceof No))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&a===void 0&&(a=n,n=null),n){if(!(n instanceof Le))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=n.span&&n.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof a!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=n?n.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,a),this.union=t,this.variant=e,this.layout=n||null}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let a=0;return this.layout&&(a=this.layout.getSpan(t,e+n)),n+a}decode(t,e=0){const n=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let a=0;return this.union.usesPrefixDiscriminator&&(a=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(t,e+a):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(t,e,n=0){let a=0;if(this.union.usesPrefixDiscriminator&&(a=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,n);let s=a;if(this.layout&&(this.layout.encode(t[this.property],e,n+a),s+=this.layout.getSpan(e,n+a),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}j.VariantLayout=va;function Gn(o){return 0>o&&(o+=4294967296),o}class zo extends Le{constructor(t,e,n){if(!(t instanceof Ur||t instanceof zr))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&n===void 0&&(n=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,n),this.word=t,this.msb=!!e,this.fields=[];let a=0;this._packedSetValue=function(s){return a=Gn(s),this},this._packedGetValue=function(){return a}}decode(t,e=0){const n=this.makeDestinationObject(),a=this.word.decode(t,e);this._packedSetValue(a);for(const s of this.fields)s.property!==void 0&&(n[s.property]=s.decode(t));return n}encode(t,e,n=0){const a=this.word.decode(e,n);this._packedSetValue(a);for(const s of this.fields)if(s.property!==void 0){const f=t[s.property];f!==void 0&&s.encode(f)}return this.word.encode(this._packedGetValue(),e,n)}addField(t,e){const n=new Do(this,t,e);return this.fields.push(n),n}addBoolean(t){const e=new Aa(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}j.BitStructure=zo;class Do{constructor(t,e,n){if(!(t instanceof zo))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const a=8*t.span,s=t.fields.reduce((f,u)=>f+u.bits,0);if(e+s>a)throw new Error("bits too long for span remainder ("+(a-s)+" of "+a+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=a-s-e),this.wordMask=Gn(this.valueMask<<this.start),this.property=n}decode(t,e){const n=this.container._packedGetValue();return Gn(n&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==Gn(t&this.valueMask))throw new TypeError(Uo("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),n=Gn(t<<this.start);this.container._packedSetValue(Gn(e&~this.wordMask)|n)}}j.BitField=Do;let Aa=class extends Do{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){typeof t=="boolean"&&(t=+t),super.encode(t)}};j.Boolean=Aa;class Ra extends Le{constructor(t,e){if(!(t instanceof _r&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;t instanceof _r||(n=t),super(n,e),this.length=t}getSpan(t,e){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),n}decode(t,e=0){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),Te(t).slice(e,e+n)}encode(t,e,n){let a=this.length;if(this.length instanceof _r&&(a=t.length),!(t instanceof Uint8Array&&a===t.length))throw new TypeError(Uo("Blob.encode",this)+" requires (length "+a+") Uint8Array as src");if(n+a>e.length)throw new RangeError("encoding overruns Uint8Array");const s=Te(t);return Te(e).write(s.toString("hex"),n,a,"hex"),this.length instanceof _r&&this.length.encode(a,e,n),a}}j.Blob=Ra;class Ta extends Le{constructor(t){super(-1,t)}getSpan(t,e=0){Vn(t);let n=e;for(;n<t.length&&t[n]!==0;)n+=1;return 1+n-e}decode(t,e=0){const n=this.getSpan(t,e);return Te(t).slice(e,e+n-1).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));const a=Po.Buffer.from(t,"utf8"),s=a.length;if(n+s>e.length)throw new RangeError("encoding overruns Buffer");const f=Te(e);return a.copy(f,n),f[n+s]=0,s+1}}j.CString=Ta;class Ma extends Le{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return Vn(t),t.length-e}decode(t,e=0){const n=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return Te(t).slice(e,e+n).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));const a=Po.Buffer.from(t,"utf8"),s=a.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(n+s>e.length)throw new RangeError("encoding overruns Buffer");return a.copy(Te(e),n),s}}j.UTF8=Ma;class Ca extends Le{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,n){return 0}}j.Constant=Ca,j.greedy=(o,t)=>new ga(o,t);var pn=j.offset=(o,t,e)=>new Lo(o,t,e),_e=j.u8=o=>new Ur(1,o),Lr=j.u16=o=>new Ur(2,o);j.u24=o=>new Ur(3,o);var Ct=j.u32=o=>new Ur(4,o);j.u40=o=>new Ur(5,o),j.u48=o=>new Ur(6,o);var dr=j.nu64=o=>new ma(o);j.u16be=o=>new zr(2,o),j.u24be=o=>new zr(3,o),j.u32be=o=>new zr(4,o),j.u40be=o=>new zr(5,o),j.u48be=o=>new zr(6,o),j.nu64be=o=>new wa(o),j.s8=o=>new _n(1,o),j.s16=o=>new _n(2,o),j.s24=o=>new _n(3,o),j.s32=o=>new _n(4,o),j.s40=o=>new _n(5,o),j.s48=o=>new _n(6,o);var Mr=j.ns64=o=>new ba(o);j.s16be=o=>new jn(2,o),j.s24be=o=>new jn(3,o),j.s32be=o=>new jn(4,o),j.s40be=o=>new jn(5,o),j.s48be=o=>new jn(6,o),j.ns64be=o=>new xa(o),j.f32=o=>new Ea(o),j.f32be=o=>new ka(o),j.f64=o=>new Sa(o),j.f64be=o=>new Ia(o);var Pt=j.struct=(o,t,e)=>new _a(o,t,e);j.bits=(o,t,e)=>new zo(o,t,e);var pr=j.seq=(o,t,e)=>new Ba(o,t,e);j.union=(o,t,e)=>new No(o,t,e),j.unionLayoutDiscriminator=(o,t)=>new zi(o,t);var Ke=j.blob=(o,t)=>new Ra(o,t);j.cstr=o=>new Ta(o),j.utf8=(o,t)=>new Ma(o,t),j.constant=(o,t)=>new Ca(o,t);var ui={};Object.defineProperty(ui,"__esModule",{value:!0});function Ff(o){{const t=Buffer.from(o);t.reverse();const e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}var Of=ui.toBigIntLE=Ff;function Nf(o){{const t=o.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}ui.toBigIntBE=Nf;function zf(o,t){{const e=o.toString(16),n=Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return n.reverse(),n}}var Pa=ui.toBufferLE=zf;function Df(o,t){{const e=o.toString(16);return Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}}ui.toBufferBE=Df;class $f extends TypeError{constructor(t,e){let n;const{message:a,explanation:s,...f}=t,{path:u}=t,y=u.length===0?a:`At path: ${u.join(".")} -- ${a}`;super(s??y),s!=null&&(this.cause=y),Object.assign(this,f),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...e()])}}function Kf(o){return fi(o)&&typeof o[Symbol.iterator]=="function"}function fi(o){return typeof o=="object"&&o!=null}function Di(o){return fi(o)&&!Array.isArray(o)}function Dr(o){return typeof o=="symbol"?o.toString():typeof o=="string"?JSON.stringify(o):`${o}`}function Wf(o){const{done:t,value:e}=o.next();return t?void 0:e}function qf(o,t,e,n){if(o===!0)return;o===!1?o={}:typeof o=="string"&&(o={message:o});const{path:a,branch:s}=t,{type:f}=e,{refinement:u,message:y=`Expected a value of type \`${f}\`${u?` with refinement \`${u}\``:""}, but received: \`${Dr(n)}\``}=o;return{value:n,type:f,refinement:u,key:a[a.length-1],path:a,branch:s,...o,message:y}}function*Ua(o,t,e,n){Kf(o)||(o=[o]);for(const a of o){const s=qf(a,t,e,n);s&&(yield s)}}function*$o(o,t,e={}){const{path:n=[],branch:a=[o],coerce:s=!1,mask:f=!1}=e,u={path:n,branch:a,mask:f};s&&(o=t.coercer(o,u));let y="valid";for(const x of t.validator(o,u))x.explanation=e.message,y="not_valid",yield[x,void 0];for(let[x,B,v]of t.entries(o,u)){const F=$o(B,v,{path:x===void 0?n:[...n,x],branch:x===void 0?a:[...a,B],coerce:s,mask:f,message:e.message});for(const L of F)L[0]?(y=L[0].refinement!=null?"not_refined":"not_valid",yield[L[0],void 0]):s&&(B=L[1],x===void 0?o=B:o instanceof Map?o.set(x,B):o instanceof Set?o.add(B):fi(o)&&(B!==void 0||x in o)&&(o[x]=B))}if(y!=="not_valid")for(const x of t.refiner(o,u))x.explanation=e.message,y="not_refined",yield[x,void 0];y==="valid"&&(yield[void 0,o])}let Gr=class{constructor(t){const{type:e,schema:n,validator:a,refiner:s,coercer:f=y=>y,entries:u=function*(){}}=t;this.type=e,this.schema=n,this.entries=u,this.coercer=f,a?this.validator=(y,x)=>{const B=a(y,x);return Ua(B,x,this,y)}:this.validator=()=>[],s?this.refiner=(y,x)=>{const B=s(y,x);return Ua(B,x,this,y)}:this.refiner=()=>[]}assert(t,e){return La(t,this,e)}create(t,e){return xt(t,this,e)}is(t){return Fa(t,this)}mask(t,e){return Hf(t,this,e)}validate(t,e={}){return hi(t,this,e)}};function La(o,t,e){const n=hi(o,t,{message:e});if(n[0])throw n[0]}function xt(o,t,e){const n=hi(o,t,{coerce:!0,message:e});if(n[0])throw n[0];return n[1]}function Hf(o,t,e){const n=hi(o,t,{coerce:!0,mask:!0,message:e});if(n[0])throw n[0];return n[1]}function Fa(o,t){return!hi(o,t)[0]}function hi(o,t,e={}){const n=$o(o,t,e),a=Wf(n);return a[0]?[new $f(a[0],function*(){for(const f of n)f[0]&&(yield f[0])}),void 0]:[void 0,a[1]]}function vn(o,t){return new Gr({type:o,schema:null,validator:t})}function Vf(){return vn("any",()=>!0)}function St(o){return new Gr({type:"array",schema:o,*entries(t){if(o&&Array.isArray(t))for(const[e,n]of t.entries())yield[e,n,o]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${Dr(t)}`}})}function Yr(){return vn("boolean",o=>typeof o=="boolean")}function Ko(o){return vn("instance",t=>t instanceof o||`Expected a \`${o.name}\` instance, but received: ${Dr(t)}`)}function je(o){const t=Dr(o),e=typeof o;return new Gr({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?o:null,validator(n){return n===o||`Expected the literal \`${t}\`, but received: ${Dr(n)}`}})}function jf(){return vn("never",()=>!1)}function It(o){return new Gr({...o,validator:(t,e)=>t===null||o.validator(t,e),refiner:(t,e)=>t===null||o.refiner(t,e)})}function H(){return vn("number",o=>typeof o=="number"&&!isNaN(o)||`Expected a number, but received: ${Dr(o)}`)}function $t(o){return new Gr({...o,validator:(t,e)=>t===void 0||o.validator(t,e),refiner:(t,e)=>t===void 0||o.refiner(t,e)})}function Oa(o,t){return new Gr({type:"record",schema:null,*entries(e){if(fi(e))for(const n in e){const a=e[n];yield[n,n,o],yield[n,a,t]}},validator(e){return Di(e)||`Expected an object, but received: ${Dr(e)}`},coercer(e){return Di(e)?{...e}:e}})}function mt(){return vn("string",o=>typeof o=="string"||`Expected a string, but received: ${Dr(o)}`)}function Wo(o){const t=jf();return new Gr({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const n=Math.max(o.length,e.length);for(let a=0;a<n;a++)yield[a,e[a],o[a]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Dr(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function ut(o){const t=Object.keys(o);return new Gr({type:"type",schema:o,*entries(e){if(fi(e))for(const n of t)yield[n,e[n],o[n]]},validator(e){return Di(e)||`Expected an object, but received: ${Dr(e)}`},coercer(e){return Di(e)?{...e}:e}})}function Br(o){const t=o.map(e=>e.type).join(" | ");return new Gr({type:"union",schema:null,coercer(e,n){for(const a of o){const[s,f]=a.validate(e,{coerce:!0,mask:n.mask});if(!s)return f}return e},validator(e,n){const a=[];for(const s of o){const[...f]=$o(e,s,n),[u]=f;if(u[0])for(const[y]of f)y&&a.push(y);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Dr(e)}`,...a]}})}function Yn(){return vn("unknown",()=>!0)}function li(o,t,e){return new Gr({...o,coercer:(n,a)=>Fa(n,t)?o.coercer(e(n,a),a):o.coercer(n,a)})}var $i,Gf=new Uint8Array(16);function Na(){if(!$i&&($i=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!$i))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return $i(Gf)}const Yf=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Ki(o){return typeof o=="string"&&Yf.test(o)}for(var yr=[],qo=0;qo<256;++qo)yr.push((qo+256).toString(16).substr(1));function Wi(o){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(yr[o[t+0]]+yr[o[t+1]]+yr[o[t+2]]+yr[o[t+3]]+"-"+yr[o[t+4]]+yr[o[t+5]]+"-"+yr[o[t+6]]+yr[o[t+7]]+"-"+yr[o[t+8]]+yr[o[t+9]]+"-"+yr[o[t+10]]+yr[o[t+11]]+yr[o[t+12]]+yr[o[t+13]]+yr[o[t+14]]+yr[o[t+15]]).toLowerCase();if(!Ki(e))throw TypeError("Stringified UUID is invalid");return e}var za,Ho,Vo=0,jo=0;function Zf(o,t,e){var n=t&&e||0,a=t||new Array(16);o=o||{};var s=o.node||za,f=o.clockseq!==void 0?o.clockseq:Ho;if(s==null||f==null){var u=o.random||(o.rng||Na)();s==null&&(s=za=[u[0]|1,u[1],u[2],u[3],u[4],u[5]]),f==null&&(f=Ho=(u[6]<<8|u[7])&16383)}var y=o.msecs!==void 0?o.msecs:Date.now(),x=o.nsecs!==void 0?o.nsecs:jo+1,B=y-Vo+(x-jo)/1e4;if(B<0&&o.clockseq===void 0&&(f=f+1&16383),(B<0||y>Vo)&&o.nsecs===void 0&&(x=0),x>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Vo=y,jo=x,Ho=f,y+=122192928e5;var v=((y&268435455)*1e4+x)%4294967296;a[n++]=v>>>24&255,a[n++]=v>>>16&255,a[n++]=v>>>8&255,a[n++]=v&255;var F=y/4294967296*1e4&268435455;a[n++]=F>>>8&255,a[n++]=F&255,a[n++]=F>>>24&15|16,a[n++]=F>>>16&255,a[n++]=f>>>8|128,a[n++]=f&255;for(var L=0;L<6;++L)a[n+L]=s[L];return t||Wi(a)}function Da(o){if(!Ki(o))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(o.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(o.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(o.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(o.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(o.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}function Jf(o){o=unescape(encodeURIComponent(o));for(var t=[],e=0;e<o.length;++e)t.push(o.charCodeAt(e));return t}var Xf="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Qf="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function $a(o,t,e){function n(a,s,f,u){if(typeof a=="string"&&(a=Jf(a)),typeof s=="string"&&(s=Da(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var y=new Uint8Array(16+a.length);if(y.set(s),y.set(a,s.length),y=e(y),y[6]=y[6]&15|t,y[8]=y[8]&63|128,f){u=u||0;for(var x=0;x<16;++x)f[u+x]=y[x];return f}return Wi(y)}try{n.name=o}catch{}return n.DNS=Xf,n.URL=Qf,n}function th(o){if(typeof o=="string"){var t=unescape(encodeURIComponent(o));o=new Uint8Array(t.length);for(var e=0;e<t.length;++e)o[e]=t.charCodeAt(e)}return eh(rh(nh(o),o.length*8))}function eh(o){for(var t=[],e=o.length*32,n="0123456789abcdef",a=0;a<e;a+=8){var s=o[a>>5]>>>a%32&255,f=parseInt(n.charAt(s>>>4&15)+n.charAt(s&15),16);t.push(f)}return t}function Ka(o){return(o+64>>>9<<4)+14+1}function rh(o,t){o[t>>5]|=128<<t%32,o[Ka(t)-1]=t;for(var e=1732584193,n=-271733879,a=-1732584194,s=271733878,f=0;f<o.length;f+=16){var u=e,y=n,x=a,B=s;e=gr(e,n,a,s,o[f],7,-680876936),s=gr(s,e,n,a,o[f+1],12,-389564586),a=gr(a,s,e,n,o[f+2],17,606105819),n=gr(n,a,s,e,o[f+3],22,-1044525330),e=gr(e,n,a,s,o[f+4],7,-176418897),s=gr(s,e,n,a,o[f+5],12,1200080426),a=gr(a,s,e,n,o[f+6],17,-1473231341),n=gr(n,a,s,e,o[f+7],22,-45705983),e=gr(e,n,a,s,o[f+8],7,1770035416),s=gr(s,e,n,a,o[f+9],12,-1958414417),a=gr(a,s,e,n,o[f+10],17,-42063),n=gr(n,a,s,e,o[f+11],22,-1990404162),e=gr(e,n,a,s,o[f+12],7,1804603682),s=gr(s,e,n,a,o[f+13],12,-40341101),a=gr(a,s,e,n,o[f+14],17,-1502002290),n=gr(n,a,s,e,o[f+15],22,1236535329),e=mr(e,n,a,s,o[f+1],5,-165796510),s=mr(s,e,n,a,o[f+6],9,-1069501632),a=mr(a,s,e,n,o[f+11],14,643717713),n=mr(n,a,s,e,o[f],20,-373897302),e=mr(e,n,a,s,o[f+5],5,-701558691),s=mr(s,e,n,a,o[f+10],9,38016083),a=mr(a,s,e,n,o[f+15],14,-660478335),n=mr(n,a,s,e,o[f+4],20,-405537848),e=mr(e,n,a,s,o[f+9],5,568446438),s=mr(s,e,n,a,o[f+14],9,-1019803690),a=mr(a,s,e,n,o[f+3],14,-187363961),n=mr(n,a,s,e,o[f+8],20,1163531501),e=mr(e,n,a,s,o[f+13],5,-1444681467),s=mr(s,e,n,a,o[f+2],9,-51403784),a=mr(a,s,e,n,o[f+7],14,1735328473),n=mr(n,a,s,e,o[f+12],20,-1926607734),e=wr(e,n,a,s,o[f+5],4,-378558),s=wr(s,e,n,a,o[f+8],11,-2022574463),a=wr(a,s,e,n,o[f+11],16,1839030562),n=wr(n,a,s,e,o[f+14],23,-35309556),e=wr(e,n,a,s,o[f+1],4,-1530992060),s=wr(s,e,n,a,o[f+4],11,1272893353),a=wr(a,s,e,n,o[f+7],16,-155497632),n=wr(n,a,s,e,o[f+10],23,-1094730640),e=wr(e,n,a,s,o[f+13],4,681279174),s=wr(s,e,n,a,o[f],11,-358537222),a=wr(a,s,e,n,o[f+3],16,-722521979),n=wr(n,a,s,e,o[f+6],23,76029189),e=wr(e,n,a,s,o[f+9],4,-640364487),s=wr(s,e,n,a,o[f+12],11,-421815835),a=wr(a,s,e,n,o[f+15],16,530742520),n=wr(n,a,s,e,o[f+2],23,-995338651),e=br(e,n,a,s,o[f],6,-198630844),s=br(s,e,n,a,o[f+7],10,1126891415),a=br(a,s,e,n,o[f+14],15,-1416354905),n=br(n,a,s,e,o[f+5],21,-57434055),e=br(e,n,a,s,o[f+12],6,1700485571),s=br(s,e,n,a,o[f+3],10,-1894986606),a=br(a,s,e,n,o[f+10],15,-1051523),n=br(n,a,s,e,o[f+1],21,-2054922799),e=br(e,n,a,s,o[f+8],6,1873313359),s=br(s,e,n,a,o[f+15],10,-30611744),a=br(a,s,e,n,o[f+6],15,-1560198380),n=br(n,a,s,e,o[f+13],21,1309151649),e=br(e,n,a,s,o[f+4],6,-145523070),s=br(s,e,n,a,o[f+11],10,-1120210379),a=br(a,s,e,n,o[f+2],15,718787259),n=br(n,a,s,e,o[f+9],21,-343485551),e=yn(e,u),n=yn(n,y),a=yn(a,x),s=yn(s,B)}return[e,n,a,s]}function nh(o){if(o.length===0)return[];for(var t=o.length*8,e=new Uint32Array(Ka(t)),n=0;n<t;n+=8)e[n>>5]|=(o[n/8]&255)<<n%32;return e}function yn(o,t){var e=(o&65535)+(t&65535),n=(o>>16)+(t>>16)+(e>>16);return n<<16|e&65535}function ih(o,t){return o<<t|o>>>32-t}function qi(o,t,e,n,a,s){return yn(ih(yn(yn(t,o),yn(n,s)),a),e)}function gr(o,t,e,n,a,s,f){return qi(t&e|~t&n,o,t,a,s,f)}function mr(o,t,e,n,a,s,f){return qi(t&n|e&~n,o,t,a,s,f)}function wr(o,t,e,n,a,s,f){return qi(t^e^n,o,t,a,s,f)}function br(o,t,e,n,a,s,f){return qi(e^(t|~n),o,t,a,s,f)}var oh=$a("v3",48,th);const sh=oh;function ah(o,t,e){o=o||{};var n=o.random||(o.rng||Na)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){e=e||0;for(var a=0;a<16;++a)t[e+a]=n[a];return t}return Wi(n)}function ch(o,t,e,n){switch(o){case 0:return t&e^~t&n;case 1:return t^e^n;case 2:return t&e^t&n^e&n;case 3:return t^e^n}}function Go(o,t){return o<<t|o>>>32-t}function uh(o){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof o=="string"){var n=unescape(encodeURIComponent(o));o=[];for(var a=0;a<n.length;++a)o.push(n.charCodeAt(a))}else Array.isArray(o)||(o=Array.prototype.slice.call(o));o.push(128);for(var s=o.length/4+2,f=Math.ceil(s/16),u=new Array(f),y=0;y<f;++y){for(var x=new Uint32Array(16),B=0;B<16;++B)x[B]=o[y*64+B*4]<<24|o[y*64+B*4+1]<<16|o[y*64+B*4+2]<<8|o[y*64+B*4+3];u[y]=x}u[f-1][14]=(o.length-1)*8/Math.pow(2,32),u[f-1][14]=Math.floor(u[f-1][14]),u[f-1][15]=(o.length-1)*8&4294967295;for(var v=0;v<f;++v){for(var F=new Uint32Array(80),L=0;L<16;++L)F[L]=u[v][L];for(var D=16;D<80;++D)F[D]=Go(F[D-3]^F[D-8]^F[D-14]^F[D-16],1);for(var U=e[0],z=e[1],$=e[2],X=e[3],V=e[4],it=0;it<80;++it){var G=Math.floor(it/20),W=Go(U,5)+ch(G,z,$,X)+V+t[G]+F[it]>>>0;V=X,X=$,$=Go(z,30)>>>0,z=U,U=W}e[0]=e[0]+U>>>0,e[1]=e[1]+z>>>0,e[2]=e[2]+$>>>0,e[3]=e[3]+X>>>0,e[4]=e[4]+V>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var fh=$a("v5",80,uh);const hh=fh,lh="00000000-0000-0000-0000-000000000000";function dh(o){if(!Ki(o))throw TypeError("Invalid UUID");return parseInt(o.substr(14,1),16)}const Wa=fo(Object.freeze(Object.defineProperty({__proto__:null,NIL:lh,parse:Da,stringify:Wi,v1:Zf,v3:sh,v4:ah,v5:hh,validate:Ki,version:dh},Symbol.toStringTag,{value:"Module"}))),ph=Wa.v4;var yh=function(o,t,e,n){if(typeof o!="string")throw new TypeError(o+" must be a string");n=n||{};const a=typeof n.version=="number"?n.version:2;if(a!==1&&a!==2)throw new TypeError(a+" must be 1 or 2");const s={method:o};if(a===2&&(s.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");s.params=t}if(typeof e>"u"){const f=typeof n.generator=="function"?n.generator:function(){return ph()};s.id=f(s,n)}else a===2&&e===null?n.notificationIdNull&&(s.id=null):s.id=e;return s};const gh=Wa.v4,mh=yh,di=function(o,t){if(!(this instanceof di))return new di(o,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return gh()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=o};var wh=di;di.prototype.request=function(o,t,e,n){const a=this;let s=null;const f=Array.isArray(o)&&typeof t=="function";if(this.options.version===1&&f)throw new TypeError("JSON-RPC 1.0 does not support batching");if(f||!f&&o&&typeof o=="object"&&typeof t=="function")n=t,s=o;else{typeof e=="function"&&(n=e,e=void 0);const x=typeof n=="function";try{s=mh(o,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(B){if(x)return n(B);throw B}if(!x)return s}let y;try{y=JSON.stringify(s,this.options.replacer)}catch(x){return n(x)}return this.callServer(y,function(x,B){a._parseResponse(x,B,n)}),s},di.prototype._parseResponse=function(o,t,e){if(o){e(o);return}if(!t)return e();let n;try{n=JSON.parse(t,this.options.reviver)}catch(a){return e(a)}if(e.length===3)if(Array.isArray(n)){const a=function(f){return typeof f.error<"u"},s=function(f){return!a(f)};return e(null,n.filter(a),n.filter(s))}else return e(null,n.error,n.result);e(null,n)};const bh=ii(wh);var qa={exports:{}};(function(o){var t=Object.prototype.hasOwnProperty,e="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(e=!1));function a(y,x,B){this.fn=y,this.context=x,this.once=B||!1}function s(y,x,B,v,F){if(typeof B!="function")throw new TypeError("The listener must be a function");var L=new a(B,v||y,F),D=e?e+x:x;return y._events[D]?y._events[D].fn?y._events[D]=[y._events[D],L]:y._events[D].push(L):(y._events[D]=L,y._eventsCount++),y}function f(y,x){--y._eventsCount===0?y._events=new n:delete y._events[x]}function u(){this._events=new n,this._eventsCount=0}u.prototype.eventNames=function(){var x=[],B,v;if(this._eventsCount===0)return x;for(v in B=this._events)t.call(B,v)&&x.push(e?v.slice(1):v);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(B)):x},u.prototype.listeners=function(x){var B=e?e+x:x,v=this._events[B];if(!v)return[];if(v.fn)return[v.fn];for(var F=0,L=v.length,D=new Array(L);F<L;F++)D[F]=v[F].fn;return D},u.prototype.listenerCount=function(x){var B=e?e+x:x,v=this._events[B];return v?v.fn?1:v.length:0},u.prototype.emit=function(x,B,v,F,L,D){var U=e?e+x:x;if(!this._events[U])return!1;var z=this._events[U],$=arguments.length,X,V;if(z.fn){switch(z.once&&this.removeListener(x,z.fn,void 0,!0),$){case 1:return z.fn.call(z.context),!0;case 2:return z.fn.call(z.context,B),!0;case 3:return z.fn.call(z.context,B,v),!0;case 4:return z.fn.call(z.context,B,v,F),!0;case 5:return z.fn.call(z.context,B,v,F,L),!0;case 6:return z.fn.call(z.context,B,v,F,L,D),!0}for(V=1,X=new Array($-1);V<$;V++)X[V-1]=arguments[V];z.fn.apply(z.context,X)}else{var it=z.length,G;for(V=0;V<it;V++)switch(z[V].once&&this.removeListener(x,z[V].fn,void 0,!0),$){case 1:z[V].fn.call(z[V].context);break;case 2:z[V].fn.call(z[V].context,B);break;case 3:z[V].fn.call(z[V].context,B,v);break;case 4:z[V].fn.call(z[V].context,B,v,F);break;default:if(!X)for(G=1,X=new Array($-1);G<$;G++)X[G-1]=arguments[G];z[V].fn.apply(z[V].context,X)}}return!0},u.prototype.on=function(x,B,v){return s(this,x,B,v,!1)},u.prototype.once=function(x,B,v){return s(this,x,B,v,!0)},u.prototype.removeListener=function(x,B,v,F){var L=e?e+x:x;if(!this._events[L])return this;if(!B)return f(this,L),this;var D=this._events[L];if(D.fn)D.fn===B&&(!F||D.once)&&(!v||D.context===v)&&f(this,L);else{for(var U=0,z=[],$=D.length;U<$;U++)(D[U].fn!==B||F&&!D[U].once||v&&D[U].context!==v)&&z.push(D[U]);z.length?this._events[L]=z.length===1?z[0]:z:f(this,L)}return this},u.prototype.removeAllListeners=function(x){var B;return x?(B=e?e+x:x,this._events[B]&&f(this,B)):(this._events=new n,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=e,u.EventEmitter=u,o.exports=u})(qa);var xh=qa.exports;const Ha=ii(xh);var Eh=class extends Ha{constructor(t,e,n){super();ir(this,"socket");this.socket=new window.WebSocket(t,n),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=a=>this.emit("message",a.data),this.socket.onerror=a=>this.emit("error",a),this.socket.onclose=a=>{this.emit("close",a.code,a.reason)}}send(t,e,n){const a=n||e;try{this.socket.send(t),a()}catch(s){a(s)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,n){this.socket.addEventListener(t,e,n)}};function kh(o,t){return new Eh(o,t)}var Sh=class{encode(o){return JSON.stringify(o)}decode(o){return JSON.parse(o)}},Ih=class extends Ha{constructor(t,e="ws://localhost:8080",{autoconnect:n=!0,reconnect:a=!0,reconnect_interval:s=1e3,max_reconnects:f=5,...u}={},y,x){super();ir(this,"address");ir(this,"rpc_id");ir(this,"queue");ir(this,"options");ir(this,"autoconnect");ir(this,"ready");ir(this,"reconnect");ir(this,"reconnect_timer_id");ir(this,"reconnect_interval");ir(this,"max_reconnects");ir(this,"rest_options");ir(this,"current_reconnects");ir(this,"generate_request_id");ir(this,"socket");ir(this,"webSocketFactory");ir(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=n,this.ready=!1,this.reconnect=a,this.reconnect_timer_id=void 0,this.reconnect_interval=s,this.max_reconnects=f,this.rest_options=u,this.current_reconnects=0,this.generate_request_id=y||(()=>++this.rpc_id),x?this.dataPack=x:this.dataPack=new Sh,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(t,e,n,a){return!a&&typeof n=="object"&&(a=n,n=null),new Promise((s,f)=>{if(!this.ready)return f(new Error("socket not ready"));const u=this.generate_request_id(t,e),y={jsonrpc:"2.0",method:t,params:e||void 0,id:u};this.socket.send(this.dataPack.encode(y),a,x=>{if(x)return f(x);this.queue[u]={promise:[s,f]},n&&(this.queue[u].timeout=setTimeout(()=>{delete this.queue[u],f(new Error("reply timeout"))},n))})})}async login(t){const e=await this.call("rpc.login",t);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(t,e){return new Promise((n,a)=>{if(!this.ready)return a(new Error("socket not ready"));const s={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(s),f=>{if(f)return a(f);n()})})}async subscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.on",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed subscribing to an event '"+t+"' with: "+e[t]);return e}async unsubscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.off",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(t,e){this.socket.close(t||1e3,e)}setAutoReconnect(t){this.reconnect=t}setReconnectInterval(t){this.reconnect_interval=t}setMaxReconnects(t){this.max_reconnects=t}_connect(t,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:n})=>{n instanceof ArrayBuffer&&(n=Nt.Buffer.from(n).toString());try{n=this.dataPack.decode(n)}catch{return}if(n.notification&&this.listeners(n.notification).length){if(!Object.keys(n.params).length)return this.emit(n.notification);const a=[n.notification];if(n.params.constructor===Object)a.push(n.params);else for(let s=0;s<n.params.length;s++)a.push(n.params[s]);return Promise.resolve().then(()=>{this.emit.apply(this,a)})}if(!this.queue[n.id])return n.method?Promise.resolve().then(()=>{this.emit(n.method,n==null?void 0:n.params)}):void 0;"error"in n=="result"in n&&this.queue[n.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[n.id].timeout&&clearTimeout(this.queue[n.id].timeout),n.error?this.queue[n.id].promise[1](n.error):this.queue[n.id].promise[0](n.result),delete this.queue[n.id]}),this.socket.addEventListener("error",n=>this.emit("error",n)),this.socket.addEventListener("close",({code:n,reason:a})=>{this.ready&&setTimeout(()=>this.emit("close",n,a),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(t,e),this.reconnect_interval)))})}};const Va=[],ja=[],Ga=[],Bh=BigInt(0),pi=BigInt(1),_h=BigInt(2),vh=BigInt(7),Ah=BigInt(256),Rh=BigInt(113);for(let o=0,t=pi,e=1,n=0;o<24;o++){[e,n]=[n,(2*e+3*n)%5],Va.push(2*(5*n+e)),ja.push((o+1)*(o+2)/2%64);let a=Bh;for(let s=0;s<7;s++)t=(t<<pi^(t>>vh)*Rh)%Ah,t&_h&&(a^=pi<<(pi<<BigInt(s))-pi);Ga.push(a)}const[Th,Mh]=Os(Ga,!0),Ya=(o,t,e)=>e>32?Ds(o,t,e):Ns(o,t,e),Za=(o,t,e)=>e>32?$s(o,t,e):zs(o,t,e);function Ch(o,t=24){const e=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let f=0;f<10;f++)e[f]=o[f]^o[f+10]^o[f+20]^o[f+30]^o[f+40];for(let f=0;f<10;f+=2){const u=(f+8)%10,y=(f+2)%10,x=e[y],B=e[y+1],v=Ya(x,B,1)^e[u],F=Za(x,B,1)^e[u+1];for(let L=0;L<50;L+=10)o[f+L]^=v,o[f+L+1]^=F}let a=o[2],s=o[3];for(let f=0;f<24;f++){const u=ja[f],y=Ya(a,s,u),x=Za(a,s,u),B=Va[f];a=o[B],s=o[B+1],o[B]=y,o[B+1]=x}for(let f=0;f<50;f+=10){for(let u=0;u<10;u++)e[u]=o[f+u];for(let u=0;u<10;u++)o[f+u]^=~e[(u+2)%10]&e[(u+4)%10]}o[0]^=Th[n],o[1]^=Mh[n]}e.fill(0)}class Yo extends yo{constructor(t,e,n,a=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=a,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,_i(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=hu(this.state)}keccak(){Cs||Ps(this.state32),Ch(this.state32,this.rounds),Cs||Ps(this.state32),this.posOut=0,this.pos=0}update(t){zn(this);const{blockLen:e,state:n}=this;t=vi(t);const a=t.length;for(let s=0;s<a;){const f=Math.min(e-this.pos,a-s);for(let u=0;u<f;u++)n[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:a}=this;t[n]^=e,e&128&&n===a-1&&this.keccak(),t[a-1]^=128,this.keccak()}writeInto(t){zn(this,!1),si(t),this.finish();const e=this.state,{blockLen:n}=this;for(let a=0,s=t.length;a<s;){this.posOut>=n&&this.keccak();const f=Math.min(n-this.posOut,s-a);t.set(e.subarray(this.posOut,this.posOut+f),a),this.posOut+=f,a+=f}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return _i(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ms(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:a,rounds:s,enableXOF:f}=this;return t||(t=new Yo(e,n,a,f,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=a,t.enableXOF=f,t.destroyed=this.destroyed,t}}const Ja=((o,t,e)=>go(()=>new Yo(t,o,e)))(1,136,256/8);class Xa extends yo{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,fu(t);const n=vi(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const a=this.blockLen,s=new Uint8Array(a);s.set(n.length>a?t.create().update(n).digest():n);for(let f=0;f<s.length;f++)s[f]^=54;this.iHash.update(s),this.oHash=t.create();for(let f=0;f<s.length;f++)s[f]^=106;this.oHash.update(s),s.fill(0)}update(t){return zn(this),this.iHash.update(t),this}digestInto(t){zn(this),si(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:a,destroyed:s,blockLen:f,outputLen:u}=this;return t=t,t.finished=a,t.destroyed=s,t.blockLen=f,t.outputLen=u,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Qa=(o,t,e)=>new Xa(o,t).update(e).digest();Qa.create=(o,t)=>new Xa(o,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ph(o){const t=Io(o);Wn(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:n,a}=t;if(e){if(!n.eql(a,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:Uh,hexToBytes:Lh}=$u,An={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(o){const{Err:t}=An;if(o.length<2||o[0]!==2)throw new t("Invalid signature integer tag");const e=o[1],n=o.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Uh(n),l:o.subarray(e+2)}},toSig(o){const{Err:t}=An,e=typeof o=="string"?Lh(o):o;ai(e);let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");const{d:a,l:s}=An._parseInt(e.subarray(2)),{d:f,l:u}=An._parseInt(s);if(u.length)throw new t("Invalid signature: left bytes after parsing");return{r:a,s:f}},hexFromSig(o){const t=x=>Number.parseInt(x[0],16)&8?"00"+x:x,e=x=>{const B=x.toString(16);return B.length&1?`0${B}`:B},n=t(e(o.s)),a=t(e(o.r)),s=n.length/2,f=a.length/2,u=e(s),y=e(f);return`30${e(f+s+4)}02${y}${a}02${u}${n}`}},on=BigInt(0),Fr=BigInt(1);BigInt(2);const tc=BigInt(3);BigInt(4);function Fh(o){const t=Ph(o),{Fp:e}=t,n=t.toBytes||((D,U,z)=>{const $=U.toAffine();return kn(Uint8Array.from([4]),e.toBytes($.x),e.toBytes($.y))}),a=t.fromBytes||(D=>{const U=D.subarray(1),z=e.fromBytes(U.subarray(0,e.BYTES)),$=e.fromBytes(U.subarray(e.BYTES,2*e.BYTES));return{x:z,y:$}});function s(D){const{a:U,b:z}=t,$=e.sqr(D),X=e.mul($,D);return e.add(e.add(X,e.mul(D,U)),z)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function f(D){return typeof D=="bigint"&&on<D&&D<t.n}function u(D){if(!f(D))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function y(D){const{allowedPrivateKeyLengths:U,nByteLength:z,wrapPrivateKey:$,n:X}=t;if(U&&typeof D!="bigint"){if(bn(D)&&(D=xn(D)),typeof D!="string"||!U.includes(D.length))throw new Error("Invalid key");D=D.padStart(z*2,"0")}let V;try{V=typeof D=="bigint"?D:En(or("private key",D,z))}catch{throw new Error(`private key must be ${z} bytes, hex or bigint, not ${typeof D}`)}return $&&(V=We(V,X)),u(V),V}const x=new Map;function B(D){if(!(D instanceof v))throw new Error("ProjectivePoint expected")}class v{constructor(U,z,$){if(this.px=U,this.py=z,this.pz=$,U==null||!e.isValid(U))throw new Error("x required");if(z==null||!e.isValid(z))throw new Error("y required");if($==null||!e.isValid($))throw new Error("z required")}static fromAffine(U){const{x:z,y:$}=U||{};if(!U||!e.isValid(z)||!e.isValid($))throw new Error("invalid affine point");if(U instanceof v)throw new Error("projective point not allowed");const X=V=>e.eql(V,e.ZERO);return X(z)&&X($)?v.ZERO:new v(z,$,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(U){const z=e.invertBatch(U.map($=>$.pz));return U.map(($,X)=>$.toAffine(z[X])).map(v.fromAffine)}static fromHex(U){const z=v.fromAffine(a(or("pointHex",U)));return z.assertValidity(),z}static fromPrivateKey(U){return v.BASE.multiply(y(U))}_setWindowSize(U){this._WINDOW_SIZE=U,x.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:U,y:z}=this.toAffine();if(!e.isValid(U)||!e.isValid(z))throw new Error("bad point: x or y not FE");const $=e.sqr(z),X=s(U);if(!e.eql($,X))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:U}=this.toAffine();if(e.isOdd)return!e.isOdd(U);throw new Error("Field doesn't support isOdd")}equals(U){B(U);const{px:z,py:$,pz:X}=this,{px:V,py:it,pz:G}=U,W=e.eql(e.mul(z,G),e.mul(V,X)),Q=e.eql(e.mul($,G),e.mul(it,X));return W&&Q}negate(){return new v(this.px,e.neg(this.py),this.pz)}double(){const{a:U,b:z}=t,$=e.mul(z,tc),{px:X,py:V,pz:it}=this;let G=e.ZERO,W=e.ZERO,Q=e.ZERO,rt=e.mul(X,X),ae=e.mul(V,V),jt=e.mul(it,it),_t=e.mul(X,V);return _t=e.add(_t,_t),Q=e.mul(X,it),Q=e.add(Q,Q),G=e.mul(U,Q),W=e.mul($,jt),W=e.add(G,W),G=e.sub(ae,W),W=e.add(ae,W),W=e.mul(G,W),G=e.mul(_t,G),Q=e.mul($,Q),jt=e.mul(U,jt),_t=e.sub(rt,jt),_t=e.mul(U,_t),_t=e.add(_t,Q),Q=e.add(rt,rt),rt=e.add(Q,rt),rt=e.add(rt,jt),rt=e.mul(rt,_t),W=e.add(W,rt),jt=e.mul(V,it),jt=e.add(jt,jt),rt=e.mul(jt,_t),G=e.sub(G,rt),Q=e.mul(jt,ae),Q=e.add(Q,Q),Q=e.add(Q,Q),new v(G,W,Q)}add(U){B(U);const{px:z,py:$,pz:X}=this,{px:V,py:it,pz:G}=U;let W=e.ZERO,Q=e.ZERO,rt=e.ZERO;const ae=t.a,jt=e.mul(t.b,tc);let _t=e.mul(z,V),re=e.mul($,it),P=e.mul(X,G),d=e.add(z,$),m=e.add(V,it);d=e.mul(d,m),m=e.add(_t,re),d=e.sub(d,m),m=e.add(z,X);let E=e.add(V,G);return m=e.mul(m,E),E=e.add(_t,P),m=e.sub(m,E),E=e.add($,X),W=e.add(it,G),E=e.mul(E,W),W=e.add(re,P),E=e.sub(E,W),rt=e.mul(ae,m),W=e.mul(jt,P),rt=e.add(W,rt),W=e.sub(re,rt),rt=e.add(re,rt),Q=e.mul(W,rt),re=e.add(_t,_t),re=e.add(re,_t),P=e.mul(ae,P),m=e.mul(jt,m),re=e.add(re,P),P=e.sub(_t,P),P=e.mul(ae,P),m=e.add(m,P),_t=e.mul(re,m),Q=e.add(Q,_t),_t=e.mul(E,m),W=e.mul(d,W),W=e.sub(W,_t),_t=e.mul(d,re),rt=e.mul(E,rt),rt=e.add(rt,_t),new v(W,Q,rt)}subtract(U){return this.add(U.negate())}is0(){return this.equals(v.ZERO)}wNAF(U){return L.wNAFCached(this,x,U,z=>{const $=e.invertBatch(z.map(X=>X.pz));return z.map((X,V)=>X.toAffine($[V])).map(v.fromAffine)})}multiplyUnsafe(U){const z=v.ZERO;if(U===on)return z;if(u(U),U===Fr)return this;const{endo:$}=t;if(!$)return L.unsafeLadder(this,U);let{k1neg:X,k1:V,k2neg:it,k2:G}=$.splitScalar(U),W=z,Q=z,rt=this;for(;V>on||G>on;)V&Fr&&(W=W.add(rt)),G&Fr&&(Q=Q.add(rt)),rt=rt.double(),V>>=Fr,G>>=Fr;return X&&(W=W.negate()),it&&(Q=Q.negate()),Q=new v(e.mul(Q.px,$.beta),Q.py,Q.pz),W.add(Q)}multiply(U){u(U);let z=U,$,X;const{endo:V}=t;if(V){const{k1neg:it,k1:G,k2neg:W,k2:Q}=V.splitScalar(z);let{p:rt,f:ae}=this.wNAF(G),{p:jt,f:_t}=this.wNAF(Q);rt=L.constTimeNegate(it,rt),jt=L.constTimeNegate(W,jt),jt=new v(e.mul(jt.px,V.beta),jt.py,jt.pz),$=rt.add(jt),X=ae.add(_t)}else{const{p:it,f:G}=this.wNAF(z);$=it,X=G}return v.normalizeZ([$,X])[0]}multiplyAndAddUnsafe(U,z,$){const X=v.BASE,V=(G,W)=>W===on||W===Fr||!G.equals(X)?G.multiplyUnsafe(W):G.multiply(W),it=V(this,z).add(V(U,$));return it.is0()?void 0:it}toAffine(U){const{px:z,py:$,pz:X}=this,V=this.is0();U==null&&(U=V?e.ONE:e.inv(X));const it=e.mul(z,U),G=e.mul($,U),W=e.mul(X,U);if(V)return{x:e.ZERO,y:e.ZERO};if(!e.eql(W,e.ONE))throw new Error("invZ was invalid");return{x:it,y:G}}isTorsionFree(){const{h:U,isTorsionFree:z}=t;if(U===Fr)return!0;if(z)return z(v,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:U,clearCofactor:z}=t;return U===Fr?this:z?z(v,this):this.multiplyUnsafe(t.h)}toRawBytes(U=!0){return this.assertValidity(),n(v,this,U)}toHex(U=!0){return xn(this.toRawBytes(U))}}v.BASE=new v(t.Gx,t.Gy,e.ONE),v.ZERO=new v(e.ZERO,e.ONE,e.ZERO);const F=t.nBitLength,L=Qs(v,t.endo?Math.ceil(F/2):F);return{CURVE:t,ProjectivePoint:v,normPrivateKeyToScalar:y,weierstrassEquation:s,isWithinCurveOrder:f}}function Oh(o){const t=Io(o);return Wn(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Nh(o){const t=Oh(o),{Fp:e,n}=t,a=e.BYTES+1,s=2*e.BYTES+1;function f(m){return on<m&&m<e.ORDER}function u(m){return We(m,n)}function y(m){return ko(m,n)}const{ProjectivePoint:x,normPrivateKeyToScalar:B,weierstrassEquation:v,isWithinCurveOrder:F}=Fh({...t,toBytes(m,E,C){const R=E.toAffine(),T=e.toBytes(R.x),N=kn;return C?N(Uint8Array.from([E.hasEvenY()?2:3]),T):N(Uint8Array.from([4]),T,e.toBytes(R.y))},fromBytes(m){const E=m.length,C=m[0],R=m.subarray(1);if(E===a&&(C===2||C===3)){const T=En(R);if(!f(T))throw new Error("Point is not on curve");const N=v(T);let k;try{k=e.sqrt(N)}catch(at){const tt=at instanceof Error?": "+at.message:"";throw new Error("Point is not on curve"+tt)}const p=(k&Fr)===Fr;return(C&1)===1!==p&&(k=e.neg(k)),{x:T,y:k}}else if(E===s&&C===4){const T=e.fromBytes(R.subarray(0,e.BYTES)),N=e.fromBytes(R.subarray(e.BYTES,2*e.BYTES));return{x:T,y:N}}else throw new Error(`Point of length ${E} was invalid. Expected ${a} compressed bytes or ${s} uncompressed bytes`)}}),L=m=>xn(Kn(m,t.nByteLength));function D(m){const E=n>>Fr;return m>E}function U(m){return D(m)?u(-m):m}const z=(m,E,C)=>En(m.slice(E,C));class ${constructor(E,C,R){this.r=E,this.s=C,this.recovery=R,this.assertValidity()}static fromCompact(E){const C=t.nByteLength;return E=or("compactSignature",E,C*2),new $(z(E,0,C),z(E,C,2*C))}static fromDER(E){const{r:C,s:R}=An.toSig(or("DER",E));return new $(C,R)}assertValidity(){if(!F(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!F(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(E){return new $(this.r,this.s,E)}recoverPublicKey(E){const{r:C,s:R,recovery:T}=this,N=Q(or("msgHash",E));if(T==null||![0,1,2,3].includes(T))throw new Error("recovery id invalid");const k=T===2||T===3?C+t.n:C;if(k>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const p=T&1?"03":"02",M=x.fromHex(p+L(k)),at=y(k),tt=u(-N*at),ft=u(R*at),Lt=x.BASE.multiplyAndAddUnsafe(M,tt,ft);if(!Lt)throw new Error("point at infinify");return Lt.assertValidity(),Lt}hasHighS(){return D(this.s)}normalizeS(){return this.hasHighS()?new $(this.r,u(-this.s),this.recovery):this}toDERRawBytes(){return Dn(this.toDERHex())}toDERHex(){return An.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Dn(this.toCompactHex())}toCompactHex(){return L(this.r)+L(this.s)}}const X={isValidPrivateKey(m){try{return B(m),!0}catch{return!1}},normPrivateKeyToScalar:B,randomPrivateKey:()=>{const m=Xs(t.n);return Ju(t.randomBytes(m),t.n)},precompute(m=8,E=x.BASE){return E._setWindowSize(m),E.multiply(BigInt(3)),E}};function V(m,E=!0){return x.fromPrivateKey(m).toRawBytes(E)}function it(m){const E=bn(m),C=typeof m=="string",R=(E||C)&&m.length;return E?R===a||R===s:C?R===2*a||R===2*s:m instanceof x}function G(m,E,C=!0){if(it(m))throw new Error("first arg must be private key");if(!it(E))throw new Error("second arg must be public key");return x.fromHex(E).multiply(B(m)).toRawBytes(C)}const W=t.bits2int||function(m){const E=En(m),C=m.length*8-t.nBitLength;return C>0?E>>BigInt(C):E},Q=t.bits2int_modN||function(m){return u(W(m))},rt=bo(t.nBitLength);function ae(m){if(typeof m!="bigint")throw new Error("bigint expected");if(!(on<=m&&m<rt))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Kn(m,t.nByteLength)}function jt(m,E,C=_t){if(["recovered","canonical"].some(Ut=>Ut in C))throw new Error("sign() legacy options not supported");const{hash:R,randomBytes:T}=t;let{lowS:N,prehash:k,extraEntropy:p}=C;N==null&&(N=!0),m=or("msgHash",m),k&&(m=or("prehashed msgHash",R(m)));const M=Q(m),at=B(E),tt=[ae(at),ae(M)];if(p!=null&&p!==!1){const Ut=p===!0?T(e.BYTES):p;tt.push(or("extraEntropy",Ut))}const ft=kn(...tt),Lt=M;function At(Ut){const Ee=W(Ut);if(!F(Ee))return;const Zt=y(Ee),Wt=x.BASE.multiply(Ee).toAffine(),Yt=u(Wt.x);if(Yt===on)return;const zt=u(Zt*u(Lt+Yt*at));if(zt===on)return;let ge=(Wt.x===Yt?0:2)|Number(Wt.y&Fr),xr=zt;return N&&D(zt)&&(xr=U(zt),ge^=1),new $(Yt,xr,ge)}return{seed:ft,k2sig:At}}const _t={lowS:t.lowS,prehash:!1},re={lowS:t.lowS,prehash:!1};function P(m,E,C=_t){const{seed:R,k2sig:T}=jt(m,E,C),N=t;return Vs(N.hash.outputLen,N.nByteLength,N.hmac)(R,T)}x.BASE._setWindowSize(8);function d(m,E,C,R=re){var Wt;const T=m;if(E=or("msgHash",E),C=or("publicKey",C),"strict"in R)throw new Error("options.strict was renamed to lowS");const{lowS:N,prehash:k}=R;let p,M;try{if(typeof T=="string"||bn(T))try{p=$.fromDER(T)}catch(Yt){if(!(Yt instanceof An.Err))throw Yt;p=$.fromCompact(T)}else if(typeof T=="object"&&typeof T.r=="bigint"&&typeof T.s=="bigint"){const{r:Yt,s:zt}=T;p=new $(Yt,zt)}else throw new Error("PARSE");M=x.fromHex(C)}catch(Yt){if(Yt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(N&&p.hasHighS())return!1;k&&(E=t.hash(E));const{r:at,s:tt}=p,ft=Q(E),Lt=y(tt),At=u(ft*Lt),Ut=u(at*Lt),Ee=(Wt=x.BASE.multiplyAndAddUnsafe(M,At,Ut))==null?void 0:Wt.toAffine();return Ee?u(Ee.x)===at:!1}return{CURVE:t,getPublicKey:V,getSharedSecret:G,sign:P,verify:d,ProjectivePoint:x,Signature:$,utils:X}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function zh(o){return{hash:o,hmac:(t,...e)=>Qa(o,t,pu(...e)),randomBytes:Us}}function Dh(o,t){const e=n=>Nh({...o,...zh(n)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ec=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),rc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),$h=BigInt(1),Zo=BigInt(2),nc=(o,t)=>(o+t/Zo)/t;function Kh(o){const t=ec,e=BigInt(3),n=BigInt(6),a=BigInt(11),s=BigInt(22),f=BigInt(23),u=BigInt(44),y=BigInt(88),x=o*o*o%t,B=x*x*o%t,v=Ze(B,e,t)*B%t,F=Ze(v,e,t)*B%t,L=Ze(F,Zo,t)*x%t,D=Ze(L,a,t)*L%t,U=Ze(D,s,t)*D%t,z=Ze(U,u,t)*U%t,$=Ze(z,y,t)*z%t,X=Ze($,u,t)*U%t,V=Ze(X,e,t)*B%t,it=Ze(V,f,t)*D%t,G=Ze(it,n,t)*x%t,W=Ze(G,Zo,t);if(!Jo.eql(Jo.sqr(W),o))throw new Error("Cannot find square root");return W}const Jo=Zs(ec,void 0,void 0,{sqrt:Kh}),Hi=Dh({a:BigInt(0),b:BigInt(7),Fp:Jo,n:rc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:o=>{const t=rc,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-$h*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),a=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,f=BigInt("0x100000000000000000000000000000000"),u=nc(s*o,t),y=nc(-n*o,t);let x=We(o-u*e-y*a,t),B=We(-u*n-y*s,t);const v=x>f,F=B>f;if(v&&(x=t-x),F&&(B=t-B),x>f||B>f)throw new Error("splitScalar: Endomorphism failed, k="+o);return{k1neg:v,k1:x,k2neg:F,k2:B}}}},Ao);BigInt(0),Hi.ProjectivePoint;const Wh=qn.utils.randomPrivateKey,ic=()=>{const o=qn.utils.randomPrivateKey(),t=Vi(o),e=new Uint8Array(64);return e.set(o),e.set(t,32),{publicKey:t,secretKey:e}},Vi=qn.getPublicKey;function oc(o){try{return qn.ExtendedPoint.fromHex(o),!0}catch{return!1}}const Xo=(o,t)=>qn.sign(o,t.slice(0,32)),qh=qn.verify,oe=o=>Nt.Buffer.isBuffer(o)?o:o instanceof Uint8Array?Nt.Buffer.from(o.buffer,o.byteOffset,o.byteLength):Nt.Buffer.from(o);class Qo{constructor(t){Object.assign(this,t)}encode(){return Nt.Buffer.from(da(yi,this))}static decode(t){return pa(yi,this,t)}static decodeUnchecked(t){return ca(yi,this,t)}}class Hh extends Qo{constructor(t){if(super(t),this.enum="",Object.keys(t).length!==1)throw new Error("Enum can only take single value");Object.keys(t).map(e=>{this.enum=e})}}const yi=new Map;var sc;const ac=32,Zr=32;function Vh(o){return o._bn!==void 0}let cc=1;class bt extends Qo{constructor(t){if(super({}),this._bn=void 0,Vh(t))this._bn=t._bn;else{if(typeof t=="string"){const e=cr.decode(t);if(e.length!=Zr)throw new Error("Invalid public key input");this._bn=new ia(e)}else this._bn=new ia(t);if(this._bn.byteLength()>Zr)throw new Error("Invalid public key input")}}static unique(){const t=new bt(cc);return cc+=1,new bt(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return cr.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(Nt.Buffer);if(t.length===Zr)return t;const e=Nt.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,n){const a=Nt.Buffer.concat([t.toBuffer(),Nt.Buffer.from(e),n.toBuffer()]),s=Ao(a);return new bt(s)}static createProgramAddressSync(t,e){let n=Nt.Buffer.alloc(0);t.forEach(function(s){if(s.length>ac)throw new TypeError("Max seed length exceeded");n=Nt.Buffer.concat([n,oe(s)])}),n=Nt.Buffer.concat([n,e.toBuffer(),Nt.Buffer.from("ProgramDerivedAddress")]);const a=Ao(n);if(oc(a))throw new Error("Invalid seeds, address must fall off the curve");return new bt(a)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let n=255,a;for(;n!=0;){try{const s=t.concat(Nt.Buffer.from([n]));a=this.createProgramAddressSync(s,e)}catch(s){if(s instanceof TypeError)throw s;n--;continue}return[a,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){const e=new bt(t);return oc(e.toBytes())}}sc=bt,bt.default=new sc("11111111111111111111111111111111"),yi.set(bt,{kind:"struct",fields:[["_bn","u256"]]});class jh{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=oe(t);if(t.length!==64)throw new Error("bad secret key size");this._publicKey=e.slice(32,64),this._secretKey=e.slice(0,32)}else this._secretKey=oe(Wh()),this._publicKey=oe(Vi(this._secretKey))}get publicKey(){return new bt(this._publicKey)}get secretKey(){return Nt.Buffer.concat([this._secretKey,this._publicKey],64)}}const Gh=new bt("BPFLoader1111111111111111111111111111111111"),gn=1232,ji=127,gi=64;class ts extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(ts.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class es extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty(es.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Zn extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Zn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class mi{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((s,f)=>{n.set(s.toBase58(),f)});const a=s=>{const f=n.get(s.toBase58());if(f===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return f};return t.map(s=>({programIdIndex:a(s.programId),accountKeyIndexes:s.keys.map(f=>a(f.pubkey)),data:s.data}))}}const pe=(o="publicKey")=>Ke(32,o),Yh=(o="signature")=>Ke(64,o),Rn=(o="string")=>{const t=Pt([Ct("length"),Ct("lengthPadding"),Ke(pn(Ct(),-8),"chars")],o),e=t.decode.bind(t),n=t.encode.bind(t),a=t;return a.decode=(s,f)=>e(s,f).chars.toString(),a.encode=(s,f,u)=>{const y={chars:Nt.Buffer.from(s,"utf8")};return n(y,f,u)},a.alloc=s=>Ct().span+Ct().span+Nt.Buffer.from(s,"utf8").length,a},Zh=(o="authorized")=>Pt([pe("staker"),pe("withdrawer")],o),Jh=(o="lockup")=>Pt([Mr("unixTimestamp"),Mr("epoch"),pe("custodian")],o),Xh=(o="voteInit")=>Pt([pe("nodePubkey"),pe("authorizedVoter"),pe("authorizedWithdrawer"),_e("commission")],o),Qh=(o="voteAuthorizeWithSeedArgs")=>Pt([Ct("voteAuthorizationType"),pe("currentAuthorityDerivedKeyOwnerPubkey"),Rn("currentAuthorityDerivedKeySeed"),pe("newAuthorized")],o);function uc(o,t){const e=a=>{if(a.span>=0)return a.span;if(typeof a.alloc=="function")return a.alloc(t[a.property]);if("count"in a&&"elementLayout"in a){const s=t[a.property];if(Array.isArray(s))return s.length*e(a.elementLayout)}else if("fields"in a)return uc({layout:a},t[a.property]);return 0};let n=0;return o.layout.fields.forEach(a=>{n+=e(a)}),n}function vr(o){let t=0,e=0;for(;;){let n=o.shift();if(t|=(n&127)<<e*7,e+=1,!(n&128))break}return t}function Cr(o,t){let e=t;for(;;){let n=e&127;if(e>>=7,e==0){o.push(n);break}else n|=128,o.push(n)}}function Me(o,t){if(!o)throw new Error(t||"Assertion failed")}class Gi{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const n=new Map,a=f=>{const u=f.toBase58();let y=n.get(u);return y===void 0&&(y={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(u,y)),y},s=a(e);s.isSigner=!0,s.isWritable=!0;for(const f of t){a(f.programId).isInvoked=!0;for(const u of f.keys){const y=a(u.pubkey);y.isSigner||(y.isSigner=u.isSigner),y.isWritable||(y.isWritable=u.isWritable)}}return new Gi(e,n)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];Me(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,y])=>y.isSigner&&y.isWritable),n=t.filter(([,y])=>y.isSigner&&!y.isWritable),a=t.filter(([,y])=>!y.isSigner&&y.isWritable),s=t.filter(([,y])=>!y.isSigner&&!y.isWritable),f={numRequiredSignatures:e.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:s.length};{Me(e.length>0,"Expected at least one writable signer key");const[y]=e[0];Me(y===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const u=[...e.map(([y])=>new bt(y)),...n.map(([y])=>new bt(y)),...a.map(([y])=>new bt(y)),...s.map(([y])=>new bt(y))];return[f,u]}extractTableLookup(t){const[e,n]=this.drainKeysFoundInLookupTable(t.state.addresses,f=>!f.isSigner&&!f.isInvoked&&f.isWritable),[a,s]=this.drainKeysFoundInLookupTable(t.state.addresses,f=>!f.isSigner&&!f.isInvoked&&!f.isWritable);if(!(e.length===0&&a.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:a},{writable:n,readonly:s}]}drainKeysFoundInLookupTable(t,e){const n=new Array,a=new Array;for(const[s,f]of this.keyMetaMap.entries())if(e(f)){const u=new bt(s),y=t.findIndex(x=>x.equals(u));y>=0&&(Me(y<256,"Max lookup table index exceeded"),n.push(y),a.push(u),this.keyMetaMap.delete(s))}return[n,a]}}const fc="Reached end of buffer unexpectedly";function Jr(o){if(o.length===0)throw new Error(fc);return o.shift()}function Ar(o,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>o.length:e>=o.length)throw new Error(fc);return o.splice(...t)}class $r{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(e=>new bt(e)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:cr.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new mi(this.staticAccountKeys)}static compile(t){const e=Gi.compile(t.instructions,t.payerKey),[n,a]=e.getMessageComponents(),f=new mi(a).compileInstructions(t.instructions).map(u=>({programIdIndex:u.programIdIndex,accounts:u.accountKeyIndexes,data:cr.encode(u.data)}));return new $r({header:n,accountKeys:a,recentBlockhash:t.recentBlockhash,instructions:f})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const n=t-e,s=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return n<s}else{const n=e-this.header.numReadonlySignedAccounts;return t<n}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,e)=>!this.isProgramId(e))}serialize(){const t=this.accountKeys.length;let e=[];Cr(e,t);const n=this.instructions.map(v=>{const{accounts:F,programIdIndex:L}=v,D=Array.from(cr.decode(v.data));let U=[];Cr(U,F.length);let z=[];return Cr(z,D.length),{programIdIndex:L,keyIndicesCount:Nt.Buffer.from(U),keyIndices:F,dataLength:Nt.Buffer.from(z),data:D}});let a=[];Cr(a,n.length);let s=Nt.Buffer.alloc(gn);Nt.Buffer.from(a).copy(s);let f=a.length;n.forEach(v=>{const L=Pt([_e("programIdIndex"),Ke(v.keyIndicesCount.length,"keyIndicesCount"),pr(_e("keyIndex"),v.keyIndices.length,"keyIndices"),Ke(v.dataLength.length,"dataLength"),pr(_e("userdatum"),v.data.length,"data")]).encode(v,s,f);f+=L}),s=s.slice(0,f);const u=Pt([Ke(1,"numRequiredSignatures"),Ke(1,"numReadonlySignedAccounts"),Ke(1,"numReadonlyUnsignedAccounts"),Ke(e.length,"keyCount"),pr(pe("key"),t,"keys"),pe("recentBlockhash")]),y={numRequiredSignatures:Nt.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Nt.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Nt.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Nt.Buffer.from(e),keys:this.accountKeys.map(v=>oe(v.toBytes())),recentBlockhash:cr.decode(this.recentBlockhash)};let x=Nt.Buffer.alloc(2048);const B=u.encode(y,x);return s.copy(x,B),x.slice(0,B+s.length)}static from(t){let e=[...t];const n=Jr(e);if(n!==(n&ji))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const a=Jr(e),s=Jr(e),f=vr(e);let u=[];for(let F=0;F<f;F++){const L=Ar(e,0,Zr);u.push(new bt(Nt.Buffer.from(L)))}const y=Ar(e,0,Zr),x=vr(e);let B=[];for(let F=0;F<x;F++){const L=Jr(e),D=vr(e),U=Ar(e,0,D),z=vr(e),$=Ar(e,0,z),X=cr.encode(Nt.Buffer.from($));B.push({programIdIndex:L,accounts:U,data:X})}const v={header:{numRequiredSignatures:n,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:s},recentBlockhash:cr.encode(Nt.Buffer.from(y)),accountKeys:u,instructions:B};return new $r(v)}}class Tn{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const e of this.addressTableLookups)t+=e.readonlyIndexes.length+e.writableIndexes.length;return t}getAccountKeys(t){let e;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");e=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)e=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new mi(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(t>=n){const a=t-n,s=this.addressTableLookups.reduce((f,u)=>f+u.writableIndexes.length,0);return a<s}else if(t>=this.header.numRequiredSignatures){const a=t-e,f=n-e-this.header.numReadonlyUnsignedAccounts;return a<f}else{const a=e-this.header.numReadonlySignedAccounts;return t<a}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const n of this.addressTableLookups){const a=t.find(s=>s.key.equals(n.accountKey));if(!a)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const s of n.writableIndexes)if(s<a.state.addresses.length)e.writable.push(a.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`);for(const s of n.readonlyIndexes)if(s<a.state.addresses.length)e.readonly.push(a.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${n.accountKey.toBase58()}`)}return e}static compile(t){const e=Gi.compile(t.instructions,t.payerKey),n=new Array,a={writable:new Array,readonly:new Array},s=t.addressLookupTableAccounts||[];for(const B of s){const v=e.extractTableLookup(B);if(v!==void 0){const[F,{writable:L,readonly:D}]=v;n.push(F),a.writable.push(...L),a.readonly.push(...D)}}const[f,u]=e.getMessageComponents(),x=new mi(u,a).compileInstructions(t.instructions);return new Tn({header:f,staticAccountKeys:u,recentBlockhash:t.recentBlockhash,compiledInstructions:x,addressTableLookups:n})}serialize(){const t=Array();Cr(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),n=Array();Cr(n,this.compiledInstructions.length);const a=this.serializeAddressTableLookups(),s=Array();Cr(s,this.addressTableLookups.length);const f=Pt([_e("prefix"),Pt([_e("numRequiredSignatures"),_e("numReadonlySignedAccounts"),_e("numReadonlyUnsignedAccounts")],"header"),Ke(t.length,"staticAccountKeysLength"),pr(pe(),this.staticAccountKeys.length,"staticAccountKeys"),pe("recentBlockhash"),Ke(n.length,"instructionsLength"),Ke(e.length,"serializedInstructions"),Ke(s.length,"addressTableLookupsLength"),Ke(a.length,"serializedAddressTableLookups")]),u=new Uint8Array(gn),x=f.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(B=>B.toBytes()),recentBlockhash:cr.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:a},u);return u.slice(0,x)}serializeInstructions(){let t=0;const e=new Uint8Array(gn);for(const n of this.compiledInstructions){const a=Array();Cr(a,n.accountKeyIndexes.length);const s=Array();Cr(s,n.data.length);const f=Pt([_e("programIdIndex"),Ke(a.length,"encodedAccountKeyIndexesLength"),pr(_e(),n.accountKeyIndexes.length,"accountKeyIndexes"),Ke(s.length,"encodedDataLength"),Ke(n.data.length,"data")]);t+=f.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(a),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:n.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(gn);for(const n of this.addressTableLookups){const a=Array();Cr(a,n.writableIndexes.length);const s=Array();Cr(s,n.readonlyIndexes.length);const f=Pt([pe("accountKey"),Ke(a.length,"encodedWritableIndexesLength"),pr(_e(),n.writableIndexes.length,"writableIndexes"),Ke(s.length,"encodedReadonlyIndexesLength"),pr(_e(),n.readonlyIndexes.length,"readonlyIndexes")]);t+=f.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(a),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:n.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const n=Jr(e),a=n&ji;Me(n!==a,"Expected versioned message but received legacy message");const s=a;Me(s===0,`Expected versioned message with version 0 but found version ${s}`);const f={numRequiredSignatures:Jr(e),numReadonlySignedAccounts:Jr(e),numReadonlyUnsignedAccounts:Jr(e)},u=[],y=vr(e);for(let D=0;D<y;D++)u.push(new bt(Ar(e,0,Zr)));const x=cr.encode(Ar(e,0,Zr)),B=vr(e),v=[];for(let D=0;D<B;D++){const U=Jr(e),z=vr(e),$=Ar(e,0,z),X=vr(e),V=new Uint8Array(Ar(e,0,X));v.push({programIdIndex:U,accountKeyIndexes:$,data:V})}const F=vr(e),L=[];for(let D=0;D<F;D++){const U=new bt(Ar(e,0,Zr)),z=vr(e),$=Ar(e,0,z),X=vr(e),V=Ar(e,0,X);L.push({accountKey:U,writableIndexes:$,readonlyIndexes:V})}return new Tn({header:f,staticAccountKeys:u,recentBlockhash:x,compiledInstructions:v,addressTableLookups:L})}}const rs={deserializeMessageVersion(o){const t=o[0],e=t&ji;return e===t?"legacy":e},deserialize:o=>{const t=rs.deserializeMessageVersion(o);if(t==="legacy")return $r.from(o);if(t===0)return Tn.deserialize(o);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let sn=function(o){return o[o.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",o[o.PROCESSED=1]="PROCESSED",o[o.TIMED_OUT=2]="TIMED_OUT",o[o.NONCE_INVALID=3]="NONCE_INVALID",o}({});const tl=Nt.Buffer.alloc(gi).fill(0);class Ne{constructor(t){this.keys=void 0,this.programId=void 0,this.data=Nt.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:e,isWritable:n})=>({pubkey:t.toJSON(),isSigner:e,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}}class ve{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:n}=t;this.minNonceContextSlot=e,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:n}=t;this.recentBlockhash=e,this.lastValidBlockHeight=n}else{const{recentBlockhash:e,nonceInfo:n}=t;n&&(this.nonceInfo=n),this.recentBlockhash=e}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new Ne(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let U=0;U<e.length;U++)if(e[U].programId===void 0)throw new Error(`Transaction instruction index ${U} has undefined program id`);const a=[],s=[];e.forEach(U=>{U.keys.forEach($=>{s.push({...$})});const z=U.programId.toString();a.includes(z)||a.push(z)}),a.forEach(U=>{s.push({pubkey:new bt(U),isSigner:!1,isWritable:!1})});const f=[];s.forEach(U=>{const z=U.pubkey.toString(),$=f.findIndex(X=>X.pubkey.toString()===z);$>-1?(f[$].isWritable=f[$].isWritable||U.isWritable,f[$].isSigner=f[$].isSigner||U.isSigner):f.push(U)}),f.sort(function(U,z){if(U.isSigner!==z.isSigner)return U.isSigner?-1:1;if(U.isWritable!==z.isWritable)return U.isWritable?-1:1;const $={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return U.pubkey.toBase58().localeCompare(z.pubkey.toBase58(),"en",$)});const u=f.findIndex(U=>U.pubkey.equals(n));if(u>-1){const[U]=f.splice(u,1);U.isSigner=!0,U.isWritable=!0,f.unshift(U)}else f.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const U of this.signatures){const z=f.findIndex($=>$.pubkey.equals(U.publicKey));if(z>-1)f[z].isSigner||(f[z].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${U.publicKey.toString()}`)}let y=0,x=0,B=0;const v=[],F=[];f.forEach(({pubkey:U,isSigner:z,isWritable:$})=>{z?(v.push(U.toString()),y+=1,$||(x+=1)):(F.push(U.toString()),$||(B+=1))});const L=v.concat(F),D=e.map(U=>{const{data:z,programId:$}=U;return{programIdIndex:L.indexOf($.toString()),accounts:U.keys.map(X=>L.indexOf(X.pubkey.toString())),data:cr.encode(z)}});return D.forEach(U=>{Me(U.programIdIndex>=0),U.accounts.forEach(z=>Me(z>=0))}),new $r({header:{numRequiredSignatures:y,numReadonlySignedAccounts:x,numReadonlyUnsignedAccounts:B},accountKeys:L,recentBlockhash:t,instructions:D})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((a,s)=>e[s].equals(a.publicKey))||(this.signatures=e.map(n=>({signature:null,publicKey:n}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");const e=new Set;this.signatures=t.filter(n=>{const a=n.toString();return e.has(a)?!1:(e.add(a),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,n=[];for(const s of t){const f=s.publicKey.toString();e.has(f)||(e.add(f),n.push(s))}this.signatures=n.map(s=>({signature:null,publicKey:s.publicKey}));const a=this._compile();this._partialSign(a,...n)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,n=[];for(const s of t){const f=s.publicKey.toString();e.has(f)||(e.add(f),n.push(s))}const a=this._compile();this._partialSign(a,...n)}_partialSign(t,...e){const n=t.serialize();e.forEach(a=>{const s=Xo(n,a.secretKey);this._addSignature(a.publicKey,oe(s))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){Me(e.length===64);const n=this.signatures.findIndex(a=>t.equals(a.publicKey));if(n<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[n].signature=Nt.Buffer.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const n={};for(const{signature:a,publicKey:s}of this.signatures)a===null?e&&(n.missing||(n.missing=[])).push(s):qh(a,t,s.toBytes())||(n.invalid||(n.invalid=[])).push(s);return n.invalid||n.missing?n:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),a=this.serializeMessage();if(n){const s=this._getMessageSignednessErrors(a,e);if(s){let f="Signature verification failed.";throw s.invalid&&(f+=`
17
17
  Invalid signature for public key${s.invalid.length===1?"":"(s)"} [\`${s.invalid.map(u=>u.toBase58()).join("`, `")}\`].`),s.missing&&(f+=`
18
- Missing signature for public key${s.missing.length===1?"":"(s)"} [\`${s.missing.map(u=>u.toBase58()).join("`, `")}\`].`),new Error(f)}}return this._serialize(a)}_serialize(t){const{signatures:e}=this,n=[];Pr(n,e.length);const a=n.length+e.length*64+t.length,s=Nt.Buffer.alloc(a);return Me(e.length<256),Nt.Buffer.from(n).copy(s,0),e.forEach(({signature:f},u)=>{f!==null&&(Me(f.length===64,"signature has invalid length"),Nt.Buffer.from(f).copy(s,n.length+u*64))}),t.copy(s,n.length+e.length*64),Me(s.length<=gn,`Transaction too large: ${s.length} > ${gn}`),s}get keys(){return Me(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return Me(this.instructions.length===1),this.instructions[0].programId}get data(){return Me(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const n=_r(e);let a=[];for(let s=0;s<n;s++){const f=Ar(e,0,gi);a.push(cr.encode(Nt.Buffer.from(f)))}return _e.populate($r.from(e),a)}static populate(t,e=[]){const n=new _e;return n.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(n.feePayer=t.accountKeys[0]),e.forEach((a,s)=>{const f={signature:a==cr.encode(tl)?null:cr.decode(a),publicKey:t.accountKeys[s]};n.signatures.push(f)}),t.instructions.forEach(a=>{const s=a.accounts.map(f=>{const u=t.accountKeys[f];return{pubkey:u,isSigner:n.signatures.some(y=>y.publicKey.toString()===u.toString())||t.isAccountSigner(f),isWritable:t.isAccountWritable(f)}});n.instructions.push(new Ne({keys:s,programId:t.accountKeys[a.programIdIndex],data:cr.decode(a.data)}))}),n._message=t,n._json=n.toJSON(),n}}class rs{constructor(t){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=t.payerKey,this.instructions=t.instructions,this.recentBlockhash=t.recentBlockhash}static decompile(t,e){const{header:n,compiledInstructions:a,recentBlockhash:s}=t,{numRequiredSignatures:f,numReadonlySignedAccounts:u,numReadonlyUnsignedAccounts:y}=n,x=f-u;Me(x>0,"Message header is invalid");const v=t.staticAccountKeys.length-f-y;Me(v>=0,"Message header is invalid");const _=t.getAccountKeys(e),F=_.get(0);if(F===void 0)throw new Error("Failed to decompile message because no account keys were found");const L=[];for(const D of a){const C=[];for(const $ of D.accountKeyIndexes){const X=_.get($);if(X===void 0)throw new Error(`Failed to find key for account key index ${$}`);const j=$<f;let it;j?it=$<x:$<_.staticAccountKeys.length?it=$-f<v:it=$-_.staticAccountKeys.length<_.accountKeysFromLookups.writable.length,C.push({pubkey:X,isSigner:$<n.numRequiredSignatures,isWritable:it})}const z=_.get(D.programIdIndex);if(z===void 0)throw new Error(`Failed to find program id for program id index ${D.programIdIndex}`);L.push(new Ne({programId:z,data:oe(D.data),keys:C}))}return new rs({payerKey:F,instructions:L,recentBlockhash:s})}compileToLegacyMessage(){return $r.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(t){return Tn.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:t})}}class ns{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,e!==void 0)Me(e.length===t.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=e;else{const n=[];for(let a=0;a<t.header.numRequiredSignatures;a++)n.push(new Uint8Array(gi));this.signatures=n}this.message=t}serialize(){const t=this.message.serialize(),e=Array();Pr(e,this.signatures.length);const n=Pt([Ke(e.length,"encodedSignaturesLength"),pr(Yh(),this.signatures.length,"signatures"),Ke(t.length,"serializedMessage")]),a=new Uint8Array(2048),s=n.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},a);return a.slice(0,s)}static deserialize(t){let e=[...t];const n=[],a=_r(e);for(let f=0;f<a;f++)n.push(new Uint8Array(Ar(e,0,gi)));const s=es.deserialize(new Uint8Array(e));return new ns(s,n)}sign(t){const e=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const a of t){const s=n.findIndex(f=>f.equals(a.publicKey));Me(s>=0,`Cannot sign with non signer key ${a.publicKey.toBase58()}`),this.signatures[s]=Jo(e,a.secretKey)}}addSignature(t,e){Me(e.byteLength===64,"Signature must be 64 bytes long");const a=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(s=>s.equals(t));Me(a>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[a]=e}}const hc=1e3/(160/64),Jr=new mt("SysvarC1ock11111111111111111111111111111111"),el=new mt("SysvarEpochSchedu1e111111111111111111111111"),rl=new mt("Sysvar1nstructions1111111111111111111111111"),Yi=new mt("SysvarRecentB1ockHashes11111111111111111111"),Jn=new mt("SysvarRent111111111111111111111111111111111"),nl=new mt("SysvarRewards111111111111111111111111111111"),il=new mt("SysvarS1otHashes111111111111111111111111111"),ol=new mt("SysvarS1otHistory11111111111111111111111111"),Zi=new mt("SysvarStakeHistory1111111111111111111111111");class mi extends Error{constructor({action:t,signature:e,transactionMessage:n,logs:a}){const s=a?`Logs:
18
+ Missing signature for public key${s.missing.length===1?"":"(s)"} [\`${s.missing.map(u=>u.toBase58()).join("`, `")}\`].`),new Error(f)}}return this._serialize(a)}_serialize(t){const{signatures:e}=this,n=[];Cr(n,e.length);const a=n.length+e.length*64+t.length,s=Nt.Buffer.alloc(a);return Me(e.length<256),Nt.Buffer.from(n).copy(s,0),e.forEach(({signature:f},u)=>{f!==null&&(Me(f.length===64,"signature has invalid length"),Nt.Buffer.from(f).copy(s,n.length+u*64))}),t.copy(s,n.length+e.length*64),Me(s.length<=gn,`Transaction too large: ${s.length} > ${gn}`),s}get keys(){return Me(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return Me(this.instructions.length===1),this.instructions[0].programId}get data(){return Me(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const n=vr(e);let a=[];for(let s=0;s<n;s++){const f=Ar(e,0,gi);a.push(cr.encode(Nt.Buffer.from(f)))}return ve.populate($r.from(e),a)}static populate(t,e=[]){const n=new ve;return n.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(n.feePayer=t.accountKeys[0]),e.forEach((a,s)=>{const f={signature:a==cr.encode(tl)?null:cr.decode(a),publicKey:t.accountKeys[s]};n.signatures.push(f)}),t.instructions.forEach(a=>{const s=a.accounts.map(f=>{const u=t.accountKeys[f];return{pubkey:u,isSigner:n.signatures.some(y=>y.publicKey.toString()===u.toString())||t.isAccountSigner(f),isWritable:t.isAccountWritable(f)}});n.instructions.push(new Ne({keys:s,programId:t.accountKeys[a.programIdIndex],data:cr.decode(a.data)}))}),n._message=t,n._json=n.toJSON(),n}}class ns{constructor(t){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=t.payerKey,this.instructions=t.instructions,this.recentBlockhash=t.recentBlockhash}static decompile(t,e){const{header:n,compiledInstructions:a,recentBlockhash:s}=t,{numRequiredSignatures:f,numReadonlySignedAccounts:u,numReadonlyUnsignedAccounts:y}=n,x=f-u;Me(x>0,"Message header is invalid");const B=t.staticAccountKeys.length-f-y;Me(B>=0,"Message header is invalid");const v=t.getAccountKeys(e),F=v.get(0);if(F===void 0)throw new Error("Failed to decompile message because no account keys were found");const L=[];for(const D of a){const U=[];for(const $ of D.accountKeyIndexes){const X=v.get($);if(X===void 0)throw new Error(`Failed to find key for account key index ${$}`);const V=$<f;let it;V?it=$<x:$<v.staticAccountKeys.length?it=$-f<B:it=$-v.staticAccountKeys.length<v.accountKeysFromLookups.writable.length,U.push({pubkey:X,isSigner:$<n.numRequiredSignatures,isWritable:it})}const z=v.get(D.programIdIndex);if(z===void 0)throw new Error(`Failed to find program id for program id index ${D.programIdIndex}`);L.push(new Ne({programId:z,data:oe(D.data),keys:U}))}return new ns({payerKey:F,instructions:L,recentBlockhash:s})}compileToLegacyMessage(){return $r.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(t){return Tn.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:t})}}class is{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,e!==void 0)Me(e.length===t.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=e;else{const n=[];for(let a=0;a<t.header.numRequiredSignatures;a++)n.push(new Uint8Array(gi));this.signatures=n}this.message=t}serialize(){const t=this.message.serialize(),e=Array();Cr(e,this.signatures.length);const n=Pt([Ke(e.length,"encodedSignaturesLength"),pr(Yh(),this.signatures.length,"signatures"),Ke(t.length,"serializedMessage")]),a=new Uint8Array(2048),s=n.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},a);return a.slice(0,s)}static deserialize(t){let e=[...t];const n=[],a=vr(e);for(let f=0;f<a;f++)n.push(new Uint8Array(Ar(e,0,gi)));const s=rs.deserialize(new Uint8Array(e));return new is(s,n)}sign(t){const e=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const a of t){const s=n.findIndex(f=>f.equals(a.publicKey));Me(s>=0,`Cannot sign with non signer key ${a.publicKey.toBase58()}`),this.signatures[s]=Xo(e,a.secretKey)}}addSignature(t,e){Me(e.byteLength===64,"Signature must be 64 bytes long");const a=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(s=>s.equals(t));Me(a>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[a]=e}}const hc=1e3/(160/64),Xr=new bt("SysvarC1ock11111111111111111111111111111111"),el=new bt("SysvarEpochSchedu1e111111111111111111111111"),rl=new bt("Sysvar1nstructions1111111111111111111111111"),Yi=new bt("SysvarRecentB1ockHashes11111111111111111111"),Jn=new bt("SysvarRent111111111111111111111111111111111"),nl=new bt("SysvarRewards111111111111111111111111111111"),il=new bt("SysvarS1otHashes111111111111111111111111111"),ol=new bt("SysvarS1otHistory11111111111111111111111111"),Zi=new bt("SysvarStakeHistory1111111111111111111111111");class wi extends Error{constructor({action:t,signature:e,transactionMessage:n,logs:a}){const s=a?`Logs:
19
19
  ${JSON.stringify(a.slice(-10),null,2)}. `:"",f="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let u;switch(t){case"send":u=`Transaction ${e} resulted in an error.
20
20
  ${n}. `+s+f;break;case"simulate":u=`Simulation failed.
21
21
  Message: ${n}.
22
- `+s+f;break;default:u=`Unknown action '${(y=>y)(t)}'`}super(u),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=n,this.transactionLogs=a||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const t=this.transactionLogs;if(!(t!=null&&typeof t=="object"&&"then"in t))return t}async getLogs(t){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((e,n)=>{t.getTransaction(this.signature).then(a=>{if(a&&a.meta&&a.meta.logMessages){const s=a.meta.logMessages;this.transactionLogs=s,e(s)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}}const sl={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016};class Ot extends Error{constructor({code:t,message:e,data:n},a){super(a!=null?`${a}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=n,this.name="SolanaJSONRPCError"}}async function is(o,t,e,n){const a=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},s=await o.sendTransaction(t,e,a);let f;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)f=(await o.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,signature:s,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},n&&n.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){const{nonceInstruction:u}=t.nonceInfo,y=u.keys[0].pubkey;f=(await o.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:y,nonceValue:t.nonceInfo.nonce,signature:s},n&&n.commitment)).value}else(n==null?void 0:n.abortSignal)!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),f=(await o.confirmTransaction(s,n&&n.commitment)).value;if(f.err)throw s!=null?new mi({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(f)})`}):new Error(`Transaction ${s} failed (${JSON.stringify(f)})`);return s}function Mn(o){return new Promise(t=>setTimeout(t,o))}function xe(o,t){const e=o.layout.span>=0?o.layout.span:uc(o,t),n=Nt.Buffer.alloc(e),a=Object.assign({instruction:o.index},t);return o.layout.encode(a,n),n}function Ue(o,t){let e;try{e=o.layout.decode(t)}catch(n){throw new Error("invalid instruction; "+n)}if(e.instruction!==o.index)throw new Error(`invalid instruction; instruction index mismatch ${e.instruction} != ${o.index}`);return e}const lc=dr("lamportsPerSignature"),dc=Pt([Mt("version"),Mt("state"),pe("authorizedPubkey"),pe("nonce"),Pt([lc],"feeCalculator")]),os=dc.span;class Ji{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=dc.decode(oe(t),0);return new Ji({authorizedPubkey:new mt(e.authorizedPubkey),nonce:new mt(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const al=o=>{const t=o.decode.bind(o),e=o.encode.bind(o);return{decode:t,encode:e}},Xn=(o=>t=>{const e=Ke(o,t),{encode:n,decode:a}=al(e),s=e;return s.decode=(f,u)=>{const y=a(f,u);return Of(Nt.Buffer.from(y))},s.encode=(f,u,y)=>{const x=Ua(f,o);return n(x,u,y)},s})(8);class cl{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=Mt("instruction").decode(t.data);let a;for(const[s,f]of Object.entries(ze))if(f.index==n){a=s;break}if(!a)throw new Error("Instruction type incorrect; not a SystemInstruction");return a}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:n,programId:a}=Ue(ze.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:n,programId:new mt(a)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=Ue(ze.Transfer,t.data);return{fromPubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,lamports:e}}static decodeTransferWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e,seed:n,programId:a}=Ue(ze.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:n,programId:new mt(a)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=Ue(ze.Allocate,t.data);return{accountPubkey:t.keys[0].pubkey,space:e}}static decodeAllocateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:n,space:a,programId:s}=Ue(ze.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new mt(e),seed:n,space:a,programId:new mt(s)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=Ue(ze.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new mt(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:n,programId:a}=Ue(ze.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new mt(e),seed:n,programId:new mt(a)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:n,lamports:a,space:s,programId:f}=Ue(ze.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new mt(e),seed:n,lamports:a,space:s,programId:new mt(f)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=Ue(ze.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new mt(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ue(ze.AdvanceNonceAccount,t.data),{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static decodeNonceWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Ue(ze.WithdrawNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e}}static decodeNonceAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e}=Ue(ze.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new mt(e)}}static checkProgramId(t){if(!t.equals(ur.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const ze=Object.freeze({Create:{index:0,layout:Pt([Mt("instruction"),Mr("lamports"),Mr("space"),pe("programId")])},Assign:{index:1,layout:Pt([Mt("instruction"),pe("programId")])},Transfer:{index:2,layout:Pt([Mt("instruction"),Xn("lamports")])},CreateWithSeed:{index:3,layout:Pt([Mt("instruction"),pe("base"),Rn("seed"),Mr("lamports"),Mr("space"),pe("programId")])},AdvanceNonceAccount:{index:4,layout:Pt([Mt("instruction")])},WithdrawNonceAccount:{index:5,layout:Pt([Mt("instruction"),Mr("lamports")])},InitializeNonceAccount:{index:6,layout:Pt([Mt("instruction"),pe("authorized")])},AuthorizeNonceAccount:{index:7,layout:Pt([Mt("instruction"),pe("authorized")])},Allocate:{index:8,layout:Pt([Mt("instruction"),Mr("space")])},AllocateWithSeed:{index:9,layout:Pt([Mt("instruction"),pe("base"),Rn("seed"),Mr("space"),pe("programId")])},AssignWithSeed:{index:10,layout:Pt([Mt("instruction"),pe("base"),Rn("seed"),pe("programId")])},TransferWithSeed:{index:11,layout:Pt([Mt("instruction"),Xn("lamports"),Rn("seed"),pe("programId")])},UpgradeNonceAccount:{index:12,layout:Pt([Mt("instruction")])}});class ur{constructor(){}static createAccount(t){const e=ze.Create,n=xe(e,{lamports:t.lamports,space:t.space,programId:oe(t.programId.toBuffer())});return new Ne({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(t){let e,n;if("basePubkey"in t){const a=ze.TransferWithSeed;e=xe(a,{lamports:BigInt(t.lamports),seed:t.seed,programId:oe(t.programId.toBuffer())}),n=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{const a=ze.Transfer;e=xe(a,{lamports:BigInt(t.lamports)}),n=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Ne({keys:n,programId:this.programId,data:e})}static assign(t){let e,n;if("basePubkey"in t){const a=ze.AssignWithSeed;e=xe(a,{base:oe(t.basePubkey.toBuffer()),seed:t.seed,programId:oe(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const a=ze.Assign;e=xe(a,{programId:oe(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ne({keys:n,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=ze.CreateWithSeed,n=xe(e,{base:oe(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:oe(t.programId.toBuffer())});let a=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey.equals(t.fromPubkey)||a.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Ne({keys:a,programId:this.programId,data:n})}static createNonceAccount(t){const e=new _e;"basePubkey"in t&&"seed"in t?e.add(ur.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:os,programId:this.programId})):e.add(ur.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:os,programId:this.programId}));const n={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(n)),e}static nonceInitialize(t){const e=ze.InitializeNonceAccount,n=xe(e,{authorized:oe(t.authorizedPubkey.toBuffer())}),a={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Yi,isSigner:!1,isWritable:!1},{pubkey:Jn,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new Ne(a)}static nonceAdvance(t){const e=ze.AdvanceNonceAccount,n=xe(e),a={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Yi,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new Ne(a)}static nonceWithdraw(t){const e=ze.WithdrawNonceAccount,n=xe(e,{lamports:t.lamports});return new Ne({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Yi,isSigner:!1,isWritable:!1},{pubkey:Jn,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(t){const e=ze.AuthorizeNonceAccount,n=xe(e,{authorized:oe(t.newAuthorizedPubkey.toBuffer())});return new Ne({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(t){let e,n;if("basePubkey"in t){const a=ze.AllocateWithSeed;e=xe(a,{base:oe(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:oe(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const a=ze.Allocate;e=xe(a,{space:t.space}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ne({keys:n,programId:this.programId,data:e})}}ur.programId=new mt("11111111111111111111111111111111");const ul=gn-300;class Pn{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/Pn.chunkSize)+1+1)}static async load(t,e,n,a,s){{const _=await t.getMinimumBalanceForRentExemption(s.length),F=await t.getAccountInfo(n.publicKey,"confirmed");let L=null;if(F!==null){if(F.executable)return console.error("Program load failed, account is already executable"),!1;F.data.length!==s.length&&(L=L||new _e,L.add(ur.allocate({accountPubkey:n.publicKey,space:s.length}))),F.owner.equals(a)||(L=L||new _e,L.add(ur.assign({accountPubkey:n.publicKey,programId:a}))),F.lamports<_&&(L=L||new _e,L.add(ur.transfer({fromPubkey:e.publicKey,toPubkey:n.publicKey,lamports:_-F.lamports})))}else L=new _e().add(ur.createAccount({fromPubkey:e.publicKey,newAccountPubkey:n.publicKey,lamports:_>0?_:1,space:s.length,programId:a}));L!==null&&await is(t,L,[e,n],{commitment:"confirmed"})}const f=Pt([Mt("instruction"),Mt("offset"),Mt("bytesLength"),Mt("bytesLengthPadding"),pr(ve("byte"),pn(Mt(),-8),"bytes")]),u=Pn.chunkSize;let y=0,x=s,v=[];for(;x.length>0;){const _=x.slice(0,u),F=Nt.Buffer.alloc(u+16);f.encode({instruction:0,offset:y,bytes:_,bytesLength:0,bytesLengthPadding:0},F);const L=new _e().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:a,data:F});v.push(is(t,L,[e,n],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await Mn(1e3/4),y+=u,x=x.slice(u)}await Promise.all(v);{const _=Pt([Mt("instruction")]),F=Nt.Buffer.alloc(_.span);_.encode({instruction:1},F);const L=new _e().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:Jn,isSigner:!1,isWritable:!1}],programId:a,data:F}),D="processed",C=await t.sendTransaction(L,[e,n],{preflightCommitment:D}),{context:z,value:$}=await t.confirmTransaction({signature:C,lastValidBlockHeight:L.lastValidBlockHeight,blockhash:L.recentBlockhash},D);if($.err)throw new Error(`Transaction ${C} failed (${JSON.stringify($)})`);for(;;){try{if(await t.getSlot({commitment:D})>z.slot)break}catch{}await new Promise(X=>setTimeout(X,Math.round(hc/2)))}}return!0}}Pn.chunkSize=ul;const fl=new mt("BPFLoader2111111111111111111111111111111111");class hl{static getMinNumSignatures(t){return Pn.getMinNumSignatures(t)}static load(t,e,n,a,s){return Pn.load(t,e,n,s,a)}}function ll(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var dl=Object.prototype.toString,pl=Object.keys||function(o){var t=[];for(var e in o)t.push(e);return t};function bi(o,t){var e,n,a,s,f,u,y;if(o===!0)return"true";if(o===!1)return"false";switch(typeof o){case"object":if(o===null)return null;if(o.toJSON&&typeof o.toJSON=="function")return bi(o.toJSON(),t);if(y=dl.call(o),y==="[object Array]"){for(a="[",n=o.length-1,e=0;e<n;e++)a+=bi(o[e],!0)+",";return n>-1&&(a+=bi(o[e],!0)),a+"]"}else if(y==="[object Object]"){for(s=pl(o).sort(),n=s.length,a="",e=0;e<n;)f=s[e],u=bi(o[f],!1),u!==void 0&&(a&&(a+=","),a+=JSON.stringify(f)+":"+u),e++;return"{"+a+"}"}else return JSON.stringify(o);case"function":case"undefined":return t?null:void 0;case"string":return JSON.stringify(o);default:return isFinite(o)?o:null}}var yl=function(o){var t=bi(o,!1);if(t!==void 0)return""+t},pc=ll(yl);const xi=32;function ss(o){let t=0;for(;o>1;)o/=2,t++;return t}function gl(o){return o===0?1:(o--,o|=o>>1,o|=o>>2,o|=o>>4,o|=o>>8,o|=o>>16,o|=o>>32,o+1)}class yc{constructor(t,e,n,a,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=t,this.leaderScheduleSlotOffset=e,this.warmup=n,this.firstNormalEpoch=a,this.firstNormalSlot=s}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=ss(gl(t+xi+1))-ss(xi)-1,n=this.getSlotsInEpoch(e),a=t-(n-xi);return[e,a]}else{const e=t-this.firstNormalSlot,n=Math.floor(e/this.slotsPerEpoch),a=this.firstNormalEpoch+n,s=e%this.slotsPerEpoch;return[a,s]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*xi:(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+ss(xi)):this.slotsPerEpoch}}var wl=globalThis.fetch;class ml extends Ih{constructor(t,e,n){const a=s=>{const f=kh(s,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in f?this.underlyingSocket=f.socket:this.underlyingSocket=f,f};super(a,t,e,n),this.underlyingSocket=void 0}call(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}function bl(o,t){let e;try{e=o.layout.decode(t)}catch(n){throw new Error("invalid instruction; "+n)}if(e.typeIndex!==o.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${o.index}`);return e}const gc=56;class as{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=bl(xl,t),n=t.length-gc;Me(n>=0,"lookup table is invalid"),Me(n%32===0,"lookup table is invalid");const a=n/32,{addresses:s}=Pt([pr(pe(),a,"addresses")]).decode(t.slice(gc));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new mt(e.authority[0]):void 0,addresses:s.map(f=>new mt(f))}}}const xl={index:1,layout:Pt([Mt("typeIndex"),Xn("deactivationSlot"),dr("lastExtendedSlot"),ve("lastExtendedStartIndex"),ve(),pr(pe(),pn(ve(),-1),"authority")])},El=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function kl(o){const t=o.match(El);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${o}\``);const[e,n,a,s]=t,f=o.startsWith("https:")?"wss:":"ws:",u=a==null?null:parseInt(a.slice(1),10),y=u==null?"":`:${u+1}`;return`${f}//${n}${y}${s}`}const Ge=li($o(mt),gt(),o=>new mt(o)),wc=Ko([gt(),Ve("base64")]),cs=li($o(Nt.Buffer),wc,o=>Nt.Buffer.from(o[0],"base64")),mc=30*1e3;function Sl(o){if(/^https?:/.test(o)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return o}function De(o){let t,e;if(typeof o=="string")t=o;else if(o){const{commitment:n,...a}=o;t=n,e=a}return{commitment:t,config:e}}function bc(o){return o.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function xc(o){return Br([ut({jsonrpc:Ve("2.0"),id:gt(),result:o}),ut({jsonrpc:Ve("2.0"),id:gt(),error:ut({code:Yn(),message:gt(),data:$t(jf())})})])}const Il=xc(Yn());function se(o){return li(xc(o),Il,t=>"error"in t?t:{...t,result:bt(t.result,o)})}function Je(o){return se(ut({context:ut({slot:H()}),value:o}))}function Xi(o){return ut({context:ut({slot:H()}),value:o})}function us(o,t){return o===0?new Tn({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new mt(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:cr.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new $r(t)}const Bl=ut({foundation:H(),foundationTerm:H(),initial:H(),taper:H(),terminal:H()}),vl=se(kt(St(ut({epoch:H(),effectiveSlot:H(),amount:H(),postBalance:H(),commission:$t(St(H()))})))),_l=kt(ut({slot:H(),prioritizationFee:H()})),Al=ut({total:H(),validator:H(),foundation:H(),epoch:H()}),Rl=ut({epoch:H(),slotIndex:H(),slotsInEpoch:H(),absoluteSlot:H(),blockHeight:$t(H()),transactionCount:$t(H())}),Tl=ut({slotsPerEpoch:H(),leaderScheduleSlotOffset:H(),warmup:Gr(),firstNormalEpoch:H(),firstNormalSlot:H()}),Ml=Oa(gt(),kt(H())),Un=St(Br([ut({}),gt()])),Pl=ut({err:Un}),Ul=Ve("receivedSignature"),Cl=ut({"solana-core":gt(),"feature-set":$t(H())}),Ll=ut({program:gt(),programId:Ge,parsed:Yn()}),Fl=ut({programId:Ge,accounts:kt(Ge),data:gt()}),Ec=Je(ut({err:St(Br([ut({}),gt()])),logs:St(kt(gt())),accounts:$t(St(kt(St(ut({executable:Gr(),owner:gt(),lamports:H(),data:kt(gt()),rentEpoch:$t(H())}))))),unitsConsumed:$t(H()),returnData:$t(St(ut({programId:gt(),data:Ko([gt(),Ve("base64")])}))),innerInstructions:$t(St(kt(ut({index:H(),instructions:kt(Br([Ll,Fl]))}))))})),Ol=Je(ut({byIdentity:Oa(gt(),kt(H())),range:ut({firstSlot:H(),lastSlot:H()})}));function Nl(o,t,e,n,a,s){const f=e||wl;let u;s!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let y;return n&&(y=async(v,_)=>{const F=await new Promise((L,D)=>{try{n(v,_,(C,z)=>L([C,z]))}catch(C){D(C)}});return await f(...F)}),new bh(async(v,_)=>{const F={method:"POST",body:v,agent:u,headers:Object.assign({"Content-Type":"application/json"},t||{},z0)};try{let L=5,D,C=500;for(;y?D=await y(o,F):D=await f(o,F),!(D.status!==429||a===!0||(L-=1,L===0));)console.error(`Server responded with ${D.status} ${D.statusText}. Retrying after ${C}ms delay...`),await Mn(C),C*=2;const z=await D.text();D.ok?_(null,z):_(new Error(`${D.status} ${D.statusText}: ${z}`))}catch(L){L instanceof Error&&_(L)}},{})}function zl(o){return(t,e)=>new Promise((n,a)=>{o.request(t,e,(s,f)=>{if(s){a(s);return}n(f)})})}function Dl(o){return t=>new Promise((e,n)=>{t.length===0&&e([]);const a=t.map(s=>o.request(s.methodName,s.args));o.request(a,(s,f)=>{if(s){n(s);return}e(f)})})}const $l=se(Bl),Kl=se(Al),Wl=se(_l),ql=se(Rl),Hl=se(Tl),jl=se(Ml),Vl=se(H()),Gl=Je(ut({total:H(),circulating:H(),nonCirculating:H(),nonCirculatingAccounts:kt(Ge)})),fs=ut({amount:gt(),uiAmount:St(H()),decimals:H(),uiAmountString:$t(gt())}),Yl=Je(kt(ut({address:Ge,amount:gt(),uiAmount:St(H()),decimals:H(),uiAmountString:$t(gt())}))),Zl=Je(kt(ut({pubkey:Ge,account:ut({executable:Gr(),owner:Ge,lamports:H(),data:cs,rentEpoch:H()})}))),hs=ut({program:gt(),parsed:Yn(),space:H()}),Jl=Je(kt(ut({pubkey:Ge,account:ut({executable:Gr(),owner:Ge,lamports:H(),data:hs,rentEpoch:H()})}))),Xl=Je(kt(ut({lamports:H(),address:Ge}))),Ei=ut({executable:Gr(),owner:Ge,lamports:H(),data:cs,rentEpoch:H()}),Ql=ut({pubkey:Ge,account:Ei}),t0=li(Br([$o(Nt.Buffer),hs]),Br([wc,hs]),o=>Array.isArray(o)?bt(o,cs):o),ls=ut({executable:Gr(),owner:Ge,lamports:H(),data:t0,rentEpoch:H()}),e0=ut({pubkey:Ge,account:ls}),r0=ut({state:Br([Ve("active"),Ve("inactive"),Ve("activating"),Ve("deactivating")]),active:H(),inactive:H()}),n0=se(kt(ut({signature:gt(),slot:H(),err:Un,memo:St(gt()),blockTime:$t(St(H()))}))),i0=se(kt(ut({signature:gt(),slot:H(),err:Un,memo:St(gt()),blockTime:$t(St(H()))}))),o0=ut({subscription:H(),result:Xi(Ei)}),s0=ut({pubkey:Ge,account:Ei}),a0=ut({subscription:H(),result:Xi(s0)}),c0=ut({parent:H(),slot:H(),root:H()}),u0=ut({subscription:H(),result:c0}),f0=Br([ut({type:Br([Ve("firstShredReceived"),Ve("completed"),Ve("optimisticConfirmation"),Ve("root")]),slot:H(),timestamp:H()}),ut({type:Ve("createdBank"),parent:H(),slot:H(),timestamp:H()}),ut({type:Ve("frozen"),slot:H(),timestamp:H(),stats:ut({numTransactionEntries:H(),numSuccessfulTransactions:H(),numFailedTransactions:H(),maxTransactionsPerEntry:H()})}),ut({type:Ve("dead"),slot:H(),timestamp:H(),err:gt()})]),h0=ut({subscription:H(),result:f0}),l0=ut({subscription:H(),result:Xi(Br([Pl,Ul]))}),d0=ut({subscription:H(),result:H()}),p0=ut({pubkey:gt(),gossip:St(gt()),tpu:St(gt()),rpc:St(gt()),version:St(gt())}),kc=ut({votePubkey:gt(),nodePubkey:gt(),activatedStake:H(),epochVoteAccount:Gr(),epochCredits:kt(Ko([H(),H(),H()])),commission:H(),lastVote:H(),rootSlot:St(H())}),y0=se(ut({current:kt(kc),delinquent:kt(kc)})),g0=Br([Ve("processed"),Ve("confirmed"),Ve("finalized")]),w0=ut({slot:H(),confirmations:St(H()),err:Un,confirmationStatus:$t(g0)}),m0=Je(kt(St(w0))),b0=se(H()),Sc=ut({accountKey:Ge,writableIndexes:kt(H()),readonlyIndexes:kt(H())}),ds=ut({signatures:kt(gt()),message:ut({accountKeys:kt(gt()),header:ut({numRequiredSignatures:H(),numReadonlySignedAccounts:H(),numReadonlyUnsignedAccounts:H()}),instructions:kt(ut({accounts:kt(H()),data:gt(),programIdIndex:H()})),recentBlockhash:gt(),addressTableLookups:$t(kt(Sc))})}),Ic=ut({pubkey:Ge,signer:Gr(),writable:Gr(),source:$t(Br([Ve("transaction"),Ve("lookupTable")]))}),Bc=ut({accountKeys:kt(Ic),signatures:kt(gt())}),vc=ut({parsed:Yn(),program:gt(),programId:Ge}),_c=ut({accounts:kt(Ge),data:gt(),programId:Ge}),x0=Br([_c,vc]),E0=Br([ut({parsed:Yn(),program:gt(),programId:gt()}),ut({accounts:kt(gt()),data:gt(),programId:gt()})]),Ac=li(x0,E0,o=>"accounts"in o?bt(o,_c):bt(o,vc)),Rc=ut({signatures:kt(gt()),message:ut({accountKeys:kt(Ic),instructions:kt(Ac),recentBlockhash:gt(),addressTableLookups:$t(St(kt(Sc)))})}),Qi=ut({accountIndex:H(),mint:gt(),owner:$t(gt()),uiTokenAmount:fs}),Tc=ut({writable:kt(Ge),readonly:kt(Ge)}),to=ut({err:Un,fee:H(),innerInstructions:$t(St(kt(ut({index:H(),instructions:kt(ut({accounts:kt(H()),data:gt(),programIdIndex:H()}))})))),preBalances:kt(H()),postBalances:kt(H()),logMessages:$t(St(kt(gt()))),preTokenBalances:$t(St(kt(Qi))),postTokenBalances:$t(St(kt(Qi))),loadedAddresses:$t(Tc),computeUnitsConsumed:$t(H())}),ps=ut({err:Un,fee:H(),innerInstructions:$t(St(kt(ut({index:H(),instructions:kt(Ac)})))),preBalances:kt(H()),postBalances:kt(H()),logMessages:$t(St(kt(gt()))),preTokenBalances:$t(St(kt(Qi))),postTokenBalances:$t(St(kt(Qi))),loadedAddresses:$t(Tc),computeUnitsConsumed:$t(H())}),Qn=Br([Ve(0),Ve("legacy")]),Cn=ut({pubkey:gt(),lamports:H(),postBalance:St(H()),rewardType:St(gt()),commission:$t(St(H()))}),k0=se(St(ut({blockhash:gt(),previousBlockhash:gt(),parentSlot:H(),transactions:kt(ut({transaction:ds,meta:St(to),version:$t(Qn)})),rewards:$t(kt(Cn)),blockTime:St(H()),blockHeight:St(H())}))),S0=se(St(ut({blockhash:gt(),previousBlockhash:gt(),parentSlot:H(),rewards:$t(kt(Cn)),blockTime:St(H()),blockHeight:St(H())}))),I0=se(St(ut({blockhash:gt(),previousBlockhash:gt(),parentSlot:H(),transactions:kt(ut({transaction:Bc,meta:St(to),version:$t(Qn)})),rewards:$t(kt(Cn)),blockTime:St(H()),blockHeight:St(H())}))),B0=se(St(ut({blockhash:gt(),previousBlockhash:gt(),parentSlot:H(),transactions:kt(ut({transaction:Rc,meta:St(ps),version:$t(Qn)})),rewards:$t(kt(Cn)),blockTime:St(H()),blockHeight:St(H())}))),v0=se(St(ut({blockhash:gt(),previousBlockhash:gt(),parentSlot:H(),transactions:kt(ut({transaction:Bc,meta:St(ps),version:$t(Qn)})),rewards:$t(kt(Cn)),blockTime:St(H()),blockHeight:St(H())}))),_0=se(St(ut({blockhash:gt(),previousBlockhash:gt(),parentSlot:H(),rewards:$t(kt(Cn)),blockTime:St(H()),blockHeight:St(H())}))),A0=se(St(ut({blockhash:gt(),previousBlockhash:gt(),parentSlot:H(),transactions:kt(ut({transaction:ds,meta:St(to)})),rewards:$t(kt(Cn)),blockTime:St(H())}))),Mc=se(St(ut({blockhash:gt(),previousBlockhash:gt(),parentSlot:H(),signatures:kt(gt()),blockTime:St(H())}))),ys=se(St(ut({slot:H(),meta:St(to),blockTime:$t(St(H())),transaction:ds,version:$t(Qn)}))),eo=se(St(ut({slot:H(),transaction:Rc,meta:St(ps),blockTime:$t(St(H())),version:$t(Qn)}))),R0=Je(ut({blockhash:gt(),feeCalculator:ut({lamportsPerSignature:H()})})),T0=Je(ut({blockhash:gt(),lastValidBlockHeight:H()})),M0=Je(Gr()),P0=ut({slot:H(),numTransactions:H(),numSlots:H(),samplePeriodSecs:H()}),U0=se(kt(P0)),C0=Je(St(ut({feeCalculator:ut({lamportsPerSignature:H()})}))),L0=se(gt()),F0=se(gt()),O0=ut({err:Un,logs:kt(gt()),signature:gt()}),N0=ut({result:Xi(O0),subscription:H()}),z0={"solana-client":"js/1.0.0-maintenance"};class D0{constructor(t,e){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const x={};return async v=>{const{commitment:_,config:F}=De(v),L=this._buildArgs([],_,void 0,F),D=pc(L);return x[D]=x[D]??(async()=>{try{const C=await this._rpcRequest("getBlockHeight",L),z=bt(C,se(H()));if("error"in z)throw new Ot(z.error,"failed to get block height information");return z.result}finally{delete x[D]}})(),await x[D]}})();let n,a,s,f,u,y;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,n=e.wsEndpoint,a=e.httpHeaders,s=e.fetch,f=e.fetchMiddleware,u=e.disableRetryOnRateLimit,y=e.httpAgent),this._rpcEndpoint=Sl(t),this._rpcWsEndpoint=n||kl(t),this._rpcClient=Nl(t,a,s,f,u,y),this._rpcRequest=zl(this._rpcClient),this._rpcBatchRequest=Dl(this._rpcClient),this._rpcWebSocket=new ml(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgs([t.toBase58()],n,void 0,a),f=await this._rpcRequest("getBalance",s),u=bt(f,Je(H()));if("error"in u)throw new Ot(u.error,`failed to get balance for ${t.toBase58()}`);return u.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+n)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),n=bt(e,se(St(H())));if("error"in n)throw new Ot(n.error,`failed to get block time for slot ${t}`);return n.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=bt(t,se(H()));if("error"in e)throw new Ot(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=bt(t,Vl);if("error"in e)throw new Ot(e.error,"failed to get first available block");return e.result}async getSupply(t){let e={};typeof t=="string"?e={commitment:t}:t?e={...t,commitment:t&&t.commitment||this.commitment}:e={commitment:this.commitment};const n=await this._rpcRequest("getSupply",[e]),a=bt(n,Gl);if("error"in a)throw new Ot(a.error,"failed to get supply");return a.result}async getTokenSupply(t,e){const n=this._buildArgs([t.toBase58()],e),a=await this._rpcRequest("getTokenSupply",n),s=bt(a,Je(fs));if("error"in s)throw new Ot(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(t,e){const n=this._buildArgs([t.toBase58()],e),a=await this._rpcRequest("getTokenAccountBalance",n),s=bt(a,Je(fs));if("error"in s)throw new Ot(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(t,e,n){const{commitment:a,config:s}=De(n);let f=[t.toBase58()];"mint"in e?f.push({mint:e.mint.toBase58()}):f.push({programId:e.programId.toBase58()});const u=this._buildArgs(f,a,"base64",s),y=await this._rpcRequest("getTokenAccountsByOwner",u),x=bt(y,Zl);if("error"in x)throw new Ot(x.error,`failed to get token accounts owned by account ${t.toBase58()}`);return x.result}async getParsedTokenAccountsByOwner(t,e,n){let a=[t.toBase58()];"mint"in e?a.push({mint:e.mint.toBase58()}):a.push({programId:e.programId.toBase58()});const s=this._buildArgs(a,n,"jsonParsed"),f=await this._rpcRequest("getTokenAccountsByOwner",s),u=bt(f,Jl);if("error"in u)throw new Ot(u.error,`failed to get token accounts owned by account ${t.toBase58()}`);return u.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},n=e.filter||e.commitment?[e]:[],a=await this._rpcRequest("getLargestAccounts",n),s=bt(a,Xl);if("error"in s)throw new Ot(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(t,e){const n=this._buildArgs([t.toBase58()],e),a=await this._rpcRequest("getTokenLargestAccounts",n),s=bt(a,Yl);if("error"in s)throw new Ot(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgs([t.toBase58()],n,"base64",a),f=await this._rpcRequest("getAccountInfo",s),u=bt(f,Je(St(Ei)));if("error"in u)throw new Ot(u.error,`failed to get info about account ${t.toBase58()}`);return u.result}async getParsedAccountInfo(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgs([t.toBase58()],n,"jsonParsed",a),f=await this._rpcRequest("getAccountInfo",s),u=bt(f,Je(St(ls)));if("error"in u)throw new Ot(u.error,`failed to get info about account ${t.toBase58()}`);return u.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(n){throw new Error("failed to get info about account "+t.toBase58()+": "+n)}}async getMultipleParsedAccounts(t,e){const{commitment:n,config:a}=De(e),s=t.map(x=>x.toBase58()),f=this._buildArgs([s],n,"jsonParsed",a),u=await this._rpcRequest("getMultipleAccounts",f),y=bt(u,Je(kt(St(ls))));if("error"in y)throw new Ot(y.error,`failed to get info for accounts ${s}`);return y.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:n,config:a}=De(e),s=t.map(x=>x.toBase58()),f=this._buildArgs([s],n,"base64",a),u=await this._rpcRequest("getMultipleAccounts",f),y=bt(u,Je(kt(St(Ei))));if("error"in y)throw new Ot(y.error,`failed to get info for accounts ${s}`);return y.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,n){const{commitment:a,config:s}=De(e),f=this._buildArgs([t.toBase58()],a,void 0,{...s,epoch:n??(s==null?void 0:s.epoch)}),u=await this._rpcRequest("getStakeActivation",f),y=bt(u,se(r0));if("error"in y)throw new Ot(y.error,`failed to get Stake Activation ${t.toBase58()}`);return y.result}async getProgramAccounts(t,e){const{commitment:n,config:a}=De(e),{encoding:s,...f}=a||{},u=this._buildArgs([t.toBase58()],n,s||"base64",{...f,...f.filters?{filters:bc(f.filters)}:null}),y=await this._rpcRequest("getProgramAccounts",u),x=kt(Ql),v=f.withContext===!0?bt(y,Je(x)):bt(y,se(x));if("error"in v)throw new Ot(v.error,`failed to get accounts owned by program ${t.toBase58()}`);return v.result}async getParsedProgramAccounts(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgs([t.toBase58()],n,"jsonParsed",a),f=await this._rpcRequest("getProgramAccounts",s),u=bt(f,se(kt(e0)));if("error"in u)throw new Ot(u.error,`failed to get accounts owned by program ${t.toBase58()}`);return u.result}async confirmTransaction(t,e){var s;let n;if(typeof t=="string")n=t;else{const f=t;if((s=f.abortSignal)!=null&&s.aborted)return Promise.reject(f.abortSignal.reason);n=f.signature}let a;try{a=cr.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return Me(a.length===64,"signature has invalid length"),typeof t=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:n}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise((e,n)=>{t!=null&&(t.aborted?n(t.reason):t.addEventListener("abort",()=>{n(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let n,a,s=!1;const f=new Promise((y,x)=>{try{n=this.onSignature(e,(_,F)=>{n=void 0;const L={context:F,value:_};y({__type:sn.PROCESSED,response:L})},t);const v=new Promise(_=>{n==null?_():a=this._onSubscriptionStateChange(n,F=>{F==="subscribed"&&_()})});(async()=>{if(await v,s)return;const _=await this.getSignatureStatus(e);if(s||_==null)return;const{context:F,value:L}=_;if(L!=null)if(L!=null&&L.err)x(L.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(L.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(L.confirmationStatus==="processed"||L.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}s=!0,y({__type:sn.PROCESSED,response:{context:F,value:L}})}})()}catch(v){x(v)}});return{abortConfirmation:()=>{a&&(a(),a=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:f}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:n,signature:a}}){let s=!1;const f=new Promise(_=>{const F=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let L=await F();if(!s){for(;L<=n;)if(await Mn(1e3),s||(L=await F(),s))return;_({__type:sn.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:u,confirmationPromise:y}=this.getTransactionConfirmationPromise({commitment:t,signature:a}),x=this.getCancellationPromise(e);let v;try{const _=await Promise.race([x,y,f]);if(_.__type===sn.PROCESSED)v=_.response;else throw new Qo(a)}finally{s=!0,u()}return v}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:n,nonceAccountPubkey:a,nonceValue:s,signature:f}}){let u=!1;const y=new Promise(L=>{let D=s,C=null;const z=async()=>{try{const{context:$,value:X}=await this.getNonceAndContext(a,{commitment:t,minContextSlot:n});return C=$.slot,X==null?void 0:X.nonce}catch{return D}};(async()=>{if(D=await z(),!u)for(;;){if(s!==D){L({__type:sn.NONCE_INVALID,slotInWhichNonceDidAdvance:C});return}if(await Mn(2e3),u||(D=await z(),u))return}})()}),{abortConfirmation:x,confirmationPromise:v}=this.getTransactionConfirmationPromise({commitment:t,signature:f}),_=this.getCancellationPromise(e);let F;try{const L=await Promise.race([_,v,y]);if(L.__type===sn.PROCESSED)F=L.response;else{let D;for(;;){const C=await this.getSignatureStatus(f);if(C==null)break;if(C.context.slot<(L.slotInWhichNonceDidAdvance??n)){await Mn(400);continue}D=C;break}if(D!=null&&D.value){const C=t||"finalized",{confirmationStatus:z}=D.value;switch(C){case"processed":case"recent":if(z!=="processed"&&z!=="confirmed"&&z!=="finalized")throw new Zn(f);break;case"confirmed":case"single":case"singleGossip":if(z!=="confirmed"&&z!=="finalized")throw new Zn(f);break;case"finalized":case"max":case"root":if(z!=="finalized")throw new Zn(f);break;default:}F={context:D.context,value:{err:D.value.err}}}else throw new Zn(f)}}finally{u=!0,x()}return F}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let n;const a=new Promise(y=>{let x=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{x=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>y({__type:sn.TIMED_OUT,timeoutMs:x}),x)}),{abortConfirmation:s,confirmationPromise:f}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let u;try{const y=await Promise.race([f,a]);if(y.__type===sn.PROCESSED)u=y.response;else throw new ts(e,y.timeoutMs/1e3)}finally{clearTimeout(n),s()}return u}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=bt(t,se(kt(p0)));if("error"in e)throw new Ot(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getVoteAccounts",e),a=bt(n,y0);if("error"in a)throw new Ot(a.error,"failed to get vote accounts");return a.result}async getSlot(t){const{commitment:e,config:n}=De(t),a=this._buildArgs([],e,void 0,n),s=await this._rpcRequest("getSlot",a),f=bt(s,se(H()));if("error"in f)throw new Ot(f.error,"failed to get slot");return f.result}async getSlotLeader(t){const{commitment:e,config:n}=De(t),a=this._buildArgs([],e,void 0,n),s=await this._rpcRequest("getSlotLeader",a),f=bt(s,se(gt()));if("error"in f)throw new Ot(f.error,"failed to get slot leader");return f.result}async getSlotLeaders(t,e){const n=[t,e],a=await this._rpcRequest("getSlotLeaders",n),s=bt(a,se(kt(Ge)));if("error"in s)throw new Ot(s.error,"failed to get slot leaders");return s.result}async getSignatureStatus(t,e){const{context:n,value:a}=await this.getSignatureStatuses([t],e);Me(a.length===1);const s=a[0];return{context:n,value:s}}async getSignatureStatuses(t,e){const n=[t];e&&n.push(e);const a=await this._rpcRequest("getSignatureStatuses",n),s=bt(a,m0);if("error"in s)throw new Ot(s.error,"failed to get signature status");return s.result}async getTransactionCount(t){const{commitment:e,config:n}=De(t),a=this._buildArgs([],e,void 0,n),s=await this._rpcRequest("getTransactionCount",a),f=bt(s,se(H()));if("error"in f)throw new Ot(f.error,"failed to get transaction count");return f.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getInflationGovernor",e),a=bt(n,$l);if("error"in a)throw new Ot(a.error,"failed to get inflation");return a.result}async getInflationReward(t,e,n){const{commitment:a,config:s}=De(n),f=this._buildArgs([t.map(x=>x.toBase58())],a,void 0,{...s,epoch:e??(s==null?void 0:s.epoch)}),u=await this._rpcRequest("getInflationReward",f),y=bt(u,vl);if("error"in y)throw new Ot(y.error,"failed to get inflation reward");return y.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=bt(t,Kl);if("error"in e)throw new Ot(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:n}=De(t),a=this._buildArgs([],e,void 0,n),s=await this._rpcRequest("getEpochInfo",a),f=bt(s,ql);if("error"in f)throw new Ot(f.error,"failed to get epoch info");return f.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=bt(t,Hl);if("error"in e)throw new Ot(e.error,"failed to get epoch schedule");const n=e.result;return new yc(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=bt(t,jl);if("error"in e)throw new Ot(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const n=this._buildArgs([t],e),a=await this._rpcRequest("getMinimumBalanceForRentExemption",n),s=bt(a,b0);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getRecentBlockhash",e),a=bt(n,R0);if("error"in a)throw new Ot(a.error,"failed to get recent blockhash");return a.result}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),n=bt(e,U0);if("error"in n)throw new Ot(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(t,e){const n=this._buildArgs([t],e),a=await this._rpcRequest("getFeeCalculatorForBlockhash",n),s=bt(a,C0);if("error"in s)throw new Ot(s.error,"failed to get fee calculator");const{context:f,value:u}=s.result;return{context:f,value:u!==null?u.feeCalculator:null}}async getFeeForMessage(t,e){const n=oe(t.serialize()).toString("base64"),a=this._buildArgs([n],e),s=await this._rpcRequest("getFeeForMessage",a),f=bt(s,Je(St(H())));if("error"in f)throw new Ot(f.error,"failed to get fee for message");if(f.result===null)throw new Error("invalid blockhash");return f.result}async getRecentPrioritizationFees(t){var f;const e=(f=t==null?void 0:t.lockedWritableAccounts)==null?void 0:f.map(u=>u.toBase58()),n=e!=null&&e.length?[e]:[],a=await this._rpcRequest("getRecentPrioritizationFees",n),s=bt(a,Wl);if("error"in s)throw new Ot(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:n}=De(t),a=this._buildArgs([],e,void 0,n),s=await this._rpcRequest("getLatestBlockhash",a),f=bt(s,T0);if("error"in f)throw new Ot(f.error,"failed to get latest blockhash");return f.result}async isBlockhashValid(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgs([t],n,void 0,a),f=await this._rpcRequest("isBlockhashValid",s),u=bt(f,M0);if("error"in u)throw new Ot(u.error,"failed to determine if the blockhash `"+t+"`is valid");return u.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=bt(t,se(Cl));if("error"in e)throw new Ot(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=bt(t,se(gt()));if("error"in e)throw new Ot(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgsAtLeastConfirmed([t],n,void 0,a),f=await this._rpcRequest("getBlock",s);try{switch(a==null?void 0:a.transactionDetails){case"accounts":{const u=bt(f,I0);if("error"in u)throw u.error;return u.result}case"none":{const u=bt(f,S0);if("error"in u)throw u.error;return u.result}default:{const u=bt(f,k0);if("error"in u)throw u.error;const{result:y}=u;return y?{...y,transactions:y.transactions.map(({transaction:x,meta:v,version:_})=>({meta:v,transaction:{...x,message:us(_,x.message)},version:_}))}:null}}}catch(u){throw new Ot(u,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",a),f=await this._rpcRequest("getBlock",s);try{switch(a==null?void 0:a.transactionDetails){case"accounts":{const u=bt(f,v0);if("error"in u)throw u.error;return u.result}case"none":{const u=bt(f,_0);if("error"in u)throw u.error;return u.result}default:{const u=bt(f,B0);if("error"in u)throw u.error;return u.result}}}catch(u){throw new Ot(u,"failed to get block")}}async getBlockProduction(t){let e,n;if(typeof t=="string")n=t;else if(t){const{commitment:u,...y}=t;n=u,e=y}const a=this._buildArgs([],n,"base64",e),s=await this._rpcRequest("getBlockProduction",a),f=bt(s,Ol);if("error"in f)throw new Ot(f.error,"failed to get block production information");return f.result}async getTransaction(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgsAtLeastConfirmed([t],n,void 0,a),f=await this._rpcRequest("getTransaction",s),u=bt(f,ys);if("error"in u)throw new Ot(u.error,"failed to get transaction");const y=u.result;return y&&{...y,transaction:{...y.transaction,message:us(y.version,y.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",a),f=await this._rpcRequest("getTransaction",s),u=bt(f,eo);if("error"in u)throw new Ot(u.error,"failed to get transaction");return u.result}async getParsedTransactions(t,e){const{commitment:n,config:a}=De(e),s=t.map(y=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([y],n,"jsonParsed",a)}));return(await this._rpcBatchRequest(s)).map(y=>{const x=bt(y,eo);if("error"in x)throw new Ot(x.error,"failed to get transactions");return x.result})}async getTransactions(t,e){const{commitment:n,config:a}=De(e),s=t.map(y=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([y],n,void 0,a)}));return(await this._rpcBatchRequest(s)).map(y=>{const x=bt(y,ys);if("error"in x)throw new Ot(x.error,"failed to get transactions");const v=x.result;return v&&{...v,transaction:{...v.transaction,message:us(v.version,v.transaction.message)}}})}async getConfirmedBlock(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),a=await this._rpcRequest("getConfirmedBlock",n),s=bt(a,A0);if("error"in s)throw new Ot(s.error,"failed to get confirmed block");const f=s.result;if(!f)throw new Error("Confirmed block "+t+" not found");const u={...f,transactions:f.transactions.map(({transaction:y,meta:x})=>{const v=new $r(y.message);return{meta:x,transaction:{...y,message:v}}})};return{...u,transactions:u.transactions.map(({transaction:y,meta:x})=>({meta:x,transaction:_e.populate(y.message,y.signatures)}))}}async getBlocks(t,e,n){const a=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],n),s=await this._rpcRequest("getBlocks",a),f=bt(s,se(kt(H())));if("error"in f)throw new Ot(f.error,"failed to get blocks");return f.result}async getBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),a=await this._rpcRequest("getBlock",n),s=bt(a,Mc);if("error"in s)throw new Ot(s.error,"failed to get block");const f=s.result;if(!f)throw new Error("Block "+t+" not found");return f}async getConfirmedBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),a=await this._rpcRequest("getConfirmedBlock",n),s=bt(a,Mc);if("error"in s)throw new Ot(s.error,"failed to get confirmed block");const f=s.result;if(!f)throw new Error("Confirmed block "+t+" not found");return f}async getConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),a=await this._rpcRequest("getConfirmedTransaction",n),s=bt(a,ys);if("error"in s)throw new Ot(s.error,"failed to get transaction");const f=s.result;if(!f)return f;const u=new $r(f.transaction.message),y=f.transaction.signatures;return{...f,transaction:_e.populate(u,y)}}async getParsedConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),a=await this._rpcRequest("getConfirmedTransaction",n),s=bt(a,eo);if("error"in s)throw new Ot(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(t,e){const n=t.map(f=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([f],e,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(f=>{const u=bt(f,eo);if("error"in u)throw new Ot(u.error,"failed to get confirmed transactions");return u.result})}async getConfirmedSignaturesForAddress(t,e,n){let a={},s=await this.getFirstAvailableBlock();for(;!("until"in a)&&(e--,!(e<=0||e<s));)try{const y=await this.getConfirmedBlockSignatures(e,"finalized");y.signatures.length>0&&(a.until=y.signatures[y.signatures.length-1].toString())}catch(y){if(y instanceof Error&&y.message.includes("skipped"))continue;throw y}let f=await this.getSlot("finalized");for(;!("before"in a)&&(n++,!(n>f));)try{const y=await this.getConfirmedBlockSignatures(n);y.signatures.length>0&&(a.before=y.signatures[y.signatures.length-1].toString())}catch(y){if(y instanceof Error&&y.message.includes("skipped"))continue;throw y}return(await this.getConfirmedSignaturesForAddress2(t,a)).map(y=>y.signature)}async getConfirmedSignaturesForAddress2(t,e,n){const a=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",a),f=bt(s,n0);if("error"in f)throw new Ot(f.error,"failed to get confirmed signatures for address");return f.result}async getSignaturesForAddress(t,e,n){const a=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),s=await this._rpcRequest("getSignaturesForAddress",a),f=bt(s,i0);if("error"in f)throw new Ot(f.error,"failed to get signatures for address");return f.result}async getAddressLookupTable(t,e){const{context:n,value:a}=await this.getAccountInfoAndContext(t,e);let s=null;return a!==null&&(s=new as({key:t,state:as.deserialize(a.data)})),{context:n,value:s}}async getNonceAndContext(t,e){const{context:n,value:a}=await this.getAccountInfoAndContext(t,e);let s=null;return a!==null&&(s=Ji.fromAccountData(a.data)),{context:n,value:s}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+n)})}async requestAirdrop(t,e){const n=await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),a=bt(n,L0);if("error"in a)throw new Ot(a.error,`airdrop to ${t.toBase58()} failed`);return a.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Mn(100);const n=Date.now()-this._blockhashInfo.lastFetch>=mc;if(this._blockhashInfo.latestBlockhash!==null&&!n)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,n=e?e.blockhash:null;for(let a=0;a<50;a++){const s=await this.getLatestBlockhash("finalized");if(n!==s.blockhash)return this._blockhashInfo={latestBlockhash:s,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},s;await Mn(hc/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:n}=De(t),a=this._buildArgs([],e,"base64",n),s=await this._rpcRequest("getStakeMinimumDelegation",a),f=bt(s,Je(H()));if("error"in f)throw new Ot(f.error,"failed to get stake minimum delegation");return f.result}async simulateTransaction(t,e,n){if("message"in t){const C=t.serialize(),z=Nt.Buffer.from(C).toString("base64");if(Array.isArray(e)||n!==void 0)throw new Error("Invalid arguments");const $=e||{};$.encoding="base64","commitment"in $||($.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&($.innerInstructions=e.innerInstructions);const X=[z,$],j=await this._rpcRequest("simulateTransaction",X),it=bt(j,Ec);if("error"in it)throw new Error("failed to simulate transaction: "+it.error.message);return it.result}let a;if(t instanceof _e){let D=t;a=new _e,a.feePayer=D.feePayer,a.instructions=t.instructions,a.nonceInfo=D.nonceInfo,a.signatures=D.signatures}else a=_e.populate(t),a._message=a._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(a.nonceInfo&&s)a.sign(...s);else{let D=this._disableBlockhashCaching;for(;;){const C=await this._blockhashWithExpiryBlockHeight(D);if(a.lastValidBlockHeight=C.lastValidBlockHeight,a.recentBlockhash=C.blockhash,!s)break;if(a.sign(...s),!a.signature)throw new Error("!signature");const z=a.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(z)&&!this._blockhashInfo.transactionSignatures.includes(z)){this._blockhashInfo.simulatedSignatures.push(z);break}else D=!0}}const f=a._compile(),u=f.serialize(),x=a._serialize(u).toString("base64"),v={encoding:"base64",commitment:this.commitment};if(n){const D=(Array.isArray(n)?n:f.nonProgramIds()).map(C=>C.toBase58());v.accounts={encoding:"base64",addresses:D}}s&&(v.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(v.innerInstructions=e.innerInstructions);const _=[x,v],F=await this._rpcRequest("simulateTransaction",_),L=bt(F,Ec);if("error"in L){let D;if("data"in L.error&&(D=L.error.data.logs,D&&Array.isArray(D))){const C=`
23
- `,z=C+D.join(C);console.error(L.error.message,z)}throw new mi({action:"simulate",signature:"",transactionMessage:L.error.message,logs:D})}return L.result}async sendTransaction(t,e,n){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const f=t.serialize();return await this.sendRawTransaction(f,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const a=e;if(t.nonceInfo)t.sign(...a);else{let f=this._disableBlockhashCaching;for(;;){const u=await this._blockhashWithExpiryBlockHeight(f);if(t.lastValidBlockHeight=u.lastValidBlockHeight,t.recentBlockhash=u.blockhash,t.sign(...a),!t.signature)throw new Error("!signature");const y=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(y))f=!0;else{this._blockhashInfo.transactionSignatures.push(y);break}}}const s=t.serialize();return await this.sendRawTransaction(s,n)}async sendRawTransaction(t,e){const n=oe(t).toString("base64");return await this.sendEncodedTransaction(n,e)}async sendEncodedTransaction(t,e){const n={encoding:"base64"},a=e&&e.skipPreflight,s=a===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(n.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(n.minContextSlot=e.minContextSlot),a&&(n.skipPreflight=a),s&&(n.preflightCommitment=s);const f=[t,n],u=await this._rpcRequest("sendTransaction",f),y=bt(u,F0);if("error"in y){let x;throw"data"in y.error&&(x=y.error.data.logs),new mi({action:a?"send":"simulate",signature:"",transactionMessage:y.error.message,logs:x})}return y.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),t===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,n])=>{this._setSubscription(e,{...n,state:"pending"})})}_setSubscription(t,e){var a;const n=(a=this._subscriptionsByHash[t])==null?void 0:a.state;if(this._subscriptionsByHash[t]=e,n!==e.state){const s=this._subscriptionStateChangeCallbacksByHash[t];s&&s.forEach(f=>{try{f(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var s;const n=this._subscriptionHashByClientSubscriptionId[t];if(n==null)return()=>{};const a=(s=this._subscriptionStateChangeCallbacksByHash)[n]||(s[n]=new Set);return a.add(e),()=>{a.delete(e),a.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{const a=this._subscriptionsByHash[n];if(a!==void 0)switch(a.state){case"pending":case"unsubscribed":if(a.callbacks.size===0){delete this._subscriptionsByHash[n],a.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[a.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:s,method:f}=a;try{this._setSubscription(n,{...a,state:"subscribing"});const u=await this._rpcWebSocket.call(f,s);this._setSubscription(n,{...a,serverSubscriptionId:u,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[u]=a.callbacks,await this._updateSubscriptions()}catch(u){if(u instanceof Error&&console.error(`${f} error for argument`,s,u.message),!e())return;this._setSubscription(n,{...a,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":a.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:s,unsubscribeMethod:f}=a;if(this._subscriptionsAutoDisposedByRpc.has(s))this._subscriptionsAutoDisposedByRpc.delete(s);else{this._setSubscription(n,{...a,state:"unsubscribing"}),this._setSubscription(n,{...a,state:"unsubscribing"});try{await this._rpcWebSocket.call(f,[s])}catch(u){if(u instanceof Error&&console.error(`${f} error:`,u.message),!e())return;this._setSubscription(n,{...a,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...a,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const n=this._subscriptionCallbacksByServerSubscriptionId[t];n!==void 0&&n.forEach(a=>{try{a(...e)}catch(s){console.error(s)}})}_wsOnAccountNotification(t){const{result:e,subscription:n}=bt(t,o0);this._handleServerNotification(n,[e.value,e.context])}_makeSubscription(t,e){const n=this._nextClientSubscriptionId++,a=pc([t.method,e]),s=this._subscriptionsByHash[a];return s===void 0?this._subscriptionsByHash[a]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:s.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[n]=a,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const f=this._subscriptionsByHash[a];Me(f!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),f.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(t,e,n){const{commitment:a,config:s}=De(n),f=this._buildArgs([t.toBase58()],a||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},f)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:n}=bt(t,a0);this._handleServerNotification(n,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,n,a){const{commitment:s,config:f}=De(n),u=this._buildArgs([t.toBase58()],s||this._commitment||"finalized","base64",f||(a?{filters:bc(a)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},u)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,n){const a=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],n||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},a)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:n}=bt(t,N0);this._handleServerNotification(n,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:n}=bt(t,u0);this._handleServerNotification(n,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:n}=bt(t,h0);this._handleServerNotification(n,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,n,a){const s=e||this._commitment;if(s||n||a){let f={};n&&(f.encoding=n),s&&(f.commitment=s),a&&(f=Object.assign(f,a)),t.push(f)}return t}_buildArgsAtLeastConfirmed(t,e,n,a){const s=e||this._commitment;if(s&&!["confirmed","finalized"].includes(s))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,n,a)}_wsOnSignatureNotification(t){const{result:e,subscription:n}=bt(t,l0);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,n){const a=this._buildArgs([t],n||this._commitment||"finalized"),s=this._makeSubscription({callback:(f,u)=>{if(f.type==="status"){e(f.result,u);try{this.removeSignatureListener(s)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},a);return s}onSignatureWithOptions(t,e,n){const{commitment:a,...s}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},f=this._buildArgs([t],a,void 0,s),u=this._makeSubscription({callback:(y,x)=>{e(y,x);try{this.removeSignatureListener(u)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},f);return u}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:n}=bt(t,d0);this._handleServerNotification(n,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}class Ln{constructor(t){this._keypair=void 0,this._keypair=t??ic()}static generate(){return new Ln(ic())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");const n=t.slice(32,64);if(!e||!e.skipValidation){const a=t.slice(0,32),s=ji(a);for(let f=0;f<32;f++)if(n[f]!==s[f])throw new Error("provided secretKey is invalid")}return new Ln({publicKey:n,secretKey:t})}static fromSeed(t){const e=ji(t),n=new Uint8Array(64);return n.set(t),n.set(e,32),new Ln({publicKey:e,secretKey:n})}get publicKey(){return new mt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const an=Object.freeze({CreateLookupTable:{index:0,layout:Pt([Mt("instruction"),Xn("recentSlot"),ve("bumpSeed")])},FreezeLookupTable:{index:1,layout:Pt([Mt("instruction")])},ExtendLookupTable:{index:2,layout:Pt([Mt("instruction"),Xn(),pr(pe(),pn(Mt(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Pt([Mt("instruction")])},CloseLookupTable:{index:4,layout:Pt([Mt("instruction")])}});class $0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=Mt("instruction").decode(t.data);let a;for(const[s,f]of Object.entries(an))if(f.index==n){a=s;break}if(!a)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return a}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=Ue(an.CreateLookupTable,t.data);return{authority:t.keys[1].pubkey,payer:t.keys[2].pubkey,recentSlot:Number(e)}}static decodeExtendLookupTable(t){if(this.checkProgramId(t.programId),t.keys.length<2)throw new Error(`invalid instruction; found ${t.keys.length} keys, expected at least 2`);const{addresses:e}=Ue(an.ExtendLookupTable,t.data);return{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,payer:t.keys.length>2?t.keys[2].pubkey:void 0,addresses:e.map(n=>new mt(n))}}static decodeCloseLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}static decodeFreezeLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static decodeDeactivateLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(gs.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}class gs{constructor(){}static createLookupTable(t){const[e,n]=mt.findProgramAddressSync([t.authority.toBuffer(),Ua(BigInt(t.recentSlot),8)],this.programId),a=an.CreateLookupTable,s=xe(a,{recentSlot:BigInt(t.recentSlot),bumpSeed:n}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:ur.programId,isSigner:!1,isWritable:!1}];return[new Ne({programId:this.programId,keys:f,data:s}),e]}static freezeLookupTable(t){const e=an.FreezeLookupTable,n=xe(e),a=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ne({programId:this.programId,keys:a,data:n})}static extendLookupTable(t){const e=an.ExtendLookupTable,n=xe(e,{addresses:t.addresses.map(s=>s.toBytes())}),a=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&a.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:ur.programId,isSigner:!1,isWritable:!1}),new Ne({programId:this.programId,keys:a,data:n})}static deactivateLookupTable(t){const e=an.DeactivateLookupTable,n=xe(e),a=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ne({programId:this.programId,keys:a,data:n})}static closeLookupTable(t){const e=an.CloseLookupTable,n=xe(e),a=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Ne({programId:this.programId,keys:a,data:n})}}gs.programId=new mt("AddressLookupTab1e1111111111111111111111111");class K0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=ve("instruction").decode(t.data);let a;for(const[s,f]of Object.entries(Xr))if(f.index==n){a=s;break}if(!a)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return a}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:n}=Ue(Xr.RequestUnits,t.data);return{units:e,additionalFee:n}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Ue(Xr.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Ue(Xr.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Ue(Xr.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(ws.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Xr=Object.freeze({RequestUnits:{index:0,layout:Pt([ve("instruction"),Mt("units"),Mt("additionalFee")])},RequestHeapFrame:{index:1,layout:Pt([ve("instruction"),Mt("bytes")])},SetComputeUnitLimit:{index:2,layout:Pt([ve("instruction"),Mt("units")])},SetComputeUnitPrice:{index:3,layout:Pt([ve("instruction"),Xn("microLamports")])}});class ws{constructor(){}static requestUnits(t){const e=Xr.RequestUnits,n=xe(e,t);return new Ne({keys:[],programId:this.programId,data:n})}static requestHeapFrame(t){const e=Xr.RequestHeapFrame,n=xe(e,t);return new Ne({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(t){const e=Xr.SetComputeUnitLimit,n=xe(e,t);return new Ne({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(t){const e=Xr.SetComputeUnitPrice,n=xe(e,{microLamports:BigInt(t.microLamports)});return new Ne({keys:[],programId:this.programId,data:n})}}ws.programId=new mt("ComputeBudget111111111111111111111111111111");const Pc=64,Uc=32,Cc=64,Lc=Pt([ve("numSignatures"),ve("padding"),Lr("signatureOffset"),Lr("signatureInstructionIndex"),Lr("publicKeyOffset"),Lr("publicKeyInstructionIndex"),Lr("messageDataOffset"),Lr("messageDataSize"),Lr("messageInstructionIndex")]);class ro{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:n,signature:a,instructionIndex:s}=t;Me(e.length===Uc,`Public Key must be ${Uc} bytes but received ${e.length} bytes`),Me(a.length===Cc,`Signature must be ${Cc} bytes but received ${a.length} bytes`);const f=Lc.span,u=f+e.length,y=u+a.length,x=1,v=Nt.Buffer.alloc(y+n.length),_=s??65535;return Lc.encode({numSignatures:x,padding:0,signatureOffset:u,signatureInstructionIndex:_,publicKeyOffset:f,publicKeyInstructionIndex:_,messageDataOffset:y,messageDataSize:n.length,messageInstructionIndex:_},v),v.fill(e,f),v.fill(a,u),v.fill(n,y),new Ne({keys:[],programId:ro.programId,data:v})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:n,instructionIndex:a}=t;Me(e.length===Pc,`Private key must be ${Pc} bytes but received ${e.length} bytes`);try{const s=Ln.fromSecretKey(e),f=s.publicKey.toBytes(),u=Jo(n,s.secretKey);return this.createInstructionWithPublicKey({publicKey:f,message:n,signature:u,instructionIndex:a})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}ro.programId=new mt("Ed25519SigVerify111111111111111111111111111");const W0=(o,t)=>{const e=Hi.sign(o,t);return[e.toCompactRawBytes(),e.recovery]};Hi.utils.isValidPrivateKey;const q0=Hi.getPublicKey,Fc=32,ms=20,Oc=64,H0=11,bs=Pt([ve("numSignatures"),Lr("signatureOffset"),ve("signatureInstructionIndex"),Lr("ethAddressOffset"),ve("ethAddressInstructionIndex"),Lr("messageDataOffset"),Lr("messageDataSize"),ve("messageInstructionIndex"),Ke(20,"ethAddress"),Ke(64,"signature"),ve("recoveryId")]);class ti{constructor(){}static publicKeyToEthAddress(t){Me(t.length===Oc,`Public key must be ${Oc} bytes but received ${t.length} bytes`);try{return Nt.Buffer.from(Ja(oe(t))).slice(-ms)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:n,signature:a,recoveryId:s,instructionIndex:f}=t;return ti.createInstructionWithEthAddress({ethAddress:ti.publicKeyToEthAddress(e),message:n,signature:a,recoveryId:s,instructionIndex:f})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:n,signature:a,recoveryId:s,instructionIndex:f=0}=t;let u;typeof e=="string"?e.startsWith("0x")?u=Nt.Buffer.from(e.substr(2),"hex"):u=Nt.Buffer.from(e,"hex"):u=e,Me(u.length===ms,`Address must be ${ms} bytes but received ${u.length} bytes`);const y=1+H0,x=y,v=y+u.length,_=v+a.length+1,F=1,L=Nt.Buffer.alloc(bs.span+n.length);return bs.encode({numSignatures:F,signatureOffset:v,signatureInstructionIndex:f,ethAddressOffset:x,ethAddressInstructionIndex:f,messageDataOffset:_,messageDataSize:n.length,messageInstructionIndex:f,signature:oe(a),ethAddress:oe(u),recoveryId:s},L),L.fill(oe(n),bs.span),new Ne({keys:[],programId:ti.programId,data:L})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:n,instructionIndex:a}=t;Me(e.length===Fc,`Private key must be ${Fc} bytes but received ${e.length} bytes`);try{const s=oe(e),f=q0(s,!1).slice(1),u=Nt.Buffer.from(Ja(oe(n))),[y,x]=W0(u,s);return this.createInstructionWithPublicKey({publicKey:f,message:n,signature:y,recoveryId:x,instructionIndex:a})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}ti.programId=new mt("KeccakSecp256k11111111111111111111111111111");var Nc;const zc=new mt("StakeConfig11111111111111111111111111111111");class Dc{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class ki{constructor(t,e,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=n}}Nc=ki,ki.default=new Nc(0,0,mt.default);class j0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=Mt("instruction").decode(t.data);let a;for(const[s,f]of Object.entries(fr))if(f.index==n){a=s;break}if(!a)throw new Error("Instruction type incorrect; not a StakeInstruction");return a}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:n}=Ue(fr.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new Dc(new mt(e.staker),new mt(e.withdrawer)),lockup:new ki(n.unixTimestamp,n.epoch,new mt(n.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),Ue(fr.Delegate,t.data),{stakePubkey:t.keys[0].pubkey,votePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[5].pubkey}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,stakeAuthorizationType:n}=Ue(fr.Authorize,t.data),a={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new mt(e),stakeAuthorizationType:{index:n}};return t.keys.length>3&&(a.custodianPubkey=t.keys[3].pubkey),a}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:n,authoritySeed:a,authorityOwner:s}=Ue(fr.AuthorizeWithSeed,t.data),f={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:a,authorityOwner:new mt(s),newAuthorizedPubkey:new mt(e),stakeAuthorizationType:{index:n}};return t.keys.length>3&&(f.custodianPubkey=t.keys[3].pubkey),f}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ue(fr.Split,t.data);return{stakePubkey:t.keys[0].pubkey,splitStakePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[2].pubkey,lamports:e}}static decodeMerge(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ue(fr.Merge,t.data),{stakePubkey:t.keys[0].pubkey,sourceStakePubKey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Ue(fr.Withdraw,t.data),n={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(n.custodianPubkey=t.keys[5].pubkey),n}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ue(fr.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(no.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const fr=Object.freeze({Initialize:{index:0,layout:Pt([Mt("instruction"),Zh(),Jh()])},Authorize:{index:1,layout:Pt([Mt("instruction"),pe("newAuthorized"),Mt("stakeAuthorizationType")])},Delegate:{index:2,layout:Pt([Mt("instruction")])},Split:{index:3,layout:Pt([Mt("instruction"),Mr("lamports")])},Withdraw:{index:4,layout:Pt([Mt("instruction"),Mr("lamports")])},Deactivate:{index:5,layout:Pt([Mt("instruction")])},Merge:{index:7,layout:Pt([Mt("instruction")])},AuthorizeWithSeed:{index:8,layout:Pt([Mt("instruction"),pe("newAuthorized"),Mt("stakeAuthorizationType"),Rn("authoritySeed"),pe("authorityOwner")])}}),V0=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class no{constructor(){}static initialize(t){const{stakePubkey:e,authorized:n,lockup:a}=t,s=a||ki.default,f=fr.Initialize,u=xe(f,{authorized:{staker:oe(n.staker.toBuffer()),withdrawer:oe(n.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:oe(s.custodian.toBuffer())}}),y={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Jn,isSigner:!1,isWritable:!1}],programId:this.programId,data:u};return new Ne(y)}static createAccountWithSeed(t){const e=new _e;e.add(ur.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:a,lockup:s}=t;return e.add(this.initialize({stakePubkey:n,authorized:a,lockup:s}))}static createAccount(t){const e=new _e;e.add(ur.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:a,lockup:s}=t;return e.add(this.initialize({stakePubkey:n,authorized:a,lockup:s}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:n,votePubkey:a}=t,s=fr.Delegate,f=xe(s);return new _e().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!1},{pubkey:Jr,isSigner:!1,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:zc,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:f})}static authorize(t){const{stakePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:a,stakeAuthorizationType:s,custodianPubkey:f}=t,u=fr.Authorize,y=xe(u,{newAuthorized:oe(a.toBuffer()),stakeAuthorizationType:s.index}),x=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Jr,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return f&&x.push({pubkey:f,isSigner:!0,isWritable:!1}),new _e().add({keys:x,programId:this.programId,data:y})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:n,authoritySeed:a,authorityOwner:s,newAuthorizedPubkey:f,stakeAuthorizationType:u,custodianPubkey:y}=t,x=fr.AuthorizeWithSeed,v=xe(x,{newAuthorized:oe(f.toBuffer()),stakeAuthorizationType:u.index,authoritySeed:a,authorityOwner:oe(s.toBuffer())}),_=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Jr,isSigner:!1,isWritable:!1}];return y&&_.push({pubkey:y,isSigner:!0,isWritable:!1}),new _e().add({keys:_,programId:this.programId,data:v})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:n,splitStakePubkey:a,lamports:s}=t,f=fr.Split,u=xe(f,{lamports:s});return new Ne({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:u})}static split(t,e){const n=new _e;return n.add(ur.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:e,space:this.space,programId:this.programId})),n.add(this.splitInstruction(t))}static splitWithSeed(t,e){const{stakePubkey:n,authorizedPubkey:a,splitStakePubkey:s,basePubkey:f,seed:u,lamports:y}=t,x=new _e;return x.add(ur.allocate({accountPubkey:s,basePubkey:f,seed:u,space:this.space,programId:this.programId})),e&&e>0&&x.add(ur.transfer({fromPubkey:t.authorizedPubkey,toPubkey:s,lamports:e})),x.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:a,splitStakePubkey:s,lamports:y}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:n,authorizedPubkey:a}=t,s=fr.Merge,f=xe(s);return new _e().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Jr,isSigner:!1,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!0,isWritable:!1}],programId:this.programId,data:f})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:n,toPubkey:a,lamports:s,custodianPubkey:f}=t,u=fr.Withdraw,y=xe(u,{lamports:s}),x=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:Jr,isSigner:!1,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return f&&x.push({pubkey:f,isSigner:!0,isWritable:!1}),new _e().add({keys:x,programId:this.programId,data:y})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:n}=t,a=fr.Deactivate,s=xe(a);return new _e().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Jr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}}no.programId=new mt("Stake11111111111111111111111111111111111111"),no.space=200;class $c{constructor(t,e,n,a){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=n,this.commission=a}}class G0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=Mt("instruction").decode(t.data);let a;for(const[s,f]of Object.entries(Qr))if(f.index==n){a=s;break}if(!a)throw new Error("Instruction type incorrect; not a VoteInstruction");return a}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=Ue(Qr.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new $c(new mt(e.nodePubkey),new mt(e.authorizedVoter),new mt(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:n}=Ue(Qr.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new mt(e),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:n,newAuthorized:a,voteAuthorizationType:s}}=Ue(Qr.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new mt(e),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new mt(a),voteAuthorizationType:{index:s},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ue(Qr.Withdraw,t.data);return{votePubkey:t.keys[0].pubkey,authorizedWithdrawerPubkey:t.keys[2].pubkey,lamports:e,toPubkey:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(ei.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const Qr=Object.freeze({InitializeAccount:{index:0,layout:Pt([Mt("instruction"),Xh()])},Authorize:{index:1,layout:Pt([Mt("instruction"),pe("newAuthorized"),Mt("voteAuthorizationType")])},Withdraw:{index:3,layout:Pt([Mt("instruction"),Mr("lamports")])},UpdateValidatorIdentity:{index:4,layout:Pt([Mt("instruction")])},AuthorizeWithSeed:{index:10,layout:Pt([Mt("instruction"),Qh()])}}),Y0=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class ei{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:n,voteInit:a}=t,s=Qr.InitializeAccount,f=xe(s,{voteInit:{nodePubkey:oe(a.nodePubkey.toBuffer()),authorizedVoter:oe(a.authorizedVoter.toBuffer()),authorizedWithdrawer:oe(a.authorizedWithdrawer.toBuffer()),commission:a.commission}}),u={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Jn,isSigner:!1,isWritable:!1},{pubkey:Jr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:f};return new Ne(u)}static createAccount(t){const e=new _e;return e.add(ur.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){const{votePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:a,voteAuthorizationType:s}=t,f=Qr.Authorize,u=xe(f,{newAuthorized:oe(a.toBuffer()),voteAuthorizationType:s.index}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Jr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new _e().add({keys:y,programId:this.programId,data:u})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:a,newAuthorizedPubkey:s,voteAuthorizationType:f,votePubkey:u}=t,y=Qr.AuthorizeWithSeed,x=xe(y,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:oe(n.toBuffer()),currentAuthorityDerivedKeySeed:a,newAuthorized:oe(s.toBuffer()),voteAuthorizationType:f.index}}),v=[{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:Jr,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new _e().add({keys:v,programId:this.programId,data:x})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:n,lamports:a,toPubkey:s}=t,f=Qr.Withdraw,u=xe(f,{lamports:a}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new _e().add({keys:y,programId:this.programId,data:u})}static safeWithdraw(t,e,n){if(t.lamports>e-n)throw new Error("Withdraw will leave vote account with insufficient funds.");return ei.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:n,nodePubkey:a}=t,s=Qr.UpdateValidatorIdentity,f=xe(s),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new _e().add({keys:u,programId:this.programId,data:f})}}ei.programId=new mt("Vote111111111111111111111111111111111111111"),ei.space=3762;const Kc=new mt("Va1idator1nfo111111111111111111111111111111"),Z0=ut({name:gt(),website:$t(gt()),details:$t(gt()),iconUrl:$t(gt()),keybaseUsername:$t(gt())});class xs{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(_r(e)!==2)return null;const a=[];for(let s=0;s<2;s++){const f=new mt(Ar(e,0,Yr)),u=Zr(e)===1;a.push({publicKey:f,isSigner:u})}if(a[0].publicKey.equals(Kc)&&a[1].isSigner){const s=Rn().decode(Nt.Buffer.from(e)),f=JSON.parse(s);return La(f,Z0),new xs(a[1].publicKey,f)}return null}}const J0=new mt("Vote111111111111111111111111111111111111111"),X0=Pt([pe("nodePubkey"),pe("authorizedWithdrawer"),ve("commission"),dr(),pr(Pt([dr("slot"),Mt("confirmationCount")]),pn(Mt(),-8),"votes"),ve("rootSlotValid"),dr("rootSlot"),dr(),pr(Pt([dr("epoch"),pe("authorizedVoter")]),pn(Mt(),-8),"authorizedVoters"),Pt([pr(Pt([pe("authorizedPubkey"),dr("epochOfLastAuthorizedSwitch"),dr("targetEpoch")]),32,"buf"),dr("idx"),ve("isEmpty")],"priorVoters"),dr(),pr(Pt([dr("epoch"),dr("credits"),dr("prevCredits")]),pn(Mt(),-8),"epochCredits"),Pt([dr("slot"),dr("timestamp")],"lastTimestamp")]);class Es{constructor(t){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=t.nodePubkey,this.authorizedWithdrawer=t.authorizedWithdrawer,this.commission=t.commission,this.rootSlot=t.rootSlot,this.votes=t.votes,this.authorizedVoters=t.authorizedVoters,this.priorVoters=t.priorVoters,this.epochCredits=t.epochCredits,this.lastTimestamp=t.lastTimestamp}static fromAccountData(t){const n=X0.decode(oe(t),4);let a=n.rootSlot;return n.rootSlotValid||(a=null),new Es({nodePubkey:new mt(n.nodePubkey),authorizedWithdrawer:new mt(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:a,authorizedVoters:n.authorizedVoters.map(Q0),priorVoters:td(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}}function Q0({authorizedVoter:o,epoch:t}){return{epoch:t,authorizedVoter:new mt(o)}}function Wc({authorizedPubkey:o,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new mt(o),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function td({buf:o,idx:t,isEmpty:e}){return e?[]:[...o.slice(t+1).map(Wc),...o.slice(0,t).map(Wc)]}const qc={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function ed(o,t){const e=t===!1?"http":"https";if(!o)return qc[e].devnet;const n=qc[e][o];if(!n)throw new Error(`Unknown ${e} cluster: ${o}`);return n}async function rd(o,t,e,n){let a,s;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(a=e,s=n):s=e;const f=s&&{skipPreflight:s.skipPreflight,preflightCommitment:s.preflightCommitment||s.commitment,minContextSlot:s.minContextSlot},u=await o.sendRawTransaction(t,f),y=s&&s.commitment,v=(await(a?o.confirmTransaction(a,y):o.confirmTransaction(u,y))).value;if(v.err)throw u!=null?new mi({action:f!=null&&f.skipPreflight?"send":"simulate",signature:u,transactionMessage:`Status: (${JSON.stringify(v)})`}):new Error(`Raw transaction ${u} failed (${JSON.stringify(v)})`);return u}const io=Object.freeze(Object.defineProperty({__proto__:null,Account:Vh,AddressLookupTableAccount:as,AddressLookupTableInstruction:$0,AddressLookupTableProgram:gs,Authorized:Dc,BLOCKHASH_CACHE_TIMEOUT_MS:mc,BPF_LOADER_DEPRECATED_PROGRAM_ID:Gh,BPF_LOADER_PROGRAM_ID:fl,BpfLoader:hl,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Xr,ComputeBudgetInstruction:K0,ComputeBudgetProgram:ws,Connection:D0,Ed25519Program:ro,Enum:Hh,EpochSchedule:yc,FeeCalculatorLayout:lc,Keypair:Ln,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:an,Loader:Pn,Lockup:ki,MAX_SEED_LENGTH:ac,Message:$r,MessageAccountKeys:wi,MessageV0:Tn,NONCE_ACCOUNT_LENGTH:os,NonceAccount:Ji,PACKET_DATA_SIZE:gn,PUBLIC_KEY_LENGTH:Yr,PublicKey:mt,SIGNATURE_LENGTH_IN_BYTES:gi,SOLANA_SCHEMA:yi,STAKE_CONFIG_ID:zc,STAKE_INSTRUCTION_LAYOUTS:fr,SYSTEM_INSTRUCTION_LAYOUTS:ze,SYSVAR_CLOCK_PUBKEY:Jr,SYSVAR_EPOCH_SCHEDULE_PUBKEY:el,SYSVAR_INSTRUCTIONS_PUBKEY:rl,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:Yi,SYSVAR_RENT_PUBKEY:Jn,SYSVAR_REWARDS_PUBKEY:nl,SYSVAR_SLOT_HASHES_PUBKEY:il,SYSVAR_SLOT_HISTORY_PUBKEY:ol,SYSVAR_STAKE_HISTORY_PUBKEY:Zi,Secp256k1Program:ti,SendTransactionError:mi,SolanaJSONRPCError:Ot,SolanaJSONRPCErrorCode:sl,StakeAuthorizationLayout:V0,StakeInstruction:j0,StakeProgram:no,Struct:Xo,SystemInstruction:cl,SystemProgram:ur,Transaction:_e,TransactionExpiredBlockheightExceededError:Qo,TransactionExpiredNonceInvalidError:Zn,TransactionExpiredTimeoutError:ts,TransactionInstruction:Ne,TransactionMessage:rs,TransactionStatus:sn,VALIDATOR_INFO_KEY:Kc,VERSION_PREFIX_MASK:Vi,VOTE_PROGRAM_ID:J0,ValidatorInfo:xs,VersionedMessage:es,VersionedTransaction:ns,VoteAccount:Es,VoteAuthorizationLayout:Y0,VoteInit:$c,VoteInstruction:G0,VoteProgram:ei,clusterApiUrl:ed,sendAndConfirmRawTransaction:rd,sendAndConfirmTransaction:is},Symbol.toStringTag,{value:"Module"})),Kr=cr;var ks={exports:{}};ks.exports,function(o){var t=function(){var e=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function f(y,x){if(!s[y]){s[y]={};for(var v=0;v<y.length;v++)s[y][y.charAt(v)]=v}return s[y][x]}var u={compressToBase64:function(y){if(y==null)return"";var x=u._compress(y,6,function(v){return n.charAt(v)});switch(x.length%4){default:case 0:return x;case 1:return x+"===";case 2:return x+"==";case 3:return x+"="}},decompressFromBase64:function(y){return y==null?"":y==""?null:u._decompress(y.length,32,function(x){return f(n,y.charAt(x))})},compressToUTF16:function(y){return y==null?"":u._compress(y,15,function(x){return e(x+32)})+" "},decompressFromUTF16:function(y){return y==null?"":y==""?null:u._decompress(y.length,16384,function(x){return y.charCodeAt(x)-32})},compressToUint8Array:function(y){for(var x=u.compress(y),v=new Uint8Array(x.length*2),_=0,F=x.length;_<F;_++){var L=x.charCodeAt(_);v[_*2]=L>>>8,v[_*2+1]=L%256}return v},decompressFromUint8Array:function(y){if(y==null)return u.decompress(y);for(var x=new Array(y.length/2),v=0,_=x.length;v<_;v++)x[v]=y[v*2]*256+y[v*2+1];var F=[];return x.forEach(function(L){F.push(e(L))}),u.decompress(F.join(""))},compressToEncodedURIComponent:function(y){return y==null?"":u._compress(y,6,function(x){return a.charAt(x)})},decompressFromEncodedURIComponent:function(y){return y==null?"":y==""?null:(y=y.replace(/ /g,"+"),u._decompress(y.length,32,function(x){return f(a,y.charAt(x))}))},compress:function(y){return u._compress(y,16,function(x){return e(x)})},_compress:function(y,x,v){if(y==null)return"";var _,F,L={},D={},C="",z="",$="",X=2,j=3,it=2,G=[],W=0,Q=0,rt;for(rt=0;rt<y.length;rt+=1)if(C=y.charAt(rt),Object.prototype.hasOwnProperty.call(L,C)||(L[C]=j++,D[C]=!0),z=$+C,Object.prototype.hasOwnProperty.call(L,z))$=z;else{if(Object.prototype.hasOwnProperty.call(D,$)){if($.charCodeAt(0)<256){for(_=0;_<it;_++)W=W<<1,Q==x-1?(Q=0,G.push(v(W)),W=0):Q++;for(F=$.charCodeAt(0),_=0;_<8;_++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(v(W)),W=0):Q++,F=F>>1}else{for(F=1,_=0;_<it;_++)W=W<<1|F,Q==x-1?(Q=0,G.push(v(W)),W=0):Q++,F=0;for(F=$.charCodeAt(0),_=0;_<16;_++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(v(W)),W=0):Q++,F=F>>1}X--,X==0&&(X=Math.pow(2,it),it++),delete D[$]}else for(F=L[$],_=0;_<it;_++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(v(W)),W=0):Q++,F=F>>1;X--,X==0&&(X=Math.pow(2,it),it++),L[z]=j++,$=String(C)}if($!==""){if(Object.prototype.hasOwnProperty.call(D,$)){if($.charCodeAt(0)<256){for(_=0;_<it;_++)W=W<<1,Q==x-1?(Q=0,G.push(v(W)),W=0):Q++;for(F=$.charCodeAt(0),_=0;_<8;_++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(v(W)),W=0):Q++,F=F>>1}else{for(F=1,_=0;_<it;_++)W=W<<1|F,Q==x-1?(Q=0,G.push(v(W)),W=0):Q++,F=0;for(F=$.charCodeAt(0),_=0;_<16;_++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(v(W)),W=0):Q++,F=F>>1}X--,X==0&&(X=Math.pow(2,it),it++),delete D[$]}else for(F=L[$],_=0;_<it;_++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(v(W)),W=0):Q++,F=F>>1;X--,X==0&&(X=Math.pow(2,it),it++)}for(F=2,_=0;_<it;_++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(v(W)),W=0):Q++,F=F>>1;for(;;)if(W=W<<1,Q==x-1){G.push(v(W));break}else Q++;return G.join("")},decompress:function(y){return y==null?"":y==""?null:u._decompress(y.length,32768,function(x){return y.charCodeAt(x)})},_decompress:function(y,x,v){var _=[],F=4,L=4,D=3,C="",z=[],$,X,j,it,G,W,Q,rt={val:v(0),position:x,index:1};for($=0;$<3;$+=1)_[$]=$;for(j=0,G=Math.pow(2,2),W=1;W!=G;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=x,rt.val=v(rt.index++)),j|=(it>0?1:0)*W,W<<=1;switch(j){case 0:for(j=0,G=Math.pow(2,8),W=1;W!=G;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=x,rt.val=v(rt.index++)),j|=(it>0?1:0)*W,W<<=1;Q=e(j);break;case 1:for(j=0,G=Math.pow(2,16),W=1;W!=G;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=x,rt.val=v(rt.index++)),j|=(it>0?1:0)*W,W<<=1;Q=e(j);break;case 2:return""}for(_[3]=Q,X=Q,z.push(Q);;){if(rt.index>y)return"";for(j=0,G=Math.pow(2,D),W=1;W!=G;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=x,rt.val=v(rt.index++)),j|=(it>0?1:0)*W,W<<=1;switch(Q=j){case 0:for(j=0,G=Math.pow(2,8),W=1;W!=G;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=x,rt.val=v(rt.index++)),j|=(it>0?1:0)*W,W<<=1;_[L++]=e(j),Q=L-1,F--;break;case 1:for(j=0,G=Math.pow(2,16),W=1;W!=G;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=x,rt.val=v(rt.index++)),j|=(it>0?1:0)*W,W<<=1;_[L++]=e(j),Q=L-1,F--;break;case 2:return z.join("")}if(F==0&&(F=Math.pow(2,D),D++),_[Q])C=_[Q];else if(Q===L)C=X+X.charAt(0);else return null;z.push(C),_[L++]=X+C.charAt(0),F--,X=C,F==0&&(F=Math.pow(2,D),D++)}}};return u}();o!=null?o.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})}(ks);var nd=ks.exports;const tn=ii(nd);function id(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Hc={exports:{}};(function(o){(function(t){var e=function(m){var I,B=new Float64Array(16);if(m)for(I=0;I<m.length;I++)B[I]=m[I];return B},n=function(){throw new Error("no PRNG")},a=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var f=e(),u=e([1]),y=e([56129,1]),x=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),v=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),_=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),F=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),L=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function D(m,I,B,l){m[I]=B>>24&255,m[I+1]=B>>16&255,m[I+2]=B>>8&255,m[I+3]=B&255,m[I+4]=l>>24&255,m[I+5]=l>>16&255,m[I+6]=l>>8&255,m[I+7]=l&255}function C(m,I,B,l,A){var q,K=0;for(q=0;q<A;q++)K|=m[I+q]^B[l+q];return(1&K-1>>>8)-1}function z(m,I,B,l){return C(m,I,B,l,16)}function $(m,I,B,l){return C(m,I,B,l,32)}function X(m,I,B,l){for(var A=l[0]&255|(l[1]&255)<<8|(l[2]&255)<<16|(l[3]&255)<<24,q=B[0]&255|(B[1]&255)<<8|(B[2]&255)<<16|(B[3]&255)<<24,K=B[4]&255|(B[5]&255)<<8|(B[6]&255)<<16|(B[7]&255)<<24,J=B[8]&255|(B[9]&255)<<8|(B[10]&255)<<16|(B[11]&255)<<24,pt=B[12]&255|(B[13]&255)<<8|(B[14]&255)<<16|(B[15]&255)<<24,wt=l[4]&255|(l[5]&255)<<8|(l[6]&255)<<16|(l[7]&255)<<24,yt=I[0]&255|(I[1]&255)<<8|(I[2]&255)<<16|(I[3]&255)<<24,ye=I[4]&255|(I[5]&255)<<8|(I[6]&255)<<16|(I[7]&255)<<24,vt=I[8]&255|(I[9]&255)<<8|(I[10]&255)<<16|(I[11]&255)<<24,Kt=I[12]&255|(I[13]&255)<<8|(I[14]&255)<<16|(I[15]&255)<<24,qt=l[8]&255|(l[9]&255)<<8|(l[10]&255)<<16|(l[11]&255)<<24,Xt=B[16]&255|(B[17]&255)<<8|(B[18]&255)<<16|(B[19]&255)<<24,Jt=B[20]&255|(B[21]&255)<<8|(B[22]&255)<<16|(B[23]&255)<<24,Ht=B[24]&255|(B[25]&255)<<8|(B[26]&255)<<16|(B[27]&255)<<24,Gt=B[28]&255|(B[29]&255)<<8|(B[30]&255)<<16|(B[31]&255)<<24,jt=l[12]&255|(l[13]&255)<<8|(l[14]&255)<<16|(l[15]&255)<<24,At=A,Ft=q,It=K,Rt=J,Tt=pt,xt=wt,Y=yt,Z=ye,ct=vt,nt=Kt,ot=qt,dt=Xt,Dt=Jt,te=Ht,ne=Gt,ee=jt,O,he=0;he<20;he+=2)O=At+Dt|0,Tt^=O<<7|O>>>25,O=Tt+At|0,ct^=O<<9|O>>>23,O=ct+Tt|0,Dt^=O<<13|O>>>19,O=Dt+ct|0,At^=O<<18|O>>>14,O=xt+Ft|0,nt^=O<<7|O>>>25,O=nt+xt|0,te^=O<<9|O>>>23,O=te+nt|0,Ft^=O<<13|O>>>19,O=Ft+te|0,xt^=O<<18|O>>>14,O=ot+Y|0,ne^=O<<7|O>>>25,O=ne+ot|0,It^=O<<9|O>>>23,O=It+ne|0,Y^=O<<13|O>>>19,O=Y+It|0,ot^=O<<18|O>>>14,O=ee+dt|0,Rt^=O<<7|O>>>25,O=Rt+ee|0,Z^=O<<9|O>>>23,O=Z+Rt|0,dt^=O<<13|O>>>19,O=dt+Z|0,ee^=O<<18|O>>>14,O=At+Rt|0,Ft^=O<<7|O>>>25,O=Ft+At|0,It^=O<<9|O>>>23,O=It+Ft|0,Rt^=O<<13|O>>>19,O=Rt+It|0,At^=O<<18|O>>>14,O=xt+Tt|0,Y^=O<<7|O>>>25,O=Y+xt|0,Z^=O<<9|O>>>23,O=Z+Y|0,Tt^=O<<13|O>>>19,O=Tt+Z|0,xt^=O<<18|O>>>14,O=ot+nt|0,dt^=O<<7|O>>>25,O=dt+ot|0,ct^=O<<9|O>>>23,O=ct+dt|0,nt^=O<<13|O>>>19,O=nt+ct|0,ot^=O<<18|O>>>14,O=ee+ne|0,Dt^=O<<7|O>>>25,O=Dt+ee|0,te^=O<<9|O>>>23,O=te+Dt|0,ne^=O<<13|O>>>19,O=ne+te|0,ee^=O<<18|O>>>14;At=At+A|0,Ft=Ft+q|0,It=It+K|0,Rt=Rt+J|0,Tt=Tt+pt|0,xt=xt+wt|0,Y=Y+yt|0,Z=Z+ye|0,ct=ct+vt|0,nt=nt+Kt|0,ot=ot+qt|0,dt=dt+Xt|0,Dt=Dt+Jt|0,te=te+Ht|0,ne=ne+Gt|0,ee=ee+jt|0,m[0]=At>>>0&255,m[1]=At>>>8&255,m[2]=At>>>16&255,m[3]=At>>>24&255,m[4]=Ft>>>0&255,m[5]=Ft>>>8&255,m[6]=Ft>>>16&255,m[7]=Ft>>>24&255,m[8]=It>>>0&255,m[9]=It>>>8&255,m[10]=It>>>16&255,m[11]=It>>>24&255,m[12]=Rt>>>0&255,m[13]=Rt>>>8&255,m[14]=Rt>>>16&255,m[15]=Rt>>>24&255,m[16]=Tt>>>0&255,m[17]=Tt>>>8&255,m[18]=Tt>>>16&255,m[19]=Tt>>>24&255,m[20]=xt>>>0&255,m[21]=xt>>>8&255,m[22]=xt>>>16&255,m[23]=xt>>>24&255,m[24]=Y>>>0&255,m[25]=Y>>>8&255,m[26]=Y>>>16&255,m[27]=Y>>>24&255,m[28]=Z>>>0&255,m[29]=Z>>>8&255,m[30]=Z>>>16&255,m[31]=Z>>>24&255,m[32]=ct>>>0&255,m[33]=ct>>>8&255,m[34]=ct>>>16&255,m[35]=ct>>>24&255,m[36]=nt>>>0&255,m[37]=nt>>>8&255,m[38]=nt>>>16&255,m[39]=nt>>>24&255,m[40]=ot>>>0&255,m[41]=ot>>>8&255,m[42]=ot>>>16&255,m[43]=ot>>>24&255,m[44]=dt>>>0&255,m[45]=dt>>>8&255,m[46]=dt>>>16&255,m[47]=dt>>>24&255,m[48]=Dt>>>0&255,m[49]=Dt>>>8&255,m[50]=Dt>>>16&255,m[51]=Dt>>>24&255,m[52]=te>>>0&255,m[53]=te>>>8&255,m[54]=te>>>16&255,m[55]=te>>>24&255,m[56]=ne>>>0&255,m[57]=ne>>>8&255,m[58]=ne>>>16&255,m[59]=ne>>>24&255,m[60]=ee>>>0&255,m[61]=ee>>>8&255,m[62]=ee>>>16&255,m[63]=ee>>>24&255}function j(m,I,B,l){for(var A=l[0]&255|(l[1]&255)<<8|(l[2]&255)<<16|(l[3]&255)<<24,q=B[0]&255|(B[1]&255)<<8|(B[2]&255)<<16|(B[3]&255)<<24,K=B[4]&255|(B[5]&255)<<8|(B[6]&255)<<16|(B[7]&255)<<24,J=B[8]&255|(B[9]&255)<<8|(B[10]&255)<<16|(B[11]&255)<<24,pt=B[12]&255|(B[13]&255)<<8|(B[14]&255)<<16|(B[15]&255)<<24,wt=l[4]&255|(l[5]&255)<<8|(l[6]&255)<<16|(l[7]&255)<<24,yt=I[0]&255|(I[1]&255)<<8|(I[2]&255)<<16|(I[3]&255)<<24,ye=I[4]&255|(I[5]&255)<<8|(I[6]&255)<<16|(I[7]&255)<<24,vt=I[8]&255|(I[9]&255)<<8|(I[10]&255)<<16|(I[11]&255)<<24,Kt=I[12]&255|(I[13]&255)<<8|(I[14]&255)<<16|(I[15]&255)<<24,qt=l[8]&255|(l[9]&255)<<8|(l[10]&255)<<16|(l[11]&255)<<24,Xt=B[16]&255|(B[17]&255)<<8|(B[18]&255)<<16|(B[19]&255)<<24,Jt=B[20]&255|(B[21]&255)<<8|(B[22]&255)<<16|(B[23]&255)<<24,Ht=B[24]&255|(B[25]&255)<<8|(B[26]&255)<<16|(B[27]&255)<<24,Gt=B[28]&255|(B[29]&255)<<8|(B[30]&255)<<16|(B[31]&255)<<24,jt=l[12]&255|(l[13]&255)<<8|(l[14]&255)<<16|(l[15]&255)<<24,At=A,Ft=q,It=K,Rt=J,Tt=pt,xt=wt,Y=yt,Z=ye,ct=vt,nt=Kt,ot=qt,dt=Xt,Dt=Jt,te=Ht,ne=Gt,ee=jt,O,he=0;he<20;he+=2)O=At+Dt|0,Tt^=O<<7|O>>>25,O=Tt+At|0,ct^=O<<9|O>>>23,O=ct+Tt|0,Dt^=O<<13|O>>>19,O=Dt+ct|0,At^=O<<18|O>>>14,O=xt+Ft|0,nt^=O<<7|O>>>25,O=nt+xt|0,te^=O<<9|O>>>23,O=te+nt|0,Ft^=O<<13|O>>>19,O=Ft+te|0,xt^=O<<18|O>>>14,O=ot+Y|0,ne^=O<<7|O>>>25,O=ne+ot|0,It^=O<<9|O>>>23,O=It+ne|0,Y^=O<<13|O>>>19,O=Y+It|0,ot^=O<<18|O>>>14,O=ee+dt|0,Rt^=O<<7|O>>>25,O=Rt+ee|0,Z^=O<<9|O>>>23,O=Z+Rt|0,dt^=O<<13|O>>>19,O=dt+Z|0,ee^=O<<18|O>>>14,O=At+Rt|0,Ft^=O<<7|O>>>25,O=Ft+At|0,It^=O<<9|O>>>23,O=It+Ft|0,Rt^=O<<13|O>>>19,O=Rt+It|0,At^=O<<18|O>>>14,O=xt+Tt|0,Y^=O<<7|O>>>25,O=Y+xt|0,Z^=O<<9|O>>>23,O=Z+Y|0,Tt^=O<<13|O>>>19,O=Tt+Z|0,xt^=O<<18|O>>>14,O=ot+nt|0,dt^=O<<7|O>>>25,O=dt+ot|0,ct^=O<<9|O>>>23,O=ct+dt|0,nt^=O<<13|O>>>19,O=nt+ct|0,ot^=O<<18|O>>>14,O=ee+ne|0,Dt^=O<<7|O>>>25,O=Dt+ee|0,te^=O<<9|O>>>23,O=te+Dt|0,ne^=O<<13|O>>>19,O=ne+te|0,ee^=O<<18|O>>>14;m[0]=At>>>0&255,m[1]=At>>>8&255,m[2]=At>>>16&255,m[3]=At>>>24&255,m[4]=xt>>>0&255,m[5]=xt>>>8&255,m[6]=xt>>>16&255,m[7]=xt>>>24&255,m[8]=ot>>>0&255,m[9]=ot>>>8&255,m[10]=ot>>>16&255,m[11]=ot>>>24&255,m[12]=ee>>>0&255,m[13]=ee>>>8&255,m[14]=ee>>>16&255,m[15]=ee>>>24&255,m[16]=Y>>>0&255,m[17]=Y>>>8&255,m[18]=Y>>>16&255,m[19]=Y>>>24&255,m[20]=Z>>>0&255,m[21]=Z>>>8&255,m[22]=Z>>>16&255,m[23]=Z>>>24&255,m[24]=ct>>>0&255,m[25]=ct>>>8&255,m[26]=ct>>>16&255,m[27]=ct>>>24&255,m[28]=nt>>>0&255,m[29]=nt>>>8&255,m[30]=nt>>>16&255,m[31]=nt>>>24&255}function it(m,I,B,l){X(m,I,B,l)}function G(m,I,B,l){j(m,I,B,l)}var W=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Q(m,I,B,l,A,q,K){var J=new Uint8Array(16),pt=new Uint8Array(64),wt,yt;for(yt=0;yt<16;yt++)J[yt]=0;for(yt=0;yt<8;yt++)J[yt]=q[yt];for(;A>=64;){for(it(pt,J,K,W),yt=0;yt<64;yt++)m[I+yt]=B[l+yt]^pt[yt];for(wt=1,yt=8;yt<16;yt++)wt=wt+(J[yt]&255)|0,J[yt]=wt&255,wt>>>=8;A-=64,I+=64,l+=64}if(A>0)for(it(pt,J,K,W),yt=0;yt<A;yt++)m[I+yt]=B[l+yt]^pt[yt];return 0}function rt(m,I,B,l,A){var q=new Uint8Array(16),K=new Uint8Array(64),J,pt;for(pt=0;pt<16;pt++)q[pt]=0;for(pt=0;pt<8;pt++)q[pt]=l[pt];for(;B>=64;){for(it(K,q,A,W),pt=0;pt<64;pt++)m[I+pt]=K[pt];for(J=1,pt=8;pt<16;pt++)J=J+(q[pt]&255)|0,q[pt]=J&255,J>>>=8;B-=64,I+=64}if(B>0)for(it(K,q,A,W),pt=0;pt<B;pt++)m[I+pt]=K[pt];return 0}function ae(m,I,B,l,A){var q=new Uint8Array(32);G(q,l,A,W);for(var K=new Uint8Array(8),J=0;J<8;J++)K[J]=l[J+16];return rt(m,I,B,K,q)}function Vt(m,I,B,l,A,q,K){var J=new Uint8Array(32);G(J,q,K,W);for(var pt=new Uint8Array(8),wt=0;wt<8;wt++)pt[wt]=q[wt+16];return Q(m,I,B,l,A,pt,J)}var Bt=function(m){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var I,B,l,A,q,K,J,pt;I=m[0]&255|(m[1]&255)<<8,this.r[0]=I&8191,B=m[2]&255|(m[3]&255)<<8,this.r[1]=(I>>>13|B<<3)&8191,l=m[4]&255|(m[5]&255)<<8,this.r[2]=(B>>>10|l<<6)&7939,A=m[6]&255|(m[7]&255)<<8,this.r[3]=(l>>>7|A<<9)&8191,q=m[8]&255|(m[9]&255)<<8,this.r[4]=(A>>>4|q<<12)&255,this.r[5]=q>>>1&8190,K=m[10]&255|(m[11]&255)<<8,this.r[6]=(q>>>14|K<<2)&8191,J=m[12]&255|(m[13]&255)<<8,this.r[7]=(K>>>11|J<<5)&8065,pt=m[14]&255|(m[15]&255)<<8,this.r[8]=(J>>>8|pt<<8)&8191,this.r[9]=pt>>>5&127,this.pad[0]=m[16]&255|(m[17]&255)<<8,this.pad[1]=m[18]&255|(m[19]&255)<<8,this.pad[2]=m[20]&255|(m[21]&255)<<8,this.pad[3]=m[22]&255|(m[23]&255)<<8,this.pad[4]=m[24]&255|(m[25]&255)<<8,this.pad[5]=m[26]&255|(m[27]&255)<<8,this.pad[6]=m[28]&255|(m[29]&255)<<8,this.pad[7]=m[30]&255|(m[31]&255)<<8};Bt.prototype.blocks=function(m,I,B){for(var l=this.fin?0:2048,A,q,K,J,pt,wt,yt,ye,vt,Kt,qt,Xt,Jt,Ht,Gt,jt,At,Ft,It,Rt=this.h[0],Tt=this.h[1],xt=this.h[2],Y=this.h[3],Z=this.h[4],ct=this.h[5],nt=this.h[6],ot=this.h[7],dt=this.h[8],Dt=this.h[9],te=this.r[0],ne=this.r[1],ee=this.r[2],O=this.r[3],he=this.r[4],Ae=this.r[5],Re=this.r[6],ue=this.r[7],Ie=this.r[8],Be=this.r[9];B>=16;)A=m[I+0]&255|(m[I+1]&255)<<8,Rt+=A&8191,q=m[I+2]&255|(m[I+3]&255)<<8,Tt+=(A>>>13|q<<3)&8191,K=m[I+4]&255|(m[I+5]&255)<<8,xt+=(q>>>10|K<<6)&8191,J=m[I+6]&255|(m[I+7]&255)<<8,Y+=(K>>>7|J<<9)&8191,pt=m[I+8]&255|(m[I+9]&255)<<8,Z+=(J>>>4|pt<<12)&8191,ct+=pt>>>1&8191,wt=m[I+10]&255|(m[I+11]&255)<<8,nt+=(pt>>>14|wt<<2)&8191,yt=m[I+12]&255|(m[I+13]&255)<<8,ot+=(wt>>>11|yt<<5)&8191,ye=m[I+14]&255|(m[I+15]&255)<<8,dt+=(yt>>>8|ye<<8)&8191,Dt+=ye>>>5|l,vt=0,Kt=vt,Kt+=Rt*te,Kt+=Tt*(5*Be),Kt+=xt*(5*Ie),Kt+=Y*(5*ue),Kt+=Z*(5*Re),vt=Kt>>>13,Kt&=8191,Kt+=ct*(5*Ae),Kt+=nt*(5*he),Kt+=ot*(5*O),Kt+=dt*(5*ee),Kt+=Dt*(5*ne),vt+=Kt>>>13,Kt&=8191,qt=vt,qt+=Rt*ne,qt+=Tt*te,qt+=xt*(5*Be),qt+=Y*(5*Ie),qt+=Z*(5*ue),vt=qt>>>13,qt&=8191,qt+=ct*(5*Re),qt+=nt*(5*Ae),qt+=ot*(5*he),qt+=dt*(5*O),qt+=Dt*(5*ee),vt+=qt>>>13,qt&=8191,Xt=vt,Xt+=Rt*ee,Xt+=Tt*ne,Xt+=xt*te,Xt+=Y*(5*Be),Xt+=Z*(5*Ie),vt=Xt>>>13,Xt&=8191,Xt+=ct*(5*ue),Xt+=nt*(5*Re),Xt+=ot*(5*Ae),Xt+=dt*(5*he),Xt+=Dt*(5*O),vt+=Xt>>>13,Xt&=8191,Jt=vt,Jt+=Rt*O,Jt+=Tt*ee,Jt+=xt*ne,Jt+=Y*te,Jt+=Z*(5*Be),vt=Jt>>>13,Jt&=8191,Jt+=ct*(5*Ie),Jt+=nt*(5*ue),Jt+=ot*(5*Re),Jt+=dt*(5*Ae),Jt+=Dt*(5*he),vt+=Jt>>>13,Jt&=8191,Ht=vt,Ht+=Rt*he,Ht+=Tt*O,Ht+=xt*ee,Ht+=Y*ne,Ht+=Z*te,vt=Ht>>>13,Ht&=8191,Ht+=ct*(5*Be),Ht+=nt*(5*Ie),Ht+=ot*(5*ue),Ht+=dt*(5*Re),Ht+=Dt*(5*Ae),vt+=Ht>>>13,Ht&=8191,Gt=vt,Gt+=Rt*Ae,Gt+=Tt*he,Gt+=xt*O,Gt+=Y*ee,Gt+=Z*ne,vt=Gt>>>13,Gt&=8191,Gt+=ct*te,Gt+=nt*(5*Be),Gt+=ot*(5*Ie),Gt+=dt*(5*ue),Gt+=Dt*(5*Re),vt+=Gt>>>13,Gt&=8191,jt=vt,jt+=Rt*Re,jt+=Tt*Ae,jt+=xt*he,jt+=Y*O,jt+=Z*ee,vt=jt>>>13,jt&=8191,jt+=ct*ne,jt+=nt*te,jt+=ot*(5*Be),jt+=dt*(5*Ie),jt+=Dt*(5*ue),vt+=jt>>>13,jt&=8191,At=vt,At+=Rt*ue,At+=Tt*Re,At+=xt*Ae,At+=Y*he,At+=Z*O,vt=At>>>13,At&=8191,At+=ct*ee,At+=nt*ne,At+=ot*te,At+=dt*(5*Be),At+=Dt*(5*Ie),vt+=At>>>13,At&=8191,Ft=vt,Ft+=Rt*Ie,Ft+=Tt*ue,Ft+=xt*Re,Ft+=Y*Ae,Ft+=Z*he,vt=Ft>>>13,Ft&=8191,Ft+=ct*O,Ft+=nt*ee,Ft+=ot*ne,Ft+=dt*te,Ft+=Dt*(5*Be),vt+=Ft>>>13,Ft&=8191,It=vt,It+=Rt*Be,It+=Tt*Ie,It+=xt*ue,It+=Y*Re,It+=Z*Ae,vt=It>>>13,It&=8191,It+=ct*he,It+=nt*O,It+=ot*ee,It+=dt*ne,It+=Dt*te,vt+=It>>>13,It&=8191,vt=(vt<<2)+vt|0,vt=vt+Kt|0,Kt=vt&8191,vt=vt>>>13,qt+=vt,Rt=Kt,Tt=qt,xt=Xt,Y=Jt,Z=Ht,ct=Gt,nt=jt,ot=At,dt=Ft,Dt=It,I+=16,B-=16;this.h[0]=Rt,this.h[1]=Tt,this.h[2]=xt,this.h[3]=Y,this.h[4]=Z,this.h[5]=ct,this.h[6]=nt,this.h[7]=ot,this.h[8]=dt,this.h[9]=Dt},Bt.prototype.finish=function(m,I){var B=new Uint16Array(10),l,A,q,K;if(this.leftover){for(K=this.leftover,this.buffer[K++]=1;K<16;K++)this.buffer[K]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(l=this.h[1]>>>13,this.h[1]&=8191,K=2;K<10;K++)this.h[K]+=l,l=this.h[K]>>>13,this.h[K]&=8191;for(this.h[0]+=l*5,l=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=l,l=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=l,B[0]=this.h[0]+5,l=B[0]>>>13,B[0]&=8191,K=1;K<10;K++)B[K]=this.h[K]+l,l=B[K]>>>13,B[K]&=8191;for(B[9]-=8192,A=(l^1)-1,K=0;K<10;K++)B[K]&=A;for(A=~A,K=0;K<10;K++)this.h[K]=this.h[K]&A|B[K];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,q=this.h[0]+this.pad[0],this.h[0]=q&65535,K=1;K<8;K++)q=(this.h[K]+this.pad[K]|0)+(q>>>16)|0,this.h[K]=q&65535;m[I+0]=this.h[0]>>>0&255,m[I+1]=this.h[0]>>>8&255,m[I+2]=this.h[1]>>>0&255,m[I+3]=this.h[1]>>>8&255,m[I+4]=this.h[2]>>>0&255,m[I+5]=this.h[2]>>>8&255,m[I+6]=this.h[3]>>>0&255,m[I+7]=this.h[3]>>>8&255,m[I+8]=this.h[4]>>>0&255,m[I+9]=this.h[4]>>>8&255,m[I+10]=this.h[5]>>>0&255,m[I+11]=this.h[5]>>>8&255,m[I+12]=this.h[6]>>>0&255,m[I+13]=this.h[6]>>>8&255,m[I+14]=this.h[7]>>>0&255,m[I+15]=this.h[7]>>>8&255},Bt.prototype.update=function(m,I,B){var l,A;if(this.leftover){for(A=16-this.leftover,A>B&&(A=B),l=0;l<A;l++)this.buffer[this.leftover+l]=m[I+l];if(B-=A,I+=A,this.leftover+=A,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(B>=16&&(A=B-B%16,this.blocks(m,I,A),I+=A,B-=A),B){for(l=0;l<B;l++)this.buffer[this.leftover+l]=m[I+l];this.leftover+=B}};function re(m,I,B,l,A,q){var K=new Bt(q);return K.update(B,l,A),K.finish(m,I),0}function U(m,I,B,l,A,q){var K=new Uint8Array(16);return re(K,0,B,l,A,q),z(m,I,K,0)}function d(m,I,B,l,A){var q;if(B<32)return-1;for(Vt(m,0,I,0,B,l,A),re(m,16,m,32,B-32,m),q=0;q<16;q++)m[q]=0;return 0}function w(m,I,B,l,A){var q,K=new Uint8Array(32);if(B<32||(ae(K,0,32,l,A),U(I,16,I,32,B-32,K)!==0))return-1;for(Vt(m,0,I,0,B,l,A),q=0;q<32;q++)m[q]=0;return 0}function E(m,I){var B;for(B=0;B<16;B++)m[B]=I[B]|0}function P(m){var I,B,l=1;for(I=0;I<16;I++)B=m[I]+l+65535,l=Math.floor(B/65536),m[I]=B-l*65536;m[0]+=l-1+37*(l-1)}function R(m,I,B){for(var l,A=~(B-1),q=0;q<16;q++)l=A&(m[q]^I[q]),m[q]^=l,I[q]^=l}function T(m,I){var B,l,A,q=e(),K=e();for(B=0;B<16;B++)K[B]=I[B];for(P(K),P(K),P(K),l=0;l<2;l++){for(q[0]=K[0]-65517,B=1;B<15;B++)q[B]=K[B]-65535-(q[B-1]>>16&1),q[B-1]&=65535;q[15]=K[15]-32767-(q[14]>>16&1),A=q[15]>>16&1,q[14]&=65535,R(K,q,1-A)}for(B=0;B<16;B++)m[2*B]=K[B]&255,m[2*B+1]=K[B]>>8}function N(m,I){var B=new Uint8Array(32),l=new Uint8Array(32);return T(B,m),T(l,I),$(B,0,l,0)}function k(m){var I=new Uint8Array(32);return T(I,m),I[0]&1}function p(m,I){var B;for(B=0;B<16;B++)m[B]=I[2*B]+(I[2*B+1]<<8);m[15]&=32767}function M(m,I,B){for(var l=0;l<16;l++)m[l]=I[l]+B[l]}function at(m,I,B){for(var l=0;l<16;l++)m[l]=I[l]-B[l]}function tt(m,I,B){var l,A,q=0,K=0,J=0,pt=0,wt=0,yt=0,ye=0,vt=0,Kt=0,qt=0,Xt=0,Jt=0,Ht=0,Gt=0,jt=0,At=0,Ft=0,It=0,Rt=0,Tt=0,xt=0,Y=0,Z=0,ct=0,nt=0,ot=0,dt=0,Dt=0,te=0,ne=0,ee=0,O=B[0],he=B[1],Ae=B[2],Re=B[3],ue=B[4],Ie=B[5],Be=B[6],nr=B[7],Fe=B[8],tr=B[9],er=B[10],rr=B[11],sr=B[12],Er=B[13],kr=B[14],Sr=B[15];l=I[0],q+=l*O,K+=l*he,J+=l*Ae,pt+=l*Re,wt+=l*ue,yt+=l*Ie,ye+=l*Be,vt+=l*nr,Kt+=l*Fe,qt+=l*tr,Xt+=l*er,Jt+=l*rr,Ht+=l*sr,Gt+=l*Er,jt+=l*kr,At+=l*Sr,l=I[1],K+=l*O,J+=l*he,pt+=l*Ae,wt+=l*Re,yt+=l*ue,ye+=l*Ie,vt+=l*Be,Kt+=l*nr,qt+=l*Fe,Xt+=l*tr,Jt+=l*er,Ht+=l*rr,Gt+=l*sr,jt+=l*Er,At+=l*kr,Ft+=l*Sr,l=I[2],J+=l*O,pt+=l*he,wt+=l*Ae,yt+=l*Re,ye+=l*ue,vt+=l*Ie,Kt+=l*Be,qt+=l*nr,Xt+=l*Fe,Jt+=l*tr,Ht+=l*er,Gt+=l*rr,jt+=l*sr,At+=l*Er,Ft+=l*kr,It+=l*Sr,l=I[3],pt+=l*O,wt+=l*he,yt+=l*Ae,ye+=l*Re,vt+=l*ue,Kt+=l*Ie,qt+=l*Be,Xt+=l*nr,Jt+=l*Fe,Ht+=l*tr,Gt+=l*er,jt+=l*rr,At+=l*sr,Ft+=l*Er,It+=l*kr,Rt+=l*Sr,l=I[4],wt+=l*O,yt+=l*he,ye+=l*Ae,vt+=l*Re,Kt+=l*ue,qt+=l*Ie,Xt+=l*Be,Jt+=l*nr,Ht+=l*Fe,Gt+=l*tr,jt+=l*er,At+=l*rr,Ft+=l*sr,It+=l*Er,Rt+=l*kr,Tt+=l*Sr,l=I[5],yt+=l*O,ye+=l*he,vt+=l*Ae,Kt+=l*Re,qt+=l*ue,Xt+=l*Ie,Jt+=l*Be,Ht+=l*nr,Gt+=l*Fe,jt+=l*tr,At+=l*er,Ft+=l*rr,It+=l*sr,Rt+=l*Er,Tt+=l*kr,xt+=l*Sr,l=I[6],ye+=l*O,vt+=l*he,Kt+=l*Ae,qt+=l*Re,Xt+=l*ue,Jt+=l*Ie,Ht+=l*Be,Gt+=l*nr,jt+=l*Fe,At+=l*tr,Ft+=l*er,It+=l*rr,Rt+=l*sr,Tt+=l*Er,xt+=l*kr,Y+=l*Sr,l=I[7],vt+=l*O,Kt+=l*he,qt+=l*Ae,Xt+=l*Re,Jt+=l*ue,Ht+=l*Ie,Gt+=l*Be,jt+=l*nr,At+=l*Fe,Ft+=l*tr,It+=l*er,Rt+=l*rr,Tt+=l*sr,xt+=l*Er,Y+=l*kr,Z+=l*Sr,l=I[8],Kt+=l*O,qt+=l*he,Xt+=l*Ae,Jt+=l*Re,Ht+=l*ue,Gt+=l*Ie,jt+=l*Be,At+=l*nr,Ft+=l*Fe,It+=l*tr,Rt+=l*er,Tt+=l*rr,xt+=l*sr,Y+=l*Er,Z+=l*kr,ct+=l*Sr,l=I[9],qt+=l*O,Xt+=l*he,Jt+=l*Ae,Ht+=l*Re,Gt+=l*ue,jt+=l*Ie,At+=l*Be,Ft+=l*nr,It+=l*Fe,Rt+=l*tr,Tt+=l*er,xt+=l*rr,Y+=l*sr,Z+=l*Er,ct+=l*kr,nt+=l*Sr,l=I[10],Xt+=l*O,Jt+=l*he,Ht+=l*Ae,Gt+=l*Re,jt+=l*ue,At+=l*Ie,Ft+=l*Be,It+=l*nr,Rt+=l*Fe,Tt+=l*tr,xt+=l*er,Y+=l*rr,Z+=l*sr,ct+=l*Er,nt+=l*kr,ot+=l*Sr,l=I[11],Jt+=l*O,Ht+=l*he,Gt+=l*Ae,jt+=l*Re,At+=l*ue,Ft+=l*Ie,It+=l*Be,Rt+=l*nr,Tt+=l*Fe,xt+=l*tr,Y+=l*er,Z+=l*rr,ct+=l*sr,nt+=l*Er,ot+=l*kr,dt+=l*Sr,l=I[12],Ht+=l*O,Gt+=l*he,jt+=l*Ae,At+=l*Re,Ft+=l*ue,It+=l*Ie,Rt+=l*Be,Tt+=l*nr,xt+=l*Fe,Y+=l*tr,Z+=l*er,ct+=l*rr,nt+=l*sr,ot+=l*Er,dt+=l*kr,Dt+=l*Sr,l=I[13],Gt+=l*O,jt+=l*he,At+=l*Ae,Ft+=l*Re,It+=l*ue,Rt+=l*Ie,Tt+=l*Be,xt+=l*nr,Y+=l*Fe,Z+=l*tr,ct+=l*er,nt+=l*rr,ot+=l*sr,dt+=l*Er,Dt+=l*kr,te+=l*Sr,l=I[14],jt+=l*O,At+=l*he,Ft+=l*Ae,It+=l*Re,Rt+=l*ue,Tt+=l*Ie,xt+=l*Be,Y+=l*nr,Z+=l*Fe,ct+=l*tr,nt+=l*er,ot+=l*rr,dt+=l*sr,Dt+=l*Er,te+=l*kr,ne+=l*Sr,l=I[15],At+=l*O,Ft+=l*he,It+=l*Ae,Rt+=l*Re,Tt+=l*ue,xt+=l*Ie,Y+=l*Be,Z+=l*nr,ct+=l*Fe,nt+=l*tr,ot+=l*er,dt+=l*rr,Dt+=l*sr,te+=l*Er,ne+=l*kr,ee+=l*Sr,q+=38*Ft,K+=38*It,J+=38*Rt,pt+=38*Tt,wt+=38*xt,yt+=38*Y,ye+=38*Z,vt+=38*ct,Kt+=38*nt,qt+=38*ot,Xt+=38*dt,Jt+=38*Dt,Ht+=38*te,Gt+=38*ne,jt+=38*ee,A=1,l=q+A+65535,A=Math.floor(l/65536),q=l-A*65536,l=K+A+65535,A=Math.floor(l/65536),K=l-A*65536,l=J+A+65535,A=Math.floor(l/65536),J=l-A*65536,l=pt+A+65535,A=Math.floor(l/65536),pt=l-A*65536,l=wt+A+65535,A=Math.floor(l/65536),wt=l-A*65536,l=yt+A+65535,A=Math.floor(l/65536),yt=l-A*65536,l=ye+A+65535,A=Math.floor(l/65536),ye=l-A*65536,l=vt+A+65535,A=Math.floor(l/65536),vt=l-A*65536,l=Kt+A+65535,A=Math.floor(l/65536),Kt=l-A*65536,l=qt+A+65535,A=Math.floor(l/65536),qt=l-A*65536,l=Xt+A+65535,A=Math.floor(l/65536),Xt=l-A*65536,l=Jt+A+65535,A=Math.floor(l/65536),Jt=l-A*65536,l=Ht+A+65535,A=Math.floor(l/65536),Ht=l-A*65536,l=Gt+A+65535,A=Math.floor(l/65536),Gt=l-A*65536,l=jt+A+65535,A=Math.floor(l/65536),jt=l-A*65536,l=At+A+65535,A=Math.floor(l/65536),At=l-A*65536,q+=A-1+37*(A-1),A=1,l=q+A+65535,A=Math.floor(l/65536),q=l-A*65536,l=K+A+65535,A=Math.floor(l/65536),K=l-A*65536,l=J+A+65535,A=Math.floor(l/65536),J=l-A*65536,l=pt+A+65535,A=Math.floor(l/65536),pt=l-A*65536,l=wt+A+65535,A=Math.floor(l/65536),wt=l-A*65536,l=yt+A+65535,A=Math.floor(l/65536),yt=l-A*65536,l=ye+A+65535,A=Math.floor(l/65536),ye=l-A*65536,l=vt+A+65535,A=Math.floor(l/65536),vt=l-A*65536,l=Kt+A+65535,A=Math.floor(l/65536),Kt=l-A*65536,l=qt+A+65535,A=Math.floor(l/65536),qt=l-A*65536,l=Xt+A+65535,A=Math.floor(l/65536),Xt=l-A*65536,l=Jt+A+65535,A=Math.floor(l/65536),Jt=l-A*65536,l=Ht+A+65535,A=Math.floor(l/65536),Ht=l-A*65536,l=Gt+A+65535,A=Math.floor(l/65536),Gt=l-A*65536,l=jt+A+65535,A=Math.floor(l/65536),jt=l-A*65536,l=At+A+65535,A=Math.floor(l/65536),At=l-A*65536,q+=A-1+37*(A-1),m[0]=q,m[1]=K,m[2]=J,m[3]=pt,m[4]=wt,m[5]=yt,m[6]=ye,m[7]=vt,m[8]=Kt,m[9]=qt,m[10]=Xt,m[11]=Jt,m[12]=Ht,m[13]=Gt,m[14]=jt,m[15]=At}function ft(m,I){tt(m,I,I)}function Lt(m,I){var B=e(),l;for(l=0;l<16;l++)B[l]=I[l];for(l=253;l>=0;l--)ft(B,B),l!==2&&l!==4&&tt(B,B,I);for(l=0;l<16;l++)m[l]=B[l]}function _t(m,I){var B=e(),l;for(l=0;l<16;l++)B[l]=I[l];for(l=250;l>=0;l--)ft(B,B),l!==1&&tt(B,B,I);for(l=0;l<16;l++)m[l]=B[l]}function Ut(m,I,B){var l=new Uint8Array(32),A=new Float64Array(80),q,K,J=e(),pt=e(),wt=e(),yt=e(),ye=e(),vt=e();for(K=0;K<31;K++)l[K]=I[K];for(l[31]=I[31]&127|64,l[0]&=248,p(A,B),K=0;K<16;K++)pt[K]=A[K],yt[K]=J[K]=wt[K]=0;for(J[0]=yt[0]=1,K=254;K>=0;--K)q=l[K>>>3]>>>(K&7)&1,R(J,pt,q),R(wt,yt,q),M(ye,J,wt),at(J,J,wt),M(wt,pt,yt),at(pt,pt,yt),ft(yt,ye),ft(vt,J),tt(J,wt,J),tt(wt,pt,ye),M(ye,J,wt),at(J,J,wt),ft(pt,J),at(wt,yt,vt),tt(J,wt,y),M(J,J,yt),tt(wt,wt,J),tt(J,yt,vt),tt(yt,pt,A),ft(pt,ye),R(J,pt,q),R(wt,yt,q);for(K=0;K<16;K++)A[K+16]=J[K],A[K+32]=wt[K],A[K+48]=pt[K],A[K+64]=yt[K];var Kt=A.subarray(32),qt=A.subarray(16);return Lt(Kt,Kt),tt(qt,qt,Kt),T(m,qt),0}function Ee(m,I){return Ut(m,I,s)}function Zt(m,I){return n(I,32),Ee(m,I)}function Wt(m,I,B){var l=new Uint8Array(32);return Ut(l,B,I),G(m,a,l,W)}var Yt=d,zt=w;function ge(m,I,B,l,A,q){var K=new Uint8Array(32);return Wt(K,A,q),Yt(m,I,B,l,K)}function xr(m,I,B,l,A,q){var K=new Uint8Array(32);return Wt(K,A,q),zt(m,I,B,l,K)}var de=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Pe(m,I,B,l){for(var A=new Int32Array(16),q=new Int32Array(16),K,J,pt,wt,yt,ye,vt,Kt,qt,Xt,Jt,Ht,Gt,jt,At,Ft,It,Rt,Tt,xt,Y,Z,ct,nt,ot,dt,Dt=m[0],te=m[1],ne=m[2],ee=m[3],O=m[4],he=m[5],Ae=m[6],Re=m[7],ue=I[0],Ie=I[1],Be=I[2],nr=I[3],Fe=I[4],tr=I[5],er=I[6],rr=I[7],sr=0;l>=128;){for(Tt=0;Tt<16;Tt++)xt=8*Tt+sr,A[Tt]=B[xt+0]<<24|B[xt+1]<<16|B[xt+2]<<8|B[xt+3],q[Tt]=B[xt+4]<<24|B[xt+5]<<16|B[xt+6]<<8|B[xt+7];for(Tt=0;Tt<80;Tt++)if(K=Dt,J=te,pt=ne,wt=ee,yt=O,ye=he,vt=Ae,Kt=Re,qt=ue,Xt=Ie,Jt=Be,Ht=nr,Gt=Fe,jt=tr,At=er,Ft=rr,Y=Re,Z=rr,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=(O>>>14|Fe<<18)^(O>>>18|Fe<<14)^(Fe>>>9|O<<23),Z=(Fe>>>14|O<<18)^(Fe>>>18|O<<14)^(O>>>9|Fe<<23),ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,Y=O&he^~O&Ae,Z=Fe&tr^~Fe&er,ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,Y=de[Tt*2],Z=de[Tt*2+1],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,Y=A[Tt%16],Z=q[Tt%16],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,It=ot&65535|dt<<16,Rt=ct&65535|nt<<16,Y=It,Z=Rt,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=(Dt>>>28|ue<<4)^(ue>>>2|Dt<<30)^(ue>>>7|Dt<<25),Z=(ue>>>28|Dt<<4)^(Dt>>>2|ue<<30)^(Dt>>>7|ue<<25),ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,Y=Dt&te^Dt&ne^te&ne,Z=ue&Ie^ue&Be^Ie&Be,ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,Kt=ot&65535|dt<<16,Ft=ct&65535|nt<<16,Y=wt,Z=Ht,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=It,Z=Rt,ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,wt=ot&65535|dt<<16,Ht=ct&65535|nt<<16,te=K,ne=J,ee=pt,O=wt,he=yt,Ae=ye,Re=vt,Dt=Kt,Ie=qt,Be=Xt,nr=Jt,Fe=Ht,tr=Gt,er=jt,rr=At,ue=Ft,Tt%16===15)for(xt=0;xt<16;xt++)Y=A[xt],Z=q[xt],ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=A[(xt+9)%16],Z=q[(xt+9)%16],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,It=A[(xt+1)%16],Rt=q[(xt+1)%16],Y=(It>>>1|Rt<<31)^(It>>>8|Rt<<24)^It>>>7,Z=(Rt>>>1|It<<31)^(Rt>>>8|It<<24)^(Rt>>>7|It<<25),ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,It=A[(xt+14)%16],Rt=q[(xt+14)%16],Y=(It>>>19|Rt<<13)^(Rt>>>29|It<<3)^It>>>6,Z=(Rt>>>19|It<<13)^(It>>>29|Rt<<3)^(Rt>>>6|It<<26),ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,A[xt]=ot&65535|dt<<16,q[xt]=ct&65535|nt<<16;Y=Dt,Z=ue,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=m[0],Z=I[0],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,m[0]=Dt=ot&65535|dt<<16,I[0]=ue=ct&65535|nt<<16,Y=te,Z=Ie,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=m[1],Z=I[1],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,m[1]=te=ot&65535|dt<<16,I[1]=Ie=ct&65535|nt<<16,Y=ne,Z=Be,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=m[2],Z=I[2],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,m[2]=ne=ot&65535|dt<<16,I[2]=Be=ct&65535|nt<<16,Y=ee,Z=nr,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=m[3],Z=I[3],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,m[3]=ee=ot&65535|dt<<16,I[3]=nr=ct&65535|nt<<16,Y=O,Z=Fe,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=m[4],Z=I[4],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,m[4]=O=ot&65535|dt<<16,I[4]=Fe=ct&65535|nt<<16,Y=he,Z=tr,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=m[5],Z=I[5],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,m[5]=he=ot&65535|dt<<16,I[5]=tr=ct&65535|nt<<16,Y=Ae,Z=er,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=m[6],Z=I[6],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,m[6]=Ae=ot&65535|dt<<16,I[6]=er=ct&65535|nt<<16,Y=Re,Z=rr,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=m[7],Z=I[7],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,m[7]=Re=ot&65535|dt<<16,I[7]=rr=ct&65535|nt<<16,sr+=128,l-=128}return l}function hr(m,I,B){var l=new Int32Array(8),A=new Int32Array(8),q=new Uint8Array(256),K,J=B;for(l[0]=1779033703,l[1]=3144134277,l[2]=1013904242,l[3]=2773480762,l[4]=1359893119,l[5]=2600822924,l[6]=528734635,l[7]=1541459225,A[0]=4089235720,A[1]=2227873595,A[2]=4271175723,A[3]=1595750129,A[4]=2917565137,A[5]=725511199,A[6]=4215389547,A[7]=327033209,Pe(l,A,I,B),B%=128,K=0;K<B;K++)q[K]=I[J-B+K];for(q[B]=128,B=256-128*(B<112?1:0),q[B-9]=0,D(q,B-8,J/536870912|0,J<<3),Pe(l,A,q,B),K=0;K<8;K++)D(m,8*K,l[K],A[K]);return 0}function we(m,I){var B=e(),l=e(),A=e(),q=e(),K=e(),J=e(),pt=e(),wt=e(),yt=e();at(B,m[1],m[0]),at(yt,I[1],I[0]),tt(B,B,yt),M(l,m[0],m[1]),M(yt,I[0],I[1]),tt(l,l,yt),tt(A,m[3],I[3]),tt(A,A,v),tt(q,m[2],I[2]),M(q,q,q),at(K,l,B),at(J,q,A),M(pt,q,A),M(wt,l,B),tt(m[0],K,J),tt(m[1],wt,pt),tt(m[2],pt,J),tt(m[3],K,wt)}function ce(m,I,B){var l;for(l=0;l<4;l++)R(m[l],I[l],B)}function Qt(m,I){var B=e(),l=e(),A=e();Lt(A,I[2]),tt(B,I[0],A),tt(l,I[1],A),T(m,l),m[31]^=k(B)<<7}function fe(m,I,B){var l,A;for(E(m[0],f),E(m[1],u),E(m[2],u),E(m[3],f),A=255;A>=0;--A)l=B[A/8|0]>>(A&7)&1,ce(m,I,l),we(I,m),we(m,m),ce(m,I,l)}function be(m,I){var B=[e(),e(),e(),e()];E(B[0],_),E(B[1],F),E(B[2],u),tt(B[3],_,F),fe(m,B,I)}function me(m,I,B){var l=new Uint8Array(64),A=[e(),e(),e(),e()],q;for(B||n(I,32),hr(l,I,32),l[0]&=248,l[31]&=127,l[31]|=64,be(A,l),Qt(m,A),q=0;q<32;q++)I[q+32]=m[q];return 0}var ke=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function c(m,I){var B,l,A,q;for(l=63;l>=32;--l){for(B=0,A=l-32,q=l-12;A<q;++A)I[A]+=B-16*I[l]*ke[A-(l-32)],B=Math.floor((I[A]+128)/256),I[A]-=B*256;I[A]+=B,I[l]=0}for(B=0,A=0;A<32;A++)I[A]+=B-(I[31]>>4)*ke[A],B=I[A]>>8,I[A]&=255;for(A=0;A<32;A++)I[A]-=B*ke[A];for(l=0;l<32;l++)I[l+1]+=I[l]>>8,m[l]=I[l]&255}function r(m){var I=new Float64Array(64),B;for(B=0;B<64;B++)I[B]=m[B];for(B=0;B<64;B++)m[B]=0;c(m,I)}function i(m,I,B,l){var A=new Uint8Array(64),q=new Uint8Array(64),K=new Uint8Array(64),J,pt,wt=new Float64Array(64),yt=[e(),e(),e(),e()];hr(A,l,32),A[0]&=248,A[31]&=127,A[31]|=64;var ye=B+64;for(J=0;J<B;J++)m[64+J]=I[J];for(J=0;J<32;J++)m[32+J]=A[32+J];for(hr(K,m.subarray(32),B+32),r(K),be(yt,K),Qt(m,yt),J=32;J<64;J++)m[J]=l[J];for(hr(q,m,B+64),r(q),J=0;J<64;J++)wt[J]=0;for(J=0;J<32;J++)wt[J]=K[J];for(J=0;J<32;J++)for(pt=0;pt<32;pt++)wt[J+pt]+=q[J]*A[pt];return c(m.subarray(32),wt),ye}function h(m,I){var B=e(),l=e(),A=e(),q=e(),K=e(),J=e(),pt=e();return E(m[2],u),p(m[1],I),ft(A,m[1]),tt(q,A,x),at(A,A,m[2]),M(q,m[2],q),ft(K,q),ft(J,K),tt(pt,J,K),tt(B,pt,A),tt(B,B,q),_t(B,B),tt(B,B,A),tt(B,B,q),tt(B,B,q),tt(m[0],B,q),ft(l,m[0]),tt(l,l,q),N(l,A)&&tt(m[0],m[0],L),ft(l,m[0]),tt(l,l,q),N(l,A)?-1:(k(m[0])===I[31]>>7&&at(m[0],f,m[0]),tt(m[3],m[0],m[1]),0)}function g(m,I,B,l){var A,q=new Uint8Array(32),K=new Uint8Array(64),J=[e(),e(),e(),e()],pt=[e(),e(),e(),e()];if(B<64||h(pt,l))return-1;for(A=0;A<B;A++)m[A]=I[A];for(A=0;A<32;A++)m[A+32]=l[A];if(hr(K,m,B),r(K),fe(J,pt,K),be(pt,I.subarray(32)),we(J,pt),Qt(q,J),B-=64,$(I,0,q,0)){for(A=0;A<B;A++)m[A]=0;return-1}for(A=0;A<B;A++)m[A]=I[A+64];return B}var b=32,S=24,et=32,lt=16,ht=32,Et=32,st=32,$e=32,ni=32,Ye=S,Xe=et,co=lt,Ce=64,Oe=32,cn=64,qe=32,He=64;t.lowlevel={crypto_core_hsalsa20:G,crypto_stream_xor:Vt,crypto_stream:ae,crypto_stream_salsa20_xor:Q,crypto_stream_salsa20:rt,crypto_onetimeauth:re,crypto_onetimeauth_verify:U,crypto_verify_16:z,crypto_verify_32:$,crypto_secretbox:d,crypto_secretbox_open:w,crypto_scalarmult:Ut,crypto_scalarmult_base:Ee,crypto_box_beforenm:Wt,crypto_box_afternm:Yt,crypto_box:ge,crypto_box_open:xr,crypto_box_keypair:Zt,crypto_hash:hr,crypto_sign:i,crypto_sign_keypair:me,crypto_sign_open:g,crypto_secretbox_KEYBYTES:b,crypto_secretbox_NONCEBYTES:S,crypto_secretbox_ZEROBYTES:et,crypto_secretbox_BOXZEROBYTES:lt,crypto_scalarmult_BYTES:ht,crypto_scalarmult_SCALARBYTES:Et,crypto_box_PUBLICKEYBYTES:st,crypto_box_SECRETKEYBYTES:$e,crypto_box_BEFORENMBYTES:ni,crypto_box_NONCEBYTES:Ye,crypto_box_ZEROBYTES:Xe,crypto_box_BOXZEROBYTES:co,crypto_sign_BYTES:Ce,crypto_sign_PUBLICKEYBYTES:Oe,crypto_sign_SECRETKEYBYTES:cn,crypto_sign_SEEDBYTES:qe,crypto_hash_BYTES:He,gf:e,D:x,L:ke,pack25519:T,unpack25519:p,M:tt,A:M,S:ft,Z:at,pow2523:_t,add:we,set25519:E,modL:c,scalarmult:fe,scalarbase:be};function Ii(m,I){if(m.length!==b)throw new Error("bad key size");if(I.length!==S)throw new Error("bad nonce size")}function Qe(m,I){if(m.length!==st)throw new Error("bad public key size");if(I.length!==$e)throw new Error("bad secret key size")}function Se(){for(var m=0;m<arguments.length;m++)if(!(arguments[m]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Bi(m){for(var I=0;I<m.length;I++)m[I]=0}t.randomBytes=function(m){var I=new Uint8Array(m);return n(I,m),I},t.secretbox=function(m,I,B){Se(m,I,B),Ii(B,I);for(var l=new Uint8Array(et+m.length),A=new Uint8Array(l.length),q=0;q<m.length;q++)l[q+et]=m[q];return d(A,l,l.length,I,B),A.subarray(lt)},t.secretbox.open=function(m,I,B){Se(m,I,B),Ii(B,I);for(var l=new Uint8Array(lt+m.length),A=new Uint8Array(l.length),q=0;q<m.length;q++)l[q+lt]=m[q];return l.length<32||w(A,l,l.length,I,B)!==0?null:A.subarray(et)},t.secretbox.keyLength=b,t.secretbox.nonceLength=S,t.secretbox.overheadLength=lt,t.scalarMult=function(m,I){if(Se(m,I),m.length!==Et)throw new Error("bad n size");if(I.length!==ht)throw new Error("bad p size");var B=new Uint8Array(ht);return Ut(B,m,I),B},t.scalarMult.base=function(m){if(Se(m),m.length!==Et)throw new Error("bad n size");var I=new Uint8Array(ht);return Ee(I,m),I},t.scalarMult.scalarLength=Et,t.scalarMult.groupElementLength=ht,t.box=function(m,I,B,l){var A=t.box.before(B,l);return t.secretbox(m,I,A)},t.box.before=function(m,I){Se(m,I),Qe(m,I);var B=new Uint8Array(ni);return Wt(B,m,I),B},t.box.after=t.secretbox,t.box.open=function(m,I,B,l){var A=t.box.before(B,l);return t.secretbox.open(m,I,A)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var m=new Uint8Array(st),I=new Uint8Array($e);return Zt(m,I),{publicKey:m,secretKey:I}},t.box.keyPair.fromSecretKey=function(m){if(Se(m),m.length!==$e)throw new Error("bad secret key size");var I=new Uint8Array(st);return Ee(I,m),{publicKey:I,secretKey:new Uint8Array(m)}},t.box.publicKeyLength=st,t.box.secretKeyLength=$e,t.box.sharedKeyLength=ni,t.box.nonceLength=Ye,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(m,I){if(Se(m,I),I.length!==cn)throw new Error("bad secret key size");var B=new Uint8Array(Ce+m.length);return i(B,m,m.length,I),B},t.sign.open=function(m,I){if(Se(m,I),I.length!==Oe)throw new Error("bad public key size");var B=new Uint8Array(m.length),l=g(B,m,m.length,I);if(l<0)return null;for(var A=new Uint8Array(l),q=0;q<A.length;q++)A[q]=B[q];return A},t.sign.detached=function(m,I){for(var B=t.sign(m,I),l=new Uint8Array(Ce),A=0;A<l.length;A++)l[A]=B[A];return l},t.sign.detached.verify=function(m,I,B){if(Se(m,I,B),I.length!==Ce)throw new Error("bad signature size");if(B.length!==Oe)throw new Error("bad public key size");var l=new Uint8Array(Ce+m.length),A=new Uint8Array(Ce+m.length),q;for(q=0;q<Ce;q++)l[q]=I[q];for(q=0;q<m.length;q++)l[q+Ce]=m[q];return g(A,l,l.length,B)>=0},t.sign.keyPair=function(){var m=new Uint8Array(Oe),I=new Uint8Array(cn);return me(m,I),{publicKey:m,secretKey:I}},t.sign.keyPair.fromSecretKey=function(m){if(Se(m),m.length!==cn)throw new Error("bad secret key size");for(var I=new Uint8Array(Oe),B=0;B<I.length;B++)I[B]=m[32+B];return{publicKey:I,secretKey:new Uint8Array(m)}},t.sign.keyPair.fromSeed=function(m){if(Se(m),m.length!==qe)throw new Error("bad seed size");for(var I=new Uint8Array(Oe),B=new Uint8Array(cn),l=0;l<32;l++)B[l]=m[l];return me(I,B,!0),{publicKey:I,secretKey:B}},t.sign.publicKeyLength=Oe,t.sign.secretKeyLength=cn,t.sign.seedLength=qe,t.sign.signatureLength=Ce,t.hash=function(m){Se(m);var I=new Uint8Array(He);return hr(I,m,m.length),I},t.hash.hashLength=He,t.verify=function(m,I){return Se(m,I),m.length===0||I.length===0||m.length!==I.length?!1:C(m,0,I,0,m.length)===0},t.setPRNG=function(m){n=m},function(){var m=typeof self<"u"?self.crypto||self.msCrypto:null;if(m&&m.getRandomValues){var I=65536;t.setPRNG(function(B,l){var A,q=new Uint8Array(l);for(A=0;A<l;A+=I)m.getRandomValues(q.subarray(A,A+Math.min(l-A,I)));for(A=0;A<l;A++)B[A]=q[A];Bi(q)})}else typeof id<"u"&&(m=ra,m&&m.randomBytes&&t.setPRNG(function(B,l){var A,q=m.randomBytes(l);for(A=0;A<l;A++)B[A]=q[A];Bi(q)}))}()})(o.exports?o.exports:self.nacl=self.nacl||{})})(Hc);var od=Hc.exports;class en{constructor(t){ir(this,"env");ir(this,"url");this.env=t??"prod",this.env==="prod"?this.url="https://api.coinflow.cash":this.env==="local"?this.url="http://localhost:5000":this.url=`https://api-${this.env}.coinflow.cash`}async getNSurePartnerId(t){return fetch(this.url+`/merchant/view/${t}`).then(e=>e.json()).then(e=>{var n;return((n=e.nSureSettings)==null?void 0:n.nSurePartnerId)||e.nSurePartnerId}).catch(e=>{console.error(e)})}async getCreditBalance(t,e,n){const a=await fetch(this.url+`/api/customer/balances/${e}`,{method:"GET",headers:{"x-coinflow-auth-wallet":t,"x-coinflow-auth-blockchain":n}}),{credits:s}=await a.json();return s}static getCoinflowBaseUrl(t){return!t||t==="prod"?"https://coinflow.cash":t==="local"?"http://localhost:3000":`https://${t}.coinflow.cash`}static getCoinflowApiUrl(t){return!t||t==="prod"?"https://api.coinflow.cash":t==="local"?"http://localhost:5000":`https://api-${t}.coinflow.cash`}static getCoinflowUrl({walletPubkey:t,route:e,routePrefix:n,env:a,amount:s,transaction:f,blockchain:u,webhookInfo:y,email:x,loaderBackground:v,handleHeightChange:_,bankAccountLinkRedirect:F,additionalWallets:L,nearDeposit:D,chargebackProtectionData:C,merchantCss:z,color:$,rent:X,lockDefaultToken:j,token:it,tokens:G,planCode:W,disableApplePay:Q,disableGooglePay:rt,customerInfo:ae,settlementType:Vt,lockAmount:Bt,nativeSolToConvert:re,theme:U,usePermit:d,transactionSigner:w,authOnly:E,deviceId:P,jwtToken:R,origins:T,threeDsChallengePreference:N}){var M;const k=n?`/${n}/${u}`:`/${u}`,p=new URL(k+e,en.getCoinflowBaseUrl(a));if(p.searchParams.append("pubkey",t),f&&p.searchParams.append("transaction",f),s&&p.searchParams.append("amount",s.toString()),y&&p.searchParams.append("webhookInfo",tn.compressToEncodedURIComponent(JSON.stringify(y))),U&&p.searchParams.append("theme",tn.compressToEncodedURIComponent(JSON.stringify(U))),ae&&p.searchParams.append("customerInfo",tn.compressToEncodedURIComponent(JSON.stringify(ae))),x&&p.searchParams.append("email",x),it&&p.searchParams.append("token",it.toString()),G&&p.searchParams.append("tokens",G.toString()),v&&p.searchParams.append("loaderBackground",v),_&&p.searchParams.append("useHeightChange","true"),F&&p.searchParams.append("bankAccountLinkRedirect",F),L&&p.searchParams.append("additionalWallets",tn.compressToEncodedURIComponent(JSON.stringify(L))),D&&p.searchParams.append("nearDeposit",D),C&&p.searchParams.append("chargebackProtectionData",tn.compressToEncodedURIComponent(JSON.stringify(C))),P)p.searchParams.append("deviceId",P);else if(typeof window<"u"){const at=(M=window==null?void 0:window.nSureSDK)==null?void 0:M.getDeviceId();at&&p.searchParams.append("deviceId",at)}return z&&p.searchParams.append("merchantCss",z),$&&p.searchParams.append("color",$),X&&p.searchParams.append("rent",X.lamports.toString()),re&&p.searchParams.append("nativeSolToConvert",re.lamports.toString()),j&&p.searchParams.append("lockDefaultToken","true"),W&&p.searchParams.append("planCode",W),Q&&p.searchParams.append("disableApplePay","true"),rt&&p.searchParams.append("disableGooglePay","true"),Vt&&p.searchParams.append("settlementType",Vt),Bt&&p.searchParams.append("lockAmount","true"),d===!1&&p.searchParams.append("usePermit","false"),w&&p.searchParams.append("transactionSigner",w),E===!0&&p.searchParams.append("authOnly","true"),R&&p.searchParams.append("jwtToken",R),T&&p.searchParams.append("origins",tn.compressToEncodedURIComponent(JSON.stringify(T))),N&&p.searchParams.append("threeDsChallengePreference",N),p.toString()}static getTransaction(t){return this.byBlockchain(t.blockchain,{solana:()=>{if(!("transaction"in t))return;const{transaction:e}=t;if(!io)throw new Error("@solana/web3.js dependency is required for Solana");if(!Kr)throw new Error("bs58 dependency is required for Solana");if(e)return Kr.encode(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return tn.compressToEncodedURIComponent(JSON.stringify(e))},eth:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return tn.compressToEncodedURIComponent(JSON.stringify(e))},base:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return tn.compressToEncodedURIComponent(JSON.stringify(e))},near:()=>{if(!("action"in t))return;const{action:e}=t;return tn.compressToEncodedURIComponent(JSON.stringify(e))}})()}static byBlockchain(t,e){switch(t){case"solana":return e.solana;case"near":return e.near;case"polygon":return e.polygon;case"eth":return e.eth;case"base":return e.base;default:throw new Error("blockchain not supported!")}}static async getWalletFromEmail({email:t,merchantId:e,env:n}){const a=new TextEncoder().encode(t),f=await window.crypto.subtle.digest("SHA-256",a),u=new Uint8Array(f),y=Ln.fromSeed(u);return{publicKey:y.publicKey,signMessage:x=>Promise.resolve(od.sign.detached(x,y.secretKey)),signTransaction:async x=>x instanceof _e?(x.sign(y),x):(x.sign([y]),x),sendTransaction:async x=>{x instanceof _e?x.sign(y):x.sign([y]);const v=this.getCoinflowApiUrl(n),_={method:"POST",headers:{"content-type":"application/json","x-coinflow-auth-wallet":y.publicKey.toString(),"x-coinflow-auth-blockchain":"solana"},body:JSON.stringify({merchantId:e,signedTransaction:Kr==null?void 0:Kr.encode(x.serialize())})},{signature:F}=await fetch(v+"/api/utils/send-coinflow-tx",_).then(L=>L.json());return F}}}}var jc=(o=>(o.SignMessage="signMessage",o.SignTransaction="signTransaction",o.SendTransaction="sendTransaction",o.HeightChange="heightChange",o.Success="success",o))(jc||{});function oo({wallet:o}){return"publicKey"in o?o.publicKey.toString():"address"in o?o.address:"accountId"in o?o.accountId:null}function Vc(o,t){let e;try{if(e=JSON.parse(o),!("method"in e)||!("data"in e))return}catch(s){console.error("handleIFrameMessage JSON parse",s);return}const{data:n,method:a}=e;switch(a){case"signMessage":return t.handleSignMessage?t.handleSignMessage(n):void 0;case"signTransaction":return t.handleSignTransaction?t.handleSignTransaction(n):void 0;case"sendTransaction":return t.handleSendTransaction(n);case"heightChange":return t.handleHeightChange?t.handleHeightChange(n):void 0;case"success":if(!t.onSuccess)return;t.onSuccess(e.info);return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${a} is not one of ${Object.values(jc)}`)}function so(o){return en.byBlockchain(o.blockchain,{solana:()=>sd(o),near:()=>ad(o),eth:()=>Ss(o),polygon:()=>Ss(o),base:()=>Ss(o)})()}function sd({wallet:o,onSuccess:t}){return{handleSendTransaction:async e=>{const n=Gc(e);return await o.sendTransaction(n)},handleSignMessage:async e=>{const n=o.signMessage;if(!n)throw new Error("signMessage is not supported by this wallet");const a=await n(new TextEncoder().encode(e));if(!Kr)throw new Error("bs58 dependency is required");return Kr.encode(a)},handleSignTransaction:async e=>{const n=o.signTransaction;if(!n)throw new Error("signTransaction is not supported by this wallet");const a=Gc(e),s=await n(a);if(!Kr)throw new Error("bs58 dependency is required");return Kr.encode(s.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:t}}function Gc(o){if(!io)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!Kr)throw new Error("bs58 is not defined. Please install bs58 into your project");const t=Kr.decode(o),e=io.VersionedTransaction.deserialize(t);return e.version==="legacy"?io.Transaction.from(t):e}function ad({wallet:o,onSuccess:t}){const e=o;return{handleSendTransaction:async n=>{const a=JSON.parse(Buffer.from(n,"base64").toString()),s=await e.signAndSendTransaction(a);if(!s)throw new Error("Transaction did not send");const{transaction:f}=s;return f.hash},onSuccess:t}}function Ss({wallet:o,onSuccess:t}){const e=o;return{handleSendTransaction:async n=>{const a=JSON.parse(Buffer.from(n,"base64").toString()),{hash:s}=await e.sendTransaction(a);return s},handleSignMessage:async n=>e.signMessage(n),onSuccess:t}}const Si="tokenExCardNumber",ri="tokenExCardCvv",Yc={[Fn.VISA]:"visa",[Fn.MASTERCARD]:"masterCard",[Fn.AMEX]:"americanExpress",[Fn.DISCOVER]:"discover"};async function Zc({token:o,origins:t,env:e}){return new Promise((n,a)=>{fetch(new en(e).url+"/api/checkout/authentication-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({origins:[...t??[],window.location.origin],token:o})}).then(async s=>{n(await s.json())}).catch(s=>a(s))})}function Is({env:o,setTokenExScriptLoaded:t}){const e="tokenex-script";if(document.head.querySelector(`#${e}`))return;const n=document.createElement("script");n.src=o==="prod"?"https://htp.tokenex.com/iframe/iframe-v3.min.js":"https://test-htp.tokenex.com/iframe/iframe-v3.min.js",n.id=e,document.head.appendChild(n),document.getElementById(e).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),t(!0)})}function cd({iframe:o,setCachedToken:t,setLoaded:e}){const n=async()=>(o.tokenize(),await new Promise((a,s)=>{o.on("tokenize",f=>{t(f.token),a(f)}),o.on("validate",f=>{(!f.isValid||f.isCvvValid===!1)&&s(f)})}));return o.on("change",()=>t(void 0)),o.on("cvvChange",()=>t(void 0)),o.on("load",()=>{setTimeout(()=>e(!0),350);const a=document.querySelector("#tx_iframe_tokenExCardNumber");a&&(a.scrolling="no")}),o.on("focus",()=>{o.focus()}),o.on("cvvFocus",()=>{o.cvvFocus()}),e(!1),o.load(),{...o,tokenize:n}}async function Jc(o){const{token:t,cardType:e}=o;return await Bs(ri,o,{cvvOnly:!0,cvv:!0,cvvContainerID:ri,placeholder:"CVV",token:t,cardType:Yc[e]})}async function Xc(o){return await Bs(Si,o,{cvv:!0,cvvContainerID:ri,cvvPlaceholder:"CVV"})}async function Qc(o){return await Bs(Si,o,{cvv:!1})}async function Bs(o,{tokenExScriptLoaded:t,origins:e,env:n,css:a,debug:s,font:f,setCachedToken:u,setLoaded:y},x){if(!t&&typeof TokenEx>"u"){console.warn("Warning Unable to load TokenEx on first attempt waiting for load event from document.head.script#tokenex-script");return}const v=await Zc({token:x.token,origins:e,env:n}),{styles:_}=ud(a),F={...v,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,styles:_,font:f,debug:s??!1,...x},L=TokenEx.Iframe(o,F);return cd({iframe:L,setCachedToken:u,setLoaded:y})}function ud(o){var n,a,s;const t=JSON.parse(o);return{styles:{base:wn(t.base),focus:wn(t.focus),error:wn(t.error),placeholder:wn(t.placeholder),cvv:{base:wn((n=t.cvv)==null?void 0:n.base),focus:wn((a=t.cvv)==null?void 0:a.focus),error:wn((s=t.cvv)==null?void 0:s.error),placeholder:wn(t==null?void 0:t.placeholder)}}}}function wn(o){if(!o)return"";if(typeof o=="string")return o;let t="";for(const[e,n]of Object.entries(o)){let a="";e.split("").forEach(s=>{s.toUpperCase()===s?a+="-"+s.toLowerCase():a+=s}),t+=a+":"+n+";"}return t}const fd=Ct.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return en.getCoinflowUrl(this.args)}},emits:{onMessage({data:o,origin:t}){return console.log({data:o,origin:t}),!0}},methods:{sendMessage(o){const t=this.$refs.iframeRef;if(!(t!=null&&t.contentWindow))throw new Error("Iframe not defined");t.contentWindow.postMessage(o,"*")},handleIframeMessages({data:o,origin:t}){if(!t.includes(en.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:o,origin:t});const e=Vc(o,this.args);e&&e.then(this.sendMessage).catch(n=>{console.error(n),this.sendMessage("ERROR "+n.message)})},async listenForMessage(o){let t;return new Promise((e,n)=>{if(t=({data:a,origin:s})=>{if(s.includes(en.getCoinflowBaseUrl(this.args.env))){if(a.startsWith("ERROR")){n(new Error(a.replace("ERROR","")));return}o(a)&&e(a)}},!window)throw new Error("Window not defined");window.addEventListener("message",t)}).finally(()=>{window.removeEventListener("message",t)})},async sendAndReceiveMessage(o,t){return this.sendMessage(o),this.listenForMessage(t)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),vs=(o,t)=>{const e=o.__vccOpts||o;for(const[n,a]of t)e[n]=a;return e},hd=["src","scrolling"];function ld(o,t,e,n,a,s){return Ct.openBlock(),Ct.createElementBlock("iframe",{style:{height:"100%",width:"100%"},ref:"iframeRef",allow:"payment;camera",title:"withdraw",frameBorder:"0",src:o.url,scrolling:o.args.handleHeightChange?"no":"yes",onLoad:t[0]||(t[0]=()=>{const f=o.$refs.iframeRef;f&&(f.style.opacity="1")})},null,40,hd)}const ao=vs(fd,[["render",ld]]),dd=Ct.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:ao},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const o=oo(this.args);return{...this.args,walletPubkey:o,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...so(this.args),handleHeightChange:this.args.handleHeightChange}}}});function pd(o,t,e,n,a,s){const f=Ct.resolveComponent("coinflow-i-frame");return Ct.openBlock(),Ct.createBlock(f,{args:{...o.iframeProps,...o.messageHandlers}},null,8,["args"])}const yd=vs(dd,[["render",pd]]),gd=Ct.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:ao},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const o=oo(this.args);return{...this.args,walletPubkey:o,route:`/purchase/${this.args.merchantId}`,transaction:en.getTransaction(this.args)}},messageHandlers(){return{...so(this.args),handleHeightChange:this.args.handleHeightChange}}}});function wd(o,t,e,n,a,s){const f=Ct.resolveComponent("coinflow-i-frame");return Ct.openBlock(),Ct.createBlock(f,{args:{...o.iframeProps,...o.messageHandlers}},null,8,["args"])}const md=vs(gd,[["render",wd]]),_s=o=>{const t=Ct.ref(!1),e=Ct.ref(!1),n=Ct.ref(void 0),a=Ct.ref(void 0);Ct.onMounted(()=>{Is({env:o,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),e.value=!0}})});const s=_=>a.value=_,f=()=>t.value=!0,u=_=>n.value=_,y=async _=>{const F=await Jc({..._,tokenExScriptLoaded:e.value,env:o,setCachedToken:s,setLoaded:f});return u(F),F},x=async _=>{const F=await Xc({..._,tokenExScriptLoaded:e.value,env:o,setCachedToken:s,setLoaded:f});return u(F),F},v=async _=>{const F=await Qc({..._,tokenExScriptLoaded:e.value,env:o,setCachedToken:s,setLoaded:f});return u(F),F};return Ct.watchEffect(_=>{n.value&&(n.value.load(),_(()=>{var F;return(F=n.value)==null?void 0:F.remove()}))}),{tokenExIframe:n,initializeTokenExIframe:x,initializeCvvOnlyTokenExIframe:y,initializeTokenExCardOnlyIframe:v,loaded:t,cachedToken:a,setTokenExScriptTag:Is,tokenExScriptLoaded:e}},bd=["id"],xd=Ct.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(o,{expose:t}){const{args:e}=o,{initializeTokenExIframe:n,tokenExIframe:a}=_s(e.env);async function s(){if(!a.value)throw new Error("Unable to get token");return a.value.tokenize()}t({getToken:s});function f(){return JSON.stringify(e.css)}return Ct.watchEffect(()=>{n({css:f(),debug:e.debug,origins:e.origins,font:e.font})},{}),(u,y)=>(Ct.openBlock(),Ct.createElementBlock("div",{id:Ct.unref(Si)},null,8,bd))}}),Ed=["id"],kd=Ct.defineComponent({__name:"CoinflowCvvInput",setup(o){return(t,e)=>(Ct.openBlock(),Ct.createElementBlock("div",{id:Ct.unref(ri)},null,8,Ed))}}),Sd=["id"],Id=Ct.defineComponent({__name:"CoinflowCvvOnlyInput",props:{args:{type:Object,required:!0}},setup(o,{expose:t}){const{args:e}=o,{initializeCvvOnlyTokenExIframe:n,tokenExIframe:a}=_s(e.env);async function s(){if(!a.value)throw new Error("Unable to get token");return a.value.tokenize()}t({getToken:s});function f(){return JSON.stringify(e.css)}return Ct.watchEffect(()=>{n({...e,origins:e.origins??[],css:f(),font:e.font})},{}),(u,y)=>(Ct.openBlock(),Ct.createElementBlock("div",{id:Ct.unref(ri)},null,8,Sd))}}),Bd=Ct.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(o){const{args:{env:t,merchantId:e}}=o,n=Ct.ref(void 0);Ct.onMounted(()=>new en(t).getNSurePartnerId(e).then(f=>n.value=f));function a(){return t==="prod"?"9JBW2RHC7JNJN8ZQ":"SANDBOX_CTCE4XK53ZW0R7V1"}function s(){return t==="prod"?"https://sdk.nsureapi.com/sdk.js":"https://sdk.nsureapi.com/sdk-sandbox.js"}return Ct.watchEffect(f=>{if(!n.value)return;const u=document.createElement("script");u.src=s(),document.head.appendChild(u);const y=`window.nSureAsyncInit = function(deviceId) {
22
+ `+s+f;break;default:u=`Unknown action '${(y=>y)(t)}'`}super(u),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=n,this.transactionLogs=a||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const t=this.transactionLogs;if(!(t!=null&&typeof t=="object"&&"then"in t))return t}async getLogs(t){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((e,n)=>{t.getTransaction(this.signature).then(a=>{if(a&&a.meta&&a.meta.logMessages){const s=a.meta.logMessages;this.transactionLogs=s,e(s)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}}const sl={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016};class Ot extends Error{constructor({code:t,message:e,data:n},a){super(a!=null?`${a}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=n,this.name="SolanaJSONRPCError"}}async function os(o,t,e,n){const a=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},s=await o.sendTransaction(t,e,a);let f;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)f=(await o.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,signature:s,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},n&&n.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){const{nonceInstruction:u}=t.nonceInfo,y=u.keys[0].pubkey;f=(await o.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:y,nonceValue:t.nonceInfo.nonce,signature:s},n&&n.commitment)).value}else(n==null?void 0:n.abortSignal)!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),f=(await o.confirmTransaction(s,n&&n.commitment)).value;if(f.err)throw s!=null?new wi({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(f)})`}):new Error(`Transaction ${s} failed (${JSON.stringify(f)})`);return s}function Mn(o){return new Promise(t=>setTimeout(t,o))}function xe(o,t){const e=o.layout.span>=0?o.layout.span:uc(o,t),n=Nt.Buffer.alloc(e),a=Object.assign({instruction:o.index},t);return o.layout.encode(a,n),n}function Pe(o,t){let e;try{e=o.layout.decode(t)}catch(n){throw new Error("invalid instruction; "+n)}if(e.instruction!==o.index)throw new Error(`invalid instruction; instruction index mismatch ${e.instruction} != ${o.index}`);return e}const lc=dr("lamportsPerSignature"),dc=Pt([Ct("version"),Ct("state"),pe("authorizedPubkey"),pe("nonce"),Pt([lc],"feeCalculator")]),ss=dc.span;class Ji{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=dc.decode(oe(t),0);return new Ji({authorizedPubkey:new bt(e.authorizedPubkey),nonce:new bt(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const al=o=>{const t=o.decode.bind(o),e=o.encode.bind(o);return{decode:t,encode:e}},Xn=(o=>t=>{const e=Ke(o,t),{encode:n,decode:a}=al(e),s=e;return s.decode=(f,u)=>{const y=a(f,u);return Of(Nt.Buffer.from(y))},s.encode=(f,u,y)=>{const x=Pa(f,o);return n(x,u,y)},s})(8);class cl{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=Ct("instruction").decode(t.data);let a;for(const[s,f]of Object.entries(ze))if(f.index==n){a=s;break}if(!a)throw new Error("Instruction type incorrect; not a SystemInstruction");return a}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:n,programId:a}=Pe(ze.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:n,programId:new bt(a)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=Pe(ze.Transfer,t.data);return{fromPubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,lamports:e}}static decodeTransferWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e,seed:n,programId:a}=Pe(ze.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:n,programId:new bt(a)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=Pe(ze.Allocate,t.data);return{accountPubkey:t.keys[0].pubkey,space:e}}static decodeAllocateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:n,space:a,programId:s}=Pe(ze.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new bt(e),seed:n,space:a,programId:new bt(s)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=Pe(ze.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new bt(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:n,programId:a}=Pe(ze.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new bt(e),seed:n,programId:new bt(a)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:n,lamports:a,space:s,programId:f}=Pe(ze.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new bt(e),seed:n,lamports:a,space:s,programId:new bt(f)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=Pe(ze.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new bt(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Pe(ze.AdvanceNonceAccount,t.data),{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static decodeNonceWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Pe(ze.WithdrawNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e}}static decodeNonceAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e}=Pe(ze.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new bt(e)}}static checkProgramId(t){if(!t.equals(ur.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const ze=Object.freeze({Create:{index:0,layout:Pt([Ct("instruction"),Mr("lamports"),Mr("space"),pe("programId")])},Assign:{index:1,layout:Pt([Ct("instruction"),pe("programId")])},Transfer:{index:2,layout:Pt([Ct("instruction"),Xn("lamports")])},CreateWithSeed:{index:3,layout:Pt([Ct("instruction"),pe("base"),Rn("seed"),Mr("lamports"),Mr("space"),pe("programId")])},AdvanceNonceAccount:{index:4,layout:Pt([Ct("instruction")])},WithdrawNonceAccount:{index:5,layout:Pt([Ct("instruction"),Mr("lamports")])},InitializeNonceAccount:{index:6,layout:Pt([Ct("instruction"),pe("authorized")])},AuthorizeNonceAccount:{index:7,layout:Pt([Ct("instruction"),pe("authorized")])},Allocate:{index:8,layout:Pt([Ct("instruction"),Mr("space")])},AllocateWithSeed:{index:9,layout:Pt([Ct("instruction"),pe("base"),Rn("seed"),Mr("space"),pe("programId")])},AssignWithSeed:{index:10,layout:Pt([Ct("instruction"),pe("base"),Rn("seed"),pe("programId")])},TransferWithSeed:{index:11,layout:Pt([Ct("instruction"),Xn("lamports"),Rn("seed"),pe("programId")])},UpgradeNonceAccount:{index:12,layout:Pt([Ct("instruction")])}});class ur{constructor(){}static createAccount(t){const e=ze.Create,n=xe(e,{lamports:t.lamports,space:t.space,programId:oe(t.programId.toBuffer())});return new Ne({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(t){let e,n;if("basePubkey"in t){const a=ze.TransferWithSeed;e=xe(a,{lamports:BigInt(t.lamports),seed:t.seed,programId:oe(t.programId.toBuffer())}),n=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{const a=ze.Transfer;e=xe(a,{lamports:BigInt(t.lamports)}),n=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Ne({keys:n,programId:this.programId,data:e})}static assign(t){let e,n;if("basePubkey"in t){const a=ze.AssignWithSeed;e=xe(a,{base:oe(t.basePubkey.toBuffer()),seed:t.seed,programId:oe(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const a=ze.Assign;e=xe(a,{programId:oe(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ne({keys:n,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=ze.CreateWithSeed,n=xe(e,{base:oe(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:oe(t.programId.toBuffer())});let a=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey.equals(t.fromPubkey)||a.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Ne({keys:a,programId:this.programId,data:n})}static createNonceAccount(t){const e=new ve;"basePubkey"in t&&"seed"in t?e.add(ur.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:ss,programId:this.programId})):e.add(ur.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:ss,programId:this.programId}));const n={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(n)),e}static nonceInitialize(t){const e=ze.InitializeNonceAccount,n=xe(e,{authorized:oe(t.authorizedPubkey.toBuffer())}),a={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Yi,isSigner:!1,isWritable:!1},{pubkey:Jn,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new Ne(a)}static nonceAdvance(t){const e=ze.AdvanceNonceAccount,n=xe(e),a={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Yi,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new Ne(a)}static nonceWithdraw(t){const e=ze.WithdrawNonceAccount,n=xe(e,{lamports:t.lamports});return new Ne({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Yi,isSigner:!1,isWritable:!1},{pubkey:Jn,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(t){const e=ze.AuthorizeNonceAccount,n=xe(e,{authorized:oe(t.newAuthorizedPubkey.toBuffer())});return new Ne({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(t){let e,n;if("basePubkey"in t){const a=ze.AllocateWithSeed;e=xe(a,{base:oe(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:oe(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const a=ze.Allocate;e=xe(a,{space:t.space}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ne({keys:n,programId:this.programId,data:e})}}ur.programId=new bt("11111111111111111111111111111111");const ul=gn-300;class Cn{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/Cn.chunkSize)+1+1)}static async load(t,e,n,a,s){{const v=await t.getMinimumBalanceForRentExemption(s.length),F=await t.getAccountInfo(n.publicKey,"confirmed");let L=null;if(F!==null){if(F.executable)return console.error("Program load failed, account is already executable"),!1;F.data.length!==s.length&&(L=L||new ve,L.add(ur.allocate({accountPubkey:n.publicKey,space:s.length}))),F.owner.equals(a)||(L=L||new ve,L.add(ur.assign({accountPubkey:n.publicKey,programId:a}))),F.lamports<v&&(L=L||new ve,L.add(ur.transfer({fromPubkey:e.publicKey,toPubkey:n.publicKey,lamports:v-F.lamports})))}else L=new ve().add(ur.createAccount({fromPubkey:e.publicKey,newAccountPubkey:n.publicKey,lamports:v>0?v:1,space:s.length,programId:a}));L!==null&&await os(t,L,[e,n],{commitment:"confirmed"})}const f=Pt([Ct("instruction"),Ct("offset"),Ct("bytesLength"),Ct("bytesLengthPadding"),pr(_e("byte"),pn(Ct(),-8),"bytes")]),u=Cn.chunkSize;let y=0,x=s,B=[];for(;x.length>0;){const v=x.slice(0,u),F=Nt.Buffer.alloc(u+16);f.encode({instruction:0,offset:y,bytes:v,bytesLength:0,bytesLengthPadding:0},F);const L=new ve().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:a,data:F});B.push(os(t,L,[e,n],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await Mn(1e3/4),y+=u,x=x.slice(u)}await Promise.all(B);{const v=Pt([Ct("instruction")]),F=Nt.Buffer.alloc(v.span);v.encode({instruction:1},F);const L=new ve().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:Jn,isSigner:!1,isWritable:!1}],programId:a,data:F}),D="processed",U=await t.sendTransaction(L,[e,n],{preflightCommitment:D}),{context:z,value:$}=await t.confirmTransaction({signature:U,lastValidBlockHeight:L.lastValidBlockHeight,blockhash:L.recentBlockhash},D);if($.err)throw new Error(`Transaction ${U} failed (${JSON.stringify($)})`);for(;;){try{if(await t.getSlot({commitment:D})>z.slot)break}catch{}await new Promise(X=>setTimeout(X,Math.round(hc/2)))}}return!0}}Cn.chunkSize=ul;const fl=new bt("BPFLoader2111111111111111111111111111111111");class hl{static getMinNumSignatures(t){return Cn.getMinNumSignatures(t)}static load(t,e,n,a,s){return Cn.load(t,e,n,s,a)}}function ll(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var dl=Object.prototype.toString,pl=Object.keys||function(o){var t=[];for(var e in o)t.push(e);return t};function bi(o,t){var e,n,a,s,f,u,y;if(o===!0)return"true";if(o===!1)return"false";switch(typeof o){case"object":if(o===null)return null;if(o.toJSON&&typeof o.toJSON=="function")return bi(o.toJSON(),t);if(y=dl.call(o),y==="[object Array]"){for(a="[",n=o.length-1,e=0;e<n;e++)a+=bi(o[e],!0)+",";return n>-1&&(a+=bi(o[e],!0)),a+"]"}else if(y==="[object Object]"){for(s=pl(o).sort(),n=s.length,a="",e=0;e<n;)f=s[e],u=bi(o[f],!1),u!==void 0&&(a&&(a+=","),a+=JSON.stringify(f)+":"+u),e++;return"{"+a+"}"}else return JSON.stringify(o);case"function":case"undefined":return t?null:void 0;case"string":return JSON.stringify(o);default:return isFinite(o)?o:null}}var yl=function(o){var t=bi(o,!1);if(t!==void 0)return""+t},pc=ll(yl);const xi=32;function as(o){let t=0;for(;o>1;)o/=2,t++;return t}function gl(o){return o===0?1:(o--,o|=o>>1,o|=o>>2,o|=o>>4,o|=o>>8,o|=o>>16,o|=o>>32,o+1)}class yc{constructor(t,e,n,a,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=t,this.leaderScheduleSlotOffset=e,this.warmup=n,this.firstNormalEpoch=a,this.firstNormalSlot=s}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=as(gl(t+xi+1))-as(xi)-1,n=this.getSlotsInEpoch(e),a=t-(n-xi);return[e,a]}else{const e=t-this.firstNormalSlot,n=Math.floor(e/this.slotsPerEpoch),a=this.firstNormalEpoch+n,s=e%this.slotsPerEpoch;return[a,s]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*xi:(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+as(xi)):this.slotsPerEpoch}}var ml=globalThis.fetch;class wl extends Ih{constructor(t,e,n){const a=s=>{const f=kh(s,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in f?this.underlyingSocket=f.socket:this.underlyingSocket=f,f};super(a,t,e,n),this.underlyingSocket=void 0}call(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}function bl(o,t){let e;try{e=o.layout.decode(t)}catch(n){throw new Error("invalid instruction; "+n)}if(e.typeIndex!==o.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${o.index}`);return e}const gc=56;class cs{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=bl(xl,t),n=t.length-gc;Me(n>=0,"lookup table is invalid"),Me(n%32===0,"lookup table is invalid");const a=n/32,{addresses:s}=Pt([pr(pe(),a,"addresses")]).decode(t.slice(gc));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new bt(e.authority[0]):void 0,addresses:s.map(f=>new bt(f))}}}const xl={index:1,layout:Pt([Ct("typeIndex"),Xn("deactivationSlot"),dr("lastExtendedSlot"),_e("lastExtendedStartIndex"),_e(),pr(pe(),pn(_e(),-1),"authority")])},El=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function kl(o){const t=o.match(El);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${o}\``);const[e,n,a,s]=t,f=o.startsWith("https:")?"wss:":"ws:",u=a==null?null:parseInt(a.slice(1),10),y=u==null?"":`:${u+1}`;return`${f}//${n}${y}${s}`}const Ge=li(Ko(bt),mt(),o=>new bt(o)),mc=Wo([mt(),je("base64")]),us=li(Ko(Nt.Buffer),mc,o=>Nt.Buffer.from(o[0],"base64")),wc=30*1e3;function Sl(o){if(/^https?:/.test(o)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return o}function De(o){let t,e;if(typeof o=="string")t=o;else if(o){const{commitment:n,...a}=o;t=n,e=a}return{commitment:t,config:e}}function bc(o){return o.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function xc(o){return Br([ut({jsonrpc:je("2.0"),id:mt(),result:o}),ut({jsonrpc:je("2.0"),id:mt(),error:ut({code:Yn(),message:mt(),data:$t(Vf())})})])}const Il=xc(Yn());function se(o){return li(xc(o),Il,t=>"error"in t?t:{...t,result:xt(t.result,o)})}function Je(o){return se(ut({context:ut({slot:H()}),value:o}))}function Xi(o){return ut({context:ut({slot:H()}),value:o})}function fs(o,t){return o===0?new Tn({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new bt(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:cr.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new $r(t)}const Bl=ut({foundation:H(),foundationTerm:H(),initial:H(),taper:H(),terminal:H()}),_l=se(St(It(ut({epoch:H(),effectiveSlot:H(),amount:H(),postBalance:H(),commission:$t(It(H()))})))),vl=St(ut({slot:H(),prioritizationFee:H()})),Al=ut({total:H(),validator:H(),foundation:H(),epoch:H()}),Rl=ut({epoch:H(),slotIndex:H(),slotsInEpoch:H(),absoluteSlot:H(),blockHeight:$t(H()),transactionCount:$t(H())}),Tl=ut({slotsPerEpoch:H(),leaderScheduleSlotOffset:H(),warmup:Yr(),firstNormalEpoch:H(),firstNormalSlot:H()}),Ml=Oa(mt(),St(H())),Pn=It(Br([ut({}),mt()])),Cl=ut({err:Pn}),Pl=je("receivedSignature"),Ul=ut({"solana-core":mt(),"feature-set":$t(H())}),Ll=ut({program:mt(),programId:Ge,parsed:Yn()}),Fl=ut({programId:Ge,accounts:St(Ge),data:mt()}),Ec=Je(ut({err:It(Br([ut({}),mt()])),logs:It(St(mt())),accounts:$t(It(St(It(ut({executable:Yr(),owner:mt(),lamports:H(),data:St(mt()),rentEpoch:$t(H())}))))),unitsConsumed:$t(H()),returnData:$t(It(ut({programId:mt(),data:Wo([mt(),je("base64")])}))),innerInstructions:$t(It(St(ut({index:H(),instructions:St(Br([Ll,Fl]))}))))})),Ol=Je(ut({byIdentity:Oa(mt(),St(H())),range:ut({firstSlot:H(),lastSlot:H()})}));function Nl(o,t,e,n,a,s){const f=e||ml;let u;s!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let y;return n&&(y=async(B,v)=>{const F=await new Promise((L,D)=>{try{n(B,v,(U,z)=>L([U,z]))}catch(U){D(U)}});return await f(...F)}),new bh(async(B,v)=>{const F={method:"POST",body:B,agent:u,headers:Object.assign({"Content-Type":"application/json"},t||{},z0)};try{let L=5,D,U=500;for(;y?D=await y(o,F):D=await f(o,F),!(D.status!==429||a===!0||(L-=1,L===0));)console.error(`Server responded with ${D.status} ${D.statusText}. Retrying after ${U}ms delay...`),await Mn(U),U*=2;const z=await D.text();D.ok?v(null,z):v(new Error(`${D.status} ${D.statusText}: ${z}`))}catch(L){L instanceof Error&&v(L)}},{})}function zl(o){return(t,e)=>new Promise((n,a)=>{o.request(t,e,(s,f)=>{if(s){a(s);return}n(f)})})}function Dl(o){return t=>new Promise((e,n)=>{t.length===0&&e([]);const a=t.map(s=>o.request(s.methodName,s.args));o.request(a,(s,f)=>{if(s){n(s);return}e(f)})})}const $l=se(Bl),Kl=se(Al),Wl=se(vl),ql=se(Rl),Hl=se(Tl),Vl=se(Ml),jl=se(H()),Gl=Je(ut({total:H(),circulating:H(),nonCirculating:H(),nonCirculatingAccounts:St(Ge)})),hs=ut({amount:mt(),uiAmount:It(H()),decimals:H(),uiAmountString:$t(mt())}),Yl=Je(St(ut({address:Ge,amount:mt(),uiAmount:It(H()),decimals:H(),uiAmountString:$t(mt())}))),Zl=Je(St(ut({pubkey:Ge,account:ut({executable:Yr(),owner:Ge,lamports:H(),data:us,rentEpoch:H()})}))),ls=ut({program:mt(),parsed:Yn(),space:H()}),Jl=Je(St(ut({pubkey:Ge,account:ut({executable:Yr(),owner:Ge,lamports:H(),data:ls,rentEpoch:H()})}))),Xl=Je(St(ut({lamports:H(),address:Ge}))),Ei=ut({executable:Yr(),owner:Ge,lamports:H(),data:us,rentEpoch:H()}),Ql=ut({pubkey:Ge,account:Ei}),t0=li(Br([Ko(Nt.Buffer),ls]),Br([mc,ls]),o=>Array.isArray(o)?xt(o,us):o),ds=ut({executable:Yr(),owner:Ge,lamports:H(),data:t0,rentEpoch:H()}),e0=ut({pubkey:Ge,account:ds}),r0=ut({state:Br([je("active"),je("inactive"),je("activating"),je("deactivating")]),active:H(),inactive:H()}),n0=se(St(ut({signature:mt(),slot:H(),err:Pn,memo:It(mt()),blockTime:$t(It(H()))}))),i0=se(St(ut({signature:mt(),slot:H(),err:Pn,memo:It(mt()),blockTime:$t(It(H()))}))),o0=ut({subscription:H(),result:Xi(Ei)}),s0=ut({pubkey:Ge,account:Ei}),a0=ut({subscription:H(),result:Xi(s0)}),c0=ut({parent:H(),slot:H(),root:H()}),u0=ut({subscription:H(),result:c0}),f0=Br([ut({type:Br([je("firstShredReceived"),je("completed"),je("optimisticConfirmation"),je("root")]),slot:H(),timestamp:H()}),ut({type:je("createdBank"),parent:H(),slot:H(),timestamp:H()}),ut({type:je("frozen"),slot:H(),timestamp:H(),stats:ut({numTransactionEntries:H(),numSuccessfulTransactions:H(),numFailedTransactions:H(),maxTransactionsPerEntry:H()})}),ut({type:je("dead"),slot:H(),timestamp:H(),err:mt()})]),h0=ut({subscription:H(),result:f0}),l0=ut({subscription:H(),result:Xi(Br([Cl,Pl]))}),d0=ut({subscription:H(),result:H()}),p0=ut({pubkey:mt(),gossip:It(mt()),tpu:It(mt()),rpc:It(mt()),version:It(mt())}),kc=ut({votePubkey:mt(),nodePubkey:mt(),activatedStake:H(),epochVoteAccount:Yr(),epochCredits:St(Wo([H(),H(),H()])),commission:H(),lastVote:H(),rootSlot:It(H())}),y0=se(ut({current:St(kc),delinquent:St(kc)})),g0=Br([je("processed"),je("confirmed"),je("finalized")]),m0=ut({slot:H(),confirmations:It(H()),err:Pn,confirmationStatus:$t(g0)}),w0=Je(St(It(m0))),b0=se(H()),Sc=ut({accountKey:Ge,writableIndexes:St(H()),readonlyIndexes:St(H())}),ps=ut({signatures:St(mt()),message:ut({accountKeys:St(mt()),header:ut({numRequiredSignatures:H(),numReadonlySignedAccounts:H(),numReadonlyUnsignedAccounts:H()}),instructions:St(ut({accounts:St(H()),data:mt(),programIdIndex:H()})),recentBlockhash:mt(),addressTableLookups:$t(St(Sc))})}),Ic=ut({pubkey:Ge,signer:Yr(),writable:Yr(),source:$t(Br([je("transaction"),je("lookupTable")]))}),Bc=ut({accountKeys:St(Ic),signatures:St(mt())}),_c=ut({parsed:Yn(),program:mt(),programId:Ge}),vc=ut({accounts:St(Ge),data:mt(),programId:Ge}),x0=Br([vc,_c]),E0=Br([ut({parsed:Yn(),program:mt(),programId:mt()}),ut({accounts:St(mt()),data:mt(),programId:mt()})]),Ac=li(x0,E0,o=>"accounts"in o?xt(o,vc):xt(o,_c)),Rc=ut({signatures:St(mt()),message:ut({accountKeys:St(Ic),instructions:St(Ac),recentBlockhash:mt(),addressTableLookups:$t(It(St(Sc)))})}),Qi=ut({accountIndex:H(),mint:mt(),owner:$t(mt()),uiTokenAmount:hs}),Tc=ut({writable:St(Ge),readonly:St(Ge)}),to=ut({err:Pn,fee:H(),innerInstructions:$t(It(St(ut({index:H(),instructions:St(ut({accounts:St(H()),data:mt(),programIdIndex:H()}))})))),preBalances:St(H()),postBalances:St(H()),logMessages:$t(It(St(mt()))),preTokenBalances:$t(It(St(Qi))),postTokenBalances:$t(It(St(Qi))),loadedAddresses:$t(Tc),computeUnitsConsumed:$t(H())}),ys=ut({err:Pn,fee:H(),innerInstructions:$t(It(St(ut({index:H(),instructions:St(Ac)})))),preBalances:St(H()),postBalances:St(H()),logMessages:$t(It(St(mt()))),preTokenBalances:$t(It(St(Qi))),postTokenBalances:$t(It(St(Qi))),loadedAddresses:$t(Tc),computeUnitsConsumed:$t(H())}),Qn=Br([je(0),je("legacy")]),Un=ut({pubkey:mt(),lamports:H(),postBalance:It(H()),rewardType:It(mt()),commission:$t(It(H()))}),k0=se(It(ut({blockhash:mt(),previousBlockhash:mt(),parentSlot:H(),transactions:St(ut({transaction:ps,meta:It(to),version:$t(Qn)})),rewards:$t(St(Un)),blockTime:It(H()),blockHeight:It(H())}))),S0=se(It(ut({blockhash:mt(),previousBlockhash:mt(),parentSlot:H(),rewards:$t(St(Un)),blockTime:It(H()),blockHeight:It(H())}))),I0=se(It(ut({blockhash:mt(),previousBlockhash:mt(),parentSlot:H(),transactions:St(ut({transaction:Bc,meta:It(to),version:$t(Qn)})),rewards:$t(St(Un)),blockTime:It(H()),blockHeight:It(H())}))),B0=se(It(ut({blockhash:mt(),previousBlockhash:mt(),parentSlot:H(),transactions:St(ut({transaction:Rc,meta:It(ys),version:$t(Qn)})),rewards:$t(St(Un)),blockTime:It(H()),blockHeight:It(H())}))),_0=se(It(ut({blockhash:mt(),previousBlockhash:mt(),parentSlot:H(),transactions:St(ut({transaction:Bc,meta:It(ys),version:$t(Qn)})),rewards:$t(St(Un)),blockTime:It(H()),blockHeight:It(H())}))),v0=se(It(ut({blockhash:mt(),previousBlockhash:mt(),parentSlot:H(),rewards:$t(St(Un)),blockTime:It(H()),blockHeight:It(H())}))),A0=se(It(ut({blockhash:mt(),previousBlockhash:mt(),parentSlot:H(),transactions:St(ut({transaction:ps,meta:It(to)})),rewards:$t(St(Un)),blockTime:It(H())}))),Mc=se(It(ut({blockhash:mt(),previousBlockhash:mt(),parentSlot:H(),signatures:St(mt()),blockTime:It(H())}))),gs=se(It(ut({slot:H(),meta:It(to),blockTime:$t(It(H())),transaction:ps,version:$t(Qn)}))),eo=se(It(ut({slot:H(),transaction:Rc,meta:It(ys),blockTime:$t(It(H())),version:$t(Qn)}))),R0=Je(ut({blockhash:mt(),feeCalculator:ut({lamportsPerSignature:H()})})),T0=Je(ut({blockhash:mt(),lastValidBlockHeight:H()})),M0=Je(Yr()),C0=ut({slot:H(),numTransactions:H(),numSlots:H(),samplePeriodSecs:H()}),P0=se(St(C0)),U0=Je(It(ut({feeCalculator:ut({lamportsPerSignature:H()})}))),L0=se(mt()),F0=se(mt()),O0=ut({err:Pn,logs:St(mt()),signature:mt()}),N0=ut({result:Xi(O0),subscription:H()}),z0={"solana-client":"js/1.0.0-maintenance"};class D0{constructor(t,e){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const x={};return async B=>{const{commitment:v,config:F}=De(B),L=this._buildArgs([],v,void 0,F),D=pc(L);return x[D]=x[D]??(async()=>{try{const U=await this._rpcRequest("getBlockHeight",L),z=xt(U,se(H()));if("error"in z)throw new Ot(z.error,"failed to get block height information");return z.result}finally{delete x[D]}})(),await x[D]}})();let n,a,s,f,u,y;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,n=e.wsEndpoint,a=e.httpHeaders,s=e.fetch,f=e.fetchMiddleware,u=e.disableRetryOnRateLimit,y=e.httpAgent),this._rpcEndpoint=Sl(t),this._rpcWsEndpoint=n||kl(t),this._rpcClient=Nl(t,a,s,f,u,y),this._rpcRequest=zl(this._rpcClient),this._rpcBatchRequest=Dl(this._rpcClient),this._rpcWebSocket=new wl(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgs([t.toBase58()],n,void 0,a),f=await this._rpcRequest("getBalance",s),u=xt(f,Je(H()));if("error"in u)throw new Ot(u.error,`failed to get balance for ${t.toBase58()}`);return u.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+n)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),n=xt(e,se(It(H())));if("error"in n)throw new Ot(n.error,`failed to get block time for slot ${t}`);return n.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=xt(t,se(H()));if("error"in e)throw new Ot(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=xt(t,jl);if("error"in e)throw new Ot(e.error,"failed to get first available block");return e.result}async getSupply(t){let e={};typeof t=="string"?e={commitment:t}:t?e={...t,commitment:t&&t.commitment||this.commitment}:e={commitment:this.commitment};const n=await this._rpcRequest("getSupply",[e]),a=xt(n,Gl);if("error"in a)throw new Ot(a.error,"failed to get supply");return a.result}async getTokenSupply(t,e){const n=this._buildArgs([t.toBase58()],e),a=await this._rpcRequest("getTokenSupply",n),s=xt(a,Je(hs));if("error"in s)throw new Ot(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(t,e){const n=this._buildArgs([t.toBase58()],e),a=await this._rpcRequest("getTokenAccountBalance",n),s=xt(a,Je(hs));if("error"in s)throw new Ot(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(t,e,n){const{commitment:a,config:s}=De(n);let f=[t.toBase58()];"mint"in e?f.push({mint:e.mint.toBase58()}):f.push({programId:e.programId.toBase58()});const u=this._buildArgs(f,a,"base64",s),y=await this._rpcRequest("getTokenAccountsByOwner",u),x=xt(y,Zl);if("error"in x)throw new Ot(x.error,`failed to get token accounts owned by account ${t.toBase58()}`);return x.result}async getParsedTokenAccountsByOwner(t,e,n){let a=[t.toBase58()];"mint"in e?a.push({mint:e.mint.toBase58()}):a.push({programId:e.programId.toBase58()});const s=this._buildArgs(a,n,"jsonParsed"),f=await this._rpcRequest("getTokenAccountsByOwner",s),u=xt(f,Jl);if("error"in u)throw new Ot(u.error,`failed to get token accounts owned by account ${t.toBase58()}`);return u.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},n=e.filter||e.commitment?[e]:[],a=await this._rpcRequest("getLargestAccounts",n),s=xt(a,Xl);if("error"in s)throw new Ot(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(t,e){const n=this._buildArgs([t.toBase58()],e),a=await this._rpcRequest("getTokenLargestAccounts",n),s=xt(a,Yl);if("error"in s)throw new Ot(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgs([t.toBase58()],n,"base64",a),f=await this._rpcRequest("getAccountInfo",s),u=xt(f,Je(It(Ei)));if("error"in u)throw new Ot(u.error,`failed to get info about account ${t.toBase58()}`);return u.result}async getParsedAccountInfo(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgs([t.toBase58()],n,"jsonParsed",a),f=await this._rpcRequest("getAccountInfo",s),u=xt(f,Je(It(ds)));if("error"in u)throw new Ot(u.error,`failed to get info about account ${t.toBase58()}`);return u.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(n){throw new Error("failed to get info about account "+t.toBase58()+": "+n)}}async getMultipleParsedAccounts(t,e){const{commitment:n,config:a}=De(e),s=t.map(x=>x.toBase58()),f=this._buildArgs([s],n,"jsonParsed",a),u=await this._rpcRequest("getMultipleAccounts",f),y=xt(u,Je(St(It(ds))));if("error"in y)throw new Ot(y.error,`failed to get info for accounts ${s}`);return y.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:n,config:a}=De(e),s=t.map(x=>x.toBase58()),f=this._buildArgs([s],n,"base64",a),u=await this._rpcRequest("getMultipleAccounts",f),y=xt(u,Je(St(It(Ei))));if("error"in y)throw new Ot(y.error,`failed to get info for accounts ${s}`);return y.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,n){const{commitment:a,config:s}=De(e),f=this._buildArgs([t.toBase58()],a,void 0,{...s,epoch:n??(s==null?void 0:s.epoch)}),u=await this._rpcRequest("getStakeActivation",f),y=xt(u,se(r0));if("error"in y)throw new Ot(y.error,`failed to get Stake Activation ${t.toBase58()}`);return y.result}async getProgramAccounts(t,e){const{commitment:n,config:a}=De(e),{encoding:s,...f}=a||{},u=this._buildArgs([t.toBase58()],n,s||"base64",{...f,...f.filters?{filters:bc(f.filters)}:null}),y=await this._rpcRequest("getProgramAccounts",u),x=St(Ql),B=f.withContext===!0?xt(y,Je(x)):xt(y,se(x));if("error"in B)throw new Ot(B.error,`failed to get accounts owned by program ${t.toBase58()}`);return B.result}async getParsedProgramAccounts(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgs([t.toBase58()],n,"jsonParsed",a),f=await this._rpcRequest("getProgramAccounts",s),u=xt(f,se(St(e0)));if("error"in u)throw new Ot(u.error,`failed to get accounts owned by program ${t.toBase58()}`);return u.result}async confirmTransaction(t,e){var s;let n;if(typeof t=="string")n=t;else{const f=t;if((s=f.abortSignal)!=null&&s.aborted)return Promise.reject(f.abortSignal.reason);n=f.signature}let a;try{a=cr.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return Me(a.length===64,"signature has invalid length"),typeof t=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:n}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise((e,n)=>{t!=null&&(t.aborted?n(t.reason):t.addEventListener("abort",()=>{n(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let n,a,s=!1;const f=new Promise((y,x)=>{try{n=this.onSignature(e,(v,F)=>{n=void 0;const L={context:F,value:v};y({__type:sn.PROCESSED,response:L})},t);const B=new Promise(v=>{n==null?v():a=this._onSubscriptionStateChange(n,F=>{F==="subscribed"&&v()})});(async()=>{if(await B,s)return;const v=await this.getSignatureStatus(e);if(s||v==null)return;const{context:F,value:L}=v;if(L!=null)if(L!=null&&L.err)x(L.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(L.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(L.confirmationStatus==="processed"||L.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}s=!0,y({__type:sn.PROCESSED,response:{context:F,value:L}})}})()}catch(B){x(B)}});return{abortConfirmation:()=>{a&&(a(),a=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:f}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:n,signature:a}}){let s=!1;const f=new Promise(v=>{const F=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let L=await F();if(!s){for(;L<=n;)if(await Mn(1e3),s||(L=await F(),s))return;v({__type:sn.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:u,confirmationPromise:y}=this.getTransactionConfirmationPromise({commitment:t,signature:a}),x=this.getCancellationPromise(e);let B;try{const v=await Promise.race([x,y,f]);if(v.__type===sn.PROCESSED)B=v.response;else throw new ts(a)}finally{s=!0,u()}return B}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:n,nonceAccountPubkey:a,nonceValue:s,signature:f}}){let u=!1;const y=new Promise(L=>{let D=s,U=null;const z=async()=>{try{const{context:$,value:X}=await this.getNonceAndContext(a,{commitment:t,minContextSlot:n});return U=$.slot,X==null?void 0:X.nonce}catch{return D}};(async()=>{if(D=await z(),!u)for(;;){if(s!==D){L({__type:sn.NONCE_INVALID,slotInWhichNonceDidAdvance:U});return}if(await Mn(2e3),u||(D=await z(),u))return}})()}),{abortConfirmation:x,confirmationPromise:B}=this.getTransactionConfirmationPromise({commitment:t,signature:f}),v=this.getCancellationPromise(e);let F;try{const L=await Promise.race([v,B,y]);if(L.__type===sn.PROCESSED)F=L.response;else{let D;for(;;){const U=await this.getSignatureStatus(f);if(U==null)break;if(U.context.slot<(L.slotInWhichNonceDidAdvance??n)){await Mn(400);continue}D=U;break}if(D!=null&&D.value){const U=t||"finalized",{confirmationStatus:z}=D.value;switch(U){case"processed":case"recent":if(z!=="processed"&&z!=="confirmed"&&z!=="finalized")throw new Zn(f);break;case"confirmed":case"single":case"singleGossip":if(z!=="confirmed"&&z!=="finalized")throw new Zn(f);break;case"finalized":case"max":case"root":if(z!=="finalized")throw new Zn(f);break;default:}F={context:D.context,value:{err:D.value.err}}}else throw new Zn(f)}}finally{u=!0,x()}return F}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let n;const a=new Promise(y=>{let x=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{x=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>y({__type:sn.TIMED_OUT,timeoutMs:x}),x)}),{abortConfirmation:s,confirmationPromise:f}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let u;try{const y=await Promise.race([f,a]);if(y.__type===sn.PROCESSED)u=y.response;else throw new es(e,y.timeoutMs/1e3)}finally{clearTimeout(n),s()}return u}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=xt(t,se(St(p0)));if("error"in e)throw new Ot(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getVoteAccounts",e),a=xt(n,y0);if("error"in a)throw new Ot(a.error,"failed to get vote accounts");return a.result}async getSlot(t){const{commitment:e,config:n}=De(t),a=this._buildArgs([],e,void 0,n),s=await this._rpcRequest("getSlot",a),f=xt(s,se(H()));if("error"in f)throw new Ot(f.error,"failed to get slot");return f.result}async getSlotLeader(t){const{commitment:e,config:n}=De(t),a=this._buildArgs([],e,void 0,n),s=await this._rpcRequest("getSlotLeader",a),f=xt(s,se(mt()));if("error"in f)throw new Ot(f.error,"failed to get slot leader");return f.result}async getSlotLeaders(t,e){const n=[t,e],a=await this._rpcRequest("getSlotLeaders",n),s=xt(a,se(St(Ge)));if("error"in s)throw new Ot(s.error,"failed to get slot leaders");return s.result}async getSignatureStatus(t,e){const{context:n,value:a}=await this.getSignatureStatuses([t],e);Me(a.length===1);const s=a[0];return{context:n,value:s}}async getSignatureStatuses(t,e){const n=[t];e&&n.push(e);const a=await this._rpcRequest("getSignatureStatuses",n),s=xt(a,w0);if("error"in s)throw new Ot(s.error,"failed to get signature status");return s.result}async getTransactionCount(t){const{commitment:e,config:n}=De(t),a=this._buildArgs([],e,void 0,n),s=await this._rpcRequest("getTransactionCount",a),f=xt(s,se(H()));if("error"in f)throw new Ot(f.error,"failed to get transaction count");return f.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getInflationGovernor",e),a=xt(n,$l);if("error"in a)throw new Ot(a.error,"failed to get inflation");return a.result}async getInflationReward(t,e,n){const{commitment:a,config:s}=De(n),f=this._buildArgs([t.map(x=>x.toBase58())],a,void 0,{...s,epoch:e??(s==null?void 0:s.epoch)}),u=await this._rpcRequest("getInflationReward",f),y=xt(u,_l);if("error"in y)throw new Ot(y.error,"failed to get inflation reward");return y.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=xt(t,Kl);if("error"in e)throw new Ot(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:n}=De(t),a=this._buildArgs([],e,void 0,n),s=await this._rpcRequest("getEpochInfo",a),f=xt(s,ql);if("error"in f)throw new Ot(f.error,"failed to get epoch info");return f.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=xt(t,Hl);if("error"in e)throw new Ot(e.error,"failed to get epoch schedule");const n=e.result;return new yc(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=xt(t,Vl);if("error"in e)throw new Ot(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const n=this._buildArgs([t],e),a=await this._rpcRequest("getMinimumBalanceForRentExemption",n),s=xt(a,b0);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getRecentBlockhash",e),a=xt(n,R0);if("error"in a)throw new Ot(a.error,"failed to get recent blockhash");return a.result}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),n=xt(e,P0);if("error"in n)throw new Ot(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(t,e){const n=this._buildArgs([t],e),a=await this._rpcRequest("getFeeCalculatorForBlockhash",n),s=xt(a,U0);if("error"in s)throw new Ot(s.error,"failed to get fee calculator");const{context:f,value:u}=s.result;return{context:f,value:u!==null?u.feeCalculator:null}}async getFeeForMessage(t,e){const n=oe(t.serialize()).toString("base64"),a=this._buildArgs([n],e),s=await this._rpcRequest("getFeeForMessage",a),f=xt(s,Je(It(H())));if("error"in f)throw new Ot(f.error,"failed to get fee for message");if(f.result===null)throw new Error("invalid blockhash");return f.result}async getRecentPrioritizationFees(t){var f;const e=(f=t==null?void 0:t.lockedWritableAccounts)==null?void 0:f.map(u=>u.toBase58()),n=e!=null&&e.length?[e]:[],a=await this._rpcRequest("getRecentPrioritizationFees",n),s=xt(a,Wl);if("error"in s)throw new Ot(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:n}=De(t),a=this._buildArgs([],e,void 0,n),s=await this._rpcRequest("getLatestBlockhash",a),f=xt(s,T0);if("error"in f)throw new Ot(f.error,"failed to get latest blockhash");return f.result}async isBlockhashValid(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgs([t],n,void 0,a),f=await this._rpcRequest("isBlockhashValid",s),u=xt(f,M0);if("error"in u)throw new Ot(u.error,"failed to determine if the blockhash `"+t+"`is valid");return u.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=xt(t,se(Ul));if("error"in e)throw new Ot(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=xt(t,se(mt()));if("error"in e)throw new Ot(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgsAtLeastConfirmed([t],n,void 0,a),f=await this._rpcRequest("getBlock",s);try{switch(a==null?void 0:a.transactionDetails){case"accounts":{const u=xt(f,I0);if("error"in u)throw u.error;return u.result}case"none":{const u=xt(f,S0);if("error"in u)throw u.error;return u.result}default:{const u=xt(f,k0);if("error"in u)throw u.error;const{result:y}=u;return y?{...y,transactions:y.transactions.map(({transaction:x,meta:B,version:v})=>({meta:B,transaction:{...x,message:fs(v,x.message)},version:v}))}:null}}}catch(u){throw new Ot(u,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",a),f=await this._rpcRequest("getBlock",s);try{switch(a==null?void 0:a.transactionDetails){case"accounts":{const u=xt(f,_0);if("error"in u)throw u.error;return u.result}case"none":{const u=xt(f,v0);if("error"in u)throw u.error;return u.result}default:{const u=xt(f,B0);if("error"in u)throw u.error;return u.result}}}catch(u){throw new Ot(u,"failed to get block")}}async getBlockProduction(t){let e,n;if(typeof t=="string")n=t;else if(t){const{commitment:u,...y}=t;n=u,e=y}const a=this._buildArgs([],n,"base64",e),s=await this._rpcRequest("getBlockProduction",a),f=xt(s,Ol);if("error"in f)throw new Ot(f.error,"failed to get block production information");return f.result}async getTransaction(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgsAtLeastConfirmed([t],n,void 0,a),f=await this._rpcRequest("getTransaction",s),u=xt(f,gs);if("error"in u)throw new Ot(u.error,"failed to get transaction");const y=u.result;return y&&{...y,transaction:{...y.transaction,message:fs(y.version,y.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:n,config:a}=De(e),s=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",a),f=await this._rpcRequest("getTransaction",s),u=xt(f,eo);if("error"in u)throw new Ot(u.error,"failed to get transaction");return u.result}async getParsedTransactions(t,e){const{commitment:n,config:a}=De(e),s=t.map(y=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([y],n,"jsonParsed",a)}));return(await this._rpcBatchRequest(s)).map(y=>{const x=xt(y,eo);if("error"in x)throw new Ot(x.error,"failed to get transactions");return x.result})}async getTransactions(t,e){const{commitment:n,config:a}=De(e),s=t.map(y=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([y],n,void 0,a)}));return(await this._rpcBatchRequest(s)).map(y=>{const x=xt(y,gs);if("error"in x)throw new Ot(x.error,"failed to get transactions");const B=x.result;return B&&{...B,transaction:{...B.transaction,message:fs(B.version,B.transaction.message)}}})}async getConfirmedBlock(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),a=await this._rpcRequest("getConfirmedBlock",n),s=xt(a,A0);if("error"in s)throw new Ot(s.error,"failed to get confirmed block");const f=s.result;if(!f)throw new Error("Confirmed block "+t+" not found");const u={...f,transactions:f.transactions.map(({transaction:y,meta:x})=>{const B=new $r(y.message);return{meta:x,transaction:{...y,message:B}}})};return{...u,transactions:u.transactions.map(({transaction:y,meta:x})=>({meta:x,transaction:ve.populate(y.message,y.signatures)}))}}async getBlocks(t,e,n){const a=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],n),s=await this._rpcRequest("getBlocks",a),f=xt(s,se(St(H())));if("error"in f)throw new Ot(f.error,"failed to get blocks");return f.result}async getBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),a=await this._rpcRequest("getBlock",n),s=xt(a,Mc);if("error"in s)throw new Ot(s.error,"failed to get block");const f=s.result;if(!f)throw new Error("Block "+t+" not found");return f}async getConfirmedBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),a=await this._rpcRequest("getConfirmedBlock",n),s=xt(a,Mc);if("error"in s)throw new Ot(s.error,"failed to get confirmed block");const f=s.result;if(!f)throw new Error("Confirmed block "+t+" not found");return f}async getConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),a=await this._rpcRequest("getConfirmedTransaction",n),s=xt(a,gs);if("error"in s)throw new Ot(s.error,"failed to get transaction");const f=s.result;if(!f)return f;const u=new $r(f.transaction.message),y=f.transaction.signatures;return{...f,transaction:ve.populate(u,y)}}async getParsedConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),a=await this._rpcRequest("getConfirmedTransaction",n),s=xt(a,eo);if("error"in s)throw new Ot(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(t,e){const n=t.map(f=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([f],e,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(f=>{const u=xt(f,eo);if("error"in u)throw new Ot(u.error,"failed to get confirmed transactions");return u.result})}async getConfirmedSignaturesForAddress(t,e,n){let a={},s=await this.getFirstAvailableBlock();for(;!("until"in a)&&(e--,!(e<=0||e<s));)try{const y=await this.getConfirmedBlockSignatures(e,"finalized");y.signatures.length>0&&(a.until=y.signatures[y.signatures.length-1].toString())}catch(y){if(y instanceof Error&&y.message.includes("skipped"))continue;throw y}let f=await this.getSlot("finalized");for(;!("before"in a)&&(n++,!(n>f));)try{const y=await this.getConfirmedBlockSignatures(n);y.signatures.length>0&&(a.before=y.signatures[y.signatures.length-1].toString())}catch(y){if(y instanceof Error&&y.message.includes("skipped"))continue;throw y}return(await this.getConfirmedSignaturesForAddress2(t,a)).map(y=>y.signature)}async getConfirmedSignaturesForAddress2(t,e,n){const a=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",a),f=xt(s,n0);if("error"in f)throw new Ot(f.error,"failed to get confirmed signatures for address");return f.result}async getSignaturesForAddress(t,e,n){const a=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),s=await this._rpcRequest("getSignaturesForAddress",a),f=xt(s,i0);if("error"in f)throw new Ot(f.error,"failed to get signatures for address");return f.result}async getAddressLookupTable(t,e){const{context:n,value:a}=await this.getAccountInfoAndContext(t,e);let s=null;return a!==null&&(s=new cs({key:t,state:cs.deserialize(a.data)})),{context:n,value:s}}async getNonceAndContext(t,e){const{context:n,value:a}=await this.getAccountInfoAndContext(t,e);let s=null;return a!==null&&(s=Ji.fromAccountData(a.data)),{context:n,value:s}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+n)})}async requestAirdrop(t,e){const n=await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),a=xt(n,L0);if("error"in a)throw new Ot(a.error,`airdrop to ${t.toBase58()} failed`);return a.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Mn(100);const n=Date.now()-this._blockhashInfo.lastFetch>=wc;if(this._blockhashInfo.latestBlockhash!==null&&!n)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,n=e?e.blockhash:null;for(let a=0;a<50;a++){const s=await this.getLatestBlockhash("finalized");if(n!==s.blockhash)return this._blockhashInfo={latestBlockhash:s,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},s;await Mn(hc/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:n}=De(t),a=this._buildArgs([],e,"base64",n),s=await this._rpcRequest("getStakeMinimumDelegation",a),f=xt(s,Je(H()));if("error"in f)throw new Ot(f.error,"failed to get stake minimum delegation");return f.result}async simulateTransaction(t,e,n){if("message"in t){const U=t.serialize(),z=Nt.Buffer.from(U).toString("base64");if(Array.isArray(e)||n!==void 0)throw new Error("Invalid arguments");const $=e||{};$.encoding="base64","commitment"in $||($.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&($.innerInstructions=e.innerInstructions);const X=[z,$],V=await this._rpcRequest("simulateTransaction",X),it=xt(V,Ec);if("error"in it)throw new Error("failed to simulate transaction: "+it.error.message);return it.result}let a;if(t instanceof ve){let D=t;a=new ve,a.feePayer=D.feePayer,a.instructions=t.instructions,a.nonceInfo=D.nonceInfo,a.signatures=D.signatures}else a=ve.populate(t),a._message=a._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(a.nonceInfo&&s)a.sign(...s);else{let D=this._disableBlockhashCaching;for(;;){const U=await this._blockhashWithExpiryBlockHeight(D);if(a.lastValidBlockHeight=U.lastValidBlockHeight,a.recentBlockhash=U.blockhash,!s)break;if(a.sign(...s),!a.signature)throw new Error("!signature");const z=a.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(z)&&!this._blockhashInfo.transactionSignatures.includes(z)){this._blockhashInfo.simulatedSignatures.push(z);break}else D=!0}}const f=a._compile(),u=f.serialize(),x=a._serialize(u).toString("base64"),B={encoding:"base64",commitment:this.commitment};if(n){const D=(Array.isArray(n)?n:f.nonProgramIds()).map(U=>U.toBase58());B.accounts={encoding:"base64",addresses:D}}s&&(B.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(B.innerInstructions=e.innerInstructions);const v=[x,B],F=await this._rpcRequest("simulateTransaction",v),L=xt(F,Ec);if("error"in L){let D;if("data"in L.error&&(D=L.error.data.logs,D&&Array.isArray(D))){const U=`
23
+ `,z=U+D.join(U);console.error(L.error.message,z)}throw new wi({action:"simulate",signature:"",transactionMessage:L.error.message,logs:D})}return L.result}async sendTransaction(t,e,n){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const f=t.serialize();return await this.sendRawTransaction(f,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const a=e;if(t.nonceInfo)t.sign(...a);else{let f=this._disableBlockhashCaching;for(;;){const u=await this._blockhashWithExpiryBlockHeight(f);if(t.lastValidBlockHeight=u.lastValidBlockHeight,t.recentBlockhash=u.blockhash,t.sign(...a),!t.signature)throw new Error("!signature");const y=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(y))f=!0;else{this._blockhashInfo.transactionSignatures.push(y);break}}}const s=t.serialize();return await this.sendRawTransaction(s,n)}async sendRawTransaction(t,e){const n=oe(t).toString("base64");return await this.sendEncodedTransaction(n,e)}async sendEncodedTransaction(t,e){const n={encoding:"base64"},a=e&&e.skipPreflight,s=a===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(n.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(n.minContextSlot=e.minContextSlot),a&&(n.skipPreflight=a),s&&(n.preflightCommitment=s);const f=[t,n],u=await this._rpcRequest("sendTransaction",f),y=xt(u,F0);if("error"in y){let x;throw"data"in y.error&&(x=y.error.data.logs),new wi({action:a?"send":"simulate",signature:"",transactionMessage:y.error.message,logs:x})}return y.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),t===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,n])=>{this._setSubscription(e,{...n,state:"pending"})})}_setSubscription(t,e){var a;const n=(a=this._subscriptionsByHash[t])==null?void 0:a.state;if(this._subscriptionsByHash[t]=e,n!==e.state){const s=this._subscriptionStateChangeCallbacksByHash[t];s&&s.forEach(f=>{try{f(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var s;const n=this._subscriptionHashByClientSubscriptionId[t];if(n==null)return()=>{};const a=(s=this._subscriptionStateChangeCallbacksByHash)[n]||(s[n]=new Set);return a.add(e),()=>{a.delete(e),a.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{const a=this._subscriptionsByHash[n];if(a!==void 0)switch(a.state){case"pending":case"unsubscribed":if(a.callbacks.size===0){delete this._subscriptionsByHash[n],a.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[a.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:s,method:f}=a;try{this._setSubscription(n,{...a,state:"subscribing"});const u=await this._rpcWebSocket.call(f,s);this._setSubscription(n,{...a,serverSubscriptionId:u,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[u]=a.callbacks,await this._updateSubscriptions()}catch(u){if(u instanceof Error&&console.error(`${f} error for argument`,s,u.message),!e())return;this._setSubscription(n,{...a,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":a.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:s,unsubscribeMethod:f}=a;if(this._subscriptionsAutoDisposedByRpc.has(s))this._subscriptionsAutoDisposedByRpc.delete(s);else{this._setSubscription(n,{...a,state:"unsubscribing"}),this._setSubscription(n,{...a,state:"unsubscribing"});try{await this._rpcWebSocket.call(f,[s])}catch(u){if(u instanceof Error&&console.error(`${f} error:`,u.message),!e())return;this._setSubscription(n,{...a,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...a,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const n=this._subscriptionCallbacksByServerSubscriptionId[t];n!==void 0&&n.forEach(a=>{try{a(...e)}catch(s){console.error(s)}})}_wsOnAccountNotification(t){const{result:e,subscription:n}=xt(t,o0);this._handleServerNotification(n,[e.value,e.context])}_makeSubscription(t,e){const n=this._nextClientSubscriptionId++,a=pc([t.method,e]),s=this._subscriptionsByHash[a];return s===void 0?this._subscriptionsByHash[a]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:s.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[n]=a,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const f=this._subscriptionsByHash[a];Me(f!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),f.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(t,e,n){const{commitment:a,config:s}=De(n),f=this._buildArgs([t.toBase58()],a||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},f)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:n}=xt(t,a0);this._handleServerNotification(n,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,n,a){const{commitment:s,config:f}=De(n),u=this._buildArgs([t.toBase58()],s||this._commitment||"finalized","base64",f||(a?{filters:bc(a)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},u)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,n){const a=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],n||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},a)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:n}=xt(t,N0);this._handleServerNotification(n,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:n}=xt(t,u0);this._handleServerNotification(n,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:n}=xt(t,h0);this._handleServerNotification(n,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,n,a){const s=e||this._commitment;if(s||n||a){let f={};n&&(f.encoding=n),s&&(f.commitment=s),a&&(f=Object.assign(f,a)),t.push(f)}return t}_buildArgsAtLeastConfirmed(t,e,n,a){const s=e||this._commitment;if(s&&!["confirmed","finalized"].includes(s))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,n,a)}_wsOnSignatureNotification(t){const{result:e,subscription:n}=xt(t,l0);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,n){const a=this._buildArgs([t],n||this._commitment||"finalized"),s=this._makeSubscription({callback:(f,u)=>{if(f.type==="status"){e(f.result,u);try{this.removeSignatureListener(s)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},a);return s}onSignatureWithOptions(t,e,n){const{commitment:a,...s}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},f=this._buildArgs([t],a,void 0,s),u=this._makeSubscription({callback:(y,x)=>{e(y,x);try{this.removeSignatureListener(u)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},f);return u}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:n}=xt(t,d0);this._handleServerNotification(n,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}class Ln{constructor(t){this._keypair=void 0,this._keypair=t??ic()}static generate(){return new Ln(ic())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");const n=t.slice(32,64);if(!e||!e.skipValidation){const a=t.slice(0,32),s=Vi(a);for(let f=0;f<32;f++)if(n[f]!==s[f])throw new Error("provided secretKey is invalid")}return new Ln({publicKey:n,secretKey:t})}static fromSeed(t){const e=Vi(t),n=new Uint8Array(64);return n.set(t),n.set(e,32),new Ln({publicKey:e,secretKey:n})}get publicKey(){return new bt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const an=Object.freeze({CreateLookupTable:{index:0,layout:Pt([Ct("instruction"),Xn("recentSlot"),_e("bumpSeed")])},FreezeLookupTable:{index:1,layout:Pt([Ct("instruction")])},ExtendLookupTable:{index:2,layout:Pt([Ct("instruction"),Xn(),pr(pe(),pn(Ct(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Pt([Ct("instruction")])},CloseLookupTable:{index:4,layout:Pt([Ct("instruction")])}});class $0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=Ct("instruction").decode(t.data);let a;for(const[s,f]of Object.entries(an))if(f.index==n){a=s;break}if(!a)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return a}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=Pe(an.CreateLookupTable,t.data);return{authority:t.keys[1].pubkey,payer:t.keys[2].pubkey,recentSlot:Number(e)}}static decodeExtendLookupTable(t){if(this.checkProgramId(t.programId),t.keys.length<2)throw new Error(`invalid instruction; found ${t.keys.length} keys, expected at least 2`);const{addresses:e}=Pe(an.ExtendLookupTable,t.data);return{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,payer:t.keys.length>2?t.keys[2].pubkey:void 0,addresses:e.map(n=>new bt(n))}}static decodeCloseLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}static decodeFreezeLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static decodeDeactivateLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(ms.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}class ms{constructor(){}static createLookupTable(t){const[e,n]=bt.findProgramAddressSync([t.authority.toBuffer(),Pa(BigInt(t.recentSlot),8)],this.programId),a=an.CreateLookupTable,s=xe(a,{recentSlot:BigInt(t.recentSlot),bumpSeed:n}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:ur.programId,isSigner:!1,isWritable:!1}];return[new Ne({programId:this.programId,keys:f,data:s}),e]}static freezeLookupTable(t){const e=an.FreezeLookupTable,n=xe(e),a=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ne({programId:this.programId,keys:a,data:n})}static extendLookupTable(t){const e=an.ExtendLookupTable,n=xe(e,{addresses:t.addresses.map(s=>s.toBytes())}),a=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&a.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:ur.programId,isSigner:!1,isWritable:!1}),new Ne({programId:this.programId,keys:a,data:n})}static deactivateLookupTable(t){const e=an.DeactivateLookupTable,n=xe(e),a=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ne({programId:this.programId,keys:a,data:n})}static closeLookupTable(t){const e=an.CloseLookupTable,n=xe(e),a=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Ne({programId:this.programId,keys:a,data:n})}}ms.programId=new bt("AddressLookupTab1e1111111111111111111111111");class K0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=_e("instruction").decode(t.data);let a;for(const[s,f]of Object.entries(Qr))if(f.index==n){a=s;break}if(!a)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return a}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:n}=Pe(Qr.RequestUnits,t.data);return{units:e,additionalFee:n}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Pe(Qr.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Pe(Qr.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Pe(Qr.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(ws.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Qr=Object.freeze({RequestUnits:{index:0,layout:Pt([_e("instruction"),Ct("units"),Ct("additionalFee")])},RequestHeapFrame:{index:1,layout:Pt([_e("instruction"),Ct("bytes")])},SetComputeUnitLimit:{index:2,layout:Pt([_e("instruction"),Ct("units")])},SetComputeUnitPrice:{index:3,layout:Pt([_e("instruction"),Xn("microLamports")])}});class ws{constructor(){}static requestUnits(t){const e=Qr.RequestUnits,n=xe(e,t);return new Ne({keys:[],programId:this.programId,data:n})}static requestHeapFrame(t){const e=Qr.RequestHeapFrame,n=xe(e,t);return new Ne({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(t){const e=Qr.SetComputeUnitLimit,n=xe(e,t);return new Ne({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(t){const e=Qr.SetComputeUnitPrice,n=xe(e,{microLamports:BigInt(t.microLamports)});return new Ne({keys:[],programId:this.programId,data:n})}}ws.programId=new bt("ComputeBudget111111111111111111111111111111");const Cc=64,Pc=32,Uc=64,Lc=Pt([_e("numSignatures"),_e("padding"),Lr("signatureOffset"),Lr("signatureInstructionIndex"),Lr("publicKeyOffset"),Lr("publicKeyInstructionIndex"),Lr("messageDataOffset"),Lr("messageDataSize"),Lr("messageInstructionIndex")]);class ro{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:n,signature:a,instructionIndex:s}=t;Me(e.length===Pc,`Public Key must be ${Pc} bytes but received ${e.length} bytes`),Me(a.length===Uc,`Signature must be ${Uc} bytes but received ${a.length} bytes`);const f=Lc.span,u=f+e.length,y=u+a.length,x=1,B=Nt.Buffer.alloc(y+n.length),v=s??65535;return Lc.encode({numSignatures:x,padding:0,signatureOffset:u,signatureInstructionIndex:v,publicKeyOffset:f,publicKeyInstructionIndex:v,messageDataOffset:y,messageDataSize:n.length,messageInstructionIndex:v},B),B.fill(e,f),B.fill(a,u),B.fill(n,y),new Ne({keys:[],programId:ro.programId,data:B})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:n,instructionIndex:a}=t;Me(e.length===Cc,`Private key must be ${Cc} bytes but received ${e.length} bytes`);try{const s=Ln.fromSecretKey(e),f=s.publicKey.toBytes(),u=Xo(n,s.secretKey);return this.createInstructionWithPublicKey({publicKey:f,message:n,signature:u,instructionIndex:a})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}ro.programId=new bt("Ed25519SigVerify111111111111111111111111111");const W0=(o,t)=>{const e=Hi.sign(o,t);return[e.toCompactRawBytes(),e.recovery]};Hi.utils.isValidPrivateKey;const q0=Hi.getPublicKey,Fc=32,bs=20,Oc=64,H0=11,xs=Pt([_e("numSignatures"),Lr("signatureOffset"),_e("signatureInstructionIndex"),Lr("ethAddressOffset"),_e("ethAddressInstructionIndex"),Lr("messageDataOffset"),Lr("messageDataSize"),_e("messageInstructionIndex"),Ke(20,"ethAddress"),Ke(64,"signature"),_e("recoveryId")]);class ti{constructor(){}static publicKeyToEthAddress(t){Me(t.length===Oc,`Public key must be ${Oc} bytes but received ${t.length} bytes`);try{return Nt.Buffer.from(Ja(oe(t))).slice(-bs)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:n,signature:a,recoveryId:s,instructionIndex:f}=t;return ti.createInstructionWithEthAddress({ethAddress:ti.publicKeyToEthAddress(e),message:n,signature:a,recoveryId:s,instructionIndex:f})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:n,signature:a,recoveryId:s,instructionIndex:f=0}=t;let u;typeof e=="string"?e.startsWith("0x")?u=Nt.Buffer.from(e.substr(2),"hex"):u=Nt.Buffer.from(e,"hex"):u=e,Me(u.length===bs,`Address must be ${bs} bytes but received ${u.length} bytes`);const y=1+H0,x=y,B=y+u.length,v=B+a.length+1,F=1,L=Nt.Buffer.alloc(xs.span+n.length);return xs.encode({numSignatures:F,signatureOffset:B,signatureInstructionIndex:f,ethAddressOffset:x,ethAddressInstructionIndex:f,messageDataOffset:v,messageDataSize:n.length,messageInstructionIndex:f,signature:oe(a),ethAddress:oe(u),recoveryId:s},L),L.fill(oe(n),xs.span),new Ne({keys:[],programId:ti.programId,data:L})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:n,instructionIndex:a}=t;Me(e.length===Fc,`Private key must be ${Fc} bytes but received ${e.length} bytes`);try{const s=oe(e),f=q0(s,!1).slice(1),u=Nt.Buffer.from(Ja(oe(n))),[y,x]=W0(u,s);return this.createInstructionWithPublicKey({publicKey:f,message:n,signature:y,recoveryId:x,instructionIndex:a})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}ti.programId=new bt("KeccakSecp256k11111111111111111111111111111");var Nc;const zc=new bt("StakeConfig11111111111111111111111111111111");class Dc{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class ki{constructor(t,e,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=n}}Nc=ki,ki.default=new Nc(0,0,bt.default);class V0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=Ct("instruction").decode(t.data);let a;for(const[s,f]of Object.entries(fr))if(f.index==n){a=s;break}if(!a)throw new Error("Instruction type incorrect; not a StakeInstruction");return a}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:n}=Pe(fr.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new Dc(new bt(e.staker),new bt(e.withdrawer)),lockup:new ki(n.unixTimestamp,n.epoch,new bt(n.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),Pe(fr.Delegate,t.data),{stakePubkey:t.keys[0].pubkey,votePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[5].pubkey}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,stakeAuthorizationType:n}=Pe(fr.Authorize,t.data),a={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new bt(e),stakeAuthorizationType:{index:n}};return t.keys.length>3&&(a.custodianPubkey=t.keys[3].pubkey),a}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:n,authoritySeed:a,authorityOwner:s}=Pe(fr.AuthorizeWithSeed,t.data),f={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:a,authorityOwner:new bt(s),newAuthorizedPubkey:new bt(e),stakeAuthorizationType:{index:n}};return t.keys.length>3&&(f.custodianPubkey=t.keys[3].pubkey),f}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Pe(fr.Split,t.data);return{stakePubkey:t.keys[0].pubkey,splitStakePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[2].pubkey,lamports:e}}static decodeMerge(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Pe(fr.Merge,t.data),{stakePubkey:t.keys[0].pubkey,sourceStakePubKey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Pe(fr.Withdraw,t.data),n={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(n.custodianPubkey=t.keys[5].pubkey),n}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Pe(fr.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(no.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const fr=Object.freeze({Initialize:{index:0,layout:Pt([Ct("instruction"),Zh(),Jh()])},Authorize:{index:1,layout:Pt([Ct("instruction"),pe("newAuthorized"),Ct("stakeAuthorizationType")])},Delegate:{index:2,layout:Pt([Ct("instruction")])},Split:{index:3,layout:Pt([Ct("instruction"),Mr("lamports")])},Withdraw:{index:4,layout:Pt([Ct("instruction"),Mr("lamports")])},Deactivate:{index:5,layout:Pt([Ct("instruction")])},Merge:{index:7,layout:Pt([Ct("instruction")])},AuthorizeWithSeed:{index:8,layout:Pt([Ct("instruction"),pe("newAuthorized"),Ct("stakeAuthorizationType"),Rn("authoritySeed"),pe("authorityOwner")])}}),j0=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class no{constructor(){}static initialize(t){const{stakePubkey:e,authorized:n,lockup:a}=t,s=a||ki.default,f=fr.Initialize,u=xe(f,{authorized:{staker:oe(n.staker.toBuffer()),withdrawer:oe(n.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:oe(s.custodian.toBuffer())}}),y={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Jn,isSigner:!1,isWritable:!1}],programId:this.programId,data:u};return new Ne(y)}static createAccountWithSeed(t){const e=new ve;e.add(ur.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:a,lockup:s}=t;return e.add(this.initialize({stakePubkey:n,authorized:a,lockup:s}))}static createAccount(t){const e=new ve;e.add(ur.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:a,lockup:s}=t;return e.add(this.initialize({stakePubkey:n,authorized:a,lockup:s}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:n,votePubkey:a}=t,s=fr.Delegate,f=xe(s);return new ve().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!1},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:zc,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:f})}static authorize(t){const{stakePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:a,stakeAuthorizationType:s,custodianPubkey:f}=t,u=fr.Authorize,y=xe(u,{newAuthorized:oe(a.toBuffer()),stakeAuthorizationType:s.index}),x=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return f&&x.push({pubkey:f,isSigner:!0,isWritable:!1}),new ve().add({keys:x,programId:this.programId,data:y})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:n,authoritySeed:a,authorityOwner:s,newAuthorizedPubkey:f,stakeAuthorizationType:u,custodianPubkey:y}=t,x=fr.AuthorizeWithSeed,B=xe(x,{newAuthorized:oe(f.toBuffer()),stakeAuthorizationType:u.index,authoritySeed:a,authorityOwner:oe(s.toBuffer())}),v=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Xr,isSigner:!1,isWritable:!1}];return y&&v.push({pubkey:y,isSigner:!0,isWritable:!1}),new ve().add({keys:v,programId:this.programId,data:B})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:n,splitStakePubkey:a,lamports:s}=t,f=fr.Split,u=xe(f,{lamports:s});return new Ne({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:u})}static split(t,e){const n=new ve;return n.add(ur.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:e,space:this.space,programId:this.programId})),n.add(this.splitInstruction(t))}static splitWithSeed(t,e){const{stakePubkey:n,authorizedPubkey:a,splitStakePubkey:s,basePubkey:f,seed:u,lamports:y}=t,x=new ve;return x.add(ur.allocate({accountPubkey:s,basePubkey:f,seed:u,space:this.space,programId:this.programId})),e&&e>0&&x.add(ur.transfer({fromPubkey:t.authorizedPubkey,toPubkey:s,lamports:e})),x.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:a,splitStakePubkey:s,lamports:y}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:n,authorizedPubkey:a}=t,s=fr.Merge,f=xe(s);return new ve().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!0,isWritable:!1}],programId:this.programId,data:f})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:n,toPubkey:a,lamports:s,custodianPubkey:f}=t,u=fr.Withdraw,y=xe(u,{lamports:s}),x=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:Zi,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return f&&x.push({pubkey:f,isSigner:!0,isWritable:!1}),new ve().add({keys:x,programId:this.programId,data:y})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:n}=t,a=fr.Deactivate,s=xe(a);return new ve().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}}no.programId=new bt("Stake11111111111111111111111111111111111111"),no.space=200;class $c{constructor(t,e,n,a){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=n,this.commission=a}}class G0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const n=Ct("instruction").decode(t.data);let a;for(const[s,f]of Object.entries(tn))if(f.index==n){a=s;break}if(!a)throw new Error("Instruction type incorrect; not a VoteInstruction");return a}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=Pe(tn.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new $c(new bt(e.nodePubkey),new bt(e.authorizedVoter),new bt(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:n}=Pe(tn.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new bt(e),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:n,newAuthorized:a,voteAuthorizationType:s}}=Pe(tn.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new bt(e),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new bt(a),voteAuthorizationType:{index:s},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Pe(tn.Withdraw,t.data);return{votePubkey:t.keys[0].pubkey,authorizedWithdrawerPubkey:t.keys[2].pubkey,lamports:e,toPubkey:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(ei.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const tn=Object.freeze({InitializeAccount:{index:0,layout:Pt([Ct("instruction"),Xh()])},Authorize:{index:1,layout:Pt([Ct("instruction"),pe("newAuthorized"),Ct("voteAuthorizationType")])},Withdraw:{index:3,layout:Pt([Ct("instruction"),Mr("lamports")])},UpdateValidatorIdentity:{index:4,layout:Pt([Ct("instruction")])},AuthorizeWithSeed:{index:10,layout:Pt([Ct("instruction"),Qh()])}}),Y0=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class ei{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:n,voteInit:a}=t,s=tn.InitializeAccount,f=xe(s,{voteInit:{nodePubkey:oe(a.nodePubkey.toBuffer()),authorizedVoter:oe(a.authorizedVoter.toBuffer()),authorizedWithdrawer:oe(a.authorizedWithdrawer.toBuffer()),commission:a.commission}}),u={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Jn,isSigner:!1,isWritable:!1},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:f};return new Ne(u)}static createAccount(t){const e=new ve;return e.add(ur.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){const{votePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:a,voteAuthorizationType:s}=t,f=tn.Authorize,u=xe(f,{newAuthorized:oe(a.toBuffer()),voteAuthorizationType:s.index}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new ve().add({keys:y,programId:this.programId,data:u})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:a,newAuthorizedPubkey:s,voteAuthorizationType:f,votePubkey:u}=t,y=tn.AuthorizeWithSeed,x=xe(y,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:oe(n.toBuffer()),currentAuthorityDerivedKeySeed:a,newAuthorized:oe(s.toBuffer()),voteAuthorizationType:f.index}}),B=[{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new ve().add({keys:B,programId:this.programId,data:x})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:n,lamports:a,toPubkey:s}=t,f=tn.Withdraw,u=xe(f,{lamports:a}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new ve().add({keys:y,programId:this.programId,data:u})}static safeWithdraw(t,e,n){if(t.lamports>e-n)throw new Error("Withdraw will leave vote account with insufficient funds.");return ei.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:n,nodePubkey:a}=t,s=tn.UpdateValidatorIdentity,f=xe(s),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new ve().add({keys:u,programId:this.programId,data:f})}}ei.programId=new bt("Vote111111111111111111111111111111111111111"),ei.space=3762;const Kc=new bt("Va1idator1nfo111111111111111111111111111111"),Z0=ut({name:mt(),website:$t(mt()),details:$t(mt()),iconUrl:$t(mt()),keybaseUsername:$t(mt())});class Es{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(vr(e)!==2)return null;const a=[];for(let s=0;s<2;s++){const f=new bt(Ar(e,0,Zr)),u=Jr(e)===1;a.push({publicKey:f,isSigner:u})}if(a[0].publicKey.equals(Kc)&&a[1].isSigner){const s=Rn().decode(Nt.Buffer.from(e)),f=JSON.parse(s);return La(f,Z0),new Es(a[1].publicKey,f)}return null}}const J0=new bt("Vote111111111111111111111111111111111111111"),X0=Pt([pe("nodePubkey"),pe("authorizedWithdrawer"),_e("commission"),dr(),pr(Pt([dr("slot"),Ct("confirmationCount")]),pn(Ct(),-8),"votes"),_e("rootSlotValid"),dr("rootSlot"),dr(),pr(Pt([dr("epoch"),pe("authorizedVoter")]),pn(Ct(),-8),"authorizedVoters"),Pt([pr(Pt([pe("authorizedPubkey"),dr("epochOfLastAuthorizedSwitch"),dr("targetEpoch")]),32,"buf"),dr("idx"),_e("isEmpty")],"priorVoters"),dr(),pr(Pt([dr("epoch"),dr("credits"),dr("prevCredits")]),pn(Ct(),-8),"epochCredits"),Pt([dr("slot"),dr("timestamp")],"lastTimestamp")]);class ks{constructor(t){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=t.nodePubkey,this.authorizedWithdrawer=t.authorizedWithdrawer,this.commission=t.commission,this.rootSlot=t.rootSlot,this.votes=t.votes,this.authorizedVoters=t.authorizedVoters,this.priorVoters=t.priorVoters,this.epochCredits=t.epochCredits,this.lastTimestamp=t.lastTimestamp}static fromAccountData(t){const n=X0.decode(oe(t),4);let a=n.rootSlot;return n.rootSlotValid||(a=null),new ks({nodePubkey:new bt(n.nodePubkey),authorizedWithdrawer:new bt(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:a,authorizedVoters:n.authorizedVoters.map(Q0),priorVoters:td(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}}function Q0({authorizedVoter:o,epoch:t}){return{epoch:t,authorizedVoter:new bt(o)}}function Wc({authorizedPubkey:o,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new bt(o),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function td({buf:o,idx:t,isEmpty:e}){return e?[]:[...o.slice(t+1).map(Wc),...o.slice(0,t).map(Wc)]}const qc={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function ed(o,t){const e=t===!1?"http":"https";if(!o)return qc[e].devnet;const n=qc[e][o];if(!n)throw new Error(`Unknown ${e} cluster: ${o}`);return n}async function rd(o,t,e,n){let a,s;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(a=e,s=n):s=e;const f=s&&{skipPreflight:s.skipPreflight,preflightCommitment:s.preflightCommitment||s.commitment,minContextSlot:s.minContextSlot},u=await o.sendRawTransaction(t,f),y=s&&s.commitment,B=(await(a?o.confirmTransaction(a,y):o.confirmTransaction(u,y))).value;if(B.err)throw u!=null?new wi({action:f!=null&&f.skipPreflight?"send":"simulate",signature:u,transactionMessage:`Status: (${JSON.stringify(B)})`}):new Error(`Raw transaction ${u} failed (${JSON.stringify(B)})`);return u}const io=Object.freeze(Object.defineProperty({__proto__:null,Account:jh,AddressLookupTableAccount:cs,AddressLookupTableInstruction:$0,AddressLookupTableProgram:ms,Authorized:Dc,BLOCKHASH_CACHE_TIMEOUT_MS:wc,BPF_LOADER_DEPRECATED_PROGRAM_ID:Gh,BPF_LOADER_PROGRAM_ID:fl,BpfLoader:hl,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Qr,ComputeBudgetInstruction:K0,ComputeBudgetProgram:ws,Connection:D0,Ed25519Program:ro,Enum:Hh,EpochSchedule:yc,FeeCalculatorLayout:lc,Keypair:Ln,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:an,Loader:Cn,Lockup:ki,MAX_SEED_LENGTH:ac,Message:$r,MessageAccountKeys:mi,MessageV0:Tn,NONCE_ACCOUNT_LENGTH:ss,NonceAccount:Ji,PACKET_DATA_SIZE:gn,PUBLIC_KEY_LENGTH:Zr,PublicKey:bt,SIGNATURE_LENGTH_IN_BYTES:gi,SOLANA_SCHEMA:yi,STAKE_CONFIG_ID:zc,STAKE_INSTRUCTION_LAYOUTS:fr,SYSTEM_INSTRUCTION_LAYOUTS:ze,SYSVAR_CLOCK_PUBKEY:Xr,SYSVAR_EPOCH_SCHEDULE_PUBKEY:el,SYSVAR_INSTRUCTIONS_PUBKEY:rl,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:Yi,SYSVAR_RENT_PUBKEY:Jn,SYSVAR_REWARDS_PUBKEY:nl,SYSVAR_SLOT_HASHES_PUBKEY:il,SYSVAR_SLOT_HISTORY_PUBKEY:ol,SYSVAR_STAKE_HISTORY_PUBKEY:Zi,Secp256k1Program:ti,SendTransactionError:wi,SolanaJSONRPCError:Ot,SolanaJSONRPCErrorCode:sl,StakeAuthorizationLayout:j0,StakeInstruction:V0,StakeProgram:no,Struct:Qo,SystemInstruction:cl,SystemProgram:ur,Transaction:ve,TransactionExpiredBlockheightExceededError:ts,TransactionExpiredNonceInvalidError:Zn,TransactionExpiredTimeoutError:es,TransactionInstruction:Ne,TransactionMessage:ns,TransactionStatus:sn,VALIDATOR_INFO_KEY:Kc,VERSION_PREFIX_MASK:ji,VOTE_PROGRAM_ID:J0,ValidatorInfo:Es,VersionedMessage:rs,VersionedTransaction:is,VoteAccount:ks,VoteAuthorizationLayout:Y0,VoteInit:$c,VoteInstruction:G0,VoteProgram:ei,clusterApiUrl:ed,sendAndConfirmRawTransaction:rd,sendAndConfirmTransaction:os},Symbol.toStringTag,{value:"Module"})),Kr=cr;var Ss={exports:{}};Ss.exports,function(o){var t=function(){var e=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function f(y,x){if(!s[y]){s[y]={};for(var B=0;B<y.length;B++)s[y][y.charAt(B)]=B}return s[y][x]}var u={compressToBase64:function(y){if(y==null)return"";var x=u._compress(y,6,function(B){return n.charAt(B)});switch(x.length%4){default:case 0:return x;case 1:return x+"===";case 2:return x+"==";case 3:return x+"="}},decompressFromBase64:function(y){return y==null?"":y==""?null:u._decompress(y.length,32,function(x){return f(n,y.charAt(x))})},compressToUTF16:function(y){return y==null?"":u._compress(y,15,function(x){return e(x+32)})+" "},decompressFromUTF16:function(y){return y==null?"":y==""?null:u._decompress(y.length,16384,function(x){return y.charCodeAt(x)-32})},compressToUint8Array:function(y){for(var x=u.compress(y),B=new Uint8Array(x.length*2),v=0,F=x.length;v<F;v++){var L=x.charCodeAt(v);B[v*2]=L>>>8,B[v*2+1]=L%256}return B},decompressFromUint8Array:function(y){if(y==null)return u.decompress(y);for(var x=new Array(y.length/2),B=0,v=x.length;B<v;B++)x[B]=y[B*2]*256+y[B*2+1];var F=[];return x.forEach(function(L){F.push(e(L))}),u.decompress(F.join(""))},compressToEncodedURIComponent:function(y){return y==null?"":u._compress(y,6,function(x){return a.charAt(x)})},decompressFromEncodedURIComponent:function(y){return y==null?"":y==""?null:(y=y.replace(/ /g,"+"),u._decompress(y.length,32,function(x){return f(a,y.charAt(x))}))},compress:function(y){return u._compress(y,16,function(x){return e(x)})},_compress:function(y,x,B){if(y==null)return"";var v,F,L={},D={},U="",z="",$="",X=2,V=3,it=2,G=[],W=0,Q=0,rt;for(rt=0;rt<y.length;rt+=1)if(U=y.charAt(rt),Object.prototype.hasOwnProperty.call(L,U)||(L[U]=V++,D[U]=!0),z=$+U,Object.prototype.hasOwnProperty.call(L,z))$=z;else{if(Object.prototype.hasOwnProperty.call(D,$)){if($.charCodeAt(0)<256){for(v=0;v<it;v++)W=W<<1,Q==x-1?(Q=0,G.push(B(W)),W=0):Q++;for(F=$.charCodeAt(0),v=0;v<8;v++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(B(W)),W=0):Q++,F=F>>1}else{for(F=1,v=0;v<it;v++)W=W<<1|F,Q==x-1?(Q=0,G.push(B(W)),W=0):Q++,F=0;for(F=$.charCodeAt(0),v=0;v<16;v++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(B(W)),W=0):Q++,F=F>>1}X--,X==0&&(X=Math.pow(2,it),it++),delete D[$]}else for(F=L[$],v=0;v<it;v++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(B(W)),W=0):Q++,F=F>>1;X--,X==0&&(X=Math.pow(2,it),it++),L[z]=V++,$=String(U)}if($!==""){if(Object.prototype.hasOwnProperty.call(D,$)){if($.charCodeAt(0)<256){for(v=0;v<it;v++)W=W<<1,Q==x-1?(Q=0,G.push(B(W)),W=0):Q++;for(F=$.charCodeAt(0),v=0;v<8;v++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(B(W)),W=0):Q++,F=F>>1}else{for(F=1,v=0;v<it;v++)W=W<<1|F,Q==x-1?(Q=0,G.push(B(W)),W=0):Q++,F=0;for(F=$.charCodeAt(0),v=0;v<16;v++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(B(W)),W=0):Q++,F=F>>1}X--,X==0&&(X=Math.pow(2,it),it++),delete D[$]}else for(F=L[$],v=0;v<it;v++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(B(W)),W=0):Q++,F=F>>1;X--,X==0&&(X=Math.pow(2,it),it++)}for(F=2,v=0;v<it;v++)W=W<<1|F&1,Q==x-1?(Q=0,G.push(B(W)),W=0):Q++,F=F>>1;for(;;)if(W=W<<1,Q==x-1){G.push(B(W));break}else Q++;return G.join("")},decompress:function(y){return y==null?"":y==""?null:u._decompress(y.length,32768,function(x){return y.charCodeAt(x)})},_decompress:function(y,x,B){var v=[],F=4,L=4,D=3,U="",z=[],$,X,V,it,G,W,Q,rt={val:B(0),position:x,index:1};for($=0;$<3;$+=1)v[$]=$;for(V=0,G=Math.pow(2,2),W=1;W!=G;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=x,rt.val=B(rt.index++)),V|=(it>0?1:0)*W,W<<=1;switch(V){case 0:for(V=0,G=Math.pow(2,8),W=1;W!=G;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=x,rt.val=B(rt.index++)),V|=(it>0?1:0)*W,W<<=1;Q=e(V);break;case 1:for(V=0,G=Math.pow(2,16),W=1;W!=G;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=x,rt.val=B(rt.index++)),V|=(it>0?1:0)*W,W<<=1;Q=e(V);break;case 2:return""}for(v[3]=Q,X=Q,z.push(Q);;){if(rt.index>y)return"";for(V=0,G=Math.pow(2,D),W=1;W!=G;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=x,rt.val=B(rt.index++)),V|=(it>0?1:0)*W,W<<=1;switch(Q=V){case 0:for(V=0,G=Math.pow(2,8),W=1;W!=G;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=x,rt.val=B(rt.index++)),V|=(it>0?1:0)*W,W<<=1;v[L++]=e(V),Q=L-1,F--;break;case 1:for(V=0,G=Math.pow(2,16),W=1;W!=G;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=x,rt.val=B(rt.index++)),V|=(it>0?1:0)*W,W<<=1;v[L++]=e(V),Q=L-1,F--;break;case 2:return z.join("")}if(F==0&&(F=Math.pow(2,D),D++),v[Q])U=v[Q];else if(Q===L)U=X+X.charAt(0);else return null;z.push(U),v[L++]=X+U.charAt(0),F--,X=U,F==0&&(F=Math.pow(2,D),D++)}}};return u}();o!=null?o.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})}(Ss);var nd=Ss.exports;const Wr=ii(nd);function id(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Hc={exports:{}};(function(o){(function(t){var e=function(w){var I,_=new Float64Array(16);if(w)for(I=0;I<w.length;I++)_[I]=w[I];return _},n=function(){throw new Error("no PRNG")},a=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var f=e(),u=e([1]),y=e([56129,1]),x=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),B=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),v=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),F=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),L=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function D(w,I,_,l){w[I]=_>>24&255,w[I+1]=_>>16&255,w[I+2]=_>>8&255,w[I+3]=_&255,w[I+4]=l>>24&255,w[I+5]=l>>16&255,w[I+6]=l>>8&255,w[I+7]=l&255}function U(w,I,_,l,A){var q,K=0;for(q=0;q<A;q++)K|=w[I+q]^_[l+q];return(1&K-1>>>8)-1}function z(w,I,_,l){return U(w,I,_,l,16)}function $(w,I,_,l){return U(w,I,_,l,32)}function X(w,I,_,l){for(var A=l[0]&255|(l[1]&255)<<8|(l[2]&255)<<16|(l[3]&255)<<24,q=_[0]&255|(_[1]&255)<<8|(_[2]&255)<<16|(_[3]&255)<<24,K=_[4]&255|(_[5]&255)<<8|(_[6]&255)<<16|(_[7]&255)<<24,J=_[8]&255|(_[9]&255)<<8|(_[10]&255)<<16|(_[11]&255)<<24,yt=_[12]&255|(_[13]&255)<<8|(_[14]&255)<<16|(_[15]&255)<<24,wt=l[4]&255|(l[5]&255)<<8|(l[6]&255)<<16|(l[7]&255)<<24,gt=I[0]&255|(I[1]&255)<<8|(I[2]&255)<<16|(I[3]&255)<<24,ye=I[4]&255|(I[5]&255)<<8|(I[6]&255)<<16|(I[7]&255)<<24,vt=I[8]&255|(I[9]&255)<<8|(I[10]&255)<<16|(I[11]&255)<<24,Kt=I[12]&255|(I[13]&255)<<8|(I[14]&255)<<16|(I[15]&255)<<24,qt=l[8]&255|(l[9]&255)<<8|(l[10]&255)<<16|(l[11]&255)<<24,Xt=_[16]&255|(_[17]&255)<<8|(_[18]&255)<<16|(_[19]&255)<<24,Jt=_[20]&255|(_[21]&255)<<8|(_[22]&255)<<16|(_[23]&255)<<24,Ht=_[24]&255|(_[25]&255)<<8|(_[26]&255)<<16|(_[27]&255)<<24,Gt=_[28]&255|(_[29]&255)<<8|(_[30]&255)<<16|(_[31]&255)<<24,Vt=l[12]&255|(l[13]&255)<<8|(l[14]&255)<<16|(l[15]&255)<<24,Rt=A,Ft=q,Bt=K,Tt=J,Mt=yt,Et=wt,Y=gt,Z=ye,ct=vt,nt=Kt,ot=qt,dt=Xt,Dt=Jt,te=Ht,ne=Gt,ee=Vt,O,he=0;he<20;he+=2)O=Rt+Dt|0,Mt^=O<<7|O>>>25,O=Mt+Rt|0,ct^=O<<9|O>>>23,O=ct+Mt|0,Dt^=O<<13|O>>>19,O=Dt+ct|0,Rt^=O<<18|O>>>14,O=Et+Ft|0,nt^=O<<7|O>>>25,O=nt+Et|0,te^=O<<9|O>>>23,O=te+nt|0,Ft^=O<<13|O>>>19,O=Ft+te|0,Et^=O<<18|O>>>14,O=ot+Y|0,ne^=O<<7|O>>>25,O=ne+ot|0,Bt^=O<<9|O>>>23,O=Bt+ne|0,Y^=O<<13|O>>>19,O=Y+Bt|0,ot^=O<<18|O>>>14,O=ee+dt|0,Tt^=O<<7|O>>>25,O=Tt+ee|0,Z^=O<<9|O>>>23,O=Z+Tt|0,dt^=O<<13|O>>>19,O=dt+Z|0,ee^=O<<18|O>>>14,O=Rt+Tt|0,Ft^=O<<7|O>>>25,O=Ft+Rt|0,Bt^=O<<9|O>>>23,O=Bt+Ft|0,Tt^=O<<13|O>>>19,O=Tt+Bt|0,Rt^=O<<18|O>>>14,O=Et+Mt|0,Y^=O<<7|O>>>25,O=Y+Et|0,Z^=O<<9|O>>>23,O=Z+Y|0,Mt^=O<<13|O>>>19,O=Mt+Z|0,Et^=O<<18|O>>>14,O=ot+nt|0,dt^=O<<7|O>>>25,O=dt+ot|0,ct^=O<<9|O>>>23,O=ct+dt|0,nt^=O<<13|O>>>19,O=nt+ct|0,ot^=O<<18|O>>>14,O=ee+ne|0,Dt^=O<<7|O>>>25,O=Dt+ee|0,te^=O<<9|O>>>23,O=te+Dt|0,ne^=O<<13|O>>>19,O=ne+te|0,ee^=O<<18|O>>>14;Rt=Rt+A|0,Ft=Ft+q|0,Bt=Bt+K|0,Tt=Tt+J|0,Mt=Mt+yt|0,Et=Et+wt|0,Y=Y+gt|0,Z=Z+ye|0,ct=ct+vt|0,nt=nt+Kt|0,ot=ot+qt|0,dt=dt+Xt|0,Dt=Dt+Jt|0,te=te+Ht|0,ne=ne+Gt|0,ee=ee+Vt|0,w[0]=Rt>>>0&255,w[1]=Rt>>>8&255,w[2]=Rt>>>16&255,w[3]=Rt>>>24&255,w[4]=Ft>>>0&255,w[5]=Ft>>>8&255,w[6]=Ft>>>16&255,w[7]=Ft>>>24&255,w[8]=Bt>>>0&255,w[9]=Bt>>>8&255,w[10]=Bt>>>16&255,w[11]=Bt>>>24&255,w[12]=Tt>>>0&255,w[13]=Tt>>>8&255,w[14]=Tt>>>16&255,w[15]=Tt>>>24&255,w[16]=Mt>>>0&255,w[17]=Mt>>>8&255,w[18]=Mt>>>16&255,w[19]=Mt>>>24&255,w[20]=Et>>>0&255,w[21]=Et>>>8&255,w[22]=Et>>>16&255,w[23]=Et>>>24&255,w[24]=Y>>>0&255,w[25]=Y>>>8&255,w[26]=Y>>>16&255,w[27]=Y>>>24&255,w[28]=Z>>>0&255,w[29]=Z>>>8&255,w[30]=Z>>>16&255,w[31]=Z>>>24&255,w[32]=ct>>>0&255,w[33]=ct>>>8&255,w[34]=ct>>>16&255,w[35]=ct>>>24&255,w[36]=nt>>>0&255,w[37]=nt>>>8&255,w[38]=nt>>>16&255,w[39]=nt>>>24&255,w[40]=ot>>>0&255,w[41]=ot>>>8&255,w[42]=ot>>>16&255,w[43]=ot>>>24&255,w[44]=dt>>>0&255,w[45]=dt>>>8&255,w[46]=dt>>>16&255,w[47]=dt>>>24&255,w[48]=Dt>>>0&255,w[49]=Dt>>>8&255,w[50]=Dt>>>16&255,w[51]=Dt>>>24&255,w[52]=te>>>0&255,w[53]=te>>>8&255,w[54]=te>>>16&255,w[55]=te>>>24&255,w[56]=ne>>>0&255,w[57]=ne>>>8&255,w[58]=ne>>>16&255,w[59]=ne>>>24&255,w[60]=ee>>>0&255,w[61]=ee>>>8&255,w[62]=ee>>>16&255,w[63]=ee>>>24&255}function V(w,I,_,l){for(var A=l[0]&255|(l[1]&255)<<8|(l[2]&255)<<16|(l[3]&255)<<24,q=_[0]&255|(_[1]&255)<<8|(_[2]&255)<<16|(_[3]&255)<<24,K=_[4]&255|(_[5]&255)<<8|(_[6]&255)<<16|(_[7]&255)<<24,J=_[8]&255|(_[9]&255)<<8|(_[10]&255)<<16|(_[11]&255)<<24,yt=_[12]&255|(_[13]&255)<<8|(_[14]&255)<<16|(_[15]&255)<<24,wt=l[4]&255|(l[5]&255)<<8|(l[6]&255)<<16|(l[7]&255)<<24,gt=I[0]&255|(I[1]&255)<<8|(I[2]&255)<<16|(I[3]&255)<<24,ye=I[4]&255|(I[5]&255)<<8|(I[6]&255)<<16|(I[7]&255)<<24,vt=I[8]&255|(I[9]&255)<<8|(I[10]&255)<<16|(I[11]&255)<<24,Kt=I[12]&255|(I[13]&255)<<8|(I[14]&255)<<16|(I[15]&255)<<24,qt=l[8]&255|(l[9]&255)<<8|(l[10]&255)<<16|(l[11]&255)<<24,Xt=_[16]&255|(_[17]&255)<<8|(_[18]&255)<<16|(_[19]&255)<<24,Jt=_[20]&255|(_[21]&255)<<8|(_[22]&255)<<16|(_[23]&255)<<24,Ht=_[24]&255|(_[25]&255)<<8|(_[26]&255)<<16|(_[27]&255)<<24,Gt=_[28]&255|(_[29]&255)<<8|(_[30]&255)<<16|(_[31]&255)<<24,Vt=l[12]&255|(l[13]&255)<<8|(l[14]&255)<<16|(l[15]&255)<<24,Rt=A,Ft=q,Bt=K,Tt=J,Mt=yt,Et=wt,Y=gt,Z=ye,ct=vt,nt=Kt,ot=qt,dt=Xt,Dt=Jt,te=Ht,ne=Gt,ee=Vt,O,he=0;he<20;he+=2)O=Rt+Dt|0,Mt^=O<<7|O>>>25,O=Mt+Rt|0,ct^=O<<9|O>>>23,O=ct+Mt|0,Dt^=O<<13|O>>>19,O=Dt+ct|0,Rt^=O<<18|O>>>14,O=Et+Ft|0,nt^=O<<7|O>>>25,O=nt+Et|0,te^=O<<9|O>>>23,O=te+nt|0,Ft^=O<<13|O>>>19,O=Ft+te|0,Et^=O<<18|O>>>14,O=ot+Y|0,ne^=O<<7|O>>>25,O=ne+ot|0,Bt^=O<<9|O>>>23,O=Bt+ne|0,Y^=O<<13|O>>>19,O=Y+Bt|0,ot^=O<<18|O>>>14,O=ee+dt|0,Tt^=O<<7|O>>>25,O=Tt+ee|0,Z^=O<<9|O>>>23,O=Z+Tt|0,dt^=O<<13|O>>>19,O=dt+Z|0,ee^=O<<18|O>>>14,O=Rt+Tt|0,Ft^=O<<7|O>>>25,O=Ft+Rt|0,Bt^=O<<9|O>>>23,O=Bt+Ft|0,Tt^=O<<13|O>>>19,O=Tt+Bt|0,Rt^=O<<18|O>>>14,O=Et+Mt|0,Y^=O<<7|O>>>25,O=Y+Et|0,Z^=O<<9|O>>>23,O=Z+Y|0,Mt^=O<<13|O>>>19,O=Mt+Z|0,Et^=O<<18|O>>>14,O=ot+nt|0,dt^=O<<7|O>>>25,O=dt+ot|0,ct^=O<<9|O>>>23,O=ct+dt|0,nt^=O<<13|O>>>19,O=nt+ct|0,ot^=O<<18|O>>>14,O=ee+ne|0,Dt^=O<<7|O>>>25,O=Dt+ee|0,te^=O<<9|O>>>23,O=te+Dt|0,ne^=O<<13|O>>>19,O=ne+te|0,ee^=O<<18|O>>>14;w[0]=Rt>>>0&255,w[1]=Rt>>>8&255,w[2]=Rt>>>16&255,w[3]=Rt>>>24&255,w[4]=Et>>>0&255,w[5]=Et>>>8&255,w[6]=Et>>>16&255,w[7]=Et>>>24&255,w[8]=ot>>>0&255,w[9]=ot>>>8&255,w[10]=ot>>>16&255,w[11]=ot>>>24&255,w[12]=ee>>>0&255,w[13]=ee>>>8&255,w[14]=ee>>>16&255,w[15]=ee>>>24&255,w[16]=Y>>>0&255,w[17]=Y>>>8&255,w[18]=Y>>>16&255,w[19]=Y>>>24&255,w[20]=Z>>>0&255,w[21]=Z>>>8&255,w[22]=Z>>>16&255,w[23]=Z>>>24&255,w[24]=ct>>>0&255,w[25]=ct>>>8&255,w[26]=ct>>>16&255,w[27]=ct>>>24&255,w[28]=nt>>>0&255,w[29]=nt>>>8&255,w[30]=nt>>>16&255,w[31]=nt>>>24&255}function it(w,I,_,l){X(w,I,_,l)}function G(w,I,_,l){V(w,I,_,l)}var W=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Q(w,I,_,l,A,q,K){var J=new Uint8Array(16),yt=new Uint8Array(64),wt,gt;for(gt=0;gt<16;gt++)J[gt]=0;for(gt=0;gt<8;gt++)J[gt]=q[gt];for(;A>=64;){for(it(yt,J,K,W),gt=0;gt<64;gt++)w[I+gt]=_[l+gt]^yt[gt];for(wt=1,gt=8;gt<16;gt++)wt=wt+(J[gt]&255)|0,J[gt]=wt&255,wt>>>=8;A-=64,I+=64,l+=64}if(A>0)for(it(yt,J,K,W),gt=0;gt<A;gt++)w[I+gt]=_[l+gt]^yt[gt];return 0}function rt(w,I,_,l,A){var q=new Uint8Array(16),K=new Uint8Array(64),J,yt;for(yt=0;yt<16;yt++)q[yt]=0;for(yt=0;yt<8;yt++)q[yt]=l[yt];for(;_>=64;){for(it(K,q,A,W),yt=0;yt<64;yt++)w[I+yt]=K[yt];for(J=1,yt=8;yt<16;yt++)J=J+(q[yt]&255)|0,q[yt]=J&255,J>>>=8;_-=64,I+=64}if(_>0)for(it(K,q,A,W),yt=0;yt<_;yt++)w[I+yt]=K[yt];return 0}function ae(w,I,_,l,A){var q=new Uint8Array(32);G(q,l,A,W);for(var K=new Uint8Array(8),J=0;J<8;J++)K[J]=l[J+16];return rt(w,I,_,K,q)}function jt(w,I,_,l,A,q,K){var J=new Uint8Array(32);G(J,q,K,W);for(var yt=new Uint8Array(8),wt=0;wt<8;wt++)yt[wt]=q[wt+16];return Q(w,I,_,l,A,yt,J)}var _t=function(w){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var I,_,l,A,q,K,J,yt;I=w[0]&255|(w[1]&255)<<8,this.r[0]=I&8191,_=w[2]&255|(w[3]&255)<<8,this.r[1]=(I>>>13|_<<3)&8191,l=w[4]&255|(w[5]&255)<<8,this.r[2]=(_>>>10|l<<6)&7939,A=w[6]&255|(w[7]&255)<<8,this.r[3]=(l>>>7|A<<9)&8191,q=w[8]&255|(w[9]&255)<<8,this.r[4]=(A>>>4|q<<12)&255,this.r[5]=q>>>1&8190,K=w[10]&255|(w[11]&255)<<8,this.r[6]=(q>>>14|K<<2)&8191,J=w[12]&255|(w[13]&255)<<8,this.r[7]=(K>>>11|J<<5)&8065,yt=w[14]&255|(w[15]&255)<<8,this.r[8]=(J>>>8|yt<<8)&8191,this.r[9]=yt>>>5&127,this.pad[0]=w[16]&255|(w[17]&255)<<8,this.pad[1]=w[18]&255|(w[19]&255)<<8,this.pad[2]=w[20]&255|(w[21]&255)<<8,this.pad[3]=w[22]&255|(w[23]&255)<<8,this.pad[4]=w[24]&255|(w[25]&255)<<8,this.pad[5]=w[26]&255|(w[27]&255)<<8,this.pad[6]=w[28]&255|(w[29]&255)<<8,this.pad[7]=w[30]&255|(w[31]&255)<<8};_t.prototype.blocks=function(w,I,_){for(var l=this.fin?0:2048,A,q,K,J,yt,wt,gt,ye,vt,Kt,qt,Xt,Jt,Ht,Gt,Vt,Rt,Ft,Bt,Tt=this.h[0],Mt=this.h[1],Et=this.h[2],Y=this.h[3],Z=this.h[4],ct=this.h[5],nt=this.h[6],ot=this.h[7],dt=this.h[8],Dt=this.h[9],te=this.r[0],ne=this.r[1],ee=this.r[2],O=this.r[3],he=this.r[4],Ae=this.r[5],Re=this.r[6],ue=this.r[7],Ie=this.r[8],Be=this.r[9];_>=16;)A=w[I+0]&255|(w[I+1]&255)<<8,Tt+=A&8191,q=w[I+2]&255|(w[I+3]&255)<<8,Mt+=(A>>>13|q<<3)&8191,K=w[I+4]&255|(w[I+5]&255)<<8,Et+=(q>>>10|K<<6)&8191,J=w[I+6]&255|(w[I+7]&255)<<8,Y+=(K>>>7|J<<9)&8191,yt=w[I+8]&255|(w[I+9]&255)<<8,Z+=(J>>>4|yt<<12)&8191,ct+=yt>>>1&8191,wt=w[I+10]&255|(w[I+11]&255)<<8,nt+=(yt>>>14|wt<<2)&8191,gt=w[I+12]&255|(w[I+13]&255)<<8,ot+=(wt>>>11|gt<<5)&8191,ye=w[I+14]&255|(w[I+15]&255)<<8,dt+=(gt>>>8|ye<<8)&8191,Dt+=ye>>>5|l,vt=0,Kt=vt,Kt+=Tt*te,Kt+=Mt*(5*Be),Kt+=Et*(5*Ie),Kt+=Y*(5*ue),Kt+=Z*(5*Re),vt=Kt>>>13,Kt&=8191,Kt+=ct*(5*Ae),Kt+=nt*(5*he),Kt+=ot*(5*O),Kt+=dt*(5*ee),Kt+=Dt*(5*ne),vt+=Kt>>>13,Kt&=8191,qt=vt,qt+=Tt*ne,qt+=Mt*te,qt+=Et*(5*Be),qt+=Y*(5*Ie),qt+=Z*(5*ue),vt=qt>>>13,qt&=8191,qt+=ct*(5*Re),qt+=nt*(5*Ae),qt+=ot*(5*he),qt+=dt*(5*O),qt+=Dt*(5*ee),vt+=qt>>>13,qt&=8191,Xt=vt,Xt+=Tt*ee,Xt+=Mt*ne,Xt+=Et*te,Xt+=Y*(5*Be),Xt+=Z*(5*Ie),vt=Xt>>>13,Xt&=8191,Xt+=ct*(5*ue),Xt+=nt*(5*Re),Xt+=ot*(5*Ae),Xt+=dt*(5*he),Xt+=Dt*(5*O),vt+=Xt>>>13,Xt&=8191,Jt=vt,Jt+=Tt*O,Jt+=Mt*ee,Jt+=Et*ne,Jt+=Y*te,Jt+=Z*(5*Be),vt=Jt>>>13,Jt&=8191,Jt+=ct*(5*Ie),Jt+=nt*(5*ue),Jt+=ot*(5*Re),Jt+=dt*(5*Ae),Jt+=Dt*(5*he),vt+=Jt>>>13,Jt&=8191,Ht=vt,Ht+=Tt*he,Ht+=Mt*O,Ht+=Et*ee,Ht+=Y*ne,Ht+=Z*te,vt=Ht>>>13,Ht&=8191,Ht+=ct*(5*Be),Ht+=nt*(5*Ie),Ht+=ot*(5*ue),Ht+=dt*(5*Re),Ht+=Dt*(5*Ae),vt+=Ht>>>13,Ht&=8191,Gt=vt,Gt+=Tt*Ae,Gt+=Mt*he,Gt+=Et*O,Gt+=Y*ee,Gt+=Z*ne,vt=Gt>>>13,Gt&=8191,Gt+=ct*te,Gt+=nt*(5*Be),Gt+=ot*(5*Ie),Gt+=dt*(5*ue),Gt+=Dt*(5*Re),vt+=Gt>>>13,Gt&=8191,Vt=vt,Vt+=Tt*Re,Vt+=Mt*Ae,Vt+=Et*he,Vt+=Y*O,Vt+=Z*ee,vt=Vt>>>13,Vt&=8191,Vt+=ct*ne,Vt+=nt*te,Vt+=ot*(5*Be),Vt+=dt*(5*Ie),Vt+=Dt*(5*ue),vt+=Vt>>>13,Vt&=8191,Rt=vt,Rt+=Tt*ue,Rt+=Mt*Re,Rt+=Et*Ae,Rt+=Y*he,Rt+=Z*O,vt=Rt>>>13,Rt&=8191,Rt+=ct*ee,Rt+=nt*ne,Rt+=ot*te,Rt+=dt*(5*Be),Rt+=Dt*(5*Ie),vt+=Rt>>>13,Rt&=8191,Ft=vt,Ft+=Tt*Ie,Ft+=Mt*ue,Ft+=Et*Re,Ft+=Y*Ae,Ft+=Z*he,vt=Ft>>>13,Ft&=8191,Ft+=ct*O,Ft+=nt*ee,Ft+=ot*ne,Ft+=dt*te,Ft+=Dt*(5*Be),vt+=Ft>>>13,Ft&=8191,Bt=vt,Bt+=Tt*Be,Bt+=Mt*Ie,Bt+=Et*ue,Bt+=Y*Re,Bt+=Z*Ae,vt=Bt>>>13,Bt&=8191,Bt+=ct*he,Bt+=nt*O,Bt+=ot*ee,Bt+=dt*ne,Bt+=Dt*te,vt+=Bt>>>13,Bt&=8191,vt=(vt<<2)+vt|0,vt=vt+Kt|0,Kt=vt&8191,vt=vt>>>13,qt+=vt,Tt=Kt,Mt=qt,Et=Xt,Y=Jt,Z=Ht,ct=Gt,nt=Vt,ot=Rt,dt=Ft,Dt=Bt,I+=16,_-=16;this.h[0]=Tt,this.h[1]=Mt,this.h[2]=Et,this.h[3]=Y,this.h[4]=Z,this.h[5]=ct,this.h[6]=nt,this.h[7]=ot,this.h[8]=dt,this.h[9]=Dt},_t.prototype.finish=function(w,I){var _=new Uint16Array(10),l,A,q,K;if(this.leftover){for(K=this.leftover,this.buffer[K++]=1;K<16;K++)this.buffer[K]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(l=this.h[1]>>>13,this.h[1]&=8191,K=2;K<10;K++)this.h[K]+=l,l=this.h[K]>>>13,this.h[K]&=8191;for(this.h[0]+=l*5,l=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=l,l=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=l,_[0]=this.h[0]+5,l=_[0]>>>13,_[0]&=8191,K=1;K<10;K++)_[K]=this.h[K]+l,l=_[K]>>>13,_[K]&=8191;for(_[9]-=8192,A=(l^1)-1,K=0;K<10;K++)_[K]&=A;for(A=~A,K=0;K<10;K++)this.h[K]=this.h[K]&A|_[K];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,q=this.h[0]+this.pad[0],this.h[0]=q&65535,K=1;K<8;K++)q=(this.h[K]+this.pad[K]|0)+(q>>>16)|0,this.h[K]=q&65535;w[I+0]=this.h[0]>>>0&255,w[I+1]=this.h[0]>>>8&255,w[I+2]=this.h[1]>>>0&255,w[I+3]=this.h[1]>>>8&255,w[I+4]=this.h[2]>>>0&255,w[I+5]=this.h[2]>>>8&255,w[I+6]=this.h[3]>>>0&255,w[I+7]=this.h[3]>>>8&255,w[I+8]=this.h[4]>>>0&255,w[I+9]=this.h[4]>>>8&255,w[I+10]=this.h[5]>>>0&255,w[I+11]=this.h[5]>>>8&255,w[I+12]=this.h[6]>>>0&255,w[I+13]=this.h[6]>>>8&255,w[I+14]=this.h[7]>>>0&255,w[I+15]=this.h[7]>>>8&255},_t.prototype.update=function(w,I,_){var l,A;if(this.leftover){for(A=16-this.leftover,A>_&&(A=_),l=0;l<A;l++)this.buffer[this.leftover+l]=w[I+l];if(_-=A,I+=A,this.leftover+=A,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(_>=16&&(A=_-_%16,this.blocks(w,I,A),I+=A,_-=A),_){for(l=0;l<_;l++)this.buffer[this.leftover+l]=w[I+l];this.leftover+=_}};function re(w,I,_,l,A,q){var K=new _t(q);return K.update(_,l,A),K.finish(w,I),0}function P(w,I,_,l,A,q){var K=new Uint8Array(16);return re(K,0,_,l,A,q),z(w,I,K,0)}function d(w,I,_,l,A){var q;if(_<32)return-1;for(jt(w,0,I,0,_,l,A),re(w,16,w,32,_-32,w),q=0;q<16;q++)w[q]=0;return 0}function m(w,I,_,l,A){var q,K=new Uint8Array(32);if(_<32||(ae(K,0,32,l,A),P(I,16,I,32,_-32,K)!==0))return-1;for(jt(w,0,I,0,_,l,A),q=0;q<32;q++)w[q]=0;return 0}function E(w,I){var _;for(_=0;_<16;_++)w[_]=I[_]|0}function C(w){var I,_,l=1;for(I=0;I<16;I++)_=w[I]+l+65535,l=Math.floor(_/65536),w[I]=_-l*65536;w[0]+=l-1+37*(l-1)}function R(w,I,_){for(var l,A=~(_-1),q=0;q<16;q++)l=A&(w[q]^I[q]),w[q]^=l,I[q]^=l}function T(w,I){var _,l,A,q=e(),K=e();for(_=0;_<16;_++)K[_]=I[_];for(C(K),C(K),C(K),l=0;l<2;l++){for(q[0]=K[0]-65517,_=1;_<15;_++)q[_]=K[_]-65535-(q[_-1]>>16&1),q[_-1]&=65535;q[15]=K[15]-32767-(q[14]>>16&1),A=q[15]>>16&1,q[14]&=65535,R(K,q,1-A)}for(_=0;_<16;_++)w[2*_]=K[_]&255,w[2*_+1]=K[_]>>8}function N(w,I){var _=new Uint8Array(32),l=new Uint8Array(32);return T(_,w),T(l,I),$(_,0,l,0)}function k(w){var I=new Uint8Array(32);return T(I,w),I[0]&1}function p(w,I){var _;for(_=0;_<16;_++)w[_]=I[2*_]+(I[2*_+1]<<8);w[15]&=32767}function M(w,I,_){for(var l=0;l<16;l++)w[l]=I[l]+_[l]}function at(w,I,_){for(var l=0;l<16;l++)w[l]=I[l]-_[l]}function tt(w,I,_){var l,A,q=0,K=0,J=0,yt=0,wt=0,gt=0,ye=0,vt=0,Kt=0,qt=0,Xt=0,Jt=0,Ht=0,Gt=0,Vt=0,Rt=0,Ft=0,Bt=0,Tt=0,Mt=0,Et=0,Y=0,Z=0,ct=0,nt=0,ot=0,dt=0,Dt=0,te=0,ne=0,ee=0,O=_[0],he=_[1],Ae=_[2],Re=_[3],ue=_[4],Ie=_[5],Be=_[6],nr=_[7],Fe=_[8],tr=_[9],er=_[10],rr=_[11],sr=_[12],Er=_[13],kr=_[14],Sr=_[15];l=I[0],q+=l*O,K+=l*he,J+=l*Ae,yt+=l*Re,wt+=l*ue,gt+=l*Ie,ye+=l*Be,vt+=l*nr,Kt+=l*Fe,qt+=l*tr,Xt+=l*er,Jt+=l*rr,Ht+=l*sr,Gt+=l*Er,Vt+=l*kr,Rt+=l*Sr,l=I[1],K+=l*O,J+=l*he,yt+=l*Ae,wt+=l*Re,gt+=l*ue,ye+=l*Ie,vt+=l*Be,Kt+=l*nr,qt+=l*Fe,Xt+=l*tr,Jt+=l*er,Ht+=l*rr,Gt+=l*sr,Vt+=l*Er,Rt+=l*kr,Ft+=l*Sr,l=I[2],J+=l*O,yt+=l*he,wt+=l*Ae,gt+=l*Re,ye+=l*ue,vt+=l*Ie,Kt+=l*Be,qt+=l*nr,Xt+=l*Fe,Jt+=l*tr,Ht+=l*er,Gt+=l*rr,Vt+=l*sr,Rt+=l*Er,Ft+=l*kr,Bt+=l*Sr,l=I[3],yt+=l*O,wt+=l*he,gt+=l*Ae,ye+=l*Re,vt+=l*ue,Kt+=l*Ie,qt+=l*Be,Xt+=l*nr,Jt+=l*Fe,Ht+=l*tr,Gt+=l*er,Vt+=l*rr,Rt+=l*sr,Ft+=l*Er,Bt+=l*kr,Tt+=l*Sr,l=I[4],wt+=l*O,gt+=l*he,ye+=l*Ae,vt+=l*Re,Kt+=l*ue,qt+=l*Ie,Xt+=l*Be,Jt+=l*nr,Ht+=l*Fe,Gt+=l*tr,Vt+=l*er,Rt+=l*rr,Ft+=l*sr,Bt+=l*Er,Tt+=l*kr,Mt+=l*Sr,l=I[5],gt+=l*O,ye+=l*he,vt+=l*Ae,Kt+=l*Re,qt+=l*ue,Xt+=l*Ie,Jt+=l*Be,Ht+=l*nr,Gt+=l*Fe,Vt+=l*tr,Rt+=l*er,Ft+=l*rr,Bt+=l*sr,Tt+=l*Er,Mt+=l*kr,Et+=l*Sr,l=I[6],ye+=l*O,vt+=l*he,Kt+=l*Ae,qt+=l*Re,Xt+=l*ue,Jt+=l*Ie,Ht+=l*Be,Gt+=l*nr,Vt+=l*Fe,Rt+=l*tr,Ft+=l*er,Bt+=l*rr,Tt+=l*sr,Mt+=l*Er,Et+=l*kr,Y+=l*Sr,l=I[7],vt+=l*O,Kt+=l*he,qt+=l*Ae,Xt+=l*Re,Jt+=l*ue,Ht+=l*Ie,Gt+=l*Be,Vt+=l*nr,Rt+=l*Fe,Ft+=l*tr,Bt+=l*er,Tt+=l*rr,Mt+=l*sr,Et+=l*Er,Y+=l*kr,Z+=l*Sr,l=I[8],Kt+=l*O,qt+=l*he,Xt+=l*Ae,Jt+=l*Re,Ht+=l*ue,Gt+=l*Ie,Vt+=l*Be,Rt+=l*nr,Ft+=l*Fe,Bt+=l*tr,Tt+=l*er,Mt+=l*rr,Et+=l*sr,Y+=l*Er,Z+=l*kr,ct+=l*Sr,l=I[9],qt+=l*O,Xt+=l*he,Jt+=l*Ae,Ht+=l*Re,Gt+=l*ue,Vt+=l*Ie,Rt+=l*Be,Ft+=l*nr,Bt+=l*Fe,Tt+=l*tr,Mt+=l*er,Et+=l*rr,Y+=l*sr,Z+=l*Er,ct+=l*kr,nt+=l*Sr,l=I[10],Xt+=l*O,Jt+=l*he,Ht+=l*Ae,Gt+=l*Re,Vt+=l*ue,Rt+=l*Ie,Ft+=l*Be,Bt+=l*nr,Tt+=l*Fe,Mt+=l*tr,Et+=l*er,Y+=l*rr,Z+=l*sr,ct+=l*Er,nt+=l*kr,ot+=l*Sr,l=I[11],Jt+=l*O,Ht+=l*he,Gt+=l*Ae,Vt+=l*Re,Rt+=l*ue,Ft+=l*Ie,Bt+=l*Be,Tt+=l*nr,Mt+=l*Fe,Et+=l*tr,Y+=l*er,Z+=l*rr,ct+=l*sr,nt+=l*Er,ot+=l*kr,dt+=l*Sr,l=I[12],Ht+=l*O,Gt+=l*he,Vt+=l*Ae,Rt+=l*Re,Ft+=l*ue,Bt+=l*Ie,Tt+=l*Be,Mt+=l*nr,Et+=l*Fe,Y+=l*tr,Z+=l*er,ct+=l*rr,nt+=l*sr,ot+=l*Er,dt+=l*kr,Dt+=l*Sr,l=I[13],Gt+=l*O,Vt+=l*he,Rt+=l*Ae,Ft+=l*Re,Bt+=l*ue,Tt+=l*Ie,Mt+=l*Be,Et+=l*nr,Y+=l*Fe,Z+=l*tr,ct+=l*er,nt+=l*rr,ot+=l*sr,dt+=l*Er,Dt+=l*kr,te+=l*Sr,l=I[14],Vt+=l*O,Rt+=l*he,Ft+=l*Ae,Bt+=l*Re,Tt+=l*ue,Mt+=l*Ie,Et+=l*Be,Y+=l*nr,Z+=l*Fe,ct+=l*tr,nt+=l*er,ot+=l*rr,dt+=l*sr,Dt+=l*Er,te+=l*kr,ne+=l*Sr,l=I[15],Rt+=l*O,Ft+=l*he,Bt+=l*Ae,Tt+=l*Re,Mt+=l*ue,Et+=l*Ie,Y+=l*Be,Z+=l*nr,ct+=l*Fe,nt+=l*tr,ot+=l*er,dt+=l*rr,Dt+=l*sr,te+=l*Er,ne+=l*kr,ee+=l*Sr,q+=38*Ft,K+=38*Bt,J+=38*Tt,yt+=38*Mt,wt+=38*Et,gt+=38*Y,ye+=38*Z,vt+=38*ct,Kt+=38*nt,qt+=38*ot,Xt+=38*dt,Jt+=38*Dt,Ht+=38*te,Gt+=38*ne,Vt+=38*ee,A=1,l=q+A+65535,A=Math.floor(l/65536),q=l-A*65536,l=K+A+65535,A=Math.floor(l/65536),K=l-A*65536,l=J+A+65535,A=Math.floor(l/65536),J=l-A*65536,l=yt+A+65535,A=Math.floor(l/65536),yt=l-A*65536,l=wt+A+65535,A=Math.floor(l/65536),wt=l-A*65536,l=gt+A+65535,A=Math.floor(l/65536),gt=l-A*65536,l=ye+A+65535,A=Math.floor(l/65536),ye=l-A*65536,l=vt+A+65535,A=Math.floor(l/65536),vt=l-A*65536,l=Kt+A+65535,A=Math.floor(l/65536),Kt=l-A*65536,l=qt+A+65535,A=Math.floor(l/65536),qt=l-A*65536,l=Xt+A+65535,A=Math.floor(l/65536),Xt=l-A*65536,l=Jt+A+65535,A=Math.floor(l/65536),Jt=l-A*65536,l=Ht+A+65535,A=Math.floor(l/65536),Ht=l-A*65536,l=Gt+A+65535,A=Math.floor(l/65536),Gt=l-A*65536,l=Vt+A+65535,A=Math.floor(l/65536),Vt=l-A*65536,l=Rt+A+65535,A=Math.floor(l/65536),Rt=l-A*65536,q+=A-1+37*(A-1),A=1,l=q+A+65535,A=Math.floor(l/65536),q=l-A*65536,l=K+A+65535,A=Math.floor(l/65536),K=l-A*65536,l=J+A+65535,A=Math.floor(l/65536),J=l-A*65536,l=yt+A+65535,A=Math.floor(l/65536),yt=l-A*65536,l=wt+A+65535,A=Math.floor(l/65536),wt=l-A*65536,l=gt+A+65535,A=Math.floor(l/65536),gt=l-A*65536,l=ye+A+65535,A=Math.floor(l/65536),ye=l-A*65536,l=vt+A+65535,A=Math.floor(l/65536),vt=l-A*65536,l=Kt+A+65535,A=Math.floor(l/65536),Kt=l-A*65536,l=qt+A+65535,A=Math.floor(l/65536),qt=l-A*65536,l=Xt+A+65535,A=Math.floor(l/65536),Xt=l-A*65536,l=Jt+A+65535,A=Math.floor(l/65536),Jt=l-A*65536,l=Ht+A+65535,A=Math.floor(l/65536),Ht=l-A*65536,l=Gt+A+65535,A=Math.floor(l/65536),Gt=l-A*65536,l=Vt+A+65535,A=Math.floor(l/65536),Vt=l-A*65536,l=Rt+A+65535,A=Math.floor(l/65536),Rt=l-A*65536,q+=A-1+37*(A-1),w[0]=q,w[1]=K,w[2]=J,w[3]=yt,w[4]=wt,w[5]=gt,w[6]=ye,w[7]=vt,w[8]=Kt,w[9]=qt,w[10]=Xt,w[11]=Jt,w[12]=Ht,w[13]=Gt,w[14]=Vt,w[15]=Rt}function ft(w,I){tt(w,I,I)}function Lt(w,I){var _=e(),l;for(l=0;l<16;l++)_[l]=I[l];for(l=253;l>=0;l--)ft(_,_),l!==2&&l!==4&&tt(_,_,I);for(l=0;l<16;l++)w[l]=_[l]}function At(w,I){var _=e(),l;for(l=0;l<16;l++)_[l]=I[l];for(l=250;l>=0;l--)ft(_,_),l!==1&&tt(_,_,I);for(l=0;l<16;l++)w[l]=_[l]}function Ut(w,I,_){var l=new Uint8Array(32),A=new Float64Array(80),q,K,J=e(),yt=e(),wt=e(),gt=e(),ye=e(),vt=e();for(K=0;K<31;K++)l[K]=I[K];for(l[31]=I[31]&127|64,l[0]&=248,p(A,_),K=0;K<16;K++)yt[K]=A[K],gt[K]=J[K]=wt[K]=0;for(J[0]=gt[0]=1,K=254;K>=0;--K)q=l[K>>>3]>>>(K&7)&1,R(J,yt,q),R(wt,gt,q),M(ye,J,wt),at(J,J,wt),M(wt,yt,gt),at(yt,yt,gt),ft(gt,ye),ft(vt,J),tt(J,wt,J),tt(wt,yt,ye),M(ye,J,wt),at(J,J,wt),ft(yt,J),at(wt,gt,vt),tt(J,wt,y),M(J,J,gt),tt(wt,wt,J),tt(J,gt,vt),tt(gt,yt,A),ft(yt,ye),R(J,yt,q),R(wt,gt,q);for(K=0;K<16;K++)A[K+16]=J[K],A[K+32]=wt[K],A[K+48]=yt[K],A[K+64]=gt[K];var Kt=A.subarray(32),qt=A.subarray(16);return Lt(Kt,Kt),tt(qt,qt,Kt),T(w,qt),0}function Ee(w,I){return Ut(w,I,s)}function Zt(w,I){return n(I,32),Ee(w,I)}function Wt(w,I,_){var l=new Uint8Array(32);return Ut(l,_,I),G(w,a,l,W)}var Yt=d,zt=m;function ge(w,I,_,l,A,q){var K=new Uint8Array(32);return Wt(K,A,q),Yt(w,I,_,l,K)}function xr(w,I,_,l,A,q){var K=new Uint8Array(32);return Wt(K,A,q),zt(w,I,_,l,K)}var de=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Ce(w,I,_,l){for(var A=new Int32Array(16),q=new Int32Array(16),K,J,yt,wt,gt,ye,vt,Kt,qt,Xt,Jt,Ht,Gt,Vt,Rt,Ft,Bt,Tt,Mt,Et,Y,Z,ct,nt,ot,dt,Dt=w[0],te=w[1],ne=w[2],ee=w[3],O=w[4],he=w[5],Ae=w[6],Re=w[7],ue=I[0],Ie=I[1],Be=I[2],nr=I[3],Fe=I[4],tr=I[5],er=I[6],rr=I[7],sr=0;l>=128;){for(Mt=0;Mt<16;Mt++)Et=8*Mt+sr,A[Mt]=_[Et+0]<<24|_[Et+1]<<16|_[Et+2]<<8|_[Et+3],q[Mt]=_[Et+4]<<24|_[Et+5]<<16|_[Et+6]<<8|_[Et+7];for(Mt=0;Mt<80;Mt++)if(K=Dt,J=te,yt=ne,wt=ee,gt=O,ye=he,vt=Ae,Kt=Re,qt=ue,Xt=Ie,Jt=Be,Ht=nr,Gt=Fe,Vt=tr,Rt=er,Ft=rr,Y=Re,Z=rr,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=(O>>>14|Fe<<18)^(O>>>18|Fe<<14)^(Fe>>>9|O<<23),Z=(Fe>>>14|O<<18)^(Fe>>>18|O<<14)^(O>>>9|Fe<<23),ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,Y=O&he^~O&Ae,Z=Fe&tr^~Fe&er,ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,Y=de[Mt*2],Z=de[Mt*2+1],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,Y=A[Mt%16],Z=q[Mt%16],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,Bt=ot&65535|dt<<16,Tt=ct&65535|nt<<16,Y=Bt,Z=Tt,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=(Dt>>>28|ue<<4)^(ue>>>2|Dt<<30)^(ue>>>7|Dt<<25),Z=(ue>>>28|Dt<<4)^(Dt>>>2|ue<<30)^(Dt>>>7|ue<<25),ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,Y=Dt&te^Dt&ne^te&ne,Z=ue&Ie^ue&Be^Ie&Be,ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,Kt=ot&65535|dt<<16,Ft=ct&65535|nt<<16,Y=wt,Z=Ht,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=Bt,Z=Tt,ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,wt=ot&65535|dt<<16,Ht=ct&65535|nt<<16,te=K,ne=J,ee=yt,O=wt,he=gt,Ae=ye,Re=vt,Dt=Kt,Ie=qt,Be=Xt,nr=Jt,Fe=Ht,tr=Gt,er=Vt,rr=Rt,ue=Ft,Mt%16===15)for(Et=0;Et<16;Et++)Y=A[Et],Z=q[Et],ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=A[(Et+9)%16],Z=q[(Et+9)%16],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,Bt=A[(Et+1)%16],Tt=q[(Et+1)%16],Y=(Bt>>>1|Tt<<31)^(Bt>>>8|Tt<<24)^Bt>>>7,Z=(Tt>>>1|Bt<<31)^(Tt>>>8|Bt<<24)^(Tt>>>7|Bt<<25),ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,Bt=A[(Et+14)%16],Tt=q[(Et+14)%16],Y=(Bt>>>19|Tt<<13)^(Tt>>>29|Bt<<3)^Bt>>>6,Z=(Tt>>>19|Bt<<13)^(Bt>>>29|Tt<<3)^(Tt>>>6|Bt<<26),ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,A[Et]=ot&65535|dt<<16,q[Et]=ct&65535|nt<<16;Y=Dt,Z=ue,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=w[0],Z=I[0],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,w[0]=Dt=ot&65535|dt<<16,I[0]=ue=ct&65535|nt<<16,Y=te,Z=Ie,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=w[1],Z=I[1],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,w[1]=te=ot&65535|dt<<16,I[1]=Ie=ct&65535|nt<<16,Y=ne,Z=Be,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=w[2],Z=I[2],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,w[2]=ne=ot&65535|dt<<16,I[2]=Be=ct&65535|nt<<16,Y=ee,Z=nr,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=w[3],Z=I[3],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,w[3]=ee=ot&65535|dt<<16,I[3]=nr=ct&65535|nt<<16,Y=O,Z=Fe,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=w[4],Z=I[4],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,w[4]=O=ot&65535|dt<<16,I[4]=Fe=ct&65535|nt<<16,Y=he,Z=tr,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=w[5],Z=I[5],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,w[5]=he=ot&65535|dt<<16,I[5]=tr=ct&65535|nt<<16,Y=Ae,Z=er,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=w[6],Z=I[6],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,w[6]=Ae=ot&65535|dt<<16,I[6]=er=ct&65535|nt<<16,Y=Re,Z=rr,ct=Z&65535,nt=Z>>>16,ot=Y&65535,dt=Y>>>16,Y=w[7],Z=I[7],ct+=Z&65535,nt+=Z>>>16,ot+=Y&65535,dt+=Y>>>16,nt+=ct>>>16,ot+=nt>>>16,dt+=ot>>>16,w[7]=Re=ot&65535|dt<<16,I[7]=rr=ct&65535|nt<<16,sr+=128,l-=128}return l}function hr(w,I,_){var l=new Int32Array(8),A=new Int32Array(8),q=new Uint8Array(256),K,J=_;for(l[0]=1779033703,l[1]=3144134277,l[2]=1013904242,l[3]=2773480762,l[4]=1359893119,l[5]=2600822924,l[6]=528734635,l[7]=1541459225,A[0]=4089235720,A[1]=2227873595,A[2]=4271175723,A[3]=1595750129,A[4]=2917565137,A[5]=725511199,A[6]=4215389547,A[7]=327033209,Ce(l,A,I,_),_%=128,K=0;K<_;K++)q[K]=I[J-_+K];for(q[_]=128,_=256-128*(_<112?1:0),q[_-9]=0,D(q,_-8,J/536870912|0,J<<3),Ce(l,A,q,_),K=0;K<8;K++)D(w,8*K,l[K],A[K]);return 0}function me(w,I){var _=e(),l=e(),A=e(),q=e(),K=e(),J=e(),yt=e(),wt=e(),gt=e();at(_,w[1],w[0]),at(gt,I[1],I[0]),tt(_,_,gt),M(l,w[0],w[1]),M(gt,I[0],I[1]),tt(l,l,gt),tt(A,w[3],I[3]),tt(A,A,B),tt(q,w[2],I[2]),M(q,q,q),at(K,l,_),at(J,q,A),M(yt,q,A),M(wt,l,_),tt(w[0],K,J),tt(w[1],wt,yt),tt(w[2],yt,J),tt(w[3],K,wt)}function ce(w,I,_){var l;for(l=0;l<4;l++)R(w[l],I[l],_)}function Qt(w,I){var _=e(),l=e(),A=e();Lt(A,I[2]),tt(_,I[0],A),tt(l,I[1],A),T(w,l),w[31]^=k(_)<<7}function fe(w,I,_){var l,A;for(E(w[0],f),E(w[1],u),E(w[2],u),E(w[3],f),A=255;A>=0;--A)l=_[A/8|0]>>(A&7)&1,ce(w,I,l),me(I,w),me(w,w),ce(w,I,l)}function be(w,I){var _=[e(),e(),e(),e()];E(_[0],v),E(_[1],F),E(_[2],u),tt(_[3],v,F),fe(w,_,I)}function we(w,I,_){var l=new Uint8Array(64),A=[e(),e(),e(),e()],q;for(_||n(I,32),hr(l,I,32),l[0]&=248,l[31]&=127,l[31]|=64,be(A,l),Qt(w,A),q=0;q<32;q++)I[q+32]=w[q];return 0}var ke=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function c(w,I){var _,l,A,q;for(l=63;l>=32;--l){for(_=0,A=l-32,q=l-12;A<q;++A)I[A]+=_-16*I[l]*ke[A-(l-32)],_=Math.floor((I[A]+128)/256),I[A]-=_*256;I[A]+=_,I[l]=0}for(_=0,A=0;A<32;A++)I[A]+=_-(I[31]>>4)*ke[A],_=I[A]>>8,I[A]&=255;for(A=0;A<32;A++)I[A]-=_*ke[A];for(l=0;l<32;l++)I[l+1]+=I[l]>>8,w[l]=I[l]&255}function r(w){var I=new Float64Array(64),_;for(_=0;_<64;_++)I[_]=w[_];for(_=0;_<64;_++)w[_]=0;c(w,I)}function i(w,I,_,l){var A=new Uint8Array(64),q=new Uint8Array(64),K=new Uint8Array(64),J,yt,wt=new Float64Array(64),gt=[e(),e(),e(),e()];hr(A,l,32),A[0]&=248,A[31]&=127,A[31]|=64;var ye=_+64;for(J=0;J<_;J++)w[64+J]=I[J];for(J=0;J<32;J++)w[32+J]=A[32+J];for(hr(K,w.subarray(32),_+32),r(K),be(gt,K),Qt(w,gt),J=32;J<64;J++)w[J]=l[J];for(hr(q,w,_+64),r(q),J=0;J<64;J++)wt[J]=0;for(J=0;J<32;J++)wt[J]=K[J];for(J=0;J<32;J++)for(yt=0;yt<32;yt++)wt[J+yt]+=q[J]*A[yt];return c(w.subarray(32),wt),ye}function h(w,I){var _=e(),l=e(),A=e(),q=e(),K=e(),J=e(),yt=e();return E(w[2],u),p(w[1],I),ft(A,w[1]),tt(q,A,x),at(A,A,w[2]),M(q,w[2],q),ft(K,q),ft(J,K),tt(yt,J,K),tt(_,yt,A),tt(_,_,q),At(_,_),tt(_,_,A),tt(_,_,q),tt(_,_,q),tt(w[0],_,q),ft(l,w[0]),tt(l,l,q),N(l,A)&&tt(w[0],w[0],L),ft(l,w[0]),tt(l,l,q),N(l,A)?-1:(k(w[0])===I[31]>>7&&at(w[0],f,w[0]),tt(w[3],w[0],w[1]),0)}function g(w,I,_,l){var A,q=new Uint8Array(32),K=new Uint8Array(64),J=[e(),e(),e(),e()],yt=[e(),e(),e(),e()];if(_<64||h(yt,l))return-1;for(A=0;A<_;A++)w[A]=I[A];for(A=0;A<32;A++)w[A+32]=l[A];if(hr(K,w,_),r(K),fe(J,yt,K),be(yt,I.subarray(32)),me(J,yt),Qt(q,J),_-=64,$(I,0,q,0)){for(A=0;A<_;A++)w[A]=0;return-1}for(A=0;A<_;A++)w[A]=I[A+64];return _}var b=32,S=24,et=32,lt=16,ht=32,kt=32,st=32,$e=32,ni=32,Ye=S,Xe=et,uo=lt,Ue=64,Oe=32,cn=64,qe=32,He=64;t.lowlevel={crypto_core_hsalsa20:G,crypto_stream_xor:jt,crypto_stream:ae,crypto_stream_salsa20_xor:Q,crypto_stream_salsa20:rt,crypto_onetimeauth:re,crypto_onetimeauth_verify:P,crypto_verify_16:z,crypto_verify_32:$,crypto_secretbox:d,crypto_secretbox_open:m,crypto_scalarmult:Ut,crypto_scalarmult_base:Ee,crypto_box_beforenm:Wt,crypto_box_afternm:Yt,crypto_box:ge,crypto_box_open:xr,crypto_box_keypair:Zt,crypto_hash:hr,crypto_sign:i,crypto_sign_keypair:we,crypto_sign_open:g,crypto_secretbox_KEYBYTES:b,crypto_secretbox_NONCEBYTES:S,crypto_secretbox_ZEROBYTES:et,crypto_secretbox_BOXZEROBYTES:lt,crypto_scalarmult_BYTES:ht,crypto_scalarmult_SCALARBYTES:kt,crypto_box_PUBLICKEYBYTES:st,crypto_box_SECRETKEYBYTES:$e,crypto_box_BEFORENMBYTES:ni,crypto_box_NONCEBYTES:Ye,crypto_box_ZEROBYTES:Xe,crypto_box_BOXZEROBYTES:uo,crypto_sign_BYTES:Ue,crypto_sign_PUBLICKEYBYTES:Oe,crypto_sign_SECRETKEYBYTES:cn,crypto_sign_SEEDBYTES:qe,crypto_hash_BYTES:He,gf:e,D:x,L:ke,pack25519:T,unpack25519:p,M:tt,A:M,S:ft,Z:at,pow2523:At,add:me,set25519:E,modL:c,scalarmult:fe,scalarbase:be};function Ii(w,I){if(w.length!==b)throw new Error("bad key size");if(I.length!==S)throw new Error("bad nonce size")}function Qe(w,I){if(w.length!==st)throw new Error("bad public key size");if(I.length!==$e)throw new Error("bad secret key size")}function Se(){for(var w=0;w<arguments.length;w++)if(!(arguments[w]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Bi(w){for(var I=0;I<w.length;I++)w[I]=0}t.randomBytes=function(w){var I=new Uint8Array(w);return n(I,w),I},t.secretbox=function(w,I,_){Se(w,I,_),Ii(_,I);for(var l=new Uint8Array(et+w.length),A=new Uint8Array(l.length),q=0;q<w.length;q++)l[q+et]=w[q];return d(A,l,l.length,I,_),A.subarray(lt)},t.secretbox.open=function(w,I,_){Se(w,I,_),Ii(_,I);for(var l=new Uint8Array(lt+w.length),A=new Uint8Array(l.length),q=0;q<w.length;q++)l[q+lt]=w[q];return l.length<32||m(A,l,l.length,I,_)!==0?null:A.subarray(et)},t.secretbox.keyLength=b,t.secretbox.nonceLength=S,t.secretbox.overheadLength=lt,t.scalarMult=function(w,I){if(Se(w,I),w.length!==kt)throw new Error("bad n size");if(I.length!==ht)throw new Error("bad p size");var _=new Uint8Array(ht);return Ut(_,w,I),_},t.scalarMult.base=function(w){if(Se(w),w.length!==kt)throw new Error("bad n size");var I=new Uint8Array(ht);return Ee(I,w),I},t.scalarMult.scalarLength=kt,t.scalarMult.groupElementLength=ht,t.box=function(w,I,_,l){var A=t.box.before(_,l);return t.secretbox(w,I,A)},t.box.before=function(w,I){Se(w,I),Qe(w,I);var _=new Uint8Array(ni);return Wt(_,w,I),_},t.box.after=t.secretbox,t.box.open=function(w,I,_,l){var A=t.box.before(_,l);return t.secretbox.open(w,I,A)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var w=new Uint8Array(st),I=new Uint8Array($e);return Zt(w,I),{publicKey:w,secretKey:I}},t.box.keyPair.fromSecretKey=function(w){if(Se(w),w.length!==$e)throw new Error("bad secret key size");var I=new Uint8Array(st);return Ee(I,w),{publicKey:I,secretKey:new Uint8Array(w)}},t.box.publicKeyLength=st,t.box.secretKeyLength=$e,t.box.sharedKeyLength=ni,t.box.nonceLength=Ye,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(w,I){if(Se(w,I),I.length!==cn)throw new Error("bad secret key size");var _=new Uint8Array(Ue+w.length);return i(_,w,w.length,I),_},t.sign.open=function(w,I){if(Se(w,I),I.length!==Oe)throw new Error("bad public key size");var _=new Uint8Array(w.length),l=g(_,w,w.length,I);if(l<0)return null;for(var A=new Uint8Array(l),q=0;q<A.length;q++)A[q]=_[q];return A},t.sign.detached=function(w,I){for(var _=t.sign(w,I),l=new Uint8Array(Ue),A=0;A<l.length;A++)l[A]=_[A];return l},t.sign.detached.verify=function(w,I,_){if(Se(w,I,_),I.length!==Ue)throw new Error("bad signature size");if(_.length!==Oe)throw new Error("bad public key size");var l=new Uint8Array(Ue+w.length),A=new Uint8Array(Ue+w.length),q;for(q=0;q<Ue;q++)l[q]=I[q];for(q=0;q<w.length;q++)l[q+Ue]=w[q];return g(A,l,l.length,_)>=0},t.sign.keyPair=function(){var w=new Uint8Array(Oe),I=new Uint8Array(cn);return we(w,I),{publicKey:w,secretKey:I}},t.sign.keyPair.fromSecretKey=function(w){if(Se(w),w.length!==cn)throw new Error("bad secret key size");for(var I=new Uint8Array(Oe),_=0;_<I.length;_++)I[_]=w[32+_];return{publicKey:I,secretKey:new Uint8Array(w)}},t.sign.keyPair.fromSeed=function(w){if(Se(w),w.length!==qe)throw new Error("bad seed size");for(var I=new Uint8Array(Oe),_=new Uint8Array(cn),l=0;l<32;l++)_[l]=w[l];return we(I,_,!0),{publicKey:I,secretKey:_}},t.sign.publicKeyLength=Oe,t.sign.secretKeyLength=cn,t.sign.seedLength=qe,t.sign.signatureLength=Ue,t.hash=function(w){Se(w);var I=new Uint8Array(He);return hr(I,w,w.length),I},t.hash.hashLength=He,t.verify=function(w,I){return Se(w,I),w.length===0||I.length===0||w.length!==I.length?!1:U(w,0,I,0,w.length)===0},t.setPRNG=function(w){n=w},function(){var w=typeof self<"u"?self.crypto||self.msCrypto:null;if(w&&w.getRandomValues){var I=65536;t.setPRNG(function(_,l){var A,q=new Uint8Array(l);for(A=0;A<l;A+=I)w.getRandomValues(q.subarray(A,A+Math.min(l-A,I)));for(A=0;A<l;A++)_[A]=q[A];Bi(q)})}else typeof id<"u"&&(w=ra,w&&w.randomBytes&&t.setPRNG(function(_,l){var A,q=w.randomBytes(l);for(A=0;A<l;A++)_[A]=q[A];Bi(q)}))}()})(o.exports?o.exports:self.nacl=self.nacl||{})})(Hc);var od=Hc.exports;class en{constructor(t){ir(this,"env");ir(this,"url");this.env=t??"prod",this.env==="prod"?this.url="https://api.coinflow.cash":this.env==="local"?this.url="http://localhost:5000":this.url=`https://api-${this.env}.coinflow.cash`}async getNSurePartnerId(t){return fetch(this.url+`/merchant/view/${t}`).then(e=>e.json()).then(e=>{var n;return((n=e.nSureSettings)==null?void 0:n.nSurePartnerId)||e.nSurePartnerId}).catch(e=>{console.error(e)})}async getCreditBalance(t,e,n){const a=await fetch(this.url+`/api/customer/balances/${e}`,{method:"GET",headers:{"x-coinflow-auth-wallet":t,"x-coinflow-auth-blockchain":n}}),{credits:s}=await a.json();return s}static getCoinflowBaseUrl(t){return!t||t==="prod"?"https://coinflow.cash":t==="local"?"http://localhost:3000":`https://${t}.coinflow.cash`}static getCoinflowApiUrl(t){return!t||t==="prod"?"https://api.coinflow.cash":t==="local"?"http://localhost:5000":`https://api-${t}.coinflow.cash`}static getCoinflowUrl({walletPubkey:t,route:e,routePrefix:n,env:a,amount:s,transaction:f,blockchain:u,webhookInfo:y,email:x,loaderBackground:B,handleHeightChange:v,bankAccountLinkRedirect:F,additionalWallets:L,nearDeposit:D,chargebackProtectionData:U,merchantCss:z,color:$,rent:X,lockDefaultToken:V,token:it,tokens:G,planCode:W,disableApplePay:Q,disableGooglePay:rt,customerInfo:ae,settlementType:jt,lockAmount:_t,nativeSolToConvert:re,theme:P,usePermit:d,transactionSigner:m,authOnly:E,deviceId:C,jwtToken:R,origins:T,threeDsChallengePreference:N}){var M;const k=n?`/${n}/${u}`:`/${u}`,p=new URL(k+e,en.getCoinflowBaseUrl(a));if(p.searchParams.append("pubkey",t),f&&p.searchParams.append("transaction",f),s&&p.searchParams.append("amount",s.toString()),y&&p.searchParams.append("webhookInfo",Wr.compressToEncodedURIComponent(JSON.stringify(y))),P&&p.searchParams.append("theme",Wr.compressToEncodedURIComponent(JSON.stringify(P))),ae&&p.searchParams.append("customerInfo",Wr.compressToEncodedURIComponent(JSON.stringify(ae))),x&&p.searchParams.append("email",x),it&&p.searchParams.append("token",it.toString()),G&&p.searchParams.append("tokens",G.toString()),B&&p.searchParams.append("loaderBackground",B),v&&p.searchParams.append("useHeightChange","true"),F&&p.searchParams.append("bankAccountLinkRedirect",F),L&&p.searchParams.append("additionalWallets",Wr.compressToEncodedURIComponent(JSON.stringify(L))),D&&p.searchParams.append("nearDeposit",D),U&&p.searchParams.append("chargebackProtectionData",Wr.compressToEncodedURIComponent(JSON.stringify(U))),C)p.searchParams.append("deviceId",C);else if(typeof window<"u"){const at=(M=window==null?void 0:window.nSureSDK)==null?void 0:M.getDeviceId();at&&p.searchParams.append("deviceId",at)}return z&&p.searchParams.append("merchantCss",z),$&&p.searchParams.append("color",$),X&&p.searchParams.append("rent",X.lamports.toString()),re&&p.searchParams.append("nativeSolToConvert",re.lamports.toString()),V&&p.searchParams.append("lockDefaultToken","true"),W&&p.searchParams.append("planCode",W),Q&&p.searchParams.append("disableApplePay","true"),rt&&p.searchParams.append("disableGooglePay","true"),jt&&p.searchParams.append("settlementType",jt),_t&&p.searchParams.append("lockAmount","true"),d===!1&&p.searchParams.append("usePermit","false"),m&&p.searchParams.append("transactionSigner",m),E===!0&&p.searchParams.append("authOnly","true"),R&&p.searchParams.append("jwtToken",R),T&&p.searchParams.append("origins",Wr.compressToEncodedURIComponent(JSON.stringify(T))),N&&p.searchParams.append("threeDsChallengePreference",N),p.toString()}static getTransaction(t){return this.byBlockchain(t.blockchain,{solana:()=>{if(!("transaction"in t))return;const{transaction:e}=t;if(!io)throw new Error("@solana/web3.js dependency is required for Solana");if(!Kr)throw new Error("bs58 dependency is required for Solana");if(e)return Kr.encode(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return Wr.compressToEncodedURIComponent(JSON.stringify(e))},eth:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return Wr.compressToEncodedURIComponent(JSON.stringify(e))},base:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return Wr.compressToEncodedURIComponent(JSON.stringify(e))},arbitrum:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return Wr.compressToEncodedURIComponent(JSON.stringify(e))},near:()=>{if(!("action"in t))return;const{action:e}=t;return Wr.compressToEncodedURIComponent(JSON.stringify(e))}})()}static byBlockchain(t,e){switch(t){case"solana":return e.solana;case"near":return e.near;case"polygon":return e.polygon;case"eth":return e.eth;case"base":return e.base;case"arbitrum":return e.arbitrum;default:throw new Error("blockchain not supported!")}}static async getWalletFromUserId({userId:t,merchantId:e,env:n}){return this.getWalletFromEmail({email:t,merchantId:e,env:n})}static async getWalletFromEmail({email:t,merchantId:e,env:n}){const a=new TextEncoder().encode(t),f=await window.crypto.subtle.digest("SHA-256",a),u=new Uint8Array(f),y=Ln.fromSeed(u);return{publicKey:y.publicKey,signMessage:x=>Promise.resolve(od.sign.detached(x,y.secretKey)),signTransaction:async x=>x instanceof ve?(x.sign(y),x):(x.sign([y]),x),sendTransaction:async x=>{x instanceof ve?x.sign(y):x.sign([y]);const B=this.getCoinflowApiUrl(n),v={method:"POST",headers:{"content-type":"application/json","x-coinflow-auth-wallet":y.publicKey.toString(),"x-coinflow-auth-blockchain":"solana"},body:JSON.stringify({merchantId:e,signedTransaction:Kr==null?void 0:Kr.encode(x.serialize())})},{signature:F}=await fetch(B+"/api/utils/send-coinflow-tx",v).then(L=>L.json());return F}}}}var Vc=(o=>(o.SignMessage="signMessage",o.SignTransaction="signTransaction",o.SendTransaction="sendTransaction",o.HeightChange="heightChange",o.Success="success",o))(Vc||{});function oo({wallet:o}){return"publicKey"in o?o.publicKey.toString():"address"in o?o.address:"accountId"in o?o.accountId:null}function jc(o,t){let e;try{if(e=JSON.parse(o),!("method"in e)||!("data"in e))return}catch(s){console.error("handleIFrameMessage JSON parse",s);return}const{data:n,method:a}=e;switch(a){case"signMessage":return t.handleSignMessage?t.handleSignMessage(n):void 0;case"signTransaction":return t.handleSignTransaction?t.handleSignTransaction(n):void 0;case"sendTransaction":return t.handleSendTransaction(n);case"heightChange":return t.handleHeightChange?t.handleHeightChange(n):void 0;case"success":if(!t.onSuccess)return;t.onSuccess(e.info);return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${a} is not one of ${Object.values(Vc)}`)}function so(o){return en.byBlockchain(o.blockchain,{solana:()=>sd(o),near:()=>ad(o),eth:()=>ao(o),polygon:()=>ao(o),base:()=>ao(o),arbitrum:()=>ao(o)})()}function sd({wallet:o,onSuccess:t}){return{handleSendTransaction:async e=>{const n=Gc(e);return await o.sendTransaction(n)},handleSignMessage:async e=>{const n=o.signMessage;if(!n)throw new Error("signMessage is not supported by this wallet");const a=await n(new TextEncoder().encode(e));if(!Kr)throw new Error("bs58 dependency is required");return Kr.encode(a)},handleSignTransaction:async e=>{const n=o.signTransaction;if(!n)throw new Error("signTransaction is not supported by this wallet");const a=Gc(e),s=await n(a);if(!Kr)throw new Error("bs58 dependency is required");return Kr.encode(s.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:t}}function Gc(o){if(!io)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!Kr)throw new Error("bs58 is not defined. Please install bs58 into your project");const t=Kr.decode(o),e=io.VersionedTransaction.deserialize(t);return e.version==="legacy"?io.Transaction.from(t):e}function ad({wallet:o,onSuccess:t}){const e=o;return{handleSendTransaction:async n=>{const a=JSON.parse(Buffer.from(n,"base64").toString()),s=await e.signAndSendTransaction(a);if(!s)throw new Error("Transaction did not send");const{transaction:f}=s;return f.hash},onSuccess:t}}function ao({wallet:o,onSuccess:t}){const e=o;return{handleSendTransaction:async n=>{const a=JSON.parse(Buffer.from(n,"base64").toString()),{hash:s}=await e.sendTransaction(a);return s},handleSignMessage:async n=>e.signMessage(n),onSuccess:t}}const Si="tokenExCardNumber",ri="tokenExCardCvv",Yc={[Fn.VISA]:"visa",[Fn.MASTERCARD]:"masterCard",[Fn.AMEX]:"americanExpress",[Fn.DISCOVER]:"discover"};async function Zc({token:o,origins:t,env:e}){return new Promise((n,a)=>{fetch(new en(e).url+"/api/checkout/authentication-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({origins:[...t??[],window.location.origin],token:o})}).then(async s=>{n(await s.json())}).catch(s=>a(s))})}function Is({env:o,setTokenExScriptLoaded:t}){const e="tokenex-script";if(document.head.querySelector(`#${e}`))return;const n=document.createElement("script");n.src=o==="prod"?"https://htp.tokenex.com/iframe/iframe-v3.min.js":"https://test-htp.tokenex.com/iframe/iframe-v3.min.js",n.id=e,document.head.appendChild(n),document.getElementById(e).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),t(!0)})}function cd({iframe:o,setCachedToken:t,setLoaded:e}){const n=async()=>(o.tokenize(),await new Promise((a,s)=>{o.on("tokenize",f=>{t(f.token),a(f)}),o.on("validate",f=>{(!f.isValid||f.isCvvValid===!1)&&s(f)})}));return o.on("change",()=>t(void 0)),o.on("cvvChange",()=>t(void 0)),o.on("load",()=>{setTimeout(()=>e(!0),350);const a=document.querySelector("#tx_iframe_tokenExCardNumber");a&&(a.scrolling="no")}),o.on("focus",()=>{o.focus()}),o.on("cvvFocus",()=>{o.cvvFocus()}),e(!1),o.load(),{...o,tokenize:n}}async function Jc(o){const{token:t,cardType:e}=o;return await Bs(ri,o,{cvvOnly:!0,cvv:!0,cvvContainerID:ri,placeholder:"CVV",token:t,cardType:Yc[e]})}async function Xc(o){return await Bs(Si,o,{cvv:!0,cvvContainerID:ri,cvvPlaceholder:"CVV"})}async function Qc(o){return await Bs(Si,o,{cvv:!1})}async function Bs(o,{tokenExScriptLoaded:t,origins:e,env:n,css:a,debug:s,font:f,setCachedToken:u,setLoaded:y},x){if(!t&&typeof TokenEx>"u"){console.warn("Warning Unable to load TokenEx on first attempt waiting for load event from document.head.script#tokenex-script");return}const B=await Zc({token:x.token,origins:e,env:n}),{styles:v}=ud(a),F={...B,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,styles:v,font:f,debug:s??!1,...x},L=TokenEx.Iframe(o,F);return cd({iframe:L,setCachedToken:u,setLoaded:y})}function ud(o){var n,a,s;const t=JSON.parse(o);return{styles:{base:mn(t.base),focus:mn(t.focus),error:mn(t.error),placeholder:mn(t.placeholder),cvv:{base:mn((n=t.cvv)==null?void 0:n.base),focus:mn((a=t.cvv)==null?void 0:a.focus),error:mn((s=t.cvv)==null?void 0:s.error),placeholder:mn(t==null?void 0:t.placeholder)}}}}function mn(o){if(!o)return"";if(typeof o=="string")return o;let t="";for(const[e,n]of Object.entries(o)){let a="";e.split("").forEach(s=>{s.toUpperCase()===s?a+="-"+s.toLowerCase():a+=s}),t+=a+":"+n+";"}return t}const fd=pt.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return en.getCoinflowUrl(this.args)}},emits:{onMessage({data:o,origin:t}){return console.log({data:o,origin:t}),!0}},methods:{sendMessage(o){const t=this.$refs.iframeRef;if(!(t!=null&&t.contentWindow))throw new Error("Iframe not defined");t.contentWindow.postMessage(o,"*")},handleIframeMessages({data:o,origin:t}){if(!t.includes(en.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:o,origin:t});const e=jc(o,this.args);e&&e.then(this.sendMessage).catch(n=>{console.error(n),this.sendMessage("ERROR "+n.message)})},async listenForMessage(o){let t;return new Promise((e,n)=>{if(t=({data:a,origin:s})=>{if(s.includes(en.getCoinflowBaseUrl(this.args.env))){if(a.startsWith("ERROR")){n(new Error(a.replace("ERROR","")));return}o(a)&&e(a)}},!window)throw new Error("Window not defined");window.addEventListener("message",t)}).finally(()=>{window.removeEventListener("message",t)})},async sendAndReceiveMessage(o,t){return this.sendMessage(o),this.listenForMessage(t)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),_s=(o,t)=>{const e=o.__vccOpts||o;for(const[n,a]of t)e[n]=a;return e},hd=["src","scrolling"];function ld(o,t,e,n,a,s){return pt.openBlock(),pt.createElementBlock("iframe",{style:{height:"100%",width:"100%"},ref:"iframeRef",allow:"payment;camera",title:"withdraw",frameBorder:"0",src:o.url,scrolling:o.args.handleHeightChange?"no":"yes",onLoad:t[0]||(t[0]=()=>{const f=o.$refs.iframeRef;f&&(f.style.opacity="1")})},null,40,hd)}const co=_s(fd,[["render",ld]]),dd=pt.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:co},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const o=oo(this.args);return{...this.args,walletPubkey:o,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...so(this.args),handleHeightChange:this.args.handleHeightChange}}}});function pd(o,t,e,n,a,s){const f=pt.resolveComponent("coinflow-i-frame");return pt.openBlock(),pt.createBlock(f,{args:{...o.iframeProps,...o.messageHandlers}},null,8,["args"])}const yd=_s(dd,[["render",pd]]),gd=pt.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:co},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const o=oo(this.args);return{...this.args,walletPubkey:o,route:`/purchase/${this.args.merchantId}`,transaction:en.getTransaction(this.args)}},messageHandlers(){return{...so(this.args),handleHeightChange:this.args.handleHeightChange}}}});function md(o,t,e,n,a,s){const f=pt.resolveComponent("coinflow-i-frame");return pt.openBlock(),pt.createBlock(f,{args:{...o.iframeProps,...o.messageHandlers}},null,8,["args"])}const wd=_s(gd,[["render",md]]),vs=o=>{const t=pt.ref(!1),e=pt.ref(!1),n=pt.ref(void 0),a=pt.ref(void 0);pt.onMounted(()=>{Is({env:o,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),e.value=!0}})});const s=v=>a.value=v,f=()=>t.value=!0,u=v=>n.value=v,y=async v=>{const F=await Jc({...v,tokenExScriptLoaded:e.value,env:o,setCachedToken:s,setLoaded:f});return u(F),F},x=async v=>{const F=await Xc({...v,tokenExScriptLoaded:e.value,env:o,setCachedToken:s,setLoaded:f});return u(F),F},B=async v=>{const F=await Qc({...v,tokenExScriptLoaded:e.value,env:o,setCachedToken:s,setLoaded:f});return u(F),F};return pt.watchEffect(v=>{n.value&&(n.value.load(),v(()=>{var F;return(F=n.value)==null?void 0:F.remove()}))}),{tokenExIframe:n,initializeTokenExIframe:x,initializeCvvOnlyTokenExIframe:y,initializeTokenExCardOnlyIframe:B,loaded:t,cachedToken:a,setTokenExScriptTag:Is,tokenExScriptLoaded:e}},bd=["id"],xd=pt.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(o,{expose:t}){const{args:e}=o,{initializeTokenExIframe:n,tokenExIframe:a}=vs(e.env);async function s(){if(!a.value)throw new Error("Unable to get token");return a.value.tokenize()}t({getToken:s});function f(){return JSON.stringify(e.css)}return pt.watchEffect(()=>{n({css:f(),debug:e.debug,origins:e.origins,font:e.font})},{}),(u,y)=>(pt.openBlock(),pt.createElementBlock("div",{id:pt.unref(Si)},null,8,bd))}}),Ed=["id"],kd=pt.defineComponent({__name:"CoinflowCvvInput",setup(o){return(t,e)=>(pt.openBlock(),pt.createElementBlock("div",{id:pt.unref(ri)},null,8,Ed))}}),Sd=["id"],Id=pt.defineComponent({__name:"CoinflowCvvOnlyInput",props:{args:{type:Object,required:!0}},setup(o,{expose:t}){const{args:e}=o,{initializeCvvOnlyTokenExIframe:n,tokenExIframe:a}=vs(e.env);async function s(){if(!a.value)throw new Error("Unable to get token");return a.value.tokenize()}t({getToken:s});function f(){return JSON.stringify(e.css)}return pt.watchEffect(()=>{n({...e,origins:e.origins??[],css:f(),font:e.font})},{}),(u,y)=>(pt.openBlock(),pt.createElementBlock("div",{id:pt.unref(ri)},null,8,Sd))}}),Bd=pt.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(o){const{args:{env:t,merchantId:e}}=o,n=pt.ref(void 0);pt.onMounted(()=>new en(t).getNSurePartnerId(e).then(f=>n.value=f));function a(){return t==="prod"?"9JBW2RHC7JNJN8ZQ":"SANDBOX_CTCE4XK53ZW0R7V1"}function s(){return t==="prod"?"https://sdk.nsureapi.com/sdk.js":"https://sdk.nsureapi.com/sdk-sandbox.js"}return pt.watchEffect(f=>{if(!n.value)return;const u=document.createElement("script");u.src=s(),document.head.appendChild(u);const y=`window.nSureAsyncInit = function(deviceId) {
24
24
  window.nSureSDK.init({
25
25
  appId: '${a()}',
26
26
  partnerId: '${n.value}',
27
27
  });
28
- };`,x=document.createElement("script");x.innerHTML=y,document.head.appendChild(x),f(()=>{document.head.removeChild(u),document.head.removeChild(x)})}),(f,u)=>null}}),vd=["id"],_d=Ct.defineComponent({__name:"CoinflowCardNumberOnlyInput",props:{args:{type:Object,required:!0}},setup(o,{expose:t}){const{args:e}=o,{tokenExIframe:n,initializeTokenExCardOnlyIframe:a}=_s(e.env);async function s(){if(!n.value)throw new Error("Unable to get token");return n.value.tokenize()}t({getToken:s});function f(){return JSON.stringify(e.css)}return Ct.watchEffect(()=>{a({css:f(),debug:e.debug,origins:e.origins,font:e.font})},{}),(u,y)=>(Ct.openBlock(),Ct.createElementBlock("div",{id:Ct.unref(Si)},null,8,vd))}}),tu=Ct.defineComponent({__name:"MobileWalletButton",props:{args:{type:Object,required:!0},route:{type:String,required:!0}},setup(o){const{args:t,route:e}=o,{onSuccess:n}=t;function a(){const u=oo(t);return{...t,walletPubkey:u,transaction:void 0,routePrefix:"form",route:`/${e}/${t.merchantId}`}}function s(){return{...so(t),handleHeightChange:t.handleHeightChange}}function f({data:u}){try{const y=JSON.parse(u);if(!("method"in y)||y.method!=="getToken")return}catch{return}n==null||n(u)}return(u,y)=>(Ct.openBlock(),Ct.createBlock(ao,{onOnMessage:f,args:{...a(),...s()}},null,8,["args"]))}}),Ad=Ct.defineComponent({__name:"CoinflowApplePayButton",props:{args:{type:Object,required:!0}},setup(o){return(t,e)=>(Ct.openBlock(),Ct.createBlock(tu,{route:"apple-pay",args:o.args},null,8,["args"]))}}),Rd=Ct.defineComponent({__name:"CoinflowGooglePayButton",props:{args:{type:Object,required:!0}},setup(o){return(t,e)=>(Ct.openBlock(),Ct.createBlock(tu,{route:"google-pay",args:o.args},null,8,["args"]))}});le.CARD_TYPE_MAPPING=Yc,le.CardType=Fn,le.CoinflowApplePayButton=Ad,le.CoinflowCardNumberInput=xd,le.CoinflowCardNumberOnlyInput=_d,le.CoinflowCvvInput=kd,le.CoinflowCvvOnlyInput=Id,le.CoinflowGooglePayButton=Rd,le.CoinflowIframe=ao,le.CoinflowPurchase=md,le.CoinflowPurchaseProtection=Bd,le.CoinflowUtils=en,le.CoinflowWithdraw=yd,le.MerchantStyle=As,le.SettlementType=mn,le.ThreeDsChallengePreference=Rs,le.TokenExCardNumberIframeId=Si,le.TokenExCvvContainerID=ri,le.doInitializeCvvOnlyTokenExIframe=Jc,le.doInitializeTokenExCardOnlyIframe=Qc,le.doInitializeTokenExIframe=Xc,le.getHandlers=so,le.getIframeConfig=Zc,le.getWalletPubkey=oo,le.handleIFrameMessage=Vc,le.setTokenExScriptTag=Is,Object.defineProperty(le,Symbol.toStringTag,{value:"Module"})});
28
+ };`,x=document.createElement("script");x.innerHTML=y,document.head.appendChild(x),f(()=>{document.head.removeChild(u),document.head.removeChild(x)})}),(f,u)=>null}}),_d=["id"],vd=pt.defineComponent({__name:"CoinflowCardNumberOnlyInput",props:{args:{type:Object,required:!0}},setup(o,{expose:t}){const{args:e}=o,{tokenExIframe:n,initializeTokenExCardOnlyIframe:a}=vs(e.env);async function s(){if(!n.value)throw new Error("Unable to get token");return n.value.tokenize()}t({getToken:s});function f(){return JSON.stringify(e.css)}return pt.watchEffect(()=>{a({css:f(),debug:e.debug,origins:e.origins,font:e.font})},{}),(u,y)=>(pt.openBlock(),pt.createElementBlock("div",{id:pt.unref(Si)},null,8,_d))}}),Ad={style:{position:"relative",height:"100%"}},Rd={style:{position:"relative",zIndex:10,height:"100%"}},tu=pt.defineComponent({__name:"MobileWalletButton",props:{args:{type:Object,required:!0},route:{type:String,required:!0},overlayDisplayOverride:{type:String,required:!1},alignItems:{type:String,required:!1}},setup(o){const{args:t,route:e,overlayDisplayOverride:n}=o,{onSuccess:a}=t;function s(){const B=oo(t);return{...t,walletPubkey:B,transaction:void 0,routePrefix:"form",route:`/${e}/${t.merchantId}`}}function f(){return{...so(t),handleHeightChange:t.handleHeightChange}}const u=pt.ref(.8),y=pt.ref("flex");function x({data:B}){try{const v=JSON.parse(B);if("method"in v&&v.method==="loaded"&&(u.value=1,setTimeout(()=>{y.value="none"},2e3)),!("method"in v)||v.method!=="getToken")return}catch{return}a==null||a(B)}return(B,v)=>(pt.openBlock(),pt.createElementBlock("div",Ad,[pt.createElementVNode("div",{style:pt.normalizeStyle({backgroundColor:o.args.color,width:"100%",height:"40px",position:"absolute",top:0,bottom:0,left:0,zIndex:20,display:o.overlayDisplayOverride??y.value,opacity:u.value,justifyContent:"center",alignItems:o.alignItems,pointerEvents:"none"})},[pt.renderSlot(B.$slots,"default")],4),pt.createElementVNode("div",Rd,[pt.createVNode(co,{onOnMessage:x,args:{...s(),...f()}},null,8,["args"])])]))}}),Td={id:"svg-logo",viewBox:"0 0 35 15"},Md={id:"svg-logo",x:"0",y:"3.85",height:"7.3",width:"35",className:"logo",viewBox:"0 0 105 43",version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},Cd=pt.createElementVNode("title",null,"Apple Logo",-1),Pd={stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},Ud=["fill"],Ld=[pt.createStaticVNode('<path d="M19.4028,5.5674 C20.6008,4.0684 21.4138,2.0564 21.1998,0.0004 C19.4458,0.0874 17.3058,1.1574 16.0668,2.6564 C14.9538,3.9414 13.9688,6.0374 14.2258,8.0074 C16.1948,8.1784 18.1618,7.0244 19.4028,5.5674"></path><path d="M21.1772,8.3926 C18.3182,8.2226 15.8872,10.0156 14.5212,10.0156 C13.1552,10.0156 11.0642,8.4786 8.8022,8.5196 C5.8592,8.5626 3.1282,10.2276 1.6342,12.8746 C-1.4378,18.1696 0.8232,26.0246 3.8112,30.3376 C5.2622,32.4716 7.0102,34.8206 9.3142,34.7366 C11.4912,34.6506 12.3442,33.3266 14.9902,33.3266 C17.6352,33.3266 18.4042,34.7366 20.7082,34.6936 C23.0972,34.6506 24.5922,32.5586 26.0422,30.4226 C27.7072,27.9906 28.3882,25.6426 28.4312,25.5126 C28.3882,25.4706 23.8232,23.7186 23.7812,18.4676 C23.7382,14.0706 27.3652,11.9786 27.5362,11.8496 C25.4882,8.8196 22.2872,8.4786 21.1772,8.3926"></path><path d="M85.5508,43.0381 L85.5508,39.1991 C85.8628,39.2421 86.6158,39.2871 87.0158,39.2871 C89.2138,39.2871 90.4558,38.3551 91.2108,35.9581 L91.6548,34.5371 L83.2428,11.2321 L88.4368,11.2321 L94.2958,30.1421 L94.4068,30.1421 L100.2668,11.2321 L105.3278,11.2321 L96.6048,35.7141 C94.6078,41.3291 92.3208,43.1721 87.4828,43.1721 C87.1048,43.1721 85.8838,43.1271 85.5508,43.0381"></path><path d="M42.6499,19.3555 L48.3549,19.3555 C52.6829,19.3555 55.1469,17.0255 55.1469,12.9855 C55.1469,8.9455 52.6829,6.6375 48.3769,6.6375 L42.6499,6.6375 L42.6499,19.3555 Z M49.6869,2.4425 C55.9009,2.4425 60.2289,6.7265 60.2289,12.9625 C60.2289,19.2225 55.8129,23.5285 49.5309,23.5285 L42.6499,23.5285 L42.6499,34.4705 L37.6779,34.4705 L37.6779,2.4425 L49.6869,2.4425 Z"></path><path d="M76.5547,25.7705 L76.5547,23.9715 L71.0287,24.3275 C67.9207,24.5275 66.3007,25.6815 66.3007,27.7015 C66.3007,29.6545 67.9887,30.9195 70.6287,30.9195 C74.0027,30.9195 76.5547,28.7665 76.5547,25.7705 M61.4617,27.8345 C61.4617,23.7285 64.5917,21.3755 70.3627,21.0205 L76.5547,20.6425 L76.5547,18.8675 C76.5547,16.2705 74.8457,14.8495 71.8057,14.8495 C69.2967,14.8495 67.4777,16.1375 67.0997,18.1125 L62.6167,18.1125 C62.7497,13.9615 66.6567,10.9435 71.9387,10.9435 C77.6207,10.9435 81.3267,13.9175 81.3267,18.5345 L81.3267,34.4705 L76.7327,34.4705 L76.7327,30.6305 L76.6217,30.6305 C75.3127,33.1395 72.4267,34.7145 69.2967,34.7145 C64.6807,34.7145 61.4617,31.9625 61.4617,27.8345"></path>',5)],Fd=pt.defineComponent({__name:"ApplePayOverlay",props:{color:{type:String,required:!0}},setup(o){const{color:t}=o,e=t==="white"?"#000":"#FFF";return(n,a)=>(pt.openBlock(),pt.createElementBlock("svg",Td,[(pt.openBlock(),pt.createElementBlock("svg",Md,[Cd,pt.createElementVNode("g",Pd,[pt.createElementVNode("g",{fill:pt.unref(e)},Ld,8,Ud)])]))]))}}),Od=pt.defineComponent({__name:"CoinflowApplePayButton",props:{args:{type:Object,required:!0}},setup(o){return(t,e)=>(pt.openBlock(),pt.createBlock(tu,{route:"apple-pay",args:o.args},{default:pt.withCtx(()=>[pt.createVNode(Fd,{color:o.args.color},null,8,["color"])]),_:1},8,["args"]))}}),Nd={key:0,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},zd=[pt.createStaticVNode('<g fill="none" fill-rule="evenodd"><path d="M19.526 2.635v4.083h2.518c.6 0 1.096-.202 1.488-.605.403-.402.605-.882.605-1.437 0-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0 5.52v4.736h-1.504V1.198h3.99c1.013 0 1.873.337 2.582 1.012.72.675 1.08 1.497 1.08 2.466 0 .991-.36 1.819-1.08 2.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668 2.287c0 .392.166.718.499.98.332.26.722.391 1.168.391.633 0 1.196-.234 1.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61 0-1.12.148-1.528.442-.409.294-.613.657-.613 1.093m1.946-5.815c1.112 0 1.989.297 2.633.89.642.594.964 1.408.964 2.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45 1.372-2.486 1.372-.882 0-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96 0-.828.313-1.486.94-1.976s1.463-.735 2.51-.735c.892 0 1.629.163 2.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132 2.132 0 0 0-1.455-.547c-.84 0-1.504.353-1.995 1.062l-1.324-.834c.73-1.045 1.81-1.568 3.238-1.568m11.853.262l-5.02 11.53H34.42l1.864-4.034-3.302-7.496h1.635l2.387 5.749h.032l2.322-5.75z" fill="#5F6368"></path><path d="M13.448 7.134c0-.473-.04-.93-.116-1.366H6.988v2.588h3.634a3.11 3.11 0 0 1-1.344 2.042v1.68h2.169c1.27-1.17 2.001-2.9 2.001-4.944" fill="#4285F4"></path><path d="M6.988 13.7c1.816 0 3.344-.595 4.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754 0-3.244-1.182-3.776-2.774H.978v1.731a6.728 6.728 0 0 0 6.01 3.703" fill="#34A853"></path><path d="M3.212 8.267a4.034 4.034 0 0 1 0-2.572V3.964H.978A6.678 6.678 0 0 0 .261 6.98c0 1.085.26 2.11.717 3.017l2.234-1.731z" fill="#FABB05"></path><path d="M6.988 2.921c.992 0 1.88.34 2.58 1.008v.001l1.92-1.918C10.324.928 8.804.262 6.989.262a6.728 6.728 0 0 0-6.01 3.702l2.234 1.731c.532-1.592 2.022-2.774 3.776-2.774" fill="#E94235"></path><path d="M0 0h41.285v18H0z"></path></g>',1)],Dd={key:1,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},$d=[pt.createStaticVNode('<g fill="none" fill-rule="evenodd"><path d="M19.526 2.635v4.083h2.518c.6 0 1.096-.202 1.488-.605.403-.402.605-.882.605-1.437 0-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0 5.52v4.736h-1.504V1.198h3.99c1.013 0 1.873.337 2.582 1.012.72.675 1.08 1.497 1.08 2.466 0 .991-.36 1.819-1.08 2.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668 2.287c0 .392.166.718.499.98.332.26.722.391 1.168.391.633 0 1.196-.234 1.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61 0-1.12.148-1.528.442-.409.294-.613.657-.613 1.093m1.946-5.815c1.112 0 1.989.297 2.633.89.642.594.964 1.408.964 2.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45 1.372-2.486 1.372-.882 0-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96 0-.828.313-1.486.94-1.976s1.463-.735 2.51-.735c.892 0 1.629.163 2.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132 2.132 0 0 0-1.455-.547c-.84 0-1.504.353-1.995 1.062l-1.324-.834c.73-1.045 1.81-1.568 3.238-1.568m11.853.262l-5.02 11.53H34.42l1.864-4.034-3.302-7.496h1.635l2.387 5.749h.032l2.322-5.75z" fill="#FFF"></path><path d="M13.448 7.134c0-.473-.04-.93-.116-1.366H6.988v2.588h3.634a3.11 3.11 0 0 1-1.344 2.042v1.68h2.169c1.27-1.17 2.001-2.9 2.001-4.944" fill="#4285F4"></path><path d="M6.988 13.7c1.816 0 3.344-.595 4.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754 0-3.244-1.182-3.776-2.774H.978v1.731a6.728 6.728 0 0 0 6.01 3.703" fill="#34A853"></path><path d="M3.212 8.267a4.034 4.034 0 0 1 0-2.572V3.964H.978A6.678 6.678 0 0 0 .261 6.98c0 1.085.26 2.11.717 3.017l2.234-1.731z" fill="#FABB05"></path><path d="M6.988 2.921c.992 0 1.88.34 2.58 1.008v.001l1.92-1.918C10.324.928 8.804.262 6.989.262a6.728 6.728 0 0 0-6.01 3.702l2.234 1.731c.532-1.592 2.022-2.774 3.776-2.774" fill="#E94235"></path></g>',1)],Kd=pt.defineComponent({__name:"GooglePayOverlay",props:{color:{type:String,required:!0}},setup(o){return(t,e)=>(pt.openBlock(),pt.createElementBlock(pt.Fragment,null,[o.color==="white"?(pt.openBlock(),pt.createElementBlock("svg",Nd,zd)):pt.createCommentVNode("",!0),o.color==="black"?(pt.openBlock(),pt.createElementBlock("svg",Dd,$d)):pt.createCommentVNode("",!0)],64))}}),Wd=pt.defineComponent({__name:"CoinflowGooglePayButton",props:{args:{type:Object,required:!0}},setup(o){return(t,e)=>(pt.openBlock(),pt.createBlock(tu,{route:"google-pay",args:o.args,overlayDisplayOverride:"flex",alignItems:"center"},{default:pt.withCtx(()=>[pt.createVNode(Kd,{color:o.args.color},null,8,["color"])]),_:1},8,["args"]))}});le.CARD_TYPE_MAPPING=Yc,le.CardType=Fn,le.CoinflowApplePayButton=Od,le.CoinflowCardNumberInput=xd,le.CoinflowCardNumberOnlyInput=vd,le.CoinflowCvvInput=kd,le.CoinflowCvvOnlyInput=Id,le.CoinflowGooglePayButton=Wd,le.CoinflowIframe=co,le.CoinflowPurchase=wd,le.CoinflowPurchaseProtection=Bd,le.CoinflowUtils=en,le.CoinflowWithdraw=yd,le.MerchantStyle=As,le.SettlementType=wn,le.ThreeDsChallengePreference=Rs,le.TokenExCardNumberIframeId=Si,le.TokenExCvvContainerID=ri,le.doInitializeCvvOnlyTokenExIframe=Jc,le.doInitializeTokenExCardOnlyIframe=Qc,le.doInitializeTokenExIframe=Xc,le.getHandlers=so,le.getIframeConfig=Zc,le.getWalletPubkey=oo,le.handleIFrameMessage=jc,le.setTokenExScriptTag=Is,Object.defineProperty(le,Symbol.toStringTag,{value:"Module"})});