@coinflowlabs/vue 0.2.8 → 0.3.1

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,18 +1,18 @@
1
- (function(se,ft){typeof exports=="object"&&typeof module<"u"?ft(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],ft):(se=typeof globalThis<"u"?globalThis:se||self,ft(se.VueTypeWriter={},se.Vue))})(this,function(se,ft){"use strict";var Fd=Object.defineProperty;var zd=(se,ft,wn)=>ft in se?Fd(se,ft,{enumerable:!0,configurable:!0,writable:!0,value:wn}):se[ft]=wn;var nr=(se,ft,wn)=>zd(se,typeof ft!="symbol"?ft+"":ft,wn);var wn=(n=>(n.Credits="Credits",n.USDC="USDC",n.Bank="Bank",n))(wn||{}),Bo=(n=>(n.Rounded="rounded",n.Sharp="sharp",n.Pill="pill",n))(Bo||{}),Ro=(n=>(n.NoPreference="NoPreference",n.Frictionless="Frictionless",n.Challenge="Challenge",n))(Ro||{}),On=(n=>(n.VISA="VISA",n.MASTERCARD="MSTR",n.AMEX="AMEX",n.DISCOVER="DISC",n))(On||{}),Nr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ni(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function us(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?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(n).forEach(function(r){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return n[r]}})}),e}var Ct={},Ei={};Ei.byteLength=eu,Ei.toByteArray=nu,Ei.fromByteArray=ou;for(var qr=[],Pr=[],Qc=typeof Uint8Array<"u"?Uint8Array:Array,fs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Nn=0,tu=fs.length;Nn<tu;++Nn)qr[Nn]=fs[Nn],Pr[fs.charCodeAt(Nn)]=Nn;Pr[45]=62,Pr[95]=63;function To(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var r=e===t?0:4-e%4;return[e,r]}function eu(n){var t=To(n),e=t[0],r=t[1];return(e+r)*3/4-r}function ru(n,t,e){return(t+e)*3/4-e}function nu(n){var t,e=To(n),r=e[0],s=e[1],i=new Qc(ru(n,r,s)),o=0,a=s>0?r-4:r,l;for(l=0;l<a;l+=4)t=Pr[n.charCodeAt(l)]<<18|Pr[n.charCodeAt(l+1)]<<12|Pr[n.charCodeAt(l+2)]<<6|Pr[n.charCodeAt(l+3)],i[o++]=t>>16&255,i[o++]=t>>8&255,i[o++]=t&255;return s===2&&(t=Pr[n.charCodeAt(l)]<<2|Pr[n.charCodeAt(l+1)]>>4,i[o++]=t&255),s===1&&(t=Pr[n.charCodeAt(l)]<<10|Pr[n.charCodeAt(l+1)]<<4|Pr[n.charCodeAt(l+2)]>>2,i[o++]=t>>8&255,i[o++]=t&255),i}function iu(n){return qr[n>>18&63]+qr[n>>12&63]+qr[n>>6&63]+qr[n&63]}function su(n,t,e){for(var r,s=[],i=t;i<e;i+=3)r=(n[i]<<16&16711680)+(n[i+1]<<8&65280)+(n[i+2]&255),s.push(iu(r));return s.join("")}function ou(n){for(var t,e=n.length,r=e%3,s=[],i=16383,o=0,a=e-r;o<a;o+=i)s.push(su(n,o,o+i>a?a:o+i));return r===1?(t=n[e-1],s.push(qr[t>>2]+qr[t<<4&63]+"==")):r===2&&(t=(n[e-2]<<8)+n[e-1],s.push(qr[t>>10]+qr[t>>4&63]+qr[t<<2&63]+"=")),s.join("")}var ls={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ls.read=function(n,t,e,r,s){var i,o,a=s*8-r-1,l=(1<<a)-1,y=l>>1,x=-7,_=e?s-1:0,L=e?-1:1,C=n[t+_];for(_+=L,i=C&(1<<-x)-1,C>>=-x,x+=a;x>0;i=i*256+n[t+_],_+=L,x-=8);for(o=i&(1<<-x)-1,i>>=-x,x+=r;x>0;o=o*256+n[t+_],_+=L,x-=8);if(i===0)i=1-y;else{if(i===l)return o?NaN:(C?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-y}return(C?-1:1)*o*Math.pow(2,i-r)},ls.write=function(n,t,e,r,s,i){var o,a,l,y=i*8-s-1,x=(1<<y)-1,_=x>>1,L=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,C=r?0:i-1,N=r?1:-1,M=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=x):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+_>=1?t+=L/l:t+=L*Math.pow(2,1-_),t*l>=2&&(o++,l/=2),o+_>=x?(a=0,o=x):o+_>=1?(a=(t*l-1)*Math.pow(2,s),o=o+_):(a=t*Math.pow(2,_-1)*Math.pow(2,s),o=0));s>=8;n[e+C]=a&255,C+=N,a/=256,s-=8);for(o=o<<s|a,y+=s;y>0;n[e+C]=o&255,C+=N,o/=256,y-=8);n[e+C-N]|=M*128};/*!
1
+ (function(se,ft){typeof exports=="object"&&typeof module<"u"?ft(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],ft):(se=typeof globalThis<"u"?globalThis:se||self,ft(se.VueTypeWriter={},se.Vue))})(this,function(se,ft){"use strict";var zd=Object.defineProperty;var Kd=(se,ft,wn)=>ft in se?zd(se,ft,{enumerable:!0,configurable:!0,writable:!0,value:wn}):se[ft]=wn;var nr=(se,ft,wn)=>Kd(se,typeof ft!="symbol"?ft+"":ft,wn);var wn=(n=>(n.Credits="Credits",n.USDC="USDC",n.Bank="Bank",n))(wn||{}),Bo=(n=>(n.Rounded="rounded",n.Sharp="sharp",n.Pill="pill",n))(Bo||{}),Ro=(n=>(n.NoPreference="NoPreference",n.Frictionless="Frictionless",n.Challenge="Challenge",n))(Ro||{}),On=(n=>(n.VISA="VISA",n.MASTERCARD="MSTR",n.AMEX="AMEX",n.DISCOVER="DISC",n))(On||{}),Nr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ni(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function cs(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?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(n).forEach(function(r){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return n[r]}})}),e}var Ct={},Si={};Si.byteLength=ru,Si.toByteArray=iu,Si.fromByteArray=au;for(var qr=[],Pr=[],tu=typeof Uint8Array<"u"?Uint8Array:Array,us="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Nn=0,eu=us.length;Nn<eu;++Nn)qr[Nn]=us[Nn],Pr[us.charCodeAt(Nn)]=Nn;Pr[45]=62,Pr[95]=63;function To(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var r=e===t?0:4-e%4;return[e,r]}function ru(n){var t=To(n),e=t[0],r=t[1];return(e+r)*3/4-r}function nu(n,t,e){return(t+e)*3/4-e}function iu(n){var t,e=To(n),r=e[0],s=e[1],i=new tu(nu(n,r,s)),o=0,a=s>0?r-4:r,l;for(l=0;l<a;l+=4)t=Pr[n.charCodeAt(l)]<<18|Pr[n.charCodeAt(l+1)]<<12|Pr[n.charCodeAt(l+2)]<<6|Pr[n.charCodeAt(l+3)],i[o++]=t>>16&255,i[o++]=t>>8&255,i[o++]=t&255;return s===2&&(t=Pr[n.charCodeAt(l)]<<2|Pr[n.charCodeAt(l+1)]>>4,i[o++]=t&255),s===1&&(t=Pr[n.charCodeAt(l)]<<10|Pr[n.charCodeAt(l+1)]<<4|Pr[n.charCodeAt(l+2)]>>2,i[o++]=t>>8&255,i[o++]=t&255),i}function su(n){return qr[n>>18&63]+qr[n>>12&63]+qr[n>>6&63]+qr[n&63]}function ou(n,t,e){for(var r,s=[],i=t;i<e;i+=3)r=(n[i]<<16&16711680)+(n[i+1]<<8&65280)+(n[i+2]&255),s.push(su(r));return s.join("")}function au(n){for(var t,e=n.length,r=e%3,s=[],i=16383,o=0,a=e-r;o<a;o+=i)s.push(ou(n,o,o+i>a?a:o+i));return r===1?(t=n[e-1],s.push(qr[t>>2]+qr[t<<4&63]+"==")):r===2&&(t=(n[e-2]<<8)+n[e-1],s.push(qr[t>>10]+qr[t>>4&63]+qr[t<<2&63]+"=")),s.join("")}var fs={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */fs.read=function(n,t,e,r,s){var i,o,a=s*8-r-1,l=(1<<a)-1,y=l>>1,x=-7,E=e?s-1:0,L=e?-1:1,C=n[t+E];for(E+=L,i=C&(1<<-x)-1,C>>=-x,x+=a;x>0;i=i*256+n[t+E],E+=L,x-=8);for(o=i&(1<<-x)-1,i>>=-x,x+=r;x>0;o=o*256+n[t+E],E+=L,x-=8);if(i===0)i=1-y;else{if(i===l)return o?NaN:(C?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-y}return(C?-1:1)*o*Math.pow(2,i-r)},fs.write=function(n,t,e,r,s,i){var o,a,l,y=i*8-s-1,x=(1<<y)-1,E=x>>1,L=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,C=r?0:i-1,N=r?1:-1,M=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=x):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+E>=1?t+=L/l:t+=L*Math.pow(2,1-E),t*l>=2&&(o++,l/=2),o+E>=x?(a=0,o=x):o+E>=1?(a=(t*l-1)*Math.pow(2,s),o=o+E):(a=t*Math.pow(2,E-1)*Math.pow(2,s),o=0));s>=8;n[e+C]=a&255,C+=N,a/=256,s-=8);for(o=o<<s|a,y+=s;y>0;n[e+C]=o&255,C+=N,o/=256,y-=8);n[e+C-N]|=M*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(n){const t=Ei,e=ls,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=X,n.INSPECT_MAX_BYTES=50;const s=2147483647;n.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.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 i(){try{const m=new Uint8Array(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,Uint8Array.prototype),Object.setPrototypeOf(m,f),m.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(m){if(m>s)throw new RangeError('The value "'+m+'" is invalid for option "size"');const f=new Uint8Array(m);return Object.setPrototypeOf(f,a.prototype),f}function a(m,f,d){if(typeof m=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _(m)}return l(m,f,d)}a.poolSize=8192;function l(m,f,d){if(typeof m=="string")return L(m,f);if(ArrayBuffer.isView(m))return N(m);if(m==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m);if(rr(m,ArrayBuffer)||m&&rr(m.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(rr(m,SharedArrayBuffer)||m&&rr(m.buffer,SharedArrayBuffer)))return M(m,f,d);if(typeof m=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const B=m.valueOf&&m.valueOf();if(B!=null&&B!==m)return a.from(B,f,d);const F=O(m);if(F)return F;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof m[Symbol.toPrimitive]=="function")return a.from(m[Symbol.toPrimitive]("string"),f,d);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m)}a.from=function(m,f,d){return l(m,f,d)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function y(m){if(typeof m!="number")throw new TypeError('"size" argument must be of type number');if(m<0)throw new RangeError('The value "'+m+'" is invalid for option "size"')}function x(m,f,d){return y(m),m<=0?o(m):f!==void 0?typeof d=="string"?o(m).fill(f,d):o(m).fill(f):o(m)}a.alloc=function(m,f,d){return x(m,f,d)};function _(m){return y(m),o(m<0?0:K(m)|0)}a.allocUnsafe=function(m){return _(m)},a.allocUnsafeSlow=function(m){return _(m)};function L(m,f){if((typeof f!="string"||f==="")&&(f="utf8"),!a.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const d=V(m,f)|0;let B=o(d);const F=B.write(m,f);return F!==d&&(B=B.slice(0,F)),B}function C(m){const f=m.length<0?0:K(m.length)|0,d=o(f);for(let B=0;B<f;B+=1)d[B]=m[B]&255;return d}function N(m){if(rr(m,Uint8Array)){const f=new Uint8Array(m);return M(f.buffer,f.byteOffset,f.byteLength)}return C(m)}function M(m,f,d){if(f<0||m.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(m.byteLength<f+(d||0))throw new RangeError('"length" is outside of buffer bounds');let B;return f===void 0&&d===void 0?B=new Uint8Array(m):d===void 0?B=new Uint8Array(m,f):B=new Uint8Array(m,f,d),Object.setPrototypeOf(B,a.prototype),B}function O(m){if(a.isBuffer(m)){const f=K(m.length)|0,d=o(f);return d.length===0||m.copy(d,0,0,f),d}if(m.length!==void 0)return typeof m.length!="number"||ke(m.length)?o(0):C(m);if(m.type==="Buffer"&&Array.isArray(m.data))return C(m.data)}function K(m){if(m>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return m|0}function X(m){return+m!=m&&(m=0),a.alloc(+m)}a.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==a.prototype},a.compare=function(f,d){if(rr(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),rr(d,Uint8Array)&&(d=a.from(d,d.offset,d.byteLength)),!a.isBuffer(f)||!a.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===d)return 0;let B=f.length,F=d.length;for(let $=0,Y=Math.min(B,F);$<Y;++$)if(f[$]!==d[$]){B=f[$],F=d[$];break}return B<F?-1:F<B?1:0},a.isEncoding=function(f){switch(String(f).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}},a.concat=function(f,d){if(!Array.isArray(f))throw new TypeError('"list" argument must be an Array of Buffers');if(f.length===0)return a.alloc(0);let B;if(d===void 0)for(d=0,B=0;B<f.length;++B)d+=f[B].length;const F=a.allocUnsafe(d);let $=0;for(B=0;B<f.length;++B){let Y=f[B];if(rr(Y,Uint8Array))$+Y.length>F.length?(a.isBuffer(Y)||(Y=a.from(Y)),Y.copy(F,$)):Uint8Array.prototype.set.call(F,Y,$);else if(a.isBuffer(Y))Y.copy(F,$);else throw new TypeError('"list" argument must be an Array of Buffers');$+=Y.length}return F};function V(m,f){if(a.isBuffer(m))return m.length;if(ArrayBuffer.isView(m)||rr(m,ArrayBuffer))return m.byteLength;if(typeof m!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof m);const d=m.length,B=arguments.length>2&&arguments[2]===!0;if(!B&&d===0)return 0;let F=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return _e(m).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return Ie(m).length;default:if(F)return B?-1:_e(m).length;f=(""+f).toLowerCase(),F=!0}}a.byteLength=V;function it(m,f,d){let B=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((d===void 0||d>this.length)&&(d=this.length),d<=0)||(d>>>=0,f>>>=0,d<=f))return"";for(m||(m="utf8");;)switch(m){case"hex":return A(this,f,d);case"utf8":case"utf-8":return u(this,f,d);case"ascii":return R(this,f,d);case"latin1":case"binary":return I(this,f,d);case"base64":return T(this,f,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,f,d);default:if(B)throw new TypeError("Unknown encoding: "+m);m=(m+"").toLowerCase(),B=!0}}a.prototype._isBuffer=!0;function Z(m,f,d){const B=m[f];m[f]=m[d],m[d]=B}a.prototype.swap16=function(){const f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let d=0;d<f;d+=2)Z(this,d,d+1);return this},a.prototype.swap32=function(){const f=this.length;if(f%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let d=0;d<f;d+=4)Z(this,d,d+3),Z(this,d+1,d+2);return this},a.prototype.swap64=function(){const f=this.length;if(f%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let d=0;d<f;d+=8)Z(this,d,d+7),Z(this,d+1,d+6),Z(this,d+2,d+5),Z(this,d+3,d+4);return this},a.prototype.toString=function(){const f=this.length;return f===0?"":arguments.length===0?u(this,0,f):it.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(f){if(!a.isBuffer(f))throw new TypeError("Argument must be a Buffer");return this===f?!0:a.compare(this,f)===0},a.prototype.inspect=function(){let f="";const d=n.INSPECT_MAX_BYTES;return f=this.toString("hex",0,d).replace(/(.{2})/g,"$1 ").trim(),this.length>d&&(f+=" ... "),"<Buffer "+f+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(f,d,B,F,$){if(rr(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),!a.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(d===void 0&&(d=0),B===void 0&&(B=f?f.length:0),F===void 0&&(F=0),$===void 0&&($=this.length),d<0||B>f.length||F<0||$>this.length)throw new RangeError("out of range index");if(F>=$&&d>=B)return 0;if(F>=$)return-1;if(d>=B)return 1;if(d>>>=0,B>>>=0,F>>>=0,$>>>=0,this===f)return 0;let Y=$-F,Ht=B-d;const zt=Math.min(Y,Ht),Nt=this.slice(F,$),Re=f.slice(d,B);for(let Lt=0;Lt<zt;++Lt)if(Nt[Lt]!==Re[Lt]){Y=Nt[Lt],Ht=Re[Lt];break}return Y<Ht?-1:Ht<Y?1:0};function D(m,f,d,B,F){if(m.length===0)return-1;if(typeof d=="string"?(B=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,ke(d)&&(d=F?0:m.length-1),d<0&&(d=m.length+d),d>=m.length){if(F)return-1;d=m.length-1}else if(d<0)if(F)d=0;else return-1;if(typeof f=="string"&&(f=a.from(f,B)),a.isBuffer(f))return f.length===0?-1:tt(m,f,d,B,F);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?F?Uint8Array.prototype.indexOf.call(m,f,d):Uint8Array.prototype.lastIndexOf.call(m,f,d):tt(m,[f],d,B,F);throw new TypeError("val must be string, number or Buffer")}function tt(m,f,d,B,F){let $=1,Y=m.length,Ht=f.length;if(B!==void 0&&(B=String(B).toLowerCase(),B==="ucs2"||B==="ucs-2"||B==="utf16le"||B==="utf-16le")){if(m.length<2||f.length<2)return-1;$=2,Y/=2,Ht/=2,d/=2}function zt(Re,Lt){return $===1?Re[Lt]:Re.readUInt16BE(Lt*$)}let Nt;if(F){let Re=-1;for(Nt=d;Nt<Y;Nt++)if(zt(m,Nt)===zt(f,Re===-1?0:Nt-Re)){if(Re===-1&&(Re=Nt),Nt-Re+1===Ht)return Re*$}else Re!==-1&&(Nt-=Nt-Re),Re=-1}else for(d+Ht>Y&&(d=Y-Ht),Nt=d;Nt>=0;Nt--){let Re=!0;for(let Lt=0;Lt<Ht;Lt++)if(zt(m,Nt+Lt)!==zt(f,Lt)){Re=!1;break}if(Re)return Nt}return-1}a.prototype.includes=function(f,d,B){return this.indexOf(f,d,B)!==-1},a.prototype.indexOf=function(f,d,B){return D(this,f,d,B,!0)},a.prototype.lastIndexOf=function(f,d,B){return D(this,f,d,B,!1)};function rt(m,f,d,B){d=Number(d)||0;const F=m.length-d;B?(B=Number(B),B>F&&(B=F)):B=F;const $=f.length;B>$/2&&(B=$/2);let Y;for(Y=0;Y<B;++Y){const Ht=parseInt(f.substr(Y*2,2),16);if(ke(Ht))return Y;m[d+Y]=Ht}return Y}function ue(m,f,d,B){return Ae(_e(f,m.length-d),m,d,B)}function jt(m,f,d,B){return Ae(Oe(f),m,d,B)}function kt(m,f,d,B){return Ae(Ie(f),m,d,B)}function ae(m,f,d,B){return Ae(Ar(f,m.length-d),m,d,B)}a.prototype.write=function(f,d,B,F){if(d===void 0)F="utf8",B=this.length,d=0;else if(B===void 0&&typeof d=="string")F=d,B=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(B)?(B=B>>>0,F===void 0&&(F="utf8")):(F=B,B=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const $=this.length-d;if((B===void 0||B>$)&&(B=$),f.length>0&&(B<0||d<0)||d>this.length)throw new RangeError("Attempt to write outside buffer bounds");F||(F="utf8");let Y=!1;for(;;)switch(F){case"hex":return rt(this,f,d,B);case"utf8":case"utf-8":return ue(this,f,d,B);case"ascii":case"latin1":case"binary":return jt(this,f,d,B);case"base64":return kt(this,f,d,B);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ae(this,f,d,B);default:if(Y)throw new TypeError("Unknown encoding: "+F);F=(""+F).toLowerCase(),Y=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(m,f,d){return f===0&&d===m.length?t.fromByteArray(m):t.fromByteArray(m.slice(f,d))}function u(m,f,d){d=Math.min(m.length,d);const B=[];let F=f;for(;F<d;){const $=m[F];let Y=null,Ht=$>239?4:$>223?3:$>191?2:1;if(F+Ht<=d){let zt,Nt,Re,Lt;switch(Ht){case 1:$<128&&(Y=$);break;case 2:zt=m[F+1],(zt&192)===128&&(Lt=($&31)<<6|zt&63,Lt>127&&(Y=Lt));break;case 3:zt=m[F+1],Nt=m[F+2],(zt&192)===128&&(Nt&192)===128&&(Lt=($&15)<<12|(zt&63)<<6|Nt&63,Lt>2047&&(Lt<55296||Lt>57343)&&(Y=Lt));break;case 4:zt=m[F+1],Nt=m[F+2],Re=m[F+3],(zt&192)===128&&(Nt&192)===128&&(Re&192)===128&&(Lt=($&15)<<18|(zt&63)<<12|(Nt&63)<<6|Re&63,Lt>65535&&Lt<1114112&&(Y=Lt))}}Y===null?(Y=65533,Ht=1):Y>65535&&(Y-=65536,B.push(Y>>>10&1023|55296),Y=56320|Y&1023),B.push(Y),F+=Ht}return w(B)}const p=4096;function w(m){const f=m.length;if(f<=p)return String.fromCharCode.apply(String,m);let d="",B=0;for(;B<f;)d+=String.fromCharCode.apply(String,m.slice(B,B+=p));return d}function R(m,f,d){let B="";d=Math.min(m.length,d);for(let F=f;F<d;++F)B+=String.fromCharCode(m[F]&127);return B}function I(m,f,d){let B="";d=Math.min(m.length,d);for(let F=f;F<d;++F)B+=String.fromCharCode(m[F]);return B}function A(m,f,d){const B=m.length;(!f||f<0)&&(f=0),(!d||d<0||d>B)&&(d=B);let F="";for(let $=f;$<d;++$)F+=Se[m[$]];return F}function U(m,f,d){const B=m.slice(f,d);let F="";for(let $=0;$<B.length-1;$+=2)F+=String.fromCharCode(B[$]+B[$+1]*256);return F}a.prototype.slice=function(f,d){const B=this.length;f=~~f,d=d===void 0?B:~~d,f<0?(f+=B,f<0&&(f=0)):f>B&&(f=B),d<0?(d+=B,d<0&&(d=0)):d>B&&(d=B),d<f&&(d=f);const F=this.subarray(f,d);return Object.setPrototypeOf(F,a.prototype),F};function k(m,f,d){if(m%1!==0||m<0)throw new RangeError("offset is not uint");if(m+f>d)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(f,d,B){f=f>>>0,d=d>>>0,B||k(f,d,this.length);let F=this[f],$=1,Y=0;for(;++Y<d&&($*=256);)F+=this[f+Y]*$;return F},a.prototype.readUintBE=a.prototype.readUIntBE=function(f,d,B){f=f>>>0,d=d>>>0,B||k(f,d,this.length);let F=this[f+--d],$=1;for(;d>0&&($*=256);)F+=this[f+--d]*$;return F},a.prototype.readUint8=a.prototype.readUInt8=function(f,d){return f=f>>>0,d||k(f,1,this.length),this[f]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(f,d){return f=f>>>0,d||k(f,2,this.length),this[f]|this[f+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(f,d){return f=f>>>0,d||k(f,2,this.length),this[f]<<8|this[f+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(f,d){return f=f>>>0,d||k(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(f,d){return f=f>>>0,d||k(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},a.prototype.readBigUInt64LE=fr(function(f){f=f>>>0,le(f,"offset");const d=this[f],B=this[f+7];(d===void 0||B===void 0)&&re(f,this.length-8);const F=d+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24,$=this[++f]+this[++f]*2**8+this[++f]*2**16+B*2**24;return BigInt(F)+(BigInt($)<<BigInt(32))}),a.prototype.readBigUInt64BE=fr(function(f){f=f>>>0,le(f,"offset");const d=this[f],B=this[f+7];(d===void 0||B===void 0)&&re(f,this.length-8);const F=d*2**24+this[++f]*2**16+this[++f]*2**8+this[++f],$=this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+B;return(BigInt(F)<<BigInt(32))+BigInt($)}),a.prototype.readIntLE=function(f,d,B){f=f>>>0,d=d>>>0,B||k(f,d,this.length);let F=this[f],$=1,Y=0;for(;++Y<d&&($*=256);)F+=this[f+Y]*$;return $*=128,F>=$&&(F-=Math.pow(2,8*d)),F},a.prototype.readIntBE=function(f,d,B){f=f>>>0,d=d>>>0,B||k(f,d,this.length);let F=d,$=1,Y=this[f+--F];for(;F>0&&($*=256);)Y+=this[f+--F]*$;return $*=128,Y>=$&&(Y-=Math.pow(2,8*d)),Y},a.prototype.readInt8=function(f,d){return f=f>>>0,d||k(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},a.prototype.readInt16LE=function(f,d){f=f>>>0,d||k(f,2,this.length);const B=this[f]|this[f+1]<<8;return B&32768?B|4294901760:B},a.prototype.readInt16BE=function(f,d){f=f>>>0,d||k(f,2,this.length);const B=this[f+1]|this[f]<<8;return B&32768?B|4294901760:B},a.prototype.readInt32LE=function(f,d){return f=f>>>0,d||k(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},a.prototype.readInt32BE=function(f,d){return f=f>>>0,d||k(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},a.prototype.readBigInt64LE=fr(function(f){f=f>>>0,le(f,"offset");const d=this[f],B=this[f+7];(d===void 0||B===void 0)&&re(f,this.length-8);const F=this[f+4]+this[f+5]*2**8+this[f+6]*2**16+(B<<24);return(BigInt(F)<<BigInt(32))+BigInt(d+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24)}),a.prototype.readBigInt64BE=fr(function(f){f=f>>>0,le(f,"offset");const d=this[f],B=this[f+7];(d===void 0||B===void 0)&&re(f,this.length-8);const F=(d<<24)+this[++f]*2**16+this[++f]*2**8+this[++f];return(BigInt(F)<<BigInt(32))+BigInt(this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+B)}),a.prototype.readFloatLE=function(f,d){return f=f>>>0,d||k(f,4,this.length),e.read(this,f,!0,23,4)},a.prototype.readFloatBE=function(f,d){return f=f>>>0,d||k(f,4,this.length),e.read(this,f,!1,23,4)},a.prototype.readDoubleLE=function(f,d){return f=f>>>0,d||k(f,8,this.length),e.read(this,f,!0,52,8)},a.prototype.readDoubleBE=function(f,d){return f=f>>>0,d||k(f,8,this.length),e.read(this,f,!1,52,8)};function h(m,f,d,B,F,$){if(!a.isBuffer(m))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>F||f<$)throw new RangeError('"value" argument is out of bounds');if(d+B>m.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(f,d,B,F){if(f=+f,d=d>>>0,B=B>>>0,!F){const Ht=Math.pow(2,8*B)-1;h(this,f,d,B,Ht,0)}let $=1,Y=0;for(this[d]=f&255;++Y<B&&($*=256);)this[d+Y]=f/$&255;return d+B},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(f,d,B,F){if(f=+f,d=d>>>0,B=B>>>0,!F){const Ht=Math.pow(2,8*B)-1;h(this,f,d,B,Ht,0)}let $=B-1,Y=1;for(this[d+$]=f&255;--$>=0&&(Y*=256);)this[d+$]=f/Y&255;return d+B},a.prototype.writeUint8=a.prototype.writeUInt8=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,1,255,0),this[d]=f&255,d+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,2,65535,0),this[d]=f&255,this[d+1]=f>>>8,d+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,2,65535,0),this[d]=f>>>8,this[d+1]=f&255,d+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,4,4294967295,0),this[d+3]=f>>>24,this[d+2]=f>>>16,this[d+1]=f>>>8,this[d]=f&255,d+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,4,4294967295,0),this[d]=f>>>24,this[d+1]=f>>>16,this[d+2]=f>>>8,this[d+3]=f&255,d+4};function E(m,f,d,B,F){Gt(f,B,F,m,d,7);let $=Number(f&BigInt(4294967295));m[d++]=$,$=$>>8,m[d++]=$,$=$>>8,m[d++]=$,$=$>>8,m[d++]=$;let Y=Number(f>>BigInt(32)&BigInt(4294967295));return m[d++]=Y,Y=Y>>8,m[d++]=Y,Y=Y>>8,m[d++]=Y,Y=Y>>8,m[d++]=Y,d}function at(m,f,d,B,F){Gt(f,B,F,m,d,7);let $=Number(f&BigInt(4294967295));m[d+7]=$,$=$>>8,m[d+6]=$,$=$>>8,m[d+5]=$,$=$>>8,m[d+4]=$;let Y=Number(f>>BigInt(32)&BigInt(4294967295));return m[d+3]=Y,Y=Y>>8,m[d+2]=Y,Y=Y>>8,m[d+1]=Y,Y=Y>>8,m[d]=Y,d+8}a.prototype.writeBigUInt64LE=fr(function(f,d=0){return E(this,f,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=fr(function(f,d=0){return at(this,f,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(f,d,B,F){if(f=+f,d=d>>>0,!F){const zt=Math.pow(2,8*B-1);h(this,f,d,B,zt-1,-zt)}let $=0,Y=1,Ht=0;for(this[d]=f&255;++$<B&&(Y*=256);)f<0&&Ht===0&&this[d+$-1]!==0&&(Ht=1),this[d+$]=(f/Y>>0)-Ht&255;return d+B},a.prototype.writeIntBE=function(f,d,B,F){if(f=+f,d=d>>>0,!F){const zt=Math.pow(2,8*B-1);h(this,f,d,B,zt-1,-zt)}let $=B-1,Y=1,Ht=0;for(this[d+$]=f&255;--$>=0&&(Y*=256);)f<0&&Ht===0&&this[d+$+1]!==0&&(Ht=1),this[d+$]=(f/Y>>0)-Ht&255;return d+B},a.prototype.writeInt8=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,1,127,-128),f<0&&(f=255+f+1),this[d]=f&255,d+1},a.prototype.writeInt16LE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,2,32767,-32768),this[d]=f&255,this[d+1]=f>>>8,d+2},a.prototype.writeInt16BE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,2,32767,-32768),this[d]=f>>>8,this[d+1]=f&255,d+2},a.prototype.writeInt32LE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,4,2147483647,-2147483648),this[d]=f&255,this[d+1]=f>>>8,this[d+2]=f>>>16,this[d+3]=f>>>24,d+4},a.prototype.writeInt32BE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[d]=f>>>24,this[d+1]=f>>>16,this[d+2]=f>>>8,this[d+3]=f&255,d+4},a.prototype.writeBigInt64LE=fr(function(f,d=0){return E(this,f,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=fr(function(f,d=0){return at(this,f,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Q(m,f,d,B,F,$){if(d+B>m.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function ct(m,f,d,B,F){return f=+f,d=d>>>0,F||Q(m,f,d,4),e.write(m,f,d,B,23,4),d+4}a.prototype.writeFloatLE=function(f,d,B){return ct(this,f,d,!0,B)},a.prototype.writeFloatBE=function(f,d,B){return ct(this,f,d,!1,B)};function Mt(m,f,d,B,F){return f=+f,d=d>>>0,F||Q(m,f,d,8),e.write(m,f,d,B,52,8),d+8}a.prototype.writeDoubleLE=function(f,d,B){return Mt(this,f,d,!0,B)},a.prototype.writeDoubleBE=function(f,d,B){return Mt(this,f,d,!1,B)},a.prototype.copy=function(f,d,B,F){if(!a.isBuffer(f))throw new TypeError("argument should be a Buffer");if(B||(B=0),!F&&F!==0&&(F=this.length),d>=f.length&&(d=f.length),d||(d=0),F>0&&F<B&&(F=B),F===B||f.length===0||this.length===0)return 0;if(d<0)throw new RangeError("targetStart out of bounds");if(B<0||B>=this.length)throw new RangeError("Index out of range");if(F<0)throw new RangeError("sourceEnd out of bounds");F>this.length&&(F=this.length),f.length-d<F-B&&(F=f.length-d+B);const $=F-B;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(d,B,F):Uint8Array.prototype.set.call(f,this.subarray(B,F),d),$},a.prototype.fill=function(f,d,B,F){if(typeof f=="string"){if(typeof d=="string"?(F=d,d=0,B=this.length):typeof B=="string"&&(F=B,B=this.length),F!==void 0&&typeof F!="string")throw new TypeError("encoding must be a string");if(typeof F=="string"&&!a.isEncoding(F))throw new TypeError("Unknown encoding: "+F);if(f.length===1){const Y=f.charCodeAt(0);(F==="utf8"&&Y<128||F==="latin1")&&(f=Y)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(d<0||this.length<d||this.length<B)throw new RangeError("Out of range index");if(B<=d)return this;d=d>>>0,B=B===void 0?this.length:B>>>0,f||(f=0);let $;if(typeof f=="number")for($=d;$<B;++$)this[$]=f;else{const Y=a.isBuffer(f)?f:a.from(f,F),Ht=Y.length;if(Ht===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for($=0;$<B-d;++$)this[$+d]=Y[$%Ht]}return this};const Tt={};function Pt(m,f,d){Tt[m]=class extends d{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${m}]`,this.stack,delete this.name}get code(){return m}set code(F){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:F,writable:!0})}toString(){return`${this.name} [${m}]: ${this.message}`}}}Pt("ERR_BUFFER_OUT_OF_BOUNDS",function(m){return m?`${m} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Pt("ERR_INVALID_ARG_TYPE",function(m,f){return`The "${m}" argument must be of type number. Received type ${typeof f}`},TypeError),Pt("ERR_OUT_OF_RANGE",function(m,f,d){let B=`The value of "${m}" is out of range.`,F=d;return Number.isInteger(d)&&Math.abs(d)>2**32?F=Ce(String(d)):typeof d=="bigint"&&(F=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(F=Ce(F)),F+="n"),B+=` It must be ${f}. Received ${F}`,B},RangeError);function Ce(m){let f="",d=m.length;const B=m[0]==="-"?1:0;for(;d>=B+4;d-=3)f=`_${m.slice(d-3,d)}${f}`;return`${m.slice(0,d)}${f}`}function Yt(m,f,d){le(f,"offset"),(m[f]===void 0||m[f+d]===void 0)&&re(f,m.length-(d+1))}function Gt(m,f,d,B,F,$){if(m>d||m<f){const Y=typeof f=="bigint"?"n":"";let Ht;throw f===0||f===BigInt(0)?Ht=`>= 0${Y} and < 2${Y} ** ${($+1)*8}${Y}`:Ht=`>= -(2${Y} ** ${($+1)*8-1}${Y}) and < 2 ** ${($+1)*8-1}${Y}`,new Tt.ERR_OUT_OF_RANGE("value",Ht,m)}Yt(B,F,$)}function le(m,f){if(typeof m!="number")throw new Tt.ERR_INVALID_ARG_TYPE(f,"number",m)}function re(m,f,d){throw Math.floor(m)!==m?(le(m,d),new Tt.ERR_OUT_OF_RANGE("offset","an integer",m)):f<0?new Tt.ERR_BUFFER_OUT_OF_BOUNDS:new Tt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${f}`,m)}const ve=/[^+/0-9A-Za-z-_]/g;function Or(m){if(m=m.split("=")[0],m=m.trim().replace(ve,""),m.length<2)return"";for(;m.length%4!==0;)m=m+"=";return m}function _e(m,f){f=f||1/0;let d;const B=m.length;let F=null;const $=[];for(let Y=0;Y<B;++Y){if(d=m.charCodeAt(Y),d>55295&&d<57344){if(!F){if(d>56319){(f-=3)>-1&&$.push(239,191,189);continue}else if(Y+1===B){(f-=3)>-1&&$.push(239,191,189);continue}F=d;continue}if(d<56320){(f-=3)>-1&&$.push(239,191,189),F=d;continue}d=(F-55296<<10|d-56320)+65536}else F&&(f-=3)>-1&&$.push(239,191,189);if(F=null,d<128){if((f-=1)<0)break;$.push(d)}else if(d<2048){if((f-=2)<0)break;$.push(d>>6|192,d&63|128)}else if(d<65536){if((f-=3)<0)break;$.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((f-=4)<0)break;$.push(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}else throw new Error("Invalid code point")}return $}function Oe(m){const f=[];for(let d=0;d<m.length;++d)f.push(m.charCodeAt(d)&255);return f}function Ar(m,f){let d,B,F;const $=[];for(let Y=0;Y<m.length&&!((f-=2)<0);++Y)d=m.charCodeAt(Y),B=d>>8,F=d%256,$.push(F),$.push(B);return $}function Ie(m){return t.toByteArray(Or(m))}function Ae(m,f,d,B){let F;for(F=0;F<B&&!(F+d>=f.length||F>=m.length);++F)f[F+d]=m[F];return F}function rr(m,f){return m instanceof f||m!=null&&m.constructor!=null&&m.constructor.name!=null&&m.constructor.name===f.name}function ke(m){return m!==m}const Se=function(){const m="0123456789abcdef",f=new Array(256);for(let d=0;d<16;++d){const B=d*16;for(let F=0;F<16;++F)f[B+F]=m[d]+m[F]}return f}();function fr(m){return typeof BigInt>"u"?Be:m}function Be(){throw new Error("BigInt not supported")}})(Ct);function _i(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`positive integer expected, not ${n}`)}function au(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function ii(n,...t){if(!au(n))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(n.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${n.length}`)}function cu(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");_i(n.outputLen),_i(n.blockLen)}function Fn(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function Mo(n,t){ii(n);const e=t.outputLen;if(n.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}const hs=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const uu=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),ds=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Hr=(n,t)=>n<<32-t|n>>>t,Po=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,fu=n=>n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255;function Co(n){for(let t=0;t<n.length;t++)n[t]=fu(n[t])}function lu(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Ii(n){return typeof n=="string"&&(n=lu(n)),ii(n),n}function hu(...n){let t=0;for(let r=0;r<n.length;r++){const s=n[r];ii(s),t+=s.length}const e=new Uint8Array(t);for(let r=0,s=0;r<n.length;r++){const i=n[r];e.set(i,s),s+=i.length}return e}class ps{clone(){return this._cloneInto()}}function gs(n){const t=r=>n().update(Ii(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function Lo(n=32){if(hs&&typeof hs.getRandomValues=="function")return hs.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}function du(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(e>>s&i),a=Number(e&i),l=r?4:0,y=r?0:4;n.setUint32(t+l,o,r),n.setUint32(t+y,a,r)}const pu=(n,t,e)=>n&t^~n&e,gu=(n,t,e)=>n&t^n&e^t&e;class Uo extends ps{constructor(t,e,r,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ds(this.buffer)}update(t){Fn(this);const{view:e,buffer:r,blockLen:s}=this;t=Ii(t);const i=t.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const l=ds(t);for(;s<=i-o;o+=s)this.process(l,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Fn(this),Mo(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let _=o;_<s;_++)e[_]=0;du(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=ds(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const y=l/4,x=this.get();if(y>x.length)throw new Error("_sha2: outputLen bigger than state");for(let _=0;_<y;_++)a.setUint32(4*_,x[_],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return t.length=s,t.pos=a,t.finished=i,t.destroyed=o,s%e&&t.buffer.set(r),t}}const Ai=BigInt(2**32-1),ys=BigInt(32);function Oo(n,t=!1){return t?{h:Number(n&Ai),l:Number(n>>ys&Ai)}:{h:Number(n>>ys&Ai)|0,l:Number(n&Ai)|0}}function No(n,t=!1){let e=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=Oo(n[s],t);[e[s],r[s]]=[i,o]}return[e,r]}const yu=(n,t)=>BigInt(n>>>0)<<ys|BigInt(t>>>0),mu=(n,t,e)=>n>>>e,wu=(n,t,e)=>n<<32-e|t>>>e,bu=(n,t,e)=>n>>>e|t<<32-e,xu=(n,t,e)=>n<<32-e|t>>>e,vu=(n,t,e)=>n<<64-e|t>>>e-32,ku=(n,t,e)=>n>>>e-32|t<<64-e,Su=(n,t)=>t,Eu=(n,t)=>n,Fo=(n,t,e)=>n<<e|t>>>32-e,zo=(n,t,e)=>t<<e|n>>>32-e,Ko=(n,t,e)=>t<<e-32|n>>>64-e,Wo=(n,t,e)=>n<<e-32|t>>>64-e;function _u(n,t,e,r){const s=(t>>>0)+(r>>>0);return{h:n+e+(s/2**32|0)|0,l:s|0}}const Qt={fromBig:Oo,split:No,toBig:yu,shrSH:mu,shrSL:wu,rotrSH:bu,rotrSL:xu,rotrBH:vu,rotrBL:ku,rotr32H:Su,rotr32L:Eu,rotlSH:Fo,rotlSL:zo,rotlBH:Ko,rotlBL:Wo,add:_u,add3L:(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),add3H:(n,t,e,r)=>t+e+r+(n/2**32|0)|0,add4L:(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),add4H:(n,t,e,r,s)=>t+e+r+s+(n/2**32|0)|0,add5H:(n,t,e,r,s,i)=>t+e+r+s+i+(n/2**32|0)|0,add5L:(n,t,e,r,s)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(s>>>0)},[Iu,Au]=Qt.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(n=>BigInt(n))),un=new Uint32Array(80),fn=new Uint32Array(80);class Bu extends Uo{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:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:l,Eh:y,El:x,Fh:_,Fl:L,Gh:C,Gl:N,Hh:M,Hl:O}=this;return[t,e,r,s,i,o,a,l,y,x,_,L,C,N,M,O]}set(t,e,r,s,i,o,a,l,y,x,_,L,C,N,M,O){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=l|0,this.Eh=y|0,this.El=x|0,this.Fh=_|0,this.Fl=L|0,this.Gh=C|0,this.Gl=N|0,this.Hh=M|0,this.Hl=O|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,Z=fn[V-15]|0,D=Qt.rotrSH(it,Z,1)^Qt.rotrSH(it,Z,8)^Qt.shrSH(it,Z,7),tt=Qt.rotrSL(it,Z,1)^Qt.rotrSL(it,Z,8)^Qt.shrSL(it,Z,7),rt=un[V-2]|0,ue=fn[V-2]|0,jt=Qt.rotrSH(rt,ue,19)^Qt.rotrBH(rt,ue,61)^Qt.shrSH(rt,ue,6),kt=Qt.rotrSL(rt,ue,19)^Qt.rotrBL(rt,ue,61)^Qt.shrSL(rt,ue,6),ae=Qt.add4L(tt,kt,fn[V-7],fn[V-16]),T=Qt.add4H(ae,D,jt,un[V-7],un[V-16]);un[V]=T|0,fn[V]=ae|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:l,Dh:y,Dl:x,Eh:_,El:L,Fh:C,Fl:N,Gh:M,Gl:O,Hh:K,Hl:X}=this;for(let V=0;V<80;V++){const it=Qt.rotrSH(_,L,14)^Qt.rotrSH(_,L,18)^Qt.rotrBH(_,L,41),Z=Qt.rotrSL(_,L,14)^Qt.rotrSL(_,L,18)^Qt.rotrBL(_,L,41),D=_&C^~_&M,tt=L&N^~L&O,rt=Qt.add5L(X,Z,tt,Au[V],fn[V]),ue=Qt.add5H(rt,K,it,D,Iu[V],un[V]),jt=rt|0,kt=Qt.rotrSH(r,s,28)^Qt.rotrBH(r,s,34)^Qt.rotrBH(r,s,39),ae=Qt.rotrSL(r,s,28)^Qt.rotrBL(r,s,34)^Qt.rotrBL(r,s,39),T=r&i^r&a^i&a,u=s&o^s&l^o&l;K=M|0,X=O|0,M=C|0,O=N|0,C=_|0,N=L|0,{h:_,l:L}=Qt.add(y|0,x|0,ue|0,jt|0),y=a|0,x=l|0,a=i|0,l=o|0,i=r|0,o=s|0;const p=Qt.add3L(jt,ae,u);r=Qt.add3H(p,ue,kt,T),s=p|0}({h:r,l:s}=Qt.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=Qt.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l}=Qt.add(this.Ch|0,this.Cl|0,a|0,l|0),{h:y,l:x}=Qt.add(this.Dh|0,this.Dl|0,y|0,x|0),{h:_,l:L}=Qt.add(this.Eh|0,this.El|0,_|0,L|0),{h:C,l:N}=Qt.add(this.Fh|0,this.Fl|0,C|0,N|0),{h:M,l:O}=Qt.add(this.Gh|0,this.Gl|0,M|0,O|0),{h:K,l:X}=Qt.add(this.Hh|0,this.Hl|0,K|0,X|0),this.set(r,s,i,o,a,l,y,x,_,L,C,N,M,O,K,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 Ru=gs(()=>new Bu);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Do=BigInt(0),Bi=BigInt(1),Tu=BigInt(2);function bn(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function si(n){if(!bn(n))throw new Error("Uint8Array expected")}const Mu=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function xn(n){si(n);let t="";for(let e=0;e<n.length;e++)t+=Mu[n[e]];return t}function $o(n){const t=n.toString(16);return t.length&1?`0${t}`:t}function ms(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}const rn={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function qo(n){if(n>=rn._0&&n<=rn._9)return n-rn._0;if(n>=rn._A&&n<=rn._F)return n-(rn._A-10);if(n>=rn._a&&n<=rn._f)return n-(rn._a-10)}function zn(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const t=n.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(e);for(let s=0,i=0;s<e;s++,i+=2){const o=qo(n.charCodeAt(i)),a=qo(n.charCodeAt(i+1));if(o===void 0||a===void 0){const l=n[i]+n[i+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+i)}r[s]=o*16+a}return r}function vn(n){return ms(xn(n))}function Kn(n){return si(n),ms(xn(Uint8Array.from(n).reverse()))}function Wn(n,t){return zn(n.toString(16).padStart(t*2,"0"))}function oi(n,t){return Wn(n,t).reverse()}function Pu(n){return zn($o(n))}function ir(n,t,e){let r;if(typeof t=="string")try{r=zn(t)}catch(i){throw new Error(`${n} must be valid hex string, got "${t}". Cause: ${i}`)}else if(bn(t))r=Uint8Array.from(t);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof e=="number"&&s!==e)throw new Error(`${n} expected ${e} bytes, got ${s}`);return r}function kn(...n){let t=0;for(let r=0;r<n.length;r++){const s=n[r];si(s),t+=s.length}const e=new Uint8Array(t);for(let r=0,s=0;r<n.length;r++){const i=n[r];e.set(i,s),s+=i.length}return e}function Cu(n,t){if(n.length!==t.length)return!1;let e=0;for(let r=0;r<n.length;r++)e|=n[r]^t[r];return e===0}function Lu(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Uu(n){let t;for(t=0;n>Do;n>>=Bi,t+=1);return t}function Ou(n,t){return n>>BigInt(t)&Bi}function Nu(n,t,e){return n|(e?Bi:Do)<<BigInt(t)}const ws=n=>(Tu<<BigInt(n-1))-Bi,bs=n=>new Uint8Array(n),Ho=n=>Uint8Array.from(n);function Vo(n,t,e){if(typeof n!="number"||n<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 r=bs(n),s=bs(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(..._)=>e(s,r,..._),l=(_=bs())=>{s=a(Ho([0]),_),r=a(),_.length!==0&&(s=a(Ho([1]),_),r=a())},y=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let _=0;const L=[];for(;_<t;){r=a();const C=r.slice();L.push(C),_+=r.length}return kn(...L)};return(_,L)=>{o(),l(_);let C;for(;!(C=L(y()));)l();return o(),C}}const Fu={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||bn(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,t)=>t.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function Dn(n,t,e={}){const r=(s,i,o)=>{const a=Fu[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const l=n[s];if(!(o&&l===void 0)&&!a(l,n))throw new Error(`Invalid param ${String(s)}=${l} (${typeof l}), expected ${i}`)};for(const[s,i]of Object.entries(t))r(s,i,!1);for(const[s,i]of Object.entries(e))r(s,i,!0);return n}const zu=Object.freeze(Object.defineProperty({__proto__:null,abytes:si,bitGet:Ou,bitLen:Uu,bitMask:ws,bitSet:Nu,bytesToHex:xn,bytesToNumberBE:vn,bytesToNumberLE:Kn,concatBytes:kn,createHmacDrbg:Vo,ensureBytes:ir,equalBytes:Cu,hexToBytes:zn,hexToNumber:ms,isBytes:bn,numberToBytesBE:Wn,numberToBytesLE:oi,numberToHexUnpadded:$o,numberToVarBytesBE:Pu,utf8ToBytes:Lu,validateObject:Dn},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const or=BigInt(0),qe=BigInt(1),Sn=BigInt(2),Ku=BigInt(3),xs=BigInt(4),jo=BigInt(5),Go=BigInt(8);BigInt(9),BigInt(16);function We(n,t){const e=n%t;return e>=or?e:t+e}function Wu(n,t,e){if(e<=or||t<or)throw new Error("Expected power/modulo > 0");if(e===qe)return or;let r=qe;for(;t>or;)t&qe&&(r=r*n%e),n=n*n%e,t>>=qe;return r}function Ge(n,t,e){let r=n;for(;t-- >or;)r*=r,r%=e;return r}function vs(n,t){if(n===or||t<=or)throw new Error(`invert: expected positive integers, got n=${n} mod=${t}`);let e=We(n,t),r=t,s=or,i=qe;for(;e!==or;){const a=r/e,l=r%e,y=s-i*a;r=e,e=l,s=i,i=y}if(r!==qe)throw new Error("invert: does not exist");return We(s,t)}function Du(n){const t=(n-qe)/Sn;let e,r,s;for(e=n-qe,r=0;e%Sn===or;e/=Sn,r++);for(s=Sn;s<n&&Wu(s,t,n)!==n-qe;s++);if(r===1){const o=(n+qe)/xs;return function(l,y){const x=l.pow(y,o);if(!l.eql(l.sqr(x),y))throw new Error("Cannot find square root");return x}}const i=(e+qe)/Sn;return function(a,l){if(a.pow(l,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let y=r,x=a.pow(a.mul(a.ONE,s),e),_=a.pow(l,i),L=a.pow(l,e);for(;!a.eql(L,a.ONE);){if(a.eql(L,a.ZERO))return a.ZERO;let C=1;for(let M=a.sqr(L);C<y&&!a.eql(M,a.ONE);C++)M=a.sqr(M);const N=a.pow(x,qe<<BigInt(y-C-1));x=a.sqr(N),_=a.mul(_,N),L=a.mul(L,x),y=C}return _}}function $u(n){if(n%xs===Ku){const t=(n+qe)/xs;return function(r,s){const i=r.pow(s,t);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%Go===jo){const t=(n-jo)/Go;return function(r,s){const i=r.mul(s,Sn),o=r.pow(i,t),a=r.mul(s,o),l=r.mul(r.mul(a,Sn),o),y=r.mul(a,r.sub(l,r.ONE));if(!r.eql(r.sqr(y),s))throw new Error("Cannot find square root");return y}}return Du(n)}const qu=(n,t)=>(We(n,t)&qe)===qe,Hu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Vu(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Hu.reduce((r,s)=>(r[s]="function",r),t);return Dn(n,e)}function ju(n,t,e){if(e<or)throw new Error("Expected power > 0");if(e===or)return n.ONE;if(e===qe)return t;let r=n.ONE,s=t;for(;e>or;)e&qe&&(r=n.mul(r,s)),s=n.sqr(s),e>>=qe;return r}function Gu(n,t){const e=new Array(t.length),r=t.reduce((i,o,a)=>n.is0(o)?i:(e[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return t.reduceRight((i,o,a)=>n.is0(o)?i:(e[a]=n.mul(i,e[a]),n.mul(i,o)),s),e}function Yo(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function Zo(n,t,e=!1,r={}){if(n<=or)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=Yo(n,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=$u(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:ws(s),ZERO:or,ONE:qe,create:l=>We(l,n),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return or<=l&&l<n},is0:l=>l===or,isOdd:l=>(l&qe)===qe,neg:l=>We(-l,n),eql:(l,y)=>l===y,sqr:l=>We(l*l,n),add:(l,y)=>We(l+y,n),sub:(l,y)=>We(l-y,n),mul:(l,y)=>We(l*y,n),pow:(l,y)=>ju(a,l,y),div:(l,y)=>We(l*vs(y,n),n),sqrN:l=>l*l,addN:(l,y)=>l+y,subN:(l,y)=>l-y,mulN:(l,y)=>l*y,inv:l=>vs(l,n),sqrt:r.sqrt||(l=>o(a,l)),invertBatch:l=>Gu(a,l),cmov:(l,y,x)=>x?y:l,toBytes:l=>e?oi(l,i):Wn(l,i),fromBytes:l=>{if(l.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${l.length}`);return e?Kn(l):vn(l)}});return Object.freeze(a)}function Jo(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const t=n.toString(2).length;return Math.ceil(t/8)}function Xo(n){const t=Jo(n);return t+Math.ceil(t/2)}function Yu(n,t,e=!1){const r=n.length,s=Jo(t),i=Xo(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=e?vn(n):Kn(n),a=We(o,t-qe)+qe;return e?oi(a,s):Wn(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Zu=BigInt(0),ks=BigInt(1);function Qo(n,t){const e=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(t/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:e,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>Zu;)i&ks&&(o=o.add(a)),a=a.double(),i>>=ks;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),l=[];let y=s,x=y;for(let _=0;_<o;_++){x=y,l.push(x);for(let L=1;L<a;L++)x=x.add(y),l.push(x);y=x.double()}return l},wNAF(s,i,o){const{windows:a,windowSize:l}=r(s);let y=n.ZERO,x=n.BASE;const _=BigInt(2**s-1),L=2**s,C=BigInt(s);for(let N=0;N<a;N++){const M=N*l;let O=Number(o&_);o>>=C,O>l&&(O-=L,o+=ks);const K=M,X=M+Math.abs(O)-1,V=N%2!==0,it=O<0;O===0?x=x.add(e(V,i[K])):y=y.add(e(it,i[X]))}return{p:y,f:x}},wNAFCached(s,i,o,a){const l=s._WINDOW_SIZE||1;let y=i.get(s);return y||(y=this.precomputeWindow(s,l),l!==1&&i.set(s,a(y))),this.wNAF(l,y,o)}}}function Ss(n){return Vu(n.Fp),Dn(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Yo(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fr=BigInt(0),Br=BigInt(1),Ri=BigInt(2),Ju=BigInt(8),Xu={zip215:!0};function Qu(n){const t=Ss(n);return Dn(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function tf(n){const t=Qu(n),{Fp:e,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:l}=t,y=Ri<<BigInt(a*8)-Br,x=e.create,_=t.uvRatio||((I,A)=>{try{return{isValid:!0,value:e.sqrt(I*e.inv(A))}}catch{return{isValid:!1,value:Fr}}}),L=t.adjustScalarBytes||(I=>I),C=t.domain||((I,A,U)=>{if(A.length||U)throw new Error("Contexts/pre-hash are not supported");return I}),N=I=>typeof I=="bigint"&&Fr<I,M=(I,A)=>N(I)&&N(A)&&I<A,O=I=>I===Fr||M(I,y);function K(I,A){if(M(I,A))return I;throw new Error(`Expected valid scalar < ${A}, got ${typeof I} ${I}`)}function X(I){return I===Fr?I:K(I,r)}const V=new Map;function it(I){if(!(I instanceof Z))throw new Error("ExtendedPoint expected")}class Z{constructor(A,U,k,h){if(this.ex=A,this.ey=U,this.ez=k,this.et=h,!O(A))throw new Error("x required");if(!O(U))throw new Error("y required");if(!O(k))throw new Error("z required");if(!O(h))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(A){if(A instanceof Z)throw new Error("extended point not allowed");const{x:U,y:k}=A||{};if(!O(U)||!O(k))throw new Error("invalid affine point");return new Z(U,k,Br,x(U*k))}static normalizeZ(A){const U=e.invertBatch(A.map(k=>k.ez));return A.map((k,h)=>k.toAffine(U[h])).map(Z.fromAffine)}_setWindowSize(A){this._WINDOW_SIZE=A,V.delete(this)}assertValidity(){const{a:A,d:U}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:k,ey:h,ez:E,et:at}=this,Q=x(k*k),ct=x(h*h),Mt=x(E*E),Tt=x(Mt*Mt),Pt=x(Q*A),Ce=x(Mt*x(Pt+ct)),Yt=x(Tt+x(U*x(Q*ct)));if(Ce!==Yt)throw new Error("bad point: equation left != right (1)");const Gt=x(k*h),le=x(E*at);if(Gt!==le)throw new Error("bad point: equation left != right (2)")}equals(A){it(A);const{ex:U,ey:k,ez:h}=this,{ex:E,ey:at,ez:Q}=A,ct=x(U*Q),Mt=x(E*h),Tt=x(k*Q),Pt=x(at*h);return ct===Mt&&Tt===Pt}is0(){return this.equals(Z.ZERO)}negate(){return new Z(x(-this.ex),this.ey,this.ez,x(-this.et))}double(){const{a:A}=t,{ex:U,ey:k,ez:h}=this,E=x(U*U),at=x(k*k),Q=x(Ri*x(h*h)),ct=x(A*E),Mt=U+k,Tt=x(x(Mt*Mt)-E-at),Pt=ct+at,Ce=Pt-Q,Yt=ct-at,Gt=x(Tt*Ce),le=x(Pt*Yt),re=x(Tt*Yt),ve=x(Ce*Pt);return new Z(Gt,le,ve,re)}add(A){it(A);const{a:U,d:k}=t,{ex:h,ey:E,ez:at,et:Q}=this,{ex:ct,ey:Mt,ez:Tt,et:Pt}=A;if(U===BigInt(-1)){const rr=x((E-h)*(Mt+ct)),ke=x((E+h)*(Mt-ct)),Se=x(ke-rr);if(Se===Fr)return this.double();const fr=x(at*Ri*Pt),Be=x(Q*Ri*Tt),m=Be+fr,f=ke+rr,d=Be-fr,B=x(m*Se),F=x(f*d),$=x(m*d),Y=x(Se*f);return new Z(B,F,Y,$)}const Ce=x(h*ct),Yt=x(E*Mt),Gt=x(Q*k*Pt),le=x(at*Tt),re=x((h+E)*(ct+Mt)-Ce-Yt),ve=le-Gt,Or=le+Gt,_e=x(Yt-U*Ce),Oe=x(re*ve),Ar=x(Or*_e),Ie=x(re*_e),Ae=x(ve*Or);return new Z(Oe,Ar,Ae,Ie)}subtract(A){return this.add(A.negate())}wNAF(A){return rt.wNAFCached(this,V,A,Z.normalizeZ)}multiply(A){const{p:U,f:k}=this.wNAF(K(A,r));return Z.normalizeZ([U,k])[0]}multiplyUnsafe(A){let U=X(A);return U===Fr?tt:this.equals(tt)||U===Br?this:this.equals(D)?this.wNAF(U).p:rt.unsafeLadder(this,U)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return rt.unsafeLadder(this,r).is0()}toAffine(A){const{ex:U,ey:k,ez:h}=this,E=this.is0();A==null&&(A=E?Ju:e.inv(h));const at=x(U*A),Q=x(k*A),ct=x(h*A);if(E)return{x:Fr,y:Br};if(ct!==Br)throw new Error("invZ was invalid");return{x:at,y:Q}}clearCofactor(){const{h:A}=t;return A===Br?this:this.multiplyUnsafe(A)}static fromHex(A,U=!1){const{d:k,a:h}=t,E=e.BYTES;A=ir("pointHex",A,E);const at=A.slice(),Q=A[E-1];at[E-1]=Q&-129;const ct=Kn(at);ct===Fr||(U?K(ct,y):K(ct,e.ORDER));const Mt=x(ct*ct),Tt=x(Mt-Br),Pt=x(k*Mt-h);let{isValid:Ce,value:Yt}=_(Tt,Pt);if(!Ce)throw new Error("Point.fromHex: invalid y coordinate");const Gt=(Yt&Br)===Br,le=(Q&128)!==0;if(!U&&Yt===Fr&&le)throw new Error("Point.fromHex: x=0 and x_0=1");return le!==Gt&&(Yt=x(-Yt)),Z.fromAffine({x:Yt,y:ct})}static fromPrivateKey(A){return kt(A).point}toRawBytes(){const{x:A,y:U}=this.toAffine(),k=oi(U,e.BYTES);return k[k.length-1]|=A&Br?128:0,k}toHex(){return xn(this.toRawBytes())}}Z.BASE=new Z(t.Gx,t.Gy,Br,x(t.Gx*t.Gy)),Z.ZERO=new Z(Fr,Br,Br,Fr);const{BASE:D,ZERO:tt}=Z,rt=Qo(Z,a*8);function ue(I){return We(I,r)}function jt(I){return ue(Kn(I))}function kt(I){const A=a;I=ir("private key",I,A);const U=ir("hashed private key",i(I),2*A),k=L(U.slice(0,A)),h=U.slice(A,2*A),E=jt(k),at=D.multiply(E),Q=at.toRawBytes();return{head:k,prefix:h,scalar:E,point:at,pointBytes:Q}}function ae(I){return kt(I).pointBytes}function T(I=new Uint8Array,...A){const U=kn(...A);return jt(i(C(U,ir("context",I),!!s)))}function u(I,A,U={}){I=ir("message",I),s&&(I=s(I));const{prefix:k,scalar:h,pointBytes:E}=kt(A),at=T(U.context,k,I),Q=D.multiply(at).toRawBytes(),ct=T(U.context,Q,E,I),Mt=ue(at+ct*h);X(Mt);const Tt=kn(Q,oi(Mt,e.BYTES));return ir("result",Tt,a*2)}const p=Xu;function w(I,A,U,k=p){const{context:h,zip215:E}=k,at=e.BYTES;I=ir("signature",I,2*at),A=ir("message",A),s&&(A=s(A));const Q=Kn(I.slice(at,2*at));let ct,Mt,Tt;try{ct=Z.fromHex(U,E),Mt=Z.fromHex(I.slice(0,at),E),Tt=D.multiplyUnsafe(Q)}catch{return!1}if(!E&&ct.isSmallOrder())return!1;const Pt=T(h,Mt.toRawBytes(),ct.toRawBytes(),A);return Mt.add(ct.multiplyUnsafe(Pt)).subtract(Tt).clearCofactor().equals(Z.ZERO)}return D._setWindowSize(8),{CURVE:t,getPublicKey:ae,sign:u,verify:w,ExtendedPoint:Z,utils:{getExtendedPublicKey:kt,randomPrivateKey:()=>o(e.BYTES),precompute(I=8,A=Z.BASE){return A._setWindowSize(I),A.multiply(BigInt(3)),A}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Es=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ta=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const ef=BigInt(1),ea=BigInt(2);BigInt(3);const rf=BigInt(5),nf=BigInt(8);function sf(n){const t=BigInt(10),e=BigInt(20),r=BigInt(40),s=BigInt(80),i=Es,a=n*n%i*n%i,l=Ge(a,ea,i)*a%i,y=Ge(l,ef,i)*n%i,x=Ge(y,rf,i)*y%i,_=Ge(x,t,i)*x%i,L=Ge(_,e,i)*_%i,C=Ge(L,r,i)*L%i,N=Ge(C,s,i)*C%i,M=Ge(N,s,i)*C%i,O=Ge(M,t,i)*x%i;return{pow_p_5_8:Ge(O,ea,i)*n%i,b2:a}}function of(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function af(n,t){const e=Es,r=We(t*t*t,e),s=We(r*r*t,e),i=sf(n*s).pow_p_5_8;let o=We(n*r*i,e);const a=We(t*o*o,e),l=o,y=We(o*ta,e),x=a===n,_=a===We(-n,e),L=a===We(-n*ta,e);return x&&(o=l),(_||L)&&(o=y),qu(o,e)&&(o=We(-o,e)),{isValid:x||_,value:o}}const cf=Zo(Es,void 0,!0),uf={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:cf,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:nf,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ru,randomBytes:Lo,adjustScalarBytes:of,uvRatio:af},$n=tf(uf);var _s={exports:{}};const ra=us(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));_s.exports,function(n){(function(t,e){function r(T,u){if(!T)throw new Error(u||"Assertion failed")}function s(T,u){T.super_=u;var p=function(){};p.prototype=u.prototype,T.prototype=new p,T.prototype.constructor=T}function i(T,u,p){if(i.isBN(T))return T;this.negative=0,this.words=null,this.length=0,this.red=null,T!==null&&((u==="le"||u==="be")&&(p=u,u=10),this._init(T||0,u||10,p||"be"))}typeof t=="object"?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=ra.Buffer}catch{}i.isBN=function(u){return u instanceof i?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===i.wordSize&&Array.isArray(u.words)},i.max=function(u,p){return u.cmp(p)>0?u:p},i.min=function(u,p){return u.cmp(p)<0?u:p},i.prototype._init=function(u,p,w){if(typeof u=="number")return this._initNumber(u,p,w);if(typeof u=="object")return this._initArray(u,p,w);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),u=u.toString().replace(/\s+/g,"");var R=0;u[0]==="-"&&(R++,this.negative=1),R<u.length&&(p===16?this._parseHex(u,R,w):(this._parseBase(u,p,R),w==="le"&&this._initArray(this.toArray(),p,w)))},i.prototype._initNumber=function(u,p,w){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(r(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),w==="le"&&this._initArray(this.toArray(),p,w)},i.prototype._initArray=function(u,p,w){if(r(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var R=0;R<this.length;R++)this.words[R]=0;var I,A,U=0;if(w==="be")for(R=u.length-1,I=0;R>=0;R-=3)A=u[R]|u[R-1]<<8|u[R-2]<<16,this.words[I]|=A<<U&67108863,this.words[I+1]=A>>>26-U&67108863,U+=24,U>=26&&(U-=26,I++);else if(w==="le")for(R=0,I=0;R<u.length;R+=3)A=u[R]|u[R+1]<<8|u[R+2]<<16,this.words[I]|=A<<U&67108863,this.words[I+1]=A>>>26-U&67108863,U+=24,U>=26&&(U-=26,I++);return this._strip()};function a(T,u){var p=T.charCodeAt(u);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;r(!1,"Invalid character in "+T)}function l(T,u,p){var w=a(T,p);return p-1>=u&&(w|=a(T,p-1)<<4),w}i.prototype._parseHex=function(u,p,w){this.length=Math.ceil((u.length-p)/6),this.words=new Array(this.length);for(var R=0;R<this.length;R++)this.words[R]=0;var I=0,A=0,U;if(w==="be")for(R=u.length-1;R>=p;R-=2)U=l(u,p,R)<<I,this.words[A]|=U&67108863,I>=18?(I-=18,A+=1,this.words[A]|=U>>>26):I+=8;else{var k=u.length-p;for(R=k%2===0?p+1:p;R<u.length;R+=2)U=l(u,p,R)<<I,this.words[A]|=U&67108863,I>=18?(I-=18,A+=1,this.words[A]|=U>>>26):I+=8}this._strip()};function y(T,u,p,w){for(var R=0,I=0,A=Math.min(T.length,p),U=u;U<A;U++){var k=T.charCodeAt(U)-48;R*=w,k>=49?I=k-49+10:k>=17?I=k-17+10:I=k,r(k>=0&&I<w,"Invalid character"),R+=I}return R}i.prototype._parseBase=function(u,p,w){this.words=[0],this.length=1;for(var R=0,I=1;I<=67108863;I*=p)R++;R--,I=I/p|0;for(var A=u.length-w,U=A%R,k=Math.min(A,A-U)+w,h=0,E=w;E<k;E+=R)h=y(u,E,E+R,p),this.imuln(I),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(U!==0){var at=1;for(h=y(u,E,u.length,p),E=0;E<U;E++)at*=p;this.imuln(at),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this._strip()},i.prototype.copy=function(u){u.words=new Array(this.length);for(var p=0;p<this.length;p++)u.words[p]=this.words[p];u.length=this.length,u.negative=this.negative,u.red=this.red};function x(T,u){T.words=u.words,T.length=u.length,T.negative=u.negative,T.red=u.red}if(i.prototype._move=function(u){x(u,this)},i.prototype.clone=function(){var u=new i(null);return this.copy(u),u},i.prototype._expand=function(u){for(;this.length<u;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=_}catch{i.prototype.inspect=_}else i.prototype.inspect=_;function _(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var L=["","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"],C=[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],N=[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];i.prototype.toString=function(u,p){u=u||10,p=p|0||1;var w;if(u===16||u==="hex"){w="";for(var R=0,I=0,A=0;A<this.length;A++){var U=this.words[A],k=((U<<R|I)&16777215).toString(16);I=U>>>24-R&16777215,R+=2,R>=26&&(R-=26,A--),I!==0||A!==this.length-1?w=L[6-k.length]+k+w:w=k+w}for(I!==0&&(w=I.toString(16)+w);w.length%p!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}if(u===(u|0)&&u>=2&&u<=36){var h=C[u],E=N[u];w="";var at=this.clone();for(at.negative=0;!at.isZero();){var Q=at.modrn(E).toString(u);at=at.idivn(E),at.isZero()?w=Q+w:w=L[h-Q.length]+Q+w}for(this.isZero()&&(w="0"+w);w.length%p!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(u,p){return this.toArrayLike(o,u,p)}),i.prototype.toArray=function(u,p){return this.toArrayLike(Array,u,p)};var M=function(u,p){return u.allocUnsafe?u.allocUnsafe(p):new u(p)};i.prototype.toArrayLike=function(u,p,w){this._strip();var R=this.byteLength(),I=w||Math.max(1,R);r(R<=I,"byte array longer than desired length"),r(I>0,"Requested array length <= 0");var A=M(u,I),U=p==="le"?"LE":"BE";return this["_toArrayLike"+U](A,R),A},i.prototype._toArrayLikeLE=function(u,p){for(var w=0,R=0,I=0,A=0;I<this.length;I++){var U=this.words[I]<<A|R;u[w++]=U&255,w<u.length&&(u[w++]=U>>8&255),w<u.length&&(u[w++]=U>>16&255),A===6?(w<u.length&&(u[w++]=U>>24&255),R=0,A=0):(R=U>>>24,A+=2)}if(w<u.length)for(u[w++]=R;w<u.length;)u[w++]=0},i.prototype._toArrayLikeBE=function(u,p){for(var w=u.length-1,R=0,I=0,A=0;I<this.length;I++){var U=this.words[I]<<A|R;u[w--]=U&255,w>=0&&(u[w--]=U>>8&255),w>=0&&(u[w--]=U>>16&255),A===6?(w>=0&&(u[w--]=U>>24&255),R=0,A=0):(R=U>>>24,A+=2)}if(w>=0)for(u[w--]=R;w>=0;)u[w--]=0},Math.clz32?i.prototype._countBits=function(u){return 32-Math.clz32(u)}:i.prototype._countBits=function(u){var p=u,w=0;return p>=4096&&(w+=13,p>>>=13),p>=64&&(w+=7,p>>>=7),p>=8&&(w+=4,p>>>=4),p>=2&&(w+=2,p>>>=2),w+p},i.prototype._zeroBits=function(u){if(u===0)return 26;var p=u,w=0;return p&8191||(w+=13,p>>>=13),p&127||(w+=7,p>>>=7),p&15||(w+=4,p>>>=4),p&3||(w+=2,p>>>=2),p&1||w++,w},i.prototype.bitLength=function(){var u=this.words[this.length-1],p=this._countBits(u);return(this.length-1)*26+p};function O(T){for(var u=new Array(T.bitLength()),p=0;p<u.length;p++){var w=p/26|0,R=p%26;u[p]=T.words[w]>>>R&1}return u}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,p=0;p<this.length;p++){var w=this._zeroBits(this.words[p]);if(u+=w,w!==26)break}return u},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},i.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var p=0;p<u.length;p++)this.words[p]=this.words[p]|u.words[p];return this._strip()},i.prototype.ior=function(u){return r((this.negative|u.negative)===0),this.iuor(u)},i.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},i.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},i.prototype.iuand=function(u){var p;this.length>u.length?p=u:p=this;for(var w=0;w<p.length;w++)this.words[w]=this.words[w]&u.words[w];return this.length=p.length,this._strip()},i.prototype.iand=function(u){return r((this.negative|u.negative)===0),this.iuand(u)},i.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},i.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},i.prototype.iuxor=function(u){var p,w;this.length>u.length?(p=this,w=u):(p=u,w=this);for(var R=0;R<w.length;R++)this.words[R]=p.words[R]^w.words[R];if(this!==p)for(;R<p.length;R++)this.words[R]=p.words[R];return this.length=p.length,this._strip()},i.prototype.ixor=function(u){return r((this.negative|u.negative)===0),this.iuxor(u)},i.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},i.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},i.prototype.inotn=function(u){r(typeof u=="number"&&u>=0);var p=Math.ceil(u/26)|0,w=u%26;this._expand(p),w>0&&p--;for(var R=0;R<p;R++)this.words[R]=~this.words[R]&67108863;return w>0&&(this.words[R]=~this.words[R]&67108863>>26-w),this._strip()},i.prototype.notn=function(u){return this.clone().inotn(u)},i.prototype.setn=function(u,p){r(typeof u=="number"&&u>=0);var w=u/26|0,R=u%26;return this._expand(w+1),p?this.words[w]=this.words[w]|1<<R:this.words[w]=this.words[w]&~(1<<R),this._strip()},i.prototype.iadd=function(u){var p;if(this.negative!==0&&u.negative===0)return this.negative=0,p=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,p=this.isub(u),u.negative=1,p._normSign();var w,R;this.length>u.length?(w=this,R=u):(w=u,R=this);for(var I=0,A=0;A<R.length;A++)p=(w.words[A]|0)+(R.words[A]|0)+I,this.words[A]=p&67108863,I=p>>>26;for(;I!==0&&A<w.length;A++)p=(w.words[A]|0)+I,this.words[A]=p&67108863,I=p>>>26;if(this.length=w.length,I!==0)this.words[this.length]=I,this.length++;else if(w!==this)for(;A<w.length;A++)this.words[A]=w.words[A];return this},i.prototype.add=function(u){var p;return u.negative!==0&&this.negative===0?(u.negative=0,p=this.sub(u),u.negative^=1,p):u.negative===0&&this.negative!==0?(this.negative=0,p=u.sub(this),this.negative=1,p):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},i.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var p=this.iadd(u);return u.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var w=this.cmp(u);if(w===0)return this.negative=0,this.length=1,this.words[0]=0,this;var R,I;w>0?(R=this,I=u):(R=u,I=this);for(var A=0,U=0;U<I.length;U++)p=(R.words[U]|0)-(I.words[U]|0)+A,A=p>>26,this.words[U]=p&67108863;for(;A!==0&&U<R.length;U++)p=(R.words[U]|0)+A,A=p>>26,this.words[U]=p&67108863;if(A===0&&U<R.length&&R!==this)for(;U<R.length;U++)this.words[U]=R.words[U];return this.length=Math.max(this.length,U),R!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(u){return this.clone().isub(u)};function K(T,u,p){p.negative=u.negative^T.negative;var w=T.length+u.length|0;p.length=w,w=w-1|0;var R=T.words[0]|0,I=u.words[0]|0,A=R*I,U=A&67108863,k=A/67108864|0;p.words[0]=U;for(var h=1;h<w;h++){for(var E=k>>>26,at=k&67108863,Q=Math.min(h,u.length-1),ct=Math.max(0,h-T.length+1);ct<=Q;ct++){var Mt=h-ct|0;R=T.words[Mt]|0,I=u.words[ct]|0,A=R*I+at,E+=A/67108864|0,at=A&67108863}p.words[h]=at|0,k=E|0}return k!==0?p.words[h]=k|0:p.length--,p._strip()}var X=function(u,p,w){var R=u.words,I=p.words,A=w.words,U=0,k,h,E,at=R[0]|0,Q=at&8191,ct=at>>>13,Mt=R[1]|0,Tt=Mt&8191,Pt=Mt>>>13,Ce=R[2]|0,Yt=Ce&8191,Gt=Ce>>>13,le=R[3]|0,re=le&8191,ve=le>>>13,Or=R[4]|0,_e=Or&8191,Oe=Or>>>13,Ar=R[5]|0,Ie=Ar&8191,Ae=Ar>>>13,rr=R[6]|0,ke=rr&8191,Se=rr>>>13,fr=R[7]|0,Be=fr&8191,m=fr>>>13,f=R[8]|0,d=f&8191,B=f>>>13,F=R[9]|0,$=F&8191,Y=F>>>13,Ht=I[0]|0,zt=Ht&8191,Nt=Ht>>>13,Re=I[1]|0,Lt=Re&8191,ze=Re>>>13,ri=I[2]|0,je=ri&8191,Ze=ri>>>13,cs=I[3]|0,Te=cs&8191,Le=cs>>>13,cn=I[4]|0,De=cn&8191,$e=cn>>>13,ki=I[5]|0,Je=ki&8191,he=ki>>>13,Si=I[6]|0,g=Si&8191,b=Si>>>13,v=I[7]|0,c=v&8191,S=v>>>13,W=I[8]|0,z=W&8191,J=W>>>13,lt=I[9]|0,pt=lt&8191,ht=lt>>>13;w.negative=u.negative^p.negative,w.length=19,k=Math.imul(Q,zt),h=Math.imul(Q,Nt),h=h+Math.imul(ct,zt)|0,E=Math.imul(ct,Nt);var ce=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(ce>>>26)|0,ce&=67108863,k=Math.imul(Tt,zt),h=Math.imul(Tt,Nt),h=h+Math.imul(Pt,zt)|0,E=Math.imul(Pt,Nt),k=k+Math.imul(Q,Lt)|0,h=h+Math.imul(Q,ze)|0,h=h+Math.imul(ct,Lt)|0,E=E+Math.imul(ct,ze)|0;var vt=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(vt>>>26)|0,vt&=67108863,k=Math.imul(Yt,zt),h=Math.imul(Yt,Nt),h=h+Math.imul(Gt,zt)|0,E=Math.imul(Gt,Nt),k=k+Math.imul(Tt,Lt)|0,h=h+Math.imul(Tt,ze)|0,h=h+Math.imul(Pt,Lt)|0,E=E+Math.imul(Pt,ze)|0,k=k+Math.imul(Q,je)|0,h=h+Math.imul(Q,Ze)|0,h=h+Math.imul(ct,je)|0,E=E+Math.imul(ct,Ze)|0;var Ft=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,k=Math.imul(re,zt),h=Math.imul(re,Nt),h=h+Math.imul(ve,zt)|0,E=Math.imul(ve,Nt),k=k+Math.imul(Yt,Lt)|0,h=h+Math.imul(Yt,ze)|0,h=h+Math.imul(Gt,Lt)|0,E=E+Math.imul(Gt,ze)|0,k=k+Math.imul(Tt,je)|0,h=h+Math.imul(Tt,Ze)|0,h=h+Math.imul(Pt,je)|0,E=E+Math.imul(Pt,Ze)|0,k=k+Math.imul(Q,Te)|0,h=h+Math.imul(Q,Le)|0,h=h+Math.imul(ct,Te)|0,E=E+Math.imul(ct,Le)|0;var Kt=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,k=Math.imul(_e,zt),h=Math.imul(_e,Nt),h=h+Math.imul(Oe,zt)|0,E=Math.imul(Oe,Nt),k=k+Math.imul(re,Lt)|0,h=h+Math.imul(re,ze)|0,h=h+Math.imul(ve,Lt)|0,E=E+Math.imul(ve,ze)|0,k=k+Math.imul(Yt,je)|0,h=h+Math.imul(Yt,Ze)|0,h=h+Math.imul(Gt,je)|0,E=E+Math.imul(Gt,Ze)|0,k=k+Math.imul(Tt,Te)|0,h=h+Math.imul(Tt,Le)|0,h=h+Math.imul(Pt,Te)|0,E=E+Math.imul(Pt,Le)|0,k=k+Math.imul(Q,De)|0,h=h+Math.imul(Q,$e)|0,h=h+Math.imul(ct,De)|0,E=E+Math.imul(ct,$e)|0;var Vt=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,k=Math.imul(Ie,zt),h=Math.imul(Ie,Nt),h=h+Math.imul(Ae,zt)|0,E=Math.imul(Ae,Nt),k=k+Math.imul(_e,Lt)|0,h=h+Math.imul(_e,ze)|0,h=h+Math.imul(Oe,Lt)|0,E=E+Math.imul(Oe,ze)|0,k=k+Math.imul(re,je)|0,h=h+Math.imul(re,Ze)|0,h=h+Math.imul(ve,je)|0,E=E+Math.imul(ve,Ze)|0,k=k+Math.imul(Yt,Te)|0,h=h+Math.imul(Yt,Le)|0,h=h+Math.imul(Gt,Te)|0,E=E+Math.imul(Gt,Le)|0,k=k+Math.imul(Tt,De)|0,h=h+Math.imul(Tt,$e)|0,h=h+Math.imul(Pt,De)|0,E=E+Math.imul(Pt,$e)|0,k=k+Math.imul(Q,Je)|0,h=h+Math.imul(Q,he)|0,h=h+Math.imul(ct,Je)|0,E=E+Math.imul(ct,he)|0;var qt=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(qt>>>26)|0,qt&=67108863,k=Math.imul(ke,zt),h=Math.imul(ke,Nt),h=h+Math.imul(Se,zt)|0,E=Math.imul(Se,Nt),k=k+Math.imul(Ie,Lt)|0,h=h+Math.imul(Ie,ze)|0,h=h+Math.imul(Ae,Lt)|0,E=E+Math.imul(Ae,ze)|0,k=k+Math.imul(_e,je)|0,h=h+Math.imul(_e,Ze)|0,h=h+Math.imul(Oe,je)|0,E=E+Math.imul(Oe,Ze)|0,k=k+Math.imul(re,Te)|0,h=h+Math.imul(re,Le)|0,h=h+Math.imul(ve,Te)|0,E=E+Math.imul(ve,Le)|0,k=k+Math.imul(Yt,De)|0,h=h+Math.imul(Yt,$e)|0,h=h+Math.imul(Gt,De)|0,E=E+Math.imul(Gt,$e)|0,k=k+Math.imul(Tt,Je)|0,h=h+Math.imul(Tt,he)|0,h=h+Math.imul(Pt,Je)|0,E=E+Math.imul(Pt,he)|0,k=k+Math.imul(Q,g)|0,h=h+Math.imul(Q,b)|0,h=h+Math.imul(ct,g)|0,E=E+Math.imul(ct,b)|0;var Wt=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,k=Math.imul(Be,zt),h=Math.imul(Be,Nt),h=h+Math.imul(m,zt)|0,E=Math.imul(m,Nt),k=k+Math.imul(ke,Lt)|0,h=h+Math.imul(ke,ze)|0,h=h+Math.imul(Se,Lt)|0,E=E+Math.imul(Se,ze)|0,k=k+Math.imul(Ie,je)|0,h=h+Math.imul(Ie,Ze)|0,h=h+Math.imul(Ae,je)|0,E=E+Math.imul(Ae,Ze)|0,k=k+Math.imul(_e,Te)|0,h=h+Math.imul(_e,Le)|0,h=h+Math.imul(Oe,Te)|0,E=E+Math.imul(Oe,Le)|0,k=k+Math.imul(re,De)|0,h=h+Math.imul(re,$e)|0,h=h+Math.imul(ve,De)|0,E=E+Math.imul(ve,$e)|0,k=k+Math.imul(Yt,Je)|0,h=h+Math.imul(Yt,he)|0,h=h+Math.imul(Gt,Je)|0,E=E+Math.imul(Gt,he)|0,k=k+Math.imul(Tt,g)|0,h=h+Math.imul(Tt,b)|0,h=h+Math.imul(Pt,g)|0,E=E+Math.imul(Pt,b)|0,k=k+Math.imul(Q,c)|0,h=h+Math.imul(Q,S)|0,h=h+Math.imul(ct,c)|0,E=E+Math.imul(ct,S)|0;var $t=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+($t>>>26)|0,$t&=67108863,k=Math.imul(d,zt),h=Math.imul(d,Nt),h=h+Math.imul(B,zt)|0,E=Math.imul(B,Nt),k=k+Math.imul(Be,Lt)|0,h=h+Math.imul(Be,ze)|0,h=h+Math.imul(m,Lt)|0,E=E+Math.imul(m,ze)|0,k=k+Math.imul(ke,je)|0,h=h+Math.imul(ke,Ze)|0,h=h+Math.imul(Se,je)|0,E=E+Math.imul(Se,Ze)|0,k=k+Math.imul(Ie,Te)|0,h=h+Math.imul(Ie,Le)|0,h=h+Math.imul(Ae,Te)|0,E=E+Math.imul(Ae,Le)|0,k=k+Math.imul(_e,De)|0,h=h+Math.imul(_e,$e)|0,h=h+Math.imul(Oe,De)|0,E=E+Math.imul(Oe,$e)|0,k=k+Math.imul(re,Je)|0,h=h+Math.imul(re,he)|0,h=h+Math.imul(ve,Je)|0,E=E+Math.imul(ve,he)|0,k=k+Math.imul(Yt,g)|0,h=h+Math.imul(Yt,b)|0,h=h+Math.imul(Gt,g)|0,E=E+Math.imul(Gt,b)|0,k=k+Math.imul(Tt,c)|0,h=h+Math.imul(Tt,S)|0,h=h+Math.imul(Pt,c)|0,E=E+Math.imul(Pt,S)|0,k=k+Math.imul(Q,z)|0,h=h+Math.imul(Q,J)|0,h=h+Math.imul(ct,z)|0,E=E+Math.imul(ct,J)|0;var Dt=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,k=Math.imul($,zt),h=Math.imul($,Nt),h=h+Math.imul(Y,zt)|0,E=Math.imul(Y,Nt),k=k+Math.imul(d,Lt)|0,h=h+Math.imul(d,ze)|0,h=h+Math.imul(B,Lt)|0,E=E+Math.imul(B,ze)|0,k=k+Math.imul(Be,je)|0,h=h+Math.imul(Be,Ze)|0,h=h+Math.imul(m,je)|0,E=E+Math.imul(m,Ze)|0,k=k+Math.imul(ke,Te)|0,h=h+Math.imul(ke,Le)|0,h=h+Math.imul(Se,Te)|0,E=E+Math.imul(Se,Le)|0,k=k+Math.imul(Ie,De)|0,h=h+Math.imul(Ie,$e)|0,h=h+Math.imul(Ae,De)|0,E=E+Math.imul(Ae,$e)|0,k=k+Math.imul(_e,Je)|0,h=h+Math.imul(_e,he)|0,h=h+Math.imul(Oe,Je)|0,E=E+Math.imul(Oe,he)|0,k=k+Math.imul(re,g)|0,h=h+Math.imul(re,b)|0,h=h+Math.imul(ve,g)|0,E=E+Math.imul(ve,b)|0,k=k+Math.imul(Yt,c)|0,h=h+Math.imul(Yt,S)|0,h=h+Math.imul(Gt,c)|0,E=E+Math.imul(Gt,S)|0,k=k+Math.imul(Tt,z)|0,h=h+Math.imul(Tt,J)|0,h=h+Math.imul(Pt,z)|0,E=E+Math.imul(Pt,J)|0,k=k+Math.imul(Q,pt)|0,h=h+Math.imul(Q,ht)|0,h=h+Math.imul(ct,pt)|0,E=E+Math.imul(ct,ht)|0;var St=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(St>>>26)|0,St&=67108863,k=Math.imul($,Lt),h=Math.imul($,ze),h=h+Math.imul(Y,Lt)|0,E=Math.imul(Y,ze),k=k+Math.imul(d,je)|0,h=h+Math.imul(d,Ze)|0,h=h+Math.imul(B,je)|0,E=E+Math.imul(B,Ze)|0,k=k+Math.imul(Be,Te)|0,h=h+Math.imul(Be,Le)|0,h=h+Math.imul(m,Te)|0,E=E+Math.imul(m,Le)|0,k=k+Math.imul(ke,De)|0,h=h+Math.imul(ke,$e)|0,h=h+Math.imul(Se,De)|0,E=E+Math.imul(Se,$e)|0,k=k+Math.imul(Ie,Je)|0,h=h+Math.imul(Ie,he)|0,h=h+Math.imul(Ae,Je)|0,E=E+Math.imul(Ae,he)|0,k=k+Math.imul(_e,g)|0,h=h+Math.imul(_e,b)|0,h=h+Math.imul(Oe,g)|0,E=E+Math.imul(Oe,b)|0,k=k+Math.imul(re,c)|0,h=h+Math.imul(re,S)|0,h=h+Math.imul(ve,c)|0,E=E+Math.imul(ve,S)|0,k=k+Math.imul(Yt,z)|0,h=h+Math.imul(Yt,J)|0,h=h+Math.imul(Gt,z)|0,E=E+Math.imul(Gt,J)|0,k=k+Math.imul(Tt,pt)|0,h=h+Math.imul(Tt,ht)|0,h=h+Math.imul(Pt,pt)|0,E=E+Math.imul(Pt,ht)|0;var Bt=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,k=Math.imul($,je),h=Math.imul($,Ze),h=h+Math.imul(Y,je)|0,E=Math.imul(Y,Ze),k=k+Math.imul(d,Te)|0,h=h+Math.imul(d,Le)|0,h=h+Math.imul(B,Te)|0,E=E+Math.imul(B,Le)|0,k=k+Math.imul(Be,De)|0,h=h+Math.imul(Be,$e)|0,h=h+Math.imul(m,De)|0,E=E+Math.imul(m,$e)|0,k=k+Math.imul(ke,Je)|0,h=h+Math.imul(ke,he)|0,h=h+Math.imul(Se,Je)|0,E=E+Math.imul(Se,he)|0,k=k+Math.imul(Ie,g)|0,h=h+Math.imul(Ie,b)|0,h=h+Math.imul(Ae,g)|0,E=E+Math.imul(Ae,b)|0,k=k+Math.imul(_e,c)|0,h=h+Math.imul(_e,S)|0,h=h+Math.imul(Oe,c)|0,E=E+Math.imul(Oe,S)|0,k=k+Math.imul(re,z)|0,h=h+Math.imul(re,J)|0,h=h+Math.imul(ve,z)|0,E=E+Math.imul(ve,J)|0,k=k+Math.imul(Yt,pt)|0,h=h+Math.imul(Yt,ht)|0,h=h+Math.imul(Gt,pt)|0,E=E+Math.imul(Gt,ht)|0;var xt=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(xt>>>26)|0,xt&=67108863,k=Math.imul($,Te),h=Math.imul($,Le),h=h+Math.imul(Y,Te)|0,E=Math.imul(Y,Le),k=k+Math.imul(d,De)|0,h=h+Math.imul(d,$e)|0,h=h+Math.imul(B,De)|0,E=E+Math.imul(B,$e)|0,k=k+Math.imul(Be,Je)|0,h=h+Math.imul(Be,he)|0,h=h+Math.imul(m,Je)|0,E=E+Math.imul(m,he)|0,k=k+Math.imul(ke,g)|0,h=h+Math.imul(ke,b)|0,h=h+Math.imul(Se,g)|0,E=E+Math.imul(Se,b)|0,k=k+Math.imul(Ie,c)|0,h=h+Math.imul(Ie,S)|0,h=h+Math.imul(Ae,c)|0,E=E+Math.imul(Ae,S)|0,k=k+Math.imul(_e,z)|0,h=h+Math.imul(_e,J)|0,h=h+Math.imul(Oe,z)|0,E=E+Math.imul(Oe,J)|0,k=k+Math.imul(re,pt)|0,h=h+Math.imul(re,ht)|0,h=h+Math.imul(ve,pt)|0,E=E+Math.imul(ve,ht)|0;var Et=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(Et>>>26)|0,Et&=67108863,k=Math.imul($,De),h=Math.imul($,$e),h=h+Math.imul(Y,De)|0,E=Math.imul(Y,$e),k=k+Math.imul(d,Je)|0,h=h+Math.imul(d,he)|0,h=h+Math.imul(B,Je)|0,E=E+Math.imul(B,he)|0,k=k+Math.imul(Be,g)|0,h=h+Math.imul(Be,b)|0,h=h+Math.imul(m,g)|0,E=E+Math.imul(m,b)|0,k=k+Math.imul(ke,c)|0,h=h+Math.imul(ke,S)|0,h=h+Math.imul(Se,c)|0,E=E+Math.imul(Se,S)|0,k=k+Math.imul(Ie,z)|0,h=h+Math.imul(Ie,J)|0,h=h+Math.imul(Ae,z)|0,E=E+Math.imul(Ae,J)|0,k=k+Math.imul(_e,pt)|0,h=h+Math.imul(_e,ht)|0,h=h+Math.imul(Oe,pt)|0,E=E+Math.imul(Oe,ht)|0;var _t=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(_t>>>26)|0,_t&=67108863,k=Math.imul($,Je),h=Math.imul($,he),h=h+Math.imul(Y,Je)|0,E=Math.imul(Y,he),k=k+Math.imul(d,g)|0,h=h+Math.imul(d,b)|0,h=h+Math.imul(B,g)|0,E=E+Math.imul(B,b)|0,k=k+Math.imul(Be,c)|0,h=h+Math.imul(Be,S)|0,h=h+Math.imul(m,c)|0,E=E+Math.imul(m,S)|0,k=k+Math.imul(ke,z)|0,h=h+Math.imul(ke,J)|0,h=h+Math.imul(Se,z)|0,E=E+Math.imul(Se,J)|0,k=k+Math.imul(Ie,pt)|0,h=h+Math.imul(Ie,ht)|0,h=h+Math.imul(Ae,pt)|0,E=E+Math.imul(Ae,ht)|0;var mt=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(mt>>>26)|0,mt&=67108863,k=Math.imul($,g),h=Math.imul($,b),h=h+Math.imul(Y,g)|0,E=Math.imul(Y,b),k=k+Math.imul(d,c)|0,h=h+Math.imul(d,S)|0,h=h+Math.imul(B,c)|0,E=E+Math.imul(B,S)|0,k=k+Math.imul(Be,z)|0,h=h+Math.imul(Be,J)|0,h=h+Math.imul(m,z)|0,E=E+Math.imul(m,J)|0,k=k+Math.imul(ke,pt)|0,h=h+Math.imul(ke,ht)|0,h=h+Math.imul(Se,pt)|0,E=E+Math.imul(Se,ht)|0;var j=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(j>>>26)|0,j&=67108863,k=Math.imul($,c),h=Math.imul($,S),h=h+Math.imul(Y,c)|0,E=Math.imul(Y,S),k=k+Math.imul(d,z)|0,h=h+Math.imul(d,J)|0,h=h+Math.imul(B,z)|0,E=E+Math.imul(B,J)|0,k=k+Math.imul(Be,pt)|0,h=h+Math.imul(Be,ht)|0,h=h+Math.imul(m,pt)|0,E=E+Math.imul(m,ht)|0;var G=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(G>>>26)|0,G&=67108863,k=Math.imul($,z),h=Math.imul($,J),h=h+Math.imul(Y,z)|0,E=Math.imul(Y,J),k=k+Math.imul(d,pt)|0,h=h+Math.imul(d,ht)|0,h=h+Math.imul(B,pt)|0,E=E+Math.imul(B,ht)|0;var st=(U+k|0)+((h&8191)<<13)|0;U=(E+(h>>>13)|0)+(st>>>26)|0,st&=67108863,k=Math.imul($,pt),h=Math.imul($,ht),h=h+Math.imul(Y,pt)|0,E=Math.imul(Y,ht);var et=(U+k|0)+((h&8191)<<13)|0;return U=(E+(h>>>13)|0)+(et>>>26)|0,et&=67108863,A[0]=ce,A[1]=vt,A[2]=Ft,A[3]=Kt,A[4]=Vt,A[5]=qt,A[6]=Wt,A[7]=$t,A[8]=Dt,A[9]=St,A[10]=Bt,A[11]=xt,A[12]=Et,A[13]=_t,A[14]=mt,A[15]=j,A[16]=G,A[17]=st,A[18]=et,U!==0&&(A[19]=U,w.length++),w};Math.imul||(X=K);function V(T,u,p){p.negative=u.negative^T.negative,p.length=T.length+u.length;for(var w=0,R=0,I=0;I<p.length-1;I++){var A=R;R=0;for(var U=w&67108863,k=Math.min(I,u.length-1),h=Math.max(0,I-T.length+1);h<=k;h++){var E=I-h,at=T.words[E]|0,Q=u.words[h]|0,ct=at*Q,Mt=ct&67108863;A=A+(ct/67108864|0)|0,Mt=Mt+U|0,U=Mt&67108863,A=A+(Mt>>>26)|0,R+=A>>>26,A&=67108863}p.words[I]=U,w=A,A=R}return w!==0?p.words[I]=w:p.length--,p._strip()}function it(T,u,p){return V(T,u,p)}i.prototype.mulTo=function(u,p){var w,R=this.length+u.length;return this.length===10&&u.length===10?w=X(this,u,p):R<63?w=K(this,u,p):R<1024?w=V(this,u,p):w=it(this,u,p),w},i.prototype.mul=function(u){var p=new i(null);return p.words=new Array(this.length+u.length),this.mulTo(u,p)},i.prototype.mulf=function(u){var p=new i(null);return p.words=new Array(this.length+u.length),it(this,u,p)},i.prototype.imul=function(u){return this.clone().mulTo(u,this)},i.prototype.imuln=function(u){var p=u<0;p&&(u=-u),r(typeof u=="number"),r(u<67108864);for(var w=0,R=0;R<this.length;R++){var I=(this.words[R]|0)*u,A=(I&67108863)+(w&67108863);w>>=26,w+=I/67108864|0,w+=A>>>26,this.words[R]=A&67108863}return w!==0&&(this.words[R]=w,this.length++),p?this.ineg():this},i.prototype.muln=function(u){return this.clone().imuln(u)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(u){var p=O(u);if(p.length===0)return new i(1);for(var w=this,R=0;R<p.length&&p[R]===0;R++,w=w.sqr());if(++R<p.length)for(var I=w.sqr();R<p.length;R++,I=I.sqr())p[R]!==0&&(w=w.mul(I));return w},i.prototype.iushln=function(u){r(typeof u=="number"&&u>=0);var p=u%26,w=(u-p)/26,R=67108863>>>26-p<<26-p,I;if(p!==0){var A=0;for(I=0;I<this.length;I++){var U=this.words[I]&R,k=(this.words[I]|0)-U<<p;this.words[I]=k|A,A=U>>>26-p}A&&(this.words[I]=A,this.length++)}if(w!==0){for(I=this.length-1;I>=0;I--)this.words[I+w]=this.words[I];for(I=0;I<w;I++)this.words[I]=0;this.length+=w}return this._strip()},i.prototype.ishln=function(u){return r(this.negative===0),this.iushln(u)},i.prototype.iushrn=function(u,p,w){r(typeof u=="number"&&u>=0);var R;p?R=(p-p%26)/26:R=0;var I=u%26,A=Math.min((u-I)/26,this.length),U=67108863^67108863>>>I<<I,k=w;if(R-=A,R=Math.max(0,R),k){for(var h=0;h<A;h++)k.words[h]=this.words[h];k.length=A}if(A!==0)if(this.length>A)for(this.length-=A,h=0;h<this.length;h++)this.words[h]=this.words[h+A];else this.words[0]=0,this.length=1;var E=0;for(h=this.length-1;h>=0&&(E!==0||h>=R);h--){var at=this.words[h]|0;this.words[h]=E<<26-I|at>>>I,E=at&U}return k&&E!==0&&(k.words[k.length++]=E),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(u,p,w){return r(this.negative===0),this.iushrn(u,p,w)},i.prototype.shln=function(u){return this.clone().ishln(u)},i.prototype.ushln=function(u){return this.clone().iushln(u)},i.prototype.shrn=function(u){return this.clone().ishrn(u)},i.prototype.ushrn=function(u){return this.clone().iushrn(u)},i.prototype.testn=function(u){r(typeof u=="number"&&u>=0);var p=u%26,w=(u-p)/26,R=1<<p;if(this.length<=w)return!1;var I=this.words[w];return!!(I&R)},i.prototype.imaskn=function(u){r(typeof u=="number"&&u>=0);var p=u%26,w=(u-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=w)return this;if(p!==0&&w++,this.length=Math.min(w,this.length),p!==0){var R=67108863^67108863>>>p<<p;this.words[this.length-1]&=R}return this._strip()},i.prototype.maskn=function(u){return this.clone().imaskn(u)},i.prototype.iaddn=function(u){return r(typeof u=="number"),r(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<=u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},i.prototype._iaddn=function(u){this.words[0]+=u;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},i.prototype.isubn=function(u){if(r(typeof u=="number"),r(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this._strip()},i.prototype.addn=function(u){return this.clone().iaddn(u)},i.prototype.subn=function(u){return this.clone().isubn(u)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(u,p,w){var R=u.length+w,I;this._expand(R);var A,U=0;for(I=0;I<u.length;I++){A=(this.words[I+w]|0)+U;var k=(u.words[I]|0)*p;A-=k&67108863,U=(A>>26)-(k/67108864|0),this.words[I+w]=A&67108863}for(;I<this.length-w;I++)A=(this.words[I+w]|0)+U,U=A>>26,this.words[I+w]=A&67108863;if(U===0)return this._strip();for(r(U===-1),U=0,I=0;I<this.length;I++)A=-(this.words[I]|0)+U,U=A>>26,this.words[I]=A&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(u,p){var w=this.length-u.length,R=this.clone(),I=u,A=I.words[I.length-1]|0,U=this._countBits(A);w=26-U,w!==0&&(I=I.ushln(w),R.iushln(w),A=I.words[I.length-1]|0);var k=R.length-I.length,h;if(p!=="mod"){h=new i(null),h.length=k+1,h.words=new Array(h.length);for(var E=0;E<h.length;E++)h.words[E]=0}var at=R.clone()._ishlnsubmul(I,1,k);at.negative===0&&(R=at,h&&(h.words[k]=1));for(var Q=k-1;Q>=0;Q--){var ct=(R.words[I.length+Q]|0)*67108864+(R.words[I.length+Q-1]|0);for(ct=Math.min(ct/A|0,67108863),R._ishlnsubmul(I,ct,Q);R.negative!==0;)ct--,R.negative=0,R._ishlnsubmul(I,1,Q),R.isZero()||(R.negative^=1);h&&(h.words[Q]=ct)}return h&&h._strip(),R._strip(),p!=="div"&&w!==0&&R.iushrn(w),{div:h||null,mod:R}},i.prototype.divmod=function(u,p,w){if(r(!u.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var R,I,A;return this.negative!==0&&u.negative===0?(A=this.neg().divmod(u,p),p!=="mod"&&(R=A.div.neg()),p!=="div"&&(I=A.mod.neg(),w&&I.negative!==0&&I.iadd(u)),{div:R,mod:I}):this.negative===0&&u.negative!==0?(A=this.divmod(u.neg(),p),p!=="mod"&&(R=A.div.neg()),{div:R,mod:A.mod}):this.negative&u.negative?(A=this.neg().divmod(u.neg(),p),p!=="div"&&(I=A.mod.neg(),w&&I.negative!==0&&I.isub(u)),{div:A.div,mod:I}):u.length>this.length||this.cmp(u)<0?{div:new i(0),mod:this}:u.length===1?p==="div"?{div:this.divn(u.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new i(this.modrn(u.words[0]))}:this._wordDiv(u,p)},i.prototype.div=function(u){return this.divmod(u,"div",!1).div},i.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},i.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},i.prototype.divRound=function(u){var p=this.divmod(u);if(p.mod.isZero())return p.div;var w=p.div.negative!==0?p.mod.isub(u):p.mod,R=u.ushrn(1),I=u.andln(1),A=w.cmp(R);return A<0||I===1&&A===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},i.prototype.modrn=function(u){var p=u<0;p&&(u=-u),r(u<=67108863);for(var w=(1<<26)%u,R=0,I=this.length-1;I>=0;I--)R=(w*R+(this.words[I]|0))%u;return p?-R:R},i.prototype.modn=function(u){return this.modrn(u)},i.prototype.idivn=function(u){var p=u<0;p&&(u=-u),r(u<=67108863);for(var w=0,R=this.length-1;R>=0;R--){var I=(this.words[R]|0)+w*67108864;this.words[R]=I/u|0,w=I%u}return this._strip(),p?this.ineg():this},i.prototype.divn=function(u){return this.clone().idivn(u)},i.prototype.egcd=function(u){r(u.negative===0),r(!u.isZero());var p=this,w=u.clone();p.negative!==0?p=p.umod(u):p=p.clone();for(var R=new i(1),I=new i(0),A=new i(0),U=new i(1),k=0;p.isEven()&&w.isEven();)p.iushrn(1),w.iushrn(1),++k;for(var h=w.clone(),E=p.clone();!p.isZero();){for(var at=0,Q=1;!(p.words[0]&Q)&&at<26;++at,Q<<=1);if(at>0)for(p.iushrn(at);at-- >0;)(R.isOdd()||I.isOdd())&&(R.iadd(h),I.isub(E)),R.iushrn(1),I.iushrn(1);for(var ct=0,Mt=1;!(w.words[0]&Mt)&&ct<26;++ct,Mt<<=1);if(ct>0)for(w.iushrn(ct);ct-- >0;)(A.isOdd()||U.isOdd())&&(A.iadd(h),U.isub(E)),A.iushrn(1),U.iushrn(1);p.cmp(w)>=0?(p.isub(w),R.isub(A),I.isub(U)):(w.isub(p),A.isub(R),U.isub(I))}return{a:A,b:U,gcd:w.iushln(k)}},i.prototype._invmp=function(u){r(u.negative===0),r(!u.isZero());var p=this,w=u.clone();p.negative!==0?p=p.umod(u):p=p.clone();for(var R=new i(1),I=new i(0),A=w.clone();p.cmpn(1)>0&&w.cmpn(1)>0;){for(var U=0,k=1;!(p.words[0]&k)&&U<26;++U,k<<=1);if(U>0)for(p.iushrn(U);U-- >0;)R.isOdd()&&R.iadd(A),R.iushrn(1);for(var h=0,E=1;!(w.words[0]&E)&&h<26;++h,E<<=1);if(h>0)for(w.iushrn(h);h-- >0;)I.isOdd()&&I.iadd(A),I.iushrn(1);p.cmp(w)>=0?(p.isub(w),R.isub(I)):(w.isub(p),I.isub(R))}var at;return p.cmpn(1)===0?at=R:at=I,at.cmpn(0)<0&&at.iadd(u),at},i.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var p=this.clone(),w=u.clone();p.negative=0,w.negative=0;for(var R=0;p.isEven()&&w.isEven();R++)p.iushrn(1),w.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;w.isEven();)w.iushrn(1);var I=p.cmp(w);if(I<0){var A=p;p=w,w=A}else if(I===0||w.cmpn(1)===0)break;p.isub(w)}while(!0);return w.iushln(R)},i.prototype.invm=function(u){return this.egcd(u).a.umod(u)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(u){return this.words[0]&u},i.prototype.bincn=function(u){r(typeof u=="number");var p=u%26,w=(u-p)/26,R=1<<p;if(this.length<=w)return this._expand(w+1),this.words[w]|=R,this;for(var I=R,A=w;I!==0&&A<this.length;A++){var U=this.words[A]|0;U+=I,I=U>>>26,U&=67108863,this.words[A]=U}return I!==0&&(this.words[A]=I,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(u){var p=u<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var w;if(this.length>1)w=1;else{p&&(u=-u),r(u<=67108863,"Number is too big");var R=this.words[0]|0;w=R===u?0:R<u?-1:1}return this.negative!==0?-w|0:w},i.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var p=this.ucmp(u);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var p=0,w=this.length-1;w>=0;w--){var R=this.words[w]|0,I=u.words[w]|0;if(R!==I){R<I?p=-1:R>I&&(p=1);break}}return p},i.prototype.gtn=function(u){return this.cmpn(u)===1},i.prototype.gt=function(u){return this.cmp(u)===1},i.prototype.gten=function(u){return this.cmpn(u)>=0},i.prototype.gte=function(u){return this.cmp(u)>=0},i.prototype.ltn=function(u){return this.cmpn(u)===-1},i.prototype.lt=function(u){return this.cmp(u)===-1},i.prototype.lten=function(u){return this.cmpn(u)<=0},i.prototype.lte=function(u){return this.cmp(u)<=0},i.prototype.eqn=function(u){return this.cmpn(u)===0},i.prototype.eq=function(u){return this.cmp(u)===0},i.red=function(u){return new kt(u)},i.prototype.toRed=function(u){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(u){return this.red=u,this},i.prototype.forceRed=function(u){return r(!this.red,"Already a number in reduction context"),this._forceRed(u)},i.prototype.redAdd=function(u){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},i.prototype.redIAdd=function(u){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},i.prototype.redSub=function(u){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},i.prototype.redISub=function(u){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},i.prototype.redShl=function(u){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},i.prototype.redMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},i.prototype.redIMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(u){return r(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var Z={k256:null,p224:null,p192:null,p25519:null};function D(T,u){this.name=T,this.p=new i(u,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}D.prototype._tmp=function(){var u=new i(null);return u.words=new Array(Math.ceil(this.n/13)),u},D.prototype.ireduce=function(u){var p=u,w;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),w=p.bitLength();while(w>this.n);var R=w<this.n?-1:p.ucmp(this.p);return R===0?(p.words[0]=0,p.length=1):R>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},D.prototype.split=function(u,p){u.iushrn(this.n,0,p)},D.prototype.imulK=function(u){return u.imul(this.k)};function tt(){D.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(tt,D),tt.prototype.split=function(u,p){for(var w=4194303,R=Math.min(u.length,9),I=0;I<R;I++)p.words[I]=u.words[I];if(p.length=R,u.length<=9){u.words[0]=0,u.length=1;return}var A=u.words[9];for(p.words[p.length++]=A&w,I=10;I<u.length;I++){var U=u.words[I]|0;u.words[I-10]=(U&w)<<4|A>>>22,A=U}A>>>=22,u.words[I-10]=A,A===0&&u.length>10?u.length-=10:u.length-=9},tt.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var p=0,w=0;w<u.length;w++){var R=u.words[w]|0;p+=R*977,u.words[w]=p&67108863,p=R*64+(p/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function rt(){D.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(rt,D);function ue(){D.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(ue,D);function jt(){D.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(jt,D),jt.prototype.imulK=function(u){for(var p=0,w=0;w<u.length;w++){var R=(u.words[w]|0)*19+p,I=R&67108863;R>>>=26,u.words[w]=I,p=R}return p!==0&&(u.words[u.length++]=p),u},i._prime=function(u){if(Z[u])return Z[u];var p;if(u==="k256")p=new tt;else if(u==="p224")p=new rt;else if(u==="p192")p=new ue;else if(u==="p25519")p=new jt;else throw new Error("Unknown prime "+u);return Z[u]=p,p};function kt(T){if(typeof T=="string"){var u=i._prime(T);this.m=u.p,this.prime=u}else r(T.gtn(1),"modulus must be greater than 1"),this.m=T,this.prime=null}kt.prototype._verify1=function(u){r(u.negative===0,"red works only with positives"),r(u.red,"red works only with red numbers")},kt.prototype._verify2=function(u,p){r((u.negative|p.negative)===0,"red works only with positives"),r(u.red&&u.red===p.red,"red works only with red numbers")},kt.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):(x(u,u.umod(this.m)._forceRed(this)),u)},kt.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},kt.prototype.add=function(u,p){this._verify2(u,p);var w=u.add(p);return w.cmp(this.m)>=0&&w.isub(this.m),w._forceRed(this)},kt.prototype.iadd=function(u,p){this._verify2(u,p);var w=u.iadd(p);return w.cmp(this.m)>=0&&w.isub(this.m),w},kt.prototype.sub=function(u,p){this._verify2(u,p);var w=u.sub(p);return w.cmpn(0)<0&&w.iadd(this.m),w._forceRed(this)},kt.prototype.isub=function(u,p){this._verify2(u,p);var w=u.isub(p);return w.cmpn(0)<0&&w.iadd(this.m),w},kt.prototype.shl=function(u,p){return this._verify1(u),this.imod(u.ushln(p))},kt.prototype.imul=function(u,p){return this._verify2(u,p),this.imod(u.imul(p))},kt.prototype.mul=function(u,p){return this._verify2(u,p),this.imod(u.mul(p))},kt.prototype.isqr=function(u){return this.imul(u,u.clone())},kt.prototype.sqr=function(u){return this.mul(u,u)},kt.prototype.sqrt=function(u){if(u.isZero())return u.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var w=this.m.add(new i(1)).iushrn(2);return this.pow(u,w)}for(var R=this.m.subn(1),I=0;!R.isZero()&&R.andln(1)===0;)I++,R.iushrn(1);r(!R.isZero());var A=new i(1).toRed(this),U=A.redNeg(),k=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new i(2*h*h).toRed(this);this.pow(h,k).cmp(U)!==0;)h.redIAdd(U);for(var E=this.pow(h,R),at=this.pow(u,R.addn(1).iushrn(1)),Q=this.pow(u,R),ct=I;Q.cmp(A)!==0;){for(var Mt=Q,Tt=0;Mt.cmp(A)!==0;Tt++)Mt=Mt.redSqr();r(Tt<ct);var Pt=this.pow(E,new i(1).iushln(ct-Tt-1));at=at.redMul(Pt),E=Pt.redSqr(),Q=Q.redMul(E),ct=Tt}return at},kt.prototype.invm=function(u){var p=u._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},kt.prototype.pow=function(u,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return u.clone();var w=4,R=new Array(1<<w);R[0]=new i(1).toRed(this),R[1]=u;for(var I=2;I<R.length;I++)R[I]=this.mul(R[I-1],u);var A=R[0],U=0,k=0,h=p.bitLength()%26;for(h===0&&(h=26),I=p.length-1;I>=0;I--){for(var E=p.words[I],at=h-1;at>=0;at--){var Q=E>>at&1;if(A!==R[0]&&(A=this.sqr(A)),Q===0&&U===0){k=0;continue}U<<=1,U|=Q,k++,!(k!==w&&(I!==0||at!==0))&&(A=this.mul(A,R[U]),k=0,U=0)}h=26}return A},kt.prototype.convertTo=function(u){var p=u.umod(this.m);return p===u?p.clone():p},kt.prototype.convertFrom=function(u){var p=u.clone();return p.red=null,p},i.mont=function(u){return new ae(u)};function ae(T){kt.call(this,T),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(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)}s(ae,kt),ae.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},ae.prototype.convertFrom=function(u){var p=this.imod(u.mul(this.rinv));return p.red=null,p},ae.prototype.imul=function(u,p){if(u.isZero()||p.isZero())return u.words[0]=0,u.length=1,u;var w=u.imul(p),R=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),I=w.isub(R).iushrn(this.shift),A=I;return I.cmp(this.m)>=0?A=I.isub(this.m):I.cmpn(0)<0&&(A=I.iadd(this.m)),A._forceRed(this)},ae.prototype.mul=function(u,p){if(u.isZero()||p.isZero())return new i(0)._forceRed(this);var w=u.mul(p),R=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),I=w.isub(R).iushrn(this.shift),A=I;return I.cmp(this.m)>=0?A=I.isub(this.m):I.cmpn(0)<0&&(A=I.iadd(this.m)),A._forceRed(this)},ae.prototype.invm=function(u){var p=this.imod(u._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(n,Nr)}(_s);var na=_s.exports;const ia=ni(na);var Is={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,t){var e=Ct,r=e.Buffer;function s(o,a){for(var l in o)a[l]=o[l]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=e:(s(e,t),t.Buffer=i);function i(o,a,l){return r(o,a,l)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,a,l){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,l)},i.alloc=function(o,a,l){if(typeof o!="number")throw new TypeError("Argument must be a number");var y=r(o);return a!==void 0?typeof l=="string"?y.fill(a,l):y.fill(a):y.fill(0),y},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}})(Is,Is.exports);var ff=Is.exports,Ti=ff.Buffer;function lf(n){if(n.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 r=0;r<n.length;r++){var s=n.charAt(r),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=r}var o=n.length,a=n.charAt(0),l=Math.log(o)/Math.log(256),y=Math.log(256)/Math.log(o);function x(C){if((Array.isArray(C)||C instanceof Uint8Array)&&(C=Ti.from(C)),!Ti.isBuffer(C))throw new TypeError("Expected Buffer");if(C.length===0)return"";for(var N=0,M=0,O=0,K=C.length;O!==K&&C[O]===0;)O++,N++;for(var X=(K-O)*y+1>>>0,V=new Uint8Array(X);O!==K;){for(var it=C[O],Z=0,D=X-1;(it!==0||Z<M)&&D!==-1;D--,Z++)it+=256*V[D]>>>0,V[D]=it%o>>>0,it=it/o>>>0;if(it!==0)throw new Error("Non-zero carry");M=Z,O++}for(var tt=X-M;tt!==X&&V[tt]===0;)tt++;for(var rt=a.repeat(N);tt<X;++tt)rt+=n.charAt(V[tt]);return rt}function _(C){if(typeof C!="string")throw new TypeError("Expected String");if(C.length===0)return Ti.alloc(0);for(var N=0,M=0,O=0;C[N]===a;)M++,N++;for(var K=(C.length-N)*l+1>>>0,X=new Uint8Array(K);C[N];){var V=t[C.charCodeAt(N)];if(V===255)return;for(var it=0,Z=K-1;(V!==0||it<O)&&Z!==-1;Z--,it++)V+=o*X[Z]>>>0,X[Z]=V%256>>>0,V=V/256>>>0;if(V!==0)throw new Error("Non-zero carry");O=it,N++}for(var D=K-O;D!==K&&X[D]===0;)D++;var tt=Ti.allocUnsafe(M+(K-D));tt.fill(0,0,M);for(var rt=M;D!==K;)tt[rt++]=X[D++];return tt}function L(C){var N=_(C);if(N)return N;throw new Error("Non-base"+o+" character")}return{encode:x,decodeUnsafe:_,decode:L}}var hf=lf,df=hf,pf="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",sa=df(pf);const ar=ni(sa),gf=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]),ln=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),hn=new Uint32Array(64);class yf extends Uo{constructor(){super(64,32,8,!1),this.A=ln[0]|0,this.B=ln[1]|0,this.C=ln[2]|0,this.D=ln[3]|0,this.E=ln[4]|0,this.F=ln[5]|0,this.G=ln[6]|0,this.H=ln[7]|0}get(){const{A:t,B:e,C:r,D:s,E:i,F:o,G:a,H:l}=this;return[t,e,r,s,i,o,a,l]}set(t,e,r,s,i,o,a,l){this.A=t|0,this.B=e|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=l|0}process(t,e){for(let _=0;_<16;_++,e+=4)hn[_]=t.getUint32(e,!1);for(let _=16;_<64;_++){const L=hn[_-15],C=hn[_-2],N=Hr(L,7)^Hr(L,18)^L>>>3,M=Hr(C,17)^Hr(C,19)^C>>>10;hn[_]=M+hn[_-7]+N+hn[_-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:l,G:y,H:x}=this;for(let _=0;_<64;_++){const L=Hr(a,6)^Hr(a,11)^Hr(a,25),C=x+L+pu(a,l,y)+gf[_]+hn[_]|0,M=(Hr(r,2)^Hr(r,13)^Hr(r,22))+gu(r,s,i)|0;x=y,y=l,l=a,a=o+C|0,o=i,i=s,s=r,r=C+M|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,y=y+this.G|0,x=x+this.H|0,this.set(r,s,i,o,a,l,y,x)}roundClean(){hn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const As=gs(()=>new yf);var lr={};function nn(n,t,e){return t<=n&&n<=e}function Mi(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function mf(n){for(var t=String(n),e=t.length,r=0,s=[];r<e;){var i=t.charCodeAt(r);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(r===e-1)s.push(65533);else{var o=n.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=i&1023,l=o&1023;s.push(65536+(a<<10)+l),r+=1}else s.push(65533)}r+=1}return s}function wf(n){for(var t="",e=0;e<n.length;++e){var r=n[e];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}var Pi=-1;function Bs(n){this.tokens=[].slice.call(n)}Bs.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Pi},prepend:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(n)},push:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.push(t.shift());else this.tokens.push(n)}};var qn=-1;function Rs(n,t){if(n)throw TypeError("Decoder error");return t||65533}var Ci="utf-8";function Li(n,t){if(!(this instanceof Li))return new Li(n,t);if(n=n!==void 0?String(n).toLowerCase():Ci,n!==Ci)throw new Error("Encoding not supported. Only utf-8 is supported");t=Mi(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 r;typeof t=="object"&&t instanceof ArrayBuffer?r=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):r=new Uint8Array(0),e=Mi(e),this._streaming||(this._decoder=new bf({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var s=new Bs(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==qn);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===qn)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),wf(i)}};function Ui(n,t){if(!(this instanceof Ui))return new Ui(n,t);if(n=n!==void 0?String(n).toLowerCase():Ci,n!==Ci)throw new Error("Encoding not supported. Only utf-8 is supported");t=Mi(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Ui.prototype={encode:function(t,e){t=t?String(t):"",e=Mi(e),this._streaming||(this._encoder=new xf(this._options)),this._streaming=!!e.stream;for(var r=[],s=new Bs(mf(t)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==qn);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==qn;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function bf(n){var t=n.fatal,e=0,r=0,s=0,i=128,o=191;this.handler=function(a,l){if(l===Pi&&s!==0)return s=0,Rs(t);if(l===Pi)return qn;if(s===0){if(nn(l,0,127))return l;if(nn(l,194,223))s=1,e=l-192;else if(nn(l,224,239))l===224&&(i=160),l===237&&(o=159),s=2,e=l-224;else if(nn(l,240,244))l===240&&(i=144),l===244&&(o=143),s=3,e=l-240;else return Rs(t);return e=e<<6*s,null}if(!nn(l,i,o))return e=s=r=0,i=128,o=191,a.prepend(l),Rs(t);if(i=128,o=191,r+=1,e+=l-128<<6*(s-r),r!==s)return null;var y=e;return e=s=r=0,y}}function xf(n){n.fatal,this.handler=function(t,e){if(e===Pi)return qn;if(nn(e,0,127))return e;var r,s;nn(e,128,2047)?(r=1,s=192):nn(e,2048,65535)?(r=2,s=224):nn(e,65536,1114111)&&(r=3,s=240);for(var i=[(e>>6*r)+s];r>0;){var o=e>>6*(r-1);i.push(128|o&63),r-=1}return i}}const vf=us(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Li,TextEncoder:Ui},Symbol.toStringTag,{value:"Module"})));var kf=Nr&&Nr.__createBinding||(Object.create?function(n,t,e,r){r===void 0&&(r=e),Object.defineProperty(n,r,{enumerable:!0,get:function(){return t[e]}})}:function(n,t,e,r){r===void 0&&(r=e),n[r]=t[e]}),Sf=Nr&&Nr.__setModuleDefault||(Object.create?function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}:function(n,t){n.default=t}),Vr=Nr&&Nr.__decorate||function(n,t,e,r){var s=arguments.length,i=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,t,e,r);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(i=(s<3?o(i):s>3?o(t,e,i):o(t,e))||i);return s>3&&i&&Object.defineProperty(t,e,i),i},Ef=Nr&&Nr.__importStar||function(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e in n)e!=="default"&&Object.hasOwnProperty.call(n,e)&&kf(t,n,e);return Sf(t,n),t},oa=Nr&&Nr.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(lr,"__esModule",{value:!0});var aa=lr.deserializeUnchecked=da=lr.deserialize=ha=lr.serialize=lr.BinaryReader=lr.BinaryWriter=lr.BorshError=lr.baseDecode=lr.baseEncode=void 0;const dn=oa(na),ca=oa(sa),_f=Ef(vf),If=typeof TextDecoder!="function"?_f.TextDecoder:TextDecoder,Af=new If("utf-8",{fatal:!0});function Bf(n){return typeof n=="string"&&(n=Buffer.from(n,"utf8")),ca.default.encode(Buffer.from(n))}lr.baseEncode=Bf;function Rf(n){return Buffer.from(ca.default.decode(n))}lr.baseDecode=Rf;const Ts=1024;class kr 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=kr;class ua{constructor(){this.buf=Buffer.alloc(Ts),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(Ts)]))}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(Ts)]),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 r of t)this.maybeResize(),e(r)}toArray(){return this.buf.subarray(0,this.length)}}lr.BinaryWriter=ua;function jr(n,t,e){const r=e.value;e.value=function(...s){try{return r.apply(this,s)}catch(i){if(i instanceof RangeError){const o=i.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new kr("Reached the end of buffer when deserializing")}throw i}}}class Rr{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 kr(`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 Af.decode(e)}catch(r){throw new kr(`Error decoding UTF-8 string: ${r}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),r=Array();for(let s=0;s<e;++s)r.push(t());return r}}Vr([jr],Rr.prototype,"readU8",null),Vr([jr],Rr.prototype,"readU16",null),Vr([jr],Rr.prototype,"readU32",null),Vr([jr],Rr.prototype,"readU64",null),Vr([jr],Rr.prototype,"readU128",null),Vr([jr],Rr.prototype,"readU256",null),Vr([jr],Rr.prototype,"readU512",null),Vr([jr],Rr.prototype,"readString",null),Vr([jr],Rr.prototype,"readFixedArray",null),Vr([jr],Rr.prototype,"readArray",null),lr.BinaryReader=Rr;function fa(n){return n.charAt(0).toUpperCase()+n.slice(1)}function En(n,t,e,r,s){try{if(typeof r=="string")s[`write${fa(r)}`](e);else if(r instanceof Array)if(typeof r[0]=="number"){if(e.length!==r[0])throw new kr(`Expecting byte array of length ${r[0]}, but got ${e.length} bytes`);s.writeFixedArray(e)}else if(r.length===2&&typeof r[1]=="number"){if(e.length!==r[1])throw new kr(`Expecting byte array of length ${r[1]}, but got ${e.length} bytes`);for(let i=0;i<r[1];i++)En(n,null,e[i],r[0],s)}else s.writeArray(e,i=>{En(n,t,i,r[0],s)});else if(r.kind!==void 0)switch(r.kind){case"option":{e==null?s.writeU8(0):(s.writeU8(1),En(n,t,e,r.type,s));break}case"map":{s.writeU32(e.size),e.forEach((i,o)=>{En(n,t,o,r.key,s),En(n,t,i,r.value,s)});break}default:throw new kr(`FieldType ${r} unrecognized`)}else la(n,e,s)}catch(i){throw i instanceof kr&&i.addToFieldPath(t),i}}function la(n,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const r=n.get(t.constructor);if(!r)throw new kr(`Class ${t.constructor.name} is missing in schema`);if(r.kind==="struct")r.fields.map(([s,i])=>{En(n,s,t[s],i,e)});else if(r.kind==="enum"){const s=t[r.field];for(let i=0;i<r.values.length;++i){const[o,a]=r.values[i];if(o===s){e.writeU8(i),En(n,o,t[o],a,e);break}}}else throw new kr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function Tf(n,t,e=ua){const r=new e;return la(n,t,r),r.toArray()}var ha=lr.serialize=Tf;function _n(n,t,e,r){try{if(typeof e=="string")return r[`read${fa(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return r.readFixedArray(e[0]);if(typeof e[1]=="number"){const s=[];for(let i=0;i<e[1];i++)s.push(_n(n,null,e[0],r));return s}else return r.readArray(()=>_n(n,t,e[0],r))}if(e.kind==="option")return r.readU8()?_n(n,t,e.type,r):void 0;if(e.kind==="map"){let s=new Map;const i=r.readU32();for(let o=0;o<i;o++){const a=_n(n,t,e.key,r),l=_n(n,t,e.value,r);s.set(a,l)}return s}return Ms(n,e,r)}catch(s){throw s instanceof kr&&s.addToFieldPath(t),s}}function Ms(n,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const r=n.get(t);if(!r)throw new kr(`Class ${t.name} is missing in schema`);if(r.kind==="struct"){const s={};for(const[i,o]of n.get(t).fields)s[i]=_n(n,i,o,e);return new t(s)}if(r.kind==="enum"){const s=e.readU8();if(s>=r.values.length)throw new kr(`Enum index: ${s} is out of range`);const[i,o]=r.values[s],a=_n(n,i,o,e);return new t({[i]:a})}throw new kr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function Mf(n,t,e,r=Rr){const s=new r(e),i=Ms(n,t,s);if(s.offset<e.length)throw new kr(`Unexpected ${e.length-s.offset} bytes after deserialized data`);return i}var da=lr.deserialize=Mf;function Pf(n,t,e,r=Rr){const s=new r(e);return Ms(n,t,s)}aa=lr.deserializeUnchecked=Pf;var H={};Object.defineProperty(H,"__esModule",{value:!0}),H.s16=H.s8=H.nu64be=H.u48be=H.u40be=H.u32be=H.u24be=H.u16be=hr=H.nu64=H.u48=H.u40=It=H.u32=H.u24=Lr=H.u16=ge=H.u8=pn=H.offset=H.greedy=H.Constant=H.UTF8=H.CString=H.Blob=H.Boolean=H.BitField=H.BitStructure=H.VariantLayout=H.Union=H.UnionLayoutDiscriminator=H.UnionDiscriminator=H.Structure=H.Sequence=H.DoubleBE=H.Double=H.FloatBE=H.Float=H.NearInt64BE=H.NearInt64=H.NearUInt64BE=H.NearUInt64=H.IntBE=H.Int=H.UIntBE=H.UInt=H.OffsetLayout=H.GreedyCount=H.ExternalLayout=H.bindConstructorLayout=H.nameWithProperty=H.Layout=H.uint8ArrayToBuffer=H.checkUint8Array=void 0,H.constant=H.utf8=H.cstr=Ke=H.blob=H.unionLayoutDiscriminator=H.union=dr=H.seq=H.bits=At=H.struct=H.f64be=H.f64=H.f32be=H.f32=H.ns64be=H.s48be=H.s40be=H.s32be=H.s24be=H.s16be=Tr=H.ns64=H.s48=H.s40=H.s32=H.s24=void 0;const Ps=Ct;function Hn(n){if(!(n instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}H.checkUint8Array=Hn;function be(n){return Hn(n),Ps.Buffer.from(n.buffer,n.byteOffset,n.length)}H.uint8ArrayToBuffer=be;class Me{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){}}H.Layout=Me;function Cs(n,t){return t.property?n+"["+t.property+"]":n}H.nameWithProperty=Cs;function Cf(n,t){if(typeof n!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(n,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Me))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");n.layout_=t,t.boundConstructor_=n,t.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(n,"decode",{value(e,r){return t.decode(e,r)},writable:!0})}H.bindConstructorLayout=Cf;class Er extends Me{isCount(){throw new Error("ExternalLayout is abstract")}}H.ExternalLayout=Er;class pa extends Er{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){Hn(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}H.GreedyCount=pa;class Ls extends Er{constructor(t,e=0,r){if(!(t instanceof Me))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||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,r=0){return this.layout.encode(t,e,r+this.offset)}}H.OffsetLayout=Ls;class Cr extends Me{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readUIntLE(e,this.span)}encode(t,e,r=0){return be(e).writeUIntLE(t,r,this.span),this.span}}H.UInt=Cr;class zr extends Me{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readUIntBE(e,this.span)}encode(t,e,r=0){return be(e).writeUIntBE(t,r,this.span),this.span}}H.UIntBE=zr;class In extends Me{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readIntLE(e,this.span)}encode(t,e,r=0){return be(e).writeIntLE(t,r,this.span),this.span}}H.Int=In;class Vn extends Me{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readIntBE(e,this.span)}encode(t,e,r=0){return be(e).writeIntBE(t,r,this.span),this.span}}H.IntBE=Vn;const Us=Math.pow(2,32);function Oi(n){const t=Math.floor(n/Us),e=n-t*Us;return{hi32:t,lo32:e}}function Ni(n,t){return n*Us+t}class ga extends Me{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),s=r.readUInt32LE(e),i=r.readUInt32LE(e+4);return Ni(i,s)}encode(t,e,r=0){const s=Oi(t),i=be(e);return i.writeUInt32LE(s.lo32,r),i.writeUInt32LE(s.hi32,r+4),8}}H.NearUInt64=ga;class ya extends Me{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),s=r.readUInt32BE(e),i=r.readUInt32BE(e+4);return Ni(s,i)}encode(t,e,r=0){const s=Oi(t),i=be(e);return i.writeUInt32BE(s.hi32,r),i.writeUInt32BE(s.lo32,r+4),8}}H.NearUInt64BE=ya;class ma extends Me{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),s=r.readUInt32LE(e),i=r.readInt32LE(e+4);return Ni(i,s)}encode(t,e,r=0){const s=Oi(t),i=be(e);return i.writeUInt32LE(s.lo32,r),i.writeInt32LE(s.hi32,r+4),8}}H.NearInt64=ma;class wa extends Me{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),s=r.readInt32BE(e),i=r.readUInt32BE(e+4);return Ni(s,i)}encode(t,e,r=0){const s=Oi(t),i=be(e);return i.writeInt32BE(s.hi32,r),i.writeUInt32BE(s.lo32,r+4),8}}H.NearInt64BE=wa;class ba extends Me{constructor(t){super(4,t)}decode(t,e=0){return be(t).readFloatLE(e)}encode(t,e,r=0){return be(e).writeFloatLE(t,r),4}}H.Float=ba;class xa extends Me{constructor(t){super(4,t)}decode(t,e=0){return be(t).readFloatBE(e)}encode(t,e,r=0){return be(e).writeFloatBE(t,r),4}}H.FloatBE=xa;class va extends Me{constructor(t){super(8,t)}decode(t,e=0){return be(t).readDoubleLE(e)}encode(t,e,r=0){return be(e).writeDoubleLE(t,r),8}}H.Double=va;class ka extends Me{constructor(t){super(8,t)}decode(t,e=0){return be(t).readDoubleBE(e)}encode(t,e,r=0){return be(e).writeDoubleBE(t,r),8}}H.DoubleBE=ka;class Sa extends Me{constructor(t,e,r){if(!(t instanceof Me))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Er&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let s=-1;!(e instanceof Er)&&0<t.span&&(s=e*t.span),super(s,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,s=this.count;if(s instanceof Er&&(s=s.decode(t,e)),0<this.elementLayout.span)r=s*this.elementLayout.span;else{let i=0;for(;i<s;)r+=this.elementLayout.getSpan(t,e+r),++i}return r}decode(t,e=0){const r=[];let s=0,i=this.count;for(i instanceof Er&&(i=i.decode(t,e));s<i;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),s+=1;return r}encode(t,e,r=0){const s=this.elementLayout,i=t.reduce((o,a)=>o+s.encode(a,e,r+o),0);return this.count instanceof Er&&this.count.encode(t.length,e,r),i}}H.Sequence=Sa;class Ea extends Me{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((i,o)=>i&&o instanceof Me,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const i of t)if(0>i.span&&i.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let s=-1;try{s=t.reduce((i,o)=>i+o.getSpan(),0)}catch{}super(s,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce((s,i)=>{const o=i.getSpan(t,e);return e+=o,s+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e=0){Hn(t);const r=this.makeDestinationObject();for(const s of this.fields)if(s.property!==void 0&&(r[s.property]=s.decode(t,e)),e+=s.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r=0){const s=r;let i=0,o=0;for(const a of this.fields){let l=a.span;if(o=0<l?l:0,a.property!==void 0){const y=t[a.property];y!==void 0&&(o=a.encode(y,e,r),0>l&&(l=a.getSpan(e,r)))}i=r,r+=l}return i+o-s}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.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 r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}H.Structure=Ea;class Os{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}}H.UnionDiscriminator=Os;class Fi extends Os{constructor(t,e){if(!(t instanceof Er&&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,r){return this.layout.encode(t,e,r)}}H.UnionLayoutDiscriminator=Fi;class Ns extends Me{constructor(t,e,r){let s;if(t instanceof Cr||t instanceof zr)s=new Fi(new Ls(t));else if(t instanceof Er&&t.isCount())s=new Fi(t);else if(t instanceof Os)s=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 Me))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 i=-1;e&&(i=e.span,0<=i&&(t instanceof Cr||t instanceof zr)&&(i+=s.layout.span)),super(i,r),this.discriminator=s,this.usesPrefixDiscriminator=t instanceof Cr||t instanceof zr,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.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 r=this.registry[e];if(r.property&&Object.prototype.hasOwnProperty.call(t,r.property))return r}throw new Error("unable to infer src variant")}decode(t,e=0){let r;const s=this.discriminator,i=s.decode(t,e),o=this.registry[i];if(o===void 0){const a=this.defaultLayout;let l=0;this.usesPrefixDiscriminator&&(l=s.layout.span),r=this.makeDestinationObject(),r[s.property]=i,r[a.property]=a.decode(t,e+l)}else r=o.decode(t,e);return r}encode(t,e,r=0){const s=this.getSourceVariant(t);if(s===void 0){const i=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=i.layout.span),i.encode(t[i.property],e,r),a+o.encode(t[o.property],e,r+a)}return s.encode(t,e,r)}addVariant(t,e,r){const s=new _a(this,t,e,r);return this.registry[t]=s,s}getVariant(t,e=0){let r;return t instanceof Uint8Array?r=this.discriminator.decode(t,e):r=t,this.registry[r]}}H.Union=Ns;class _a extends Me{constructor(t,e,r,s){if(!(t instanceof Ns))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 r=="string"&&s===void 0&&(s=r,r=null),r){if(!(r instanceof Me))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof s!="string")throw new TypeError("variant must have a String property")}let i=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,s),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span);let s=0;return this.layout&&(s=this.layout.getSpan(t,e+r)),r+s}decode(t,e=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let s=0;return this.union.usesPrefixDiscriminator&&(s=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+s):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let s=0;if(this.union.usesPrefixDiscriminator&&(s=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,r);let i=s;if(this.layout&&(this.layout.encode(t[this.property],e,r+s),i+=this.layout.getSpan(e,r+s),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}H.VariantLayout=_a;function jn(n){return 0>n&&(n+=4294967296),n}class Fs extends Me{constructor(t,e,r){if(!(t instanceof Cr||t instanceof zr))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&r===void 0&&(r=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let s=0;this._packedSetValue=function(i){return s=jn(i),this},this._packedGetValue=function(){return s}}decode(t,e=0){const r=this.makeDestinationObject(),s=this.word.decode(t,e);this._packedSetValue(s);for(const i of this.fields)i.property!==void 0&&(r[i.property]=i.decode(t));return r}encode(t,e,r=0){const s=this.word.decode(e,r);this._packedSetValue(s);for(const i of this.fields)if(i.property!==void 0){const o=t[i.property];o!==void 0&&i.encode(o)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new zs(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new Ia(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}}H.BitStructure=Fs;class zs{constructor(t,e,r){if(!(t instanceof Fs))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const s=8*t.span,i=t.fields.reduce((o,a)=>o+a.bits,0);if(e+i>s)throw new Error("bits too long for span remainder ("+(s-i)+" of "+s+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=s-i-e),this.wordMask=jn(this.valueMask<<this.start),this.property=r}decode(t,e){const r=this.container._packedGetValue();return jn(r&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==jn(t&this.valueMask))throw new TypeError(Cs("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=jn(t<<this.start);this.container._packedSetValue(jn(e&~this.wordMask)|r)}}H.BitField=zs;let Ia=class extends zs{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)}};H.Boolean=Ia;class Aa extends Me{constructor(t,e){if(!(t instanceof Er&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Er||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e=0){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),be(t).slice(e,e+r)}encode(t,e,r){let s=this.length;if(this.length instanceof Er&&(s=t.length),!(t instanceof Uint8Array&&s===t.length))throw new TypeError(Cs("Blob.encode",this)+" requires (length "+s+") Uint8Array as src");if(r+s>e.length)throw new RangeError("encoding overruns Uint8Array");const i=be(t);return be(e).write(i.toString("hex"),r,s,"hex"),this.length instanceof Er&&this.length.encode(s,e,r),s}}H.Blob=Aa;class Ba extends Me{constructor(t){super(-1,t)}getSpan(t,e=0){Hn(t);let r=e;for(;r<t.length&&t[r]!==0;)r+=1;return 1+r-e}decode(t,e=0){const r=this.getSpan(t,e);return be(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const s=Ps.Buffer.from(t,"utf8"),i=s.length;if(r+i>e.length)throw new RangeError("encoding overruns Buffer");const o=be(e);return s.copy(o,r),o[r+i]=0,i+1}}H.CString=Ba;class Ra extends Me{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 Hn(t),t.length-e}decode(t,e=0){const r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return be(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const s=Ps.Buffer.from(t,"utf8"),i=s.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return s.copy(be(e),r),i}}H.UTF8=Ra;class Ta extends Me{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}}H.Constant=Ta,H.greedy=(n,t)=>new pa(n,t);var pn=H.offset=(n,t,e)=>new Ls(n,t,e),ge=H.u8=n=>new Cr(1,n),Lr=H.u16=n=>new Cr(2,n);H.u24=n=>new Cr(3,n);var It=H.u32=n=>new Cr(4,n);H.u40=n=>new Cr(5,n),H.u48=n=>new Cr(6,n);var hr=H.nu64=n=>new ga(n);H.u16be=n=>new zr(2,n),H.u24be=n=>new zr(3,n),H.u32be=n=>new zr(4,n),H.u40be=n=>new zr(5,n),H.u48be=n=>new zr(6,n),H.nu64be=n=>new ya(n),H.s8=n=>new In(1,n),H.s16=n=>new In(2,n),H.s24=n=>new In(3,n),H.s32=n=>new In(4,n),H.s40=n=>new In(5,n),H.s48=n=>new In(6,n);var Tr=H.ns64=n=>new ma(n);H.s16be=n=>new Vn(2,n),H.s24be=n=>new Vn(3,n),H.s32be=n=>new Vn(4,n),H.s40be=n=>new Vn(5,n),H.s48be=n=>new Vn(6,n),H.ns64be=n=>new wa(n),H.f32=n=>new ba(n),H.f32be=n=>new xa(n),H.f64=n=>new va(n),H.f64be=n=>new ka(n);var At=H.struct=(n,t,e)=>new Ea(n,t,e);H.bits=(n,t,e)=>new Fs(n,t,e);var dr=H.seq=(n,t,e)=>new Sa(n,t,e);H.union=(n,t,e)=>new Ns(n,t,e),H.unionLayoutDiscriminator=(n,t)=>new Fi(n,t);var Ke=H.blob=(n,t)=>new Aa(n,t);H.cstr=n=>new Ba(n),H.utf8=(n,t)=>new Ra(n,t),H.constant=(n,t)=>new Ta(n,t);var ai={};Object.defineProperty(ai,"__esModule",{value:!0});function Lf(n){{const t=Buffer.from(n);t.reverse();const e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}var Uf=ai.toBigIntLE=Lf;function Of(n){{const t=n.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}ai.toBigIntBE=Of;function Nf(n,t){{const e=n.toString(16),r=Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return r.reverse(),r}}var Ma=ai.toBufferLE=Nf;function Ff(n,t){{const e=n.toString(16);return Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}}ai.toBufferBE=Ff;class zf extends TypeError{constructor(t,e){let r;const{message:s,explanation:i,...o}=t,{path:a}=t,l=a.length===0?s:`At path: ${a.join(".")} -- ${s}`;super(i??l),i!=null&&(this.cause=l),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}}function Kf(n){return ci(n)&&typeof n[Symbol.iterator]=="function"}function ci(n){return typeof n=="object"&&n!=null}function zi(n){return ci(n)&&!Array.isArray(n)}function Kr(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function Wf(n){const{done:t,value:e}=n.next();return t?void 0:e}function Df(n,t,e,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:s,branch:i}=t,{type:o}=e,{refinement:a,message:l=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${Kr(r)}\``}=n;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...n,message:l}}function*Pa(n,t,e,r){Kf(n)||(n=[n]);for(const s of n){const i=Df(s,t,e,r);i&&(yield i)}}function*Ks(n,t,e={}){const{path:r=[],branch:s=[n],coerce:i=!1,mask:o=!1}=e,a={path:r,branch:s,mask:o};i&&(n=t.coercer(n,a));let l="valid";for(const y of t.validator(n,a))y.explanation=e.message,l="not_valid",yield[y,void 0];for(let[y,x,_]of t.entries(n,a)){const L=Ks(x,_,{path:y===void 0?r:[...r,y],branch:y===void 0?s:[...s,x],coerce:i,mask:o,message:e.message});for(const C of L)C[0]?(l=C[0].refinement!=null?"not_refined":"not_valid",yield[C[0],void 0]):i&&(x=C[1],y===void 0?n=x:n instanceof Map?n.set(y,x):n instanceof Set?n.add(x):ci(n)&&(x!==void 0||y in n)&&(n[y]=x))}if(l!=="not_valid")for(const y of t.refiner(n,a))y.explanation=e.message,l="not_refined",yield[y,void 0];l==="valid"&&(yield[void 0,n])}let Gr=class{constructor(t){const{type:e,schema:r,validator:s,refiner:i,coercer:o=l=>l,entries:a=function*(){}}=t;this.type=e,this.schema=r,this.entries=a,this.coercer=o,s?this.validator=(l,y)=>{const x=s(l,y);return Pa(x,y,this,l)}:this.validator=()=>[],i?this.refiner=(l,y)=>{const x=i(l,y);return Pa(x,y,this,l)}:this.refiner=()=>[]}assert(t,e){return Ca(t,this,e)}create(t,e){return yt(t,this,e)}is(t){return La(t,this)}mask(t,e){return $f(t,this,e)}validate(t,e={}){return ui(t,this,e)}};function Ca(n,t,e){const r=ui(n,t,{message:e});if(r[0])throw r[0]}function yt(n,t,e){const r=ui(n,t,{coerce:!0,message:e});if(r[0])throw r[0];return r[1]}function $f(n,t,e){const r=ui(n,t,{coerce:!0,mask:!0,message:e});if(r[0])throw r[0];return r[1]}function La(n,t){return!ui(n,t)[0]}function ui(n,t,e={}){const r=Ks(n,t,e),s=Wf(r);return s[0]?[new zf(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function An(n,t){return new Gr({type:n,schema:null,validator:t})}function qf(){return An("any",()=>!0)}function wt(n){return new Gr({type:"array",schema:n,*entries(t){if(n&&Array.isArray(t))for(const[e,r]of t.entries())yield[e,r,n]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${Kr(t)}`}})}function Yr(){return An("boolean",n=>typeof n=="boolean")}function Ws(n){return An("instance",t=>t instanceof n||`Expected a \`${n.name}\` instance, but received: ${Kr(t)}`)}function He(n){const t=Kr(n),e=typeof n;return new Gr({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${t}\`, but received: ${Kr(r)}`}})}function Hf(){return An("never",()=>!1)}function bt(n){return new Gr({...n,validator:(t,e)=>t===null||n.validator(t,e),refiner:(t,e)=>t===null||n.refiner(t,e)})}function q(){return An("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${Kr(n)}`)}function Ot(n){return new Gr({...n,validator:(t,e)=>t===void 0||n.validator(t,e),refiner:(t,e)=>t===void 0||n.refiner(t,e)})}function Ua(n,t){return new Gr({type:"record",schema:null,*entries(e){if(ci(e))for(const r in e){const s=e[r];yield[r,r,n],yield[r,s,t]}},validator(e){return zi(e)||`Expected an object, but received: ${Kr(e)}`},coercer(e){return zi(e)?{...e}:e}})}function dt(){return An("string",n=>typeof n=="string"||`Expected a string, but received: ${Kr(n)}`)}function Ds(n){const t=Hf();return new Gr({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const r=Math.max(n.length,e.length);for(let s=0;s<r;s++)yield[s,e[s],n[s]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Kr(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function ot(n){const t=Object.keys(n);return new Gr({type:"type",schema:n,*entries(e){if(ci(e))for(const r of t)yield[r,e[r],n[r]]},validator(e){return zi(e)||`Expected an object, but received: ${Kr(e)}`},coercer(e){return zi(e)?{...e}:e}})}function Sr(n){const t=n.map(e=>e.type).join(" | ");return new Gr({type:"union",schema:null,coercer(e,r){for(const s of n){const[i,o]=s.validate(e,{coerce:!0,mask:r.mask});if(!i)return o}return e},validator(e,r){const s=[];for(const i of n){const[...o]=Ks(e,i,r),[a]=o;if(a[0])for(const[l]of o)l&&s.push(l);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Kr(e)}`,...s]}})}function Gn(){return An("unknown",()=>!0)}function fi(n,t,e){return new Gr({...n,coercer:(r,s)=>La(r,t)?n.coercer(e(r,s),s):n.coercer(r,s)})}var Ki,Vf=new Uint8Array(16);function Oa(){if(!Ki&&(Ki=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Ki))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ki(Vf)}const jf=/^(?:[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 Wi(n){return typeof n=="string"&&jf.test(n)}for(var pr=[],$s=0;$s<256;++$s)pr.push(($s+256).toString(16).substr(1));function Di(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(pr[n[t+0]]+pr[n[t+1]]+pr[n[t+2]]+pr[n[t+3]]+"-"+pr[n[t+4]]+pr[n[t+5]]+"-"+pr[n[t+6]]+pr[n[t+7]]+"-"+pr[n[t+8]]+pr[n[t+9]]+"-"+pr[n[t+10]]+pr[n[t+11]]+pr[n[t+12]]+pr[n[t+13]]+pr[n[t+14]]+pr[n[t+15]]).toLowerCase();if(!Wi(e))throw TypeError("Stringified UUID is invalid");return e}var Na,qs,Hs=0,Vs=0;function Gf(n,t,e){var r=t&&e||0,s=t||new Array(16);n=n||{};var i=n.node||Na,o=n.clockseq!==void 0?n.clockseq:qs;if(i==null||o==null){var a=n.random||(n.rng||Oa)();i==null&&(i=Na=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=qs=(a[6]<<8|a[7])&16383)}var l=n.msecs!==void 0?n.msecs:Date.now(),y=n.nsecs!==void 0?n.nsecs:Vs+1,x=l-Hs+(y-Vs)/1e4;if(x<0&&n.clockseq===void 0&&(o=o+1&16383),(x<0||l>Hs)&&n.nsecs===void 0&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Hs=l,Vs=y,qs=o,l+=122192928e5;var _=((l&268435455)*1e4+y)%4294967296;s[r++]=_>>>24&255,s[r++]=_>>>16&255,s[r++]=_>>>8&255,s[r++]=_&255;var L=l/4294967296*1e4&268435455;s[r++]=L>>>8&255,s[r++]=L&255,s[r++]=L>>>24&15|16,s[r++]=L>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var C=0;C<6;++C)s[r+C]=i[C];return t||Di(s)}function Fa(n){if(!Wi(n))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(n.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(n.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(n.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(n.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(n.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 Yf(n){n=unescape(encodeURIComponent(n));for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}var Zf="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Jf="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function za(n,t,e){function r(s,i,o,a){if(typeof s=="string"&&(s=Yf(s)),typeof i=="string"&&(i=Fa(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var l=new Uint8Array(16+s.length);if(l.set(i),l.set(s,i.length),l=e(l),l[6]=l[6]&15|t,l[8]=l[8]&63|128,o){a=a||0;for(var y=0;y<16;++y)o[a+y]=l[y];return o}return Di(l)}try{r.name=n}catch{}return r.DNS=Zf,r.URL=Jf,r}function Xf(n){if(typeof n=="string"){var t=unescape(encodeURIComponent(n));n=new Uint8Array(t.length);for(var e=0;e<t.length;++e)n[e]=t.charCodeAt(e)}return Qf(tl(el(n),n.length*8))}function Qf(n){for(var t=[],e=n.length*32,r="0123456789abcdef",s=0;s<e;s+=8){var i=n[s>>5]>>>s%32&255,o=parseInt(r.charAt(i>>>4&15)+r.charAt(i&15),16);t.push(o)}return t}function Ka(n){return(n+64>>>9<<4)+14+1}function tl(n,t){n[t>>5]|=128<<t%32,n[Ka(t)-1]=t;for(var e=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<n.length;o+=16){var a=e,l=r,y=s,x=i;e=gr(e,r,s,i,n[o],7,-680876936),i=gr(i,e,r,s,n[o+1],12,-389564586),s=gr(s,i,e,r,n[o+2],17,606105819),r=gr(r,s,i,e,n[o+3],22,-1044525330),e=gr(e,r,s,i,n[o+4],7,-176418897),i=gr(i,e,r,s,n[o+5],12,1200080426),s=gr(s,i,e,r,n[o+6],17,-1473231341),r=gr(r,s,i,e,n[o+7],22,-45705983),e=gr(e,r,s,i,n[o+8],7,1770035416),i=gr(i,e,r,s,n[o+9],12,-1958414417),s=gr(s,i,e,r,n[o+10],17,-42063),r=gr(r,s,i,e,n[o+11],22,-1990404162),e=gr(e,r,s,i,n[o+12],7,1804603682),i=gr(i,e,r,s,n[o+13],12,-40341101),s=gr(s,i,e,r,n[o+14],17,-1502002290),r=gr(r,s,i,e,n[o+15],22,1236535329),e=yr(e,r,s,i,n[o+1],5,-165796510),i=yr(i,e,r,s,n[o+6],9,-1069501632),s=yr(s,i,e,r,n[o+11],14,643717713),r=yr(r,s,i,e,n[o],20,-373897302),e=yr(e,r,s,i,n[o+5],5,-701558691),i=yr(i,e,r,s,n[o+10],9,38016083),s=yr(s,i,e,r,n[o+15],14,-660478335),r=yr(r,s,i,e,n[o+4],20,-405537848),e=yr(e,r,s,i,n[o+9],5,568446438),i=yr(i,e,r,s,n[o+14],9,-1019803690),s=yr(s,i,e,r,n[o+3],14,-187363961),r=yr(r,s,i,e,n[o+8],20,1163531501),e=yr(e,r,s,i,n[o+13],5,-1444681467),i=yr(i,e,r,s,n[o+2],9,-51403784),s=yr(s,i,e,r,n[o+7],14,1735328473),r=yr(r,s,i,e,n[o+12],20,-1926607734),e=mr(e,r,s,i,n[o+5],4,-378558),i=mr(i,e,r,s,n[o+8],11,-2022574463),s=mr(s,i,e,r,n[o+11],16,1839030562),r=mr(r,s,i,e,n[o+14],23,-35309556),e=mr(e,r,s,i,n[o+1],4,-1530992060),i=mr(i,e,r,s,n[o+4],11,1272893353),s=mr(s,i,e,r,n[o+7],16,-155497632),r=mr(r,s,i,e,n[o+10],23,-1094730640),e=mr(e,r,s,i,n[o+13],4,681279174),i=mr(i,e,r,s,n[o],11,-358537222),s=mr(s,i,e,r,n[o+3],16,-722521979),r=mr(r,s,i,e,n[o+6],23,76029189),e=mr(e,r,s,i,n[o+9],4,-640364487),i=mr(i,e,r,s,n[o+12],11,-421815835),s=mr(s,i,e,r,n[o+15],16,530742520),r=mr(r,s,i,e,n[o+2],23,-995338651),e=wr(e,r,s,i,n[o],6,-198630844),i=wr(i,e,r,s,n[o+7],10,1126891415),s=wr(s,i,e,r,n[o+14],15,-1416354905),r=wr(r,s,i,e,n[o+5],21,-57434055),e=wr(e,r,s,i,n[o+12],6,1700485571),i=wr(i,e,r,s,n[o+3],10,-1894986606),s=wr(s,i,e,r,n[o+10],15,-1051523),r=wr(r,s,i,e,n[o+1],21,-2054922799),e=wr(e,r,s,i,n[o+8],6,1873313359),i=wr(i,e,r,s,n[o+15],10,-30611744),s=wr(s,i,e,r,n[o+6],15,-1560198380),r=wr(r,s,i,e,n[o+13],21,1309151649),e=wr(e,r,s,i,n[o+4],6,-145523070),i=wr(i,e,r,s,n[o+11],10,-1120210379),s=wr(s,i,e,r,n[o+2],15,718787259),r=wr(r,s,i,e,n[o+9],21,-343485551),e=gn(e,a),r=gn(r,l),s=gn(s,y),i=gn(i,x)}return[e,r,s,i]}function el(n){if(n.length===0)return[];for(var t=n.length*8,e=new Uint32Array(Ka(t)),r=0;r<t;r+=8)e[r>>5]|=(n[r/8]&255)<<r%32;return e}function gn(n,t){var e=(n&65535)+(t&65535),r=(n>>16)+(t>>16)+(e>>16);return r<<16|e&65535}function rl(n,t){return n<<t|n>>>32-t}function $i(n,t,e,r,s,i){return gn(rl(gn(gn(t,n),gn(r,i)),s),e)}function gr(n,t,e,r,s,i,o){return $i(t&e|~t&r,n,t,s,i,o)}function yr(n,t,e,r,s,i,o){return $i(t&r|e&~r,n,t,s,i,o)}function mr(n,t,e,r,s,i,o){return $i(t^e^r,n,t,s,i,o)}function wr(n,t,e,r,s,i,o){return $i(e^(t|~r),n,t,s,i,o)}var nl=za("v3",48,Xf);const il=nl;function sl(n,t,e){n=n||{};var r=n.random||(n.rng||Oa)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){e=e||0;for(var s=0;s<16;++s)t[e+s]=r[s];return t}return Di(r)}function ol(n,t,e,r){switch(n){case 0:return t&e^~t&r;case 1:return t^e^r;case 2:return t&e^t&r^e&r;case 3:return t^e^r}}function js(n,t){return n<<t|n>>>32-t}function al(n){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){var r=unescape(encodeURIComponent(n));n=[];for(var s=0;s<r.length;++s)n.push(r.charCodeAt(s))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var i=n.length/4+2,o=Math.ceil(i/16),a=new Array(o),l=0;l<o;++l){for(var y=new Uint32Array(16),x=0;x<16;++x)y[x]=n[l*64+x*4]<<24|n[l*64+x*4+1]<<16|n[l*64+x*4+2]<<8|n[l*64+x*4+3];a[l]=y}a[o-1][14]=(n.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(n.length-1)*8&4294967295;for(var _=0;_<o;++_){for(var L=new Uint32Array(80),C=0;C<16;++C)L[C]=a[_][C];for(var N=16;N<80;++N)L[N]=js(L[N-3]^L[N-8]^L[N-14]^L[N-16],1);for(var M=e[0],O=e[1],K=e[2],X=e[3],V=e[4],it=0;it<80;++it){var Z=Math.floor(it/20),D=js(M,5)+ol(Z,O,K,X)+V+t[Z]+L[it]>>>0;V=X,X=K,K=js(O,30)>>>0,O=M,M=D}e[0]=e[0]+M>>>0,e[1]=e[1]+O>>>0,e[2]=e[2]+K>>>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 cl=za("v5",80,al);const ul=cl,fl="00000000-0000-0000-0000-000000000000";function ll(n){if(!Wi(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const Wa=us(Object.freeze(Object.defineProperty({__proto__:null,NIL:fl,parse:Fa,stringify:Di,v1:Gf,v3:il,v4:sl,v5:ul,validate:Wi,version:ll},Symbol.toStringTag,{value:"Module"}))),hl=Wa.v4;var dl=function(n,t,e,r){if(typeof n!="string")throw new TypeError(n+" must be a string");r=r||{};const s=typeof r.version=="number"?r.version:2;if(s!==1&&s!==2)throw new TypeError(s+" must be 1 or 2");const i={method:n};if(s===2&&(i.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");i.params=t}if(typeof e>"u"){const o=typeof r.generator=="function"?r.generator:function(){return hl()};i.id=o(i,r)}else s===2&&e===null?r.notificationIdNull&&(i.id=null):i.id=e;return i};const pl=Wa.v4,gl=dl,li=function(n,t){if(!(this instanceof li))return new li(n,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 pl()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=n};var yl=li;li.prototype.request=function(n,t,e,r){const s=this;let i=null;const o=Array.isArray(n)&&typeof t=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&n&&typeof n=="object"&&typeof t=="function")r=t,i=n;else{typeof e=="function"&&(r=e,e=void 0);const y=typeof r=="function";try{i=gl(n,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(x){if(y)return r(x);throw x}if(!y)return i}let l;try{l=JSON.stringify(i,this.options.replacer)}catch(y){return r(y)}return this.callServer(l,function(y,x){s._parseResponse(y,x,r)}),i},li.prototype._parseResponse=function(n,t,e){if(n){e(n);return}if(!t)return e();let r;try{r=JSON.parse(t,this.options.reviver)}catch(s){return e(s)}if(e.length===3)if(Array.isArray(r)){const s=function(o){return typeof o.error<"u"},i=function(o){return!s(o)};return e(null,r.filter(s),r.filter(i))}else return e(null,r.error,r.result);e(null,r)};const ml=ni(yl);var Da={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function s(l,y,x){this.fn=l,this.context=y,this.once=x||!1}function i(l,y,x,_,L){if(typeof x!="function")throw new TypeError("The listener must be a function");var C=new s(x,_||l,L),N=e?e+y:y;return l._events[N]?l._events[N].fn?l._events[N]=[l._events[N],C]:l._events[N].push(C):(l._events[N]=C,l._eventsCount++),l}function o(l,y){--l._eventsCount===0?l._events=new r:delete l._events[y]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var y=[],x,_;if(this._eventsCount===0)return y;for(_ in x=this._events)t.call(x,_)&&y.push(e?_.slice(1):_);return Object.getOwnPropertySymbols?y.concat(Object.getOwnPropertySymbols(x)):y},a.prototype.listeners=function(y){var x=e?e+y:y,_=this._events[x];if(!_)return[];if(_.fn)return[_.fn];for(var L=0,C=_.length,N=new Array(C);L<C;L++)N[L]=_[L].fn;return N},a.prototype.listenerCount=function(y){var x=e?e+y:y,_=this._events[x];return _?_.fn?1:_.length:0},a.prototype.emit=function(y,x,_,L,C,N){var M=e?e+y:y;if(!this._events[M])return!1;var O=this._events[M],K=arguments.length,X,V;if(O.fn){switch(O.once&&this.removeListener(y,O.fn,void 0,!0),K){case 1:return O.fn.call(O.context),!0;case 2:return O.fn.call(O.context,x),!0;case 3:return O.fn.call(O.context,x,_),!0;case 4:return O.fn.call(O.context,x,_,L),!0;case 5:return O.fn.call(O.context,x,_,L,C),!0;case 6:return O.fn.call(O.context,x,_,L,C,N),!0}for(V=1,X=new Array(K-1);V<K;V++)X[V-1]=arguments[V];O.fn.apply(O.context,X)}else{var it=O.length,Z;for(V=0;V<it;V++)switch(O[V].once&&this.removeListener(y,O[V].fn,void 0,!0),K){case 1:O[V].fn.call(O[V].context);break;case 2:O[V].fn.call(O[V].context,x);break;case 3:O[V].fn.call(O[V].context,x,_);break;case 4:O[V].fn.call(O[V].context,x,_,L);break;default:if(!X)for(Z=1,X=new Array(K-1);Z<K;Z++)X[Z-1]=arguments[Z];O[V].fn.apply(O[V].context,X)}}return!0},a.prototype.on=function(y,x,_){return i(this,y,x,_,!1)},a.prototype.once=function(y,x,_){return i(this,y,x,_,!0)},a.prototype.removeListener=function(y,x,_,L){var C=e?e+y:y;if(!this._events[C])return this;if(!x)return o(this,C),this;var N=this._events[C];if(N.fn)N.fn===x&&(!L||N.once)&&(!_||N.context===_)&&o(this,C);else{for(var M=0,O=[],K=N.length;M<K;M++)(N[M].fn!==x||L&&!N[M].once||_&&N[M].context!==_)&&O.push(N[M]);O.length?this._events[C]=O.length===1?O[0]:O:o(this,C)}return this},a.prototype.removeAllListeners=function(y){var x;return y?(x=e?e+y:y,this._events[x]&&o(this,x)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,n.exports=a})(Da);var wl=Da.exports;const $a=ni(wl);var bl=class extends $a{constructor(t,e,r){super();nr(this,"socket");this.socket=new window.WebSocket(t,r),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=s=>this.emit("message",s.data),this.socket.onerror=s=>this.emit("error",s),this.socket.onclose=s=>{this.emit("close",s.code,s.reason)}}send(t,e,r){const s=r||e;try{this.socket.send(t),s()}catch(i){s(i)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,r){this.socket.addEventListener(t,e,r)}};function xl(n,t){return new bl(n,t)}var vl=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},kl=class extends $a{constructor(t,e="ws://localhost:8080",{autoconnect:r=!0,reconnect:s=!0,reconnect_interval:i=1e3,max_reconnects:o=5,...a}={},l,y){super();nr(this,"address");nr(this,"rpc_id");nr(this,"queue");nr(this,"options");nr(this,"autoconnect");nr(this,"ready");nr(this,"reconnect");nr(this,"reconnect_timer_id");nr(this,"reconnect_interval");nr(this,"max_reconnects");nr(this,"rest_options");nr(this,"current_reconnects");nr(this,"generate_request_id");nr(this,"socket");nr(this,"webSocketFactory");nr(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=r,this.ready=!1,this.reconnect=s,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=l||(()=>++this.rpc_id),y?this.dataPack=y:this.dataPack=new vl,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,r,s){return!s&&typeof r=="object"&&(s=r,r=null),new Promise((i,o)=>{if(!this.ready)return o(new Error("socket not ready"));const a=this.generate_request_id(t,e),l={jsonrpc:"2.0",method:t,params:e||void 0,id:a};this.socket.send(this.dataPack.encode(l),s,y=>{if(y)return o(y);this.queue[a]={promise:[i,o]},r&&(this.queue[a].timeout=setTimeout(()=>{delete this.queue[a],o(new Error("reply timeout"))},r))})})}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((r,s)=>{if(!this.ready)return s(new Error("socket not ready"));const i={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(i),o=>{if(o)return s(o);r()})})}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:r})=>{r instanceof ArrayBuffer&&(r=Ct.Buffer.from(r).toString());try{r=this.dataPack.decode(r)}catch{return}if(r.notification&&this.listeners(r.notification).length){if(!Object.keys(r.params).length)return this.emit(r.notification);const s=[r.notification];if(r.params.constructor===Object)s.push(r.params);else for(let i=0;i<r.params.length;i++)s.push(r.params[i]);return Promise.resolve().then(()=>{this.emit.apply(this,s)})}if(!this.queue[r.id])return r.method?Promise.resolve().then(()=>{this.emit(r.method,r==null?void 0:r.params)}):void 0;"error"in r=="result"in r&&this.queue[r.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[r.id].timeout&&clearTimeout(this.queue[r.id].timeout),r.error?this.queue[r.id].promise[1](r.error):this.queue[r.id].promise[0](r.result),delete this.queue[r.id]}),this.socket.addEventListener("error",r=>this.emit("error",r)),this.socket.addEventListener("close",({code:r,reason:s})=>{this.ready&&setTimeout(()=>this.emit("close",r,s),0),this.ready=!1,this.socket=void 0,r!==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 qa=[],Ha=[],Va=[],Sl=BigInt(0),hi=BigInt(1),El=BigInt(2),_l=BigInt(7),Il=BigInt(256),Al=BigInt(113);for(let n=0,t=hi,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],qa.push(2*(5*r+e)),Ha.push((n+1)*(n+2)/2%64);let s=Sl;for(let i=0;i<7;i++)t=(t<<hi^(t>>_l)*Al)%Il,t&El&&(s^=hi<<(hi<<BigInt(i))-hi);Va.push(s)}const[Bl,Rl]=No(Va,!0),ja=(n,t,e)=>e>32?Ko(n,t,e):Fo(n,t,e),Ga=(n,t,e)=>e>32?Wo(n,t,e):zo(n,t,e);function Tl(n,t=24){const e=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)e[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,y=e[l],x=e[l+1],_=ja(y,x,1)^e[a],L=Ga(y,x,1)^e[a+1];for(let C=0;C<50;C+=10)n[o+C]^=_,n[o+C+1]^=L}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=Ha[o],l=ja(s,i,a),y=Ga(s,i,a),x=qa[o];s=n[x],i=n[x+1],n[x]=l,n[x+1]=y}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)e[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~e[(a+2)%10]&e[(a+4)%10]}n[0]^=Bl[r],n[1]^=Rl[r]}e.fill(0)}class Gs extends ps{constructor(t,e,r,s=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,_i(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=uu(this.state)}keccak(){Po||Co(this.state32),Tl(this.state32,this.rounds),Po||Co(this.state32),this.posOut=0,this.pos=0}update(t){Fn(this);const{blockLen:e,state:r}=this;t=Ii(t);const s=t.length;for(let i=0;i<s;){const o=Math.min(e-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:s}=this;t[r]^=e,e&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Fn(this,!1),ii(t),this.finish();const e=this.state,{blockLen:r}=this;for(let s=0,i=t.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);t.set(e.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}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(Mo(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:r,outputLen:s,rounds:i,enableXOF:o}=this;return t||(t=new Gs(e,r,s,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=s,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Ya=((n,t,e)=>gs(()=>new Gs(t,n,e)))(1,136,256/8);class Za extends ps{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,cu(t);const r=Ii(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 s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?t.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(t){return Fn(this),this.iHash.update(t),this}digestInto(t){Fn(this),ii(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:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return t=t,t.finished=s,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ja=(n,t,e)=>new Za(n,t).update(e).digest();Ja.create=(n,t)=>new Za(n,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ml(n){const t=Ss(n);Dn(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:r,a:s}=t;if(e){if(!r.eql(s,r.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:Pl,hexToBytes:Cl}=zu,Bn={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(n){const{Err:t}=Bn;if(n.length<2||n[0]!==2)throw new t("Invalid signature integer tag");const e=n[1],r=n.subarray(2,e+2);if(!e||r.length!==e)throw new t("Invalid signature integer: wrong length");if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Pl(r),l:n.subarray(e+2)}},toSig(n){const{Err:t}=Bn,e=typeof n=="string"?Cl(n):n;si(e);let r=e.length;if(r<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:s,l:i}=Bn._parseInt(e.subarray(2)),{d:o,l:a}=Bn._parseInt(i);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const t=y=>Number.parseInt(y[0],16)&8?"00"+y:y,e=y=>{const x=y.toString(16);return x.length&1?`0${x}`:x},r=t(e(n.s)),s=t(e(n.r)),i=r.length/2,o=s.length/2,a=e(i),l=e(o);return`30${e(o+i+4)}02${l}${s}02${a}${r}`}},sn=BigInt(0),Ur=BigInt(1);BigInt(2);const Xa=BigInt(3);BigInt(4);function Ll(n){const t=Ml(n),{Fp:e}=t,r=t.toBytes||((N,M,O)=>{const K=M.toAffine();return kn(Uint8Array.from([4]),e.toBytes(K.x),e.toBytes(K.y))}),s=t.fromBytes||(N=>{const M=N.subarray(1),O=e.fromBytes(M.subarray(0,e.BYTES)),K=e.fromBytes(M.subarray(e.BYTES,2*e.BYTES));return{x:O,y:K}});function i(N){const{a:M,b:O}=t,K=e.sqr(N),X=e.mul(K,N);return e.add(e.add(X,e.mul(N,M)),O)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function o(N){return typeof N=="bigint"&&sn<N&&N<t.n}function a(N){if(!o(N))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(N){const{allowedPrivateKeyLengths:M,nByteLength:O,wrapPrivateKey:K,n:X}=t;if(M&&typeof N!="bigint"){if(bn(N)&&(N=xn(N)),typeof N!="string"||!M.includes(N.length))throw new Error("Invalid key");N=N.padStart(O*2,"0")}let V;try{V=typeof N=="bigint"?N:vn(ir("private key",N,O))}catch{throw new Error(`private key must be ${O} bytes, hex or bigint, not ${typeof N}`)}return K&&(V=We(V,X)),a(V),V}const y=new Map;function x(N){if(!(N instanceof _))throw new Error("ProjectivePoint expected")}class _{constructor(M,O,K){if(this.px=M,this.py=O,this.pz=K,M==null||!e.isValid(M))throw new Error("x required");if(O==null||!e.isValid(O))throw new Error("y required");if(K==null||!e.isValid(K))throw new Error("z required")}static fromAffine(M){const{x:O,y:K}=M||{};if(!M||!e.isValid(O)||!e.isValid(K))throw new Error("invalid affine point");if(M instanceof _)throw new Error("projective point not allowed");const X=V=>e.eql(V,e.ZERO);return X(O)&&X(K)?_.ZERO:new _(O,K,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(M){const O=e.invertBatch(M.map(K=>K.pz));return M.map((K,X)=>K.toAffine(O[X])).map(_.fromAffine)}static fromHex(M){const O=_.fromAffine(s(ir("pointHex",M)));return O.assertValidity(),O}static fromPrivateKey(M){return _.BASE.multiply(l(M))}_setWindowSize(M){this._WINDOW_SIZE=M,y.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:M,y:O}=this.toAffine();if(!e.isValid(M)||!e.isValid(O))throw new Error("bad point: x or y not FE");const K=e.sqr(O),X=i(M);if(!e.eql(K,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:M}=this.toAffine();if(e.isOdd)return!e.isOdd(M);throw new Error("Field doesn't support isOdd")}equals(M){x(M);const{px:O,py:K,pz:X}=this,{px:V,py:it,pz:Z}=M,D=e.eql(e.mul(O,Z),e.mul(V,X)),tt=e.eql(e.mul(K,Z),e.mul(it,X));return D&&tt}negate(){return new _(this.px,e.neg(this.py),this.pz)}double(){const{a:M,b:O}=t,K=e.mul(O,Xa),{px:X,py:V,pz:it}=this;let Z=e.ZERO,D=e.ZERO,tt=e.ZERO,rt=e.mul(X,X),ue=e.mul(V,V),jt=e.mul(it,it),kt=e.mul(X,V);return kt=e.add(kt,kt),tt=e.mul(X,it),tt=e.add(tt,tt),Z=e.mul(M,tt),D=e.mul(K,jt),D=e.add(Z,D),Z=e.sub(ue,D),D=e.add(ue,D),D=e.mul(Z,D),Z=e.mul(kt,Z),tt=e.mul(K,tt),jt=e.mul(M,jt),kt=e.sub(rt,jt),kt=e.mul(M,kt),kt=e.add(kt,tt),tt=e.add(rt,rt),rt=e.add(tt,rt),rt=e.add(rt,jt),rt=e.mul(rt,kt),D=e.add(D,rt),jt=e.mul(V,it),jt=e.add(jt,jt),rt=e.mul(jt,kt),Z=e.sub(Z,rt),tt=e.mul(jt,ue),tt=e.add(tt,tt),tt=e.add(tt,tt),new _(Z,D,tt)}add(M){x(M);const{px:O,py:K,pz:X}=this,{px:V,py:it,pz:Z}=M;let D=e.ZERO,tt=e.ZERO,rt=e.ZERO;const ue=t.a,jt=e.mul(t.b,Xa);let kt=e.mul(O,V),ae=e.mul(K,it),T=e.mul(X,Z),u=e.add(O,K),p=e.add(V,it);u=e.mul(u,p),p=e.add(kt,ae),u=e.sub(u,p),p=e.add(O,X);let w=e.add(V,Z);return p=e.mul(p,w),w=e.add(kt,T),p=e.sub(p,w),w=e.add(K,X),D=e.add(it,Z),w=e.mul(w,D),D=e.add(ae,T),w=e.sub(w,D),rt=e.mul(ue,p),D=e.mul(jt,T),rt=e.add(D,rt),D=e.sub(ae,rt),rt=e.add(ae,rt),tt=e.mul(D,rt),ae=e.add(kt,kt),ae=e.add(ae,kt),T=e.mul(ue,T),p=e.mul(jt,p),ae=e.add(ae,T),T=e.sub(kt,T),T=e.mul(ue,T),p=e.add(p,T),kt=e.mul(ae,p),tt=e.add(tt,kt),kt=e.mul(w,p),D=e.mul(u,D),D=e.sub(D,kt),kt=e.mul(u,ae),rt=e.mul(w,rt),rt=e.add(rt,kt),new _(D,tt,rt)}subtract(M){return this.add(M.negate())}is0(){return this.equals(_.ZERO)}wNAF(M){return C.wNAFCached(this,y,M,O=>{const K=e.invertBatch(O.map(X=>X.pz));return O.map((X,V)=>X.toAffine(K[V])).map(_.fromAffine)})}multiplyUnsafe(M){const O=_.ZERO;if(M===sn)return O;if(a(M),M===Ur)return this;const{endo:K}=t;if(!K)return C.unsafeLadder(this,M);let{k1neg:X,k1:V,k2neg:it,k2:Z}=K.splitScalar(M),D=O,tt=O,rt=this;for(;V>sn||Z>sn;)V&Ur&&(D=D.add(rt)),Z&Ur&&(tt=tt.add(rt)),rt=rt.double(),V>>=Ur,Z>>=Ur;return X&&(D=D.negate()),it&&(tt=tt.negate()),tt=new _(e.mul(tt.px,K.beta),tt.py,tt.pz),D.add(tt)}multiply(M){a(M);let O=M,K,X;const{endo:V}=t;if(V){const{k1neg:it,k1:Z,k2neg:D,k2:tt}=V.splitScalar(O);let{p:rt,f:ue}=this.wNAF(Z),{p:jt,f:kt}=this.wNAF(tt);rt=C.constTimeNegate(it,rt),jt=C.constTimeNegate(D,jt),jt=new _(e.mul(jt.px,V.beta),jt.py,jt.pz),K=rt.add(jt),X=ue.add(kt)}else{const{p:it,f:Z}=this.wNAF(O);K=it,X=Z}return _.normalizeZ([K,X])[0]}multiplyAndAddUnsafe(M,O,K){const X=_.BASE,V=(Z,D)=>D===sn||D===Ur||!Z.equals(X)?Z.multiplyUnsafe(D):Z.multiply(D),it=V(this,O).add(V(M,K));return it.is0()?void 0:it}toAffine(M){const{px:O,py:K,pz:X}=this,V=this.is0();M==null&&(M=V?e.ONE:e.inv(X));const it=e.mul(O,M),Z=e.mul(K,M),D=e.mul(X,M);if(V)return{x:e.ZERO,y:e.ZERO};if(!e.eql(D,e.ONE))throw new Error("invZ was invalid");return{x:it,y:Z}}isTorsionFree(){const{h:M,isTorsionFree:O}=t;if(M===Ur)return!0;if(O)return O(_,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:M,clearCofactor:O}=t;return M===Ur?this:O?O(_,this):this.multiplyUnsafe(t.h)}toRawBytes(M=!0){return this.assertValidity(),r(_,this,M)}toHex(M=!0){return xn(this.toRawBytes(M))}}_.BASE=new _(t.Gx,t.Gy,e.ONE),_.ZERO=new _(e.ZERO,e.ONE,e.ZERO);const L=t.nBitLength,C=Qo(_,t.endo?Math.ceil(L/2):L);return{CURVE:t,ProjectivePoint:_,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:o}}function Ul(n){const t=Ss(n);return Dn(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ol(n){const t=Ul(n),{Fp:e,n:r}=t,s=e.BYTES+1,i=2*e.BYTES+1;function o(p){return sn<p&&p<e.ORDER}function a(p){return We(p,r)}function l(p){return vs(p,r)}const{ProjectivePoint:y,normPrivateKeyToScalar:x,weierstrassEquation:_,isWithinCurveOrder:L}=Ll({...t,toBytes(p,w,R){const I=w.toAffine(),A=e.toBytes(I.x),U=kn;return R?U(Uint8Array.from([w.hasEvenY()?2:3]),A):U(Uint8Array.from([4]),A,e.toBytes(I.y))},fromBytes(p){const w=p.length,R=p[0],I=p.subarray(1);if(w===s&&(R===2||R===3)){const A=vn(I);if(!o(A))throw new Error("Point is not on curve");const U=_(A);let k;try{k=e.sqrt(U)}catch(at){const Q=at instanceof Error?": "+at.message:"";throw new Error("Point is not on curve"+Q)}const h=(k&Ur)===Ur;return(R&1)===1!==h&&(k=e.neg(k)),{x:A,y:k}}else if(w===i&&R===4){const A=e.fromBytes(I.subarray(0,e.BYTES)),U=e.fromBytes(I.subarray(e.BYTES,2*e.BYTES));return{x:A,y:U}}else throw new Error(`Point of length ${w} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),C=p=>xn(Wn(p,t.nByteLength));function N(p){const w=r>>Ur;return p>w}function M(p){return N(p)?a(-p):p}const O=(p,w,R)=>vn(p.slice(w,R));class K{constructor(w,R,I){this.r=w,this.s=R,this.recovery=I,this.assertValidity()}static fromCompact(w){const R=t.nByteLength;return w=ir("compactSignature",w,R*2),new K(O(w,0,R),O(w,R,2*R))}static fromDER(w){const{r:R,s:I}=Bn.toSig(ir("DER",w));return new K(R,I)}assertValidity(){if(!L(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!L(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(w){return new K(this.r,this.s,w)}recoverPublicKey(w){const{r:R,s:I,recovery:A}=this,U=tt(ir("msgHash",w));if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");const k=A===2||A===3?R+t.n:R;if(k>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=A&1?"03":"02",E=y.fromHex(h+C(k)),at=l(k),Q=a(-U*at),ct=a(I*at),Mt=y.BASE.multiplyAndAddUnsafe(E,Q,ct);if(!Mt)throw new Error("point at infinify");return Mt.assertValidity(),Mt}hasHighS(){return N(this.s)}normalizeS(){return this.hasHighS()?new K(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return zn(this.toDERHex())}toDERHex(){return Bn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return zn(this.toCompactHex())}toCompactHex(){return C(this.r)+C(this.s)}}const X={isValidPrivateKey(p){try{return x(p),!0}catch{return!1}},normPrivateKeyToScalar:x,randomPrivateKey:()=>{const p=Xo(t.n);return Yu(t.randomBytes(p),t.n)},precompute(p=8,w=y.BASE){return w._setWindowSize(p),w.multiply(BigInt(3)),w}};function V(p,w=!0){return y.fromPrivateKey(p).toRawBytes(w)}function it(p){const w=bn(p),R=typeof p=="string",I=(w||R)&&p.length;return w?I===s||I===i:R?I===2*s||I===2*i:p instanceof y}function Z(p,w,R=!0){if(it(p))throw new Error("first arg must be private key");if(!it(w))throw new Error("second arg must be public key");return y.fromHex(w).multiply(x(p)).toRawBytes(R)}const D=t.bits2int||function(p){const w=vn(p),R=p.length*8-t.nBitLength;return R>0?w>>BigInt(R):w},tt=t.bits2int_modN||function(p){return a(D(p))},rt=ws(t.nBitLength);function ue(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(sn<=p&&p<rt))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Wn(p,t.nByteLength)}function jt(p,w,R=kt){if(["recovered","canonical"].some(Pt=>Pt in R))throw new Error("sign() legacy options not supported");const{hash:I,randomBytes:A}=t;let{lowS:U,prehash:k,extraEntropy:h}=R;U==null&&(U=!0),p=ir("msgHash",p),k&&(p=ir("prehashed msgHash",I(p)));const E=tt(p),at=x(w),Q=[ue(at),ue(E)];if(h!=null&&h!==!1){const Pt=h===!0?A(e.BYTES):h;Q.push(ir("extraEntropy",Pt))}const ct=kn(...Q),Mt=E;function Tt(Pt){const Ce=D(Pt);if(!L(Ce))return;const Yt=l(Ce),Gt=y.BASE.multiply(Ce).toAffine(),le=a(Gt.x);if(le===sn)return;const re=a(Yt*a(Mt+le*at));if(re===sn)return;let ve=(Gt.x===le?0:2)|Number(Gt.y&Ur),Or=re;return U&&N(re)&&(Or=M(re),ve^=1),new K(le,Or,ve)}return{seed:ct,k2sig:Tt}}const kt={lowS:t.lowS,prehash:!1},ae={lowS:t.lowS,prehash:!1};function T(p,w,R=kt){const{seed:I,k2sig:A}=jt(p,w,R),U=t;return Vo(U.hash.outputLen,U.nByteLength,U.hmac)(I,A)}y.BASE._setWindowSize(8);function u(p,w,R,I=ae){var Gt;const A=p;if(w=ir("msgHash",w),R=ir("publicKey",R),"strict"in I)throw new Error("options.strict was renamed to lowS");const{lowS:U,prehash:k}=I;let h,E;try{if(typeof A=="string"||bn(A))try{h=K.fromDER(A)}catch(le){if(!(le instanceof Bn.Err))throw le;h=K.fromCompact(A)}else if(typeof A=="object"&&typeof A.r=="bigint"&&typeof A.s=="bigint"){const{r:le,s:re}=A;h=new K(le,re)}else throw new Error("PARSE");E=y.fromHex(R)}catch(le){if(le.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(U&&h.hasHighS())return!1;k&&(w=t.hash(w));const{r:at,s:Q}=h,ct=tt(w),Mt=l(Q),Tt=a(ct*Mt),Pt=a(at*Mt),Ce=(Gt=y.BASE.multiplyAndAddUnsafe(E,Tt,Pt))==null?void 0:Gt.toAffine();return Ce?a(Ce.x)===at:!1}return{CURVE:t,getPublicKey:V,getSharedSecret:Z,sign:T,verify:u,ProjectivePoint:y,Signature:K,utils:X}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Nl(n){return{hash:n,hmac:(t,...e)=>Ja(n,t,hu(...e)),randomBytes:Lo}}function Fl(n,t){const e=r=>Ol({...n,...Nl(r)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qa=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),tc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),zl=BigInt(1),Ys=BigInt(2),ec=(n,t)=>(n+t/Ys)/t;function Kl(n){const t=Qa,e=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),y=n*n*n%t,x=y*y*n%t,_=Ge(x,e,t)*x%t,L=Ge(_,e,t)*x%t,C=Ge(L,Ys,t)*y%t,N=Ge(C,s,t)*C%t,M=Ge(N,i,t)*N%t,O=Ge(M,a,t)*M%t,K=Ge(O,l,t)*O%t,X=Ge(K,a,t)*M%t,V=Ge(X,e,t)*x%t,it=Ge(V,o,t)*N%t,Z=Ge(it,r,t)*y%t,D=Ge(Z,Ys,t);if(!Zs.eql(Zs.sqr(D),n))throw new Error("Cannot find square root");return D}const Zs=Zo(Qa,void 0,void 0,{sqrt:Kl}),qi=Fl({a:BigInt(0),b:BigInt(7),Fp:Zs,n:tc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=tc,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-zl*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,o=BigInt("0x100000000000000000000000000000000"),a=ec(i*n,t),l=ec(-r*n,t);let y=We(n-a*e-l*s,t),x=We(-a*r-l*i,t);const _=y>o,L=x>o;if(_&&(y=t-y),L&&(x=t-x),y>o||x>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:_,k1:y,k2neg:L,k2:x}}}},As);BigInt(0),qi.ProjectivePoint;const Wl=$n.utils.randomPrivateKey,rc=()=>{const n=$n.utils.randomPrivateKey(),t=Hi(n),e=new Uint8Array(64);return e.set(n),e.set(t,32),{publicKey:t,secretKey:e}},Hi=$n.getPublicKey;function nc(n){try{return $n.ExtendedPoint.fromHex(n),!0}catch{return!1}}const Js=(n,t)=>$n.sign(n,t.slice(0,32)),Dl=$n.verify,te=n=>Ct.Buffer.isBuffer(n)?n:n instanceof Uint8Array?Ct.Buffer.from(n.buffer,n.byteOffset,n.byteLength):Ct.Buffer.from(n);class Xs{constructor(t){Object.assign(this,t)}encode(){return Ct.Buffer.from(ha(di,this))}static decode(t){return da(di,this,t)}static decodeUnchecked(t){return aa(di,this,t)}}class $l extends Xs{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 di=new Map;var ic;const sc=32,Zr=32;function ql(n){return n._bn!==void 0}let oc=1;class gt extends Xs{constructor(t){if(super({}),this._bn=void 0,ql(t))this._bn=t._bn;else{if(typeof t=="string"){const e=ar.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 gt(oc);return oc+=1,new gt(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return ar.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(Ct.Buffer);if(t.length===Zr)return t;const e=Ct.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,r){const s=Ct.Buffer.concat([t.toBuffer(),Ct.Buffer.from(e),r.toBuffer()]),i=As(s);return new gt(i)}static createProgramAddressSync(t,e){let r=Ct.Buffer.alloc(0);t.forEach(function(i){if(i.length>sc)throw new TypeError("Max seed length exceeded");r=Ct.Buffer.concat([r,te(i)])}),r=Ct.Buffer.concat([r,e.toBuffer(),Ct.Buffer.from("ProgramDerivedAddress")]);const s=As(r);if(nc(s))throw new Error("Invalid seeds, address must fall off the curve");return new gt(s)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let r=255,s;for(;r!=0;){try{const i=t.concat(Ct.Buffer.from([r]));s=this.createProgramAddressSync(i,e)}catch(i){if(i instanceof TypeError)throw i;r--;continue}return[s,r]}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 gt(t);return nc(e.toBytes())}}ic=gt,gt.default=new ic("11111111111111111111111111111111"),di.set(gt,{kind:"struct",fields:[["_bn","u256"]]});class Hl{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=te(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=te(Wl()),this._publicKey=te(Hi(this._secretKey))}get publicKey(){return new gt(this._publicKey)}get secretKey(){return Ct.Buffer.concat([this._secretKey,this._publicKey],64)}}const Vl=new gt("BPFLoader1111111111111111111111111111111111"),yn=1232,Vi=127,pi=64;class Qs extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Qs.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class to 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(to.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Yn extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Yn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class gi{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 r=new Map;this.keySegments().flat().forEach((i,o)=>{r.set(i.toBase58(),o)});const s=i=>{const o=r.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return t.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const oe=(n="publicKey")=>Ke(32,n),jl=(n="signature")=>Ke(64,n),Rn=(n="string")=>{const t=At([It("length"),It("lengthPadding"),Ke(pn(It(),-8),"chars")],n),e=t.decode.bind(t),r=t.encode.bind(t),s=t;return s.decode=(i,o)=>e(i,o).chars.toString(),s.encode=(i,o,a)=>{const l={chars:Ct.Buffer.from(i,"utf8")};return r(l,o,a)},s.alloc=i=>It().span+It().span+Ct.Buffer.from(i,"utf8").length,s},Gl=(n="authorized")=>At([oe("staker"),oe("withdrawer")],n),Yl=(n="lockup")=>At([Tr("unixTimestamp"),Tr("epoch"),oe("custodian")],n),Zl=(n="voteInit")=>At([oe("nodePubkey"),oe("authorizedVoter"),oe("authorizedWithdrawer"),ge("commission")],n),Jl=(n="voteAuthorizeWithSeedArgs")=>At([It("voteAuthorizationType"),oe("currentAuthorityDerivedKeyOwnerPubkey"),Rn("currentAuthorityDerivedKeySeed"),oe("newAuthorized")],n);function ac(n,t){const e=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(t[s.property]);if("count"in s&&"elementLayout"in s){const i=t[s.property];if(Array.isArray(i))return i.length*e(s.elementLayout)}else if("fields"in s)return ac({layout:s},t[s.property]);return 0};let r=0;return n.layout.fields.forEach(s=>{r+=e(s)}),r}function _r(n){let t=0,e=0;for(;;){let r=n.shift();if(t|=(r&127)<<e*7,e+=1,!(r&128))break}return t}function Mr(n,t){let e=t;for(;;){let r=e&127;if(e>>=7,e==0){n.push(r);break}else r|=128,n.push(r)}}function xe(n,t){if(!n)throw new Error(t||"Assertion failed")}class ji{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const r=new Map,s=o=>{const a=o.toBase58();let l=r.get(a);return l===void 0&&(l={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,l)),l},i=s(e);i.isSigner=!0,i.isWritable=!0;for(const o of t){s(o.programId).isInvoked=!0;for(const a of o.keys){const l=s(a.pubkey);l.isSigner||(l.isSigner=a.isSigner),l.isWritable||(l.isWritable=a.isWritable)}}return new ji(e,r)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];xe(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,l])=>l.isSigner&&l.isWritable),r=t.filter(([,l])=>l.isSigner&&!l.isWritable),s=t.filter(([,l])=>!l.isSigner&&l.isWritable),i=t.filter(([,l])=>!l.isSigner&&!l.isWritable),o={numRequiredSignatures:e.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{xe(e.length>0,"Expected at least one writable signer key");const[l]=e[0];xe(l===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...e.map(([l])=>new gt(l)),...r.map(([l])=>new gt(l)),...s.map(([l])=>new gt(l)),...i.map(([l])=>new gt(l))];return[o,a]}extractTableLookup(t){const[e,r]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(e.length===0&&s.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:s},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(t,e){const r=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(e(o)){const a=new gt(i),l=t.findIndex(y=>y.equals(a));l>=0&&(xe(l<256,"Max lookup table index exceeded"),r.push(l),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const cc="Reached end of buffer unexpectedly";function Jr(n){if(n.length===0)throw new Error(cc);return n.shift()}function Ir(n,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>n.length:e>=n.length)throw new Error(cc);return n.splice(...t)}class Wr{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 gt(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:ar.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new gi(this.staticAccountKeys)}static compile(t){const e=ji.compile(t.instructions,t.payerKey),[r,s]=e.getMessageComponents(),o=new gi(s).compileInstructions(t.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:ar.encode(a.data)}));return new Wr({header:r,accountKeys:s,recentBlockhash:t.recentBlockhash,instructions:o})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const r=t-e,i=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return r<i}else{const r=e-this.header.numReadonlySignedAccounts;return t<r}}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=[];Mr(e,t);const r=this.instructions.map(_=>{const{accounts:L,programIdIndex:C}=_,N=Array.from(ar.decode(_.data));let M=[];Mr(M,L.length);let O=[];return Mr(O,N.length),{programIdIndex:C,keyIndicesCount:Ct.Buffer.from(M),keyIndices:L,dataLength:Ct.Buffer.from(O),data:N}});let s=[];Mr(s,r.length);let i=Ct.Buffer.alloc(yn);Ct.Buffer.from(s).copy(i);let o=s.length;r.forEach(_=>{const C=At([ge("programIdIndex"),Ke(_.keyIndicesCount.length,"keyIndicesCount"),dr(ge("keyIndex"),_.keyIndices.length,"keyIndices"),Ke(_.dataLength.length,"dataLength"),dr(ge("userdatum"),_.data.length,"data")]).encode(_,i,o);o+=C}),i=i.slice(0,o);const a=At([Ke(1,"numRequiredSignatures"),Ke(1,"numReadonlySignedAccounts"),Ke(1,"numReadonlyUnsignedAccounts"),Ke(e.length,"keyCount"),dr(oe("key"),t,"keys"),oe("recentBlockhash")]),l={numRequiredSignatures:Ct.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Ct.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Ct.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Ct.Buffer.from(e),keys:this.accountKeys.map(_=>te(_.toBytes())),recentBlockhash:ar.decode(this.recentBlockhash)};let y=Ct.Buffer.alloc(2048);const x=a.encode(l,y);return i.copy(y,x),y.slice(0,x+i.length)}static from(t){let e=[...t];const r=Jr(e);if(r!==(r&Vi))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=Jr(e),i=Jr(e),o=_r(e);let a=[];for(let L=0;L<o;L++){const C=Ir(e,0,Zr);a.push(new gt(Ct.Buffer.from(C)))}const l=Ir(e,0,Zr),y=_r(e);let x=[];for(let L=0;L<y;L++){const C=Jr(e),N=_r(e),M=Ir(e,0,N),O=_r(e),K=Ir(e,0,O),X=ar.encode(Ct.Buffer.from(K));x.push({programIdIndex:C,accounts:M,data:X})}const _={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:ar.encode(Ct.Buffer.from(l)),accountKeys:a,instructions:x};return new Wr(_)}}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 gi(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(t>=r){const s=t-r,i=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return s<i}else if(t>=this.header.numRequiredSignatures){const s=t-e,o=r-e-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=e-this.header.numReadonlySignedAccounts;return t<s}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const r of this.addressTableLookups){const s=t.find(i=>i.key.equals(r.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const i of r.writableIndexes)if(i<s.state.addresses.length)e.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`);for(const i of r.readonlyIndexes)if(i<s.state.addresses.length)e.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`)}return e}static compile(t){const e=ji.compile(t.instructions,t.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=t.addressLookupTableAccounts||[];for(const x of i){const _=e.extractTableLookup(x);if(_!==void 0){const[L,{writable:C,readonly:N}]=_;r.push(L),s.writable.push(...C),s.readonly.push(...N)}}const[o,a]=e.getMessageComponents(),y=new gi(a,s).compileInstructions(t.instructions);return new Tn({header:o,staticAccountKeys:a,recentBlockhash:t.recentBlockhash,compiledInstructions:y,addressTableLookups:r})}serialize(){const t=Array();Mr(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),r=Array();Mr(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Mr(i,this.addressTableLookups.length);const o=At([ge("prefix"),At([ge("numRequiredSignatures"),ge("numReadonlySignedAccounts"),ge("numReadonlyUnsignedAccounts")],"header"),Ke(t.length,"staticAccountKeysLength"),dr(oe(),this.staticAccountKeys.length,"staticAccountKeys"),oe("recentBlockhash"),Ke(r.length,"instructionsLength"),Ke(e.length,"serializedInstructions"),Ke(i.length,"addressTableLookupsLength"),Ke(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(yn),y=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(x=>x.toBytes()),recentBlockhash:ar.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},a);return a.slice(0,y)}serializeInstructions(){let t=0;const e=new Uint8Array(yn);for(const r of this.compiledInstructions){const s=Array();Mr(s,r.accountKeyIndexes.length);const i=Array();Mr(i,r.data.length);const o=At([ge("programIdIndex"),Ke(s.length,"encodedAccountKeyIndexesLength"),dr(ge(),r.accountKeyIndexes.length,"accountKeyIndexes"),Ke(i.length,"encodedDataLength"),Ke(r.data.length,"data")]);t+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(yn);for(const r of this.addressTableLookups){const s=Array();Mr(s,r.writableIndexes.length);const i=Array();Mr(i,r.readonlyIndexes.length);const o=At([oe("accountKey"),Ke(s.length,"encodedWritableIndexesLength"),dr(ge(),r.writableIndexes.length,"writableIndexes"),Ke(i.length,"encodedReadonlyIndexesLength"),dr(ge(),r.readonlyIndexes.length,"readonlyIndexes")]);t+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const r=Jr(e),s=r&Vi;xe(r!==s,"Expected versioned message but received legacy message");const i=s;xe(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:Jr(e),numReadonlySignedAccounts:Jr(e),numReadonlyUnsignedAccounts:Jr(e)},a=[],l=_r(e);for(let N=0;N<l;N++)a.push(new gt(Ir(e,0,Zr)));const y=ar.encode(Ir(e,0,Zr)),x=_r(e),_=[];for(let N=0;N<x;N++){const M=Jr(e),O=_r(e),K=Ir(e,0,O),X=_r(e),V=new Uint8Array(Ir(e,0,X));_.push({programIdIndex:M,accountKeyIndexes:K,data:V})}const L=_r(e),C=[];for(let N=0;N<L;N++){const M=new gt(Ir(e,0,Zr)),O=_r(e),K=Ir(e,0,O),X=_r(e),V=Ir(e,0,X);C.push({accountKey:M,writableIndexes:K,readonlyIndexes:V})}return new Tn({header:o,staticAccountKeys:a,recentBlockhash:y,compiledInstructions:_,addressTableLookups:C})}}const eo={deserializeMessageVersion(n){const t=n[0],e=t&Vi;return e===t?"legacy":e},deserialize:n=>{const t=eo.deserializeMessageVersion(n);if(t==="legacy")return Wr.from(n);if(t===0)return Tn.deserialize(n);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let on=function(n){return n[n.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",n[n.PROCESSED=1]="PROCESSED",n[n.TIMED_OUT=2]="TIMED_OUT",n[n.NONCE_INVALID=3]="NONCE_INVALID",n}({});const Xl=Ct.Buffer.alloc(pi).fill(0);class Ue{constructor(t){this.keys=void 0,this.programId=void 0,this.data=Ct.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:r})=>({pubkey:t.toJSON(),isSigner:e,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class ye{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:r}=t;this.minNonceContextSlot=e,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:r}=t;this.recentBlockhash=e,this.lastValidBlockHeight=r}else{const{recentBlockhash:e,nonceInfo:r}=t;r&&(this.nonceInfo=r),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 Ue(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 r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let M=0;M<e.length;M++)if(e[M].programId===void 0)throw new Error(`Transaction instruction index ${M} has undefined program id`);const s=[],i=[];e.forEach(M=>{M.keys.forEach(K=>{i.push({...K})});const O=M.programId.toString();s.includes(O)||s.push(O)}),s.forEach(M=>{i.push({pubkey:new gt(M),isSigner:!1,isWritable:!1})});const o=[];i.forEach(M=>{const O=M.pubkey.toString(),K=o.findIndex(X=>X.pubkey.toString()===O);K>-1?(o[K].isWritable=o[K].isWritable||M.isWritable,o[K].isSigner=o[K].isSigner||M.isSigner):o.push(M)}),o.sort(function(M,O){if(M.isSigner!==O.isSigner)return M.isSigner?-1:1;if(M.isWritable!==O.isWritable)return M.isWritable?-1:1;const K={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return M.pubkey.toBase58().localeCompare(O.pubkey.toBase58(),"en",K)});const a=o.findIndex(M=>M.pubkey.equals(r));if(a>-1){const[M]=o.splice(a,1);M.isSigner=!0,M.isWritable=!0,o.unshift(M)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const M of this.signatures){const O=o.findIndex(K=>K.pubkey.equals(M.publicKey));if(O>-1)o[O].isSigner||(o[O].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: ${M.publicKey.toString()}`)}let l=0,y=0,x=0;const _=[],L=[];o.forEach(({pubkey:M,isSigner:O,isWritable:K})=>{O?(_.push(M.toString()),l+=1,K||(y+=1)):(L.push(M.toString()),K||(x+=1))});const C=_.concat(L),N=e.map(M=>{const{data:O,programId:K}=M;return{programIdIndex:C.indexOf(K.toString()),accounts:M.keys.map(X=>C.indexOf(X.pubkey.toString())),data:ar.encode(O)}});return N.forEach(M=>{xe(M.programIdIndex>=0),M.accounts.forEach(O=>xe(O>=0))}),new Wr({header:{numRequiredSignatures:l,numReadonlySignedAccounts:y,numReadonlyUnsignedAccounts:x},accountKeys:C,recentBlockhash:t,instructions:N})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((s,i)=>e[i].equals(s.publicKey))||(this.signatures=e.map(r=>({signature:null,publicKey:r}))),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(r=>{const s=r.toString();return e.has(s)?!1:(e.add(s),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const i of t){const o=i.publicKey.toString();e.has(o)||(e.add(o),r.push(i))}this.signatures=r.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...r)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const i of t){const o=i.publicKey.toString();e.has(o)||(e.add(o),r.push(i))}const s=this._compile();this._partialSign(s,...r)}_partialSign(t,...e){const r=t.serialize();e.forEach(s=>{const i=Js(r,s.secretKey);this._addSignature(s.publicKey,te(i))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){xe(e.length===64);const r=this.signatures.findIndex(s=>t.equals(s.publicKey));if(r<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[r].signature=Ct.Buffer.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const r={};for(const{signature:s,publicKey:i}of this.signatures)s===null?e&&(r.missing||(r.missing=[])).push(i):Dl(s,t,i.toBytes())||(r.invalid||(r.invalid=[])).push(i);return r.invalid||r.missing?r:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),s=this.serializeMessage();if(r){const i=this._getMessageSignednessErrors(s,e);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
6
+ */(function(n){const t=Si,e=fs,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=Q,n.INSPECT_MAX_BYTES=50;const s=2147483647;n.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.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 i(){try{const w=new Uint8Array(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,Uint8Array.prototype),Object.setPrototypeOf(w,f),w.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(w){if(w>s)throw new RangeError('The value "'+w+'" is invalid for option "size"');const f=new Uint8Array(w);return Object.setPrototypeOf(f,a.prototype),f}function a(w,f,d){if(typeof w=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return E(w)}return l(w,f,d)}a.poolSize=8192;function l(w,f,d){if(typeof w=="string")return L(w,f);if(ArrayBuffer.isView(w))return N(w);if(w==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof w);if(rr(w,ArrayBuffer)||w&&rr(w.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(rr(w,SharedArrayBuffer)||w&&rr(w.buffer,SharedArrayBuffer)))return M(w,f,d);if(typeof w=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const B=w.valueOf&&w.valueOf();if(B!=null&&B!==w)return a.from(B,f,d);const F=O(w);if(F)return F;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof w[Symbol.toPrimitive]=="function")return a.from(w[Symbol.toPrimitive]("string"),f,d);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof w)}a.from=function(w,f,d){return l(w,f,d)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function y(w){if(typeof w!="number")throw new TypeError('"size" argument must be of type number');if(w<0)throw new RangeError('The value "'+w+'" is invalid for option "size"')}function x(w,f,d){return y(w),w<=0?o(w):f!==void 0?typeof d=="string"?o(w).fill(f,d):o(w).fill(f):o(w)}a.alloc=function(w,f,d){return x(w,f,d)};function E(w){return y(w),o(w<0?0:K(w)|0)}a.allocUnsafe=function(w){return E(w)},a.allocUnsafeSlow=function(w){return E(w)};function L(w,f){if((typeof f!="string"||f==="")&&(f="utf8"),!a.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const d=V(w,f)|0;let B=o(d);const F=B.write(w,f);return F!==d&&(B=B.slice(0,F)),B}function C(w){const f=w.length<0?0:K(w.length)|0,d=o(f);for(let B=0;B<f;B+=1)d[B]=w[B]&255;return d}function N(w){if(rr(w,Uint8Array)){const f=new Uint8Array(w);return M(f.buffer,f.byteOffset,f.byteLength)}return C(w)}function M(w,f,d){if(f<0||w.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(w.byteLength<f+(d||0))throw new RangeError('"length" is outside of buffer bounds');let B;return f===void 0&&d===void 0?B=new Uint8Array(w):d===void 0?B=new Uint8Array(w,f):B=new Uint8Array(w,f,d),Object.setPrototypeOf(B,a.prototype),B}function O(w){if(a.isBuffer(w)){const f=K(w.length)|0,d=o(f);return d.length===0||w.copy(d,0,0,f),d}if(w.length!==void 0)return typeof w.length!="number"||ke(w.length)?o(0):C(w);if(w.type==="Buffer"&&Array.isArray(w.data))return C(w.data)}function K(w){if(w>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return w|0}function Q(w){return+w!=w&&(w=0),a.alloc(+w)}a.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==a.prototype},a.compare=function(f,d){if(rr(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),rr(d,Uint8Array)&&(d=a.from(d,d.offset,d.byteLength)),!a.isBuffer(f)||!a.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===d)return 0;let B=f.length,F=d.length;for(let $=0,Y=Math.min(B,F);$<Y;++$)if(f[$]!==d[$]){B=f[$],F=d[$];break}return B<F?-1:F<B?1:0},a.isEncoding=function(f){switch(String(f).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}},a.concat=function(f,d){if(!Array.isArray(f))throw new TypeError('"list" argument must be an Array of Buffers');if(f.length===0)return a.alloc(0);let B;if(d===void 0)for(d=0,B=0;B<f.length;++B)d+=f[B].length;const F=a.allocUnsafe(d);let $=0;for(B=0;B<f.length;++B){let Y=f[B];if(rr(Y,Uint8Array))$+Y.length>F.length?(a.isBuffer(Y)||(Y=a.from(Y)),Y.copy(F,$)):Uint8Array.prototype.set.call(F,Y,$);else if(a.isBuffer(Y))Y.copy(F,$);else throw new TypeError('"list" argument must be an Array of Buffers');$+=Y.length}return F};function V(w,f){if(a.isBuffer(w))return w.length;if(ArrayBuffer.isView(w)||rr(w,ArrayBuffer))return w.byteLength;if(typeof w!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof w);const d=w.length,B=arguments.length>2&&arguments[2]===!0;if(!B&&d===0)return 0;let F=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return _e(w).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return Ie(w).length;default:if(F)return B?-1:_e(w).length;f=(""+f).toLowerCase(),F=!0}}a.byteLength=V;function st(w,f,d){let B=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((d===void 0||d>this.length)&&(d=this.length),d<=0)||(d>>>=0,f>>>=0,d<=f))return"";for(w||(w="utf8");;)switch(w){case"hex":return I(this,f,d);case"utf8":case"utf-8":return u(this,f,d);case"ascii":return R(this,f,d);case"latin1":case"binary":return _(this,f,d);case"base64":return T(this,f,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,f,d);default:if(B)throw new TypeError("Unknown encoding: "+w);w=(w+"").toLowerCase(),B=!0}}a.prototype._isBuffer=!0;function J(w,f,d){const B=w[f];w[f]=w[d],w[d]=B}a.prototype.swap16=function(){const f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let d=0;d<f;d+=2)J(this,d,d+1);return this},a.prototype.swap32=function(){const f=this.length;if(f%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let d=0;d<f;d+=4)J(this,d,d+3),J(this,d+1,d+2);return this},a.prototype.swap64=function(){const f=this.length;if(f%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let d=0;d<f;d+=8)J(this,d,d+7),J(this,d+1,d+6),J(this,d+2,d+5),J(this,d+3,d+4);return this},a.prototype.toString=function(){const f=this.length;return f===0?"":arguments.length===0?u(this,0,f):st.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(f){if(!a.isBuffer(f))throw new TypeError("Argument must be a Buffer");return this===f?!0:a.compare(this,f)===0},a.prototype.inspect=function(){let f="";const d=n.INSPECT_MAX_BYTES;return f=this.toString("hex",0,d).replace(/(.{2})/g,"$1 ").trim(),this.length>d&&(f+=" ... "),"<Buffer "+f+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(f,d,B,F,$){if(rr(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),!a.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(d===void 0&&(d=0),B===void 0&&(B=f?f.length:0),F===void 0&&(F=0),$===void 0&&($=this.length),d<0||B>f.length||F<0||$>this.length)throw new RangeError("out of range index");if(F>=$&&d>=B)return 0;if(F>=$)return-1;if(d>=B)return 1;if(d>>>=0,B>>>=0,F>>>=0,$>>>=0,this===f)return 0;let Y=$-F,Ht=B-d;const zt=Math.min(Y,Ht),Nt=this.slice(F,$),Re=f.slice(d,B);for(let Lt=0;Lt<zt;++Lt)if(Nt[Lt]!==Re[Lt]){Y=Nt[Lt],Ht=Re[Lt];break}return Y<Ht?-1:Ht<Y?1:0};function D(w,f,d,B,F){if(w.length===0)return-1;if(typeof d=="string"?(B=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,ke(d)&&(d=F?0:w.length-1),d<0&&(d=w.length+d),d>=w.length){if(F)return-1;d=w.length-1}else if(d<0)if(F)d=0;else return-1;if(typeof f=="string"&&(f=a.from(f,B)),a.isBuffer(f))return f.length===0?-1:tt(w,f,d,B,F);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?F?Uint8Array.prototype.indexOf.call(w,f,d):Uint8Array.prototype.lastIndexOf.call(w,f,d):tt(w,[f],d,B,F);throw new TypeError("val must be string, number or Buffer")}function tt(w,f,d,B,F){let $=1,Y=w.length,Ht=f.length;if(B!==void 0&&(B=String(B).toLowerCase(),B==="ucs2"||B==="ucs-2"||B==="utf16le"||B==="utf-16le")){if(w.length<2||f.length<2)return-1;$=2,Y/=2,Ht/=2,d/=2}function zt(Re,Lt){return $===1?Re[Lt]:Re.readUInt16BE(Lt*$)}let Nt;if(F){let Re=-1;for(Nt=d;Nt<Y;Nt++)if(zt(w,Nt)===zt(f,Re===-1?0:Nt-Re)){if(Re===-1&&(Re=Nt),Nt-Re+1===Ht)return Re*$}else Re!==-1&&(Nt-=Nt-Re),Re=-1}else for(d+Ht>Y&&(d=Y-Ht),Nt=d;Nt>=0;Nt--){let Re=!0;for(let Lt=0;Lt<Ht;Lt++)if(zt(w,Nt+Lt)!==zt(f,Lt)){Re=!1;break}if(Re)return Nt}return-1}a.prototype.includes=function(f,d,B){return this.indexOf(f,d,B)!==-1},a.prototype.indexOf=function(f,d,B){return D(this,f,d,B,!0)},a.prototype.lastIndexOf=function(f,d,B){return D(this,f,d,B,!1)};function nt(w,f,d,B){d=Number(d)||0;const F=w.length-d;B?(B=Number(B),B>F&&(B=F)):B=F;const $=f.length;B>$/2&&(B=$/2);let Y;for(Y=0;Y<B;++Y){const Ht=parseInt(f.substr(Y*2,2),16);if(ke(Ht))return Y;w[d+Y]=Ht}return Y}function ue(w,f,d,B){return Ae(_e(f,w.length-d),w,d,B)}function jt(w,f,d,B){return Ae(Oe(f),w,d,B)}function kt(w,f,d,B){return Ae(Ie(f),w,d,B)}function ce(w,f,d,B){return Ae(Ar(f,w.length-d),w,d,B)}a.prototype.write=function(f,d,B,F){if(d===void 0)F="utf8",B=this.length,d=0;else if(B===void 0&&typeof d=="string")F=d,B=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(B)?(B=B>>>0,F===void 0&&(F="utf8")):(F=B,B=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const $=this.length-d;if((B===void 0||B>$)&&(B=$),f.length>0&&(B<0||d<0)||d>this.length)throw new RangeError("Attempt to write outside buffer bounds");F||(F="utf8");let Y=!1;for(;;)switch(F){case"hex":return nt(this,f,d,B);case"utf8":case"utf-8":return ue(this,f,d,B);case"ascii":case"latin1":case"binary":return jt(this,f,d,B);case"base64":return kt(this,f,d,B);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ce(this,f,d,B);default:if(Y)throw new TypeError("Unknown encoding: "+F);F=(""+F).toLowerCase(),Y=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(w,f,d){return f===0&&d===w.length?t.fromByteArray(w):t.fromByteArray(w.slice(f,d))}function u(w,f,d){d=Math.min(w.length,d);const B=[];let F=f;for(;F<d;){const $=w[F];let Y=null,Ht=$>239?4:$>223?3:$>191?2:1;if(F+Ht<=d){let zt,Nt,Re,Lt;switch(Ht){case 1:$<128&&(Y=$);break;case 2:zt=w[F+1],(zt&192)===128&&(Lt=($&31)<<6|zt&63,Lt>127&&(Y=Lt));break;case 3:zt=w[F+1],Nt=w[F+2],(zt&192)===128&&(Nt&192)===128&&(Lt=($&15)<<12|(zt&63)<<6|Nt&63,Lt>2047&&(Lt<55296||Lt>57343)&&(Y=Lt));break;case 4:zt=w[F+1],Nt=w[F+2],Re=w[F+3],(zt&192)===128&&(Nt&192)===128&&(Re&192)===128&&(Lt=($&15)<<18|(zt&63)<<12|(Nt&63)<<6|Re&63,Lt>65535&&Lt<1114112&&(Y=Lt))}}Y===null?(Y=65533,Ht=1):Y>65535&&(Y-=65536,B.push(Y>>>10&1023|55296),Y=56320|Y&1023),B.push(Y),F+=Ht}return m(B)}const p=4096;function m(w){const f=w.length;if(f<=p)return String.fromCharCode.apply(String,w);let d="",B=0;for(;B<f;)d+=String.fromCharCode.apply(String,w.slice(B,B+=p));return d}function R(w,f,d){let B="";d=Math.min(w.length,d);for(let F=f;F<d;++F)B+=String.fromCharCode(w[F]&127);return B}function _(w,f,d){let B="";d=Math.min(w.length,d);for(let F=f;F<d;++F)B+=String.fromCharCode(w[F]);return B}function I(w,f,d){const B=w.length;(!f||f<0)&&(f=0),(!d||d<0||d>B)&&(d=B);let F="";for(let $=f;$<d;++$)F+=Se[w[$]];return F}function U(w,f,d){const B=w.slice(f,d);let F="";for(let $=0;$<B.length-1;$+=2)F+=String.fromCharCode(B[$]+B[$+1]*256);return F}a.prototype.slice=function(f,d){const B=this.length;f=~~f,d=d===void 0?B:~~d,f<0?(f+=B,f<0&&(f=0)):f>B&&(f=B),d<0?(d+=B,d<0&&(d=0)):d>B&&(d=B),d<f&&(d=f);const F=this.subarray(f,d);return Object.setPrototypeOf(F,a.prototype),F};function k(w,f,d){if(w%1!==0||w<0)throw new RangeError("offset is not uint");if(w+f>d)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(f,d,B){f=f>>>0,d=d>>>0,B||k(f,d,this.length);let F=this[f],$=1,Y=0;for(;++Y<d&&($*=256);)F+=this[f+Y]*$;return F},a.prototype.readUintBE=a.prototype.readUIntBE=function(f,d,B){f=f>>>0,d=d>>>0,B||k(f,d,this.length);let F=this[f+--d],$=1;for(;d>0&&($*=256);)F+=this[f+--d]*$;return F},a.prototype.readUint8=a.prototype.readUInt8=function(f,d){return f=f>>>0,d||k(f,1,this.length),this[f]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(f,d){return f=f>>>0,d||k(f,2,this.length),this[f]|this[f+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(f,d){return f=f>>>0,d||k(f,2,this.length),this[f]<<8|this[f+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(f,d){return f=f>>>0,d||k(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(f,d){return f=f>>>0,d||k(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},a.prototype.readBigUInt64LE=fr(function(f){f=f>>>0,le(f,"offset");const d=this[f],B=this[f+7];(d===void 0||B===void 0)&&re(f,this.length-8);const F=d+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24,$=this[++f]+this[++f]*2**8+this[++f]*2**16+B*2**24;return BigInt(F)+(BigInt($)<<BigInt(32))}),a.prototype.readBigUInt64BE=fr(function(f){f=f>>>0,le(f,"offset");const d=this[f],B=this[f+7];(d===void 0||B===void 0)&&re(f,this.length-8);const F=d*2**24+this[++f]*2**16+this[++f]*2**8+this[++f],$=this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+B;return(BigInt(F)<<BigInt(32))+BigInt($)}),a.prototype.readIntLE=function(f,d,B){f=f>>>0,d=d>>>0,B||k(f,d,this.length);let F=this[f],$=1,Y=0;for(;++Y<d&&($*=256);)F+=this[f+Y]*$;return $*=128,F>=$&&(F-=Math.pow(2,8*d)),F},a.prototype.readIntBE=function(f,d,B){f=f>>>0,d=d>>>0,B||k(f,d,this.length);let F=d,$=1,Y=this[f+--F];for(;F>0&&($*=256);)Y+=this[f+--F]*$;return $*=128,Y>=$&&(Y-=Math.pow(2,8*d)),Y},a.prototype.readInt8=function(f,d){return f=f>>>0,d||k(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},a.prototype.readInt16LE=function(f,d){f=f>>>0,d||k(f,2,this.length);const B=this[f]|this[f+1]<<8;return B&32768?B|4294901760:B},a.prototype.readInt16BE=function(f,d){f=f>>>0,d||k(f,2,this.length);const B=this[f+1]|this[f]<<8;return B&32768?B|4294901760:B},a.prototype.readInt32LE=function(f,d){return f=f>>>0,d||k(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},a.prototype.readInt32BE=function(f,d){return f=f>>>0,d||k(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},a.prototype.readBigInt64LE=fr(function(f){f=f>>>0,le(f,"offset");const d=this[f],B=this[f+7];(d===void 0||B===void 0)&&re(f,this.length-8);const F=this[f+4]+this[f+5]*2**8+this[f+6]*2**16+(B<<24);return(BigInt(F)<<BigInt(32))+BigInt(d+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24)}),a.prototype.readBigInt64BE=fr(function(f){f=f>>>0,le(f,"offset");const d=this[f],B=this[f+7];(d===void 0||B===void 0)&&re(f,this.length-8);const F=(d<<24)+this[++f]*2**16+this[++f]*2**8+this[++f];return(BigInt(F)<<BigInt(32))+BigInt(this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+B)}),a.prototype.readFloatLE=function(f,d){return f=f>>>0,d||k(f,4,this.length),e.read(this,f,!0,23,4)},a.prototype.readFloatBE=function(f,d){return f=f>>>0,d||k(f,4,this.length),e.read(this,f,!1,23,4)},a.prototype.readDoubleLE=function(f,d){return f=f>>>0,d||k(f,8,this.length),e.read(this,f,!0,52,8)},a.prototype.readDoubleBE=function(f,d){return f=f>>>0,d||k(f,8,this.length),e.read(this,f,!1,52,8)};function h(w,f,d,B,F,$){if(!a.isBuffer(w))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>F||f<$)throw new RangeError('"value" argument is out of bounds');if(d+B>w.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(f,d,B,F){if(f=+f,d=d>>>0,B=B>>>0,!F){const Ht=Math.pow(2,8*B)-1;h(this,f,d,B,Ht,0)}let $=1,Y=0;for(this[d]=f&255;++Y<B&&($*=256);)this[d+Y]=f/$&255;return d+B},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(f,d,B,F){if(f=+f,d=d>>>0,B=B>>>0,!F){const Ht=Math.pow(2,8*B)-1;h(this,f,d,B,Ht,0)}let $=B-1,Y=1;for(this[d+$]=f&255;--$>=0&&(Y*=256);)this[d+$]=f/Y&255;return d+B},a.prototype.writeUint8=a.prototype.writeUInt8=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,1,255,0),this[d]=f&255,d+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,2,65535,0),this[d]=f&255,this[d+1]=f>>>8,d+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,2,65535,0),this[d]=f>>>8,this[d+1]=f&255,d+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,4,4294967295,0),this[d+3]=f>>>24,this[d+2]=f>>>16,this[d+1]=f>>>8,this[d]=f&255,d+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,4,4294967295,0),this[d]=f>>>24,this[d+1]=f>>>16,this[d+2]=f>>>8,this[d+3]=f&255,d+4};function A(w,f,d,B,F){Gt(f,B,F,w,d,7);let $=Number(f&BigInt(4294967295));w[d++]=$,$=$>>8,w[d++]=$,$=$>>8,w[d++]=$,$=$>>8,w[d++]=$;let Y=Number(f>>BigInt(32)&BigInt(4294967295));return w[d++]=Y,Y=Y>>8,w[d++]=Y,Y=Y>>8,w[d++]=Y,Y=Y>>8,w[d++]=Y,d}function Z(w,f,d,B,F){Gt(f,B,F,w,d,7);let $=Number(f&BigInt(4294967295));w[d+7]=$,$=$>>8,w[d+6]=$,$=$>>8,w[d+5]=$,$=$>>8,w[d+4]=$;let Y=Number(f>>BigInt(32)&BigInt(4294967295));return w[d+3]=Y,Y=Y>>8,w[d+2]=Y,Y=Y>>8,w[d+1]=Y,Y=Y>>8,w[d]=Y,d+8}a.prototype.writeBigUInt64LE=fr(function(f,d=0){return A(this,f,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=fr(function(f,d=0){return Z(this,f,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(f,d,B,F){if(f=+f,d=d>>>0,!F){const zt=Math.pow(2,8*B-1);h(this,f,d,B,zt-1,-zt)}let $=0,Y=1,Ht=0;for(this[d]=f&255;++$<B&&(Y*=256);)f<0&&Ht===0&&this[d+$-1]!==0&&(Ht=1),this[d+$]=(f/Y>>0)-Ht&255;return d+B},a.prototype.writeIntBE=function(f,d,B,F){if(f=+f,d=d>>>0,!F){const zt=Math.pow(2,8*B-1);h(this,f,d,B,zt-1,-zt)}let $=B-1,Y=1,Ht=0;for(this[d+$]=f&255;--$>=0&&(Y*=256);)f<0&&Ht===0&&this[d+$+1]!==0&&(Ht=1),this[d+$]=(f/Y>>0)-Ht&255;return d+B},a.prototype.writeInt8=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,1,127,-128),f<0&&(f=255+f+1),this[d]=f&255,d+1},a.prototype.writeInt16LE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,2,32767,-32768),this[d]=f&255,this[d+1]=f>>>8,d+2},a.prototype.writeInt16BE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,2,32767,-32768),this[d]=f>>>8,this[d+1]=f&255,d+2},a.prototype.writeInt32LE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,4,2147483647,-2147483648),this[d]=f&255,this[d+1]=f>>>8,this[d+2]=f>>>16,this[d+3]=f>>>24,d+4},a.prototype.writeInt32BE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[d]=f>>>24,this[d+1]=f>>>16,this[d+2]=f>>>8,this[d+3]=f&255,d+4},a.prototype.writeBigInt64LE=fr(function(f,d=0){return A(this,f,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=fr(function(f,d=0){return Z(this,f,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function et(w,f,d,B,F,$){if(d+B>w.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function ct(w,f,d,B,F){return f=+f,d=d>>>0,F||et(w,f,d,4),e.write(w,f,d,B,23,4),d+4}a.prototype.writeFloatLE=function(f,d,B){return ct(this,f,d,!0,B)},a.prototype.writeFloatBE=function(f,d,B){return ct(this,f,d,!1,B)};function Mt(w,f,d,B,F){return f=+f,d=d>>>0,F||et(w,f,d,8),e.write(w,f,d,B,52,8),d+8}a.prototype.writeDoubleLE=function(f,d,B){return Mt(this,f,d,!0,B)},a.prototype.writeDoubleBE=function(f,d,B){return Mt(this,f,d,!1,B)},a.prototype.copy=function(f,d,B,F){if(!a.isBuffer(f))throw new TypeError("argument should be a Buffer");if(B||(B=0),!F&&F!==0&&(F=this.length),d>=f.length&&(d=f.length),d||(d=0),F>0&&F<B&&(F=B),F===B||f.length===0||this.length===0)return 0;if(d<0)throw new RangeError("targetStart out of bounds");if(B<0||B>=this.length)throw new RangeError("Index out of range");if(F<0)throw new RangeError("sourceEnd out of bounds");F>this.length&&(F=this.length),f.length-d<F-B&&(F=f.length-d+B);const $=F-B;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(d,B,F):Uint8Array.prototype.set.call(f,this.subarray(B,F),d),$},a.prototype.fill=function(f,d,B,F){if(typeof f=="string"){if(typeof d=="string"?(F=d,d=0,B=this.length):typeof B=="string"&&(F=B,B=this.length),F!==void 0&&typeof F!="string")throw new TypeError("encoding must be a string");if(typeof F=="string"&&!a.isEncoding(F))throw new TypeError("Unknown encoding: "+F);if(f.length===1){const Y=f.charCodeAt(0);(F==="utf8"&&Y<128||F==="latin1")&&(f=Y)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(d<0||this.length<d||this.length<B)throw new RangeError("Out of range index");if(B<=d)return this;d=d>>>0,B=B===void 0?this.length:B>>>0,f||(f=0);let $;if(typeof f=="number")for($=d;$<B;++$)this[$]=f;else{const Y=a.isBuffer(f)?f:a.from(f,F),Ht=Y.length;if(Ht===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for($=0;$<B-d;++$)this[$+d]=Y[$%Ht]}return this};const Tt={};function Pt(w,f,d){Tt[w]=class extends d{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${w}]`,this.stack,delete this.name}get code(){return w}set code(F){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:F,writable:!0})}toString(){return`${this.name} [${w}]: ${this.message}`}}}Pt("ERR_BUFFER_OUT_OF_BOUNDS",function(w){return w?`${w} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Pt("ERR_INVALID_ARG_TYPE",function(w,f){return`The "${w}" argument must be of type number. Received type ${typeof f}`},TypeError),Pt("ERR_OUT_OF_RANGE",function(w,f,d){let B=`The value of "${w}" is out of range.`,F=d;return Number.isInteger(d)&&Math.abs(d)>2**32?F=Ce(String(d)):typeof d=="bigint"&&(F=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(F=Ce(F)),F+="n"),B+=` It must be ${f}. Received ${F}`,B},RangeError);function Ce(w){let f="",d=w.length;const B=w[0]==="-"?1:0;for(;d>=B+4;d-=3)f=`_${w.slice(d-3,d)}${f}`;return`${w.slice(0,d)}${f}`}function Yt(w,f,d){le(f,"offset"),(w[f]===void 0||w[f+d]===void 0)&&re(f,w.length-(d+1))}function Gt(w,f,d,B,F,$){if(w>d||w<f){const Y=typeof f=="bigint"?"n":"";let Ht;throw f===0||f===BigInt(0)?Ht=`>= 0${Y} and < 2${Y} ** ${($+1)*8}${Y}`:Ht=`>= -(2${Y} ** ${($+1)*8-1}${Y}) and < 2 ** ${($+1)*8-1}${Y}`,new Tt.ERR_OUT_OF_RANGE("value",Ht,w)}Yt(B,F,$)}function le(w,f){if(typeof w!="number")throw new Tt.ERR_INVALID_ARG_TYPE(f,"number",w)}function re(w,f,d){throw Math.floor(w)!==w?(le(w,d),new Tt.ERR_OUT_OF_RANGE("offset","an integer",w)):f<0?new Tt.ERR_BUFFER_OUT_OF_BOUNDS:new Tt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${f}`,w)}const ve=/[^+/0-9A-Za-z-_]/g;function Or(w){if(w=w.split("=")[0],w=w.trim().replace(ve,""),w.length<2)return"";for(;w.length%4!==0;)w=w+"=";return w}function _e(w,f){f=f||1/0;let d;const B=w.length;let F=null;const $=[];for(let Y=0;Y<B;++Y){if(d=w.charCodeAt(Y),d>55295&&d<57344){if(!F){if(d>56319){(f-=3)>-1&&$.push(239,191,189);continue}else if(Y+1===B){(f-=3)>-1&&$.push(239,191,189);continue}F=d;continue}if(d<56320){(f-=3)>-1&&$.push(239,191,189),F=d;continue}d=(F-55296<<10|d-56320)+65536}else F&&(f-=3)>-1&&$.push(239,191,189);if(F=null,d<128){if((f-=1)<0)break;$.push(d)}else if(d<2048){if((f-=2)<0)break;$.push(d>>6|192,d&63|128)}else if(d<65536){if((f-=3)<0)break;$.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((f-=4)<0)break;$.push(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}else throw new Error("Invalid code point")}return $}function Oe(w){const f=[];for(let d=0;d<w.length;++d)f.push(w.charCodeAt(d)&255);return f}function Ar(w,f){let d,B,F;const $=[];for(let Y=0;Y<w.length&&!((f-=2)<0);++Y)d=w.charCodeAt(Y),B=d>>8,F=d%256,$.push(F),$.push(B);return $}function Ie(w){return t.toByteArray(Or(w))}function Ae(w,f,d,B){let F;for(F=0;F<B&&!(F+d>=f.length||F>=w.length);++F)f[F+d]=w[F];return F}function rr(w,f){return w instanceof f||w!=null&&w.constructor!=null&&w.constructor.name!=null&&w.constructor.name===f.name}function ke(w){return w!==w}const Se=function(){const w="0123456789abcdef",f=new Array(256);for(let d=0;d<16;++d){const B=d*16;for(let F=0;F<16;++F)f[B+F]=w[d]+w[F]}return f}();function fr(w){return typeof BigInt>"u"?Be:w}function Be(){throw new Error("BigInt not supported")}})(Ct);function Ei(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`positive integer expected, not ${n}`)}function cu(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function ii(n,...t){if(!cu(n))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(n.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${n.length}`)}function uu(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ei(n.outputLen),Ei(n.blockLen)}function Fn(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function Mo(n,t){ii(n);const e=t.outputLen;if(n.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}const ls=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fu=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),hs=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Hr=(n,t)=>n<<32-t|n>>>t,Po=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,lu=n=>n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255;function Co(n){for(let t=0;t<n.length;t++)n[t]=lu(n[t])}function hu(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function _i(n){return typeof n=="string"&&(n=hu(n)),ii(n),n}function du(...n){let t=0;for(let r=0;r<n.length;r++){const s=n[r];ii(s),t+=s.length}const e=new Uint8Array(t);for(let r=0,s=0;r<n.length;r++){const i=n[r];e.set(i,s),s+=i.length}return e}class ds{clone(){return this._cloneInto()}}function ps(n){const t=r=>n().update(_i(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function Lo(n=32){if(ls&&typeof ls.getRandomValues=="function")return ls.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}function pu(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(e>>s&i),a=Number(e&i),l=r?4:0,y=r?0:4;n.setUint32(t+l,o,r),n.setUint32(t+y,a,r)}const gu=(n,t,e)=>n&t^~n&e,yu=(n,t,e)=>n&t^n&e^t&e;class Uo extends ds{constructor(t,e,r,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=hs(this.buffer)}update(t){Fn(this);const{view:e,buffer:r,blockLen:s}=this;t=_i(t);const i=t.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const l=hs(t);for(;s<=i-o;o+=s)this.process(l,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Fn(this),Mo(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let E=o;E<s;E++)e[E]=0;pu(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=hs(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const y=l/4,x=this.get();if(y>x.length)throw new Error("_sha2: outputLen bigger than state");for(let E=0;E<y;E++)a.setUint32(4*E,x[E],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return t.length=s,t.pos=a,t.finished=i,t.destroyed=o,s%e&&t.buffer.set(r),t}}const Ii=BigInt(2**32-1),gs=BigInt(32);function Oo(n,t=!1){return t?{h:Number(n&Ii),l:Number(n>>gs&Ii)}:{h:Number(n>>gs&Ii)|0,l:Number(n&Ii)|0}}function No(n,t=!1){let e=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=Oo(n[s],t);[e[s],r[s]]=[i,o]}return[e,r]}const mu=(n,t)=>BigInt(n>>>0)<<gs|BigInt(t>>>0),wu=(n,t,e)=>n>>>e,bu=(n,t,e)=>n<<32-e|t>>>e,xu=(n,t,e)=>n>>>e|t<<32-e,vu=(n,t,e)=>n<<32-e|t>>>e,ku=(n,t,e)=>n<<64-e|t>>>e-32,Su=(n,t,e)=>n>>>e-32|t<<64-e,Eu=(n,t)=>t,_u=(n,t)=>n,Fo=(n,t,e)=>n<<e|t>>>32-e,zo=(n,t,e)=>t<<e|n>>>32-e,Ko=(n,t,e)=>t<<e-32|n>>>64-e,Wo=(n,t,e)=>n<<e-32|t>>>64-e;function Iu(n,t,e,r){const s=(t>>>0)+(r>>>0);return{h:n+e+(s/2**32|0)|0,l:s|0}}const Qt={fromBig:Oo,split:No,toBig:mu,shrSH:wu,shrSL:bu,rotrSH:xu,rotrSL:vu,rotrBH:ku,rotrBL:Su,rotr32H:Eu,rotr32L:_u,rotlSH:Fo,rotlSL:zo,rotlBH:Ko,rotlBL:Wo,add:Iu,add3L:(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),add3H:(n,t,e,r)=>t+e+r+(n/2**32|0)|0,add4L:(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),add4H:(n,t,e,r,s)=>t+e+r+s+(n/2**32|0)|0,add5H:(n,t,e,r,s,i)=>t+e+r+s+i+(n/2**32|0)|0,add5L:(n,t,e,r,s)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(s>>>0)},[Au,Bu]=Qt.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(n=>BigInt(n))),un=new Uint32Array(80),fn=new Uint32Array(80);class Ru extends Uo{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:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:l,Eh:y,El:x,Fh:E,Fl:L,Gh:C,Gl:N,Hh:M,Hl:O}=this;return[t,e,r,s,i,o,a,l,y,x,E,L,C,N,M,O]}set(t,e,r,s,i,o,a,l,y,x,E,L,C,N,M,O){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=l|0,this.Eh=y|0,this.El=x|0,this.Fh=E|0,this.Fl=L|0,this.Gh=C|0,this.Gl=N|0,this.Hh=M|0,this.Hl=O|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 st=un[V-15]|0,J=fn[V-15]|0,D=Qt.rotrSH(st,J,1)^Qt.rotrSH(st,J,8)^Qt.shrSH(st,J,7),tt=Qt.rotrSL(st,J,1)^Qt.rotrSL(st,J,8)^Qt.shrSL(st,J,7),nt=un[V-2]|0,ue=fn[V-2]|0,jt=Qt.rotrSH(nt,ue,19)^Qt.rotrBH(nt,ue,61)^Qt.shrSH(nt,ue,6),kt=Qt.rotrSL(nt,ue,19)^Qt.rotrBL(nt,ue,61)^Qt.shrSL(nt,ue,6),ce=Qt.add4L(tt,kt,fn[V-7],fn[V-16]),T=Qt.add4H(ce,D,jt,un[V-7],un[V-16]);un[V]=T|0,fn[V]=ce|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:l,Dh:y,Dl:x,Eh:E,El:L,Fh:C,Fl:N,Gh:M,Gl:O,Hh:K,Hl:Q}=this;for(let V=0;V<80;V++){const st=Qt.rotrSH(E,L,14)^Qt.rotrSH(E,L,18)^Qt.rotrBH(E,L,41),J=Qt.rotrSL(E,L,14)^Qt.rotrSL(E,L,18)^Qt.rotrBL(E,L,41),D=E&C^~E&M,tt=L&N^~L&O,nt=Qt.add5L(Q,J,tt,Bu[V],fn[V]),ue=Qt.add5H(nt,K,st,D,Au[V],un[V]),jt=nt|0,kt=Qt.rotrSH(r,s,28)^Qt.rotrBH(r,s,34)^Qt.rotrBH(r,s,39),ce=Qt.rotrSL(r,s,28)^Qt.rotrBL(r,s,34)^Qt.rotrBL(r,s,39),T=r&i^r&a^i&a,u=s&o^s&l^o&l;K=M|0,Q=O|0,M=C|0,O=N|0,C=E|0,N=L|0,{h:E,l:L}=Qt.add(y|0,x|0,ue|0,jt|0),y=a|0,x=l|0,a=i|0,l=o|0,i=r|0,o=s|0;const p=Qt.add3L(jt,ce,u);r=Qt.add3H(p,ue,kt,T),s=p|0}({h:r,l:s}=Qt.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=Qt.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l}=Qt.add(this.Ch|0,this.Cl|0,a|0,l|0),{h:y,l:x}=Qt.add(this.Dh|0,this.Dl|0,y|0,x|0),{h:E,l:L}=Qt.add(this.Eh|0,this.El|0,E|0,L|0),{h:C,l:N}=Qt.add(this.Fh|0,this.Fl|0,C|0,N|0),{h:M,l:O}=Qt.add(this.Gh|0,this.Gl|0,M|0,O|0),{h:K,l:Q}=Qt.add(this.Hh|0,this.Hl|0,K|0,Q|0),this.set(r,s,i,o,a,l,y,x,E,L,C,N,M,O,K,Q)}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 Tu=ps(()=>new Ru);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Do=BigInt(0),Ai=BigInt(1),Mu=BigInt(2);function bn(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function si(n){if(!bn(n))throw new Error("Uint8Array expected")}const Pu=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function xn(n){si(n);let t="";for(let e=0;e<n.length;e++)t+=Pu[n[e]];return t}function $o(n){const t=n.toString(16);return t.length&1?`0${t}`:t}function ys(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}const rn={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function qo(n){if(n>=rn._0&&n<=rn._9)return n-rn._0;if(n>=rn._A&&n<=rn._F)return n-(rn._A-10);if(n>=rn._a&&n<=rn._f)return n-(rn._a-10)}function zn(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const t=n.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(e);for(let s=0,i=0;s<e;s++,i+=2){const o=qo(n.charCodeAt(i)),a=qo(n.charCodeAt(i+1));if(o===void 0||a===void 0){const l=n[i]+n[i+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+i)}r[s]=o*16+a}return r}function vn(n){return ys(xn(n))}function Kn(n){return si(n),ys(xn(Uint8Array.from(n).reverse()))}function Wn(n,t){return zn(n.toString(16).padStart(t*2,"0"))}function oi(n,t){return Wn(n,t).reverse()}function Cu(n){return zn($o(n))}function ir(n,t,e){let r;if(typeof t=="string")try{r=zn(t)}catch(i){throw new Error(`${n} must be valid hex string, got "${t}". Cause: ${i}`)}else if(bn(t))r=Uint8Array.from(t);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof e=="number"&&s!==e)throw new Error(`${n} expected ${e} bytes, got ${s}`);return r}function kn(...n){let t=0;for(let r=0;r<n.length;r++){const s=n[r];si(s),t+=s.length}const e=new Uint8Array(t);for(let r=0,s=0;r<n.length;r++){const i=n[r];e.set(i,s),s+=i.length}return e}function Lu(n,t){if(n.length!==t.length)return!1;let e=0;for(let r=0;r<n.length;r++)e|=n[r]^t[r];return e===0}function Uu(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Ou(n){let t;for(t=0;n>Do;n>>=Ai,t+=1);return t}function Nu(n,t){return n>>BigInt(t)&Ai}function Fu(n,t,e){return n|(e?Ai:Do)<<BigInt(t)}const ms=n=>(Mu<<BigInt(n-1))-Ai,ws=n=>new Uint8Array(n),Ho=n=>Uint8Array.from(n);function Vo(n,t,e){if(typeof n!="number"||n<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 r=ws(n),s=ws(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...E)=>e(s,r,...E),l=(E=ws())=>{s=a(Ho([0]),E),r=a(),E.length!==0&&(s=a(Ho([1]),E),r=a())},y=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let E=0;const L=[];for(;E<t;){r=a();const C=r.slice();L.push(C),E+=r.length}return kn(...L)};return(E,L)=>{o(),l(E);let C;for(;!(C=L(y()));)l();return o(),C}}const zu={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||bn(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,t)=>t.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function Dn(n,t,e={}){const r=(s,i,o)=>{const a=zu[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const l=n[s];if(!(o&&l===void 0)&&!a(l,n))throw new Error(`Invalid param ${String(s)}=${l} (${typeof l}), expected ${i}`)};for(const[s,i]of Object.entries(t))r(s,i,!1);for(const[s,i]of Object.entries(e))r(s,i,!0);return n}const Ku=Object.freeze(Object.defineProperty({__proto__:null,abytes:si,bitGet:Nu,bitLen:Ou,bitMask:ms,bitSet:Fu,bytesToHex:xn,bytesToNumberBE:vn,bytesToNumberLE:Kn,concatBytes:kn,createHmacDrbg:Vo,ensureBytes:ir,equalBytes:Lu,hexToBytes:zn,hexToNumber:ys,isBytes:bn,numberToBytesBE:Wn,numberToBytesLE:oi,numberToHexUnpadded:$o,numberToVarBytesBE:Cu,utf8ToBytes:Uu,validateObject:Dn},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const or=BigInt(0),qe=BigInt(1),Sn=BigInt(2),Wu=BigInt(3),bs=BigInt(4),jo=BigInt(5),Go=BigInt(8);BigInt(9),BigInt(16);function We(n,t){const e=n%t;return e>=or?e:t+e}function Du(n,t,e){if(e<=or||t<or)throw new Error("Expected power/modulo > 0");if(e===qe)return or;let r=qe;for(;t>or;)t&qe&&(r=r*n%e),n=n*n%e,t>>=qe;return r}function Ge(n,t,e){let r=n;for(;t-- >or;)r*=r,r%=e;return r}function xs(n,t){if(n===or||t<=or)throw new Error(`invert: expected positive integers, got n=${n} mod=${t}`);let e=We(n,t),r=t,s=or,i=qe;for(;e!==or;){const a=r/e,l=r%e,y=s-i*a;r=e,e=l,s=i,i=y}if(r!==qe)throw new Error("invert: does not exist");return We(s,t)}function $u(n){const t=(n-qe)/Sn;let e,r,s;for(e=n-qe,r=0;e%Sn===or;e/=Sn,r++);for(s=Sn;s<n&&Du(s,t,n)!==n-qe;s++);if(r===1){const o=(n+qe)/bs;return function(l,y){const x=l.pow(y,o);if(!l.eql(l.sqr(x),y))throw new Error("Cannot find square root");return x}}const i=(e+qe)/Sn;return function(a,l){if(a.pow(l,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let y=r,x=a.pow(a.mul(a.ONE,s),e),E=a.pow(l,i),L=a.pow(l,e);for(;!a.eql(L,a.ONE);){if(a.eql(L,a.ZERO))return a.ZERO;let C=1;for(let M=a.sqr(L);C<y&&!a.eql(M,a.ONE);C++)M=a.sqr(M);const N=a.pow(x,qe<<BigInt(y-C-1));x=a.sqr(N),E=a.mul(E,N),L=a.mul(L,x),y=C}return E}}function qu(n){if(n%bs===Wu){const t=(n+qe)/bs;return function(r,s){const i=r.pow(s,t);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%Go===jo){const t=(n-jo)/Go;return function(r,s){const i=r.mul(s,Sn),o=r.pow(i,t),a=r.mul(s,o),l=r.mul(r.mul(a,Sn),o),y=r.mul(a,r.sub(l,r.ONE));if(!r.eql(r.sqr(y),s))throw new Error("Cannot find square root");return y}}return $u(n)}const Hu=(n,t)=>(We(n,t)&qe)===qe,Vu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ju(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Vu.reduce((r,s)=>(r[s]="function",r),t);return Dn(n,e)}function Gu(n,t,e){if(e<or)throw new Error("Expected power > 0");if(e===or)return n.ONE;if(e===qe)return t;let r=n.ONE,s=t;for(;e>or;)e&qe&&(r=n.mul(r,s)),s=n.sqr(s),e>>=qe;return r}function Yu(n,t){const e=new Array(t.length),r=t.reduce((i,o,a)=>n.is0(o)?i:(e[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return t.reduceRight((i,o,a)=>n.is0(o)?i:(e[a]=n.mul(i,e[a]),n.mul(i,o)),s),e}function Yo(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function Zo(n,t,e=!1,r={}){if(n<=or)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=Yo(n,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=qu(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:ms(s),ZERO:or,ONE:qe,create:l=>We(l,n),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return or<=l&&l<n},is0:l=>l===or,isOdd:l=>(l&qe)===qe,neg:l=>We(-l,n),eql:(l,y)=>l===y,sqr:l=>We(l*l,n),add:(l,y)=>We(l+y,n),sub:(l,y)=>We(l-y,n),mul:(l,y)=>We(l*y,n),pow:(l,y)=>Gu(a,l,y),div:(l,y)=>We(l*xs(y,n),n),sqrN:l=>l*l,addN:(l,y)=>l+y,subN:(l,y)=>l-y,mulN:(l,y)=>l*y,inv:l=>xs(l,n),sqrt:r.sqrt||(l=>o(a,l)),invertBatch:l=>Yu(a,l),cmov:(l,y,x)=>x?y:l,toBytes:l=>e?oi(l,i):Wn(l,i),fromBytes:l=>{if(l.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${l.length}`);return e?Kn(l):vn(l)}});return Object.freeze(a)}function Jo(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const t=n.toString(2).length;return Math.ceil(t/8)}function Xo(n){const t=Jo(n);return t+Math.ceil(t/2)}function Zu(n,t,e=!1){const r=n.length,s=Jo(t),i=Xo(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=e?vn(n):Kn(n),a=We(o,t-qe)+qe;return e?oi(a,s):Wn(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ju=BigInt(0),vs=BigInt(1);function Qo(n,t){const e=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(t/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:e,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>Ju;)i&vs&&(o=o.add(a)),a=a.double(),i>>=vs;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),l=[];let y=s,x=y;for(let E=0;E<o;E++){x=y,l.push(x);for(let L=1;L<a;L++)x=x.add(y),l.push(x);y=x.double()}return l},wNAF(s,i,o){const{windows:a,windowSize:l}=r(s);let y=n.ZERO,x=n.BASE;const E=BigInt(2**s-1),L=2**s,C=BigInt(s);for(let N=0;N<a;N++){const M=N*l;let O=Number(o&E);o>>=C,O>l&&(O-=L,o+=vs);const K=M,Q=M+Math.abs(O)-1,V=N%2!==0,st=O<0;O===0?x=x.add(e(V,i[K])):y=y.add(e(st,i[Q]))}return{p:y,f:x}},wNAFCached(s,i,o,a){const l=s._WINDOW_SIZE||1;let y=i.get(s);return y||(y=this.precomputeWindow(s,l),l!==1&&i.set(s,a(y))),this.wNAF(l,y,o)}}}function ks(n){return ju(n.Fp),Dn(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Yo(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fr=BigInt(0),Br=BigInt(1),Bi=BigInt(2),Xu=BigInt(8),Qu={zip215:!0};function tf(n){const t=ks(n);return Dn(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function ef(n){const t=tf(n),{Fp:e,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:l}=t,y=Bi<<BigInt(a*8)-Br,x=e.create,E=t.uvRatio||((_,I)=>{try{return{isValid:!0,value:e.sqrt(_*e.inv(I))}}catch{return{isValid:!1,value:Fr}}}),L=t.adjustScalarBytes||(_=>_),C=t.domain||((_,I,U)=>{if(I.length||U)throw new Error("Contexts/pre-hash are not supported");return _}),N=_=>typeof _=="bigint"&&Fr<_,M=(_,I)=>N(_)&&N(I)&&_<I,O=_=>_===Fr||M(_,y);function K(_,I){if(M(_,I))return _;throw new Error(`Expected valid scalar < ${I}, got ${typeof _} ${_}`)}function Q(_){return _===Fr?_:K(_,r)}const V=new Map;function st(_){if(!(_ instanceof J))throw new Error("ExtendedPoint expected")}class J{constructor(I,U,k,h){if(this.ex=I,this.ey=U,this.ez=k,this.et=h,!O(I))throw new Error("x required");if(!O(U))throw new Error("y required");if(!O(k))throw new Error("z required");if(!O(h))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(I){if(I instanceof J)throw new Error("extended point not allowed");const{x:U,y:k}=I||{};if(!O(U)||!O(k))throw new Error("invalid affine point");return new J(U,k,Br,x(U*k))}static normalizeZ(I){const U=e.invertBatch(I.map(k=>k.ez));return I.map((k,h)=>k.toAffine(U[h])).map(J.fromAffine)}_setWindowSize(I){this._WINDOW_SIZE=I,V.delete(this)}assertValidity(){const{a:I,d:U}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:k,ey:h,ez:A,et:Z}=this,et=x(k*k),ct=x(h*h),Mt=x(A*A),Tt=x(Mt*Mt),Pt=x(et*I),Ce=x(Mt*x(Pt+ct)),Yt=x(Tt+x(U*x(et*ct)));if(Ce!==Yt)throw new Error("bad point: equation left != right (1)");const Gt=x(k*h),le=x(A*Z);if(Gt!==le)throw new Error("bad point: equation left != right (2)")}equals(I){st(I);const{ex:U,ey:k,ez:h}=this,{ex:A,ey:Z,ez:et}=I,ct=x(U*et),Mt=x(A*h),Tt=x(k*et),Pt=x(Z*h);return ct===Mt&&Tt===Pt}is0(){return this.equals(J.ZERO)}negate(){return new J(x(-this.ex),this.ey,this.ez,x(-this.et))}double(){const{a:I}=t,{ex:U,ey:k,ez:h}=this,A=x(U*U),Z=x(k*k),et=x(Bi*x(h*h)),ct=x(I*A),Mt=U+k,Tt=x(x(Mt*Mt)-A-Z),Pt=ct+Z,Ce=Pt-et,Yt=ct-Z,Gt=x(Tt*Ce),le=x(Pt*Yt),re=x(Tt*Yt),ve=x(Ce*Pt);return new J(Gt,le,ve,re)}add(I){st(I);const{a:U,d:k}=t,{ex:h,ey:A,ez:Z,et}=this,{ex:ct,ey:Mt,ez:Tt,et:Pt}=I;if(U===BigInt(-1)){const rr=x((A-h)*(Mt+ct)),ke=x((A+h)*(Mt-ct)),Se=x(ke-rr);if(Se===Fr)return this.double();const fr=x(Z*Bi*Pt),Be=x(et*Bi*Tt),w=Be+fr,f=ke+rr,d=Be-fr,B=x(w*Se),F=x(f*d),$=x(w*d),Y=x(Se*f);return new J(B,F,Y,$)}const Ce=x(h*ct),Yt=x(A*Mt),Gt=x(et*k*Pt),le=x(Z*Tt),re=x((h+A)*(ct+Mt)-Ce-Yt),ve=le-Gt,Or=le+Gt,_e=x(Yt-U*Ce),Oe=x(re*ve),Ar=x(Or*_e),Ie=x(re*_e),Ae=x(ve*Or);return new J(Oe,Ar,Ae,Ie)}subtract(I){return this.add(I.negate())}wNAF(I){return nt.wNAFCached(this,V,I,J.normalizeZ)}multiply(I){const{p:U,f:k}=this.wNAF(K(I,r));return J.normalizeZ([U,k])[0]}multiplyUnsafe(I){let U=Q(I);return U===Fr?tt:this.equals(tt)||U===Br?this:this.equals(D)?this.wNAF(U).p:nt.unsafeLadder(this,U)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return nt.unsafeLadder(this,r).is0()}toAffine(I){const{ex:U,ey:k,ez:h}=this,A=this.is0();I==null&&(I=A?Xu:e.inv(h));const Z=x(U*I),et=x(k*I),ct=x(h*I);if(A)return{x:Fr,y:Br};if(ct!==Br)throw new Error("invZ was invalid");return{x:Z,y:et}}clearCofactor(){const{h:I}=t;return I===Br?this:this.multiplyUnsafe(I)}static fromHex(I,U=!1){const{d:k,a:h}=t,A=e.BYTES;I=ir("pointHex",I,A);const Z=I.slice(),et=I[A-1];Z[A-1]=et&-129;const ct=Kn(Z);ct===Fr||(U?K(ct,y):K(ct,e.ORDER));const Mt=x(ct*ct),Tt=x(Mt-Br),Pt=x(k*Mt-h);let{isValid:Ce,value:Yt}=E(Tt,Pt);if(!Ce)throw new Error("Point.fromHex: invalid y coordinate");const Gt=(Yt&Br)===Br,le=(et&128)!==0;if(!U&&Yt===Fr&&le)throw new Error("Point.fromHex: x=0 and x_0=1");return le!==Gt&&(Yt=x(-Yt)),J.fromAffine({x:Yt,y:ct})}static fromPrivateKey(I){return kt(I).point}toRawBytes(){const{x:I,y:U}=this.toAffine(),k=oi(U,e.BYTES);return k[k.length-1]|=I&Br?128:0,k}toHex(){return xn(this.toRawBytes())}}J.BASE=new J(t.Gx,t.Gy,Br,x(t.Gx*t.Gy)),J.ZERO=new J(Fr,Br,Br,Fr);const{BASE:D,ZERO:tt}=J,nt=Qo(J,a*8);function ue(_){return We(_,r)}function jt(_){return ue(Kn(_))}function kt(_){const I=a;_=ir("private key",_,I);const U=ir("hashed private key",i(_),2*I),k=L(U.slice(0,I)),h=U.slice(I,2*I),A=jt(k),Z=D.multiply(A),et=Z.toRawBytes();return{head:k,prefix:h,scalar:A,point:Z,pointBytes:et}}function ce(_){return kt(_).pointBytes}function T(_=new Uint8Array,...I){const U=kn(...I);return jt(i(C(U,ir("context",_),!!s)))}function u(_,I,U={}){_=ir("message",_),s&&(_=s(_));const{prefix:k,scalar:h,pointBytes:A}=kt(I),Z=T(U.context,k,_),et=D.multiply(Z).toRawBytes(),ct=T(U.context,et,A,_),Mt=ue(Z+ct*h);Q(Mt);const Tt=kn(et,oi(Mt,e.BYTES));return ir("result",Tt,a*2)}const p=Qu;function m(_,I,U,k=p){const{context:h,zip215:A}=k,Z=e.BYTES;_=ir("signature",_,2*Z),I=ir("message",I),s&&(I=s(I));const et=Kn(_.slice(Z,2*Z));let ct,Mt,Tt;try{ct=J.fromHex(U,A),Mt=J.fromHex(_.slice(0,Z),A),Tt=D.multiplyUnsafe(et)}catch{return!1}if(!A&&ct.isSmallOrder())return!1;const Pt=T(h,Mt.toRawBytes(),ct.toRawBytes(),I);return Mt.add(ct.multiplyUnsafe(Pt)).subtract(Tt).clearCofactor().equals(J.ZERO)}return D._setWindowSize(8),{CURVE:t,getPublicKey:ce,sign:u,verify:m,ExtendedPoint:J,utils:{getExtendedPublicKey:kt,randomPrivateKey:()=>o(e.BYTES),precompute(_=8,I=J.BASE){return I._setWindowSize(_),I.multiply(BigInt(3)),I}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ss=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ta=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const rf=BigInt(1),ea=BigInt(2);BigInt(3);const nf=BigInt(5),sf=BigInt(8);function of(n){const t=BigInt(10),e=BigInt(20),r=BigInt(40),s=BigInt(80),i=Ss,a=n*n%i*n%i,l=Ge(a,ea,i)*a%i,y=Ge(l,rf,i)*n%i,x=Ge(y,nf,i)*y%i,E=Ge(x,t,i)*x%i,L=Ge(E,e,i)*E%i,C=Ge(L,r,i)*L%i,N=Ge(C,s,i)*C%i,M=Ge(N,s,i)*C%i,O=Ge(M,t,i)*x%i;return{pow_p_5_8:Ge(O,ea,i)*n%i,b2:a}}function af(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function cf(n,t){const e=Ss,r=We(t*t*t,e),s=We(r*r*t,e),i=of(n*s).pow_p_5_8;let o=We(n*r*i,e);const a=We(t*o*o,e),l=o,y=We(o*ta,e),x=a===n,E=a===We(-n,e),L=a===We(-n*ta,e);return x&&(o=l),(E||L)&&(o=y),Hu(o,e)&&(o=We(-o,e)),{isValid:x||E,value:o}}const uf=Zo(Ss,void 0,!0),ff={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:uf,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:sf,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Tu,randomBytes:Lo,adjustScalarBytes:af,uvRatio:cf},$n=ef(ff);var Es={exports:{}};const ra=cs(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));Es.exports,function(n){(function(t,e){function r(T,u){if(!T)throw new Error(u||"Assertion failed")}function s(T,u){T.super_=u;var p=function(){};p.prototype=u.prototype,T.prototype=new p,T.prototype.constructor=T}function i(T,u,p){if(i.isBN(T))return T;this.negative=0,this.words=null,this.length=0,this.red=null,T!==null&&((u==="le"||u==="be")&&(p=u,u=10),this._init(T||0,u||10,p||"be"))}typeof t=="object"?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=ra.Buffer}catch{}i.isBN=function(u){return u instanceof i?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===i.wordSize&&Array.isArray(u.words)},i.max=function(u,p){return u.cmp(p)>0?u:p},i.min=function(u,p){return u.cmp(p)<0?u:p},i.prototype._init=function(u,p,m){if(typeof u=="number")return this._initNumber(u,p,m);if(typeof u=="object")return this._initArray(u,p,m);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),u=u.toString().replace(/\s+/g,"");var R=0;u[0]==="-"&&(R++,this.negative=1),R<u.length&&(p===16?this._parseHex(u,R,m):(this._parseBase(u,p,R),m==="le"&&this._initArray(this.toArray(),p,m)))},i.prototype._initNumber=function(u,p,m){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(r(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),m==="le"&&this._initArray(this.toArray(),p,m)},i.prototype._initArray=function(u,p,m){if(r(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var R=0;R<this.length;R++)this.words[R]=0;var _,I,U=0;if(m==="be")for(R=u.length-1,_=0;R>=0;R-=3)I=u[R]|u[R-1]<<8|u[R-2]<<16,this.words[_]|=I<<U&67108863,this.words[_+1]=I>>>26-U&67108863,U+=24,U>=26&&(U-=26,_++);else if(m==="le")for(R=0,_=0;R<u.length;R+=3)I=u[R]|u[R+1]<<8|u[R+2]<<16,this.words[_]|=I<<U&67108863,this.words[_+1]=I>>>26-U&67108863,U+=24,U>=26&&(U-=26,_++);return this._strip()};function a(T,u){var p=T.charCodeAt(u);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;r(!1,"Invalid character in "+T)}function l(T,u,p){var m=a(T,p);return p-1>=u&&(m|=a(T,p-1)<<4),m}i.prototype._parseHex=function(u,p,m){this.length=Math.ceil((u.length-p)/6),this.words=new Array(this.length);for(var R=0;R<this.length;R++)this.words[R]=0;var _=0,I=0,U;if(m==="be")for(R=u.length-1;R>=p;R-=2)U=l(u,p,R)<<_,this.words[I]|=U&67108863,_>=18?(_-=18,I+=1,this.words[I]|=U>>>26):_+=8;else{var k=u.length-p;for(R=k%2===0?p+1:p;R<u.length;R+=2)U=l(u,p,R)<<_,this.words[I]|=U&67108863,_>=18?(_-=18,I+=1,this.words[I]|=U>>>26):_+=8}this._strip()};function y(T,u,p,m){for(var R=0,_=0,I=Math.min(T.length,p),U=u;U<I;U++){var k=T.charCodeAt(U)-48;R*=m,k>=49?_=k-49+10:k>=17?_=k-17+10:_=k,r(k>=0&&_<m,"Invalid character"),R+=_}return R}i.prototype._parseBase=function(u,p,m){this.words=[0],this.length=1;for(var R=0,_=1;_<=67108863;_*=p)R++;R--,_=_/p|0;for(var I=u.length-m,U=I%R,k=Math.min(I,I-U)+m,h=0,A=m;A<k;A+=R)h=y(u,A,A+R,p),this.imuln(_),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(U!==0){var Z=1;for(h=y(u,A,u.length,p),A=0;A<U;A++)Z*=p;this.imuln(Z),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this._strip()},i.prototype.copy=function(u){u.words=new Array(this.length);for(var p=0;p<this.length;p++)u.words[p]=this.words[p];u.length=this.length,u.negative=this.negative,u.red=this.red};function x(T,u){T.words=u.words,T.length=u.length,T.negative=u.negative,T.red=u.red}if(i.prototype._move=function(u){x(u,this)},i.prototype.clone=function(){var u=new i(null);return this.copy(u),u},i.prototype._expand=function(u){for(;this.length<u;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=E}catch{i.prototype.inspect=E}else i.prototype.inspect=E;function E(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var L=["","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"],C=[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],N=[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];i.prototype.toString=function(u,p){u=u||10,p=p|0||1;var m;if(u===16||u==="hex"){m="";for(var R=0,_=0,I=0;I<this.length;I++){var U=this.words[I],k=((U<<R|_)&16777215).toString(16);_=U>>>24-R&16777215,R+=2,R>=26&&(R-=26,I--),_!==0||I!==this.length-1?m=L[6-k.length]+k+m:m=k+m}for(_!==0&&(m=_.toString(16)+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(u===(u|0)&&u>=2&&u<=36){var h=C[u],A=N[u];m="";var Z=this.clone();for(Z.negative=0;!Z.isZero();){var et=Z.modrn(A).toString(u);Z=Z.idivn(A),Z.isZero()?m=et+m:m=L[h-et.length]+et+m}for(this.isZero()&&(m="0"+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(u,p){return this.toArrayLike(o,u,p)}),i.prototype.toArray=function(u,p){return this.toArrayLike(Array,u,p)};var M=function(u,p){return u.allocUnsafe?u.allocUnsafe(p):new u(p)};i.prototype.toArrayLike=function(u,p,m){this._strip();var R=this.byteLength(),_=m||Math.max(1,R);r(R<=_,"byte array longer than desired length"),r(_>0,"Requested array length <= 0");var I=M(u,_),U=p==="le"?"LE":"BE";return this["_toArrayLike"+U](I,R),I},i.prototype._toArrayLikeLE=function(u,p){for(var m=0,R=0,_=0,I=0;_<this.length;_++){var U=this.words[_]<<I|R;u[m++]=U&255,m<u.length&&(u[m++]=U>>8&255),m<u.length&&(u[m++]=U>>16&255),I===6?(m<u.length&&(u[m++]=U>>24&255),R=0,I=0):(R=U>>>24,I+=2)}if(m<u.length)for(u[m++]=R;m<u.length;)u[m++]=0},i.prototype._toArrayLikeBE=function(u,p){for(var m=u.length-1,R=0,_=0,I=0;_<this.length;_++){var U=this.words[_]<<I|R;u[m--]=U&255,m>=0&&(u[m--]=U>>8&255),m>=0&&(u[m--]=U>>16&255),I===6?(m>=0&&(u[m--]=U>>24&255),R=0,I=0):(R=U>>>24,I+=2)}if(m>=0)for(u[m--]=R;m>=0;)u[m--]=0},Math.clz32?i.prototype._countBits=function(u){return 32-Math.clz32(u)}:i.prototype._countBits=function(u){var p=u,m=0;return p>=4096&&(m+=13,p>>>=13),p>=64&&(m+=7,p>>>=7),p>=8&&(m+=4,p>>>=4),p>=2&&(m+=2,p>>>=2),m+p},i.prototype._zeroBits=function(u){if(u===0)return 26;var p=u,m=0;return p&8191||(m+=13,p>>>=13),p&127||(m+=7,p>>>=7),p&15||(m+=4,p>>>=4),p&3||(m+=2,p>>>=2),p&1||m++,m},i.prototype.bitLength=function(){var u=this.words[this.length-1],p=this._countBits(u);return(this.length-1)*26+p};function O(T){for(var u=new Array(T.bitLength()),p=0;p<u.length;p++){var m=p/26|0,R=p%26;u[p]=T.words[m]>>>R&1}return u}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,p=0;p<this.length;p++){var m=this._zeroBits(this.words[p]);if(u+=m,m!==26)break}return u},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},i.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var p=0;p<u.length;p++)this.words[p]=this.words[p]|u.words[p];return this._strip()},i.prototype.ior=function(u){return r((this.negative|u.negative)===0),this.iuor(u)},i.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},i.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},i.prototype.iuand=function(u){var p;this.length>u.length?p=u:p=this;for(var m=0;m<p.length;m++)this.words[m]=this.words[m]&u.words[m];return this.length=p.length,this._strip()},i.prototype.iand=function(u){return r((this.negative|u.negative)===0),this.iuand(u)},i.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},i.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},i.prototype.iuxor=function(u){var p,m;this.length>u.length?(p=this,m=u):(p=u,m=this);for(var R=0;R<m.length;R++)this.words[R]=p.words[R]^m.words[R];if(this!==p)for(;R<p.length;R++)this.words[R]=p.words[R];return this.length=p.length,this._strip()},i.prototype.ixor=function(u){return r((this.negative|u.negative)===0),this.iuxor(u)},i.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},i.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},i.prototype.inotn=function(u){r(typeof u=="number"&&u>=0);var p=Math.ceil(u/26)|0,m=u%26;this._expand(p),m>0&&p--;for(var R=0;R<p;R++)this.words[R]=~this.words[R]&67108863;return m>0&&(this.words[R]=~this.words[R]&67108863>>26-m),this._strip()},i.prototype.notn=function(u){return this.clone().inotn(u)},i.prototype.setn=function(u,p){r(typeof u=="number"&&u>=0);var m=u/26|0,R=u%26;return this._expand(m+1),p?this.words[m]=this.words[m]|1<<R:this.words[m]=this.words[m]&~(1<<R),this._strip()},i.prototype.iadd=function(u){var p;if(this.negative!==0&&u.negative===0)return this.negative=0,p=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,p=this.isub(u),u.negative=1,p._normSign();var m,R;this.length>u.length?(m=this,R=u):(m=u,R=this);for(var _=0,I=0;I<R.length;I++)p=(m.words[I]|0)+(R.words[I]|0)+_,this.words[I]=p&67108863,_=p>>>26;for(;_!==0&&I<m.length;I++)p=(m.words[I]|0)+_,this.words[I]=p&67108863,_=p>>>26;if(this.length=m.length,_!==0)this.words[this.length]=_,this.length++;else if(m!==this)for(;I<m.length;I++)this.words[I]=m.words[I];return this},i.prototype.add=function(u){var p;return u.negative!==0&&this.negative===0?(u.negative=0,p=this.sub(u),u.negative^=1,p):u.negative===0&&this.negative!==0?(this.negative=0,p=u.sub(this),this.negative=1,p):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},i.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var p=this.iadd(u);return u.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var m=this.cmp(u);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var R,_;m>0?(R=this,_=u):(R=u,_=this);for(var I=0,U=0;U<_.length;U++)p=(R.words[U]|0)-(_.words[U]|0)+I,I=p>>26,this.words[U]=p&67108863;for(;I!==0&&U<R.length;U++)p=(R.words[U]|0)+I,I=p>>26,this.words[U]=p&67108863;if(I===0&&U<R.length&&R!==this)for(;U<R.length;U++)this.words[U]=R.words[U];return this.length=Math.max(this.length,U),R!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(u){return this.clone().isub(u)};function K(T,u,p){p.negative=u.negative^T.negative;var m=T.length+u.length|0;p.length=m,m=m-1|0;var R=T.words[0]|0,_=u.words[0]|0,I=R*_,U=I&67108863,k=I/67108864|0;p.words[0]=U;for(var h=1;h<m;h++){for(var A=k>>>26,Z=k&67108863,et=Math.min(h,u.length-1),ct=Math.max(0,h-T.length+1);ct<=et;ct++){var Mt=h-ct|0;R=T.words[Mt]|0,_=u.words[ct]|0,I=R*_+Z,A+=I/67108864|0,Z=I&67108863}p.words[h]=Z|0,k=A|0}return k!==0?p.words[h]=k|0:p.length--,p._strip()}var Q=function(u,p,m){var R=u.words,_=p.words,I=m.words,U=0,k,h,A,Z=R[0]|0,et=Z&8191,ct=Z>>>13,Mt=R[1]|0,Tt=Mt&8191,Pt=Mt>>>13,Ce=R[2]|0,Yt=Ce&8191,Gt=Ce>>>13,le=R[3]|0,re=le&8191,ve=le>>>13,Or=R[4]|0,_e=Or&8191,Oe=Or>>>13,Ar=R[5]|0,Ie=Ar&8191,Ae=Ar>>>13,rr=R[6]|0,ke=rr&8191,Se=rr>>>13,fr=R[7]|0,Be=fr&8191,w=fr>>>13,f=R[8]|0,d=f&8191,B=f>>>13,F=R[9]|0,$=F&8191,Y=F>>>13,Ht=_[0]|0,zt=Ht&8191,Nt=Ht>>>13,Re=_[1]|0,Lt=Re&8191,ze=Re>>>13,ri=_[2]|0,je=ri&8191,Ze=ri>>>13,as=_[3]|0,Te=as&8191,Le=as>>>13,cn=_[4]|0,De=cn&8191,$e=cn>>>13,vi=_[5]|0,Je=vi&8191,he=vi>>>13,ki=_[6]|0,g=ki&8191,b=ki>>>13,v=_[7]|0,c=v&8191,S=v>>>13,W=_[8]|0,z=W&8191,X=W>>>13,lt=_[9]|0,pt=lt&8191,ht=lt>>>13;m.negative=u.negative^p.negative,m.length=19,k=Math.imul(et,zt),h=Math.imul(et,Nt),h=h+Math.imul(ct,zt)|0,A=Math.imul(ct,Nt);var ae=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(ae>>>26)|0,ae&=67108863,k=Math.imul(Tt,zt),h=Math.imul(Tt,Nt),h=h+Math.imul(Pt,zt)|0,A=Math.imul(Pt,Nt),k=k+Math.imul(et,Lt)|0,h=h+Math.imul(et,ze)|0,h=h+Math.imul(ct,Lt)|0,A=A+Math.imul(ct,ze)|0;var vt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(vt>>>26)|0,vt&=67108863,k=Math.imul(Yt,zt),h=Math.imul(Yt,Nt),h=h+Math.imul(Gt,zt)|0,A=Math.imul(Gt,Nt),k=k+Math.imul(Tt,Lt)|0,h=h+Math.imul(Tt,ze)|0,h=h+Math.imul(Pt,Lt)|0,A=A+Math.imul(Pt,ze)|0,k=k+Math.imul(et,je)|0,h=h+Math.imul(et,Ze)|0,h=h+Math.imul(ct,je)|0,A=A+Math.imul(ct,Ze)|0;var Ft=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,k=Math.imul(re,zt),h=Math.imul(re,Nt),h=h+Math.imul(ve,zt)|0,A=Math.imul(ve,Nt),k=k+Math.imul(Yt,Lt)|0,h=h+Math.imul(Yt,ze)|0,h=h+Math.imul(Gt,Lt)|0,A=A+Math.imul(Gt,ze)|0,k=k+Math.imul(Tt,je)|0,h=h+Math.imul(Tt,Ze)|0,h=h+Math.imul(Pt,je)|0,A=A+Math.imul(Pt,Ze)|0,k=k+Math.imul(et,Te)|0,h=h+Math.imul(et,Le)|0,h=h+Math.imul(ct,Te)|0,A=A+Math.imul(ct,Le)|0;var Kt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,k=Math.imul(_e,zt),h=Math.imul(_e,Nt),h=h+Math.imul(Oe,zt)|0,A=Math.imul(Oe,Nt),k=k+Math.imul(re,Lt)|0,h=h+Math.imul(re,ze)|0,h=h+Math.imul(ve,Lt)|0,A=A+Math.imul(ve,ze)|0,k=k+Math.imul(Yt,je)|0,h=h+Math.imul(Yt,Ze)|0,h=h+Math.imul(Gt,je)|0,A=A+Math.imul(Gt,Ze)|0,k=k+Math.imul(Tt,Te)|0,h=h+Math.imul(Tt,Le)|0,h=h+Math.imul(Pt,Te)|0,A=A+Math.imul(Pt,Le)|0,k=k+Math.imul(et,De)|0,h=h+Math.imul(et,$e)|0,h=h+Math.imul(ct,De)|0,A=A+Math.imul(ct,$e)|0;var Vt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,k=Math.imul(Ie,zt),h=Math.imul(Ie,Nt),h=h+Math.imul(Ae,zt)|0,A=Math.imul(Ae,Nt),k=k+Math.imul(_e,Lt)|0,h=h+Math.imul(_e,ze)|0,h=h+Math.imul(Oe,Lt)|0,A=A+Math.imul(Oe,ze)|0,k=k+Math.imul(re,je)|0,h=h+Math.imul(re,Ze)|0,h=h+Math.imul(ve,je)|0,A=A+Math.imul(ve,Ze)|0,k=k+Math.imul(Yt,Te)|0,h=h+Math.imul(Yt,Le)|0,h=h+Math.imul(Gt,Te)|0,A=A+Math.imul(Gt,Le)|0,k=k+Math.imul(Tt,De)|0,h=h+Math.imul(Tt,$e)|0,h=h+Math.imul(Pt,De)|0,A=A+Math.imul(Pt,$e)|0,k=k+Math.imul(et,Je)|0,h=h+Math.imul(et,he)|0,h=h+Math.imul(ct,Je)|0,A=A+Math.imul(ct,he)|0;var qt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(qt>>>26)|0,qt&=67108863,k=Math.imul(ke,zt),h=Math.imul(ke,Nt),h=h+Math.imul(Se,zt)|0,A=Math.imul(Se,Nt),k=k+Math.imul(Ie,Lt)|0,h=h+Math.imul(Ie,ze)|0,h=h+Math.imul(Ae,Lt)|0,A=A+Math.imul(Ae,ze)|0,k=k+Math.imul(_e,je)|0,h=h+Math.imul(_e,Ze)|0,h=h+Math.imul(Oe,je)|0,A=A+Math.imul(Oe,Ze)|0,k=k+Math.imul(re,Te)|0,h=h+Math.imul(re,Le)|0,h=h+Math.imul(ve,Te)|0,A=A+Math.imul(ve,Le)|0,k=k+Math.imul(Yt,De)|0,h=h+Math.imul(Yt,$e)|0,h=h+Math.imul(Gt,De)|0,A=A+Math.imul(Gt,$e)|0,k=k+Math.imul(Tt,Je)|0,h=h+Math.imul(Tt,he)|0,h=h+Math.imul(Pt,Je)|0,A=A+Math.imul(Pt,he)|0,k=k+Math.imul(et,g)|0,h=h+Math.imul(et,b)|0,h=h+Math.imul(ct,g)|0,A=A+Math.imul(ct,b)|0;var Wt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,k=Math.imul(Be,zt),h=Math.imul(Be,Nt),h=h+Math.imul(w,zt)|0,A=Math.imul(w,Nt),k=k+Math.imul(ke,Lt)|0,h=h+Math.imul(ke,ze)|0,h=h+Math.imul(Se,Lt)|0,A=A+Math.imul(Se,ze)|0,k=k+Math.imul(Ie,je)|0,h=h+Math.imul(Ie,Ze)|0,h=h+Math.imul(Ae,je)|0,A=A+Math.imul(Ae,Ze)|0,k=k+Math.imul(_e,Te)|0,h=h+Math.imul(_e,Le)|0,h=h+Math.imul(Oe,Te)|0,A=A+Math.imul(Oe,Le)|0,k=k+Math.imul(re,De)|0,h=h+Math.imul(re,$e)|0,h=h+Math.imul(ve,De)|0,A=A+Math.imul(ve,$e)|0,k=k+Math.imul(Yt,Je)|0,h=h+Math.imul(Yt,he)|0,h=h+Math.imul(Gt,Je)|0,A=A+Math.imul(Gt,he)|0,k=k+Math.imul(Tt,g)|0,h=h+Math.imul(Tt,b)|0,h=h+Math.imul(Pt,g)|0,A=A+Math.imul(Pt,b)|0,k=k+Math.imul(et,c)|0,h=h+Math.imul(et,S)|0,h=h+Math.imul(ct,c)|0,A=A+Math.imul(ct,S)|0;var $t=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+($t>>>26)|0,$t&=67108863,k=Math.imul(d,zt),h=Math.imul(d,Nt),h=h+Math.imul(B,zt)|0,A=Math.imul(B,Nt),k=k+Math.imul(Be,Lt)|0,h=h+Math.imul(Be,ze)|0,h=h+Math.imul(w,Lt)|0,A=A+Math.imul(w,ze)|0,k=k+Math.imul(ke,je)|0,h=h+Math.imul(ke,Ze)|0,h=h+Math.imul(Se,je)|0,A=A+Math.imul(Se,Ze)|0,k=k+Math.imul(Ie,Te)|0,h=h+Math.imul(Ie,Le)|0,h=h+Math.imul(Ae,Te)|0,A=A+Math.imul(Ae,Le)|0,k=k+Math.imul(_e,De)|0,h=h+Math.imul(_e,$e)|0,h=h+Math.imul(Oe,De)|0,A=A+Math.imul(Oe,$e)|0,k=k+Math.imul(re,Je)|0,h=h+Math.imul(re,he)|0,h=h+Math.imul(ve,Je)|0,A=A+Math.imul(ve,he)|0,k=k+Math.imul(Yt,g)|0,h=h+Math.imul(Yt,b)|0,h=h+Math.imul(Gt,g)|0,A=A+Math.imul(Gt,b)|0,k=k+Math.imul(Tt,c)|0,h=h+Math.imul(Tt,S)|0,h=h+Math.imul(Pt,c)|0,A=A+Math.imul(Pt,S)|0,k=k+Math.imul(et,z)|0,h=h+Math.imul(et,X)|0,h=h+Math.imul(ct,z)|0,A=A+Math.imul(ct,X)|0;var Dt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,k=Math.imul($,zt),h=Math.imul($,Nt),h=h+Math.imul(Y,zt)|0,A=Math.imul(Y,Nt),k=k+Math.imul(d,Lt)|0,h=h+Math.imul(d,ze)|0,h=h+Math.imul(B,Lt)|0,A=A+Math.imul(B,ze)|0,k=k+Math.imul(Be,je)|0,h=h+Math.imul(Be,Ze)|0,h=h+Math.imul(w,je)|0,A=A+Math.imul(w,Ze)|0,k=k+Math.imul(ke,Te)|0,h=h+Math.imul(ke,Le)|0,h=h+Math.imul(Se,Te)|0,A=A+Math.imul(Se,Le)|0,k=k+Math.imul(Ie,De)|0,h=h+Math.imul(Ie,$e)|0,h=h+Math.imul(Ae,De)|0,A=A+Math.imul(Ae,$e)|0,k=k+Math.imul(_e,Je)|0,h=h+Math.imul(_e,he)|0,h=h+Math.imul(Oe,Je)|0,A=A+Math.imul(Oe,he)|0,k=k+Math.imul(re,g)|0,h=h+Math.imul(re,b)|0,h=h+Math.imul(ve,g)|0,A=A+Math.imul(ve,b)|0,k=k+Math.imul(Yt,c)|0,h=h+Math.imul(Yt,S)|0,h=h+Math.imul(Gt,c)|0,A=A+Math.imul(Gt,S)|0,k=k+Math.imul(Tt,z)|0,h=h+Math.imul(Tt,X)|0,h=h+Math.imul(Pt,z)|0,A=A+Math.imul(Pt,X)|0,k=k+Math.imul(et,pt)|0,h=h+Math.imul(et,ht)|0,h=h+Math.imul(ct,pt)|0,A=A+Math.imul(ct,ht)|0;var St=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(St>>>26)|0,St&=67108863,k=Math.imul($,Lt),h=Math.imul($,ze),h=h+Math.imul(Y,Lt)|0,A=Math.imul(Y,ze),k=k+Math.imul(d,je)|0,h=h+Math.imul(d,Ze)|0,h=h+Math.imul(B,je)|0,A=A+Math.imul(B,Ze)|0,k=k+Math.imul(Be,Te)|0,h=h+Math.imul(Be,Le)|0,h=h+Math.imul(w,Te)|0,A=A+Math.imul(w,Le)|0,k=k+Math.imul(ke,De)|0,h=h+Math.imul(ke,$e)|0,h=h+Math.imul(Se,De)|0,A=A+Math.imul(Se,$e)|0,k=k+Math.imul(Ie,Je)|0,h=h+Math.imul(Ie,he)|0,h=h+Math.imul(Ae,Je)|0,A=A+Math.imul(Ae,he)|0,k=k+Math.imul(_e,g)|0,h=h+Math.imul(_e,b)|0,h=h+Math.imul(Oe,g)|0,A=A+Math.imul(Oe,b)|0,k=k+Math.imul(re,c)|0,h=h+Math.imul(re,S)|0,h=h+Math.imul(ve,c)|0,A=A+Math.imul(ve,S)|0,k=k+Math.imul(Yt,z)|0,h=h+Math.imul(Yt,X)|0,h=h+Math.imul(Gt,z)|0,A=A+Math.imul(Gt,X)|0,k=k+Math.imul(Tt,pt)|0,h=h+Math.imul(Tt,ht)|0,h=h+Math.imul(Pt,pt)|0,A=A+Math.imul(Pt,ht)|0;var Bt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,k=Math.imul($,je),h=Math.imul($,Ze),h=h+Math.imul(Y,je)|0,A=Math.imul(Y,Ze),k=k+Math.imul(d,Te)|0,h=h+Math.imul(d,Le)|0,h=h+Math.imul(B,Te)|0,A=A+Math.imul(B,Le)|0,k=k+Math.imul(Be,De)|0,h=h+Math.imul(Be,$e)|0,h=h+Math.imul(w,De)|0,A=A+Math.imul(w,$e)|0,k=k+Math.imul(ke,Je)|0,h=h+Math.imul(ke,he)|0,h=h+Math.imul(Se,Je)|0,A=A+Math.imul(Se,he)|0,k=k+Math.imul(Ie,g)|0,h=h+Math.imul(Ie,b)|0,h=h+Math.imul(Ae,g)|0,A=A+Math.imul(Ae,b)|0,k=k+Math.imul(_e,c)|0,h=h+Math.imul(_e,S)|0,h=h+Math.imul(Oe,c)|0,A=A+Math.imul(Oe,S)|0,k=k+Math.imul(re,z)|0,h=h+Math.imul(re,X)|0,h=h+Math.imul(ve,z)|0,A=A+Math.imul(ve,X)|0,k=k+Math.imul(Yt,pt)|0,h=h+Math.imul(Yt,ht)|0,h=h+Math.imul(Gt,pt)|0,A=A+Math.imul(Gt,ht)|0;var xt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(xt>>>26)|0,xt&=67108863,k=Math.imul($,Te),h=Math.imul($,Le),h=h+Math.imul(Y,Te)|0,A=Math.imul(Y,Le),k=k+Math.imul(d,De)|0,h=h+Math.imul(d,$e)|0,h=h+Math.imul(B,De)|0,A=A+Math.imul(B,$e)|0,k=k+Math.imul(Be,Je)|0,h=h+Math.imul(Be,he)|0,h=h+Math.imul(w,Je)|0,A=A+Math.imul(w,he)|0,k=k+Math.imul(ke,g)|0,h=h+Math.imul(ke,b)|0,h=h+Math.imul(Se,g)|0,A=A+Math.imul(Se,b)|0,k=k+Math.imul(Ie,c)|0,h=h+Math.imul(Ie,S)|0,h=h+Math.imul(Ae,c)|0,A=A+Math.imul(Ae,S)|0,k=k+Math.imul(_e,z)|0,h=h+Math.imul(_e,X)|0,h=h+Math.imul(Oe,z)|0,A=A+Math.imul(Oe,X)|0,k=k+Math.imul(re,pt)|0,h=h+Math.imul(re,ht)|0,h=h+Math.imul(ve,pt)|0,A=A+Math.imul(ve,ht)|0;var Et=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Et>>>26)|0,Et&=67108863,k=Math.imul($,De),h=Math.imul($,$e),h=h+Math.imul(Y,De)|0,A=Math.imul(Y,$e),k=k+Math.imul(d,Je)|0,h=h+Math.imul(d,he)|0,h=h+Math.imul(B,Je)|0,A=A+Math.imul(B,he)|0,k=k+Math.imul(Be,g)|0,h=h+Math.imul(Be,b)|0,h=h+Math.imul(w,g)|0,A=A+Math.imul(w,b)|0,k=k+Math.imul(ke,c)|0,h=h+Math.imul(ke,S)|0,h=h+Math.imul(Se,c)|0,A=A+Math.imul(Se,S)|0,k=k+Math.imul(Ie,z)|0,h=h+Math.imul(Ie,X)|0,h=h+Math.imul(Ae,z)|0,A=A+Math.imul(Ae,X)|0,k=k+Math.imul(_e,pt)|0,h=h+Math.imul(_e,ht)|0,h=h+Math.imul(Oe,pt)|0,A=A+Math.imul(Oe,ht)|0;var _t=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(_t>>>26)|0,_t&=67108863,k=Math.imul($,Je),h=Math.imul($,he),h=h+Math.imul(Y,Je)|0,A=Math.imul(Y,he),k=k+Math.imul(d,g)|0,h=h+Math.imul(d,b)|0,h=h+Math.imul(B,g)|0,A=A+Math.imul(B,b)|0,k=k+Math.imul(Be,c)|0,h=h+Math.imul(Be,S)|0,h=h+Math.imul(w,c)|0,A=A+Math.imul(w,S)|0,k=k+Math.imul(ke,z)|0,h=h+Math.imul(ke,X)|0,h=h+Math.imul(Se,z)|0,A=A+Math.imul(Se,X)|0,k=k+Math.imul(Ie,pt)|0,h=h+Math.imul(Ie,ht)|0,h=h+Math.imul(Ae,pt)|0,A=A+Math.imul(Ae,ht)|0;var mt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(mt>>>26)|0,mt&=67108863,k=Math.imul($,g),h=Math.imul($,b),h=h+Math.imul(Y,g)|0,A=Math.imul(Y,b),k=k+Math.imul(d,c)|0,h=h+Math.imul(d,S)|0,h=h+Math.imul(B,c)|0,A=A+Math.imul(B,S)|0,k=k+Math.imul(Be,z)|0,h=h+Math.imul(Be,X)|0,h=h+Math.imul(w,z)|0,A=A+Math.imul(w,X)|0,k=k+Math.imul(ke,pt)|0,h=h+Math.imul(ke,ht)|0,h=h+Math.imul(Se,pt)|0,A=A+Math.imul(Se,ht)|0;var j=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(j>>>26)|0,j&=67108863,k=Math.imul($,c),h=Math.imul($,S),h=h+Math.imul(Y,c)|0,A=Math.imul(Y,S),k=k+Math.imul(d,z)|0,h=h+Math.imul(d,X)|0,h=h+Math.imul(B,z)|0,A=A+Math.imul(B,X)|0,k=k+Math.imul(Be,pt)|0,h=h+Math.imul(Be,ht)|0,h=h+Math.imul(w,pt)|0,A=A+Math.imul(w,ht)|0;var G=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(G>>>26)|0,G&=67108863,k=Math.imul($,z),h=Math.imul($,X),h=h+Math.imul(Y,z)|0,A=Math.imul(Y,X),k=k+Math.imul(d,pt)|0,h=h+Math.imul(d,ht)|0,h=h+Math.imul(B,pt)|0,A=A+Math.imul(B,ht)|0;var ot=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(ot>>>26)|0,ot&=67108863,k=Math.imul($,pt),h=Math.imul($,ht),h=h+Math.imul(Y,pt)|0,A=Math.imul(Y,ht);var rt=(U+k|0)+((h&8191)<<13)|0;return U=(A+(h>>>13)|0)+(rt>>>26)|0,rt&=67108863,I[0]=ae,I[1]=vt,I[2]=Ft,I[3]=Kt,I[4]=Vt,I[5]=qt,I[6]=Wt,I[7]=$t,I[8]=Dt,I[9]=St,I[10]=Bt,I[11]=xt,I[12]=Et,I[13]=_t,I[14]=mt,I[15]=j,I[16]=G,I[17]=ot,I[18]=rt,U!==0&&(I[19]=U,m.length++),m};Math.imul||(Q=K);function V(T,u,p){p.negative=u.negative^T.negative,p.length=T.length+u.length;for(var m=0,R=0,_=0;_<p.length-1;_++){var I=R;R=0;for(var U=m&67108863,k=Math.min(_,u.length-1),h=Math.max(0,_-T.length+1);h<=k;h++){var A=_-h,Z=T.words[A]|0,et=u.words[h]|0,ct=Z*et,Mt=ct&67108863;I=I+(ct/67108864|0)|0,Mt=Mt+U|0,U=Mt&67108863,I=I+(Mt>>>26)|0,R+=I>>>26,I&=67108863}p.words[_]=U,m=I,I=R}return m!==0?p.words[_]=m:p.length--,p._strip()}function st(T,u,p){return V(T,u,p)}i.prototype.mulTo=function(u,p){var m,R=this.length+u.length;return this.length===10&&u.length===10?m=Q(this,u,p):R<63?m=K(this,u,p):R<1024?m=V(this,u,p):m=st(this,u,p),m},i.prototype.mul=function(u){var p=new i(null);return p.words=new Array(this.length+u.length),this.mulTo(u,p)},i.prototype.mulf=function(u){var p=new i(null);return p.words=new Array(this.length+u.length),st(this,u,p)},i.prototype.imul=function(u){return this.clone().mulTo(u,this)},i.prototype.imuln=function(u){var p=u<0;p&&(u=-u),r(typeof u=="number"),r(u<67108864);for(var m=0,R=0;R<this.length;R++){var _=(this.words[R]|0)*u,I=(_&67108863)+(m&67108863);m>>=26,m+=_/67108864|0,m+=I>>>26,this.words[R]=I&67108863}return m!==0&&(this.words[R]=m,this.length++),p?this.ineg():this},i.prototype.muln=function(u){return this.clone().imuln(u)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(u){var p=O(u);if(p.length===0)return new i(1);for(var m=this,R=0;R<p.length&&p[R]===0;R++,m=m.sqr());if(++R<p.length)for(var _=m.sqr();R<p.length;R++,_=_.sqr())p[R]!==0&&(m=m.mul(_));return m},i.prototype.iushln=function(u){r(typeof u=="number"&&u>=0);var p=u%26,m=(u-p)/26,R=67108863>>>26-p<<26-p,_;if(p!==0){var I=0;for(_=0;_<this.length;_++){var U=this.words[_]&R,k=(this.words[_]|0)-U<<p;this.words[_]=k|I,I=U>>>26-p}I&&(this.words[_]=I,this.length++)}if(m!==0){for(_=this.length-1;_>=0;_--)this.words[_+m]=this.words[_];for(_=0;_<m;_++)this.words[_]=0;this.length+=m}return this._strip()},i.prototype.ishln=function(u){return r(this.negative===0),this.iushln(u)},i.prototype.iushrn=function(u,p,m){r(typeof u=="number"&&u>=0);var R;p?R=(p-p%26)/26:R=0;var _=u%26,I=Math.min((u-_)/26,this.length),U=67108863^67108863>>>_<<_,k=m;if(R-=I,R=Math.max(0,R),k){for(var h=0;h<I;h++)k.words[h]=this.words[h];k.length=I}if(I!==0)if(this.length>I)for(this.length-=I,h=0;h<this.length;h++)this.words[h]=this.words[h+I];else this.words[0]=0,this.length=1;var A=0;for(h=this.length-1;h>=0&&(A!==0||h>=R);h--){var Z=this.words[h]|0;this.words[h]=A<<26-_|Z>>>_,A=Z&U}return k&&A!==0&&(k.words[k.length++]=A),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(u,p,m){return r(this.negative===0),this.iushrn(u,p,m)},i.prototype.shln=function(u){return this.clone().ishln(u)},i.prototype.ushln=function(u){return this.clone().iushln(u)},i.prototype.shrn=function(u){return this.clone().ishrn(u)},i.prototype.ushrn=function(u){return this.clone().iushrn(u)},i.prototype.testn=function(u){r(typeof u=="number"&&u>=0);var p=u%26,m=(u-p)/26,R=1<<p;if(this.length<=m)return!1;var _=this.words[m];return!!(_&R)},i.prototype.imaskn=function(u){r(typeof u=="number"&&u>=0);var p=u%26,m=(u-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(p!==0&&m++,this.length=Math.min(m,this.length),p!==0){var R=67108863^67108863>>>p<<p;this.words[this.length-1]&=R}return this._strip()},i.prototype.maskn=function(u){return this.clone().imaskn(u)},i.prototype.iaddn=function(u){return r(typeof u=="number"),r(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<=u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},i.prototype._iaddn=function(u){this.words[0]+=u;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},i.prototype.isubn=function(u){if(r(typeof u=="number"),r(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this._strip()},i.prototype.addn=function(u){return this.clone().iaddn(u)},i.prototype.subn=function(u){return this.clone().isubn(u)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(u,p,m){var R=u.length+m,_;this._expand(R);var I,U=0;for(_=0;_<u.length;_++){I=(this.words[_+m]|0)+U;var k=(u.words[_]|0)*p;I-=k&67108863,U=(I>>26)-(k/67108864|0),this.words[_+m]=I&67108863}for(;_<this.length-m;_++)I=(this.words[_+m]|0)+U,U=I>>26,this.words[_+m]=I&67108863;if(U===0)return this._strip();for(r(U===-1),U=0,_=0;_<this.length;_++)I=-(this.words[_]|0)+U,U=I>>26,this.words[_]=I&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(u,p){var m=this.length-u.length,R=this.clone(),_=u,I=_.words[_.length-1]|0,U=this._countBits(I);m=26-U,m!==0&&(_=_.ushln(m),R.iushln(m),I=_.words[_.length-1]|0);var k=R.length-_.length,h;if(p!=="mod"){h=new i(null),h.length=k+1,h.words=new Array(h.length);for(var A=0;A<h.length;A++)h.words[A]=0}var Z=R.clone()._ishlnsubmul(_,1,k);Z.negative===0&&(R=Z,h&&(h.words[k]=1));for(var et=k-1;et>=0;et--){var ct=(R.words[_.length+et]|0)*67108864+(R.words[_.length+et-1]|0);for(ct=Math.min(ct/I|0,67108863),R._ishlnsubmul(_,ct,et);R.negative!==0;)ct--,R.negative=0,R._ishlnsubmul(_,1,et),R.isZero()||(R.negative^=1);h&&(h.words[et]=ct)}return h&&h._strip(),R._strip(),p!=="div"&&m!==0&&R.iushrn(m),{div:h||null,mod:R}},i.prototype.divmod=function(u,p,m){if(r(!u.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var R,_,I;return this.negative!==0&&u.negative===0?(I=this.neg().divmod(u,p),p!=="mod"&&(R=I.div.neg()),p!=="div"&&(_=I.mod.neg(),m&&_.negative!==0&&_.iadd(u)),{div:R,mod:_}):this.negative===0&&u.negative!==0?(I=this.divmod(u.neg(),p),p!=="mod"&&(R=I.div.neg()),{div:R,mod:I.mod}):this.negative&u.negative?(I=this.neg().divmod(u.neg(),p),p!=="div"&&(_=I.mod.neg(),m&&_.negative!==0&&_.isub(u)),{div:I.div,mod:_}):u.length>this.length||this.cmp(u)<0?{div:new i(0),mod:this}:u.length===1?p==="div"?{div:this.divn(u.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new i(this.modrn(u.words[0]))}:this._wordDiv(u,p)},i.prototype.div=function(u){return this.divmod(u,"div",!1).div},i.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},i.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},i.prototype.divRound=function(u){var p=this.divmod(u);if(p.mod.isZero())return p.div;var m=p.div.negative!==0?p.mod.isub(u):p.mod,R=u.ushrn(1),_=u.andln(1),I=m.cmp(R);return I<0||_===1&&I===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},i.prototype.modrn=function(u){var p=u<0;p&&(u=-u),r(u<=67108863);for(var m=(1<<26)%u,R=0,_=this.length-1;_>=0;_--)R=(m*R+(this.words[_]|0))%u;return p?-R:R},i.prototype.modn=function(u){return this.modrn(u)},i.prototype.idivn=function(u){var p=u<0;p&&(u=-u),r(u<=67108863);for(var m=0,R=this.length-1;R>=0;R--){var _=(this.words[R]|0)+m*67108864;this.words[R]=_/u|0,m=_%u}return this._strip(),p?this.ineg():this},i.prototype.divn=function(u){return this.clone().idivn(u)},i.prototype.egcd=function(u){r(u.negative===0),r(!u.isZero());var p=this,m=u.clone();p.negative!==0?p=p.umod(u):p=p.clone();for(var R=new i(1),_=new i(0),I=new i(0),U=new i(1),k=0;p.isEven()&&m.isEven();)p.iushrn(1),m.iushrn(1),++k;for(var h=m.clone(),A=p.clone();!p.isZero();){for(var Z=0,et=1;!(p.words[0]&et)&&Z<26;++Z,et<<=1);if(Z>0)for(p.iushrn(Z);Z-- >0;)(R.isOdd()||_.isOdd())&&(R.iadd(h),_.isub(A)),R.iushrn(1),_.iushrn(1);for(var ct=0,Mt=1;!(m.words[0]&Mt)&&ct<26;++ct,Mt<<=1);if(ct>0)for(m.iushrn(ct);ct-- >0;)(I.isOdd()||U.isOdd())&&(I.iadd(h),U.isub(A)),I.iushrn(1),U.iushrn(1);p.cmp(m)>=0?(p.isub(m),R.isub(I),_.isub(U)):(m.isub(p),I.isub(R),U.isub(_))}return{a:I,b:U,gcd:m.iushln(k)}},i.prototype._invmp=function(u){r(u.negative===0),r(!u.isZero());var p=this,m=u.clone();p.negative!==0?p=p.umod(u):p=p.clone();for(var R=new i(1),_=new i(0),I=m.clone();p.cmpn(1)>0&&m.cmpn(1)>0;){for(var U=0,k=1;!(p.words[0]&k)&&U<26;++U,k<<=1);if(U>0)for(p.iushrn(U);U-- >0;)R.isOdd()&&R.iadd(I),R.iushrn(1);for(var h=0,A=1;!(m.words[0]&A)&&h<26;++h,A<<=1);if(h>0)for(m.iushrn(h);h-- >0;)_.isOdd()&&_.iadd(I),_.iushrn(1);p.cmp(m)>=0?(p.isub(m),R.isub(_)):(m.isub(p),_.isub(R))}var Z;return p.cmpn(1)===0?Z=R:Z=_,Z.cmpn(0)<0&&Z.iadd(u),Z},i.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var p=this.clone(),m=u.clone();p.negative=0,m.negative=0;for(var R=0;p.isEven()&&m.isEven();R++)p.iushrn(1),m.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;m.isEven();)m.iushrn(1);var _=p.cmp(m);if(_<0){var I=p;p=m,m=I}else if(_===0||m.cmpn(1)===0)break;p.isub(m)}while(!0);return m.iushln(R)},i.prototype.invm=function(u){return this.egcd(u).a.umod(u)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(u){return this.words[0]&u},i.prototype.bincn=function(u){r(typeof u=="number");var p=u%26,m=(u-p)/26,R=1<<p;if(this.length<=m)return this._expand(m+1),this.words[m]|=R,this;for(var _=R,I=m;_!==0&&I<this.length;I++){var U=this.words[I]|0;U+=_,_=U>>>26,U&=67108863,this.words[I]=U}return _!==0&&(this.words[I]=_,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(u){var p=u<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var m;if(this.length>1)m=1;else{p&&(u=-u),r(u<=67108863,"Number is too big");var R=this.words[0]|0;m=R===u?0:R<u?-1:1}return this.negative!==0?-m|0:m},i.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var p=this.ucmp(u);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var p=0,m=this.length-1;m>=0;m--){var R=this.words[m]|0,_=u.words[m]|0;if(R!==_){R<_?p=-1:R>_&&(p=1);break}}return p},i.prototype.gtn=function(u){return this.cmpn(u)===1},i.prototype.gt=function(u){return this.cmp(u)===1},i.prototype.gten=function(u){return this.cmpn(u)>=0},i.prototype.gte=function(u){return this.cmp(u)>=0},i.prototype.ltn=function(u){return this.cmpn(u)===-1},i.prototype.lt=function(u){return this.cmp(u)===-1},i.prototype.lten=function(u){return this.cmpn(u)<=0},i.prototype.lte=function(u){return this.cmp(u)<=0},i.prototype.eqn=function(u){return this.cmpn(u)===0},i.prototype.eq=function(u){return this.cmp(u)===0},i.red=function(u){return new kt(u)},i.prototype.toRed=function(u){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(u){return this.red=u,this},i.prototype.forceRed=function(u){return r(!this.red,"Already a number in reduction context"),this._forceRed(u)},i.prototype.redAdd=function(u){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},i.prototype.redIAdd=function(u){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},i.prototype.redSub=function(u){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},i.prototype.redISub=function(u){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},i.prototype.redShl=function(u){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},i.prototype.redMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},i.prototype.redIMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(u){return r(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var J={k256:null,p224:null,p192:null,p25519:null};function D(T,u){this.name=T,this.p=new i(u,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}D.prototype._tmp=function(){var u=new i(null);return u.words=new Array(Math.ceil(this.n/13)),u},D.prototype.ireduce=function(u){var p=u,m;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),m=p.bitLength();while(m>this.n);var R=m<this.n?-1:p.ucmp(this.p);return R===0?(p.words[0]=0,p.length=1):R>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},D.prototype.split=function(u,p){u.iushrn(this.n,0,p)},D.prototype.imulK=function(u){return u.imul(this.k)};function tt(){D.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(tt,D),tt.prototype.split=function(u,p){for(var m=4194303,R=Math.min(u.length,9),_=0;_<R;_++)p.words[_]=u.words[_];if(p.length=R,u.length<=9){u.words[0]=0,u.length=1;return}var I=u.words[9];for(p.words[p.length++]=I&m,_=10;_<u.length;_++){var U=u.words[_]|0;u.words[_-10]=(U&m)<<4|I>>>22,I=U}I>>>=22,u.words[_-10]=I,I===0&&u.length>10?u.length-=10:u.length-=9},tt.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var p=0,m=0;m<u.length;m++){var R=u.words[m]|0;p+=R*977,u.words[m]=p&67108863,p=R*64+(p/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function nt(){D.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(nt,D);function ue(){D.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(ue,D);function jt(){D.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(jt,D),jt.prototype.imulK=function(u){for(var p=0,m=0;m<u.length;m++){var R=(u.words[m]|0)*19+p,_=R&67108863;R>>>=26,u.words[m]=_,p=R}return p!==0&&(u.words[u.length++]=p),u},i._prime=function(u){if(J[u])return J[u];var p;if(u==="k256")p=new tt;else if(u==="p224")p=new nt;else if(u==="p192")p=new ue;else if(u==="p25519")p=new jt;else throw new Error("Unknown prime "+u);return J[u]=p,p};function kt(T){if(typeof T=="string"){var u=i._prime(T);this.m=u.p,this.prime=u}else r(T.gtn(1),"modulus must be greater than 1"),this.m=T,this.prime=null}kt.prototype._verify1=function(u){r(u.negative===0,"red works only with positives"),r(u.red,"red works only with red numbers")},kt.prototype._verify2=function(u,p){r((u.negative|p.negative)===0,"red works only with positives"),r(u.red&&u.red===p.red,"red works only with red numbers")},kt.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):(x(u,u.umod(this.m)._forceRed(this)),u)},kt.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},kt.prototype.add=function(u,p){this._verify2(u,p);var m=u.add(p);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},kt.prototype.iadd=function(u,p){this._verify2(u,p);var m=u.iadd(p);return m.cmp(this.m)>=0&&m.isub(this.m),m},kt.prototype.sub=function(u,p){this._verify2(u,p);var m=u.sub(p);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},kt.prototype.isub=function(u,p){this._verify2(u,p);var m=u.isub(p);return m.cmpn(0)<0&&m.iadd(this.m),m},kt.prototype.shl=function(u,p){return this._verify1(u),this.imod(u.ushln(p))},kt.prototype.imul=function(u,p){return this._verify2(u,p),this.imod(u.imul(p))},kt.prototype.mul=function(u,p){return this._verify2(u,p),this.imod(u.mul(p))},kt.prototype.isqr=function(u){return this.imul(u,u.clone())},kt.prototype.sqr=function(u){return this.mul(u,u)},kt.prototype.sqrt=function(u){if(u.isZero())return u.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var m=this.m.add(new i(1)).iushrn(2);return this.pow(u,m)}for(var R=this.m.subn(1),_=0;!R.isZero()&&R.andln(1)===0;)_++,R.iushrn(1);r(!R.isZero());var I=new i(1).toRed(this),U=I.redNeg(),k=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new i(2*h*h).toRed(this);this.pow(h,k).cmp(U)!==0;)h.redIAdd(U);for(var A=this.pow(h,R),Z=this.pow(u,R.addn(1).iushrn(1)),et=this.pow(u,R),ct=_;et.cmp(I)!==0;){for(var Mt=et,Tt=0;Mt.cmp(I)!==0;Tt++)Mt=Mt.redSqr();r(Tt<ct);var Pt=this.pow(A,new i(1).iushln(ct-Tt-1));Z=Z.redMul(Pt),A=Pt.redSqr(),et=et.redMul(A),ct=Tt}return Z},kt.prototype.invm=function(u){var p=u._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},kt.prototype.pow=function(u,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return u.clone();var m=4,R=new Array(1<<m);R[0]=new i(1).toRed(this),R[1]=u;for(var _=2;_<R.length;_++)R[_]=this.mul(R[_-1],u);var I=R[0],U=0,k=0,h=p.bitLength()%26;for(h===0&&(h=26),_=p.length-1;_>=0;_--){for(var A=p.words[_],Z=h-1;Z>=0;Z--){var et=A>>Z&1;if(I!==R[0]&&(I=this.sqr(I)),et===0&&U===0){k=0;continue}U<<=1,U|=et,k++,!(k!==m&&(_!==0||Z!==0))&&(I=this.mul(I,R[U]),k=0,U=0)}h=26}return I},kt.prototype.convertTo=function(u){var p=u.umod(this.m);return p===u?p.clone():p},kt.prototype.convertFrom=function(u){var p=u.clone();return p.red=null,p},i.mont=function(u){return new ce(u)};function ce(T){kt.call(this,T),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(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)}s(ce,kt),ce.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},ce.prototype.convertFrom=function(u){var p=this.imod(u.mul(this.rinv));return p.red=null,p},ce.prototype.imul=function(u,p){if(u.isZero()||p.isZero())return u.words[0]=0,u.length=1,u;var m=u.imul(p),R=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=m.isub(R).iushrn(this.shift),I=_;return _.cmp(this.m)>=0?I=_.isub(this.m):_.cmpn(0)<0&&(I=_.iadd(this.m)),I._forceRed(this)},ce.prototype.mul=function(u,p){if(u.isZero()||p.isZero())return new i(0)._forceRed(this);var m=u.mul(p),R=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=m.isub(R).iushrn(this.shift),I=_;return _.cmp(this.m)>=0?I=_.isub(this.m):_.cmpn(0)<0&&(I=_.iadd(this.m)),I._forceRed(this)},ce.prototype.invm=function(u){var p=this.imod(u._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(n,Nr)}(Es);var na=Es.exports;const ia=ni(na);var _s={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,t){var e=Ct,r=e.Buffer;function s(o,a){for(var l in o)a[l]=o[l]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=e:(s(e,t),t.Buffer=i);function i(o,a,l){return r(o,a,l)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,a,l){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,l)},i.alloc=function(o,a,l){if(typeof o!="number")throw new TypeError("Argument must be a number");var y=r(o);return a!==void 0?typeof l=="string"?y.fill(a,l):y.fill(a):y.fill(0),y},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}})(_s,_s.exports);var lf=_s.exports,Ri=lf.Buffer;function hf(n){if(n.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 r=0;r<n.length;r++){var s=n.charAt(r),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=r}var o=n.length,a=n.charAt(0),l=Math.log(o)/Math.log(256),y=Math.log(256)/Math.log(o);function x(C){if((Array.isArray(C)||C instanceof Uint8Array)&&(C=Ri.from(C)),!Ri.isBuffer(C))throw new TypeError("Expected Buffer");if(C.length===0)return"";for(var N=0,M=0,O=0,K=C.length;O!==K&&C[O]===0;)O++,N++;for(var Q=(K-O)*y+1>>>0,V=new Uint8Array(Q);O!==K;){for(var st=C[O],J=0,D=Q-1;(st!==0||J<M)&&D!==-1;D--,J++)st+=256*V[D]>>>0,V[D]=st%o>>>0,st=st/o>>>0;if(st!==0)throw new Error("Non-zero carry");M=J,O++}for(var tt=Q-M;tt!==Q&&V[tt]===0;)tt++;for(var nt=a.repeat(N);tt<Q;++tt)nt+=n.charAt(V[tt]);return nt}function E(C){if(typeof C!="string")throw new TypeError("Expected String");if(C.length===0)return Ri.alloc(0);for(var N=0,M=0,O=0;C[N]===a;)M++,N++;for(var K=(C.length-N)*l+1>>>0,Q=new Uint8Array(K);C[N];){var V=t[C.charCodeAt(N)];if(V===255)return;for(var st=0,J=K-1;(V!==0||st<O)&&J!==-1;J--,st++)V+=o*Q[J]>>>0,Q[J]=V%256>>>0,V=V/256>>>0;if(V!==0)throw new Error("Non-zero carry");O=st,N++}for(var D=K-O;D!==K&&Q[D]===0;)D++;var tt=Ri.allocUnsafe(M+(K-D));tt.fill(0,0,M);for(var nt=M;D!==K;)tt[nt++]=Q[D++];return tt}function L(C){var N=E(C);if(N)return N;throw new Error("Non-base"+o+" character")}return{encode:x,decodeUnsafe:E,decode:L}}var df=hf,pf=df,gf="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",sa=pf(gf);const ar=ni(sa),yf=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]),ln=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),hn=new Uint32Array(64);class mf extends Uo{constructor(){super(64,32,8,!1),this.A=ln[0]|0,this.B=ln[1]|0,this.C=ln[2]|0,this.D=ln[3]|0,this.E=ln[4]|0,this.F=ln[5]|0,this.G=ln[6]|0,this.H=ln[7]|0}get(){const{A:t,B:e,C:r,D:s,E:i,F:o,G:a,H:l}=this;return[t,e,r,s,i,o,a,l]}set(t,e,r,s,i,o,a,l){this.A=t|0,this.B=e|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=l|0}process(t,e){for(let E=0;E<16;E++,e+=4)hn[E]=t.getUint32(e,!1);for(let E=16;E<64;E++){const L=hn[E-15],C=hn[E-2],N=Hr(L,7)^Hr(L,18)^L>>>3,M=Hr(C,17)^Hr(C,19)^C>>>10;hn[E]=M+hn[E-7]+N+hn[E-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:l,G:y,H:x}=this;for(let E=0;E<64;E++){const L=Hr(a,6)^Hr(a,11)^Hr(a,25),C=x+L+gu(a,l,y)+yf[E]+hn[E]|0,M=(Hr(r,2)^Hr(r,13)^Hr(r,22))+yu(r,s,i)|0;x=y,y=l,l=a,a=o+C|0,o=i,i=s,s=r,r=C+M|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,y=y+this.G|0,x=x+this.H|0,this.set(r,s,i,o,a,l,y,x)}roundClean(){hn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Is=ps(()=>new mf);var lr={};function nn(n,t,e){return t<=n&&n<=e}function Ti(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function wf(n){for(var t=String(n),e=t.length,r=0,s=[];r<e;){var i=t.charCodeAt(r);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(r===e-1)s.push(65533);else{var o=n.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=i&1023,l=o&1023;s.push(65536+(a<<10)+l),r+=1}else s.push(65533)}r+=1}return s}function bf(n){for(var t="",e=0;e<n.length;++e){var r=n[e];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}var Mi=-1;function As(n){this.tokens=[].slice.call(n)}As.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Mi},prepend:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(n)},push:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.push(t.shift());else this.tokens.push(n)}};var qn=-1;function Bs(n,t){if(n)throw TypeError("Decoder error");return t||65533}var Pi="utf-8";function Ci(n,t){if(!(this instanceof Ci))return new Ci(n,t);if(n=n!==void 0?String(n).toLowerCase():Pi,n!==Pi)throw new Error("Encoding not supported. Only utf-8 is supported");t=Ti(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})}Ci.prototype={decode:function(t,e){var r;typeof t=="object"&&t instanceof ArrayBuffer?r=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):r=new Uint8Array(0),e=Ti(e),this._streaming||(this._decoder=new xf({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var s=new As(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==qn);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===qn)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),bf(i)}};function Li(n,t){if(!(this instanceof Li))return new Li(n,t);if(n=n!==void 0?String(n).toLowerCase():Pi,n!==Pi)throw new Error("Encoding not supported. Only utf-8 is supported");t=Ti(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Li.prototype={encode:function(t,e){t=t?String(t):"",e=Ti(e),this._streaming||(this._encoder=new vf(this._options)),this._streaming=!!e.stream;for(var r=[],s=new As(wf(t)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==qn);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==qn;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function xf(n){var t=n.fatal,e=0,r=0,s=0,i=128,o=191;this.handler=function(a,l){if(l===Mi&&s!==0)return s=0,Bs(t);if(l===Mi)return qn;if(s===0){if(nn(l,0,127))return l;if(nn(l,194,223))s=1,e=l-192;else if(nn(l,224,239))l===224&&(i=160),l===237&&(o=159),s=2,e=l-224;else if(nn(l,240,244))l===240&&(i=144),l===244&&(o=143),s=3,e=l-240;else return Bs(t);return e=e<<6*s,null}if(!nn(l,i,o))return e=s=r=0,i=128,o=191,a.prepend(l),Bs(t);if(i=128,o=191,r+=1,e+=l-128<<6*(s-r),r!==s)return null;var y=e;return e=s=r=0,y}}function vf(n){n.fatal,this.handler=function(t,e){if(e===Mi)return qn;if(nn(e,0,127))return e;var r,s;nn(e,128,2047)?(r=1,s=192):nn(e,2048,65535)?(r=2,s=224):nn(e,65536,1114111)&&(r=3,s=240);for(var i=[(e>>6*r)+s];r>0;){var o=e>>6*(r-1);i.push(128|o&63),r-=1}return i}}const kf=cs(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Ci,TextEncoder:Li},Symbol.toStringTag,{value:"Module"})));var Sf=Nr&&Nr.__createBinding||(Object.create?function(n,t,e,r){r===void 0&&(r=e),Object.defineProperty(n,r,{enumerable:!0,get:function(){return t[e]}})}:function(n,t,e,r){r===void 0&&(r=e),n[r]=t[e]}),Ef=Nr&&Nr.__setModuleDefault||(Object.create?function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}:function(n,t){n.default=t}),Vr=Nr&&Nr.__decorate||function(n,t,e,r){var s=arguments.length,i=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,t,e,r);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(i=(s<3?o(i):s>3?o(t,e,i):o(t,e))||i);return s>3&&i&&Object.defineProperty(t,e,i),i},_f=Nr&&Nr.__importStar||function(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e in n)e!=="default"&&Object.hasOwnProperty.call(n,e)&&Sf(t,n,e);return Ef(t,n),t},oa=Nr&&Nr.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(lr,"__esModule",{value:!0});var aa=lr.deserializeUnchecked=da=lr.deserialize=ha=lr.serialize=lr.BinaryReader=lr.BinaryWriter=lr.BorshError=lr.baseDecode=lr.baseEncode=void 0;const dn=oa(na),ca=oa(sa),If=_f(kf),Af=typeof TextDecoder!="function"?If.TextDecoder:TextDecoder,Bf=new Af("utf-8",{fatal:!0});function Rf(n){return typeof n=="string"&&(n=Buffer.from(n,"utf8")),ca.default.encode(Buffer.from(n))}lr.baseEncode=Rf;function Tf(n){return Buffer.from(ca.default.decode(n))}lr.baseDecode=Tf;const Rs=1024;class kr 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=kr;class ua{constructor(){this.buf=Buffer.alloc(Rs),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(Rs)]))}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(Rs)]),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 r of t)this.maybeResize(),e(r)}toArray(){return this.buf.subarray(0,this.length)}}lr.BinaryWriter=ua;function jr(n,t,e){const r=e.value;e.value=function(...s){try{return r.apply(this,s)}catch(i){if(i instanceof RangeError){const o=i.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new kr("Reached the end of buffer when deserializing")}throw i}}}class Rr{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 kr(`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 Bf.decode(e)}catch(r){throw new kr(`Error decoding UTF-8 string: ${r}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),r=Array();for(let s=0;s<e;++s)r.push(t());return r}}Vr([jr],Rr.prototype,"readU8",null),Vr([jr],Rr.prototype,"readU16",null),Vr([jr],Rr.prototype,"readU32",null),Vr([jr],Rr.prototype,"readU64",null),Vr([jr],Rr.prototype,"readU128",null),Vr([jr],Rr.prototype,"readU256",null),Vr([jr],Rr.prototype,"readU512",null),Vr([jr],Rr.prototype,"readString",null),Vr([jr],Rr.prototype,"readFixedArray",null),Vr([jr],Rr.prototype,"readArray",null),lr.BinaryReader=Rr;function fa(n){return n.charAt(0).toUpperCase()+n.slice(1)}function En(n,t,e,r,s){try{if(typeof r=="string")s[`write${fa(r)}`](e);else if(r instanceof Array)if(typeof r[0]=="number"){if(e.length!==r[0])throw new kr(`Expecting byte array of length ${r[0]}, but got ${e.length} bytes`);s.writeFixedArray(e)}else if(r.length===2&&typeof r[1]=="number"){if(e.length!==r[1])throw new kr(`Expecting byte array of length ${r[1]}, but got ${e.length} bytes`);for(let i=0;i<r[1];i++)En(n,null,e[i],r[0],s)}else s.writeArray(e,i=>{En(n,t,i,r[0],s)});else if(r.kind!==void 0)switch(r.kind){case"option":{e==null?s.writeU8(0):(s.writeU8(1),En(n,t,e,r.type,s));break}case"map":{s.writeU32(e.size),e.forEach((i,o)=>{En(n,t,o,r.key,s),En(n,t,i,r.value,s)});break}default:throw new kr(`FieldType ${r} unrecognized`)}else la(n,e,s)}catch(i){throw i instanceof kr&&i.addToFieldPath(t),i}}function la(n,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const r=n.get(t.constructor);if(!r)throw new kr(`Class ${t.constructor.name} is missing in schema`);if(r.kind==="struct")r.fields.map(([s,i])=>{En(n,s,t[s],i,e)});else if(r.kind==="enum"){const s=t[r.field];for(let i=0;i<r.values.length;++i){const[o,a]=r.values[i];if(o===s){e.writeU8(i),En(n,o,t[o],a,e);break}}}else throw new kr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function Mf(n,t,e=ua){const r=new e;return la(n,t,r),r.toArray()}var ha=lr.serialize=Mf;function _n(n,t,e,r){try{if(typeof e=="string")return r[`read${fa(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return r.readFixedArray(e[0]);if(typeof e[1]=="number"){const s=[];for(let i=0;i<e[1];i++)s.push(_n(n,null,e[0],r));return s}else return r.readArray(()=>_n(n,t,e[0],r))}if(e.kind==="option")return r.readU8()?_n(n,t,e.type,r):void 0;if(e.kind==="map"){let s=new Map;const i=r.readU32();for(let o=0;o<i;o++){const a=_n(n,t,e.key,r),l=_n(n,t,e.value,r);s.set(a,l)}return s}return Ts(n,e,r)}catch(s){throw s instanceof kr&&s.addToFieldPath(t),s}}function Ts(n,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const r=n.get(t);if(!r)throw new kr(`Class ${t.name} is missing in schema`);if(r.kind==="struct"){const s={};for(const[i,o]of n.get(t).fields)s[i]=_n(n,i,o,e);return new t(s)}if(r.kind==="enum"){const s=e.readU8();if(s>=r.values.length)throw new kr(`Enum index: ${s} is out of range`);const[i,o]=r.values[s],a=_n(n,i,o,e);return new t({[i]:a})}throw new kr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function Pf(n,t,e,r=Rr){const s=new r(e),i=Ts(n,t,s);if(s.offset<e.length)throw new kr(`Unexpected ${e.length-s.offset} bytes after deserialized data`);return i}var da=lr.deserialize=Pf;function Cf(n,t,e,r=Rr){const s=new r(e);return Ts(n,t,s)}aa=lr.deserializeUnchecked=Cf;var H={};Object.defineProperty(H,"__esModule",{value:!0}),H.s16=H.s8=H.nu64be=H.u48be=H.u40be=H.u32be=H.u24be=H.u16be=hr=H.nu64=H.u48=H.u40=It=H.u32=H.u24=Lr=H.u16=ge=H.u8=pn=H.offset=H.greedy=H.Constant=H.UTF8=H.CString=H.Blob=H.Boolean=H.BitField=H.BitStructure=H.VariantLayout=H.Union=H.UnionLayoutDiscriminator=H.UnionDiscriminator=H.Structure=H.Sequence=H.DoubleBE=H.Double=H.FloatBE=H.Float=H.NearInt64BE=H.NearInt64=H.NearUInt64BE=H.NearUInt64=H.IntBE=H.Int=H.UIntBE=H.UInt=H.OffsetLayout=H.GreedyCount=H.ExternalLayout=H.bindConstructorLayout=H.nameWithProperty=H.Layout=H.uint8ArrayToBuffer=H.checkUint8Array=void 0,H.constant=H.utf8=H.cstr=Ke=H.blob=H.unionLayoutDiscriminator=H.union=dr=H.seq=H.bits=At=H.struct=H.f64be=H.f64=H.f32be=H.f32=H.ns64be=H.s48be=H.s40be=H.s32be=H.s24be=H.s16be=Tr=H.ns64=H.s48=H.s40=H.s32=H.s24=void 0;const Ms=Ct;function Hn(n){if(!(n instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}H.checkUint8Array=Hn;function be(n){return Hn(n),Ms.Buffer.from(n.buffer,n.byteOffset,n.length)}H.uint8ArrayToBuffer=be;class Me{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){}}H.Layout=Me;function Ps(n,t){return t.property?n+"["+t.property+"]":n}H.nameWithProperty=Ps;function Lf(n,t){if(typeof n!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(n,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Me))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");n.layout_=t,t.boundConstructor_=n,t.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(n,"decode",{value(e,r){return t.decode(e,r)},writable:!0})}H.bindConstructorLayout=Lf;class Er extends Me{isCount(){throw new Error("ExternalLayout is abstract")}}H.ExternalLayout=Er;class pa extends Er{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){Hn(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}H.GreedyCount=pa;class Cs extends Er{constructor(t,e=0,r){if(!(t instanceof Me))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||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,r=0){return this.layout.encode(t,e,r+this.offset)}}H.OffsetLayout=Cs;class Cr extends Me{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readUIntLE(e,this.span)}encode(t,e,r=0){return be(e).writeUIntLE(t,r,this.span),this.span}}H.UInt=Cr;class zr extends Me{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readUIntBE(e,this.span)}encode(t,e,r=0){return be(e).writeUIntBE(t,r,this.span),this.span}}H.UIntBE=zr;class In extends Me{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readIntLE(e,this.span)}encode(t,e,r=0){return be(e).writeIntLE(t,r,this.span),this.span}}H.Int=In;class Vn extends Me{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readIntBE(e,this.span)}encode(t,e,r=0){return be(e).writeIntBE(t,r,this.span),this.span}}H.IntBE=Vn;const Ls=Math.pow(2,32);function Ui(n){const t=Math.floor(n/Ls),e=n-t*Ls;return{hi32:t,lo32:e}}function Oi(n,t){return n*Ls+t}class ga extends Me{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),s=r.readUInt32LE(e),i=r.readUInt32LE(e+4);return Oi(i,s)}encode(t,e,r=0){const s=Ui(t),i=be(e);return i.writeUInt32LE(s.lo32,r),i.writeUInt32LE(s.hi32,r+4),8}}H.NearUInt64=ga;class ya extends Me{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),s=r.readUInt32BE(e),i=r.readUInt32BE(e+4);return Oi(s,i)}encode(t,e,r=0){const s=Ui(t),i=be(e);return i.writeUInt32BE(s.hi32,r),i.writeUInt32BE(s.lo32,r+4),8}}H.NearUInt64BE=ya;class ma extends Me{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),s=r.readUInt32LE(e),i=r.readInt32LE(e+4);return Oi(i,s)}encode(t,e,r=0){const s=Ui(t),i=be(e);return i.writeUInt32LE(s.lo32,r),i.writeInt32LE(s.hi32,r+4),8}}H.NearInt64=ma;class wa extends Me{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),s=r.readInt32BE(e),i=r.readUInt32BE(e+4);return Oi(s,i)}encode(t,e,r=0){const s=Ui(t),i=be(e);return i.writeInt32BE(s.hi32,r),i.writeUInt32BE(s.lo32,r+4),8}}H.NearInt64BE=wa;class ba extends Me{constructor(t){super(4,t)}decode(t,e=0){return be(t).readFloatLE(e)}encode(t,e,r=0){return be(e).writeFloatLE(t,r),4}}H.Float=ba;class xa extends Me{constructor(t){super(4,t)}decode(t,e=0){return be(t).readFloatBE(e)}encode(t,e,r=0){return be(e).writeFloatBE(t,r),4}}H.FloatBE=xa;class va extends Me{constructor(t){super(8,t)}decode(t,e=0){return be(t).readDoubleLE(e)}encode(t,e,r=0){return be(e).writeDoubleLE(t,r),8}}H.Double=va;class ka extends Me{constructor(t){super(8,t)}decode(t,e=0){return be(t).readDoubleBE(e)}encode(t,e,r=0){return be(e).writeDoubleBE(t,r),8}}H.DoubleBE=ka;class Sa extends Me{constructor(t,e,r){if(!(t instanceof Me))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Er&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let s=-1;!(e instanceof Er)&&0<t.span&&(s=e*t.span),super(s,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,s=this.count;if(s instanceof Er&&(s=s.decode(t,e)),0<this.elementLayout.span)r=s*this.elementLayout.span;else{let i=0;for(;i<s;)r+=this.elementLayout.getSpan(t,e+r),++i}return r}decode(t,e=0){const r=[];let s=0,i=this.count;for(i instanceof Er&&(i=i.decode(t,e));s<i;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),s+=1;return r}encode(t,e,r=0){const s=this.elementLayout,i=t.reduce((o,a)=>o+s.encode(a,e,r+o),0);return this.count instanceof Er&&this.count.encode(t.length,e,r),i}}H.Sequence=Sa;class Ea extends Me{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((i,o)=>i&&o instanceof Me,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const i of t)if(0>i.span&&i.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let s=-1;try{s=t.reduce((i,o)=>i+o.getSpan(),0)}catch{}super(s,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce((s,i)=>{const o=i.getSpan(t,e);return e+=o,s+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e=0){Hn(t);const r=this.makeDestinationObject();for(const s of this.fields)if(s.property!==void 0&&(r[s.property]=s.decode(t,e)),e+=s.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r=0){const s=r;let i=0,o=0;for(const a of this.fields){let l=a.span;if(o=0<l?l:0,a.property!==void 0){const y=t[a.property];y!==void 0&&(o=a.encode(y,e,r),0>l&&(l=a.getSpan(e,r)))}i=r,r+=l}return i+o-s}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.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 r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}H.Structure=Ea;class Us{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}}H.UnionDiscriminator=Us;class Ni extends Us{constructor(t,e){if(!(t instanceof Er&&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,r){return this.layout.encode(t,e,r)}}H.UnionLayoutDiscriminator=Ni;class Os extends Me{constructor(t,e,r){let s;if(t instanceof Cr||t instanceof zr)s=new Ni(new Cs(t));else if(t instanceof Er&&t.isCount())s=new Ni(t);else if(t instanceof Us)s=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 Me))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 i=-1;e&&(i=e.span,0<=i&&(t instanceof Cr||t instanceof zr)&&(i+=s.layout.span)),super(i,r),this.discriminator=s,this.usesPrefixDiscriminator=t instanceof Cr||t instanceof zr,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.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 r=this.registry[e];if(r.property&&Object.prototype.hasOwnProperty.call(t,r.property))return r}throw new Error("unable to infer src variant")}decode(t,e=0){let r;const s=this.discriminator,i=s.decode(t,e),o=this.registry[i];if(o===void 0){const a=this.defaultLayout;let l=0;this.usesPrefixDiscriminator&&(l=s.layout.span),r=this.makeDestinationObject(),r[s.property]=i,r[a.property]=a.decode(t,e+l)}else r=o.decode(t,e);return r}encode(t,e,r=0){const s=this.getSourceVariant(t);if(s===void 0){const i=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=i.layout.span),i.encode(t[i.property],e,r),a+o.encode(t[o.property],e,r+a)}return s.encode(t,e,r)}addVariant(t,e,r){const s=new _a(this,t,e,r);return this.registry[t]=s,s}getVariant(t,e=0){let r;return t instanceof Uint8Array?r=this.discriminator.decode(t,e):r=t,this.registry[r]}}H.Union=Os;class _a extends Me{constructor(t,e,r,s){if(!(t instanceof Os))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 r=="string"&&s===void 0&&(s=r,r=null),r){if(!(r instanceof Me))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof s!="string")throw new TypeError("variant must have a String property")}let i=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,s),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span);let s=0;return this.layout&&(s=this.layout.getSpan(t,e+r)),r+s}decode(t,e=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let s=0;return this.union.usesPrefixDiscriminator&&(s=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+s):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let s=0;if(this.union.usesPrefixDiscriminator&&(s=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,r);let i=s;if(this.layout&&(this.layout.encode(t[this.property],e,r+s),i+=this.layout.getSpan(e,r+s),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}H.VariantLayout=_a;function jn(n){return 0>n&&(n+=4294967296),n}class Ns extends Me{constructor(t,e,r){if(!(t instanceof Cr||t instanceof zr))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&r===void 0&&(r=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let s=0;this._packedSetValue=function(i){return s=jn(i),this},this._packedGetValue=function(){return s}}decode(t,e=0){const r=this.makeDestinationObject(),s=this.word.decode(t,e);this._packedSetValue(s);for(const i of this.fields)i.property!==void 0&&(r[i.property]=i.decode(t));return r}encode(t,e,r=0){const s=this.word.decode(e,r);this._packedSetValue(s);for(const i of this.fields)if(i.property!==void 0){const o=t[i.property];o!==void 0&&i.encode(o)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new Fs(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new Ia(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}}H.BitStructure=Ns;class Fs{constructor(t,e,r){if(!(t instanceof Ns))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const s=8*t.span,i=t.fields.reduce((o,a)=>o+a.bits,0);if(e+i>s)throw new Error("bits too long for span remainder ("+(s-i)+" of "+s+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=s-i-e),this.wordMask=jn(this.valueMask<<this.start),this.property=r}decode(t,e){const r=this.container._packedGetValue();return jn(r&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==jn(t&this.valueMask))throw new TypeError(Ps("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=jn(t<<this.start);this.container._packedSetValue(jn(e&~this.wordMask)|r)}}H.BitField=Fs;let Ia=class extends Fs{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)}};H.Boolean=Ia;class Aa extends Me{constructor(t,e){if(!(t instanceof Er&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Er||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e=0){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),be(t).slice(e,e+r)}encode(t,e,r){let s=this.length;if(this.length instanceof Er&&(s=t.length),!(t instanceof Uint8Array&&s===t.length))throw new TypeError(Ps("Blob.encode",this)+" requires (length "+s+") Uint8Array as src");if(r+s>e.length)throw new RangeError("encoding overruns Uint8Array");const i=be(t);return be(e).write(i.toString("hex"),r,s,"hex"),this.length instanceof Er&&this.length.encode(s,e,r),s}}H.Blob=Aa;class Ba extends Me{constructor(t){super(-1,t)}getSpan(t,e=0){Hn(t);let r=e;for(;r<t.length&&t[r]!==0;)r+=1;return 1+r-e}decode(t,e=0){const r=this.getSpan(t,e);return be(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const s=Ms.Buffer.from(t,"utf8"),i=s.length;if(r+i>e.length)throw new RangeError("encoding overruns Buffer");const o=be(e);return s.copy(o,r),o[r+i]=0,i+1}}H.CString=Ba;class Ra extends Me{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 Hn(t),t.length-e}decode(t,e=0){const r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return be(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const s=Ms.Buffer.from(t,"utf8"),i=s.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return s.copy(be(e),r),i}}H.UTF8=Ra;class Ta extends Me{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}}H.Constant=Ta,H.greedy=(n,t)=>new pa(n,t);var pn=H.offset=(n,t,e)=>new Cs(n,t,e),ge=H.u8=n=>new Cr(1,n),Lr=H.u16=n=>new Cr(2,n);H.u24=n=>new Cr(3,n);var It=H.u32=n=>new Cr(4,n);H.u40=n=>new Cr(5,n),H.u48=n=>new Cr(6,n);var hr=H.nu64=n=>new ga(n);H.u16be=n=>new zr(2,n),H.u24be=n=>new zr(3,n),H.u32be=n=>new zr(4,n),H.u40be=n=>new zr(5,n),H.u48be=n=>new zr(6,n),H.nu64be=n=>new ya(n),H.s8=n=>new In(1,n),H.s16=n=>new In(2,n),H.s24=n=>new In(3,n),H.s32=n=>new In(4,n),H.s40=n=>new In(5,n),H.s48=n=>new In(6,n);var Tr=H.ns64=n=>new ma(n);H.s16be=n=>new Vn(2,n),H.s24be=n=>new Vn(3,n),H.s32be=n=>new Vn(4,n),H.s40be=n=>new Vn(5,n),H.s48be=n=>new Vn(6,n),H.ns64be=n=>new wa(n),H.f32=n=>new ba(n),H.f32be=n=>new xa(n),H.f64=n=>new va(n),H.f64be=n=>new ka(n);var At=H.struct=(n,t,e)=>new Ea(n,t,e);H.bits=(n,t,e)=>new Ns(n,t,e);var dr=H.seq=(n,t,e)=>new Sa(n,t,e);H.union=(n,t,e)=>new Os(n,t,e),H.unionLayoutDiscriminator=(n,t)=>new Ni(n,t);var Ke=H.blob=(n,t)=>new Aa(n,t);H.cstr=n=>new Ba(n),H.utf8=(n,t)=>new Ra(n,t),H.constant=(n,t)=>new Ta(n,t);var ai={};Object.defineProperty(ai,"__esModule",{value:!0});function Uf(n){{const t=Buffer.from(n);t.reverse();const e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}var Of=ai.toBigIntLE=Uf;function Nf(n){{const t=n.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}ai.toBigIntBE=Nf;function Ff(n,t){{const e=n.toString(16),r=Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return r.reverse(),r}}var Ma=ai.toBufferLE=Ff;function zf(n,t){{const e=n.toString(16);return Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}}ai.toBufferBE=zf;class Kf extends TypeError{constructor(t,e){let r;const{message:s,explanation:i,...o}=t,{path:a}=t,l=a.length===0?s:`At path: ${a.join(".")} -- ${s}`;super(i??l),i!=null&&(this.cause=l),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}}function Wf(n){return ci(n)&&typeof n[Symbol.iterator]=="function"}function ci(n){return typeof n=="object"&&n!=null}function Fi(n){return ci(n)&&!Array.isArray(n)}function Kr(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function Df(n){const{done:t,value:e}=n.next();return t?void 0:e}function $f(n,t,e,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:s,branch:i}=t,{type:o}=e,{refinement:a,message:l=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${Kr(r)}\``}=n;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...n,message:l}}function*Pa(n,t,e,r){Wf(n)||(n=[n]);for(const s of n){const i=$f(s,t,e,r);i&&(yield i)}}function*zs(n,t,e={}){const{path:r=[],branch:s=[n],coerce:i=!1,mask:o=!1}=e,a={path:r,branch:s,mask:o};i&&(n=t.coercer(n,a));let l="valid";for(const y of t.validator(n,a))y.explanation=e.message,l="not_valid",yield[y,void 0];for(let[y,x,E]of t.entries(n,a)){const L=zs(x,E,{path:y===void 0?r:[...r,y],branch:y===void 0?s:[...s,x],coerce:i,mask:o,message:e.message});for(const C of L)C[0]?(l=C[0].refinement!=null?"not_refined":"not_valid",yield[C[0],void 0]):i&&(x=C[1],y===void 0?n=x:n instanceof Map?n.set(y,x):n instanceof Set?n.add(x):ci(n)&&(x!==void 0||y in n)&&(n[y]=x))}if(l!=="not_valid")for(const y of t.refiner(n,a))y.explanation=e.message,l="not_refined",yield[y,void 0];l==="valid"&&(yield[void 0,n])}let Gr=class{constructor(t){const{type:e,schema:r,validator:s,refiner:i,coercer:o=l=>l,entries:a=function*(){}}=t;this.type=e,this.schema=r,this.entries=a,this.coercer=o,s?this.validator=(l,y)=>{const x=s(l,y);return Pa(x,y,this,l)}:this.validator=()=>[],i?this.refiner=(l,y)=>{const x=i(l,y);return Pa(x,y,this,l)}:this.refiner=()=>[]}assert(t,e){return Ca(t,this,e)}create(t,e){return yt(t,this,e)}is(t){return La(t,this)}mask(t,e){return qf(t,this,e)}validate(t,e={}){return ui(t,this,e)}};function Ca(n,t,e){const r=ui(n,t,{message:e});if(r[0])throw r[0]}function yt(n,t,e){const r=ui(n,t,{coerce:!0,message:e});if(r[0])throw r[0];return r[1]}function qf(n,t,e){const r=ui(n,t,{coerce:!0,mask:!0,message:e});if(r[0])throw r[0];return r[1]}function La(n,t){return!ui(n,t)[0]}function ui(n,t,e={}){const r=zs(n,t,e),s=Df(r);return s[0]?[new Kf(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function An(n,t){return new Gr({type:n,schema:null,validator:t})}function Hf(){return An("any",()=>!0)}function wt(n){return new Gr({type:"array",schema:n,*entries(t){if(n&&Array.isArray(t))for(const[e,r]of t.entries())yield[e,r,n]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${Kr(t)}`}})}function Yr(){return An("boolean",n=>typeof n=="boolean")}function Ks(n){return An("instance",t=>t instanceof n||`Expected a \`${n.name}\` instance, but received: ${Kr(t)}`)}function He(n){const t=Kr(n),e=typeof n;return new Gr({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${t}\`, but received: ${Kr(r)}`}})}function Vf(){return An("never",()=>!1)}function bt(n){return new Gr({...n,validator:(t,e)=>t===null||n.validator(t,e),refiner:(t,e)=>t===null||n.refiner(t,e)})}function q(){return An("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${Kr(n)}`)}function Ot(n){return new Gr({...n,validator:(t,e)=>t===void 0||n.validator(t,e),refiner:(t,e)=>t===void 0||n.refiner(t,e)})}function Ua(n,t){return new Gr({type:"record",schema:null,*entries(e){if(ci(e))for(const r in e){const s=e[r];yield[r,r,n],yield[r,s,t]}},validator(e){return Fi(e)||`Expected an object, but received: ${Kr(e)}`},coercer(e){return Fi(e)?{...e}:e}})}function dt(){return An("string",n=>typeof n=="string"||`Expected a string, but received: ${Kr(n)}`)}function Ws(n){const t=Vf();return new Gr({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const r=Math.max(n.length,e.length);for(let s=0;s<r;s++)yield[s,e[s],n[s]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Kr(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function at(n){const t=Object.keys(n);return new Gr({type:"type",schema:n,*entries(e){if(ci(e))for(const r of t)yield[r,e[r],n[r]]},validator(e){return Fi(e)||`Expected an object, but received: ${Kr(e)}`},coercer(e){return Fi(e)?{...e}:e}})}function Sr(n){const t=n.map(e=>e.type).join(" | ");return new Gr({type:"union",schema:null,coercer(e,r){for(const s of n){const[i,o]=s.validate(e,{coerce:!0,mask:r.mask});if(!i)return o}return e},validator(e,r){const s=[];for(const i of n){const[...o]=zs(e,i,r),[a]=o;if(a[0])for(const[l]of o)l&&s.push(l);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Kr(e)}`,...s]}})}function Gn(){return An("unknown",()=>!0)}function fi(n,t,e){return new Gr({...n,coercer:(r,s)=>La(r,t)?n.coercer(e(r,s),s):n.coercer(r,s)})}var zi,jf=new Uint8Array(16);function Oa(){if(!zi&&(zi=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!zi))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return zi(jf)}const Gf=/^(?:[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(n){return typeof n=="string"&&Gf.test(n)}for(var pr=[],Ds=0;Ds<256;++Ds)pr.push((Ds+256).toString(16).substr(1));function Wi(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(pr[n[t+0]]+pr[n[t+1]]+pr[n[t+2]]+pr[n[t+3]]+"-"+pr[n[t+4]]+pr[n[t+5]]+"-"+pr[n[t+6]]+pr[n[t+7]]+"-"+pr[n[t+8]]+pr[n[t+9]]+"-"+pr[n[t+10]]+pr[n[t+11]]+pr[n[t+12]]+pr[n[t+13]]+pr[n[t+14]]+pr[n[t+15]]).toLowerCase();if(!Ki(e))throw TypeError("Stringified UUID is invalid");return e}var Na,$s,qs=0,Hs=0;function Yf(n,t,e){var r=t&&e||0,s=t||new Array(16);n=n||{};var i=n.node||Na,o=n.clockseq!==void 0?n.clockseq:$s;if(i==null||o==null){var a=n.random||(n.rng||Oa)();i==null&&(i=Na=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=$s=(a[6]<<8|a[7])&16383)}var l=n.msecs!==void 0?n.msecs:Date.now(),y=n.nsecs!==void 0?n.nsecs:Hs+1,x=l-qs+(y-Hs)/1e4;if(x<0&&n.clockseq===void 0&&(o=o+1&16383),(x<0||l>qs)&&n.nsecs===void 0&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");qs=l,Hs=y,$s=o,l+=122192928e5;var E=((l&268435455)*1e4+y)%4294967296;s[r++]=E>>>24&255,s[r++]=E>>>16&255,s[r++]=E>>>8&255,s[r++]=E&255;var L=l/4294967296*1e4&268435455;s[r++]=L>>>8&255,s[r++]=L&255,s[r++]=L>>>24&15|16,s[r++]=L>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var C=0;C<6;++C)s[r+C]=i[C];return t||Wi(s)}function Fa(n){if(!Ki(n))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(n.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(n.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(n.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(n.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(n.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 Zf(n){n=unescape(encodeURIComponent(n));for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}var Jf="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Xf="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function za(n,t,e){function r(s,i,o,a){if(typeof s=="string"&&(s=Zf(s)),typeof i=="string"&&(i=Fa(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var l=new Uint8Array(16+s.length);if(l.set(i),l.set(s,i.length),l=e(l),l[6]=l[6]&15|t,l[8]=l[8]&63|128,o){a=a||0;for(var y=0;y<16;++y)o[a+y]=l[y];return o}return Wi(l)}try{r.name=n}catch{}return r.DNS=Jf,r.URL=Xf,r}function Qf(n){if(typeof n=="string"){var t=unescape(encodeURIComponent(n));n=new Uint8Array(t.length);for(var e=0;e<t.length;++e)n[e]=t.charCodeAt(e)}return tl(el(rl(n),n.length*8))}function tl(n){for(var t=[],e=n.length*32,r="0123456789abcdef",s=0;s<e;s+=8){var i=n[s>>5]>>>s%32&255,o=parseInt(r.charAt(i>>>4&15)+r.charAt(i&15),16);t.push(o)}return t}function Ka(n){return(n+64>>>9<<4)+14+1}function el(n,t){n[t>>5]|=128<<t%32,n[Ka(t)-1]=t;for(var e=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<n.length;o+=16){var a=e,l=r,y=s,x=i;e=gr(e,r,s,i,n[o],7,-680876936),i=gr(i,e,r,s,n[o+1],12,-389564586),s=gr(s,i,e,r,n[o+2],17,606105819),r=gr(r,s,i,e,n[o+3],22,-1044525330),e=gr(e,r,s,i,n[o+4],7,-176418897),i=gr(i,e,r,s,n[o+5],12,1200080426),s=gr(s,i,e,r,n[o+6],17,-1473231341),r=gr(r,s,i,e,n[o+7],22,-45705983),e=gr(e,r,s,i,n[o+8],7,1770035416),i=gr(i,e,r,s,n[o+9],12,-1958414417),s=gr(s,i,e,r,n[o+10],17,-42063),r=gr(r,s,i,e,n[o+11],22,-1990404162),e=gr(e,r,s,i,n[o+12],7,1804603682),i=gr(i,e,r,s,n[o+13],12,-40341101),s=gr(s,i,e,r,n[o+14],17,-1502002290),r=gr(r,s,i,e,n[o+15],22,1236535329),e=yr(e,r,s,i,n[o+1],5,-165796510),i=yr(i,e,r,s,n[o+6],9,-1069501632),s=yr(s,i,e,r,n[o+11],14,643717713),r=yr(r,s,i,e,n[o],20,-373897302),e=yr(e,r,s,i,n[o+5],5,-701558691),i=yr(i,e,r,s,n[o+10],9,38016083),s=yr(s,i,e,r,n[o+15],14,-660478335),r=yr(r,s,i,e,n[o+4],20,-405537848),e=yr(e,r,s,i,n[o+9],5,568446438),i=yr(i,e,r,s,n[o+14],9,-1019803690),s=yr(s,i,e,r,n[o+3],14,-187363961),r=yr(r,s,i,e,n[o+8],20,1163531501),e=yr(e,r,s,i,n[o+13],5,-1444681467),i=yr(i,e,r,s,n[o+2],9,-51403784),s=yr(s,i,e,r,n[o+7],14,1735328473),r=yr(r,s,i,e,n[o+12],20,-1926607734),e=mr(e,r,s,i,n[o+5],4,-378558),i=mr(i,e,r,s,n[o+8],11,-2022574463),s=mr(s,i,e,r,n[o+11],16,1839030562),r=mr(r,s,i,e,n[o+14],23,-35309556),e=mr(e,r,s,i,n[o+1],4,-1530992060),i=mr(i,e,r,s,n[o+4],11,1272893353),s=mr(s,i,e,r,n[o+7],16,-155497632),r=mr(r,s,i,e,n[o+10],23,-1094730640),e=mr(e,r,s,i,n[o+13],4,681279174),i=mr(i,e,r,s,n[o],11,-358537222),s=mr(s,i,e,r,n[o+3],16,-722521979),r=mr(r,s,i,e,n[o+6],23,76029189),e=mr(e,r,s,i,n[o+9],4,-640364487),i=mr(i,e,r,s,n[o+12],11,-421815835),s=mr(s,i,e,r,n[o+15],16,530742520),r=mr(r,s,i,e,n[o+2],23,-995338651),e=wr(e,r,s,i,n[o],6,-198630844),i=wr(i,e,r,s,n[o+7],10,1126891415),s=wr(s,i,e,r,n[o+14],15,-1416354905),r=wr(r,s,i,e,n[o+5],21,-57434055),e=wr(e,r,s,i,n[o+12],6,1700485571),i=wr(i,e,r,s,n[o+3],10,-1894986606),s=wr(s,i,e,r,n[o+10],15,-1051523),r=wr(r,s,i,e,n[o+1],21,-2054922799),e=wr(e,r,s,i,n[o+8],6,1873313359),i=wr(i,e,r,s,n[o+15],10,-30611744),s=wr(s,i,e,r,n[o+6],15,-1560198380),r=wr(r,s,i,e,n[o+13],21,1309151649),e=wr(e,r,s,i,n[o+4],6,-145523070),i=wr(i,e,r,s,n[o+11],10,-1120210379),s=wr(s,i,e,r,n[o+2],15,718787259),r=wr(r,s,i,e,n[o+9],21,-343485551),e=gn(e,a),r=gn(r,l),s=gn(s,y),i=gn(i,x)}return[e,r,s,i]}function rl(n){if(n.length===0)return[];for(var t=n.length*8,e=new Uint32Array(Ka(t)),r=0;r<t;r+=8)e[r>>5]|=(n[r/8]&255)<<r%32;return e}function gn(n,t){var e=(n&65535)+(t&65535),r=(n>>16)+(t>>16)+(e>>16);return r<<16|e&65535}function nl(n,t){return n<<t|n>>>32-t}function Di(n,t,e,r,s,i){return gn(nl(gn(gn(t,n),gn(r,i)),s),e)}function gr(n,t,e,r,s,i,o){return Di(t&e|~t&r,n,t,s,i,o)}function yr(n,t,e,r,s,i,o){return Di(t&r|e&~r,n,t,s,i,o)}function mr(n,t,e,r,s,i,o){return Di(t^e^r,n,t,s,i,o)}function wr(n,t,e,r,s,i,o){return Di(e^(t|~r),n,t,s,i,o)}var il=za("v3",48,Qf);const sl=il;function ol(n,t,e){n=n||{};var r=n.random||(n.rng||Oa)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){e=e||0;for(var s=0;s<16;++s)t[e+s]=r[s];return t}return Wi(r)}function al(n,t,e,r){switch(n){case 0:return t&e^~t&r;case 1:return t^e^r;case 2:return t&e^t&r^e&r;case 3:return t^e^r}}function Vs(n,t){return n<<t|n>>>32-t}function cl(n){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){var r=unescape(encodeURIComponent(n));n=[];for(var s=0;s<r.length;++s)n.push(r.charCodeAt(s))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var i=n.length/4+2,o=Math.ceil(i/16),a=new Array(o),l=0;l<o;++l){for(var y=new Uint32Array(16),x=0;x<16;++x)y[x]=n[l*64+x*4]<<24|n[l*64+x*4+1]<<16|n[l*64+x*4+2]<<8|n[l*64+x*4+3];a[l]=y}a[o-1][14]=(n.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(n.length-1)*8&4294967295;for(var E=0;E<o;++E){for(var L=new Uint32Array(80),C=0;C<16;++C)L[C]=a[E][C];for(var N=16;N<80;++N)L[N]=Vs(L[N-3]^L[N-8]^L[N-14]^L[N-16],1);for(var M=e[0],O=e[1],K=e[2],Q=e[3],V=e[4],st=0;st<80;++st){var J=Math.floor(st/20),D=Vs(M,5)+al(J,O,K,Q)+V+t[J]+L[st]>>>0;V=Q,Q=K,K=Vs(O,30)>>>0,O=M,M=D}e[0]=e[0]+M>>>0,e[1]=e[1]+O>>>0,e[2]=e[2]+K>>>0,e[3]=e[3]+Q>>>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 ul=za("v5",80,cl);const fl=ul,ll="00000000-0000-0000-0000-000000000000";function hl(n){if(!Ki(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const Wa=cs(Object.freeze(Object.defineProperty({__proto__:null,NIL:ll,parse:Fa,stringify:Wi,v1:Yf,v3:sl,v4:ol,v5:fl,validate:Ki,version:hl},Symbol.toStringTag,{value:"Module"}))),dl=Wa.v4;var pl=function(n,t,e,r){if(typeof n!="string")throw new TypeError(n+" must be a string");r=r||{};const s=typeof r.version=="number"?r.version:2;if(s!==1&&s!==2)throw new TypeError(s+" must be 1 or 2");const i={method:n};if(s===2&&(i.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");i.params=t}if(typeof e>"u"){const o=typeof r.generator=="function"?r.generator:function(){return dl()};i.id=o(i,r)}else s===2&&e===null?r.notificationIdNull&&(i.id=null):i.id=e;return i};const gl=Wa.v4,yl=pl,li=function(n,t){if(!(this instanceof li))return new li(n,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 gl()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=n};var ml=li;li.prototype.request=function(n,t,e,r){const s=this;let i=null;const o=Array.isArray(n)&&typeof t=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&n&&typeof n=="object"&&typeof t=="function")r=t,i=n;else{typeof e=="function"&&(r=e,e=void 0);const y=typeof r=="function";try{i=yl(n,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(x){if(y)return r(x);throw x}if(!y)return i}let l;try{l=JSON.stringify(i,this.options.replacer)}catch(y){return r(y)}return this.callServer(l,function(y,x){s._parseResponse(y,x,r)}),i},li.prototype._parseResponse=function(n,t,e){if(n){e(n);return}if(!t)return e();let r;try{r=JSON.parse(t,this.options.reviver)}catch(s){return e(s)}if(e.length===3)if(Array.isArray(r)){const s=function(o){return typeof o.error<"u"},i=function(o){return!s(o)};return e(null,r.filter(s),r.filter(i))}else return e(null,r.error,r.result);e(null,r)};const wl=ni(ml);var Da={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function s(l,y,x){this.fn=l,this.context=y,this.once=x||!1}function i(l,y,x,E,L){if(typeof x!="function")throw new TypeError("The listener must be a function");var C=new s(x,E||l,L),N=e?e+y:y;return l._events[N]?l._events[N].fn?l._events[N]=[l._events[N],C]:l._events[N].push(C):(l._events[N]=C,l._eventsCount++),l}function o(l,y){--l._eventsCount===0?l._events=new r:delete l._events[y]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var y=[],x,E;if(this._eventsCount===0)return y;for(E in x=this._events)t.call(x,E)&&y.push(e?E.slice(1):E);return Object.getOwnPropertySymbols?y.concat(Object.getOwnPropertySymbols(x)):y},a.prototype.listeners=function(y){var x=e?e+y:y,E=this._events[x];if(!E)return[];if(E.fn)return[E.fn];for(var L=0,C=E.length,N=new Array(C);L<C;L++)N[L]=E[L].fn;return N},a.prototype.listenerCount=function(y){var x=e?e+y:y,E=this._events[x];return E?E.fn?1:E.length:0},a.prototype.emit=function(y,x,E,L,C,N){var M=e?e+y:y;if(!this._events[M])return!1;var O=this._events[M],K=arguments.length,Q,V;if(O.fn){switch(O.once&&this.removeListener(y,O.fn,void 0,!0),K){case 1:return O.fn.call(O.context),!0;case 2:return O.fn.call(O.context,x),!0;case 3:return O.fn.call(O.context,x,E),!0;case 4:return O.fn.call(O.context,x,E,L),!0;case 5:return O.fn.call(O.context,x,E,L,C),!0;case 6:return O.fn.call(O.context,x,E,L,C,N),!0}for(V=1,Q=new Array(K-1);V<K;V++)Q[V-1]=arguments[V];O.fn.apply(O.context,Q)}else{var st=O.length,J;for(V=0;V<st;V++)switch(O[V].once&&this.removeListener(y,O[V].fn,void 0,!0),K){case 1:O[V].fn.call(O[V].context);break;case 2:O[V].fn.call(O[V].context,x);break;case 3:O[V].fn.call(O[V].context,x,E);break;case 4:O[V].fn.call(O[V].context,x,E,L);break;default:if(!Q)for(J=1,Q=new Array(K-1);J<K;J++)Q[J-1]=arguments[J];O[V].fn.apply(O[V].context,Q)}}return!0},a.prototype.on=function(y,x,E){return i(this,y,x,E,!1)},a.prototype.once=function(y,x,E){return i(this,y,x,E,!0)},a.prototype.removeListener=function(y,x,E,L){var C=e?e+y:y;if(!this._events[C])return this;if(!x)return o(this,C),this;var N=this._events[C];if(N.fn)N.fn===x&&(!L||N.once)&&(!E||N.context===E)&&o(this,C);else{for(var M=0,O=[],K=N.length;M<K;M++)(N[M].fn!==x||L&&!N[M].once||E&&N[M].context!==E)&&O.push(N[M]);O.length?this._events[C]=O.length===1?O[0]:O:o(this,C)}return this},a.prototype.removeAllListeners=function(y){var x;return y?(x=e?e+y:y,this._events[x]&&o(this,x)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,n.exports=a})(Da);var bl=Da.exports;const $a=ni(bl);var xl=class extends $a{constructor(t,e,r){super();nr(this,"socket");this.socket=new window.WebSocket(t,r),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=s=>this.emit("message",s.data),this.socket.onerror=s=>this.emit("error",s),this.socket.onclose=s=>{this.emit("close",s.code,s.reason)}}send(t,e,r){const s=r||e;try{this.socket.send(t),s()}catch(i){s(i)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,r){this.socket.addEventListener(t,e,r)}};function vl(n,t){return new xl(n,t)}var kl=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},Sl=class extends $a{constructor(t,e="ws://localhost:8080",{autoconnect:r=!0,reconnect:s=!0,reconnect_interval:i=1e3,max_reconnects:o=5,...a}={},l,y){super();nr(this,"address");nr(this,"rpc_id");nr(this,"queue");nr(this,"options");nr(this,"autoconnect");nr(this,"ready");nr(this,"reconnect");nr(this,"reconnect_timer_id");nr(this,"reconnect_interval");nr(this,"max_reconnects");nr(this,"rest_options");nr(this,"current_reconnects");nr(this,"generate_request_id");nr(this,"socket");nr(this,"webSocketFactory");nr(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=r,this.ready=!1,this.reconnect=s,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=l||(()=>++this.rpc_id),y?this.dataPack=y:this.dataPack=new kl,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,r,s){return!s&&typeof r=="object"&&(s=r,r=null),new Promise((i,o)=>{if(!this.ready)return o(new Error("socket not ready"));const a=this.generate_request_id(t,e),l={jsonrpc:"2.0",method:t,params:e||void 0,id:a};this.socket.send(this.dataPack.encode(l),s,y=>{if(y)return o(y);this.queue[a]={promise:[i,o]},r&&(this.queue[a].timeout=setTimeout(()=>{delete this.queue[a],o(new Error("reply timeout"))},r))})})}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((r,s)=>{if(!this.ready)return s(new Error("socket not ready"));const i={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(i),o=>{if(o)return s(o);r()})})}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:r})=>{r instanceof ArrayBuffer&&(r=Ct.Buffer.from(r).toString());try{r=this.dataPack.decode(r)}catch{return}if(r.notification&&this.listeners(r.notification).length){if(!Object.keys(r.params).length)return this.emit(r.notification);const s=[r.notification];if(r.params.constructor===Object)s.push(r.params);else for(let i=0;i<r.params.length;i++)s.push(r.params[i]);return Promise.resolve().then(()=>{this.emit.apply(this,s)})}if(!this.queue[r.id])return r.method?Promise.resolve().then(()=>{this.emit(r.method,r==null?void 0:r.params)}):void 0;"error"in r=="result"in r&&this.queue[r.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[r.id].timeout&&clearTimeout(this.queue[r.id].timeout),r.error?this.queue[r.id].promise[1](r.error):this.queue[r.id].promise[0](r.result),delete this.queue[r.id]}),this.socket.addEventListener("error",r=>this.emit("error",r)),this.socket.addEventListener("close",({code:r,reason:s})=>{this.ready&&setTimeout(()=>this.emit("close",r,s),0),this.ready=!1,this.socket=void 0,r!==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 qa=[],Ha=[],Va=[],El=BigInt(0),hi=BigInt(1),_l=BigInt(2),Il=BigInt(7),Al=BigInt(256),Bl=BigInt(113);for(let n=0,t=hi,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],qa.push(2*(5*r+e)),Ha.push((n+1)*(n+2)/2%64);let s=El;for(let i=0;i<7;i++)t=(t<<hi^(t>>Il)*Bl)%Al,t&_l&&(s^=hi<<(hi<<BigInt(i))-hi);Va.push(s)}const[Rl,Tl]=No(Va,!0),ja=(n,t,e)=>e>32?Ko(n,t,e):Fo(n,t,e),Ga=(n,t,e)=>e>32?Wo(n,t,e):zo(n,t,e);function Ml(n,t=24){const e=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)e[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,y=e[l],x=e[l+1],E=ja(y,x,1)^e[a],L=Ga(y,x,1)^e[a+1];for(let C=0;C<50;C+=10)n[o+C]^=E,n[o+C+1]^=L}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=Ha[o],l=ja(s,i,a),y=Ga(s,i,a),x=qa[o];s=n[x],i=n[x+1],n[x]=l,n[x+1]=y}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)e[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~e[(a+2)%10]&e[(a+4)%10]}n[0]^=Rl[r],n[1]^=Tl[r]}e.fill(0)}class js extends ds{constructor(t,e,r,s=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ei(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=fu(this.state)}keccak(){Po||Co(this.state32),Ml(this.state32,this.rounds),Po||Co(this.state32),this.posOut=0,this.pos=0}update(t){Fn(this);const{blockLen:e,state:r}=this;t=_i(t);const s=t.length;for(let i=0;i<s;){const o=Math.min(e-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:s}=this;t[r]^=e,e&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Fn(this,!1),ii(t),this.finish();const e=this.state,{blockLen:r}=this;for(let s=0,i=t.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);t.set(e.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Ei(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Mo(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:r,outputLen:s,rounds:i,enableXOF:o}=this;return t||(t=new js(e,r,s,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=s,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Ya=((n,t,e)=>ps(()=>new js(t,n,e)))(1,136,256/8);class Za extends ds{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,uu(t);const r=_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 s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?t.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(t){return Fn(this),this.iHash.update(t),this}digestInto(t){Fn(this),ii(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:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return t=t,t.finished=s,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ja=(n,t,e)=>new Za(n,t).update(e).digest();Ja.create=(n,t)=>new Za(n,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Pl(n){const t=ks(n);Dn(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:r,a:s}=t;if(e){if(!r.eql(s,r.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:Cl,hexToBytes:Ll}=Ku,Bn={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(n){const{Err:t}=Bn;if(n.length<2||n[0]!==2)throw new t("Invalid signature integer tag");const e=n[1],r=n.subarray(2,e+2);if(!e||r.length!==e)throw new t("Invalid signature integer: wrong length");if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Cl(r),l:n.subarray(e+2)}},toSig(n){const{Err:t}=Bn,e=typeof n=="string"?Ll(n):n;si(e);let r=e.length;if(r<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:s,l:i}=Bn._parseInt(e.subarray(2)),{d:o,l:a}=Bn._parseInt(i);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const t=y=>Number.parseInt(y[0],16)&8?"00"+y:y,e=y=>{const x=y.toString(16);return x.length&1?`0${x}`:x},r=t(e(n.s)),s=t(e(n.r)),i=r.length/2,o=s.length/2,a=e(i),l=e(o);return`30${e(o+i+4)}02${l}${s}02${a}${r}`}},sn=BigInt(0),Ur=BigInt(1);BigInt(2);const Xa=BigInt(3);BigInt(4);function Ul(n){const t=Pl(n),{Fp:e}=t,r=t.toBytes||((N,M,O)=>{const K=M.toAffine();return kn(Uint8Array.from([4]),e.toBytes(K.x),e.toBytes(K.y))}),s=t.fromBytes||(N=>{const M=N.subarray(1),O=e.fromBytes(M.subarray(0,e.BYTES)),K=e.fromBytes(M.subarray(e.BYTES,2*e.BYTES));return{x:O,y:K}});function i(N){const{a:M,b:O}=t,K=e.sqr(N),Q=e.mul(K,N);return e.add(e.add(Q,e.mul(N,M)),O)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function o(N){return typeof N=="bigint"&&sn<N&&N<t.n}function a(N){if(!o(N))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(N){const{allowedPrivateKeyLengths:M,nByteLength:O,wrapPrivateKey:K,n:Q}=t;if(M&&typeof N!="bigint"){if(bn(N)&&(N=xn(N)),typeof N!="string"||!M.includes(N.length))throw new Error("Invalid key");N=N.padStart(O*2,"0")}let V;try{V=typeof N=="bigint"?N:vn(ir("private key",N,O))}catch{throw new Error(`private key must be ${O} bytes, hex or bigint, not ${typeof N}`)}return K&&(V=We(V,Q)),a(V),V}const y=new Map;function x(N){if(!(N instanceof E))throw new Error("ProjectivePoint expected")}class E{constructor(M,O,K){if(this.px=M,this.py=O,this.pz=K,M==null||!e.isValid(M))throw new Error("x required");if(O==null||!e.isValid(O))throw new Error("y required");if(K==null||!e.isValid(K))throw new Error("z required")}static fromAffine(M){const{x:O,y:K}=M||{};if(!M||!e.isValid(O)||!e.isValid(K))throw new Error("invalid affine point");if(M instanceof E)throw new Error("projective point not allowed");const Q=V=>e.eql(V,e.ZERO);return Q(O)&&Q(K)?E.ZERO:new E(O,K,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(M){const O=e.invertBatch(M.map(K=>K.pz));return M.map((K,Q)=>K.toAffine(O[Q])).map(E.fromAffine)}static fromHex(M){const O=E.fromAffine(s(ir("pointHex",M)));return O.assertValidity(),O}static fromPrivateKey(M){return E.BASE.multiply(l(M))}_setWindowSize(M){this._WINDOW_SIZE=M,y.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:M,y:O}=this.toAffine();if(!e.isValid(M)||!e.isValid(O))throw new Error("bad point: x or y not FE");const K=e.sqr(O),Q=i(M);if(!e.eql(K,Q))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:M}=this.toAffine();if(e.isOdd)return!e.isOdd(M);throw new Error("Field doesn't support isOdd")}equals(M){x(M);const{px:O,py:K,pz:Q}=this,{px:V,py:st,pz:J}=M,D=e.eql(e.mul(O,J),e.mul(V,Q)),tt=e.eql(e.mul(K,J),e.mul(st,Q));return D&&tt}negate(){return new E(this.px,e.neg(this.py),this.pz)}double(){const{a:M,b:O}=t,K=e.mul(O,Xa),{px:Q,py:V,pz:st}=this;let J=e.ZERO,D=e.ZERO,tt=e.ZERO,nt=e.mul(Q,Q),ue=e.mul(V,V),jt=e.mul(st,st),kt=e.mul(Q,V);return kt=e.add(kt,kt),tt=e.mul(Q,st),tt=e.add(tt,tt),J=e.mul(M,tt),D=e.mul(K,jt),D=e.add(J,D),J=e.sub(ue,D),D=e.add(ue,D),D=e.mul(J,D),J=e.mul(kt,J),tt=e.mul(K,tt),jt=e.mul(M,jt),kt=e.sub(nt,jt),kt=e.mul(M,kt),kt=e.add(kt,tt),tt=e.add(nt,nt),nt=e.add(tt,nt),nt=e.add(nt,jt),nt=e.mul(nt,kt),D=e.add(D,nt),jt=e.mul(V,st),jt=e.add(jt,jt),nt=e.mul(jt,kt),J=e.sub(J,nt),tt=e.mul(jt,ue),tt=e.add(tt,tt),tt=e.add(tt,tt),new E(J,D,tt)}add(M){x(M);const{px:O,py:K,pz:Q}=this,{px:V,py:st,pz:J}=M;let D=e.ZERO,tt=e.ZERO,nt=e.ZERO;const ue=t.a,jt=e.mul(t.b,Xa);let kt=e.mul(O,V),ce=e.mul(K,st),T=e.mul(Q,J),u=e.add(O,K),p=e.add(V,st);u=e.mul(u,p),p=e.add(kt,ce),u=e.sub(u,p),p=e.add(O,Q);let m=e.add(V,J);return p=e.mul(p,m),m=e.add(kt,T),p=e.sub(p,m),m=e.add(K,Q),D=e.add(st,J),m=e.mul(m,D),D=e.add(ce,T),m=e.sub(m,D),nt=e.mul(ue,p),D=e.mul(jt,T),nt=e.add(D,nt),D=e.sub(ce,nt),nt=e.add(ce,nt),tt=e.mul(D,nt),ce=e.add(kt,kt),ce=e.add(ce,kt),T=e.mul(ue,T),p=e.mul(jt,p),ce=e.add(ce,T),T=e.sub(kt,T),T=e.mul(ue,T),p=e.add(p,T),kt=e.mul(ce,p),tt=e.add(tt,kt),kt=e.mul(m,p),D=e.mul(u,D),D=e.sub(D,kt),kt=e.mul(u,ce),nt=e.mul(m,nt),nt=e.add(nt,kt),new E(D,tt,nt)}subtract(M){return this.add(M.negate())}is0(){return this.equals(E.ZERO)}wNAF(M){return C.wNAFCached(this,y,M,O=>{const K=e.invertBatch(O.map(Q=>Q.pz));return O.map((Q,V)=>Q.toAffine(K[V])).map(E.fromAffine)})}multiplyUnsafe(M){const O=E.ZERO;if(M===sn)return O;if(a(M),M===Ur)return this;const{endo:K}=t;if(!K)return C.unsafeLadder(this,M);let{k1neg:Q,k1:V,k2neg:st,k2:J}=K.splitScalar(M),D=O,tt=O,nt=this;for(;V>sn||J>sn;)V&Ur&&(D=D.add(nt)),J&Ur&&(tt=tt.add(nt)),nt=nt.double(),V>>=Ur,J>>=Ur;return Q&&(D=D.negate()),st&&(tt=tt.negate()),tt=new E(e.mul(tt.px,K.beta),tt.py,tt.pz),D.add(tt)}multiply(M){a(M);let O=M,K,Q;const{endo:V}=t;if(V){const{k1neg:st,k1:J,k2neg:D,k2:tt}=V.splitScalar(O);let{p:nt,f:ue}=this.wNAF(J),{p:jt,f:kt}=this.wNAF(tt);nt=C.constTimeNegate(st,nt),jt=C.constTimeNegate(D,jt),jt=new E(e.mul(jt.px,V.beta),jt.py,jt.pz),K=nt.add(jt),Q=ue.add(kt)}else{const{p:st,f:J}=this.wNAF(O);K=st,Q=J}return E.normalizeZ([K,Q])[0]}multiplyAndAddUnsafe(M,O,K){const Q=E.BASE,V=(J,D)=>D===sn||D===Ur||!J.equals(Q)?J.multiplyUnsafe(D):J.multiply(D),st=V(this,O).add(V(M,K));return st.is0()?void 0:st}toAffine(M){const{px:O,py:K,pz:Q}=this,V=this.is0();M==null&&(M=V?e.ONE:e.inv(Q));const st=e.mul(O,M),J=e.mul(K,M),D=e.mul(Q,M);if(V)return{x:e.ZERO,y:e.ZERO};if(!e.eql(D,e.ONE))throw new Error("invZ was invalid");return{x:st,y:J}}isTorsionFree(){const{h:M,isTorsionFree:O}=t;if(M===Ur)return!0;if(O)return O(E,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:M,clearCofactor:O}=t;return M===Ur?this:O?O(E,this):this.multiplyUnsafe(t.h)}toRawBytes(M=!0){return this.assertValidity(),r(E,this,M)}toHex(M=!0){return xn(this.toRawBytes(M))}}E.BASE=new E(t.Gx,t.Gy,e.ONE),E.ZERO=new E(e.ZERO,e.ONE,e.ZERO);const L=t.nBitLength,C=Qo(E,t.endo?Math.ceil(L/2):L);return{CURVE:t,ProjectivePoint:E,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:o}}function Ol(n){const t=ks(n);return Dn(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Nl(n){const t=Ol(n),{Fp:e,n:r}=t,s=e.BYTES+1,i=2*e.BYTES+1;function o(p){return sn<p&&p<e.ORDER}function a(p){return We(p,r)}function l(p){return xs(p,r)}const{ProjectivePoint:y,normPrivateKeyToScalar:x,weierstrassEquation:E,isWithinCurveOrder:L}=Ul({...t,toBytes(p,m,R){const _=m.toAffine(),I=e.toBytes(_.x),U=kn;return R?U(Uint8Array.from([m.hasEvenY()?2:3]),I):U(Uint8Array.from([4]),I,e.toBytes(_.y))},fromBytes(p){const m=p.length,R=p[0],_=p.subarray(1);if(m===s&&(R===2||R===3)){const I=vn(_);if(!o(I))throw new Error("Point is not on curve");const U=E(I);let k;try{k=e.sqrt(U)}catch(Z){const et=Z instanceof Error?": "+Z.message:"";throw new Error("Point is not on curve"+et)}const h=(k&Ur)===Ur;return(R&1)===1!==h&&(k=e.neg(k)),{x:I,y:k}}else if(m===i&&R===4){const I=e.fromBytes(_.subarray(0,e.BYTES)),U=e.fromBytes(_.subarray(e.BYTES,2*e.BYTES));return{x:I,y:U}}else throw new Error(`Point of length ${m} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),C=p=>xn(Wn(p,t.nByteLength));function N(p){const m=r>>Ur;return p>m}function M(p){return N(p)?a(-p):p}const O=(p,m,R)=>vn(p.slice(m,R));class K{constructor(m,R,_){this.r=m,this.s=R,this.recovery=_,this.assertValidity()}static fromCompact(m){const R=t.nByteLength;return m=ir("compactSignature",m,R*2),new K(O(m,0,R),O(m,R,2*R))}static fromDER(m){const{r:R,s:_}=Bn.toSig(ir("DER",m));return new K(R,_)}assertValidity(){if(!L(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!L(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(m){return new K(this.r,this.s,m)}recoverPublicKey(m){const{r:R,s:_,recovery:I}=this,U=tt(ir("msgHash",m));if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");const k=I===2||I===3?R+t.n:R;if(k>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=I&1?"03":"02",A=y.fromHex(h+C(k)),Z=l(k),et=a(-U*Z),ct=a(_*Z),Mt=y.BASE.multiplyAndAddUnsafe(A,et,ct);if(!Mt)throw new Error("point at infinify");return Mt.assertValidity(),Mt}hasHighS(){return N(this.s)}normalizeS(){return this.hasHighS()?new K(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return zn(this.toDERHex())}toDERHex(){return Bn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return zn(this.toCompactHex())}toCompactHex(){return C(this.r)+C(this.s)}}const Q={isValidPrivateKey(p){try{return x(p),!0}catch{return!1}},normPrivateKeyToScalar:x,randomPrivateKey:()=>{const p=Xo(t.n);return Zu(t.randomBytes(p),t.n)},precompute(p=8,m=y.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function V(p,m=!0){return y.fromPrivateKey(p).toRawBytes(m)}function st(p){const m=bn(p),R=typeof p=="string",_=(m||R)&&p.length;return m?_===s||_===i:R?_===2*s||_===2*i:p instanceof y}function J(p,m,R=!0){if(st(p))throw new Error("first arg must be private key");if(!st(m))throw new Error("second arg must be public key");return y.fromHex(m).multiply(x(p)).toRawBytes(R)}const D=t.bits2int||function(p){const m=vn(p),R=p.length*8-t.nBitLength;return R>0?m>>BigInt(R):m},tt=t.bits2int_modN||function(p){return a(D(p))},nt=ms(t.nBitLength);function ue(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(sn<=p&&p<nt))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Wn(p,t.nByteLength)}function jt(p,m,R=kt){if(["recovered","canonical"].some(Pt=>Pt in R))throw new Error("sign() legacy options not supported");const{hash:_,randomBytes:I}=t;let{lowS:U,prehash:k,extraEntropy:h}=R;U==null&&(U=!0),p=ir("msgHash",p),k&&(p=ir("prehashed msgHash",_(p)));const A=tt(p),Z=x(m),et=[ue(Z),ue(A)];if(h!=null&&h!==!1){const Pt=h===!0?I(e.BYTES):h;et.push(ir("extraEntropy",Pt))}const ct=kn(...et),Mt=A;function Tt(Pt){const Ce=D(Pt);if(!L(Ce))return;const Yt=l(Ce),Gt=y.BASE.multiply(Ce).toAffine(),le=a(Gt.x);if(le===sn)return;const re=a(Yt*a(Mt+le*Z));if(re===sn)return;let ve=(Gt.x===le?0:2)|Number(Gt.y&Ur),Or=re;return U&&N(re)&&(Or=M(re),ve^=1),new K(le,Or,ve)}return{seed:ct,k2sig:Tt}}const kt={lowS:t.lowS,prehash:!1},ce={lowS:t.lowS,prehash:!1};function T(p,m,R=kt){const{seed:_,k2sig:I}=jt(p,m,R),U=t;return Vo(U.hash.outputLen,U.nByteLength,U.hmac)(_,I)}y.BASE._setWindowSize(8);function u(p,m,R,_=ce){var Gt;const I=p;if(m=ir("msgHash",m),R=ir("publicKey",R),"strict"in _)throw new Error("options.strict was renamed to lowS");const{lowS:U,prehash:k}=_;let h,A;try{if(typeof I=="string"||bn(I))try{h=K.fromDER(I)}catch(le){if(!(le instanceof Bn.Err))throw le;h=K.fromCompact(I)}else if(typeof I=="object"&&typeof I.r=="bigint"&&typeof I.s=="bigint"){const{r:le,s:re}=I;h=new K(le,re)}else throw new Error("PARSE");A=y.fromHex(R)}catch(le){if(le.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(U&&h.hasHighS())return!1;k&&(m=t.hash(m));const{r:Z,s:et}=h,ct=tt(m),Mt=l(et),Tt=a(ct*Mt),Pt=a(Z*Mt),Ce=(Gt=y.BASE.multiplyAndAddUnsafe(A,Tt,Pt))==null?void 0:Gt.toAffine();return Ce?a(Ce.x)===Z:!1}return{CURVE:t,getPublicKey:V,getSharedSecret:J,sign:T,verify:u,ProjectivePoint:y,Signature:K,utils:Q}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Fl(n){return{hash:n,hmac:(t,...e)=>Ja(n,t,du(...e)),randomBytes:Lo}}function zl(n,t){const e=r=>Nl({...n,...Fl(r)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qa=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),tc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Kl=BigInt(1),Gs=BigInt(2),ec=(n,t)=>(n+t/Gs)/t;function Wl(n){const t=Qa,e=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),y=n*n*n%t,x=y*y*n%t,E=Ge(x,e,t)*x%t,L=Ge(E,e,t)*x%t,C=Ge(L,Gs,t)*y%t,N=Ge(C,s,t)*C%t,M=Ge(N,i,t)*N%t,O=Ge(M,a,t)*M%t,K=Ge(O,l,t)*O%t,Q=Ge(K,a,t)*M%t,V=Ge(Q,e,t)*x%t,st=Ge(V,o,t)*N%t,J=Ge(st,r,t)*y%t,D=Ge(J,Gs,t);if(!Ys.eql(Ys.sqr(D),n))throw new Error("Cannot find square root");return D}const Ys=Zo(Qa,void 0,void 0,{sqrt:Wl}),$i=zl({a:BigInt(0),b:BigInt(7),Fp:Ys,n:tc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=tc,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Kl*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,o=BigInt("0x100000000000000000000000000000000"),a=ec(i*n,t),l=ec(-r*n,t);let y=We(n-a*e-l*s,t),x=We(-a*r-l*i,t);const E=y>o,L=x>o;if(E&&(y=t-y),L&&(x=t-x),y>o||x>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:E,k1:y,k2neg:L,k2:x}}}},Is);BigInt(0),$i.ProjectivePoint;const Dl=$n.utils.randomPrivateKey,rc=()=>{const n=$n.utils.randomPrivateKey(),t=qi(n),e=new Uint8Array(64);return e.set(n),e.set(t,32),{publicKey:t,secretKey:e}},qi=$n.getPublicKey;function nc(n){try{return $n.ExtendedPoint.fromHex(n),!0}catch{return!1}}const Zs=(n,t)=>$n.sign(n,t.slice(0,32)),$l=$n.verify,te=n=>Ct.Buffer.isBuffer(n)?n:n instanceof Uint8Array?Ct.Buffer.from(n.buffer,n.byteOffset,n.byteLength):Ct.Buffer.from(n);class Js{constructor(t){Object.assign(this,t)}encode(){return Ct.Buffer.from(ha(di,this))}static decode(t){return da(di,this,t)}static decodeUnchecked(t){return aa(di,this,t)}}class ql extends Js{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 di=new Map;var ic;const sc=32,Zr=32;function Hl(n){return n._bn!==void 0}let oc=1;class gt extends Js{constructor(t){if(super({}),this._bn=void 0,Hl(t))this._bn=t._bn;else{if(typeof t=="string"){const e=ar.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 gt(oc);return oc+=1,new gt(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return ar.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(Ct.Buffer);if(t.length===Zr)return t;const e=Ct.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,r){const s=Ct.Buffer.concat([t.toBuffer(),Ct.Buffer.from(e),r.toBuffer()]),i=Is(s);return new gt(i)}static createProgramAddressSync(t,e){let r=Ct.Buffer.alloc(0);t.forEach(function(i){if(i.length>sc)throw new TypeError("Max seed length exceeded");r=Ct.Buffer.concat([r,te(i)])}),r=Ct.Buffer.concat([r,e.toBuffer(),Ct.Buffer.from("ProgramDerivedAddress")]);const s=Is(r);if(nc(s))throw new Error("Invalid seeds, address must fall off the curve");return new gt(s)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let r=255,s;for(;r!=0;){try{const i=t.concat(Ct.Buffer.from([r]));s=this.createProgramAddressSync(i,e)}catch(i){if(i instanceof TypeError)throw i;r--;continue}return[s,r]}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 gt(t);return nc(e.toBytes())}}ic=gt,gt.default=new ic("11111111111111111111111111111111"),di.set(gt,{kind:"struct",fields:[["_bn","u256"]]});class Vl{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=te(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=te(Dl()),this._publicKey=te(qi(this._secretKey))}get publicKey(){return new gt(this._publicKey)}get secretKey(){return Ct.Buffer.concat([this._secretKey,this._publicKey],64)}}const jl=new gt("BPFLoader1111111111111111111111111111111111"),yn=1232,Hi=127,pi=64;class Xs extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Xs.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Qs 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(Qs.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Yn extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Yn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class gi{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 r=new Map;this.keySegments().flat().forEach((i,o)=>{r.set(i.toBase58(),o)});const s=i=>{const o=r.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return t.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const oe=(n="publicKey")=>Ke(32,n),Gl=(n="signature")=>Ke(64,n),Rn=(n="string")=>{const t=At([It("length"),It("lengthPadding"),Ke(pn(It(),-8),"chars")],n),e=t.decode.bind(t),r=t.encode.bind(t),s=t;return s.decode=(i,o)=>e(i,o).chars.toString(),s.encode=(i,o,a)=>{const l={chars:Ct.Buffer.from(i,"utf8")};return r(l,o,a)},s.alloc=i=>It().span+It().span+Ct.Buffer.from(i,"utf8").length,s},Yl=(n="authorized")=>At([oe("staker"),oe("withdrawer")],n),Zl=(n="lockup")=>At([Tr("unixTimestamp"),Tr("epoch"),oe("custodian")],n),Jl=(n="voteInit")=>At([oe("nodePubkey"),oe("authorizedVoter"),oe("authorizedWithdrawer"),ge("commission")],n),Xl=(n="voteAuthorizeWithSeedArgs")=>At([It("voteAuthorizationType"),oe("currentAuthorityDerivedKeyOwnerPubkey"),Rn("currentAuthorityDerivedKeySeed"),oe("newAuthorized")],n);function ac(n,t){const e=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(t[s.property]);if("count"in s&&"elementLayout"in s){const i=t[s.property];if(Array.isArray(i))return i.length*e(s.elementLayout)}else if("fields"in s)return ac({layout:s},t[s.property]);return 0};let r=0;return n.layout.fields.forEach(s=>{r+=e(s)}),r}function _r(n){let t=0,e=0;for(;;){let r=n.shift();if(t|=(r&127)<<e*7,e+=1,!(r&128))break}return t}function Mr(n,t){let e=t;for(;;){let r=e&127;if(e>>=7,e==0){n.push(r);break}else r|=128,n.push(r)}}function xe(n,t){if(!n)throw new Error(t||"Assertion failed")}class Vi{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const r=new Map,s=o=>{const a=o.toBase58();let l=r.get(a);return l===void 0&&(l={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,l)),l},i=s(e);i.isSigner=!0,i.isWritable=!0;for(const o of t){s(o.programId).isInvoked=!0;for(const a of o.keys){const l=s(a.pubkey);l.isSigner||(l.isSigner=a.isSigner),l.isWritable||(l.isWritable=a.isWritable)}}return new Vi(e,r)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];xe(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,l])=>l.isSigner&&l.isWritable),r=t.filter(([,l])=>l.isSigner&&!l.isWritable),s=t.filter(([,l])=>!l.isSigner&&l.isWritable),i=t.filter(([,l])=>!l.isSigner&&!l.isWritable),o={numRequiredSignatures:e.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{xe(e.length>0,"Expected at least one writable signer key");const[l]=e[0];xe(l===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...e.map(([l])=>new gt(l)),...r.map(([l])=>new gt(l)),...s.map(([l])=>new gt(l)),...i.map(([l])=>new gt(l))];return[o,a]}extractTableLookup(t){const[e,r]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(e.length===0&&s.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:s},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(t,e){const r=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(e(o)){const a=new gt(i),l=t.findIndex(y=>y.equals(a));l>=0&&(xe(l<256,"Max lookup table index exceeded"),r.push(l),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const cc="Reached end of buffer unexpectedly";function Jr(n){if(n.length===0)throw new Error(cc);return n.shift()}function Ir(n,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>n.length:e>=n.length)throw new Error(cc);return n.splice(...t)}class Wr{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 gt(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:ar.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new gi(this.staticAccountKeys)}static compile(t){const e=Vi.compile(t.instructions,t.payerKey),[r,s]=e.getMessageComponents(),o=new gi(s).compileInstructions(t.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:ar.encode(a.data)}));return new Wr({header:r,accountKeys:s,recentBlockhash:t.recentBlockhash,instructions:o})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const r=t-e,i=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return r<i}else{const r=e-this.header.numReadonlySignedAccounts;return t<r}}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=[];Mr(e,t);const r=this.instructions.map(E=>{const{accounts:L,programIdIndex:C}=E,N=Array.from(ar.decode(E.data));let M=[];Mr(M,L.length);let O=[];return Mr(O,N.length),{programIdIndex:C,keyIndicesCount:Ct.Buffer.from(M),keyIndices:L,dataLength:Ct.Buffer.from(O),data:N}});let s=[];Mr(s,r.length);let i=Ct.Buffer.alloc(yn);Ct.Buffer.from(s).copy(i);let o=s.length;r.forEach(E=>{const C=At([ge("programIdIndex"),Ke(E.keyIndicesCount.length,"keyIndicesCount"),dr(ge("keyIndex"),E.keyIndices.length,"keyIndices"),Ke(E.dataLength.length,"dataLength"),dr(ge("userdatum"),E.data.length,"data")]).encode(E,i,o);o+=C}),i=i.slice(0,o);const a=At([Ke(1,"numRequiredSignatures"),Ke(1,"numReadonlySignedAccounts"),Ke(1,"numReadonlyUnsignedAccounts"),Ke(e.length,"keyCount"),dr(oe("key"),t,"keys"),oe("recentBlockhash")]),l={numRequiredSignatures:Ct.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Ct.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Ct.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Ct.Buffer.from(e),keys:this.accountKeys.map(E=>te(E.toBytes())),recentBlockhash:ar.decode(this.recentBlockhash)};let y=Ct.Buffer.alloc(2048);const x=a.encode(l,y);return i.copy(y,x),y.slice(0,x+i.length)}static from(t){let e=[...t];const r=Jr(e);if(r!==(r&Hi))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=Jr(e),i=Jr(e),o=_r(e);let a=[];for(let L=0;L<o;L++){const C=Ir(e,0,Zr);a.push(new gt(Ct.Buffer.from(C)))}const l=Ir(e,0,Zr),y=_r(e);let x=[];for(let L=0;L<y;L++){const C=Jr(e),N=_r(e),M=Ir(e,0,N),O=_r(e),K=Ir(e,0,O),Q=ar.encode(Ct.Buffer.from(K));x.push({programIdIndex:C,accounts:M,data:Q})}const E={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:ar.encode(Ct.Buffer.from(l)),accountKeys:a,instructions:x};return new Wr(E)}}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 gi(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(t>=r){const s=t-r,i=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return s<i}else if(t>=this.header.numRequiredSignatures){const s=t-e,o=r-e-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=e-this.header.numReadonlySignedAccounts;return t<s}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const r of this.addressTableLookups){const s=t.find(i=>i.key.equals(r.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const i of r.writableIndexes)if(i<s.state.addresses.length)e.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`);for(const i of r.readonlyIndexes)if(i<s.state.addresses.length)e.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`)}return e}static compile(t){const e=Vi.compile(t.instructions,t.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=t.addressLookupTableAccounts||[];for(const x of i){const E=e.extractTableLookup(x);if(E!==void 0){const[L,{writable:C,readonly:N}]=E;r.push(L),s.writable.push(...C),s.readonly.push(...N)}}const[o,a]=e.getMessageComponents(),y=new gi(a,s).compileInstructions(t.instructions);return new Tn({header:o,staticAccountKeys:a,recentBlockhash:t.recentBlockhash,compiledInstructions:y,addressTableLookups:r})}serialize(){const t=Array();Mr(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),r=Array();Mr(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Mr(i,this.addressTableLookups.length);const o=At([ge("prefix"),At([ge("numRequiredSignatures"),ge("numReadonlySignedAccounts"),ge("numReadonlyUnsignedAccounts")],"header"),Ke(t.length,"staticAccountKeysLength"),dr(oe(),this.staticAccountKeys.length,"staticAccountKeys"),oe("recentBlockhash"),Ke(r.length,"instructionsLength"),Ke(e.length,"serializedInstructions"),Ke(i.length,"addressTableLookupsLength"),Ke(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(yn),y=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(x=>x.toBytes()),recentBlockhash:ar.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},a);return a.slice(0,y)}serializeInstructions(){let t=0;const e=new Uint8Array(yn);for(const r of this.compiledInstructions){const s=Array();Mr(s,r.accountKeyIndexes.length);const i=Array();Mr(i,r.data.length);const o=At([ge("programIdIndex"),Ke(s.length,"encodedAccountKeyIndexesLength"),dr(ge(),r.accountKeyIndexes.length,"accountKeyIndexes"),Ke(i.length,"encodedDataLength"),Ke(r.data.length,"data")]);t+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(yn);for(const r of this.addressTableLookups){const s=Array();Mr(s,r.writableIndexes.length);const i=Array();Mr(i,r.readonlyIndexes.length);const o=At([oe("accountKey"),Ke(s.length,"encodedWritableIndexesLength"),dr(ge(),r.writableIndexes.length,"writableIndexes"),Ke(i.length,"encodedReadonlyIndexesLength"),dr(ge(),r.readonlyIndexes.length,"readonlyIndexes")]);t+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const r=Jr(e),s=r&Hi;xe(r!==s,"Expected versioned message but received legacy message");const i=s;xe(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:Jr(e),numReadonlySignedAccounts:Jr(e),numReadonlyUnsignedAccounts:Jr(e)},a=[],l=_r(e);for(let N=0;N<l;N++)a.push(new gt(Ir(e,0,Zr)));const y=ar.encode(Ir(e,0,Zr)),x=_r(e),E=[];for(let N=0;N<x;N++){const M=Jr(e),O=_r(e),K=Ir(e,0,O),Q=_r(e),V=new Uint8Array(Ir(e,0,Q));E.push({programIdIndex:M,accountKeyIndexes:K,data:V})}const L=_r(e),C=[];for(let N=0;N<L;N++){const M=new gt(Ir(e,0,Zr)),O=_r(e),K=Ir(e,0,O),Q=_r(e),V=Ir(e,0,Q);C.push({accountKey:M,writableIndexes:K,readonlyIndexes:V})}return new Tn({header:o,staticAccountKeys:a,recentBlockhash:y,compiledInstructions:E,addressTableLookups:C})}}const to={deserializeMessageVersion(n){const t=n[0],e=t&Hi;return e===t?"legacy":e},deserialize:n=>{const t=to.deserializeMessageVersion(n);if(t==="legacy")return Wr.from(n);if(t===0)return Tn.deserialize(n);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let on=function(n){return n[n.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",n[n.PROCESSED=1]="PROCESSED",n[n.TIMED_OUT=2]="TIMED_OUT",n[n.NONCE_INVALID=3]="NONCE_INVALID",n}({});const Ql=Ct.Buffer.alloc(pi).fill(0);class Ue{constructor(t){this.keys=void 0,this.programId=void 0,this.data=Ct.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:r})=>({pubkey:t.toJSON(),isSigner:e,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class ye{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:r}=t;this.minNonceContextSlot=e,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:r}=t;this.recentBlockhash=e,this.lastValidBlockHeight=r}else{const{recentBlockhash:e,nonceInfo:r}=t;r&&(this.nonceInfo=r),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 Ue(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 r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let M=0;M<e.length;M++)if(e[M].programId===void 0)throw new Error(`Transaction instruction index ${M} has undefined program id`);const s=[],i=[];e.forEach(M=>{M.keys.forEach(K=>{i.push({...K})});const O=M.programId.toString();s.includes(O)||s.push(O)}),s.forEach(M=>{i.push({pubkey:new gt(M),isSigner:!1,isWritable:!1})});const o=[];i.forEach(M=>{const O=M.pubkey.toString(),K=o.findIndex(Q=>Q.pubkey.toString()===O);K>-1?(o[K].isWritable=o[K].isWritable||M.isWritable,o[K].isSigner=o[K].isSigner||M.isSigner):o.push(M)}),o.sort(function(M,O){if(M.isSigner!==O.isSigner)return M.isSigner?-1:1;if(M.isWritable!==O.isWritable)return M.isWritable?-1:1;const K={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return M.pubkey.toBase58().localeCompare(O.pubkey.toBase58(),"en",K)});const a=o.findIndex(M=>M.pubkey.equals(r));if(a>-1){const[M]=o.splice(a,1);M.isSigner=!0,M.isWritable=!0,o.unshift(M)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const M of this.signatures){const O=o.findIndex(K=>K.pubkey.equals(M.publicKey));if(O>-1)o[O].isSigner||(o[O].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: ${M.publicKey.toString()}`)}let l=0,y=0,x=0;const E=[],L=[];o.forEach(({pubkey:M,isSigner:O,isWritable:K})=>{O?(E.push(M.toString()),l+=1,K||(y+=1)):(L.push(M.toString()),K||(x+=1))});const C=E.concat(L),N=e.map(M=>{const{data:O,programId:K}=M;return{programIdIndex:C.indexOf(K.toString()),accounts:M.keys.map(Q=>C.indexOf(Q.pubkey.toString())),data:ar.encode(O)}});return N.forEach(M=>{xe(M.programIdIndex>=0),M.accounts.forEach(O=>xe(O>=0))}),new Wr({header:{numRequiredSignatures:l,numReadonlySignedAccounts:y,numReadonlyUnsignedAccounts:x},accountKeys:C,recentBlockhash:t,instructions:N})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((s,i)=>e[i].equals(s.publicKey))||(this.signatures=e.map(r=>({signature:null,publicKey:r}))),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(r=>{const s=r.toString();return e.has(s)?!1:(e.add(s),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const i of t){const o=i.publicKey.toString();e.has(o)||(e.add(o),r.push(i))}this.signatures=r.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...r)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const i of t){const o=i.publicKey.toString();e.has(o)||(e.add(o),r.push(i))}const s=this._compile();this._partialSign(s,...r)}_partialSign(t,...e){const r=t.serialize();e.forEach(s=>{const i=Zs(r,s.secretKey);this._addSignature(s.publicKey,te(i))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){xe(e.length===64);const r=this.signatures.findIndex(s=>t.equals(s.publicKey));if(r<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[r].signature=Ct.Buffer.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const r={};for(const{signature:s,publicKey:i}of this.signatures)s===null?e&&(r.missing||(r.missing=[])).push(i):$l(s,t,i.toBytes())||(r.invalid||(r.invalid=[])).push(i);return r.invalid||r.missing?r:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),s=this.serializeMessage();if(r){const i=this._getMessageSignednessErrors(s,e);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
7
7
  Invalid signature for public key${i.invalid.length===1?"":"(s)"} [\`${i.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),i.missing&&(o+=`
8
- Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(t){const{signatures:e}=this,r=[];Mr(r,e.length);const s=r.length+e.length*64+t.length,i=Ct.Buffer.alloc(s);return xe(e.length<256),Ct.Buffer.from(r).copy(i,0),e.forEach(({signature:o},a)=>{o!==null&&(xe(o.length===64,"signature has invalid length"),Ct.Buffer.from(o).copy(i,r.length+a*64))}),t.copy(i,r.length+e.length*64),xe(i.length<=yn,`Transaction too large: ${i.length} > ${yn}`),i}get keys(){return xe(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return xe(this.instructions.length===1),this.instructions[0].programId}get data(){return xe(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const r=_r(e);let s=[];for(let i=0;i<r;i++){const o=Ir(e,0,pi);s.push(ar.encode(Ct.Buffer.from(o)))}return ye.populate(Wr.from(e),s)}static populate(t,e=[]){const r=new ye;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),e.forEach((s,i)=>{const o={signature:s==ar.encode(Xl)?null:ar.decode(s),publicKey:t.accountKeys[i]};r.signatures.push(o)}),t.instructions.forEach(s=>{const i=s.accounts.map(o=>{const a=t.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(l=>l.publicKey.toString()===a.toString())||t.isAccountSigner(o),isWritable:t.isAccountWritable(o)}});r.instructions.push(new Ue({keys:i,programId:t.accountKeys[s.programIdIndex],data:ar.decode(s.data)}))}),r._message=t,r._json=r.toJSON(),r}}class ro{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:r,compiledInstructions:s,recentBlockhash:i}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:l}=r,y=o-a;xe(y>0,"Message header is invalid");const x=t.staticAccountKeys.length-o-l;xe(x>=0,"Message header is invalid");const _=t.getAccountKeys(e),L=_.get(0);if(L===void 0)throw new Error("Failed to decompile message because no account keys were found");const C=[];for(const N of s){const M=[];for(const K of N.accountKeyIndexes){const X=_.get(K);if(X===void 0)throw new Error(`Failed to find key for account key index ${K}`);const V=K<o;let it;V?it=K<y:K<_.staticAccountKeys.length?it=K-o<x:it=K-_.staticAccountKeys.length<_.accountKeysFromLookups.writable.length,M.push({pubkey:X,isSigner:K<r.numRequiredSignatures,isWritable:it})}const O=_.get(N.programIdIndex);if(O===void 0)throw new Error(`Failed to find program id for program id index ${N.programIdIndex}`);C.push(new Ue({programId:O,data:te(N.data),keys:M}))}return new ro({payerKey:L,instructions:C,recentBlockhash:i})}compileToLegacyMessage(){return Wr.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 no{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,e!==void 0)xe(e.length===t.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=e;else{const r=[];for(let s=0;s<t.header.numRequiredSignatures;s++)r.push(new Uint8Array(pi));this.signatures=r}this.message=t}serialize(){const t=this.message.serialize(),e=Array();Mr(e,this.signatures.length);const r=At([Ke(e.length,"encodedSignaturesLength"),dr(jl(),this.signatures.length,"signatures"),Ke(t.length,"serializedMessage")]),s=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},s);return s.slice(0,i)}static deserialize(t){let e=[...t];const r=[],s=_r(e);for(let o=0;o<s;o++)r.push(new Uint8Array(Ir(e,0,pi)));const i=eo.deserialize(new Uint8Array(e));return new no(i,r)}sign(t){const e=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of t){const i=r.findIndex(o=>o.equals(s.publicKey));xe(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=Js(e,s.secretKey)}}addSignature(t,e){xe(e.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(t));xe(s>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=e}}const uc=1e3/(160/64),Xr=new gt("SysvarC1ock11111111111111111111111111111111"),Ql=new gt("SysvarEpochSchedu1e111111111111111111111111"),th=new gt("Sysvar1nstructions1111111111111111111111111"),Gi=new gt("SysvarRecentB1ockHashes11111111111111111111"),Zn=new gt("SysvarRent111111111111111111111111111111111"),eh=new gt("SysvarRewards111111111111111111111111111111"),rh=new gt("SysvarS1otHashes111111111111111111111111111"),nh=new gt("SysvarS1otHistory11111111111111111111111111"),Yi=new gt("SysvarStakeHistory1111111111111111111111111");class yi extends Error{constructor({action:t,signature:e,transactionMessage:r,logs:s}){const i=s?`Logs:
8
+ Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(t){const{signatures:e}=this,r=[];Mr(r,e.length);const s=r.length+e.length*64+t.length,i=Ct.Buffer.alloc(s);return xe(e.length<256),Ct.Buffer.from(r).copy(i,0),e.forEach(({signature:o},a)=>{o!==null&&(xe(o.length===64,"signature has invalid length"),Ct.Buffer.from(o).copy(i,r.length+a*64))}),t.copy(i,r.length+e.length*64),xe(i.length<=yn,`Transaction too large: ${i.length} > ${yn}`),i}get keys(){return xe(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return xe(this.instructions.length===1),this.instructions[0].programId}get data(){return xe(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const r=_r(e);let s=[];for(let i=0;i<r;i++){const o=Ir(e,0,pi);s.push(ar.encode(Ct.Buffer.from(o)))}return ye.populate(Wr.from(e),s)}static populate(t,e=[]){const r=new ye;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),e.forEach((s,i)=>{const o={signature:s==ar.encode(Ql)?null:ar.decode(s),publicKey:t.accountKeys[i]};r.signatures.push(o)}),t.instructions.forEach(s=>{const i=s.accounts.map(o=>{const a=t.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(l=>l.publicKey.toString()===a.toString())||t.isAccountSigner(o),isWritable:t.isAccountWritable(o)}});r.instructions.push(new Ue({keys:i,programId:t.accountKeys[s.programIdIndex],data:ar.decode(s.data)}))}),r._message=t,r._json=r.toJSON(),r}}class eo{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:r,compiledInstructions:s,recentBlockhash:i}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:l}=r,y=o-a;xe(y>0,"Message header is invalid");const x=t.staticAccountKeys.length-o-l;xe(x>=0,"Message header is invalid");const E=t.getAccountKeys(e),L=E.get(0);if(L===void 0)throw new Error("Failed to decompile message because no account keys were found");const C=[];for(const N of s){const M=[];for(const K of N.accountKeyIndexes){const Q=E.get(K);if(Q===void 0)throw new Error(`Failed to find key for account key index ${K}`);const V=K<o;let st;V?st=K<y:K<E.staticAccountKeys.length?st=K-o<x:st=K-E.staticAccountKeys.length<E.accountKeysFromLookups.writable.length,M.push({pubkey:Q,isSigner:K<r.numRequiredSignatures,isWritable:st})}const O=E.get(N.programIdIndex);if(O===void 0)throw new Error(`Failed to find program id for program id index ${N.programIdIndex}`);C.push(new Ue({programId:O,data:te(N.data),keys:M}))}return new eo({payerKey:L,instructions:C,recentBlockhash:i})}compileToLegacyMessage(){return Wr.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 ro{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,e!==void 0)xe(e.length===t.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=e;else{const r=[];for(let s=0;s<t.header.numRequiredSignatures;s++)r.push(new Uint8Array(pi));this.signatures=r}this.message=t}serialize(){const t=this.message.serialize(),e=Array();Mr(e,this.signatures.length);const r=At([Ke(e.length,"encodedSignaturesLength"),dr(Gl(),this.signatures.length,"signatures"),Ke(t.length,"serializedMessage")]),s=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},s);return s.slice(0,i)}static deserialize(t){let e=[...t];const r=[],s=_r(e);for(let o=0;o<s;o++)r.push(new Uint8Array(Ir(e,0,pi)));const i=to.deserialize(new Uint8Array(e));return new ro(i,r)}sign(t){const e=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of t){const i=r.findIndex(o=>o.equals(s.publicKey));xe(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=Zs(e,s.secretKey)}}addSignature(t,e){xe(e.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(t));xe(s>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=e}}const uc=1e3/(160/64),Xr=new gt("SysvarC1ock11111111111111111111111111111111"),th=new gt("SysvarEpochSchedu1e111111111111111111111111"),eh=new gt("Sysvar1nstructions1111111111111111111111111"),ji=new gt("SysvarRecentB1ockHashes11111111111111111111"),Zn=new gt("SysvarRent111111111111111111111111111111111"),rh=new gt("SysvarRewards111111111111111111111111111111"),nh=new gt("SysvarS1otHashes111111111111111111111111111"),ih=new gt("SysvarS1otHistory11111111111111111111111111"),Gi=new gt("SysvarStakeHistory1111111111111111111111111");class yi extends Error{constructor({action:t,signature:e,transactionMessage:r,logs:s}){const i=s?`Logs:
9
9
  ${JSON.stringify(s.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let a;switch(t){case"send":a=`Transaction ${e} resulted in an error.
10
10
  ${r}. `+i+o;break;case"simulate":a=`Simulation failed.
11
11
  Message: ${r}.
12
- `+i+o;break;default:a=`Unknown action '${(l=>l)(t)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=r,this.transactionLogs=s||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,r)=>{t.getTransaction(this.signature).then(s=>{if(s&&s.meta&&s.meta.logMessages){const i=s.meta.logMessages;this.transactionLogs=i,e(i)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}const ih={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 Rt extends Error{constructor({code:t,message:e,data:r},s){super(s!=null?`${s}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=r,this.name="SolanaJSONRPCError"}}async function io(n,t,e,r){const s=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},i=await n.sendTransaction(t,e,s);let o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,signature:i,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){const{nonceInstruction:a}=t.nonceInfo,l=a.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:l,nonceValue:t.nonceInfo.nonce,signature:i},r&&r.commitment)).value}else(r==null?void 0:r.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."),o=(await n.confirmTransaction(i,r&&r.commitment)).value;if(o.err)throw i!=null?new yi({action:"send",signature:i,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${i} failed (${JSON.stringify(o)})`);return i}function Mn(n){return new Promise(t=>setTimeout(t,n))}function fe(n,t){const e=n.layout.span>=0?n.layout.span:ac(n,t),r=Ct.Buffer.alloc(e),s=Object.assign({instruction:n.index},t);return n.layout.encode(s,r),r}function Ee(n,t){let e;try{e=n.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(e.instruction!==n.index)throw new Error(`invalid instruction; instruction index mismatch ${e.instruction} != ${n.index}`);return e}const fc=hr("lamportsPerSignature"),lc=At([It("version"),It("state"),oe("authorizedPubkey"),oe("nonce"),At([fc],"feeCalculator")]),so=lc.span;class Zi{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=lc.decode(te(t),0);return new Zi({authorizedPubkey:new gt(e.authorizedPubkey),nonce:new gt(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const sh=n=>{const t=n.decode.bind(n),e=n.encode.bind(n);return{decode:t,encode:e}},Jn=(n=>t=>{const e=Ke(n,t),{encode:r,decode:s}=sh(e),i=e;return i.decode=(o,a)=>{const l=s(o,a);return Uf(Ct.Buffer.from(l))},i.encode=(o,a,l)=>{const y=Ma(o,n);return r(y,a,l)},i})(8);class oh{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=It("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(Ne))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a SystemInstruction");return s}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:r,programId:s}=Ee(Ne.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:r,programId:new gt(s)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=Ee(Ne.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:r,programId:s}=Ee(Ne.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:r,programId:new gt(s)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=Ee(Ne.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:r,space:s,programId:i}=Ee(Ne.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new gt(e),seed:r,space:s,programId:new gt(i)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=Ee(Ne.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new gt(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,programId:s}=Ee(Ne.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new gt(e),seed:r,programId:new gt(s)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:r,lamports:s,space:i,programId:o}=Ee(Ne.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new gt(e),seed:r,lamports:s,space:i,programId:new gt(o)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=Ee(Ne.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new gt(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ee(Ne.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}=Ee(Ne.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}=Ee(Ne.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new gt(e)}}static checkProgramId(t){if(!t.equals(cr.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 Ne=Object.freeze({Create:{index:0,layout:At([It("instruction"),Tr("lamports"),Tr("space"),oe("programId")])},Assign:{index:1,layout:At([It("instruction"),oe("programId")])},Transfer:{index:2,layout:At([It("instruction"),Jn("lamports")])},CreateWithSeed:{index:3,layout:At([It("instruction"),oe("base"),Rn("seed"),Tr("lamports"),Tr("space"),oe("programId")])},AdvanceNonceAccount:{index:4,layout:At([It("instruction")])},WithdrawNonceAccount:{index:5,layout:At([It("instruction"),Tr("lamports")])},InitializeNonceAccount:{index:6,layout:At([It("instruction"),oe("authorized")])},AuthorizeNonceAccount:{index:7,layout:At([It("instruction"),oe("authorized")])},Allocate:{index:8,layout:At([It("instruction"),Tr("space")])},AllocateWithSeed:{index:9,layout:At([It("instruction"),oe("base"),Rn("seed"),Tr("space"),oe("programId")])},AssignWithSeed:{index:10,layout:At([It("instruction"),oe("base"),Rn("seed"),oe("programId")])},TransferWithSeed:{index:11,layout:At([It("instruction"),Jn("lamports"),Rn("seed"),oe("programId")])},UpgradeNonceAccount:{index:12,layout:At([It("instruction")])}});class cr{constructor(){}static createAccount(t){const e=Ne.Create,r=fe(e,{lamports:t.lamports,space:t.space,programId:te(t.programId.toBuffer())});return new Ue({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(t){let e,r;if("basePubkey"in t){const s=Ne.TransferWithSeed;e=fe(s,{lamports:BigInt(t.lamports),seed:t.seed,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{const s=Ne.Transfer;e=fe(s,{lamports:BigInt(t.lamports)}),r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Ue({keys:r,programId:this.programId,data:e})}static assign(t){let e,r;if("basePubkey"in t){const s=Ne.AssignWithSeed;e=fe(s,{base:te(t.basePubkey.toBuffer()),seed:t.seed,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Ne.Assign;e=fe(s,{programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ue({keys:r,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=Ne.CreateWithSeed,r=fe(e,{base:te(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:te(t.programId.toBuffer())});let s=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey.equals(t.fromPubkey)||s.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Ue({keys:s,programId:this.programId,data:r})}static createNonceAccount(t){const e=new ye;"basePubkey"in t&&"seed"in t?e.add(cr.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:so,programId:this.programId})):e.add(cr.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:so,programId:this.programId}));const r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(r)),e}static nonceInitialize(t){const e=Ne.InitializeNonceAccount,r=fe(e,{authorized:te(t.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Gi,isSigner:!1,isWritable:!1},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new Ue(s)}static nonceAdvance(t){const e=Ne.AdvanceNonceAccount,r=fe(e),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Gi,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new Ue(s)}static nonceWithdraw(t){const e=Ne.WithdrawNonceAccount,r=fe(e,{lamports:t.lamports});return new Ue({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Gi,isSigner:!1,isWritable:!1},{pubkey:Zn,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(t){const e=Ne.AuthorizeNonceAccount,r=fe(e,{authorized:te(t.newAuthorizedPubkey.toBuffer())});return new Ue({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(t){let e,r;if("basePubkey"in t){const s=Ne.AllocateWithSeed;e=fe(s,{base:te(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Ne.Allocate;e=fe(s,{space:t.space}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ue({keys:r,programId:this.programId,data:e})}}cr.programId=new gt("11111111111111111111111111111111");const ah=yn-300;class Pn{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/Pn.chunkSize)+1+1)}static async load(t,e,r,s,i){{const _=await t.getMinimumBalanceForRentExemption(i.length),L=await t.getAccountInfo(r.publicKey,"confirmed");let C=null;if(L!==null){if(L.executable)return console.error("Program load failed, account is already executable"),!1;L.data.length!==i.length&&(C=C||new ye,C.add(cr.allocate({accountPubkey:r.publicKey,space:i.length}))),L.owner.equals(s)||(C=C||new ye,C.add(cr.assign({accountPubkey:r.publicKey,programId:s}))),L.lamports<_&&(C=C||new ye,C.add(cr.transfer({fromPubkey:e.publicKey,toPubkey:r.publicKey,lamports:_-L.lamports})))}else C=new ye().add(cr.createAccount({fromPubkey:e.publicKey,newAccountPubkey:r.publicKey,lamports:_>0?_:1,space:i.length,programId:s}));C!==null&&await io(t,C,[e,r],{commitment:"confirmed"})}const o=At([It("instruction"),It("offset"),It("bytesLength"),It("bytesLengthPadding"),dr(ge("byte"),pn(It(),-8),"bytes")]),a=Pn.chunkSize;let l=0,y=i,x=[];for(;y.length>0;){const _=y.slice(0,a),L=Ct.Buffer.alloc(a+16);o.encode({instruction:0,offset:l,bytes:_,bytesLength:0,bytesLengthPadding:0},L);const C=new ye().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:L});x.push(io(t,C,[e,r],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await Mn(1e3/4),l+=a,y=y.slice(a)}await Promise.all(x);{const _=At([It("instruction")]),L=Ct.Buffer.alloc(_.span);_.encode({instruction:1},L);const C=new ye().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:s,data:L}),N="processed",M=await t.sendTransaction(C,[e,r],{preflightCommitment:N}),{context:O,value:K}=await t.confirmTransaction({signature:M,lastValidBlockHeight:C.lastValidBlockHeight,blockhash:C.recentBlockhash},N);if(K.err)throw new Error(`Transaction ${M} failed (${JSON.stringify(K)})`);for(;;){try{if(await t.getSlot({commitment:N})>O.slot)break}catch{}await new Promise(X=>setTimeout(X,Math.round(uc/2)))}}return!0}}Pn.chunkSize=ah;const ch=new gt("BPFLoader2111111111111111111111111111111111");class uh{static getMinNumSignatures(t){return Pn.getMinNumSignatures(t)}static load(t,e,r,s,i){return Pn.load(t,e,r,i,s)}}function fh(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var lh=Object.prototype.toString,hh=Object.keys||function(n){var t=[];for(var e in n)t.push(e);return t};function mi(n,t){var e,r,s,i,o,a,l;if(n===!0)return"true";if(n===!1)return"false";switch(typeof n){case"object":if(n===null)return null;if(n.toJSON&&typeof n.toJSON=="function")return mi(n.toJSON(),t);if(l=lh.call(n),l==="[object Array]"){for(s="[",r=n.length-1,e=0;e<r;e++)s+=mi(n[e],!0)+",";return r>-1&&(s+=mi(n[e],!0)),s+"]"}else if(l==="[object Object]"){for(i=hh(n).sort(),r=i.length,s="",e=0;e<r;)o=i[e],a=mi(n[o],!1),a!==void 0&&(s&&(s+=","),s+=JSON.stringify(o)+":"+a),e++;return"{"+s+"}"}else return JSON.stringify(n);case"function":case"undefined":return t?null:void 0;case"string":return JSON.stringify(n);default:return isFinite(n)?n:null}}var dh=function(n){var t=mi(n,!1);if(t!==void 0)return""+t},hc=fh(dh);const wi=32;function oo(n){let t=0;for(;n>1;)n/=2,t++;return t}function ph(n){return n===0?1:(n--,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,n|=n>>32,n+1)}class dc{constructor(t,e,r,s,i){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=r,this.firstNormalEpoch=s,this.firstNormalSlot=i}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=oo(ph(t+wi+1))-oo(wi)-1,r=this.getSlotsInEpoch(e),s=t-(r-wi);return[e,s]}else{const e=t-this.firstNormalSlot,r=Math.floor(e/this.slotsPerEpoch),s=this.firstNormalEpoch+r,i=e%this.slotsPerEpoch;return[s,i]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*wi:(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+oo(wi)):this.slotsPerEpoch}}var gh=globalThis.fetch;class yh extends kl{constructor(t,e,r){const s=i=>{const o=xl(i,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(s,t,e,r),this.underlyingSocket=void 0}call(...t){var r;const e=(r=this.underlyingSocket)==null?void 0:r.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 r;const e=(r=this.underlyingSocket)==null?void 0:r.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 mh(n,t){let e;try{e=n.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(e.typeIndex!==n.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${n.index}`);return e}const pc=56;class ao{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=mh(wh,t),r=t.length-pc;xe(r>=0,"lookup table is invalid"),xe(r%32===0,"lookup table is invalid");const s=r/32,{addresses:i}=At([dr(oe(),s,"addresses")]).decode(t.slice(pc));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new gt(e.authority[0]):void 0,addresses:i.map(o=>new gt(o))}}}const wh={index:1,layout:At([It("typeIndex"),Jn("deactivationSlot"),hr("lastExtendedSlot"),ge("lastExtendedStartIndex"),ge(),dr(oe(),pn(ge(),-1),"authority")])},bh=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function xh(n){const t=n.match(bh);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[e,r,s,i]=t,o=n.startsWith("https:")?"wss:":"ws:",a=s==null?null:parseInt(s.slice(1),10),l=a==null?"":`:${a+1}`;return`${o}//${r}${l}${i}`}const Ve=fi(Ws(gt),dt(),n=>new gt(n)),gc=Ds([dt(),He("base64")]),co=fi(Ws(Ct.Buffer),gc,n=>Ct.Buffer.from(n[0],"base64")),yc=30*1e3;function vh(n){if(/^https?:/.test(n)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return n}function Fe(n){let t,e;if(typeof n=="string")t=n;else if(n){const{commitment:r,...s}=n;t=r,e=s}return{commitment:t,config:e}}function mc(n){return n.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function wc(n){return Sr([ot({jsonrpc:He("2.0"),id:dt(),result:n}),ot({jsonrpc:He("2.0"),id:dt(),error:ot({code:Gn(),message:dt(),data:Ot(qf())})})])}const kh=wc(Gn());function ee(n){return fi(wc(n),kh,t=>"error"in t?t:{...t,result:yt(t.result,n)})}function Ye(n){return ee(ot({context:ot({slot:q()}),value:n}))}function Ji(n){return ot({context:ot({slot:q()}),value:n})}function uo(n,t){return n===0?new Tn({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new gt(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:ar.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Wr(t)}const Sh=ot({foundation:q(),foundationTerm:q(),initial:q(),taper:q(),terminal:q()}),Eh=ee(wt(bt(ot({epoch:q(),effectiveSlot:q(),amount:q(),postBalance:q(),commission:Ot(bt(q()))})))),_h=wt(ot({slot:q(),prioritizationFee:q()})),Ih=ot({total:q(),validator:q(),foundation:q(),epoch:q()}),Ah=ot({epoch:q(),slotIndex:q(),slotsInEpoch:q(),absoluteSlot:q(),blockHeight:Ot(q()),transactionCount:Ot(q())}),Bh=ot({slotsPerEpoch:q(),leaderScheduleSlotOffset:q(),warmup:Yr(),firstNormalEpoch:q(),firstNormalSlot:q()}),Rh=Ua(dt(),wt(q())),Cn=bt(Sr([ot({}),dt()])),Th=ot({err:Cn}),Mh=He("receivedSignature"),Ph=ot({"solana-core":dt(),"feature-set":Ot(q())}),Ch=ot({program:dt(),programId:Ve,parsed:Gn()}),Lh=ot({programId:Ve,accounts:wt(Ve),data:dt()}),bc=Ye(ot({err:bt(Sr([ot({}),dt()])),logs:bt(wt(dt())),accounts:Ot(bt(wt(bt(ot({executable:Yr(),owner:dt(),lamports:q(),data:wt(dt()),rentEpoch:Ot(q())}))))),unitsConsumed:Ot(q()),returnData:Ot(bt(ot({programId:dt(),data:Ds([dt(),He("base64")])}))),innerInstructions:Ot(bt(wt(ot({index:q(),instructions:wt(Sr([Ch,Lh]))}))))})),Uh=Ye(ot({byIdentity:Ua(dt(),wt(q())),range:ot({firstSlot:q(),lastSlot:q()})}));function Oh(n,t,e,r,s,i){const o=e||gh;let a;i!=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 l;return r&&(l=async(x,_)=>{const L=await new Promise((C,N)=>{try{r(x,_,(M,O)=>C([M,O]))}catch(M){N(M)}});return await o(...L)}),new ml(async(x,_)=>{const L={method:"POST",body:x,agent:a,headers:Object.assign({"Content-Type":"application/json"},t||{},N0)};try{let C=5,N,M=500;for(;l?N=await l(n,L):N=await o(n,L),!(N.status!==429||s===!0||(C-=1,C===0));)console.error(`Server responded with ${N.status} ${N.statusText}. Retrying after ${M}ms delay...`),await Mn(M),M*=2;const O=await N.text();N.ok?_(null,O):_(new Error(`${N.status} ${N.statusText}: ${O}`))}catch(C){C instanceof Error&&_(C)}},{})}function Nh(n){return(t,e)=>new Promise((r,s)=>{n.request(t,e,(i,o)=>{if(i){s(i);return}r(o)})})}function Fh(n){return t=>new Promise((e,r)=>{t.length===0&&e([]);const s=t.map(i=>n.request(i.methodName,i.args));n.request(s,(i,o)=>{if(i){r(i);return}e(o)})})}const zh=ee(Sh),Kh=ee(Ih),Wh=ee(_h),Dh=ee(Ah),$h=ee(Bh),qh=ee(Rh),Hh=ee(q()),Vh=Ye(ot({total:q(),circulating:q(),nonCirculating:q(),nonCirculatingAccounts:wt(Ve)})),fo=ot({amount:dt(),uiAmount:bt(q()),decimals:q(),uiAmountString:Ot(dt())}),jh=Ye(wt(ot({address:Ve,amount:dt(),uiAmount:bt(q()),decimals:q(),uiAmountString:Ot(dt())}))),Gh=Ye(wt(ot({pubkey:Ve,account:ot({executable:Yr(),owner:Ve,lamports:q(),data:co,rentEpoch:q()})}))),lo=ot({program:dt(),parsed:Gn(),space:q()}),Yh=Ye(wt(ot({pubkey:Ve,account:ot({executable:Yr(),owner:Ve,lamports:q(),data:lo,rentEpoch:q()})}))),Zh=Ye(wt(ot({lamports:q(),address:Ve}))),bi=ot({executable:Yr(),owner:Ve,lamports:q(),data:co,rentEpoch:q()}),Jh=ot({pubkey:Ve,account:bi}),Xh=fi(Sr([Ws(Ct.Buffer),lo]),Sr([gc,lo]),n=>Array.isArray(n)?yt(n,co):n),ho=ot({executable:Yr(),owner:Ve,lamports:q(),data:Xh,rentEpoch:q()}),Qh=ot({pubkey:Ve,account:ho}),t0=ot({state:Sr([He("active"),He("inactive"),He("activating"),He("deactivating")]),active:q(),inactive:q()}),e0=ee(wt(ot({signature:dt(),slot:q(),err:Cn,memo:bt(dt()),blockTime:Ot(bt(q()))}))),r0=ee(wt(ot({signature:dt(),slot:q(),err:Cn,memo:bt(dt()),blockTime:Ot(bt(q()))}))),n0=ot({subscription:q(),result:Ji(bi)}),i0=ot({pubkey:Ve,account:bi}),s0=ot({subscription:q(),result:Ji(i0)}),o0=ot({parent:q(),slot:q(),root:q()}),a0=ot({subscription:q(),result:o0}),c0=Sr([ot({type:Sr([He("firstShredReceived"),He("completed"),He("optimisticConfirmation"),He("root")]),slot:q(),timestamp:q()}),ot({type:He("createdBank"),parent:q(),slot:q(),timestamp:q()}),ot({type:He("frozen"),slot:q(),timestamp:q(),stats:ot({numTransactionEntries:q(),numSuccessfulTransactions:q(),numFailedTransactions:q(),maxTransactionsPerEntry:q()})}),ot({type:He("dead"),slot:q(),timestamp:q(),err:dt()})]),u0=ot({subscription:q(),result:c0}),f0=ot({subscription:q(),result:Ji(Sr([Th,Mh]))}),l0=ot({subscription:q(),result:q()}),h0=ot({pubkey:dt(),gossip:bt(dt()),tpu:bt(dt()),rpc:bt(dt()),version:bt(dt())}),xc=ot({votePubkey:dt(),nodePubkey:dt(),activatedStake:q(),epochVoteAccount:Yr(),epochCredits:wt(Ds([q(),q(),q()])),commission:q(),lastVote:q(),rootSlot:bt(q())}),d0=ee(ot({current:wt(xc),delinquent:wt(xc)})),p0=Sr([He("processed"),He("confirmed"),He("finalized")]),g0=ot({slot:q(),confirmations:bt(q()),err:Cn,confirmationStatus:Ot(p0)}),y0=Ye(wt(bt(g0))),m0=ee(q()),vc=ot({accountKey:Ve,writableIndexes:wt(q()),readonlyIndexes:wt(q())}),po=ot({signatures:wt(dt()),message:ot({accountKeys:wt(dt()),header:ot({numRequiredSignatures:q(),numReadonlySignedAccounts:q(),numReadonlyUnsignedAccounts:q()}),instructions:wt(ot({accounts:wt(q()),data:dt(),programIdIndex:q()})),recentBlockhash:dt(),addressTableLookups:Ot(wt(vc))})}),kc=ot({pubkey:Ve,signer:Yr(),writable:Yr(),source:Ot(Sr([He("transaction"),He("lookupTable")]))}),Sc=ot({accountKeys:wt(kc),signatures:wt(dt())}),Ec=ot({parsed:Gn(),program:dt(),programId:Ve}),_c=ot({accounts:wt(Ve),data:dt(),programId:Ve}),w0=Sr([_c,Ec]),b0=Sr([ot({parsed:Gn(),program:dt(),programId:dt()}),ot({accounts:wt(dt()),data:dt(),programId:dt()})]),Ic=fi(w0,b0,n=>"accounts"in n?yt(n,_c):yt(n,Ec)),Ac=ot({signatures:wt(dt()),message:ot({accountKeys:wt(kc),instructions:wt(Ic),recentBlockhash:dt(),addressTableLookups:Ot(bt(wt(vc)))})}),Xi=ot({accountIndex:q(),mint:dt(),owner:Ot(dt()),uiTokenAmount:fo}),Bc=ot({writable:wt(Ve),readonly:wt(Ve)}),Qi=ot({err:Cn,fee:q(),innerInstructions:Ot(bt(wt(ot({index:q(),instructions:wt(ot({accounts:wt(q()),data:dt(),programIdIndex:q()}))})))),preBalances:wt(q()),postBalances:wt(q()),logMessages:Ot(bt(wt(dt()))),preTokenBalances:Ot(bt(wt(Xi))),postTokenBalances:Ot(bt(wt(Xi))),loadedAddresses:Ot(Bc),computeUnitsConsumed:Ot(q())}),go=ot({err:Cn,fee:q(),innerInstructions:Ot(bt(wt(ot({index:q(),instructions:wt(Ic)})))),preBalances:wt(q()),postBalances:wt(q()),logMessages:Ot(bt(wt(dt()))),preTokenBalances:Ot(bt(wt(Xi))),postTokenBalances:Ot(bt(wt(Xi))),loadedAddresses:Ot(Bc),computeUnitsConsumed:Ot(q())}),Xn=Sr([He(0),He("legacy")]),Ln=ot({pubkey:dt(),lamports:q(),postBalance:bt(q()),rewardType:bt(dt()),commission:Ot(bt(q()))}),x0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(ot({transaction:po,meta:bt(Qi),version:Ot(Xn)})),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),v0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),k0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(ot({transaction:Sc,meta:bt(Qi),version:Ot(Xn)})),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),S0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(ot({transaction:Ac,meta:bt(go),version:Ot(Xn)})),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),E0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(ot({transaction:Sc,meta:bt(go),version:Ot(Xn)})),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),_0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),I0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(ot({transaction:po,meta:bt(Qi)})),rewards:Ot(wt(Ln)),blockTime:bt(q())}))),Rc=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),signatures:wt(dt()),blockTime:bt(q())}))),yo=ee(bt(ot({slot:q(),meta:bt(Qi),blockTime:Ot(bt(q())),transaction:po,version:Ot(Xn)}))),ts=ee(bt(ot({slot:q(),transaction:Ac,meta:bt(go),blockTime:Ot(bt(q())),version:Ot(Xn)}))),A0=Ye(ot({blockhash:dt(),feeCalculator:ot({lamportsPerSignature:q()})})),B0=Ye(ot({blockhash:dt(),lastValidBlockHeight:q()})),R0=Ye(Yr()),T0=ot({slot:q(),numTransactions:q(),numSlots:q(),samplePeriodSecs:q()}),M0=ee(wt(T0)),P0=Ye(bt(ot({feeCalculator:ot({lamportsPerSignature:q()})}))),C0=ee(dt()),L0=ee(dt()),U0=ot({err:Cn,logs:wt(dt()),signature:dt()}),O0=ot({result:Ji(U0),subscription:q()}),N0={"solana-client":"js/1.0.0-maintenance"};class F0{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 y={};return async x=>{const{commitment:_,config:L}=Fe(x),C=this._buildArgs([],_,void 0,L),N=hc(C);return y[N]=y[N]??(async()=>{try{const M=await this._rpcRequest("getBlockHeight",C),O=yt(M,ee(q()));if("error"in O)throw new Rt(O.error,"failed to get block height information");return O.result}finally{delete y[N]}})(),await y[N]}})();let r,s,i,o,a,l;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,r=e.wsEndpoint,s=e.httpHeaders,i=e.fetch,o=e.fetchMiddleware,a=e.disableRetryOnRateLimit,l=e.httpAgent),this._rpcEndpoint=vh(t),this._rpcWsEndpoint=r||xh(t),this._rpcClient=Oh(t,s,i,o,a,l),this._rpcRequest=Nh(this._rpcClient),this._rpcBatchRequest=Fh(this._rpcClient),this._rpcWebSocket=new yh(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:r,config:s}=Fe(e),i=this._buildArgs([t.toBase58()],r,void 0,s),o=await this._rpcRequest("getBalance",i),a=yt(o,Ye(q()));if("error"in a)throw new Rt(a.error,`failed to get balance for ${t.toBase58()}`);return a.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(r=>r.value).catch(r=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+r)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),r=yt(e,ee(bt(q())));if("error"in r)throw new Rt(r.error,`failed to get block time for slot ${t}`);return r.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=yt(t,ee(q()));if("error"in e)throw new Rt(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=yt(t,Hh);if("error"in e)throw new Rt(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 r=await this._rpcRequest("getSupply",[e]),s=yt(r,Vh);if("error"in s)throw new Rt(s.error,"failed to get supply");return s.result}async getTokenSupply(t,e){const r=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenSupply",r),i=yt(s,Ye(fo));if("error"in i)throw new Rt(i.error,"failed to get token supply");return i.result}async getTokenAccountBalance(t,e){const r=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenAccountBalance",r),i=yt(s,Ye(fo));if("error"in i)throw new Rt(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(t,e,r){const{commitment:s,config:i}=Fe(r);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const a=this._buildArgs(o,s,"base64",i),l=await this._rpcRequest("getTokenAccountsByOwner",a),y=yt(l,Gh);if("error"in y)throw new Rt(y.error,`failed to get token accounts owned by account ${t.toBase58()}`);return y.result}async getParsedTokenAccountsByOwner(t,e,r){let s=[t.toBase58()];"mint"in e?s.push({mint:e.mint.toBase58()}):s.push({programId:e.programId.toBase58()});const i=this._buildArgs(s,r,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",i),a=yt(o,Yh);if("error"in a)throw new Rt(a.error,`failed to get token accounts owned by account ${t.toBase58()}`);return a.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},r=e.filter||e.commitment?[e]:[],s=await this._rpcRequest("getLargestAccounts",r),i=yt(s,Zh);if("error"in i)throw new Rt(i.error,"failed to get largest accounts");return i.result}async getTokenLargestAccounts(t,e){const r=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenLargestAccounts",r),i=yt(s,jh);if("error"in i)throw new Rt(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgs([t.toBase58()],r,"base64",s),o=await this._rpcRequest("getAccountInfo",i),a=yt(o,Ye(bt(bi)));if("error"in a)throw new Rt(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getParsedAccountInfo(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgs([t.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getAccountInfo",i),a=yt(o,Ye(bt(ho)));if("error"in a)throw new Rt(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(r){throw new Error("failed to get info about account "+t.toBase58()+": "+r)}}async getMultipleParsedAccounts(t,e){const{commitment:r,config:s}=Fe(e),i=t.map(y=>y.toBase58()),o=this._buildArgs([i],r,"jsonParsed",s),a=await this._rpcRequest("getMultipleAccounts",o),l=yt(a,Ye(wt(bt(ho))));if("error"in l)throw new Rt(l.error,`failed to get info for accounts ${i}`);return l.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:r,config:s}=Fe(e),i=t.map(y=>y.toBase58()),o=this._buildArgs([i],r,"base64",s),a=await this._rpcRequest("getMultipleAccounts",o),l=yt(a,Ye(wt(bt(bi))));if("error"in l)throw new Rt(l.error,`failed to get info for accounts ${i}`);return l.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,r){const{commitment:s,config:i}=Fe(e),o=this._buildArgs([t.toBase58()],s,void 0,{...i,epoch:r??(i==null?void 0:i.epoch)}),a=await this._rpcRequest("getStakeActivation",o),l=yt(a,ee(t0));if("error"in l)throw new Rt(l.error,`failed to get Stake Activation ${t.toBase58()}`);return l.result}async getProgramAccounts(t,e){const{commitment:r,config:s}=Fe(e),{encoding:i,...o}=s||{},a=this._buildArgs([t.toBase58()],r,i||"base64",{...o,...o.filters?{filters:mc(o.filters)}:null}),l=await this._rpcRequest("getProgramAccounts",a),y=wt(Jh),x=o.withContext===!0?yt(l,Ye(y)):yt(l,ee(y));if("error"in x)throw new Rt(x.error,`failed to get accounts owned by program ${t.toBase58()}`);return x.result}async getParsedProgramAccounts(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgs([t.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getProgramAccounts",i),a=yt(o,ee(wt(Qh)));if("error"in a)throw new Rt(a.error,`failed to get accounts owned by program ${t.toBase58()}`);return a.result}async confirmTransaction(t,e){var i;let r;if(typeof t=="string")r=t;else{const o=t;if((i=o.abortSignal)!=null&&i.aborted)return Promise.reject(o.abortSignal.reason);r=o.signature}let s;try{s=ar.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return xe(s.length===64,"signature has invalid length"),typeof t=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:r}):"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,r)=>{t!=null&&(t.aborted?r(t.reason):t.addEventListener("abort",()=>{r(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let r,s,i=!1;const o=new Promise((l,y)=>{try{r=this.onSignature(e,(_,L)=>{r=void 0;const C={context:L,value:_};l({__type:on.PROCESSED,response:C})},t);const x=new Promise(_=>{r==null?_():s=this._onSubscriptionStateChange(r,L=>{L==="subscribed"&&_()})});(async()=>{if(await x,i)return;const _=await this.getSignatureStatus(e);if(i||_==null)return;const{context:L,value:C}=_;if(C!=null)if(C!=null&&C.err)y(C.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(C.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(C.confirmationStatus==="processed"||C.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}i=!0,l({__type:on.PROCESSED,response:{context:L,value:C}})}})()}catch(x){y(x)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:r,signature:s}}){let i=!1;const o=new Promise(_=>{const L=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let C=await L();if(!i){for(;C<=r;)if(await Mn(1e3),i||(C=await L(),i))return;_({__type:on.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:t,signature:s}),y=this.getCancellationPromise(e);let x;try{const _=await Promise.race([y,l,o]);if(_.__type===on.PROCESSED)x=_.response;else throw new Qs(s)}finally{i=!0,a()}return x}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:r,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let a=!1;const l=new Promise(C=>{let N=i,M=null;const O=async()=>{try{const{context:K,value:X}=await this.getNonceAndContext(s,{commitment:t,minContextSlot:r});return M=K.slot,X==null?void 0:X.nonce}catch{return N}};(async()=>{if(N=await O(),!a)for(;;){if(i!==N){C({__type:on.NONCE_INVALID,slotInWhichNonceDidAdvance:M});return}if(await Mn(2e3),a||(N=await O(),a))return}})()}),{abortConfirmation:y,confirmationPromise:x}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),_=this.getCancellationPromise(e);let L;try{const C=await Promise.race([_,x,l]);if(C.__type===on.PROCESSED)L=C.response;else{let N;for(;;){const M=await this.getSignatureStatus(o);if(M==null)break;if(M.context.slot<(C.slotInWhichNonceDidAdvance??r)){await Mn(400);continue}N=M;break}if(N!=null&&N.value){const M=t||"finalized",{confirmationStatus:O}=N.value;switch(M){case"processed":case"recent":if(O!=="processed"&&O!=="confirmed"&&O!=="finalized")throw new Yn(o);break;case"confirmed":case"single":case"singleGossip":if(O!=="confirmed"&&O!=="finalized")throw new Yn(o);break;case"finalized":case"max":case"root":if(O!=="finalized")throw new Yn(o);break;default:}L={context:N.context,value:{err:N.value.err}}}else throw new Yn(o)}}finally{a=!0,y()}return L}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let r;const s=new Promise(l=>{let y=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{y=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>l({__type:on.TIMED_OUT,timeoutMs:y}),y)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let a;try{const l=await Promise.race([o,s]);if(l.__type===on.PROCESSED)a=l.response;else throw new to(e,l.timeoutMs/1e3)}finally{clearTimeout(r),i()}return a}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=yt(t,ee(wt(h0)));if("error"in e)throw new Rt(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getVoteAccounts",e),s=yt(r,d0);if("error"in s)throw new Rt(s.error,"failed to get vote accounts");return s.result}async getSlot(t){const{commitment:e,config:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getSlot",s),o=yt(i,ee(q()));if("error"in o)throw new Rt(o.error,"failed to get slot");return o.result}async getSlotLeader(t){const{commitment:e,config:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getSlotLeader",s),o=yt(i,ee(dt()));if("error"in o)throw new Rt(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(t,e){const r=[t,e],s=await this._rpcRequest("getSlotLeaders",r),i=yt(s,ee(wt(Ve)));if("error"in i)throw new Rt(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(t,e){const{context:r,value:s}=await this.getSignatureStatuses([t],e);xe(s.length===1);const i=s[0];return{context:r,value:i}}async getSignatureStatuses(t,e){const r=[t];e&&r.push(e);const s=await this._rpcRequest("getSignatureStatuses",r),i=yt(s,y0);if("error"in i)throw new Rt(i.error,"failed to get signature status");return i.result}async getTransactionCount(t){const{commitment:e,config:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getTransactionCount",s),o=yt(i,ee(q()));if("error"in o)throw new Rt(o.error,"failed to get transaction count");return o.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getInflationGovernor",e),s=yt(r,zh);if("error"in s)throw new Rt(s.error,"failed to get inflation");return s.result}async getInflationReward(t,e,r){const{commitment:s,config:i}=Fe(r),o=this._buildArgs([t.map(y=>y.toBase58())],s,void 0,{...i,epoch:e??(i==null?void 0:i.epoch)}),a=await this._rpcRequest("getInflationReward",o),l=yt(a,Eh);if("error"in l)throw new Rt(l.error,"failed to get inflation reward");return l.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=yt(t,Kh);if("error"in e)throw new Rt(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getEpochInfo",s),o=yt(i,Dh);if("error"in o)throw new Rt(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=yt(t,$h);if("error"in e)throw new Rt(e.error,"failed to get epoch schedule");const r=e.result;return new dc(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=yt(t,qh);if("error"in e)throw new Rt(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const r=this._buildArgs([t],e),s=await this._rpcRequest("getMinimumBalanceForRentExemption",r),i=yt(s,m0);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result}async getRecentBlockhashAndContext(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getRecentBlockhash",e),s=yt(r,A0);if("error"in s)throw new Rt(s.error,"failed to get recent blockhash");return s.result}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),r=yt(e,M0);if("error"in r)throw new Rt(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(t,e){const r=this._buildArgs([t],e),s=await this._rpcRequest("getFeeCalculatorForBlockhash",r),i=yt(s,P0);if("error"in i)throw new Rt(i.error,"failed to get fee calculator");const{context:o,value:a}=i.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(t,e){const r=te(t.serialize()).toString("base64"),s=this._buildArgs([r],e),i=await this._rpcRequest("getFeeForMessage",s),o=yt(i,Ye(bt(q())));if("error"in o)throw new Rt(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(t){var o;const e=(o=t==null?void 0:t.lockedWritableAccounts)==null?void 0:o.map(a=>a.toBase58()),r=e!=null&&e.length?[e]:[],s=await this._rpcRequest("getRecentPrioritizationFees",r),i=yt(s,Wh);if("error"in i)throw new Rt(i.error,"failed to get recent prioritization fees");return i.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:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getLatestBlockhash",s),o=yt(i,B0);if("error"in o)throw new Rt(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgs([t],r,void 0,s),o=await this._rpcRequest("isBlockhashValid",i),a=yt(o,R0);if("error"in a)throw new Rt(a.error,"failed to determine if the blockhash `"+t+"`is valid");return a.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=yt(t,ee(Ph));if("error"in e)throw new Rt(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=yt(t,ee(dt()));if("error"in e)throw new Rt(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgsAtLeastConfirmed([t],r,void 0,s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=yt(o,k0);if("error"in a)throw a.error;return a.result}case"none":{const a=yt(o,v0);if("error"in a)throw a.error;return a.result}default:{const a=yt(o,x0);if("error"in a)throw a.error;const{result:l}=a;return l?{...l,transactions:l.transactions.map(({transaction:y,meta:x,version:_})=>({meta:x,transaction:{...y,message:uo(_,y.message)},version:_}))}:null}}}catch(a){throw new Rt(a,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=yt(o,E0);if("error"in a)throw a.error;return a.result}case"none":{const a=yt(o,_0);if("error"in a)throw a.error;return a.result}default:{const a=yt(o,S0);if("error"in a)throw a.error;return a.result}}}catch(a){throw new Rt(a,"failed to get block")}}async getBlockProduction(t){let e,r;if(typeof t=="string")r=t;else if(t){const{commitment:a,...l}=t;r=a,e=l}const s=this._buildArgs([],r,"base64",e),i=await this._rpcRequest("getBlockProduction",s),o=yt(i,Uh);if("error"in o)throw new Rt(o.error,"failed to get block production information");return o.result}async getTransaction(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgsAtLeastConfirmed([t],r,void 0,s),o=await this._rpcRequest("getTransaction",i),a=yt(o,yo);if("error"in a)throw new Rt(a.error,"failed to get transaction");const l=a.result;return l&&{...l,transaction:{...l.transaction,message:uo(l.version,l.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",s),o=await this._rpcRequest("getTransaction",i),a=yt(o,ts);if("error"in a)throw new Rt(a.error,"failed to get transaction");return a.result}async getParsedTransactions(t,e){const{commitment:r,config:s}=Fe(e),i=t.map(l=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([l],r,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(l=>{const y=yt(l,ts);if("error"in y)throw new Rt(y.error,"failed to get transactions");return y.result})}async getTransactions(t,e){const{commitment:r,config:s}=Fe(e),i=t.map(l=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([l],r,void 0,s)}));return(await this._rpcBatchRequest(i)).map(l=>{const y=yt(l,yo);if("error"in y)throw new Rt(y.error,"failed to get transactions");const x=y.result;return x&&{...x,transaction:{...x.transaction,message:uo(x.version,x.transaction.message)}}})}async getConfirmedBlock(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getConfirmedBlock",r),i=yt(s,I0);if("error"in i)throw new Rt(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");const a={...o,transactions:o.transactions.map(({transaction:l,meta:y})=>{const x=new Wr(l.message);return{meta:y,transaction:{...l,message:x}}})};return{...a,transactions:a.transactions.map(({transaction:l,meta:y})=>({meta:y,transaction:ye.populate(l.message,l.signatures)}))}}async getBlocks(t,e,r){const s=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],r),i=await this._rpcRequest("getBlocks",s),o=yt(i,ee(wt(q())));if("error"in o)throw new Rt(o.error,"failed to get blocks");return o.result}async getBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",r),i=yt(s,Rc);if("error"in i)throw new Rt(i.error,"failed to get block");const o=i.result;if(!o)throw new Error("Block "+t+" not found");return o}async getConfirmedBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getConfirmedBlock",r),i=yt(s,Rc);if("error"in i)throw new Rt(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");return o}async getConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getConfirmedTransaction",r),i=yt(s,yo);if("error"in i)throw new Rt(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const a=new Wr(o.transaction.message),l=o.transaction.signatures;return{...o,transaction:ye.populate(a,l)}}async getParsedConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),s=await this._rpcRequest("getConfirmedTransaction",r),i=yt(s,ts);if("error"in i)throw new Rt(i.error,"failed to get confirmed transaction");return i.result}async getParsedConfirmedTransactions(t,e){const r=t.map(o=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const a=yt(o,ts);if("error"in a)throw new Rt(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(t,e,r){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(e--,!(e<=0||e<i));)try{const l=await this.getConfirmedBlockSignatures(e,"finalized");l.signatures.length>0&&(s.until=l.signatures[l.signatures.length-1].toString())}catch(l){if(l instanceof Error&&l.message.includes("skipped"))continue;throw l}let o=await this.getSlot("finalized");for(;!("before"in s)&&(r++,!(r>o));)try{const l=await this.getConfirmedBlockSignatures(r);l.signatures.length>0&&(s.before=l.signatures[l.signatures.length-1].toString())}catch(l){if(l instanceof Error&&l.message.includes("skipped"))continue;throw l}return(await this.getConfirmedSignaturesForAddress2(t,s)).map(l=>l.signature)}async getConfirmedSignaturesForAddress2(t,e,r){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=yt(i,e0);if("error"in o)throw new Rt(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(t,e,r){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),i=await this._rpcRequest("getSignaturesForAddress",s),o=yt(i,r0);if("error"in o)throw new Rt(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(t,e){const{context:r,value:s}=await this.getAccountInfoAndContext(t,e);let i=null;return s!==null&&(i=new ao({key:t,state:ao.deserialize(s.data)})),{context:r,value:i}}async getNonceAndContext(t,e){const{context:r,value:s}=await this.getAccountInfoAndContext(t,e);let i=null;return s!==null&&(i=Zi.fromAccountData(s.data)),{context:r,value:i}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then(r=>r.value).catch(r=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+r)})}async requestAirdrop(t,e){const r=await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),s=yt(r,C0);if("error"in s)throw new Rt(s.error,`airdrop to ${t.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Mn(100);const r=Date.now()-this._blockhashInfo.lastFetch>=yc;if(this._blockhashInfo.latestBlockhash!==null&&!r)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,r=e?e.blockhash:null;for(let s=0;s<50;s++){const i=await this.getLatestBlockhash("finalized");if(r!==i.blockhash)return this._blockhashInfo={latestBlockhash:i,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},i;await Mn(uc/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:r}=Fe(t),s=this._buildArgs([],e,"base64",r),i=await this._rpcRequest("getStakeMinimumDelegation",s),o=yt(i,Ye(q()));if("error"in o)throw new Rt(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(t,e,r){if("message"in t){const M=t.serialize(),O=Ct.Buffer.from(M).toString("base64");if(Array.isArray(e)||r!==void 0)throw new Error("Invalid arguments");const K=e||{};K.encoding="base64","commitment"in K||(K.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(K.innerInstructions=e.innerInstructions);const X=[O,K],V=await this._rpcRequest("simulateTransaction",X),it=yt(V,bc);if("error"in it)throw new Error("failed to simulate transaction: "+it.error.message);return it.result}let s;if(t instanceof ye){let N=t;s=new ye,s.feePayer=N.feePayer,s.instructions=t.instructions,s.nonceInfo=N.nonceInfo,s.signatures=N.signatures}else s=ye.populate(t),s._message=s._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(s.nonceInfo&&i)s.sign(...i);else{let N=this._disableBlockhashCaching;for(;;){const M=await this._blockhashWithExpiryBlockHeight(N);if(s.lastValidBlockHeight=M.lastValidBlockHeight,s.recentBlockhash=M.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");const O=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(O)&&!this._blockhashInfo.transactionSignatures.includes(O)){this._blockhashInfo.simulatedSignatures.push(O);break}else N=!0}}const o=s._compile(),a=o.serialize(),y=s._serialize(a).toString("base64"),x={encoding:"base64",commitment:this.commitment};if(r){const N=(Array.isArray(r)?r:o.nonProgramIds()).map(M=>M.toBase58());x.accounts={encoding:"base64",addresses:N}}i&&(x.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(x.innerInstructions=e.innerInstructions);const _=[y,x],L=await this._rpcRequest("simulateTransaction",_),C=yt(L,bc);if("error"in C){let N;if("data"in C.error&&(N=C.error.data.logs,N&&Array.isArray(N))){const M=`
13
- `,O=M+N.join(M);console.error(C.error.message,O)}throw new yi({action:"simulate",signature:"",transactionMessage:C.error.message,logs:N})}return C.result}async sendTransaction(t,e,r){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const o=t.serialize();return await this.sendRawTransaction(o,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(t.nonceInfo)t.sign(...s);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=a.lastValidBlockHeight,t.recentBlockhash=a.blockhash,t.sign(...s),!t.signature)throw new Error("!signature");const l=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(l))o=!0;else{this._blockhashInfo.transactionSignatures.push(l);break}}}const i=t.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(t,e){const r=te(t).toString("base64");return await this.sendEncodedTransaction(r,e)}async sendEncodedTransaction(t,e){const r={encoding:"base64"},s=e&&e.skipPreflight,i=s===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(r.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(r.minContextSlot=e.minContextSlot),s&&(r.skipPreflight=s),i&&(r.preflightCommitment=i);const o=[t,r],a=await this._rpcRequest("sendTransaction",o),l=yt(a,L0);if("error"in l){let y;throw"data"in l.error&&(y=l.error.data.logs),new yi({action:s?"send":"simulate",signature:"",transactionMessage:l.error.message,logs:y})}return l.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,r])=>{this._setSubscription(e,{...r,state:"pending"})})}_setSubscription(t,e){var s;const r=(s=this._subscriptionsByHash[t])==null?void 0:s.state;if(this._subscriptionsByHash[t]=e,r!==e.state){const i=this._subscriptionStateChangeCallbacksByHash[t];i&&i.forEach(o=>{try{o(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var i;const r=this._subscriptionHashByClientSubscriptionId[t];if(r==null)return()=>{};const s=(i=this._subscriptionStateChangeCallbacksByHash)[r]||(i[r]=new Set);return s.add(e),()=>{s.delete(e),s.size===0&&delete this._subscriptionStateChangeCallbacksByHash[r]}}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(r){r instanceof Error&&console.log(`Error when closing socket connection: ${r.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 r=>{const s=this._subscriptionsByHash[r];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[r],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:i,method:o}=s;try{this._setSubscription(r,{...s,state:"subscribing"});const a=await this._rpcWebSocket.call(o,i);this._setSubscription(r,{...s,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=s.callbacks,await this._updateSubscriptions()}catch(a){if(a instanceof Error&&console.error(`${o} error for argument`,i,a.message),!e())return;this._setSubscription(r,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:i,unsubscribeMethod:o}=s;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(r,{...s,state:"unsubscribing"}),this._setSubscription(r,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[i])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!e())return;this._setSubscription(r,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const r=this._subscriptionCallbacksByServerSubscriptionId[t];r!==void 0&&r.forEach(s=>{try{s(...e)}catch(i){console.error(i)}})}_wsOnAccountNotification(t){const{result:e,subscription:r}=yt(t,n0);this._handleServerNotification(r,[e.value,e.context])}_makeSubscription(t,e){const r=this._nextClientSubscriptionId++,s=hc([t.method,e]),i=this._subscriptionsByHash[s];return i===void 0?this._subscriptionsByHash[s]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:i.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[r]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const o=this._subscriptionsByHash[s];xe(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),o.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(t,e,r){const{commitment:s,config:i}=Fe(r),o=this._buildArgs([t.toBase58()],s||this._commitment||"finalized","base64",i);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:r}=yt(t,s0);this._handleServerNotification(r,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,r,s){const{commitment:i,config:o}=Fe(r),a=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:mc(s)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,r){const s=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],r||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:r}=yt(t,O0);this._handleServerNotification(r,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:r}=yt(t,a0);this._handleServerNotification(r,[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:r}=yt(t,u0);this._handleServerNotification(r,[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 r=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,r,s){const i=e||this._commitment;if(i||r||s){let o={};r&&(o.encoding=r),i&&(o.commitment=i),s&&(o=Object.assign(o,s)),t.push(o)}return t}_buildArgsAtLeastConfirmed(t,e,r,s){const i=e||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,r,s)}_wsOnSignatureNotification(t){const{result:e,subscription:r}=yt(t,f0);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,r){const s=this._buildArgs([t],r||this._commitment||"finalized"),i=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){e(o.result,a);try{this.removeSignatureListener(i)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return i}onSignatureWithOptions(t,e,r){const{commitment:s,...i}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([t],s,void 0,i),a=this._makeSubscription({callback:(l,y)=>{e(l,y);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:r}=yt(t,l0);this._handleServerNotification(r,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}class Un{constructor(t){this._keypair=void 0,this._keypair=t??rc()}static generate(){return new Un(rc())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");const r=t.slice(32,64);if(!e||!e.skipValidation){const s=t.slice(0,32),i=Hi(s);for(let o=0;o<32;o++)if(r[o]!==i[o])throw new Error("provided secretKey is invalid")}return new Un({publicKey:r,secretKey:t})}static fromSeed(t){const e=Hi(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),new Un({publicKey:e,secretKey:r})}get publicKey(){return new gt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const an=Object.freeze({CreateLookupTable:{index:0,layout:At([It("instruction"),Jn("recentSlot"),ge("bumpSeed")])},FreezeLookupTable:{index:1,layout:At([It("instruction")])},ExtendLookupTable:{index:2,layout:At([It("instruction"),Jn(),dr(oe(),pn(It(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:At([It("instruction")])},CloseLookupTable:{index:4,layout:At([It("instruction")])}});class z0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=It("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(an))if(o.index==r){s=i;break}if(!s)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return s}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=Ee(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}=Ee(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(r=>new gt(r))}}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(mo.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 mo{constructor(){}static createLookupTable(t){const[e,r]=gt.findProgramAddressSync([t.authority.toBuffer(),Ma(BigInt(t.recentSlot),8)],this.programId),s=an.CreateLookupTable,i=fe(s,{recentSlot:BigInt(t.recentSlot),bumpSeed:r}),o=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:cr.programId,isSigner:!1,isWritable:!1}];return[new Ue({programId:this.programId,keys:o,data:i}),e]}static freezeLookupTable(t){const e=an.FreezeLookupTable,r=fe(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ue({programId:this.programId,keys:s,data:r})}static extendLookupTable(t){const e=an.ExtendLookupTable,r=fe(e,{addresses:t.addresses.map(i=>i.toBytes())}),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&s.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:cr.programId,isSigner:!1,isWritable:!1}),new Ue({programId:this.programId,keys:s,data:r})}static deactivateLookupTable(t){const e=an.DeactivateLookupTable,r=fe(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ue({programId:this.programId,keys:s,data:r})}static closeLookupTable(t){const e=an.CloseLookupTable,r=fe(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Ue({programId:this.programId,keys:s,data:r})}}mo.programId=new gt("AddressLookupTab1e1111111111111111111111111");class K0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=ge("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(Qr))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return s}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:r}=Ee(Qr.RequestUnits,t.data);return{units:e,additionalFee:r}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Ee(Qr.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Ee(Qr.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Ee(Qr.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(wo.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Qr=Object.freeze({RequestUnits:{index:0,layout:At([ge("instruction"),It("units"),It("additionalFee")])},RequestHeapFrame:{index:1,layout:At([ge("instruction"),It("bytes")])},SetComputeUnitLimit:{index:2,layout:At([ge("instruction"),It("units")])},SetComputeUnitPrice:{index:3,layout:At([ge("instruction"),Jn("microLamports")])}});class wo{constructor(){}static requestUnits(t){const e=Qr.RequestUnits,r=fe(e,t);return new Ue({keys:[],programId:this.programId,data:r})}static requestHeapFrame(t){const e=Qr.RequestHeapFrame,r=fe(e,t);return new Ue({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(t){const e=Qr.SetComputeUnitLimit,r=fe(e,t);return new Ue({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(t){const e=Qr.SetComputeUnitPrice,r=fe(e,{microLamports:BigInt(t.microLamports)});return new Ue({keys:[],programId:this.programId,data:r})}}wo.programId=new gt("ComputeBudget111111111111111111111111111111");const Tc=64,Mc=32,Pc=64,Cc=At([ge("numSignatures"),ge("padding"),Lr("signatureOffset"),Lr("signatureInstructionIndex"),Lr("publicKeyOffset"),Lr("publicKeyInstructionIndex"),Lr("messageDataOffset"),Lr("messageDataSize"),Lr("messageInstructionIndex")]);class es{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:s,instructionIndex:i}=t;xe(e.length===Mc,`Public Key must be ${Mc} bytes but received ${e.length} bytes`),xe(s.length===Pc,`Signature must be ${Pc} bytes but received ${s.length} bytes`);const o=Cc.span,a=o+e.length,l=a+s.length,y=1,x=Ct.Buffer.alloc(l+r.length),_=i??65535;return Cc.encode({numSignatures:y,padding:0,signatureOffset:a,signatureInstructionIndex:_,publicKeyOffset:o,publicKeyInstructionIndex:_,messageDataOffset:l,messageDataSize:r.length,messageInstructionIndex:_},x),x.fill(e,o),x.fill(s,a),x.fill(r,l),new Ue({keys:[],programId:es.programId,data:x})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:s}=t;xe(e.length===Tc,`Private key must be ${Tc} bytes but received ${e.length} bytes`);try{const i=Un.fromSecretKey(e),o=i.publicKey.toBytes(),a=Js(r,i.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:a,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}es.programId=new gt("Ed25519SigVerify111111111111111111111111111");const W0=(n,t)=>{const e=qi.sign(n,t);return[e.toCompactRawBytes(),e.recovery]};qi.utils.isValidPrivateKey;const D0=qi.getPublicKey,Lc=32,bo=20,Uc=64,$0=11,xo=At([ge("numSignatures"),Lr("signatureOffset"),ge("signatureInstructionIndex"),Lr("ethAddressOffset"),ge("ethAddressInstructionIndex"),Lr("messageDataOffset"),Lr("messageDataSize"),ge("messageInstructionIndex"),Ke(20,"ethAddress"),Ke(64,"signature"),ge("recoveryId")]);class Qn{constructor(){}static publicKeyToEthAddress(t){xe(t.length===Uc,`Public key must be ${Uc} bytes but received ${t.length} bytes`);try{return Ct.Buffer.from(Ya(te(t))).slice(-bo)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:s,recoveryId:i,instructionIndex:o}=t;return Qn.createInstructionWithEthAddress({ethAddress:Qn.publicKeyToEthAddress(e),message:r,signature:s,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:r,signature:s,recoveryId:i,instructionIndex:o=0}=t;let a;typeof e=="string"?e.startsWith("0x")?a=Ct.Buffer.from(e.substr(2),"hex"):a=Ct.Buffer.from(e,"hex"):a=e,xe(a.length===bo,`Address must be ${bo} bytes but received ${a.length} bytes`);const l=1+$0,y=l,x=l+a.length,_=x+s.length+1,L=1,C=Ct.Buffer.alloc(xo.span+r.length);return xo.encode({numSignatures:L,signatureOffset:x,signatureInstructionIndex:o,ethAddressOffset:y,ethAddressInstructionIndex:o,messageDataOffset:_,messageDataSize:r.length,messageInstructionIndex:o,signature:te(s),ethAddress:te(a),recoveryId:i},C),C.fill(te(r),xo.span),new Ue({keys:[],programId:Qn.programId,data:C})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:s}=t;xe(e.length===Lc,`Private key must be ${Lc} bytes but received ${e.length} bytes`);try{const i=te(e),o=D0(i,!1).slice(1),a=Ct.Buffer.from(Ya(te(r))),[l,y]=W0(a,i);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:l,recoveryId:y,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Qn.programId=new gt("KeccakSecp256k11111111111111111111111111111");var Oc;const Nc=new gt("StakeConfig11111111111111111111111111111111");class Fc{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class xi{constructor(t,e,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=r}}Oc=xi,xi.default=new Oc(0,0,gt.default);class q0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=It("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(ur))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a StakeInstruction");return s}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:r}=Ee(ur.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new Fc(new gt(e.staker),new gt(e.withdrawer)),lockup:new xi(r.unixTimestamp,r.epoch,new gt(r.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),Ee(ur.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:r}=Ee(ur.Authorize,t.data),s={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new gt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(s.custodianPubkey=t.keys[3].pubkey),s}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:r,authoritySeed:s,authorityOwner:i}=Ee(ur.AuthorizeWithSeed,t.data),o={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:s,authorityOwner:new gt(i),newAuthorizedPubkey:new gt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(o.custodianPubkey=t.keys[3].pubkey),o}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ee(ur.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),Ee(ur.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}=Ee(ur.Withdraw,t.data),r={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(r.custodianPubkey=t.keys[5].pubkey),r}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ee(ur.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(rs.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 ur=Object.freeze({Initialize:{index:0,layout:At([It("instruction"),Gl(),Yl()])},Authorize:{index:1,layout:At([It("instruction"),oe("newAuthorized"),It("stakeAuthorizationType")])},Delegate:{index:2,layout:At([It("instruction")])},Split:{index:3,layout:At([It("instruction"),Tr("lamports")])},Withdraw:{index:4,layout:At([It("instruction"),Tr("lamports")])},Deactivate:{index:5,layout:At([It("instruction")])},Merge:{index:7,layout:At([It("instruction")])},AuthorizeWithSeed:{index:8,layout:At([It("instruction"),oe("newAuthorized"),It("stakeAuthorizationType"),Rn("authoritySeed"),oe("authorityOwner")])}}),H0=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class rs{constructor(){}static initialize(t){const{stakePubkey:e,authorized:r,lockup:s}=t,i=s||xi.default,o=ur.Initialize,a=fe(o,{authorized:{staker:te(r.staker.toBuffer()),withdrawer:te(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:te(i.custodian.toBuffer())}}),l={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new Ue(l)}static createAccountWithSeed(t){const e=new ye;e.add(cr.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=t;return e.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static createAccount(t){const e=new ye;e.add(cr.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=t;return e.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:r,votePubkey:s}=t,i=ur.Delegate,o=fe(i);return new ye().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:Yi,isSigner:!1,isWritable:!1},{pubkey:Nc,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(t){const{stakePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:s,stakeAuthorizationType:i,custodianPubkey:o}=t,a=ur.Authorize,l=fe(a,{newAuthorized:te(s.toBuffer()),stakeAuthorizationType:i.index}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&y.push({pubkey:o,isSigner:!0,isWritable:!1}),new ye().add({keys:y,programId:this.programId,data:l})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:r,authoritySeed:s,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:l}=t,y=ur.AuthorizeWithSeed,x=fe(y,{newAuthorized:te(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:s,authorityOwner:te(i.toBuffer())}),_=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:Xr,isSigner:!1,isWritable:!1}];return l&&_.push({pubkey:l,isSigner:!0,isWritable:!1}),new ye().add({keys:_,programId:this.programId,data:x})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:r,splitStakePubkey:s,lamports:i}=t,o=ur.Split,a=fe(o,{lamports:i});return new Ue({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(t,e){const r=new ye;return r.add(cr.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:e,space:this.space,programId:this.programId})),r.add(this.splitInstruction(t))}static splitWithSeed(t,e){const{stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,basePubkey:o,seed:a,lamports:l}=t,y=new ye;return y.add(cr.allocate({accountPubkey:i,basePubkey:o,seed:a,space:this.space,programId:this.programId})),e&&e>0&&y.add(cr.transfer({fromPubkey:t.authorizedPubkey,toPubkey:i,lamports:e})),y.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,lamports:l}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:r,authorizedPubkey:s}=t,i=ur.Merge,o=fe(i);return new ye().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:Yi,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:r,toPubkey:s,lamports:i,custodianPubkey:o}=t,a=ur.Withdraw,l=fe(a,{lamports:i}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:Yi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&y.push({pubkey:o,isSigner:!0,isWritable:!1}),new ye().add({keys:y,programId:this.programId,data:l})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:r}=t,s=ur.Deactivate,i=fe(s);return new ye().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}rs.programId=new gt("Stake11111111111111111111111111111111111111"),rs.space=200;class zc{constructor(t,e,r,s){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=r,this.commission=s}}class V0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=It("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(tn))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a VoteInstruction");return s}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=Ee(tn.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new zc(new gt(e.nodePubkey),new gt(e.authorizedVoter),new gt(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:r}=Ee(tn.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new gt(e),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:r,newAuthorized:s,voteAuthorizationType:i}}=Ee(tn.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new gt(e),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new gt(s),voteAuthorizationType:{index:i},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ee(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(ti.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:At([It("instruction"),Zl()])},Authorize:{index:1,layout:At([It("instruction"),oe("newAuthorized"),It("voteAuthorizationType")])},Withdraw:{index:3,layout:At([It("instruction"),Tr("lamports")])},UpdateValidatorIdentity:{index:4,layout:At([It("instruction")])},AuthorizeWithSeed:{index:10,layout:At([It("instruction"),Jl()])}}),j0=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class ti{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:r,voteInit:s}=t,i=tn.InitializeAccount,o=fe(i,{voteInit:{nodePubkey:te(s.nodePubkey.toBuffer()),authorizedVoter:te(s.authorizedVoter.toBuffer()),authorizedWithdrawer:te(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),a={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Ue(a)}static createAccount(t){const e=new ye;return e.add(cr.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:r,newAuthorizedPubkey:s,voteAuthorizationType:i}=t,o=tn.Authorize,a=fe(o,{newAuthorized:te(s.toBuffer()),voteAuthorizationType:i.index}),l=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new ye().add({keys:l,programId:this.programId,data:a})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:a}=t,l=tn.AuthorizeWithSeed,y=fe(l,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:te(r.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:te(i.toBuffer()),voteAuthorizationType:o.index}}),x=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new ye().add({keys:x,programId:this.programId,data:y})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,lamports:s,toPubkey:i}=t,o=tn.Withdraw,a=fe(o,{lamports:s}),l=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new ye().add({keys:l,programId:this.programId,data:a})}static safeWithdraw(t,e,r){if(t.lamports>e-r)throw new Error("Withdraw will leave vote account with insufficient funds.");return ti.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,nodePubkey:s}=t,i=tn.UpdateValidatorIdentity,o=fe(i),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new ye().add({keys:a,programId:this.programId,data:o})}}ti.programId=new gt("Vote111111111111111111111111111111111111111"),ti.space=3762;const Kc=new gt("Va1idator1nfo111111111111111111111111111111"),G0=ot({name:dt(),website:Ot(dt()),details:Ot(dt()),iconUrl:Ot(dt()),keybaseUsername:Ot(dt())});class vo{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 s=[];for(let i=0;i<2;i++){const o=new gt(Ir(e,0,Zr)),a=Jr(e)===1;s.push({publicKey:o,isSigner:a})}if(s[0].publicKey.equals(Kc)&&s[1].isSigner){const i=Rn().decode(Ct.Buffer.from(e)),o=JSON.parse(i);return Ca(o,G0),new vo(s[1].publicKey,o)}return null}}const Y0=new gt("Vote111111111111111111111111111111111111111"),Z0=At([oe("nodePubkey"),oe("authorizedWithdrawer"),ge("commission"),hr(),dr(At([hr("slot"),It("confirmationCount")]),pn(It(),-8),"votes"),ge("rootSlotValid"),hr("rootSlot"),hr(),dr(At([hr("epoch"),oe("authorizedVoter")]),pn(It(),-8),"authorizedVoters"),At([dr(At([oe("authorizedPubkey"),hr("epochOfLastAuthorizedSwitch"),hr("targetEpoch")]),32,"buf"),hr("idx"),ge("isEmpty")],"priorVoters"),hr(),dr(At([hr("epoch"),hr("credits"),hr("prevCredits")]),pn(It(),-8),"epochCredits"),At([hr("slot"),hr("timestamp")],"lastTimestamp")]);class ko{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 r=Z0.decode(te(t),4);let s=r.rootSlot;return r.rootSlotValid||(s=null),new ko({nodePubkey:new gt(r.nodePubkey),authorizedWithdrawer:new gt(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:s,authorizedVoters:r.authorizedVoters.map(J0),priorVoters:X0(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function J0({authorizedVoter:n,epoch:t}){return{epoch:t,authorizedVoter:new gt(n)}}function Wc({authorizedPubkey:n,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new gt(n),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function X0({buf:n,idx:t,isEmpty:e}){return e?[]:[...n.slice(t+1).map(Wc),...n.slice(0,t).map(Wc)]}const Dc={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 Q0(n,t){const e=t===!1?"http":"https";if(!n)return Dc[e].devnet;const r=Dc[e][n];if(!r)throw new Error(`Unknown ${e} cluster: ${n}`);return r}async function td(n,t,e,r){let s,i;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(s=e,i=r):i=e;const o=i&&{skipPreflight:i.skipPreflight,preflightCommitment:i.preflightCommitment||i.commitment,minContextSlot:i.minContextSlot},a=await n.sendRawTransaction(t,o),l=i&&i.commitment,x=(await(s?n.confirmTransaction(s,l):n.confirmTransaction(a,l))).value;if(x.err)throw a!=null?new yi({action:o!=null&&o.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(x)})`}):new Error(`Raw transaction ${a} failed (${JSON.stringify(x)})`);return a}const ns=Object.freeze(Object.defineProperty({__proto__:null,Account:Hl,AddressLookupTableAccount:ao,AddressLookupTableInstruction:z0,AddressLookupTableProgram:mo,Authorized:Fc,BLOCKHASH_CACHE_TIMEOUT_MS:yc,BPF_LOADER_DEPRECATED_PROGRAM_ID:Vl,BPF_LOADER_PROGRAM_ID:ch,BpfLoader:uh,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Qr,ComputeBudgetInstruction:K0,ComputeBudgetProgram:wo,Connection:F0,Ed25519Program:es,Enum:$l,EpochSchedule:dc,FeeCalculatorLayout:fc,Keypair:Un,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:an,Loader:Pn,Lockup:xi,MAX_SEED_LENGTH:sc,Message:Wr,MessageAccountKeys:gi,MessageV0:Tn,NONCE_ACCOUNT_LENGTH:so,NonceAccount:Zi,PACKET_DATA_SIZE:yn,PUBLIC_KEY_LENGTH:Zr,PublicKey:gt,SIGNATURE_LENGTH_IN_BYTES:pi,SOLANA_SCHEMA:di,STAKE_CONFIG_ID:Nc,STAKE_INSTRUCTION_LAYOUTS:ur,SYSTEM_INSTRUCTION_LAYOUTS:Ne,SYSVAR_CLOCK_PUBKEY:Xr,SYSVAR_EPOCH_SCHEDULE_PUBKEY:Ql,SYSVAR_INSTRUCTIONS_PUBKEY:th,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:Gi,SYSVAR_RENT_PUBKEY:Zn,SYSVAR_REWARDS_PUBKEY:eh,SYSVAR_SLOT_HASHES_PUBKEY:rh,SYSVAR_SLOT_HISTORY_PUBKEY:nh,SYSVAR_STAKE_HISTORY_PUBKEY:Yi,Secp256k1Program:Qn,SendTransactionError:yi,SolanaJSONRPCError:Rt,SolanaJSONRPCErrorCode:ih,StakeAuthorizationLayout:H0,StakeInstruction:q0,StakeProgram:rs,Struct:Xs,SystemInstruction:oh,SystemProgram:cr,Transaction:ye,TransactionExpiredBlockheightExceededError:Qs,TransactionExpiredNonceInvalidError:Yn,TransactionExpiredTimeoutError:to,TransactionInstruction:Ue,TransactionMessage:ro,TransactionStatus:on,VALIDATOR_INFO_KEY:Kc,VERSION_PREFIX_MASK:Vi,VOTE_PROGRAM_ID:Y0,ValidatorInfo:vo,VersionedMessage:eo,VersionedTransaction:no,VoteAccount:ko,VoteAuthorizationLayout:j0,VoteInit:zc,VoteInstruction:V0,VoteProgram:ti,clusterApiUrl:Q0,sendAndConfirmRawTransaction:td,sendAndConfirmTransaction:io},Symbol.toStringTag,{value:"Module"})),Dr=ar;var So={exports:{}};So.exports,function(n){var t=function(){var e=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function o(l,y){if(!i[l]){i[l]={};for(var x=0;x<l.length;x++)i[l][l.charAt(x)]=x}return i[l][y]}var a={compressToBase64:function(l){if(l==null)return"";var y=a._compress(l,6,function(x){return r.charAt(x)});switch(y.length%4){default:case 0:return y;case 1:return y+"===";case 2:return y+"==";case 3:return y+"="}},decompressFromBase64:function(l){return l==null?"":l==""?null:a._decompress(l.length,32,function(y){return o(r,l.charAt(y))})},compressToUTF16:function(l){return l==null?"":a._compress(l,15,function(y){return e(y+32)})+" "},decompressFromUTF16:function(l){return l==null?"":l==""?null:a._decompress(l.length,16384,function(y){return l.charCodeAt(y)-32})},compressToUint8Array:function(l){for(var y=a.compress(l),x=new Uint8Array(y.length*2),_=0,L=y.length;_<L;_++){var C=y.charCodeAt(_);x[_*2]=C>>>8,x[_*2+1]=C%256}return x},decompressFromUint8Array:function(l){if(l==null)return a.decompress(l);for(var y=new Array(l.length/2),x=0,_=y.length;x<_;x++)y[x]=l[x*2]*256+l[x*2+1];var L=[];return y.forEach(function(C){L.push(e(C))}),a.decompress(L.join(""))},compressToEncodedURIComponent:function(l){return l==null?"":a._compress(l,6,function(y){return s.charAt(y)})},decompressFromEncodedURIComponent:function(l){return l==null?"":l==""?null:(l=l.replace(/ /g,"+"),a._decompress(l.length,32,function(y){return o(s,l.charAt(y))}))},compress:function(l){return a._compress(l,16,function(y){return e(y)})},_compress:function(l,y,x){if(l==null)return"";var _,L,C={},N={},M="",O="",K="",X=2,V=3,it=2,Z=[],D=0,tt=0,rt;for(rt=0;rt<l.length;rt+=1)if(M=l.charAt(rt),Object.prototype.hasOwnProperty.call(C,M)||(C[M]=V++,N[M]=!0),O=K+M,Object.prototype.hasOwnProperty.call(C,O))K=O;else{if(Object.prototype.hasOwnProperty.call(N,K)){if(K.charCodeAt(0)<256){for(_=0;_<it;_++)D=D<<1,tt==y-1?(tt=0,Z.push(x(D)),D=0):tt++;for(L=K.charCodeAt(0),_=0;_<8;_++)D=D<<1|L&1,tt==y-1?(tt=0,Z.push(x(D)),D=0):tt++,L=L>>1}else{for(L=1,_=0;_<it;_++)D=D<<1|L,tt==y-1?(tt=0,Z.push(x(D)),D=0):tt++,L=0;for(L=K.charCodeAt(0),_=0;_<16;_++)D=D<<1|L&1,tt==y-1?(tt=0,Z.push(x(D)),D=0):tt++,L=L>>1}X--,X==0&&(X=Math.pow(2,it),it++),delete N[K]}else for(L=C[K],_=0;_<it;_++)D=D<<1|L&1,tt==y-1?(tt=0,Z.push(x(D)),D=0):tt++,L=L>>1;X--,X==0&&(X=Math.pow(2,it),it++),C[O]=V++,K=String(M)}if(K!==""){if(Object.prototype.hasOwnProperty.call(N,K)){if(K.charCodeAt(0)<256){for(_=0;_<it;_++)D=D<<1,tt==y-1?(tt=0,Z.push(x(D)),D=0):tt++;for(L=K.charCodeAt(0),_=0;_<8;_++)D=D<<1|L&1,tt==y-1?(tt=0,Z.push(x(D)),D=0):tt++,L=L>>1}else{for(L=1,_=0;_<it;_++)D=D<<1|L,tt==y-1?(tt=0,Z.push(x(D)),D=0):tt++,L=0;for(L=K.charCodeAt(0),_=0;_<16;_++)D=D<<1|L&1,tt==y-1?(tt=0,Z.push(x(D)),D=0):tt++,L=L>>1}X--,X==0&&(X=Math.pow(2,it),it++),delete N[K]}else for(L=C[K],_=0;_<it;_++)D=D<<1|L&1,tt==y-1?(tt=0,Z.push(x(D)),D=0):tt++,L=L>>1;X--,X==0&&(X=Math.pow(2,it),it++)}for(L=2,_=0;_<it;_++)D=D<<1|L&1,tt==y-1?(tt=0,Z.push(x(D)),D=0):tt++,L=L>>1;for(;;)if(D=D<<1,tt==y-1){Z.push(x(D));break}else tt++;return Z.join("")},decompress:function(l){return l==null?"":l==""?null:a._decompress(l.length,32768,function(y){return l.charCodeAt(y)})},_decompress:function(l,y,x){var _=[],L=4,C=4,N=3,M="",O=[],K,X,V,it,Z,D,tt,rt={val:x(0),position:y,index:1};for(K=0;K<3;K+=1)_[K]=K;for(V=0,Z=Math.pow(2,2),D=1;D!=Z;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=y,rt.val=x(rt.index++)),V|=(it>0?1:0)*D,D<<=1;switch(V){case 0:for(V=0,Z=Math.pow(2,8),D=1;D!=Z;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=y,rt.val=x(rt.index++)),V|=(it>0?1:0)*D,D<<=1;tt=e(V);break;case 1:for(V=0,Z=Math.pow(2,16),D=1;D!=Z;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=y,rt.val=x(rt.index++)),V|=(it>0?1:0)*D,D<<=1;tt=e(V);break;case 2:return""}for(_[3]=tt,X=tt,O.push(tt);;){if(rt.index>l)return"";for(V=0,Z=Math.pow(2,N),D=1;D!=Z;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=y,rt.val=x(rt.index++)),V|=(it>0?1:0)*D,D<<=1;switch(tt=V){case 0:for(V=0,Z=Math.pow(2,8),D=1;D!=Z;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=y,rt.val=x(rt.index++)),V|=(it>0?1:0)*D,D<<=1;_[C++]=e(V),tt=C-1,L--;break;case 1:for(V=0,Z=Math.pow(2,16),D=1;D!=Z;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=y,rt.val=x(rt.index++)),V|=(it>0?1:0)*D,D<<=1;_[C++]=e(V),tt=C-1,L--;break;case 2:return O.join("")}if(L==0&&(L=Math.pow(2,N),N++),_[tt])M=_[tt];else if(tt===C)M=X+X.charAt(0);else return null;O.push(M),_[C++]=X+M.charAt(0),L--,X=M,L==0&&(L=Math.pow(2,N),N++)}}};return a}();n!=null?n.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})}(So);var ed=So.exports;const $r=ni(ed);function rd(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var $c={exports:{}};(function(n){(function(t){var e=function(g){var b,v=new Float64Array(16);if(g)for(b=0;b<g.length;b++)v[b]=g[b];return v},r=function(){throw new Error("no PRNG")},s=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var o=e(),a=e([1]),l=e([56129,1]),y=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),x=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]),L=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),C=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function N(g,b,v,c){g[b]=v>>24&255,g[b+1]=v>>16&255,g[b+2]=v>>8&255,g[b+3]=v&255,g[b+4]=c>>24&255,g[b+5]=c>>16&255,g[b+6]=c>>8&255,g[b+7]=c&255}function M(g,b,v,c,S){var W,z=0;for(W=0;W<S;W++)z|=g[b+W]^v[c+W];return(1&z-1>>>8)-1}function O(g,b,v,c){return M(g,b,v,c,16)}function K(g,b,v,c){return M(g,b,v,c,32)}function X(g,b,v,c){for(var S=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,W=v[0]&255|(v[1]&255)<<8|(v[2]&255)<<16|(v[3]&255)<<24,z=v[4]&255|(v[5]&255)<<8|(v[6]&255)<<16|(v[7]&255)<<24,J=v[8]&255|(v[9]&255)<<8|(v[10]&255)<<16|(v[11]&255)<<24,lt=v[12]&255|(v[13]&255)<<8|(v[14]&255)<<16|(v[15]&255)<<24,pt=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,ht=b[0]&255|(b[1]&255)<<8|(b[2]&255)<<16|(b[3]&255)<<24,ce=b[4]&255|(b[5]&255)<<8|(b[6]&255)<<16|(b[7]&255)<<24,vt=b[8]&255|(b[9]&255)<<8|(b[10]&255)<<16|(b[11]&255)<<24,Ft=b[12]&255|(b[13]&255)<<8|(b[14]&255)<<16|(b[15]&255)<<24,Kt=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,Vt=v[16]&255|(v[17]&255)<<8|(v[18]&255)<<16|(v[19]&255)<<24,qt=v[20]&255|(v[21]&255)<<8|(v[22]&255)<<16|(v[23]&255)<<24,Wt=v[24]&255|(v[25]&255)<<8|(v[26]&255)<<16|(v[27]&255)<<24,$t=v[28]&255|(v[29]&255)<<8|(v[30]&255)<<16|(v[31]&255)<<24,Dt=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,St=S,Bt=W,xt=z,Et=J,_t=lt,mt=pt,j=ht,G=ce,st=vt,et=Ft,nt=Kt,ut=Vt,Ut=qt,Zt=Wt,Xt=$t,Jt=Dt,P,ie=0;ie<20;ie+=2)P=St+Ut|0,_t^=P<<7|P>>>25,P=_t+St|0,st^=P<<9|P>>>23,P=st+_t|0,Ut^=P<<13|P>>>19,P=Ut+st|0,St^=P<<18|P>>>14,P=mt+Bt|0,et^=P<<7|P>>>25,P=et+mt|0,Zt^=P<<9|P>>>23,P=Zt+et|0,Bt^=P<<13|P>>>19,P=Bt+Zt|0,mt^=P<<18|P>>>14,P=nt+j|0,Xt^=P<<7|P>>>25,P=Xt+nt|0,xt^=P<<9|P>>>23,P=xt+Xt|0,j^=P<<13|P>>>19,P=j+xt|0,nt^=P<<18|P>>>14,P=Jt+ut|0,Et^=P<<7|P>>>25,P=Et+Jt|0,G^=P<<9|P>>>23,P=G+Et|0,ut^=P<<13|P>>>19,P=ut+G|0,Jt^=P<<18|P>>>14,P=St+Et|0,Bt^=P<<7|P>>>25,P=Bt+St|0,xt^=P<<9|P>>>23,P=xt+Bt|0,Et^=P<<13|P>>>19,P=Et+xt|0,St^=P<<18|P>>>14,P=mt+_t|0,j^=P<<7|P>>>25,P=j+mt|0,G^=P<<9|P>>>23,P=G+j|0,_t^=P<<13|P>>>19,P=_t+G|0,mt^=P<<18|P>>>14,P=nt+et|0,ut^=P<<7|P>>>25,P=ut+nt|0,st^=P<<9|P>>>23,P=st+ut|0,et^=P<<13|P>>>19,P=et+st|0,nt^=P<<18|P>>>14,P=Jt+Xt|0,Ut^=P<<7|P>>>25,P=Ut+Jt|0,Zt^=P<<9|P>>>23,P=Zt+Ut|0,Xt^=P<<13|P>>>19,P=Xt+Zt|0,Jt^=P<<18|P>>>14;St=St+S|0,Bt=Bt+W|0,xt=xt+z|0,Et=Et+J|0,_t=_t+lt|0,mt=mt+pt|0,j=j+ht|0,G=G+ce|0,st=st+vt|0,et=et+Ft|0,nt=nt+Kt|0,ut=ut+Vt|0,Ut=Ut+qt|0,Zt=Zt+Wt|0,Xt=Xt+$t|0,Jt=Jt+Dt|0,g[0]=St>>>0&255,g[1]=St>>>8&255,g[2]=St>>>16&255,g[3]=St>>>24&255,g[4]=Bt>>>0&255,g[5]=Bt>>>8&255,g[6]=Bt>>>16&255,g[7]=Bt>>>24&255,g[8]=xt>>>0&255,g[9]=xt>>>8&255,g[10]=xt>>>16&255,g[11]=xt>>>24&255,g[12]=Et>>>0&255,g[13]=Et>>>8&255,g[14]=Et>>>16&255,g[15]=Et>>>24&255,g[16]=_t>>>0&255,g[17]=_t>>>8&255,g[18]=_t>>>16&255,g[19]=_t>>>24&255,g[20]=mt>>>0&255,g[21]=mt>>>8&255,g[22]=mt>>>16&255,g[23]=mt>>>24&255,g[24]=j>>>0&255,g[25]=j>>>8&255,g[26]=j>>>16&255,g[27]=j>>>24&255,g[28]=G>>>0&255,g[29]=G>>>8&255,g[30]=G>>>16&255,g[31]=G>>>24&255,g[32]=st>>>0&255,g[33]=st>>>8&255,g[34]=st>>>16&255,g[35]=st>>>24&255,g[36]=et>>>0&255,g[37]=et>>>8&255,g[38]=et>>>16&255,g[39]=et>>>24&255,g[40]=nt>>>0&255,g[41]=nt>>>8&255,g[42]=nt>>>16&255,g[43]=nt>>>24&255,g[44]=ut>>>0&255,g[45]=ut>>>8&255,g[46]=ut>>>16&255,g[47]=ut>>>24&255,g[48]=Ut>>>0&255,g[49]=Ut>>>8&255,g[50]=Ut>>>16&255,g[51]=Ut>>>24&255,g[52]=Zt>>>0&255,g[53]=Zt>>>8&255,g[54]=Zt>>>16&255,g[55]=Zt>>>24&255,g[56]=Xt>>>0&255,g[57]=Xt>>>8&255,g[58]=Xt>>>16&255,g[59]=Xt>>>24&255,g[60]=Jt>>>0&255,g[61]=Jt>>>8&255,g[62]=Jt>>>16&255,g[63]=Jt>>>24&255}function V(g,b,v,c){for(var S=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,W=v[0]&255|(v[1]&255)<<8|(v[2]&255)<<16|(v[3]&255)<<24,z=v[4]&255|(v[5]&255)<<8|(v[6]&255)<<16|(v[7]&255)<<24,J=v[8]&255|(v[9]&255)<<8|(v[10]&255)<<16|(v[11]&255)<<24,lt=v[12]&255|(v[13]&255)<<8|(v[14]&255)<<16|(v[15]&255)<<24,pt=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,ht=b[0]&255|(b[1]&255)<<8|(b[2]&255)<<16|(b[3]&255)<<24,ce=b[4]&255|(b[5]&255)<<8|(b[6]&255)<<16|(b[7]&255)<<24,vt=b[8]&255|(b[9]&255)<<8|(b[10]&255)<<16|(b[11]&255)<<24,Ft=b[12]&255|(b[13]&255)<<8|(b[14]&255)<<16|(b[15]&255)<<24,Kt=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,Vt=v[16]&255|(v[17]&255)<<8|(v[18]&255)<<16|(v[19]&255)<<24,qt=v[20]&255|(v[21]&255)<<8|(v[22]&255)<<16|(v[23]&255)<<24,Wt=v[24]&255|(v[25]&255)<<8|(v[26]&255)<<16|(v[27]&255)<<24,$t=v[28]&255|(v[29]&255)<<8|(v[30]&255)<<16|(v[31]&255)<<24,Dt=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,St=S,Bt=W,xt=z,Et=J,_t=lt,mt=pt,j=ht,G=ce,st=vt,et=Ft,nt=Kt,ut=Vt,Ut=qt,Zt=Wt,Xt=$t,Jt=Dt,P,ie=0;ie<20;ie+=2)P=St+Ut|0,_t^=P<<7|P>>>25,P=_t+St|0,st^=P<<9|P>>>23,P=st+_t|0,Ut^=P<<13|P>>>19,P=Ut+st|0,St^=P<<18|P>>>14,P=mt+Bt|0,et^=P<<7|P>>>25,P=et+mt|0,Zt^=P<<9|P>>>23,P=Zt+et|0,Bt^=P<<13|P>>>19,P=Bt+Zt|0,mt^=P<<18|P>>>14,P=nt+j|0,Xt^=P<<7|P>>>25,P=Xt+nt|0,xt^=P<<9|P>>>23,P=xt+Xt|0,j^=P<<13|P>>>19,P=j+xt|0,nt^=P<<18|P>>>14,P=Jt+ut|0,Et^=P<<7|P>>>25,P=Et+Jt|0,G^=P<<9|P>>>23,P=G+Et|0,ut^=P<<13|P>>>19,P=ut+G|0,Jt^=P<<18|P>>>14,P=St+Et|0,Bt^=P<<7|P>>>25,P=Bt+St|0,xt^=P<<9|P>>>23,P=xt+Bt|0,Et^=P<<13|P>>>19,P=Et+xt|0,St^=P<<18|P>>>14,P=mt+_t|0,j^=P<<7|P>>>25,P=j+mt|0,G^=P<<9|P>>>23,P=G+j|0,_t^=P<<13|P>>>19,P=_t+G|0,mt^=P<<18|P>>>14,P=nt+et|0,ut^=P<<7|P>>>25,P=ut+nt|0,st^=P<<9|P>>>23,P=st+ut|0,et^=P<<13|P>>>19,P=et+st|0,nt^=P<<18|P>>>14,P=Jt+Xt|0,Ut^=P<<7|P>>>25,P=Ut+Jt|0,Zt^=P<<9|P>>>23,P=Zt+Ut|0,Xt^=P<<13|P>>>19,P=Xt+Zt|0,Jt^=P<<18|P>>>14;g[0]=St>>>0&255,g[1]=St>>>8&255,g[2]=St>>>16&255,g[3]=St>>>24&255,g[4]=mt>>>0&255,g[5]=mt>>>8&255,g[6]=mt>>>16&255,g[7]=mt>>>24&255,g[8]=nt>>>0&255,g[9]=nt>>>8&255,g[10]=nt>>>16&255,g[11]=nt>>>24&255,g[12]=Jt>>>0&255,g[13]=Jt>>>8&255,g[14]=Jt>>>16&255,g[15]=Jt>>>24&255,g[16]=j>>>0&255,g[17]=j>>>8&255,g[18]=j>>>16&255,g[19]=j>>>24&255,g[20]=G>>>0&255,g[21]=G>>>8&255,g[22]=G>>>16&255,g[23]=G>>>24&255,g[24]=st>>>0&255,g[25]=st>>>8&255,g[26]=st>>>16&255,g[27]=st>>>24&255,g[28]=et>>>0&255,g[29]=et>>>8&255,g[30]=et>>>16&255,g[31]=et>>>24&255}function it(g,b,v,c){X(g,b,v,c)}function Z(g,b,v,c){V(g,b,v,c)}var D=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function tt(g,b,v,c,S,W,z){var J=new Uint8Array(16),lt=new Uint8Array(64),pt,ht;for(ht=0;ht<16;ht++)J[ht]=0;for(ht=0;ht<8;ht++)J[ht]=W[ht];for(;S>=64;){for(it(lt,J,z,D),ht=0;ht<64;ht++)g[b+ht]=v[c+ht]^lt[ht];for(pt=1,ht=8;ht<16;ht++)pt=pt+(J[ht]&255)|0,J[ht]=pt&255,pt>>>=8;S-=64,b+=64,c+=64}if(S>0)for(it(lt,J,z,D),ht=0;ht<S;ht++)g[b+ht]=v[c+ht]^lt[ht];return 0}function rt(g,b,v,c,S){var W=new Uint8Array(16),z=new Uint8Array(64),J,lt;for(lt=0;lt<16;lt++)W[lt]=0;for(lt=0;lt<8;lt++)W[lt]=c[lt];for(;v>=64;){for(it(z,W,S,D),lt=0;lt<64;lt++)g[b+lt]=z[lt];for(J=1,lt=8;lt<16;lt++)J=J+(W[lt]&255)|0,W[lt]=J&255,J>>>=8;v-=64,b+=64}if(v>0)for(it(z,W,S,D),lt=0;lt<v;lt++)g[b+lt]=z[lt];return 0}function ue(g,b,v,c,S){var W=new Uint8Array(32);Z(W,c,S,D);for(var z=new Uint8Array(8),J=0;J<8;J++)z[J]=c[J+16];return rt(g,b,v,z,W)}function jt(g,b,v,c,S,W,z){var J=new Uint8Array(32);Z(J,W,z,D);for(var lt=new Uint8Array(8),pt=0;pt<8;pt++)lt[pt]=W[pt+16];return tt(g,b,v,c,S,lt,J)}var kt=function(g){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 b,v,c,S,W,z,J,lt;b=g[0]&255|(g[1]&255)<<8,this.r[0]=b&8191,v=g[2]&255|(g[3]&255)<<8,this.r[1]=(b>>>13|v<<3)&8191,c=g[4]&255|(g[5]&255)<<8,this.r[2]=(v>>>10|c<<6)&7939,S=g[6]&255|(g[7]&255)<<8,this.r[3]=(c>>>7|S<<9)&8191,W=g[8]&255|(g[9]&255)<<8,this.r[4]=(S>>>4|W<<12)&255,this.r[5]=W>>>1&8190,z=g[10]&255|(g[11]&255)<<8,this.r[6]=(W>>>14|z<<2)&8191,J=g[12]&255|(g[13]&255)<<8,this.r[7]=(z>>>11|J<<5)&8065,lt=g[14]&255|(g[15]&255)<<8,this.r[8]=(J>>>8|lt<<8)&8191,this.r[9]=lt>>>5&127,this.pad[0]=g[16]&255|(g[17]&255)<<8,this.pad[1]=g[18]&255|(g[19]&255)<<8,this.pad[2]=g[20]&255|(g[21]&255)<<8,this.pad[3]=g[22]&255|(g[23]&255)<<8,this.pad[4]=g[24]&255|(g[25]&255)<<8,this.pad[5]=g[26]&255|(g[27]&255)<<8,this.pad[6]=g[28]&255|(g[29]&255)<<8,this.pad[7]=g[30]&255|(g[31]&255)<<8};kt.prototype.blocks=function(g,b,v){for(var c=this.fin?0:2048,S,W,z,J,lt,pt,ht,ce,vt,Ft,Kt,Vt,qt,Wt,$t,Dt,St,Bt,xt,Et=this.h[0],_t=this.h[1],mt=this.h[2],j=this.h[3],G=this.h[4],st=this.h[5],et=this.h[6],nt=this.h[7],ut=this.h[8],Ut=this.h[9],Zt=this.r[0],Xt=this.r[1],Jt=this.r[2],P=this.r[3],ie=this.r[4],me=this.r[5],we=this.r[6],ne=this.r[7],de=this.r[8],pe=this.r[9];v>=16;)S=g[b+0]&255|(g[b+1]&255)<<8,Et+=S&8191,W=g[b+2]&255|(g[b+3]&255)<<8,_t+=(S>>>13|W<<3)&8191,z=g[b+4]&255|(g[b+5]&255)<<8,mt+=(W>>>10|z<<6)&8191,J=g[b+6]&255|(g[b+7]&255)<<8,j+=(z>>>7|J<<9)&8191,lt=g[b+8]&255|(g[b+9]&255)<<8,G+=(J>>>4|lt<<12)&8191,st+=lt>>>1&8191,pt=g[b+10]&255|(g[b+11]&255)<<8,et+=(lt>>>14|pt<<2)&8191,ht=g[b+12]&255|(g[b+13]&255)<<8,nt+=(pt>>>11|ht<<5)&8191,ce=g[b+14]&255|(g[b+15]&255)<<8,ut+=(ht>>>8|ce<<8)&8191,Ut+=ce>>>5|c,vt=0,Ft=vt,Ft+=Et*Zt,Ft+=_t*(5*pe),Ft+=mt*(5*de),Ft+=j*(5*ne),Ft+=G*(5*we),vt=Ft>>>13,Ft&=8191,Ft+=st*(5*me),Ft+=et*(5*ie),Ft+=nt*(5*P),Ft+=ut*(5*Jt),Ft+=Ut*(5*Xt),vt+=Ft>>>13,Ft&=8191,Kt=vt,Kt+=Et*Xt,Kt+=_t*Zt,Kt+=mt*(5*pe),Kt+=j*(5*de),Kt+=G*(5*ne),vt=Kt>>>13,Kt&=8191,Kt+=st*(5*we),Kt+=et*(5*me),Kt+=nt*(5*ie),Kt+=ut*(5*P),Kt+=Ut*(5*Jt),vt+=Kt>>>13,Kt&=8191,Vt=vt,Vt+=Et*Jt,Vt+=_t*Xt,Vt+=mt*Zt,Vt+=j*(5*pe),Vt+=G*(5*de),vt=Vt>>>13,Vt&=8191,Vt+=st*(5*ne),Vt+=et*(5*we),Vt+=nt*(5*me),Vt+=ut*(5*ie),Vt+=Ut*(5*P),vt+=Vt>>>13,Vt&=8191,qt=vt,qt+=Et*P,qt+=_t*Jt,qt+=mt*Xt,qt+=j*Zt,qt+=G*(5*pe),vt=qt>>>13,qt&=8191,qt+=st*(5*de),qt+=et*(5*ne),qt+=nt*(5*we),qt+=ut*(5*me),qt+=Ut*(5*ie),vt+=qt>>>13,qt&=8191,Wt=vt,Wt+=Et*ie,Wt+=_t*P,Wt+=mt*Jt,Wt+=j*Xt,Wt+=G*Zt,vt=Wt>>>13,Wt&=8191,Wt+=st*(5*pe),Wt+=et*(5*de),Wt+=nt*(5*ne),Wt+=ut*(5*we),Wt+=Ut*(5*me),vt+=Wt>>>13,Wt&=8191,$t=vt,$t+=Et*me,$t+=_t*ie,$t+=mt*P,$t+=j*Jt,$t+=G*Xt,vt=$t>>>13,$t&=8191,$t+=st*Zt,$t+=et*(5*pe),$t+=nt*(5*de),$t+=ut*(5*ne),$t+=Ut*(5*we),vt+=$t>>>13,$t&=8191,Dt=vt,Dt+=Et*we,Dt+=_t*me,Dt+=mt*ie,Dt+=j*P,Dt+=G*Jt,vt=Dt>>>13,Dt&=8191,Dt+=st*Xt,Dt+=et*Zt,Dt+=nt*(5*pe),Dt+=ut*(5*de),Dt+=Ut*(5*ne),vt+=Dt>>>13,Dt&=8191,St=vt,St+=Et*ne,St+=_t*we,St+=mt*me,St+=j*ie,St+=G*P,vt=St>>>13,St&=8191,St+=st*Jt,St+=et*Xt,St+=nt*Zt,St+=ut*(5*pe),St+=Ut*(5*de),vt+=St>>>13,St&=8191,Bt=vt,Bt+=Et*de,Bt+=_t*ne,Bt+=mt*we,Bt+=j*me,Bt+=G*ie,vt=Bt>>>13,Bt&=8191,Bt+=st*P,Bt+=et*Jt,Bt+=nt*Xt,Bt+=ut*Zt,Bt+=Ut*(5*pe),vt+=Bt>>>13,Bt&=8191,xt=vt,xt+=Et*pe,xt+=_t*de,xt+=mt*ne,xt+=j*we,xt+=G*me,vt=xt>>>13,xt&=8191,xt+=st*ie,xt+=et*P,xt+=nt*Jt,xt+=ut*Xt,xt+=Ut*Zt,vt+=xt>>>13,xt&=8191,vt=(vt<<2)+vt|0,vt=vt+Ft|0,Ft=vt&8191,vt=vt>>>13,Kt+=vt,Et=Ft,_t=Kt,mt=Vt,j=qt,G=Wt,st=$t,et=Dt,nt=St,ut=Bt,Ut=xt,b+=16,v-=16;this.h[0]=Et,this.h[1]=_t,this.h[2]=mt,this.h[3]=j,this.h[4]=G,this.h[5]=st,this.h[6]=et,this.h[7]=nt,this.h[8]=ut,this.h[9]=Ut},kt.prototype.finish=function(g,b){var v=new Uint16Array(10),c,S,W,z;if(this.leftover){for(z=this.leftover,this.buffer[z++]=1;z<16;z++)this.buffer[z]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(c=this.h[1]>>>13,this.h[1]&=8191,z=2;z<10;z++)this.h[z]+=c,c=this.h[z]>>>13,this.h[z]&=8191;for(this.h[0]+=c*5,c=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=c,c=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=c,v[0]=this.h[0]+5,c=v[0]>>>13,v[0]&=8191,z=1;z<10;z++)v[z]=this.h[z]+c,c=v[z]>>>13,v[z]&=8191;for(v[9]-=8192,S=(c^1)-1,z=0;z<10;z++)v[z]&=S;for(S=~S,z=0;z<10;z++)this.h[z]=this.h[z]&S|v[z];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,W=this.h[0]+this.pad[0],this.h[0]=W&65535,z=1;z<8;z++)W=(this.h[z]+this.pad[z]|0)+(W>>>16)|0,this.h[z]=W&65535;g[b+0]=this.h[0]>>>0&255,g[b+1]=this.h[0]>>>8&255,g[b+2]=this.h[1]>>>0&255,g[b+3]=this.h[1]>>>8&255,g[b+4]=this.h[2]>>>0&255,g[b+5]=this.h[2]>>>8&255,g[b+6]=this.h[3]>>>0&255,g[b+7]=this.h[3]>>>8&255,g[b+8]=this.h[4]>>>0&255,g[b+9]=this.h[4]>>>8&255,g[b+10]=this.h[5]>>>0&255,g[b+11]=this.h[5]>>>8&255,g[b+12]=this.h[6]>>>0&255,g[b+13]=this.h[6]>>>8&255,g[b+14]=this.h[7]>>>0&255,g[b+15]=this.h[7]>>>8&255},kt.prototype.update=function(g,b,v){var c,S;if(this.leftover){for(S=16-this.leftover,S>v&&(S=v),c=0;c<S;c++)this.buffer[this.leftover+c]=g[b+c];if(v-=S,b+=S,this.leftover+=S,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(v>=16&&(S=v-v%16,this.blocks(g,b,S),b+=S,v-=S),v){for(c=0;c<v;c++)this.buffer[this.leftover+c]=g[b+c];this.leftover+=v}};function ae(g,b,v,c,S,W){var z=new kt(W);return z.update(v,c,S),z.finish(g,b),0}function T(g,b,v,c,S,W){var z=new Uint8Array(16);return ae(z,0,v,c,S,W),O(g,b,z,0)}function u(g,b,v,c,S){var W;if(v<32)return-1;for(jt(g,0,b,0,v,c,S),ae(g,16,g,32,v-32,g),W=0;W<16;W++)g[W]=0;return 0}function p(g,b,v,c,S){var W,z=new Uint8Array(32);if(v<32||(ue(z,0,32,c,S),T(b,16,b,32,v-32,z)!==0))return-1;for(jt(g,0,b,0,v,c,S),W=0;W<32;W++)g[W]=0;return 0}function w(g,b){var v;for(v=0;v<16;v++)g[v]=b[v]|0}function R(g){var b,v,c=1;for(b=0;b<16;b++)v=g[b]+c+65535,c=Math.floor(v/65536),g[b]=v-c*65536;g[0]+=c-1+37*(c-1)}function I(g,b,v){for(var c,S=~(v-1),W=0;W<16;W++)c=S&(g[W]^b[W]),g[W]^=c,b[W]^=c}function A(g,b){var v,c,S,W=e(),z=e();for(v=0;v<16;v++)z[v]=b[v];for(R(z),R(z),R(z),c=0;c<2;c++){for(W[0]=z[0]-65517,v=1;v<15;v++)W[v]=z[v]-65535-(W[v-1]>>16&1),W[v-1]&=65535;W[15]=z[15]-32767-(W[14]>>16&1),S=W[15]>>16&1,W[14]&=65535,I(z,W,1-S)}for(v=0;v<16;v++)g[2*v]=z[v]&255,g[2*v+1]=z[v]>>8}function U(g,b){var v=new Uint8Array(32),c=new Uint8Array(32);return A(v,g),A(c,b),K(v,0,c,0)}function k(g){var b=new Uint8Array(32);return A(b,g),b[0]&1}function h(g,b){var v;for(v=0;v<16;v++)g[v]=b[2*v]+(b[2*v+1]<<8);g[15]&=32767}function E(g,b,v){for(var c=0;c<16;c++)g[c]=b[c]+v[c]}function at(g,b,v){for(var c=0;c<16;c++)g[c]=b[c]-v[c]}function Q(g,b,v){var c,S,W=0,z=0,J=0,lt=0,pt=0,ht=0,ce=0,vt=0,Ft=0,Kt=0,Vt=0,qt=0,Wt=0,$t=0,Dt=0,St=0,Bt=0,xt=0,Et=0,_t=0,mt=0,j=0,G=0,st=0,et=0,nt=0,ut=0,Ut=0,Zt=0,Xt=0,Jt=0,P=v[0],ie=v[1],me=v[2],we=v[3],ne=v[4],de=v[5],pe=v[6],er=v[7],Pe=v[8],Xe=v[9],Qe=v[10],tr=v[11],sr=v[12],br=v[13],xr=v[14],vr=v[15];c=b[0],W+=c*P,z+=c*ie,J+=c*me,lt+=c*we,pt+=c*ne,ht+=c*de,ce+=c*pe,vt+=c*er,Ft+=c*Pe,Kt+=c*Xe,Vt+=c*Qe,qt+=c*tr,Wt+=c*sr,$t+=c*br,Dt+=c*xr,St+=c*vr,c=b[1],z+=c*P,J+=c*ie,lt+=c*me,pt+=c*we,ht+=c*ne,ce+=c*de,vt+=c*pe,Ft+=c*er,Kt+=c*Pe,Vt+=c*Xe,qt+=c*Qe,Wt+=c*tr,$t+=c*sr,Dt+=c*br,St+=c*xr,Bt+=c*vr,c=b[2],J+=c*P,lt+=c*ie,pt+=c*me,ht+=c*we,ce+=c*ne,vt+=c*de,Ft+=c*pe,Kt+=c*er,Vt+=c*Pe,qt+=c*Xe,Wt+=c*Qe,$t+=c*tr,Dt+=c*sr,St+=c*br,Bt+=c*xr,xt+=c*vr,c=b[3],lt+=c*P,pt+=c*ie,ht+=c*me,ce+=c*we,vt+=c*ne,Ft+=c*de,Kt+=c*pe,Vt+=c*er,qt+=c*Pe,Wt+=c*Xe,$t+=c*Qe,Dt+=c*tr,St+=c*sr,Bt+=c*br,xt+=c*xr,Et+=c*vr,c=b[4],pt+=c*P,ht+=c*ie,ce+=c*me,vt+=c*we,Ft+=c*ne,Kt+=c*de,Vt+=c*pe,qt+=c*er,Wt+=c*Pe,$t+=c*Xe,Dt+=c*Qe,St+=c*tr,Bt+=c*sr,xt+=c*br,Et+=c*xr,_t+=c*vr,c=b[5],ht+=c*P,ce+=c*ie,vt+=c*me,Ft+=c*we,Kt+=c*ne,Vt+=c*de,qt+=c*pe,Wt+=c*er,$t+=c*Pe,Dt+=c*Xe,St+=c*Qe,Bt+=c*tr,xt+=c*sr,Et+=c*br,_t+=c*xr,mt+=c*vr,c=b[6],ce+=c*P,vt+=c*ie,Ft+=c*me,Kt+=c*we,Vt+=c*ne,qt+=c*de,Wt+=c*pe,$t+=c*er,Dt+=c*Pe,St+=c*Xe,Bt+=c*Qe,xt+=c*tr,Et+=c*sr,_t+=c*br,mt+=c*xr,j+=c*vr,c=b[7],vt+=c*P,Ft+=c*ie,Kt+=c*me,Vt+=c*we,qt+=c*ne,Wt+=c*de,$t+=c*pe,Dt+=c*er,St+=c*Pe,Bt+=c*Xe,xt+=c*Qe,Et+=c*tr,_t+=c*sr,mt+=c*br,j+=c*xr,G+=c*vr,c=b[8],Ft+=c*P,Kt+=c*ie,Vt+=c*me,qt+=c*we,Wt+=c*ne,$t+=c*de,Dt+=c*pe,St+=c*er,Bt+=c*Pe,xt+=c*Xe,Et+=c*Qe,_t+=c*tr,mt+=c*sr,j+=c*br,G+=c*xr,st+=c*vr,c=b[9],Kt+=c*P,Vt+=c*ie,qt+=c*me,Wt+=c*we,$t+=c*ne,Dt+=c*de,St+=c*pe,Bt+=c*er,xt+=c*Pe,Et+=c*Xe,_t+=c*Qe,mt+=c*tr,j+=c*sr,G+=c*br,st+=c*xr,et+=c*vr,c=b[10],Vt+=c*P,qt+=c*ie,Wt+=c*me,$t+=c*we,Dt+=c*ne,St+=c*de,Bt+=c*pe,xt+=c*er,Et+=c*Pe,_t+=c*Xe,mt+=c*Qe,j+=c*tr,G+=c*sr,st+=c*br,et+=c*xr,nt+=c*vr,c=b[11],qt+=c*P,Wt+=c*ie,$t+=c*me,Dt+=c*we,St+=c*ne,Bt+=c*de,xt+=c*pe,Et+=c*er,_t+=c*Pe,mt+=c*Xe,j+=c*Qe,G+=c*tr,st+=c*sr,et+=c*br,nt+=c*xr,ut+=c*vr,c=b[12],Wt+=c*P,$t+=c*ie,Dt+=c*me,St+=c*we,Bt+=c*ne,xt+=c*de,Et+=c*pe,_t+=c*er,mt+=c*Pe,j+=c*Xe,G+=c*Qe,st+=c*tr,et+=c*sr,nt+=c*br,ut+=c*xr,Ut+=c*vr,c=b[13],$t+=c*P,Dt+=c*ie,St+=c*me,Bt+=c*we,xt+=c*ne,Et+=c*de,_t+=c*pe,mt+=c*er,j+=c*Pe,G+=c*Xe,st+=c*Qe,et+=c*tr,nt+=c*sr,ut+=c*br,Ut+=c*xr,Zt+=c*vr,c=b[14],Dt+=c*P,St+=c*ie,Bt+=c*me,xt+=c*we,Et+=c*ne,_t+=c*de,mt+=c*pe,j+=c*er,G+=c*Pe,st+=c*Xe,et+=c*Qe,nt+=c*tr,ut+=c*sr,Ut+=c*br,Zt+=c*xr,Xt+=c*vr,c=b[15],St+=c*P,Bt+=c*ie,xt+=c*me,Et+=c*we,_t+=c*ne,mt+=c*de,j+=c*pe,G+=c*er,st+=c*Pe,et+=c*Xe,nt+=c*Qe,ut+=c*tr,Ut+=c*sr,Zt+=c*br,Xt+=c*xr,Jt+=c*vr,W+=38*Bt,z+=38*xt,J+=38*Et,lt+=38*_t,pt+=38*mt,ht+=38*j,ce+=38*G,vt+=38*st,Ft+=38*et,Kt+=38*nt,Vt+=38*ut,qt+=38*Ut,Wt+=38*Zt,$t+=38*Xt,Dt+=38*Jt,S=1,c=W+S+65535,S=Math.floor(c/65536),W=c-S*65536,c=z+S+65535,S=Math.floor(c/65536),z=c-S*65536,c=J+S+65535,S=Math.floor(c/65536),J=c-S*65536,c=lt+S+65535,S=Math.floor(c/65536),lt=c-S*65536,c=pt+S+65535,S=Math.floor(c/65536),pt=c-S*65536,c=ht+S+65535,S=Math.floor(c/65536),ht=c-S*65536,c=ce+S+65535,S=Math.floor(c/65536),ce=c-S*65536,c=vt+S+65535,S=Math.floor(c/65536),vt=c-S*65536,c=Ft+S+65535,S=Math.floor(c/65536),Ft=c-S*65536,c=Kt+S+65535,S=Math.floor(c/65536),Kt=c-S*65536,c=Vt+S+65535,S=Math.floor(c/65536),Vt=c-S*65536,c=qt+S+65535,S=Math.floor(c/65536),qt=c-S*65536,c=Wt+S+65535,S=Math.floor(c/65536),Wt=c-S*65536,c=$t+S+65535,S=Math.floor(c/65536),$t=c-S*65536,c=Dt+S+65535,S=Math.floor(c/65536),Dt=c-S*65536,c=St+S+65535,S=Math.floor(c/65536),St=c-S*65536,W+=S-1+37*(S-1),S=1,c=W+S+65535,S=Math.floor(c/65536),W=c-S*65536,c=z+S+65535,S=Math.floor(c/65536),z=c-S*65536,c=J+S+65535,S=Math.floor(c/65536),J=c-S*65536,c=lt+S+65535,S=Math.floor(c/65536),lt=c-S*65536,c=pt+S+65535,S=Math.floor(c/65536),pt=c-S*65536,c=ht+S+65535,S=Math.floor(c/65536),ht=c-S*65536,c=ce+S+65535,S=Math.floor(c/65536),ce=c-S*65536,c=vt+S+65535,S=Math.floor(c/65536),vt=c-S*65536,c=Ft+S+65535,S=Math.floor(c/65536),Ft=c-S*65536,c=Kt+S+65535,S=Math.floor(c/65536),Kt=c-S*65536,c=Vt+S+65535,S=Math.floor(c/65536),Vt=c-S*65536,c=qt+S+65535,S=Math.floor(c/65536),qt=c-S*65536,c=Wt+S+65535,S=Math.floor(c/65536),Wt=c-S*65536,c=$t+S+65535,S=Math.floor(c/65536),$t=c-S*65536,c=Dt+S+65535,S=Math.floor(c/65536),Dt=c-S*65536,c=St+S+65535,S=Math.floor(c/65536),St=c-S*65536,W+=S-1+37*(S-1),g[0]=W,g[1]=z,g[2]=J,g[3]=lt,g[4]=pt,g[5]=ht,g[6]=ce,g[7]=vt,g[8]=Ft,g[9]=Kt,g[10]=Vt,g[11]=qt,g[12]=Wt,g[13]=$t,g[14]=Dt,g[15]=St}function ct(g,b){Q(g,b,b)}function Mt(g,b){var v=e(),c;for(c=0;c<16;c++)v[c]=b[c];for(c=253;c>=0;c--)ct(v,v),c!==2&&c!==4&&Q(v,v,b);for(c=0;c<16;c++)g[c]=v[c]}function Tt(g,b){var v=e(),c;for(c=0;c<16;c++)v[c]=b[c];for(c=250;c>=0;c--)ct(v,v),c!==1&&Q(v,v,b);for(c=0;c<16;c++)g[c]=v[c]}function Pt(g,b,v){var c=new Uint8Array(32),S=new Float64Array(80),W,z,J=e(),lt=e(),pt=e(),ht=e(),ce=e(),vt=e();for(z=0;z<31;z++)c[z]=b[z];for(c[31]=b[31]&127|64,c[0]&=248,h(S,v),z=0;z<16;z++)lt[z]=S[z],ht[z]=J[z]=pt[z]=0;for(J[0]=ht[0]=1,z=254;z>=0;--z)W=c[z>>>3]>>>(z&7)&1,I(J,lt,W),I(pt,ht,W),E(ce,J,pt),at(J,J,pt),E(pt,lt,ht),at(lt,lt,ht),ct(ht,ce),ct(vt,J),Q(J,pt,J),Q(pt,lt,ce),E(ce,J,pt),at(J,J,pt),ct(lt,J),at(pt,ht,vt),Q(J,pt,l),E(J,J,ht),Q(pt,pt,J),Q(J,ht,vt),Q(ht,lt,S),ct(lt,ce),I(J,lt,W),I(pt,ht,W);for(z=0;z<16;z++)S[z+16]=J[z],S[z+32]=pt[z],S[z+48]=lt[z],S[z+64]=ht[z];var Ft=S.subarray(32),Kt=S.subarray(16);return Mt(Ft,Ft),Q(Kt,Kt,Ft),A(g,Kt),0}function Ce(g,b){return Pt(g,b,i)}function Yt(g,b){return r(b,32),Ce(g,b)}function Gt(g,b,v){var c=new Uint8Array(32);return Pt(c,v,b),Z(g,s,c,D)}var le=u,re=p;function ve(g,b,v,c,S,W){var z=new Uint8Array(32);return Gt(z,S,W),le(g,b,v,c,z)}function Or(g,b,v,c,S,W){var z=new Uint8Array(32);return Gt(z,S,W),re(g,b,v,c,z)}var _e=[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 Oe(g,b,v,c){for(var S=new Int32Array(16),W=new Int32Array(16),z,J,lt,pt,ht,ce,vt,Ft,Kt,Vt,qt,Wt,$t,Dt,St,Bt,xt,Et,_t,mt,j,G,st,et,nt,ut,Ut=g[0],Zt=g[1],Xt=g[2],Jt=g[3],P=g[4],ie=g[5],me=g[6],we=g[7],ne=b[0],de=b[1],pe=b[2],er=b[3],Pe=b[4],Xe=b[5],Qe=b[6],tr=b[7],sr=0;c>=128;){for(_t=0;_t<16;_t++)mt=8*_t+sr,S[_t]=v[mt+0]<<24|v[mt+1]<<16|v[mt+2]<<8|v[mt+3],W[_t]=v[mt+4]<<24|v[mt+5]<<16|v[mt+6]<<8|v[mt+7];for(_t=0;_t<80;_t++)if(z=Ut,J=Zt,lt=Xt,pt=Jt,ht=P,ce=ie,vt=me,Ft=we,Kt=ne,Vt=de,qt=pe,Wt=er,$t=Pe,Dt=Xe,St=Qe,Bt=tr,j=we,G=tr,st=G&65535,et=G>>>16,nt=j&65535,ut=j>>>16,j=(P>>>14|Pe<<18)^(P>>>18|Pe<<14)^(Pe>>>9|P<<23),G=(Pe>>>14|P<<18)^(Pe>>>18|P<<14)^(P>>>9|Pe<<23),st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,j=P&ie^~P&me,G=Pe&Xe^~Pe&Qe,st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,j=_e[_t*2],G=_e[_t*2+1],st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,j=S[_t%16],G=W[_t%16],st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,xt=nt&65535|ut<<16,Et=st&65535|et<<16,j=xt,G=Et,st=G&65535,et=G>>>16,nt=j&65535,ut=j>>>16,j=(Ut>>>28|ne<<4)^(ne>>>2|Ut<<30)^(ne>>>7|Ut<<25),G=(ne>>>28|Ut<<4)^(Ut>>>2|ne<<30)^(Ut>>>7|ne<<25),st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,j=Ut&Zt^Ut&Xt^Zt&Xt,G=ne&de^ne&pe^de&pe,st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,Ft=nt&65535|ut<<16,Bt=st&65535|et<<16,j=pt,G=Wt,st=G&65535,et=G>>>16,nt=j&65535,ut=j>>>16,j=xt,G=Et,st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,pt=nt&65535|ut<<16,Wt=st&65535|et<<16,Zt=z,Xt=J,Jt=lt,P=pt,ie=ht,me=ce,we=vt,Ut=Ft,de=Kt,pe=Vt,er=qt,Pe=Wt,Xe=$t,Qe=Dt,tr=St,ne=Bt,_t%16===15)for(mt=0;mt<16;mt++)j=S[mt],G=W[mt],st=G&65535,et=G>>>16,nt=j&65535,ut=j>>>16,j=S[(mt+9)%16],G=W[(mt+9)%16],st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,xt=S[(mt+1)%16],Et=W[(mt+1)%16],j=(xt>>>1|Et<<31)^(xt>>>8|Et<<24)^xt>>>7,G=(Et>>>1|xt<<31)^(Et>>>8|xt<<24)^(Et>>>7|xt<<25),st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,xt=S[(mt+14)%16],Et=W[(mt+14)%16],j=(xt>>>19|Et<<13)^(Et>>>29|xt<<3)^xt>>>6,G=(Et>>>19|xt<<13)^(xt>>>29|Et<<3)^(Et>>>6|xt<<26),st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,S[mt]=nt&65535|ut<<16,W[mt]=st&65535|et<<16;j=Ut,G=ne,st=G&65535,et=G>>>16,nt=j&65535,ut=j>>>16,j=g[0],G=b[0],st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[0]=Ut=nt&65535|ut<<16,b[0]=ne=st&65535|et<<16,j=Zt,G=de,st=G&65535,et=G>>>16,nt=j&65535,ut=j>>>16,j=g[1],G=b[1],st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[1]=Zt=nt&65535|ut<<16,b[1]=de=st&65535|et<<16,j=Xt,G=pe,st=G&65535,et=G>>>16,nt=j&65535,ut=j>>>16,j=g[2],G=b[2],st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[2]=Xt=nt&65535|ut<<16,b[2]=pe=st&65535|et<<16,j=Jt,G=er,st=G&65535,et=G>>>16,nt=j&65535,ut=j>>>16,j=g[3],G=b[3],st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[3]=Jt=nt&65535|ut<<16,b[3]=er=st&65535|et<<16,j=P,G=Pe,st=G&65535,et=G>>>16,nt=j&65535,ut=j>>>16,j=g[4],G=b[4],st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[4]=P=nt&65535|ut<<16,b[4]=Pe=st&65535|et<<16,j=ie,G=Xe,st=G&65535,et=G>>>16,nt=j&65535,ut=j>>>16,j=g[5],G=b[5],st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[5]=ie=nt&65535|ut<<16,b[5]=Xe=st&65535|et<<16,j=me,G=Qe,st=G&65535,et=G>>>16,nt=j&65535,ut=j>>>16,j=g[6],G=b[6],st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[6]=me=nt&65535|ut<<16,b[6]=Qe=st&65535|et<<16,j=we,G=tr,st=G&65535,et=G>>>16,nt=j&65535,ut=j>>>16,j=g[7],G=b[7],st+=G&65535,et+=G>>>16,nt+=j&65535,ut+=j>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[7]=we=nt&65535|ut<<16,b[7]=tr=st&65535|et<<16,sr+=128,c-=128}return c}function Ar(g,b,v){var c=new Int32Array(8),S=new Int32Array(8),W=new Uint8Array(256),z,J=v;for(c[0]=1779033703,c[1]=3144134277,c[2]=1013904242,c[3]=2773480762,c[4]=1359893119,c[5]=2600822924,c[6]=528734635,c[7]=1541459225,S[0]=4089235720,S[1]=2227873595,S[2]=4271175723,S[3]=1595750129,S[4]=2917565137,S[5]=725511199,S[6]=4215389547,S[7]=327033209,Oe(c,S,b,v),v%=128,z=0;z<v;z++)W[z]=b[J-v+z];for(W[v]=128,v=256-128*(v<112?1:0),W[v-9]=0,N(W,v-8,J/536870912|0,J<<3),Oe(c,S,W,v),z=0;z<8;z++)N(g,8*z,c[z],S[z]);return 0}function Ie(g,b){var v=e(),c=e(),S=e(),W=e(),z=e(),J=e(),lt=e(),pt=e(),ht=e();at(v,g[1],g[0]),at(ht,b[1],b[0]),Q(v,v,ht),E(c,g[0],g[1]),E(ht,b[0],b[1]),Q(c,c,ht),Q(S,g[3],b[3]),Q(S,S,x),Q(W,g[2],b[2]),E(W,W,W),at(z,c,v),at(J,W,S),E(lt,W,S),E(pt,c,v),Q(g[0],z,J),Q(g[1],pt,lt),Q(g[2],lt,J),Q(g[3],z,pt)}function Ae(g,b,v){var c;for(c=0;c<4;c++)I(g[c],b[c],v)}function rr(g,b){var v=e(),c=e(),S=e();Mt(S,b[2]),Q(v,b[0],S),Q(c,b[1],S),A(g,c),g[31]^=k(v)<<7}function ke(g,b,v){var c,S;for(w(g[0],o),w(g[1],a),w(g[2],a),w(g[3],o),S=255;S>=0;--S)c=v[S/8|0]>>(S&7)&1,Ae(g,b,c),Ie(b,g),Ie(g,g),Ae(g,b,c)}function Se(g,b){var v=[e(),e(),e(),e()];w(v[0],_),w(v[1],L),w(v[2],a),Q(v[3],_,L),ke(g,v,b)}function fr(g,b,v){var c=new Uint8Array(64),S=[e(),e(),e(),e()],W;for(v||r(b,32),Ar(c,b,32),c[0]&=248,c[31]&=127,c[31]|=64,Se(S,c),rr(g,S),W=0;W<32;W++)b[W+32]=g[W];return 0}var Be=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 m(g,b){var v,c,S,W;for(c=63;c>=32;--c){for(v=0,S=c-32,W=c-12;S<W;++S)b[S]+=v-16*b[c]*Be[S-(c-32)],v=Math.floor((b[S]+128)/256),b[S]-=v*256;b[S]+=v,b[c]=0}for(v=0,S=0;S<32;S++)b[S]+=v-(b[31]>>4)*Be[S],v=b[S]>>8,b[S]&=255;for(S=0;S<32;S++)b[S]-=v*Be[S];for(c=0;c<32;c++)b[c+1]+=b[c]>>8,g[c]=b[c]&255}function f(g){var b=new Float64Array(64),v;for(v=0;v<64;v++)b[v]=g[v];for(v=0;v<64;v++)g[v]=0;m(g,b)}function d(g,b,v,c){var S=new Uint8Array(64),W=new Uint8Array(64),z=new Uint8Array(64),J,lt,pt=new Float64Array(64),ht=[e(),e(),e(),e()];Ar(S,c,32),S[0]&=248,S[31]&=127,S[31]|=64;var ce=v+64;for(J=0;J<v;J++)g[64+J]=b[J];for(J=0;J<32;J++)g[32+J]=S[32+J];for(Ar(z,g.subarray(32),v+32),f(z),Se(ht,z),rr(g,ht),J=32;J<64;J++)g[J]=c[J];for(Ar(W,g,v+64),f(W),J=0;J<64;J++)pt[J]=0;for(J=0;J<32;J++)pt[J]=z[J];for(J=0;J<32;J++)for(lt=0;lt<32;lt++)pt[J+lt]+=W[J]*S[lt];return m(g.subarray(32),pt),ce}function B(g,b){var v=e(),c=e(),S=e(),W=e(),z=e(),J=e(),lt=e();return w(g[2],a),h(g[1],b),ct(S,g[1]),Q(W,S,y),at(S,S,g[2]),E(W,g[2],W),ct(z,W),ct(J,z),Q(lt,J,z),Q(v,lt,S),Q(v,v,W),Tt(v,v),Q(v,v,S),Q(v,v,W),Q(v,v,W),Q(g[0],v,W),ct(c,g[0]),Q(c,c,W),U(c,S)&&Q(g[0],g[0],C),ct(c,g[0]),Q(c,c,W),U(c,S)?-1:(k(g[0])===b[31]>>7&&at(g[0],o,g[0]),Q(g[3],g[0],g[1]),0)}function F(g,b,v,c){var S,W=new Uint8Array(32),z=new Uint8Array(64),J=[e(),e(),e(),e()],lt=[e(),e(),e(),e()];if(v<64||B(lt,c))return-1;for(S=0;S<v;S++)g[S]=b[S];for(S=0;S<32;S++)g[S+32]=c[S];if(Ar(z,g,v),f(z),ke(J,lt,z),Se(lt,b.subarray(32)),Ie(J,lt),rr(W,J),v-=64,K(b,0,W,0)){for(S=0;S<v;S++)g[S]=0;return-1}for(S=0;S<v;S++)g[S]=b[S+64];return v}var $=32,Y=24,Ht=32,zt=16,Nt=32,Re=32,Lt=32,ze=32,ri=32,je=Y,Ze=Ht,cs=zt,Te=64,Le=32,cn=64,De=32,$e=64;t.lowlevel={crypto_core_hsalsa20:Z,crypto_stream_xor:jt,crypto_stream:ue,crypto_stream_salsa20_xor:tt,crypto_stream_salsa20:rt,crypto_onetimeauth:ae,crypto_onetimeauth_verify:T,crypto_verify_16:O,crypto_verify_32:K,crypto_secretbox:u,crypto_secretbox_open:p,crypto_scalarmult:Pt,crypto_scalarmult_base:Ce,crypto_box_beforenm:Gt,crypto_box_afternm:le,crypto_box:ve,crypto_box_open:Or,crypto_box_keypair:Yt,crypto_hash:Ar,crypto_sign:d,crypto_sign_keypair:fr,crypto_sign_open:F,crypto_secretbox_KEYBYTES:$,crypto_secretbox_NONCEBYTES:Y,crypto_secretbox_ZEROBYTES:Ht,crypto_secretbox_BOXZEROBYTES:zt,crypto_scalarmult_BYTES:Nt,crypto_scalarmult_SCALARBYTES:Re,crypto_box_PUBLICKEYBYTES:Lt,crypto_box_SECRETKEYBYTES:ze,crypto_box_BEFORENMBYTES:ri,crypto_box_NONCEBYTES:je,crypto_box_ZEROBYTES:Ze,crypto_box_BOXZEROBYTES:cs,crypto_sign_BYTES:Te,crypto_sign_PUBLICKEYBYTES:Le,crypto_sign_SECRETKEYBYTES:cn,crypto_sign_SEEDBYTES:De,crypto_hash_BYTES:$e,gf:e,D:y,L:Be,pack25519:A,unpack25519:h,M:Q,A:E,S:ct,Z:at,pow2523:Tt,add:Ie,set25519:w,modL:m,scalarmult:ke,scalarbase:Se};function ki(g,b){if(g.length!==$)throw new Error("bad key size");if(b.length!==Y)throw new Error("bad nonce size")}function Je(g,b){if(g.length!==Lt)throw new Error("bad public key size");if(b.length!==ze)throw new Error("bad secret key size")}function he(){for(var g=0;g<arguments.length;g++)if(!(arguments[g]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Si(g){for(var b=0;b<g.length;b++)g[b]=0}t.randomBytes=function(g){var b=new Uint8Array(g);return r(b,g),b},t.secretbox=function(g,b,v){he(g,b,v),ki(v,b);for(var c=new Uint8Array(Ht+g.length),S=new Uint8Array(c.length),W=0;W<g.length;W++)c[W+Ht]=g[W];return u(S,c,c.length,b,v),S.subarray(zt)},t.secretbox.open=function(g,b,v){he(g,b,v),ki(v,b);for(var c=new Uint8Array(zt+g.length),S=new Uint8Array(c.length),W=0;W<g.length;W++)c[W+zt]=g[W];return c.length<32||p(S,c,c.length,b,v)!==0?null:S.subarray(Ht)},t.secretbox.keyLength=$,t.secretbox.nonceLength=Y,t.secretbox.overheadLength=zt,t.scalarMult=function(g,b){if(he(g,b),g.length!==Re)throw new Error("bad n size");if(b.length!==Nt)throw new Error("bad p size");var v=new Uint8Array(Nt);return Pt(v,g,b),v},t.scalarMult.base=function(g){if(he(g),g.length!==Re)throw new Error("bad n size");var b=new Uint8Array(Nt);return Ce(b,g),b},t.scalarMult.scalarLength=Re,t.scalarMult.groupElementLength=Nt,t.box=function(g,b,v,c){var S=t.box.before(v,c);return t.secretbox(g,b,S)},t.box.before=function(g,b){he(g,b),Je(g,b);var v=new Uint8Array(ri);return Gt(v,g,b),v},t.box.after=t.secretbox,t.box.open=function(g,b,v,c){var S=t.box.before(v,c);return t.secretbox.open(g,b,S)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var g=new Uint8Array(Lt),b=new Uint8Array(ze);return Yt(g,b),{publicKey:g,secretKey:b}},t.box.keyPair.fromSecretKey=function(g){if(he(g),g.length!==ze)throw new Error("bad secret key size");var b=new Uint8Array(Lt);return Ce(b,g),{publicKey:b,secretKey:new Uint8Array(g)}},t.box.publicKeyLength=Lt,t.box.secretKeyLength=ze,t.box.sharedKeyLength=ri,t.box.nonceLength=je,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(g,b){if(he(g,b),b.length!==cn)throw new Error("bad secret key size");var v=new Uint8Array(Te+g.length);return d(v,g,g.length,b),v},t.sign.open=function(g,b){if(he(g,b),b.length!==Le)throw new Error("bad public key size");var v=new Uint8Array(g.length),c=F(v,g,g.length,b);if(c<0)return null;for(var S=new Uint8Array(c),W=0;W<S.length;W++)S[W]=v[W];return S},t.sign.detached=function(g,b){for(var v=t.sign(g,b),c=new Uint8Array(Te),S=0;S<c.length;S++)c[S]=v[S];return c},t.sign.detached.verify=function(g,b,v){if(he(g,b,v),b.length!==Te)throw new Error("bad signature size");if(v.length!==Le)throw new Error("bad public key size");var c=new Uint8Array(Te+g.length),S=new Uint8Array(Te+g.length),W;for(W=0;W<Te;W++)c[W]=b[W];for(W=0;W<g.length;W++)c[W+Te]=g[W];return F(S,c,c.length,v)>=0},t.sign.keyPair=function(){var g=new Uint8Array(Le),b=new Uint8Array(cn);return fr(g,b),{publicKey:g,secretKey:b}},t.sign.keyPair.fromSecretKey=function(g){if(he(g),g.length!==cn)throw new Error("bad secret key size");for(var b=new Uint8Array(Le),v=0;v<b.length;v++)b[v]=g[32+v];return{publicKey:b,secretKey:new Uint8Array(g)}},t.sign.keyPair.fromSeed=function(g){if(he(g),g.length!==De)throw new Error("bad seed size");for(var b=new Uint8Array(Le),v=new Uint8Array(cn),c=0;c<32;c++)v[c]=g[c];return fr(b,v,!0),{publicKey:b,secretKey:v}},t.sign.publicKeyLength=Le,t.sign.secretKeyLength=cn,t.sign.seedLength=De,t.sign.signatureLength=Te,t.hash=function(g){he(g);var b=new Uint8Array($e);return Ar(b,g,g.length),b},t.hash.hashLength=$e,t.verify=function(g,b){return he(g,b),g.length===0||b.length===0||g.length!==b.length?!1:M(g,0,b,0,g.length)===0},t.setPRNG=function(g){r=g},function(){var g=typeof self<"u"?self.crypto||self.msCrypto:null;if(g&&g.getRandomValues){var b=65536;t.setPRNG(function(v,c){var S,W=new Uint8Array(c);for(S=0;S<c;S+=b)g.getRandomValues(W.subarray(S,S+Math.min(c-S,b)));for(S=0;S<c;S++)v[S]=W[S];Si(W)})}else typeof rd<"u"&&(g=ra,g&&g.randomBytes&&t.setPRNG(function(v,c){var S,W=g.randomBytes(c);for(S=0;S<c;S++)v[S]=W[S];Si(W)}))}()})(n.exports?n.exports:self.nacl=self.nacl||{})})($c);var nd=$c.exports;class en{constructor(t){nr(this,"env");nr(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 r;return((r=e.nSureSettings)==null?void 0:r.nSurePartnerId)||e.nSurePartnerId}).catch(e=>{console.error(e)})}async getCreditBalance(t,e,r){const s=await fetch(this.url+`/api/customer/balances/${e}`,{method:"GET",headers:{"x-coinflow-auth-wallet":t,"x-coinflow-auth-blockchain":r}}),{credits:i}=await s.json();return i}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:r,env:s,amount:i,transaction:o,blockchain:a,webhookInfo:l,email:y,loaderBackground:x,handleHeightChange:_,bankAccountLinkRedirect:L,additionalWallets:C,nearDeposit:N,chargebackProtectionData:M,merchantCss:O,color:K,rent:X,lockDefaultToken:V,token:it,tokens:Z,planCode:D,disableApplePay:tt,disableGooglePay:rt,customerInfo:ue,settlementType:jt,lockAmount:kt,nativeSolToConvert:ae,theme:T,usePermit:u,transactionSigner:p,authOnly:w,deviceId:R,jwtToken:I,origins:A,threeDsChallengePreference:U,supportEmail:k}){var at;const h=r?`/${r}/${a}`:`/${a}`,E=new URL(h+e,en.getCoinflowBaseUrl(s));if(E.searchParams.append("pubkey",t),o&&E.searchParams.append("transaction",o),i&&E.searchParams.append("amount",i.toString()),l&&E.searchParams.append("webhookInfo",$r.compressToEncodedURIComponent(JSON.stringify(l))),T&&E.searchParams.append("theme",$r.compressToEncodedURIComponent(JSON.stringify(T))),ue&&E.searchParams.append("customerInfo",$r.compressToEncodedURIComponent(JSON.stringify(ue))),y&&E.searchParams.append("email",y),k&&E.searchParams.append("supportEmail",k),it&&E.searchParams.append("token",it.toString()),Z&&E.searchParams.append("tokens",Z.toString()),x&&E.searchParams.append("loaderBackground",x),_&&E.searchParams.append("useHeightChange","true"),L&&E.searchParams.append("bankAccountLinkRedirect",L),C&&E.searchParams.append("additionalWallets",$r.compressToEncodedURIComponent(JSON.stringify(C))),N&&E.searchParams.append("nearDeposit",N),M&&E.searchParams.append("chargebackProtectionData",$r.compressToEncodedURIComponent(JSON.stringify(M))),R)E.searchParams.append("deviceId",R);else if(typeof window<"u"){const Q=(at=window==null?void 0:window.nSureSDK)==null?void 0:at.getDeviceId();Q&&E.searchParams.append("deviceId",Q)}return O&&E.searchParams.append("merchantCss",O),K&&E.searchParams.append("color",K),X&&E.searchParams.append("rent",X.lamports.toString()),ae&&E.searchParams.append("nativeSolToConvert",ae.lamports.toString()),V&&E.searchParams.append("lockDefaultToken","true"),D&&E.searchParams.append("planCode",D),tt&&E.searchParams.append("disableApplePay","true"),rt&&E.searchParams.append("disableGooglePay","true"),jt&&E.searchParams.append("settlementType",jt),kt&&E.searchParams.append("lockAmount","true"),u===!1&&E.searchParams.append("usePermit","false"),p&&E.searchParams.append("transactionSigner",p),w===!0&&E.searchParams.append("authOnly","true"),I&&E.searchParams.append("jwtToken",I),A&&E.searchParams.append("origins",$r.compressToEncodedURIComponent(JSON.stringify(A))),U&&E.searchParams.append("threeDsChallengePreference",U),E.toString()}static getTransaction(t){return this.byBlockchain(t.blockchain,{solana:()=>{if(!("transaction"in t))return;const{transaction:e}=t;if(!ns)throw new Error("@solana/web3.js dependency is required for Solana");if(!Dr)throw new Error("bs58 dependency is required for Solana");if(e)return Dr.encode(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},eth:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},base:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},arbitrum:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},near:()=>{if(!("action"in t))return;const{action:e}=t;return $r.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:r}){return this.getWalletFromEmail({email:t,merchantId:e,env:r})}static async getWalletFromEmail({email:t,merchantId:e,env:r}){const s=new TextEncoder().encode(t),o=await window.crypto.subtle.digest("SHA-256",s),a=new Uint8Array(o),l=Un.fromSeed(a);return{publicKey:l.publicKey,signMessage:y=>Promise.resolve(nd.sign.detached(y,l.secretKey)),signTransaction:async y=>y instanceof ye?(y.sign(l),y):(y.sign([l]),y),sendTransaction:async y=>{y instanceof ye?y.sign(l):y.sign([l]);const x=this.getCoinflowApiUrl(r),_={method:"POST",headers:{"content-type":"application/json","x-coinflow-auth-wallet":l.publicKey.toString(),"x-coinflow-auth-blockchain":"solana"},body:JSON.stringify({merchantId:e,signedTransaction:Dr==null?void 0:Dr.encode(y.serialize())})},{signature:L}=await fetch(x+"/api/utils/send-coinflow-tx",_).then(C=>C.json());return L}}}}var qc=(n=>(n.SignMessage="signMessage",n.SignTransaction="signTransaction",n.SendTransaction="sendTransaction",n.HeightChange="heightChange",n.Success="success",n.Load="load",n))(qc||{});function is({wallet:n}){return"publicKey"in n?n.publicKey.toString():"address"in n?n.address:"accountId"in n?n.accountId:null}function Hc(n,t){let e;try{if(e=JSON.parse(n),!("method"in e)||!("data"in e))return}catch(i){console.error("handleIFrameMessage JSON parse",i);return}const{data:r,method:s}=e;switch(s){case"signMessage":return t.handleSignMessage?t.handleSignMessage(r):void 0;case"signTransaction":return t.handleSignTransaction?t.handleSignTransaction(r):void 0;case"sendTransaction":return t.handleSendTransaction(r);case"heightChange":return t.handleHeightChange?t.handleHeightChange(r):void 0;case"success":if(!t.onSuccess)return;t.onSuccess(e.info);return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${s} is not one of ${Object.values(qc)}`)}function ss(n){return en.byBlockchain(n.blockchain,{solana:()=>id(n),near:()=>sd(n),eth:()=>os(n),polygon:()=>os(n),base:()=>os(n),arbitrum:()=>os(n)})()}function id({wallet:n,onSuccess:t}){return{handleSendTransaction:async e=>{const r=Vc(e);return await n.sendTransaction(r)},handleSignMessage:async e=>{const r=n.signMessage;if(!r)throw new Error("signMessage is not supported by this wallet");const s=await r(new TextEncoder().encode(e));if(!Dr)throw new Error("bs58 dependency is required");return Dr.encode(s)},handleSignTransaction:async e=>{const r=n.signTransaction;if(!r)throw new Error("signTransaction is not supported by this wallet");const s=Vc(e),i=await r(s);if(!Dr)throw new Error("bs58 dependency is required");return Dr.encode(i.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:t}}function Vc(n){if(!ns)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!Dr)throw new Error("bs58 is not defined. Please install bs58 into your project");const t=Dr.decode(n),e=ns.VersionedTransaction.deserialize(t);return e.version==="legacy"?ns.Transaction.from(t):e}function sd({wallet:n,onSuccess:t}){const e=n;return{handleSendTransaction:async r=>{const s=JSON.parse(Buffer.from(r,"base64").toString()),i=await e.signAndSendTransaction(s);if(!i)throw new Error("Transaction did not send");const{transaction:o}=i;return o.hash},onSuccess:t}}function os({wallet:n,onSuccess:t}){const e=n;return{handleSendTransaction:async r=>{const s=JSON.parse(Buffer.from(r,"base64").toString()),{hash:i}=await e.sendTransaction(s);return i},handleSignMessage:async r=>e.signMessage(r),onSuccess:t}}const vi="tokenExCardNumber",ei="tokenExCardCvv",jc={[On.VISA]:"visa",[On.MASTERCARD]:"masterCard",[On.AMEX]:"americanExpress",[On.DISCOVER]:"discover"};async function Gc({token:n,origins:t,env:e}){return new Promise((r,s)=>{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:n})}).then(async i=>{r(await i.json())}).catch(i=>s(i))})}function Eo({env:n,setTokenExScriptLoaded:t}){const e="tokenex-script";if(document.head.querySelector(`#${e}`))return;const r=document.createElement("script");r.src=n==="prod"?"https://htp.tokenex.com/iframe/iframe-v3.min.js":"https://test-htp.tokenex.com/iframe/iframe-v3.min.js",r.id=e,document.head.appendChild(r),document.getElementById(e).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),t(!0)})}function od({iframe:n,setCachedToken:t,setLoaded:e}){const r=async()=>(n.tokenize(),await new Promise((s,i)=>{n.on("tokenize",o=>{t(o.token),s(o)}),n.on("validate",o=>{(!o.isValid||o.isCvvValid===!1)&&i(o)})}));return n.on("change",()=>t(void 0)),n.on("cvvChange",()=>t(void 0)),n.on("load",()=>{setTimeout(()=>e(!0),350);const s=document.querySelector("#tx_iframe_tokenExCardNumber");s&&(s.scrolling="no")}),n.on("focus",()=>{n.focus()}),n.on("cvvFocus",()=>{n.cvvFocus()}),e(!1),n.load(),{...n,tokenize:r}}async function Yc(n){const{token:t,cardType:e}=n;return await _o(ei,n,{cvvOnly:!0,cvv:!0,cvvContainerID:ei,placeholder:"CVV",token:t,cardType:jc[e]})}async function Zc(n){return await _o(vi,n,{cvv:!0,cvvContainerID:ei,cvvPlaceholder:"CVV"})}async function Jc(n){return await _o(vi,n,{cvv:!1})}async function _o(n,{tokenExScriptLoaded:t,origins:e,env:r,css:s,debug:i,font:o,setCachedToken:a,setLoaded:l},y){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 x=await Gc({token:y.token,origins:e,env:r}),{styles:_}=ad(s),L={...x,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,styles:_,font:o,debug:i??!1,...y},C=TokenEx.Iframe(n,L);return od({iframe:C,setCachedToken:a,setLoaded:l})}function ad(n){var r,s,i;const t=JSON.parse(n);return{styles:{base:mn(t.base),focus:mn(t.focus),error:mn(t.error),placeholder:mn(t.placeholder),cvv:{base:mn((r=t.cvv)==null?void 0:r.base),focus:mn((s=t.cvv)==null?void 0:s.focus),error:mn((i=t.cvv)==null?void 0:i.error),placeholder:mn(t==null?void 0:t.placeholder)}}}}function mn(n){if(!n)return"";if(typeof n=="string")return n;let t="";for(const[e,r]of Object.entries(n)){let s="";e.split("").forEach(i=>{i.toUpperCase()===i?s+="-"+i.toLowerCase():s+=i}),t+=s+":"+r+";"}return t}const cd=ft.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return en.getCoinflowUrl(this.args)}},emits:{onMessage(n){return!0}},methods:{sendMessage(n){const t=this.$refs.iframeRef;if(!(t!=null&&t.contentWindow))throw new Error("Iframe not defined");t.contentWindow.postMessage(n,"*")},handleIframeMessages({data:n,origin:t}){if(!t.includes(en.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:n,origin:t});const e=Hc(n,this.args);e&&e.then(this.sendMessage).catch(r=>{console.error(r),this.sendMessage("ERROR "+r.message)})},async listenForMessage(n){let t;return new Promise((e,r)=>{if(t=({data:s,origin:i})=>{if(i.includes(en.getCoinflowBaseUrl(this.args.env))){if(s.startsWith("ERROR")){r(new Error(s.replace("ERROR","")));return}n(s)&&e(s)}},!window)throw new Error("Window not defined");window.addEventListener("message",t)}).finally(()=>{window.removeEventListener("message",t)})},async sendAndReceiveMessage(n,t){return this.sendMessage(n),this.listenForMessage(t)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),Io=(n,t)=>{const e=n.__vccOpts||n;for(const[r,s]of t)e[r]=s;return e},ud=["src","scrolling"];function fd(n,t,e,r,s,i){return ft.openBlock(),ft.createElementBlock("iframe",{style:{height:"100%",width:"100%"},ref:"iframeRef",allow:"payment;camera",title:"withdraw",frameBorder:"0",src:n.url,scrolling:n.args.handleHeightChange?"no":"yes",onLoad:t[0]||(t[0]=()=>{const o=n.$refs.iframeRef;o&&(o.style.opacity="1")})},null,40,ud)}const as=Io(cd,[["render",fd]]),ld=ft.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:as},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const n=is(this.args);return{...this.args,walletPubkey:n,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...ss(this.args),handleHeightChange:this.args.handleHeightChange}}}});function hd(n,t,e,r,s,i){const o=ft.resolveComponent("coinflow-i-frame");return ft.openBlock(),ft.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers}},null,8,["args"])}const dd=Io(ld,[["render",hd]]),pd=ft.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:as},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const n=is(this.args);return{...this.args,walletPubkey:n,route:`/purchase-v2/${this.args.merchantId}`,transaction:en.getTransaction(this.args)}},messageHandlers(){return{...ss(this.args),handleHeightChange:this.args.handleHeightChange}}}});function gd(n,t,e,r,s,i){const o=ft.resolveComponent("coinflow-i-frame");return ft.openBlock(),ft.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers}},null,8,["args"])}const yd=Io(pd,[["render",gd]]),Ao=n=>{const t=ft.ref(!1),e=ft.ref(!1),r=ft.ref(void 0),s=ft.ref(void 0);ft.onMounted(()=>{Eo({env:n,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),e.value=!0}})});const i=_=>s.value=_,o=()=>t.value=!0,a=_=>r.value=_,l=async _=>{const L=await Yc({..._,tokenExScriptLoaded:e.value,env:n,setCachedToken:i,setLoaded:o});return a(L),L},y=async _=>{const L=await Zc({..._,tokenExScriptLoaded:e.value,env:n,setCachedToken:i,setLoaded:o});return a(L),L},x=async _=>{const L=await Jc({..._,tokenExScriptLoaded:e.value,env:n,setCachedToken:i,setLoaded:o});return a(L),L};return ft.watchEffect(_=>{r.value&&(r.value.load(),_(()=>{var L;return(L=r.value)==null?void 0:L.remove()}))}),{tokenExIframe:r,initializeTokenExIframe:y,initializeCvvOnlyTokenExIframe:l,initializeTokenExCardOnlyIframe:x,loaded:t,cachedToken:s,setTokenExScriptTag:Eo,tokenExScriptLoaded:e}},md=["id"],wd=ft.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{initializeTokenExIframe:e,tokenExIframe:r}=Ao(n.args.env);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}t({getToken:s});function i(){return JSON.stringify(n.args.css)}return ft.watchEffect(()=>{e({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(ft.openBlock(),ft.createElementBlock("div",{id:ft.unref(vi)},null,8,md))}}),bd=["id"],xd=ft.defineComponent({__name:"CoinflowCvvInput",setup(n){return(t,e)=>(ft.openBlock(),ft.createElementBlock("div",{id:ft.unref(ei)},null,8,bd))}}),vd=["id"],kd=ft.defineComponent({__name:"CoinflowCvvOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{initializeCvvOnlyTokenExIframe:e,tokenExIframe:r}=Ao(n.args.env);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}t({getToken:s});function i(){return JSON.stringify(n.args.css)}return ft.watchEffect(()=>{e({...n.args,origins:n.args.origins??[],css:i(),font:n.args.font})},{}),(o,a)=>(ft.openBlock(),ft.createElementBlock("div",{id:ft.unref(ei)},null,8,vd))}}),Sd=ft.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(n){const t=ft.ref(void 0);ft.onMounted(()=>new en(n.args.env).getNSurePartnerId(n.args.merchantId).then(s=>t.value=s));function e(){return n.args.env==="prod"?"9JBW2RHC7JNJN8ZQ":"SANDBOX_CTCE4XK53ZW0R7V1"}function r(){return n.args.env==="prod"?"https://sdk.nsureapi.com/sdk.js":"https://sdk.nsureapi.com/sdk-sandbox.js"}return ft.watchEffect(s=>{if(!t.value)return;const i=document.createElement("script");i.src=r(),document.head.appendChild(i);const o=`window.nSureAsyncInit = function(deviceId) {
12
+ `+i+o;break;default:a=`Unknown action '${(l=>l)(t)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=r,this.transactionLogs=s||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,r)=>{t.getTransaction(this.signature).then(s=>{if(s&&s.meta&&s.meta.logMessages){const i=s.meta.logMessages;this.transactionLogs=i,e(i)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}const sh={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 Rt extends Error{constructor({code:t,message:e,data:r},s){super(s!=null?`${s}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=r,this.name="SolanaJSONRPCError"}}async function no(n,t,e,r){const s=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},i=await n.sendTransaction(t,e,s);let o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,signature:i,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){const{nonceInstruction:a}=t.nonceInfo,l=a.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:l,nonceValue:t.nonceInfo.nonce,signature:i},r&&r.commitment)).value}else(r==null?void 0:r.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."),o=(await n.confirmTransaction(i,r&&r.commitment)).value;if(o.err)throw i!=null?new yi({action:"send",signature:i,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${i} failed (${JSON.stringify(o)})`);return i}function Mn(n){return new Promise(t=>setTimeout(t,n))}function fe(n,t){const e=n.layout.span>=0?n.layout.span:ac(n,t),r=Ct.Buffer.alloc(e),s=Object.assign({instruction:n.index},t);return n.layout.encode(s,r),r}function Ee(n,t){let e;try{e=n.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(e.instruction!==n.index)throw new Error(`invalid instruction; instruction index mismatch ${e.instruction} != ${n.index}`);return e}const fc=hr("lamportsPerSignature"),lc=At([It("version"),It("state"),oe("authorizedPubkey"),oe("nonce"),At([fc],"feeCalculator")]),io=lc.span;class Yi{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=lc.decode(te(t),0);return new Yi({authorizedPubkey:new gt(e.authorizedPubkey),nonce:new gt(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const oh=n=>{const t=n.decode.bind(n),e=n.encode.bind(n);return{decode:t,encode:e}},Jn=(n=>t=>{const e=Ke(n,t),{encode:r,decode:s}=oh(e),i=e;return i.decode=(o,a)=>{const l=s(o,a);return Of(Ct.Buffer.from(l))},i.encode=(o,a,l)=>{const y=Ma(o,n);return r(y,a,l)},i})(8);class ah{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=It("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(Ne))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a SystemInstruction");return s}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:r,programId:s}=Ee(Ne.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:r,programId:new gt(s)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=Ee(Ne.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:r,programId:s}=Ee(Ne.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:r,programId:new gt(s)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=Ee(Ne.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:r,space:s,programId:i}=Ee(Ne.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new gt(e),seed:r,space:s,programId:new gt(i)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=Ee(Ne.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new gt(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,programId:s}=Ee(Ne.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new gt(e),seed:r,programId:new gt(s)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:r,lamports:s,space:i,programId:o}=Ee(Ne.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new gt(e),seed:r,lamports:s,space:i,programId:new gt(o)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=Ee(Ne.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new gt(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ee(Ne.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}=Ee(Ne.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}=Ee(Ne.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new gt(e)}}static checkProgramId(t){if(!t.equals(cr.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 Ne=Object.freeze({Create:{index:0,layout:At([It("instruction"),Tr("lamports"),Tr("space"),oe("programId")])},Assign:{index:1,layout:At([It("instruction"),oe("programId")])},Transfer:{index:2,layout:At([It("instruction"),Jn("lamports")])},CreateWithSeed:{index:3,layout:At([It("instruction"),oe("base"),Rn("seed"),Tr("lamports"),Tr("space"),oe("programId")])},AdvanceNonceAccount:{index:4,layout:At([It("instruction")])},WithdrawNonceAccount:{index:5,layout:At([It("instruction"),Tr("lamports")])},InitializeNonceAccount:{index:6,layout:At([It("instruction"),oe("authorized")])},AuthorizeNonceAccount:{index:7,layout:At([It("instruction"),oe("authorized")])},Allocate:{index:8,layout:At([It("instruction"),Tr("space")])},AllocateWithSeed:{index:9,layout:At([It("instruction"),oe("base"),Rn("seed"),Tr("space"),oe("programId")])},AssignWithSeed:{index:10,layout:At([It("instruction"),oe("base"),Rn("seed"),oe("programId")])},TransferWithSeed:{index:11,layout:At([It("instruction"),Jn("lamports"),Rn("seed"),oe("programId")])},UpgradeNonceAccount:{index:12,layout:At([It("instruction")])}});class cr{constructor(){}static createAccount(t){const e=Ne.Create,r=fe(e,{lamports:t.lamports,space:t.space,programId:te(t.programId.toBuffer())});return new Ue({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(t){let e,r;if("basePubkey"in t){const s=Ne.TransferWithSeed;e=fe(s,{lamports:BigInt(t.lamports),seed:t.seed,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{const s=Ne.Transfer;e=fe(s,{lamports:BigInt(t.lamports)}),r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Ue({keys:r,programId:this.programId,data:e})}static assign(t){let e,r;if("basePubkey"in t){const s=Ne.AssignWithSeed;e=fe(s,{base:te(t.basePubkey.toBuffer()),seed:t.seed,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Ne.Assign;e=fe(s,{programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ue({keys:r,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=Ne.CreateWithSeed,r=fe(e,{base:te(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:te(t.programId.toBuffer())});let s=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey.equals(t.fromPubkey)||s.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Ue({keys:s,programId:this.programId,data:r})}static createNonceAccount(t){const e=new ye;"basePubkey"in t&&"seed"in t?e.add(cr.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:io,programId:this.programId})):e.add(cr.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:io,programId:this.programId}));const r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(r)),e}static nonceInitialize(t){const e=Ne.InitializeNonceAccount,r=fe(e,{authorized:te(t.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ji,isSigner:!1,isWritable:!1},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new Ue(s)}static nonceAdvance(t){const e=Ne.AdvanceNonceAccount,r=fe(e),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ji,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new Ue(s)}static nonceWithdraw(t){const e=Ne.WithdrawNonceAccount,r=fe(e,{lamports:t.lamports});return new Ue({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:ji,isSigner:!1,isWritable:!1},{pubkey:Zn,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(t){const e=Ne.AuthorizeNonceAccount,r=fe(e,{authorized:te(t.newAuthorizedPubkey.toBuffer())});return new Ue({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(t){let e,r;if("basePubkey"in t){const s=Ne.AllocateWithSeed;e=fe(s,{base:te(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Ne.Allocate;e=fe(s,{space:t.space}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ue({keys:r,programId:this.programId,data:e})}}cr.programId=new gt("11111111111111111111111111111111");const ch=yn-300;class Pn{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/Pn.chunkSize)+1+1)}static async load(t,e,r,s,i){{const E=await t.getMinimumBalanceForRentExemption(i.length),L=await t.getAccountInfo(r.publicKey,"confirmed");let C=null;if(L!==null){if(L.executable)return console.error("Program load failed, account is already executable"),!1;L.data.length!==i.length&&(C=C||new ye,C.add(cr.allocate({accountPubkey:r.publicKey,space:i.length}))),L.owner.equals(s)||(C=C||new ye,C.add(cr.assign({accountPubkey:r.publicKey,programId:s}))),L.lamports<E&&(C=C||new ye,C.add(cr.transfer({fromPubkey:e.publicKey,toPubkey:r.publicKey,lamports:E-L.lamports})))}else C=new ye().add(cr.createAccount({fromPubkey:e.publicKey,newAccountPubkey:r.publicKey,lamports:E>0?E:1,space:i.length,programId:s}));C!==null&&await no(t,C,[e,r],{commitment:"confirmed"})}const o=At([It("instruction"),It("offset"),It("bytesLength"),It("bytesLengthPadding"),dr(ge("byte"),pn(It(),-8),"bytes")]),a=Pn.chunkSize;let l=0,y=i,x=[];for(;y.length>0;){const E=y.slice(0,a),L=Ct.Buffer.alloc(a+16);o.encode({instruction:0,offset:l,bytes:E,bytesLength:0,bytesLengthPadding:0},L);const C=new ye().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:L});x.push(no(t,C,[e,r],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await Mn(1e3/4),l+=a,y=y.slice(a)}await Promise.all(x);{const E=At([It("instruction")]),L=Ct.Buffer.alloc(E.span);E.encode({instruction:1},L);const C=new ye().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:s,data:L}),N="processed",M=await t.sendTransaction(C,[e,r],{preflightCommitment:N}),{context:O,value:K}=await t.confirmTransaction({signature:M,lastValidBlockHeight:C.lastValidBlockHeight,blockhash:C.recentBlockhash},N);if(K.err)throw new Error(`Transaction ${M} failed (${JSON.stringify(K)})`);for(;;){try{if(await t.getSlot({commitment:N})>O.slot)break}catch{}await new Promise(Q=>setTimeout(Q,Math.round(uc/2)))}}return!0}}Pn.chunkSize=ch;const uh=new gt("BPFLoader2111111111111111111111111111111111");class fh{static getMinNumSignatures(t){return Pn.getMinNumSignatures(t)}static load(t,e,r,s,i){return Pn.load(t,e,r,i,s)}}function lh(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var so,hc;function hh(){if(hc)return so;hc=1;var n=Object.prototype.toString,t=Object.keys||function(r){var s=[];for(var i in r)s.push(i);return s};function e(r,s){var i,o,a,l,y,x,E;if(r===!0)return"true";if(r===!1)return"false";switch(typeof r){case"object":if(r===null)return null;if(r.toJSON&&typeof r.toJSON=="function")return e(r.toJSON(),s);if(E=n.call(r),E==="[object Array]"){for(a="[",o=r.length-1,i=0;i<o;i++)a+=e(r[i],!0)+",";return o>-1&&(a+=e(r[i],!0)),a+"]"}else if(E==="[object Object]"){for(l=t(r).sort(),o=l.length,a="",i=0;i<o;)y=l[i],x=e(r[y],!1),x!==void 0&&(a&&(a+=","),a+=JSON.stringify(y)+":"+x),i++;return"{"+a+"}"}else return JSON.stringify(r);case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return so=function(r){var s=e(r,!1);if(s!==void 0)return""+s},so}var dh=hh(),dc=lh(dh);const mi=32;function oo(n){let t=0;for(;n>1;)n/=2,t++;return t}function ph(n){return n===0?1:(n--,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,n|=n>>32,n+1)}class pc{constructor(t,e,r,s,i){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=r,this.firstNormalEpoch=s,this.firstNormalSlot=i}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=oo(ph(t+mi+1))-oo(mi)-1,r=this.getSlotsInEpoch(e),s=t-(r-mi);return[e,s]}else{const e=t-this.firstNormalSlot,r=Math.floor(e/this.slotsPerEpoch),s=this.firstNormalEpoch+r,i=e%this.slotsPerEpoch;return[s,i]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*mi:(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+oo(mi)):this.slotsPerEpoch}}var gh=globalThis.fetch;class yh extends Sl{constructor(t,e,r){const s=i=>{const o=vl(i,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(s,t,e,r),this.underlyingSocket=void 0}call(...t){var r;const e=(r=this.underlyingSocket)==null?void 0:r.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 r;const e=(r=this.underlyingSocket)==null?void 0:r.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 mh(n,t){let e;try{e=n.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(e.typeIndex!==n.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${n.index}`);return e}const gc=56;class ao{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=mh(wh,t),r=t.length-gc;xe(r>=0,"lookup table is invalid"),xe(r%32===0,"lookup table is invalid");const s=r/32,{addresses:i}=At([dr(oe(),s,"addresses")]).decode(t.slice(gc));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new gt(e.authority[0]):void 0,addresses:i.map(o=>new gt(o))}}}const wh={index:1,layout:At([It("typeIndex"),Jn("deactivationSlot"),hr("lastExtendedSlot"),ge("lastExtendedStartIndex"),ge(),dr(oe(),pn(ge(),-1),"authority")])},bh=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function xh(n){const t=n.match(bh);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[e,r,s,i]=t,o=n.startsWith("https:")?"wss:":"ws:",a=s==null?null:parseInt(s.slice(1),10),l=a==null?"":`:${a+1}`;return`${o}//${r}${l}${i}`}const Ve=fi(Ks(gt),dt(),n=>new gt(n)),yc=Ws([dt(),He("base64")]),co=fi(Ks(Ct.Buffer),yc,n=>Ct.Buffer.from(n[0],"base64")),mc=30*1e3;function vh(n){if(/^https?:/.test(n)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return n}function Fe(n){let t,e;if(typeof n=="string")t=n;else if(n){const{commitment:r,...s}=n;t=r,e=s}return{commitment:t,config:e}}function wc(n){return n.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function bc(n){return Sr([at({jsonrpc:He("2.0"),id:dt(),result:n}),at({jsonrpc:He("2.0"),id:dt(),error:at({code:Gn(),message:dt(),data:Ot(Hf())})})])}const kh=bc(Gn());function ee(n){return fi(bc(n),kh,t=>"error"in t?t:{...t,result:yt(t.result,n)})}function Ye(n){return ee(at({context:at({slot:q()}),value:n}))}function Zi(n){return at({context:at({slot:q()}),value:n})}function uo(n,t){return n===0?new Tn({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new gt(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:ar.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Wr(t)}const Sh=at({foundation:q(),foundationTerm:q(),initial:q(),taper:q(),terminal:q()}),Eh=ee(wt(bt(at({epoch:q(),effectiveSlot:q(),amount:q(),postBalance:q(),commission:Ot(bt(q()))})))),_h=wt(at({slot:q(),prioritizationFee:q()})),Ih=at({total:q(),validator:q(),foundation:q(),epoch:q()}),Ah=at({epoch:q(),slotIndex:q(),slotsInEpoch:q(),absoluteSlot:q(),blockHeight:Ot(q()),transactionCount:Ot(q())}),Bh=at({slotsPerEpoch:q(),leaderScheduleSlotOffset:q(),warmup:Yr(),firstNormalEpoch:q(),firstNormalSlot:q()}),Rh=Ua(dt(),wt(q())),Cn=bt(Sr([at({}),dt()])),Th=at({err:Cn}),Mh=He("receivedSignature"),Ph=at({"solana-core":dt(),"feature-set":Ot(q())}),Ch=at({program:dt(),programId:Ve,parsed:Gn()}),Lh=at({programId:Ve,accounts:wt(Ve),data:dt()}),xc=Ye(at({err:bt(Sr([at({}),dt()])),logs:bt(wt(dt())),accounts:Ot(bt(wt(bt(at({executable:Yr(),owner:dt(),lamports:q(),data:wt(dt()),rentEpoch:Ot(q())}))))),unitsConsumed:Ot(q()),returnData:Ot(bt(at({programId:dt(),data:Ws([dt(),He("base64")])}))),innerInstructions:Ot(bt(wt(at({index:q(),instructions:wt(Sr([Ch,Lh]))}))))})),Uh=Ye(at({byIdentity:Ua(dt(),wt(q())),range:at({firstSlot:q(),lastSlot:q()})}));function Oh(n,t,e,r,s,i){const o=e||gh;let a;i!=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 l;return r&&(l=async(x,E)=>{const L=await new Promise((C,N)=>{try{r(x,E,(M,O)=>C([M,O]))}catch(M){N(M)}});return await o(...L)}),new wl(async(x,E)=>{const L={method:"POST",body:x,agent:a,headers:Object.assign({"Content-Type":"application/json"},t||{},N0)};try{let C=5,N,M=500;for(;l?N=await l(n,L):N=await o(n,L),!(N.status!==429||s===!0||(C-=1,C===0));)console.error(`Server responded with ${N.status} ${N.statusText}. Retrying after ${M}ms delay...`),await Mn(M),M*=2;const O=await N.text();N.ok?E(null,O):E(new Error(`${N.status} ${N.statusText}: ${O}`))}catch(C){C instanceof Error&&E(C)}},{})}function Nh(n){return(t,e)=>new Promise((r,s)=>{n.request(t,e,(i,o)=>{if(i){s(i);return}r(o)})})}function Fh(n){return t=>new Promise((e,r)=>{t.length===0&&e([]);const s=t.map(i=>n.request(i.methodName,i.args));n.request(s,(i,o)=>{if(i){r(i);return}e(o)})})}const zh=ee(Sh),Kh=ee(Ih),Wh=ee(_h),Dh=ee(Ah),$h=ee(Bh),qh=ee(Rh),Hh=ee(q()),Vh=Ye(at({total:q(),circulating:q(),nonCirculating:q(),nonCirculatingAccounts:wt(Ve)})),fo=at({amount:dt(),uiAmount:bt(q()),decimals:q(),uiAmountString:Ot(dt())}),jh=Ye(wt(at({address:Ve,amount:dt(),uiAmount:bt(q()),decimals:q(),uiAmountString:Ot(dt())}))),Gh=Ye(wt(at({pubkey:Ve,account:at({executable:Yr(),owner:Ve,lamports:q(),data:co,rentEpoch:q()})}))),lo=at({program:dt(),parsed:Gn(),space:q()}),Yh=Ye(wt(at({pubkey:Ve,account:at({executable:Yr(),owner:Ve,lamports:q(),data:lo,rentEpoch:q()})}))),Zh=Ye(wt(at({lamports:q(),address:Ve}))),wi=at({executable:Yr(),owner:Ve,lamports:q(),data:co,rentEpoch:q()}),Jh=at({pubkey:Ve,account:wi}),Xh=fi(Sr([Ks(Ct.Buffer),lo]),Sr([yc,lo]),n=>Array.isArray(n)?yt(n,co):n),ho=at({executable:Yr(),owner:Ve,lamports:q(),data:Xh,rentEpoch:q()}),Qh=at({pubkey:Ve,account:ho}),t0=at({state:Sr([He("active"),He("inactive"),He("activating"),He("deactivating")]),active:q(),inactive:q()}),e0=ee(wt(at({signature:dt(),slot:q(),err:Cn,memo:bt(dt()),blockTime:Ot(bt(q()))}))),r0=ee(wt(at({signature:dt(),slot:q(),err:Cn,memo:bt(dt()),blockTime:Ot(bt(q()))}))),n0=at({subscription:q(),result:Zi(wi)}),i0=at({pubkey:Ve,account:wi}),s0=at({subscription:q(),result:Zi(i0)}),o0=at({parent:q(),slot:q(),root:q()}),a0=at({subscription:q(),result:o0}),c0=Sr([at({type:Sr([He("firstShredReceived"),He("completed"),He("optimisticConfirmation"),He("root")]),slot:q(),timestamp:q()}),at({type:He("createdBank"),parent:q(),slot:q(),timestamp:q()}),at({type:He("frozen"),slot:q(),timestamp:q(),stats:at({numTransactionEntries:q(),numSuccessfulTransactions:q(),numFailedTransactions:q(),maxTransactionsPerEntry:q()})}),at({type:He("dead"),slot:q(),timestamp:q(),err:dt()})]),u0=at({subscription:q(),result:c0}),f0=at({subscription:q(),result:Zi(Sr([Th,Mh]))}),l0=at({subscription:q(),result:q()}),h0=at({pubkey:dt(),gossip:bt(dt()),tpu:bt(dt()),rpc:bt(dt()),version:bt(dt())}),vc=at({votePubkey:dt(),nodePubkey:dt(),activatedStake:q(),epochVoteAccount:Yr(),epochCredits:wt(Ws([q(),q(),q()])),commission:q(),lastVote:q(),rootSlot:bt(q())}),d0=ee(at({current:wt(vc),delinquent:wt(vc)})),p0=Sr([He("processed"),He("confirmed"),He("finalized")]),g0=at({slot:q(),confirmations:bt(q()),err:Cn,confirmationStatus:Ot(p0)}),y0=Ye(wt(bt(g0))),m0=ee(q()),kc=at({accountKey:Ve,writableIndexes:wt(q()),readonlyIndexes:wt(q())}),po=at({signatures:wt(dt()),message:at({accountKeys:wt(dt()),header:at({numRequiredSignatures:q(),numReadonlySignedAccounts:q(),numReadonlyUnsignedAccounts:q()}),instructions:wt(at({accounts:wt(q()),data:dt(),programIdIndex:q()})),recentBlockhash:dt(),addressTableLookups:Ot(wt(kc))})}),Sc=at({pubkey:Ve,signer:Yr(),writable:Yr(),source:Ot(Sr([He("transaction"),He("lookupTable")]))}),Ec=at({accountKeys:wt(Sc),signatures:wt(dt())}),_c=at({parsed:Gn(),program:dt(),programId:Ve}),Ic=at({accounts:wt(Ve),data:dt(),programId:Ve}),w0=Sr([Ic,_c]),b0=Sr([at({parsed:Gn(),program:dt(),programId:dt()}),at({accounts:wt(dt()),data:dt(),programId:dt()})]),Ac=fi(w0,b0,n=>"accounts"in n?yt(n,Ic):yt(n,_c)),Bc=at({signatures:wt(dt()),message:at({accountKeys:wt(Sc),instructions:wt(Ac),recentBlockhash:dt(),addressTableLookups:Ot(bt(wt(kc)))})}),Ji=at({accountIndex:q(),mint:dt(),owner:Ot(dt()),uiTokenAmount:fo}),Rc=at({writable:wt(Ve),readonly:wt(Ve)}),Xi=at({err:Cn,fee:q(),innerInstructions:Ot(bt(wt(at({index:q(),instructions:wt(at({accounts:wt(q()),data:dt(),programIdIndex:q()}))})))),preBalances:wt(q()),postBalances:wt(q()),logMessages:Ot(bt(wt(dt()))),preTokenBalances:Ot(bt(wt(Ji))),postTokenBalances:Ot(bt(wt(Ji))),loadedAddresses:Ot(Rc),computeUnitsConsumed:Ot(q())}),go=at({err:Cn,fee:q(),innerInstructions:Ot(bt(wt(at({index:q(),instructions:wt(Ac)})))),preBalances:wt(q()),postBalances:wt(q()),logMessages:Ot(bt(wt(dt()))),preTokenBalances:Ot(bt(wt(Ji))),postTokenBalances:Ot(bt(wt(Ji))),loadedAddresses:Ot(Rc),computeUnitsConsumed:Ot(q())}),Xn=Sr([He(0),He("legacy")]),Ln=at({pubkey:dt(),lamports:q(),postBalance:bt(q()),rewardType:bt(dt()),commission:Ot(bt(q()))}),x0=ee(bt(at({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(at({transaction:po,meta:bt(Xi),version:Ot(Xn)})),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),v0=ee(bt(at({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),k0=ee(bt(at({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(at({transaction:Ec,meta:bt(Xi),version:Ot(Xn)})),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),S0=ee(bt(at({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(at({transaction:Bc,meta:bt(go),version:Ot(Xn)})),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),E0=ee(bt(at({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(at({transaction:Ec,meta:bt(go),version:Ot(Xn)})),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),_0=ee(bt(at({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),I0=ee(bt(at({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(at({transaction:po,meta:bt(Xi)})),rewards:Ot(wt(Ln)),blockTime:bt(q())}))),Tc=ee(bt(at({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),signatures:wt(dt()),blockTime:bt(q())}))),yo=ee(bt(at({slot:q(),meta:bt(Xi),blockTime:Ot(bt(q())),transaction:po,version:Ot(Xn)}))),Qi=ee(bt(at({slot:q(),transaction:Bc,meta:bt(go),blockTime:Ot(bt(q())),version:Ot(Xn)}))),A0=Ye(at({blockhash:dt(),feeCalculator:at({lamportsPerSignature:q()})})),B0=Ye(at({blockhash:dt(),lastValidBlockHeight:q()})),R0=Ye(Yr()),T0=at({slot:q(),numTransactions:q(),numSlots:q(),samplePeriodSecs:q()}),M0=ee(wt(T0)),P0=Ye(bt(at({feeCalculator:at({lamportsPerSignature:q()})}))),C0=ee(dt()),L0=ee(dt()),U0=at({err:Cn,logs:wt(dt()),signature:dt()}),O0=at({result:Zi(U0),subscription:q()}),N0={"solana-client":"js/1.0.0-maintenance"};class F0{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 y={};return async x=>{const{commitment:E,config:L}=Fe(x),C=this._buildArgs([],E,void 0,L),N=dc(C);return y[N]=y[N]??(async()=>{try{const M=await this._rpcRequest("getBlockHeight",C),O=yt(M,ee(q()));if("error"in O)throw new Rt(O.error,"failed to get block height information");return O.result}finally{delete y[N]}})(),await y[N]}})();let r,s,i,o,a,l;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,r=e.wsEndpoint,s=e.httpHeaders,i=e.fetch,o=e.fetchMiddleware,a=e.disableRetryOnRateLimit,l=e.httpAgent),this._rpcEndpoint=vh(t),this._rpcWsEndpoint=r||xh(t),this._rpcClient=Oh(t,s,i,o,a,l),this._rpcRequest=Nh(this._rpcClient),this._rpcBatchRequest=Fh(this._rpcClient),this._rpcWebSocket=new yh(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:r,config:s}=Fe(e),i=this._buildArgs([t.toBase58()],r,void 0,s),o=await this._rpcRequest("getBalance",i),a=yt(o,Ye(q()));if("error"in a)throw new Rt(a.error,`failed to get balance for ${t.toBase58()}`);return a.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(r=>r.value).catch(r=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+r)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),r=yt(e,ee(bt(q())));if("error"in r)throw new Rt(r.error,`failed to get block time for slot ${t}`);return r.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=yt(t,ee(q()));if("error"in e)throw new Rt(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=yt(t,Hh);if("error"in e)throw new Rt(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 r=await this._rpcRequest("getSupply",[e]),s=yt(r,Vh);if("error"in s)throw new Rt(s.error,"failed to get supply");return s.result}async getTokenSupply(t,e){const r=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenSupply",r),i=yt(s,Ye(fo));if("error"in i)throw new Rt(i.error,"failed to get token supply");return i.result}async getTokenAccountBalance(t,e){const r=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenAccountBalance",r),i=yt(s,Ye(fo));if("error"in i)throw new Rt(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(t,e,r){const{commitment:s,config:i}=Fe(r);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const a=this._buildArgs(o,s,"base64",i),l=await this._rpcRequest("getTokenAccountsByOwner",a),y=yt(l,Gh);if("error"in y)throw new Rt(y.error,`failed to get token accounts owned by account ${t.toBase58()}`);return y.result}async getParsedTokenAccountsByOwner(t,e,r){let s=[t.toBase58()];"mint"in e?s.push({mint:e.mint.toBase58()}):s.push({programId:e.programId.toBase58()});const i=this._buildArgs(s,r,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",i),a=yt(o,Yh);if("error"in a)throw new Rt(a.error,`failed to get token accounts owned by account ${t.toBase58()}`);return a.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},r=e.filter||e.commitment?[e]:[],s=await this._rpcRequest("getLargestAccounts",r),i=yt(s,Zh);if("error"in i)throw new Rt(i.error,"failed to get largest accounts");return i.result}async getTokenLargestAccounts(t,e){const r=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenLargestAccounts",r),i=yt(s,jh);if("error"in i)throw new Rt(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgs([t.toBase58()],r,"base64",s),o=await this._rpcRequest("getAccountInfo",i),a=yt(o,Ye(bt(wi)));if("error"in a)throw new Rt(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getParsedAccountInfo(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgs([t.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getAccountInfo",i),a=yt(o,Ye(bt(ho)));if("error"in a)throw new Rt(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(r){throw new Error("failed to get info about account "+t.toBase58()+": "+r)}}async getMultipleParsedAccounts(t,e){const{commitment:r,config:s}=Fe(e),i=t.map(y=>y.toBase58()),o=this._buildArgs([i],r,"jsonParsed",s),a=await this._rpcRequest("getMultipleAccounts",o),l=yt(a,Ye(wt(bt(ho))));if("error"in l)throw new Rt(l.error,`failed to get info for accounts ${i}`);return l.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:r,config:s}=Fe(e),i=t.map(y=>y.toBase58()),o=this._buildArgs([i],r,"base64",s),a=await this._rpcRequest("getMultipleAccounts",o),l=yt(a,Ye(wt(bt(wi))));if("error"in l)throw new Rt(l.error,`failed to get info for accounts ${i}`);return l.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,r){const{commitment:s,config:i}=Fe(e),o=this._buildArgs([t.toBase58()],s,void 0,{...i,epoch:r??(i==null?void 0:i.epoch)}),a=await this._rpcRequest("getStakeActivation",o),l=yt(a,ee(t0));if("error"in l)throw new Rt(l.error,`failed to get Stake Activation ${t.toBase58()}`);return l.result}async getProgramAccounts(t,e){const{commitment:r,config:s}=Fe(e),{encoding:i,...o}=s||{},a=this._buildArgs([t.toBase58()],r,i||"base64",{...o,...o.filters?{filters:wc(o.filters)}:null}),l=await this._rpcRequest("getProgramAccounts",a),y=wt(Jh),x=o.withContext===!0?yt(l,Ye(y)):yt(l,ee(y));if("error"in x)throw new Rt(x.error,`failed to get accounts owned by program ${t.toBase58()}`);return x.result}async getParsedProgramAccounts(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgs([t.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getProgramAccounts",i),a=yt(o,ee(wt(Qh)));if("error"in a)throw new Rt(a.error,`failed to get accounts owned by program ${t.toBase58()}`);return a.result}async confirmTransaction(t,e){var i;let r;if(typeof t=="string")r=t;else{const o=t;if((i=o.abortSignal)!=null&&i.aborted)return Promise.reject(o.abortSignal.reason);r=o.signature}let s;try{s=ar.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return xe(s.length===64,"signature has invalid length"),typeof t=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:r}):"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,r)=>{t!=null&&(t.aborted?r(t.reason):t.addEventListener("abort",()=>{r(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let r,s,i=!1;const o=new Promise((l,y)=>{try{r=this.onSignature(e,(E,L)=>{r=void 0;const C={context:L,value:E};l({__type:on.PROCESSED,response:C})},t);const x=new Promise(E=>{r==null?E():s=this._onSubscriptionStateChange(r,L=>{L==="subscribed"&&E()})});(async()=>{if(await x,i)return;const E=await this.getSignatureStatus(e);if(i||E==null)return;const{context:L,value:C}=E;if(C!=null)if(C!=null&&C.err)y(C.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(C.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(C.confirmationStatus==="processed"||C.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}i=!0,l({__type:on.PROCESSED,response:{context:L,value:C}})}})()}catch(x){y(x)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:r,signature:s}}){let i=!1;const o=new Promise(E=>{const L=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let C=await L();if(!i){for(;C<=r;)if(await Mn(1e3),i||(C=await L(),i))return;E({__type:on.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:t,signature:s}),y=this.getCancellationPromise(e);let x;try{const E=await Promise.race([y,l,o]);if(E.__type===on.PROCESSED)x=E.response;else throw new Xs(s)}finally{i=!0,a()}return x}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:r,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let a=!1;const l=new Promise(C=>{let N=i,M=null;const O=async()=>{try{const{context:K,value:Q}=await this.getNonceAndContext(s,{commitment:t,minContextSlot:r});return M=K.slot,Q==null?void 0:Q.nonce}catch{return N}};(async()=>{if(N=await O(),!a)for(;;){if(i!==N){C({__type:on.NONCE_INVALID,slotInWhichNonceDidAdvance:M});return}if(await Mn(2e3),a||(N=await O(),a))return}})()}),{abortConfirmation:y,confirmationPromise:x}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),E=this.getCancellationPromise(e);let L;try{const C=await Promise.race([E,x,l]);if(C.__type===on.PROCESSED)L=C.response;else{let N;for(;;){const M=await this.getSignatureStatus(o);if(M==null)break;if(M.context.slot<(C.slotInWhichNonceDidAdvance??r)){await Mn(400);continue}N=M;break}if(N!=null&&N.value){const M=t||"finalized",{confirmationStatus:O}=N.value;switch(M){case"processed":case"recent":if(O!=="processed"&&O!=="confirmed"&&O!=="finalized")throw new Yn(o);break;case"confirmed":case"single":case"singleGossip":if(O!=="confirmed"&&O!=="finalized")throw new Yn(o);break;case"finalized":case"max":case"root":if(O!=="finalized")throw new Yn(o);break;default:}L={context:N.context,value:{err:N.value.err}}}else throw new Yn(o)}}finally{a=!0,y()}return L}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let r;const s=new Promise(l=>{let y=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{y=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>l({__type:on.TIMED_OUT,timeoutMs:y}),y)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let a;try{const l=await Promise.race([o,s]);if(l.__type===on.PROCESSED)a=l.response;else throw new Qs(e,l.timeoutMs/1e3)}finally{clearTimeout(r),i()}return a}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=yt(t,ee(wt(h0)));if("error"in e)throw new Rt(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getVoteAccounts",e),s=yt(r,d0);if("error"in s)throw new Rt(s.error,"failed to get vote accounts");return s.result}async getSlot(t){const{commitment:e,config:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getSlot",s),o=yt(i,ee(q()));if("error"in o)throw new Rt(o.error,"failed to get slot");return o.result}async getSlotLeader(t){const{commitment:e,config:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getSlotLeader",s),o=yt(i,ee(dt()));if("error"in o)throw new Rt(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(t,e){const r=[t,e],s=await this._rpcRequest("getSlotLeaders",r),i=yt(s,ee(wt(Ve)));if("error"in i)throw new Rt(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(t,e){const{context:r,value:s}=await this.getSignatureStatuses([t],e);xe(s.length===1);const i=s[0];return{context:r,value:i}}async getSignatureStatuses(t,e){const r=[t];e&&r.push(e);const s=await this._rpcRequest("getSignatureStatuses",r),i=yt(s,y0);if("error"in i)throw new Rt(i.error,"failed to get signature status");return i.result}async getTransactionCount(t){const{commitment:e,config:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getTransactionCount",s),o=yt(i,ee(q()));if("error"in o)throw new Rt(o.error,"failed to get transaction count");return o.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getInflationGovernor",e),s=yt(r,zh);if("error"in s)throw new Rt(s.error,"failed to get inflation");return s.result}async getInflationReward(t,e,r){const{commitment:s,config:i}=Fe(r),o=this._buildArgs([t.map(y=>y.toBase58())],s,void 0,{...i,epoch:e??(i==null?void 0:i.epoch)}),a=await this._rpcRequest("getInflationReward",o),l=yt(a,Eh);if("error"in l)throw new Rt(l.error,"failed to get inflation reward");return l.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=yt(t,Kh);if("error"in e)throw new Rt(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getEpochInfo",s),o=yt(i,Dh);if("error"in o)throw new Rt(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=yt(t,$h);if("error"in e)throw new Rt(e.error,"failed to get epoch schedule");const r=e.result;return new pc(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=yt(t,qh);if("error"in e)throw new Rt(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const r=this._buildArgs([t],e),s=await this._rpcRequest("getMinimumBalanceForRentExemption",r),i=yt(s,m0);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result}async getRecentBlockhashAndContext(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getRecentBlockhash",e),s=yt(r,A0);if("error"in s)throw new Rt(s.error,"failed to get recent blockhash");return s.result}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),r=yt(e,M0);if("error"in r)throw new Rt(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(t,e){const r=this._buildArgs([t],e),s=await this._rpcRequest("getFeeCalculatorForBlockhash",r),i=yt(s,P0);if("error"in i)throw new Rt(i.error,"failed to get fee calculator");const{context:o,value:a}=i.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(t,e){const r=te(t.serialize()).toString("base64"),s=this._buildArgs([r],e),i=await this._rpcRequest("getFeeForMessage",s),o=yt(i,Ye(bt(q())));if("error"in o)throw new Rt(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(t){var o;const e=(o=t==null?void 0:t.lockedWritableAccounts)==null?void 0:o.map(a=>a.toBase58()),r=e!=null&&e.length?[e]:[],s=await this._rpcRequest("getRecentPrioritizationFees",r),i=yt(s,Wh);if("error"in i)throw new Rt(i.error,"failed to get recent prioritization fees");return i.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:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getLatestBlockhash",s),o=yt(i,B0);if("error"in o)throw new Rt(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgs([t],r,void 0,s),o=await this._rpcRequest("isBlockhashValid",i),a=yt(o,R0);if("error"in a)throw new Rt(a.error,"failed to determine if the blockhash `"+t+"`is valid");return a.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=yt(t,ee(Ph));if("error"in e)throw new Rt(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=yt(t,ee(dt()));if("error"in e)throw new Rt(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgsAtLeastConfirmed([t],r,void 0,s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=yt(o,k0);if("error"in a)throw a.error;return a.result}case"none":{const a=yt(o,v0);if("error"in a)throw a.error;return a.result}default:{const a=yt(o,x0);if("error"in a)throw a.error;const{result:l}=a;return l?{...l,transactions:l.transactions.map(({transaction:y,meta:x,version:E})=>({meta:x,transaction:{...y,message:uo(E,y.message)},version:E}))}:null}}}catch(a){throw new Rt(a,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=yt(o,E0);if("error"in a)throw a.error;return a.result}case"none":{const a=yt(o,_0);if("error"in a)throw a.error;return a.result}default:{const a=yt(o,S0);if("error"in a)throw a.error;return a.result}}}catch(a){throw new Rt(a,"failed to get block")}}async getBlockProduction(t){let e,r;if(typeof t=="string")r=t;else if(t){const{commitment:a,...l}=t;r=a,e=l}const s=this._buildArgs([],r,"base64",e),i=await this._rpcRequest("getBlockProduction",s),o=yt(i,Uh);if("error"in o)throw new Rt(o.error,"failed to get block production information");return o.result}async getTransaction(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgsAtLeastConfirmed([t],r,void 0,s),o=await this._rpcRequest("getTransaction",i),a=yt(o,yo);if("error"in a)throw new Rt(a.error,"failed to get transaction");const l=a.result;return l&&{...l,transaction:{...l.transaction,message:uo(l.version,l.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",s),o=await this._rpcRequest("getTransaction",i),a=yt(o,Qi);if("error"in a)throw new Rt(a.error,"failed to get transaction");return a.result}async getParsedTransactions(t,e){const{commitment:r,config:s}=Fe(e),i=t.map(l=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([l],r,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(l=>{const y=yt(l,Qi);if("error"in y)throw new Rt(y.error,"failed to get transactions");return y.result})}async getTransactions(t,e){const{commitment:r,config:s}=Fe(e),i=t.map(l=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([l],r,void 0,s)}));return(await this._rpcBatchRequest(i)).map(l=>{const y=yt(l,yo);if("error"in y)throw new Rt(y.error,"failed to get transactions");const x=y.result;return x&&{...x,transaction:{...x.transaction,message:uo(x.version,x.transaction.message)}}})}async getConfirmedBlock(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getConfirmedBlock",r),i=yt(s,I0);if("error"in i)throw new Rt(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");const a={...o,transactions:o.transactions.map(({transaction:l,meta:y})=>{const x=new Wr(l.message);return{meta:y,transaction:{...l,message:x}}})};return{...a,transactions:a.transactions.map(({transaction:l,meta:y})=>({meta:y,transaction:ye.populate(l.message,l.signatures)}))}}async getBlocks(t,e,r){const s=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],r),i=await this._rpcRequest("getBlocks",s),o=yt(i,ee(wt(q())));if("error"in o)throw new Rt(o.error,"failed to get blocks");return o.result}async getBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",r),i=yt(s,Tc);if("error"in i)throw new Rt(i.error,"failed to get block");const o=i.result;if(!o)throw new Error("Block "+t+" not found");return o}async getConfirmedBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getConfirmedBlock",r),i=yt(s,Tc);if("error"in i)throw new Rt(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");return o}async getConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getConfirmedTransaction",r),i=yt(s,yo);if("error"in i)throw new Rt(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const a=new Wr(o.transaction.message),l=o.transaction.signatures;return{...o,transaction:ye.populate(a,l)}}async getParsedConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),s=await this._rpcRequest("getConfirmedTransaction",r),i=yt(s,Qi);if("error"in i)throw new Rt(i.error,"failed to get confirmed transaction");return i.result}async getParsedConfirmedTransactions(t,e){const r=t.map(o=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const a=yt(o,Qi);if("error"in a)throw new Rt(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(t,e,r){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(e--,!(e<=0||e<i));)try{const l=await this.getConfirmedBlockSignatures(e,"finalized");l.signatures.length>0&&(s.until=l.signatures[l.signatures.length-1].toString())}catch(l){if(l instanceof Error&&l.message.includes("skipped"))continue;throw l}let o=await this.getSlot("finalized");for(;!("before"in s)&&(r++,!(r>o));)try{const l=await this.getConfirmedBlockSignatures(r);l.signatures.length>0&&(s.before=l.signatures[l.signatures.length-1].toString())}catch(l){if(l instanceof Error&&l.message.includes("skipped"))continue;throw l}return(await this.getConfirmedSignaturesForAddress2(t,s)).map(l=>l.signature)}async getConfirmedSignaturesForAddress2(t,e,r){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=yt(i,e0);if("error"in o)throw new Rt(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(t,e,r){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),i=await this._rpcRequest("getSignaturesForAddress",s),o=yt(i,r0);if("error"in o)throw new Rt(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(t,e){const{context:r,value:s}=await this.getAccountInfoAndContext(t,e);let i=null;return s!==null&&(i=new ao({key:t,state:ao.deserialize(s.data)})),{context:r,value:i}}async getNonceAndContext(t,e){const{context:r,value:s}=await this.getAccountInfoAndContext(t,e);let i=null;return s!==null&&(i=Yi.fromAccountData(s.data)),{context:r,value:i}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then(r=>r.value).catch(r=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+r)})}async requestAirdrop(t,e){const r=await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),s=yt(r,C0);if("error"in s)throw new Rt(s.error,`airdrop to ${t.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Mn(100);const r=Date.now()-this._blockhashInfo.lastFetch>=mc;if(this._blockhashInfo.latestBlockhash!==null&&!r)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,r=e?e.blockhash:null;for(let s=0;s<50;s++){const i=await this.getLatestBlockhash("finalized");if(r!==i.blockhash)return this._blockhashInfo={latestBlockhash:i,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},i;await Mn(uc/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:r}=Fe(t),s=this._buildArgs([],e,"base64",r),i=await this._rpcRequest("getStakeMinimumDelegation",s),o=yt(i,Ye(q()));if("error"in o)throw new Rt(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(t,e,r){if("message"in t){const M=t.serialize(),O=Ct.Buffer.from(M).toString("base64");if(Array.isArray(e)||r!==void 0)throw new Error("Invalid arguments");const K=e||{};K.encoding="base64","commitment"in K||(K.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(K.innerInstructions=e.innerInstructions);const Q=[O,K],V=await this._rpcRequest("simulateTransaction",Q),st=yt(V,xc);if("error"in st)throw new Error("failed to simulate transaction: "+st.error.message);return st.result}let s;if(t instanceof ye){let N=t;s=new ye,s.feePayer=N.feePayer,s.instructions=t.instructions,s.nonceInfo=N.nonceInfo,s.signatures=N.signatures}else s=ye.populate(t),s._message=s._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(s.nonceInfo&&i)s.sign(...i);else{let N=this._disableBlockhashCaching;for(;;){const M=await this._blockhashWithExpiryBlockHeight(N);if(s.lastValidBlockHeight=M.lastValidBlockHeight,s.recentBlockhash=M.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");const O=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(O)&&!this._blockhashInfo.transactionSignatures.includes(O)){this._blockhashInfo.simulatedSignatures.push(O);break}else N=!0}}const o=s._compile(),a=o.serialize(),y=s._serialize(a).toString("base64"),x={encoding:"base64",commitment:this.commitment};if(r){const N=(Array.isArray(r)?r:o.nonProgramIds()).map(M=>M.toBase58());x.accounts={encoding:"base64",addresses:N}}i&&(x.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(x.innerInstructions=e.innerInstructions);const E=[y,x],L=await this._rpcRequest("simulateTransaction",E),C=yt(L,xc);if("error"in C){let N;if("data"in C.error&&(N=C.error.data.logs,N&&Array.isArray(N))){const M=`
13
+ `,O=M+N.join(M);console.error(C.error.message,O)}throw new yi({action:"simulate",signature:"",transactionMessage:C.error.message,logs:N})}return C.result}async sendTransaction(t,e,r){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const o=t.serialize();return await this.sendRawTransaction(o,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(t.nonceInfo)t.sign(...s);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=a.lastValidBlockHeight,t.recentBlockhash=a.blockhash,t.sign(...s),!t.signature)throw new Error("!signature");const l=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(l))o=!0;else{this._blockhashInfo.transactionSignatures.push(l);break}}}const i=t.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(t,e){const r=te(t).toString("base64");return await this.sendEncodedTransaction(r,e)}async sendEncodedTransaction(t,e){const r={encoding:"base64"},s=e&&e.skipPreflight,i=s===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(r.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(r.minContextSlot=e.minContextSlot),s&&(r.skipPreflight=s),i&&(r.preflightCommitment=i);const o=[t,r],a=await this._rpcRequest("sendTransaction",o),l=yt(a,L0);if("error"in l){let y;throw"data"in l.error&&(y=l.error.data.logs),new yi({action:s?"send":"simulate",signature:"",transactionMessage:l.error.message,logs:y})}return l.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,r])=>{this._setSubscription(e,{...r,state:"pending"})})}_setSubscription(t,e){var s;const r=(s=this._subscriptionsByHash[t])==null?void 0:s.state;if(this._subscriptionsByHash[t]=e,r!==e.state){const i=this._subscriptionStateChangeCallbacksByHash[t];i&&i.forEach(o=>{try{o(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var i;const r=this._subscriptionHashByClientSubscriptionId[t];if(r==null)return()=>{};const s=(i=this._subscriptionStateChangeCallbacksByHash)[r]||(i[r]=new Set);return s.add(e),()=>{s.delete(e),s.size===0&&delete this._subscriptionStateChangeCallbacksByHash[r]}}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(r){r instanceof Error&&console.log(`Error when closing socket connection: ${r.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 r=>{const s=this._subscriptionsByHash[r];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[r],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:i,method:o}=s;try{this._setSubscription(r,{...s,state:"subscribing"});const a=await this._rpcWebSocket.call(o,i);this._setSubscription(r,{...s,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=s.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:a}),!e())return;this._setSubscription(r,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:i,unsubscribeMethod:o}=s;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(r,{...s,state:"unsubscribing"}),this._setSubscription(r,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[i])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!e())return;this._setSubscription(r,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const r=this._subscriptionCallbacksByServerSubscriptionId[t];r!==void 0&&r.forEach(s=>{try{s(...e)}catch(i){console.error(i)}})}_wsOnAccountNotification(t){const{result:e,subscription:r}=yt(t,n0);this._handleServerNotification(r,[e.value,e.context])}_makeSubscription(t,e){const r=this._nextClientSubscriptionId++,s=dc([t.method,e]),i=this._subscriptionsByHash[s];return i===void 0?this._subscriptionsByHash[s]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:i.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[r]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const o=this._subscriptionsByHash[s];xe(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),o.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(t,e,r){const{commitment:s,config:i}=Fe(r),o=this._buildArgs([t.toBase58()],s||this._commitment||"finalized","base64",i);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:r}=yt(t,s0);this._handleServerNotification(r,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,r,s){const{commitment:i,config:o}=Fe(r),a=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:wc(s)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,r){const s=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],r||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:r}=yt(t,O0);this._handleServerNotification(r,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:r}=yt(t,a0);this._handleServerNotification(r,[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:r}=yt(t,u0);this._handleServerNotification(r,[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 r=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,r,s){const i=e||this._commitment;if(i||r||s){let o={};r&&(o.encoding=r),i&&(o.commitment=i),s&&(o=Object.assign(o,s)),t.push(o)}return t}_buildArgsAtLeastConfirmed(t,e,r,s){const i=e||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,r,s)}_wsOnSignatureNotification(t){const{result:e,subscription:r}=yt(t,f0);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,r){const s=this._buildArgs([t],r||this._commitment||"finalized"),i=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){e(o.result,a);try{this.removeSignatureListener(i)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return i}onSignatureWithOptions(t,e,r){const{commitment:s,...i}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([t],s,void 0,i),a=this._makeSubscription({callback:(l,y)=>{e(l,y);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:r}=yt(t,l0);this._handleServerNotification(r,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}class Un{constructor(t){this._keypair=void 0,this._keypair=t??rc()}static generate(){return new Un(rc())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");const r=t.slice(32,64);if(!e||!e.skipValidation){const s=t.slice(0,32),i=qi(s);for(let o=0;o<32;o++)if(r[o]!==i[o])throw new Error("provided secretKey is invalid")}return new Un({publicKey:r,secretKey:t})}static fromSeed(t){const e=qi(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),new Un({publicKey:e,secretKey:r})}get publicKey(){return new gt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const an=Object.freeze({CreateLookupTable:{index:0,layout:At([It("instruction"),Jn("recentSlot"),ge("bumpSeed")])},FreezeLookupTable:{index:1,layout:At([It("instruction")])},ExtendLookupTable:{index:2,layout:At([It("instruction"),Jn(),dr(oe(),pn(It(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:At([It("instruction")])},CloseLookupTable:{index:4,layout:At([It("instruction")])}});class z0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=It("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(an))if(o.index==r){s=i;break}if(!s)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return s}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=Ee(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}=Ee(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(r=>new gt(r))}}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(mo.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 mo{constructor(){}static createLookupTable(t){const[e,r]=gt.findProgramAddressSync([t.authority.toBuffer(),Ma(BigInt(t.recentSlot),8)],this.programId),s=an.CreateLookupTable,i=fe(s,{recentSlot:BigInt(t.recentSlot),bumpSeed:r}),o=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:cr.programId,isSigner:!1,isWritable:!1}];return[new Ue({programId:this.programId,keys:o,data:i}),e]}static freezeLookupTable(t){const e=an.FreezeLookupTable,r=fe(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ue({programId:this.programId,keys:s,data:r})}static extendLookupTable(t){const e=an.ExtendLookupTable,r=fe(e,{addresses:t.addresses.map(i=>i.toBytes())}),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&s.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:cr.programId,isSigner:!1,isWritable:!1}),new Ue({programId:this.programId,keys:s,data:r})}static deactivateLookupTable(t){const e=an.DeactivateLookupTable,r=fe(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ue({programId:this.programId,keys:s,data:r})}static closeLookupTable(t){const e=an.CloseLookupTable,r=fe(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Ue({programId:this.programId,keys:s,data:r})}}mo.programId=new gt("AddressLookupTab1e1111111111111111111111111");class K0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=ge("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(Qr))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return s}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:r}=Ee(Qr.RequestUnits,t.data);return{units:e,additionalFee:r}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Ee(Qr.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Ee(Qr.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Ee(Qr.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(wo.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Qr=Object.freeze({RequestUnits:{index:0,layout:At([ge("instruction"),It("units"),It("additionalFee")])},RequestHeapFrame:{index:1,layout:At([ge("instruction"),It("bytes")])},SetComputeUnitLimit:{index:2,layout:At([ge("instruction"),It("units")])},SetComputeUnitPrice:{index:3,layout:At([ge("instruction"),Jn("microLamports")])}});class wo{constructor(){}static requestUnits(t){const e=Qr.RequestUnits,r=fe(e,t);return new Ue({keys:[],programId:this.programId,data:r})}static requestHeapFrame(t){const e=Qr.RequestHeapFrame,r=fe(e,t);return new Ue({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(t){const e=Qr.SetComputeUnitLimit,r=fe(e,t);return new Ue({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(t){const e=Qr.SetComputeUnitPrice,r=fe(e,{microLamports:BigInt(t.microLamports)});return new Ue({keys:[],programId:this.programId,data:r})}}wo.programId=new gt("ComputeBudget111111111111111111111111111111");const Mc=64,Pc=32,Cc=64,Lc=At([ge("numSignatures"),ge("padding"),Lr("signatureOffset"),Lr("signatureInstructionIndex"),Lr("publicKeyOffset"),Lr("publicKeyInstructionIndex"),Lr("messageDataOffset"),Lr("messageDataSize"),Lr("messageInstructionIndex")]);class ts{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:s,instructionIndex:i}=t;xe(e.length===Pc,`Public Key must be ${Pc} bytes but received ${e.length} bytes`),xe(s.length===Cc,`Signature must be ${Cc} bytes but received ${s.length} bytes`);const o=Lc.span,a=o+e.length,l=a+s.length,y=1,x=Ct.Buffer.alloc(l+r.length),E=i??65535;return Lc.encode({numSignatures:y,padding:0,signatureOffset:a,signatureInstructionIndex:E,publicKeyOffset:o,publicKeyInstructionIndex:E,messageDataOffset:l,messageDataSize:r.length,messageInstructionIndex:E},x),x.fill(e,o),x.fill(s,a),x.fill(r,l),new Ue({keys:[],programId:ts.programId,data:x})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:s}=t;xe(e.length===Mc,`Private key must be ${Mc} bytes but received ${e.length} bytes`);try{const i=Un.fromSecretKey(e),o=i.publicKey.toBytes(),a=Zs(r,i.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:a,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}ts.programId=new gt("Ed25519SigVerify111111111111111111111111111");const W0=(n,t)=>{const e=$i.sign(n,t);return[e.toCompactRawBytes(),e.recovery]};$i.utils.isValidPrivateKey;const D0=$i.getPublicKey,Uc=32,bo=20,Oc=64,$0=11,xo=At([ge("numSignatures"),Lr("signatureOffset"),ge("signatureInstructionIndex"),Lr("ethAddressOffset"),ge("ethAddressInstructionIndex"),Lr("messageDataOffset"),Lr("messageDataSize"),ge("messageInstructionIndex"),Ke(20,"ethAddress"),Ke(64,"signature"),ge("recoveryId")]);class Qn{constructor(){}static publicKeyToEthAddress(t){xe(t.length===Oc,`Public key must be ${Oc} bytes but received ${t.length} bytes`);try{return Ct.Buffer.from(Ya(te(t))).slice(-bo)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:s,recoveryId:i,instructionIndex:o}=t;return Qn.createInstructionWithEthAddress({ethAddress:Qn.publicKeyToEthAddress(e),message:r,signature:s,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:r,signature:s,recoveryId:i,instructionIndex:o=0}=t;let a;typeof e=="string"?e.startsWith("0x")?a=Ct.Buffer.from(e.substr(2),"hex"):a=Ct.Buffer.from(e,"hex"):a=e,xe(a.length===bo,`Address must be ${bo} bytes but received ${a.length} bytes`);const l=1+$0,y=l,x=l+a.length,E=x+s.length+1,L=1,C=Ct.Buffer.alloc(xo.span+r.length);return xo.encode({numSignatures:L,signatureOffset:x,signatureInstructionIndex:o,ethAddressOffset:y,ethAddressInstructionIndex:o,messageDataOffset:E,messageDataSize:r.length,messageInstructionIndex:o,signature:te(s),ethAddress:te(a),recoveryId:i},C),C.fill(te(r),xo.span),new Ue({keys:[],programId:Qn.programId,data:C})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:s}=t;xe(e.length===Uc,`Private key must be ${Uc} bytes but received ${e.length} bytes`);try{const i=te(e),o=D0(i,!1).slice(1),a=Ct.Buffer.from(Ya(te(r))),[l,y]=W0(a,i);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:l,recoveryId:y,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Qn.programId=new gt("KeccakSecp256k11111111111111111111111111111");var Nc;const Fc=new gt("StakeConfig11111111111111111111111111111111");class zc{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class bi{constructor(t,e,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=r}}Nc=bi,bi.default=new Nc(0,0,gt.default);class q0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=It("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(ur))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a StakeInstruction");return s}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:r}=Ee(ur.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new zc(new gt(e.staker),new gt(e.withdrawer)),lockup:new bi(r.unixTimestamp,r.epoch,new gt(r.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),Ee(ur.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:r}=Ee(ur.Authorize,t.data),s={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new gt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(s.custodianPubkey=t.keys[3].pubkey),s}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:r,authoritySeed:s,authorityOwner:i}=Ee(ur.AuthorizeWithSeed,t.data),o={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:s,authorityOwner:new gt(i),newAuthorizedPubkey:new gt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(o.custodianPubkey=t.keys[3].pubkey),o}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ee(ur.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),Ee(ur.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}=Ee(ur.Withdraw,t.data),r={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(r.custodianPubkey=t.keys[5].pubkey),r}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ee(ur.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(es.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 ur=Object.freeze({Initialize:{index:0,layout:At([It("instruction"),Yl(),Zl()])},Authorize:{index:1,layout:At([It("instruction"),oe("newAuthorized"),It("stakeAuthorizationType")])},Delegate:{index:2,layout:At([It("instruction")])},Split:{index:3,layout:At([It("instruction"),Tr("lamports")])},Withdraw:{index:4,layout:At([It("instruction"),Tr("lamports")])},Deactivate:{index:5,layout:At([It("instruction")])},Merge:{index:7,layout:At([It("instruction")])},AuthorizeWithSeed:{index:8,layout:At([It("instruction"),oe("newAuthorized"),It("stakeAuthorizationType"),Rn("authoritySeed"),oe("authorityOwner")])}}),H0=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class es{constructor(){}static initialize(t){const{stakePubkey:e,authorized:r,lockup:s}=t,i=s||bi.default,o=ur.Initialize,a=fe(o,{authorized:{staker:te(r.staker.toBuffer()),withdrawer:te(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:te(i.custodian.toBuffer())}}),l={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new Ue(l)}static createAccountWithSeed(t){const e=new ye;e.add(cr.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=t;return e.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static createAccount(t){const e=new ye;e.add(cr.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=t;return e.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:r,votePubkey:s}=t,i=ur.Delegate,o=fe(i);return new ye().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:Gi,isSigner:!1,isWritable:!1},{pubkey:Fc,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(t){const{stakePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:s,stakeAuthorizationType:i,custodianPubkey:o}=t,a=ur.Authorize,l=fe(a,{newAuthorized:te(s.toBuffer()),stakeAuthorizationType:i.index}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&y.push({pubkey:o,isSigner:!0,isWritable:!1}),new ye().add({keys:y,programId:this.programId,data:l})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:r,authoritySeed:s,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:l}=t,y=ur.AuthorizeWithSeed,x=fe(y,{newAuthorized:te(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:s,authorityOwner:te(i.toBuffer())}),E=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:Xr,isSigner:!1,isWritable:!1}];return l&&E.push({pubkey:l,isSigner:!0,isWritable:!1}),new ye().add({keys:E,programId:this.programId,data:x})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:r,splitStakePubkey:s,lamports:i}=t,o=ur.Split,a=fe(o,{lamports:i});return new Ue({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(t,e){const r=new ye;return r.add(cr.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:e,space:this.space,programId:this.programId})),r.add(this.splitInstruction(t))}static splitWithSeed(t,e){const{stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,basePubkey:o,seed:a,lamports:l}=t,y=new ye;return y.add(cr.allocate({accountPubkey:i,basePubkey:o,seed:a,space:this.space,programId:this.programId})),e&&e>0&&y.add(cr.transfer({fromPubkey:t.authorizedPubkey,toPubkey:i,lamports:e})),y.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,lamports:l}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:r,authorizedPubkey:s}=t,i=ur.Merge,o=fe(i);return new ye().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:Gi,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:r,toPubkey:s,lamports:i,custodianPubkey:o}=t,a=ur.Withdraw,l=fe(a,{lamports:i}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:Gi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&y.push({pubkey:o,isSigner:!0,isWritable:!1}),new ye().add({keys:y,programId:this.programId,data:l})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:r}=t,s=ur.Deactivate,i=fe(s);return new ye().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}es.programId=new gt("Stake11111111111111111111111111111111111111"),es.space=200;class Kc{constructor(t,e,r,s){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=r,this.commission=s}}class V0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=It("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(tn))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a VoteInstruction");return s}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=Ee(tn.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new Kc(new gt(e.nodePubkey),new gt(e.authorizedVoter),new gt(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:r}=Ee(tn.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new gt(e),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:r,newAuthorized:s,voteAuthorizationType:i}}=Ee(tn.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new gt(e),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new gt(s),voteAuthorizationType:{index:i},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ee(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(ti.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:At([It("instruction"),Jl()])},Authorize:{index:1,layout:At([It("instruction"),oe("newAuthorized"),It("voteAuthorizationType")])},Withdraw:{index:3,layout:At([It("instruction"),Tr("lamports")])},UpdateValidatorIdentity:{index:4,layout:At([It("instruction")])},AuthorizeWithSeed:{index:10,layout:At([It("instruction"),Xl()])}}),j0=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class ti{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:r,voteInit:s}=t,i=tn.InitializeAccount,o=fe(i,{voteInit:{nodePubkey:te(s.nodePubkey.toBuffer()),authorizedVoter:te(s.authorizedVoter.toBuffer()),authorizedWithdrawer:te(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),a={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Ue(a)}static createAccount(t){const e=new ye;return e.add(cr.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:r,newAuthorizedPubkey:s,voteAuthorizationType:i}=t,o=tn.Authorize,a=fe(o,{newAuthorized:te(s.toBuffer()),voteAuthorizationType:i.index}),l=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new ye().add({keys:l,programId:this.programId,data:a})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:a}=t,l=tn.AuthorizeWithSeed,y=fe(l,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:te(r.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:te(i.toBuffer()),voteAuthorizationType:o.index}}),x=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new ye().add({keys:x,programId:this.programId,data:y})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,lamports:s,toPubkey:i}=t,o=tn.Withdraw,a=fe(o,{lamports:s}),l=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new ye().add({keys:l,programId:this.programId,data:a})}static safeWithdraw(t,e,r){if(t.lamports>e-r)throw new Error("Withdraw will leave vote account with insufficient funds.");return ti.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,nodePubkey:s}=t,i=tn.UpdateValidatorIdentity,o=fe(i),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new ye().add({keys:a,programId:this.programId,data:o})}}ti.programId=new gt("Vote111111111111111111111111111111111111111"),ti.space=3762;const Wc=new gt("Va1idator1nfo111111111111111111111111111111"),G0=at({name:dt(),website:Ot(dt()),details:Ot(dt()),iconUrl:Ot(dt()),keybaseUsername:Ot(dt())});class vo{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 s=[];for(let i=0;i<2;i++){const o=new gt(Ir(e,0,Zr)),a=Jr(e)===1;s.push({publicKey:o,isSigner:a})}if(s[0].publicKey.equals(Wc)&&s[1].isSigner){const i=Rn().decode(Ct.Buffer.from(e)),o=JSON.parse(i);return Ca(o,G0),new vo(s[1].publicKey,o)}return null}}const Y0=new gt("Vote111111111111111111111111111111111111111"),Z0=At([oe("nodePubkey"),oe("authorizedWithdrawer"),ge("commission"),hr(),dr(At([hr("slot"),It("confirmationCount")]),pn(It(),-8),"votes"),ge("rootSlotValid"),hr("rootSlot"),hr(),dr(At([hr("epoch"),oe("authorizedVoter")]),pn(It(),-8),"authorizedVoters"),At([dr(At([oe("authorizedPubkey"),hr("epochOfLastAuthorizedSwitch"),hr("targetEpoch")]),32,"buf"),hr("idx"),ge("isEmpty")],"priorVoters"),hr(),dr(At([hr("epoch"),hr("credits"),hr("prevCredits")]),pn(It(),-8),"epochCredits"),At([hr("slot"),hr("timestamp")],"lastTimestamp")]);class ko{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 r=Z0.decode(te(t),4);let s=r.rootSlot;return r.rootSlotValid||(s=null),new ko({nodePubkey:new gt(r.nodePubkey),authorizedWithdrawer:new gt(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:s,authorizedVoters:r.authorizedVoters.map(J0),priorVoters:X0(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function J0({authorizedVoter:n,epoch:t}){return{epoch:t,authorizedVoter:new gt(n)}}function Dc({authorizedPubkey:n,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new gt(n),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function X0({buf:n,idx:t,isEmpty:e}){return e?[]:[...n.slice(t+1).map(Dc),...n.slice(0,t).map(Dc)]}const $c={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 Q0(n,t){const e=t===!1?"http":"https";if(!n)return $c[e].devnet;const r=$c[e][n];if(!r)throw new Error(`Unknown ${e} cluster: ${n}`);return r}async function td(n,t,e,r){let s,i;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(s=e,i=r):i=e;const o=i&&{skipPreflight:i.skipPreflight,preflightCommitment:i.preflightCommitment||i.commitment,minContextSlot:i.minContextSlot},a=await n.sendRawTransaction(t,o),l=i&&i.commitment,x=(await(s?n.confirmTransaction(s,l):n.confirmTransaction(a,l))).value;if(x.err)throw a!=null?new yi({action:o!=null&&o.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(x)})`}):new Error(`Raw transaction ${a} failed (${JSON.stringify(x)})`);return a}const rs=Object.freeze(Object.defineProperty({__proto__:null,Account:Vl,AddressLookupTableAccount:ao,AddressLookupTableInstruction:z0,AddressLookupTableProgram:mo,Authorized:zc,BLOCKHASH_CACHE_TIMEOUT_MS:mc,BPF_LOADER_DEPRECATED_PROGRAM_ID:jl,BPF_LOADER_PROGRAM_ID:uh,BpfLoader:fh,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Qr,ComputeBudgetInstruction:K0,ComputeBudgetProgram:wo,Connection:F0,Ed25519Program:ts,Enum:ql,EpochSchedule:pc,FeeCalculatorLayout:fc,Keypair:Un,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:an,Loader:Pn,Lockup:bi,MAX_SEED_LENGTH:sc,Message:Wr,MessageAccountKeys:gi,MessageV0:Tn,NONCE_ACCOUNT_LENGTH:io,NonceAccount:Yi,PACKET_DATA_SIZE:yn,PUBLIC_KEY_LENGTH:Zr,PublicKey:gt,SIGNATURE_LENGTH_IN_BYTES:pi,SOLANA_SCHEMA:di,STAKE_CONFIG_ID:Fc,STAKE_INSTRUCTION_LAYOUTS:ur,SYSTEM_INSTRUCTION_LAYOUTS:Ne,SYSVAR_CLOCK_PUBKEY:Xr,SYSVAR_EPOCH_SCHEDULE_PUBKEY:th,SYSVAR_INSTRUCTIONS_PUBKEY:eh,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:ji,SYSVAR_RENT_PUBKEY:Zn,SYSVAR_REWARDS_PUBKEY:rh,SYSVAR_SLOT_HASHES_PUBKEY:nh,SYSVAR_SLOT_HISTORY_PUBKEY:ih,SYSVAR_STAKE_HISTORY_PUBKEY:Gi,Secp256k1Program:Qn,SendTransactionError:yi,SolanaJSONRPCError:Rt,SolanaJSONRPCErrorCode:sh,StakeAuthorizationLayout:H0,StakeInstruction:q0,StakeProgram:es,Struct:Js,SystemInstruction:ah,SystemProgram:cr,Transaction:ye,TransactionExpiredBlockheightExceededError:Xs,TransactionExpiredNonceInvalidError:Yn,TransactionExpiredTimeoutError:Qs,TransactionInstruction:Ue,TransactionMessage:eo,TransactionStatus:on,VALIDATOR_INFO_KEY:Wc,VERSION_PREFIX_MASK:Hi,VOTE_PROGRAM_ID:Y0,ValidatorInfo:vo,VersionedMessage:to,VersionedTransaction:ro,VoteAccount:ko,VoteAuthorizationLayout:j0,VoteInit:Kc,VoteInstruction:V0,VoteProgram:ti,clusterApiUrl:Q0,sendAndConfirmRawTransaction:td,sendAndConfirmTransaction:no},Symbol.toStringTag,{value:"Module"})),Dr=ar;var So={exports:{}};So.exports,function(n){var t=function(){var e=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function o(l,y){if(!i[l]){i[l]={};for(var x=0;x<l.length;x++)i[l][l.charAt(x)]=x}return i[l][y]}var a={compressToBase64:function(l){if(l==null)return"";var y=a._compress(l,6,function(x){return r.charAt(x)});switch(y.length%4){default:case 0:return y;case 1:return y+"===";case 2:return y+"==";case 3:return y+"="}},decompressFromBase64:function(l){return l==null?"":l==""?null:a._decompress(l.length,32,function(y){return o(r,l.charAt(y))})},compressToUTF16:function(l){return l==null?"":a._compress(l,15,function(y){return e(y+32)})+" "},decompressFromUTF16:function(l){return l==null?"":l==""?null:a._decompress(l.length,16384,function(y){return l.charCodeAt(y)-32})},compressToUint8Array:function(l){for(var y=a.compress(l),x=new Uint8Array(y.length*2),E=0,L=y.length;E<L;E++){var C=y.charCodeAt(E);x[E*2]=C>>>8,x[E*2+1]=C%256}return x},decompressFromUint8Array:function(l){if(l==null)return a.decompress(l);for(var y=new Array(l.length/2),x=0,E=y.length;x<E;x++)y[x]=l[x*2]*256+l[x*2+1];var L=[];return y.forEach(function(C){L.push(e(C))}),a.decompress(L.join(""))},compressToEncodedURIComponent:function(l){return l==null?"":a._compress(l,6,function(y){return s.charAt(y)})},decompressFromEncodedURIComponent:function(l){return l==null?"":l==""?null:(l=l.replace(/ /g,"+"),a._decompress(l.length,32,function(y){return o(s,l.charAt(y))}))},compress:function(l){return a._compress(l,16,function(y){return e(y)})},_compress:function(l,y,x){if(l==null)return"";var E,L,C={},N={},M="",O="",K="",Q=2,V=3,st=2,J=[],D=0,tt=0,nt;for(nt=0;nt<l.length;nt+=1)if(M=l.charAt(nt),Object.prototype.hasOwnProperty.call(C,M)||(C[M]=V++,N[M]=!0),O=K+M,Object.prototype.hasOwnProperty.call(C,O))K=O;else{if(Object.prototype.hasOwnProperty.call(N,K)){if(K.charCodeAt(0)<256){for(E=0;E<st;E++)D=D<<1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++;for(L=K.charCodeAt(0),E=0;E<8;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1}else{for(L=1,E=0;E<st;E++)D=D<<1|L,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=0;for(L=K.charCodeAt(0),E=0;E<16;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1}Q--,Q==0&&(Q=Math.pow(2,st),st++),delete N[K]}else for(L=C[K],E=0;E<st;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1;Q--,Q==0&&(Q=Math.pow(2,st),st++),C[O]=V++,K=String(M)}if(K!==""){if(Object.prototype.hasOwnProperty.call(N,K)){if(K.charCodeAt(0)<256){for(E=0;E<st;E++)D=D<<1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++;for(L=K.charCodeAt(0),E=0;E<8;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1}else{for(L=1,E=0;E<st;E++)D=D<<1|L,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=0;for(L=K.charCodeAt(0),E=0;E<16;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1}Q--,Q==0&&(Q=Math.pow(2,st),st++),delete N[K]}else for(L=C[K],E=0;E<st;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1;Q--,Q==0&&(Q=Math.pow(2,st),st++)}for(L=2,E=0;E<st;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1;for(;;)if(D=D<<1,tt==y-1){J.push(x(D));break}else tt++;return J.join("")},decompress:function(l){return l==null?"":l==""?null:a._decompress(l.length,32768,function(y){return l.charCodeAt(y)})},_decompress:function(l,y,x){var E=[],L=4,C=4,N=3,M="",O=[],K,Q,V,st,J,D,tt,nt={val:x(0),position:y,index:1};for(K=0;K<3;K+=1)E[K]=K;for(V=0,J=Math.pow(2,2),D=1;D!=J;)st=nt.val&nt.position,nt.position>>=1,nt.position==0&&(nt.position=y,nt.val=x(nt.index++)),V|=(st>0?1:0)*D,D<<=1;switch(V){case 0:for(V=0,J=Math.pow(2,8),D=1;D!=J;)st=nt.val&nt.position,nt.position>>=1,nt.position==0&&(nt.position=y,nt.val=x(nt.index++)),V|=(st>0?1:0)*D,D<<=1;tt=e(V);break;case 1:for(V=0,J=Math.pow(2,16),D=1;D!=J;)st=nt.val&nt.position,nt.position>>=1,nt.position==0&&(nt.position=y,nt.val=x(nt.index++)),V|=(st>0?1:0)*D,D<<=1;tt=e(V);break;case 2:return""}for(E[3]=tt,Q=tt,O.push(tt);;){if(nt.index>l)return"";for(V=0,J=Math.pow(2,N),D=1;D!=J;)st=nt.val&nt.position,nt.position>>=1,nt.position==0&&(nt.position=y,nt.val=x(nt.index++)),V|=(st>0?1:0)*D,D<<=1;switch(tt=V){case 0:for(V=0,J=Math.pow(2,8),D=1;D!=J;)st=nt.val&nt.position,nt.position>>=1,nt.position==0&&(nt.position=y,nt.val=x(nt.index++)),V|=(st>0?1:0)*D,D<<=1;E[C++]=e(V),tt=C-1,L--;break;case 1:for(V=0,J=Math.pow(2,16),D=1;D!=J;)st=nt.val&nt.position,nt.position>>=1,nt.position==0&&(nt.position=y,nt.val=x(nt.index++)),V|=(st>0?1:0)*D,D<<=1;E[C++]=e(V),tt=C-1,L--;break;case 2:return O.join("")}if(L==0&&(L=Math.pow(2,N),N++),E[tt])M=E[tt];else if(tt===C)M=Q+Q.charAt(0);else return null;O.push(M),E[C++]=Q+M.charAt(0),L--,Q=M,L==0&&(L=Math.pow(2,N),N++)}}};return a}();n!=null?n.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})}(So);var ed=So.exports;const $r=ni(ed);function rd(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var qc={exports:{}};(function(n){(function(t){var e=function(g){var b,v=new Float64Array(16);if(g)for(b=0;b<g.length;b++)v[b]=g[b];return v},r=function(){throw new Error("no PRNG")},s=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var o=e(),a=e([1]),l=e([56129,1]),y=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),x=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),E=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),L=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),C=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function N(g,b,v,c){g[b]=v>>24&255,g[b+1]=v>>16&255,g[b+2]=v>>8&255,g[b+3]=v&255,g[b+4]=c>>24&255,g[b+5]=c>>16&255,g[b+6]=c>>8&255,g[b+7]=c&255}function M(g,b,v,c,S){var W,z=0;for(W=0;W<S;W++)z|=g[b+W]^v[c+W];return(1&z-1>>>8)-1}function O(g,b,v,c){return M(g,b,v,c,16)}function K(g,b,v,c){return M(g,b,v,c,32)}function Q(g,b,v,c){for(var S=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,W=v[0]&255|(v[1]&255)<<8|(v[2]&255)<<16|(v[3]&255)<<24,z=v[4]&255|(v[5]&255)<<8|(v[6]&255)<<16|(v[7]&255)<<24,X=v[8]&255|(v[9]&255)<<8|(v[10]&255)<<16|(v[11]&255)<<24,lt=v[12]&255|(v[13]&255)<<8|(v[14]&255)<<16|(v[15]&255)<<24,pt=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,ht=b[0]&255|(b[1]&255)<<8|(b[2]&255)<<16|(b[3]&255)<<24,ae=b[4]&255|(b[5]&255)<<8|(b[6]&255)<<16|(b[7]&255)<<24,vt=b[8]&255|(b[9]&255)<<8|(b[10]&255)<<16|(b[11]&255)<<24,Ft=b[12]&255|(b[13]&255)<<8|(b[14]&255)<<16|(b[15]&255)<<24,Kt=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,Vt=v[16]&255|(v[17]&255)<<8|(v[18]&255)<<16|(v[19]&255)<<24,qt=v[20]&255|(v[21]&255)<<8|(v[22]&255)<<16|(v[23]&255)<<24,Wt=v[24]&255|(v[25]&255)<<8|(v[26]&255)<<16|(v[27]&255)<<24,$t=v[28]&255|(v[29]&255)<<8|(v[30]&255)<<16|(v[31]&255)<<24,Dt=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,St=S,Bt=W,xt=z,Et=X,_t=lt,mt=pt,j=ht,G=ae,ot=vt,rt=Ft,it=Kt,ut=Vt,Ut=qt,Zt=Wt,Xt=$t,Jt=Dt,P,ie=0;ie<20;ie+=2)P=St+Ut|0,_t^=P<<7|P>>>25,P=_t+St|0,ot^=P<<9|P>>>23,P=ot+_t|0,Ut^=P<<13|P>>>19,P=Ut+ot|0,St^=P<<18|P>>>14,P=mt+Bt|0,rt^=P<<7|P>>>25,P=rt+mt|0,Zt^=P<<9|P>>>23,P=Zt+rt|0,Bt^=P<<13|P>>>19,P=Bt+Zt|0,mt^=P<<18|P>>>14,P=it+j|0,Xt^=P<<7|P>>>25,P=Xt+it|0,xt^=P<<9|P>>>23,P=xt+Xt|0,j^=P<<13|P>>>19,P=j+xt|0,it^=P<<18|P>>>14,P=Jt+ut|0,Et^=P<<7|P>>>25,P=Et+Jt|0,G^=P<<9|P>>>23,P=G+Et|0,ut^=P<<13|P>>>19,P=ut+G|0,Jt^=P<<18|P>>>14,P=St+Et|0,Bt^=P<<7|P>>>25,P=Bt+St|0,xt^=P<<9|P>>>23,P=xt+Bt|0,Et^=P<<13|P>>>19,P=Et+xt|0,St^=P<<18|P>>>14,P=mt+_t|0,j^=P<<7|P>>>25,P=j+mt|0,G^=P<<9|P>>>23,P=G+j|0,_t^=P<<13|P>>>19,P=_t+G|0,mt^=P<<18|P>>>14,P=it+rt|0,ut^=P<<7|P>>>25,P=ut+it|0,ot^=P<<9|P>>>23,P=ot+ut|0,rt^=P<<13|P>>>19,P=rt+ot|0,it^=P<<18|P>>>14,P=Jt+Xt|0,Ut^=P<<7|P>>>25,P=Ut+Jt|0,Zt^=P<<9|P>>>23,P=Zt+Ut|0,Xt^=P<<13|P>>>19,P=Xt+Zt|0,Jt^=P<<18|P>>>14;St=St+S|0,Bt=Bt+W|0,xt=xt+z|0,Et=Et+X|0,_t=_t+lt|0,mt=mt+pt|0,j=j+ht|0,G=G+ae|0,ot=ot+vt|0,rt=rt+Ft|0,it=it+Kt|0,ut=ut+Vt|0,Ut=Ut+qt|0,Zt=Zt+Wt|0,Xt=Xt+$t|0,Jt=Jt+Dt|0,g[0]=St>>>0&255,g[1]=St>>>8&255,g[2]=St>>>16&255,g[3]=St>>>24&255,g[4]=Bt>>>0&255,g[5]=Bt>>>8&255,g[6]=Bt>>>16&255,g[7]=Bt>>>24&255,g[8]=xt>>>0&255,g[9]=xt>>>8&255,g[10]=xt>>>16&255,g[11]=xt>>>24&255,g[12]=Et>>>0&255,g[13]=Et>>>8&255,g[14]=Et>>>16&255,g[15]=Et>>>24&255,g[16]=_t>>>0&255,g[17]=_t>>>8&255,g[18]=_t>>>16&255,g[19]=_t>>>24&255,g[20]=mt>>>0&255,g[21]=mt>>>8&255,g[22]=mt>>>16&255,g[23]=mt>>>24&255,g[24]=j>>>0&255,g[25]=j>>>8&255,g[26]=j>>>16&255,g[27]=j>>>24&255,g[28]=G>>>0&255,g[29]=G>>>8&255,g[30]=G>>>16&255,g[31]=G>>>24&255,g[32]=ot>>>0&255,g[33]=ot>>>8&255,g[34]=ot>>>16&255,g[35]=ot>>>24&255,g[36]=rt>>>0&255,g[37]=rt>>>8&255,g[38]=rt>>>16&255,g[39]=rt>>>24&255,g[40]=it>>>0&255,g[41]=it>>>8&255,g[42]=it>>>16&255,g[43]=it>>>24&255,g[44]=ut>>>0&255,g[45]=ut>>>8&255,g[46]=ut>>>16&255,g[47]=ut>>>24&255,g[48]=Ut>>>0&255,g[49]=Ut>>>8&255,g[50]=Ut>>>16&255,g[51]=Ut>>>24&255,g[52]=Zt>>>0&255,g[53]=Zt>>>8&255,g[54]=Zt>>>16&255,g[55]=Zt>>>24&255,g[56]=Xt>>>0&255,g[57]=Xt>>>8&255,g[58]=Xt>>>16&255,g[59]=Xt>>>24&255,g[60]=Jt>>>0&255,g[61]=Jt>>>8&255,g[62]=Jt>>>16&255,g[63]=Jt>>>24&255}function V(g,b,v,c){for(var S=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,W=v[0]&255|(v[1]&255)<<8|(v[2]&255)<<16|(v[3]&255)<<24,z=v[4]&255|(v[5]&255)<<8|(v[6]&255)<<16|(v[7]&255)<<24,X=v[8]&255|(v[9]&255)<<8|(v[10]&255)<<16|(v[11]&255)<<24,lt=v[12]&255|(v[13]&255)<<8|(v[14]&255)<<16|(v[15]&255)<<24,pt=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,ht=b[0]&255|(b[1]&255)<<8|(b[2]&255)<<16|(b[3]&255)<<24,ae=b[4]&255|(b[5]&255)<<8|(b[6]&255)<<16|(b[7]&255)<<24,vt=b[8]&255|(b[9]&255)<<8|(b[10]&255)<<16|(b[11]&255)<<24,Ft=b[12]&255|(b[13]&255)<<8|(b[14]&255)<<16|(b[15]&255)<<24,Kt=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,Vt=v[16]&255|(v[17]&255)<<8|(v[18]&255)<<16|(v[19]&255)<<24,qt=v[20]&255|(v[21]&255)<<8|(v[22]&255)<<16|(v[23]&255)<<24,Wt=v[24]&255|(v[25]&255)<<8|(v[26]&255)<<16|(v[27]&255)<<24,$t=v[28]&255|(v[29]&255)<<8|(v[30]&255)<<16|(v[31]&255)<<24,Dt=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,St=S,Bt=W,xt=z,Et=X,_t=lt,mt=pt,j=ht,G=ae,ot=vt,rt=Ft,it=Kt,ut=Vt,Ut=qt,Zt=Wt,Xt=$t,Jt=Dt,P,ie=0;ie<20;ie+=2)P=St+Ut|0,_t^=P<<7|P>>>25,P=_t+St|0,ot^=P<<9|P>>>23,P=ot+_t|0,Ut^=P<<13|P>>>19,P=Ut+ot|0,St^=P<<18|P>>>14,P=mt+Bt|0,rt^=P<<7|P>>>25,P=rt+mt|0,Zt^=P<<9|P>>>23,P=Zt+rt|0,Bt^=P<<13|P>>>19,P=Bt+Zt|0,mt^=P<<18|P>>>14,P=it+j|0,Xt^=P<<7|P>>>25,P=Xt+it|0,xt^=P<<9|P>>>23,P=xt+Xt|0,j^=P<<13|P>>>19,P=j+xt|0,it^=P<<18|P>>>14,P=Jt+ut|0,Et^=P<<7|P>>>25,P=Et+Jt|0,G^=P<<9|P>>>23,P=G+Et|0,ut^=P<<13|P>>>19,P=ut+G|0,Jt^=P<<18|P>>>14,P=St+Et|0,Bt^=P<<7|P>>>25,P=Bt+St|0,xt^=P<<9|P>>>23,P=xt+Bt|0,Et^=P<<13|P>>>19,P=Et+xt|0,St^=P<<18|P>>>14,P=mt+_t|0,j^=P<<7|P>>>25,P=j+mt|0,G^=P<<9|P>>>23,P=G+j|0,_t^=P<<13|P>>>19,P=_t+G|0,mt^=P<<18|P>>>14,P=it+rt|0,ut^=P<<7|P>>>25,P=ut+it|0,ot^=P<<9|P>>>23,P=ot+ut|0,rt^=P<<13|P>>>19,P=rt+ot|0,it^=P<<18|P>>>14,P=Jt+Xt|0,Ut^=P<<7|P>>>25,P=Ut+Jt|0,Zt^=P<<9|P>>>23,P=Zt+Ut|0,Xt^=P<<13|P>>>19,P=Xt+Zt|0,Jt^=P<<18|P>>>14;g[0]=St>>>0&255,g[1]=St>>>8&255,g[2]=St>>>16&255,g[3]=St>>>24&255,g[4]=mt>>>0&255,g[5]=mt>>>8&255,g[6]=mt>>>16&255,g[7]=mt>>>24&255,g[8]=it>>>0&255,g[9]=it>>>8&255,g[10]=it>>>16&255,g[11]=it>>>24&255,g[12]=Jt>>>0&255,g[13]=Jt>>>8&255,g[14]=Jt>>>16&255,g[15]=Jt>>>24&255,g[16]=j>>>0&255,g[17]=j>>>8&255,g[18]=j>>>16&255,g[19]=j>>>24&255,g[20]=G>>>0&255,g[21]=G>>>8&255,g[22]=G>>>16&255,g[23]=G>>>24&255,g[24]=ot>>>0&255,g[25]=ot>>>8&255,g[26]=ot>>>16&255,g[27]=ot>>>24&255,g[28]=rt>>>0&255,g[29]=rt>>>8&255,g[30]=rt>>>16&255,g[31]=rt>>>24&255}function st(g,b,v,c){Q(g,b,v,c)}function J(g,b,v,c){V(g,b,v,c)}var D=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function tt(g,b,v,c,S,W,z){var X=new Uint8Array(16),lt=new Uint8Array(64),pt,ht;for(ht=0;ht<16;ht++)X[ht]=0;for(ht=0;ht<8;ht++)X[ht]=W[ht];for(;S>=64;){for(st(lt,X,z,D),ht=0;ht<64;ht++)g[b+ht]=v[c+ht]^lt[ht];for(pt=1,ht=8;ht<16;ht++)pt=pt+(X[ht]&255)|0,X[ht]=pt&255,pt>>>=8;S-=64,b+=64,c+=64}if(S>0)for(st(lt,X,z,D),ht=0;ht<S;ht++)g[b+ht]=v[c+ht]^lt[ht];return 0}function nt(g,b,v,c,S){var W=new Uint8Array(16),z=new Uint8Array(64),X,lt;for(lt=0;lt<16;lt++)W[lt]=0;for(lt=0;lt<8;lt++)W[lt]=c[lt];for(;v>=64;){for(st(z,W,S,D),lt=0;lt<64;lt++)g[b+lt]=z[lt];for(X=1,lt=8;lt<16;lt++)X=X+(W[lt]&255)|0,W[lt]=X&255,X>>>=8;v-=64,b+=64}if(v>0)for(st(z,W,S,D),lt=0;lt<v;lt++)g[b+lt]=z[lt];return 0}function ue(g,b,v,c,S){var W=new Uint8Array(32);J(W,c,S,D);for(var z=new Uint8Array(8),X=0;X<8;X++)z[X]=c[X+16];return nt(g,b,v,z,W)}function jt(g,b,v,c,S,W,z){var X=new Uint8Array(32);J(X,W,z,D);for(var lt=new Uint8Array(8),pt=0;pt<8;pt++)lt[pt]=W[pt+16];return tt(g,b,v,c,S,lt,X)}var kt=function(g){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 b,v,c,S,W,z,X,lt;b=g[0]&255|(g[1]&255)<<8,this.r[0]=b&8191,v=g[2]&255|(g[3]&255)<<8,this.r[1]=(b>>>13|v<<3)&8191,c=g[4]&255|(g[5]&255)<<8,this.r[2]=(v>>>10|c<<6)&7939,S=g[6]&255|(g[7]&255)<<8,this.r[3]=(c>>>7|S<<9)&8191,W=g[8]&255|(g[9]&255)<<8,this.r[4]=(S>>>4|W<<12)&255,this.r[5]=W>>>1&8190,z=g[10]&255|(g[11]&255)<<8,this.r[6]=(W>>>14|z<<2)&8191,X=g[12]&255|(g[13]&255)<<8,this.r[7]=(z>>>11|X<<5)&8065,lt=g[14]&255|(g[15]&255)<<8,this.r[8]=(X>>>8|lt<<8)&8191,this.r[9]=lt>>>5&127,this.pad[0]=g[16]&255|(g[17]&255)<<8,this.pad[1]=g[18]&255|(g[19]&255)<<8,this.pad[2]=g[20]&255|(g[21]&255)<<8,this.pad[3]=g[22]&255|(g[23]&255)<<8,this.pad[4]=g[24]&255|(g[25]&255)<<8,this.pad[5]=g[26]&255|(g[27]&255)<<8,this.pad[6]=g[28]&255|(g[29]&255)<<8,this.pad[7]=g[30]&255|(g[31]&255)<<8};kt.prototype.blocks=function(g,b,v){for(var c=this.fin?0:2048,S,W,z,X,lt,pt,ht,ae,vt,Ft,Kt,Vt,qt,Wt,$t,Dt,St,Bt,xt,Et=this.h[0],_t=this.h[1],mt=this.h[2],j=this.h[3],G=this.h[4],ot=this.h[5],rt=this.h[6],it=this.h[7],ut=this.h[8],Ut=this.h[9],Zt=this.r[0],Xt=this.r[1],Jt=this.r[2],P=this.r[3],ie=this.r[4],me=this.r[5],we=this.r[6],ne=this.r[7],de=this.r[8],pe=this.r[9];v>=16;)S=g[b+0]&255|(g[b+1]&255)<<8,Et+=S&8191,W=g[b+2]&255|(g[b+3]&255)<<8,_t+=(S>>>13|W<<3)&8191,z=g[b+4]&255|(g[b+5]&255)<<8,mt+=(W>>>10|z<<6)&8191,X=g[b+6]&255|(g[b+7]&255)<<8,j+=(z>>>7|X<<9)&8191,lt=g[b+8]&255|(g[b+9]&255)<<8,G+=(X>>>4|lt<<12)&8191,ot+=lt>>>1&8191,pt=g[b+10]&255|(g[b+11]&255)<<8,rt+=(lt>>>14|pt<<2)&8191,ht=g[b+12]&255|(g[b+13]&255)<<8,it+=(pt>>>11|ht<<5)&8191,ae=g[b+14]&255|(g[b+15]&255)<<8,ut+=(ht>>>8|ae<<8)&8191,Ut+=ae>>>5|c,vt=0,Ft=vt,Ft+=Et*Zt,Ft+=_t*(5*pe),Ft+=mt*(5*de),Ft+=j*(5*ne),Ft+=G*(5*we),vt=Ft>>>13,Ft&=8191,Ft+=ot*(5*me),Ft+=rt*(5*ie),Ft+=it*(5*P),Ft+=ut*(5*Jt),Ft+=Ut*(5*Xt),vt+=Ft>>>13,Ft&=8191,Kt=vt,Kt+=Et*Xt,Kt+=_t*Zt,Kt+=mt*(5*pe),Kt+=j*(5*de),Kt+=G*(5*ne),vt=Kt>>>13,Kt&=8191,Kt+=ot*(5*we),Kt+=rt*(5*me),Kt+=it*(5*ie),Kt+=ut*(5*P),Kt+=Ut*(5*Jt),vt+=Kt>>>13,Kt&=8191,Vt=vt,Vt+=Et*Jt,Vt+=_t*Xt,Vt+=mt*Zt,Vt+=j*(5*pe),Vt+=G*(5*de),vt=Vt>>>13,Vt&=8191,Vt+=ot*(5*ne),Vt+=rt*(5*we),Vt+=it*(5*me),Vt+=ut*(5*ie),Vt+=Ut*(5*P),vt+=Vt>>>13,Vt&=8191,qt=vt,qt+=Et*P,qt+=_t*Jt,qt+=mt*Xt,qt+=j*Zt,qt+=G*(5*pe),vt=qt>>>13,qt&=8191,qt+=ot*(5*de),qt+=rt*(5*ne),qt+=it*(5*we),qt+=ut*(5*me),qt+=Ut*(5*ie),vt+=qt>>>13,qt&=8191,Wt=vt,Wt+=Et*ie,Wt+=_t*P,Wt+=mt*Jt,Wt+=j*Xt,Wt+=G*Zt,vt=Wt>>>13,Wt&=8191,Wt+=ot*(5*pe),Wt+=rt*(5*de),Wt+=it*(5*ne),Wt+=ut*(5*we),Wt+=Ut*(5*me),vt+=Wt>>>13,Wt&=8191,$t=vt,$t+=Et*me,$t+=_t*ie,$t+=mt*P,$t+=j*Jt,$t+=G*Xt,vt=$t>>>13,$t&=8191,$t+=ot*Zt,$t+=rt*(5*pe),$t+=it*(5*de),$t+=ut*(5*ne),$t+=Ut*(5*we),vt+=$t>>>13,$t&=8191,Dt=vt,Dt+=Et*we,Dt+=_t*me,Dt+=mt*ie,Dt+=j*P,Dt+=G*Jt,vt=Dt>>>13,Dt&=8191,Dt+=ot*Xt,Dt+=rt*Zt,Dt+=it*(5*pe),Dt+=ut*(5*de),Dt+=Ut*(5*ne),vt+=Dt>>>13,Dt&=8191,St=vt,St+=Et*ne,St+=_t*we,St+=mt*me,St+=j*ie,St+=G*P,vt=St>>>13,St&=8191,St+=ot*Jt,St+=rt*Xt,St+=it*Zt,St+=ut*(5*pe),St+=Ut*(5*de),vt+=St>>>13,St&=8191,Bt=vt,Bt+=Et*de,Bt+=_t*ne,Bt+=mt*we,Bt+=j*me,Bt+=G*ie,vt=Bt>>>13,Bt&=8191,Bt+=ot*P,Bt+=rt*Jt,Bt+=it*Xt,Bt+=ut*Zt,Bt+=Ut*(5*pe),vt+=Bt>>>13,Bt&=8191,xt=vt,xt+=Et*pe,xt+=_t*de,xt+=mt*ne,xt+=j*we,xt+=G*me,vt=xt>>>13,xt&=8191,xt+=ot*ie,xt+=rt*P,xt+=it*Jt,xt+=ut*Xt,xt+=Ut*Zt,vt+=xt>>>13,xt&=8191,vt=(vt<<2)+vt|0,vt=vt+Ft|0,Ft=vt&8191,vt=vt>>>13,Kt+=vt,Et=Ft,_t=Kt,mt=Vt,j=qt,G=Wt,ot=$t,rt=Dt,it=St,ut=Bt,Ut=xt,b+=16,v-=16;this.h[0]=Et,this.h[1]=_t,this.h[2]=mt,this.h[3]=j,this.h[4]=G,this.h[5]=ot,this.h[6]=rt,this.h[7]=it,this.h[8]=ut,this.h[9]=Ut},kt.prototype.finish=function(g,b){var v=new Uint16Array(10),c,S,W,z;if(this.leftover){for(z=this.leftover,this.buffer[z++]=1;z<16;z++)this.buffer[z]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(c=this.h[1]>>>13,this.h[1]&=8191,z=2;z<10;z++)this.h[z]+=c,c=this.h[z]>>>13,this.h[z]&=8191;for(this.h[0]+=c*5,c=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=c,c=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=c,v[0]=this.h[0]+5,c=v[0]>>>13,v[0]&=8191,z=1;z<10;z++)v[z]=this.h[z]+c,c=v[z]>>>13,v[z]&=8191;for(v[9]-=8192,S=(c^1)-1,z=0;z<10;z++)v[z]&=S;for(S=~S,z=0;z<10;z++)this.h[z]=this.h[z]&S|v[z];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,W=this.h[0]+this.pad[0],this.h[0]=W&65535,z=1;z<8;z++)W=(this.h[z]+this.pad[z]|0)+(W>>>16)|0,this.h[z]=W&65535;g[b+0]=this.h[0]>>>0&255,g[b+1]=this.h[0]>>>8&255,g[b+2]=this.h[1]>>>0&255,g[b+3]=this.h[1]>>>8&255,g[b+4]=this.h[2]>>>0&255,g[b+5]=this.h[2]>>>8&255,g[b+6]=this.h[3]>>>0&255,g[b+7]=this.h[3]>>>8&255,g[b+8]=this.h[4]>>>0&255,g[b+9]=this.h[4]>>>8&255,g[b+10]=this.h[5]>>>0&255,g[b+11]=this.h[5]>>>8&255,g[b+12]=this.h[6]>>>0&255,g[b+13]=this.h[6]>>>8&255,g[b+14]=this.h[7]>>>0&255,g[b+15]=this.h[7]>>>8&255},kt.prototype.update=function(g,b,v){var c,S;if(this.leftover){for(S=16-this.leftover,S>v&&(S=v),c=0;c<S;c++)this.buffer[this.leftover+c]=g[b+c];if(v-=S,b+=S,this.leftover+=S,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(v>=16&&(S=v-v%16,this.blocks(g,b,S),b+=S,v-=S),v){for(c=0;c<v;c++)this.buffer[this.leftover+c]=g[b+c];this.leftover+=v}};function ce(g,b,v,c,S,W){var z=new kt(W);return z.update(v,c,S),z.finish(g,b),0}function T(g,b,v,c,S,W){var z=new Uint8Array(16);return ce(z,0,v,c,S,W),O(g,b,z,0)}function u(g,b,v,c,S){var W;if(v<32)return-1;for(jt(g,0,b,0,v,c,S),ce(g,16,g,32,v-32,g),W=0;W<16;W++)g[W]=0;return 0}function p(g,b,v,c,S){var W,z=new Uint8Array(32);if(v<32||(ue(z,0,32,c,S),T(b,16,b,32,v-32,z)!==0))return-1;for(jt(g,0,b,0,v,c,S),W=0;W<32;W++)g[W]=0;return 0}function m(g,b){var v;for(v=0;v<16;v++)g[v]=b[v]|0}function R(g){var b,v,c=1;for(b=0;b<16;b++)v=g[b]+c+65535,c=Math.floor(v/65536),g[b]=v-c*65536;g[0]+=c-1+37*(c-1)}function _(g,b,v){for(var c,S=~(v-1),W=0;W<16;W++)c=S&(g[W]^b[W]),g[W]^=c,b[W]^=c}function I(g,b){var v,c,S,W=e(),z=e();for(v=0;v<16;v++)z[v]=b[v];for(R(z),R(z),R(z),c=0;c<2;c++){for(W[0]=z[0]-65517,v=1;v<15;v++)W[v]=z[v]-65535-(W[v-1]>>16&1),W[v-1]&=65535;W[15]=z[15]-32767-(W[14]>>16&1),S=W[15]>>16&1,W[14]&=65535,_(z,W,1-S)}for(v=0;v<16;v++)g[2*v]=z[v]&255,g[2*v+1]=z[v]>>8}function U(g,b){var v=new Uint8Array(32),c=new Uint8Array(32);return I(v,g),I(c,b),K(v,0,c,0)}function k(g){var b=new Uint8Array(32);return I(b,g),b[0]&1}function h(g,b){var v;for(v=0;v<16;v++)g[v]=b[2*v]+(b[2*v+1]<<8);g[15]&=32767}function A(g,b,v){for(var c=0;c<16;c++)g[c]=b[c]+v[c]}function Z(g,b,v){for(var c=0;c<16;c++)g[c]=b[c]-v[c]}function et(g,b,v){var c,S,W=0,z=0,X=0,lt=0,pt=0,ht=0,ae=0,vt=0,Ft=0,Kt=0,Vt=0,qt=0,Wt=0,$t=0,Dt=0,St=0,Bt=0,xt=0,Et=0,_t=0,mt=0,j=0,G=0,ot=0,rt=0,it=0,ut=0,Ut=0,Zt=0,Xt=0,Jt=0,P=v[0],ie=v[1],me=v[2],we=v[3],ne=v[4],de=v[5],pe=v[6],er=v[7],Pe=v[8],Xe=v[9],Qe=v[10],tr=v[11],sr=v[12],br=v[13],xr=v[14],vr=v[15];c=b[0],W+=c*P,z+=c*ie,X+=c*me,lt+=c*we,pt+=c*ne,ht+=c*de,ae+=c*pe,vt+=c*er,Ft+=c*Pe,Kt+=c*Xe,Vt+=c*Qe,qt+=c*tr,Wt+=c*sr,$t+=c*br,Dt+=c*xr,St+=c*vr,c=b[1],z+=c*P,X+=c*ie,lt+=c*me,pt+=c*we,ht+=c*ne,ae+=c*de,vt+=c*pe,Ft+=c*er,Kt+=c*Pe,Vt+=c*Xe,qt+=c*Qe,Wt+=c*tr,$t+=c*sr,Dt+=c*br,St+=c*xr,Bt+=c*vr,c=b[2],X+=c*P,lt+=c*ie,pt+=c*me,ht+=c*we,ae+=c*ne,vt+=c*de,Ft+=c*pe,Kt+=c*er,Vt+=c*Pe,qt+=c*Xe,Wt+=c*Qe,$t+=c*tr,Dt+=c*sr,St+=c*br,Bt+=c*xr,xt+=c*vr,c=b[3],lt+=c*P,pt+=c*ie,ht+=c*me,ae+=c*we,vt+=c*ne,Ft+=c*de,Kt+=c*pe,Vt+=c*er,qt+=c*Pe,Wt+=c*Xe,$t+=c*Qe,Dt+=c*tr,St+=c*sr,Bt+=c*br,xt+=c*xr,Et+=c*vr,c=b[4],pt+=c*P,ht+=c*ie,ae+=c*me,vt+=c*we,Ft+=c*ne,Kt+=c*de,Vt+=c*pe,qt+=c*er,Wt+=c*Pe,$t+=c*Xe,Dt+=c*Qe,St+=c*tr,Bt+=c*sr,xt+=c*br,Et+=c*xr,_t+=c*vr,c=b[5],ht+=c*P,ae+=c*ie,vt+=c*me,Ft+=c*we,Kt+=c*ne,Vt+=c*de,qt+=c*pe,Wt+=c*er,$t+=c*Pe,Dt+=c*Xe,St+=c*Qe,Bt+=c*tr,xt+=c*sr,Et+=c*br,_t+=c*xr,mt+=c*vr,c=b[6],ae+=c*P,vt+=c*ie,Ft+=c*me,Kt+=c*we,Vt+=c*ne,qt+=c*de,Wt+=c*pe,$t+=c*er,Dt+=c*Pe,St+=c*Xe,Bt+=c*Qe,xt+=c*tr,Et+=c*sr,_t+=c*br,mt+=c*xr,j+=c*vr,c=b[7],vt+=c*P,Ft+=c*ie,Kt+=c*me,Vt+=c*we,qt+=c*ne,Wt+=c*de,$t+=c*pe,Dt+=c*er,St+=c*Pe,Bt+=c*Xe,xt+=c*Qe,Et+=c*tr,_t+=c*sr,mt+=c*br,j+=c*xr,G+=c*vr,c=b[8],Ft+=c*P,Kt+=c*ie,Vt+=c*me,qt+=c*we,Wt+=c*ne,$t+=c*de,Dt+=c*pe,St+=c*er,Bt+=c*Pe,xt+=c*Xe,Et+=c*Qe,_t+=c*tr,mt+=c*sr,j+=c*br,G+=c*xr,ot+=c*vr,c=b[9],Kt+=c*P,Vt+=c*ie,qt+=c*me,Wt+=c*we,$t+=c*ne,Dt+=c*de,St+=c*pe,Bt+=c*er,xt+=c*Pe,Et+=c*Xe,_t+=c*Qe,mt+=c*tr,j+=c*sr,G+=c*br,ot+=c*xr,rt+=c*vr,c=b[10],Vt+=c*P,qt+=c*ie,Wt+=c*me,$t+=c*we,Dt+=c*ne,St+=c*de,Bt+=c*pe,xt+=c*er,Et+=c*Pe,_t+=c*Xe,mt+=c*Qe,j+=c*tr,G+=c*sr,ot+=c*br,rt+=c*xr,it+=c*vr,c=b[11],qt+=c*P,Wt+=c*ie,$t+=c*me,Dt+=c*we,St+=c*ne,Bt+=c*de,xt+=c*pe,Et+=c*er,_t+=c*Pe,mt+=c*Xe,j+=c*Qe,G+=c*tr,ot+=c*sr,rt+=c*br,it+=c*xr,ut+=c*vr,c=b[12],Wt+=c*P,$t+=c*ie,Dt+=c*me,St+=c*we,Bt+=c*ne,xt+=c*de,Et+=c*pe,_t+=c*er,mt+=c*Pe,j+=c*Xe,G+=c*Qe,ot+=c*tr,rt+=c*sr,it+=c*br,ut+=c*xr,Ut+=c*vr,c=b[13],$t+=c*P,Dt+=c*ie,St+=c*me,Bt+=c*we,xt+=c*ne,Et+=c*de,_t+=c*pe,mt+=c*er,j+=c*Pe,G+=c*Xe,ot+=c*Qe,rt+=c*tr,it+=c*sr,ut+=c*br,Ut+=c*xr,Zt+=c*vr,c=b[14],Dt+=c*P,St+=c*ie,Bt+=c*me,xt+=c*we,Et+=c*ne,_t+=c*de,mt+=c*pe,j+=c*er,G+=c*Pe,ot+=c*Xe,rt+=c*Qe,it+=c*tr,ut+=c*sr,Ut+=c*br,Zt+=c*xr,Xt+=c*vr,c=b[15],St+=c*P,Bt+=c*ie,xt+=c*me,Et+=c*we,_t+=c*ne,mt+=c*de,j+=c*pe,G+=c*er,ot+=c*Pe,rt+=c*Xe,it+=c*Qe,ut+=c*tr,Ut+=c*sr,Zt+=c*br,Xt+=c*xr,Jt+=c*vr,W+=38*Bt,z+=38*xt,X+=38*Et,lt+=38*_t,pt+=38*mt,ht+=38*j,ae+=38*G,vt+=38*ot,Ft+=38*rt,Kt+=38*it,Vt+=38*ut,qt+=38*Ut,Wt+=38*Zt,$t+=38*Xt,Dt+=38*Jt,S=1,c=W+S+65535,S=Math.floor(c/65536),W=c-S*65536,c=z+S+65535,S=Math.floor(c/65536),z=c-S*65536,c=X+S+65535,S=Math.floor(c/65536),X=c-S*65536,c=lt+S+65535,S=Math.floor(c/65536),lt=c-S*65536,c=pt+S+65535,S=Math.floor(c/65536),pt=c-S*65536,c=ht+S+65535,S=Math.floor(c/65536),ht=c-S*65536,c=ae+S+65535,S=Math.floor(c/65536),ae=c-S*65536,c=vt+S+65535,S=Math.floor(c/65536),vt=c-S*65536,c=Ft+S+65535,S=Math.floor(c/65536),Ft=c-S*65536,c=Kt+S+65535,S=Math.floor(c/65536),Kt=c-S*65536,c=Vt+S+65535,S=Math.floor(c/65536),Vt=c-S*65536,c=qt+S+65535,S=Math.floor(c/65536),qt=c-S*65536,c=Wt+S+65535,S=Math.floor(c/65536),Wt=c-S*65536,c=$t+S+65535,S=Math.floor(c/65536),$t=c-S*65536,c=Dt+S+65535,S=Math.floor(c/65536),Dt=c-S*65536,c=St+S+65535,S=Math.floor(c/65536),St=c-S*65536,W+=S-1+37*(S-1),S=1,c=W+S+65535,S=Math.floor(c/65536),W=c-S*65536,c=z+S+65535,S=Math.floor(c/65536),z=c-S*65536,c=X+S+65535,S=Math.floor(c/65536),X=c-S*65536,c=lt+S+65535,S=Math.floor(c/65536),lt=c-S*65536,c=pt+S+65535,S=Math.floor(c/65536),pt=c-S*65536,c=ht+S+65535,S=Math.floor(c/65536),ht=c-S*65536,c=ae+S+65535,S=Math.floor(c/65536),ae=c-S*65536,c=vt+S+65535,S=Math.floor(c/65536),vt=c-S*65536,c=Ft+S+65535,S=Math.floor(c/65536),Ft=c-S*65536,c=Kt+S+65535,S=Math.floor(c/65536),Kt=c-S*65536,c=Vt+S+65535,S=Math.floor(c/65536),Vt=c-S*65536,c=qt+S+65535,S=Math.floor(c/65536),qt=c-S*65536,c=Wt+S+65535,S=Math.floor(c/65536),Wt=c-S*65536,c=$t+S+65535,S=Math.floor(c/65536),$t=c-S*65536,c=Dt+S+65535,S=Math.floor(c/65536),Dt=c-S*65536,c=St+S+65535,S=Math.floor(c/65536),St=c-S*65536,W+=S-1+37*(S-1),g[0]=W,g[1]=z,g[2]=X,g[3]=lt,g[4]=pt,g[5]=ht,g[6]=ae,g[7]=vt,g[8]=Ft,g[9]=Kt,g[10]=Vt,g[11]=qt,g[12]=Wt,g[13]=$t,g[14]=Dt,g[15]=St}function ct(g,b){et(g,b,b)}function Mt(g,b){var v=e(),c;for(c=0;c<16;c++)v[c]=b[c];for(c=253;c>=0;c--)ct(v,v),c!==2&&c!==4&&et(v,v,b);for(c=0;c<16;c++)g[c]=v[c]}function Tt(g,b){var v=e(),c;for(c=0;c<16;c++)v[c]=b[c];for(c=250;c>=0;c--)ct(v,v),c!==1&&et(v,v,b);for(c=0;c<16;c++)g[c]=v[c]}function Pt(g,b,v){var c=new Uint8Array(32),S=new Float64Array(80),W,z,X=e(),lt=e(),pt=e(),ht=e(),ae=e(),vt=e();for(z=0;z<31;z++)c[z]=b[z];for(c[31]=b[31]&127|64,c[0]&=248,h(S,v),z=0;z<16;z++)lt[z]=S[z],ht[z]=X[z]=pt[z]=0;for(X[0]=ht[0]=1,z=254;z>=0;--z)W=c[z>>>3]>>>(z&7)&1,_(X,lt,W),_(pt,ht,W),A(ae,X,pt),Z(X,X,pt),A(pt,lt,ht),Z(lt,lt,ht),ct(ht,ae),ct(vt,X),et(X,pt,X),et(pt,lt,ae),A(ae,X,pt),Z(X,X,pt),ct(lt,X),Z(pt,ht,vt),et(X,pt,l),A(X,X,ht),et(pt,pt,X),et(X,ht,vt),et(ht,lt,S),ct(lt,ae),_(X,lt,W),_(pt,ht,W);for(z=0;z<16;z++)S[z+16]=X[z],S[z+32]=pt[z],S[z+48]=lt[z],S[z+64]=ht[z];var Ft=S.subarray(32),Kt=S.subarray(16);return Mt(Ft,Ft),et(Kt,Kt,Ft),I(g,Kt),0}function Ce(g,b){return Pt(g,b,i)}function Yt(g,b){return r(b,32),Ce(g,b)}function Gt(g,b,v){var c=new Uint8Array(32);return Pt(c,v,b),J(g,s,c,D)}var le=u,re=p;function ve(g,b,v,c,S,W){var z=new Uint8Array(32);return Gt(z,S,W),le(g,b,v,c,z)}function Or(g,b,v,c,S,W){var z=new Uint8Array(32);return Gt(z,S,W),re(g,b,v,c,z)}var _e=[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 Oe(g,b,v,c){for(var S=new Int32Array(16),W=new Int32Array(16),z,X,lt,pt,ht,ae,vt,Ft,Kt,Vt,qt,Wt,$t,Dt,St,Bt,xt,Et,_t,mt,j,G,ot,rt,it,ut,Ut=g[0],Zt=g[1],Xt=g[2],Jt=g[3],P=g[4],ie=g[5],me=g[6],we=g[7],ne=b[0],de=b[1],pe=b[2],er=b[3],Pe=b[4],Xe=b[5],Qe=b[6],tr=b[7],sr=0;c>=128;){for(_t=0;_t<16;_t++)mt=8*_t+sr,S[_t]=v[mt+0]<<24|v[mt+1]<<16|v[mt+2]<<8|v[mt+3],W[_t]=v[mt+4]<<24|v[mt+5]<<16|v[mt+6]<<8|v[mt+7];for(_t=0;_t<80;_t++)if(z=Ut,X=Zt,lt=Xt,pt=Jt,ht=P,ae=ie,vt=me,Ft=we,Kt=ne,Vt=de,qt=pe,Wt=er,$t=Pe,Dt=Xe,St=Qe,Bt=tr,j=we,G=tr,ot=G&65535,rt=G>>>16,it=j&65535,ut=j>>>16,j=(P>>>14|Pe<<18)^(P>>>18|Pe<<14)^(Pe>>>9|P<<23),G=(Pe>>>14|P<<18)^(Pe>>>18|P<<14)^(P>>>9|Pe<<23),ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,j=P&ie^~P&me,G=Pe&Xe^~Pe&Qe,ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,j=_e[_t*2],G=_e[_t*2+1],ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,j=S[_t%16],G=W[_t%16],ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,rt+=ot>>>16,it+=rt>>>16,ut+=it>>>16,xt=it&65535|ut<<16,Et=ot&65535|rt<<16,j=xt,G=Et,ot=G&65535,rt=G>>>16,it=j&65535,ut=j>>>16,j=(Ut>>>28|ne<<4)^(ne>>>2|Ut<<30)^(ne>>>7|Ut<<25),G=(ne>>>28|Ut<<4)^(Ut>>>2|ne<<30)^(Ut>>>7|ne<<25),ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,j=Ut&Zt^Ut&Xt^Zt&Xt,G=ne&de^ne&pe^de&pe,ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,rt+=ot>>>16,it+=rt>>>16,ut+=it>>>16,Ft=it&65535|ut<<16,Bt=ot&65535|rt<<16,j=pt,G=Wt,ot=G&65535,rt=G>>>16,it=j&65535,ut=j>>>16,j=xt,G=Et,ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,rt+=ot>>>16,it+=rt>>>16,ut+=it>>>16,pt=it&65535|ut<<16,Wt=ot&65535|rt<<16,Zt=z,Xt=X,Jt=lt,P=pt,ie=ht,me=ae,we=vt,Ut=Ft,de=Kt,pe=Vt,er=qt,Pe=Wt,Xe=$t,Qe=Dt,tr=St,ne=Bt,_t%16===15)for(mt=0;mt<16;mt++)j=S[mt],G=W[mt],ot=G&65535,rt=G>>>16,it=j&65535,ut=j>>>16,j=S[(mt+9)%16],G=W[(mt+9)%16],ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,xt=S[(mt+1)%16],Et=W[(mt+1)%16],j=(xt>>>1|Et<<31)^(xt>>>8|Et<<24)^xt>>>7,G=(Et>>>1|xt<<31)^(Et>>>8|xt<<24)^(Et>>>7|xt<<25),ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,xt=S[(mt+14)%16],Et=W[(mt+14)%16],j=(xt>>>19|Et<<13)^(Et>>>29|xt<<3)^xt>>>6,G=(Et>>>19|xt<<13)^(xt>>>29|Et<<3)^(Et>>>6|xt<<26),ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,rt+=ot>>>16,it+=rt>>>16,ut+=it>>>16,S[mt]=it&65535|ut<<16,W[mt]=ot&65535|rt<<16;j=Ut,G=ne,ot=G&65535,rt=G>>>16,it=j&65535,ut=j>>>16,j=g[0],G=b[0],ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,rt+=ot>>>16,it+=rt>>>16,ut+=it>>>16,g[0]=Ut=it&65535|ut<<16,b[0]=ne=ot&65535|rt<<16,j=Zt,G=de,ot=G&65535,rt=G>>>16,it=j&65535,ut=j>>>16,j=g[1],G=b[1],ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,rt+=ot>>>16,it+=rt>>>16,ut+=it>>>16,g[1]=Zt=it&65535|ut<<16,b[1]=de=ot&65535|rt<<16,j=Xt,G=pe,ot=G&65535,rt=G>>>16,it=j&65535,ut=j>>>16,j=g[2],G=b[2],ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,rt+=ot>>>16,it+=rt>>>16,ut+=it>>>16,g[2]=Xt=it&65535|ut<<16,b[2]=pe=ot&65535|rt<<16,j=Jt,G=er,ot=G&65535,rt=G>>>16,it=j&65535,ut=j>>>16,j=g[3],G=b[3],ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,rt+=ot>>>16,it+=rt>>>16,ut+=it>>>16,g[3]=Jt=it&65535|ut<<16,b[3]=er=ot&65535|rt<<16,j=P,G=Pe,ot=G&65535,rt=G>>>16,it=j&65535,ut=j>>>16,j=g[4],G=b[4],ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,rt+=ot>>>16,it+=rt>>>16,ut+=it>>>16,g[4]=P=it&65535|ut<<16,b[4]=Pe=ot&65535|rt<<16,j=ie,G=Xe,ot=G&65535,rt=G>>>16,it=j&65535,ut=j>>>16,j=g[5],G=b[5],ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,rt+=ot>>>16,it+=rt>>>16,ut+=it>>>16,g[5]=ie=it&65535|ut<<16,b[5]=Xe=ot&65535|rt<<16,j=me,G=Qe,ot=G&65535,rt=G>>>16,it=j&65535,ut=j>>>16,j=g[6],G=b[6],ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,rt+=ot>>>16,it+=rt>>>16,ut+=it>>>16,g[6]=me=it&65535|ut<<16,b[6]=Qe=ot&65535|rt<<16,j=we,G=tr,ot=G&65535,rt=G>>>16,it=j&65535,ut=j>>>16,j=g[7],G=b[7],ot+=G&65535,rt+=G>>>16,it+=j&65535,ut+=j>>>16,rt+=ot>>>16,it+=rt>>>16,ut+=it>>>16,g[7]=we=it&65535|ut<<16,b[7]=tr=ot&65535|rt<<16,sr+=128,c-=128}return c}function Ar(g,b,v){var c=new Int32Array(8),S=new Int32Array(8),W=new Uint8Array(256),z,X=v;for(c[0]=1779033703,c[1]=3144134277,c[2]=1013904242,c[3]=2773480762,c[4]=1359893119,c[5]=2600822924,c[6]=528734635,c[7]=1541459225,S[0]=4089235720,S[1]=2227873595,S[2]=4271175723,S[3]=1595750129,S[4]=2917565137,S[5]=725511199,S[6]=4215389547,S[7]=327033209,Oe(c,S,b,v),v%=128,z=0;z<v;z++)W[z]=b[X-v+z];for(W[v]=128,v=256-128*(v<112?1:0),W[v-9]=0,N(W,v-8,X/536870912|0,X<<3),Oe(c,S,W,v),z=0;z<8;z++)N(g,8*z,c[z],S[z]);return 0}function Ie(g,b){var v=e(),c=e(),S=e(),W=e(),z=e(),X=e(),lt=e(),pt=e(),ht=e();Z(v,g[1],g[0]),Z(ht,b[1],b[0]),et(v,v,ht),A(c,g[0],g[1]),A(ht,b[0],b[1]),et(c,c,ht),et(S,g[3],b[3]),et(S,S,x),et(W,g[2],b[2]),A(W,W,W),Z(z,c,v),Z(X,W,S),A(lt,W,S),A(pt,c,v),et(g[0],z,X),et(g[1],pt,lt),et(g[2],lt,X),et(g[3],z,pt)}function Ae(g,b,v){var c;for(c=0;c<4;c++)_(g[c],b[c],v)}function rr(g,b){var v=e(),c=e(),S=e();Mt(S,b[2]),et(v,b[0],S),et(c,b[1],S),I(g,c),g[31]^=k(v)<<7}function ke(g,b,v){var c,S;for(m(g[0],o),m(g[1],a),m(g[2],a),m(g[3],o),S=255;S>=0;--S)c=v[S/8|0]>>(S&7)&1,Ae(g,b,c),Ie(b,g),Ie(g,g),Ae(g,b,c)}function Se(g,b){var v=[e(),e(),e(),e()];m(v[0],E),m(v[1],L),m(v[2],a),et(v[3],E,L),ke(g,v,b)}function fr(g,b,v){var c=new Uint8Array(64),S=[e(),e(),e(),e()],W;for(v||r(b,32),Ar(c,b,32),c[0]&=248,c[31]&=127,c[31]|=64,Se(S,c),rr(g,S),W=0;W<32;W++)b[W+32]=g[W];return 0}var Be=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 w(g,b){var v,c,S,W;for(c=63;c>=32;--c){for(v=0,S=c-32,W=c-12;S<W;++S)b[S]+=v-16*b[c]*Be[S-(c-32)],v=Math.floor((b[S]+128)/256),b[S]-=v*256;b[S]+=v,b[c]=0}for(v=0,S=0;S<32;S++)b[S]+=v-(b[31]>>4)*Be[S],v=b[S]>>8,b[S]&=255;for(S=0;S<32;S++)b[S]-=v*Be[S];for(c=0;c<32;c++)b[c+1]+=b[c]>>8,g[c]=b[c]&255}function f(g){var b=new Float64Array(64),v;for(v=0;v<64;v++)b[v]=g[v];for(v=0;v<64;v++)g[v]=0;w(g,b)}function d(g,b,v,c){var S=new Uint8Array(64),W=new Uint8Array(64),z=new Uint8Array(64),X,lt,pt=new Float64Array(64),ht=[e(),e(),e(),e()];Ar(S,c,32),S[0]&=248,S[31]&=127,S[31]|=64;var ae=v+64;for(X=0;X<v;X++)g[64+X]=b[X];for(X=0;X<32;X++)g[32+X]=S[32+X];for(Ar(z,g.subarray(32),v+32),f(z),Se(ht,z),rr(g,ht),X=32;X<64;X++)g[X]=c[X];for(Ar(W,g,v+64),f(W),X=0;X<64;X++)pt[X]=0;for(X=0;X<32;X++)pt[X]=z[X];for(X=0;X<32;X++)for(lt=0;lt<32;lt++)pt[X+lt]+=W[X]*S[lt];return w(g.subarray(32),pt),ae}function B(g,b){var v=e(),c=e(),S=e(),W=e(),z=e(),X=e(),lt=e();return m(g[2],a),h(g[1],b),ct(S,g[1]),et(W,S,y),Z(S,S,g[2]),A(W,g[2],W),ct(z,W),ct(X,z),et(lt,X,z),et(v,lt,S),et(v,v,W),Tt(v,v),et(v,v,S),et(v,v,W),et(v,v,W),et(g[0],v,W),ct(c,g[0]),et(c,c,W),U(c,S)&&et(g[0],g[0],C),ct(c,g[0]),et(c,c,W),U(c,S)?-1:(k(g[0])===b[31]>>7&&Z(g[0],o,g[0]),et(g[3],g[0],g[1]),0)}function F(g,b,v,c){var S,W=new Uint8Array(32),z=new Uint8Array(64),X=[e(),e(),e(),e()],lt=[e(),e(),e(),e()];if(v<64||B(lt,c))return-1;for(S=0;S<v;S++)g[S]=b[S];for(S=0;S<32;S++)g[S+32]=c[S];if(Ar(z,g,v),f(z),ke(X,lt,z),Se(lt,b.subarray(32)),Ie(X,lt),rr(W,X),v-=64,K(b,0,W,0)){for(S=0;S<v;S++)g[S]=0;return-1}for(S=0;S<v;S++)g[S]=b[S+64];return v}var $=32,Y=24,Ht=32,zt=16,Nt=32,Re=32,Lt=32,ze=32,ri=32,je=Y,Ze=Ht,as=zt,Te=64,Le=32,cn=64,De=32,$e=64;t.lowlevel={crypto_core_hsalsa20:J,crypto_stream_xor:jt,crypto_stream:ue,crypto_stream_salsa20_xor:tt,crypto_stream_salsa20:nt,crypto_onetimeauth:ce,crypto_onetimeauth_verify:T,crypto_verify_16:O,crypto_verify_32:K,crypto_secretbox:u,crypto_secretbox_open:p,crypto_scalarmult:Pt,crypto_scalarmult_base:Ce,crypto_box_beforenm:Gt,crypto_box_afternm:le,crypto_box:ve,crypto_box_open:Or,crypto_box_keypair:Yt,crypto_hash:Ar,crypto_sign:d,crypto_sign_keypair:fr,crypto_sign_open:F,crypto_secretbox_KEYBYTES:$,crypto_secretbox_NONCEBYTES:Y,crypto_secretbox_ZEROBYTES:Ht,crypto_secretbox_BOXZEROBYTES:zt,crypto_scalarmult_BYTES:Nt,crypto_scalarmult_SCALARBYTES:Re,crypto_box_PUBLICKEYBYTES:Lt,crypto_box_SECRETKEYBYTES:ze,crypto_box_BEFORENMBYTES:ri,crypto_box_NONCEBYTES:je,crypto_box_ZEROBYTES:Ze,crypto_box_BOXZEROBYTES:as,crypto_sign_BYTES:Te,crypto_sign_PUBLICKEYBYTES:Le,crypto_sign_SECRETKEYBYTES:cn,crypto_sign_SEEDBYTES:De,crypto_hash_BYTES:$e,gf:e,D:y,L:Be,pack25519:I,unpack25519:h,M:et,A,S:ct,Z,pow2523:Tt,add:Ie,set25519:m,modL:w,scalarmult:ke,scalarbase:Se};function vi(g,b){if(g.length!==$)throw new Error("bad key size");if(b.length!==Y)throw new Error("bad nonce size")}function Je(g,b){if(g.length!==Lt)throw new Error("bad public key size");if(b.length!==ze)throw new Error("bad secret key size")}function he(){for(var g=0;g<arguments.length;g++)if(!(arguments[g]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function ki(g){for(var b=0;b<g.length;b++)g[b]=0}t.randomBytes=function(g){var b=new Uint8Array(g);return r(b,g),b},t.secretbox=function(g,b,v){he(g,b,v),vi(v,b);for(var c=new Uint8Array(Ht+g.length),S=new Uint8Array(c.length),W=0;W<g.length;W++)c[W+Ht]=g[W];return u(S,c,c.length,b,v),S.subarray(zt)},t.secretbox.open=function(g,b,v){he(g,b,v),vi(v,b);for(var c=new Uint8Array(zt+g.length),S=new Uint8Array(c.length),W=0;W<g.length;W++)c[W+zt]=g[W];return c.length<32||p(S,c,c.length,b,v)!==0?null:S.subarray(Ht)},t.secretbox.keyLength=$,t.secretbox.nonceLength=Y,t.secretbox.overheadLength=zt,t.scalarMult=function(g,b){if(he(g,b),g.length!==Re)throw new Error("bad n size");if(b.length!==Nt)throw new Error("bad p size");var v=new Uint8Array(Nt);return Pt(v,g,b),v},t.scalarMult.base=function(g){if(he(g),g.length!==Re)throw new Error("bad n size");var b=new Uint8Array(Nt);return Ce(b,g),b},t.scalarMult.scalarLength=Re,t.scalarMult.groupElementLength=Nt,t.box=function(g,b,v,c){var S=t.box.before(v,c);return t.secretbox(g,b,S)},t.box.before=function(g,b){he(g,b),Je(g,b);var v=new Uint8Array(ri);return Gt(v,g,b),v},t.box.after=t.secretbox,t.box.open=function(g,b,v,c){var S=t.box.before(v,c);return t.secretbox.open(g,b,S)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var g=new Uint8Array(Lt),b=new Uint8Array(ze);return Yt(g,b),{publicKey:g,secretKey:b}},t.box.keyPair.fromSecretKey=function(g){if(he(g),g.length!==ze)throw new Error("bad secret key size");var b=new Uint8Array(Lt);return Ce(b,g),{publicKey:b,secretKey:new Uint8Array(g)}},t.box.publicKeyLength=Lt,t.box.secretKeyLength=ze,t.box.sharedKeyLength=ri,t.box.nonceLength=je,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(g,b){if(he(g,b),b.length!==cn)throw new Error("bad secret key size");var v=new Uint8Array(Te+g.length);return d(v,g,g.length,b),v},t.sign.open=function(g,b){if(he(g,b),b.length!==Le)throw new Error("bad public key size");var v=new Uint8Array(g.length),c=F(v,g,g.length,b);if(c<0)return null;for(var S=new Uint8Array(c),W=0;W<S.length;W++)S[W]=v[W];return S},t.sign.detached=function(g,b){for(var v=t.sign(g,b),c=new Uint8Array(Te),S=0;S<c.length;S++)c[S]=v[S];return c},t.sign.detached.verify=function(g,b,v){if(he(g,b,v),b.length!==Te)throw new Error("bad signature size");if(v.length!==Le)throw new Error("bad public key size");var c=new Uint8Array(Te+g.length),S=new Uint8Array(Te+g.length),W;for(W=0;W<Te;W++)c[W]=b[W];for(W=0;W<g.length;W++)c[W+Te]=g[W];return F(S,c,c.length,v)>=0},t.sign.keyPair=function(){var g=new Uint8Array(Le),b=new Uint8Array(cn);return fr(g,b),{publicKey:g,secretKey:b}},t.sign.keyPair.fromSecretKey=function(g){if(he(g),g.length!==cn)throw new Error("bad secret key size");for(var b=new Uint8Array(Le),v=0;v<b.length;v++)b[v]=g[32+v];return{publicKey:b,secretKey:new Uint8Array(g)}},t.sign.keyPair.fromSeed=function(g){if(he(g),g.length!==De)throw new Error("bad seed size");for(var b=new Uint8Array(Le),v=new Uint8Array(cn),c=0;c<32;c++)v[c]=g[c];return fr(b,v,!0),{publicKey:b,secretKey:v}},t.sign.publicKeyLength=Le,t.sign.secretKeyLength=cn,t.sign.seedLength=De,t.sign.signatureLength=Te,t.hash=function(g){he(g);var b=new Uint8Array($e);return Ar(b,g,g.length),b},t.hash.hashLength=$e,t.verify=function(g,b){return he(g,b),g.length===0||b.length===0||g.length!==b.length?!1:M(g,0,b,0,g.length)===0},t.setPRNG=function(g){r=g},function(){var g=typeof self<"u"?self.crypto||self.msCrypto:null;if(g&&g.getRandomValues){var b=65536;t.setPRNG(function(v,c){var S,W=new Uint8Array(c);for(S=0;S<c;S+=b)g.getRandomValues(W.subarray(S,S+Math.min(c-S,b)));for(S=0;S<c;S++)v[S]=W[S];ki(W)})}else typeof rd<"u"&&(g=ra,g&&g.randomBytes&&t.setPRNG(function(v,c){var S,W=g.randomBytes(c);for(S=0;S<c;S++)v[S]=W[S];ki(W)}))}()})(n.exports?n.exports:self.nacl=self.nacl||{})})(qc);var nd=qc.exports;class en{constructor(t){nr(this,"env");nr(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 r;return((r=e.nSureSettings)==null?void 0:r.nSurePartnerId)||e.nSurePartnerId}).catch(e=>{console.error(e)})}async getCreditBalance(t,e,r){const s=await fetch(this.url+`/api/customer/balances/${e}`,{method:"GET",headers:{"x-coinflow-auth-wallet":t,"x-coinflow-auth-blockchain":r}}),{credits:i}=await s.json();return i}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,sessionKey:e,route:r,routePrefix:s,env:i,amount:o,transaction:a,blockchain:l="solana",webhookInfo:y,email:x,loaderBackground:E,handleHeightChange:L,bankAccountLinkRedirect:C,additionalWallets:N,nearDeposit:M,chargebackProtectionData:O,merchantCss:K,color:Q,rent:V,lockDefaultToken:st,token:J,tokens:D,planCode:tt,disableApplePay:nt,disableGooglePay:ue,customerInfo:jt,settlementType:kt,lockAmount:ce,nativeSolToConvert:T,theme:u,usePermit:p,transactionSigner:m,authOnly:R,deviceId:_,jwtToken:I,origins:U,threeDsChallengePreference:k,supportEmail:h}){var et;const A=s?`/${s}/${l}`:`/${l}`,Z=new URL(A+r,en.getCoinflowBaseUrl(i));if(t&&Z.searchParams.append("pubkey",t),e&&Z.searchParams.append("sessionKey",e),a&&Z.searchParams.append("transaction",a),o&&Z.searchParams.append("amount",o.toString()),y&&Z.searchParams.append("webhookInfo",$r.compressToEncodedURIComponent(JSON.stringify(y))),u&&Z.searchParams.append("theme",$r.compressToEncodedURIComponent(JSON.stringify(u))),jt&&Z.searchParams.append("customerInfo",$r.compressToEncodedURIComponent(JSON.stringify(jt))),x&&Z.searchParams.append("email",x),h&&Z.searchParams.append("supportEmail",h),J&&Z.searchParams.append("token",J.toString()),D&&Z.searchParams.append("tokens",D.toString()),E&&Z.searchParams.append("loaderBackground",E),L&&Z.searchParams.append("useHeightChange","true"),C&&Z.searchParams.append("bankAccountLinkRedirect",C),N&&Z.searchParams.append("additionalWallets",$r.compressToEncodedURIComponent(JSON.stringify(N))),M&&Z.searchParams.append("nearDeposit",M),O&&Z.searchParams.append("chargebackProtectionData",$r.compressToEncodedURIComponent(JSON.stringify(O))),_)Z.searchParams.append("deviceId",_);else if(typeof window<"u"){const ct=(et=window==null?void 0:window.nSureSDK)==null?void 0:et.getDeviceId();ct&&Z.searchParams.append("deviceId",ct)}return K&&Z.searchParams.append("merchantCss",K),Q&&Z.searchParams.append("color",Q),V&&Z.searchParams.append("rent",V.lamports.toString()),T&&Z.searchParams.append("nativeSolToConvert",T.lamports.toString()),st&&Z.searchParams.append("lockDefaultToken","true"),tt&&Z.searchParams.append("planCode",tt),nt&&Z.searchParams.append("disableApplePay","true"),ue&&Z.searchParams.append("disableGooglePay","true"),kt&&Z.searchParams.append("settlementType",kt),ce&&Z.searchParams.append("lockAmount","true"),p===!1&&Z.searchParams.append("usePermit","false"),m&&Z.searchParams.append("transactionSigner",m),R===!0&&Z.searchParams.append("authOnly","true"),I&&Z.searchParams.append("jwtToken",I),U&&Z.searchParams.append("origins",$r.compressToEncodedURIComponent(JSON.stringify(U))),k&&Z.searchParams.append("threeDsChallengePreference",k),Z.toString()}static getTransaction(t){if(t.blockchain)return this.byBlockchain(t.blockchain,{solana:()=>{if(!("transaction"in t))return;const{transaction:e}=t;if(!rs)throw new Error("@solana/web3.js dependency is required for Solana");if(!Dr)throw new Error("bs58 dependency is required for Solana");if(e)return Dr.encode(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},eth:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},base:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},arbitrum:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},near:()=>{if(!("action"in t))return;const{action:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},user:()=>{}})()}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;case"user":return e.user;default:throw new Error("blockchain not supported!")}}static async getWalletFromUserId({userId:t,merchantId:e,env:r}){return this.getWalletFromEmail({email:t,merchantId:e,env:r})}static async getWalletFromEmail({email:t,merchantId:e,env:r}){const s=new TextEncoder().encode(t),o=await window.crypto.subtle.digest("SHA-256",s),a=new Uint8Array(o),l=Un.fromSeed(a);return{publicKey:l.publicKey,signMessage:y=>Promise.resolve(nd.sign.detached(y,l.secretKey)),signTransaction:async y=>y instanceof ye?(y.sign(l),y):(y.sign([l]),y),sendTransaction:async y=>{y instanceof ye?y.sign(l):y.sign([l]);const x=this.getCoinflowApiUrl(r),E={method:"POST",headers:{"content-type":"application/json","x-coinflow-auth-wallet":l.publicKey.toString(),"x-coinflow-auth-blockchain":"solana"},body:JSON.stringify({merchantId:e,signedTransaction:Dr==null?void 0:Dr.encode(y.serialize())})},{signature:L}=await fetch(x+"/api/utils/send-coinflow-tx",E).then(C=>C.json());return L}}}}var Hc=(n=>(n.SignMessage="signMessage",n.SignTransaction="signTransaction",n.SendTransaction="sendTransaction",n.HeightChange="heightChange",n.Success="success",n.Loaded="loaded",n))(Hc||{});function ns(n){let t;if("signer"in n&&typeof n.signer=="object"&&n.signer&&"wallet"in n.signer?t=n.signer.wallet:"wallet"in n&&n.wallet&&(t=n.wallet),!!t){if(typeof t=="string")return t;if(typeof t=="object"){if("publicKey"in t)return t.publicKey?t.publicKey.toString():void 0;if("address"in t)return t.address?t.address:void 0;if("accountId"in t)return t.accountId?t.accountId:void 0}return null}}function Vc(n,t){let e;try{if(e=JSON.parse(n),!("method"in e)||!("data"in e))return}catch(i){console.error("handleIFrameMessage JSON parse",i);return}const{data:r,method:s}=e;switch(s){case"signMessage":return t.handleSignMessage?t.handleSignMessage(r):void 0;case"signTransaction":return t.handleSignTransaction?t.handleSignTransaction(r):void 0;case"sendTransaction":return t.handleSendTransaction(r);case"heightChange":return t.handleHeightChange?t.handleHeightChange(r):void 0;case"success":if(!t.onSuccess)return;t.onSuccess(e.info);return;case"loaded":return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${s} is not one of ${Object.values(Hc)}`)}function is(n){let t,e;return"signer"in n&&typeof n.signer=="object"&&n.signer&&"blockchain"in n.signer&&"wallet"in n.signer?(t=n.signer.blockchain,e=n.signer.wallet):"blockchain"in n&&n.blockchain&&(t=n.blockchain,e=n.wallet),t?en.byBlockchain(t,{solana:()=>id({wallet:e,onSuccess:n.onSuccess}),near:()=>sd({wallet:e,onSuccess:n.onSuccess}),eth:()=>ss({wallet:e,onSuccess:n.onSuccess}),polygon:()=>ss({wallet:e,onSuccess:n.onSuccess}),base:()=>ss({wallet:e,onSuccess:n.onSuccess}),arbitrum:()=>ss({wallet:e,onSuccess:n.onSuccess}),user:()=>od(n)})():{handleSendTransaction:()=>{throw new Error("handleSendTransaction Not Implemented")},handleSignMessage:()=>{throw new Error("handleSendTransaction Not Implemented")},handleSignTransaction:()=>{throw new Error("handleSendTransaction Not Implemented")},onSuccess:n.onSuccess}}function id({wallet:n,onSuccess:t}){return{handleSendTransaction:async e=>{const r=jc(e);return await n.sendTransaction(r)},handleSignMessage:async e=>{const r=n.signMessage;if(!r)throw new Error("signMessage is not supported by this wallet");const s=await r(new TextEncoder().encode(e));if(!Dr)throw new Error("bs58 dependency is required");return Dr.encode(s)},handleSignTransaction:async e=>{const r=n.signTransaction;if(!r)throw new Error("signTransaction is not supported by this wallet");const s=jc(e),i=await r(s);if(!Dr)throw new Error("bs58 dependency is required");return Dr.encode(i.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:t}}function jc(n){if(!rs)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!Dr)throw new Error("bs58 is not defined. Please install bs58 into your project");const t=Dr.decode(n),e=rs.VersionedTransaction.deserialize(t);return e.version==="legacy"?rs.Transaction.from(t):e}function sd({wallet:n,onSuccess:t}){return{handleSendTransaction:async e=>{const r=JSON.parse(Buffer.from(e,"base64").toString()),s=await n.signAndSendTransaction(r);if(!s)throw new Error("Transaction did not send");const{transaction:i}=s;return i.hash},onSuccess:t}}function ss({wallet:n,onSuccess:t}){return{handleSendTransaction:async e=>{const r=JSON.parse(Buffer.from(e,"base64").toString()),{hash:s}=await n.sendTransaction(r);return s},handleSignMessage:async e=>n.signMessage(e),onSuccess:t}}function od({onSuccess:n}){return{handleSendTransaction:async()=>Promise.resolve(""),onSuccess:n}}const xi="tokenExCardNumber",ei="tokenExCardCvv",Gc={[On.VISA]:"visa",[On.MASTERCARD]:"masterCard",[On.AMEX]:"americanExpress",[On.DISCOVER]:"discover"};async function Yc({token:n,origins:t,env:e}){return new Promise((r,s)=>{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:n})}).then(async i=>{r(await i.json())}).catch(i=>s(i))})}function Eo({env:n,setTokenExScriptLoaded:t}){const e="tokenex-script";if(document.head.querySelector(`#${e}`))return;const r=document.createElement("script");r.src=n==="prod"?"https://htp.tokenex.com/iframe/iframe-v3.min.js":"https://test-htp.tokenex.com/iframe/iframe-v3.min.js",r.id=e,document.head.appendChild(r),document.getElementById(e).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),t(!0)})}function ad({iframe:n,setCachedToken:t,setLoaded:e}){const r=async()=>(n.tokenize(),await new Promise((s,i)=>{n.on("tokenize",o=>{t(o.token),s(o)}),n.on("validate",o=>{(!o.isValid||o.isCvvValid===!1)&&i(o)})}));return n.on("change",()=>t(void 0)),n.on("cvvChange",()=>t(void 0)),n.on("load",()=>{setTimeout(()=>e(!0),350);const s=document.querySelector("#tx_iframe_tokenExCardNumber");s&&(s.scrolling="no")}),n.on("focus",()=>{n.focus()}),n.on("cvvFocus",()=>{n.cvvFocus()}),e(!1),n.load(),{...n,tokenize:r}}async function Zc(n){const{token:t,cardType:e}=n;return await _o(ei,n,{cvvOnly:!0,cvv:!0,cvvContainerID:ei,placeholder:"CVV",token:t,cardType:Gc[e]})}async function Jc(n){return await _o(xi,n,{cvv:!0,cvvContainerID:ei,cvvPlaceholder:"CVV"})}async function Xc(n){return await _o(xi,n,{cvv:!1})}async function _o(n,{tokenExScriptLoaded:t,origins:e,env:r,css:s,debug:i,font:o,setCachedToken:a,setLoaded:l},y){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 x=await Yc({token:y.token,origins:e,env:r}),{styles:E}=cd(s),L={...x,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,styles:E,font:o,debug:i??!1,...y},C=TokenEx.Iframe(n,L);return ad({iframe:C,setCachedToken:a,setLoaded:l})}function cd(n){var r,s,i;const t=JSON.parse(n);return{styles:{base:mn(t.base),focus:mn(t.focus),error:mn(t.error),placeholder:mn(t.placeholder),cvv:{base:mn((r=t.cvv)==null?void 0:r.base),focus:mn((s=t.cvv)==null?void 0:s.focus),error:mn((i=t.cvv)==null?void 0:i.error),placeholder:mn(t==null?void 0:t.placeholder)}}}}function mn(n){if(!n)return"";if(typeof n=="string")return n;let t="";for(const[e,r]of Object.entries(n)){let s="";e.split("").forEach(i=>{i.toUpperCase()===i?s+="-"+i.toLowerCase():s+=i}),t+=s+":"+r+";"}return t}const ud=ft.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return en.getCoinflowUrl(this.args)}},emits:{onMessage(n){return!0}},methods:{sendMessage(n){const t=this.$refs.iframeRef;if(!(t!=null&&t.contentWindow))throw new Error("Iframe not defined");t.contentWindow.postMessage(n,"*")},handleIframeMessages({data:n,origin:t}){if(!t.includes(en.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:n,origin:t});const e=Vc(n,this.args);e&&e.then(this.sendMessage).catch(r=>{console.error(r),this.sendMessage("ERROR "+r.message)})},async listenForMessage(n){let t;return new Promise((e,r)=>{if(t=({data:s,origin:i})=>{if(i.includes(en.getCoinflowBaseUrl(this.args.env))){if(s.startsWith("ERROR")){r(new Error(s.replace("ERROR","")));return}n(s)&&e(s)}},!window)throw new Error("Window not defined");window.addEventListener("message",t)}).finally(()=>{window.removeEventListener("message",t)})},async sendAndReceiveMessage(n,t){return this.sendMessage(n),this.listenForMessage(t)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),Io=(n,t)=>{const e=n.__vccOpts||n;for(const[r,s]of t)e[r]=s;return e},fd=["src","scrolling"];function ld(n,t,e,r,s,i){return ft.openBlock(),ft.createElementBlock("iframe",{style:{height:"100%",width:"100%"},ref:"iframeRef",allow:"payment;camera",title:"withdraw",frameBorder:"0",src:n.url,scrolling:n.args.handleHeightChange?"no":"yes",onLoad:t[0]||(t[0]=()=>{const o=n.$refs.iframeRef;o&&(o.style.opacity="1")})},null,40,fd)}const os=Io(ud,[["render",ld]]),hd=ft.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:os},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const n=ns(this.args);return{...this.args,walletPubkey:n,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...is(this.args),handleHeightChange:this.args.handleHeightChange}}}});function dd(n,t,e,r,s,i){const o=ft.resolveComponent("coinflow-i-frame");return ft.openBlock(),ft.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers}},null,8,["args"])}const pd=Io(hd,[["render",dd]]),gd=ft.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:os},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const n=ns(this.args);return{...this.args,walletPubkey:n,route:`/purchase-v2/${this.args.merchantId}`,transaction:en.getTransaction(this.args)}},messageHandlers(){return{...is(this.args),handleHeightChange:this.args.handleHeightChange}}}});function yd(n,t,e,r,s,i){const o=ft.resolveComponent("coinflow-i-frame");return ft.openBlock(),ft.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers}},null,8,["args"])}const md=Io(gd,[["render",yd]]),Ao=n=>{const t=ft.ref(!1),e=ft.ref(!1),r=ft.ref(void 0),s=ft.ref(void 0);ft.onMounted(()=>{Eo({env:n,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),e.value=!0}})});const i=E=>s.value=E,o=()=>t.value=!0,a=E=>r.value=E,l=async E=>{const L=await Zc({...E,tokenExScriptLoaded:e.value,env:n,setCachedToken:i,setLoaded:o});return a(L),L},y=async E=>{const L=await Jc({...E,tokenExScriptLoaded:e.value,env:n,setCachedToken:i,setLoaded:o});return a(L),L},x=async E=>{const L=await Xc({...E,tokenExScriptLoaded:e.value,env:n,setCachedToken:i,setLoaded:o});return a(L),L};return ft.watchEffect(E=>{r.value&&(r.value.load(),E(()=>{var L;return(L=r.value)==null?void 0:L.remove()}))}),{tokenExIframe:r,initializeTokenExIframe:y,initializeCvvOnlyTokenExIframe:l,initializeTokenExCardOnlyIframe:x,loaded:t,cachedToken:s,setTokenExScriptTag:Eo,tokenExScriptLoaded:e}},wd=["id"],bd=ft.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{initializeTokenExIframe:e,tokenExIframe:r}=Ao(n.args.env);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}t({getToken:s});function i(){return JSON.stringify(n.args.css)}return ft.watchEffect(()=>{e({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(ft.openBlock(),ft.createElementBlock("div",{id:ft.unref(xi)},null,8,wd))}}),xd=["id"],vd=ft.defineComponent({__name:"CoinflowCvvInput",setup(n){return(t,e)=>(ft.openBlock(),ft.createElementBlock("div",{id:ft.unref(ei)},null,8,xd))}}),kd=["id"],Sd=ft.defineComponent({__name:"CoinflowCvvOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{initializeCvvOnlyTokenExIframe:e,tokenExIframe:r}=Ao(n.args.env);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}t({getToken:s});function i(){return JSON.stringify(n.args.css)}return ft.watchEffect(()=>{e({...n.args,origins:n.args.origins??[],css:i(),font:n.args.font})},{}),(o,a)=>(ft.openBlock(),ft.createElementBlock("div",{id:ft.unref(ei)},null,8,kd))}}),Ed=ft.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(n){const t=ft.ref(void 0);ft.onMounted(()=>new en(n.args.env).getNSurePartnerId(n.args.merchantId).then(s=>t.value=s));function e(){return n.args.env==="prod"?"9JBW2RHC7JNJN8ZQ":"SANDBOX_CTCE4XK53ZW0R7V1"}function r(){return n.args.env==="prod"?"https://sdk.nsureapi.com/sdk.js":"https://sdk.nsureapi.com/sdk-sandbox.js"}return ft.watchEffect(s=>{if(!t.value)return;const i=document.createElement("script");i.src=r(),document.head.appendChild(i);const o=`window.nSureAsyncInit = function(deviceId) {
14
14
  window.nSureSDK.init({
15
15
  appId: '${e()}',
16
16
  partnerId: '${t.value}',
17
17
  });
18
- };`,a=document.createElement("script");a.innerHTML=o,document.head.appendChild(a),s(()=>{document.head.removeChild(i),document.head.removeChild(a)})}),(s,i)=>null}}),Ed=["id"],_d=ft.defineComponent({__name:"CoinflowCardNumberOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{tokenExIframe:e,initializeTokenExCardOnlyIframe:r}=Ao(n.args.env);async function s(){if(!e.value)throw new Error("Unable to get token");return e.value.tokenize()}t({getToken:s});function i(){return JSON.stringify(n.args.css)}return ft.watchEffect(()=>{r({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(ft.openBlock(),ft.createElementBlock("div",{id:ft.unref(vi)},null,8,Ed))}}),Id={style:{position:"relative",height:"100%"}},Ad={style:{position:"relative",zIndex:10,height:"100%"}},Xc=ft.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(n){const{onSuccess:t}=n.args;function e(){const a=is(n.args);return{...n.args,walletPubkey:a,transaction:void 0,routePrefix:"form",route:`/${n.route}/${n.args.merchantId}`}}function r(){return{...ss(n.args),handleHeightChange:n.args.handleHeightChange}}const s=ft.ref(.8),i=ft.ref("flex");function o({data:a}){var l,y;try{const x=JSON.parse(a);if("method"in x&&x.method==="loaded"&&(s.value=1,setTimeout(()=>{i.value="none"},2e3)),"method"in x&&x.data.startsWith("ERROR"))return(y=(l=n.args)==null?void 0:l.onError)==null||y.call(l,x.info),!1;if(!("method"in x)||x.method!=="getToken")return}catch{return}t==null||t(a)}return(a,l)=>(ft.openBlock(),ft.createElementBlock("div",Id,[ft.createElementVNode("div",{style:ft.normalizeStyle({backgroundColor:n.args.color,display:n.overlayDisplayOverride??i.value,opacity:s.value,alignItems:n.alignItems,width:"100%",height:"40px",position:"absolute",top:0,bottom:0,left:0,zIndex:20,justifyContent:"center",pointerEvents:"none"})},[ft.renderSlot(a.$slots,"default")],4),ft.createElementVNode("div",Ad,[ft.createVNode(as,{onOnMessage:o,args:{...e(),...r()}},null,8,["args"])])]))}}),Bd={id:"svg-logo",viewBox:"0 0 35 15"},Rd={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"},Td={stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},Md=["fill"],Pd=ft.defineComponent({__name:"ApplePayOverlay",props:{color:{type:String,required:!0}},setup(n){const t=n.color==="white"?"#000":"#FFF";return(e,r)=>(ft.openBlock(),ft.createElementBlock("svg",Bd,[(ft.openBlock(),ft.createElementBlock("svg",Rd,[r[1]||(r[1]=ft.createElementVNode("title",null,"Apple Logo",-1)),ft.createElementVNode("g",Td,[ft.createElementVNode("g",{fill:ft.unref(t)},r[0]||(r[0]=[ft.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)]),8,Md)])]))]))}}),Cd=ft.defineComponent({__name:"CoinflowApplePayButton",props:{args:{type:Object,required:!0}},setup(n){return(t,e)=>(ft.openBlock(),ft.createBlock(Xc,{route:"apple-pay",args:n.args},{default:ft.withCtx(()=>[ft.createVNode(Pd,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}}),Ld={key:0,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Ud={key:1,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Od=ft.defineComponent({__name:"GooglePayOverlay",props:{color:{type:String,required:!0}},setup(n){return(t,e)=>(ft.openBlock(),ft.createElementBlock(ft.Fragment,null,[n.color==="white"?(ft.openBlock(),ft.createElementBlock("svg",Ld,e[0]||(e[0]=[ft.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)]))):ft.createCommentVNode("",!0),n.color==="black"?(ft.openBlock(),ft.createElementBlock("svg",Ud,e[1]||(e[1]=[ft.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)]))):ft.createCommentVNode("",!0)],64))}}),Nd=ft.defineComponent({__name:"CoinflowGooglePayButton",props:{args:{type:Object,required:!0}},setup(n){return(t,e)=>(ft.openBlock(),ft.createBlock(Xc,{route:"google-pay",args:n.args,overlayDisplayOverride:"flex",alignItems:"center"},{default:ft.withCtx(()=>[ft.createVNode(Od,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}});se.CARD_TYPE_MAPPING=jc,se.CardType=On,se.CoinflowApplePayButton=Cd,se.CoinflowCardNumberInput=wd,se.CoinflowCardNumberOnlyInput=_d,se.CoinflowCvvInput=xd,se.CoinflowCvvOnlyInput=kd,se.CoinflowGooglePayButton=Nd,se.CoinflowIframe=as,se.CoinflowPurchase=yd,se.CoinflowPurchaseProtection=Sd,se.CoinflowUtils=en,se.CoinflowWithdraw=dd,se.MerchantStyle=Bo,se.SettlementType=wn,se.ThreeDsChallengePreference=Ro,se.TokenExCardNumberIframeId=vi,se.TokenExCvvContainerID=ei,se.doInitializeCvvOnlyTokenExIframe=Yc,se.doInitializeTokenExCardOnlyIframe=Jc,se.doInitializeTokenExIframe=Zc,se.getHandlers=ss,se.getIframeConfig=Gc,se.getWalletPubkey=is,se.handleIFrameMessage=Hc,se.setTokenExScriptTag=Eo,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})});
18
+ };`,a=document.createElement("script");a.innerHTML=o,document.head.appendChild(a),s(()=>{document.head.removeChild(i),document.head.removeChild(a)})}),(s,i)=>null}}),_d=["id"],Id=ft.defineComponent({__name:"CoinflowCardNumberOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{tokenExIframe:e,initializeTokenExCardOnlyIframe:r}=Ao(n.args.env);async function s(){if(!e.value)throw new Error("Unable to get token");return e.value.tokenize()}t({getToken:s});function i(){return JSON.stringify(n.args.css)}return ft.watchEffect(()=>{r({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(ft.openBlock(),ft.createElementBlock("div",{id:ft.unref(xi)},null,8,_d))}}),Ad={style:{position:"relative",height:"100%"}},Bd={style:{position:"relative",zIndex:10,height:"100%"}},Qc=ft.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(n){const{onSuccess:t}=n.args;function e(){const a=ns(n.args);return{...n.args,walletPubkey:a,transaction:void 0,routePrefix:"form",route:`/${n.route}/${n.args.merchantId}`}}function r(){return{...is(n.args),handleHeightChange:n.args.handleHeightChange}}const s=ft.ref(.8),i=ft.ref("flex");function o({data:a}){var l,y;try{const x=JSON.parse(a);if("method"in x&&x.method==="loaded"&&(s.value=1,setTimeout(()=>{i.value="none"},2e3)),"method"in x&&x.data.startsWith("ERROR"))return(y=(l=n.args)==null?void 0:l.onError)==null||y.call(l,x.info),!1;if(!("method"in x)||x.method!=="getToken")return}catch{return}t==null||t(a)}return(a,l)=>(ft.openBlock(),ft.createElementBlock("div",Ad,[ft.createElementVNode("div",{style:ft.normalizeStyle({backgroundColor:n.args.color,display:n.overlayDisplayOverride??i.value,opacity:s.value,alignItems:n.alignItems,width:"100%",height:"40px",position:"absolute",top:0,bottom:0,left:0,zIndex:20,justifyContent:"center",pointerEvents:"none"})},[ft.renderSlot(a.$slots,"default")],4),ft.createElementVNode("div",Bd,[ft.createVNode(os,{onOnMessage:o,args:{...e(),...r()}},null,8,["args"])])]))}}),Rd={id:"svg-logo",viewBox:"0 0 35 15"},Td={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"},Md={stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},Pd=["fill"],Cd=ft.defineComponent({__name:"ApplePayOverlay",props:{color:{type:String,required:!0}},setup(n){const t=n.color==="white"?"#000":"#FFF";return(e,r)=>(ft.openBlock(),ft.createElementBlock("svg",Rd,[(ft.openBlock(),ft.createElementBlock("svg",Td,[r[1]||(r[1]=ft.createElementVNode("title",null,"Apple Logo",-1)),ft.createElementVNode("g",Md,[ft.createElementVNode("g",{fill:ft.unref(t)},r[0]||(r[0]=[ft.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)]),8,Pd)])]))]))}}),Ld=ft.defineComponent({__name:"CoinflowApplePayButton",props:{args:{type:Object,required:!0}},setup(n){return(t,e)=>(ft.openBlock(),ft.createBlock(Qc,{route:"apple-pay",args:n.args},{default:ft.withCtx(()=>[ft.createVNode(Cd,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}}),Ud={key:0,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Od={key:1,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Nd=ft.defineComponent({__name:"GooglePayOverlay",props:{color:{type:String,required:!0}},setup(n){return(t,e)=>(ft.openBlock(),ft.createElementBlock(ft.Fragment,null,[n.color==="white"?(ft.openBlock(),ft.createElementBlock("svg",Ud,e[0]||(e[0]=[ft.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)]))):ft.createCommentVNode("",!0),n.color==="black"?(ft.openBlock(),ft.createElementBlock("svg",Od,e[1]||(e[1]=[ft.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)]))):ft.createCommentVNode("",!0)],64))}}),Fd=ft.defineComponent({__name:"CoinflowGooglePayButton",props:{args:{type:Object,required:!0}},setup(n){return(t,e)=>(ft.openBlock(),ft.createBlock(Qc,{route:"google-pay",args:n.args,overlayDisplayOverride:"flex",alignItems:"center"},{default:ft.withCtx(()=>[ft.createVNode(Nd,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}});se.CARD_TYPE_MAPPING=Gc,se.CardType=On,se.CoinflowApplePayButton=Ld,se.CoinflowCardNumberInput=bd,se.CoinflowCardNumberOnlyInput=Id,se.CoinflowCvvInput=vd,se.CoinflowCvvOnlyInput=Sd,se.CoinflowGooglePayButton=Fd,se.CoinflowIframe=os,se.CoinflowPurchase=md,se.CoinflowPurchaseProtection=Ed,se.CoinflowUtils=en,se.CoinflowWithdraw=pd,se.MerchantStyle=Bo,se.SettlementType=wn,se.ThreeDsChallengePreference=Ro,se.TokenExCardNumberIframeId=xi,se.TokenExCvvContainerID=ei,se.doInitializeCvvOnlyTokenExIframe=Zc,se.doInitializeTokenExCardOnlyIframe=Xc,se.doInitializeTokenExIframe=Jc,se.getHandlers=is,se.getIframeConfig=Yc,se.getWalletPubkey=ns,se.handleIFrameMessage=Vc,se.setTokenExScriptTag=Eo,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})});